var _growthbook=function(){"use strict";function t(t){for(var e=1;e>>0}function B(t,e,n){return 2===n?R(R(t+e)+"")%1e4/1e4:1===n?R(e+t)%1e3/1e3:null}function I(t,e){return t>=e[0]&&t{r.push([t.searchParams.get(n)||"",e,!1])})),!r.some((t=>!function(t,e,n){try{let r=e.replace(/[*.+?^${}()|[\]\\]/g,"\\$&").replace(/_____/g,".*");return n&&(r="\\/?"+r.replace(/(^\/|\/$)/g,"")+"\\/?"),new RegExp("^"+r+"$","i").test(t)}catch(t){return!1}}(t[0],t[1],t[2])))}catch(t){return!1}}(r,n)}catch(t){return!1}}const J=t=>Uint8Array.from(atob(t),(t=>t.charCodeAt(0)));async function P(t,e,n){if(e=e||"",!(n=n||globalThis.crypto&&globalThis.crypto.subtle||M.SubtleCrypto))throw new Error("No SubtleCrypto implementation found");try{const r=await n.importKey("raw",J(e),{name:"AES-CBC",length:128},!0,["encrypt","decrypt"]),[i,s]=t.split("."),o=await n.decrypt({name:"AES-CBC",iv:J(i)},r,J(s));return(new TextDecoder).decode(o)}catch(t){throw new Error("Failed to decrypt")}}function L(t){return"string"==typeof t?t:JSON.stringify(t)}function K(t){"number"==typeof t&&(t+=""),t&&"string"==typeof t||(t="0");const e=t.replace(/(^v|\+.*$)/g,"").split(/[-.]/);return 3===e.length&&e.push("~"),e.map((t=>t.match(/^[0-9]+$/)?t.padStart(5," "):t)).join("-")}function H(){let t;try{t="1.6.5"}catch(e){t=""}return t}function q(t){return"object"==typeof t&&null!==t}function G(t){return t.urlPatterns&&t.variations.some((t=>q(t)&&"urlRedirect"in t))?"redirect":t.variations.some((t=>q(t)&&(t.domMutations||"js"in t||"css"in t)))?"visual":"unknown"}async function z(t,e){return new Promise((n=>{let r,i=!1;const s=t=>{i||(i=!0,r&&clearTimeout(r),n(t||null))};e&&(r=setTimeout((()=>s()),e)),t.then((t=>s(t))).catch((()=>s()))}))}const Z={staleTTL:6e4,maxAge:144e5,cacheKey:"gbFeaturesCache",backgroundSync:!0,maxEntries:10,disableIdleStreams:!1,idleStreamInterval:2e4,disableCache:!1},Q=M,W={fetchFeaturesCall:({host:t,clientKey:e,headers:n})=>Q.fetch(`${t}/api/features/${e}`,{headers:n}),fetchRemoteEvalCall:({host:t,clientKey:e,payload:n,headers:r})=>{const i={method:"POST",headers:{"Content-Type":"application/json",...r},body:JSON.stringify(n)};return Q.fetch(`${t}/api/eval/${e}`,i)},eventSourceCall:({host:t,clientKey:e,headers:n})=>n?new Q.EventSource(`${t}/sub/${e}`,{headers:n}):new Q.EventSource(`${t}/sub/${e}`),startIdleListener:()=>{let t;if("undefined"==typeof window||"undefined"==typeof document)return;const e=()=>{"visible"===document.visibilityState?(window.clearTimeout(t),nt.forEach((t=>{t&&"idle"===t.state&&wt(t)}))):"hidden"===document.visibilityState&&(t=window.setTimeout(it,Z.idleStreamInterval))};return document.addEventListener("visibilitychange",e),()=>document.removeEventListener("visibilitychange",e)},stopIdleListener:()=>{}};try{globalThis.localStorage&&(Q.localStorage=globalThis.localStorage)}catch(t){}const X=new Map;let Y=!1;const tt=new Map,et=new Map,nt=new Map,rt=new Set;function it(){nt.forEach((t=>{t&&(t.state="idle",dt(t))}))}async function st(){try{if(!Q.localStorage)return;await Q.localStorage.setItem(Z.cacheKey,JSON.stringify(Array.from(tt.entries())))}catch(t){}}function ot(t){const[e,n]=t.getApiInfo();return`${e}||${n}`}function ut(t){const e=ot(t);if(!("isRemoteEval"in t)||!t.isRemoteEval())return e;const n=t.getAttributes(),r=t.getCacheKeyAttributes()||Object.keys(t.getAttributes()),i={};r.forEach((t=>{i[t]=n[t]}));const s=t.getForcedVariations(),o=t.getUrl();return`${e}||${JSON.stringify({ca:i,fv:s,url:o})}`}function ct(){const t=Array.from(tt.entries()).map((([t,e])=>({key:t,staleAt:e.staleAt.getTime()}))).sort(((t,e)=>t.staleAt-e.staleAt)),e=Math.min(Math.max(0,tt.size-Z.maxEntries),tt.size);for(let n=0;nasync function(t,e){await t.setPayload(e||t.getPayload())}(t,n)))}async function lt(t){const{apiHost:e,apiRequestHeaders:n}=t.getApiHosts(),r=t.getClientKey(),i="isRemoteEval"in t&&t.isRemoteEval(),s=ot(t),o=ut(t);let u=et.get(o);return u||(u=(i?W.fetchRemoteEvalCall({host:e,clientKey:r,payload:{attributes:t.getAttributes(),forcedVariations:t.getForcedVariations(),forcedFeatures:Array.from(t.getForcedFeatures().entries()),url:t.getUrl()},headers:n}):W.fetchFeaturesCall({host:e,clientKey:r,headers:n})).then((t=>{if(!t.ok)throw new Error(`HTTP error: ${t.status}`);return"enabled"===t.headers.get("x-sse-support")&&rt.add(s),t.json()})).then((e=>(at(s,o,e),ht(t),et.delete(o),{data:e,success:!0,source:"network"}))).catch((t=>(et.delete(o),{data:null,source:"error",success:!1,error:t}))),et.set(o,u)),u}function ht(t,e=!1){const n=ot(t),r=ut(t),{streamingHost:i,streamingHostRequestHeaders:s}=t.getApiHosts(),o=t.getClientKey();if(e&&rt.add(n),Z.backgroundSync&&rt.has(n)&&Q.EventSource){if(nt.has(n))return;const t={src:null,host:i,clientKey:o,headers:s,cb:e=>{try{if("features-updated"===e.type){const t=X.get(n);t&&t.forEach((t=>{lt(t)}))}else if("features"===e.type){const t=JSON.parse(e.data);at(n,r,t)}t.errors=0}catch(e){ft(t)}},errors:0,state:"active"};nt.set(n,t),wt(t)}}function ft(t){if("idle"!==t.state&&(t.errors++,t.errors>3||t.src&&2===t.src.readyState)){const e=Math.pow(3,t.errors-3)*(1e3+1e3*Math.random());dt(t),setTimeout((()=>{["idle","active"].includes(t.state)||wt(t)}),Math.min(e,3e5))}}function dt(t){t.src&&(t.src.onopen=null,t.src.onerror=null,t.src.close(),t.src=null,"active"===t.state&&(t.state="disabled"))}function wt(t){t.src=W.eventSourceCall({host:t.host,clientKey:t.clientKey,headers:t.headers}),t.state="active",t.src.addEventListener("features",t.cb),t.src.addEventListener("features-updated",t.cb),t.src.onerror=()=>ft(t),t.src.onopen=()=>{t.errors=0}}function yt(t,e){dt(t),nt.delete(e)}function pt(){rt.clear(),nt.forEach(yt),X.clear(),W.stopIdleListener()}function gt(t,e){if(e.streaming){if(!t.getClientKey())throw new Error("Must specify clientKey to enable streaming");e.payload&&ht(t,!0),function(t){const e=ot(t),n=X.get(e)||new Set;n.add(t),X.set(e,n)}(t)}}const mt={};function vt(t,e,n){n=n||{};for(const[r,i]of Object.entries(e))switch(r){case"$or":if(!Ct(t,i,n))return!1;break;case"$nor":if(Ct(t,i,n))return!1;break;case"$and":if(!Et(t,i,n))return!1;break;case"$not":if(vt(t,i,n))return!1;break;default:if(!St(i,bt(t,r),n))return!1}return!0}function bt(t,e){const n=e.split(".");let r=t;for(let t=0;t0&&e.filter((t=>"$"===t[0])).length===e.length}function _t(t,e,n=!1){if(n){const n=t=>"string"==typeof t?t.toLowerCase():t;return Array.isArray(t)?t.some((t=>e.some((e=>n(t)===n(e))))):e.some((e=>n(t)===n(e)))}return Array.isArray(t)?t.some((t=>e.includes(t))):e.includes(t)}function $t(t,e,n,r=!1){if(!Array.isArray(t))return!1;for(let i=0;iK(n);case"$vgte":return K(e)>=K(n);case"$vlt":return K(e)n;case"$gte":return e>=n;case"$exists":return n?null!=e:null==e;case"$in":return!!Array.isArray(n)&&_t(e,n);case"$ini":return!!Array.isArray(n)&&_t(e,n,!0);case"$inGroup":return _t(e,r[n]||[]);case"$notInGroup":return!_t(e,r[n]||[]);case"$nin":return!!Array.isArray(n)&&!_t(e,n);case"$nini":return!!Array.isArray(n)&&!_t(e,n,!0);case"$not":return!St(n,e,r);case"$size":return!!Array.isArray(e)&&St(n,e.length,r);case"$elemMatch":return function(t,e,n){if(!Array.isArray(t))return!1;const r=At(e)?t=>St(e,t,n):t=>vt(t,e,n);for(let e=0;ei(e,n,t.user))))}if(t.user.trackingCallback){const i=t.user.trackingCallback;r.push(Nt((()=>i(e,n))))}if(t.global.eventLogger){const i=t.global.eventLogger;r.push(Nt((()=>i(Tt,{experimentId:e.key,variationId:n.key,hashAttribute:n.hashAttribute,hashValue:n.hashValue},t.user))))}return r}function Ft(t,e){if(e.stack.evaluatedFeatures.has(t))return Rt(e,t,null,"cyclicPrerequisite");e.stack.evaluatedFeatures.add(t),e.stack.id=t;const n=function(t){const e=new Map;return t.global.forcedFeatureValues&&t.global.forcedFeatureValues.forEach(((t,n)=>e.set(n,t))),t.user.forcedFeatureValues&&t.user.forcedFeatureValues.forEach(((t,n)=>e.set(n,t))),e}(e);if(n.has(t))return Rt(e,t,n.get(t),"override");if(!e.global.features||!e.global.features[t])return Rt(e,t,null,"unknownFeature");const r=e.global.features[t];if(r.rules){const n=new Set(e.stack.evaluatedFeatures);t:for(const i of r.rules){if(i.parentConditions)for(const r of i.parentConditions){e.stack.evaluatedFeatures=new Set(n);const i=Ft(r.id,e);if("cyclicPrerequisite"===i.source)return Rt(e,t,null,"cyclicPrerequisite");if(!vt({value:i.value},r.condition||{})){if(r.gate)return Rt(e,t,null,"prerequisite");continue t}}if(i.filters&&Ut(i.filters,e))continue;if("force"in i){if(i.condition&&!It(i.condition,e))continue;if(!Vt(e,i.seed||t,i.hashAttribute,e.user.saveStickyBucketAssignmentDoc&&!i.disableStickyBucketing?i.fallbackAttribute:void 0,i.range,i.coverage,i.hashVersion))continue;return i.tracks&&i.tracks.forEach((t=>{!Dt(e,t.experiment,t.result).length&&e.global.saveDeferredTrack&&e.global.saveDeferredTrack({experiment:t.experiment,result:t.result})})),Rt(e,t,i.force,"force",i.id)}if(!i.variations)continue;const r={variations:i.variations,key:i.key||t};"coverage"in i&&(r.coverage=i.coverage),i.weights&&(r.weights=i.weights),i.hashAttribute&&(r.hashAttribute=i.hashAttribute),i.fallbackAttribute&&(r.fallbackAttribute=i.fallbackAttribute),i.disableStickyBucketing&&(r.disableStickyBucketing=i.disableStickyBucketing),void 0!==i.bucketVersion&&(r.bucketVersion=i.bucketVersion),void 0!==i.minBucketVersion&&(r.minBucketVersion=i.minBucketVersion),i.namespace&&(r.namespace=i.namespace),i.meta&&(r.meta=i.meta),i.ranges&&(r.ranges=i.ranges),i.name&&(r.name=i.name),i.phase&&(r.phase=i.phase),i.seed&&(r.seed=i.seed),i.hashVersion&&(r.hashVersion=i.hashVersion),i.filters&&(r.filters=i.filters),i.condition&&(r.condition=i.condition);const{result:s}=Mt(r,t,e);if(e.global.onExperimentEval&&e.global.onExperimentEval(r,s),s.inExperiment&&!s.passthrough)return Rt(e,t,s.value,"experiment",i.id,r,s)}}return Rt(e,t,void 0===r.defaultValue?null:r.defaultValue,"defaultValue")}function Mt(t,e,n){const r=t.key,i=t.variations.length;if(i<2)return{result:jt(n,t,-1,!1,e)};if(!1===n.global.enabled||!1===n.user.enabled)return{result:jt(n,t,-1,!1,e)};if(t=function(t,e){const n=t.key,r=e.global.overrides;return r&&r[n]&&"string"==typeof(t=Object.assign({},t,r[n])).url&&(t.url=U(t.url)),t}(t,n),t.urlPatterns&&!V(n.user.url||"",t.urlPatterns))return{result:jt(n,t,-1,!1,e)};const s=function(t,e,n){if(!e)return null;const r=e.split("?")[1];if(!r)return null;const i=r.replace(/#.*/,"").split("&").map((t=>t.split("=",2))).filter((([e])=>e===t)).map((([,t])=>parseInt(t)));return i.length>0&&i[0]>=0&&i[0]0)for(let t=0;tt.key===a));return l<0?{variation:-1}:{variation:l}}({ctx:n,expKey:t.key,expBucketVersion:t.bucketVersion,expHashAttribute:t.hashAttribute,expFallbackAttribute:t.fallbackAttribute,expMinBucketVersion:t.minBucketVersion,expMeta:t.meta});l=e>=0,a=e,h=!!r}if(!l){if(t.filters){if(Ut(t.filters,n))return{result:jt(n,t,-1,!1,e)}}else if(t.namespace&&!function(t,e){const n=B("__"+e[0],t,1);return null!==n&&n>=e[1]&&n1&&(e=1);const r=(i=t)<=0?[]:new Array(i).fill(1/i);var i;(n=n||r).length!==t&&(n=r);const s=n.reduce(((t,e)=>e+t),0);(s<.99||s>1.01)&&(n=r);let o=0;return n.map((t=>{const n=o;return o+=t,[n,n+e*t]}))}(i,void 0===t.coverage?1:t.coverage,t.weights))),h)return{result:jt(n,t,-1,!1,e,void 0,!0)};if(a<0)return{result:jt(n,t,-1,!1,e)};if("force"in t)return{result:jt(n,t,void 0===t.force?-1:t.force,!1,e)};if(n.global.qaMode||n.user.qaMode)return{result:jt(n,t,-1,!1,e)};if("stopped"===t.status)return{result:jt(n,t,-1,!1,e)};const d=jt(n,t,a,!0,e,f,l);if(n.user.saveStickyBucketAssignmentDoc&&!t.disableStickyBucketing){const{changed:e,key:r,doc:i}=function(t,e,n,r){const i=Lt(e,n),s=t.user.stickyBucketAssignmentDocs&&t.user.stickyBucketAssignmentDocs[i]&&t.user.stickyBucketAssignmentDocs[i].assignments||{},o={...s,...r};return{key:i,doc:{attributeName:e,attributeValue:n,assignments:o},changed:JSON.stringify(s)!==JSON.stringify(o)}}(n,u,L(c),{[Pt(t.key,t.bucketVersion)]:d.key});e&&(n.user.stickyBucketAssignmentDocs=n.user.stickyBucketAssignmentDocs||{},n.user.stickyBucketAssignmentDocs[r]=i,n.user.saveStickyBucketAssignmentDoc(i))}const w=Dt(n,t,d);0===w.length&&n.global.saveDeferredTrack&&n.global.saveDeferredTrack({experiment:t,result:d});const y=w.length?1===w.length?w[0]:Promise.all(w).then((()=>{})):void 0;return"changeId"in t&&t.changeId&&n.global.recordChangeId&&n.global.recordChangeId(t.changeId),{result:d,trackingCall:y}}function Rt(t,e,n,r,i,s,o){const u={value:n,on:!!n,off:!n,source:r,ruleId:i||""};return s&&(u.experiment=s),o&&(u.experimentResult=o),"override"!==r&&function(t,e,n){if(t.user.trackedFeatureUsage){const r=JSON.stringify(n.value);if(t.user.trackedFeatureUsage[e]===r)return;t.user.trackedFeatureUsage[e]=r,t.user.enableDevMode&&t.user.devLogs&&t.user.devLogs.push({featureKey:e,result:n,timestamp:Date.now().toString(),logType:"feature"})}if(t.global.onFeatureUsage){const r=t.global.onFeatureUsage;Nt((()=>r(e,n,t.user)))}if(t.user.onFeatureUsage){const r=t.user.onFeatureUsage;Nt((()=>r(e,n)))}if(t.global.eventLogger){const r=t.global.eventLogger;Nt((()=>r(Ot,{feature:e,source:n.source,value:n.value,ruleId:"defaultValue"===n.source?"$default":n.ruleId||"",variationId:n.experimentResult?n.experimentResult.key:""},t.user)))}}(t,e,u),u}function Bt(t){return{...t.user.attributes,...t.user.attributeOverrides}}function It(t,e){return vt(Bt(e),t,e.global.savedGroups||{})}function Ut(t,e){return t.some((t=>{const{hashValue:n}=Jt(e,t.attribute);if(!n)return!0;const r=B(t.seed,n,t.hashVersion||2);return null===r||!t.ranges.some((t=>I(r,t)))}))}function Vt(t,e,n,r,i,s,o){if(!i&&void 0===s)return!0;if(!i&&0===s)return!1;const{hashValue:u}=Jt(t,n,r);if(!u)return!1;const c=B(e,u,o||1);return null!==c&&(i?I(c,i):void 0===s||c<=s)}function jt(t,e,n,r,i,s,o){let u=!0;(n<0||n>=e.variations.length)&&(n=0,u=!1);const{hashAttribute:c,hashValue:a}=Jt(t,e.hashAttribute,t.user.saveStickyBucketAssignmentDoc&&!e.disableStickyBucketing?e.fallbackAttribute:void 0),l=e.meta?e.meta[n]:{},h={key:l.key||""+n,featureId:i,inExperiment:u,hashUsed:r,variationId:n,value:e.variations[n],hashAttribute:c,hashValue:a,stickyBucketUsed:!!o};return l.name&&(h.name=l.name),void 0!==s&&(h.bucket=s),l.passthrough&&(h.passthrough=l.passthrough),h}function Jt(t,e,n){let r=e||"id",i="";const s=Bt(t);return s[r]&&(i=s[r]),!i&&n&&(s[n]&&(i=s[n]),i&&(r=n)),{hashAttribute:r,hashValue:i}}function Pt(t,e){return`${t}__${e=e||0}`}function Lt(t,e){return`${t}||${e}`}function Kt(t,e){const n={},r=function(t,e){const n=new Set,r=e&&e.features?e.features:t.global.features||{},i=e&&e.experiments?e.experiments:t.global.experiments||[];return Object.keys(r).forEach((t=>{const e=r[t];if(e.rules)for(const t of e.rules)t.variations&&(n.add(t.hashAttribute||"id"),t.fallbackAttribute&&n.add(t.fallbackAttribute))})),i.map((t=>{n.add(t.hashAttribute||"id"),t.fallbackAttribute&&n.add(t.fallbackAttribute)})),Array.from(n)}(t,e);return r.forEach((e=>{const{hashValue:r}=Jt(t,e);n[e]=L(r)})),n}function Ht(t,e){return e.hashAttribute+e.hashValue+t.key+e.variationId}const qt="undefined"!=typeof window&&"undefined"!=typeof document,Gt=H();class zt{constructor(t){this.prefix=(t=t||{}).prefix||""}async getAllAssignments(t){const e={};return(await Promise.all(Object.entries(t).map((([t,e])=>this.getAssignments(t,e))))).forEach((t=>{if(t){const n=Lt(t.attributeName,t.attributeValue);e[n]=t}})),e}getKey(t,e){return`${this.prefix}${t}||${e}`}}class Zt extends zt{async getAssignments(t,e){return this.getAssignmentsSync(t,e)}async saveAssignments(t){this.saveAssignmentsSync(t)}getAllAssignmentsSync(t){const e={};return Object.entries(t).map((([t,e])=>this.getAssignmentsSync(t,e))).forEach((t=>{if(t){const n=Lt(t.attributeName,t.attributeValue);e[n]=t}})),e}}function Qt(t){return{browser:t.match(/Edg/)?"edge":t.match(/Chrome/)?"chrome":t.match(/Firefox/)?"firefox":t.match(/Safari/)?"safari":"unknown",deviceType:t.match(/Mobi/)?"mobile":"desktop"}}function Wt(t){return t?{url:t.href,path:t.pathname,host:t.host,query:t.search}:{}}function Xt(t){let e={};try{const t=sessionStorage.getItem("utm_params");t&&(e=JSON.parse(t))}catch(t){}if(t&&t.search){const n=new URLSearchParams(t.search);let r=!1;if(["source","medium","campaign","term","content"].forEach((t=>{const i=`utm_${t}`,s="utm"+t[0].toUpperCase()+t.slice(1);n.has(i)&&(e[s]=n.get(i)||"",r=!0)})),r)try{sessionStorage.setItem("utm_params",JSON.stringify(e))}catch(t){}}return e}function Yt(){if("undefined"==typeof window||!window.dataLayer||!window.dataLayer.forEach)return{};const t={};return window.dataLayer.forEach((e=>{e&&"object"==typeof e&&!("length"in e)&&("event"in e||Object.keys(e).forEach((n=>{if("string"!=typeof n||n.match(/^(gtm)/))return;const r=e[n];["string","number","boolean"].includes(typeof r)&&(t[n]=r)})))})),t}const te=H();function ee(t){return"string"==typeof t?t:null}window.dataLayer=window.dataLayer||[];const ne=document.currentScript,re=ne?ne.dataset:{},ie=window.growthbook_config||{};let se,oe;function ue(){window.clearTimeout(se);let t=ie.antiFlickerTimeout??(re.antiFlickerTimeout?parseInt(re.antiFlickerTimeout):null)??3500;isFinite(t)||(t=3500);try{if(!document.getElementById("gb-anti-flicker-style")){const t=document.createElement("style");t.setAttribute("id","gb-anti-flicker-style"),t.innerHTML=".gb-anti-flicker { opacity: 0 !important; pointer-events: none; }",document.head.appendChild(t)}document.documentElement.classList.add("gb-anti-flicker"),se=window.setTimeout(ce,t)}catch(t){console.error(t)}}function ce(){window.clearTimeout(se);try{document.documentElement.classList.remove("gb-anti-flicker")}catch(t){console.error(t)}}(ie.antiFlicker||re.antiFlicker)&&ue(),"cookie"===ie.useStickyBucketService||"cookie"===re.useStickyBucketService?oe=new class extends Zt{constructor({prefix:t="gbStickyBuckets__",jsCookie:e,cookieAttributes:n={expires:180}}){super(),this.prefix=t,this.jsCookie=e,this.cookieAttributes=n}getAssignmentsSync(t,e){const n=this.getKey(t,e);let r=null;if(!this.jsCookie)return r;try{const t=this.jsCookie.get(n),e=JSON.parse(t||"{}");e.attributeName&&e.attributeValue&&e.assignments&&(r=e)}catch(t){}return r}async saveAssignmentsSync(t){const e=this.getKey(t.attributeName,t.attributeValue);if(!this.jsCookie)return;const n=JSON.stringify(t);this.jsCookie.set(e,n,this.cookieAttributes)}}({prefix:ie.stickyBucketPrefix||re.stickyBucketPrefix||void 0,jsCookie:e}):"localStorage"!==ie.useStickyBucketService&&"localStorage"!==re.useStickyBucketService||(oe=new class extends zt{constructor(t){t=t||{},super(),this.prefix=t.prefix||"gbStickyBuckets__";try{this.localStorage=t.localStorage||globalThis.localStorage}catch(t){}}async getAssignments(t,e){const n=this.getKey(t,e);let r=null;if(!this.localStorage)return r;try{const t=await this.localStorage.getItem(n)||"{}",e=JSON.parse(t);e.attributeName&&e.attributeValue&&e.assignments&&(r=e)}catch(t){}return r}async saveAssignments(t){const e=this.getKey(t.attributeName,t.attributeValue);if(this.localStorage)try{await this.localStorage.setItem(e,JSON.stringify(t))}catch(t){}}}({prefix:ie.stickyBucketPrefix||re.stickyBucketPrefix||void 0}));const ae=re.uuid||ie.uuid,le=[function(t={}){if("undefined"==typeof window)throw new Error("autoAttributesPlugin only works in the browser");const e=t.uuidCookieName||"gbuuid",n=t.uuidKey||"id";let r=t.uuid||"";function i(){!function(t,e){const n=new Date;n.setTime(n.getTime()+3456e7),document.cookie=t+"="+e+";path=/;expires="+n.toUTCString()}(e,r)}function s(t){const s=navigator.userAgent,o=r||(r=function(t){const e=("; "+document.cookie).split(`; ${t}=`);return 2===e.length?e[1].split(";")[0]:""}(e),r||(u=window.crypto,r=u&&u.randomUUID?u.randomUUID():"10000000-1000-4000-8000-100000000000".replace(/[018]/g,(t=>(t^(u&&u.getRandomValues?u.getRandomValues(new Uint8Array(1))[0]:Math.floor(256*Math.random()))&15>>t/4).toString(16))),r));var u;(t.uuidAutoPersist??!t.uuid)&&i();const c=location;return{...Yt(),[n]:o,...Wt(c),pageTitle:document.title,...Qt(s),...Xt(c)}}return document.addEventListener("growthbookpersist",(()=>{i()})),e=>{if("createScopedInstance"in e)return;const n=s(t);n.url&&e.setURL(n.url),e.updateAttributes(n);let r=n.url;const i=setInterval((()=>{location.href!==r&&(r=location.href,e.setURL(r),e.updateAttributes(s(t)))}),500),o=()=>{location.href!==r&&(r=location.href,e.setURL(r)),e.updateAttributes(s(t))};document.addEventListener("growthbookrefresh",o),"onDestroy"in e&&e.onDestroy((()=>{clearInterval(i),document.removeEventListener("growthbookrefresh",o)}))}}({uuid:ae,uuidCookieName:ie.uuidCookieName||re.uuidCookieName,uuidKey:ie.uuidKey||re.uuidKey,uuidAutoPersist:!ae&&null==re.noAutoCookies})],he=re.tracking||"gtag,gtm,segment";if("none"!==he){const t=he.toLowerCase().split(",").map((t=>t.trim()));t.includes("growthbook")&&le.push(function({queueFlushInterval:t=100,ingestorHost:e,enable:n=!0,debug:r,dedupeCacheSize:i=1e3,dedupeKeyAttributes:s=[],eventFilter:o}={}){return u=>{const c=u.getClientKey();if(!c)throw new Error("clientKey must be specified to use event logging");const a=new Set;if("setEventLogger"in u){let l=[],h=null;const f=async()=>{const t=l;l=[],h&&clearTimeout(h),h=null,t.length&&await async function({clientKey:t,ingestorHost:e,events:n}){if(!n.length)return;const r=`${e||"https://us1.gb-ingest.com"}/track?client_key=${t}`,i=JSON.stringify(n);try{await fetch(r,{method:"POST",body:i,headers:{Accept:"application/json","Content-Type":"text/plain"},credentials:"omit"})}catch(t){console.error("Failed to track event",t)}}({clientKey:c,events:t,ingestorHost:e})};let d=null;u.setEventLogger((async(e,u,c)=>{const w={eventName:e,properties:u,attributes:c.attributes||{},url:c.url||""};if(o&&!o(w))return;if(e===Ot||e===Tt){const t={eventName:e,properties:u};for(const e of s)t["attr:"+e]=w.attributes[e];const n=JSON.stringify(t);if(a.has(n))return a.delete(n),void a.add(n);if(a.add(n),a.size>i){const t=a.values().next().value;t&&a.delete(t)}}const y=function({eventName:t,properties:e,attributes:n,url:r}){const{nested:i,topLevel:s}=function(t){const{user_id:e,device_id:n,anonymous_id:r,id:i,page_id:s,session_id:o,utmCampaign:u,utmContent:c,utmMedium:a,utmSource:l,utmTerm:h,pageTitle:f,...d}=t;return{nested:d,topLevel:{user_id:ee(e),device_id:ee(n||r||i),page_id:ee(s),session_id:ee(o),utm_campaign:ee(u)||void 0,utm_content:ee(c)||void 0,utm_medium:ee(a)||void 0,utm_source:ee(l)||void 0,utm_term:ee(h)||void 0,page_title:ee(f)||void 0}}}(n||{});return{event_name:t,properties_json:e||{},...s,sdk_language:"js",sdk_version:te,url:r,context_json:i}}(w);r&&console.log("Logging event to GrowthBook",JSON.parse(JSON.stringify(y))),n&&(l.push(y),d||(d=new Promise(((e,n)=>{h=setTimeout((()=>{f().then(e).catch(n),d=null}),t)}))),await d)})),"undefined"!=typeof document&&document.visibilityState&&document.addEventListener("visibilitychange",(()=>{"hidden"===document.visibilityState&&f().catch(console.error)})),"onDestroy"in u&&u.onDestroy((()=>{f().catch(console.error)}))}if("undefined"!=typeof window&&!("createScopedInstance"in u)){const t=Array.isArray(window.gbEvents)?window.gbEvents:[];window.gbEvents={push:t=>{"isDestroyed"in u&&u.isDestroyed()?window.gbEvents=[t]:"string"==typeof t?u.logEvent(t):t&&u.logEvent(t.eventName,t.properties)}};for(const e of t)window.gbEvents.push(e)}}}({ingestorHost:re.eventIngestorHost})),ie.trackingCallback||le.push(function({additionalCallback:t,trackers:e=["gtag","gtm","segment"]}={}){if("undefined"==typeof window)throw new Error("thirdPartyTrackingPlugin only works in the browser");return n=>{n.setTrackingCallback((async(n,r)=>{const i=[],s={experiment_id:n.key,variation_id:r.key};if(t&&i.push(Promise.resolve(t(n,r))),e.includes("gtag")&&window.gtag){let t;const e=new Promise((e=>{t=e}));i.push(e),window.gtag("event","experiment_viewed",{...s,event_callback:t})}if(e.includes("gtm")&&window.dataLayer){let t;const e=new Promise((e=>{t=e}));i.push(e),window.dataLayer.push({event:"experiment_viewed",...s,eventCallback:t})}if(e.includes("segment")&&window.analytics&&window.analytics.track){window.analytics.track("Experiment Viewed",s);const t=new Promise((t=>window.setTimeout(t,300)));i.push(t)}await Promise.all(i)}))}}({additionalCallback:ie.additionalTrackingCallback,trackers:t}))}const fe=new class{constructor(t){if(t=t||{},this.version=Gt,this.i=this.context=t,this.o=t.renderer||null,this.u=new Set,this.l=new Set,this.h={},this.debug=!!t.debug,this.p=new Set,this.ready=!1,this.g=new Map,this.m=new Map,this.v=new Set,this.k=!1,this.S="",this.A=new Map,this._=!t.disableExperimentsOnLoad,this.$=[],this.logs=[],this.log=this.log.bind(this),this.C=this.C.bind(this),this.O=this.O.bind(this),this.T=this.T.bind(this),this.N=this.N.bind(this),t.remoteEval){if(t.decryptionKey)throw new Error("Encryption is not available for remoteEval");if(!t.clientKey)throw new Error("Missing clientKey");let e=!1;try{e=!!new URL(t.apiHost||"").hostname.match(/growthbook\.io$/i)}catch(t){}if(e)throw new Error("Cannot use remoteEval on GrowthBook Cloud")}else if(t.cacheKeyAttributes)throw new Error("cacheKeyAttributes are only used for remoteEval");if(t.stickyBucketService){const e=t.stickyBucketService;this.D=t=>e.saveAssignments(t)}if(t.plugins)for(const e of t.plugins)e(this);if(t.features&&(this.ready=!0),qt&&t.enableDevMode&&(window._growthbook=this,document.dispatchEvent(new Event("gbloaded"))),t.experiments&&(this.ready=!0,this.F()),this.i.stickyBucketService&&this.i.stickyBucketAssignmentDocs)for(const t in this.i.stickyBucketAssignmentDocs){const e=this.i.stickyBucketAssignmentDocs[t];e&&this.i.stickyBucketService.saveAssignments(e).catch((()=>{}))}this.ready&&this.refreshStickyBuckets(this.getPayload())}async setPayload(t){this.M=t;const e=await async function(t,e,n){if((t={...t}).encryptedFeatures){try{t.features=JSON.parse(await P(t.encryptedFeatures,e,n))}catch(t){console.error(t)}delete t.encryptedFeatures}if(t.encryptedExperiments){try{t.experiments=JSON.parse(await P(t.encryptedExperiments,e,n))}catch(t){console.error(t)}delete t.encryptedExperiments}if(t.encryptedSavedGroups){try{t.savedGroups=JSON.parse(await P(t.encryptedSavedGroups,e,n))}catch(t){console.error(t)}delete t.encryptedSavedGroups}return t}(t,this.i.decryptionKey);this.R=e,await this.refreshStickyBuckets(e),e.features&&(this.i.features=e.features),e.savedGroups&&(this.i.savedGroups=e.savedGroups),e.experiments&&(this.i.experiments=e.experiments,this.F()),this.ready=!0,this.B()}initSync(t){this.k=!0;const e=t.payload;if(e.encryptedExperiments||e.encryptedFeatures)throw new Error("initSync does not support encrypted payloads");return this.i.stickyBucketService&&!this.i.stickyBucketAssignmentDocs&&(this.i.stickyBucketAssignmentDocs=this.generateStickyBucketAssignmentDocsSync(this.i.stickyBucketService,e)),this.M=e,this.R=e,e.features&&(this.i.features=e.features),e.experiments&&(this.i.experiments=e.experiments,this.F()),this.ready=!0,gt(this,t),this}async init(t){if(this.k=!0,(t=t||{}).cacheSettings&&(Object.assign(Z,t.cacheSettings),Z.backgroundSync||pt()),t.payload)return await this.setPayload(t.payload),gt(this,t),{success:!0,source:"init"};{const{data:e,...n}=await this.I({...t,allowStale:!0});return gt(this,t),await this.setPayload(e||{}),n}}async loadFeatures(t){t=t||{},await this.init({skipCache:t.skipCache,timeout:t.timeout,streaming:(this.i.backgroundSync??!0)&&(t.autoRefresh||this.i.subscribeToChanges)})}async refreshFeatures(t){const e=await this.I({...t||{},allowStale:!1});e.data&&await this.setPayload(e.data)}getApiInfo(){return[this.getApiHosts().apiHost,this.getClientKey()]}getApiHosts(){return function(t){const e=t.apiHost||"https://cdn.growthbook.io";return{apiHost:e.replace(/\/*$/,""),streamingHost:(t.streamingHost||e).replace(/\/*$/,""),apiRequestHeaders:t.apiHostRequestHeaders,streamingHostRequestHeaders:t.streamingHostRequestHeaders}}(this.i)}getClientKey(){return this.i.clientKey||""}getPayload(){return this.M||{features:this.getFeatures(),experiments:this.getExperiments()}}getDecryptedPayload(){return this.R||this.getPayload()}isRemoteEval(){return this.i.remoteEval||!1}getCacheKeyAttributes(){return this.i.cacheKeyAttributes}async I({timeout:t,skipCache:e,allowStale:n,streaming:r}){if(!this.i.clientKey)throw new Error("Missing clientKey");return async function({instance:t,timeout:e,skipCache:n,allowStale:r,backgroundSync:i}){return i||(Z.backgroundSync=!1),async function({instance:t,allowStale:e,timeout:n,skipCache:r}){const i=ot(t),s=ut(t),o=new Date,u=new Date(o.getTime()-Z.maxAge+Z.staleTTL);await async function(){if(!Y){Y=!0;try{if(Q.localStorage){const t=await Q.localStorage.getItem(Z.cacheKey);if(!Z.disableCache&&t){const e=JSON.parse(t);e&&Array.isArray(e)&&e.forEach((([t,e])=>{tt.set(t,{...e,staleAt:new Date(e.staleAt)})})),ct()}}}catch(t){}if(!Z.disableIdleStreams){const t=W.startIdleListener();t&&(W.stopIdleListener=t)}}}();const c=Z.disableCache||r?void 0:tt.get(s);return c&&(e||c.staleAt>o)&&c.staleAt>u?(c.sse&&rt.add(i),c.staleAt{this.p.delete(t)}}async U(){if(!this.i.remoteEval)return;if(!this.k)return;const t=await this.I({allowStale:!1});t.data&&await this.setPayload(t.data)}getAllResults(){return new Map(this.g)}onDestroy(t){this.$.push(t)}isDestroyed(){return!!this.V}destroy(t){var e;t=t||{},this.V=!0,this.$.forEach((t=>{try{t()}catch(t){console.error(t)}})),this.p.clear(),this.g.clear(),this.u.clear(),this.l.clear(),this.A.clear(),this.h={},this.$=[],this.M=void 0,this.D=void 0,e=this,X.forEach((t=>t.delete(e))),t.destroyAllStreams&&pt(),this.logs=[],qt&&window._growthbook===this&&delete window._growthbook,this.m.forEach((t=>{t.undo()})),this.m.clear(),this.v.clear()}setRenderer(t){this.o=t}forceVariation(t,e){this.i.forcedVariations=this.i.forcedVariations||{},this.i.forcedVariations[t]=e,this.i.remoteEval?this.U():(this.F(),this.B())}run(t){const{result:e}=Mt(t,null,this.j());return this.O(t,e),e}triggerExperiment(t){return this.v.add(t),this.i.experiments?this.i.experiments.filter((e=>e.key===t)).map((t=>this.J(t))).filter((t=>null!==t)):null}triggerAutoExperiments(){this._=!0,this.F(!0)}j(){return{user:this.P(),global:this.L(),stack:{evaluatedFeatures:new Set}}}P(){return{attributes:this.i.user?{...this.i.user,...this.i.attributes}:this.i.attributes,enableDevMode:this.i.enableDevMode,blockedChangeIds:this.i.blockedChangeIds,stickyBucketAssignmentDocs:this.i.stickyBucketAssignmentDocs,url:this.K(),forcedVariations:this.i.forcedVariations,forcedFeatureValues:this.i.forcedFeatureValues,attributeOverrides:this.i.attributeOverrides,saveStickyBucketAssignmentDoc:this.D,trackingCallback:this.i.trackingCallback,onFeatureUsage:this.i.onFeatureUsage,devLogs:this.logs,trackedExperiments:this.u,trackedFeatureUsage:this.h}}L(){return{features:this.i.features,experiments:this.i.experiments,log:this.log,enabled:this.i.enabled,qaMode:this.i.qaMode,savedGroups:this.i.savedGroups,groups:this.i.groups,overrides:this.i.overrides,onExperimentEval:this.O,recordChangeId:this.N,saveDeferredTrack:this.C,eventLogger:this.i.eventLogger}}J(t,e){const n=this.m.get(t);if(t.manual&&!this.v.has(t.key)&&!n)return null;let r,i;this.H(t)?r=jt(this.j(),t,-1,!1,""):(({result:r,trackingCall:i}=Mt(t,null,this.j())),this.O(t,r));const s=JSON.stringify(r.value);if(!e&&r.inExperiment&&n&&n.valueHash===s)return r;if(n&&this.q(t),r.inExperiment){const e=G(t);if("redirect"===e&&r.value.urlRedirect&&t.urlPatterns){const e=t.persistQueryString?function(t,e){let n,r;try{n=new URL(t),r=new URL(e)}catch(t){return console.error(`Unable to merge query strings: ${t}`),e}return n.searchParams.forEach(((t,e)=>{r.searchParams.has(e)||r.searchParams.set(e,t)})),r.toString()}(this.K(),r.value.urlRedirect):r.value.urlRedirect;if(V(e,t.urlPatterns))return this.log("Skipping redirect because original URL matches redirect URL",{id:t.key}),r;this.S=e;const{navigate:n,delay:s}=this.G();if(n)if(qt)Promise.all([...i?[z(i,this.i.maxNavigateDelay??1e3)]:[],new Promise((t=>window.setTimeout(t,this.i.navigateDelay??s)))]).then((()=>{try{n(e)}catch(t){console.error(t)}}));else try{n(e)}catch(t){console.error(t)}}else if("visual"===e){const e=this.i.applyDomChangesCallback?this.i.applyDomChangesCallback(r.value):this.Z(r.value);e&&this.m.set(t,{undo:e,valueHash:s})}}return r}q(t){const e=this.m.get(t);e&&(e.undo(),this.m.delete(t))}F(t){if(!this._)return;const e=this.i.experiments||[],n=new Set(e);this.m.forEach(((t,e)=>{n.has(e)||(t.undo(),this.m.delete(e))}));for(const n of e){const e=this.J(n,t);if(e&&e.inExperiment&&"redirect"===G(n))break}}O(t,e){const n=this.g.get(t.key);this.g.set(t.key,{experiment:t,result:e}),this.p.size>0&&this.T(t,e,n)}T(t,e,n){n&&n.result.inExperiment===e.inExperiment&&n.result.variationId===e.variationId||this.p.forEach((n=>{try{n(t,e)}catch(t){console.error(t)}}))}N(t){this.l.add(t)}isOn(t){return this.evalFeature(t).on}isOff(t){return this.evalFeature(t).off}getFeatureValue(t,e){const n=this.evalFeature(t).value;return null===n?e:n}feature(t){return this.evalFeature(t)}evalFeature(t){return Ft(t,this.j())}log(t,e){this.debug&&(this.i.log?this.i.log(t,e):console.log(t,e))}getDeferredTrackingCalls(){return Array.from(this.A.values())}setDeferredTrackingCalls(t){this.A=new Map(t.filter((t=>t&&t.experiment&&t.result)).map((t=>[Ht(t.experiment,t.result),t])))}async fireDeferredTrackingCalls(){if(!this.i.trackingCallback)return;const t=[];this.A.forEach((e=>{e&&e.experiment&&e.result?t.push(this.i.trackingCallback(e.experiment,e.result)):console.error("Invalid deferred tracking call",{call:e})})),this.A.clear(),await Promise.all(t)}setTrackingCallback(t){this.i.trackingCallback=t,this.fireDeferredTrackingCalls()}setFeatureUsageCallback(t){this.i.onFeatureUsage=t}setEventLogger(t){this.i.eventLogger=t}async logEvent(t,e){if(this.V)console.error("Cannot log event to destroyed GrowthBook instance");else if(this.i.enableDevMode&&this.logs.push({eventName:t,properties:e,timestamp:Date.now().toString(),logType:"event"}),this.i.eventLogger)try{await this.i.eventLogger(t,e||{},this.P())}catch(t){console.error(t)}else console.error("No event logger configured")}C(t){this.A.set(Ht(t.experiment,t.result),t)}K(){return this.i.url||(qt?window.location.href:"")}H(t){const e=G(t);if("visual"===e){if(this.i.disableVisualExperiments)return!0;if(this.i.disableJsInjection&&t.variations.some((t=>t.js)))return!0}else{if("redirect"!==e)return!0;if(this.i.disableUrlRedirectExperiments)return!0;try{const e=new URL(this.K());for(const n of t.variations){if(!n||!n.urlRedirect)continue;const t=new URL(n.urlRedirect);if(this.i.disableCrossOriginUrlRedirectExperiments){if(t.protocol!==e.protocol)return!0;if(t.host!==e.host)return!0}}}catch(e){return this.log("Error parsing current or redirect URL",{id:t.key,error:e}),!0}}return!(!t.changeId||!(this.i.blockedChangeIds||[]).includes(t.changeId))}getRedirectUrl(){return this.S}G(){return this.i.navigate?{navigate:this.i.navigate,delay:0}:qt?{navigate:t=>{window.location.replace(t)},delay:100}:{navigate:null,delay:0}}Z(t){if(!qt)return;const e=[];if(t.css){const n=document.createElement("style");n.innerHTML=t.css,document.head.appendChild(n),e.push((()=>n.remove()))}if(t.js){const n=document.createElement("script");n.innerHTML=t.js,this.i.jsInjectionNonce&&(n.nonce=this.i.jsInjectionNonce),document.head.appendChild(n),e.push((()=>n.remove()))}return t.domMutations&&t.domMutations.forEach((t=>{e.push(function(t){var e=t.selector,n=t.action,i=t.value,s=t.attribute,o=t.parentSelector,u=t.insertBeforeSelector;if("html"===s){if("append"===n)return N(e,(function(t){return t+(null!=i?i:"")}));if("set"===n)return N(e,(function(){return null!=i?i:""}))}else if("class"===s){if("append"===n)return D(e,(function(t){i&&t.add(i)}));if("remove"===n)return D(e,(function(t){i&&t.delete(i)}));if("set"===n)return D(e,(function(t){t.clear(),i&&t.add(i)}))}else if("position"===s){if("set"===n&&o)return function(t,e){return T({kind:"position",elements:new Set,mutate:function(){return{insertBeforeSelector:u,parentSelector:o}},selector:t})}(e)}else{if("append"===n)return F(e,s,(function(t){return null!==t?t+(null!=i?i:""):null!=i?i:""}));if("set"===n)return F(e,s,(function(){return null!=i?i:""}));if("remove"===n)return F(e,s,(function(){return null}))}return r}(t).revert)})),()=>{e.forEach((t=>t()))}}async refreshStickyBuckets(t){if(this.i.stickyBucketService){const e=this.j(),n=await async function(t,e,n){const r=Kt(t,n);return e.getAllAssignments(r)}(e,this.i.stickyBucketService,t);this.i.stickyBucketAssignmentDocs=n}}generateStickyBucketAssignmentDocsSync(t,e){if(!("getAllAssignmentsSync"in t))return void console.error("generating StickyBucketAssignmentDocs docs requires StickyBucketServiceSync");const n=Kt(this.j(),e);return t.getAllAssignmentsSync(n)}inDevMode(){return!!this.i.enableDevMode}}({enableDevMode:!0,...re,remoteEval:!!re.remoteEval,...ie,plugins:le,stickyBucketService:oe});fe.setRenderer((()=>{document.dispatchEvent(new CustomEvent("growthbookdata"))})),fe.init({payload:ie.payload,streaming:!(ie.noStreaming||re.noStreaming||!1===ie.backgroundSync),cacheSettings:ie.cacheSettings}).then((()=>{(ie.antiFlicker||re.antiFlicker)&&(fe.getRedirectUrl()?ue():ce())}));const de=t=>{try{t&&t(fe)}catch(t){console.error("Uncaught growthbook_queue error",t)}};return window.growthbook_queue&&Array.isArray(window.growthbook_queue)&&window.growthbook_queue.forEach((t=>{de(t)})),window.growthbook_queue={push:t=>{de(t)}},fe}(); //# sourceMappingURL=auto.min.js.map