!function(e){!function(e){"use strict";var t,r,i,n,s,o,a,c,u,l,d,p,h,g,m,w,v,f,y,b,S,P,I,E,C,D,k,T,A,U,V,N,_,x,W,O,F,L,R,j,B,J,M,$,q,G,z,H,K,Y,Z,X,Q,ee,te,re,ie,ne,se,oe,ae,ce,ue,le,de,pe,he,ge,me,we,ve,fe,ye,be,Se,Pe,Ie,Ee,Ce,De,ke,Te,Ae,Ue,Ve,Ne,_e,xe,We,Oe,Fe,Le,Re,je,Be,Je,Me,$e,qe,Ge,ze,He,Ke,Ye,Ze,Xe,Qe,et,tt,rt,it,nt,st,ot,at,ct,ut,lt,dt,pt,ht,gt,mt,wt,vt,ft,yt,bt,St=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},Pt=(e,t,r)=>(St(e,t,"read from private field"),r?r.call(e):t.get(e)),It=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},Et=(e,t,r,i)=>(St(e,t,"write to private field"),i?i.call(e,r):t.set(e,r),r),Ct=(e,t,r)=>(St(e,t,"access private method"),r),Dt=(e=>(e["Await"]="await",e["Filter"]="filter",e["React"]="react",e["BackendTransfer"]="backend_transfer",e))(Dt||{}),kt=(e=>(e["AwaitClick"]="await_click",e["AwaitScroll"]="await_scroll",e["AwaitExit"]="await_exit",e["AwaitInactivity"]="await_inactivity",e["AwaitECommerceActivity"]="await_ecommerce_activity",e["AwaitMergedNodes"]="await_merged_nodes",e["AwaitWebPushConsent"]="await_webpush_consent",e["FilterUrl"]="filter_url",e["FilterSubscriber"]="filter_subscriber",e["FilterDevice"]="filter_device",e["FilterLocation"]="filter_location",e["FilterTime"]="filter_time",e["FilterVisit"]="filter_visit",e["FilterUniqueSessionVisit"]="filter_unique_session_visit",e["FilterPopup"]="filter_popup",e["FilterECommerceActivity"]="filter_ecommerce_activity",e["ReactDelay"]="react_delay",e["ReactScroll"]="react_scroll",e["ReactRedirect"]="react_redirect",e["ReactPopup"]="react_popup",e["ReactSendToBackend"]="react_send_to_backend",e["ReactSendWebPush"]="react_send_webpush",e["ReactCollectWebPushConsent"]="react_collect_web_push_consent",e))(kt||{});class Tt extends Error{}const At="true",Ut="false",Vt="exit";class Nt extends ReferenceError{constructor(e){super(`Node of selector ${e} not found`)}}if(false){if("undefined"!=typeof navigator&&"ReactNative"===navigator.product&&"undefined"==typeof crypto)throw new Error("React Native does not have a built-in secure random generator. If you don’t need unpredictable IDs use `nanoid/non-secure`. For secure IDs, import `react-native-get-random-values` before Nano ID.");if("undefined"!=typeof msCrypto&&"undefined"==typeof crypto)throw new Error("Import file with `if (!window.crypto) window.crypto = window.msCrypto` before importing Nano ID to fix IE 11 support");if("undefined"==typeof crypto)throw new Error("Your browser does not have secure random generator. If you don’t need unpredictable IDs, you can use nanoid/non-secure.")}let _t=(e=21)=>{let t="",r=crypto.getRandomValues(new Uint8Array(e));for(;e--;){let i=63&r[e];if(36>i)t+=i.toString(36);else if(62>i)t+=(i-26).toString(36).toUpperCase();else if(63>i)t+="_";else t+="-"}return t};const xt="_grDebugMode",Wt=new class{isDebugEnabled(){return!!window.sessionStorage.getItem(xt)}startDebug(){window.sessionStorage.setItem(xt,"true")}},Ot=new class{get isLoggingEnabled(){return Wt.isDebugEnabled()}log(...e){this.displayLog("log",...e)}info(...e){this.displayLog("info",...e)}error(...e){if(e[0]instanceof Error)e.push(e[0].stack);this.displayLog("error",...e)}warn(...e){this.displayLog("warn",...e)}displayLog(e,...t){if(this.isLoggingEnabled)console[e](...t)}};function Ft(e){const t=document.cookie.match(new RegExp(`(^| )${e}=([^;]+)`));if(t)return t[2]}function Lt(){const e=new Date,t=location.hostname.split(".").reverse(),r=[],i=`gaDomain-${_t(6)}`,n=_t(6);let s="";for(e.setTime(e.getTime()+60*1e3),r.push(t.shift());t.length>0;){if(s=r.reverse().join("."),document.cookie=`${i}=${n}; expires=${e.toUTCString()}; domain=.${s}; path=/`,Ft(i)===n)return s;r.push(t.shift())}return location.hostname}function Rt(e){return new Proxy({},{get(t,r){if(!(r in t))if("object"==typeof e&&null!==e)t[r]=structuredClone(e);else t[r]=e;return t[r]}})}function jt(e){return e.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function Bt(e){return!!e&&"object"==typeof e}function Jt(e,t){const r={...e};for(const i of Object.keys(t))if(e.hasOwnProperty(i)&&Bt(e[i])&&Bt(t[i])&&!Array.isArray(e[i]))r[i]=Jt(e[i],t[i]);else r[i]=t[i];return r}class Mt{constructor(){It(this,t,Rt([]))}on(e,r,i={}){if(Pt(this,t)[e].push({once:i.once,listener:r}),i.signal)i.signal.addEventListener("abort",(()=>{this.off(e,r)}),{once:true})}off(e,r){Pt(this,t)[e]=Pt(this,t)[e].filter((e=>e.listener!==r))}emit(e,...r){Pt(this,t)[e].forEach((({listener:t,once:i})=>{if(t(...r),i)this.off(e,t)}))}}t=new WeakMap;const $t={1:"1",2:"2",3:"3",4:"4",5:"5",6:"6",0:"7"};r=new WeakMap,i=new WeakMap,n=new WeakMap,s=new WeakSet,o=function(){const{specific_date:e,delay_seconds:t}=Pt(this,n)||{};let r,i;if(e)r=Ct(this,g,m).call(this);if(t)i=Ct(this,w,v).call(this);return r||i},a=new WeakSet,c=function(){const e=Ct(this,u,l).call(this);if(!Number.isNaN(e))if(e>0)Et(this,i,window.setTimeout((()=>{this.emit("upstreamPassed"),this.hasUpstreamTimePassed=true}),e));else this.emit("upstreamPassed"),this.hasUpstreamTimePassed=true},u=new WeakSet,l=function(){var e;const t=Date.now();if(null==(e=Pt(this,n))?void 0:e.delay_seconds)return Pt(this,r).getTime()+1e3*Pt(this,n).delay_seconds-t;if(Pt(this,n).specific_date)return Date.parse(Pt(this,n).specific_date)-t;else return NaN},d=new WeakSet,(e,t)=>{const r=new Date(t);return e.includes((r.getHours()+1).toString())},p=new WeakSet,(e,t)=>{const r=new Date(t);return e.includes(r.getDate().toString())},h=new WeakSet,(e,t)=>{const r=new Date(t);return e.includes($t[r.getDay().toString()])},g=new WeakSet,m=function(){return Pt(this,r).getTime()>Date.parse(Pt(this,n).specific_date)},w=new WeakSet,v=function(){return Date.now()-Pt(this,r).getTime()>1e3*Pt(this,n).delay_seconds};let qt=class e extends Mt{constructor(e){super(),It(this,s),It(this,a),It(this,u),It(this,d),It(this,p),It(this,h),It(this,g),It(this,w),It(this,r,void 0),It(this,i,void 0),It(this,n,void 0),Et(this,n,null),this.hasUpstreamTimePassed=false,Et(this,n,e)}static create(t){return new e(t)}initVisitorEntry(e){if(Et(this,r,e),Pt(this,n))if(Ct(this,s,o).call(this))this.emit("upstreamPassed"),this.hasUpstreamTimePassed=true;else Ct(this,a,c).call(this)}};class Gt{constructor({id:e,externalId:t,properties:r,isRecurrent:i,upstream:n,context:s}){this.context=null,this.id=e,this.externalId=t,this.isRecurrent=i,this.properties=r,this.upstream=n,this.context=s}get nodeTypeGroup(){var e,t;if(this.type===kt.ReactSendToBackend)return Dt.BackendTransfer;else return null==(t=null==(e=this.type.match(/^(?[a-zA-Z]*)_.*/))?void 0:e.groups)?void 0:t.nodeGroupType}startUpstreamCalculation(){this.upstreamService=qt.create(this.upstream),this.upstreamService.initVisitorEntry(new Date),this.upstreamAbortController=new AbortController}waitForUpstreamPassed(){return new Promise((e=>{if(this.upstream)if(this.upstreamService.hasUpstreamTimePassed)e(Symbol.for("upstreamPassed"));else this.upstreamService.on("upstreamPassed",(()=>{e(Symbol.for("upstreamPassed"))}),{once:true,signal:this.upstreamAbortController.signal})}))}cancelUpstreamToResolveWait(){this.upstreamAbortController.abort()}shouldProcessHandler(){return!this.upstreamService.hasUpstreamTimePassed}}class zt extends Gt{constructor(){super(...arguments),this.leaveFalseTimeout=null}waitForDelayLeaveFalse(){return new Promise((e=>{const{leaveFalseDelay:t}=this.properties;if(t)this.leaveFalseTimeout=window.setTimeout(e,t)}))}cleanLeaveFalseTimeout(){if(this.leaveFalseTimeout)window.clearTimeout(this.leaveFalseTimeout),this.leaveFalseTimeout=null}}const Ht=100;var Kt=(e=>(e["UuidHasBeenSet"]="grUuidHasBeenSet",e["PopupsRendererCustomUrl"]="grPopupsRendererCustomUrl",e))(Kt||{});class Yt{constructor(){It(this,f,new Proxy({},{get(e,t){if(t in e)return e[t];else return e[t]=[],e[t]}}))}addEvent(e,t){Pt(this,f)[e].push(t)}drainEvents(e){const t=Pt(this,f)[e];return Pt(this,f)[e]=[],t}getEvents(e){return Pt(this,f)[e]}hasDelayedEvents(e){return Pt(this,f)[e].length>0}}f=new WeakMap,y=new WeakMap,b=new WeakMap;const Zt=new class{constructor(){It(this,y,{}),It(this,b,new Yt)}publish(e,...t){var r;if(null==(r=Pt(this,y)[e])?void 0:r.length)Pt(this,y)[e].forEach((r=>{r(...t),Ot.log(`Event ${e} published with arguments'`,...t)}));else Pt(this,b).addEvent(e,t)}subscribe(e,t,r={}){const{preventEventDraining:i,ignoreQueuedEvents:n}=r;if(!Pt(this,y)[e])Pt(this,y)[e]=[];if(Pt(this,b).hasDelayedEvents(e)&&!n)if(i)Pt(this,b).getEvents(e).forEach((e=>t(...e)));else Pt(this,b).drainEvents(e).forEach((e=>t(...e)));Pt(this,y)[e].push(t)}unsubscribe(e,t){var r;const i=null==(r=Pt(this,y)[e])?void 0:r.indexOf(t);if(i>-1)Pt(this,y)[e].splice(i,1)}removeListeners(e){delete Pt(this,y)[e]}};var Xt,Qt,er=(e=>(e["DeviceType"]="debug_device_type",e["Location"]="debug_location",e["VisitUrlPath"]="debug_visit_url_path",e["BrowserStorageLastActivityDate"]="debug_browser_storage_last_activity_date",e["NewVisitor"]="debug_new_visitor",e["HasUserVisitPage"]="debug_has_user_visit_page",e["Events"]="debug_events",e))(er||{});function tr(){const e=e=>{const t=sessionStorage.getItem(e);if(t){if([er.DeviceType,er.VisitUrlPath,er.Location].includes(e))return t;if(e===er.BrowserStorageLastActivityDate){const e=new Date(t);return isNaN(e.getTime())?void 0:e}if([er.NewVisitor,er.HasUserVisitPage,er.Events].includes(e))try{return JSON.parse(t)}catch(r){Ot.error(`Invalid debug data for: ${e}`)}}};return{enabled:true,data:{[er.DeviceType]:e(er.DeviceType),[er.BrowserStorageLastActivityDate]:e(er.BrowserStorageLastActivityDate),[er.Location]:e(er.Location),[er.NewVisitor]:e(er.NewVisitor),[er.VisitUrlPath]:e(er.VisitUrlPath),[er.HasUserVisitPage]:e(er.HasUserVisitPage),[er.Events]:e(er.Events)}}}function rr(e,t,r){const i=Ir.debugObject;Ir.debugObject={...i,data:{...null==i?void 0:i.data,[e]:t}},sessionStorage.setItem(e,r||String(t))}function ir(e){var t,r;return null==(r=null==(t=Ir.debugObject)?void 0:t.data)?void 0:r[e]}function nr(e,t){return Ir.isDebug?t:e}(Qt=Xt||(Xt={}))["PageVisit"]="visit",Qt["Popup"]="popup",Qt["ViewItem"]="view_item",Qt["ViewCategory"]="view_category",Qt["WishlistItem"]="wishlist_item",Qt["LikeItem"]="like_item",Qt["UnlikeItem"]="unlike_item",Qt["OrderPlaced"]="order_placed",Qt["Cart"]="cart_update",void(Qt["ShopifyAbandonedCart"]="shopify_webhook_abandoned_cart");let sr=class extends Error{constructor(e){super(e),Object.setPrototypeOf(this,new.target.prototype),this.name=this.constructor.name}};class or extends sr{constructor(e){super(e)}}const ar={cartToken:"string",urlToken:"string",visitorEmail:"string"},cr=["cartToken","urlToken"];var ur,lr,dr,pr,hr,gr,mr,wr,vr;(vr=ur||(ur={}))["Inline"]="inline",void(vr["Popup"]="popup"),(wr=lr||(lr={}))["Hq"]="Hq",void(wr["Us"]="Us"),void((dr||(dr={}))["UserAid"]="X-Aid"),(mr=pr||(pr={}))["Active"]="active",void(mr["Inactive"]="inactive"),(gr=hr||(hr={}))["ReactSendWebPush"]="react_web_webpush",gr["ReactCollectWebPushConsent"]="react_web_collect_webpush_subscription",gr["FilterWebUrl"]="filter_web_url",gr["FilterWebSubscribers"]="filter_web_subscriber",gr["FilterLocation"]="filter_web_geolocation",gr["FilterDevice"]="filter_web_device",gr["FilterReturningVisitor"]="filter_web_returning_visitor",gr["ConditionProductViewed"]="await_web_view_item_event",gr["ConditionCategoryViewed"]="await_web_view_category_event",gr["ConditionWebPushConsent"]="await_web_webpush_subscribe",gr["ConditionProductLiked"]="await_web_like_item_event",gr["TransferToBackend"]="react_backend_transfer",gr["AwaitScroll"]="await_scroll",void(gr["ShowPopup"]="react_popup"),S=new WeakMap;const fr=new class{constructor(){It(this,S,{[Xt.LikeItem]:[],[Xt.OrderPlaced]:[],[Xt.UnlikeItem]:[],[Xt.ViewCategory]:[],[Xt.ViewItem]:[],[Xt.WishlistItem]:[],[Xt.PageVisit]:[],[Xt.Popup]:[],[Xt.Cart]:[]})}getEvents(e){return Promise.resolve(Pt(this,S)[e])}getAllEvents(){return Promise.resolve(Object.values(Pt(this,S)).flat(1))}getAllECommerceEvents(){return Promise.resolve([...Pt(this,S)[Xt.ViewItem],...Pt(this,S)[Xt.ViewCategory],...Pt(this,S)[Xt.LikeItem],...Pt(this,S)[Xt.UnlikeItem],...Pt(this,S)[Xt.WishlistItem],...Pt(this,S)[Xt.OrderPlaced],...Pt(this,S)[Xt.Cart]])}getAllPopupEvents(){return Promise.resolve([...Pt(this,S)[Xt.Popup]])}saveEvent(e){return Pt(this,S)[e.eventType].push(e),Promise.resolve()}};var yr=(e=>(e["v2"]="v2",e["af"]="af",e["wp"]="wp",e["we"]="we",e["ec"]="ec",e))(yr||{}),br=(e=>(e["v2"]="GRV2",e["af"]="GRAF",e["wp"]="GRWP",e["we"]="GRWE",e["ec"]="GREC",e))(br||{});const Sr={[yr.af]:"autoFunnel",[yr.ec]:"ecommerce",[yr.v2]:"tracking",[yr.we]:"webEvents",[yr.wp]:"webPush"};P=new WeakSet,I=e=>Sr[e];const Pr=new class{constructor(){It(this,P)}setScriptInitialized(e){const t=Ct(this,P,I).call(this,e);window.__grIntegrationConfig[t].isModuleInitialized=true}isScriptInitialized(e){var t,r;const i=Ct(this,P,I).call(this,e);return(null==(r=null==(t=null==window?void 0:window.__grIntegrationConfig)?void 0:t[i])?void 0:r.isModuleInitialized)??false}},Ir=new class{constructor(){this.scriptModuleManager=Pr}initialize(e){const{xsid:t,grid:r,clientLatestGrid:i,domain:n,aid:s,useNOStorage:o,useBetterSubscriberIdentification:a,isServedFromCustomDomain:c,scriptsDomain:u,scriptsVersion:l,tracking:d,isDebugMode:p,uuuid:h}=e;if(p)Wt.startDebug();window.__grIntegrationConfig=window.__grIntegrationConfig||{cData:{aid:s,grid:r,domain:n,useNOStorage:o,useBetterSubscriberIdentification:a,isServedFromCustomDomain:c,clientLatestGrid:i,uuuid:h},visitor:{email:null,eComId:null,xsid:t},tracking:{isModuleInitialized:false,isEnabled:d},webEvents:{isModuleInitialized:false,visitorApplicationEndpoint:null,automationJourneyGraphs:[],popupGraphs:[]},webPush:{isModuleInitialized:false,customSwPath:null,wpid:null,pushDomain:null,promptEndpoint:null},analyticsData:{scriptsDomain:u,scriptsVersion:l},ecommerce:{isModuleInitialized:false},autoFunnel:{isModuleInitialized:false},eventBus:Zt,temporaryEventsStorage:fr,debug:p?tr():void 0,delayedScripts:{},scriptTypesInitialized:new Set}}canUseBackendForSubscriberIdentification(){return window.__grIntegrationConfig.cData.useBetterSubscriberIdentification}getUserAid(){return window.__grIntegrationConfig.cData.aid}getClientLatestGrid(){return window.__grIntegrationConfig.cData.clientLatestGrid}getUserAnalyticsDomain(){return window.__grIntegrationConfig.cData.domain}getUserUuid(){return window.__grIntegrationConfig.cData.uuuid}enablePopupDevMode(){window.__grIntegrationConfig.setCustomPopupRendererUrl=e=>{window.sessionStorage.setItem(Kt.PopupsRendererCustomUrl,e)}}getPopupRendererCustomUrl(){return window.sessionStorage.getItem(Kt.PopupsRendererCustomUrl)}setCustomSwPath(e){if("string"!=typeof e)throw new Error("Path type must be string");if(!e.match(/gr_sw_main.js|service-worker\/service-worker.js$/))throw new Error("Invalid sw file name");window.__grIntegrationConfig.webPush.customSwPath=e}getCustomSwPath(){var e;return null==(e=window.__grIntegrationConfig)?void 0:e.webPush.customSwPath}isTrackingEnabled(){return window.__grIntegrationConfig.tracking.isEnabled}isTrackingScriptServedFromCustomDomain(){return window.__grIntegrationConfig.cData.isServedFromCustomDomain}set visitorEmail(e){window.__grIntegrationConfig.visitor.email=e}get visitorEmail(){return window.__grIntegrationConfig.visitor.email}get pushWpid(){return window.__grIntegrationConfig.webPush.wpid}set pushWpid(e){window.__grIntegrationConfig.webPush.wpid=e}set pushDomain(e){window.__grIntegrationConfig.webPush.pushDomain=e}get pushDomain(){return window.__grIntegrationConfig.webPush.pushDomain}set pushPromptEndpoint(e){window.__grIntegrationConfig.webPush.promptEndpoint=e}get pushPromptEndpoint(){return window.__grIntegrationConfig.webPush.promptEndpoint}get eventBus(){return window.__grIntegrationConfig.eventBus}get canUseBackendStorageForEvents(){return window.__grIntegrationConfig.cData.useNOStorage}get webConnectScriptCdnUrl(){return window.__grIntegrationConfig.analyticsData.scriptsDomain}get webConnectCurrentScriptsVersion(){return window.__grIntegrationConfig.analyticsData.scriptsVersion}get isDebug(){var e,t;return!!(null==(t=null==(e=window.__grIntegrationConfig)?void 0:e.debug)?void 0:t.enabled)}set debugObject(e){window.__grIntegrationConfig.debug=e}get debugObject(){var e;return null==(e=window.__grIntegrationConfig)?void 0:e.debug}get delayedScripts(){var e;return(null==(e=window.__grIntegrationConfig)?void 0:e.delayedScripts)||{}}set delayedScripts(e){window.__grIntegrationConfig.delayedScripts=e}set visitorApplicationEndpoint(e){window.__grIntegrationConfig.webEvents.visitorApplicationEndpoint=e}get visitorApplicationEndpoint(){return window.__grIntegrationConfig.webEvents.visitorApplicationEndpoint}get userEventsStorageApplicationUrl(){return window.__grIntegrationConfig.ecommerce.webEventsSearchApplicationEndpoint}set userEventsStorageApplicationUrl(e){window.__grIntegrationConfig.ecommerce.webEventsSearchApplicationEndpoint=e}get temporaryEventsStorage(){return window.__grIntegrationConfig.temporaryEventsStorage}get automationJourneyGraphs(){return window.__grIntegrationConfig.webEvents.automationJourneyGraphs}get popupGraphs(){return window.__grIntegrationConfig.webEvents.popupGraphs}get visitorXsid(){return window.__grIntegrationConfig.visitor.xsid}},Er=204;function Cr(e,t){const r=e.isTextResponse??(null==t?void 0:t.isTextResponse);return fetch(e,{...t,headers:{...null==t?void 0:t.headers,...(null==t?void 0:t.omitAidHeader)?{}:{[dr.UserAid]:Ir.getUserAid()}}}).then((async e=>{if(e.ok){if(e.status===Er)return;return r?e.text():e.json()}const t=await e.text();return Promise.reject({statusCode:e.status,message:t})}))}var Dr=(e=>(e["visitorUuid"]="gaVisitorUuid",e["visitorValuable"]="gaIsValuable",e["VisitorEmail"]="gaVisitorEId",e["VisitorResubscribed"]="gaVisitorResubscribed",e["NotificationConsentStatus"]="gaNotificationConsent",e["NotificationConsentAcceptedFromPrompt"]="gaWpnConAcc",e["NotificationConsentCustomPromptRejectedDEPRECATED"]="gaWpnConRej-{promptId}",e["NotificationConsentCustomPromptRejected"]="gaWpnConRej-promptId",e))(Dr||{}),kr=(e=>(e[e["OneYear"]=31536e6]="OneYear",e[e["TwoWeeks"]=12096e5]="TwoWeeks",e))(kr||{});const Tr=new class{getVisitorData(){return Cr(new URL(`visitors/${Ir.getUserAid()}/${Ft(Dr.visitorUuid)}`,Ir.getUserAnalyticsDomain()).href)}},Ar=1e3*60*60*24,Ur=1e3;function Vr(e,t){const r=new Date(e+t*Ar),i=new Date(r.getFullYear(),r.getMonth(),r.getDate(),0,0,0);return Date.now()>=Date.parse(i.toString())}async function Nr(e,{maxAttempts:t=void 0,delay:r=Ur,multiplyDelay:i=true,maxDelay:n=Ur}={}){const s=async o=>{try{return await e()}catch(c){if(t&&o+1>t)throw c;const e=i?r*o:r;return 0,a=n&&e>n?n:e,new Promise((e=>{setTimeout((()=>e(s(o+1))),a)}))}var a};return s(1)}var _r,xr,Wr,Or,Fr,Lr,Rr,jr,Br,Jr,Mr,$r,qr,Gr,zr,Hr,Kr,Yr,Zr,Xr,Qr,ei,ti,ri,ii,ni,si,oi,ai,ci,ui,li,di,pi,hi,gi,mi,wi,vi,fi;(fi=_r||(_r={}))["ShowWhenCondition"]="showWhenCondition",fi["VisitorsCondition"]="visitors",fi["DeviceCondition"]="device",fi["LocationCondition"]="location",fi["ECommerceCondition"]="ecommerce",fi["TriggerFrequency"]="frequency",fi["PreventDisplay"]="preventDisplay",void(fi["DateRange"]="dateRange"),(vi=xr||(xr={}))["Mobile"]="mobile",vi["Tablet"]="tablet",void(vi["Desktop"]="desktop"),(wi=Wr||(Wr={}))["All"]="all",wi["New"]="new",void(wi["Returning"]="returning"),void((Or||(Or={}))["All"]="all"),(mi=Fr||(Fr={}))["ConditionsLogicSeparator"]="conditionsLogicSeparator",void(mi["ECommerceConditions"]="ecommerceConditions"),(gi=Lr||(Lr={}))["Amount"]="amount",void(gi["Date"]="date"),(hi=Rr||(Rr={}))["And"]="and",void(hi["Or"]="or"),(pi=jr||(jr={}))["Exactly"]="exactly",pi["LessThan"]="lessThan",void(pi["MoreThan"]="moreThan"),(di=Br||(Br={}))["LastDays"]="lastDays",void(di["DateRange"]="dateRange"),(li=Jr||(Jr={}))["AnyProduct"]="any",li["AnyCategory"]="any",li["AnyProductLiked"]="any",li["AnyProductInPlacedOrder"]="any",li["AnyCategoryInPlacedOrder"]="any",li["AnyProductInUpdatedCart"]="any",void(li["AnyCategoryInUpdatedCart"]="any"),(ui=Mr||(Mr={}))["PastEvents"]="filter",void(ui["FutureEvents"]="await"),(ci=$r||($r={}))["Category"]="category",void(ci["Product"]="product"),void((qr||(qr={}))["Product"]="product"),(ai=Gr||(Gr={}))["ViewProductOrCategory"]="productOrCategoryView",ai["LikeProduct"]="likeItem",ai["OrderPlaced"]="orderPlaced",void(ai["CartUpdated"]="cartUpdated"),(oi=zr||(zr={}))["Percent"]="percent",void(oi["Selector"]="selector"),(si=Hr||(Hr={}))["Instantly"]="instantly",si["Delay"]="delay",si["Exit"]="exit",si["Scroll"]="scroll",si["Inactivity"]="inactivity",void(si["Click"]="click"),(ni=Kr||(Kr={}))["AfterSubmit"]="submit",ni["AfterClose"]="close",void(ni["AfterTimes"]="timesAmount"),(ii=Yr||(Yr={}))["Always"]="always",ii["Session"]="session",void(ii["EveryDays"]="everyDays"),(ri=Zr||(Zr={}))["Exactly"]="equal",ri["LessThan"]="lessThan",void(ri["MoreThan"]="moreThan"),(ti=Xr||(Xr={}))["Exactly"]="equal",ti["LessThan"]="lessThan",void(ti["MoreThan"]="moreThan"),(ei=Qr||(Qr={}))[ei["InvalidCssSelector"]=1]="InvalidCssSelector",ei[ei["EmptyCssSelector"]=2]="EmptyCssSelector",ei[ei["CssSelectorTooLong"]=3]="CssSelectorTooLong",ei[ei["CssInvalidType"]=4]="CssInvalidType",ei[ei["InvalidTimeoutProperty"]=5]="InvalidTimeoutProperty",ei[ei["ShowWhenScrollPercentInvalidValueType"]=6]="ShowWhenScrollPercentInvalidValueType",ei[ei["ShowWhenScrollPercentValueOutOfBound"]=7]="ShowWhenScrollPercentValueOutOfBound",ei[ei["VisitorTriggerEmpty"]=8]="VisitorTriggerEmpty",ei[ei["VisitorTriggerInvalidProperty"]=9]="VisitorTriggerInvalidProperty",ei[ei["DevicesTriggerEmpty"]=10]="DevicesTriggerEmpty",ei[ei["DevicesTriggerInvalidValue"]=11]="DevicesTriggerInvalidValue",ei[ei["FrequencyEmptyTrigger"]=12]="FrequencyEmptyTrigger",ei[ei["FrequencyTriggerInvalidName"]=13]="FrequencyTriggerInvalidName",ei[ei["FrequencyTriggerNDaysInvalidPropertyValue"]=14]="FrequencyTriggerNDaysInvalidPropertyValue",ei[ei["FrequencyTriggerNDaysEmptyValue"]=15]="FrequencyTriggerNDaysEmptyValue",ei[ei["PreventDisplayTriggerInvalidName"]=16]="PreventDisplayTriggerInvalidName",ei[ei["PreventDisplayTriggerAfterTimesNoValue"]=17]="PreventDisplayTriggerAfterTimesNoValue",ei[ei["PreventDisplayTriggerAfterTimesInvalidValue"]=18]="PreventDisplayTriggerAfterTimesInvalidValue",ei[ei["DateRangeInvalidFromDate"]=19]="DateRangeInvalidFromDate",ei[ei["DateRangeInvalidToDate"]=20]="DateRangeInvalidToDate",ei[ei["DateRangeDateFromAfterDateTo"]=21]="DateRangeDateFromAfterDateTo",ei[ei["DateRangeToBeforeCurrentTime"]=22]="DateRangeToBeforeCurrentTime",ei[ei["LocationEmptyTrigger"]=23]="LocationEmptyTrigger",ei[ei["LocationInvalidType"]=24]="LocationInvalidType",ei[ei["LackOfLogicSeparator"]=25]="LackOfLogicSeparator",ei[ei["LackOfTriggerConditions"]=26]="LackOfTriggerConditions",ei[ei["InvalidTriggerConditions"]=27]="InvalidTriggerConditions",ei[ei["NoProductOrCategorySelected"]=28]="NoProductOrCategorySelected",ei[ei["ProductInvalidType"]=29]="ProductInvalidType",ei[ei["CategoryInvalidType"]=30]="CategoryInvalidType",ei[ei["AmountInvalidConditionName"]=31]="AmountInvalidConditionName",ei[ei["AmountInvalidConditionValueType"]=32]="AmountInvalidConditionValueType",ei[ei["DateInvalidConditionName"]=33]="DateInvalidConditionName",ei[ei["DateLastDaysInvalidConditionValue"]=34]="DateLastDaysInvalidConditionValue",ei[ei["DateDateRangeInvalidConditionValue"]=35]="DateDateRangeInvalidConditionValue",ei[ei["DateDateRangeFromInvalidValue"]=36]="DateDateRangeFromInvalidValue",ei[ei["DateDateRangeToInvalidValue"]=37]="DateDateRangeToInvalidValue",ei[ei["DateDateRangeDateFromAfterDateTo"]=38]="DateDateRangeDateFromAfterDateTo",ei[ei["PopupTriggerInvalidName"]=39]="PopupTriggerInvalidName",ei[ei["PopupTriggerLackOfValuesInLikeItemTrigger"]=40]="PopupTriggerLackOfValuesInLikeItemTrigger",ei[ei["PopupTriggerLikeItemInvalidValues"]=41]="PopupTriggerLikeItemInvalidValues",ei[ei["PopupTriggerOrderPlacedNoConditions"]=42]="PopupTriggerOrderPlacedNoConditions",ei[ei["PopupTriggerOrderPlacedInvalidProducts"]=43]="PopupTriggerOrderPlacedInvalidProducts",ei[ei["PopupTriggerOrderPlacedInvalidCategories"]=44]="PopupTriggerOrderPlacedInvalidCategories",ei[ei["PopupTriggerCartUpdatedNoConditions"]=45]="PopupTriggerCartUpdatedNoConditions",ei[ei["PopupTriggerCartUpdatedInvalidProducts"]=46]="PopupTriggerCartUpdatedInvalidProducts",ei[ei["PopupTriggerCartUpdatedInvalidCategories"]=47]="PopupTriggerCartUpdatedInvalidCategories",ei[ei["PopupTriggerPriceValueConditionInvalidComparator"]=48]="PopupTriggerPriceValueConditionInvalidComparator",ei[ei["PopupTriggerPriceValueConditionInvalidValue"]=49]="PopupTriggerPriceValueConditionInvalidValue",ei[ei["PopupTriggerProductsAmountValueConditionInvalidComparator"]=50]="PopupTriggerProductsAmountValueConditionInvalidComparator",ei[ei["PopupTriggerProductsAmountValueConditionInvalidValue"]=51]="PopupTriggerProductsAmountValueConditionInvalidValue",void(ei[ei["PopupTriggerInvalidTriggerType"]=52]="PopupTriggerInvalidTriggerType");var yi=(e=>(e[e["Mobile"]=480]="Mobile",e[e["Tablet"]=768]="Tablet",e))(yi||{});const bi=Symbol("DeviceService");class Si{constructor(e){if(new.target===Si&&e!==bi)throw new Error(`Invalid ${new.target.name} constructor`)}detectDeviceTypeByScreenWidth(e){var t;const{availWidth:r,availHeight:i}=screen;let n=null==(t=screen.orientation)?void 0:t.type;if(!n)n=window.matchMedia("(orientation: landscape)").matches?"landscape":"portrait";const s=n.match(/landscape/)?i:r;if(yi.Mobile>=s)return xr.Mobile;else if(s>yi.Mobile&&yi.Tablet>=s)return xr.Tablet;return e?xr.Tablet:xr.Desktop}isDesktopDevice(){return this.getDeviceType()===xr.Desktop}getDeviceType(){const{userAgentData:e}=window.navigator;if(e){const{mobile:t}=e;if(t)return this.detectDeviceTypeByScreenWidth(true);else return xr.Desktop}return this.detectDeviceTypeByScreenWidth()}getBrowserLanguage(){const{language:e}=window.navigator;if(e.match(/\w{2}-\w{2}/))return e.split("-")[0].toLowerCase();else return e.toLowerCase()}getUserOs(){const{userAgentData:e}=window.navigator;if(e)return e.platform.toLowerCase();else return this.getOsFromUserAgent()}getOsFromUserAgent(){let e="unknown";const{userAgent:t}=navigator,r=t.toLowerCase();if(r.includes("win"))e="windows";if(r.includes("mac"))e="macos";if(r.includes("x11"))e="unix";if(r.includes("linux"))e="Linux";if(r.includes("android"))e="android";if(/iphone|ipad|ipod/.test(r))e="ios";return e}}const Pi=new Si(bi);var Ii=(e=>(e["ExitIntend"]="exit-intend",e))(Ii||{});const Ei={gr:"exit-intend"},Ci=50;E=new WeakSet,C=function(e){return new Promise((t=>{document.documentElement.addEventListener("mouseleave",(r=>{if(Ct(this,N,_).call(this,r))t(),this.cleanLeaveFalseTimeout(),e.abort()}),{signal:e.signal})}))},D=new WeakSet,k=function(e){const{useMobileHistoryBasedExitIntend:t,useMobileScrollBasedExitIntend:r}=this.properties,i=[Ct(this,E,C).call(this,e)];if(t)i.push(Ct(this,T,A).call(this,e));if(r)i.push(Ct(this,U,V).call(this,e));return Promise.race(i)},T=new WeakSet,A=function(e){return new Promise((t=>{const r=window.history.state;document.documentElement.addEventListener("touchstart",(()=>{window.history.replaceState(Ei,""),window.history.pushState(Ei,""),window.addEventListener("popstate",(()=>{setTimeout((()=>{var i;if((null==(i=window.history.state)?void 0:i.gr)===Ii.ExitIntend)t(),this.cleanLeaveFalseTimeout(),e.abort(),window.history.replaceState(r,"")}),0)}),{signal:e.signal})}),{once:true,signal:e.signal})}))},U=new WeakSet,V=function(e){const t=document.documentElement;let r=t.scrollTop;return new Promise((i=>{window.addEventListener("scroll",(()=>{if(Ci>t.scrollTop&&-Ci>t.scrollTop-r)i(),this.cleanLeaveFalseTimeout(),e.abort();else r=t.scrollTop}),{signal:e.signal})}))},N=new WeakSet,_=e=>{const{clientX:t,clientY:r}=e,{clientWidth:i,clientHeight:n}=document.documentElement;return!(t>0&&i>t&&r>0&&n>r)};class Di extends Error{constructor(e){super(e),Object.setPrototypeOf(this,new.target.prototype),this.name=this.constructor.name}}class ki extends Di{}const Ti=Symbol("DebugDeviceService");class Ai extends Si{constructor(e){if(super(),new.target===Ai&&e!==Ti)throw new Error(`Invalid ${new.target.name} constructor`)}getDeviceType(){const e=ir(er.DeviceType);if(!e)return super.getDeviceType();if(!Object.values(xr).includes(e))return Ot.error("Incorrect debug device type. Check if device is correct. Instead of that we will use normal values"),super.getDeviceType();else return e}setDeviceType(e){rr(er.DeviceType,e)}}const Ui=new Ai(Ti),Vi=Symbol("LocationService");class Ni{constructor(e){if(new.target===Ni&&e!==Vi)throw new Error(`Invalid ${new.target.name} constructor`)}getVisitorCountryCode(){const{domain:e}=window.__grIntegrationConfig.cData;return fetch(`${e}web-user-data/country`).then((e=>e.text()))}}const _i=new Ni(Vi),xi=Symbol("DebugLocationService");class Wi extends Ni{constructor(e){if(super(),new.target===Wi&&e!==xi)throw new Error(`Invalid ${new.target.name} constructor`)}getVisitorCountryCode(){const e=ir(er.Location);if(!e)return super.getVisitorCountryCode();else return Promise.resolve(e)}setVisitorCountryCode(e){if("string"!=typeof e)return Ot.error("Incorrect debug country code value"),null;rr(er.Location,e)}}const Oi=new Wi(xi),Fi=400;class Li extends Di{constructor(){super("Invalid time properties")}}const Ri=new Map,ji=(e,t)=>{if(!Array.isArray(e))switch(typeof e){case"string":e=[e];break;case"undefined":e=[];break;default:throw new TypeError(`Expected '${t}' to be a string or an array, but got a type of '${typeof e}'`)}return e.filter((e=>{if("string"!=typeof e){if(void 0===e)return false;throw new TypeError(`Expected '${t}' to be an array of strings, but found a type of '${typeof e}' in the array`)}return true}))};function Bi(e,t,r){return((e,t,r,i)=>{if(e=ji(e,"inputs"),0===(t=ji(t,"patterns")).length)return[];t=t.map((e=>((e,t)=>{t={caseSensitive:false,...t};const r=e+JSON.stringify(t);if(Ri.has(r))return Ri.get(r);const i="!"===e[0];if(i)e=e.slice(1);e=(e=>{if("string"!=typeof e)throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")})(e).replace(/\\\*/g,"[\\s\\S]*");const n=new RegExp(`^${e}$`,t.caseSensitive?"":"i");return n.negated=i,Ri.set(r,n),n})(e,r)));const{allPatterns:n}=r||{},s=[];for(const o of e){let e;const r=[...t].fill(false);for(const[i,n]of t.entries())if(n.test(o))if(r[i]=true,e=!n.negated,!e)break;if(!(false===e||void 0===e&&t.some((e=>!e.negated))||n&&r.some(((e,r)=>!e&&!t[r].negated))))if(s.push(o),i)break}return s})(e,t,r,true).length>0}class Ji extends Di{constructor(){super("Failed to parse data from JSON string")}}var Mi=(e=>(e["Show"]="show",e["Close"]="close",e["Submit"]="submit",e))(Mi||{}),$i=(e=>(e["One"]="1.0",e))($i||{}),qi=(e=>(e["Web"]="web",e["Mobile"]="mobile",e))(qi||{});const Gi=new class{constructor(){this.timer=Date.now()}getCurrentVisitOnPageTime(){return Date.now()-this.timer}},zi=new class{encodeEmail(e){return btoa(e)}decode(e){return atob(e)}isEncodedString(e){try{return atob(e),true}catch{return false}}validateEmail(e){return/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/.test(e)}};function Hi(e){Ot.error(`Unsupported value: ${e}`)}class Ki extends Error{constructor(e){super(e)}static create(...[e,t]){switch(e){case"email":return new Ki(`Provided string ${t} is not valid email address`);default:Hi(e)}}}class Yi{constructor({e}={}){if(e)this.e=zi.encodeEmail(e)}static createFromContextData(e){try{if(zi.isEncodedString(e.e))e.e=zi.decode(e.e);return Yi.validate(e),new Yi(e)}catch(t){if(t instanceof Ki)return Ot.error(t),Yi.createBlank();throw t}}static createBlank(){return new Yi}static validate(e){if("e"in e&&!zi.validateEmail(e.e))throw Ki.create("email",e.e)}toJSON(){return{...this}}}class Zi{constructor(e){It(this,x,void 0),this.eventType=e,Et(this,x,null),this.eventId=null,this.aid=Ir.getUserAid(),this.grid=Ir.getClientLatestGrid(),this.time=Gi.getCurrentVisitOnPageTime(),this.context=Yi.createBlank(),this.uuid=Ft(Dr.visitorUuid),this.url=window.location.href,this.occurredOn=new Date,this.tags=[]}get externalUid(){return Pt(this,x)}toJSON(){return{eventId:this.eventId,aid:this.aid,grid:this.aid,uuid:this.uuid,externalUid:this.externalUid,context:this.context.toJSON(),time:this.time,url:this.url,tags:this.tags,eventType:this.eventType,occurredOn:this.occurredOn.toUTCString()}}toString({normalized:e}={}){if(e)return JSON.stringify(this.normalizeForExternalStorage());else return JSON.stringify(this.toJSON())}normalize(){const{eventId:e,...t}=this.toJSON();return t}getBaseNormalizedEvent(){return{version:$i.One,user_uuid:Ir.getUserUuid(),time:this.time,tags:this.tags,occurred_on:this.occurredOn.toISOString(),url:this.url,app:{lang:Pi.getBrowserLanguage(),device:Pi.getDeviceType(),os:Pi.getUserOs()},channel:qi.Web,visitor:{uuid:this.uuid,external_id:this.externalUid,xsid:Ir.visitorXsid}}}}x=new WeakMap;class Xi extends Zi{constructor(e,t,r=Yi.createBlank()){super(Xt.Popup),this.popupEvent=e,this.popupId=t,this.context=r}toJSON(){return{...super.toJSON(),popupId:this.popupId,popupEvent:this.popupEvent}}normalizeForExternalStorage(){return{...this.getBaseNormalizedEvent(),event:{version:"1.0",name:Xt.Popup}}}}class Qi extends Zi{toJSON(){return{...super.toJSON(),data:this.data}}normalizeForExternalStorage(){return{...this.getBaseNormalizedEvent(),event:{version:this.eventVersion,name:this.eventType,data:this.data}}}}class en extends Zi{constructor(e){super(Xt.ShopifyAbandonedCart),this.data=e}toJSON(){return{...super.toJSON(),data:this.data}}normalizeForExternalStorage(){return{...this.getBaseNormalizedEvent(),event:{version:"1.0",name:Xt.ShopifyAbandonedCart,data:this.data}}}}const tn=class e{constructor(e){It(this,W,void 0),Et(this,W,e)}static create(t){return new e(t)}validate(e){return Object.entries(Pt(this,W)).reduce(((t,[r,i])=>{if(false===t)return t;if(null==e[r]&&i._isOptional)return t;else return i.call(e,e[r])}),true)}stringifySchemaShape(){var t;return Ct(t=e,O,F).call(t,Pt(this,W))}trim(e,t=Pt(this,W)){var r;const i={};for(const[n,s]of Object.entries(e))if("object"==typeof s&&null!==s){if(n in t){const e=null==(r=t[n])?void 0:r.valueShape;if(Array.isArray(s))if(e)i[n]=s.map((t=>this.trim(t,e)));else i[n]=s;else i[n]=this.trim(s,e)}}else if(n in t)i[n]=s;return i}static string(){return nn((e=>"string"==typeof e),(()=>"string"))}static number(){return nn((e=>"number"==typeof e),(()=>"number"))}static boolean(){return nn((e=>"boolean"==typeof e),(()=>"boolean"))}static dateString(){return nn((e=>{if("string"!=typeof e)return false;else return!Number.isNaN(new Date(e).getTime())}),(()=>"date string"))}static object(t){return nn((r=>{if(!t||"object"!=typeof t)return false;else return e.create(t).validate(r)}),(()=>Ct(this,O,F).call(this,t)),t)}static array(t){return nn((r=>{if(!Array.isArray(r))return false;if("function"==typeof t)return r.every((e=>t(e)));const i=e.create(t);return r.every((e=>i.validate(e)))}),(()=>`[${Ct(this,O,F).call(this,t)}]`),"function"==typeof t?void 0:t)}};W=new WeakMap,O=new WeakSet,F=e=>{const t={};if("function"==typeof e)return e.getValueType();else for(const[r,i]of Object.entries(e))t[r]=i.getValueType();try{return JSON.stringify(t).replaceAll('\\"','"')}catch{return"Failed to parse validation shape"}},It(tn,O);let rn=tn;function nn(e,t,r){if(e.optional=()=>(e._isOptional=true,e),e.getValueType=t,r)e.valueShape=r;return e}const sn={id:rn.string(),sku:rn.string().optional(),name:rn.string().optional(),vendor:rn.string().optional(),price:rn.string().optional(),currency:rn.string().optional()},on=rn.array({id:rn.string(),name:rn.string().optional()}).optional(),an={id:rn.string()},cn={shop:rn.object({...an}).optional(),product:rn.object({...sn}),categories:on},un={product:rn.object({...sn}),categories:on,quantity:rn.number()},ln=rn.create({...cn}),dn=rn.create({shop:rn.object({...an}).optional(),id:rn.string(),name:rn.string().optional()}),pn=rn.create({...cn}),hn=rn.create({...cn}),gn=rn.create({...cn}),mn=rn.create({orderId:rn.string(),cartId:rn.string().optional(),price:rn.number(),currency:rn.string(),products:rn.array(un)}),wn=rn.create({price:rn.number(),cartId:rn.string(),cartUrl:rn.string(),currency:rn.string(),products:rn.array(un)});class vn extends Error{constructor(e){super(`Data doesn't match required schema: ${e}`)}}class fn extends Zi{constructor(e=Yi.createBlank()){super(Xt.PageVisit),this.context=e}normalizeForExternalStorage(){return{...this.getBaseNormalizedEvent(),event:{version:"1.0",name:this.eventType}}}}const yn={[Xt.ViewItem]:ln,[Xt.ViewCategory]:dn,[Xt.WishlistItem]:pn,[Xt.LikeItem]:hn,[Xt.UnlikeItem]:gn,[Xt.OrderPlaced]:mn,[Xt.Cart]:wn},bn={[Xt.ViewItem]:class extends Qi{constructor(e,t){super(Xt.ViewItem),this.data=e,this.context=t,this.eventVersion="1.0"}normalizeForExternalStorage(){const e=super.normalizeForExternalStorage();return e.event.data.product.price=parseFloat(e.event.data.product.price),e.time=Gi.getCurrentVisitOnPageTime(),e}},[Xt.ViewCategory]:class extends Qi{constructor(e,t){super(Xt.ViewCategory),this.data=e,this.context=t,this.eventVersion="1.0"}normalizeForExternalStorage(){const e=super.normalizeForExternalStorage();return e.time=Gi.getCurrentVisitOnPageTime(),e}},[Xt.WishlistItem]:class extends Qi{constructor(e,t){super(Xt.WishlistItem),this.data=e,this.context=t,this.eventVersion="1.0"}},[Xt.LikeItem]:class extends Qi{constructor(e,t){super(Xt.LikeItem),this.data=e,this.context=t,this.eventVersion="1.0"}normalizeForExternalStorage(){const e=super.normalizeForExternalStorage();return e.event.data.product.price=parseFloat(e.event.data.product.price),e}},[Xt.UnlikeItem]:class extends Qi{constructor(e,t){super(Xt.UnlikeItem),this.data=e,this.context=t,this.eventVersion="1.0"}normalizeForExternalStorage(){const e=super.normalizeForExternalStorage();return e.event.data.product.price=parseFloat(e.event.data.product.price),e}},[Xt.OrderPlaced]:class extends Qi{constructor(e,t){super(Xt.OrderPlaced),this.data=e,this.context=t,this.eventVersion="1.0"}},[Xt.Cart]:class extends Qi{constructor(e,t){super(Xt.Cart),this.data=e,this.context=t,this.eventVersion="1.0"}}},Sn=class e{static getPageVisitEvent(){return new fn}static getPopupEvent({popupId:e,popupEventName:t}){return new Xi(t,e)}static getPopupSubmitEvent(e){return new Xi(Mi.Submit,e)}static getPopupShowEvent(e){return new Xi(Mi.Show,e)}static getPopupCloseEvent(e){return new Xi(Mi.Close,e)}static getViewItemEvent(t,r){var i;return Ct(i=e,L,R).call(i,Xt.ViewItem,t,r)}static getWishlistItemEvent(t,r){var i;return Ct(i=e,L,R).call(i,Xt.WishlistItem,t,r)}static getLikeItemEvent(t,r){var i;return Ct(i=e,L,R).call(i,Xt.LikeItem,t,r)}static getUnlikeItemEvent(t,r){var i;return Ct(i=e,L,R).call(i,Xt.UnlikeItem,t,r)}static getViewCategoryEvent(t,r){var i;return Ct(i=e,L,R).call(i,Xt.ViewCategory,t,r)}static getOrderPlacedEvent(t,r){var i;return Ct(i=e,L,R).call(i,Xt.OrderPlaced,t,r)}static getCartUpdateEvent(t,r){var i;return Ct(i=e,L,R).call(i,Xt.Cart,t,r)}static getShopifyIntegrationAbandonedCartEvent(e){try{return(e=>{if("object"!=typeof e||null===e)throw new or("Invalid data parameter type");else{const t=Object.entries(ar),r=Object.keys(e);if(!cr.every((e=>r.includes(e))))throw new or("Lack of required parameters");if(!t.every((([t,r])=>!e[t]||typeof e[t]===r)))throw new or("Properties have invalid type")}return true})(e),new en((t=e,r=Object.keys(ar),Object.entries(t).reduce(((e,[t,i])=>{if(r.includes(t))e[t]=i;return e}),{})))}catch(i){return Ot.error(i),null}var t,r}};L=new WeakSet,R=(e,t,r)=>{const i=yn[e],n=bn[e];if(!i||!n)throw new Error("Event type not supported in event factory");if(!i.validate(t))throw new vn(i.stringifySchemaShape());return new n(i.trim(t),r)},It(Sn,L);let Pn=Sn;var In=(e=>(e["SetDomain"]="setDomain",e["SetListToken"]="setListToken",e["SetUserId"]="setUserId",e["SetEvent"]="setEvent",e["SetCookie"]="setCookie",e["SetAutoFunnelData"]="setAutoFunnelData",e["Push"]="push",e["SetCustomServiceWorkerPath"]="setCustomSwPath",e["ViewItem"]="viewItem",e["ViewCategory"]="viewCategory",e["LikeItem"]="likeItem",e["UnlikeItem"]="unlikeItem",e["WishListItem"]="wishlistItem",e["Purchase"]="orderPlaced",e["CartUpdate"]="cartUpdate",e["ShopifyAbandonedCart"]="shopifyAbandonedCart",e["SaveEvent"]="saveEvent",e["FlushEvents"]="flushEvents",e["SetUserDevice"]="setUserDevice",e["SetUserLocation"]="setUserLocation",e["SetVisitUrlPath"]="setVisitUrlPath",e["SetLastActivityDate"]="setLastActivityDate",e["SetIsNewVisitor"]="setIsNewVisitor",e["SetHasUserVisitPage"]="setHasUserVisitPage",e["SetRawEvent"]="setRawEvent",e["ImportScript"]="importScript",e["DelayScript"]="delayScript",e["InitScript"]="initScript",e))(In||{}),En=(e=>(e["UserEventSaved"]="userEventSaved",e["WebPushConsentAccepted"]="webPushConsentAccepted",e["WebPushCustomConsentRejected"]="webPushCustomConsentRejected",e["WebPushNativeConsentRejected"]="webPushNativeConsentRejected",e))(En||{});const Cn=Symbol("StorageService");class Dn{constructor(e){if(new.target===Dn&&e!==Cn)throw new Error(`Invalid ${new.target.name} constructor`)}async isNewVisitor(){return!(await this.getLastActivityDate())}getLastActivityDate(){return this.getLastActivityDateFromBrowserStorage()}getLastActivityDateFromBrowserStorage(){var e;const t=Ft(Dr.visitorUuid),r=localStorage.getItem("gaLocalStorageVisitKey");let i;try{i=JSON.parse(r)}catch{throw new Ji}if(null==i?void 0:i[t])return Promise.resolve(new Date(null==(e=i[t])?void 0:e.lastActivity));else return null}saveUserActivity(){Ir.eventBus.publish(In.SaveEvent,{sendToBackend:true,saveToLocal:false},Yi.createBlank(),Xt.PageVisit,null),this.saveUserActivityToBrowserStorage()}saveUserActivityToBrowserStorage(){const e={[Ft(Dr.visitorUuid)]:{lastActivity:Pn.getPageVisitEvent().occurredOn.toUTCString()}};try{window.localStorage.setItem("gaLocalStorageVisitKey",JSON.stringify(e))}catch{throw new Ji}}}const kn=new Dn(Cn),Tn=Symbol("DebugStorageService");class An extends Dn{constructor(e){if(super(),new.target===An&&e!==Tn)throw new Error(`Invalid ${new.target.name} constructor`)}getLastActivityDate(){var e;const t=ir(er.BrowserStorageLastActivityDate);if(isNaN(null==(e=null==t?void 0:t.getTime)?void 0:e.call(t)))return super.getLastActivityDate();else return Promise.resolve(t)}setLastActivityDate(e){const t=new Date(e);if(isNaN(t.getTime()))return Ot.error("Incorrect dateString for last activity date. Try again with isoString."),null;rr(er.BrowserStorageLastActivityDate,t,t.toISOString())}isNewVisitor(){const e=ir(er.NewVisitor);if(void 0===e)return super.isNewVisitor();else return Promise.resolve(e)}setIsNewVisitor(e){rr(er.NewVisitor,e,String(e))}}const Un=new An(Tn);function Vn(){return nr(kn,Un)}var Nn=(e=>(e["Always"]="always",e["OnceEveryDays"]="xDays",e["Session"]="everySession",e))(Nn||{});const _n=Symbol("SessionService");class xn{constructor(e){if(new.target===xn&&e!==_n)throw new Error(`Invalid ${new.target.name} constructor`)}hasUserVisitedPage(){return this.getSessionVisitData().count>1}saveUserVisit(){const e=this.getSessionVisitData()||{count:0};sessionStorage.setItem("gaUserPageSessionVisit",JSON.stringify({...e,count:e.count+1}))}getSessionVisitData(){return JSON.parse(sessionStorage.getItem("gaUserPageSessionVisit"))}}const Wn=new xn(_n),On=Symbol("DebugSessionService");class Fn extends xn{constructor(e){if(super(),new.target===Fn&&e!==On)throw new Error(`Invalid ${new.target.name} constructor`)}hasUserVisitedPage(){const e=ir(er.HasUserVisitPage);if(void 0===e)return super.hasUserVisitedPage();else return e}setHasUserVisitedPage(e){rr(er.HasUserVisitPage,e)}}const Ln=new Fn(On);function Rn(){return nr(Wn,Ln)}const jn=Symbol("VisitService");class Bn{constructor(e){if(new.target===Bn&&e!==jn)throw new Error(`Invalid ${new.target.name} constructor`)}async validateFrequencyProperty(e,t=0){if(e===Nn.Session)return!Rn().hasUserVisitedPage();else if(e===Nn.OnceEveryDays){const e=await Vn().getLastActivityDate();if(e)return Vr(e.getTime(),t)}return true}async validateVisitorsProperty(e){const t=await Vn().isNewVisitor();switch(e){case Wr.New:return t;case Wr.Returning:return!t;default:return true}}validateUrlPath(e="*"){const t=window.location.pathname;return this.validatePath(e,t)}validatePath(e,t){return Bi(t,e)}}const Jn=new Bn(jn),Mn=Symbol("DebugVisitService");class $n extends Bn{constructor(e){if(super(),new.target===$n&&e!==Mn)throw new Error(`Invalid ${new.target.name} constructor`)}validateUrlPath(e="*"){const t=ir(er.VisitUrlPath);if(void 0===t)return super.validateUrlPath(e);else return super.validatePath(e,t)}setVisitPathUrl(e){if("string"!=typeof e)return Ot.error("Invalid url path type. Try again with string variable"),null;rr(er.VisitUrlPath,e)}}const qn=new $n(Mn);var Gn=(e=>(e["Api"]="api",e["Db"]="db",e["AutomationJourneyReactWebPushApi"]="automationJourneyReactWebPushApi",e["AutomationJourneyReactWebPushDb"]="automationJourneyReactWebPushDb",e))(Gn||{}),zn=(e=>(e["Events"]="gr_webconnect",e["VisitorJourneys"]="gr_visitor_journeys",e["ServiceWorkerCallbacks"]="gr_sw_callbacks",e))(zn||{});const Hn={gr_webconnect:1,gr_visitor_journeys:2,gr_sw_callbacks:1};var Kn=(e=>(e["UserActivityEvents"]="user_activity_events",e))(Kn||{}),Yn=(e=>(e["EventType"]="eventType",e["VisitorUuid"]="visitorUuid",e["EventTypeWithVisitor"]="eventType, visitorUuid",e))(Yn||{}),Zn=(e=>(e["VisitorJourneys"]="visitorJourneys",e["VisitorJourneysGraphHistory"]="visitorJourneysGraphHistory",e["GraphJourneyFetchedData"]="graphJourneyFetchedData",e))(Zn||{}),Xn=(e=>(e["Callbacks"]="callbacks",e))(Xn||{}),Qn=(e=>(e["VisitorUuid"]="visitor_uuid",e["JourneyIdentifier"]="uuid",e["VisitorUuidWithJourneyIdentifier"]="visitor_uuid, uuid",e))(Qn||{}),es=(e=>(e["VisitorUuid"]="visitor.uuid",e["NodeUuid"]="node.uuid",e["VisitorUuidWithNodeUuid"]="visitor.uuid, node.uuid",e))(es||{}),ts=(e=>(e["GraphId"]="graph.id",e))(ts||{});let rs,is;const ns=new WeakMap,ss=new WeakMap,os=new WeakMap,as=new WeakMap,cs=new WeakMap;let us={get(e,t,r){if(e instanceof IDBTransaction){if("done"===t)return ss.get(e);if("objectStoreNames"===t)return e.objectStoreNames||os.get(e);if("store"===t)return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return ds(e[t])},set:(e,t,r)=>(e[t]=r,true),has(e,t){if(e instanceof IDBTransaction&&("done"===t||"store"===t))return true;else return t in e}};function ls(e){if("function"==typeof e)return function(e){if(e===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype))return function(t,...r){const i=e.call(ps(this),t,...r);return os.set(i,t.sort?t.sort():[t]),ds(i)};if((is||(is=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(e))return function(...t){return e.apply(ps(this),t),ds(ns.get(this))};else return function(...t){return ds(e.apply(ps(this),t))}}(e);if(e instanceof IDBTransaction)!(e=>{if(ss.has(e))return;const t=new Promise(((t,r)=>{const i=()=>{e.removeEventListener("complete",n),e.removeEventListener("error",s),e.removeEventListener("abort",s)},n=()=>{t(),i()},s=()=>{r(e.error||new DOMException("AbortError","AbortError")),i()};e.addEventListener("complete",n),e.addEventListener("error",s),e.addEventListener("abort",s)}));ss.set(e,t)})(e);if(t=e,(rs||(rs=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])).some((e=>t instanceof e)))return new Proxy(e,us);else return e;var t}function ds(e){if(e instanceof IDBRequest)return(e=>{const t=new Promise(((t,r)=>{const i=()=>{e.removeEventListener("success",n),e.removeEventListener("error",s)},n=()=>{t(ds(e.result)),i()},s=()=>{r(e.error),i()};e.addEventListener("success",n),e.addEventListener("error",s)}));return t.then((t=>{if(t instanceof IDBCursor)ns.set(t,e)})).catch((()=>{})),cs.set(t,e),t})(e);if(as.has(e))return as.get(e);const t=ls(e);if(t!==e)as.set(e,t),cs.set(t,e);return t}const ps=e=>cs.get(e),hs=["get","getKey","getAll","getAllKeys","count"],gs=["put","add","delete","clear"],ms=new Map;function ws(e,t){if(!(e instanceof IDBDatabase&&!(t in e)&&"string"==typeof t))return;if(ms.get(t))return ms.get(t);const r=t.replace(/FromIndex$/,""),i=t!==r,n=gs.includes(r);if(!(r in(i?IDBIndex:IDBObjectStore).prototype)||!(n||hs.includes(r)))return;const s=async function(e,...t){const s=this.transaction(e,n?"readwrite":"readonly");let o=s.store;if(i)o=o.index(t.shift());return(await Promise.all([o[r](...t),n&&s.done]))[0]};return ms.set(t,s),s}var vs;vs=us,void(us={...vs,get(e,t,r){return ws(e,t)||vs.get(e,t,r)},has(e,t){return!!ws(e,t)||vs.has(e,t)}});const fs=new class{openEventsDatabaseConnection(e){return this.openConnection(zn.Events,Hn[zn.Events],e)}openAutomationJourneysDatabaseConnection(e){return this.openConnection(zn.VisitorJourneys,Hn[zn.VisitorJourneys],e)}openServiceWorkerCallbacksDatabaseConnection(e){return this.openConnection(zn.ServiceWorkerCallbacks,Hn[zn.ServiceWorkerCallbacks],e)}async openConnection(e,t,r){const i=await((e,t,{blocked:r,upgrade:i,blocking:n,terminated:s}={})=>{const o=indexedDB.open(e,t),a=ds(o);if(i)o.addEventListener("upgradeneeded",(e=>{i(ds(o.result),e.oldVersion,e.newVersion,ds(o.transaction),e)}));if(r)o.addEventListener("blocked",(e=>r(e.oldVersion,e.newVersion,e)));return a.then((e=>{if(s)e.addEventListener("close",(()=>s()));if(n)e.addEventListener("versionchange",(e=>n(e.oldVersion,e.newVersion,e)))})).catch((()=>{})),a})(e,t,{blocked(e,t,r){Ot.error(`Connection to old db version: ${t} not closed. Version ${e} not available`,r)},upgrade(e,t,i){Ot.log(`New db version ${i} detected, upgrading from ${t}`),r(t,i,e)},terminated(){Ot.log("Closing db connection")},blocking(e,t,r){Ot.log(`Current connection od db version ${e} is blocking connection to version ${t}.`,r),i.close()}});return i}};fs.openServiceWorkerCallbacksDatabaseConnection.bind(fs),fs.openAutomationJourneysDatabaseConnection.bind(fs);const ys=Symbol("BrowserEventsStorageService");j=new WeakSet,B=(e,t,r)=>{if(0===e&&1===t)!(e=>{if(!e.objectStoreNames.contains(Kn.UserActivityEvents))try{const t=e.createObjectStore(Kn.UserActivityEvents,{keyPath:"id",autoIncrement:true});t.createIndex(Yn.EventType,"eventType",{unique:false}),t.createIndex(Yn.VisitorUuid,"uuid",{unique:false}),t.createIndex(Yn.EventTypeWithVisitor,["eventType","uuid"])}catch(t){Ot.error("Error while initializing/upgrading database",t)}})(r)};let bs=class e{constructor(t){if(It(this,j),new.target===e&&t!==ys)throw new Error(`Invalid ${new.target.name} constructor`)}async saveEvent(e){const t=e instanceof Zi?e.normalize():e;try{const e=(await fs.openEventsDatabaseConnection(Ct(this,j,B))).transaction(Kn.UserActivityEvents,"readwrite"),r=e.objectStore(Kn.UserActivityEvents),i=await r.add(t);return await e.done,i}catch(r){Ot.error("Error while saving event to database",r)}}async getEvents(e){const t=Ft(Dr.visitorUuid);try{const r=(await fs.openEventsDatabaseConnection(Ct(this,j,B))).transaction(Kn.UserActivityEvents,"readwrite"),i=r.objectStore(Kn.UserActivityEvents).index(Yn.EventTypeWithVisitor),n=await i.getAll([e,t]);return await r.done,n}catch(r){Ot.error("Error while reading from database",r)}}async updateEvent(e,t){const r=(await fs.openEventsDatabaseConnection(Ct(this,j,B))).transaction(Kn.UserActivityEvents,"readwrite").objectStore(Kn.UserActivityEvents),i=await r.get(e);if(i){const e=Jt(i,t);await r.put(e)}}async getPopupECommerceEvents(e){const t=Ft(Dr.visitorUuid),r=(await fs.openEventsDatabaseConnection(Ct(this,j,B))).transaction(Kn.UserActivityEvents,"readwrite").store.index(Yn.VisitorUuid),i=[];let n=await r.openCursor(IDBKeyRange.only(t));for(;n;){const{value:t}=n;if(e(t))i.push(t);n=await n.continue()}return i}};const Ss=new bs(ys),Ps=Symbol("DebugBrowserEventsStorageService");class Is extends bs{constructor(e){if(super(),new.target===Is&&e!==Ps)throw new Error(`Invalid ${new.target.name} constructor`)}async getPopupECommerceEvents(e){const t=ir(er.Events)||[];if(!t.length)return super.getPopupECommerceEvents(e);else return t.filter(e)}async getEvents(e){const t=Ft(Dr.visitorUuid),r=ir(er.Events)||[];if(!r.length)return super.getEvents(e);else return r.filter((({eventType:r,uuid:i})=>r===e&&i===t))}async saveEvent(e){const t=e instanceof Zi?e.toJSON():e,r=[...ir(er.Events)||[],t];try{const e=JSON.stringify(r);return rr(er.Events,r,e),Math.random()}catch(i){Ot.error(`Can't parse new debug events. Try again.`)}}}const Es=new Is(Ps);function Cs(e,t,r){return r.filter((r=>r.popupEvent===t&&r.popupId===e))}function Ds(e,t){return Cs(e,Mi.Show,t).length>0}function ks(e,t){var r;const i=Cs(e,Mi.Show,t).sort(((e,t)=>Date.parse(t.occurredOn)-Date.parse(e.occurredOn)));if(!(null==(r=i[0])?void 0:r.occurredOn))return null;else return new Date(i[0].occurredOn)}function Ts(e,t){return Cs(e,Mi.Close,t).length>0}function As(e,t){return Cs(e,Mi.Submit,t).length>0}function Us(e,t){return Cs(e,Mi.Show,t).length}const Vs=new class{getStorage(){try{const e=localStorage.getItem("grPopupsServiceKey");return JSON.parse(e)}catch(e){Ot.error("Failed to get local storage data",e)}}getPopupEvents(){return nr(Ss,Es).getEvents(Xt.Popup)}async getLastPopupImpression(e){return ks(e,await this.getPopupEvents())}async getPopupImpressionsAmount(e){return Us(e,await this.getPopupEvents())}async hasPopupBeenClosedBefore(e){return Ts(e,await this.getPopupEvents())}async hasPopupBeenSeenInSession(e){return Ds(e,await this.getPopupEvents())}async hasPopupBeenSubmittedBefore(e){return As(e,await this.getPopupEvents())}_getPopupEventsFromLocalStorage(){var e,t;return null==(t=null==(e=this.getStorage())?void 0:e.events)?void 0:t.filter((e=>e.popupEvent===Mi.Submit||Mi.Close||Mi.Show))}registerPopupClose(e){return this.addEventToStorage(Mi.Close,e)}registerPopupSubmit(e){return this.addEventToStorage(Mi.Submit,e)}registerPopupView(e){return this.addEventToStorage(Mi.Show,e)}async migrateData(){if(!localStorage.getItem("grPopupsMigration")){const e=this._getPopupEventsFromLocalStorage();if(e)e.forEach((e=>{this.addEventToStorage(e.popupEvent,e.popupId,true)})),localStorage.setItem("grPopupsServiceKey",JSON.stringify({})),localStorage.setItem("grPopupsMigration","true")}}addEventToStorage(e,t,r){return Ir.eventBus.publish(In.SaveEvent,{sendToBackend:false,preventRenotify:r},Yi.createBlank(),Xt.Popup,{popupEventName:e,popupId:t}),Promise.resolve()}};class Ns{static sendJSON(e,t,r=true){const i=r?JSON.stringify({...JSON.parse(t),[dr.UserAid]:Ir.getUserAid()}):t;navigator.sendBeacon(e,new Blob([i],{type:"application/json"}))}}const _s=[Xt.OrderPlaced,Xt.Cart,Xt.LikeItem,Xt.UnlikeItem,Xt.WishlistItem,Xt.ViewItem,Xt.ViewCategory],xs=[Xt.Cart,Xt.LikeItem,Xt.UnlikeItem,Xt.OrderPlaced,Xt.ViewCategory,Xt.ViewItem];J=new WeakSet,M=()=>new URL(`u/${Ir.getUserUuid()}/e/${qi.Web}/handle/`,Ir.userEventsStorageApplicationUrl).href;const Ws=new class{constructor(){It(this,J)}async addPopupEventToStorage(e){throw new Error("Not implemented")}async getPopupActivityData(e){throw new Error("Not implemented")}async saveEventsToStorage(e){if(Ir.userEventsStorageApplicationUrl&&Ir.getUserUuid()){const t=e.filter((e=>_s.includes(e.event.name)));if(t.length>0)Ns.sendJSON(Ct(this,J,M).call(this),JSON.stringify(t),false)}else Ot.error("Attempt to send web events to search was made without search application endpoint or uuuid!")}async sendEventsToMetricsInc(e){const t=e.filter((e=>xs.includes(e.event.name)));if(t.length>0){const e=JSON.stringify({events:t.map((e=>({eventType:e.event.name}))),url:window.location.origin}),r=new URL("/a/ue",Ir.getUserAnalyticsDomain()).href;Ns.sendJSON(r,e)}}},Os=Symbol("PopupsService");class Fs{constructor(e){if(new.target===Fs&&e!==Os)throw new Error(`Invalid ${new.target.name} constructor`)}setGrid(e){this.grid=e}setAid(e){this.aid=e}async registerPopupClose(e){return this.addEventToStorage(Pn.getPopupCloseEvent(e))}async registerPopupSubmit(e){return this.addEventToStorage(Pn.getPopupSubmitEvent(e))}async registerPopupView(e){return this.addEventToStorage(Pn.getPopupShowEvent(e))}hasPopupBeenSeenInSession(e){return this.getPopupActivityData(e).then((e=>!!e.lastImpressionOccurredAt))}addEventToStorage(e){return Ws.addPopupEventToStorage(e)}async getPopupActivityData(e){return Ws.getPopupActivityData(e)}getLastPopupImpression(e){return this.getPopupActivityData(e).then((e=>new Date(e.lastImpressionOccurredAt)))}hasPopupBeenClosedBefore(e){return this.getPopupActivityData(e).then((e=>e.closes>0))}hasPopupBeenSubmittedBefore(e){return this.getPopupActivityData(e).then((e=>e.submits>0))}getPopupImpressionsAmount(e){return this.getPopupActivityData(e).then((e=>e.impressions))}}function Ls(){return Vs}new Fs(Os);const Rs=Symbol("DebugPopupService");class js extends Fs{constructor(e){if(super(),this.hasPopupBeenSeenInSession=e=>{const t=this.getAllEvents();return Promise.resolve(Ds(e,t))},this.getLastPopupImpression=e=>{var t;const r=ks(e,this.getAllEvents());if(isNaN(null==(t=null==r?void 0:r.getTime)?void 0:t.call(r)))return Ls().getLastPopupImpression(e);else return Promise.resolve(r)},this.hasPopupBeenClosedBefore=e=>{const t=this.getAllEvents();return Promise.resolve(Ts(e,t))},this.hasPopupBeenSubmittedBefore=e=>{const t=this.getAllEvents();return Promise.resolve(As(e,t))},this.getPopupImpressionsAmount=e=>{const t=this.getAllEvents();return Promise.resolve(Us(e,t))},new.target===js&&e!==Rs)throw new Error(`Invalid ${new.target.name} constructor`)}getAllEvents(){return ir(er.Events)||[]}}const Bs=new js(Rs);function Js(){return nr(Ls(),Bs)}const Ms="https://us-wbe.gr-cdn.com/dynamic/gr-popups.js";$=new WeakMap,q=new WeakMap;const $s=new class extends Mt{constructor(){super(...arguments),It(this,$,false),It(this,q,false)}attachPopupLibrary(){return new Promise(((e,t)=>{if(Pt(this,$))e();else if(Pt(this,q))this.on("libraryAttachingFinished",e,{once:true});else{Et(this,q,true);const r=document.createElement("script");r.src=Ir.getPopupRendererCustomUrl()??Ms,r.async=true,r.addEventListener("load",(()=>{Et(this,$,true),Et(this,q,false),this.emit("libraryAttachingFinished"),e()}),{once:true}),r.addEventListener("error",t),document.head.appendChild(r)}}))}},qs="https://",Gs="http://",zs="www.",Hs=/^(http:\/\/|https:\/\/)/;class Ks{constructor(e){this.url=e,this.enhancedUrls=[]}static create(e){return new Ks(decodeURI(e))}withSlash(){if(!(this.url.endsWith("*")||this.url.endsWith("+")||this.url.includes("?")||this.url.endsWith("/")))this.url=`${this.url}/`;return this}withLackOfProtocolAndWww(){if(!this.url.startsWith("*")&&!this.hasProtocolIncluded()&&!this.hasWwwPart())this.enhancedUrls=[...this.enhancedUrls,`${qs}${this.url}`,`${Gs}${this.url}`,`${qs}${zs}${this.url}`,`${Gs}${zs}${this.url}`];return this}withEnforcedProtocol(){if(!this.hasProtocolIncluded())this.enhancedUrls=[...this.enhancedUrls,`${qs}${this.url}`,`${Gs}${this.url}`];return this}withDecodeSpecialChars(){return this.enhancedUrls=this.enhancedUrls.map((e=>decodeURI(e))),this}withLackOfWww(){if(this.url.startsWith("*"))return this;if(this.hasProtocolIncluded()&&!this.hasWwwPart())this.enhancedUrls=[...this.enhancedUrls,`${qs}${zs}${this.url.replace(Hs,"")}`,`${Gs}${zs}${this.url.replace(Hs,"")}`];return this}withLackOfProtocol(){if(this.url.startsWith("*"))return this;if(!this.hasProtocolIncluded()&&this.hasWwwPart())this.enhancedUrls=[...this.enhancedUrls,`${qs}${this.url}`,`${Gs}${this.url}`];return this}enhance(){return[...this.enhancedUrls,this.url]}hasProtocolIncluded(){return this.url.startsWith(qs)||this.url.startsWith(Gs)}hasWwwPart(){return this.url.replace(/^(http:\/\/|https:\/\/)/,"").startsWith(zs)}}function Ys(e,t){return(e=>e.map((e=>Ks.create(e).withSlash().withLackOfProtocolAndWww().withLackOfProtocol().withLackOfWww().withDecodeSpecialChars().enhance())).flat(1))(t).some((t=>{const r=Array.from(t.matchAll(/[*+]/g));let i;if(r.length)i=r.reduce(((e,r,i,n)=>{var s;const o=[...e,Zs(t.substring(((null==(s=n[i-1])?void 0:s.index)??-1)+1,r.index)),"*"===r[0]?".*":"."];if(i===n.length-1)o.push(Zs(t.substring(r.index+1)));return o}),[]).join("");else i=Zs(t);return new RegExp(`^${i}$`).test((e=>{if(!e.includes("?")&&!e.endsWith("/"))return`${decodeURI(e)}/`;else return decodeURI(e)})(e))}))}function Zs(e){return e.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}G=new WeakMap,z=new WeakSet,H=function(e,t,r,i="eq"){if(r.has(e))return Ct(this,K,Y).call(this,t,r.get(e),i);else return false},K=new WeakSet,Y=(e,t,r="eq")=>{switch(r){case"eq":return!!decodeURIComponent(t).match(new RegExp(`^${decodeURIComponent(e).replaceAll("*",".*").replaceAll("+",".")}$`));default:return Hi(r),false}};let Xs=class e{constructor({baseUrl:e,queryParamsSelectionRule:t,queryParams:r,path:i,currentUrl:n}){It(this,z),It(this,K),It(this,G,(e=>{const t=new URL(this.path||"",e),r=new URL(this.currentUrl);for(const[i,n]of Object.entries(this.queryParams||{}))t.searchParams.append(i,n.value);if(this.queryParams)if("all"===this.queryParamsSelectionRule){if(!Array.from(t.searchParams.entries()).every((([e,t])=>Ct(this,z,H).call(this,e,t,r.searchParams,this.queryParams[e].operator))))return false}else if(!Array.from(t.searchParams.entries()).some((([e,t])=>Ct(this,z,H).call(this,e,t,r.searchParams,this.queryParams[e].operator))))return false;if(this.path)if(!Ct(this,K,Y).call(this,t.pathname,r.pathname))return false;return Ct(this,K,Y).call(this,t.origin,r.origin)})),this.baseUrl=e,this.path=i,this.queryParams=r,this.queryParamsSelectionRule=t,this.currentUrl=n}static create(t){return new e(t)}isOnCurrentUrl(){return Ks.create(this.baseUrl).withEnforcedProtocol().withSlash().enhance().filter((e=>{try{return new URL(e),true}catch(t){return Ot.warn("Invalid URL",e),false}})).some(Pt(this,G))}};function Qs(e){return e.sort(((e,t)=>Date.parse(t.occurredOn)-Date.parse(e.occurredOn)))[0].eventType===Xt.LikeItem}const eo=[Xt.ViewItem,Xt.ViewCategory,Xt.LikeItem,Xt.UnlikeItem,Xt.OrderPlaced,Xt.Cart,Xt.WishlistItem];function to(e){return oo(e,Xt.ViewCategory)}function ro(e){return oo(e,Xt.ViewItem)}function io(e){return oo(e,Xt.LikeItem)}function no(e){return oo(e,Xt.OrderPlaced)}function so(e){return oo(e,Xt.Cart)}function oo(e,t){return"object"==typeof e&&null!==e&&"eventType"in e&&e["eventType"]===t}const ao=1e3*60*60*24;function co(e,t,r){switch(r){case"equal":return e===t;case"lessThan":return t>e;case"moreThan":return e>t;default:Hi(r)}}function uo(e,t){var r;const{category:i,amount:n,product:s,price:o}=e.condition,{products:a,price:c}=t.data;let u=false;if(s){if("any"===s.id)u=true;if(a.some((e=>s.id.includes(e.product.id))))u=true}if(i){if("any"===i.id)u=true;if(a.some((e=>e.categories.some((e=>i.id.includes(e.id))))))u=true}if(n){const{value:e,condition:t}=n;if(co(a.reduce(((e,t)=>e+t.quantity),0),e,t))u=true}if(o){const{value:e,condition:t}=o;if(co(c,e,t))u=true}if(u)u=lo(t,null==(r=e.settings)?void 0:r.date);return u}function lo(e,t,{ignoreToDateInDateRange:r}={}){const{occurredOn:i}=e;if(t){const{name:e,value:n}=t;if(e===Br.LastDays)return new Date(i).getTime()>Date.now()-n*ao;if(e===Br.DateRange){const{from:e,to:t}=n,s=new Date(i).getTime(),o=!e||new Date(e).getTime(){if(t){const{name:r,value:i}=t;switch(r){case jr.Exactly:return i===e.length;case jr.MoreThan:return e.length>i;case jr.LessThan:return i>e.length;default:Hi(r)}}return e.length>0};const po=new class{constructor(){this.visitorFlow=[]}addEntry(e){this.visitorFlow.push(e)}hasElementBeenVisited(e){return!!this.visitorFlow.find((t=>t===e))}};function ho(e,t){const{amount:r,value:i,product:n,category:s}=e,{price:o,products:a}=t.data;if(r){const{condition:e,value:t}=r,i=a.reduce(((e,t)=>e+t.quantity),0);switch(e){case"equal":return i===t;case"lessThan":return t>i;case"moreThan":return i>t}}if(i){const{condition:e,value:t}=i;switch(e){case"equal":return o===t;case"lessThan":return t>o;case"moreThan":return o>t}}if(n){const{id:e}=n;if("any"===e)return true;else if(Array.isArray(e))return a.some((t=>e.includes(t.product.id)))}if(s){const{id:e}=s;if("any"===e)return true;else if(Array.isArray(e))return a.some((t=>{const{categories:r}=t;return r.some((t=>e.includes(t.id)))}))}throw new Error("Unknown condition in order placed ecommerce activity node condition")}const go=new Map;ie=new WeakMap,ne=new WeakMap,se=new WeakSet,oe=function(e){const{conditions:t,separator:r="or"}=this.properties;if("or"===r){const r=t.some((t=>Ct(this,ae,ce).call(this,t,e)));if(r)Ct(this,de,pe).call(this,e.eventId);return r}else if("and"===r){const r=t.find((t=>Ct(this,ae,ce).call(this,t,e)));if(r)return Pt(this,ne).push(r.conditionId),Ct(this,de,pe).call(this,e.eventId),this.properties.conditions.every((e=>Pt(this,ne).includes(e.conditionId)))}else Hi(r)},ae=new WeakSet,ce=(e,t)=>{const{product:r,category:i,likeProduct:n,orderPlaced:s,cartUpdate:o}=e;if(r&&ro(t)){const{data:e}=t,{id:i,category:n}=r;if("any"===i)return true;else if(Array.isArray(i))return i.includes(e.product.id);else if("any"===n)return e.categories.length>0;else if(Array.isArray(n))return n.some((t=>{var r;return null==(r=e.categories)?void 0:r.find((e=>e.id===t))}))}if(i&&to(t)){const{data:e}=t,{id:r}=i;if("any"===r)return true;else if(Array.isArray(r))return r.includes(e.id)}if(n&&io(t)){const{product:e}=n;if("any"===e.id)return true;else if(Array.isArray(e.id))return e.id.includes(t.data.product.id)}if(s&&no(t))return((e,t)=>ho(e,t))(s,t);if(o&&so(t))return((e,t)=>ho(e,t))(o,t);else return false},ue=new WeakSet,le=async function(){if(Pt(this,ie)){const e=await Ir.temporaryEventsStorage.getAllECommerceEvents();for(const t of e)if(!Ct(this,he,ge).call(this,t.eventId))if(Ct(this,se,oe).call(this,t))return true}else Ot.error("Could not find graph id for await ecommerce activity node",this.id)},de=new WeakSet,pe=function(e){if(go.has(Pt(this,ie)))go.get(Pt(this,ie)).add(e);else go.set(Pt(this,ie),new Set([e]))},he=new WeakSet,ge=function(e){if(go.has(Pt(this,ie)))return go.get(Pt(this,ie)).has(e);else return false};const mo=new class{generateRandomUuid(){if("randomUUID"in window.crypto)return window.crypto.randomUUID();const e=window.URL.createObjectURL(new Blob([])),t=e.slice(-36);return window.URL.revokeObjectURL(e),t}};me=new WeakMap;class wo{constructor(e){this.resourceId=e}toJSON(){return{...this}}processBeforeExecution(){return Promise.resolve()}}class vo extends wo{constructor(e,t,r){super(e),this.type=Gn.Api,this.data=t,this.issuer=r}isSame(e){return e.issuer.id===this.issuer.id&&this.type===e.type}}class fo extends wo{constructor(e,t,r){super(e),this.type=Gn.Db,this.data=t,this.issuer=r}isSame(e){return e.issuer.id===this.issuer.id&&this.type===e.type}}class yo extends vo{processBeforeExecution(){const e=JSON.parse(this.data.body);return e.transitions[e.transitions.length-1].leave.occurred_at=(new Date).toISOString(),this.data.body=JSON.stringify(e),Promise.resolve()}}class bo extends fo{processBeforeExecution(){if("put"===this.data.operationType){const e=structuredClone(this.data.data);e.node_entered_at=(new Date).toISOString(),this.data.data=e}return Promise.resolve()}}class So{static create(e){const{type:t}=e;switch(t){case Gn.Api:return new vo(e.resourceId,e.data,e.issuer);case Gn.Db:return new fo(e.resourceId,e.data,e.issuer);case Gn.AutomationJourneyReactWebPushApi:return new yo(e.resourceId,e.data,e.issuer);case Gn.AutomationJourneyReactWebPushDb:return new bo(e.resourceId,e.data,e.issuer);default:Hi(t)}}}we=new WeakSet,ve=async function(e,t){return(await fs.openServiceWorkerCallbacksDatabaseConnection(Ct(this,fe,ye))).transaction(e,t)},fe=new WeakSet,ye=(e,t,r)=>{!(e=>{if(!e.objectStoreNames.contains(Xn.Callbacks))e.createObjectStore(Xn.Callbacks)})(r)};const Po=new class{constructor(){It(this,we),It(this,fe)}async addCallback(e){const t=await Ct(this,we,ve).call(this,Xn.Callbacks,"readwrite"),r=t.objectStore(Xn.Callbacks),i=await r.get(e.resourceId);if(!(i||[]).find((t=>e.isSame(t))))await r.put([...i||[],e.toJSON()],e.resourceId);await t.done}async getCallbacks({resourceId:e}){const t=await Ct(this,we,ve).call(this,Xn.Callbacks,"readonly"),r=t.objectStore(Xn.Callbacks),i=await r.get(e);if(await t.done,i)return i.map((e=>So.create(e)))}async deleteCallbacks({resourceId:e}){const t=await Ct(this,we,ve).call(this,Xn.Callbacks,"readwrite"),r=t.objectStore(Xn.Callbacks);await r.delete(e),await t.done}};be=new WeakSet,Se=()=>({visitorUuid:Ft(Dr.visitorUuid),grid:Ir.getClientLatestGrid()}),Pe=new WeakSet,Ie=(e,t)=>`/c/${jt(e)}/v/${jt(t)}/state/`;const Io=new class{constructor(){It(this,be),It(this,Pe)}getVisitorJourneys({visitorUuid:e,grid:t}=Ct(this,be,Se).call(this)){return Cr(new URL(Ct(this,Pe,Ie).call(this,t,e),Ir.visitorApplicationEndpoint).href)}sendVisitorTransitions(e,{visitorUuid:t,grid:r}=Ct(this,be,Se).call(this)){return Cr(this.getVisitorApplicationEndpoint(r,t),{omitAidHeader:true,headers:{"Content-Type":"application/json"},body:JSON.stringify(e),method:"PUT"})}getVisitorApplicationEndpoint(e,t){return new URL(Ct(this,Pe,Ie).call(this,e,t),Ir.visitorApplicationEndpoint).href}};var Eo=(e=>(e["PushNotificationDisplayed"]="pushNotificationDisplayed",e["ReceiptOfPushNotificationDisplayedConfirmation"]="receiptOfPushNotificationDisplayedConfirmation",e))(Eo||{});Ee=new WeakSet,Ce=e=>window.navigator.serviceWorker.ready.then((t=>t.active.postMessage(e)));const Co=new class{constructor(){It(this,Ee)}waitForWebPushReceptionConfirmation(e){return new Promise((t=>{window.navigator.serviceWorker.addEventListener("message",(r=>{if(r.origin===window.location.origin&&!!(i=r).data&&"object"==typeof i.data&&"type"in i.data&&i.data.type===Eo.PushNotificationDisplayed){const{messageId:i}=r.data.data;if(i===e)Ct(this,Ee,Ce).call(this,{type:Eo.ReceiptOfPushNotificationDisplayedConfirmation,data:{messageId:e}}).catch((e=>{Ot.error("Failed to send message to service worker about confirmation of push reception",e)})),t()}var i}))}))}async saveCallbackForServiceWorker({apiCallbackData:e,dbCallbackData:t,senderId:r,messageId:i}){const n=So.create({type:Gn.AutomationJourneyReactWebPushDb,resourceId:i,issuer:{id:r},data:{dbName:zn.VisitorJourneys,operationType:t.operationType,key:[t.data.journey.uuid,Ft(Dr.visitorUuid)],objectStore:Zn.VisitorJourneys,data:t.data.toJSON()}}),s=So.create({type:Gn.AutomationJourneyReactWebPushApi,resourceId:i,issuer:{id:r},data:{body:JSON.stringify(e.toJSON()),headers:{"Content-Type":"application/json"},method:"PUT",url:Io.getVisitorApplicationEndpoint(Ir.getClientLatestGrid(),Ft(Dr.visitorUuid))}});await Promise.all([Po.addCallback(n),Po.addCallback(s)])}};class Do extends Di{constructor(e){super(`Failed to send message: ${e}`)}}const ko=new class{constructor(){this.authToken=null}async getAuthToken(){const{pushWpid:e,pushDomain:t}=Ir;if(e)try{if(this.authToken)return this.authToken;const r=await fetch(`${t}webpush/auth`,{method:"POST",mode:"cors",headers:{"X-WpId":e,"Content-Type":"application/json"},body:JSON.stringify({url:window.location.origin,gau:Ft("gaVisitorUuid")})});return this.authToken=await r.text(),this.authToken}catch(r){Ot.error(r)}}};function To(e){this.message=e}(To.prototype=new Error).name="InvalidCharacterError";var Ao="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||(e=>{var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new To("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,i,n=0,s=0,o="";i=t.charAt(s++);~i&&(r=n%4?64*r+i:i,n++%4)?o+=String.fromCharCode(255&r>>(-2*n&6)):0)i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(i);return o});function Uo(e){this.message=e}function Vo(e,t){if("string"!=typeof e)throw new Uo("Invalid token specified");var r=true===(t=t||{}).header?0:1;try{return JSON.parse((e=>{var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return decodeURIComponent(Ao(t).replace(/(.)/g,((e,t)=>{var r=t.charCodeAt(0).toString(16).toUpperCase();return 2>r.length&&(r="0"+r),"%"+r})))}catch(r){return Ao(t)}})(e.split(".")[r]))}catch(i){throw new Uo("Invalid token specified: "+i.message)}}(Uo.prototype=new Error).name="InvalidTokenError";const No="gr_webpush_database",_o="gr_visitor_data",xo="sub_data",Wo=480;var Oo=(e=>(e["DISPLAYED_CUSTOMIZED"]="dic",e["ACCEPTED_CUSTOMIZED"]="acc",e["DENIED_CUSTOMIZED"]="dec",e["DISPLAYED_NATIVE"]="din",e["ACCEPTED_NATIVE"]="acn",e["DENIED_NATIVE"]="den",e))(Oo||{}),Fo=(e=>(e["V1"]="1.0.0",e["V1_1"]="1.1.0",e["V2"]="2.0.0",e))(Fo||{});function Lo(e,t,r=Ir.pushDomain,i=Ir.pushWpid){window.indexedDB.deleteDatabase(No),window.indexedDB.open(No,1).onupgradeneeded=n=>{n.target.result.createObjectStore(_o,{keyPath:"id"}).add({id:xo,uuid:e,pushSubscription:t.toJSON(),domain:r,wpid:i})}}const Ro=new class{sendConsentData(e,t,r){navigator.sendBeacon(new URL("wpn/consent-data",Ir.getUserAnalyticsDomain()),new Blob([JSON.stringify({uuid:t,aid:r,publicVpk:e})],{type:"application/json"}))}async renewSubscription(e,t){const{pushWpid:r,pushDomain:i}=Ir,n=await ko.getAuthToken();return fetch(`${i}webpush/renew`,{method:"POST",mode:"cors",headers:{"Content-Type":"application/json","X-WpId":r,Authorization:`Bearer ${n}`},body:JSON.stringify({oldSubscription:null==e?void 0:e.toJSON(),newSubscription:null==t?void 0:t.toJSON()})})}},jo=new class{async registerServiceWorker(){const e=Ir.getCustomSwPath();if(e)return navigator.serviceWorker.register(`${e}`);try{return await navigator.serviceWorker.register("/gr_sw_main.js")}catch(t){return navigator.serviceWorker.register("./gr_sw_main.js")}}getExistingServiceWorkerRegistration(){return navigator.serviceWorker.getRegistration()}};class Bo{get promptId(){var e;return null==(e=this.promptData)?void 0:e.id}get statisticsEndpoint(){var e;return Ir.pushDomain+(null==(e=this.promptData)?void 0:e.pst)}get hasMobile(){var e,t;return!!(null==(t=null==(e=this.promptData)?void 0:e.data)?void 0:t.mobile)}get hasDesktop(){var e,t;return!!(null==(t=null==(e=this.promptData)?void 0:e.data)?void 0:t.desktop)}get mobilePromptData(){var e,t;return null==(t=null==(e=this.promptData)?void 0:e.data)?void 0:t.mobile}get desktopPromptData(){var e,t;return null==(t=null==(e=this.promptData)?void 0:e.data)?void 0:t.desktop}}class Jo extends Bo{constructor(e){super(),this.promptData={id:e.pid,pst:e.pst,data:e.pc}}setActivePrompt(){throw new Error("Method not implemented in Prompt v1")}}function Mo(e){const t=new URL(document.location.href).host;return Ys(document.location.href,(Array.isArray(e)?e:[e]).map((e=>`${t}${e}`)))}var $o=(e=>(e["Includes"]="allowed",e["Excluded"]="excluded",e["Entire"]="entire",e))($o||{});class qo extends Bo{constructor(e){super(),this.globalPromptConfig=e;const t=e.paths.map((e=>{switch(e.type){case $o.Entire:return{...e,type:$o.Includes,path:"*"};case $o.Includes:case $o.Excluded:return{...e,path:e.path.startsWith("/")?`${e.path}*`:`*${e.path}*`};default:return e}})).find((e=>e.type===$o.Includes?Mo(e.path):!Mo(e.path)));if(e.nativePrompt&&e.nativePrompt.pid===(null==t?void 0:t.pid))return this.promptData={id:e.nativePrompt.pid,pst:e.nativePrompt.pst,data:null},void 0;const r=e.customPrompts.find((e=>e.pid===(null==t?void 0:t.pid)));if(r)this.promptData={id:r.pid,pst:r.pst,data:r.pc}}setActivePrompt(e){const t=this.globalPromptConfig.customPrompts.find((t=>t.pid===e));if(t)this.promptData={id:t.pid,pst:t.pst,data:t.pc}}}class Go{constructor(e){this.nativePromptPaths=[],this.version=e._v;const t=e,r=e;switch(this.version){case Fo.V1:case Fo.V1_1:this.prompt=new Jo(t),this.nativePromptPaths=t.paths;break;case Fo.V2:this.prompt=new qo(r);break;default:throw new Error("Unsupported version of prompt")}}get shouldShowNativePrompt(){var e,t,r;if(this.version===Fo.V2){if(!(null==(e=this.prompt)?void 0:e.hasDesktop)&&!(null==(t=this.prompt)?void 0:t.hasMobile)&&(null==(r=this.prompt)?void 0:r.promptId))return true}else if(Mo(this.nativePromptPaths))return true;return false}getVersion(){return this.version}}const zo=new class{async initialize(){await this.fetchSiteConfig(Ir.pushPromptEndpoint),this.promptConfig=new Go(globalThis._grpr)}get prompt(){return this.promptConfig.prompt}get promptData(){return this.promptConfig}fetchSiteConfig(e){return new Promise(((t,r)=>{const i=document.createElement("script");i.type="text/javascript",i.src=e,document.body.appendChild(i),i.onload=()=>{t()},i.onerror=r}))}setActivePrompt(e){try{this.promptConfig.prompt.setActivePrompt(e)}catch(t){Ot.error(t)}}},Ho=new class{sendStatsData(e){return fetch(`${zo.prompt.statisticsEndpoint}${e}`,{mode:"cors"})}},Ko=new class{setCookie({expiresIn:e,domain:t="",value:r,name:i}){const n=this.getExpirationTimeString(e);document.cookie=`${i}=${r}; expires=${n}; path=/; ${t?`domain=${t}`:""}`}getExpirationTimeString(e){if(e instanceof Date)return e.toUTCString();const t=new Date;return t.setTime(t.getTime()+e),t.toUTCString()}getCookie(e){const t=document.cookie.match(new RegExp(`(^| )${e}=([^;]+)`));if(t)return t[2]}removeUuidCookieSessionInfo(){window.sessionStorage.removeItem(Kt.UuidHasBeenSet)}};class Yo extends Di{constructor(e){if(super("User denied push notification consent"),e)this.cause=e}}const Zo=1e3*60*60*24*7,Xo=new class{async isSubscribed(){return null!==await this.checkIfUserIsSubscribed()}async isSubscribedFromPrompt(e){if(Boolean(await this.checkIfUserIsSubscribed()))return e===Ko.getCookie(Dr.NotificationConsentAcceptedFromPrompt);else return false}isPermissionPermanentlyDenied(){return"denied"===Notification.permission}isPermissionDeniedForCustomPrompt(e){const t=!!Ko.getCookie(Dr.NotificationConsentCustomPromptRejected.replace("promptId",e)),r=!!Ko.getCookie(Dr.NotificationConsentCustomPromptRejectedDEPRECATED.replace("promptId",e));return"default"===Notification.permission&&(t||r)}async registerUserForNotifications(){const e=zo.promptData.getVersion(),{pushWpid:t,pushDomain:r}=Ir,i=Ft(Dr.visitorUuid),n=await jo.registerServiceWorker();let s=await n.pushManager.getSubscription();if(!(null!==s))try{const n=await ko.getAuthToken(),o=Vo(n),a=o.subEndp;return s=await this.getUserNotificationsSubscription(),Lo(i,s,r,t),Ho.sendStatsData(Oo.ACCEPTED_NATIVE),await fetch(a,{method:"POST",mode:"cors",headers:{"Content-Type":"application/json","X-WpId":t,Authorization:`Bearer ${n}`},body:JSON.stringify({sub:s,prv:e})}).then((e=>{if(!e.ok)throw new Error(`Subscription failed ${e.status}`);return true})),Ro.sendConsentData(o.vpk,i,Ir.getUserAid()),Ko.setCookie({value:zo.promptData.prompt.promptId,name:Dr.NotificationConsentAcceptedFromPrompt,expiresIn:kr.OneYear,domain:Lt()}),Ko.removeUuidCookieSessionInfo(),this.markVisitorAsResubscribed(),s}catch(o){if(0===o.code)throw Ho.sendStatsData(Oo.DENIED_NATIVE),Ir.eventBus.publish(En.WebPushNativeConsentRejected),new Yo(o);throw o}}async resubscribeVisitor(){if(this.shouldResubscribeVisitor()){const e=await jo.getExistingServiceWorkerRegistration(),t=await(null==e?void 0:e.pushManager.getSubscription());if(t)await t.unsubscribe();await(async()=>{var e,t;if("serviceWorker"in navigator){const r=await navigator.serviceWorker.getRegistrations(),i=[];for(const n of r)if(!((null==(e=n.active)?void 0:e.scriptURL.endsWith("gr_sw_main.js"))||(null==(t=n.active)?void 0:t.scriptURL.endsWith("service-worker/service-worker.js"))))i.push(n.unregister());return Promise.all(i)}})();const r=await this.getUserNotificationsSubscription();if(t||r)await Ro.renewSubscription(t,r).then((e=>{if(!e.ok)throw new Error(`Subscription failed ${e.status}`);return true})),Ko.removeUuidCookieSessionInfo();if(r)this.markVisitorAsResubscribed(),Lo(Ft(Dr.visitorUuid),r);return r}}async getUserNotificationsSubscription(){const e=await jo.registerServiceWorker(),t=await e.pushManager.getSubscription();if(!(null!==t))try{const t=Vo(await ko.getAuthToken());if("default"===Notification.permission)Ho.sendStatsData(Oo.DISPLAYED_NATIVE);return e.pushManager.subscribe({userVisibleOnly:true,applicationServerKey:t.vpk})}catch(r){Ot.error(r)}return t}markVisitorAsResubscribed(){Ko.setCookie({name:Dr.VisitorResubscribed,value:"true",expiresIn:Zo})}shouldResubscribeVisitor(){return!Ko.getCookie(Dr.VisitorResubscribed)||!!window.sessionStorage.getItem(Kt.UuidHasBeenSet)}async checkIfUserIsSubscribed(){return(await jo.registerServiceWorker()).pushManager.getSubscription()}},Qo={".gr-visual-prompt":{all:"initial !important",position:"fixed !important",left:"50% !important",top:"0 !important","z-index":"999999999 !important",transform:"translateX(-50%) !important"}},ea={".gr-visual-prompt":{all:"initial !important",position:"fixed !important",left:"50% !important",bottom:"0 !important","z-index":"999999999 !important",transform:"translateX(-50%) !important"}};function ta(e,t){return(e.shadowRoot||e).querySelector(t)}De=new WeakMap,ke=new WeakMap,Te=new WeakMap,Ae=new WeakSet,Ue=e=>{Ko.setCookie({value:e,name:Dr.NotificationConsentCustomPromptRejected.replace("promptId",e),expiresIn:kr.TwoWeeks,domain:Lt()})};const ra=new class{constructor(){It(this,Ae),It(this,De,void 0),It(this,ke,void 0),It(this,Te,void 0),Et(this,De,new AbortController),Et(this,ke,new AbortController),Et(this,Te,null),this.onImageError=e=>{const t=e.target;t.parentNode.removeChild(t)},this.closeNotificationPrompt=e=>{const t=document.documentElement.querySelector('[data-gr-prompt="content"]'),r=ta(t,"img");if(null==r?void 0:r.removeEventListener("error",this.onImageError),!e){const e=Date.now()+(Pt(this,Te)??kr.OneYear);Ko.setCookie({name:Dr.NotificationConsentStatus,value:"rejected",expiresIn:e}),Ho.sendStatsData(Oo.DENIED_CUSTOMIZED)}document.body.removeChild(t)}}get shouldCustomPromptBeDisplayed(){const{prompt:e}=zo;return e&&((null==e?void 0:e.hasMobile)||(null==e?void 0:e.hasDesktop))}async displayCustomPrompt(e){if(e)Et(this,Te,e);if(this.shouldCustomPromptBeDisplayed){const{prompt:e}=zo;if(Xo.isPermissionDeniedForCustomPrompt(null==e?void 0:e.promptId))throw new Yo;const r=function(e,t){const r=document.createElement("div"),i=/iPhone|iPad|iPod|Android|webOS|BlackBerry|Windows Phone/i.test(navigator.userAgent)||screen.availWidth{const t=document.createElement("style"),r=(i="mobile"===e?ea:Qo,Object.keys(i).reduce(((e,t)=>{const r=i[t];if("object"==typeof r){const i=Object.keys(r).reduce(((e,t)=>e+=`${t}: ${r[t]};`),"");e.push(`${t} {${i}}`)}return e}),[]));var i;let n;document.head.appendChild(t),n=t.sheet,r.forEach((e=>{n.insertRule(e,n.rules.length)}))})(i?"mobile":"desktop"),r}(e.desktopPromptData,e.mobilePromptData),i=ta(r,'[data-gr-prompt-button="allow"]'),n=ta(r,'[data-gr-prompt-button="cancel"]');ta(r,"img").addEventListener("error",this.onImageError),i.style.cursor="pointer",n.style.cursor="pointer",t=r,void new MutationObserver(((e,r)=>{e.forEach((e=>{if(Array.from(e.addedNodes).includes(t))void Ho.sendStatsData(Oo.DISPLAYED_CUSTOMIZED),r.disconnect()}))})).observe(document.body,{childList:true}),document.body.appendChild(r);const s=await Promise.race([this.getUserSubscriptionFromCustomPromptConfirm(r),this.waitForUserDenyConsent(r)]);if(this.isPushSubscription(s))return s;throw new Yo}var t}getUserSubscriptionFromCustomPromptConfirm(e){return new Promise(((t,r)=>{const i=ta(e,'[data-gr-prompt-button="allow"]');if(i)i.addEventListener("click",(()=>{Ho.sendStatsData(Oo.ACCEPTED_CUSTOMIZED),Xo.registerUserForNotifications().then((e=>{const{promptId:r,hasDesktop:i,hasMobile:n}=zo.promptData.prompt;Ir.eventBus.publish(En.WebPushConsentAccepted,n||i?r:""),Pt(this,ke).abort(),t(e)})).catch((e=>{r(e)})),this.closeNotificationPrompt(true)}),{once:true,signal:Pt(this,De).signal})}))}waitForUserDenyConsent(e){return new Promise((t=>{const r=ta(e,'[data-gr-prompt-button="cancel"]');if(r)r.addEventListener("click",(()=>{const{promptId:e}=zo.promptData.prompt;this.closeNotificationPrompt(),Pt(this,De).abort(),Ct(this,Ae,Ue).call(this,e),Ir.eventBus.publish(En.WebPushCustomConsentRejected,e),t()}),{once:true,signal:Pt(this,ke).signal})}))}isPushSubscription(e){return e instanceof PushSubscription||!!e&&"object"==typeof e&&"endpoint"in e&&"expirationTime"in e}},ia=new class{async collectPushNotificationSubscription(e,t){if(await zo.initialize(),await Xo.isSubscribed())return Xo.isSubscribedFromPrompt(e);if(Xo.isPermissionPermanentlyDenied()||Xo.isPermissionDeniedForCustomPrompt(e))return false;if(zo.setActivePrompt(e),!ra.shouldCustomPromptBeDisplayed)throw new Error("No prompt data");try{return await ra.displayCustomPrompt(t),Xo.isSubscribedFromPrompt(e)}catch(r){if(r instanceof Yo)return false;throw Ot.error("Error while trying to send web push",r),r}}};class na{constructor(e){this.promptId=e}static create(e){return new na(e)}}class sa{constructor(e){this.promptId=e}static create(e){return new sa(e)}}Ve=new WeakSet,Ne=()=>new Promise((e=>{Ir.eventBus.subscribe(En.WebPushConsentAccepted,(t=>{e(sa.create(t))}))})),_e=new WeakSet,xe=()=>new Promise((e=>{Ir.eventBus.subscribe(En.WebPushNativeConsentRejected,(()=>{e(na.create())}))})),We=new WeakSet,Oe=()=>new Promise((e=>{Ir.eventBus.subscribe(En.WebPushCustomConsentRejected,(t=>{e(na.create(t))}))}));const oa=Object.freeze({[At]:true,[Ut]:true}),aa=Object.freeze({[At]:true}),ca=Object.freeze({[Vt]:true}),ua=Object.freeze({}),la={[kt.AwaitClick]:class extends zt{constructor(){super(...arguments),this.type=kt.AwaitClick,this.outs=pa.getNodeOutsInstance(kt.AwaitClick)}async handler(){const{selector:e}=this.properties;try{return await this.waitForElementClick(e),At}catch(t){if(t instanceof Tt)return Ut;Ot.error(t)}}waitForElementClick(e){return new Promise(((t,r)=>{const i=document.querySelector(e),n=()=>{t(),this.cleanLeaveFalseTimeout()};if(i)i.addEventListener("click",n,{once:true}),this.waitForDelayLeaveFalse().then((()=>{i.removeEventListener("click",n),r(new Tt)}));else r(new Nt(e))}))}},[kt.AwaitScroll]:class extends zt{constructor(){super(...arguments),this.type=kt.AwaitScroll,this.outs=pa.getNodeOutsInstance(kt.AwaitScroll)}async handler(){const{selector:e,percent:t}=this.properties;try{if(e)await this.watchForElementIntersectWithViewport(e);else if(t)await this.watchForPagePercentValueIntersectsWithViewport(t);return At}catch(r){if(r instanceof Tt)return Ut;Ot.error(r)}finally{this.cleanLeaveFalseTimeout()}}watchForElementIntersectWithViewport(e){return new Promise(((t,r)=>{const i=document.querySelector(e);if(i){const e=new IntersectionObserver(((e,r)=>{for(const n of e)if(n.isIntersecting&&n.target===i)t(),r.disconnect()}));e.observe(i),this.waitForDelayLeaveFalse().then((()=>{e.disconnect(),r(new Tt)}))}else r(new Nt(e))}))}async watchForPagePercentValueIntersectsWithViewport(e){return new Promise(((t,r)=>{const i=document.documentElement.scrollHeight*(e/Ht);function n(){if(document.documentElement.clientHeight+document.documentElement.scrollTop>i)t(),document.removeEventListener("scroll",n)}if(document.documentElement.clientHeight+document.documentElement.scrollTop>i)t();else document.addEventListener("scroll",n,true);this.waitForDelayLeaveFalse().then((()=>{document.removeEventListener("scroll",n),r(new Tt)}))}))}},[kt.AwaitExit]:class extends zt{constructor(){super(...arguments),It(this,E),It(this,D),It(this,T),It(this,U),It(this,N),this.outs=pa.getNodeOutsInstance(kt.AwaitExit),this.type=kt.AwaitExit}handler(){const e=new AbortController;return new Promise((t=>{(Pi.isDesktopDevice()?Ct(this,E,C).call(this,e):Ct(this,D,k).call(this,e)).then((()=>{t(At)})).catch((e=>{Ot.error("Error while exit intend handler",e)})),this.waitForDelayLeaveFalse().then((()=>{t(Ut),e.abort()}))}))}},[kt.AwaitInactivity]:class extends zt{constructor(){super(...arguments),this.abortController=new AbortController,this.handlersMap={click:null,scroll:null,keydown:null,mousemove:null},this.type=kt.AwaitInactivity,this.outs=pa.getNodeOutsInstance(kt.AwaitInactivity)}handler(){const{inactivityTime:e}=this.properties;return new Promise((t=>{this.waitForDelayLeaveFalse().then((()=>{t(Ut)})),this.waitForUserActivity(e).then((()=>{t(At),this.cleanLeaveFalseTimeout()}))}))}async waitForUserActivity(e){const t=window.setTimeout((()=>{this.abortController.abort()}),e);try{return await Promise.race([this.waitForUserAction("scroll"),this.waitForUserAction("click"),this.waitForUserAction("keydown"),this.waitForUserAction("mousemove")]),window.clearTimeout(t),this.detachActivityMonitorHandlers(),this.waitForUserActivity(e)}catch(r){if(r instanceof ki)return;window.clearTimeout(t),Ot.error(r)}}detachActivityMonitorHandlers(){const{click:e,keydown:t,scroll:r,mousemove:i}=this.handlersMap;document.removeEventListener("click",e),document.removeEventListener("scroll",r),document.removeEventListener("keydown",t),document.removeEventListener("mousemove",i),this.handlersMap={click:null,keydown:null,scroll:null,mousemove:null}}waitForUserAction(e){return new Promise(((t,r)=>{document.addEventListener(e,t,{once:true,capture:"scroll"===e}),this.handlersMap[e]=t,this.abortController.signal.addEventListener("abort",(()=>{r(new ki)}),{once:true})}))}},[kt.AwaitECommerceActivity]:class extends zt{constructor(e){super(e),It(this,se),It(this,ae),It(this,ue),It(this,de),It(this,he),It(this,ie,void 0),It(this,ne,void 0),Et(this,ie,(e=>{var t,r;const i=null==(t=Ir.automationJourneyGraphs.find((t=>t.nodes.find((t=>t.id===e)))))?void 0:t.id,n=Ir.popupGraphs.find((t=>t.nodes.find((t=>t.id===e)))),s=null==(r=null==n?void 0:n.nodes.find((e=>e.type===kt.ReactPopup)))?void 0:r.id;return i||s||null})(this.id)),Et(this,ne,[]),this.outs=pa.getNodeOutsInstance(kt.AwaitECommerceActivity),this.type=kt.AwaitECommerceActivity,this.properties.conditions=this.properties.conditions.map((e=>({...e,conditionId:"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))})))}async handler(){return new Promise((async e=>{const{conditions:t}=this.properties;if(0===t.length||await Ct(this,ue,le).call(this))e(At);else Ir.eventBus.subscribe(En.UserEventSaved,(t=>{if((e=>eo.includes(e.eventType))(t)&&!Ct(this,he,ge).call(this,t.eventId))if(Ct(this,se,oe).call(this,t))Ct(this,de,pe).call(this,t.eventId),e(At)}),{ignoreQueuedEvents:true})}))}},[kt.AwaitMergedNodes]:class extends zt{constructor(e){super(e),It(this,me,void 0),this.type=kt.AwaitMergedNodes,this.outs=pa.getNodeOutsInstance(kt.AwaitMergedNodes),Et(this,me,[]);const{nodesDefinition:t}=e.properties;Et(this,me,t.map((e=>pa.getNodeInstance(e.type,{id:mo.generateRandomUuid(),properties:e.properties,context:this.context}))))}async handler(e){const{separator:t="or"}=this.properties;if("or"===t){const t=await Promise.race(Pt(this,me).map((t=>t.handler(e))));if(t!==Ut)return t;else return this.handler()}else if("and"===t)if((await Promise.all(Pt(this,me).map((t=>t.handler(e))))).includes(Ut))return Ut;else return At;else Hi(t)}},[kt.AwaitWebPushConsent]:class extends zt{constructor(){super(...arguments),It(this,Ve),It(this,_e),It(this,We),this.type=kt.AwaitWebPushConsent,this.outs=pa.getNodeOutsInstance(kt.AwaitWebPushConsent)}async handler(){const{pid:e}=this.properties;if("Notification"in window){if("denied"===window.Notification.permission)return Ut;else if("granted"===window.Notification.permission)if(Ko.getCookie(Dr.NotificationConsentAcceptedFromPrompt)===e||"any"===e)return At;else return Ut;else if("default"===window.Notification.permission){const t=await Promise.race([Ct(this,Ve,Ne).call(this),Ct(this,We,Oe).call(this),Ct(this,_e,xe).call(this)]);if(t instanceof sa)if(t.promptId===e||"any"===e)return At;else return this.handler();else if(t instanceof na)if(t.promptId===e)return Ut;else return this.handler()}}else return Ut}},[kt.FilterSubscriber]:class extends Gt{constructor(){super(...arguments),this.type=kt.FilterSubscriber,this.outs=pa.getNodeOutsInstance(kt.FilterSubscriber)}async handler(){let e="1"===Ft("gaIsValuable");if(Ir.canUseBackendForSubscriberIdentification())try{e=(await Tr.getVisitorData()).isConfirmedIdentifiedVisitor}catch(t){Ot.error("Failed to load subscriber data",t)}return Promise.resolve(e?At:Ut)}},[kt.FilterDevice]:class extends Gt{constructor(){super(...arguments),this.type=kt.FilterDevice,this.outs=pa.getNodeOutsInstance(kt.FilterDevice)}handler(){const{deviceType:e}=this.properties,t=nr(Pi,Ui).getDeviceType();if(e.includes(t))return Promise.resolve(At);else return Promise.resolve(Ut)}},[kt.FilterLocation]:class extends Gt{constructor(){super(...arguments),this.type=kt.FilterLocation,this.outs=pa.getNodeOutsInstance(kt.FilterLocation)}handler(){return new Promise((async e=>{let{locations:t}=this.properties;if(null==t?void 0:t.length){if(t=(Array.isArray(t)?t:[t]).map((e=>e.toLowerCase())),t.includes(Or.All))return e(At),void 0;try{const r=(await nr(_i,Oi).getVisitorCountryCode()).toLowerCase();if(t.includes(r))e(At);else e(Ut)}catch(r){if(r.status===Fi)e(Ut);Ot.error(r)}}else e(At)}))}},[kt.FilterUrl]:class extends Gt{constructor(){super(...arguments),this.type=kt.FilterUrl,this.outs=pa.getNodeOutsInstance(kt.FilterUrl)}handler(){if("urls"in(e=this.properties)&&Array.isArray(e.urls)&&e.urls.every((e=>"string"==typeof e))){const{urls:e}=this.properties;if(Ys(document.location.href,e))return Promise.resolve(At);else return Promise.resolve(Ut)}else if(Xs.create({...this.properties,currentUrl:window.location.href}).isOnCurrentUrl())return Promise.resolve(At);else return Promise.resolve(Ut);var e}},[kt.FilterTime]:class extends Gt{constructor(){super(...arguments),this.type=kt.FilterTime,this.outs=pa.getNodeOutsInstance(kt.FilterVisit)}handler(){const{beforeTime:e,afterTime:t}=this.properties,r=Date.now();let i=true,n=true;if(null===e&&null===t)return Promise.resolve(At);if(this.validateProperties(),e)i=e>r;if(t)n=r>t;if(i&&n)return Promise.resolve(At);else return Promise.resolve(Ut)}validateProperties(){const{afterTime:e,beforeTime:t}=this.properties,r="number"==typeof e,i="number"==typeof t;if(e&&!r||t&&!i||(r&&i?e>=t:false))throw new Li}},[kt.FilterECommerceActivity]:class extends Gt{constructor(){super(...arguments),It(this,te),It(this,Z,void 0),It(this,X,void 0),It(this,Q,void 0),It(this,ee,void 0),this.type=kt.FilterECommerceActivity,this.outs=pa.getNodeOutsInstance(kt.FilterECommerceActivity),Et(this,Z,(e=>{if(io(e)||oo(e,Xt.UnlikeItem)){const{product:t,date:r}=this.properties.likeItem,{product:{id:i}}=e.data;if(t===Jr.AnyProductLiked)return true;else if(!t.includes(i))return false;return lo(e,r,{ignoreToDateInDateRange:true})}})),Et(this,X,(e=>{if(no(e))return uo(this.properties.orderPlaced,e)})),Et(this,Q,(e=>{if(so(e))return uo(this.properties.cartUpdated,e)})),Et(this,ee,(e=>{const{conditions:t}=this.properties,r=t[$r.Product],i=t[$r.Category],{date:n}=t;if(ro(e)){const{data:{product:{id:t}}}=e;if(r===Jr.AnyProduct)return true;else if(!(null==r?void 0:r.includes(t)))return false;return lo(e,n)}if(to(e)){const{data:{id:t}}=e;if(i===Jr.AnyCategory)return true;else if(!(null==i?void 0:i.includes(t)))return false;return lo(e,n)}return false}))}async handler(){var e,t,r;const i=0===Object.keys(this.properties).length;let n=i,s=i,o=i,a=i;if(this.properties.conditions){const{amount:e}=this.properties.conditions,t=await Ss.getPopupECommerceEvents(Pt(this,ee));n=Ct(this,te,re).call(this,t,e)}if((null==(e=this.properties.likeItem)?void 0:e.product.length)>0){const e=(await Ss.getPopupECommerceEvents(Pt(this,Z))).reduce(((e,t)=>(e[t.data.product.id].push(t),e)),Rt([]));let t=Object.values(e).filter(Qs);if(this.properties.likeItem.date)t=t.map((e=>e.filter((e=>lo(e,this.properties.likeItem.date)))));s=t.some((e=>e.some((e=>e.eventType===Xt.LikeItem))))}if(Object.keys((null==(t=this.properties.orderPlaced)?void 0:t.condition)||{}).length>0)o=(await Ss.getPopupECommerceEvents(Pt(this,X))).length>0;if(Object.keys((null==(r=this.properties.cartUpdated)?void 0:r.condition)||{}).length>0){const[e,t]=await Promise.all([Ss.getPopupECommerceEvents(Pt(this,Q)),Ss.getPopupECommerceEvents((()=>true))]);a=e.filter((e=>!t.find((t=>t.data.cartId===e.data.cartId&&t.time>e.time)))).length>0}return n||s||o||a?At:Ut}},[kt.FilterUniqueSessionVisit]:class extends Gt{constructor(){super(...arguments),this.outs=pa.getNodeOutsInstance(kt.FilterUniqueSessionVisit),this.type=kt.FilterUniqueSessionVisit}handler(){return Promise.resolve(po.hasElementBeenVisited(this.id)?Ut:At)}},[kt.FilterVisit]:class extends Gt{constructor(){super(...arguments),this.type=kt.FilterVisit,this.outs=pa.getNodeOutsInstance(kt.FilterVisit)}async handler(){const{frequency:e,frequencyDaysNumber:t,urlPath:r,visitors:i}=this.properties,n=nr(Jn,qn);if(!n.validateUrlPath(r))return Ut;const[s,o]=await Promise.all([n.validateFrequencyProperty(e,t),n.validateVisitorsProperty(i)]);if(s&&o)return At;else return Ut}},[kt.FilterPopup]:class extends Gt{constructor(){super(...arguments),this.type=kt.FilterPopup,this.outs=pa.getNodeOutsInstance(kt.FilterPopup)}async handler(){const{popupId:e,showIfNotCloseBefore:t,showIfNotSubmittedBefore:r,showIfSeenLessThanAmount:i}=this.properties;if(!(await this.shouldPassFrequencyConditionCheck()))return Ut;if(t&&await Js().hasPopupBeenClosedBefore(e))return Ut;if(r&&await Js().hasPopupBeenSubmittedBefore(e))return Ut;if(i&&await Js().getPopupImpressionsAmount(e)>=i)return Ut;else return At}async shouldPassFrequencyConditionCheck(){const{showEveryDays:e,frequency:t,popupId:r}=this.properties;if("session"===t)return!(await Js().hasPopupBeenSeenInSession(r));if("everyDays"===t&&e){const t=await Js().getLastPopupImpression(r);if(t)return Vr(t.getTime(),e);else return true}return true}},[kt.ReactScroll]:class extends Gt{constructor(){super(...arguments),this.type=kt.ReactScroll,this.outs=pa.getNodeOutsInstance(kt.ReactScroll)}handler(){if(this.shouldProcessHandler()){const{selector:e}=this.properties,t=document.querySelector(e);if(t)return t.scrollIntoView({behavior:"smooth"}),Promise.resolve(At)}}},[kt.ReactRedirect]:class extends Gt{constructor(){super(...arguments),this.type=kt.ReactRedirect,this.outs=pa.getNodeOutsInstance(kt.ReactRedirect)}handler(){if(this.shouldProcessHandler()){const{url:e}=this.properties;return window.location.assign(e),Promise.resolve(void 0)}}},[kt.ReactDelay]:class extends Gt{constructor(){super(...arguments),this.type=kt.ReactDelay,this.outs=pa.getNodeOutsInstance(kt.ReactDelay)}async handler(){const{delay:e}=this.properties;return await(t=e,new Promise((e=>{setTimeout(e,t)}))),At;var t}},[kt.ReactPopup]:class extends Gt{constructor(){super(...arguments),this.type=kt.ReactPopup,this.outs=pa.getNodeOutsInstance(kt.ReactPopup)}async handler(){var e;const{env:t,id:r,mode:i}=this.properties;if(await $s.attachPopupLibrary(),i===ur.Inline)return null==(e=window.PopupsRenderer)?void 0:e.registerCustomElements(),At;if(window.PopupsRenderer)if(this.shouldProcessHandler()){this.attachPopupEvents();try{await window.PopupsRenderer.renderPopupFromId(r,{env:window.PopupsRenderer.GeoEnvironment[t]})}catch(n){Ot.error(n)}return At}}attachPopupEvents(){window.PopupsRenderer.registerEventSubscriber((e=>{if(e instanceof window.PopupsRenderer.PopupEvents.Close)this.closePopupHandler();if(e instanceof window.PopupsRenderer.PopupEvents.BodyView)this.showPopupHandler();if(e instanceof window.PopupsRenderer.PopupEvents.FormLead)this.submitPopupHandler()}))}closePopupHandler(){Js().registerPopupClose(this.properties.id)}showPopupHandler(){Js().registerPopupView(this.properties.id)}submitPopupHandler(){Js().registerPopupSubmit(this.properties.id)}},[kt.ReactSendToBackend]:class extends Gt{constructor(){super(...arguments),this.type=kt.ReactSendToBackend,this.outs=pa.getNodeOutsInstance(kt.ReactSendToBackend)}async handler(){if(this.shouldProcessHandler())return Promise.resolve(Vt)}},[kt.ReactSendWebPush]:class extends Gt{constructor(){super(...arguments),this.type=kt.ReactSendWebPush,this.outs=pa.getNodeOutsInstance(kt.ReactSendWebPush)}async handler(e){const{messageId:t}=this.properties,{journeyVo:r,type:i}=this.context.calculateJourneyStateForNextNode(e.journey.uuid,this,At);if(Xo.isPermissionPermanentlyDenied())return Ut;try{return Co.saveCallbackForServiceWorker({senderId:`${this.id}-${e.journey.uuid}`,apiCallbackData:this.context.calculateTransitionsForNextNodeFromNode(e.journey.uuid,this,At),dbCallbackData:{operationType:i,data:r},messageId:t}).catch((e=>{Ot.error("Error while saving callback data for sw",e)})),await Co.waitForWebPushReceptionConfirmation(t),At}catch(n){if(n instanceof Do)return Ut;throw n}}},[kt.ReactCollectWebPushConsent]:class extends Gt{constructor(){super(...arguments),this.type=kt.ReactCollectWebPushConsent,this.outs=pa.getNodeOutsInstance(kt.ReactCollectWebPushConsent)}async handler(){const{customPromptRejectionDuration:e=kr.OneYear,pid:t}=this.properties;return await ia.collectPushNotificationSubscription(t,e)?At:Ut}}},da={[kt.AwaitClick]:oa,[kt.AwaitScroll]:oa,[kt.AwaitExit]:oa,[kt.AwaitInactivity]:oa,[kt.AwaitECommerceActivity]:oa,[kt.AwaitMergedNodes]:oa,[kt.AwaitWebPushConsent]:oa,[kt.FilterUrl]:oa,[kt.FilterSubscriber]:oa,[kt.FilterDevice]:oa,[kt.FilterLocation]:oa,[kt.FilterECommerceActivity]:oa,[kt.FilterUniqueSessionVisit]:oa,[kt.FilterTime]:oa,[kt.FilterVisit]:oa,[kt.FilterPopup]:oa,[kt.ReactDelay]:aa,[kt.ReactScroll]:aa,[kt.ReactRedirect]:ua,[kt.ReactPopup]:aa,[kt.ReactSendToBackend]:ca,[kt.ReactSendWebPush]:oa,[kt.ReactCollectWebPushConsent]:oa};class pa{static getNodeInstance(e,t){return new la[e](t)}static getNodeOutsInstance(e){return da[e]}}function ha(e){return"object"==typeof e&&null!==e&&"id"in e&&"status"in e&&"starting"in e}function ga(e){var t;switch(e){case hr.TransferToBackend:return"backend_transfer";case hr.ReactSendWebPush:return"react_web_push";default:return null==(t=/(?filter|react|await)_.*/g.exec(e))?void 0:t.groups.type}}function ma(e){switch(e.type){case hr.TransferToBackend:return e.data;case hr.ReactSendWebPush:return{message_encoded_id:e.data.nid};default:return{upstream:e.upstream||null}}}const wa=class e{constructor(e){this.node={},Object.assign(this,e)}static create(t){var r;if(!Ct(r=e,Fe,Le).call(r,t))throw new Error("Automation journey data does not match required schema");return new e(t)}static createBlank(t){var r;if(!Ct(r=e,Re,je).call(r,t))throw new Error("Automation journey data does not match required schema");return new e(t)}updateJourneyData({node_entered_at:e,node:t,upstreamed_to:r}){this.node.uuid=t.uuid,this.upstreamed_to=r,this.node_entered_at=e}toJSON(){return structuredClone({...this})}};Fe=new WeakSet,Le=e=>rn.create({journey:rn.object({uuid:rn.string()}),visitor:rn.object({uuid:rn.string()}),node:rn.object({uuid:rn.string()}),node_entered_at:rn.dateString(),upstreamed_to:rn.dateString().optional()}).validate(e),Re=new WeakSet,je=e=>rn.create({journey:rn.object({uuid:rn.string()}),visitor:rn.object({uuid:rn.string()})}).validate(e),It(wa,Fe),It(wa,Re);let va=wa;function fa(e,t,r){(e=>{if(!e.objectStoreNames.contains(Zn.VisitorJourneys))try{const t=e.createObjectStore(Zn.VisitorJourneys,{keyPath:["journey.uuid","visitor.uuid"],autoIncrement:false}),r=e.createObjectStore(Zn.VisitorJourneysGraphHistory,{keyPath:["node.uuid","visitor.uuid"],autoIncrement:false});t.createIndex(Qn.VisitorUuid,"visitor.uuid",{unique:false}),t.createIndex(Qn.JourneyIdentifier,"journey.uuid",{unique:false}),t.createIndex(Qn.VisitorUuidWithJourneyIdentifier,["visitor.uuid","journey.uuid"],{unique:false}),r.createIndex(es.VisitorUuid,"visitor.uuid",{unique:false}),r.createIndex(es.NodeUuid,"node.uuid",{unique:false}),r.createIndex(es.VisitorUuidWithNodeUuid,["visitor.uuid","node.uuid"],{unique:true})}catch(t){Ot.error("Error while initializing/upgrading visitor journeys database",t)}})(r),(e=>{if(!e.objectStoreNames.contains(Zn.GraphJourneyFetchedData))try{e.createObjectStore(Zn.GraphJourneyFetchedData,{keyPath:["graph.id","journey.id","node.id"],autoIncrement:false}).createIndex(ts.GraphId,"graph.id",{unique:false})}catch(t){Ot.error("Error while initializing graph journey active node since date store",t)}})(r)}function ya(e,t){return[e,t]}const ba=new class{async getVisitorJourneys(e){const t=(await fs.openAutomationJourneysDatabaseConnection(fa)).transaction(Zn.VisitorJourneys,"readonly"),r=t.objectStore(Zn.VisitorJourneys).index(Qn.VisitorUuid),i=await r.getAll(e);return await t.done,i}async saveVisitorJourney(e){const{journey:t,visitor:r}=e,i=(await fs.openAutomationJourneysDatabaseConnection(fa)).transaction(Zn.VisitorJourneys,"readwrite"),n=i.objectStore(Zn.VisitorJourneys);await n.delete([t.uuid,r.uuid]),await n.add(e.toJSON()),await i.done}async clearVisitorJourney(e){const{journey:t,visitor:r}=e,i=(await fs.openAutomationJourneysDatabaseConnection(fa)).transaction(Zn.VisitorJourneys,"readwrite"),n=i.objectStore(Zn.VisitorJourneys);await n.delete([t.uuid,r.uuid]),await i.done}async getNodeEntryHistory(e,t){const r=(await fs.openAutomationJourneysDatabaseConnection(fa)).transaction(Zn.VisitorJourneysGraphHistory,"readonly"),i=r.objectStore(Zn.VisitorJourneysGraphHistory),n=await i.getAll(ya(e,t));return await r.done,n}async saveNodeHistoryEntry(e,t,r){const i=(await fs.openAutomationJourneysDatabaseConnection(fa)).transaction(Zn.VisitorJourneysGraphHistory,"readwrite"),n=i.objectStore(Zn.VisitorJourneysGraphHistory);await n.delete(ya(e,t)),await n.add({node:{uuid:e},visitor:{uuid:t},entered_at:r}),await i.done}};Be=new WeakMap;let Sa=class e{constructor({journey:e,transitions:t,workflowEncodedId:r,graphEncodedId:i}){It(this,Be,(new Date).toISOString()),this.journey=e,this.transitions=t,this.graph={encodedId:i},this.workflow={encodedId:r}}static create(t){return new e(t)}toJSON(){return{...this}}};Je=new WeakMap,Me=new WeakMap,$e=new WeakMap,qe=new WeakMap,Ge=new WeakSet,ze=function(e){const t=e.filter((e=>{var t;return e.from.externalId!==(null==(t=e.to)?void 0:t.externalId)})).map(Pt(this,He)).filter(Boolean),{wId:r,id:i}=Pt(this,Je);return Sa.create({workflowEncodedId:r,graphEncodedId:i,journey:Pt(this,Me).journey,transitions:t})},He=new WeakMap,Ke=new WeakSet,Ye=function(e){var t,r,i,n,s;const o=Pt(this,He).call(this,e),a=(null==(t=e.to)?void 0:t.nodeTypeGroup)===Dt.Await,c=null==(i=null==(r=o.entered)?void 0:r.element)?void 0:i.starting,u=(null==(n=e.to)?void 0:n.nodeTypeGroup)===Dt.BackendTransfer,l=(null==(s=e.to)?void 0:s.type)===kt.ReactSendWebPush;if(u||l)return true;if(a&&!c)return true;if(!o.entered&&!o.leave.element.starting)return true;else return false};let Pa=class e{constructor(e,t){It(this,Ge),It(this,Ke),It(this,Je,void 0),It(this,Me,void 0),It(this,$e,[]),It(this,qe,(e=>{const t=Ct(this,Ge,ze).call(this,e);return Io.sendVisitorTransitions(t.toJSON())})),It(this,He,(e=>{var t,r,i;const{fromPathKey:n,from:s,to:o,transitionTime:a,reason:c}=e,u={reason:c},l=Pt(this,Je).originalGraph.nodes.find((e=>e.id===s.externalId)),d=o?Pt(this,Je).originalGraph.nodes.find((e=>e.id===o.externalId)):null,p=Pt(this,Je).originalGraph.transitions.find((e=>e.from===l.id&&e.to===(null==d?void 0:d.id)));let h;if(Pt(this,Je).outsMap[s.externalId])h=Pt(this,Je).outsMap[s.externalId][n];const g=(null==p?void 0:p.key)??h??n;if(u.leave={node:{id:l.id},path:g,occurred_at:a,element:l.element,stats:{...(null==(r=null==(t=l.stats)?void 0:t.transitions)?void 0:r[g])?{[g]:l.stats.transitions[g]}:{}}},d)if(u.entered={node:{id:d.id,type:ga(d.type),data:ma(d)},occurred_at:a,element:d.element},d.type!==hr.TransferToBackend)u.entered.stats=(null==(i=d.stats)?void 0:i.enters)?{input:d.stats.enters.input}:{};return u})),Et(this,Je,e),Et(this,Me,t)}static create(t,r){return new e(t,r)}async addTransition(e){if(Pt(this,$e).push(e),Ct(this,Ke,Ye).call(this,e)){const e=[...Pt(this,$e)];Et(this,$e,[]),await Nr((()=>Pt(this,qe).call(this,e)),{multiplyDelay:true,maxAttempts:10})}}getCurrentVisitorTransitionsVoCopyWithTransitions(e){const t=[...Pt(this,$e),...e||[]];return Ct(this,Ge,ze).call(this,t)}};const Ia=1e3;Ze=new WeakMap,Xe=new WeakSet,Qe=function(e){Pt(this,Ze).set(e,Date.now())};const Ea=new class{constructor(){It(this,Xe),It(this,Ze,new Map)}isNodeUsedInLoop(e,t){const r=`${e.id}-${t}`,i=Pt(this,Ze).get(r);if(!i||Date.now()-i>Ia)return Ct(this,Xe,Qe).call(this,r),false;else return Ot.log(`JourneyLoopPrevention: Node overused. Journey will be stopped and removed because it violates fair usage policy. Node data:`,e),true}};class Ca{constructor({webflowSerializedData:e,visitorJourneys:t,isJourneyGraph:r}){It(this,et,void 0),It(this,tt,void 0),It(this,rt,void 0),It(this,it,Ft(Dr.visitorUuid)),It(this,nt,new Map),Et(this,et,this.createWebFlowFromSerializedData(e)),Et(this,tt,t),Et(this,rt,r)}initVisitorFlow(){this.findStartingElements().forEach((({node:e,journey:t})=>{const r=mo.generateRandomUuid();let i;if(ha(Pt(this,et))){if(t)i=va.create(t);else i=va.createBlank({journey:{uuid:r},visitor:{uuid:Pt(this,it)}});Pt(this,nt).set(i.journey.uuid,Pa.create(Pt(this,et),i))}this.shouldProcessFlow(e,i).then((t=>{if(t)this.processFlow(e,i)}))}))}calculateTransitionsForNextNodeFromNode(e,t,r){const i=this.calculateNextTransitionForNode(t,r);return Pt(this,nt).get(e).getCurrentVisitorTransitionsVoCopyWithTransitions([{...i}])}calculateJourneyStateForNextNode(e,t,r){var i,n;const s=this.calculateNextTransitionForNode(t,r),o=null==(i=s.to)?void 0:i.id;return{journeyVo:va.create({journey:{uuid:e},node:{uuid:(null==(n=s.to)?void 0:n.id)||t.id},visitor:{uuid:Pt(this,it)},node_entered_at:(new Date).toISOString()}),type:o?"put":"delete"}}calculateNextTransitionForNode(e,t){return{from:e,to:this.getNodeConnectedToNodes(e)[t],fromPathKey:t,transitionTime:null}}async processFlow(e,t){try{const r=(new Date).toISOString();if(t)t.updateJourneyData({node:{uuid:e.id},node_entered_at:r});if(Pt(this,rt))await ba.saveVisitorJourney(t);this.processNode(e,t).then((async i=>{if(po.addEntry(e.id),Pt(this,rt))await ba.saveNodeHistoryEntry(e.id,Pt(this,it),r);if(i&&await this.shouldProcessFlow(i,t))this.processFlow(i,t);else if(!i&&Pt(this,rt)&&e.type!==kt.ReactSendToBackend)await ba.clearVisitorJourney(t)})).catch((e=>{Ot.error(e)}))}catch(r){Ot.error(r)}}async processNode(e,t){const r=this.getNodeConnectedToNodes(e);Ot.log(`Processing node ${e.type} with id: ${e.id}`,e),e.startUpstreamCalculation();const i=await Promise.race([e.waitForUpstreamPassed(),e.handler(t)]);let n;if(i===Symbol.for("upstreamPassed"))n=Ut;else n=i,e.cancelUpstreamToResolveWait();const s=r[n];if(Pt(this,rt))if(e.type!==kt.ReactSendToBackend){const r=s?Ea.isNodeUsedInLoop(s,t.journey.uuid):false;if(await Pt(this,nt).get(t.journey.uuid).addTransition({from:e,to:r?void 0:s,fromPathKey:r?"exit":n,transitionTime:(new Date).toISOString(),reason:r?"loop":void 0}),r)return}return Ot.log(`Finished processing node ${e.type} with id: ${e.id} with result ${n}`),s}getNodeConnectedToNodes(e){return Pt(this,et).connections.filter((t=>t.from===e.id)).reduce(((e,t)=>(e[t.fromPathKey]=Pt(this,et).nodes.find((e=>e.id===t.to)),e)),{})}findStartingElements(){var e;if(ha(Pt(this,et))){const{starting:t,nodes:r,startAt:i,stopAt:n}=Pt(this,et),s=null==(e=Pt(this,tt))?void 0:e.length;if(!(({startAt:e,stopAt:t})=>{const r=Date.parse(e),i=Date.parse(t),n=Date.now();if(!Number.isNaN(r)&&r>n)return false;if(!Number.isNaN(i)&&n>i)return false;else return true})({startAt:i,stopAt:n}))return[];if(s)return Pt(this,tt).map((e=>({node:r.find((t=>t.id===e.node.uuid)),journey:e}))).filter((e=>e.node.type!==kt.ReactSendToBackend));if(t.length)return r.filter((e=>t.includes(e.externalId))).map((e=>({node:e})));else return[]}const{nodes:t,connections:r}=Pt(this,et);return t.filter((e=>!r.some((t=>t.to===e.id)))).map((e=>({node:e})))}createWebFlowFromSerializedData(e){return{...e,nodes:e.nodes.map((e=>pa.getNodeInstance(e.type,{...e,context:this})))}}async shouldProcessFlow(e,t){var r,i;if(Pt(this,rt)){if(e.isRecurrent)return true;if((null==(r=null==t?void 0:t.node)?void 0:r.uuid)===e.id&&!po.hasElementBeenVisited(e.id))return true;if(null==(i=await ba.getNodeEntryHistory(e.id,Pt(this,it)))?void 0:i.length)return Ot.log(`Element ${e.id} already visited`),false}return true}}et=new WeakMap,tt=new WeakMap,rt=new WeakMap,it=new WeakMap,nt=new WeakMap;class Da{constructor(e,t){this.webEventFlowData=e,e.forEach((e=>{const r=ha(e);if(r)Ir.automationJourneyGraphs.push(e);else if(!!(i=e)&&"object"==typeof i&&2===Object.keys(i).length&&"nodes"in i&&Array.isArray(i.nodes)&&i.nodes.some((e=>e.type===kt.ReactPopup)))Ir.popupGraphs.push(e);var i;const n=r?t.get(e.id):null,s=new Ca({webflowSerializedData:e,visitorJourneys:n,isJourneyGraph:r});Ot.log("New web event workflow initialized with data",e),Ot.log("With journey data:",n),s.initVisitorFlow()}))}}const ka=new class{isScriptDelayed(e){return Object.keys(Ir.delayedScripts).includes(e)}delay(e){if(!this.isScriptDelayed(e))Ir.delayedScripts={...Ir.delayedScripts,[e]:void 0}}storeDelayedScriptParams(e,t){if(this.isScriptDelayed(e))Ir.delayedScripts={...Ir.delayedScripts,[e]:t}}initScript(e){var t;const r=Ir.delayedScripts[e];if(r){Ir.delayedScripts=Object.fromEntries(Object.entries(Ir.delayedScripts).filter((([t])=>t!==e)));const i=br[e];null==(t=null==window?void 0:window[i])?void 0:t.init(...r)}}};st=new WeakSet,ot=async e=>(await fs.openAutomationJourneysDatabaseConnection(fa)).transaction(Zn.GraphJourneyFetchedData,e);const Ta=new class{constructor(){It(this,st)}async getGraphActiveNodesData(e){const t=await Ct(this,st,ot).call(this,"readonly"),r=t.objectStore(Zn.GraphJourneyFetchedData).index(ts.GraphId),i=await r.getAll(e);return await t.done,i}async saveGraphJourneyActiveNodeData(e,t){const{journey:r,node:i}=t,n=(await Ct(this,st,ot).call(this,"readwrite")).objectStore(Zn.GraphJourneyFetchedData),s=e.nodes.find((e=>e.id===i.uuid)),o=e.originalGraph.nodes.find((e=>e.id===(null==s?void 0:s.externalId)));if(o)await n.put({graph:{id:e.id},journey:{id:r.uuid},node:{id:i.uuid,since:o.since}})}},Aa=30;at=new WeakSet,ct=(e,t)=>t.map((t=>{const r=e.nodes.find((e=>e.externalId===t.node.uuid));if(r)return{...t,node:{uuid:r.id}}})).filter(Boolean),ut=new WeakSet,lt=(e,t)=>e.reduce(((e,r)=>{const i=t.filter((e=>r.nodes.some((t=>t.id===e.node.uuid))));return e.set(r,i.length?i:null),e}),new Map),dt=new WeakSet,pt=e=>new Map(Array.from(e.entries()).map((([e,t])=>[e.id,t]))),ht=new WeakSet,gt=async(e,t)=>{const r=Array.from(t.values()).flat().filter(Boolean).map((e=>e.journey.uuid)),i=e.filter((e=>!r.includes(e.journey.uuid)));return Promise.all(i.map((e=>ba.clearVisitorJourney(e))))},mt=new WeakSet,wt=async(e,t)=>{if(!(null==t?void 0:t.length))return false;const r=new Date(e.since),i=await Ta.getGraphActiveNodesData(e.id);return t.every((t=>{const n=new Date(t.node_entered_at);if(Number(n)>=Number(r))return true;const s=e.nodes.find((e=>e.id===t.node.uuid)),o=e.originalGraph.nodes.find((e=>e.id===(null==s?void 0:s.externalId))),a=new Date(o.since);if(Number(a)<=Number(n))return true;const c=i.find((e=>e.journey.id===t.journey.uuid&&e.node.id===(null==s?void 0:s.id))),u=c?new Date(c.node.since):void 0;if(u&&Number(a)===Number(u))return true;else return false}))},vt=new WeakSet,ft=async function(e){return(await Promise.all(Array.from(e.entries()).map((([e,t])=>Ct(this,mt,wt).call(this,e,t))))).every(Boolean)},yt=new WeakSet,bt=e=>e.filter((e=>{const t=new Date(e.node_entered_at),r=new Date(t.setDate(t.getDate()+Aa));if(Number(r)>Number(new Date))return true;else return false}));const Ua=new class{constructor(){It(this,at),It(this,ut),It(this,dt),It(this,ht),It(this,mt),It(this,vt),It(this,yt)}async getVisitorJourneys(e){const t=Ko.getCookie(Dr.visitorUuid),r=await ba.getVisitorJourneys(t),i=Ct(this,ut,lt).call(this,e,Ct(this,yt,bt).call(this,r)),n=await Ct(this,vt,ft).call(this,i);await Ct(this,ht,gt).call(this,r,i);const s=Array.from(i).some((([e,t])=>{if(!(null==t?void 0:t.length))return false;else return t.some((t=>{const r=e.nodes.find((e=>e.id===t.node.uuid));return(null==r?void 0:r.type)===kt.ReactSendToBackend}))}));if(n&&!s)return Ct(this,dt,pt).call(this,i);const o=await Io.getVisitorJourneys();return await Promise.all(Array.from(i.keys()).map((async e=>{const t=Ct(this,at,ct).call(this,e,o);if(t.length)return i.set(e,t),Promise.all(t.map((t=>Ta.saveGraphJourneyActiveNodeData(e,t))))}))),Ct(this,dt,pt).call(this,i)}};function Va(e){return e&&"object"==typeof e&&"connections"in e&&"nodes"in e&&Array.isArray(e["nodes"])&&e["nodes"].length>0}let Na=null;async function _a(e){Rn().saveUserVisit();const t=e.filter(ha);let r=new Map;try{if(t.length>0)r=(await Promise.all([Ua.getVisitorJourneys(t),Vs.migrateData().catch((e=>Ot.warn("Failed to migrate popup data",e)))]))[0];else await Vs.migrateData()}catch(i){Ot.error("Failed to get journey data",i)}if(null==e?void 0:e.length)if("complete"===window.document.readyState)Na=new Da(e,r);else window.addEventListener("load",(()=>{Na=new Da(e,r)}),{once:true})}e.init=e=>{const{visitorApplicationEndpoint:t,flowData:r}=JSON.parse(e);if(ka.isScriptDelayed(yr.we))return ka.storeDelayedScriptParams(yr.we,[e]),null;if(!Ir.scriptModuleManager.isScriptInitialized(yr.we)){if(Ir.scriptModuleManager.setScriptInitialized(yr.we),Ir.enablePopupDevMode(),t)Ir.visitorApplicationEndpoint=t;(i=r,Promise.all(i.map((e=>{if(Va(e))return e;else if("flowDataUrl"in e)return fetch(e.flowDataUrl).then((e=>e.json())).then((e=>{if(Va(e))return e;else return null})).catch((e=>(Ot.error("Failed to fetch web flow data",e),null)));return null})))).then((e=>e.filter(Boolean))).then((e=>{_a(e),window.history.pushState=new Proxy(window.history.pushState,{apply(t,r,i){var n;if((null==(n=null==i?void 0:i[0])?void 0:n.gr)!==Ii.ExitIntend)_a(e),Ir.eventBus.publish(In.FlushEvents);return t.apply(r,i)}}),window.history.replaceState=new Proxy(window.history.replaceState,{apply(t,r,i){if(3===i.length&&!!i[2])_a(e),Ir.eventBus.publish(In.FlushEvents);return t.apply(r,i)}}),window.addEventListener("popstate",(t=>{var r;if((null==(r=t.state)?void 0:r.gr)!==Ii.ExitIntend)_a(e),Ir.eventBus.publish(In.FlushEvents)}))}))}var i},Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}((e="undefined"!=typeof globalThis?globalThis:e||self).GRWE={})}(this);