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