import{F as e,T as s,a,S as n,b as o,c as t,i,l as r,Q as c,o as d,d as f,e as g,f as l,g as w,h as m,j as p,k as u,m as v}from"./ppyR687H.js";import{s as h,a as A,I as y,M as E}from"./BHG4384U.js";import"events";const S=e=>document.querySelector(`script[src*="${e}"]`);function Q(e=!1){"TypeScript"===n.name&&document.location.reload();const s=new CustomEvent(y.FsTriggerRendering,{detail:{forcedReFetchFlags:e}});window.dispatchEvent(s)}function b({event:s,config:a,func:n}){if(a.isQAModeEnabled&&i())switch(s.data.name){case E.FsQaAssistantReady:window.flagship?.visitorVariations&&h(window.flagship?.visitorVariations),window.flagship?.exposedVariations&&A(window.flagship?.exposedVariations);break;case E.MinimizeQaAssistantClose:case E.QaAssistantClose:!function({config:s,func:a}){s.isQAModeEnabled=!1,sessionStorage.removeItem(t),a&&window.removeEventListener("message",a),document.getElementById(e)?.remove(),window.flagship={...window.flagship,forcedVariations:{}},Q()}({config:a,func:n});break;case E.FsApplyForcedVariations:!function({value:e}){const s=sessionStorage.getItem(o);let a={};try{a=JSON.parse(s||"{}")}catch(e){console.error("Error parsing sessionForcedVariations",e)}a={...a,...e},sessionStorage.setItem(o,JSON.stringify(a)),window.flagship={...window.flagship,forcedVariations:a},Q()}({value:s.data.value});break;case E.FsResetForcedVariations:sessionStorage.removeItem(o),window.flagship={...window.flagship,forcedVariations:{}},Q();break;case E.FsTriggerRender:Q(!0)}}function F(n,i=null){if(window?.frames?.ABTastyQaAssistant)return;let d={};const f=sessionStorage.getItem(o);try{d=JSON.parse(f||"{}")}catch(e){console.error("Error parsing sessionForcedVariations",e)}window.flagship={...window.flagship,envId:n.envId,forcedVariations:d};const g=e=>{b({event:e,config:n,func:g})};window.addEventListener("message",g),r(n,"QA assistant","Loading QA Assistant"),function(n){if(S(s)||S(a))return;const o=document.createElement("script");o.src=n,o.id=e,document.body.append(o)}(i||c),n.isQAModeEnabled=!0,sessionStorage.setItem(t,"true")}function V(e){r(e,"QA assistant","Listening for keyboard events to launch QA Assistant");const s={};document.addEventListener("keydown",(a=>{s[a.key]=!0,sessionStorage.removeItem(o),(s.Control||s.Alt)&&s.q&&s.a&&F(e)})),document.addEventListener("keyup",(e=>{delete s[e.key]}))}function k(e){i()&&d((()=>{const s={[v]:c,[u]:c,[p]:g,[m]:g,[w]:f,[l]:f},a=new URLSearchParams(window.location.search),n=Object.keys(s).find((e=>"true"===a.get(e)))||"";e.isQAModeEnabled||n?F(e,s[n]):V(e)}))}export{k as launchQaAssistant};
//# sourceMappingURL=CyFhZr-s.js.map
