{"version":3,"sources":["node_modules/@vendasta/address/fesm2020/vendasta-address.mjs","libs/conversation/core/src/lib/conversation.constants.ts","libs/conversation/core/src/lib/inbox-utils.ts","libs/conversation/core/src/lib/inbox.constants.ts","libs/conversation/core/src/lib/participant-utils.ts","libs/conversation/core/src/lib/participant.service.ts","libs/conversation/core/src/lib/inbox.service.ts"],"sourcesContent":["import * as i0 from '@angular/core';\nimport { Injectable } from '@angular/core';\nimport * as i1 from '@angular/common/http';\nimport { HttpHeaders } from '@angular/common/http';\nimport { map } from 'rxjs/operators';\nclass CountryConfiguration {\n static fromProto(proto) {\n let m = new CountryConfiguration();\n m = Object.assign(m, proto);\n if (proto.phoneNumberPrefix) {\n m.phoneNumberPrefix = parseInt(proto.phoneNumberPrefix, 10);\n }\n if (proto.formatting) {\n m.formatting = CountryConfigurationFormatting.fromProto(proto.formatting);\n }\n if (proto.labels) {\n m.labels = CountryConfigurationLabels.fromProto(proto.labels);\n }\n if (proto.zones) {\n m.zones = proto.zones.map(CountryConfigurationZone.fromProto);\n }\n return m;\n }\n constructor(kwargs) {\n if (!kwargs) {\n return;\n }\n Object.assign(this, kwargs);\n }\n toApiJson() {\n const toReturn = {};\n if (typeof this.code !== 'undefined') {\n toReturn['code'] = this.code;\n }\n if (typeof this.continent !== 'undefined') {\n toReturn['continent'] = this.continent;\n }\n if (typeof this.name !== 'undefined') {\n toReturn['name'] = this.name;\n }\n if (typeof this.phoneNumberPrefix !== 'undefined') {\n toReturn['phoneNumberPrefix'] = this.phoneNumberPrefix;\n }\n if (typeof this.formatting !== 'undefined' && this.formatting !== null) {\n toReturn['formatting'] = 'toApiJson' in this.formatting ? this.formatting.toApiJson() : this.formatting;\n }\n if (typeof this.labels !== 'undefined' && this.labels !== null) {\n toReturn['labels'] = 'toApiJson' in this.labels ? this.labels.toApiJson() : this.labels;\n }\n if (typeof this.zones !== 'undefined' && this.zones !== null) {\n toReturn['zones'] = 'toApiJson' in this.zones ? this.zones.toApiJson() : this.zones;\n }\n if (typeof this.locale !== 'undefined') {\n toReturn['locale'] = this.locale;\n }\n return toReturn;\n }\n}\nclass CountryOption {\n static fromProto(proto) {\n let m = new CountryOption();\n m = Object.assign(m, proto);\n return m;\n }\n constructor(kwargs) {\n if (!kwargs) {\n return;\n }\n Object.assign(this, kwargs);\n }\n toApiJson() {\n const toReturn = {};\n if (typeof this.code !== 'undefined') {\n toReturn['code'] = this.code;\n }\n if (typeof this.name !== 'undefined') {\n toReturn['name'] = this.name;\n }\n return toReturn;\n }\n}\nclass CountryConfigurationFormatting {\n static fromProto(proto) {\n let m = new CountryConfigurationFormatting();\n m = Object.assign(m, proto);\n return m;\n }\n constructor(kwargs) {\n if (!kwargs) {\n return;\n }\n Object.assign(this, kwargs);\n }\n toApiJson() {\n const toReturn = {};\n if (typeof this.show !== 'undefined') {\n toReturn['show'] = this.show;\n }\n if (typeof this.edit !== 'undefined') {\n toReturn['edit'] = this.edit;\n }\n if (typeof this.required !== 'undefined') {\n toReturn['required'] = this.required;\n }\n return toReturn;\n }\n}\nclass CountryConfigurationLabels {\n static fromProto(proto) {\n let m = new CountryConfigurationLabels();\n m = Object.assign(m, proto);\n return m;\n }\n constructor(kwargs) {\n if (!kwargs) {\n return;\n }\n Object.assign(this, kwargs);\n }\n toApiJson() {\n const toReturn = {};\n if (typeof this.address1 !== 'undefined') {\n toReturn['address1'] = this.address1;\n }\n if (typeof this.address2 !== 'undefined') {\n toReturn['address2'] = this.address2;\n }\n if (typeof this.city !== 'undefined') {\n toReturn['city'] = this.city;\n }\n if (typeof this.company !== 'undefined') {\n toReturn['company'] = this.company;\n }\n if (typeof this.country !== 'undefined') {\n toReturn['country'] = this.country;\n }\n if (typeof this.firstName !== 'undefined') {\n toReturn['firstName'] = this.firstName;\n }\n if (typeof this.lastName !== 'undefined') {\n toReturn['lastName'] = this.lastName;\n }\n if (typeof this.phone !== 'undefined') {\n toReturn['phone'] = this.phone;\n }\n if (typeof this.postalCode !== 'undefined') {\n toReturn['postalCode'] = this.postalCode;\n }\n if (typeof this.zone !== 'undefined') {\n toReturn['zone'] = this.zone;\n }\n return toReturn;\n }\n}\nclass CountryConfigurationZone {\n static fromProto(proto) {\n let m = new CountryConfigurationZone();\n m = Object.assign(m, proto);\n return m;\n }\n constructor(kwargs) {\n if (!kwargs) {\n return;\n }\n Object.assign(this, kwargs);\n }\n toApiJson() {\n const toReturn = {};\n if (typeof this.code !== 'undefined') {\n toReturn['code'] = this.code;\n }\n if (typeof this.name !== 'undefined') {\n toReturn['name'] = this.name;\n }\n return toReturn;\n }\n}\nclass DeleteLocalizedZoneRequest {\n static fromProto(proto) {\n let m = new DeleteLocalizedZoneRequest();\n m = Object.assign(m, proto);\n return m;\n }\n constructor(kwargs) {\n if (!kwargs) {\n return;\n }\n Object.assign(this, kwargs);\n }\n toApiJson() {\n const toReturn = {};\n if (typeof this.locale !== 'undefined') {\n toReturn['locale'] = this.locale;\n }\n if (typeof this.countryCode !== 'undefined') {\n toReturn['countryCode'] = this.countryCode;\n }\n if (typeof this.zoneCode !== 'undefined') {\n toReturn['zoneCode'] = this.zoneCode;\n }\n return toReturn;\n }\n}\nclass GetCountryConfigurationRequest {\n static fromProto(proto) {\n let m = new GetCountryConfigurationRequest();\n m = Object.assign(m, proto);\n return m;\n }\n constructor(kwargs) {\n if (!kwargs) {\n return;\n }\n Object.assign(this, kwargs);\n }\n toApiJson() {\n const toReturn = {};\n if (typeof this.countryCode !== 'undefined') {\n toReturn['countryCode'] = this.countryCode;\n }\n if (typeof this.locale !== 'undefined') {\n toReturn['locale'] = this.locale;\n }\n return toReturn;\n }\n}\nclass GetCountryConfigurationResponse {\n static fromProto(proto) {\n let m = new GetCountryConfigurationResponse();\n m = Object.assign(m, proto);\n if (proto.country) {\n m.country = CountryConfiguration.fromProto(proto.country);\n }\n return m;\n }\n constructor(kwargs) {\n if (!kwargs) {\n return;\n }\n Object.assign(this, kwargs);\n }\n toApiJson() {\n const toReturn = {};\n if (typeof this.country !== 'undefined' && this.country !== null) {\n toReturn['country'] = 'toApiJson' in this.country ? this.country.toApiJson() : this.country;\n }\n return toReturn;\n }\n}\nclass ListAllCountryOptionsRequest {\n static fromProto(proto) {\n let m = new ListAllCountryOptionsRequest();\n m = Object.assign(m, proto);\n return m;\n }\n constructor(kwargs) {\n if (!kwargs) {\n return;\n }\n Object.assign(this, kwargs);\n }\n toApiJson() {\n const toReturn = {};\n if (typeof this.locale !== 'undefined') {\n toReturn['locale'] = this.locale;\n }\n return toReturn;\n }\n}\nclass ListAllCountryOptionsResponse {\n static fromProto(proto) {\n let m = new ListAllCountryOptionsResponse();\n m = Object.assign(m, proto);\n if (proto.countryOptions) {\n m.countryOptions = proto.countryOptions.map(CountryOption.fromProto);\n }\n return m;\n }\n constructor(kwargs) {\n if (!kwargs) {\n return;\n }\n Object.assign(this, kwargs);\n }\n toApiJson() {\n const toReturn = {};\n if (typeof this.countryOptions !== 'undefined' && this.countryOptions !== null) {\n toReturn['countryOptions'] = 'toApiJson' in this.countryOptions ? this.countryOptions.toApiJson() : this.countryOptions;\n }\n return toReturn;\n }\n}\nclass ReplaceCountryFormattingRequest {\n static fromProto(proto) {\n let m = new ReplaceCountryFormattingRequest();\n m = Object.assign(m, proto);\n return m;\n }\n constructor(kwargs) {\n if (!kwargs) {\n return;\n }\n Object.assign(this, kwargs);\n }\n toApiJson() {\n const toReturn = {};\n if (typeof this.countryCode !== 'undefined') {\n toReturn['countryCode'] = this.countryCode;\n }\n if (typeof this.showTemplate !== 'undefined') {\n toReturn['showTemplate'] = this.showTemplate;\n }\n if (typeof this.editTemplate !== 'undefined') {\n toReturn['editTemplate'] = this.editTemplate;\n }\n if (typeof this.requiredTemplate !== 'undefined') {\n toReturn['requiredTemplate'] = this.requiredTemplate;\n }\n return toReturn;\n }\n}\nclass ReplaceLocalizedCountryRequest {\n static fromProto(proto) {\n let m = new ReplaceLocalizedCountryRequest();\n m = Object.assign(m, proto);\n if (proto.phoneNumberPrefix) {\n m.phoneNumberPrefix = parseInt(proto.phoneNumberPrefix, 10);\n }\n return m;\n }\n constructor(kwargs) {\n if (!kwargs) {\n return;\n }\n Object.assign(this, kwargs);\n }\n toApiJson() {\n const toReturn = {};\n if (typeof this.locale !== 'undefined') {\n toReturn['locale'] = this.locale;\n }\n if (typeof this.countryCode !== 'undefined') {\n toReturn['countryCode'] = this.countryCode;\n }\n if (typeof this.name !== 'undefined') {\n toReturn['name'] = this.name;\n }\n if (typeof this.continent !== 'undefined') {\n toReturn['continent'] = this.continent;\n }\n if (typeof this.phoneNumberPrefix !== 'undefined') {\n toReturn['phoneNumberPrefix'] = this.phoneNumberPrefix;\n }\n if (typeof this.address1Label !== 'undefined') {\n toReturn['address1Label'] = this.address1Label;\n }\n if (typeof this.address2Label !== 'undefined') {\n toReturn['address2Label'] = this.address2Label;\n }\n if (typeof this.cityLabel !== 'undefined') {\n toReturn['cityLabel'] = this.cityLabel;\n }\n if (typeof this.countryLabel !== 'undefined') {\n toReturn['countryLabel'] = this.countryLabel;\n }\n if (typeof this.companyLabel !== 'undefined') {\n toReturn['companyLabel'] = this.companyLabel;\n }\n if (typeof this.firstNameLabel !== 'undefined') {\n toReturn['firstNameLabel'] = this.firstNameLabel;\n }\n if (typeof this.lastNameLabel !== 'undefined') {\n toReturn['lastNameLabel'] = this.lastNameLabel;\n }\n if (typeof this.phoneNumberLabel !== 'undefined') {\n toReturn['phoneNumberLabel'] = this.phoneNumberLabel;\n }\n if (typeof this.postalCodeLabel !== 'undefined') {\n toReturn['postalCodeLabel'] = this.postalCodeLabel;\n }\n if (typeof this.zoneLabel !== 'undefined') {\n toReturn['zoneLabel'] = this.zoneLabel;\n }\n return toReturn;\n }\n}\nclass ReplaceLocalizedZoneRequest {\n static fromProto(proto) {\n let m = new ReplaceLocalizedZoneRequest();\n m = Object.assign(m, proto);\n return m;\n }\n constructor(kwargs) {\n if (!kwargs) {\n return;\n }\n Object.assign(this, kwargs);\n }\n toApiJson() {\n const toReturn = {};\n if (typeof this.locale !== 'undefined') {\n toReturn['locale'] = this.locale;\n }\n if (typeof this.countryCode !== 'undefined') {\n toReturn['countryCode'] = this.countryCode;\n }\n if (typeof this.zoneCode !== 'undefined') {\n toReturn['zoneCode'] = this.zoneCode;\n }\n if (typeof this.name !== 'undefined') {\n toReturn['name'] = this.name;\n }\n return toReturn;\n }\n}\n\n// *********************************\n// Code generated by sdkgen\n// DO NOT EDIT!.\n//\n// Objects Index.\n// *********************************\n\nconst environment = (window ? window['environment'] : 'prod') ?? 'prod';\nconst hostMap = {\n 'local': 'address-api.vendasta-local.com',\n 'test': '',\n 'demo': 'address-demo.apigateway.co',\n 'prod': 'address-prod.apigateway.co',\n 'production': 'address-prod.apigateway.co'\n};\nlet HostService = /*#__PURE__*/(() => {\n class HostService {\n get host() {\n return hostMap[environment.toLowerCase()];\n }\n get hostWithScheme() {\n return 'https://' + this.host;\n }\n }\n HostService.ɵfac = function HostService_Factory(t) {\n return new (t || HostService)();\n };\n HostService.ɵprov = /* @__PURE__ */i0.ɵɵdefineInjectable({\n token: HostService,\n factory: HostService.ɵfac,\n providedIn: 'root'\n });\n return HostService;\n})();\n(() => {\n (typeof ngDevMode === \"undefined\" || ngDevMode) && void 0;\n})();\n\n// *********************************\n// Code generated by sdkgen\n// DO NOT EDIT!.\n//\n// API Service.\n// *********************************\nlet AddressApiService = /*#__PURE__*/(() => {\n class AddressApiService {\n constructor(http, hostService) {\n this.http = http;\n this.hostService = hostService;\n this._host = this.hostService.hostWithScheme;\n }\n apiOptions() {\n return {\n headers: new HttpHeaders({\n 'Content-Type': 'application/json'\n }),\n withCredentials: true\n };\n }\n getCountryConfiguration(r) {\n const request = r.toApiJson ? r : new GetCountryConfigurationRequest(r);\n return this.http.post(this._host + \"/address.v1.Address/GetCountryConfiguration\", request.toApiJson(), this.apiOptions()).pipe(map(resp => GetCountryConfigurationResponse.fromProto(resp)));\n }\n replaceCountryFormatting(r) {\n const request = r.toApiJson ? r : new ReplaceCountryFormattingRequest(r);\n return this.http.post(this._host + \"/address.v1.Address/ReplaceCountryFormatting\", request.toApiJson(), {\n ...this.apiOptions(),\n observe: 'response'\n });\n }\n replaceLocalizedCountry(r) {\n const request = r.toApiJson ? r : new ReplaceLocalizedCountryRequest(r);\n return this.http.post(this._host + \"/address.v1.Address/ReplaceLocalizedCountry\", request.toApiJson(), {\n ...this.apiOptions(),\n observe: 'response'\n });\n }\n replaceLocalizedZone(r) {\n const request = r.toApiJson ? r : new ReplaceLocalizedZoneRequest(r);\n return this.http.post(this._host + \"/address.v1.Address/ReplaceLocalizedZone\", request.toApiJson(), {\n ...this.apiOptions(),\n observe: 'response'\n });\n }\n deleteLocalizedZone(r) {\n const request = r.toApiJson ? r : new DeleteLocalizedZoneRequest(r);\n return this.http.post(this._host + \"/address.v1.Address/DeleteLocalizedZone\", request.toApiJson(), {\n ...this.apiOptions(),\n observe: 'response'\n });\n }\n listAllCountryOptions(r) {\n const request = r.toApiJson ? r : new ListAllCountryOptionsRequest(r);\n return this.http.post(this._host + \"/address.v1.Address/ListAllCountryOptions\", request.toApiJson(), this.apiOptions()).pipe(map(resp => ListAllCountryOptionsResponse.fromProto(resp)));\n }\n }\n AddressApiService.ɵfac = function AddressApiService_Factory(t) {\n return new (t || AddressApiService)(i0.ɵɵinject(i1.HttpClient), i0.ɵɵinject(HostService));\n };\n AddressApiService.ɵprov = /* @__PURE__ */i0.ɵɵdefineInjectable({\n token: AddressApiService,\n factory: AddressApiService.ɵfac,\n providedIn: 'root'\n });\n return AddressApiService;\n})();\n(() => {\n (typeof ngDevMode === \"undefined\" || ngDevMode) && void 0;\n})();\nlet AddressAPIService = /*#__PURE__*/(() => {\n class AddressAPIService {\n constructor(addressApiService) {\n this.addressApiService = addressApiService;\n }\n getCountryConfiguration(countryCode, locale) {\n const req = new GetCountryConfigurationRequest({\n countryCode: countryCode,\n locale: locale\n });\n return this.addressApiService.getCountryConfiguration(req).pipe(map(resp => resp.country));\n }\n listAllCountryOptions(locale) {\n const req = new ListAllCountryOptionsRequest({\n locale: locale\n });\n return this.addressApiService.listAllCountryOptions(req).pipe(map(resp => resp.countryOptions));\n }\n }\n AddressAPIService.ɵfac = function AddressAPIService_Factory(t) {\n return new (t || AddressAPIService)(i0.ɵɵinject(AddressApiService));\n };\n AddressAPIService.ɵprov = /* @__PURE__ */i0.ɵɵdefineInjectable({\n token: AddressAPIService,\n factory: AddressAPIService.ɵfac,\n providedIn: 'root'\n });\n return AddressAPIService;\n})();\n(() => {\n (typeof ngDevMode === \"undefined\" || ngDevMode) && void 0;\n})();\n\n// *********************************\n// Code generated by sdkgen\n// DO NOT EDIT!.\n//\n// Index.\n// *********************************\n\n/**\n * Generated bundle index. Do not edit.\n */\n\nexport { AddressAPIService, CountryConfiguration, CountryOption };\n","import { Timestamp } from 'firebase/firestore';\nimport { ConversationChannel } from '@vendasta/conversation';\n\nexport const PAGE_SIZE = 20;\nexport const FIRESTORE_MESSAGE_LIMIT = 20;\nexport const FIRESTORE_CONVERSATION_LIMIT = 20;\nexport const INBOX = 'Inbox';\nexport const DELETED_TIMESTAMP_FIRESTORE = new Timestamp(10800, 0);\n// List of United States territories that are excluded from SMS feature\n// [Armed Forces Americas, Armed Forces Europe, Armed Forces Pacific, American Samoa, Micronesia, Guam, Marshall Islands, Northern Mariana Islands, Puerto Rico, Palau, U.S. Virgin Islands]\nexport const MARKETING_SERVICES_PIDS = ['VMKS', 'VMKA', 'VMKW', 'VMKV'];\nexport const SUPPORT_PID = 'VMF';\n\nexport const MAX_FILES = 1;\nexport const MAX_RECORDING_TIME = 60000;\n\nexport const POSTHOG_CHANNEL_NAME = new Map([\n [ConversationChannel.CONVERSATION_CHANNEL_UNDEFINED, 'undefined'],\n [ConversationChannel.CONVERSATION_CHANNEL_INTERNAL, 'platform'],\n [ConversationChannel.CONVERSATION_CHANNEL_SMS, 'sms'],\n [ConversationChannel.CONVERSATION_CHANNEL_FACEBOOK, 'facebook'],\n [ConversationChannel.CONVERSATION_CHANNEL_GOOGLE_MESSAGES, 'google_messages'],\n [ConversationChannel.CONVERSATION_CHANNEL_OPENAI, 'openai'],\n [ConversationChannel.CONVERSATION_CHANNEL_EMAIL, 'email'],\n [ConversationChannel.CONVERSATION_CHANNEL_GOOGLE_BUSINESS_COMMUNICATIONS, 'google_business_communications'],\n [ConversationChannel.CONVERSATION_CHANNEL_WEB_CHAT, 'webchat'],\n [ConversationChannel.CONVERSATION_CHANNEL_INSTAGRAM, 'instagram'],\n]);\n","/**\n * check if the window view port reach out the max width query\n * @return {boolean}\n */\nexport function isMobile(): boolean {\n return window.matchMedia('(max-width:600px)').matches;\n}\n\n/**\n * check if the window view port reach out the max width query\n * @return {boolean}\n */\nexport function isWideScreen(): boolean {\n return window.matchMedia('(max-width:1440px)').matches;\n}\n","import { Environment } from '@galaxy/core';\nexport const IAMUserPrefix = 'U-'; // Unified User ID\nexport const AccountGroupPrefix = 'AG-';\n\nexport const CustomerPrefix = 'CUSTOMER-';\nexport const ContactPrefix = 'CONTACT-';\n\nexport const PCLearnMoreUrl = 'https://support.vendasta.com/hc/en-us/articles/6926511028887/';\n\nexport const GOOGLE_SOURCE_ID = '10010';\nexport const FACEBOOK_SOURCE_ID = '10050';\n\nexport const LOCAL_STORAGE_ID = 'inbox-last-channel-id';\n\nexport const EXCLUDED_GEOGRAPHICAL_US_STATES = ['AA', 'AE', 'AP', 'AS', 'FM', 'GU', 'MH', 'MP', 'PR', 'PW', 'VI'];\n\nexport const DEFAULT_CV_ICON = 'https://vstatic-prod.apigateway.co/business-center-client/assets/cv-logo.png';\nexport const DEFAULT_CV_NAME = 'Customer Voice';\nexport const CustomerVoiceAppIDs = {\n [Environment.LOCAL]: 'MP-fba21121b71148c9bb33e11fcd92d520',\n [Environment.TEST]: 'MP-fba21121b71148c9bb33e11fcd92d520',\n [Environment.DEMO]: 'MP-fba21121b71148c9bb33e11fcd92d520',\n [Environment.PROD]: 'MP-c4974d390a044c28aec31e421aa662b2',\n};\n\nexport const REPLACE_NAME_WITH_PHONE_PLACEHOLDER = '-';\n\nexport const INVALID_CONTACT_NAMES = [undefined, null, REPLACE_NAME_WITH_PHONE_PLACEHOLDER, '- -', ''];\n\n// Used as a placeholder / fallback name\nexport const DEFAULT_OPENAI_BOT_NAME = 'Automated Assistant';\nexport const DEFAULT_WEBCHAT_BOT_NAME = DEFAULT_OPENAI_BOT_NAME;\n\nexport const CONTACTS_PAGE_SIZE = 5;\nexport const TEMPLATES_PAGE_SIZE = 20;\n\n// default view id for follow DefaultViewID\nexport const FOLLOWING_VIEW_ID = 'following';\nexport const ALL_VIEW_ID = 'all';\n\n// feature flag ids\nexport const SMB_MESSAGE_PARTNER_FEATURE = 'inbox_smb_message_partner';\nexport const INBOX_OPEN_DEFAULT = 'inbox_open_default';\nexport const INBOX_SMS_A2P = 'inbox_sms_a2p';\nexport const WEBCHAT_SETTING_CARD = 'web_chat_setting_card';\nexport const WEB_CHAT_FOR_PARTNER_INBOX = 'web_chat_for_partner_inbox';\nexport const MESSAGE_TEMPLATE_CARD = 'inbox_template_card';\nexport const INBOX_EMAIL = 'inbox_email';\nexport const CONVERSATION_SUMMARY = 'conversation_summary';\n\nexport const NEW_INBOX_TAB = 'new_inbox';\n\n// TODO: Use CRM SDK provided constants when available (CRMAAS-355 + MEGA-221)\nexport const STANDARD_CRM_FIELD_EXTERNAL_IDS = {\n firstName: 'standard__first_name',\n lastName: 'standard__last_name',\n phoneNumber: 'standard__phone_number',\n email: 'standard__email',\n updated: 'system__contact_updated',\n created: 'system__contact_created',\n tags: 'standard__tags',\n source: 'standard__contact_source_name',\n};\n\nexport type AppOptionsKeys = 'is_multilocation';\n\nexport const INBOX_CRM_SOURCE_NAME = 'Inbox';\n","import { GlobalParticipantType, NamespaceDetail, Participant, ParticipantType } from '@vendasta/conversation';\nimport { CrmObject, FieldValue } from '@vendasta/crm';\nimport { INBOX_CRM_SOURCE_NAME, STANDARD_CRM_FIELD_EXTERNAL_IDS } from './inbox.constants';\nimport { ConversationAvailableChannels, ConversationDetail } from './interface/conversation.interface';\nimport { InboxContact } from './interface/inbox.interface';\n\nexport function getSubjectParticipantByType(participants: Participant[], type: ParticipantType): Participant | null {\n return (\n participants?.find((participant) => participant?.isSubjectParticipant && participant?.participantType === type) ??\n null\n );\n}\n\n/**\n * isSameParticipant returns true if the target participant is the same based on the fields that makes a participant unique\n * @param userId\n * @param partnerId\n * @param accountGroupId\n * @param {Participant} targetParticipant\n * @returns {boolean}\n */\nexport function isSameParticipant(\n userId: string,\n partnerId: string,\n accountGroupId: string,\n targetParticipant: Participant,\n): boolean {\n return (\n targetParticipant?.internalParticipantId === userId &&\n targetParticipant?.partnerId === partnerId &&\n targetParticipant?.accountGroupId === accountGroupId\n );\n}\n\n/** Create a map of contact fields, using fieldID as key\n * @param {CrmObject} customerFields - contactFields\n * @return {Map} - Map of contact fields\n */\nexport function createContactFieldMap(contactFields: CrmObject): Map {\n const contactFieldMap = new Map();\n contactFields.fields.forEach((field) => {\n if (field?.fieldId) contactFieldMap.set(field.externalId, field);\n });\n return contactFieldMap;\n}\n\n/** Return an InboxContact object from CrmObject\n * @param {string} accountGroupId - accountGroupId\n * @param {CrmObject} contactFields - accountGroupId\n * @return {InboxContact} - Inbox Contact object\n */\nexport function getInboxContactFromCrm(accountGroupId: string, contactFields: CrmObject): InboxContact {\n const contactFieldMap = createContactFieldMap(contactFields);\n const inboxContact: InboxContact = {\n contactId: contactFields.crmObjectId,\n firstName: contactFieldMap.get(STANDARD_CRM_FIELD_EXTERNAL_IDS.firstName)?.stringValue ?? '',\n lastName: contactFieldMap.get(STANDARD_CRM_FIELD_EXTERNAL_IDS.lastName)?.stringValue ?? '',\n email: contactFieldMap.get(STANDARD_CRM_FIELD_EXTERNAL_IDS.email)?.stringValue ?? '',\n phone: contactFieldMap.get(STANDARD_CRM_FIELD_EXTERNAL_IDS.phoneNumber)?.stringValue ?? '',\n permissionToContact: true, //TODO (MEGA-221): hydrate this field when CRM service support it or delete it if not needed\n accountGroupId: accountGroupId,\n };\n return inboxContact;\n}\n\nexport function createCrmField(fieldName: string, stringValue: string): FieldValue | null {\n if (!fieldName || !stringValue) return null;\n return {\n externalId: fieldName,\n stringValue: stringValue,\n } as FieldValue;\n}\n\nexport function buildCrmFieldsForCreateContact(inboxContact: InboxContact): FieldValue[] {\n const object = [\n createCrmField(STANDARD_CRM_FIELD_EXTERNAL_IDS.firstName, inboxContact?.firstName),\n createCrmField(STANDARD_CRM_FIELD_EXTERNAL_IDS.lastName, inboxContact?.lastName),\n createCrmField(STANDARD_CRM_FIELD_EXTERNAL_IDS.phoneNumber, inboxContact?.phone),\n createCrmField(STANDARD_CRM_FIELD_EXTERNAL_IDS.email, inboxContact?.email),\n createCrmField(STANDARD_CRM_FIELD_EXTERNAL_IDS.source, INBOX_CRM_SOURCE_NAME),\n ].filter((field) => !!field);\n return object;\n}\n\n/**\n * Checks if the contact information is missing\n * @param {ConversationDetail} conversationDetail - Conversation Detail information\n * @param {ConversationAvailableChannels} availableChannels - Conversation Available Channels\n * @return {boolean}\n */\nexport function isContactInformationMissing(\n conversationDetail: ConversationDetail,\n availableChannels: ConversationAvailableChannels,\n): boolean {\n if (!conversationDetail?.conversation) return false;\n\n const recipients = conversationDetail?.participants\n ?.filter((p) => p.isSubjectParticipant && p.internalParticipantId)\n .filter((participant) => participant.participantType === ParticipantType.PARTICIPANT_TYPE_CUSTOMER);\n\n if (recipients?.length === 0) return false;\n\n const contactParticipant = conversationDetail?.participants?.find(\n (participant) => participant?.internalParticipantId === recipients[0].internalParticipantId,\n );\n\n return (\n !contactParticipant?.phoneNumber && !contactParticipant?.email && !availableChannels?.availableChannels?.length\n );\n}\n\n/**\n * Checks if the NamespaceDetail information used for describe participant hierarchy contains a participantType\n * @param {NamespaceDetail[]} hierarchy - Participant Hierarchy\n * @param {GlobalParticipantType} participantType - Participant Type\n * @return {boolean}\n */\nexport function isSubjectParticipantInHierarchy(\n hierarchy: NamespaceDetail[],\n participantType: GlobalParticipantType,\n): boolean {\n if (!hierarchy || !hierarchy.length) return false;\n return hierarchy.some((namespace) => namespace.participantType === participantType);\n}\n","import { Inject, Injectable, OnDestroy } from '@angular/core';\nimport { Router } from '@angular/router';\nimport { CrmFieldService, PAGE_ROUTES } from '@galaxy/crm/static';\nimport {\n ConversationApiService,\n ConversationChannel,\n GetMultiParticipantsRequest,\n GetMultiParticipantsResponse,\n GetParticipantsByKeyRequest,\n GetParticipantsByKeyResponse,\n GlobalParticipantType,\n Participant,\n ParticipantKey,\n ParticipantType,\n NamespaceDetail,\n} from '@vendasta/conversation';\nimport {\n CRMApiService,\n CreateCrmObjectRequest,\n CreateCrmObjectResponse,\n CrmObject,\n CrmObjectSearch,\n FilterGroupOperator,\n FilterOperator,\n ListCrmObjectsRequest,\n} from '@vendasta/crm';\nimport { SnackbarService } from '@vendasta/galaxy/snackbar-service';\nimport {\n BehaviorSubject,\n EMPTY,\n Observable,\n Subject,\n catchError,\n combineLatest,\n defaultIfEmpty,\n firstValueFrom,\n map,\n of,\n shareReplay,\n switchMap,\n take,\n} from 'rxjs';\nimport { CONTACTS_PAGE_SIZE } from './inbox.constants';\nimport { InboxContact } from './interface/inbox.interface';\nimport { buildCrmFieldsForCreateContact, getInboxContactFromCrm } from './participant-utils';\nimport { ACCOUNT_GROUP_ID_TOKEN, GROUP_ID_TOKEN, PARTNER_ID_TOKEN, USER_ID_TOKEN } from './tokens';\n\nexport class ParticipantBuilder {\n private readonly participant: Participant;\n constructor() {\n this.participant = new Participant();\n }\n\n partnerId(partnerId: string): ParticipantBuilder {\n this.participant.partnerId = partnerId;\n return this;\n }\n\n accountGroupId(accountGroupId: string): ParticipantBuilder {\n this.participant.accountGroupId = accountGroupId;\n return this;\n }\n\n channel(channel: ConversationChannel): ParticipantBuilder {\n this.participant.channel = channel;\n return this;\n }\n\n participantType(participantType: ParticipantType): ParticipantBuilder {\n this.participant.participantType = participantType;\n return this;\n }\n\n internalParticipantId(internalParticipantId: string): ParticipantBuilder {\n this.participant.internalParticipantId = internalParticipantId;\n return this;\n }\n\n isSubjectParticipant(isSubjectParticipant: boolean): ParticipantBuilder {\n this.participant.isSubjectParticipant = isSubjectParticipant;\n return this;\n }\n\n build(): Participant {\n return this.participant;\n }\n}\n\n@Injectable()\nexport class ParticipantService implements OnDestroy {\n constructor(\n @Inject(USER_ID_TOKEN) readonly userId$: Observable,\n @Inject(PARTNER_ID_TOKEN) readonly partnerId$: Observable,\n @Inject(ACCOUNT_GROUP_ID_TOKEN) readonly accountGroupId$: Observable,\n @Inject(GROUP_ID_TOKEN) readonly groupId$: Observable,\n private conversationApiService: ConversationApiService,\n private crmService: CRMApiService,\n private readonly snackbarService: SnackbarService,\n private readonly router: Router,\n private readonly fieldService: CrmFieldService,\n ) {}\n private unsubscribe$ = new Subject();\n private contacts$$: BehaviorSubject> = new BehaviorSubject([]);\n\n readonly participantDetails$ = combineLatest([\n this.partnerId$,\n this.accountGroupId$,\n this.userId$,\n this.groupId$,\n ]).pipe(\n map(([partnerId, accountGroupId, userId, groupId]) => {\n return {\n partnerId: partnerId ?? '',\n accountGroupId: accountGroupId ?? '',\n userId: userId ?? '',\n groupId: groupId ?? '',\n };\n }),\n );\n\n readonly currentParticipant$: Observable = this.participantDetails$.pipe(\n switchMap((details) => this.getParticipant(details)),\n shareReplay({ bufferSize: 1, refCount: true }),\n );\n\n public contacts$ = this.contacts$$.asObservable();\n ngOnDestroy(): void {\n this.unsubscribe$.next();\n this.unsubscribe$.complete();\n }\n\n getParticipant(participantDetails: {\n userId: string;\n partnerId: string;\n accountGroupId: string;\n groupId?: string;\n }): Observable {\n const participantKey = {\n internalParticipantId: participantDetails.userId,\n partnerId: participantDetails.partnerId ?? '',\n accountGroupId: participantDetails.accountGroupId ?? '',\n participantType: GlobalParticipantType.GLOBAL_PARTICIPANT_TYPE_IAM_USER,\n namespaceHierarchy: this.buildNamespaceHierarchy(\n participantDetails.partnerId,\n participantDetails.accountGroupId,\n participantDetails.groupId,\n ),\n } as ParticipantKey;\n return this.getParticipantsByKey(participantKey).pipe(\n catchError((err) => {\n console.error(err);\n return EMPTY;\n }),\n map((resp) => {\n return resp?.participant;\n }),\n defaultIfEmpty({} as Participant),\n shareReplay({ bufferSize: 1, refCount: true }),\n );\n }\n\n // buildNamespaceHierarchy is a helper function to build the namespace hierarchy for a participant\n buildNamespaceHierarchy(partnerId: string, accountGroupId: string, groupId?: string): NamespaceDetail[] {\n const namespaceHierarchy = [\n new NamespaceDetail({\n participantType: GlobalParticipantType.GLOBAL_PARTICIPANT_TYPE_PARTNER,\n internalParticipantId: partnerId,\n }),\n ];\n\n // either group or account group will be set.\n if (groupId) {\n namespaceHierarchy.push(\n new NamespaceDetail({\n participantType: GlobalParticipantType.GLOBAL_PARTICIPANT_TYPE_GROUP,\n internalParticipantId: groupId,\n }),\n );\n } else if (accountGroupId) {\n namespaceHierarchy.push(\n new NamespaceDetail({\n participantType: GlobalParticipantType.GLOBAL_PARTICIPANT_TYPE_ACCOUNT_GROUP,\n internalParticipantId: accountGroupId,\n }),\n );\n }\n return namespaceHierarchy;\n }\n\n buildIAMUserParticipant(isSubjectParticipant?: boolean): Observable {\n return combineLatest([this.partnerId$, this.accountGroupId$, this.userId$]).pipe(\n map(([partnerId, accountGroupId, userId]) => {\n return this.buildIamUser(partnerId, accountGroupId, userId, isSubjectParticipant);\n }),\n );\n }\n\n public buildIamUser(\n partnerId: string,\n accountGroupId: string,\n userId: string,\n isSubjectParticipant?: boolean,\n ): Participant {\n return accountGroupId\n ? new ParticipantBuilder()\n .partnerId(partnerId)\n .accountGroupId(accountGroupId)\n .participantType(ParticipantType.PARTICIPANT_TYPE_IAM_USER)\n .internalParticipantId(userId)\n .isSubjectParticipant(isSubjectParticipant ?? false)\n .build()\n : new ParticipantBuilder()\n .partnerId(partnerId)\n .participantType(ParticipantType.PARTICIPANT_TYPE_IAM_USER)\n .internalParticipantId(userId)\n .isSubjectParticipant(isSubjectParticipant ?? false)\n .build();\n }\n\n public buildAccountGroup(partnerId: string, accountGroupId: string): Participant {\n return new ParticipantBuilder()\n .partnerId(partnerId)\n .accountGroupId(accountGroupId)\n .participantType(ParticipantType.PARTICIPANT_TYPE_ACCOUNT_GROUP)\n .internalParticipantId('')\n .isSubjectParticipant(true)\n .build();\n }\n\n public buildPartner(partnerId: string): Participant {\n return new ParticipantBuilder()\n .partnerId(partnerId)\n .participantType(ParticipantType.PARTICIPANT_TYPE_PARTNER)\n .internalParticipantId('')\n .isSubjectParticipant(true)\n .build();\n }\n\n public buildVendor(vendorId: string): Participant {\n return new ParticipantBuilder()\n .partnerId(vendorId)\n .participantType(ParticipantType.PARTICIPANT_TYPE_VENDOR)\n .internalParticipantId('')\n .isSubjectParticipant(true)\n .build();\n }\n\n public buildContactParticipant(internalId: string, partnerId: string, accountGroupId?: string): Participant {\n return new ParticipantBuilder()\n .partnerId(partnerId)\n .accountGroupId(accountGroupId ?? '')\n .participantType(ParticipantType.PARTICIPANT_TYPE_CUSTOMER)\n .internalParticipantId(internalId)\n .isSubjectParticipant(true)\n .build();\n }\n\n public addContact(contact: InboxContact): Observable {\n if (!contact) return of({} as InboxContact);\n return this.createCrmContact(contact);\n }\n\n private createCrmContact(contact: InboxContact): Observable {\n return this.crmService\n .createContact({\n namespace: contact.accountGroupId,\n crmObject: {\n fields: buildCrmFieldsForCreateContact(contact),\n },\n } as CreateCrmObjectRequest)\n .pipe(\n map((crmObjectResponse: CreateCrmObjectResponse) => {\n contact.contactId = crmObjectResponse?.crmObjectId;\n return contact;\n }),\n );\n }\n\n public getContactByField(namespace: string, crmField: string, value: string): Observable> {\n if (namespace === '' || crmField === '' || value === '') return of([] as Array);\n\n return this.getCrmContactByField(namespace, this.fieldService.getFieldId(crmField), value);\n }\n\n public searchContacts(term: string, accountGroupId: string): void {\n if (term?.length <= 2) {\n this.contacts$$.next([] as Array);\n return;\n }\n\n this.getContactsFromCrmService(accountGroupId, term)\n .pipe(take(1))\n .subscribe((contactList) => {\n this.contacts$$.next(contactList);\n });\n }\n\n /**\n * Get contact list from CRM Service\n * @param {string} accountGroupId - accountGroupId\n * @param {string} term - search term\n * @return {Observable>} - Inbox Contact list observable\n */\n private getContactsFromCrmService(accountGroupId: string, term: string): Observable> {\n return this.crmService\n .listContacts({\n namespace: accountGroupId,\n search: { searchTerm: term } as CrmObjectSearch,\n pagingOptions: {\n pageSize: CONTACTS_PAGE_SIZE,\n },\n } as ListCrmObjectsRequest)\n .pipe(\n map((response) =>\n response?.crmObjects\n ?.filter((contact) => !!contact)\n .map((contact: CrmObject) => getInboxContactFromCrm(accountGroupId, contact)),\n ),\n catchError(() => of([] as Array)),\n );\n }\n\n /**\n * Get contact from CRM Service by email\n * @param {string} namespace - Crm namespace\n * @param {string} fieldId - Crm field to filter\n * @param {string} term - search term\n * @return {Observable>} - Inbox Contact list observable\n */\n private getCrmContactByField(namespace: string, fieldId: string, term: string): Observable> {\n return this.crmService\n .listContacts({\n namespace: namespace,\n pagingOptions: {\n pageSize: 1,\n },\n filtersV2: {\n operator: FilterGroupOperator.FILTER_GROUP_OPERATOR_AND,\n filters: [\n {\n fieldId: fieldId,\n operator: FilterOperator.FILTER_OPERATOR_IS,\n values: [\n {\n string: term,\n },\n ],\n },\n ],\n },\n } as ListCrmObjectsRequest)\n .pipe(\n map((response) =>\n response?.crmObjects\n ?.filter((contact) => !!contact)\n .map((contact: CrmObject) => getInboxContactFromCrm(namespace, contact)),\n ),\n catchError(() => of([] as Array)),\n );\n }\n\n /**\n * get multi participants from the Conversation µs\n * @param {string[]} participantIds - the participant IDs\n * @return {Observable}\n */\n public getMultiParticipants(\n participantIds: string[],\n conversationId: string,\n ): Observable {\n if (!participantIds || participantIds.length === 0) {\n console.error('the participantIds is not valid');\n return of({ participants: [] as Participant[] } as GetMultiParticipantsResponse);\n }\n\n const req = {\n conversationId: conversationId,\n participantIds: participantIds,\n } as GetMultiParticipantsRequest;\n return this.conversationApiService.getMultiParticipants(req).pipe(\n catchError((err) => {\n console.error('getMultiParticipants error:', err?.message);\n return of({} as GetMultiParticipantsResponse);\n }),\n );\n }\n\n /**\n * get participants by key from the Conversation µs\n */\n public getParticipantsByKey(participantKeyInfo: ParticipantKey): Observable {\n const req = {\n participantKey: participantKeyInfo,\n } as GetParticipantsByKeyRequest;\n\n return this.conversationApiService.getParticipantsByKey(req);\n }\n\n organizationId$ = combineLatest([this.partnerId$, this.accountGroupId$]).pipe(\n map(([partnerId, accountGroupId]) => {\n return accountGroupId || partnerId;\n }),\n );\n\n //TODO: (MEGA-433) Improve inbox logic to get hydrated participant information from getMultiConversationDetail participants\n // instead of subjectParticipants. This will allow us to remove unnecessary conversation Id argument.\n /**\n * View recipient contact information\n * @param contactId - contact ID\n * @param participantType - Firestore Participant Type\n * @param conversationId - Conversation ID\n */\n async viewContact(\n contactId: string,\n participantType: ParticipantType,\n conversationId: string,\n firestoreDocId?: string,\n ): Promise {\n if (!contactId || !participantType) {\n this.snackbarService.openErrorSnack('INBOX.TOPBAR.ERROR_LOADING_RECIPIENT');\n return;\n }\n\n const accountGroupId = await firstValueFrom(this.accountGroupId$);\n\n const returnUrl = `/account/location/${accountGroupId}/inbox/channel/${firestoreDocId}`;\n const routeTemplate = `/account/location/${accountGroupId}/crm/${PAGE_ROUTES.CONTACT.ROOT}/${PAGE_ROUTES.CONTACT.SUBROUTES.PROFILE}`;\n this.router.navigate([routeTemplate.replace(':crmObjectId', contactId)], {\n queryParams: { returnUrl: returnUrl },\n });\n }\n}\n","import { Inject, inject, Injectable, OnDestroy } from '@angular/core';\nimport { FeatureFlagService } from '@galaxy/partner';\nimport { AddressAPIService } from '@vendasta/address';\nimport { GlobalParticipantType, InboxApiService, PlatformLocation } from '@vendasta/conversation';\nimport { IAMService, Role, UserIdentifier } from '@vendasta/iamv2';\nimport {\n catchError,\n combineLatest,\n distinctUntilChanged,\n firstValueFrom,\n map,\n Observable,\n of,\n shareReplay,\n Subject,\n switchMap,\n take,\n} from 'rxjs';\nimport { MARKETING_SERVICES_PIDS } from './conversation.constants';\nimport { isWideScreen } from './inbox-utils';\nimport {\n CONVERSATION_SUMMARY,\n EXCLUDED_GEOGRAPHICAL_US_STATES,\n INBOX_EMAIL,\n INBOX_OPEN_DEFAULT,\n INBOX_SMS_A2P,\n MESSAGE_TEMPLATE_CARD,\n WEB_CHAT_FOR_PARTNER_INBOX,\n WEBCHAT_SETTING_CARD,\n} from './inbox.constants';\nimport {\n ACCOUNT_GROUP_ID_TOKEN,\n CONVERSATION_CONFIG_TOKEN,\n CONVERSATION_COUNTRY_TOKEN,\n CONVERSATION_GEOGRAPHICAL_STATE_TOKEN,\n CONVERSATION_GOOGLE_BUSINESS_MESSAGES_AVAILABLE_TOKEN,\n CONVERSATION_PLATFORM_LOCATION_TOKEN,\n CONVERSATION_SMS_ENABLED_TOKEN,\n CONVERSATION_WEB_CHAT_ENABLED_TOKEN,\n FEATURE_FLAG_TOKEN,\n PARTNER_ID_TOKEN,\n USER_ID_TOKEN,\n GROUP_ID_TOKEN,\n} from './tokens';\nimport { GetAccountInfoResponse, ParticipantType, SmsService } from '@vendasta/smsv2';\nimport { HttpErrorResponse } from '@angular/common/http';\nimport { ParticipantService } from './participant.service';\n\nconst isSuperAdminFn = (partner: Role): boolean => !!partner?.attributes.attributes['is_super_admin']?.boolAttribute;\n\n@Injectable()\nexport class InboxService implements OnDestroy {\n private readonly unsubscribe$$ = new Subject();\n private readonly smsService = this.isBusinessApp ? inject(SmsService) : null;\n\n readonly iamUser$ = this.userId$.pipe(\n switchMap((userId) => this.iamService.getUser({ userId: userId } as UserIdentifier)),\n );\n\n readonly canAccessEmbeddedSettings$ = combineLatest([this.iamUser$, this.partnerId$]).pipe(\n map(([user, currentPartnerId]) => {\n if (!this.isPartnerCenter) return false;\n const { partnerId: userPartnerID, roles: { partner } = {} } = user;\n const isSuperAdmin = isSuperAdminFn(partner);\n return (currentPartnerId === userPartnerID && !!partner) || isSuperAdmin;\n }),\n shareReplay(1),\n );\n\n readonly showAvailabilityMessageSettings$ = combineLatest([this.iamUser$, this.partnerId$]).pipe(\n map(([user, currentPartnerId]) => {\n const { partnerId: userPartnerID, roles: { partner } = {} } = user;\n const isSuperAdmin = isSuperAdminFn(partner);\n return (\n ((currentPartnerId === userPartnerID && !!partner) || isSuperAdmin) &&\n MARKETING_SERVICES_PIDS.includes(currentPartnerId)\n );\n }),\n shareReplay(1),\n );\n\n private readonly featureFlags$ = this.partnerId$.pipe(\n switchMap((partnerId) => {\n return this.featureFlagService\n .batchGetStatus(partnerId, '', [\n INBOX_OPEN_DEFAULT,\n INBOX_SMS_A2P,\n WEBCHAT_SETTING_CARD,\n MESSAGE_TEMPLATE_CARD,\n WEB_CHAT_FOR_PARTNER_INBOX,\n INBOX_EMAIL,\n CONVERSATION_SUMMARY,\n ])\n .pipe(take(1), shareReplay(1));\n }),\n );\n\n readonly isConversationSummaryEnabled$ = this.featureFlags$.pipe(\n map((res) => res[CONVERSATION_SUMMARY]),\n distinctUntilChanged(),\n shareReplay(1),\n );\n\n readonly partnerHasA2PAccess$ = this.featureFlags$.pipe(\n map((res) => res[INBOX_SMS_A2P]),\n distinctUntilChanged(),\n shareReplay(1),\n );\n\n readonly SMSNumber$ = this.accountGroupId$.pipe(\n switchMap((accountGroupId) => {\n if (!this.smsService || !accountGroupId) return of(null);\n return this.smsService.getAccountInfo({\n internalId: accountGroupId,\n type: ParticipantType.PARTICIPANT_TYPE_ACCOUNT_GROUP,\n });\n }),\n catchError((error: HttpErrorResponse) => {\n console.error('error to get account info:', error.message);\n return of({} as GetAccountInfoResponse);\n }),\n map((accountInfo) => accountInfo?.phoneNumber),\n distinctUntilChanged(),\n shareReplay(1),\n );\n\n constructor(\n private readonly featureFlagService: FeatureFlagService,\n private readonly participantService: ParticipantService,\n @Inject(ACCOUNT_GROUP_ID_TOKEN) private readonly accountGroupId$: Observable,\n @Inject(CONVERSATION_COUNTRY_TOKEN) readonly country$: Observable,\n @Inject(CONVERSATION_GEOGRAPHICAL_STATE_TOKEN) private readonly geographicalState$: Observable,\n @Inject(PARTNER_ID_TOKEN) private readonly partnerId$: Observable,\n @Inject(FEATURE_FLAG_TOKEN)\n @Inject(CONVERSATION_PLATFORM_LOCATION_TOKEN)\n readonly platformLocation: PlatformLocation,\n private readonly addressService: AddressAPIService,\n @Inject(CONVERSATION_SMS_ENABLED_TOKEN) private smsEnabled$: Observable,\n @Inject(CONVERSATION_WEB_CHAT_ENABLED_TOKEN) private webChatEnabled$: Observable,\n @Inject(CONVERSATION_GOOGLE_BUSINESS_MESSAGES_AVAILABLE_TOKEN)\n private googleBusinessMessagesAvailable$: Observable,\n @Inject(USER_ID_TOKEN) private readonly userId$: Observable,\n private iamService: IAMService,\n private readonly inboxApiService: InboxApiService,\n @Inject(GROUP_ID_TOKEN) private readonly groupId$: Observable,\n ) {}\n\n hasAccessToInboxPage$ =\n inject(CONVERSATION_CONFIG_TOKEN)?.hasAccessToInboxPage$?.pipe(map((result) => !!result)) || of(true);\n allowSmbChatWithPartner$ =\n inject(CONVERSATION_CONFIG_TOKEN)?.allowSmbChatWithPartner$?.pipe(map((result) => !!result)) || of(false);\n\n /**\n * Check if account can access SMS feature.\n * SMS is only accessible for US/CA accounts.\n */\n get canAccessSMS$(): Observable {\n const hasAccessByCountry$ = this.geographicalState$.pipe(\n switchMap((geographicalState) => this.hasAccessByCountry(geographicalState)),\n );\n return combineLatest([this.hasAccessToInboxPage$, hasAccessByCountry$, this.smsEnabled$]).pipe(\n map(([hasAccessToInboxPage, hasAccessByCountry, smsEnabled]) => {\n return hasAccessToInboxPage && hasAccessByCountry && smsEnabled;\n }),\n distinctUntilChanged(),\n shareReplay(1),\n );\n }\n\n reauthorizeGoogleAccount() {\n // TODO: (BREW-316) - Reauthorize Google Account\n }\n\n get canAccess$(): Observable {\n return combineLatest([this.hasAccessToInboxPage$, this.hasAccessByCountry()]).pipe(\n map(([hasAccess, hasAccessByCountry]) => hasAccess && hasAccessByCountry),\n take(1),\n shareReplay(1),\n );\n }\n\n private hasAccessByCountry(accountGroupGeographicalState?: string): Observable {\n // https://address-demo.apigateway.co/address.v1.Address/ListAllCountryOptions\n // Australia - AU / United Kingdom - GB\n const availableCountries = ['ca', 'us'];\n return this.country$.pipe(\n switchMap((accountGroupCountry) => {\n const country = accountGroupCountry?.toLowerCase() || '';\n if (!availableCountries?.includes(country)) {\n return of(false);\n }\n if (country === 'us' && accountGroupGeographicalState) {\n return this.hasAccessByUSState(accountGroupGeographicalState).pipe(\n take(1),\n map((hasAccessByUSState) => hasAccessByUSState),\n );\n }\n return of(true);\n }),\n );\n }\n\n /**\n * Check if account is a US account\n * If the Country is US and the state doesn't belong to a valid US state the validation would be false.\n */\n private isUsAccountWithSmsAccess$(accountGroupGeographicalState?: string): Observable {\n return this.country$.pipe(\n switchMap((accountGroupCountry) => {\n const country = accountGroupCountry?.toLowerCase() || '';\n if (country === 'us' && accountGroupGeographicalState) {\n return this.hasAccessByUSState(accountGroupGeographicalState);\n }\n return of(false);\n }),\n );\n }\n\n private hasAccessByUSState(accountGroupState: string): Observable {\n const state = accountGroupState?.toLowerCase() || '';\n return this.addressService.getCountryConfiguration('US', undefined).pipe(\n take(1),\n map((countryInfo) => {\n const filteredStateList = countryInfo?.zones?.reduce((accumulator, currentValue) => {\n if (!EXCLUDED_GEOGRAPHICAL_US_STATES.includes(currentValue?.code)) {\n return [...accumulator, currentValue?.code?.toLocaleLowerCase()];\n }\n return accumulator;\n }, []);\n return filteredStateList?.includes(state);\n }),\n catchError((error) => {\n console.error('Error getting country configuration:', error.message);\n return of(false);\n }),\n );\n }\n\n readonly showInboxViews$ = of(!this.isBusinessApp);\n\n readonly canAccessInboxGetStartedCard$ = combineLatest([\n this.smsEnabled$,\n this.googleBusinessMessagesAvailable$,\n ]).pipe(\n map(([smsEnable, googleBusinessMessagesEnable]) => {\n return smsEnable && googleBusinessMessagesEnable;\n }),\n distinctUntilChanged(),\n );\n\n readonly openInboxDefault$ = this.featureFlags$.pipe(\n map((featureFlags) => {\n return featureFlags[INBOX_OPEN_DEFAULT] && this.isPartnerCenter && !isWideScreen();\n }),\n shareReplay(1),\n );\n\n readonly canAccessWebChatSettings$ = combineLatest([this.featureFlags$, this.webChatEnabled$]).pipe(\n map(([featureFlags, webchatEnabled]) => {\n const canAccessBA = featureFlags[WEBCHAT_SETTING_CARD] && this.isBusinessApp && webchatEnabled;\n const canAccessPCC = featureFlags[WEB_CHAT_FOR_PARTNER_INBOX] && this.isPartnerCenter;\n return canAccessBA || canAccessPCC;\n }),\n shareReplay(1),\n );\n\n readonly canAccessEmailChannel$ = this.featureFlags$.pipe(\n map((featureFlags) => {\n return featureFlags[INBOX_EMAIL] && this.isBusinessApp;\n }),\n );\n\n readonly canAccessMessageTemplateSettingsCard$ = this.featureFlags$.pipe(\n map((featureFlags) => featureFlags[MESSAGE_TEMPLATE_CARD]),\n shareReplay(1),\n );\n\n readonly multiLocationEnabled$ = this.groupId$.pipe(\n switchMap((groupId) => {\n if (!groupId || !this.isBusinessApp) {\n return of({ configuration: { multiLocationEnabled: false } });\n }\n return this.inboxApiService\n .getConfiguration({\n subjectParticipant: {\n participantType: GlobalParticipantType.GLOBAL_PARTICIPANT_TYPE_GROUP,\n internalParticipantId: groupId,\n },\n })\n .pipe(catchError(() => of({ configuration: { multiLocationEnabled: false } })));\n }),\n map((config) => {\n return config.configuration.multiLocationEnabled ?? false;\n }),\n catchError(() => of(false)),\n shareReplay(1),\n );\n\n /**\n * check if the current platform location is the business app\n * @return {boolean}\n */\n get isBusinessApp(): boolean {\n return this.platformLocation === PlatformLocation.PLATFORM_LOCATION_BUSINESS_APP;\n }\n\n /**\n * check if the current platform location is the partner center\n * @return {boolean}\n */\n get isPartnerCenter(): boolean {\n return this.platformLocation === PlatformLocation.PLATFORM_LOCATION_PARTNER_CENTER;\n }\n\n /**\n * check if the current platform location is the sales center\n * @return {boolean}\n */\n get isSalesCenter(): boolean {\n return this.platformLocation === PlatformLocation.PLATFORM_LOCATION_SALES_CENTER;\n }\n\n /**\n * check if displaying the A2P card in business app inbox setting page\n * @return {Promise}\n */\n async displayA2pCard$(): Promise {\n const hasAccessByCountry$ = this.geographicalState$.pipe(\n switchMap((geographicalState) => this.hasAccessByCountry(geographicalState)),\n );\n\n return await firstValueFrom(\n combineLatest([\n this.hasAccessToInboxPage$,\n hasAccessByCountry$,\n this.partnerHasA2PAccess$,\n this.smsEnabled$,\n ]).pipe(\n map(([hasAccessToInboxPage, hasAccessByCountry, partnerHasA2PAccess, smsEnable]): boolean => {\n return this.isBusinessApp && hasAccessToInboxPage && hasAccessByCountry && partnerHasA2PAccess && smsEnable;\n }),\n ),\n );\n }\n\n async buildTemplateTrackProperties() {\n return {\n accountGroupId: await firstValueFrom(this.accountGroupId$),\n participantName: (await firstValueFrom(this.participantService.currentParticipant$)).name || '',\n partnerId: await firstValueFrom(this.partnerId$),\n location: PlatformLocation[this.platformLocation],\n };\n }\n\n async buildAiKnowledgeAppConfigurationUrl(widgetId: string): Promise {\n const accountGroupId = await firstValueFrom(this.accountGroupId$);\n if (accountGroupId) {\n return `/account/location/${accountGroupId}/settings/widgets/${widgetId}/edit`;\n }\n return `/(inbox:inbox/widgets/${widgetId}/edit)`;\n }\n\n buildAppId(widgetId: string): string {\n return `APP-WEBCHAT-${widgetId}`;\n }\n\n ngOnDestroy(): void {\n this.unsubscribe$$.next();\n this.unsubscribe$$.complete();\n }\n}\n"],"mappings":"0pBAKA,IAAMA,GAAN,MAAMC,CAAqB,CACzB,OAAO,UAAUC,EAAO,CACtB,IAAIC,EAAI,IAAIF,EACZ,OAAAE,EAAI,OAAO,OAAOA,EAAGD,CAAK,EACtBA,EAAM,oBACRC,EAAE,kBAAoB,SAASD,EAAM,kBAAmB,EAAE,GAExDA,EAAM,aACRC,EAAE,WAAaC,GAA+B,UAAUF,EAAM,UAAU,GAEtEA,EAAM,SACRC,EAAE,OAASE,GAA2B,UAAUH,EAAM,MAAM,GAE1DA,EAAM,QACRC,EAAE,MAAQD,EAAM,MAAM,IAAII,GAAyB,SAAS,GAEvDH,CACT,CACA,YAAYI,EAAQ,CACbA,GAGL,OAAO,OAAO,KAAMA,CAAM,CAC5B,CACA,WAAY,CACV,IAAMC,EAAW,CAAC,EACl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A7FbjK,EAAYkK,QAAZlK,EAAYmK,SAAA,CAAA,EAAnB,IAAOnK,EAAPoK,SAAOpK,CAAY,GAAA","names":["CountryConfiguration","_CountryConfiguration","proto","m","CountryConfigurationFormatting","CountryConfigurationLabels","CountryConfigurationZone","kwargs","toReturn","CountryOption","_CountryOption","_CountryConfigurationFormatting","_CountryConfigurationLabels","_CountryConfigurationZone","DeleteLocalizedZoneRequest","_DeleteLocalizedZoneRequest","GetCountryConfigurationRequest","_GetCountryConfigurationRequest","GetCountryConfigurationResponse","_GetCountryConfigurationResponse","ListAllCountryOptionsRequest","_ListAllCountryOptionsRequest","ListAllCountryOptionsResponse","_ListAllCountryOptionsResponse","ReplaceCountryFormattingRequest","_ReplaceCountryFormattingRequest","ReplaceLocalizedCountryRequest","_ReplaceLocalizedCountryRequest","ReplaceLocalizedZoneRequest","_ReplaceLocalizedZoneRequest","environment","hostMap","HostService","t","ɵɵdefineInjectable","AddressApiService","http","hostService","HttpHeaders","r","request","map","resp","__spreadProps","__spreadValues","ɵɵinject","HttpClient","AddressAPIService","addressApiService","countryCode","locale","req","FIRESTORE_CONVERSATION_LIMIT","DELETED_TIMESTAMP_FIRESTORE","Timestamp","MARKETING_SERVICES_PIDS","SUPPORT_PID","MAX_FILES","MAX_RECORDING_TIME","POSTHOG_CHANNEL_NAME","Map","ConversationChannel","CONVERSATION_CHANNEL_UNDEFINED","CONVERSATION_CHANNEL_INTERNAL","CONVERSATION_CHANNEL_SMS","CONVERSATION_CHANNEL_FACEBOOK","CONVERSATION_CHANNEL_GOOGLE_MESSAGES","CONVERSATION_CHANNEL_OPENAI","CONVERSATION_CHANNEL_EMAIL","CONVERSATION_CHANNEL_GOOGLE_BUSINESS_COMMUNICATIONS","CONVERSATION_CHANNEL_WEB_CHAT","CONVERSATION_CHANNEL_INSTAGRAM","isMobile","window","matchMedia","matches","isWideScreen","GOOGLE_SOURCE_ID","FACEBOOK_SOURCE_ID","LOCAL_STORAGE_ID","EXCLUDED_GEOGRAPHICAL_US_STATES","DEFAULT_CV_ICON","DEFAULT_CV_NAME","CustomerVoiceAppIDs","Environment","LOCAL","TEST","DEMO","PROD","DEFAULT_OPENAI_BOT_NAME","DEFAULT_WEBCHAT_BOT_NAME","CONTACTS_PAGE_SIZE","TEMPLATES_PAGE_SIZE","FOLLOWING_VIEW_ID","ALL_VIEW_ID","SMB_MESSAGE_PARTNER_FEATURE","INBOX_OPEN_DEFAULT","INBOX_SMS_A2P","WEBCHAT_SETTING_CARD","WEB_CHAT_FOR_PARTNER_INBOX","MESSAGE_TEMPLATE_CARD","INBOX_EMAIL","CONVERSATION_SUMMARY","STANDARD_CRM_FIELD_EXTERNAL_IDS","firstName","lastName","phoneNumber","email","updated","created","tags","source","INBOX_CRM_SOURCE_NAME","createContactFieldMap","contactFields","contactFieldMap","Map","fields","forEach","field","fieldId","set","externalId","getInboxContactFromCrm","accountGroupId","contactId","crmObjectId","firstName","get","STANDARD_CRM_FIELD_EXTERNAL_IDS","stringValue","lastName","email","phone","phoneNumber","permissionToContact","createCrmField","fieldName","buildCrmFieldsForCreateContact","inboxContact","source","INBOX_CRM_SOURCE_NAME","filter","isContactInformationMissing","conversationDetail","availableChannels","conversation","recipients","participants","p","isSubjectParticipant","internalParticipantId","participant","participantType","ParticipantType","PARTICIPANT_TYPE_CUSTOMER","length","contactParticipant","find","ParticipantBuilder","constructor","participant","Participant","partnerId","accountGroupId","channel","participantType","internalParticipantId","isSubjectParticipant","build","ParticipantService","userId$","partnerId$","accountGroupId$","groupId$","conversationApiService","crmService","snackbarService","router","fieldService","unsubscribe$","Subject","contacts$$","BehaviorSubject","participantDetails$","combineLatest","pipe","map","userId","groupId","currentParticipant$","switchMap","details","getParticipant","shareReplay","bufferSize","refCount","contacts$","asObservable","organizationId$","ngOnDestroy","next","complete","participantDetails","participantKey","GlobalParticipantType","GLOBAL_PARTICIPANT_TYPE_IAM_USER","namespaceHierarchy","buildNamespaceHierarchy","getParticipantsByKey","catchError","err","console","error","EMPTY","resp","defaultIfEmpty","NamespaceDetail","GLOBAL_PARTICIPANT_TYPE_PARTNER","push","GLOBAL_PARTICIPANT_TYPE_GROUP","GLOBAL_PARTICIPANT_TYPE_ACCOUNT_GROUP","buildIAMUserParticipant","buildIamUser","ParticipantType","PARTICIPANT_TYPE_IAM_USER","buildAccountGroup","PARTICIPANT_TYPE_ACCOUNT_GROUP","buildPartner","PARTICIPANT_TYPE_PARTNER","buildVendor","vendorId","PARTICIPANT_TYPE_VENDOR","buildContactParticipant","internalId","PARTICIPANT_TYPE_CUSTOMER","addContact","contact","createCrmContact","of","createContact","namespace","crmObject","fields","buildCrmFieldsForCreateContact","crmObjectResponse","contactId","crmObjectId","getContactByField","crmField","value","getCrmContactByField","getFieldId","searchContacts","term","length","getContactsFromCrmService","take","subscribe","contactList","listContacts","search","searchTerm","pagingOptions","pageSize","CONTACTS_PAGE_SIZE","response","crmObjects","filter","getInboxContactFromCrm","fieldId","filtersV2","operator","FilterGroupOperator","FILTER_GROUP_OPERATOR_AND","filters","FilterOperator","FILTER_OPERATOR_IS","values","string","getMultiParticipants","participantIds","conversationId","participants","req","message","participantKeyInfo","viewContact","firestoreDocId","__async","openErrorSnack","firstValueFrom","returnUrl","routeTemplate","PAGE_ROUTES","CONTACT","ROOT","SUBROUTES","PROFILE","navigate","replace","queryParams","ɵɵinject","USER_ID_TOKEN","PARTNER_ID_TOKEN","ACCOUNT_GROUP_ID_TOKEN","GROUP_ID_TOKEN","ConversationApiService","CRMApiService","SnackbarService","Router","CrmFieldService","factory","ɵfac","_ParticipantService","isSuperAdminFn","partner","attributes","boolAttribute","InboxService","constructor","featureFlagService","participantService","accountGroupId$","country$","geographicalState$","partnerId$","platformLocation","addressService","smsEnabled$","webChatEnabled$","googleBusinessMessagesAvailable$","userId$","iamService","inboxApiService","groupId$","unsubscribe$$","Subject","smsService","isBusinessApp","inject","SmsService","iamUser$","pipe","switchMap","userId","getUser","canAccessEmbeddedSettings$","combineLatest","map","user","currentPartnerId","isPartnerCenter","partnerId","userPartnerID","roles","isSuperAdmin","shareReplay","showAvailabilityMessageSettings$","MARKETING_SERVICES_PIDS","includes","featureFlags$","batchGetStatus","INBOX_OPEN_DEFAULT","INBOX_SMS_A2P","WEBCHAT_SETTING_CARD","MESSAGE_TEMPLATE_CARD","WEB_CHAT_FOR_PARTNER_INBOX","INBOX_EMAIL","CONVERSATION_SUMMARY","take","isConversationSummaryEnabled$","res","distinctUntilChanged","partnerHasA2PAccess$","SMSNumber$","accountGroupId","of","getAccountInfo","internalId","type","ParticipantType","PARTICIPANT_TYPE_ACCOUNT_GROUP","catchError","error","console","message","accountInfo","phoneNumber","hasAccessToInboxPage$","CONVERSATION_CONFIG_TOKEN","result","allowSmbChatWithPartner$","showInboxViews$","canAccessInboxGetStartedCard$","smsEnable","googleBusinessMessagesEnable","openInboxDefault$","featureFlags","isWideScreen","canAccessWebChatSettings$","webchatEnabled","canAccessBA","canAccessPCC","canAccessEmailChannel$","canAccessMessageTemplateSettingsCard$","multiLocationEnabled$","groupId","configuration","multiLocationEnabled","getConfiguration","subjectParticipant","participantType","GlobalParticipantType","GLOBAL_PARTICIPANT_TYPE_GROUP","internalParticipantId","config","canAccessSMS$","hasAccessByCountry$","geographicalState","hasAccessByCountry","hasAccessToInboxPage","smsEnabled","reauthorizeGoogleAccount","canAccess$","hasAccess","accountGroupGeographicalState","availableCountries","accountGroupCountry","country","toLowerCase","hasAccessByUSState","isUsAccountWithSmsAccess$","accountGroupState","state","getCountryConfiguration","undefined","countryInfo","zones","reduce","accumulator","currentValue","EXCLUDED_GEOGRAPHICAL_US_STATES","code","toLocaleLowerCase","PlatformLocation","PLATFORM_LOCATION_BUSINESS_APP","PLATFORM_LOCATION_PARTNER_CENTER","isSalesCenter","PLATFORM_LOCATION_SALES_CENTER","displayA2pCard$","__async","firstValueFrom","partnerHasA2PAccess","buildTemplateTrackProperties","participantName","currentParticipant$","name","location","buildAiKnowledgeAppConfigurationUrl","widgetId","buildAppId","ngOnDestroy","next","complete","ɵɵinject","FeatureFlagService","ParticipantService","ACCOUNT_GROUP_ID_TOKEN","CONVERSATION_COUNTRY_TOKEN","CONVERSATION_GEOGRAPHICAL_STATE_TOKEN","PARTNER_ID_TOKEN","CONVERSATION_PLATFORM_LOCATION_TOKEN","AddressAPIService","CONVERSATION_SMS_ENABLED_TOKEN","CONVERSATION_WEB_CHAT_ENABLED_TOKEN","CONVERSATION_GOOGLE_BUSINESS_MESSAGES_AVAILABLE_TOKEN","USER_ID_TOKEN","IAMService","InboxApiService","GROUP_ID_TOKEN","factory","ɵfac","_InboxService"],"x_google_ignoreList":[0]}