define("metaserver/static/js/dropbox/proto/js_init_data/chat/chat",["require","exports","tslib","protobufjs/minimal"],(function(t,e,a,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=e.chat=void 0;const n=(i=a.__importStar(i)).Reader,s=i.Writer,r=i.util,o=i.roots.default||(i.roots.default={});var h;e.default=o,e.chat=o.chat=((h=o.chat||{}).ChatProviderType=(function(){const t={},e=Object.create(t);return e[t[0]="SNAPENGAGE"]=0,e[t[1]="DIALOGUE_CHAT"]=1,e[t[2]="SOLVVY"]=2,e})(),h.ProactiveMessageType=(function(){const t={},e=Object.create(t);return e[t[0]="DEFAULT"]=0,e[t[1]="MINIMIZED_PROACTIVE"]=1,e})(),h.ChatInitialState=(function(){const t={},e=Object.create(t);return e[t[0]="HIDDEN"]=0,e[t[1]="SHOW_PROVIDER_REACTIVE_BUTTON"]=1,e})(),h.ChatMetadata=(function(t){function t(t){if(t)for(let e=Object.keys(t),a=0;a>>3){case 1:i.cookieDomain=t.string();break;case 2:i.cookieCampaignName=t.string();break;case 3:i.legacyCookieCampaignName=t.string();break;default:t.skipType(7&e)}}return i},t.getTypeUrl=function(){return"type.googleapis.com/chat.ChatMetadata"},t})(h.ChatMetadata||{}),h.SnapengageChatMetadata=(function(t){function t(t){if(t)for(let e=Object.keys(t),a=0;a>>3){case 4:i.snapengageIframeOrigin=t.string();break;default:t.skipType(7&e)}}return i},t.getTypeUrl=function(){return"type.googleapis.com/chat.SnapengageChatMetadata"},t})(h.SnapengageChatMetadata||{}),h.SolvvyChatMetadata=(function(t){function t(t){if(t)for(let e=Object.keys(t),a=0;a>>3){case 1:i.solvvyIframeOrigin=t.string();break;default:t.skipType(7&e)}}return i},t.getTypeUrl=function(){return"type.googleapis.com/chat.SolvvyChatMetadata"},t})(h.SolvvyChatMetadata||{}),h.UserProperties=(function(t){function t(t){if(this.pricings=[],this.experiments={},t)for(let e=Object.keys(t),a=0;a>>3){case 1:h.chatHmac=t.string();break;case 2:h.email=t.string();break;case 3:h.firstName=t.string();break;case 4:h.lastName=t.string();break;case 5:h.pageLoadTs=t.string();break;case 6:h.pricings&&h.pricings.length||(h.pricings=[]),h.pricings.push(t.string());break;case 7:h.sessionId=t.string();break;case 8:h.userId=t.string();break;case 9:h.serviceTier=t.string();break;case 10:{h.experiments===r.emptyObject&&(h.experiments={});let e=t.uint32()+t.pos;for(a="",i="";t.pos>>3){case 1:a=t.string();break;case 2:i=t.string();break;default:t.skipType(7&e)}}h.experiments[a]=i;break}case 11:h.locale=t.string();break;case 12:h.countryCode=t.string();break;case 13:h.authToken=t.string();break;default:t.skipType(7&e)}}return h},t.getTypeUrl=function(){return"type.googleapis.com/chat.UserProperties"},t})(h.UserProperties||{}),h.SnapengageChatSystemSettings=(function(t){function t(t){if(t)for(let e=Object.keys(t),a=0;a>>3){case 1:i.widgetId=t.string();break;default:t.skipType(7&e)}}return i},t.getTypeUrl=function(){return"type.googleapis.com/chat.SnapengageChatSystemSettings"},t})(h.SnapengageChatSystemSettings||{}),h.DialogueBotProvider=(function(){const t={},e=Object.create(t);return e[t[0]="UNKNOWN"]=0,e[t[1]="LEX"]=1,e[t[2]="RASA"]=2,e})(),h.DialogueBotType=(function(){const t={},e=Object.create(t);return e[t[0]="CX_SUPPORT"]=0,e[t[1]="BUSINESS"]=1,e[t[2]="CX_SPECIALIZED"]=2,e[t[3]="SCALED_ONBOARDING"]=3,e})(),h.DialogueExperiment=(function(t){function t(t){if(t)for(let e=Object.keys(t),a=0;a>>3){case 1:i.name=t.string();break;case 2:i.active=t.bool();break;default:t.skipType(7&e)}}return i},t.getTypeUrl=function(){return"type.googleapis.com/chat.DialogueExperiment"},t})(h.DialogueExperiment||{}),h.DialogueChatSystemSettings=(function(t){function t(t){if(this.experiments=[],t)for(let e=Object.keys(t),a=0;a>>3){case 2:i.botProvider=t.int32();break;case 3:i.environment=t.string();break;case 4:i.settingsHmac=t.string();break;case 5:i.experiments&&i.experiments.length||(i.experiments=[]),i.experiments.push(o.chat.DialogueExperiment.decode(t,t.uint32()));break;case 6:i.botType=t.int32();break;case 7:i.proactiveIntent=t.string();break;case 8:i.portaled=t.bool();break;default:t.skipType(7&e)}}return i},t.getTypeUrl=function(){return"type.googleapis.com/chat.DialogueChatSystemSettings"},t})(h.DialogueChatSystemSettings||{}),h.ProactiveSettings=(function(t){function t(t){if(t)for(let e=Object.keys(t),a=0;a>>3){case 1:i.proactiveType=t.int32();break;case 2:i.whenToShowControlledByProvider=t.bool();break;case 3:i.secondsUntilShown=t.uint64();break;case 4:i.coolOffPeriodMinutes=t.uint64();break;default:t.skipType(7&e)}}return i},t.getTypeUrl=function(){return"type.googleapis.com/chat.ProactiveSettings"},t})(h.ProactiveSettings||{}),h.ChatHmacInput=(function(t){function t(t){if(t)for(let e=Object.keys(t),a=0;a>>3){case 1:i.widgetId=t.string();break;default:t.skipType(7&e)}}return i},t.getTypeUrl=function(){return"type.googleapis.com/chat.ChatHmacInput"},t})(h.ChatHmacInput||{}),h.CampaignResult=(function(t){function t(t){if(t)for(let e=Object.keys(t),a=0;a>>3){case 1:i.campaignId=t.uint64();break;case 2:i.versionId=t.uint64();break;case 3:i.campaignName=t.string();break;case 4:i.versionName=t.string();break;case 5:i.snapengageChatSystemSettings=o.chat.SnapengageChatSystemSettings.decode(t,t.uint32());break;case 14:i.dialogueChatSystemSettings=o.chat.DialogueChatSystemSettings.decode(t,t.uint32());break;case 6:i.mustHaveAvailableAgents=t.bool();break;case 7:i.proactiveSettings=o.chat.ProactiveSettings.decode(t,t.uint32());break;case 8:i.greetingMessage=t.string();break;case 9:i.chatInitialState=t.int32();break;case 10:i.persistenceCookie=t.string();break;case 11:i.deprecatedExperimentNameToLog=t.string();break;case 12:i.deprecatedExperimentVariantToLog=t.string();break;case 13:i.isControl=t.bool();break;case 15:i.chatHmacInput=o.chat.ChatHmacInput.decode(t,t.uint32());break;default:t.skipType(7&e)}}return i},t.getTypeUrl=function(){return"type.googleapis.com/chat.CampaignResult"},t})(h.CampaignResult||{}),h.ChatProviderMetadata=(function(t){function t(t){if(t)for(let e=Object.keys(t),a=0;a>>3){case 1:i.snapengage=o.chat.SnapengageChatMetadata.decode(t,t.uint32());break;default:t.skipType(7&e)}}return i},t.getTypeUrl=function(){return"type.googleapis.com/chat.ChatProviderMetadata"},t})(h.ChatProviderMetadata||{}),h.ChatInitializerProperties=(function(t){function t(t){if(this.featureGates={},t)for(let e=Object.keys(t),a=0;a>>3){case 1:h.chatMetadata=o.chat.ChatMetadata.decode(t,t.uint32());break;case 2:h.userProperties=o.chat.UserProperties.decode(t,t.uint32());break;case 3:h.campaignResult=o.chat.CampaignResult.decode(t,t.uint32());break;case 4:h.resume=t.bool();break;case 5:h.chatProviderType=t.int32();break;case 6:h.snapengageChatMetadata=o.chat.SnapengageChatMetadata.decode(t,t.uint32());break;case 10:h.solvvyChatMetadata=o.chat.SolvvyChatMetadata.decode(t,t.uint32());break;case 7:h.loggingCorrelationId=t.string();break;case 8:{h.featureGates===r.emptyObject&&(h.featureGates={});let e=t.uint32()+t.pos;for(a="",i=!1;t.pos>>3){case 1:a=t.string();break;case 2:i=t.bool();break;default:t.skipType(7&e)}}h.featureGates[a]=i;break}case 9:h.providerMetadata=o.chat.ChatProviderMetadata.decode(t,t.uint32());break;default:t.skipType(7&e)}}return h},t.getTypeUrl=function(){return"type.googleapis.com/chat.ChatInitializerProperties"},t})(h.ChatInitializerProperties||{}),h)})),define("metaserver/static/js/modules/clean/chat/chat_client",["require","exports","tslib","metaserver/static/js/dropbox/proto/js_init_data/chat/chat","metaserver/static/js/modules/core/cookies","metaserver/static/js/modules/clean/chat/chat_identifier","metaserver/static/js/modules/clean/chat/chat_provider_api","metaserver/static/js/modules/clean/chat/chat_client_api","metaserver/static/js/modules/clean/chat/chat_provider_factory","metaserver/static/js/proto_utils/unpack","metaserver/static/js/modules/core/browser","metaserver/static/js/modules/clean/analytics","metaserver/static/js/modules/clean/amp_web_logger","metaserver/static/js/modules/clean/ncct/manual_assist_util","metaserver/static/js/modules/clean/deprecated_ajax/ajax","metaserver/static/js/modules/clean/stormcrow/stormcrow_exposure_logger","metaserver/static/js/modules/clean/chat/chat_logger_api","metaserver/static/js/modules/clean/chat/chat_logger_factory"],(function(t,e,a,i,n,s,r,o,h,c,p,d,l,g,u,m,C,_){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.moduleInit=e.ChatClientSingleton=e._ChatClientSingleton=e.ChatStartSourceType=void 0,p=a.__importStar(p);var S,v;(function(t){t[t.NOT_SHOWN=0]="NOT_SHOWN",t[t.TO_SHOW_PROVIDER_REACTIVE_BUTTON_ON_LOAD=1]="TO_SHOW_PROVIDER_REACTIVE_BUTTON_ON_LOAD",t[t.TO_SHOW_PROVIDER_REACTIVE_BUTTON_ON_AGENT_STATUS_UPDATE=2]="TO_SHOW_PROVIDER_REACTIVE_BUTTON_ON_AGENT_STATUS_UPDATE",t[t.REQUESTED_PROVIDER_TO_SHOW_REACTIVE_BUTTON=3]="REQUESTED_PROVIDER_TO_SHOW_REACTIVE_BUTTON",t[t.SHOWING_PROVIDER_REACTIVE_BUTTON=4]="SHOWING_PROVIDER_REACTIVE_BUTTON",t[t.SHOWING_CHAT=5]="SHOWING_CHAT",t[t.TO_START_ON_LOAD=6]="TO_START_ON_LOAD",t[t.TO_START_ON_AGENT_STATUS_UPDATE=7]="TO_START_ON_AGENT_STATUS_UPDATE",t[t.REQUESTED_PROVIDER_TO_START_CHAT=8]="REQUESTED_PROVIDER_TO_START_CHAT",t[t.CHAT_ONGOING=9]="CHAT_ONGOING"})(S||(S={})),(function(t){t[t.REACTIVE=0]="REACTIVE",t[t.PROACTIVE=1]="PROACTIVE",t[t.RESUME=2]="RESUME",t[t.TRANSFER=3]="TRANSFER",t[t.PROVIDER_DRIVEN_PROACTIVE=4]="PROVIDER_DRIVEN_PROACTIVE"})(v=e.ChatStartSourceType||(e.ChatStartSourceType={}));class T extends o.ChatClient{constructor(t,e,a){super(t,e),this.setupChatEnvironment=t=>{if(this._isSetup)return;if(t.featureGates.enable_vortex_logger&&(this.logger=this.loggerFactory.getChatLogger(C.LoggerType.HIVE_VORTEX_COMBO)),!this.shouldAllowChat())return;if(this.initProperties=t,this.setupTime=new Date,this.hasFirstLoadOccured=!1,this.state={lifecycleState:S.NOT_SHOWN,hasShownAChat:!1,interactedWithChat:!1,cookieBannerState:{isVisible:!1,height:0}},!t.chatMetadata)throw new Error("Did not provide chat metadata.");if(this.metadata=t.chatMetadata,!t.userProperties)throw new Error("Did not provide user properties.");const e=this.getChatProviderMetadata(t),a=t.campaignResult;if(this.setupProvider(a,e,t.userProperties,t.chatProviderType),a&&a.isControl)this.setupControlLogging(a);else{const e=a&&a.chatInitialState===i.chat.ChatInitialState.SHOW_PROVIDER_REACTIVE_BUTTON;if(t.resume){const t=this.chatCampaignWrapper||this.defaultChatWrapper;this.deprecatedLogChatAction("chat_persistence",s.getSnapengageWidgetId(t.chatCampaign)),this.intializeStartingChat(t,v.RESUME)}else this.setupProactivePropertiesIfNeeded(),e&&(this.attemptToShowProviderReactiveChatButton(),this.deprecatedMaybeLogExperiment(a))}window.addEventListener("beforeunload",()=>{this.maybeLogImpressionFailedOnUnload()})},this.startReactiveChat=()=>{if(this.logEvent(C.ChatEvent.CLICK,{source:"startReactiveChat"}),!this.shouldAllowChat())return void this.logEvent(C.ChatEvent.IMPRESSION_FAILED,{failed_reason:C.FailedReason.CHAT_IS_NOT_ALLOWED});if(this.logAndRaiseIfNotSetup(),!this.canStartChat())return;let t=this.chatCampaignWrapper;const e=t&&s.isCampaignResult(t.chatCampaign)&&t.chatCampaign.isControl;if(!this.chatCampaignWrapper||e)return t=this.defaultChatWrapper,this.deprecatedLogChatAction("chat_initiated",s.getSnapengageWidgetId(t.chatCampaign)),void this.intializeStartingChat(t,v.REACTIVE);this.deprecatedLogChatAction("chat_initiated",s.getSnapengageWidgetId(t.chatCampaign)),this.intializeStartingChat(this.chatCampaignWrapper,v.REACTIVE)},this.startSupportChat=t=>{this.logEvent(C.ChatEvent.CLICK,{source:"startSupportChat",widgetOverride:t}),this.shouldAllowChat()?(this.logAndRaiseIfNotSetup(),this.canStartChat()&&(this.supportChatWrapper={chatCampaign:t,chatCampaignState:this.getInitialChatCampaignState()},g.isNCCTChat(t)&&u.WebRequest({url:"/team/admin/engaged_chat",data:{chatId:t}}),this.deprecatedLogChatAction("support_chat_initiated",t),this.intializeStartingChat(this.supportChatWrapper,v.REACTIVE))):this.logEvent(C.ChatEvent.IMPRESSION_FAILED,{failed_reason:C.FailedReason.CHAT_IS_NOT_ALLOWED,widgetOverride:t})},this.isSetup=()=>this._isSetup,this.setCookieBannerInfo=(t,e)=>{this.state.cookieBannerState={isVisible:t,height:e},this.adjustProviderMarginOnStateChange()},this.adjustProviderMarginOnStateChange=()=>{this.state.cookieBannerState.isVisible?this.state.lifecycleState===S.CHAT_ONGOING||this.state.lifecycleState===S.SHOWING_CHAT?this.provider.removeBottomMargin():this.provider.addBottomMargin(this.state.cookieBannerState.height):this.provider.removeBottomMargin()},this.modifyLifecycleState=t=>{this.state.lifecycleState=t,this.adjustProviderMarginOnStateChange()},this.logAndRaiseIfNotSetup=()=>{if(!this._isSetup)throw this.logEvent(C.ChatEvent.IMPRESSION_FAILED,{failed_reason:C.FailedReason.CHAT_IS_NOT_INITIALIZED}),this.logError(C.ErrorType.ATTEMPT_TO_START_UNINITIALIZED_CHAT),new Error("Started chat without being initialized")},this.setupProvider=(t,e,a,i)=>{const n={chatCampaign:t,metadata:e,userProperties:a,onAgentStatusUpdate:this.onAgentStatusUpdate,onChatLoadStatusUpdate:this.onChatLoadStatusUpdate,onChatShown:this.onChatShown,onChatStarted:this.onChatStarted,onChatClosed:this.onChatClosed,onChatMinimized:this.onChatMinimized,onChatMaximized:this.onChatMaximized,onProviderDrivenOpenProactive:this.onProviderDrivenOpenProactive,onProviderReactiveButtonShown:this.onProviderReactiveButtonShown,onSwitchProviderWithNewCampaign:this.onSwitchProviderWithNewCampaign};t&&(this.chatCampaignWrapper={chatCampaign:t,chatCampaignState:this.getInitialChatCampaignState()}),this.provider=this.getChatProvider(i,n),this.defaultChatWrapper={chatCampaign:this.provider.getDefaultChatIdentifier(),chatCampaignState:this.getInitialChatCampaignState()},this._isSetup=!0},this.attemptToShowProviderReactiveChatButton=()=>{const t=this.chatCampaignWrapper;t&&s.isCampaignResult(t.chatCampaign)&&(this.state.campaign=t.chatCampaign,this.state.source_type=v.REACTIVE,t.chatCampaignState.isLoaded?s.isCampaignResult(t.chatCampaign)&&t.chatCampaign.mustHaveAvailableAgents?this.attemptToShowReactiveButtonChatThatMustHaveAgents(t):this.requestProviderToShowProviderReactiveButton():this.requestProviderToLoadChatToShowProviderReactiveButton(t))},this.requestProviderToShowProviderReactiveButton=()=>{this.modifyLifecycleState(S.REQUESTED_PROVIDER_TO_SHOW_REACTIVE_BUTTON),this.provider.showProviderReactiveChatButton();const t=this.chatCampaignWrapper||this.defaultChatWrapper;this.deprecatedLogChatAction("minimized_chat_initiated",s.getSnapengageWidgetId(t.chatCampaign))},this.requestProviderToGetAgentStatusUpdateToShowProviderReactiveButton=t=>{this.modifyLifecycleState(S.TO_SHOW_PROVIDER_REACTIVE_BUTTON_ON_AGENT_STATUS_UPDATE),this.provider.requestAgentStatusUpdate(t.chatCampaign)},this.requestProviderToLoadChatToShowProviderReactiveButton=t=>{this.modifyLifecycleState(S.TO_SHOW_PROVIDER_REACTIVE_BUTTON_ON_LOAD),this.provider.requestAgentStatusUpdate(t.chatCampaign)},this.canStartChat=()=>{const t=this.state.lifecycleState;return t===S.NOT_SHOWN||t===S.TO_SHOW_PROVIDER_REACTIVE_BUTTON_ON_LOAD||t===S.TO_SHOW_PROVIDER_REACTIVE_BUTTON_ON_AGENT_STATUS_UPDATE||t===S.REQUESTED_PROVIDER_TO_SHOW_REACTIVE_BUTTON||t===S.SHOWING_PROVIDER_REACTIVE_BUTTON},this.intializeStartingChat=(t,e)=>{this.state.source_type=e,this.state.campaign=t.chatCampaign,this.attemptToStartChat(t)},this.attemptToStartChat=t=>{const e=this.state.source_type,a=e===v.PROACTIVE||e===v.PROVIDER_DRIVEN_PROACTIVE;t.chatCampaignState.isLoaded?a&&s.isCampaignResult(t.chatCampaign)&&t.chatCampaign.mustHaveAvailableAgents?this.attemptToStartChatThatMustHaveAgents(t,e===v.PROVIDER_DRIVEN_PROACTIVE):e===v.PROVIDER_DRIVEN_PROACTIVE?this.requestProviderToHandleProviderDrivenOpen():this.requestProviderToStartChat(t):this.requestProviderToLoadChatToStartChat(t)},this.requestProviderToHandleProviderDrivenOpen=()=>{this.provider.handleProviderDrivenOpen(),this.modifyLifecycleState(S.SHOWING_CHAT)},this.requestProviderToStartChat=t=>{this.modifyLifecycleState(S.REQUESTED_PROVIDER_TO_START_CHAT),this.provider.startChat(t.chatCampaign,this.state.source_type===v.PROACTIVE)},this.requestProviderToGetAgentStatusUpdateToStartChat=t=>{this.modifyLifecycleState(S.TO_START_ON_AGENT_STATUS_UPDATE),this.provider.requestAgentStatusUpdate(t.chatCampaign)},this.setupProactivePropertiesIfNeeded=()=>{const t=this.chatCampaignWrapper;if(!t||!s.isCampaignResult(t.chatCampaign))return;const e=t.chatCampaign,a=e.proactiveSettings;if(!a||a.whenToShowControlledByProvider||e.isControl)return;if(!e.greetingMessage)return void this.logError(C.ErrorType.ATTEMPT_START_PROACTIVE_CHAT_WITHOUT_MESSAGE);const i=this.readProactiveChatCooloffCookie();if(i)return void this.logEvent(C.ChatEvent.IMPRESSION_FAILED,{failed_reason:C.FailedReason.COOLOFF_PERIOD,debug_info:i},e);const n=1e3*a.secondsUntilShown;setTimeout(()=>{this.state.hasShownAChat||this.state.campaign&&this.state.campaign!==e?this.logEvent(C.ChatEvent.IMPRESSION_FAILED,{failed_reason:C.FailedReason.ANOTHER_CHAT_STARTED},e):this.intializeStartingChat(t,v.PROACTIVE)},n)},this.setupControlLogging=t=>{const e=t.proactiveSettings,a=()=>{let e=C.FailedReason.CONTROL_VERSION;this.readProactiveChatCooloffCookie()?e=C.FailedReason.COOLOFF_PERIOD:this.state.campaign&&this.state.campaign!==t?e=C.FailedReason.ANOTHER_CHAT_STARTED:this.chatCampaignWrapper&&this.chatCampaignWrapper.chatCampaignState.agentStatus!==r.AgentStatus.ONLINE&&s.isCampaignResult(this.chatCampaignWrapper.chatCampaign)&&this.chatCampaignWrapper.chatCampaign.mustHaveAvailableAgents&&(e=C.FailedReason.NO_ONLINE_AGENTS),this.logEvent(C.ChatEvent.IMPRESSION_FAILED,{failed_reason:e},t)};if(!e)return void a();const i=1e3*e.secondsUntilShown;setTimeout(a,i),setTimeout(()=>this.deprecatedMaybeLogExperiment(t),i)},this.getPersistenceCookie=t=>s.isCampaignResult(t)?t.persistenceCookie:`SNAPENGAGE:${t}`,this.setChatVisibleCookie=t=>{if(!this.metadata)return;const e=this.getPersistenceCookie(t),a=this.getLegacyCampaignIdentifierToCookieStr(t);a&&n.Cookies.create(this.metadata.legacyCookieCampaignName,a,1,this.metadata.cookieDomain),n.Cookies.create(this.metadata.cookieCampaignName,e,1,this.metadata.cookieDomain)},this.maybeSetProactiveChatCooloffCookie=(t,e)=>{if(this.metadata&&t===v.PROACTIVE&&e&&s.isCampaignResult(e.chatCampaign)&&e.chatCampaign.proactiveSettings&&e.chatCampaign.proactiveSettings.coolOffPeriodMinutes){const t=e.chatCampaign,a=(new Date).getTime(),i=`${t.campaignId}:${t.versionId}:${a}`,s=t.proactiveSettings.coolOffPeriodMinutes/1440;n.Cookies.create("MegaphoneChatCooloff",i,s,this.metadata.cookieDomain)}},this.readProactiveChatCooloffCookie=()=>n.Cookies.read("MegaphoneChatCooloff"),this.getInitialChatCampaignState=()=>({isLoaded:!1,agentStatus:r.AgentStatus.UNKNOWN}),this.getWrapperFromIdentifier=t=>this.chatCampaignWrapper&&s.areChatCampaignsEqual(this.chatCampaignWrapper.chatCampaign,t)?this.chatCampaignWrapper:s.areChatCampaignsEqual(this.defaultChatWrapper.chatCampaign,t)?this.defaultChatWrapper:this.supportChatWrapper&&s.areChatCampaignsEqual(this.supportChatWrapper.chatCampaign,t)?this.supportChatWrapper:void 0,this.getLegacyCampaignIdentifierToCookieStr=t=>s.isCampaignResult(t)?t.snapengageChatSystemSettings?t.snapengageChatSystemSettings.widgetId:null:t,this.legacyToggleOutsideChatVisibilityOnAgentStatusUpdate=t=>{this.modifyVisibility("[data-snap-engage-visibility]",!1),t===r.AgentStatus.ONLINE?this.modifyVisibility('[data-snap-engage-visibility="online"]',!0):this.modifyVisibility('[data-snap-engage-visibility="offline"]',!0)},this.modifyVisibility=(t,e)=>{const a=e?"inline":"none",i=document.querySelectorAll(t);for(let t=0;t{const a=s.areChatCampaignsEqual(this.state.campaign,t),i=this.state.lifecycleState,n=i===S.TO_SHOW_PROVIDER_REACTIVE_BUTTON_ON_AGENT_STATUS_UPDATE&&a,r=i===S.TO_START_ON_AGENT_STATUS_UPDATE&&a,o=this.getWrapperFromIdentifier(t);void 0!==o&&(o.chatCampaignState.agentStatus=e,this.legacyToggleOutsideChatVisibilityOnAgentStatusUpdate(e),n?this.attemptToShowProviderReactiveChatButton():r&&this.attemptToStartChat(o))},this.onChatLoadStatusUpdate=(t,e)=>{if(!this.hasFirstLoadOccured&&e){this.hasFirstLoadOccured=!0;const e=((new Date).valueOf()-this.setupTime.valueOf()).toString();this.logEvent(C.ChatEvent.INITIALIZED,{init_latency_ms:e}),this.deprecatedLogChatAction("snapengage_loaded",s.getSnapengageWidgetId(t),{total_time:e})}const a=s.areChatCampaignsEqual(this.state.campaign,t),i=this.state.lifecycleState,n=i===S.TO_SHOW_PROVIDER_REACTIVE_BUTTON_ON_LOAD&&a,r=i===S.TO_START_ON_LOAD&&a,o=this.getWrapperFromIdentifier(t);void 0!==o&&(o.chatCampaignState.isLoaded=e,e&&this.provider.requestAgentStatusUpdate(t),n?this.attemptToShowProviderReactiveChatButton():r&&this.attemptToStartChat(o))},this.onProviderReactiveButtonShown=()=>{this.state.lifecycleState===S.REQUESTED_PROVIDER_TO_SHOW_REACTIVE_BUTTON&&(this.modifyLifecycleState(S.SHOWING_PROVIDER_REACTIVE_BUTTON),this.logEvent(C.ChatEvent.IMPRESSION,{impression_type:C.ImpressionType.CHAT_ICON}))},this.onProviderDrivenOpenProactive=t=>{this.chatCampaignWrapper&&s.areChatCampaignsEqual(this.chatCampaignWrapper.chatCampaign,t)&&(this.state.hasShownAChat||(this.logEvent(C.ChatEvent.IMPRESSION,{impression_type:C.ImpressionType.PROACTIVE_CHAT}),this.deprecatedMaybeLogExperiment(t),this.deprecatedLogChatAction("proactive_chat_opened",s.getSnapengageWidgetId(t)),this.canStartChat()&&this.intializeStartingChat(this.chatCampaignWrapper,v.PROVIDER_DRIVEN_PROACTIVE)))},this.onChatShown=t=>{this.state.lifecycleState!==S.SHOWING_PROVIDER_REACTIVE_BUTTON&&this.state.lifecycleState!==S.REQUESTED_PROVIDER_TO_START_CHAT||s.areChatCampaignsEqual(this.state.campaign,t),this.modifyLifecycleState(S.SHOWING_CHAT),this.state.campaign=t,this.state.hasShownAChat=!0,this.state.source_type===v.RESUME?(this.provider.updateHmac(),this.state.interactedWithChat=!0,this.logEvent(C.ChatEvent.IMPRESSION,{impression_type:C.ImpressionType.RESUMED_CHAT})):this.state.source_type!==v.REACTIVE||this.impressionLogged||this.logEvent(C.ChatEvent.IMPRESSION,{impression_type:C.ImpressionType.REACTIVE_CHAT})},this.onChatStarted=t=>{const e=this.state.source_type;if(void 0!==e){let a;this.state.interactedWithChat=!0;let i=C.InteractionType.UNKNOWN;e===v.RESUME?(a="chat_persistence_init",i=C.InteractionType.RESUMED_CHAT):e===v.PROACTIVE||e===v.PROVIDER_DRIVEN_PROACTIVE?(a="proactive_chat_initiated",i=C.InteractionType.PROACTIVE_CHAT,g.isNCCTChat(s.getSnapengageWidgetId(t))&&u.WebRequest({url:"/team/admin/engaged_chat",data:{chatId:s.getSnapengageWidgetId(t)}})):e===v.REACTIVE?(a="reactive_chat_initiated",i=C.InteractionType.REACTIVE_CHAT):e===v.TRANSFER&&(i=C.InteractionType.TRANSFERRED_CHAT),this.logEvent(C.ChatEvent.INTERACT,{interaction_type:i}),void 0!==a&&this.deprecatedLogChatAction(a,s.getSnapengageWidgetId(t))}else this.logError(C.ErrorType.CHAT_STARTED_FROM_UNKNOWN_SOURCE);this.setChatVisibleCookie(t),this.modifyLifecycleState(S.CHAT_ONGOING)},this.onChatClosed=(t,e)=>{this.handleCookieOnClosed(this.state.source_type,this.chatCampaignWrapper);let a=void 0,i=r.AgentStatus.UNKNOWN;void 0!==e.agentStatus&&(a=e.agentStatus===r.AgentStatus.ONLINE?"online":"offline",i=e.agentStatus===r.AgentStatus.ONLINE?r.AgentStatus.ONLINE:r.AgentStatus.OFFLINE),this.deprecatedLogChatAction("snapengage_chat_close",s.getSnapengageWidgetId(t),{type:e.chatType,agent_status:a});const n=this.state.interactedWithChat?C.ChatEvent.CLOSE:C.ChatEvent.DISMISSED;this.logEvent(n,{agents_status:i,chat_form_type:e.chatType}),this.resetChatState()},this.onChatMinimized=t=>{this.modifyLifecycleState(S.SHOWING_PROVIDER_REACTIVE_BUTTON)},this.onChatMaximized=t=>{this.modifyLifecycleState(S.SHOWING_CHAT)},this.onSwitchProviderWithNewCampaign=(t,e)=>{const a=this.provider;let i;a.handleTransferEvent(r.TransferEvent.START_TRANSFER);try{const e=this.getChatProviderMetadata(t);if(!t.userProperties)throw new Error("User properties cannot be empty");this.setupProvider(t.campaignResult,e,t.userProperties,t.chatProviderType),i=t.campaignResult}catch(t){return void a.handleTransferEvent(r.TransferEvent.ERROR_ON_TRANSFER)}this.logEvent(C.ChatEvent.TRANSFER,{},i),this.onChatLoadStatusUpdate(e,!1),this.onAgentStatusUpdate(e,r.AgentStatus.UNKNOWN),this.resetChatState(),this.provider.requestAgentStatusUpdate(i),a.handleTransferEvent(r.TransferEvent.END_TRANSFER),this.setChatVisibleCookie(i),this.intializeStartingChat(this.chatCampaignWrapper,v.TRANSFER)},this.getChatProviderMetadata=t=>{let e;if("snapengageChatMetadata"===t.chatProviderMetadata)e=t.snapengageChatMetadata;else if(t.chatProviderType!==i.chat.ChatProviderType.DIALOGUE_CHAT)throw new Error("No provider metadata provided");return e},this.maybeLogImpressionFailedOnUnload=()=>{if(!this.impressionLogged){const t=(new Date).valueOf()-this.setupTime.valueOf();this.logEvent(C.ChatEvent.IMPRESSION_FAILED,{failed_reason:C.FailedReason.NOT_ENOUGH_TIME_ON_PAGE,time_on_page_ms:t.toString()})}},this.logEvent=(t,e,a)=>{t!==C.ChatEvent.IMPRESSION&&t!==C.ChatEvent.IMPRESSION_FAILED||(this.impressionLogged=!0),this.logger.logEvent(t,this.createEventData(e,a))},this.logError=t=>{this.logEvent(C.ChatEvent.ERROR,{error_type:t})},this.createEventData=(t,e)=>{var a;let i="-1",r=-1,o=-1,h="";if(this.initProperties.userProperties&&(i=this.initProperties.userProperties.userId),e)r=e.campaignId,o=e.versionId,h=(null===(a=e.snapengageChatSystemSettings)||void 0===a?void 0:a.widgetId)||"";else{const t=this.chatCampaignWrapper||this.defaultChatWrapper;t&&(h=s.getSnapengageWidgetId(t.chatCampaign)||"",s.isCampaignResult(t.chatCampaign)&&(r=t.chatCampaign.campaignId,o=t.chatCampaign.versionId))}return t.chat_session_id||(t.chat_session_id=n.Cookies.read("SnapABugChatSession")||""),{userId:i,campaignId:r,versionId:o,widgetId:h,correlationId:this.initProperties.loggingCorrelationId,platform:"WEB",eventDetails:t}},this.loggerFactory=a,this.logger=a.getChatLogger(),this.getChatProvider=t,this.shouldAllowChat=e,this._isSetup=!1}attemptToShowReactiveButtonChatThatMustHaveAgents(t){const e=t.chatCampaignState.agentStatus;e===r.AgentStatus.UNKNOWN?this.requestProviderToGetAgentStatusUpdateToShowProviderReactiveButton(t):e===r.AgentStatus.OFFLINE?(this.deprecatedLogChatAction("chat_agent_must_be_online_but_was_offline",s.getSnapengageWidgetId(t.chatCampaign)),this.logEvent(C.ChatEvent.IMPRESSION_FAILED,{failed_reason:C.FailedReason.NO_ONLINE_AGENTS}),this.resetChatState()):this.requestProviderToShowProviderReactiveButton()}attemptToStartChatThatMustHaveAgents(t,e){const a=t.chatCampaignState.agentStatus;a===r.AgentStatus.UNKNOWN?this.requestProviderToGetAgentStatusUpdateToStartChat(t):a===r.AgentStatus.OFFLINE?(this.logEvent(C.ChatEvent.IMPRESSION_FAILED,{failed_reason:C.FailedReason.NO_ONLINE_AGENTS}),this.resetChatState()):e?this.requestProviderToHandleProviderDrivenOpen():this.requestProviderToStartChat(t)}requestProviderToLoadChatToStartChat(t){this.modifyLifecycleState(S.TO_START_ON_LOAD),this.provider.loadChatIfNecessary(t.chatCampaign)}handleCookieOnClosed(t,e){this.metadata&&(n.Cookies.delete(this.metadata.cookieCampaignName),n.Cookies.delete(this.metadata.legacyCookieCampaignName),this.maybeSetProactiveChatCooloffCookie(t,e))}deprecatedLogChatAction(t,e,a){if(!e)return;const i={chat_widget_id:e,url:p.get_href()},n=Object.assign(Object.assign({},i),a);d.TeamsWebActionsLogger.log(t,n),l.getAMPWebLogger().logEventCount("chat_events",t,{chat_widget_id:e})}deprecatedMaybeLogExperiment(t){if(!s.isCampaignResult(t))return;const{deprecatedExperimentNameToLog:e,deprecatedExperimentVariantToLog:a}=t;if(e&&a){(new m.StormcrowExposureLogger).logExposure(e,a)}}resetChatState(){this.modifyLifecycleState(S.NOT_SHOWN),this.state.campaign=void 0,this.state.source_type=void 0,this.state.interactedWithChat=!1}}e._ChatClientSingleton=T;e.ChatClientSingleton=new T(h.ChatProviderFactorySingleton.getChatProvider,()=>top===window,_.ChatLoggerFactorySingleton),e.moduleInit=function(t){const a=c.unpackProto(t,i.chat.ChatInitializerProperties);e.ChatClientSingleton.setupChatEnvironment(a)}})),define("metaserver/static/js/modules/clean/chat/chat_client_api",["require","exports"],(function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ChatClient=void 0;e.ChatClient=class{constructor(t,e){this.setupChatEnvironment=t=>{},this.startReactiveChat=()=>{},this.startSupportChat=t=>{},this.setCookieBannerInfo=(t,e)=>{}}}})),define("metaserver/static/js/modules/clean/chat/chat_client_factory",["require","exports","metaserver/static/js/modules/clean/chat/chat_wrapper"],(function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ChatClientFactory=void 0;e.ChatClientFactory=new class{constructor(){this.getClient=()=>a.ChatWrapperSingleton}}}));var __createBinding=this&&this.__createBinding||(Object.create?function(t,e,a,i){void 0===i&&(i=a),Object.defineProperty(t,i,{enumerable:!0,get:function(){return e[a]}})}:function(t,e,a,i){void 0===i&&(i=a),t[i]=e[a]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),__importStar=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var a in t)"default"!==a&&Object.prototype.hasOwnProperty.call(t,a)&&__createBinding(e,t,a);return __setModuleDefault(e,t),e};define("metaserver/static/js/modules/clean/chat/chat_client_loader",["require","exports","metaserver/static/js/modules/clean/web_timing_logger"],(function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.initialize_module=e.ChatClientLoaderSingleton=e._ChatClientLoaderDoNotUseDirectly=void 0;class i{constructor(){this.loadClient=(t,e)=>{if(t){const a=e.chatStoneToProtoModule.chatStoneToProto(t);e.chatClientModule.ChatClientSingleton.setupChatEnvironment(a)}},this.getBestChatCampaignAndLoadChatClient=(t,e,a)=>{const i={url:t};if(a){return(new e.userClientModule.UserApiV2Client).ns("megaphone_chat").rpc("get_best_chat_campaigns",i,{subjectUserId:a}).then(t=>this.loadClient(t.props,e))}return(new e.noAuthClientModule.NoAuthApiV2Client).ns("megaphone_chat").rpc("get_best_chat_campaigns",i,{}).then(t=>this.loadClient(t.props,e))},this.getChatCampaignByIdAndLoadClient=(t,e,a,i)=>{const n={url:t,campaign_id:e,locale:window.navigator.language?window.navigator.language:window.navigator.browserLanguage};if(i){return(new a.userClientModule.UserApiV2Client).ns("megaphone_chat").rpc("get_chat_campaign_by_id",n,{subjectUserId:i}).then(t=>this.loadClient(t.props,a))}return(new a.noAuthClientModule.NoAuthApiV2Client).ns("megaphone_chat").rpc("get_chat_campaign_by_id",n,{}).then(t=>this.loadClient(t.props,a))},this.resumeOrGetBestChatCampaignAndLoadClient=(t,e,a,i)=>t?Promise.resolve(this.loadClient(t,e)):this.getBestChatCampaignAndLoadChatClient(a,e,i),this.getResumedChatCampaignAndLoadClient=(t,e,a,i,n)=>{const s={url:t,legacy_persistence_cookie:e||"",chat_persistence_cookie:a||""};if(n){return(new i.userClientModule.UserApiV2Client).ns("megaphone_chat").rpc("get_resumed_chat_campaign",s,{subjectUserId:n}).then(e=>this.resumeOrGetBestChatCampaignAndLoadClient(e.props,i,t,n))}return(new i.noAuthClientModule.NoAuthApiV2Client).ns("megaphone_chat").rpc("get_resumed_chat_campaign",s,{}).then(e=>this.resumeOrGetBestChatCampaignAndLoadClient(e.props,i,t,n))},this.importDependencies=()=>Promise.all([new Promise((e,a)=>{t(["metaserver/static/js/api_v2/user_client"],e,a)}).then(__importStar),new Promise((e,a)=>{t(["metaserver/static/js/api_v2/noauth_client"],e,a)}).then(__importStar),new Promise((e,a)=>{t(["metaserver/static/js/modules/clean/chat/chat_stone_to_proto"],e,a)}).then(__importStar),new Promise((e,a)=>{t(["metaserver/static/js/modules/clean/chat/chat_client"],e,a)}).then(__importStar),new Promise((e,a)=>{t(["metaserver/static/js/modules/core/cookies"],e,a)}).then(__importStar),new Promise((e,a)=>{t(["metaserver/static/js/modules/clean/chat/chat_constants"],e,a)}).then(__importStar)]),this.getCookies=(t,e)=>{const{Cookies:a}=t,{SNAPENGAGE_CHAT_VISIBLE_COOKIE:i,CHAT_CAMPAIGN_VISIBLE_COOKIE:n}=e;return{legacy_persistence_cookie:a.read(i),chat_persistence_cookie:a.read(n)}},this.getCampaignFromChatServiceWithDependencies=([t,e,a,i,n,s],r,o)=>{const h={userClientModule:t,noAuthClientModule:e,chatStoneToProtoModule:a,chatClientModule:i,cookiesModule:n,chatConstantsModule:s},c=this.getCookies(n,s);return c.legacy_persistence_cookie||c.chat_persistence_cookie?this.getResumedChatCampaignAndLoadClient(r,c.legacy_persistence_cookie,c.chat_persistence_cookie,h,o):this.getBestChatCampaignAndLoadChatClient(r,h,o)},this.getChatCampaignIDFromChatServiceWithDependencies=([t,e,a,i,n,s],r,o,h)=>{const c={userClientModule:t,noAuthClientModule:e,chatStoneToProtoModule:a,chatClientModule:i,cookiesModule:n,chatConstantsModule:s},p=this.getCookies(n,s);return p.legacy_persistence_cookie||p.chat_persistence_cookie?this.getResumedChatCampaignAndLoadClient(r,p.legacy_persistence_cookie,p.chat_persistence_cookie,c,h):this.getChatCampaignByIdAndLoadClient(r,o,c,h)},this.loadChatClientWithBestCampaign=(t,e,i)=>{if(this.loadPromise)return this.loadPromise;const n=i?Promise.resolve():a.waitForTTI({timeoutMS:5e3});return this.loadPromise=n.then(()=>this.importDependencies()).then(a=>this.getCampaignFromChatServiceWithDependencies(a,t,e)),this.loadPromise},this.loadCampaignByID=(t,e,i)=>this.loadPromise?this.loadPromise:(this.loadPromise=a.waitForTTI({timeoutMS:5e3}).then(()=>this.importDependencies()).then(a=>this.getChatCampaignIDFromChatServiceWithDependencies(a,t,e,i)),this.loadPromise)}}e._ChatClientLoaderDoNotUseDirectly=i,e.ChatClientLoaderSingleton=new i,e.initialize_module=t=>{e.ChatClientLoaderSingleton.loadChatClientWithBestCampaign(t.url,t.userId,t.bypassWaitForTTI)}})),define("metaserver/static/js/modules/clean/chat/chat_constants",["require","exports"],(function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.SNAPENGAGE_CHAT_VISIBLE_COOKIE=e.CHAT_CAMPAIGN_VISIBLE_COOKIE=void 0,e.CHAT_CAMPAIGN_VISIBLE_COOKIE="chat-campaign-visible",e.SNAPENGAGE_CHAT_VISIBLE_COOKIE="db-snapengage-visible"})),define("metaserver/static/js/modules/clean/chat/chat_identifier",["require","exports"],(function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getSnapengageWidgetId=e.areChatCampaignsEqual=e.isSnapengageWidgetId=e.isCampaignResult=void 0,e.isCampaignResult=t=>void 0!==t.campaignId,e.isSnapengageWidgetId=t=>"string"==typeof t,e.areChatCampaignsEqual=(t,a)=>!!t&&(e.isCampaignResult(t)&&e.isCampaignResult(a)?t.campaignId===a.campaignId:!(!e.isSnapengageWidgetId(t)||!e.isSnapengageWidgetId(a))&&t===a),e.getSnapengageWidgetId=t=>e.isCampaignResult(t)?t.snapengageChatSystemSettings?t.snapengageChatSystemSettings.widgetId:null:t})),define("metaserver/static/js/modules/clean/chat/chat_logger",["require","exports","metaserver/static/js/modules/clean/logging/hive/schemas/megaphone-events"],(function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.TelemetryChatLogger=void 0;e.TelemetryChatLogger=class{constructor(t){this.logger=t}logEvent(t,e,i){const n={entity_type:"chat",event_name:t,correlation_id:e.correlationId,event_id:i,user_id:this.toNumber(e.userId),entity_id:this.toNumber(e.campaignId),version_id:this.toNumber(e.versionId),platform:e.platform,event_details:this.getEventDetails(t,e)};this.logger.log(new a.MegaphoneEventsRow(n))}toNumber(t,e=-1){return null==t||""===t?e:"string"==typeof t?parseInt(t,10):"number"==typeof t?t:t.toNumber()}getEventDetails(t,e){const a=Object.assign({},e.eventDetails);let i=e.widgetId;return e.eventDetails.widgetOverride&&(i=e.eventDetails.widgetOverride),a.widget_id=i,a}}})),define("metaserver/static/js/modules/clean/chat/chat_logger_api",["require","exports"],(function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.LoggerType=e.ErrorType=e.InteractionType=e.ImpressionType=e.FailedReason=e.ChatEvent=void 0,(function(t){t.INITIALIZED="initialized",t.IMPRESSION_FAILED="impression_failed",t.CLICK="click",t.IMPRESSION="impression",t.INTERACT="interact",t.DISMISSED="dismissed",t.CLOSE="close",t.ERROR="error",t.TRANSFER="transfer"})(e.ChatEvent||(e.ChatEvent={})),(function(t){t.CONTROL_VERSION="control_version",t.NO_ONLINE_AGENTS="no_online_agents",t.NOT_ENOUGH_TIME_ON_PAGE="not_enough_time_on_page",t.CHAT_IS_NOT_ALLOWED="chat_is_not_allowed",t.CHAT_IS_NOT_INITIALIZED="chat_is_not_initialized",t.ANOTHER_CHAT_STARTED="another_chat_started",t.COOLOFF_PERIOD="COOLOFF_PERIOD"})(e.FailedReason||(e.FailedReason={})),(function(t){t.CHAT_ICON="chat_icon",t.PROACTIVE_CHAT="proactive_chat",t.RESUMED_CHAT="resumed_chat",t.REACTIVE_CHAT="reactive_chat"})(e.ImpressionType||(e.ImpressionType={})),(function(t){t.UNKNOWN="unknown",t.RESUMED_CHAT="resumed_chat",t.PROACTIVE_CHAT="proactive_chat",t.REACTIVE_CHAT="reactive_chat",t.TRANSFERRED_CHAT="transferred_chat"})(e.InteractionType||(e.InteractionType={})),(function(t){t.ATTEMPT_TO_START_UNINITIALIZED_CHAT="attempt_to_start_uninitialized_chat",t.CHAT_STARTED_FROM_UNKNOWN_SOURCE="chat_started_from_unknown_source",t.ATTEMPT_START_PROACTIVE_CHAT_WITHOUT_MESSAGE="attempt_start_proactive_chat_without_message"})(e.ErrorType||(e.ErrorType={})),(function(t){t.DEFAULT="default",t.HIVE_VORTEX_COMBO="hive_vortex_combo"})(e.LoggerType||(e.LoggerType={}))})),define("metaserver/static/js/modules/clean/chat/chat_logger_factory",["require","exports","tslib","metaserver/static/js/modules/clean/chat/chat_logger_api","metaserver/static/js/modules/clean/chat/chat_logger","metaserver/static/js/modules/clean/logging/telemetry"],(function(t,e,a,i,n,s){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ChatLoggerFactorySingleton=void 0;const r=new((s=a.__importStar(s)).HiveLogger),o=new s.VortexComboLogger;e.ChatLoggerFactorySingleton=new class{getChatLogger(t=i.LoggerType.DEFAULT){const e=t===i.LoggerType.HIVE_VORTEX_COMBO?o:r;return new n.TelemetryChatLogger(e)}}})),define("metaserver/static/js/modules/clean/chat/chat_provider_api",["require","exports"],(function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ChatProvider=e.TransferEvent=e.AgentStatus=void 0,(function(t){t.UNKNOWN="unknown",t.OFFLINE="offline",t.ONLINE="online"})(e.AgentStatus||(e.AgentStatus={})),(function(t){t.START_TRANSFER="startTransfer",t.END_TRANSFER="endTransfer",t.ERROR_ON_TRANSFER="errorOnTransfer"})(e.TransferEvent||(e.TransferEvent={}));e.ChatProvider=class{constructor(t){this.addBottomMargin=t=>{},this.removeBottomMargin=()=>{}}}})),define("metaserver/static/js/modules/clean/chat/chat_provider_factory",["require","exports","metaserver/static/js/dropbox/proto/js_init_data/chat/chat","metaserver/static/js/modules/clean/chat/snapengage_chat_provider","metaserver/static/js/modules/clean/chat/dialogue/dialogue_chat_provider"],(function(t,e,a,i,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ChatProviderFactorySingleton=void 0;e.ChatProviderFactorySingleton=new class{constructor(){this.getChatProvider=(t,e)=>{if(t===a.chat.ChatProviderType.SNAPENGAGE)return new i.SnapengageChatProvider(e);if(t===a.chat.ChatProviderType.DIALOGUE_CHAT)return new n.DialogueChatProvider(e);throw new Error(`Unknown chat provider type ${t}`)}}}})),define("metaserver/static/js/modules/clean/chat/chat_stone_to_proto",["require","exports","metaserver/static/js/dropbox/proto/js_init_data/chat/chat","metaserver/static/js/modules/clean/chat/dialogue/dialogue_stone_proto_transformer"],(function(t,e,a,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.chatStoneToProto=void 0;const n=t=>{if(void 0!==t)return new a.chat.ChatMetadata({cookieDomain:t.cookie_domain,cookieCampaignName:t.cookie_campaign_name,legacyCookieCampaignName:t.legacy_cookie_campaign_name})},s=t=>{if(void 0!==t)return new a.chat.UserProperties({chatHmac:t.chat_hmac,email:t.email,firstName:t.first_name,lastName:t.last_name,pageLoadTs:t.page_load_ts,pricings:t.pricings,sessionId:t.session_id,userId:t.user_id,serviceTier:t.service_tier,locale:t.locale,countryCode:t.country_code,authToken:t.auth_token})},r=t=>{const e=t.proactive_type;if(void 0===e)throw new Error("Proactive Message Type undefined");const i=e[".tag"];if("default"===i)return a.chat.ProactiveMessageType.DEFAULT;if("minimized_proactive"===i)return a.chat.ProactiveMessageType.MINIMIZED_PROACTIVE;throw new Error(`Unknown tag for proactive message type ${i}`)},o=t=>{if(void 0!==t)return new a.chat.ProactiveSettings({proactiveType:r(t),whenToShowControlledByProvider:t.when_to_show_controlled_by_provider,secondsUntilShown:t.seconds_until_shown,coolOffPeriodMinutes:t.cool_off_period_minutes})},h=t=>{if(void 0===t)return;const e=t[".tag"];if("hidden"===e)return a.chat.ChatInitialState.HIDDEN;if("show_provider_reactive_button"===e)return a.chat.ChatInitialState.SHOW_PROVIDER_REACTIVE_BUTTON;throw new Error(`Unknown tag for chat initial state ${e}`)},c=t=>{if(void 0===t)return;const e=(t=>{const e=t.system_settings;let n=void 0,s=void 0;return e&&(t=>"snapengage_chat_system_settings"===t[".tag"])(e)?n=new a.chat.SnapengageChatSystemSettings({widgetId:e.widget_id}):e&&(t=>"dialogue_chat_system_settings"===t[".tag"])(e)&&(s=i.convertStoneSettingsToProto(e)),{snapengageSettings:n,dialogueSettings:s}})(t);return new a.chat.CampaignResult({campaignId:t.campaign_id,versionId:t.version_id,campaignName:t.campaign_name,versionName:t.version_name,snapengageChatSystemSettings:e.snapengageSettings,dialogueChatSystemSettings:e.dialogueSettings,mustHaveAvailableAgents:t.must_have_available_agents,proactiveSettings:o(t.proactive_settings),greetingMessage:t.greeting_message,chatInitialState:h(t.chat_initial_state),persistenceCookie:t.persistence_cookie,deprecatedExperimentNameToLog:t.deprecated_experiment_name_to_log,deprecatedExperimentVariantToLog:t.deprecated_experiment_variant_to_log,isControl:t.is_control})},p=t=>{if(void 0===t)return;const e=t[".tag"];if("snapengage"===e)return a.chat.ChatProviderType.SNAPENGAGE;if("dialogue_chat"===e)return a.chat.ChatProviderType.DIALOGUE_CHAT;throw new Error(`Unknown tag for chat provider type ${e}`)},d=t=>{if(void 0!==t)return"snapengage_chat_metadata"===t[".tag"]?new a.chat.SnapengageChatMetadata({snapengageIframeOrigin:t.snapengage_iframe_origin}):void 0};e.chatStoneToProto=t=>new a.chat.ChatInitializerProperties({chatMetadata:n(t.chat_metadata),userProperties:s(t.user_properties),campaignResult:c(t.campaign_result),resume:t.resume,chatProviderType:p(t.chat_provider_type),snapengageChatMetadata:d(t.chat_provider_metadata),loggingCorrelationId:t.logging_correlation_id})})),define("metaserver/static/js/modules/clean/chat/chat_wrapper",["require","exports","metaserver/static/js/modules/clean/chat/chat_client","metaserver/static/js/modules/clean/chat/snapengage"],(function(t,e,a,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ChatWrapperSingleton=e.ChatWrapper=void 0;class n{constructor(){this.startReactiveChat=()=>{this.getClient().startReactiveChat()},this.startSupportChat=t=>{const e=this.getClient();void 0===t?a.ChatClientSingleton.isSetup()?a.ChatClientSingleton.startReactiveChat():i.DropboxSnapEngage.startSupportChat(t):e.startSupportChat(t)},this.disableDropboxSnapEngageUpdateChatStatus=()=>{i.DropboxSnapEngage.updateChatStatus=function(){}},this.getClient=()=>a.ChatClientSingleton.isSetup()?a.ChatClientSingleton:i.DropboxSnapEngage}}e.ChatWrapper=n,e.ChatWrapperSingleton=new n})),define("metaserver/static/js/modules/clean/chat/snapengage_chat_instance_handler",["require","exports","tslib","metaserver/static/js/modules/clean/chat/chat_identifier","metaserver/static/js/dropbox/proto/js_init_data/chat/chat","metaserver/static/js/modules/clean/css/css","metaserver/static/js/modules/core/browser","metaserver/static/js/modules/core/uri","metaserver/static/js/modules/core/i18n","metaserver/static/js/modules/clean/chat/snapengage_tags","metaserver/static/js/modules/clean/chat/snapengage_chat_instance_handler_api","metaserver/static/js/modules/clean/chat/chat_provider_api"],(function(t,e,a,i,n,s,r,o,h,c,p,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.SnapengageChatHandlerImpl=void 0,r=a.__importStar(r);var l=n.chat.ProactiveMessageType;class g extends p.SnapengageChatInstanceHandler{constructor(t){super(t),this.isLoaded=()=>this._isLoaded,this.requestAgentStatusUpdate=()=>{this.checkChatStatus()},this.showReactiveButton=()=>{this.showSnapEngageIframe(),this.minimizeSnapEngageIframe(),this.onProviderReactiveButtonShownListener(this.chatCampaign)},this.startChat=()=>{this.showSnapEngageIframe(),this.sendMessage("startChatV2")},this.startProactiveChat=()=>{this.showSnapEngageIframe(),this.sendMessage("startProactiveChat")},this.handleProviderDrivenOpen=()=>{this.showSnapEngageIframe()},this.switchCampaign=t=>{this.chatCampaign=t,this.chatId=i.getSnapengageWidgetId(this.chatCampaign),this.sendMessage("switchCampaign")},this.updateHmac=()=>{this.sendMessage("updateHmac")},this.addBottomMargin=t=>{if(this.iframe){this.iframe.style.removeProperty("margin-bottom");const e=parseInt(window.getComputedStyle(this.iframe).marginBottom,10)||0;this.iframe.style.marginBottom=`${t+e}px`}},this.removeBottomMargin=()=>{this.iframe&&this.iframe.style.removeProperty("margin-bottom")},this.initialize=()=>{window.addEventListener("message",this.receiveMessage,!1),s.require_css("/static/css/business/components/snap_engage-vfldJUS6n.css",()=>{this.createIframe()})},this.createIframe=()=>{const t=r.get_uri(),e=o.URI.parse(this.metadata.snapengageIframeOrigin);this.iframe=document.createElement("iframe"),t.setScheme(e.getScheme()),t.setAuthority(e.getAuthority()),this.iframe.src=t.toString(),this.iframe.setAttribute("sandbox","allow-scripts allow-same-origin allow-popups allow-forms"),this.iframe.setAttribute("class","snapengage-iframe"),this.iframe.setAttribute("id",this.iframeId),this.iframe.setAttribute("allowTransparency","true"),this.iframe.setAttribute("title",h.intl.formatMessage({id:"/nsbvt",defaultMessage:"Live chat box"})),this.iframe.addEventListener("load",this.handleIframeLoad);const a=document.querySelector("main");null!==a?a.insertBefore(this.iframe,a.firstChild):(this.iframe.setAttribute("tabindex","1"),document.body.insertBefore(this.iframe,document.body.childNodes[0])),setInterval(this.checkChatStatus,13e4)},this.handleIframeLoad=()=>{this.iFrameLeftStyle=this.iframe&&this.iframe.style.left,this.sendMessage("createSnapEngageScriptV2")},this.showSnapEngageIframe=(t=!1)=>{this.iframe&&(this.iframe.style.display="inline",this.iframe.style.left=this.iFrameLeftStyle,this.isVisible=!0)},this.onCloseChat=t=>{let e,a;this.iframe&&(this.iframe.style.display="none"),this.isVisible=!1,t&&(a=t.type,e="online"===t.agentStatus?d.AgentStatus.ONLINE:d.AgentStatus.OFFLINE),this.onChatClosedListener(this.chatCampaign,{agentStatus:e,chatType:a})},this.onMinimized=t=>{this.onChatMinimizedListener(this.chatCampaign),this.minimizeSnapEngageIframe(t)},this.onMaximized=t=>{this.onChatMaximizedListener(this.chatCampaign),this.maximizeSnapEngageIframe(t)},this.minimizeSnapEngageIframe=t=>{const e=t?Math.max(t.width,80):80,a=t?Math.max(t.height,80):80;this.iframe&&this.isVisible&&(this.iframe.style.width=`${e}px`,this.iframe.style.height=`${a}px`)},this.maximizeSnapEngageIframe=t=>{if(this.iframe){const e=(t||{}).width,a=(t||{}).height;this.iframe.style.width=e?`${e}px`:"",this.iframe.style.height=a?`${a}px`:""}},this.checkChatStatus=()=>{this.sendMessage("checkChatStatusV2")},this.onOpenProactive=()=>{this.onProviderDrivenOpenProactiveListener(this.chatCampaign)},this.onAgentStatusUpdate=t=>{this.onAgentStatusUpdateListener(this.chatCampaign,t)},this.isValidSource=t=>t.origin===this.metadata.snapengageIframeOrigin,this.onOpen=()=>{this.onChatShownListener(this.chatCampaign)},this.onChatMessageReceived=()=>{},this.onStartChat=()=>{this.onChatStartedListener(this.chatCampaign)},this.onSwitchCampaign=()=>{this.onSwitchCampaignListener(this.chatCampaign)},this.onSnapEngageInitialized=()=>{this._isLoaded=!0,this.onChatLoadListener(this.chatCampaign,!0)},this.buildChatData=()=>{const t=c.getSnapengageTags(this.userProperties.locale,this.userProperties.countryCode),e=i.isCampaignResult(this.chatCampaign)&&!this.chatCampaign.isControl&&void 0!==this.chatCampaign.proactiveSettings&&null!==this.chatCampaign.proactiveSettings&&this.chatCampaign.proactiveSettings.whenToShowControlledByProvider;let a=void 0,n=!1;return i.isCampaignResult(this.chatCampaign)&&(a=this.chatCampaign.greetingMessage,this.chatCampaign.proactiveSettings&&(n=this.chatCampaign.proactiveSettings.proactiveType===l.MINIMIZED_PROACTIVE)),{FirstName:this.userProperties.firstName,LastName:this.userProperties.lastName,Email:this.userProperties.email,locale:this.userProperties.locale,SessionID:this.userProperties.sessionId,Country:this.userProperties.countryCode,pricing:this.userProperties.pricings.join(),user_id:this.userProperties.userId,pageLoadTs:this.userProperties.pageLoadTs,chatHmac:this.userProperties.chatHmac,authToken:this.userProperties.authToken,ncct:"",serviceTier:this.userProperties.serviceTier,tags:t,phoneSupportForPlusUsers:this.userProperties.experiments.phoneSupportForPlusUsers,supportExperimentShowOnboardingNumber:this.userProperties.experiments.supportExperimentShowOnboardingNumber,supportExperimentHideEmailOption:this.userProperties.experiments.supportExperimentHideEmailOption,supportExperimentBasic36HourSla:this.userProperties.experiments.supportExperimentBasic36HourSla,phoneSupportForProfessionalUsers:this.userProperties.experiments.phoneSupportForProfessionalUsers,supportExperimentProfessionalPhoneSupportedLanguages:this.userProperties.experiments.supportExperimentProfessionalPhoneSupportedLanguages,cxChatbotName:"",allowProactive:e,greetingMessage:a,minimizedProactive:n}},this.receiveMessage=t=>{this.isValidSource(t)&&("SnapEngageInitialized"===t.data.message_type?this.onSnapEngageInitialized():"UpdateChatStatus"===t.data.message_type?this.onAgentStatusUpdate(t.data.online):"Close"===t.data.message_type?this.onCloseChat(t.data):"Minimize"===t.data.message_type?this.onMinimized(t.data.rect):"Maximize"===t.data.message_type?this.onMaximized(t.data.rect):"OpenProactive"===t.data.message_type?this.onOpenProactive():"StartChat"===t.data.message_type?this.onStartChat():"Open"===t.data.message_type?this.onOpen():"EndProactiveChat"===t.data.message_type?this.onCloseChat():"ChatMessageReceived"===t.data.message_type?this.onChatMessageReceived():"onSwitchCampaign"===t.data.message_type&&this.onSwitchCampaign())},this.sendMessage=t=>{const e={message_type:t,chatId:this.chatId,chatData:this.chatData};this.iframe&&this.iframe.contentWindow&&this.iframe.contentWindow.postMessage(e,this.metadata.snapengageIframeOrigin)},this._isLoaded=!1,this.chatCampaign=t.campaignResult,this.metadata=t.metadata,this.userProperties=t.userProperties,this.onAgentStatusUpdateListener=t.onAgentStatusUpdate,this.onChatLoadListener=t.onChatLoadStatusUpdate,this.onChatShownListener=t.onChatShown,this.onChatStartedListener=t.onChatStarted,this.onChatClosedListener=t.onChatClosed,this.onSwitchCampaignListener=t.onSwitchCampaign,this.onProviderDrivenOpenProactiveListener=t.onProviderDrivenOpenProactive,this.onProviderReactiveButtonShownListener=t.onProviderReactiveButtonShown,this.onChatMinimizedListener=t.onChatMinimized,this.onChatMaximizedListener=t.onChatMaximized,this.isVisible=!1,this.iframeId="snapengage-iframe",this.chatData=this.buildChatData(),this.chatId=i.getSnapengageWidgetId(this.chatCampaign),this.initialize()}}e.SnapengageChatHandlerImpl=g})),define("metaserver/static/js/modules/clean/chat/snapengage_chat_instance_handler_api",["require","exports"],(function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.SnapengageChatInstanceHandler=void 0;e.SnapengageChatInstanceHandler=class{constructor(t){this.addBottomMargin=t=>{},this.removeBottomMargin=()=>{}}}})),define("metaserver/static/js/modules/clean/chat/snapengage_chat_provider",["require","exports","metaserver/static/js/modules/clean/chat/chat_identifier","metaserver/static/js/modules/clean/chat/chat_provider_api","metaserver/static/js/modules/clean/chat/snapengage_chat_instance_handler"],(function(t,e,a,i,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.SnapengageChatProvider=void 0;class s extends i.ChatProvider{constructor(t){super(t),this.DEFAULT_WIDGET_ID="d5c1efed-d0ef-4fca-8c7d-faff398ad272",this.getDefaultChatIdentifier=()=>this.DEFAULT_WIDGET_ID,this.loadChatIfNecessary=t=>{a.areChatCampaignsEqual(this.currentChatCampaign,t)?this.handler.isLoaded()&&this.onChatLoadStatusUpdate(this.currentChatCampaign,!0):this.handler.switchCampaign(t)},this.onSwitchCampaign=t=>{const e=this.currentChatCampaign;this.currentChatCampaign=t,this.onChatLoadStatusUpdate(e,!1),this.onAgentStatusUpdateListener(e,i.AgentStatus.UNKNOWN),this.onChatLoadStatusUpdate(t,!0),this.handler.requestAgentStatusUpdate()},this.requestAgentStatusUpdate=t=>{if(!a.areChatCampaignsEqual(this.currentChatCampaign,t))throw new Error("Requesting agent status for a chat campaign that is not loaded");this.handler.requestAgentStatusUpdate()},this.showProviderReactiveChatButton=()=>{this.handler.showReactiveButton()},this.handleProviderDrivenOpen=()=>{this.handler.handleProviderDrivenOpen()},this.startChat=(t,e)=>{if(!a.areChatCampaignsEqual(this.currentChatCampaign,t))throw new Error("Requesting to start chat for a chat campaign that is not loaded");e?this.handler.startProactiveChat():this.handler.startChat()},this.updateHmac=()=>{this.handler.updateHmac()},this.addBottomMargin=t=>{this.handler.addBottomMargin(t)},this.removeBottomMargin=()=>{this.handler.removeBottomMargin()},this.onAgentStatusUpdate=(t,e)=>{this.onAgentStatusUpdateListener(t,e?i.AgentStatus.ONLINE:i.AgentStatus.OFFLINE)},this.handleTransferEvent=t=>{},this.onAgentStatusUpdateListener=t.onAgentStatusUpdate,this.onChatLoadStatusUpdate=t.onChatLoadStatusUpdate,this.onChatShown=t.onChatShown,this.onChatStarted=t.onChatStarted,this.onChatClosed=t.onChatClosed,this.onProviderDrivenOpenProactive=t.onProviderDrivenOpenProactive,this.onProviderReactiveButtonShown=t.onProviderReactiveButtonShown,this.metadata=t.metadata,this.userProperties=t.userProperties,this.onChatMinimized=t.onChatMinimized,this.onChatMaximized=t.onChatMaximized,t.chatCampaign?(this.currentChatCampaign=t.chatCampaign,this.handler=this.createHandler(t.chatCampaign)):(this.currentChatCampaign=this.DEFAULT_WIDGET_ID,this.handler=this.createHandler(this.DEFAULT_WIDGET_ID))}createHandler(t){return new n.SnapengageChatHandlerImpl({campaignResult:t,metadata:this.metadata,userProperties:this.userProperties,onAgentStatusUpdate:this.onAgentStatusUpdate,onChatLoadStatusUpdate:this.onChatLoadStatusUpdate,onChatShown:this.onChatShown,onChatStarted:this.onChatStarted,onChatClosed:this.onChatClosed,onProviderDrivenOpenProactive:this.onProviderDrivenOpenProactive,onProviderReactiveButtonShown:this.onProviderReactiveButtonShown,onSwitchCampaign:this.onSwitchCampaign,onChatMinimized:this.onChatMinimized,onChatMaximized:this.onChatMaximized})}}e.SnapengageChatProvider=s})),define("metaserver/static/js/modules/clean/chat/snapengage_tags",["require","exports"],(function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getSnapengageTags=void 0;const a={NAMER:["US","CA"],APAC:["AU","BD","KH","C2","FJ","GU","HK","IN","ID","JP","MY","MV","NP","NZ","PK","PH","SG","KR","LK","TW","TH","VN"],EMEA:["AL","DZ","AO","AT","AZ","BH","BY","BE","BA","BW","BG","CM","HR","CY","CZ","DK","EG","EE","ET","FI","FR","GE","DE","GH","GI","GR","HU","IS","IQ","IE","IL","IT","CI","JO","KE","KW","LV","LB","LT","LU","MK","MG","MT","MQ","MU","MD","MC","MA","MZ","NA","NL","NG","NO","OM","PS","PL","PT","QA","RO","RU","RW","SA","SN","RS","SK","SI","ZA","ES","SE","CH","TZ","TN","TR","UG","UA","AE","GB","YE","ZM","ZW"],LATAM:["AG","AN","AR","AW","BB","BO","BR","BS","BZ","CL","CO","CR","CU","DM","DO","EC","GT","GY","HN","HT","JM","KN","LC","MX","NI","PA","PE","PR","PY","SR","SV","TT","UY","VC","VE"]},i={en:"",en_GB:"",da_DK:"dutch",de:"german",es:"spanish, spanish-la",es_ES:"spanish, spanish-es",fr:"french",id:"",it:"italian",ja:"japanese",ko:"korean",ms:"",nb_NO:"norwegian",nl_NL:"dutch",pl:"",pt_BR:"portuguese",ru:"russian",sv_SE:"swedish",th_TH:"thai",zh_CN:"chinese, chinese-sim",zh_TW:"chinese, chinese-trad"};e.getSnapengageTags=(t,e)=>{const a=[],s=i[t],r=n(e);return void 0!==s&&a.push(s),void 0!==r&&a.push(r),a.join(", ")};const n=t=>{if(void 0!==t)return a.NAMER.indexOf(t)>=0?"namer":a.APAC.indexOf(t)>=0?"apac":a.EMEA.indexOf(t)>=0?"emea":a.LATAM.indexOf(t)>=0?"latam":void 0}})),define("metaserver/static/js/modules/clean/logging/hive/schemas/megaphone-events",["require","exports","metaserver/static/js/modules/clean/uuid/insecure_uuid"],(function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.MegaphoneEventsRow=void 0;e.MegaphoneEventsRow=class{constructor(t,e){this.category="megaphone-events_v0_5",this.user_id=-1,this.team_id=-1,this.entity_id=-1,this.version_id=-1,this.node_id="-1",this.parent_correlation_id="none",this.parent_event_id="none",this.external_tag="none",this.location="none",this.platform="WEB",this.surface_screen_height=-1,this.surface_screen_width=-1,this.event_details={},e&&(this.category=e),["user_id","team_id","entity_type","entity_id","version_id","node_id","event_id","event_name","correlation_id","parent_correlation_id","parent_event_id","external_tag","location","platform","surface_screen_height","surface_screen_width","event_details"].map(e=>{t.hasOwnProperty(e)&&void 0!==t[e]&&(this[e]=t[e])}),this.event_id||(this.event_id=a.InsecureUUID.v4()),Object.seal(this)}}})),define("metaserver/static/js/modules/clean/chat/dialogue/dialogue_chat_provider",["require","exports","tslib","metaserver/static/js/modules/clean/chat/chat_provider_api","metaserver/static/js/modules/clean/chat/dialogue/actions/action_types","react-dom","react","metaserver/static/js/dropbox/proto/js_init_data/chat/chat","metaserver/static/js/modules/clean/chat/dialogue/dialogue_stone_proto_transformer","metaserver/static/js/modules/clean/chat/dialogue/experiments","metaserver/static/js/modules/clean/chat/dialogue/components/async_dialogue"],(function(t,e,a,i,n,s,r,o,h,c,p){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.DialogueChatProvider=void 0,s=a.__importStar(s),r=a.__importDefault(r);class d extends i.ChatProvider{constructor(e){var s;super(e),this.DEFAULT_ID="chatbot",this.setup=()=>a.__awaiter(this,void 0,void 0,(function*(){new Promise((e,a)=>{t(["metaserver/static/js/modules/clean/chat/dialogue/store/index"],e,a)}).then(a.__importStar).then(({createAppRootStore:t})=>{this.initialiseReduxStore(t),this.loadChat()}),this.chatActions=yield new Promise((e,a)=>{t(["metaserver/static/js/modules/clean/chat/dialogue/actions/chat_actions"],e,a)}).then(a.__importStar);const e={text:this.campaign.greetingMessage,sender:"bot"};this.chatActions.getChat(this.stoneSettings,e)(this.dispatch)})),this.initialiseReduxStore=t=>{this.store=t(this),this.actionQueue.forEach(t=>this.dispatch(t));const e=c.getExperiments(this.settings.experiments);this.store.dispatch({type:n.DialogueActionType.INIT_PROVIDER,settings:this.stoneSettings,userProperties:this.userProperties,experiments:e})},this.dispatch=t=>{void 0!==this.store?this.store.dispatch(t):this.actionQueue.push(t)},this.transferToNewCampaign=t=>{t.chatProviderType===o.chat.ChatProviderType.SNAPENGAGE&&this.onSwitchProviderWithNewCampaign(t,this.campaign)},this.handleTransferEvent=t=>{var e;if(t===i.TransferEvent.START_TRANSFER);else if(t===i.TransferEvent.END_TRANSFER){const{providerState:t}=this.store.getState(),a=null===(e=t.savedTransferProps)||void 0===e?void 0:e.campaignResult;let i;if(a){const{campaignName:t,versionName:e,campaignId:n}=a;i=`chatbot_transfer_${n}`,this.logAsync("transfer",{campaignName:t,versionName:e,campaignId:n})}this.chatActions.endChat({},this.stoneSettings,!1,i)(this.dispatch)}else t===i.TransferEvent.ERROR_ON_TRANSFER&&this.addMessage({text:"Sorry, I wasn't able to transfer you.",sender:"bot"})},this.addMessage=(t,e=!1)=>{this.dispatch({type:n.DialogueActionType.ADD_MESSAGE,message:t,awaitingResponse:e})},this.addBottomMargin=t=>{const e=document.getElementById("dialog_chat_container");if(e){e.style.removeProperty("margin-bottom");const a=parseInt(window.getComputedStyle(e).marginBottom,10)||0;e.style.marginBottom=`${t+a}px`}},this.removeBottomMargin=()=>{const t=document.getElementById("dialog_chat_container");t&&t.style.removeProperty("margin-bottom")},this.getLogger=()=>a.__awaiter(this,void 0,void 0,(function*(){if(this.logger)return this.logger;const{DialogueEventsLogger:e}=yield new Promise((e,a)=>{t(["metaserver/static/js/modules/clean/chat/dialogue/logging"],e,a)}).then(a.__importStar);return this.logger=new e,this.logger})),this.logAsync=(t,e={})=>a.__awaiter(this,void 0,void 0,(function*(){(yield this.getLogger()).logEvent(t,e)})),this.settings=null===(s=e.chatCampaign)||void 0===s?void 0:s.dialogueChatSystemSettings,this.stoneSettings=h.convertProtoSettingsToStone(this.settings),this.campaign=e.chatCampaign,this.userProperties=e.userProperties,this.actionQueue=[],this.onAgentStatusUpdateListener=e.onAgentStatusUpdate,this.onChatLoadStatusListener=e.onChatLoadStatusUpdate,this.onChatShownListener=e.onChatShown,this.onChatStartedListener=e.onChatStarted,this.onChatClosedListener=e.onChatClosed,this.onChatMinimizedListener=e.onChatMinimized,this.onChatMaximizedListener=e.onChatMaximized,this.onProviderDrivenOpenProactive=e.onProviderDrivenOpenProactive,this.onProviderReactiveButtonShown=e.onProviderReactiveButtonShown,this.onSwitchProviderWithNewCampaign=e.onSwitchProviderWithNewCampaign,this.hasLoaded=!1,this.setup().catch(t=>a.__awaiter(this,void 0,void 0,(function*(){var a;(yield this.getLogger()).logError("provider_init",{userId:null===(a=e.userProperties)||void 0===a?void 0:a.userId,error:t.toString()})})))}getDefaultChatIdentifier(){return this.DEFAULT_ID}loadChatIfNecessary(t){this.onChatLoadStatusListener(t,!0)}requestAgentStatusUpdate(t){this.onAgentStatusUpdateListener(t,i.AgentStatus.ONLINE)}showProviderReactiveChatButton(){this.dispatch({type:n.DialogueActionType.SHOW_REACTIVE_BUTTON_WHEN_MINIMIZED})}handleProviderDrivenOpen(){}startChat(t,e){this.chatActions.openChat(e)(this.dispatch)}updateHmac(){}onChatStarted(){this.onChatStartedListener(this.campaign)}onChatClosed(){this.onChatClosedListener(this.campaign,{})}onChatMinimized(){this.onChatMinimizedListener(this.campaign)}onChatMaximized(){this.onChatMaximizedListener(this.campaign)}onChatShown(t){this.onChatShownListener(t||this.campaign)}loadChat(){return a.__awaiter(this,void 0,void 0,(function*(){if(!document.getElementById("dialogue-chat-root")){const t=document.createElement("div");t.setAttribute("id","dialogue-chat-root"),document.body.appendChild(t)}this.hasLoaded||(s.render(r.default.createElement(p.AsyncDialogue,{store:this.store,portaled:this.settings.portaled}),document.getElementById("dialogue-chat-root")),this.hasLoaded=!0),this.onChatLoadStatusListener(this.campaign,!0)}))}}e.DialogueChatProvider=d})),define("metaserver/static/js/modules/clean/chat/dialogue/actions/action_types",["require","exports"],(function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.DialogueActionType=void 0,(function(t){t.INIT_PROVIDER="DIALOGUE/INIT_PROVIDER",t.SET_TRANSFER_PROPS="DIALOGUE/SET_TRANSFER_PROPS",t.START_TRANSFER="DIALOGUE/START_TRANSFER",t.END_CHAT="DIALOGUE/END_CHAT",t.GET_CHAT="DIALOGUE/GET_CHAT",t.MINIMIZE_CHAT="DIALOGUE/MINIMIZE_CHAT",t.SHOW_REACTIVE_BUTTON_WHEN_MINIMIZED="DIALOGUE/SHOW_REACTIVE_BUTTON_WHEN_MINIMIZED",t.TOGGLE_REACTIVE_BUTTON="DIALOGUE/TOGGLE_REACTIVE_BUTTON",t.OPEN_CHAT="DIALOGUE/OPEN_CHAT",t.TOGGLE_END_CHAT_MODAL="DIALOGUE/TOGGLE_END_CHAT_MODAL",t.TOGGLE_TRANSFER_MODAL="DIALOGUE/TOGGLE_TRANSFER_MODAL",t.SET_LOGGING_ID="DIALOGUE/SET_LOGGING_ID",t.SET_GREETING_MESSAGE="DIALOGUE/SET_GREETING_MESSAGE",t.SET_FATAL_ERROR_MESSAGE="DIALOGUE/SET_FATAL_ERROR_MESSAGE",t.ADD_MESSAGE="DIALOGUE/ADD_MESSAGE",t.UPDATE_CURRENT_MESSAGE="DIALOGUE/UPDATE_CURRENT_MESSAGE",t.UPDATE_SURVEY_RESPONSE="DIALOGUE/UPDATE_SURVEY_RESPONSE",t.CLICK_LINK="DIALOGUE/CLICK_LINK",t.LOAD_GROMIT_SUGGESTED_ARTICLES="DIALOGUE/LOAD_GROMIT_SUGGESTED_ARTICLES",t.MARK_ARTICLE_AS_VIEWED="DIALOGUE/MARK_ARTICLE_AS_VIEWED",t.TOGGLE_CONFIRM_PASSWORD_MODAL="DIALOGUE/TOGGLE_CONFIRM_PASSWORD_MODAL",t.SAVE_ENCRYPTION_OPTIONS="DIALOGUE/SAVE_ENCRYPTION_OPTIONS",t.RESTART_CHAT="DIALOGUE/RESTART_CHAT"})(e.DialogueActionType||(e.DialogueActionType={}))})),define("metaserver/static/js/modules/clean/chat/dialogue/dialogue_stone_proto_transformer",["require","exports","metaserver/static/js/dropbox/proto/js_init_data/chat/chat"],(function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.convertProtoSettingsToStone=e.convertProtoBotProviderToStone=e.convertProtoBotTypeToStone=e.convertStoneSettingsToProto=e.convertStoneBotProviderToProto=e.convertStoneBotTypeToProto=void 0;const i={cx_support:a.chat.DialogueBotType.CX_SUPPORT,cx_specialized:a.chat.DialogueBotType.CX_SPECIALIZED,business:a.chat.DialogueBotType.BUSINESS,scaled_onboarding:a.chat.DialogueBotType.SCALED_ONBOARDING};e.convertStoneBotTypeToProto=t=>i[t[".tag"]],e.convertStoneBotProviderToProto=t=>{switch(t[".tag"]){case"lex":return a.chat.DialogueBotProvider.LEX;case"rasa":return a.chat.DialogueBotProvider.RASA;default:return a.chat.DialogueBotProvider.UNKNOWN}},e.convertStoneSettingsToProto=t=>{const i=(t.experiments||[]).map(t=>new a.chat.DialogueExperiment(t));return new a.chat.DialogueChatSystemSettings({botProvider:e.convertStoneBotProviderToProto(t.bot_provider),botType:e.convertStoneBotTypeToProto(t.bot_type),environment:t.environment,settingsHmac:t.settings_hmac,experiments:i,proactiveIntent:t.proactive_intent})},e.convertProtoBotTypeToStone=t=>{const e=Object.keys(i).find(e=>i[e]===t);if(!e)throw new Error("invalid bot type");return{".tag":e}},e.convertProtoBotProviderToStone=t=>{switch(t){case a.chat.DialogueBotProvider.LEX:return{".tag":"lex"};case a.chat.DialogueBotProvider.RASA:return{".tag":"rasa"};default:return{".tag":"unknown"}}},e.convertProtoSettingsToStone=t=>({bot_provider:e.convertProtoBotProviderToStone(t.botProvider),bot_type:e.convertProtoBotTypeToStone(t.botType),environment:t.environment,settings_hmac:t.settingsHmac,proactive_intent:t.proactiveIntent,portaled:t.portaled})})),define("metaserver/static/js/modules/clean/chat/dialogue/experiments",["require","exports"],(function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getExperiments=void 0,e.getExperiments=t=>{const e={};return t.forEach(t=>{const a=t.name;e[a]=t.active}),e}})),define("metaserver/static/js/modules/clean/chat/dialogue/components/async_dialogue",["require","exports","tslib","react"],(function(t,e,a,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.AsyncDialogue=void 0;const n=(i=a.__importDefault(i)).default.lazy(()=>a.__awaiter(void 0,void 0,void 0,(function*(){const{Dialogue:e}=yield new Promise((e,a)=>{t(["metaserver/static/js/modules/clean/chat/dialogue/dialogue"],e,a)}).then(a.__importStar);return{default:e}}))),s=()=>i.default.createElement(i.default.Fragment,null);e.AsyncDialogue=t=>i.default.createElement(i.default.Suspense,{fallback:i.default.createElement(s,null)},i.default.createElement(n,Object.assign({},t)))})); //# sourceMappingURL=pkg-chat.min.js-vflyOTCCC.map