"use strict";(self.webpackChunk_flagship_io_js_sdk=self.webpackChunk_flagship_io_js_sdk||[]).push([[566,618],{8566:(e,s,i)=>{i.r(s),i.d(s,{launchQaAssistant:()=>S});var n=i(3641),t=i(1358);const o=e=>document.querySelector(`script[src*="${e}"]`);var a=i(2799),A=i(4618);function r(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];"TypeScript"===n.SDK_INFO.name&&document.location.reload();const s=new CustomEvent(a.INTERNAL_EVENTS.FsTriggerRendering,{detail:{forcedReFetchFlags:e}});window.dispatchEvent(s)}function _(e){let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(window?.frames?.ABTastyQaAssistant)return;let i={};const _=sessionStorage.getItem(n.FS_FORCED_VARIATIONS);try{i=JSON.parse(_||"{}")}catch(e){console.error("Error parsing sessionForcedVariations",e)}window.flagship={...window.flagship,envId:e.envId,forcedVariations:i};const S=s=>{!function(e){let{event:s,config:i,func:o}=e;if(i.isQAModeEnabled&&(0,t.isBrowser)())switch(s.data.name){case a.MSG_NAME_FROM_IFRAME.FsQaAssistantReady:window.flagship?.visitorVariations&&(0,A.sendVisitorAllocatedVariations)(window.flagship?.visitorVariations),window.flagship?.exposedVariations&&(0,A.sendVisitorExposedVariations)(window.flagship?.exposedVariations);break;case a.MSG_NAME_FROM_IFRAME.MinimizeQaAssistantClose:case a.MSG_NAME_FROM_IFRAME.QaAssistantClose:!function(e){let{config:s,func:i}=e;s.isQAModeEnabled=!1,sessionStorage.removeItem(n.FS_IS_QA_MODE_ENABLED),i&&window.removeEventListener("message",i),document.getElementById(n.FS_QA_ASSISTANT_SCRIPT_TAG_ID)?.remove(),window.flagship={...window.flagship,forcedVariations:{}},r()}({config:i,func:o});break;case a.MSG_NAME_FROM_IFRAME.FsApplyForcedVariations:!function(e){let{value:s}=e;const i=sessionStorage.getItem(n.FS_FORCED_VARIATIONS);let t={};try{t=JSON.parse(i||"{}")}catch(e){console.error("Error parsing sessionForcedVariations",e)}t={...t,...s},sessionStorage.setItem(n.FS_FORCED_VARIATIONS,JSON.stringify(t)),window.flagship={...window.flagship,forcedVariations:t},r()}({value:s.data.value});break;case a.MSG_NAME_FROM_IFRAME.FsResetForcedVariations:sessionStorage.removeItem(n.FS_FORCED_VARIATIONS),window.flagship={...window.flagship,forcedVariations:{}},r();break;case a.MSG_NAME_FROM_IFRAME.FsTriggerRender:r(!0)}}({event:s,config:e,func:S})};window.addEventListener("message",S),(0,t.logInfoSprintf)(e,"QA assistant","Loading QA Assistant"),function(e){if(o(n.TAG_QA_URL)||o(n.FS_QA_URL))return;const s=document.createElement("script");s.src=e,s.id=n.FS_QA_ASSISTANT_SCRIPT_TAG_ID,document.body.append(s)}(s||n.QA_ASSISTANT_PROD_URL),e.isQAModeEnabled=!0,sessionStorage.setItem(n.FS_IS_QA_MODE_ENABLED,"true")}function S(e){(0,t.isBrowser)()&&(0,t.onDomReady)((()=>{const s={[n.FS_QA_ASSISTANT]:n.QA_ASSISTANT_PROD_URL,[n.TAG_QA_ASSISTANT]:n.QA_ASSISTANT_PROD_URL,[n.FS_QA_ASSISTANT_STAGING]:n.QA_ASSISTANT_STAGING_URL,[n.TAG_QA_ASSISTANT_STAGING]:n.QA_ASSISTANT_STAGING_URL,[n.FS_QA_ASSISTANT_LOCAL]:n.QA_ASSISTANT_LOCAL_URL,[n.TAG_QA_ASSISTANT_LOCAL]:n.QA_ASSISTANT_LOCAL_URL},i=new URLSearchParams(window.location.search),o=Object.keys(s).find((e=>"true"===i.get(e)))||"";e.isQAModeEnabled||o?_(e,s[o]):function(e){(0,t.logInfoSprintf)(e,"QA assistant","Listening for keyboard events to launch QA Assistant");const s={};document.addEventListener("keydown",(i=>{s[i.key]=!0,sessionStorage.removeItem(n.FS_FORCED_VARIATIONS),(s.Control||s.Alt)&&s.q&&s.a&&_(e)})),document.addEventListener("keyup",(e=>{delete s[e.key]}))}(e)}))}},4618:(e,s,i)=>{i.r(s),i.d(s,{sendFsHitToQA:()=>r,sendMessageToIframe:()=>o,sendVisitorAllocatedVariations:()=>a,sendVisitorExposedVariations:()=>A});var n=i(1358),t=i(2799);function o(e){window?.frames?.ABTastyQaAssistant&&(0,n.isBrowser)()&&window.frames.ABTastyQaAssistant.postMessage(e,"*")}function a(e){(0,n.isBrowser)()&&(window.flagship={...window.flagship,visitorVariations:e},o({name:t.MSG_NAME_TO_IFRAME.FsUpdateVisitorAllocatedVariation,value:e}))}function A(e){o({name:t.MSG_NAME_TO_IFRAME.FsVisitorExposedVariation,value:e})}function r(e){o({name:t.MSG_NAME_TO_IFRAME.FsHIT,value:e.map((e=>({...e,timestamp:Date.now()-e.qt})))})}},2799:(e,s,i)=>{i.d(s,{INTERNAL_EVENTS:()=>o,MSG_NAME_FROM_IFRAME:()=>n,MSG_NAME_TO_IFRAME:()=>t});let n=function(e){return e.QaAssistantClose="ABTASTY_QA_ASSISTANT_CLOSE",e.FsApplyForcedVariations="FS_APPLY_FORCED_VARIATIONS",e.FsResetForcedVariations="FS_RESET_FORCED_VARIATIONS",e.FsQaAssistantReady="FS_QA_ASSISTANT_READY",e.MinimizeQaAssistantClose="ABTASTY_QA_MINIMIZE_QA_ASSISTANT_CLOSE",e.FsTriggerRender="FS_TRIGGER_RENDER",e}({}),t=function(e){return e.FsUpdateVisitorAllocatedVariation="FS_UPDATE_VISITOR_ALLOCATED_VARIATION",e.FsVisitorExposedVariation="FS_VISITOR_EXPOSED_VARIATION",e.FsHIT="FS_HIT",e}({}),o=function(e){return e.FsTriggerRendering="FS_TRIGGER_RENDERING",e}({})}}]);
//# sourceMappingURL=566.610af9afde8fd052e0dd.js.map