{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./src/unblu-api-error.ts","webpack:///./src/internal/module/module.ts","webpack:///./src/internal/util/event-emitter.ts","webpack:///./src/unblu-api.ts","webpack:///./src/conversation.ts","webpack:///./src/unblu-util.ts","webpack:///./src/index.ts","webpack:///./src/unblu-static-api.ts","webpack:///./src/unblu-api-ui.ts","webpack:///./src/internal/api-bridge.ts","webpack:///./src/internal/java-error-codes.ts","webpack:///./src/internal/internal-api.ts","webpack:///./src/internal/module/meta-module.ts","webpack:///./src/internal/module/general-module.ts","webpack:///./src/internal/module/general-lazy-module.ts","webpack:///./src/internal/module/conversation-module.ts","webpack:///./src/internal/module/agent-availability-module.ts","webpack:///./src/model/call-state.ts","webpack:///./src/model/connection-state.ts","webpack:///./src/model/conversation-type.ts","webpack:///./src/model/agent-availability-state.ts","webpack:///./src/model/conversation-state.ts"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","UnbluErrorType","UnbluApiError","_super","type","detail","_this","this","__extends","Error","InternalModule","bridge","moduleName","callApiFunction","functionName","args","on","eventName","listener","off","EventEmitter","listeners","reset","event","indexOf","push","index","splice","offAll","hasListeners","length","getEventsWithListeners","events","event_1","emit","data","forEach","e","console","warn","conversation_1","event_emitter_1","unblu_api_error_1","unblu_api_ui_1","UnbluApi","internalApi","internalListeners","eventEmitter","meta","onUpgraded","ui","UnbluUiApi","needsInternalSubscription","onInternal","catch","removed","offInternal","AGENT_AVAILABILITY_CHANGE","internalListener","internalModule","agentAvailability","needsUpgrade","ACTIVE_CONVERSATION_CHANGE","Conversation","general","NOTIFICATION_COUNT_CHANGE","PERSON_CHANGE","INVALID_FUNCTION_ARGUMENTS","_a","isUpgraded","_b","sent","e_1","getPersonInfo","requireUpgrade","setPersonNickname","nickname","getNotificationCount","generalLazy","startConversation","visitorName","visitorData","conversationId","setNewConversationInterceptor","callback","joinConversation","pin","openConversation","getActiveConversation","isAgentAvailable","getAgentAvailabilityState","upgrade","_i","destroyed","CLOSE","destroy","checkNotDestroyed","CONNECTION_STATE_CHANGE","connectionState","CONVERSATION_STATE_CHANGE","conversationState","CALL_STATE_CHANGE","callState","INVITATIONS_CHANGE","invitations","conversation","getConversationId","getConnectionState","getConversationState","getCallState","createAnonymousPinInvitation","createAnonymousEmailInvitation","email","revokeInvitation","invitationId","renewInvitationPin","getInvitations","startAudioCall","startVideoCall","endConversation","leaveConversation","closeConversation","ILLEGAL_STATE","isDestroyed","END","UnbluUtil","loadScript","uri","timeout","timeoutTime","script","document","createElement","setAttribute","toString","src","Promise","resolve","reject","timeoutId","cleanup","onerror","onload","window","clearTimeout","onError","error","setTimeout","getElementsByTagName","appendChild","setNamedArea","namedArea","metaTag","querySelector","parentElement","head","setLocale","locale","getUnbluObject","isUnbluLoaded","APIKEY","unblu","createUnbluObject","unblu_static_api_1","unblu_util_1","call_state_1","connection_state_1","conversation_type_1","agent_availability_state_1","conversation_state_1","unblu_api_1","AgentAvailabilityState","CallState","ConnectionState","ConversationState","ConversationType","api","UnbluStaticApi","api_bridge_1","internal_api_1","state","ERROR","handleError","initializeApi","READY","initializedApi","isConfigurationNeeded","getApiState","isInitialized","configure","config","configuration","initialize","CONFIGURATION_MISSING","injectUnblu","apiBridge","ApiBridge","waitUntilLoaded","initTimeout","InternalApi","checkCompatibility","waitUntilInitialized","serverUrl","apiKey","unbluPath","entryPath","unbluUrl","ERROR_LOADING_UNBLU","e_2","UI_STATE_CHANGE","toggleIndividualUi","openPinEntryUi","popoutIndividualUi","popinIndividualUi","maximizeIndividualUi","minimizeIndividualUi","openIndividualUi","collapseIndividualUi","getIndividualUiState","java_error_codes_1","mountPoint","promise","timeoutTimestamp","Date","now","waitForLoaded","checkLoaded","INITIALIZATION_TIMEOUT","internal","INCOMPATIBLE_UNBLU_VERSION","getApiVersion","version","execute","CATEGORY_INVALID_FUNCTION_CALL","INVALID_FUNCTION_CALL","message","CATEGORY_INVALID_FUNCTION_ARGUMENTS","CATEGORY_ACTION_NOT_GRANTED","ACTION_NOT_GRANTED","CATEGORY_EXECUTION_EXCEPTION","EXECUTION_EXCEPTION","registerEventListener","removeEventListener","meta_module_1","general_module_1","general_lazy_module_1","conversation_module_1","agent_availability_module_1","MetaModule","GeneralModule","GeneralLazyModule","ConversationModule","AgentAvailabilityModule","openUi"],"mappings":"aACA,IAAAA,EAAA,GAGA,SAAAC,EAAAC,GAGA,GAAAF,EAAAE,GACA,OAAAF,EAAAE,GAAAC,QAGA,IAAAC,EAAAJ,EAAAE,GAAA,CACAG,EAAAH,EACAI,GAAA,EACAH,QAAA,IAUA,OANAI,EAAAL,GAAAM,KAAAJ,EAAAD,QAAAC,IAAAD,QAAAF,GAGAG,EAAAE,GAAA,EAGAF,EAAAD,QAKAF,EAAAQ,EAAAF,EAGAN,EAAAS,EAAAV,EAGAC,EAAAU,EAAA,SAAAR,EAAAS,EAAAC,GACAZ,EAAAa,EAAAX,EAAAS,IACAG,OAAAC,eAAAb,EAAAS,EAAA,CAA0CK,YAAA,EAAAC,IAAAL,KAK1CZ,EAAAkB,EAAA,SAAAhB,GACA,oBAAAiB,eAAAC,aACAN,OAAAC,eAAAb,EAAAiB,OAAAC,YAAA,CAAwDC,MAAA,WAExDP,OAAAC,eAAAb,EAAA,cAAiDmB,OAAA,KAQjDrB,EAAAsB,EAAA,SAAAD,EAAAE,GAEA,GADA,EAAAA,IAAAF,EAAArB,EAAAqB,IACA,EAAAE,EAAA,OAAAF,EACA,KAAAE,GAAA,iBAAAF,QAAAG,WAAA,OAAAH,EACA,IAAAI,EAAAX,OAAAY,OAAA,MAGA,GAFA1B,EAAAkB,EAAAO,GACAX,OAAAC,eAAAU,EAAA,WAAyCT,YAAA,EAAAK,UACzC,EAAAE,GAAA,iBAAAF,EAAA,QAAAM,KAAAN,EAAArB,EAAAU,EAAAe,EAAAE,EAAA,SAAA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AAe,4BAAsD,KAEzF+O,EAZA,CAZA/R,EAAA,GAY6C6C,gBAAhC3C,EAAA6R,yGCZb,SAAYhF,GAIRA,EAAA,kBAIAA,EAAA,oBAIAA,EAAA,8BAIAA,EAAA,sCAIAA,EAAA,kDAIAA,EAAA,YAxBJ,CAAY7M,EAAA6M,YAAA7M,EAAA6M,UAAS,oFCArB,SAAYC,GAIRA,EAAA,kBAKAA,EAAA,wBAKAA,EAAA,sBAKAA,EAAA,4BAMAA,EAAA,gBAKAA,EAAA,cA9BJ,CAAY9M,EAAA8M,kBAAA9M,EAAA8M,gBAAe,oFCA3B,SAAYE,GAIRA,EAAA,4BAIAA,EAAA,4CAIAA,EAAA,8BAIAA,EAAA,8BAIAA,EAAA,oDAIAA,EAAA,gDAIAA,EAAA,sDAIAA,EAAA,gDAKHA,EAAA,wCArCD,CAAYhN,EAAAgN,mBAAAhN,EAAAgN,iBAAgB,oFCA5B,SAAYJ,GAIRA,EAAA,sBAMAA,EAAA,YAMAA,EAAA,0BAMAA,EAAA,kBAtBJ,CAAY5M,EAAA4M,yBAAA5M,EAAA4M,uBAAsB,oFCAlC,SAAYG,GAIRA,EAAA,kBAMAA,EAAA,wBAMAA,EAAA,wBAKAA,EAAA,gBAKAA,EAAA,gBAMAA,EAAA,wBAKAA,EAAA,0BAKAA,EAAA,cA1CJ,CAAY/M,EAAA+M,oBAAA/M,EAAA+M,kBAAiB","file":"visitor-api.min.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 6);\n","/**\n * Type of an unblu error. This can be used to check what kind of error occurred.\n */\nexport enum UnbluErrorType {\n /**\n * Thrown if the browser is not supported by unblu.\n */\n UNSUPPORTED_BROWSER = 'UNSUPPORTED_BROWSER',\n /**\n * Thrown if the initialization of the unblu API failed due to a timeout.\n */\n INITIALIZATION_TIMEOUT = 'INITIALIZATION_TIMEOUT',\n /**\n * Thrown if the initialization is called with no existing snippet and no configuration.\n */\n CONFIGURATION_MISSING = 'CONFIGURATION_MISSING',\n /**\n * Thrown during initialization if the snippet can't be loaded or unblu can't be initialized from the snippet.\n */\n ERROR_LOADING_UNBLU = 'ERROR_LOADING_UNBLU',\n /**\n * Thrown if the unblu JS API is not compatible with the unblu collaboration server.\n */\n INCOMPATIBLE_UNBLU_VERSION = 'INCOMPATIBLE_UNBLU_VERSION',\n /**\n * Thrown if a function call was invalid.\n * This is usually do to an incompatibility between the unblu JS API and the unblu collaboration server.\n */\n INVALID_FUNCTION_CALL = 'INVALID_FUNCTION_CALL',\n /**\n * Thrown if the arguments passed to a function where invalid.\n */\n INVALID_FUNCTION_ARGUMENTS = 'INVALID_FUNCTION_ARGUMENTS',\n /**\n * Thrown if a called action is not permitted for the local person.\n * The details message usually has more information about the required permissions.\n */\n ACTION_NOT_GRANTED = 'ACTION_NOT_GRANTED',\n /**\n * Thrown if an unexpected exception occurrs during a function execution.\n */\n EXECUTION_EXCEPTION = 'EXECUTION_EXCEPTION',\n /**\n * Thrown if a method is called in an invalid context. E.g. if the Object called upon was already destroyed.\n */\n ILLEGAL_STATE = 'ILLEGAL_STATE'\n}\n\n/**\n * General unblu JS API error class that will be thrown whenever something goes wrong.\n *\n * - Use the [[UnbluApiError.type]] to check what kind of error occurred.\n * - Use the [[UnbluApiError.detail]] for human readable details.\n *\n * Check the documentation of [[UnbluErrorType]] for more details on the different error types.\n *\n * Example:\n * ```ts\n * unblu.api.initialize().then(api => {\n * // use the api\n * }).catch(e => {\n * if(e.type === 'INITIALIZATION_TIMEOUT') {\n * //retry\n * } else if(e.type === 'UNSUPPORTED_BROWSER') {\n * // display unsupported browser dialog\n * } else {\n * // show generic error message\n * }\n * });\n * ```\n *\n * or using async / await:\n *\n * ```ts\n * try {\n * const api = await unblu.api.initialize();\n * // use the api\n * } catch(e) {\n * if(e.type === 'INITIALIZATION_TIMEOUT') {\n * //retry\n * } else if(e.type === 'UNSUPPORTED_BROWSER') {\n * // display unsupported browser dialog\n * } else {\n * // show generic error message\n * }\n * }\n * ```\n *\n *\n * The error types may either be checked via their constant string values or via the UnbluErrorType enum:\n *\n * ```ts\n * // using string constant\n * function isTimeout(e: UnbluApiError) {\n * return e.type === 'INITIALIZATION_TIMEOUT';\n * }\n * ```\n * ```ts\n * // using the enum\n * function isTimeout(e: UnbluApiError) {\n * return e.type === window.unblu.UnbluErrorType.INITIALIZATION_TIMEOUT;\n * }\n * ```\n *\n */\nexport class UnbluApiError extends Error {\n\n constructor(public type: UnbluErrorType, public detail: string) {\n super(`type: ${type}, detail: ${detail}`);\n this.name = 'UnbluApiError';\n }\n\n}","import {ApiBridge} from '../api-bridge';\nimport {EventCallback} from '../event';\n\nexport class InternalModule {\n constructor(private bridge: ApiBridge, public moduleName: string) {\n\n }\n\n protected callApiFunction(functionName: T, args: any[]): Promise {\n return this.bridge.callApiFunction(this.moduleName, functionName, args);\n }\n\n public on(eventName: E, listener: EventCallback): Promise {\n return this.bridge.on(this.moduleName, eventName, listener);\n }\n\n public off(eventName: E, listener: EventCallback): Promise {\n return this.bridge.off(this.moduleName, eventName, listener);\n }\n\n}","export type Listener = (data?: any) => void;\n\nexport class EventEmitter {\n private listeners: { [key: string]: EventListener[] } = {};\n\n /**\n * Resets the emitter by removing all registered listeners.\n */\n public reset(): void {\n this.listeners = {};\n }\n\n /**\n * Adds an event listeners\n * @param event the event to listen to\n * @param listener the listener to be called.\n */\n public on(event: string, listener: Listener) {\n this.listeners[event] = this.listeners[event] || [];\n if (this.listeners[event].indexOf(listener) === -1)\n this.listeners[event].push(listener);\n }\n\n /**\n * removes a previously registered listener\n * @param event the event\n * @param listener the listener that should be removed.\n * @return `true` if the listener was removed, `false` otherwise.\n */\n off(event: string, listener: any): boolean {\n const listeners = this.listeners[event] || [];\n const index = listeners.indexOf(listener);\n if (index > -1) {\n listeners.splice(index, 1);\n return true;\n }\n return false;\n }\n\n /**\n * removes all listeners for the given event.\n * @param event the event for which all listeners will be removed.\n */\n offAll(event: string) {\n delete this.listeners[event];\n }\n\n /**\n * Checks weather at least one listener exists for a given event.\n * @param event the event to check for\n * @return weather or not any listeners for the given event are registered.\n */\n hasListeners(event: string): boolean {\n return this.listeners[event] != null && this.listeners[event].length > 0;\n }\n\n /**\n * Returns all events that have at least one listeners registered to them.\n * @return An array containing all events that have at least one listener.\n * If no listeners are registered at all, an empty array will be returned.\n */\n getEventsWithListeners(): string[] {\n const events: string[] = [];\n for (let event in this.listeners) {\n if (this.listeners[event].length)\n events.push(event);\n }\n return events;\n }\n\n /**\n * Emits an event dispatching it to all listeners registered for it.\n * @param event the event name.\n * @param data the event data.\n */\n emit(event: string, data?: any) {\n const listeners = this.listeners[event];\n if (listeners) {\n listeners.forEach(l => {\n try {\n l(data);\n } catch (e) {\n console.warn('Error dispatching event:', event, 'in listener:', l, e);\n }\n });\n }\n }\n\n}","import {InternalApi} from './internal/internal-api';\nimport {GeneralEventType} from './internal/module/general-module';\nimport {Conversation} from './conversation';\nimport {PersonInfo} from './model/person-info';\nimport {Event, EventCallback} from './internal/event';\nimport {EventEmitter, Listener} from './internal/util/event-emitter';\nimport {ConversationType} from './model/conversation-type';\nimport {AgentAvailabilityState} from './model/agent-availability-state';\nimport {AgentAvailabilityEventType} from './internal/module/agent-availability-module';\nimport {InternalModule} from './internal/module/module';\nimport {UnbluApiError, UnbluErrorType} from './unblu-api-error';\nimport {UnbluUiApi} from './unblu-api-ui';\n\n/**\n * Listener called whenever the active conversation changes.\n *\n * **Note:** If no conversation is currently active the passed conversation object will be `null`\n * @param conversation API object for the active conversation or `null` if no conversation is active.\n */\nexport type ConversationChangeListener = (conversation?: Conversation) => void;\n/**\n * Listener called whenever the notification count of a person (i.e. unread messages) changes.\n * @param count The number of unseen notifications.\n */\nexport type NotificationCountChangeListener = (count: number) => void;\n/**\n * Listener called whenever the local person changes.\n * @param person Info about the person.\n */\nexport type PersonChangeListener = (person: PersonInfo) => void;\n/**\n * Listener called whenever the agent availability changes.\n * @param availability The new availability.\n */\nexport type AgentAvailabilityChangeListener = (availability: AgentAvailabilityState) => void;\n/**\n * Interceptor function which is called every time a new conversation is started from the UI or JS API.\n *\n * The starting of the conversation will be deferred until the Promis returned by this interceptor resolves:\n * If the interceptor rejects the Promise, the starting of the conversation will be canceled.\n * If the interceptor resolves the Promise with a String, its value will be used and set as \"visitorData\" for the created conversation.\n * If the interceptor resolves the Promise without any value or something else then a String the conversation will be started without any visitorData.\n * If visitorData was passed to the [startConversation]{@link startConversation} it will be passed to this callback as second argument.\n @param conversationType The type of the conversation being started.\n @param visitorData Optional visitorData, only present if passed to the [startConversation]{@link startConversation} method\n @return A Promise deferring the start of the conversation until it resolves.\n */\nexport type NewConversationInterceptor = (conversationType: ConversationType, visitorData?: String, ) => Promise;\n\n/**\n * #### This class represents the initialized Unblu Visitor JS API.\n *\n * There is only ever one instance of this api which can be retrieved via `unblu.api.initialize()`,\n * see [[UnbluStaticApi]] for more details on configuring and initializing the UnbluApi.\n *\n * The API connects to the integrated version of Unblu. All actions performed via the UnbluApi are executed in\n * the name of and with the rights of current visitor and may have direct effect on the displayed Unblu UI.\n *\n * For example if a conversation is started from the UnbluApi, the Unblu UI will navigate to it.\n * If a conversation is closed via the API, it will also be closed on the Unblu UI of the visitor.\n * For more information on UI side effects please check the documentation for each method call.\n *\n * For programmatic administrator access and configuration of Unblu please use the Unblu WebAPI.\n */\nexport class UnbluApi {\n\n /**\n * Event emitted every time the active conversation changed.\n *\n * This may happen due to a UI-navigation or an API-call.\n *\n * @event activeConversationChange\n * @see [[on]] for listener registration\n * @see [[ConversationChangeListener]]\n */\n public static readonly ACTIVE_CONVERSATION_CHANGE: 'activeConversationChange' = 'activeConversationChange';\n\n /**\n * Event emitted every time the notification count (unread messages) changes.\n *\n * @event notificationCountChange\n * @see [[on]] for listener registration\n * @see [[NotificationCountChangeListener]]\n */\n public static readonly NOTIFICATION_COUNT_CHANGE: 'notificationCountChange' = 'notificationCountChange';\n\n /**\n * Event emitted every time the local person changes. This may be i.e. due to the person setting its name.\n *\n * @event personChange\n * @see [[on]] for listener registration\n * @see [[PersonChangeListener]]\n */\n public static readonly PERSON_CHANGE: 'personChange' = 'personChange';\n\n /**\n * Event emitted every time the agent availability changes for the current named area and locale.\n *\n * @event availabilityChange\n * @see [[on]] for listener registration\n * @see [[AgentAvailabilityChangeListener]]\n */\n public static readonly AGENT_AVAILABILITY_CHANGE: 'availabilityChange' = 'availabilityChange';\n\n\n /**\n * Access the UI functionality over the UI property.\n */\n public ui: UnbluUiApi;\n\n private internalListeners: { [key: string]: EventCallback } = {};\n private eventEmitter = new EventEmitter();\n\n /**\n * @hidden\n */\n constructor(private internalApi: InternalApi) {\n internalApi.meta.on('upgraded', () => this.onUpgraded());\n // All UI functionality is provided with the ui namespace\n this.ui = new UnbluUiApi(internalApi);\n }\n\n // Event\n /**\n * Registers an event listener for the given event.\n * @param event The activeConversationChange event.\n * @param listener The listener to be called.\n * @see [[ACTIVE_CONVERSATION_CHANGE]]\n */\n public on(event: typeof UnbluApi.ACTIVE_CONVERSATION_CHANGE, listener: ConversationChangeListener): void;\n /**\n * Registers an event listener for the given event.\n * @param event The notificationCountChange event.\n * @param listener The listener to be called.\n * @see [[NOTIFICATION_COUNT_CHANGE]]\n */\n public on(event: typeof UnbluApi.NOTIFICATION_COUNT_CHANGE, listener: NotificationCountChangeListener): void;\n /**\n * Registers an event listener for the given event.\n * @param event The personChange event.\n * @param listener The listener to be called.\n * @see [[PERSON_CHANGE]]\n */\n public on(event: typeof UnbluApi.PERSON_CHANGE, listener: PersonChangeListener): void;\n /**\n * Registers an event listener for the given event.\n * @param event The personChange event.\n * @param listener The listener to be called.\n * @see [[PERSON_CHANGE]]\n */\n public on(event: typeof UnbluApi.AGENT_AVAILABILITY_CHANGE, listener: AgentAvailabilityChangeListener): void;\n\n public on(event: GeneralEventType | AgentAvailabilityEventType, listener: Listener): void {\n const needsInternalSubscription = !this.eventEmitter.hasListeners(event);\n this.eventEmitter.on(event, listener);\n if (needsInternalSubscription)\n this.onInternal(event).catch(e => console.warn('Error registering internal listener for event:', event, 'error:' + e, e));\n }\n\n /**\n * Removes a previously registered listener\n * @param event The event to unregister from.\n * @param listener The listener to remove.\n */\n public off(event: GeneralEventType | AgentAvailabilityEventType, listener: Listener): boolean {\n const removed = this.eventEmitter.off(event, listener);\n if (!this.eventEmitter.hasListeners(event))\n this.offInternal(event).catch(e => console.warn('Error removing internal listener for event:', event, 'error:' + e, e));\n return removed;\n }\n\n private async onInternal(eventName: GeneralEventType | AgentAvailabilityEventType) {\n let internalListener: EventCallback;\n let internalModule: InternalModule;\n let needsUpgrade: boolean;\n switch (eventName) {\n case UnbluApi.AGENT_AVAILABILITY_CHANGE:\n internalListener = (event: Event) => {\n this.eventEmitter.emit(event.name, event.data);\n };\n internalModule = this.internalApi.agentAvailability;\n needsUpgrade = false;\n break;\n case UnbluApi.ACTIVE_CONVERSATION_CHANGE:\n internalListener = (event: Event) => {\n this.eventEmitter.emit(event.name, event.data ? new Conversation(this.internalApi, event.data) : null);\n };\n internalModule = this.internalApi.general;\n needsUpgrade = true;\n break;\n case UnbluApi.NOTIFICATION_COUNT_CHANGE:\n case UnbluApi.PERSON_CHANGE:\n internalListener = (event: Event) => {\n this.eventEmitter.emit(event.name, event.data);\n };\n internalModule = this.internalApi.general;\n needsUpgrade = true;\n break;\n default:\n throw new UnbluApiError(UnbluErrorType.INVALID_FUNCTION_ARGUMENTS, 'Registration to unknown event:' + eventName);\n }\n\n if (!needsUpgrade || await this.internalApi.meta.isUpgraded()) {\n this.internalListeners[eventName] = internalListener;\n try {\n await internalModule.on(eventName, internalListener);\n } catch (e) {\n delete this.internalListeners[eventName];\n throw e;\n }\n }\n }\n\n private async offInternal(eventName: GeneralEventType | AgentAvailabilityEventType) {\n const listener = this.internalListeners[eventName];\n if (listener == null) {\n return;\n }\n delete this.internalListeners[eventName];\n\n let internalModule: InternalModule;\n switch (eventName) {\n case UnbluApi.AGENT_AVAILABILITY_CHANGE:\n internalModule = this.internalApi.agentAvailability;\n break;\n default:\n internalModule = this.internalApi.general;\n break;\n }\n await internalModule.off(eventName, listener);\n }\n\n // General\n\n /**\n * Returns information about the visitor.\n * @return A promise that resolves to the current visitors person info.\n */\n public async getPersonInfo(): Promise {\n await this.requireUpgrade();\n return this.internalApi.general.getPersonInfo();\n }\n\n /**\n * Set the nickname of the current visitor.\n * This could be set before or during a conversation.\n * @return A empty promise when operation is done.\n */\n public async setPersonNickname(nickname: string): Promise {\n await this.requireUpgrade();\n return this.internalApi.general.setPersonNickname(nickname);\n }\n\n /**\n * Returns the number of unread messages.\n * @return A promise that resolves to the current number of unread messages.\n */\n public async getNotificationCount(): Promise {\n if (await this.internalApi.meta.isUpgraded()) {\n return this.internalApi.general.getNotificationCount();\n } else {\n return this.internalApi.generalLazy.getNotificationCount();\n }\n }\n\n // Conversation\n\n\n /**\n * Starts a new Conversation and places it into the inbound conversation queue.\n *\n * **NOTE:** calling this method will NOT automatically open the Unblu UI if it is collapsed. Use [ui.openIndividualUi()]{@link UnbluUiApi.openIndividualUi} if this is needed.\n *\n * @param type The conversation type that shall be started.\n * @param visitorName The name the local visitor should have. This is only taken into account if the visitor is not already authenticated.\n * @param visitorData Custom data for the visitor in any format. **NOTE:** The data which is passed here could be used in [NewConversationCallback]{@link NewConversationInterceptor}\n * @return A promise that resolves to the conversation object giving API access to the started conversation.\n */\n public async startConversation(type: ConversationType, visitorName?: string, visitorData?: string): Promise {\n await this.requireUpgrade();\n const conversationId = await this.internalApi.general.startConversation(type, visitorName, visitorData);\n return new Conversation(this.internalApi, conversationId);\n }\n\n /**\n * Set a custom interceptor which will be triggered when a new conversation is started (initiated from UI or JavaScript).\n * @param callback The interceptor which is called before a new conversation is started. The Callback is of type [NewConversationCallback]{@link NewConversationInterceptor}\n * @return A promise that resolves when the interceptor is successfully applied and active.\n */\n public async setNewConversationInterceptor(callback: NewConversationInterceptor): Promise {\n if (!await this.internalApi.meta.isUpgraded()) {\n return await this.internalApi.generalLazy.setNewConversationInterceptor(callback);\n } else {\n return await this.internalApi.general.setNewConversationInterceptor(callback);\n }\n }\n\n /**\n * Joins an existing conversation with a given PIN.\n *\n * **NOTE:** calling this method will NOT automatically open the Unblu UI if it is collapsed. Use [ui.openIndividualUi()]{@link UnbluUiApi.openIndividualUi} if this is needed.\n *\n * @param pin The PIN retrieved from the Unblu Agent Desk.\n * @param visitorName The name the local visitor should have. This is only taken into account if the visitor is not already authenticated.\n * @return A promise that resolves to the conversation object giving API access to the joined conversation.\n */\n public async joinConversation(pin: string, visitorName?: string): Promise {\n await this.requireUpgrade();\n const conversationId = await this.internalApi.general.joinConversation(pin, visitorName);\n return new Conversation(this.internalApi, conversationId);\n }\n\n /**\n * Opens the existing conversation with the given conversation ID.\n *\n * **NOTE:** calling this method will NOT automatically open the Unblu UI if it is collapsed. Use [ui.openIndividualUi()]{@link UnbluUiApi.openIndividualUi} if this is needed.\n *\n * @param conversationId The PIN retrieved from tha Unblu Agent Desk.\n * @return A promise that resolves to the conversation object giving API access to the opened conversation.\n */\n public async openConversation(conversationId: string): Promise {\n await this.requireUpgrade();\n await this.internalApi.general.openConversation(conversationId);\n return new Conversation(this.internalApi, conversationId);\n }\n\n /**\n * Returns the currently active conversation or `null` if no conversation is active.\n *\n * **NOTE:** calling this method twice while the same conversation is active, will result in two individual conversation API instances being returned.\n * destroying one of them will not cause the other one to also be destroyed. If however the active conversation is closed, all returned Conversation instances will be destroyed.\n *\n * @return A promise that either resolves to the currently active conversation or `null` if no conversation is open.\n * @see [[ACTIVE_CONVERSATION_CHANGE]]\n */\n public async getActiveConversation(): Promise {\n if (await this.internalApi.meta.isUpgraded()) {\n const conversationId = await this.internalApi.general.getActiveConversation();\n return conversationId != null ? new Conversation(this.internalApi, conversationId) : null;\n } else {\n return null;\n }\n }\n\n /**\n * Checks if an agent is available for the current named area and language.\n *\n * @return Promise that resolves to `true` if the availability state is [AVAILABLE]{@link AgentAvailabilityState.AVAILABLE} or [BUSY]{@link AgentAvailabilityState.BUSY}, `false` otherwise.\n * @see [[getAgentAvailabilityState]] for a more detailed check.\n */\n public async isAgentAvailable(): Promise {\n return this.internalApi.agentAvailability.isAgentAvailable();\n }\n\n /**\n * Returns the current availability state for the current named area and language.\n * @return Promise that resolves to the current availability state.\n * @see [[isAgentAvailable]] for a simpler check.\n */\n public async getAgentAvailabilityState(): Promise {\n return this.internalApi.agentAvailability.getAgentAvailabilityState();\n }\n\n private async requireUpgrade(): Promise {\n await this.internalApi.meta.upgrade(false);\n }\n\n private onUpgraded() {\n for (let event of this.eventEmitter.getEventsWithListeners()) {\n // register internal listeners for all events that need upgrade.\n if (!this.internalListeners[event])\n this.onInternal(event as GeneralEventType);\n }\n }\n\n}","import {InternalApi} from './internal/internal-api';\nimport {CallState} from './model/call-state';\nimport {Event, EventCallback} from './internal/event';\nimport {\n ConversationCallState,\n ConversationConnectionState,\n ConversationEventType, ConversationInvitations, ConversationWithState\n} from './internal/module/conversation-module';\nimport {UnbluApiError, UnbluErrorType} from './unblu-api-error';\nimport {EventEmitter, Listener} from './internal/util/event-emitter';\nimport {ConversationState} from './model/conversation-state';\nimport {ConnectionState} from './model/connection-state';\nimport {Invitation} from \"./model/invitation\";\n\nexport type ConnectionStateListener = (connectionState: ConnectionState) => void;\nexport type ConversationStateListener = (conversationState: ConversationState) => void;\nexport type CallStateListener = (callState: CallState) => void;\nexport type InvitationsListener = (invitations: Invitation[]) => void;\n\n/**\n * #### This class gives API access to the currently active conversation.\n *\n * As long as a conversation is active one can register and receive the events provided by this class and call the methods.\n * Once the conversation is closed this API object will be destroyed and no more event callbacks will be called.\n * Any subsequent calls will fail.\n *\n * Use the [[CLOSE]] event to de-init any code connected to this conversation.\n */\nexport class Conversation {\n\n /**\n * Event emitted when the [[ConnectionState]] of this conversation changes.\n * @event connectionStateChange\n * @see [[on]] for listener registration\n */\n public static readonly CONNECTION_STATE_CHANGE: 'connectionStateChange' = 'connectionStateChange';\n\n /**\n * Event emitted when the [[ConversationState]] of this conversation changes.\n * @event conversationStateChange\n * @see [[on]] for listener registration\n */\n public static readonly CONVERSATION_STATE_CHANGE: 'conversationStateChange' = 'conversationStateChange';\n\n /**\n * Event emitted when the [[CallState]] of this conversation changes.\n * @event callStateChange\n * @see [[on]] for listener registration\n */\n public static readonly CALL_STATE_CHANGE: 'callStateChange' = 'callStateChange';\n\n /**\n * Event emitted when the conversation ends.\n * @deprecated The end event is not always available, depending on the configuration. Use instead [[CONVERSATION_STATE_CHANGE]] event.\n * @event end\n * @see [[on]] for listener registration\n */\n public static readonly END: 'end' = 'end';\n\n /**\n * Event emitted when the conversation is closed.\n *\n * This may happen due to a UI-navigation or an API-call.\n *\n * @event close\n * @see [[on]] for listener registration\n */\n public static readonly CLOSE: 'close' = 'close';\n\n /**\n * Event emitted when an [[Invitation]] is added to or removed from this conversation or if an existing one changes.\n * The event emits an array of all visitor invitations created by the local person, all other invitations will not be present.\n * @event invitationsChange\n * @see [[on]] for listener registration\n */\n public static readonly INVITATIONS_CHANGE: 'invitationsChange' = 'invitationsChange';\n\n private eventEmitter = new EventEmitter();\n private internalListeners: { [key: string]: EventCallback } = {};\n private destroyed = false;\n\n /**\n * @hidden\n */\n constructor(private internalApi: InternalApi, private conversationId: string) {\n // clean up all listeners when the conversation disconnects.\n this.on(Conversation.CLOSE, () => this.destroy());\n }\n\n /**\n * Registers an event listener for the given event.\n * @param event The call state change event.\n * @param listener The listener to be called.\n * @see [[CONNECTION_STATE_CHANGE]]\n */\n public on(event: typeof Conversation.CONNECTION_STATE_CHANGE, listener: ConnectionStateListener): void ;\n\n /**\n * Registers an event listener for the given event.\n * @param event The conversation state change event.\n * @param listener The listener to be called.\n * @see [[CONVERSATION_STATE_CHANGE]]\n */\n public on(event: typeof Conversation.CONVERSATION_STATE_CHANGE, listener: ConversationStateListener): void ;\n\n\n /**\n * Registers an event listener for the given event.\n * @param event The call state change event.\n * @param listener The listener to be called.\n * @see [[CALL_STATE_CHANGE]]\n */\n public on(event: typeof Conversation.CALL_STATE_CHANGE, listener: CallStateListener): void ;\n\n /**\n * Registers an event listener for the given event.\n * @deprecated The end event is not always available, depending on the configuration. Use instead [[CONVERSATION_STATE_CHANGE]] event.\n * @param event The end event.\n * @param listener The listener to be called.\n * @see [[END]]\n */\n public on(event: typeof Conversation.END, listener: () => void): void ;\n\n /**\n * Registers an event listener for the given event.\n * @param event The close event.\n * @param listener The listener to be called.\n * @see [[CLOSE]]\n */\n public on(event: typeof Conversation.CLOSE, listener: () => void): void;\n\n /**\n * Registers an event listener for the given event.\n * @param event The invitations change event.\n * @param listener The listener to be called.\n * @see [[INVITATIONS_CHANGE]]\n */\n public on(event: typeof Conversation.INVITATIONS_CHANGE, listener: InvitationsListener): void ;\n\n /**\n * Adds a listener.\n * @param event The event to register.\n * @param listener The listener to register.\n */\n public on(event: ConversationEventType, listener: Listener): void {\n this.checkNotDestroyed();\n const needsInternalSubscription = !this.eventEmitter.hasListeners(event);\n this.eventEmitter.on(event, listener);\n if (needsInternalSubscription)\n this.onInternal(event);\n }\n\n /**\n * Removes a previously registered listener.\n * @param event The event to unregister from.\n * @param listener The listener to remove.\n */\n public off(event: ConversationEventType, listener: Listener): boolean {\n this.checkNotDestroyed();\n const removed = this.eventEmitter.off(event, listener);\n if (!this.eventEmitter.hasListeners(event))\n this.offInternal(event);\n return removed;\n }\n\n private onInternal(eventName: ConversationEventType) {\n let internalListener: EventCallback;\n switch (eventName) {\n case Conversation.CONNECTION_STATE_CHANGE:\n internalListener = (event: Event) => {\n if (event.data.conversationId == this.conversationId)\n this.eventEmitter.emit(event.name, event.data.connectionState);\n };\n break;\n case Conversation.CONVERSATION_STATE_CHANGE:\n internalListener = (event: Event) => {\n if (event.data.conversationId == this.conversationId)\n this.eventEmitter.emit(event.name, event.data.conversationState);\n };\n break;\n case Conversation.CALL_STATE_CHANGE:\n internalListener = (event: Event) => {\n if (event.data.conversationId == this.conversationId)\n this.eventEmitter.emit(event.name, event.data.callState);\n };\n break;\n case Conversation.INVITATIONS_CHANGE:\n internalListener = (event: Event) => {\n if (event.data.conversationId == this.conversationId)\n this.eventEmitter.emit(event.name, event.data.invitations);\n };\n break;\n default:\n internalListener = (event: Event) => {\n if (event.data == this.conversationId) {\n this.eventEmitter.emit(event.name);\n }\n };\n break;\n }\n this.internalListeners[eventName] = internalListener;\n this.internalApi.conversation.on(eventName, internalListener).catch(e => console.warn('Error registering internal listener for event:', eventName, 'error:' + e, e));\n }\n\n private offInternal(eventName: ConversationEventType) {\n const listener = this.internalListeners[eventName];\n if (listener == null)\n return;\n delete this.internalListeners[eventName];\n this.internalApi.conversation.off(eventName, listener).catch(e => console.warn('Error removing internal listener for event:', eventName, 'error:' + e, e));\n }\n\n /**\n * Returns the ID of this conversation.\n */\n public getConversationId(): string {\n return this.conversationId;\n }\n\n /**\n * Returns the current connection state the conversation is in.\n *\n * If the connection is lost, the conversation will automatically try to reconnect using an exponential back-off strategy.\n * If a fatal error is detected, the state will change to [[ConnectionState.ERROR]].\n *\n * If this happens, the conversation is in it's terminal state. A dialog or other UI will be displayed to the user with details on the failure.\n * The conversation is not automatically closed in this case.\n * It may either be closed through a manual action by the visitor (confirming the error) or via the API.\n *\n * @see [[CONNECTION_STATE_CHANGE]] If you need to listen to changes.\n * @return A promise that resolves to the current connection state of the conversation\n * or is rejected with a [[UnbluApiError]] if the call fails.\n */\n public async getConnectionState(): Promise {\n this.checkNotDestroyed();\n return this.internalApi.conversation.getConnectionState(this.conversationId);\n }\n\n /**\n * Returns the current state the conversation is in.\n * @return A promise that resolves to the current state of the conversation\n * or is rejected with a [[UnbluApiError]] if the call fails.\n */\n public async getConversationState(): Promise {\n this.checkNotDestroyed();\n return this.internalApi.conversation.getConversationState(this.conversationId);\n }\n\n /**\n * @see [[CALL_STATE_CHANGE]] If you need to listen to changes.\n * @return A promise that resolves to the current call state of the local user\n * or is rejected with a [[UnbluApiError]] if the call fails.\n */\n public async getCallState(): Promise {\n this.checkNotDestroyed();\n return this.internalApi.conversation.getCallState(this.conversationId);\n }\n\n /**\n * Creates a new PIN invitation for this conversation.\n *\n * - If the local person doesn't have the right to invite a visitor,\n * the returned promise will be rejected with the unblu error type [[UnbluErrorType.ACTION_NOT_GRANTED]].\n * @see [[INVITATIONS_CHANGE]] If you need to listen to changes for new invitations on this conversation.\n * @return A promise that resolves to a new [[Invitation]] object with all relevant metadata.\n * or is rejected with a [[UnbluApiError]] if the call fails.\n */\n public async createAnonymousPinInvitation(): Promise {\n this.checkNotDestroyed();\n return this.internalApi.conversation.createAnonymousPinInvitation(this.conversationId);\n }\n\n /**\n * Creates a new EMail invitation for this conversation.\n *\n * - If the local person doesn't have the right to invite a visitor,\n * the returned promise will be rejected with the unblu error type [[UnbluErrorType.ACTION_NOT_GRANTED]].\n * - If a non valid email address is provided,\n * the returned promise will be rejected with the unblu error type [[UnbluErrorType.INVALID_FUNCTION_ARGUMENTS]].\n * @param email The email which the invitation should be send. It must be a valid email address.\n * @see [[INVITATIONS_CHANGE]] If you need to listen to changes for new invitations on this conversation.\n * @return A promise that resolves to a new [[Invitation]] object with all relevant metadata.\n * or is rejected with a [[UnbluApiError]] if the call fails.\n */\n public async createAnonymousEmailInvitation(email: String) : Promise {\n this.checkNotDestroyed();\n return this.internalApi.conversation.createAnonymousEmailInvitation(this.conversationId, email);\n }\n\n /**\n * Revoke an invitation.\n *\n * - If the local person doesn't have the right to invite a visitor,\n * the returned promise will be rejected with the unblu error type [[UnbluErrorType.ACTION_NOT_GRANTED]].\n * @param invitationId The invitation id.\n * @return A Promise that resolves to null or is rejected with a [[UnbluApiError]] if the call fails.\n */\n public async revokeInvitation(invitationId: String) : Promise {\n this.checkNotDestroyed();\n return this.internalApi.conversation.revokeInvitation(this.conversationId, invitationId);\n }\n\n /**\n * Renews an invitation PIN if the invitation is expired.\n *\n * - If the local person doesn't have the right to invite a visitor,\n * the returned promise will be rejected with the unblu error type [[UnbluErrorType.ACTION_NOT_GRANTED]].\n * @param invitationId The invitation id.\n * @return A promise that resolves to a new [[Invitation]] object with all relevant metadata.\n */\n public async renewInvitationPin(invitationId: String) : Promise {\n this.checkNotDestroyed();\n return this.internalApi.conversation.renewInvitationPin(this.conversationId, invitationId);\n }\n\n /**\n * Get all visitor invitations created by the local person for this conversation.\n * @return A promise that resolves to a new [[Invitation]] array with all relevant metadata.\n * or is rejected with a [[UnbluApiError]] if the call fails.\n */\n public async getInvitations(): Promise {\n this.checkNotDestroyed();\n return this.internalApi.conversation.getInvitations(this.conversationId);\n }\n\n /**\n * Starts a voice call in this conversation.\n *\n * - If a call is already active, this call will be ignored.\n * - If the local person doesn't have the right to start a voice call,\n * the returned promise will be rejected with the unblu error type [[UnbluErrorType.ACTION_NOT_GRANTED]].\n * @see [[CALL_STATE_CHANGE]] If you need to listen to changes.\n * @return A Promise that resolves to null or is rejected with a [[UnbluApiError]] if the call fails.\n */\n public async startAudioCall(): Promise {\n this.checkNotDestroyed();\n return this.internalApi.conversation.startAudioCall(this.conversationId);\n }\n\n /**\n * Starts a video call in this conversation.\n *\n * - If a call is already active, this call will be ignored.\n * - If the local person doesn't have the right to start a video call,\n * the returned promise will be rejected with the unblu error type [[UnbluErrorType.ACTION_NOT_GRANTED]].\n * @see [[CALL_STATE_CHANGE]] If you need to listen to changes.\n * @return A Promise that resolves to null or is rejected with a [[UnbluApiError]] if the call fails.\n */\n public async startVideoCall(): Promise {\n this.checkNotDestroyed();\n return this.internalApi.conversation.startVideoCall(this.conversationId);\n }\n\n /**\n * Ends and closes this conversation.\n *\n * If the local person doesn't have the right to end the conversation,\n * the returned promise will be rejected with the unblu error type [[UnbluErrorType.ACTION_NOT_GRANTED]].\n * @see [[END]] fired after this call.\n * @see [[closeConversation]] for details on closing a conversation.\n * @return A Promise that resolves to null or is rejected with a [[UnbluApiError]] if the call fails.\n */\n public async endConversation(): Promise {\n this.checkNotDestroyed();\n return this.internalApi.conversation.endConversation(this.conversationId);\n }\n\n /**\n * Leaves and closes this conversation.\n *\n * By leaving, the visitor is removed from the active participant list of the conversation.\n * Once a conversation is left, the visitor can not re-open it. It will not be visible in the conversation history either.\n *\n * If the local person doesn't have the right to leave the conversation,\n * the returned promise will be rejected with the unblu error type [[UnbluErrorType.ACTION_NOT_GRANTED]].\n * @see [[CLOSE]] fired after this call.\n * @see [[closeConversation]] for details on closing a conversation without leaving.\n * @return A Promise that resolves to null or is rejected with a [[UnbluApiError]] if the call fails.\n */\n public async leaveConversation(): Promise {\n this.checkNotDestroyed();\n return this.internalApi.conversation.leaveConversation(this.conversationId);\n }\n\n /**\n * Closes this conversation locally.\n *\n * When called, the connection to this conversation is closed and the overview is displayed.\n *\n * **Note that:**\n * - Closing does NOT end the conversation.\n * - The person does NOT leave the conversation.\n * - All Conversation api instances for this conversation will be destroyed.\n *\n * The conversation can be joined again either via the UI or using [[UnbluApi.openConversation]].\n * @see [[CLOSE]] fired after this call.\n * @see [[endConversation]] for details on ending a conversation.\n * @see [[leavingConversation]] for details on leaving a conversation.\n * @see [[destroy]] for details on destroying a conversation.\n * @return A Promise that resolves to null or is rejected with a [[UnbluApiError]] if the call fails.\n */\n public async closeConversation(): Promise {\n this.checkNotDestroyed();\n return this.internalApi.conversation.closeConversation(this.conversationId);\n }\n\n private checkNotDestroyed(): void {\n if (this.destroyed) throw new UnbluApiError(UnbluErrorType.ILLEGAL_STATE, 'Error: trying to execute method on destroyed conversation object.')\n }\n\n /**\n * Returns weather this conversation is destroyed or not.\n *\n * Conversations are either destroyed if [[destroy]] is called or the conversation is closed.\n * This usually happens when the user navigates back to an overview or into an other conversation.\n * @see [[destroy]]\n * @see [[CLOSE]]\n * @return Weather this conversation is destroyed or not.\n */\n public isDestroyed(): boolean {\n return this.destroyed;\n }\n\n /**\n * Destroys this conversation API instance.\n *\n * Calling destroy will unregister all event listeners and prohibit any further calls to this object.\n * Once the conversation is destroyed, any subsequent calls will reject the returned promise with [[UnbluErrorType.ILLEGAL_STATE]] as reason.\n *\n * **Note that:**\n * - Destroying does NOT close the conversation .\n * - Destroying does NOT end the conversation.\n * - Destroying does NOT leave the conversation.\n * - Other instances of the same Conversation will NOT be destroyed.\n *\n * This call simply destroys this local API instance to the conversation.\n *\n * A destroyed but still open conversation can be accessed again using [[UnbluApi.getActiveConversation]].\n *\n * @see [[isDestroyed]]\n * @see [[closeConversation]] for details on how to close a conversation\n * @see [[endConversation]] for details on how to end a conversation\n */\n public destroy(): void {\n if (this.destroyed) return;\n this.destroyed = true;\n this.eventEmitter.reset();\n for (let event in this.internalListeners) {\n this.offInternal(event as ConversationEventType);\n }\n }\n}","// Typedef Helpers\n\n\n/**\n * Internal type definition of the unblu object.\n * @hidden\n */\nexport interface UnbluObject {\n api?: any,\n\n /**\n * internal unblu field\n * @hidden\n */\n APIKEY?: string,\n /**\n * internal unblu field\n * @hidden\n */\n SERVER?: string,\n /**\n * internal unblu field\n * @hidden\n */\n l?: string\n}\n\n/**\n * @hidden\n */\nexport class UnbluUtil {\n static async loadScript(uri: string, timeout: number): Promise {\n const timeoutTime = timeout || 30000;\n const script = document.createElement('script');\n script.setAttribute('charset', 'UTF-8');\n script.setAttribute('type', 'text/javascript');\n script.setAttribute('async', 'true');\n script.setAttribute('timeout', timeoutTime.toString());\n script.src = uri;\n\n return new Promise(function (resolve, reject) {\n let timeoutId: number;\n\n const cleanup = () => {\n // avoid mem leaks in IE.\n script.onerror = script.onload = null;\n window.clearTimeout(timeoutId);\n };\n\n const onError = (error: string | Event) => {\n cleanup();\n console.error('Failed to load script! Uri:', uri, 'Error:', error);\n reject(error);\n };\n\n script.onload = () => {\n cleanup();\n resolve();\n };\n script.onerror = onError;\n timeoutId = window.setTimeout(() => onError('Timeout'), timeoutTime);\n\n const head = document.getElementsByTagName('HEAD')[0];\n head.appendChild(script);\n });\n }\n\n static setNamedArea(namedArea: string): void {\n const metaTag = window.document.querySelector('meta[name=\"unblu:named-area\"]') || window.document.createElement('meta');\n metaTag.setAttribute('name', 'unblu:named-area');\n metaTag.setAttribute('content', namedArea);\n if (!metaTag.parentElement) {\n window.document.head.appendChild(metaTag);\n }\n }\n\n static setLocale(locale: string): void {\n // unblu.l will be read in user-locale-util.js\n UnbluUtil.getUnbluObject().l = locale;\n }\n\n static isUnbluLoaded(): boolean {\n return UnbluUtil.getUnbluObject() && !!UnbluUtil.getUnbluObject().APIKEY;\n }\n\n static getUnbluObject(): UnbluObject {\n return window.unblu;\n }\n\n static createUnbluObject(): UnbluObject {\n return window.unblu = {};\n }\n\n}","import {UnbluApi} from './unblu-api';\nimport {Conversation} from './conversation';\nimport {UnbluStaticApi} from './unblu-static-api';\nimport {UnbluUtil} from './unblu-util';\nimport {CallState} from './model/call-state';\nimport {ConnectionState} from './model/connection-state';\nimport {ConversationType} from './model/conversation-type';\nimport {AgentAvailabilityState} from './model/agent-availability-state';\nimport {ConversationState} from './model/conversation-state';\nimport {UnbluErrorType} from './unblu-api-error';\n\nexport {UnbluApi} from './unblu-api';\nexport {Conversation} from './conversation';\n\n\n/**\n * The main unblu namespace which gives access to the unblu api.\n *\n * Access:\n * ```javascript\n * window.unblu.api;\n * ```\n *\n * **Note:** all fields inside the unblu namespace except for the [[api]] are not public and may change without any notice.\n */\nexport interface Unblu {\n /**\n * Access to the unblu API.\n *\n * This field will be available as soon as the unblu API has been loaded.\n */\n api?: UnbluStaticApi,\n\n AgentAvailabilityState?: typeof AgentAvailabilityState,\n\n CallState?: typeof CallState,\n\n ConnectionState?: typeof ConnectionState,\n\n ConversationState?: typeof ConversationState,\n\n ConversationType?: typeof ConversationType,\n\n UnbluErrorType?: typeof UnbluErrorType\n}\n\n/**\n * Global window scope definition of the unblu namespace on the window.\n * Access:\n * ```javascript\n * window.unblu.api;\n * ```\n */\ndeclare global {\n interface Window {\n /**\n * The main unblu namespace\n */\n unblu: Unblu;\n }\n}\n\nconst unblu = (UnbluUtil.getUnbluObject() || UnbluUtil.createUnbluObject()) as Unblu;\nunblu.AgentAvailabilityState = AgentAvailabilityState;\nunblu.CallState = CallState;\nunblu.ConnectionState = ConnectionState;\nunblu.ConversationState = ConversationState;\nunblu.ConversationType = ConversationType;\nunblu.UnbluErrorType = UnbluErrorType;\n\n\n/**\n * The central access point to the unblu JS API.\n * This api object gives static access to configure and initialize the full unblu `UnbluApi`.\n * When loaded in the global space use `Unblu.Api` to access it.\n * @hidden\n */\nexport const api = new UnbluStaticApi();\n\n","import {UnbluApi} from './unblu-api';\nimport {EventEmitter, Listener} from './internal/util/event-emitter';\nimport {UnbluUtil} from './unblu-util';\nimport {UnbluApiError, UnbluErrorType} from './unblu-api-error';\nimport {ApiBridge} from './internal/api-bridge';\nimport {InternalApi} from './internal/internal-api';\n\nexport interface Configuration {\n /**\n * An API-Key of the account to be used.\n * This is a mandatory configuration.\n *\n * API keys can be retrieved from the Unblu Agent Desk in the settings section.\n * Keep in mind, that an Admin role is needed.\n */\n apiKey: string,\n\n /**\n * The url of the Unblu server to connect to.\n *\n * @default If not set, the domain of the current page will be used.\n */\n serverUrl?: string,\n\n /**\n * The public path to Unblu which will be used in combination with [[serverUrl]] to connect to Unblu.\n *\n * @default If not set, '/unblu' will be used.\n */\n entryPath?: string,\n\n /**\n * The locale to be used for all Unblu translation texts.\n *\n * @default If not set, the browsers locale will be used.\n */\n locale?: string\n\n /**\n * The named area to be used. The named area determines the agent availability, the queue that conversation requests go to, and the configuration.\n *\n * @default If not set, if the `\"/>` will be used if present and if not, the domain will be used.\n */\n namedArea?: string\n\n /**\n * The timeout im milliseconds that should be waited for the Unblu integration to load.\n *\n * @default 30'000 (30 seconds).\n */\n initTimeout?: number\n}\n\nexport const enum ApiState {\n INITIAL = 'INITIAL',\n INITIALIZING = 'INITIALIZING',\n INITIALIZED = 'INITIALIZED',\n ERROR = 'ERROR'\n}\n\nexport type ReadyListener = (api: UnbluApi) => void;\nexport type ErrorListener = (e: Error) => void;\n\n\n/**\n * #### The central entry point that allows to configure an initialize the Unblu Visitor JS API.\n * The static Unblu API works without actually loading the rest of Unblu.\n * It can do some general checks and load Unblu or connect the API to a loaded version of Unblu.\n * The JS API is an optional add-on to the Unblu visitor site integration.\n *\n * Depending on how Unblu is integrated into the local website the API has to be initialized differently.\n *\n * **a.) API-only integration**\n * If no unblu-snippet is loaded into the page, Unblu can be fully initialized with the API.\n * In this case, both the `configure` and the `initialize` methods have to be called.\n * Example:\n * ```ts\n * const api = await unblu.api\n * // configure the unblu server\n * .configure({\n * apiKey: \"\",\n * serverUrl: \"\"\n * })\n * // initialize the api.\n * .initialize();\n * ```\n * This implementation will load the Unblu snippet and initialize both Unblu and the JS API.\n *\n * **b.) Snippet and JS API integration**\n * If the Unblu snippet is already present in the local website, Unblu doesn't have to be loaded\n * and only the API has to be initialized.\n * Example:\n * ```ts\n * // directly initialize the api without configuring.\n * const api = await unblu.api.initialize();\n *\n * ```\n */\nexport class UnbluStaticApi {\n private state: ApiState = ApiState.INITIAL;\n private error: UnbluApiError;\n private eventEmitter = new EventEmitter();\n\n private configuration: Configuration;\n private initializedApi: UnbluApi;\n\n /**\n * Event emitted as soon as the API is initialized.\n *\n * It usually makes sense to use this event if there is some general action that has to be triggered when the API is initialized,\n * but there are several places in the integration code that may trigger the initialization.\n *\n * In most cases however, it is better to use\n * ```ts\n * unblu.api.initialize().then(api => { //use api here });\n * ```\n * or\n * ```ts\n * let api = await unblu.api.initialize();\n * // use api here\n * ```\n *\n * @event ready\n * @see [[on]] for listener registration\n */\n public static readonly READY: 'ready' = 'ready';\n /**\n * Event emitted if the API initialization fails.\n *\n * It usually makes sense to use this event if there is some general action that has to be triggered when the API initialization fails,\n * but there are several places in the integration code that may trigger the initialization.\n *\n * In most cases however, it is better to use\n * ```ts\n * unblu.api.initialize().catch(error=> { //handle error here });\n * ```\n * or\n * ```ts\n * try{\n * let api = await unblu.api.initialize();\n * }catch(e){\n * // handle error here\n * }\n *\n * ```\n *\n * @event error\n * @see [[on]] for listener registration\n */\n public static readonly ERROR: 'error' = 'error';\n\n /**\n * @hidden\n */\n constructor() {\n //TODO: detect browser support;\n\n // store the error\n this.eventEmitter.on(UnbluStaticApi.ERROR, e => this.error = e);\n\n // install globally\n const unblu = UnbluUtil.getUnbluObject();\n if (unblu.api) {\n this.handleError(new UnbluApiError(UnbluErrorType.ILLEGAL_STATE, 'Unblu API has already been loaded.'));\n } else {\n unblu.api = this;\n }\n if (UnbluUtil.isUnbluLoaded()) {\n // Auto init if snippet is already loaded.\n this.initializeApi().catch(e => console.warn('Error during auto initialization', e));\n }\n }\n\n //TODO: Add version\n\n /**\n * Registers an event listener for the given event.\n *\n * **Note** If the API is already initialized, this listener will be called directly.\n * @param event The ready event\n * @param listener The listener to be called.\n * @see [[READY]]\n */\n on(event: typeof UnbluStaticApi.READY, listener: ReadyListener): void;\n\n /**\n * Registers an event listener for the given event.\n *\n * **Note** If the API has already failed, this listener will be called directly.\n * @param event The error event\n * @param listener The listener to be called.\n * @see [[ERROR]]\n */\n on(event: typeof UnbluStaticApi.ERROR, listener: ErrorListener): void;\n\n on(event: string, listener: Listener): void {\n if (event == UnbluStaticApi.READY && this.state == ApiState.INITIALIZED)\n listener(this.initializedApi);\n else if (event == UnbluStaticApi.ERROR && this.state == ApiState.ERROR)\n listener(this.error);\n else\n this.eventEmitter.on(event, listener)\n }\n\n /**\n * Removes a previously registered listener.\n * @param event The event unregister.\n * @param listener The listener to be removed.\n * @return `true` if the listener was removed, `false` otherwise.\n */\n off(event: string, listener: Listener): boolean {\n return this.eventEmitter.off(event, listener);\n }\n\n\n /**\n * Checks whether the API has to be configured or not.\n *\n * - If no snippet is present and the API state is still [INITIAL]{@link ApiState.INITIAL} a configuration is necessary.\n * - If a snippet is present or the API is already loaded, configuration is not necessary.\n *\n * @return `true` if a configuration is needed to initialize the API, `false` otherwise.\n * @see [[configure]] to configure the API\n * @see [[initialize]] to initialize the API\n */\n public isConfigurationNeeded(): boolean {\n return this.state === ApiState.INITIAL && !UnbluUtil.isUnbluLoaded();\n }\n\n\n /**\n * Returns the current state of the API\n * @return the current API state.\n * @see [[isInitialized]] for a simpler check\n */\n public getApiState(): ApiState {\n return this.state;\n }\n\n /**\n * Checks whether the API is initialized or not.\n * @return `true` if the API is initialized, `false` for any other state.\n * @see [[getApiState]] for the full state\n */\n public isInitialized(): boolean {\n return this.state === ApiState.INITIALIZED;\n }\n\n /**\n * Configures the way that Unblu should be initialized.\n *\n * The configuration of the Unblu API is needed when, and only when no Unblu snippet is already present in the website.\n *\n * **Note:**\n * - Calling this method when there already is an unblu-snippet will result in an [[UnbluApiError]].\n * - This method must be called BEFORE [[initialize]]. If it is called afterwards an [[UnbluApiError]] will be thrown.\n *\n * @param config The configuration to be set.\n * @return an instance of `this` allowing chaining like `unblu.api.configure({...}).initialize();`\n * @see [[isConfigurationNeeded]] to check if configuration is needed or not.\n */\n configure(config: Configuration): UnbluStaticApi {\n if (UnbluUtil.isUnbluLoaded()) {\n throw new UnbluApiError(UnbluErrorType.ILLEGAL_STATE, 'Configure called when Unblu was already loaded.')\n } else if (this.state !== ApiState.INITIAL) {\n throw new UnbluApiError(UnbluErrorType.ILLEGAL_STATE, 'Error configure called after API was already initialized.');\n }\n this.configuration = config;\n return this;\n }\n\n /**\n * Initializes the API and resolves to the fully initialized API.\n *\n * If the API has already been initialized or is already in the initializing process, the existing API will be returned.\n * There is only ever one instance of the API which will be returned by any call of this method which makes it safe to call this multiple times.\n *\n * *The initialization may fail with a [[UnbluApiError]] for the following reasons*\n * - A configuration is needed but none was provided: [CONFIGURATION_MISSING]{@link UnbluErrorType.CONFIGURATION_MISSING}\n * - Loading Unblu encounters a problem: [ERROR_LOADING_UNBLU]{@link UnbluErrorType.ERROR_LOADING_UNBLU}\n * - The initialization timed out: [INITIALIZATION_TIMEOUT]{@link UnbluErrorType.INITIALIZATION_TIMEOUT}\n * - The Unblu API is incompatible with the Unblu server: [INCOMPATIBLE_UNBLU_VERSION]{@link UnbluErrorType.INCOMPATIBLE_UNBLU_VERSION}\n * - The browser is unsupported: [UNSUPPORTED_BROWSER]{@link UnbluErrorType.UNSUPPORTED_BROWSER}\n */\n public async initialize(): Promise {\n if (this.state === ApiState.INITIALIZED) {\n return this.initializedApi;\n } else if (this.state === ApiState.INITIALIZING) {\n return new Promise((resolve, reject) => {\n this.on(UnbluStaticApi.READY, resolve);\n this.on(UnbluStaticApi.ERROR, reject);\n });\n } else {\n return this.initializeApi();\n }\n }\n\n private async initializeApi(): Promise {\n this.state = ApiState.INITIALIZING;\n try {\n if (!UnbluUtil.isUnbluLoaded()) {\n if (!this.configuration) {\n throw new UnbluApiError(UnbluErrorType.CONFIGURATION_MISSING, 'No Unblu snippet present and no configuration provided. Use configure if you want to initialize Unblu without having the Unblu snippet loaded.')\n }\n if (this.configuration.namedArea) {\n UnbluUtil.setNamedArea(this.configuration.namedArea);\n }\n if (this.configuration.locale) {\n UnbluUtil.setLocale(this.configuration.locale);\n }\n await this.injectUnblu(this.configuration);\n }\n let apiBridge = new ApiBridge(UnbluUtil.getUnbluObject());\n await apiBridge.waitUntilLoaded(this.configuration ? this.configuration.initTimeout || 30000 : 30000);\n\n let internalApi = new InternalApi(apiBridge);\n internalApi.checkCompatibility();\n\n // Check internalApi waitUntilInitialized\n await internalApi.meta.waitUntilInitialized();\n\n this.initializedApi = new UnbluApi(internalApi);\n this.state = ApiState.INITIALIZED;\n } catch (e) {\n this.handleError(e);\n }\n\n this.eventEmitter.emit(UnbluStaticApi.READY, this.initializedApi);\n\n return this.initializedApi;\n }\n\n private async injectUnblu(config: Configuration): Promise {\n const serverUrl = config.serverUrl || '';\n const apiKey = config.apiKey || '';\n const unbluPath = config.entryPath || '/unblu';\n let unbluUrl = `${serverUrl}${unbluPath}/visitor.js?x-unblu-apikey=${apiKey}`;\n try {\n await UnbluUtil.loadScript(unbluUrl, config.initTimeout);\n } catch (e) {\n throw new UnbluApiError(UnbluErrorType.ERROR_LOADING_UNBLU, 'Error loading unblu snippet: ' + e + ' check the configuration: ' + config);\n }\n }\n\n private handleError(error: UnbluApiError) {\n this.state = ApiState.ERROR;\n this.eventEmitter.emit(UnbluStaticApi.ERROR, error);\n console.error(error);\n throw error;\n }\n\n\n}","import {InternalApi} from './internal/internal-api';\nimport {GeneralEventType} from './internal/module/general-module';\nimport {Event, EventCallback} from './internal/event';\nimport {EventEmitter, Listener} from './internal/util/event-emitter';\nimport {UnbluApiError, UnbluErrorType} from './unblu-api-error';\nimport {IndividualUiState} from './model/individualui_state';\n\n/**\n * Listener called whenever the UI state changes.\n * @param uistate The new UI state.\n */\nexport type UiStateChangeListener = (uistate: IndividualUiState) => void;\n\n/**\n * This class allows controlling of the UI state and the Unblu individual UI.\n */\nexport class UnbluUiApi {\n\n private internalListeners: { [key: string]: EventCallback } = {};\n private eventEmitter = new EventEmitter();\n\n /**\n * Event emitted every time the state of the individual UI is changed.\n *\n * @event uiStateChange\n * @see [[on]] for listener registration\n * @see [[UiStateChangeListener]]\n */\n public static readonly UI_STATE_CHANGE: 'uiStateChange' = 'uiStateChange';\n\n\n /**\n * @hidden\n */\n constructor(private internalApi: InternalApi) {\n internalApi.meta.on('upgraded', () => this.onUpgraded());\n }\n\n /**\n * Registers an event listener for the given event.\n * @param event The uistateChange event.\n * @param listener The listener to be called.\n * @see [[UI_STATE_CHANGE]]\n */\n public on(event: typeof UnbluUiApi.UI_STATE_CHANGE, listener: UiStateChangeListener): void;\n\n public on(event: GeneralEventType, listener: Listener): void {\n const needsInternalSubscription = !this.eventEmitter.hasListeners(event);\n this.eventEmitter.on(event, listener);\n if (needsInternalSubscription)\n this.onInternal(event).catch(e => console.warn('Error registering internal listener for event:', event, 'error:' + e, e));\n }\n\n /**\n * Removes a previously registered listener\n * @param event The event to unregister from.\n * @param listener The listener to remove.\n */\n public off(event: GeneralEventType, listener: Listener): boolean {\n const removed = this.eventEmitter.off(event, listener);\n if (!this.eventEmitter.hasListeners(event))\n this.offInternal(event).catch(e => console.warn('Error removing internal listener for event:', event, 'error:' + e, e));\n return removed;\n }\n\n\n private async onInternal(eventName: GeneralEventType) {\n let internalListener: EventCallback;\n switch (eventName) {\n case UnbluUiApi.UI_STATE_CHANGE:\n internalListener = (event: Event) => {\n this.eventEmitter.emit(event.name, event.data);\n };\n break;\n default:\n throw new UnbluApiError(UnbluErrorType.INVALID_FUNCTION_ARGUMENTS, 'Registration to unknown event:' + eventName);\n }\n\n if (await this.internalApi.meta.isUpgraded()) {\n this.internalListeners[eventName] = internalListener;\n try {\n await this.internalApi.general.on(eventName, internalListener);\n } catch (e) {\n delete this.internalListeners[eventName];\n throw e;\n }\n }\n }\n\n private async offInternal(eventName: GeneralEventType) {\n const listener = this.internalListeners[eventName];\n if (listener == null) {\n return;\n }\n delete this.internalListeners[eventName];\n await this.internalApi.general.off(eventName, listener);\n }\n\n\n /**\n * Opens the individual UI if it is collapsed and collapses it if it is open.\n */\n public async toggleIndividualUi(): Promise {\n await this.requireUpgrade();\n await this.internalApi.general.toggleIndividualUi();\n }\n\n /**\n * Navigates the individual UI to the PIN entry UI.\n *\n * **NOTE:** calling this method will NOT automatically open the Unblu UI if it is collapsed. Use [[openIndividualUi]] if this is needed.\n */\n public async openPinEntryUi(): Promise {\n await this.requireUpgrade();\n await this.internalApi.general.openPinEntryUi();\n }\n\n\n /**\n * Pop-out the individual UI into a separate window.\n *\n * **NOTE:** this has to be called in a click-event in order to be able to open the pop-up window without being blocked by the browser!\n */\n public async popoutIndividualUi(): Promise {\n await this.requireUpgrade();\n await this.internalApi.general.popoutIndividualUi();\n }\n\n /**\n * Pop-in the individual UI when it is in [POPPED_OUT]{@link IndividualUiState.POPPED_OUT} state.\n *\n * The pop-out window will automatically close and the individual UI will be displayed in the original window again.\n */\n public async popinIndividualUi(): Promise {\n await this.requireUpgrade();\n await this.internalApi.general.popinIndividualUi();\n }\n\n /**\n * Maximize the individual UI - Does nothing if it is already maximized or popped out.\n */\n public async maximizeIndividualUi(): Promise {\n await this.requireUpgrade();\n await this.internalApi.general.maximizeIndividualUi();\n }\n\n /**\n * Minimize the individual UI - Does nothing if it is already minimized.\n */\n public async minimizeIndividualUi(): Promise {\n await this.requireUpgrade();\n await this.internalApi.general.minimizeIndividualUi();\n }\n\n /**\n * Opens the individual UI if it was collapsed. - Does nothing if it was already open.\n */\n public async openIndividualUi(): Promise {\n await this.requireUpgrade();\n await this.internalApi.general.openIndividualUi();\n }\n\n /**\n * Collapses the individual UI if it was open. - Does nothing if it was already collapsed.\n */\n public async collapseIndividualUi(): Promise {\n await this.requireUpgrade();\n await this.internalApi.general.collapseIndividualUi();\n }\n\n /**\n * Get the state of the individual UI.\n * @return A promise that resolves to the [[IndividualUiState]] of the individual UI.\n */\n public async getIndividualUiState(): Promise {\n await this.requireUpgrade();\n return await this.internalApi.general.getIndividualUiState();\n }\n\n private async requireUpgrade(): Promise {\n await this.internalApi.meta.upgrade(false);\n }\n\n private onUpgraded() {\n for (let event of this.eventEmitter.getEventsWithListeners()) {\n // register internal listeners for all events that need upgrade.\n if (!this.internalListeners[event])\n this.onInternal(event as GeneralEventType);\n }\n }\n}","import {EventCallback} from './event';\nimport {UnbluApiError, UnbluErrorType} from '../unblu-api-error';\nimport {\n CATEGORY_ACTION_NOT_GRANTED,\n CATEGORY_EXECUTION_EXCEPTION,\n CATEGORY_INVALID_FUNCTION_ARGUMENTS,\n CATEGORY_INVALID_FUNCTION_CALL\n} from './java-error-codes';\n\n\nconst SUPPORTED_MAJOR_VERSION = 2;\n\ninterface ApiConsumer {\n onUnbluEvent(event: Event): Promise;\n}\n\ninterface CollabServerInternalApi {\n getApiVersion(): string;\n\n execute(moduleName: string, functionName: string, args: any[]): Promise;\n\n registerEventListener(moduleName: string, eventName: string, listener: EventCallback): Promise;\n\n removeEventListener(moduleName: string, eventName: string, listener: EventCallback): Promise;\n}\n\nexport class ApiBridge {\n private internal: CollabServerInternalApi;\n private readonly eventHandler: ApiConsumer;\n\n /**\n * instantiates the bridge that links the UNBLU internal API provided by the collaboration server with the UNBLU JS-API\n * @param mountPoint the global unblu object under which the internal API is registered.\n */\n constructor(private mountPoint: any) {\n }\n\n public async waitUntilLoaded(timeout: number, promise?: Promise): Promise {\n const timeoutTimestamp = Date.now() + timeout;\n return new Promise((resolve, reject) => {\n const waitForLoaded = () => {\n if (timeoutTimestamp - Date.now() > 0) {\n if (this.checkLoaded()) return resolve();\n setTimeout(waitForLoaded, 50);\n } else {\n reject(new UnbluApiError(UnbluErrorType.INITIALIZATION_TIMEOUT, 'Timeout while waiting for collaboration server API to be loaded.'));\n }\n };\n waitForLoaded();\n });\n }\n\n private checkLoaded(): boolean {\n this.internal = this.mountPoint['internal'];\n return this.internal != null;\n }\n\n\n public checkCompatibility(): void {\n if (!this.internal) {\n throw new UnbluApiError(UnbluErrorType.INCOMPATIBLE_UNBLU_VERSION, 'Incompatible unblu collaboration server, no API bridge provided.');\n } else if (typeof this.internal.getApiVersion !== 'function') {\n throw new UnbluApiError(UnbluErrorType.INCOMPATIBLE_UNBLU_VERSION, 'Incompatible unblu collaboration server, incompatible API bridge.');\n }\n const version = this.internal.getApiVersion();\n if (+version[0] != SUPPORTED_MAJOR_VERSION) {\n throw new UnbluApiError(UnbluErrorType.INCOMPATIBLE_UNBLU_VERSION, `Incompatible collaboration server version. \n Supported API version: ${SUPPORTED_MAJOR_VERSION}.x.x.\n collaboration server API version: ${version}.`);\n }\n }\n\n\n /**\n * Calls an API function of the internal unblu collaboration server API.\n * @param moduleName The module to which the function belongs.\n * @param functionName The function to call.\n * @param args The arguments to pass to the function.\n */\n public async callApiFunction(moduleName: string, functionName: string, args: any[]): Promise {\n try {\n return await this.internal.execute(moduleName, functionName, args);\n } catch (e) {\n switch (e.type) {\n case CATEGORY_INVALID_FUNCTION_CALL:\n throw new UnbluApiError(UnbluErrorType.INVALID_FUNCTION_CALL, e.message);\n case CATEGORY_INVALID_FUNCTION_ARGUMENTS:\n throw new UnbluApiError(UnbluErrorType.INVALID_FUNCTION_ARGUMENTS, e.message);\n case CATEGORY_ACTION_NOT_GRANTED:\n throw new UnbluApiError(UnbluErrorType.ACTION_NOT_GRANTED, e.message);\n case CATEGORY_EXECUTION_EXCEPTION:\n throw new UnbluApiError(UnbluErrorType.EXECUTION_EXCEPTION, e.message);\n default:\n throw new UnbluApiError(UnbluErrorType.EXECUTION_EXCEPTION, '' + e);\n }\n }\n }\n\n /**\n * Registers a callback for an event emitted by the internal unblu collaboration server API.\n * @param module The module that emits the event.\n * @param event The event name.\n * @param callback The callback which will be called every time the event is emitted.\n */\n public on(module: string, event: string, callback: EventCallback): Promise {\n return this.internal.registerEventListener(module, event, callback);\n }\n\n /**\n * Unregisters a callback for an event emitted by the internal unblu collaboration server API.\n * @param module The module that emits the event.\n * @param event The event name.\n * @param callback Optionally callback which will be removed, if none is provided all listeners of the event will be removed.\n */\n public off(module: string, event: string, callback?: EventCallback): Promise {\n return this.internal.removeEventListener(module, event, callback);\n }\n\n}","export const CATEGORY_INVALID_FUNCTION_CALL = 1;\nexport const CATEGORY_INVALID_FUNCTION_ARGUMENTS = 2;\nexport const CATEGORY_EXECUTION_EXCEPTION = 3;\nexport const CATEGORY_ACTION_NOT_GRANTED = 4;","import {ApiBridge} from './api-bridge';\nimport {MetaModule} from './module/meta-module';\nimport {GeneralModule} from './module/general-module';\nimport {GeneralLazyModule} from './module/general-lazy-module';\nimport {ConversationModule} from './module/conversation-module';\nimport {AgentAvailabilityModule} from './module/agent-availability-module';\n\nexport class InternalApi {\n public meta: MetaModule;\n public general: GeneralModule;\n public generalLazy: GeneralLazyModule;\n public conversation: ConversationModule;\n public agentAvailability: AgentAvailabilityModule;\n\n constructor(private bridge: ApiBridge) {\n this.meta = new MetaModule(bridge);\n this.general = new GeneralModule(bridge);\n this.generalLazy = new GeneralLazyModule(bridge);\n this.conversation = new ConversationModule(bridge);\n this.agentAvailability = new AgentAvailabilityModule(bridge);\n }\n\n public checkCompatibility(): void {\n this.bridge.checkCompatibility();\n }\n}","import {InternalModule} from './module';\nimport {ApiBridge} from '../api-bridge';\n\nexport type MetaEventType = 'upgraded';\n\nconst enum MetaFunction {\n isUpgraded = 'isUpgraded',\n upgrade = 'upgrade',\n waitUntilInitialized = 'waitUntilInitialized'\n}\n\nexport class MetaModule extends InternalModule {\n constructor(bridge: ApiBridge) {\n super(bridge, 'meta');\n }\n\n public isUpgraded(): Promise {\n return this.callApiFunction(MetaFunction.isUpgraded, []);\n }\n\n public upgrade(openUi?: boolean): Promise {\n return this.callApiFunction(MetaFunction.upgrade, [openUi]);\n }\n\n public waitUntilInitialized(): Promise {\n return this.callApiFunction(MetaFunction.waitUntilInitialized, []);\n }\n}","import {InternalModule} from './module';\nimport {ApiBridge} from '../api-bridge';\nimport {PersonInfo} from '../../model/person-info';\nimport {ConversationType} from '../../model/conversation-type';\nimport {IndividualUiState} from '../../model/individualui_state';\nimport {NewConversationInterceptor} from \"../../unblu-api\";\n\nexport type GeneralEventType =\n 'activeConversationChange' |\n 'notificationCountChange' |\n 'personChange' |\n 'uiStateChange';\n\nconst enum GeneralFunction {\n startConversation = 'startConversation',\n setNewConversationInterceptor = 'setNewConversationInterceptor',\n joinConversation = 'joinConversation',\n openConversation = 'openConversation',\n toggleIndividualUi = 'toggleIndividualUi',\n popoutIndividualUi = 'popoutIndividualUi',\n popinIndividualUi = 'popinIndividualUi',\n maximizeIndividualUi = 'maximizeIndividualUi',\n minimizeIndividualUi = 'minimizeIndividualUi',\n openIndividualUi = 'openIndividualUi',\n openPinEntryUi = 'openPinEntryUi',\n collapseIndividualUi = 'collapseIndividualUi',\n getIndividualUiState = 'getIndividualUiState',\n getActiveConversation = 'getActiveConversation',\n getNotificationCount = 'getNotificationCount',\n getPersonInfo = 'getPersonInfo',\n setPersonNickname = 'setPersonNickname'\n}\n\nexport class GeneralModule extends InternalModule {\n constructor(bridge: ApiBridge) {\n super(bridge, 'general');\n }\n\n public startConversation(type: ConversationType, visitorName?: string, visitorData?: string): Promise {\n return this.callApiFunction(GeneralFunction.startConversation, [type, visitorName, visitorData]);\n }\n\n public setNewConversationInterceptor(callback: NewConversationInterceptor): Promise {\n return this.callApiFunction(GeneralFunction.setNewConversationInterceptor, [callback]);\n }\n\n public joinConversation(pin: string, visitorName?: string): Promise {\n return this.callApiFunction(GeneralFunction.joinConversation, [pin, visitorName]);\n }\n\n public openConversation(conversationId: string): Promise {\n return this.callApiFunction(GeneralFunction.openConversation, [conversationId]);\n }\n\n public toggleIndividualUi(): Promise {\n return this.callApiFunction(GeneralFunction.toggleIndividualUi, []);\n }\n\n public openPinEntryUi(): Promise {\n return this.callApiFunction(GeneralFunction.openPinEntryUi, []);\n }\n\n public popoutIndividualUi(): Promise {\n return this.callApiFunction(GeneralFunction.popoutIndividualUi, []);\n }\n\n public popinIndividualUi(): Promise {\n return this.callApiFunction(GeneralFunction.popinIndividualUi, []);\n }\n\n public maximizeIndividualUi(): Promise {\n return this.callApiFunction(GeneralFunction.maximizeIndividualUi, []);\n }\n\n public minimizeIndividualUi(): Promise {\n return this.callApiFunction(GeneralFunction.minimizeIndividualUi, []);\n }\n\n public openIndividualUi(): Promise {\n return this.callApiFunction(GeneralFunction.openIndividualUi, []);\n }\n\n public collapseIndividualUi(): Promise {\n return this.callApiFunction(GeneralFunction.collapseIndividualUi, []);\n }\n\n public getIndividualUiState(): Promise {\n return this.callApiFunction(GeneralFunction.getIndividualUiState, []); \n }\n\n public getActiveConversation(): Promise {\n return this.callApiFunction(GeneralFunction.getActiveConversation, []);\n }\n\n public getNotificationCount(): Promise {\n return this.callApiFunction(GeneralFunction.getNotificationCount, []);\n }\n\n public getPersonInfo(): Promise {\n return this.callApiFunction(GeneralFunction.getPersonInfo, []);\n }\n\n public setPersonNickname(nickname: string): Promise {\n return this.callApiFunction(GeneralFunction.setPersonNickname, [nickname]);\n }\n}","import {InternalModule} from './module';\nimport {ApiBridge} from '../api-bridge';\nimport {PersonInfo} from '../../model/person-info';\nimport {NewConversationInterceptor} from \"../../unblu-api\";\n\n\nexport type GeneralLazyEventType = '';\n\nconst enum GeneralLazyFunction {\n getNotificationCount = 'getNotificationCount',\n getPersonInfo = 'getPersonInfo',\n setNewConversationInterceptor = 'setNewConversationInterceptor',\n}\n\nexport class GeneralLazyModule extends InternalModule {\n constructor(bridge: ApiBridge) {\n super(bridge, 'generallazy');\n }\n\n public getNotificationCount(): Promise {\n return this.callApiFunction(GeneralLazyFunction.getNotificationCount, []);\n }\n\n public getPersonInfo(): Promise {\n return this.callApiFunction(GeneralLazyFunction.getPersonInfo, []);\n }\n\n public setNewConversationInterceptor(callback: NewConversationInterceptor): Promise {\n return this.callApiFunction(GeneralLazyFunction.setNewConversationInterceptor, [callback]);\n }\n}","import {InternalModule} from './module';\nimport {ApiBridge} from '../api-bridge';\nimport {CallState} from '../../model/call-state';\nimport {ConversationState} from '../../model/conversation-state';\nimport {ConnectionState} from '../../model/connection-state';\nimport {Invitation} from \"../../model/invitation\";\n\n\nexport interface ConversationCallState {\n conversationId: string\n callState: CallState\n}\n\nexport interface ConversationConnectionState {\n conversationId: string\n connectionState: ConnectionState\n}\n\nexport interface ConversationWithState {\n conversationId: string\n conversationState: ConversationState\n}\n\nexport interface ConversationInvitations {\n conversationId: string\n invitations: Invitation[]\n}\n\nexport type ConversationEventType =\n 'connectionStateChange' |\n 'conversationStateChange' |\n 'end' |\n 'close' |\n 'personChange' |\n 'callStateChange' |\n 'invitationsChange'\n\nconst enum ConversationFunction {\n getConnectionState = 'getConnectionState',\n getConversationState = 'getConversationState',\n getCallState = 'getCallState',\n startAudioCall = 'startAudioCall',\n startVideoCall = 'startVideoCall',\n endConversation = 'endConversation',\n leaveConversation = 'leaveConversation',\n closeConversation = 'closeConversation',\n createAnonymousPinInvitation = 'createAnonymousPinInvitation',\n createAnonymousEmailInvitation = 'createAnonymousEmailInvitation',\n getInvitations = 'getInvitations',\n revokeInvitation = 'revokeInvitation',\n renewInvitationPin = 'renewInvitationPin'\n}\n\nexport class ConversationModule extends InternalModule {\n constructor(bridge: ApiBridge) {\n super(bridge, 'conversation');\n }\n\n public getConnectionState(conversationId: string): Promise {\n return this.callApiFunction(ConversationFunction.getConnectionState, [conversationId]);\n }\n\n public getConversationState(conversationId: string): Promise {\n return this.callApiFunction(ConversationFunction.getConversationState, [conversationId]);\n }\n\n public getCallState(conversationId: string): Promise {\n return this.callApiFunction(ConversationFunction.getCallState, [conversationId]);\n }\n\n public startAudioCall(conversationId: string): Promise {\n return this.callApiFunction(ConversationFunction.startAudioCall, [conversationId]);\n }\n\n public startVideoCall(conversationId: string): Promise {\n return this.callApiFunction(ConversationFunction.startVideoCall, [conversationId]);\n }\n\n public endConversation(conversationId: string): Promise {\n return this.callApiFunction(ConversationFunction.endConversation, [conversationId]);\n }\n\n public leaveConversation(conversationId: string): Promise {\n return this.callApiFunction(ConversationFunction.leaveConversation, [conversationId]);\n }\n\n public closeConversation(conversationId: string): Promise {\n return this.callApiFunction(ConversationFunction.closeConversation, [conversationId]);\n }\n\n public createAnonymousPinInvitation(conversationId: string): Promise {\n return this.callApiFunction(ConversationFunction.createAnonymousPinInvitation, [conversationId]);\n }\n\n public createAnonymousEmailInvitation(conversationId: string, email: String) : Promise {\n return this.callApiFunction(ConversationFunction.createAnonymousEmailInvitation, [conversationId, email]);\n }\n\n public async getInvitations(conversationId: string): Promise {\n return this.callApiFunction(ConversationFunction.getInvitations, [conversationId]);\n }\n\n public async revokeInvitation(conversationId: string, invitationId: String) : Promise {\n return this.callApiFunction(ConversationFunction.revokeInvitation, [conversationId, invitationId]);\n }\n\n public async renewInvitationPin(conversationId: string, invitationId: String) : Promise {\n return this.callApiFunction(ConversationFunction.renewInvitationPin, [conversationId, invitationId]);\n }\n}","import {InternalModule} from './module';\nimport {ApiBridge} from '../api-bridge';\nimport {AgentAvailabilityState} from '../../model/agent-availability-state';\n\n\nexport type AgentAvailabilityEventType = 'availabilityChange';\n\nconst enum AgentAvailabilityFunction {\n isAgentAvailable = 'isAgentAvailable',\n getAgentAvailabilityState = 'getAgentAvailabilityState'\n}\n\nexport class AgentAvailabilityModule extends InternalModule {\n constructor(bridge: ApiBridge) {\n super(bridge, 'agentavailability');\n }\n\n public isAgentAvailable(): Promise {\n return this.callApiFunction(AgentAvailabilityFunction.isAgentAvailable, []);\n }\n\n public getAgentAvailabilityState(): Promise {\n return this.callApiFunction(AgentAvailabilityFunction.getAgentAvailabilityState, []);\n }\n}","export enum CallState {\n /**\n * A some one is trying to call, the phone is ringing\n */\n INBOUND = 'INBOUND',\n /**\n * You are trying to call someone\n */\n OUTBOUND = 'OUTBOUND',\n /**\n * A call is active and the local tab is connected to the call.\n */\n ACTIVE_JOINED = 'ACTIVE_JOINED',\n /**\n * A call is active but the local person has declined it.\n */\n ACTIVE_NOT_JOINED = 'ACTIVE_NOT_JOINED',\n /**\n * A call is active and the local person has joined it on an other device.\n */\n ACTIVE_JOINED_ELSEWHERE = 'ACTIVE_JOINED_ELSEWHERE',\n /**\n * No inbound, outgoing or active call.\n */\n NONE = 'NONE'\n}\n\n","export enum ConnectionState {\n /**\n * Initial state before connection establishment has started\n */\n INITIAL = 'INITIAL',\n\n /**\n * State during the first connection to the server\n */\n CONNECTING = 'CONNECTING',\n\n /**\n * The connection has been successfully established.\n */\n CONNECTED = 'CONNECTED',\n\n /**\n * The connection has been lost, reconnect is active.\n */\n RECONNECTING = 'RECONNECTING',\n\n /**\n * The connection has been successfully closed.\n *\n */\n CLOSED = 'CLOSED',\n\n /**\n * A fatal error has occurred. The connection has been permanently lost. No reconnect will be be possible.\n */\n ERROR = 'ERROR'\n}\n\n","export enum ConversationType {\n /**\n * (Visitor initiated, visitor centered) A visitor creates an incoming chat conversation.\n */\n CHAT_REQUEST = 'CHAT_REQUEST',\n /**\n * (Visitor initiated, visitor centered) A visitor creates an incoming chat conversation while all agents are offline.\n */\n OFFLINE_CHAT_REQUEST = 'OFFLINE_CHAT_REQUEST',\n /**\n * (Visitor initiated, visitor centered) A visitor creates an incoming video conversation.\n */\n VIDEO_REQUEST = 'VIDEO_REQUEST',\n /**\n * (Visitor initiated, visitor centered) A visitor creates an incoming audio conversation.\n */\n AUDIO_REQUEST = 'AUDIO_REQUEST',\n /**\n * (Visitor initiated, visitor centered) A visitor creates an incoming universal co-browsing conversation.\n */\n HEADLESS_BROWSER_REQUEST = 'HEADLESS_BROWSER_REQUEST',\n /**\n * (Visitor initiated, visitor centered) A visitor creates an incoming embedded co-browsing conversation.\n */\n DOMCAP_BROWSER_REQUEST = 'DOMCAP_BROWSER_REQUEST',\n /**\n * (Visitor initiated, visitor centered) A visitor creates an incoming mobile co-browsing conversation.\n */\n MOBILE_COBROWSING_REQUEST = 'MOBILE_COBROWSING_REQUEST',\n /**\n * (Visitor initiated, visitor centered) A visitor creates an incoming screen sharing conversation.\n */\n SCREEN_SHARING_REQUEST = 'SCREEN_SHARING_REQUEST',\n\t/**\n\t * (Api initiated, visitor centered) A visitor creates a conversation via API which is not added to the queue and where he can invite other visitor to do\n\t * embedded\n\t */\n\tVISITOR_COBROWSING = 'VISITOR_COBROWSING'\n}","export enum AgentAvailabilityState {\n /**\n * There is at least one agent available for the specified named area and language.\n */\n AVAILABLE = 'AVAILABLE',\n /**\n * There is at least one agent watching the inbound queue for the specified named area and language but the max capacity of parallel conversations is reached.\n *\n * It is very likely, that an agent will be available in a short time.\n */\n BUSY = 'BUSY',\n /**\n * There is no agent watching the inbound queue for the specified named area and language.\n *\n * It is unlikely, that an agent will be available in a short time.\n */\n UNAVAILABLE = 'UNAVAILABLE',\n /**\n * There is currently no agent handling any inbound queue items.\n *\n * It is very unlikely, that an agent will be available in a short time.\n */\n OFFLINE = 'OFFLINE'\n}","export enum ConversationState {\n /**\n * Initial state of a conversation\n */\n CREATED = 'CREATED',\n\n /**\n * Depending of the engagement type of the conversation, the conversation stays in the onboarding state as long as the person in the center of the conversation\n * is doing his onboarding\n */\n ONBOARDING = 'ONBOARDING',\n\n /**\n * When a message is send to an unassigned conversation, the conversation first is put into the reboarding state as long as the person in the center of the\n * conversation is doing the reboarding.\n */\n REBOARDING = 'REBOARDING',\n\n /**\n * Depending of the engagement type of the conversation, the conversation is put in the queued state when it is inside the queue.\n */\n QUEUED = 'QUEUED',\n\n /**\n * Conversation is active\n */\n ACTIVE = 'ACTIVE',\n\n /**\n * After there is no assignee of a conversation anymore, the conversation goes to unassigned state until a message from a visitor is written to start reboarding\n * again.\n */\n UNASSIGNED = 'UNASSIGNED',\n\n /**\n * Conversation is being ended\n */\n OFFBOARDING = 'OFFBOARDING',\n\n /**\n * Conversation is ended\n */\n ENDED = 'ENDED'\n}"],"sourceRoot":""}