@mcpjam/inspector 0.9.25 → 0.9.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1764,5 +1764,5 @@ An authorization_code was supplied for a login which did not originate at the ap
1764
1764
  * The developer may not have configured a Login Initiation endpoint.`);const i=new URL(window.location.toString());i.search="",window.sessionStorage.removeItem($r.codeVerifier),window.history.replaceState({},"",i)};ch=async function(){Qn(this,uv,setTimeout(()=>{Fn(this,jn,cT).call(this)&&Lt(this,dv).call(this)?Fn(this,jn,uh).call(this).catch(t=>{console.debug(t)}).finally(()=>Fn(this,jn,ch).call(this)):Fn(this,jn,ch).call(this)},1e3))};uh=async function({organizationId:t}={}){if(Lt(this,ir).tag==="AUTHENTICATING"){await Lt(this,ir).response;return}const e=Lt(this,ir);Qn(this,ir,{tag:"AUTHENTICATING",response:Fn(this,jn,iU).call(this,{organizationId:t,beginningState:e})}),await Lt(this,ir).response};iU=async function({organizationId:t,beginningState:e}){try{return await pve(bve,async()=>{if(t)sessionStorage.setItem(SM,t);else{const r=Fn(this,jn,uT).call(this);r?t=Ey(r)?.org_id:t=sessionStorage.getItem(SM)??void 0}const n=await Lt(this,Dl).authenticateWithRefreshToken({refreshToken:nU({devMode:Lt(this,zi)}),organizationId:t,useCookie:Lt(this,jn,dT)});return Qn(this,ir,{tag:"AUTHENTICATED"}),eU(n,{devMode:Lt(this,zi)}),Fn(this,jn,fT).call(this,n),n})}catch(n){throw n instanceof lT&&n.name==="AcquisitionTimeoutError"?(console.warn("Couldn't acquire refresh lock."),Qn(this,ir,e),n):(e.tag!=="INITIAL"&&console.debug(n),n instanceof cv?(tU({devMode:Lt(this,zi)}),e.tag!=="INITIAL"&&Lt(this,Vh)&&Lt(this,Vh).call(this,{signIn:this.signIn.bind(this)}),Qn(this,ir,{tag:"ERROR"})):Qn(this,ir,{tag:"AUTHENTICATED"}),n)}};cT=function(){switch(Lt(this,ir).tag){case"INITIAL":case"AUTHENTICATING":return!0;case"ERROR":return!1;case"AUTHENTICATED":const t=us.getItem($r.accessToken),e=us.getItem($r.expiresAt);if(!t||!e)return!0;const n=Lt(this,hv)*1e3;return e-n<Date.now()}};zf=async function({context:t,invitationToken:e,loginHint:n,organizationId:r,passwordResetToken:s,state:i,type:o}){const{codeVerifier:c,codeChallenge:u}=await rve();return window.sessionStorage.setItem($r.codeVerifier,c),Lt(this,Dl).getAuthorizationUrl({codeChallenge:u,codeChallengeMethod:"S256",context:t,invitationToken:e,loginHint:n,organizationId:r,passwordResetToken:s,redirectUri:Lt(this,lh),screenHint:o,state:i?JSON.stringify(i):void 0})};uT=function(){return us.getItem($r.accessToken)};dT=function(){return!Lt(this,zi)};fT=async function(t){if(Lt(this,Uh)){const{refreshToken:e,...n}=t;Lt(this,Uh).call(this,n)}};async function _ve(t,e={}){const n=new wve(t,e);return await n.initialize(),n}var Sve=Object.defineProperty,Eve=Object.defineProperties,kve=Object.getOwnPropertyDescriptors,EM=Object.getOwnPropertySymbols,Tve=Object.prototype.hasOwnProperty,Cve=Object.prototype.propertyIsEnumerable,kM=(t,e,n)=>e in t?Sve(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Km=(t,e)=>{for(var n in e||(e={}))Tve.call(e,n)&&kM(t,n,e[n]);if(EM)for(var n of EM(e))Cve.call(e,n)&&kM(t,n,e[n]);return t},TM=(t,e)=>Eve(t,kve(e)),vg=(t,e,n)=>new Promise((r,s)=>{var i=u=>{try{c(n.next(u))}catch(d){s(d)}},o=u=>{try{c(n.throw(u))}catch(d){s(d)}},c=u=>u.done?r(u.value):Promise.resolve(u.value).then(i,o);c((n=n.apply(t,e)).next())}),pv={isLoading:!0,user:null,role:null,organizationId:null,permissions:[],featureFlags:[],impersonator:null},aU=_.createContext(pv);function oU(){const t=_.useContext(aU);if(t===pv)throw new Error("useAuth must be used within an AuthKitProvider");return t}function Rve(t){const{clientId:e,devMode:n,apiHostname:r,https:s,port:i,redirectUri:o,children:c,onRefresh:u,onRefreshFailure:d,onRedirectCallback:p,refreshBufferInterval:m}=t,[v,y]=_.useState(CM),[x,w]=_.useState(pv),k=_.useCallback(S=>{const{user:R,accessToken:C,organizationId:A=null,impersonator:D=null}=S,{role:T=null,permissions:P=[],feature_flags:O=[]}=Ey(C);w(L=>{const M=TM(Km({},L),{user:R,organizationId:A,role:T,permissions:P,featureFlags:O,impersonator:D});return Ave(L,M)?L:M}),u?.(S)},[v]);return _.useEffect(()=>{function S(){const R=setTimeout(()=>{_ve(e,{apiHostname:r,port:i,https:s,redirectUri:o,devMode:n,onRedirectCallback:p,onRefresh:k,onRefreshFailure:d,refreshBufferInterval:m}).then(C=>vg(this,null,function*(){const A=C.getUser();y({getAccessToken:C.getAccessToken.bind(C),getUser:C.getUser.bind(C),signIn:C.signIn.bind(C),signUp:C.signUp.bind(C),signOut:C.signOut.bind(C),switchToOrganization:C.switchToOrganization.bind(C)}),w(D=>TM(Km({},D),{isLoading:!1,user:A}))}))});return()=>{clearTimeout(R)}}return y(CM),w(pv),S()},[e,r,s,i,o,m]),_.createElement(aU.Provider,{value:Km(Km({},v),x)},c)}function Ave(t,e){var n,r,s,i,o,c;return((n=t.user)==null?void 0:n.updatedAt)===((r=e.user)==null?void 0:r.updatedAt)&&t.organizationId===e.organizationId&&t.role===e.role&&t.permissions.length===e.permissions.length&&t.permissions.every((u,d)=>u===e.permissions[d])&&t.featureFlags.length===e.featureFlags.length&&t.featureFlags.every((u,d)=>u===e.featureFlags[d])&&((s=t.impersonator)==null?void 0:s.email)===((i=e.impersonator)==null?void 0:i.email)&&((o=t.impersonator)==null?void 0:o.reason)===((c=e.impersonator)==null?void 0:c.reason)}var CM={signIn:()=>vg(void 0,null,function*(){}),signUp:()=>vg(void 0,null,function*(){}),getUser:()=>null,getAccessToken:()=>Promise.reject(new t1),switchToOrganization:()=>Promise.resolve(),signOut:()=>vg(void 0,null,function*(){})};function Nve(){const{isLoading:t}=KD(),{user:e,signIn:n,signOut:r}=oU();return t?h.jsx(Be,{variant:"outline",size:"sm",disabled:!0,children:"Loading..."}):e?h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-sm text-muted-foreground max-w-[160px] truncate",children:e?.email||e?.id}),h.jsx(Be,{variant:"outline",size:"sm",onClick:()=>{const s=window.location.origin,o=s.includes("://localhost")?s.replace("://localhost","://127.0.0.1"):s;r({returnTo:o})},children:"Sign out"})]}):h.jsx(Be,{variant:"outline",size:"sm",onClick:()=>n(),children:"Sign in"})}function jve(){_.useEffect(()=>{if(!window.isElectron||!window.electronAPI?.oauth)return;const t=e=>{console.log("Electron OAuth callback received:",e);try{const n=new URL(e),r=new URLSearchParams(n.search),s=r.get("code"),i=r.get("state"),o=r.get("error");if(o){console.error("OAuth error:",o);return}if(s){console.log("OAuth code received, redirecting to callback page");const c=new URL("/callback",window.location.origin);c.searchParams.set("code",s),i&&c.searchParams.set("state",i),window.location.href=c.toString()}}catch(n){console.error("Failed to parse OAuth callback URL:",n)}};return window.electronAPI.oauth.onCallback(t),()=>{window.electronAPI?.oauth&&window.electronAPI.oauth.removeCallback()}},[])}function Ove(){const[t,e]=_.useState("servers"),{isAuthenticated:n}=KD();jve();const r=_.useMemo(()=>window.location.pathname.startsWith("/oauth/callback/debug"),[]),s=_.useMemo(()=>window.location.pathname==="/callback",[]),{appState:i,isLoading:o,connectedServerConfigs:c,selectedMCPConfig:u,handleConnect:d,handleDisconnect:p,handleReconnect:m,handleUpdate:v,handleRemoveServer:y,setSelectedServer:x,toggleServerSelection:w,selectedMCPConfigsMap:k,setSelectedMultipleServersToAllServers:S}=Zge();_.useEffect(()=>{if(!n)return;const C=new AbortController;return fetch("/backend/ensureUser",{method:"POST",headers:{"Content-Type":"application/json"},signal:C.signal,credentials:"include"}).catch(()=>{}),()=>C.abort()},[n]);const R=C=>{e(C),C==="chat"&&S()};return r?h.jsx(oge,{}):s?(_.useEffect(()=>{const C=setTimeout(()=>{window.location.href="/"},5e3);return()=>clearTimeout(C)},[]),h.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center",children:h.jsxs("div",{className:"text-center",children:[h.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-primary mx-auto"}),h.jsx("p",{className:"mt-4 text-muted-foreground",children:"Completing sign in..."}),h.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:"If this takes too long, you'll be redirected automatically"})]})})):o?h.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center",children:h.jsxs("div",{className:"text-center",children:[h.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-primary mx-auto"}),h.jsx("p",{className:"mt-4 text-muted-foreground",children:"Loading..."})]})}):h.jsxs(rpe,{themeMode:"light",themePreset:"default",children:[h.jsxs(_ge,{defaultOpen:!0,children:[h.jsx(Ige,{onNavigate:R,activeTab:t}),h.jsxs(kge,{className:"flex flex-col",children:[h.jsx("header",{className:"flex h-12 shrink-0 items-center gap-2 border-b transition-[width,height] ease-linear drag",children:h.jsxs("div",{className:"flex w-full items-center justify-between px-4 lg:px-6",children:[h.jsx("div",{className:"flex items-center gap-1 lg:gap-2",children:h.jsx(Ege,{className:"-ml-1"})}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(Uge,{}),h.jsx(Nve,{})]})]})}),h.jsxs("div",{className:"flex-1",children:[(t==="tools"||t==="resources"||t==="prompts"||t==="auth"||t==="chat")&&h.jsx($ge,{connectedServerConfigs:c,selectedServer:i.selectedServer,onServerChange:x,onConnect:d,isMultiSelectEnabled:t==="chat",onMultiServerToggle:w,selectedMultipleServers:i.selectedMultipleServers}),t==="servers"&&h.jsx(RJ,{connectedServerConfigs:c,onConnect:d,onDisconnect:p,onReconnect:m,onUpdate:v,onRemove:y}),t==="tools"&&h.jsx(One,{serverConfig:u,serverName:i.selectedServer}),t==="tests"&&h.jsx(gpe,{serverConfig:u,serverConfigsMap:k,allServerConfigsMap:Object.fromEntries(Object.entries(c).filter(([,C])=>C.connectionStatus==="connected").map(([C,A])=>[C,A.config]))}),t==="resources"&&h.jsx(Pne,{serverConfig:u,serverName:i.selectedServer}),t==="prompts"&&h.jsx(Mne,{serverConfig:u,serverName:i.selectedServer}),t==="auth"&&h.jsx(age,{serverConfig:u,serverEntry:i.servers[i.selectedServer],serverName:i.selectedServer}),t==="chat"&&h.jsx(dpe,{serverConfigs:k}),t==="tracing"&&h.jsx(tge,{}),t==="settings"&&h.jsx(kpe,{})]})]})]}),h.jsx(Jge,{})]})}const Pve="phc_dTOPniyUNU2kD8Jx8yHMXSqiZHM8I91uWopTMX6EBE9",Mve="https://us.i.posthog.com",Dve={api_host:Mve,capture_pageview:!1},Ive=()=>Pve,Lve=()=>Dve;var ye=typeof window<"u"?window:void 0,ds=typeof globalThis<"u"?globalThis:ye,lU=Array.prototype,RM=lU.forEach,AM=lU.indexOf,Ns=ds?.navigator,Ue=ds?.document,ls=ds?.location,s1=ds?.fetch,i1=ds!=null&&ds.XMLHttpRequest&&"withCredentials"in new ds.XMLHttpRequest?ds.XMLHttpRequest:void 0,NM=ds?.AbortController,os=Ns?.userAgent,bt=ye??{},Ea={DEBUG:!1,LIB_VERSION:"1.260.3"};function Fe(){return Fe=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Fe.apply(null,arguments)}function cU(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var zve=["$snapshot","$pageview","$pageleave","$set","survey dismissed","survey sent","survey shown","$identify","$groupidentify","$create_alias","$$client_ingestion_warning","$web_experiment_applied","$feature_enrollment_update","$feature_flag_called"];function It(t,e){return t.indexOf(e)!==-1}var ky=function(t){return t.trim()},a1=function(t){return t.replace(/^\$/,"")},$ve=Array.isArray,uU=Object.prototype,dU=uU.hasOwnProperty,Ty=uU.toString,kn=$ve||function(t){return Ty.call(t)==="[object Array]"},Zs=t=>typeof t=="function",Bn=t=>t===Object(t)&&!kn(t),hu=t=>{if(Bn(t)){for(var e in t)if(dU.call(t,e))return!1;return!0}return!1},Me=t=>t===void 0,qn=t=>Ty.call(t)=="[object String]",o1=t=>qn(t)&&t.trim().length===0,Ko=t=>t===null,Zt=t=>Me(t)||Ko(t),Ir=t=>Ty.call(t)=="[object Number]",$i=t=>Ty.call(t)==="[object Boolean]",Fve=t=>t instanceof FormData,Uve=t=>It(zve,t);function js(t,e,n,r,s){return e>n&&(r.warn("min cannot be greater than max."),e=n),Ir(t)?t>n?(r.warn(" cannot be greater than max: "+n+". Using max value instead."),n):t<e?(r.warn(" cannot be less than min: "+e+". Using min value instead."),e):t:(r.warn(" must be a number. using max or fallback. max: "+n+", fallback: "+s),js(s||n,e,n,r))}class fU{constructor(e){this.t=e,this.i={},this.o=()=>{Object.keys(this.i).forEach(n=>{var r=this.h(n)+this.m;r>=this.S?delete this.i[n]:this.$(n,r)})},this.h=n=>this.i[String(n)],this.$=(n,r)=>{this.i[String(n)]=r},this.consumeRateLimit=n=>{var r,s=(r=this.h(n))!=null?r:this.S;if((s=Math.max(s-1,0))===0)return!0;this.$(n,s);var i,o=s===0;return o&&((i=this.k)==null||i.call(this,n)),o},this.k=this.t.k,this.S=js(this.t.bucketSize,0,100,this.t.I),this.m=js(this.t.refillRate,0,this.S,this.t.I),this.P=js(this.t.refillInterval,0,864e5,this.t.I),setInterval(()=>{this.o()},this.P)}}var hU=t=>{var e={R:function(n){if(ye&&(Ea.DEBUG||bt.POSTHOG_DEBUG)&&!Me(ye.console)&&ye.console){for(var r=("__rrweb_original__"in ye.console[n])?ye.console[n].__rrweb_original__:ye.console[n],s=arguments.length,i=new Array(s>1?s-1:0),o=1;o<s;o++)i[o-1]=arguments[o];r(t,...i)}},info:function(){for(var n=arguments.length,r=new Array(n),s=0;s<n;s++)r[s]=arguments[s];e.R("log",...r)},warn:function(){for(var n=arguments.length,r=new Array(n),s=0;s<n;s++)r[s]=arguments[s];e.R("warn",...r)},error:function(){for(var n=arguments.length,r=new Array(n),s=0;s<n;s++)r[s]=arguments[s];e.R("error",...r)},critical:function(){for(var n=arguments.length,r=new Array(n),s=0;s<n;s++)r[s]=arguments[s];console.error(t,...r)},uninitializedWarning:n=>{e.error("You must initialize PostHog before calling "+n)},createLogger:n=>hU(t+" "+n)};return e},$e=hU("[PostHog.js]"),br=$e.createLogger,Vve=br("[ExternalScriptsLoader]"),jM=(t,e,n)=>{if(t.config.disable_external_dependency_loading)return Vve.warn(e+" was requested but loading of external scripts is disabled."),n("Loading of external scripts is disabled");var r=Ue?.querySelectorAll("script");if(r){for(var s=0;s<r.length;s++)if(r[s].src===e)return n()}var i=()=>{if(!Ue)return n("document not found");var o=Ue.createElement("script");if(o.type="text/javascript",o.crossOrigin="anonymous",o.src=e,o.onload=d=>n(void 0,d),o.onerror=d=>n(d),t.config.prepare_external_dependency_script&&(o=t.config.prepare_external_dependency_script(o)),!o)return n("prepare_external_dependency_script returned null");var c,u=Ue.querySelectorAll("body > script");u.length>0?(c=u[0].parentNode)==null||c.insertBefore(o,u[0]):Ue.body.appendChild(o)};Ue!=null&&Ue.body?i():Ue?.addEventListener("DOMContentLoaded",i)};bt.__PosthogExtensions__=bt.__PosthogExtensions__||{},bt.__PosthogExtensions__.loadExternalDependency=(t,e,n)=>{var r="/static/"+e+".js?v="+t.version;if(e==="remote-config"&&(r="/array/"+t.config.token+"/config.js"),e==="toolbar"){var s=3e5;r=r+"&t="+Math.floor(Date.now()/s)*s}var i=t.requestRouter.endpointFor("assets",r);jM(t,i,n)},bt.__PosthogExtensions__.loadSiteApp=(t,e,n)=>{var r=t.requestRouter.endpointFor("api",e);jM(t,r,n)};var mv={};function Ao(t,e,n){if(kn(t)){if(RM&&t.forEach===RM)t.forEach(e,n);else if("length"in t&&t.length===+t.length){for(var r=0,s=t.length;r<s;r++)if(r in t&&e.call(n,t[r],r)===mv)return}}}function mn(t,e,n){if(!Zt(t)){if(kn(t))return Ao(t,e,n);if(Fve(t)){for(var r of t.entries())if(e.call(n,r[1],r[0])===mv)return}else for(var s in t)if(dU.call(t,s)&&e.call(n,t[s],s)===mv)return}}var Xn=function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return Ao(n,function(s){for(var i in s)s[i]!==void 0&&(t[i]=s[i])}),t},Cy=function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return Ao(n,function(s){Ao(s,function(i){t.push(i)})}),t};function yg(t){for(var e=Object.keys(t),n=e.length,r=new Array(n);n--;)r[n]=[e[n],t[e[n]]];return r}var OM=function(t){try{return t()}catch{return}},Bve=function(t){return function(){try{for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return t.apply(this,n)}catch(s){$e.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),$e.critical(s)}}},hT=function(t){var e={};return mn(t,function(n,r){(qn(n)&&n.length>0||Ir(n))&&(e[r]=n)}),e};function qve(t,e){return n=t,r=i=>qn(i)&&!Ko(e)?i.slice(0,e):i,s=new Set,function i(o,c){return o!==Object(o)?r?r(o,c):o:s.has(o)?void 0:(s.add(o),kn(o)?(u=[],Ao(o,d=>{u.push(i(d))})):(u={},mn(o,(d,p)=>{s.has(d)||(u[p]=i(d,p))})),u);var u}(n);var n,r,s}var Hve=["herokuapp.com","vercel.app","netlify.app"];function Gve(t){var e=t?.hostname;if(!qn(e))return!1;var n=e.split(".").slice(-2).join(".");for(var r of Hve)if(n===r)return!1;return!0}function pU(t,e){for(var n=0;n<t.length;n++)if(e(t[n]))return t[n]}function In(t,e,n,r){var{capture:s=!1,passive:i=!0}=r??{};t?.addEventListener(e,n,{capture:s,passive:i})}var mU="$people_distinct_id",$f="__alias",Ff="__timers",PM="$autocapture_disabled_server_side",l1="$heatmaps_enabled_server_side",MM="$exception_capture_enabled_server_side",c1="$error_tracking_suppression_rules",DM="$error_tracking_capture_extension_exceptions",IM="$web_vitals_enabled_server_side",gU="$dead_clicks_enabled_server_side",LM="$web_vitals_allowed_metrics",u1="$session_recording_enabled_server_side",zM="$console_log_recording_enabled_server_side",$M="$session_recording_network_payload_capture",FM="$session_recording_masking",UM="$session_recording_canvas_recording",VM="$replay_sample_rate",BM="$replay_minimum_duration",qM="$replay_script_config",gv="$sesid",Uf="$session_is_sampled",d1="$session_recording_url_trigger_activated_session",f1="$session_recording_event_trigger_activated_session",pu="$enabled_feature_flags",Vf="$early_access_features",h1="$feature_flag_details",Bf="$stored_person_properties",Tl="$stored_group_properties",p1="$surveys",Qm="$surveys_activated",vv="$flag_call_reported",wa="$user_state",m1="$client_session_props",g1="$capture_rate_limit",v1="$initial_campaign_params",y1="$initial_referrer_info",yv="$initial_person_info",xv="$epp",vU="__POSTHOG_TOOLBAR__",bf="$posthog_cookieless",Yve=[mU,$f,"__cmpns",Ff,u1,l1,gv,pu,c1,wa,Vf,h1,Tl,Bf,p1,vv,m1,g1,v1,y1,xv,yv];function HM(t){return t instanceof Element&&(t.id===vU||!(t.closest==null||!t.closest(".toolbar-global-fade-container")))}function Ry(t){return!!t&&t.nodeType===1}function No(t,e){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===e.toLowerCase()}function yU(t){return!!t&&t.nodeType===3}function xU(t){return!!t&&t.nodeType===11}function pT(t){return t?ky(t).split(/\s+/):[]}function GM(t){var e=ye?.location.href;return!!(e&&t&&t.some(n=>e.match(n)))}function bv(t){var e="";switch(typeof t.className){case"string":e=t.className;break;case"object":e=(t.className&&"baseVal"in t.className?t.className.baseVal:null)||t.getAttribute("class")||"";break;default:e=""}return pT(e)}function bU(t){return Zt(t)?null:ky(t).split(/(\s+)/).filter(e=>Hu(e)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Ay(t){var e="";return b1(t)&&!SU(t)&&t.childNodes&&t.childNodes.length&&mn(t.childNodes,function(n){var r;yU(n)&&n.textContent&&(e+=(r=bU(n.textContent))!==null&&r!==void 0?r:"")}),ky(e)}function wU(t){return Me(t.target)?t.srcElement||null:(e=t.target)!=null&&e.shadowRoot?t.composedPath()[0]||null:t.target||null;var e}var x1=["a","button","form","input","select","textarea","label"];function _U(t){var e=t.parentNode;return!(!e||!Ry(e))&&e}function Wve(t,e,n,r,s){var i,o,c;if(n===void 0&&(n=void 0),!ye||!t||No(t,"html")||!Ry(t)||(i=n)!=null&&i.url_allowlist&&!GM(n.url_allowlist)||(o=n)!=null&&o.url_ignorelist&&GM(n.url_ignorelist))return!1;if((c=n)!=null&&c.dom_event_allowlist){var u=n.dom_event_allowlist;if(u&&!u.some(k=>e.type===k))return!1}for(var d=!1,p=[t],m=!0,v=t;v.parentNode&&!No(v,"body");)if(xU(v.parentNode))p.push(v.parentNode.host),v=v.parentNode.host;else{if(!(m=_U(v)))break;if(r||x1.indexOf(m.tagName.toLowerCase())>-1)d=!0;else{var y=ye.getComputedStyle(m);y&&y.getPropertyValue("cursor")==="pointer"&&(d=!0)}p.push(m),v=m}if(!function(k,S){var R=S?.element_allowlist;if(Me(R))return!0;var C,A=function(T){if(R.some(P=>T.tagName.toLowerCase()===P))return{v:!0}};for(var D of k)if(C=A(D))return C.v;return!1}(p,n)||!function(k,S){var R=S?.css_selector_allowlist;if(Me(R))return!0;var C,A=function(T){if(R.some(P=>T.matches(P)))return{v:!0}};for(var D of k)if(C=A(D))return C.v;return!1}(p,n))return!1;var x=ye.getComputedStyle(t);if(x&&x.getPropertyValue("cursor")==="pointer"&&e.type==="click")return!0;var w=t.tagName.toLowerCase();switch(w){case"html":return!1;case"form":return(s||["submit"]).indexOf(e.type)>=0;case"input":case"select":case"textarea":return(s||["change","click"]).indexOf(e.type)>=0;default:return d?(s||["click"]).indexOf(e.type)>=0:(s||["click"]).indexOf(e.type)>=0&&(x1.indexOf(w)>-1||t.getAttribute("contenteditable")==="true")}}function b1(t){for(var e=t;e.parentNode&&!No(e,"body");e=e.parentNode){var n=bv(e);if(It(n,"ph-sensitive")||It(n,"ph-no-capture"))return!1}if(It(bv(t),"ph-include"))return!0;var r=t.type||"";if(qn(r))switch(r.toLowerCase()){case"hidden":case"password":return!1}var s=t.name||t.id||"";return!(qn(s)&&/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(s.replace(/[^a-zA-Z0-9]/g,"")))}function SU(t){return!!(No(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||No(t,"select")||No(t,"textarea")||t.getAttribute("contenteditable")==="true")}var EU="(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11})",Kve=new RegExp("^(?:"+EU+")$"),Qve=new RegExp(EU),kU="\\d{3}-?\\d{2}-?\\d{4}",Xve=new RegExp("^("+kU+")$"),Zve=new RegExp("("+kU+")");function Hu(t,e){return e===void 0&&(e=!0),!(Zt(t)||qn(t)&&(t=ky(t),(e?Kve:Qve).test((t||"").replace(/[- ]/g,""))||(e?Xve:Zve).test(t)))}function TU(t){var e=Ay(t);return Hu(e=(e+" "+CU(t)).trim())?e:""}function CU(t){var e="";return t&&t.childNodes&&t.childNodes.length&&mn(t.childNodes,function(n){var r;if(n&&((r=n.tagName)==null?void 0:r.toLowerCase())==="span")try{var s=Ay(n);e=(e+" "+s).trim(),n.childNodes&&n.childNodes.length&&(e=(e+" "+CU(n)).trim())}catch(i){$e.error("[AutoCapture]",i)}}),e}function Jve(t){return function(e){var n=e.map(r=>{var s,i,o="";if(r.tag_name&&(o+=r.tag_name),r.attr_class)for(var c of(r.attr_class.sort(),r.attr_class))o+="."+c.replace(/"/g,"");var u=Fe({},r.text?{text:r.text}:{},{"nth-child":(s=r.nth_child)!==null&&s!==void 0?s:0,"nth-of-type":(i=r.nth_of_type)!==null&&i!==void 0?i:0},r.href?{href:r.href}:{},r.attr_id?{attr_id:r.attr_id}:{},r.attributes),d={};return yg(u).sort((p,m)=>{var[v]=p,[y]=m;return v.localeCompare(y)}).forEach(p=>{var[m,v]=p;return d[YM(m.toString())]=YM(v.toString())}),o+=":",o+=yg(d).map(p=>{var[m,v]=p;return m+'="'+v+'"'}).join("")});return n.join(";")}(function(e){return e.map(n=>{var r,s,i={text:(r=n.$el_text)==null?void 0:r.slice(0,400),tag_name:n.tag_name,href:(s=n.attr__href)==null?void 0:s.slice(0,2048),attr_class:eye(n),attr_id:n.attr__id,nth_child:n.nth_child,nth_of_type:n.nth_of_type,attributes:{}};return yg(n).filter(o=>{var[c]=o;return c.indexOf("attr__")===0}).forEach(o=>{var[c,u]=o;return i.attributes[c]=u}),i})}(t))}function YM(t){return t.replace(/"|\\"/g,'\\"')}function eye(t){var e=t.attr__class;return e?kn(e)?e:pT(e):void 0}class RU{constructor(){this.clicks=[]}isRageClick(e,n,r){var s=this.clicks[this.clicks.length-1];if(s&&Math.abs(e-s.x)+Math.abs(n-s.y)<30&&r-s.timestamp<1e3){if(this.clicks.push({x:e,y:n,timestamp:r}),this.clicks.length===3)return!0}else this.clicks=[{x:e,y:n,timestamp:r}];return!1}}var Uw="$copy_autocapture",Ta=function(t){return t.GZipJS="gzip-js",t.Base64="base64",t}({}),tye=["fatal","error","warning","log","info","debug"],nye=["localhost","127.0.0.1"],Gu=t=>{var e=Ue?.createElement("a");return Me(e)?null:(e.href=t,e)},rye=function(t,e){var n,r;e===void 0&&(e="&");var s=[];return mn(t,function(i,o){Me(i)||Me(o)||o==="undefined"||(n=encodeURIComponent((c=>c instanceof File)(i)?i.name:i.toString()),r=encodeURIComponent(o),s[s.length]=r+"="+n)}),s.join(e)},wv=function(t,e){for(var n,r=((t.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),s=0;s<r.length;s++){var i=r[s].split("=");if(i[0]===e){n=i;break}}if(!kn(n)||n.length<2)return"";var o=n[1];try{o=decodeURIComponent(o)}catch{$e.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},mT=function(t,e,n){if(!t||!e||!e.length)return t;for(var r=t.split("#"),s=r[0]||"",i=r[1],o=s.split("?"),c=o[1],u=o[0],d=(c||"").split("&"),p=[],m=0;m<d.length;m++){var v=d[m].split("=");kn(v)&&(e.includes(v[0])?p.push(v[0]+"="+n):p.push(d[m]))}var y=u;return c!=null&&(y+="?"+p.join("&")),i!=null&&(y+="#"+i),y},_v=function(t,e){var n=t.match(new RegExp(e+"=([^&]*)"));return n?n[1]:null},WM=br("[AutoCapture]");function Vw(t,e){return e.length>t?e.slice(0,t)+"...":e}function sye(t){if(t.previousElementSibling)return t.previousElementSibling;var e=t;do e=e.previousSibling;while(e&&!Ry(e));return e}function iye(t,e,n,r){var s=t.tagName.toLowerCase(),i={tag_name:s};x1.indexOf(s)>-1&&!n&&(s.toLowerCase()==="a"||s.toLowerCase()==="button"?i.$el_text=Vw(1024,TU(t)):i.$el_text=Vw(1024,Ay(t)));var o=bv(t);o.length>0&&(i.classes=o.filter(function(p){return p!==""})),mn(t.attributes,function(p){var m;if((!SU(t)||["name","id","class","aria-label"].indexOf(p.name)!==-1)&&(r==null||!r.includes(p.name))&&!e&&Hu(p.value)&&(m=p.name,!qn(m)||m.substring(0,10)!=="_ngcontent"&&m.substring(0,7)!=="_nghost")){var v=p.value;p.name==="class"&&(v=pT(v).join(" ")),i["attr__"+p.name]=Vw(1024,v)}});for(var c=1,u=1,d=t;d=sye(d);)c++,d.tagName===t.tagName&&u++;return i.nth_child=c,i.nth_of_type=u,i}function aye(t,e){for(var n,r,{e:s,maskAllElementAttributes:i,maskAllText:o,elementAttributeIgnoreList:c,elementsChainAsString:u}=e,d=[t],p=t;p.parentNode&&!No(p,"body");)xU(p.parentNode)?(d.push(p.parentNode.host),p=p.parentNode.host):(d.push(p.parentNode),p=p.parentNode);var m,v=[],y={},x=!1,w=!1;if(mn(d,A=>{var D=b1(A);A.tagName.toLowerCase()==="a"&&(x=A.getAttribute("href"),x=D&&x&&Hu(x)&&x),It(bv(A),"ph-no-capture")&&(w=!0),v.push(iye(A,i,o,c));var T=function(P){if(!b1(P))return{};var O={};return mn(P.attributes,function(L){if(L.name&&L.name.indexOf("data-ph-capture-attribute")===0){var M=L.name.replace("data-ph-capture-attribute-",""),$=L.value;M&&$&&Hu($)&&(O[M]=$)}}),O}(A);Xn(y,T)}),w)return{props:{},explicitNoCapture:w};if(o||(t.tagName.toLowerCase()==="a"||t.tagName.toLowerCase()==="button"?v[0].$el_text=TU(t):v[0].$el_text=Ay(t)),x){var k,S;v[0].attr__href=x;var R=(k=Gu(x))==null?void 0:k.host,C=ye==null||(S=ye.location)==null?void 0:S.host;R&&C&&R!==C&&(m=x)}return{props:Xn({$event_type:s.type,$ce_version:1},u?{}:{$elements:v},{$elements_chain:Jve(v)},(n=v[0])!=null&&n.$el_text?{$el_text:(r=v[0])==null?void 0:r.$el_text}:{},m&&s.type==="click"?{$external_click_url:m}:{},y)}}class oye{constructor(e){this.T=!1,this.C=null,this.rageclicks=new RU,this.M=!1,this.instance=e,this.F=null}get O(){var e,n,r=Bn(this.instance.config.autocapture)?this.instance.config.autocapture:{};return r.url_allowlist=(e=r.url_allowlist)==null?void 0:e.map(s=>new RegExp(s)),r.url_ignorelist=(n=r.url_ignorelist)==null?void 0:n.map(s=>new RegExp(s)),r}A(){if(this.isBrowserSupported()){if(ye&&Ue){var e=r=>{r=r||ye?.event;try{this.D(r)}catch(s){WM.error("Failed to capture event",s)}};if(In(Ue,"submit",e,{capture:!0}),In(Ue,"change",e,{capture:!0}),In(Ue,"click",e,{capture:!0}),this.O.capture_copied_text){var n=r=>{r=r||ye?.event,this.D(r,Uw)};In(Ue,"copy",n,{capture:!0}),In(Ue,"cut",n,{capture:!0})}}}else WM.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this.T&&(this.A(),this.T=!0)}onRemoteConfig(e){e.elementsChainAsString&&(this.M=e.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[PM]:!!e.autocapture_opt_out}),this.C=!!e.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(e){this.F=e}getElementSelectors(e){var n,r=[];return(n=this.F)==null||n.forEach(s=>{var i=Ue?.querySelectorAll(s);i?.forEach(o=>{e===o&&r.push(s)})}),r}get isEnabled(){var e,n,r=(e=this.instance.persistence)==null?void 0:e.props[PM],s=this.C;if(Ko(s)&&!$i(r)&&!this.instance.j())return!1;var i=(n=this.C)!==null&&n!==void 0?n:!!r;return!!this.instance.config.autocapture&&!i}D(e,n){if(n===void 0&&(n="$autocapture"),this.isEnabled){var r,s=wU(e);yU(s)&&(s=s.parentNode||null),n==="$autocapture"&&e.type==="click"&&e instanceof MouseEvent&&this.instance.config.rageclick&&(r=this.rageclicks)!=null&&r.isRageClick(e.clientX,e.clientY,new Date().getTime())&&this.D(e,"$rageclick");var i=n===Uw;if(s&&Wve(s,e,this.O,i,i?["copy","cut"]:void 0)){var{props:o,explicitNoCapture:c}=aye(s,{e,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.O.element_attribute_ignorelist,elementsChainAsString:this.M});if(c)return!1;var u=this.getElementSelectors(s);if(u&&u.length>0&&(o.$element_selectors=u),n===Uw){var d,p=bU(ye==null||(d=ye.getSelection())==null?void 0:d.toString()),m=e.type||"clipboard";if(!p)return!1;o.$selected_content=p,o.$copy_type=m}return this.instance.capture(n,o),!0}}}isBrowserSupported(){return Zs(Ue?.querySelectorAll)}}Math.trunc||(Math.trunc=function(t){return t<0?Math.ceil(t):Math.floor(t)}),Number.isInteger||(Number.isInteger=function(t){return Ir(t)&&isFinite(t)&&Math.floor(t)===t});var KM="0123456789abcdef";class Sv{constructor(e){if(this.bytes=e,e.length!==16)throw new TypeError("not 128-bit length")}static fromFieldsV7(e,n,r,s){if(!Number.isInteger(e)||!Number.isInteger(n)||!Number.isInteger(r)||!Number.isInteger(s)||e<0||n<0||r<0||s<0||e>0xffffffffffff||n>4095||r>1073741823||s>4294967295)throw new RangeError("invalid field value");var i=new Uint8Array(16);return i[0]=e/Math.pow(2,40),i[1]=e/Math.pow(2,32),i[2]=e/Math.pow(2,24),i[3]=e/Math.pow(2,16),i[4]=e/Math.pow(2,8),i[5]=e,i[6]=112|n>>>8,i[7]=n,i[8]=128|r>>>24,i[9]=r>>>16,i[10]=r>>>8,i[11]=r,i[12]=s>>>24,i[13]=s>>>16,i[14]=s>>>8,i[15]=s,new Sv(i)}toString(){for(var e="",n=0;n<this.bytes.length;n++)e=e+KM.charAt(this.bytes[n]>>>4)+KM.charAt(15&this.bytes[n]),n!==3&&n!==5&&n!==7&&n!==9||(e+="-");if(e.length!==36)throw new Error("Invalid UUIDv7 was generated");return e}clone(){return new Sv(this.bytes.slice(0))}equals(e){return this.compareTo(e)===0}compareTo(e){for(var n=0;n<16;n++){var r=this.bytes[n]-e.bytes[n];if(r!==0)return Math.sign(r)}return 0}}class lye{constructor(){this.L=0,this.N=0,this.U=new cye}generate(){var e=this.generateOrAbort();if(Me(e)){this.L=0;var n=this.generateOrAbort();if(Me(n))throw new Error("Could not generate UUID after timestamp reset");return n}return e}generateOrAbort(){var e=Date.now();if(e>this.L)this.L=e,this.q();else{if(!(e+1e4>this.L))return;this.N++,this.N>4398046511103&&(this.L++,this.q())}return Sv.fromFieldsV7(this.L,Math.trunc(this.N/Math.pow(2,30)),this.N&Math.pow(2,30)-1,this.U.nextUint32())}q(){this.N=1024*this.U.nextUint32()+(1023&this.U.nextUint32())}}var QM,AU=t=>{if(typeof UUIDV7_DENY_WEAK_RNG<"u"&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var e=0;e<t.length;e++)t[e]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return t};ye&&!Me(ye.crypto)&&crypto.getRandomValues&&(AU=t=>crypto.getRandomValues(t));class cye{constructor(){this.B=new Uint32Array(8),this.H=1/0}nextUint32(){return this.H>=this.B.length&&(AU(this.B),this.H=0),this.B[this.H++]}}var Eo=()=>uye().toString(),uye=()=>(QM||(QM=new lye)).generate(),wf="",dye=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;function fye(t,e){if(e){var n=function(s,i){if(i===void 0&&(i=Ue),wf)return wf;if(!i||["localhost","127.0.0.1"].includes(s))return"";for(var o=s.split("."),c=Math.min(o.length,8),u="dmn_chk_"+Eo();!wf&&c--;){var d=o.slice(c).join("."),p=u+"=1;domain=."+d+";path=/";i.cookie=p+";max-age=3",i.cookie.includes(u)&&(i.cookie=p+";max-age=0",wf=d)}return wf}(t);if(!n){var r=(s=>{var i=s.match(dye);return i?i[0]:""})(t);r!==n&&$e.info("Warning: cookie subdomain discovery mismatch",r,n),n=r}return n?"; domain=."+n:""}return""}var Yi={W:()=>!!Ue,G:function(t){$e.error("cookieStore error: "+t)},J:function(t){if(Ue){try{for(var e=t+"=",n=Ue.cookie.split(";").filter(i=>i.length),r=0;r<n.length;r++){for(var s=n[r];s.charAt(0)==" ";)s=s.substring(1,s.length);if(s.indexOf(e)===0)return decodeURIComponent(s.substring(e.length,s.length))}}catch{}return null}},V:function(t){var e;try{e=JSON.parse(Yi.J(t))||{}}catch{}return e},K:function(t,e,n,r,s){if(Ue)try{var i="",o="",c=fye(Ue.location.hostname,r);if(n){var u=new Date;u.setTime(u.getTime()+24*n*60*60*1e3),i="; expires="+u.toUTCString()}s&&(o="; secure");var d=t+"="+encodeURIComponent(JSON.stringify(e))+i+"; SameSite=Lax; path=/"+c+o;return d.length>3686.4&&$e.warn("cookieStore warning: large cookie, len="+d.length),Ue.cookie=d,d}catch{return}},Y:function(t,e){if(Ue!=null&&Ue.cookie)try{Yi.K(t,"",-1,e)}catch{return}}},Bw=null,dr={W:function(){if(!Ko(Bw))return Bw;var t=!0;if(Me(ye))t=!1;else try{var e="__mplssupport__";dr.K(e,"xyz"),dr.J(e)!=='"xyz"'&&(t=!1),dr.Y(e)}catch{t=!1}return t||$e.error("localStorage unsupported; falling back to cookie store"),Bw=t,t},G:function(t){$e.error("localStorage error: "+t)},J:function(t){try{return ye?.localStorage.getItem(t)}catch(e){dr.G(e)}return null},V:function(t){try{return JSON.parse(dr.J(t))||{}}catch{}return null},K:function(t,e){try{ye?.localStorage.setItem(t,JSON.stringify(e))}catch(n){dr.G(n)}},Y:function(t){try{ye?.localStorage.removeItem(t)}catch(e){dr.G(e)}}},hye=["distinct_id",gv,Uf,xv,yv],Xm=Fe({},dr,{V:function(t){try{var e={};try{e=Yi.V(t)||{}}catch{}var n=Xn(e,JSON.parse(dr.J(t)||"{}"));return dr.K(t,n),n}catch{}return null},K:function(t,e,n,r,s,i){try{dr.K(t,e,void 0,void 0,i);var o={};hye.forEach(c=>{e[c]&&(o[c]=e[c])}),Object.keys(o).length&&Yi.K(t,o,n,r,s,i)}catch(c){dr.G(c)}},Y:function(t,e){try{ye?.localStorage.removeItem(t),Yi.Y(t,e)}catch(n){dr.G(n)}}}),Zm={},pye={W:function(){return!0},G:function(t){$e.error("memoryStorage error: "+t)},J:function(t){return Zm[t]||null},V:function(t){return Zm[t]||null},K:function(t,e){Zm[t]=e},Y:function(t){delete Zm[t]}},xl=null,Rr={W:function(){if(!Ko(xl))return xl;if(xl=!0,Me(ye))xl=!1;else try{var t="__support__";Rr.K(t,"xyz"),Rr.J(t)!=='"xyz"'&&(xl=!1),Rr.Y(t)}catch{xl=!1}return xl},G:function(t){$e.error("sessionStorage error: ",t)},J:function(t){try{return ye?.sessionStorage.getItem(t)}catch(e){Rr.G(e)}return null},V:function(t){try{return JSON.parse(Rr.J(t))||null}catch{}return null},K:function(t,e){try{ye?.sessionStorage.setItem(t,JSON.stringify(e))}catch(n){Rr.G(n)}},Y:function(t){try{ye?.sessionStorage.removeItem(t)}catch(e){Rr.G(e)}}},bl=function(t){return t[t.PENDING=-1]="PENDING",t[t.DENIED=0]="DENIED",t[t.GRANTED=1]="GRANTED",t}({});class mye{constructor(e){this._instance=e}get O(){return this._instance.config}get consent(){return this.X()?bl.DENIED:this.Z}isOptedOut(){return this.O.cookieless_mode==="always"||this.consent===bl.DENIED||this.consent===bl.PENDING&&(this.O.opt_out_capturing_by_default||this.O.cookieless_mode==="on_reject")}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===bl.DENIED}optInOut(e){this.tt.K(this.it,e?1:0,this.O.cookie_expiration,this.O.cross_subdomain_cookie,this.O.secure_cookie)}reset(){this.tt.Y(this.it,this.O.cross_subdomain_cookie)}get it(){var{token:e,opt_out_capturing_cookie_prefix:n,consent_persistence_name:r}=this._instance.config;return r||(n?n+e:"__ph_opt_in_out_"+e)}get Z(){var e=this.tt.J(this.it);return e==="1"?bl.GRANTED:e==="0"?bl.DENIED:bl.PENDING}get tt(){if(!this.et){var e=this.O.opt_out_capturing_persistence_type;this.et=e==="localStorage"?dr:Yi;var n=e==="localStorage"?Yi:dr;n.J(this.it)&&(this.et.J(this.it)||this.optInOut(n.J(this.it)==="1"),n.Y(this.it,this.O.cross_subdomain_cookie))}return this.et}X(){return!!this.O.respect_dnt&&!!pU([Ns?.doNotTrack,Ns?.msDoNotTrack,bt.doNotTrack],e=>It([!0,1,"1","yes"],e))}}var Jm=br("[Dead Clicks]"),gye=()=>!0,vye=t=>{var e,n=!((e=t.instance.persistence)==null||!e.get_property(gU)),r=t.instance.config.capture_dead_clicks;return $i(r)?r:n};class NU{get lazyLoadedDeadClicksAutocapture(){return this.rt}constructor(e,n,r){this.instance=e,this.isEnabled=n,this.onCapture=r,this.startIfEnabled()}onRemoteConfig(e){this.instance.persistence&&this.instance.persistence.register({[gU]:e?.captureDeadClicks}),this.startIfEnabled()}startIfEnabled(){this.isEnabled(this)&&this.st(()=>{this.nt()})}st(e){var n,r;(n=bt.__PosthogExtensions__)!=null&&n.initDeadClicksAutocapture&&e(),(r=bt.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this.instance,"dead-clicks-autocapture",s=>{s?Jm.error("failed to load script",s):e()})}nt(){var e;if(Ue){if(!this.rt&&(e=bt.__PosthogExtensions__)!=null&&e.initDeadClicksAutocapture){var n=Bn(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};n.__onCapture=this.onCapture,this.rt=bt.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,n),this.rt.start(Ue),Jm.info("starting...")}}else Jm.error("`document` not found. Cannot start.")}stop(){this.rt&&(this.rt.stop(),this.rt=void 0,Jm.info("stopping..."))}}var _f=br("[ExceptionAutocapture]");class yye{constructor(e){var n,r,s;this.ot=()=>{var i;if(ye&&this.isEnabled&&(i=bt.__PosthogExtensions__)!=null&&i.errorWrappingFunctions){var o=bt.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,c=bt.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,u=bt.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.lt&&this.O.capture_unhandled_errors&&(this.lt=o(this.captureException.bind(this))),!this.ut&&this.O.capture_unhandled_rejections&&(this.ut=c(this.captureException.bind(this))),!this.ht&&this.O.capture_console_errors&&(this.ht=u(this.captureException.bind(this)))}catch(d){_f.error("failed to start",d),this.dt()}}},this._instance=e,this.vt=!((n=this._instance.persistence)==null||!n.props[MM]),this.O=this.ct(),this.ft=new fU({refillRate:(r=this._instance.config.error_tracking.__exceptionRateLimiterRefillRate)!==null&&r!==void 0?r:1,bucketSize:(s=this._instance.config.error_tracking.__exceptionRateLimiterBucketSize)!==null&&s!==void 0?s:10,refillInterval:1e4,I:_f}),this.startIfEnabled()}ct(){var e=this._instance.config.capture_exceptions,n={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return Bn(e)?n=Fe({},n,e):(Me(e)?this.vt:e)&&(n=Fe({},n,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),n}get isEnabled(){return this.O.capture_console_errors||this.O.capture_unhandled_errors||this.O.capture_unhandled_rejections}startIfEnabled(){this.isEnabled&&(_f.info("enabled"),this.st(this.ot))}st(e){var n,r;(n=bt.__PosthogExtensions__)!=null&&n.errorWrappingFunctions&&e(),(r=bt.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,"exception-autocapture",s=>{if(s)return _f.error("failed to load script",s);e()})}dt(){var e,n,r;(e=this.lt)==null||e.call(this),this.lt=void 0,(n=this.ut)==null||n.call(this),this.ut=void 0,(r=this.ht)==null||r.call(this),this.ht=void 0}onRemoteConfig(e){var n=e.autocaptureExceptions;this.vt=!!n||!1,this.O=this.ct(),this._instance.persistence&&this._instance.persistence.register({[MM]:this.vt}),this.startIfEnabled()}captureException(e){var n,r=this._instance.requestRouter.endpointFor("ui");e.$exception_personURL=r+"/project/"+this._instance.config.token+"/person/"+this._instance.get_distinct_id();var s=(n=e.$exception_list[0].type)!==null&&n!==void 0?n:"Exception";this.ft.consumeRateLimit(s)?_f.info("Skipping exception capture because of client rate limiting.",{exception:e.$exception_list[0].type}):this._instance.exceptions.sendExceptionEvent(e)}}function jU(t){return!Me(Event)&&OU(t,Event)}function OU(t,e){try{return t instanceof e}catch{return!1}}function PU(t){switch(Object.prototype.toString.call(t)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object DOMError]":return!0;default:return OU(t,Error)}}function xg(t,e){return Object.prototype.toString.call(t)==="[object "+e+"]"}function qw(t){return xg(t,"DOMError")}var XM=/\(error: (.*)\)/,ZM=50,mu="?";function Hw(t,e,n,r){var s={platform:"web:javascript",filename:t,function:e==="<anonymous>"?mu:e,in_app:!0};return Me(n)||(s.lineno=n),Me(r)||(s.colno=r),s}var xye=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,bye=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,wye=/\((\S*)(?::(\d+))(?::(\d+))\)/,_ye=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,Sye=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,Eye=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var r=e.sort((s,i)=>s[0]-i[0]).map(s=>s[1]);return function(s,i){i===void 0&&(i=0);for(var o=[],c=s.split(`
1765
1765
  `),u=i;u<c.length;u++){var d=c[u];if(!(d.length>1024)){var p=XM.test(d)?d.replace(XM,"$1"):d;if(!p.match(/\S*Error: /)){for(var m of r){var v=m(p);if(v){o.push(v);break}}if(o.length>=ZM)break}}}return function(y){if(!y.length)return[];var x=Array.from(y);return x.reverse(),x.slice(0,ZM).map(w=>Fe({},w,{filename:w.filename||kye(x).filename,function:w.function||mu}))}(o)}}([30,t=>{var e=xye.exec(t);if(e){var[,n,r,s]=e;return Hw(n,mu,+r,+s)}var i=bye.exec(t);if(i){if(i[2]&&i[2].indexOf("eval")===0){var o=wye.exec(i[2]);o&&(i[2]=o[1],i[3]=o[2],i[4]=o[3])}var[c,u]=eD(i[1]||mu,i[2]);return Hw(u,c,i[3]?+i[3]:void 0,i[4]?+i[4]:void 0)}}],[50,t=>{var e=_ye.exec(t);if(e){if(e[3]&&e[3].indexOf(" > eval")>-1){var n=Sye.exec(e[3]);n&&(e[1]=e[1]||"eval",e[3]=n[1],e[4]=n[2],e[5]="")}var r=e[3],s=e[1]||mu;return[s,r]=eD(s,r),Hw(r,s,e[4]?+e[4]:void 0,e[5]?+e[5]:void 0)}}]);function kye(t){return t[t.length-1]||{}}var eg,JM,Gw,eD=(t,e)=>{var n=t.indexOf("safari-extension")!==-1,r=t.indexOf("safari-web-extension")!==-1;return n||r?[t.indexOf("@")!==-1?t.split("@")[0]:mu,n?"safari-extension:"+e:"safari-web-extension:"+e]:[t,e]},Tye=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;function gT(t,e){e===void 0&&(e=0);var n=t.stacktrace||t.stack||"",r=function(o){return o&&Cye.test(o.message)?1:0}(t);try{var s=Eye,i=function(o,c){var u=function(d){var p=globalThis._posthogChunkIds;if(!p)return{};var m=Object.keys(p);return Gw&&m.length===JM||(JM=m.length,Gw=m.reduce((v,y)=>{eg||(eg={});var x=eg[y];if(x)v[x[0]]=x[1];else for(var w=d(y),k=w.length-1;k>=0;k--){var S=w[k],R=S?.filename,C=p[y];if(R&&C){v[R]=C,eg[y]=[R,C];break}}return v},{})),Gw}(c);return o.forEach(d=>{d.filename&&(d.chunk_id=u[d.filename])}),o}(s(n,r),s);return i.slice(0,i.length-e)}catch{}return[]}var Cye=/Minified React error #\d+;/i;function Rye(t,e){var n,r,s=gT(t),i=(n=e?.handled)===null||n===void 0||n,o=(r=e?.synthetic)!==null&&r!==void 0&&r;return{type:e!=null&&e.overrideExceptionType?e.overrideExceptionType:t.name,value:function(c){var u=c.message;return u.error&&typeof u.error.message=="string"?String(u.error.message):String(u)}(t),stacktrace:{frames:s,type:"raw"},mechanism:{handled:i,synthetic:o}}}function MU(t,e){var n=Rye(t,e);return t.cause&&PU(t.cause)&&t.cause!==t?[n,...MU(t.cause,{handled:e?.handled,synthetic:e?.synthetic})]:[n]}function Yw(t,e){return{$exception_list:MU(t,e),$exception_level:"error"}}function Ww(t,e){var n,r,s,i=(n=e?.handled)===null||n===void 0||n,o=(r=e?.synthetic)===null||r===void 0||r,c={type:e!=null&&e.overrideExceptionType?e.overrideExceptionType:(s=e?.defaultExceptionType)!==null&&s!==void 0?s:"Error",value:t||e?.defaultExceptionMessage,mechanism:{handled:i,synthetic:o}};if(e!=null&&e.syntheticException){var u=gT(e.syntheticException,1);u.length&&(c.stacktrace={frames:u,type:"raw"})}return{$exception_list:[c],$exception_level:"error"}}function Aye(t){return qn(t)&&!o1(t)&&tye.indexOf(t)>=0}function Nye(t,e){var n,r,s=(n=e?.handled)===null||n===void 0||n,i=(r=e?.synthetic)===null||r===void 0||r,o=e!=null&&e.overrideExceptionType?e.overrideExceptionType:jU(t)?t.constructor.name:"Error",c="Non-Error 'exception' captured with keys: "+function(p,m){m===void 0&&(m=40);var v=Object.keys(p);if(v.sort(),!v.length)return"[object has no keys]";for(var y=v.length;y>0;y--){var x=v.slice(0,y).join(", ");if(!(x.length>m))return y===v.length||x.length<=m?x:x.slice(0,m)+"..."}return""}(t),u={type:o,value:c,mechanism:{handled:s,synthetic:i}};if(e!=null&&e.syntheticException){var d=gT(e?.syntheticException,1);d.length&&(u.stacktrace={frames:d,type:"raw"})}return{$exception_list:[u],$exception_level:Aye(t.level)?t.level:"error"}}function jye(t,e){var{error:n,event:r}=t,s={$exception_list:[]},i=n||r;if(qw(i)||function(v){return xg(v,"DOMException")}(i)){var o=i;if(function(v){return"stack"in v}(i))s=Yw(i,e);else{var c=o.name||(qw(o)?"DOMError":"DOMException"),u=o.message?c+": "+o.message:c;s=Ww(u,Fe({},e,{overrideExceptionType:qw(o)?"DOMError":"DOMException",defaultExceptionMessage:u}))}return"code"in o&&(s.$exception_DOMException_code=""+o.code),s}if(function(v){return xg(v,"ErrorEvent")}(i)&&i.error)return Yw(i.error,e);if(PU(i))return Yw(i,e);if(function(v){return xg(v,"Object")}(i)||jU(i))return Nye(i,e);if(Me(n)&&qn(r)){var d="Error",p=r,m=r.match(Tye);return m&&(d=m[1],p=m[2]),Ww(p,Fe({},e,{overrideExceptionType:d,defaultExceptionMessage:p}))}return Ww(i,e)}function tD(t,e,n){try{if(!(e in t))return()=>{};var r=t[e],s=n(r);return Zs(s)&&(s.prototype=s.prototype||{},Object.defineProperties(s,{__posthog_wrapped__:{enumerable:!1,value:!0}})),t[e]=s,()=>{t[e]=r}}catch{return()=>{}}}class Oye{constructor(e){var n;this._instance=e,this.gt=(ye==null||(n=ye.location)==null?void 0:n.pathname)||""}get isEnabled(){return this._instance.config.capture_pageview==="history_change"}startIfEnabled(){this.isEnabled&&($e.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this._t&&this._t(),this._t=void 0,$e.info("History API monitoring stopped")}monitorHistoryChanges(){var e,n;if(ye&&ye.history){var r=this;(e=ye.history.pushState)!=null&&e.__posthog_wrapped__||tD(ye.history,"pushState",s=>function(i,o,c){s.call(this,i,o,c),r.bt("pushState")}),(n=ye.history.replaceState)!=null&&n.__posthog_wrapped__||tD(ye.history,"replaceState",s=>function(i,o,c){s.call(this,i,o,c),r.bt("replaceState")}),this.yt()}}bt(e){try{var n,r=ye==null||(n=ye.location)==null?void 0:n.pathname;if(!r)return;r!==this.gt&&this.isEnabled&&this._instance.capture("$pageview",{navigation_type:e}),this.gt=r}catch(s){$e.error("Error capturing "+e+" pageview",s)}}yt(){if(!this._t){var e=()=>{this.bt("popstate")};In(ye,"popstate",e),this._t=()=>{ye&&ye.removeEventListener("popstate",e)}}}}function Ev(t){var e,n;return((e=JSON.stringify(t,(n=[],function(r,s){if(Bn(s)){for(;n.length>0&&n[n.length-1]!==this;)n.pop();return n.includes(s)?"[Circular]":(n.push(s),s)}return s})))==null?void 0:e.length)||0}function w1(t,e){if(e===void 0&&(e=66060288e-1),t.size>=e&&t.data.length>1){var n=Math.floor(t.data.length/2),r=t.data.slice(0,n),s=t.data.slice(n);return[w1({size:Ev(r),data:r,sessionId:t.sessionId,windowId:t.windowId}),w1({size:Ev(s),data:s,sessionId:t.sessionId,windowId:t.windowId})].flatMap(i=>i)}return[t]}var _a=(t=>(t[t.DomContentLoaded=0]="DomContentLoaded",t[t.Load=1]="Load",t[t.FullSnapshot=2]="FullSnapshot",t[t.IncrementalSnapshot=3]="IncrementalSnapshot",t[t.Meta=4]="Meta",t[t.Custom=5]="Custom",t[t.Plugin=6]="Plugin",t))(_a||{}),fi=(t=>(t[t.Mutation=0]="Mutation",t[t.MouseMove=1]="MouseMove",t[t.MouseInteraction=2]="MouseInteraction",t[t.Scroll=3]="Scroll",t[t.ViewportResize=4]="ViewportResize",t[t.Input=5]="Input",t[t.TouchMove=6]="TouchMove",t[t.MediaInteraction=7]="MediaInteraction",t[t.StyleSheetRule=8]="StyleSheetRule",t[t.CanvasMutation=9]="CanvasMutation",t[t.Font=10]="Font",t[t.Log=11]="Log",t[t.Drag=12]="Drag",t[t.StyleDeclaration=13]="StyleDeclaration",t[t.Selection=14]="Selection",t[t.AdoptedStyleSheet=15]="AdoptedStyleSheet",t[t.CustomElement=16]="CustomElement",t))(fi||{}),_1="[SessionRecording]",S1="redacted",tg={initiatorTypes:["audio","beacon","body","css","early-hint","embed","fetch","frame","iframe","icon","image","img","input","link","navigation","object","ping","script","track","video","xmlhttprequest"],maskRequestFn:t=>t,recordHeaders:!1,recordBody:!1,recordInitialRequests:!1,recordPerformance:!1,performanceEntryTypeToObserve:["first-input","navigation","paint","resource"],payloadSizeLimitBytes:1e6,payloadHostDenyList:[".lr-ingest.io",".ingest.sentry.io",".clarity.ms","analytics.google.com","bam.nr-data.net"]},Pye=["authorization","x-forwarded-for","authorization","cookie","set-cookie","x-api-key","x-real-ip","remote-addr","forwarded","proxy-authorization","x-csrf-token","x-csrftoken","x-xsrf-token"],Mye=["password","secret","passwd","api_key","apikey","auth","credentials","mysql_pwd","privatekey","private_key","token"],Dye=["/s/","/e/","/i/"];function nD(t,e,n,r){if(Zt(t))return t;var s=e?.["content-length"]||function(i){return new Blob([i]).size}(t);return qn(s)&&(s=parseInt(s)),s>n?_1+" "+r+" body too large to record ("+s+" bytes)":t}function rD(t,e){if(Zt(t))return t;var n=t;return Hu(n,!1)||(n=_1+" "+e+" body "+S1),mn(Mye,r=>{var s,i;(s=n)!=null&&s.length&&((i=n)==null?void 0:i.indexOf(r))!==-1&&(n=_1+" "+e+" body "+S1+" as might contain: "+r)}),n}var Iye=(t,e)=>{var n,r,s,i={payloadSizeLimitBytes:tg.payloadSizeLimitBytes,performanceEntryTypeToObserve:[...tg.performanceEntryTypeToObserve],payloadHostDenyList:[...e.payloadHostDenyList||[],...tg.payloadHostDenyList]},o=t.session_recording.recordHeaders!==!1&&e.recordHeaders,c=t.session_recording.recordBody!==!1&&e.recordBody,u=t.capture_performance!==!1&&e.recordPerformance,d=(n=i,s=Math.min(1e6,(r=n.payloadSizeLimitBytes)!==null&&r!==void 0?r:1e6),v=>(v!=null&&v.requestBody&&(v.requestBody=nD(v.requestBody,v.requestHeaders,s,"Request")),v!=null&&v.responseBody&&(v.responseBody=nD(v.responseBody,v.responseHeaders,s,"Response")),v)),p=v=>{return d(((w,k)=>{var S,R=Gu(w.name),C=k.indexOf("http")===0?(S=Gu(k))==null?void 0:S.pathname:k;C==="/"&&(C="");var A=R?.pathname.replace(C||"","");if(!(R&&A&&Dye.some(D=>A.indexOf(D)===0)))return w})((x=(y=v).requestHeaders,Zt(x)||mn(Object.keys(x??{}),w=>{Pye.includes(w.toLowerCase())&&(x[w]=S1)}),y),t.api_host));var y,x},m=Zs(t.session_recording.maskNetworkRequestFn);return m&&Zs(t.session_recording.maskCapturedNetworkRequestFn)&&$e.warn("Both `maskNetworkRequestFn` and `maskCapturedNetworkRequestFn` are defined. `maskNetworkRequestFn` will be ignored."),m&&(t.session_recording.maskCapturedNetworkRequestFn=v=>{var y=t.session_recording.maskNetworkRequestFn({url:v.name});return Fe({},v,{name:y?.url})}),i.maskRequestFn=Zs(t.session_recording.maskCapturedNetworkRequestFn)?v=>{var y,x=p(v);return x&&(y=t.session_recording.maskCapturedNetworkRequestFn==null?void 0:t.session_recording.maskCapturedNetworkRequestFn(x))!==null&&y!==void 0?y:void 0}:v=>function(y){if(!Me(y))return y.requestBody=rD(y.requestBody,"Request"),y.responseBody=rD(y.responseBody,"Response"),y}(p(v)),Fe({},tg,i,{recordHeaders:o,recordBody:c,recordPerformance:u,recordInitialRequests:u})};class Lye{constructor(e,n){var r,s;n===void 0&&(n={}),this.wt={},this.St=i=>{if(!this.wt[i]){var o,c;this.wt[i]=!0;var u=this.$t(i);(o=(c=this.t).onBlockedNode)==null||o.call(c,i,u)}},this.xt=i=>{var o=this.$t(i);if(o?.nodeName!=="svg"&&o instanceof Element){var c=o.closest("svg");if(c)return[this._rrweb.mirror.getId(c),c]}return[i,o]},this.$t=i=>this._rrweb.mirror.getNode(i),this.kt=i=>{var o,c,u,d,p,m,v,y;return((o=(c=i.removes)==null?void 0:c.length)!==null&&o!==void 0?o:0)+((u=(d=i.attributes)==null?void 0:d.length)!==null&&u!==void 0?u:0)+((p=(m=i.texts)==null?void 0:m.length)!==null&&p!==void 0?p:0)+((v=(y=i.adds)==null?void 0:y.length)!==null&&v!==void 0?v:0)},this.throttleMutations=i=>{if(i.type!==3||i.data.source!==0)return i;var o=i.data,c=this.kt(o);o.attributes&&(o.attributes=o.attributes.filter(d=>{var[p]=this.xt(d.id);return!this.ft.consumeRateLimit(p)&&d}));var u=this.kt(o);return u!==0||c===u?i:void 0},this._rrweb=e,this.t=n,this.ft=new fU({bucketSize:(r=this.t.bucketSize)!==null&&r!==void 0?r:100,refillRate:(s=this.t.refillRate)!==null&&s!==void 0?s:10,refillInterval:1e3,k:this.St,I:$e})}}var Js=Uint8Array,fs=Uint16Array,Yu=Uint32Array,vT=new Js([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),yT=new Js([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),sD=new Js([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),DU=function(t,e){for(var n=new fs(31),r=0;r<31;++r)n[r]=e+=1<<t[r-1];var s=new Yu(n[30]);for(r=1;r<30;++r)for(var i=n[r];i<n[r+1];++i)s[i]=i-n[r]<<5|r;return[n,s]},IU=DU(vT,2),zye=IU[0],E1=IU[1];zye[28]=258,E1[258]=28;for(var iD=DU(yT,0)[1],LU=new fs(32768),Tn=0;Tn<32768;++Tn){var wl=(43690&Tn)>>>1|(21845&Tn)<<1;wl=(61680&(wl=(52428&wl)>>>2|(13107&wl)<<2))>>>4|(3855&wl)<<4,LU[Tn]=((65280&wl)>>>8|(255&wl)<<8)>>>1}var dh=function(t,e,n){for(var r=t.length,s=0,i=new fs(e);s<r;++s)++i[t[s]-1];var o,c=new fs(e);for(s=0;s<e;++s)c[s]=c[s-1]+i[s-1]<<1;for(o=new fs(r),s=0;s<r;++s)o[s]=LU[c[t[s]-1]++]>>>15-t[s];return o},Xl=new Js(288);for(Tn=0;Tn<144;++Tn)Xl[Tn]=8;for(Tn=144;Tn<256;++Tn)Xl[Tn]=9;for(Tn=256;Tn<280;++Tn)Xl[Tn]=7;for(Tn=280;Tn<288;++Tn)Xl[Tn]=8;var kv=new Js(32);for(Tn=0;Tn<32;++Tn)kv[Tn]=5;var $ye=dh(Xl,9),Fye=dh(kv,5),zU=function(t){return(t/8>>0)+(7&t&&1)},$U=function(t,e,n){(n==null||n>t.length)&&(n=t.length);var r=new(t instanceof fs?fs:t instanceof Yu?Yu:Js)(n-e);return r.set(t.subarray(e,n)),r},xa=function(t,e,n){n<<=7&e;var r=e/8>>0;t[r]|=n,t[r+1]|=n>>>8},Sf=function(t,e,n){n<<=7&e;var r=e/8>>0;t[r]|=n,t[r+1]|=n>>>8,t[r+2]|=n>>>16},Kw=function(t,e){for(var n=[],r=0;r<t.length;++r)t[r]&&n.push({s:r,f:t[r]});var s=n.length,i=n.slice();if(!s)return[new Js(0),0];if(s==1){var o=new Js(n[0].s+1);return o[n[0].s]=1,[o,1]}n.sort(function(D,T){return D.f-T.f}),n.push({s:-1,f:25001});var c=n[0],u=n[1],d=0,p=1,m=2;for(n[0]={s:-1,f:c.f+u.f,l:c,r:u};p!=s-1;)c=n[n[d].f<n[m].f?d++:m++],u=n[d!=p&&n[d].f<n[m].f?d++:m++],n[p++]={s:-1,f:c.f+u.f,l:c,r:u};var v=i[0].s;for(r=1;r<s;++r)i[r].s>v&&(v=i[r].s);var y=new fs(v+1),x=k1(n[p-1],y,0);if(x>e){r=0;var w=0,k=x-e,S=1<<k;for(i.sort(function(D,T){return y[T.s]-y[D.s]||D.f-T.f});r<s;++r){var R=i[r].s;if(!(y[R]>e))break;w+=S-(1<<x-y[R]),y[R]=e}for(w>>>=k;w>0;){var C=i[r].s;y[C]<e?w-=1<<e-y[C]++-1:++r}for(;r>=0&&w;--r){var A=i[r].s;y[A]==e&&(--y[A],++w)}x=e}return[new Js(y),x]},k1=function(t,e,n){return t.s==-1?Math.max(k1(t.l,e,n+1),k1(t.r,e,n+1)):e[t.s]=n},aD=function(t){for(var e=t.length;e&&!t[--e];);for(var n=new fs(++e),r=0,s=t[0],i=1,o=function(u){n[r++]=u},c=1;c<=e;++c)if(t[c]==s&&c!=e)++i;else{if(!s&&i>2){for(;i>138;i-=138)o(32754);i>2&&(o(i>10?i-11<<5|28690:i-3<<5|12305),i=0)}else if(i>3){for(o(s),--i;i>6;i-=6)o(8304);i>2&&(o(i-3<<5|8208),i=0)}for(;i--;)o(s);i=1,s=t[c]}return[n.subarray(0,r),e]},Ef=function(t,e){for(var n=0,r=0;r<e.length;++r)n+=t[r]*e[r];return n},T1=function(t,e,n){var r=n.length,s=zU(e+2);t[s]=255&r,t[s+1]=r>>>8,t[s+2]=255^t[s],t[s+3]=255^t[s+1];for(var i=0;i<r;++i)t[s+i+4]=n[i];return 8*(s+4+r)},oD=function(t,e,n,r,s,i,o,c,u,d,p){xa(e,p++,n),++s[256];for(var m=Kw(s,15),v=m[0],y=m[1],x=Kw(i,15),w=x[0],k=x[1],S=aD(v),R=S[0],C=S[1],A=aD(w),D=A[0],T=A[1],P=new fs(19),O=0;O<R.length;++O)P[31&R[O]]++;for(O=0;O<D.length;++O)P[31&D[O]]++;for(var L=Kw(P,7),M=L[0],$=L[1],F=19;F>4&&!M[sD[F-1]];--F);var W,q,X,V,Y=d+5<<3,H=Ef(s,Xl)+Ef(i,kv)+o,J=Ef(s,v)+Ef(i,w)+o+14+3*F+Ef(P,M)+(2*P[16]+3*P[17]+7*P[18]);if(Y<=H&&Y<=J)return T1(e,p,t.subarray(u,u+d));if(xa(e,p,1+(J<H)),p+=2,J<H){W=dh(v,y),q=v,X=dh(w,k),V=w;var N=dh(M,$);for(xa(e,p,C-257),xa(e,p+5,T-1),xa(e,p+10,F-4),p+=14,O=0;O<F;++O)xa(e,p+3*O,M[sD[O]]);p+=3*F;for(var ie=[R,D],ee=0;ee<2;++ee){var j=ie[ee];for(O=0;O<j.length;++O){var Q=31&j[O];xa(e,p,N[Q]),p+=M[Q],Q>15&&(xa(e,p,j[O]>>>5&127),p+=j[O]>>>12)}}}else W=$ye,q=Xl,X=Fye,V=kv;for(O=0;O<c;++O)if(r[O]>255){Q=r[O]>>>18&31,Sf(e,p,W[Q+257]),p+=q[Q+257],Q>7&&(xa(e,p,r[O]>>>23&31),p+=vT[Q]);var le=31&r[O];Sf(e,p,X[le]),p+=V[le],le>3&&(Sf(e,p,r[O]>>>5&8191),p+=yT[le])}else Sf(e,p,W[r[O]]),p+=q[r[O]];return Sf(e,p,W[256]),p+q[256]},Uye=new Yu([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Vye=function(){for(var t=new Yu(256),e=0;e<256;++e){for(var n=e,r=9;--r;)n=(1&n&&3988292384)^n>>>1;t[e]=n}return t}(),Bye=function(){var t=4294967295;return{p:function(e){for(var n=t,r=0;r<e.length;++r)n=Vye[255&n^e[r]]^n>>>8;t=n},d:function(){return 4294967295^t}}},qye=function(t,e,n,r,s){return function(i,o,c,u,d,p){var m=i.length,v=new Js(u+m+5*(1+Math.floor(m/7e3))+d),y=v.subarray(u,v.length-d),x=0;if(!o||m<8)for(var w=0;w<=m;w+=65535){var k=w+65535;k<m?x=T1(y,x,i.subarray(w,k)):(y[w]=p,x=T1(y,x,i.subarray(w,m)))}else{for(var S=Uye[o-1],R=S>>>13,C=8191&S,A=(1<<c)-1,D=new fs(32768),T=new fs(A+1),P=Math.ceil(c/3),O=2*P,L=function(Ve){return(i[Ve]^i[Ve+1]<<P^i[Ve+2]<<O)&A},M=new Yu(25e3),$=new fs(288),F=new fs(32),W=0,q=0,X=(w=0,0),V=0,Y=0;w<m;++w){var H=L(w),J=32767&w,N=T[H];if(D[J]=N,T[H]=J,V<=w){var ie=m-w;if((W>7e3||X>24576)&&ie>423){x=oD(i,y,0,M,$,F,q,X,Y,w-Y,x),X=W=q=0,Y=w;for(var ee=0;ee<286;++ee)$[ee]=0;for(ee=0;ee<30;++ee)F[ee]=0}var j=2,Q=0,le=C,z=J-N&32767;if(ie>2&&H==L(w-z))for(var B=Math.min(R,ie)-1,K=Math.min(32767,w),de=Math.min(258,ie);z<=K&&--le&&J!=N;){if(i[w+j]==i[w+j-z]){for(var ne=0;ne<de&&i[w+ne]==i[w+ne-z];++ne);if(ne>j){if(j=ne,Q=z,ne>B)break;var ce=Math.min(z,ne-2),we=0;for(ee=0;ee<ce;++ee){var Se=w-z+ee+32768&32767,Ne=Se-D[Se]+32768&32767;Ne>we&&(we=Ne,N=Se)}}}z+=(J=N)-(N=D[J])+32768&32767}if(Q){M[X++]=268435456|E1[j]<<18|iD[Q];var pt=31&E1[j],Je=31&iD[Q];q+=vT[pt]+yT[Je],++$[257+pt],++F[Je],V=w+j,++W}else M[X++]=i[w],++$[i[w]]}}x=oD(i,y,p,M,$,F,q,X,Y,w-Y,x)}return $U(v,0,u+zU(x)+d)}(t,e.level==null?6:e.level,e.mem==null?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(t.length)))):12+e.mem,n,r,!0)},C1=function(t,e,n){for(;n;++e)t[e]=n,n>>>=8},Hye=function(t,e){var n=e.filename;if(t[0]=31,t[1]=139,t[2]=8,t[8]=e.level<2?4:e.level==9?2:0,t[9]=3,e.mtime!=0&&C1(t,4,Math.floor(new Date(e.mtime||Date.now())/1e3)),n){t[3]=8;for(var r=0;r<=n.length;++r)t[r+10]=n.charCodeAt(r)}},Gye=function(t){return 10+(t.filename&&t.filename.length+1||0)};function FU(t,e){e===void 0&&(e={});var n=Bye(),r=t.length;n.p(t);var s=qye(t,e,Gye(e),8),i=s.length;return Hye(s,e),C1(s,i-8,n.d()),C1(s,i-4,r),s}function UU(t,e){var n=t.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(t);for(var r=new Js(t.length+(t.length>>>1)),s=0,i=function(d){r[s++]=d},o=0;o<n;++o){if(s+5>r.length){var c=new Js(s+8+(n-o<<1));c.set(r),r=c}var u=t.charCodeAt(o);u<128||e?i(u):u<2048?(i(192|u>>>6),i(128|63&u)):u>55295&&u<57344?(i(240|(u=65536+(1047552&u)|1023&t.charCodeAt(++o))>>>18),i(128|u>>>12&63),i(128|u>>>6&63),i(128|63&u)):(i(224|u>>>12),i(128|u>>>6&63),i(128|63&u))}return $U(r,0,s)}function Yye(t,e){return function(n){for(var r=0,s=0;s<n.length;s++)r=(r<<5)-r+n.charCodeAt(s),r|=0;return Math.abs(r)}(t)%100<js(100*e,0,100,$e)}var Lo="disabled",xT="sampled",Tv="active",Zl="buffering",bT="paused",wT="trigger",Wi=wT+"_activated",Fr=wT+"_pending",Zi=wT+"_"+Lo;function lD(t,e){return e.some(n=>n.matching==="regex"&&new RegExp(n.url).test(t))}class VU{constructor(e){this.Et=e}triggerStatus(e){var n=this.Et.map(r=>r.triggerStatus(e));return n.includes(Wi)?Wi:n.includes(Fr)?Fr:Zi}stop(){this.Et.forEach(e=>e.stop())}}class BU{constructor(e){this.Et=e}triggerStatus(e){var n=new Set;for(var r of this.Et)n.add(r.triggerStatus(e));switch(n.delete(Zi),n.size){case 0:return Zi;case 1:return Array.from(n)[0];default:return Fr}}stop(){this.Et.forEach(e=>e.stop())}}class Wye{triggerStatus(){return Fr}stop(){}}class Kye{constructor(e){this.It=[],this.Pt=[],this.urlBlocked=!1,this._instance=e}onRemoteConfig(e){var n,r;this.It=((n=e.sessionRecording)==null?void 0:n.urlTriggers)||[],this.Pt=((r=e.sessionRecording)==null?void 0:r.urlBlocklist)||[]}Rt(e){var n;return this.It.length===0?Zi:((n=this._instance)==null?void 0:n.get_property(d1))===e?Wi:Fr}triggerStatus(e){var n=this.Rt(e),r=n===Wi?Wi:n===Fr?Fr:Zi;return this._instance.register_for_session({$sdk_debug_replay_url_trigger_status:r}),r}checkUrlTriggerConditions(e,n,r){if(ye!==void 0&&ye.location.href){var s=ye.location.href,i=this.urlBlocked,o=lD(s,this.Pt);i&&o||(o&&!i?e():!o&&i&&n(),lD(s,this.It)&&r("url"))}}stop(){}}class Qye{constructor(e){this.linkedFlag=null,this.linkedFlagSeen=!1,this.Tt=()=>{},this._instance=e}triggerStatus(){var e=Fr;return Zt(this.linkedFlag)&&(e=Zi),this.linkedFlagSeen&&(e=Wi),this._instance.register_for_session({$sdk_debug_replay_linked_flag_trigger_status:e}),e}onRemoteConfig(e,n){var r;if(this.linkedFlag=((r=e.sessionRecording)==null?void 0:r.linkedFlag)||null,!Zt(this.linkedFlag)&&!this.linkedFlagSeen){var s=qn(this.linkedFlag)?this.linkedFlag:this.linkedFlag.flag,i=qn(this.linkedFlag)?null:this.linkedFlag.variant;this.Tt=this._instance.onFeatureFlags((o,c)=>{var u=!1;if(Bn(c)&&s in c){var d=c[s];u=$i(d)?d===!0:i?d===i:!!d}this.linkedFlagSeen=u,u&&n(s,i)})}}stop(){this.Tt()}}class Xye{constructor(e){this.Ct=[],this._instance=e}onRemoteConfig(e){var n;this.Ct=((n=e.sessionRecording)==null?void 0:n.eventTriggers)||[]}Mt(e){var n;return this.Ct.length===0?Zi:((n=this._instance)==null?void 0:n.get_property(f1))===e?Wi:Fr}triggerStatus(e){var n=this.Mt(e),r=n===Wi?Wi:n===Fr?Fr:Zi;return this._instance.register_for_session({$sdk_debug_replay_event_trigger_status:r}),r}stop(){}}function Zye(t){return t.isRecordingEnabled?Zl:Lo}function Jye(t){if(!t.receivedFlags)return Zl;if(!t.isRecordingEnabled)return Lo;if(t.urlTriggerMatching.urlBlocked)return bT;var e=t.isSampled===!0,n=new VU([t.eventTriggerMatching,t.urlTriggerMatching,t.linkedFlagMatching]).triggerStatus(t.sessionId);return e?xT:n===Wi?Tv:n===Fr?Zl:t.isSampled===!1?Lo:Tv}function exe(t){if(!t.receivedFlags)return Zl;if(!t.isRecordingEnabled)return Lo;if(t.urlTriggerMatching.urlBlocked)return bT;var e=new BU([t.eventTriggerMatching,t.urlTriggerMatching,t.linkedFlagMatching]).triggerStatus(t.sessionId),n=e!==Zi,r=$i(t.isSampled);return n&&e===Fr?Zl:n&&e===Zi||r&&!t.isSampled?Lo:t.isSampled===!0?xT:Tv}var qf="[SessionRecording]",gr=br(qf);function ng(){var t;return bt==null||(t=bt.__PosthogExtensions__)==null||(t=t.rrweb)==null?void 0:t.record}var txe=3e5,nxe=[fi.MouseMove,fi.MouseInteraction,fi.Scroll,fi.ViewportResize,fi.Input,fi.TouchMove,fi.MediaInteraction,fi.Drag],cD=t=>({rrwebMethod:t,enqueuedAt:Date.now(),attempt:1});function _l(t){return function(e,n){for(var r="",s=0;s<e.length;){var i=e[s++];r+=String.fromCharCode(i)}return r}(FU(UU(JSON.stringify(t))))}function uD(t){return t.type===_a.Custom&&t.data.tag==="sessionIdle"}class dD{get sessionId(){return this.Ft}get Ot(){return this._instance.config.session_recording.session_idle_threshold_ms||3e5}get started(){return this.At}get Dt(){if(!this._instance.sessionManager)throw new Error(qf+" must be started with a valid sessionManager.");return this._instance.sessionManager}get jt(){var e,n;return this.Lt.triggerStatus(this.sessionId)===Fr?6e4:(e=(n=this._instance.config.session_recording)==null?void 0:n.full_snapshot_interval_millis)!==null&&e!==void 0?e:txe}get Nt(){var e=this._instance.get_property(Uf);return $i(e)?e:null}get zt(){var e,n,r=(e=this.B)==null?void 0:e.data[((n=this.B)==null?void 0:n.data.length)-1],{sessionStartTimestamp:s}=this.Dt.checkAndGetSessionAndWindowId(!0);return r?r.timestamp-s:null}get Ut(){var e=!!this._instance.get_property(u1),n=!this._instance.config.disable_session_recording;return ye&&e&&n}get qt(){var e=!!this._instance.get_property(zM),n=this._instance.config.enable_recording_console_log;return n??e}get Bt(){var e,n,r,s,i,o,c=this._instance.config.session_recording.captureCanvas,u=this._instance.get_property(UM),d=(e=(n=c?.recordCanvas)!==null&&n!==void 0?n:u?.enabled)!==null&&e!==void 0&&e,p=(r=(s=c?.canvasFps)!==null&&s!==void 0?s:u?.fps)!==null&&r!==void 0?r:4,m=(i=(o=c?.canvasQuality)!==null&&o!==void 0?o:u?.quality)!==null&&i!==void 0?i:.4;if(typeof m=="string"){var v=parseFloat(m);m=isNaN(v)?.4:v}return{enabled:d,fps:js(p,0,12,gr.createLogger("canvas recording fps"),4),quality:js(m,0,1,gr.createLogger("canvas recording quality"),.4)}}get Ht(){var e,n,r=this._instance.get_property($M),s={recordHeaders:(e=this._instance.config.session_recording)==null?void 0:e.recordHeaders,recordBody:(n=this._instance.config.session_recording)==null?void 0:n.recordBody},i=s?.recordHeaders||r?.recordHeaders,o=s?.recordBody||r?.recordBody,c=Bn(this._instance.config.capture_performance)?this._instance.config.capture_performance.network_timing:this._instance.config.capture_performance,u=!!($i(c)?c:r?.capturePerformance);return i||o||u?{recordHeaders:i,recordBody:o,recordPerformance:u}:void 0}get Wt(){var e,n,r,s,i,o,c=this._instance.get_property(FM),u={maskAllInputs:(e=this._instance.config.session_recording)==null?void 0:e.maskAllInputs,maskTextSelector:(n=this._instance.config.session_recording)==null?void 0:n.maskTextSelector,blockSelector:(r=this._instance.config.session_recording)==null?void 0:r.blockSelector},d=(s=u?.maskAllInputs)!==null&&s!==void 0?s:c?.maskAllInputs,p=(i=u?.maskTextSelector)!==null&&i!==void 0?i:c?.maskTextSelector,m=(o=u?.blockSelector)!==null&&o!==void 0?o:c?.blockSelector;return Me(d)&&Me(p)&&Me(m)?void 0:{maskAllInputs:d==null||d,maskTextSelector:p,blockSelector:m}}get Gt(){var e=this._instance.get_property(VM);return Ir(e)?e:null}get Jt(){var e=this._instance.get_property(BM);return Ir(e)?e:null}get status(){return this.Vt?this.Kt({receivedFlags:this.Vt,isRecordingEnabled:this.Ut,isSampled:this.Nt,urlTriggerMatching:this.Yt,eventTriggerMatching:this.Xt,linkedFlagMatching:this.Qt,sessionId:this.sessionId}):Zl}constructor(e){if(this.Kt=Zye,this.Vt=!1,this.Zt=[],this.ti="unknown",this.ii=Date.now(),this.Lt=new Wye,this.ei=void 0,this.ri=void 0,this.si=void 0,this.ni=void 0,this.oi=void 0,this._forceAllowLocalhostNetworkCapture=!1,this.ai=()=>{this.li()},this.ui=()=>{this.hi("browser offline",{})},this.di=()=>{this.hi("browser online",{})},this.vi=()=>{if(Ue!=null&&Ue.visibilityState){var s="window "+Ue.visibilityState;this.hi(s,{})}},this._instance=e,this.At=!1,this.ci="/s/",this.fi=void 0,this.Vt=!1,!this._instance.sessionManager)throw gr.error("started without valid sessionManager"),new Error(qf+" started without valid sessionManager. This is a bug.");if(this._instance.config.cookieless_mode==="always")throw new Error(qf+' cannot be used with cookieless_mode="always"');this.Qt=new Qye(this._instance),this.Yt=new Kye(this._instance),this.Xt=new Xye(this._instance);var{sessionId:n,windowId:r}=this.Dt.checkAndGetSessionAndWindowId();this.Ft=n,this.pi=r,this.B=this.gi(),this.Ot>=this.Dt.sessionTimeoutMs&&gr.warn("session_idle_threshold_ms ("+this.Ot+") is greater than the session timeout ("+this.Dt.sessionTimeoutMs+"). Session will never be detected as idle")}startIfEnabledOrStop(e){this.Ut?(this.mi(e),In(ye,"beforeunload",this.ai),In(ye,"offline",this.ui),In(ye,"online",this.di),In(ye,"visibilitychange",this.vi),this.bi(),this.yi(),Zt(this.ei)&&(this.ei=this._instance.on("eventCaptured",n=>{try{if(n.event==="$pageview"){var r=n!=null&&n.properties.$current_url?this.wi(n?.properties.$current_url):"";if(!r)return;this.hi("$pageview",{href:r})}}catch(s){gr.error("Could not add $pageview to rrweb session",s)}})),this.ri||(this.ri=this.Dt.onSessionId((n,r,s)=>{var i,o;s&&(this.hi("$session_id_change",{sessionId:n,windowId:r,changeReason:s}),(i=this._instance)==null||(i=i.persistence)==null||i.unregister(f1),(o=this._instance)==null||(o=o.persistence)==null||o.unregister(d1))}))):this.stopRecording()}stopRecording(){var e,n,r,s;this.At&&this.fi&&(this.fi(),this.fi=void 0,this.At=!1,ye?.removeEventListener("beforeunload",this.ai),ye?.removeEventListener("offline",this.ui),ye?.removeEventListener("online",this.di),ye?.removeEventListener("visibilitychange",this.vi),this.gi(),clearInterval(this.Si),(e=this.ei)==null||e.call(this),this.ei=void 0,(n=this.oi)==null||n.call(this),this.oi=void 0,(r=this.ri)==null||r.call(this),this.ri=void 0,(s=this.ni)==null||s.call(this),this.ni=void 0,this.Xt.stop(),this.Yt.stop(),this.Qt.stop(),gr.info("stopped"))}$i(){var e;(e=this._instance.persistence)==null||e.unregister(Uf)}xi(e){var n,r=this.Ft!==e,s=this.Gt;if(Ir(s)){var i=this.Nt,o=r||!$i(i),c=o?Yye(e,s):i;o&&(c?this.ki(xT):gr.warn("Sample rate ("+s+") has determined that this sessionId ("+e+") will not be sent to the server."),this.hi("samplingDecisionMade",{sampleRate:s,isSampled:c})),(n=this._instance.persistence)==null||n.register({[Uf]:c})}else this.$i()}onRemoteConfig(e){var n,r,s,i;this.hi("$remote_config_received",e),this.Ei(e),(n=e.sessionRecording)!=null&&n.endpoint&&(this.ci=(i=e.sessionRecording)==null?void 0:i.endpoint),this.bi(),((r=e.sessionRecording)==null?void 0:r.triggerMatchType)==="any"?(this.Kt=Jye,this.Lt=new VU([this.Xt,this.Yt])):(this.Kt=exe,this.Lt=new BU([this.Xt,this.Yt])),this._instance.register_for_session({$sdk_debug_replay_remote_trigger_matching_config:(s=e.sessionRecording)==null?void 0:s.triggerMatchType}),this.Yt.onRemoteConfig(e),this.Xt.onRemoteConfig(e),this.Qt.onRemoteConfig(e,(o,c)=>{this.ki("linked_flag_matched",{flag:o,variant:c})}),this.Vt=!0,this.startIfEnabledOrStop()}bi(){Ir(this.Gt)&&Zt(this.ni)&&(this.ni=this.Dt.onSessionId(e=>{this.xi(e)}))}Ei(e){if(this._instance.persistence){var n,r=this._instance.persistence,s=()=>{var i,o,c,u,d,p,m,v,y,x=(i=e.sessionRecording)==null?void 0:i.sampleRate,w=Zt(x)?null:parseFloat(x);Zt(w)&&this.$i();var k=(o=e.sessionRecording)==null?void 0:o.minimumDurationMilliseconds;r.register({[u1]:!!e.sessionRecording,[zM]:(c=e.sessionRecording)==null?void 0:c.consoleLogRecordingEnabled,[$M]:Fe({capturePerformance:e.capturePerformance},(u=e.sessionRecording)==null?void 0:u.networkPayloadCapture),[FM]:(d=e.sessionRecording)==null?void 0:d.masking,[UM]:{enabled:(p=e.sessionRecording)==null?void 0:p.recordCanvas,fps:(m=e.sessionRecording)==null?void 0:m.canvasFps,quality:(v=e.sessionRecording)==null?void 0:v.canvasQuality},[VM]:w,[BM]:Me(k)?null:k,[qM]:(y=e.sessionRecording)==null?void 0:y.scriptConfig})};s(),(n=this.si)==null||n.call(this),this.si=this.Dt.onSessionId(s)}}log(e,n){var r;n===void 0&&(n="log"),(r=this._instance.sessionRecording)==null||r.onRRwebEmit({type:6,data:{plugin:"rrweb/console@1",payload:{level:n,trace:[],payload:[JSON.stringify(e)]}},timestamp:Date.now()})}mi(e){if(!Me(Object.assign)&&!Me(Array.from)&&!(this.At||this._instance.config.disable_session_recording||this._instance.consent.isOptedOut())){var n;this.At=!0,this.Dt.checkAndGetSessionAndWindowId(),ng()?this.Ii():(n=bt.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,this.Pi,r=>{if(r)return gr.error("could not load recorder",r);this.Ii()}),gr.info("starting"),this.status===Tv&&this.ki(e||"recording_initialized")}}get Pi(){var e;return((e=this._instance)==null||(e=e.persistence)==null||(e=e.get_property(qM))==null?void 0:e.script)||"recorder"}Ri(e){var n;return e.type===3&&nxe.indexOf((n=e.data)==null?void 0:n.source)!==-1}Ti(e){var n=this.Ri(e);n||this.ti||e.timestamp-this.ii>this.Ot&&(this.ti=!0,clearInterval(this.Si),this.hi("sessionIdle",{eventTimestamp:e.timestamp,lastActivityTimestamp:this.ii,threshold:this.Ot,bufferLength:this.B.data.length,bufferSize:this.B.size}),this.li());var r=!1;if(n&&(this.ii=e.timestamp,this.ti)){var s=this.ti==="unknown";this.ti=!1,s||(this.hi("sessionNoLongerIdle",{reason:"user activity",type:e.type}),r=!0)}if(!this.ti){var{windowId:i,sessionId:o}=this.Dt.checkAndGetSessionAndWindowId(!n,e.timestamp),c=this.Ft!==o,u=this.pi!==i;this.pi=i,this.Ft=o,c||u?(this.stopRecording(),this.startIfEnabledOrStop("session_id_changed")):r&&this.Ci()}}Mi(e){try{return e.rrwebMethod(),!0}catch(n){return this.Zt.length<10?this.Zt.push({enqueuedAt:e.enqueuedAt||Date.now(),attempt:e.attempt++,rrwebMethod:e.rrwebMethod}):gr.warn("could not emit queued rrweb event.",n,e),!1}}hi(e,n){return this.Mi(cD(()=>ng().addCustomEvent(e,n)))}Fi(){return this.Mi(cD(()=>ng().takeFullSnapshot()))}Ii(){var e,n,r,s,i={blockClass:"ph-no-capture",blockSelector:void 0,ignoreClass:"ph-ignore-input",maskTextClass:"ph-mask",maskTextSelector:void 0,maskTextFn:void 0,maskAllInputs:!0,maskInputOptions:{password:!0},maskInputFn:void 0,slimDOMOptions:{},collectFonts:!1,inlineStylesheet:!0,recordCrossOriginIframes:!1},o=this._instance.config.session_recording;for(var[c,u]of Object.entries(o||{}))c in i&&(c==="maskInputOptions"?i.maskInputOptions=Fe({password:!0},u):i[c]=u);this.Bt&&this.Bt.enabled&&(i.recordCanvas=!0,i.sampling={canvas:this.Bt.fps},i.dataURLOptions={type:"image/webp",quality:this.Bt.quality}),this.Wt&&(i.maskAllInputs=(n=this.Wt.maskAllInputs)===null||n===void 0||n,i.maskTextSelector=(r=this.Wt.maskTextSelector)!==null&&r!==void 0?r:void 0,i.blockSelector=(s=this.Wt.blockSelector)!==null&&s!==void 0?s:void 0);var d=ng();if(d){this.Oi=(e=this.Oi)!==null&&e!==void 0?e:new Lye(d,{refillRate:this._instance.config.session_recording.__mutationThrottlerRefillRate,bucketSize:this._instance.config.session_recording.__mutationThrottlerBucketSize,onBlockedNode:(m,v)=>{var y="Too many mutations on node '"+m+"'. Rate limiting. This could be due to SVG animations or something similar";gr.info(y,{node:v}),this.log(qf+" "+y,"warn")}});var p=this.Ai();this.fi=d(Fe({emit:m=>{this.onRRwebEmit(m)},plugins:p},i)),this.ii=Date.now(),this.ti=$i(this.ti)?this.ti:"unknown",this.hi("$session_options",{sessionRecordingOptions:i,activePlugins:p.map(m=>m?.name)}),this.hi("$posthog_config",{config:this._instance.config})}else gr.error("onScriptLoaded was called but rrwebRecord is not available. This indicates something has gone wrong.")}Ci(){if(this.Si&&clearInterval(this.Si),this.ti!==!0){var e=this.jt;e&&(this.Si=setInterval(()=>{this.Fi()},e))}}Ai(){var e,n,r=[],s=(e=bt.__PosthogExtensions__)==null||(e=e.rrwebPlugins)==null?void 0:e.getRecordConsolePlugin;s&&this.qt&&r.push(s());var i=(n=bt.__PosthogExtensions__)==null||(n=n.rrwebPlugins)==null?void 0:n.getRecordNetworkPlugin;return this.Ht&&Zs(i)&&(!nye.includes(location.hostname)||this._forceAllowLocalhostNetworkCapture?r.push(i(Iye(this._instance.config,this.Ht))):gr.info("NetworkCapture not started because we are on localhost.")),r}onRRwebEmit(e){var n;if(this.Di(),e&&Bn(e)){if(e.type===_a.Meta){var r=this.wi(e.data.href);if(this.ji=r,!r)return;e.data.href=r}else this.Li();if(this.Yt.checkUrlTriggerConditions(()=>this.Ni(),()=>this.zi(),v=>this.Ui(v)),!this.Yt.urlBlocked||(s=e).type===_a.Custom&&s.data.tag==="recording paused"){var s;e.type===_a.FullSnapshot&&this.Ci(),e.type===_a.FullSnapshot&&this.Vt&&this.Lt.triggerStatus(this.sessionId)===Fr&&this.gi();var i=this.Oi?this.Oi.throttleMutations(e):e;if(i){var o=function(v){var y=v;if(y&&Bn(y)&&y.type===6&&Bn(y.data)&&y.data.plugin==="rrweb/console@1"){y.data.payload.payload.length>10&&(y.data.payload.payload=y.data.payload.payload.slice(0,10),y.data.payload.payload.push("...[truncated]"));for(var x=[],w=0;w<y.data.payload.payload.length;w++)y.data.payload.payload[w]&&y.data.payload.payload[w].length>2e3?x.push(y.data.payload.payload[w].slice(0,2e3)+"...[truncated]"):x.push(y.data.payload.payload[w]);return y.data.payload.payload=x,v}return v}(i);if(this.Ti(o),this.ti!==!0||uD(o)){if(uD(o)){var c=o.data.payload;if(c){var u=c.lastActivityTimestamp,d=c.threshold;o.timestamp=u+d}}var p=(n=this._instance.config.session_recording.compress_events)===null||n===void 0||n?function(v){if(Ev(v)<1024)return v;try{if(v.type===_a.FullSnapshot)return Fe({},v,{data:_l(v.data),cv:"2024-10"});if(v.type===_a.IncrementalSnapshot&&v.data.source===fi.Mutation)return Fe({},v,{cv:"2024-10",data:Fe({},v.data,{texts:_l(v.data.texts),attributes:_l(v.data.attributes),removes:_l(v.data.removes),adds:_l(v.data.adds)})});if(v.type===_a.IncrementalSnapshot&&v.data.source===fi.StyleSheetRule)return Fe({},v,{cv:"2024-10",data:Fe({},v.data,{adds:v.data.adds?_l(v.data.adds):void 0,removes:v.data.removes?_l(v.data.removes):void 0})})}catch(y){gr.error("could not compress event - will use uncompressed event",y)}return v}(o):o,m={$snapshot_bytes:Ev(p),$snapshot_data:p,$session_id:this.Ft,$window_id:this.pi};this.status!==Lo?this.qi(m):this.gi()}}}}}Li(){if(!this._instance.config.capture_pageview&&ye){var e=this.wi(ye.location.href);this.ji!==e&&(this.hi("$url_changed",{href:e}),this.ji=e)}}Di(){if(this.Zt.length){var e=[...this.Zt];this.Zt=[],e.forEach(n=>{Date.now()-n.enqueuedAt<=2e3&&this.Mi(n)})}}wi(e){var n=this._instance.config.session_recording;if(n.maskNetworkRequestFn){var r,s={url:e};return(r=s=n.maskNetworkRequestFn(s))==null?void 0:r.url}return e}gi(){return this.B={size:0,data:[],sessionId:this.Ft,windowId:this.pi},this.B}li(){this.Bi&&(clearTimeout(this.Bi),this.Bi=void 0);var e=this.Jt,n=this.zt,r=Ir(n)&&n>=0,s=Ir(e)&&r&&n<e;return this.status===Zl||this.status===bT||this.status===Lo||s?(this.Bi=setTimeout(()=>{this.li()},2e3),this.B):(this.B.data.length>0&&w1(this.B).forEach(i=>{this.Hi({$snapshot_bytes:i.size,$snapshot_data:i.data,$session_id:i.sessionId,$window_id:i.windowId,$lib:"web",$lib_version:Ea.LIB_VERSION})}),this.gi())}qi(e){var n,r=2+(((n=this.B)==null?void 0:n.data.length)||0);!this.ti&&(this.B.size+e.$snapshot_bytes+r>943718.4||this.B.sessionId!==this.Ft)&&(this.B=this.li()),this.B.size+=e.$snapshot_bytes,this.B.data.push(e.$snapshot_data),this.Bi||this.ti||(this.Bi=setTimeout(()=>{this.li()},2e3))}Hi(e){this._instance.capture("$snapshot",e,{_url:this._instance.requestRouter.endpointFor("api",this.ci),_noTruncate:!0,_batchKey:"recordings",skip_client_rate_limiting:!0})}Ui(e){var n;this.Lt.triggerStatus(this.sessionId)===Fr&&((n=this._instance)==null||(n=n.persistence)==null||n.register({[e==="url"?d1:f1]:this.Ft}),this.li(),this.ki(e+"_trigger_matched"))}Ni(){this.Yt.urlBlocked||(this.Yt.urlBlocked=!0,clearInterval(this.Si),gr.info("recording paused due to URL blocker"),this.hi("recording paused",{reason:"url blocker"}))}zi(){this.Yt.urlBlocked&&(this.Yt.urlBlocked=!1,this.Fi(),this.Ci(),this.hi("recording resumed",{reason:"left blocked url"}),gr.info("recording resumed"))}yi(){this.Xt.Ct.length!==0&&Zt(this.oi)&&(this.oi=this._instance.on("eventCaptured",e=>{try{this.Xt.Ct.includes(e.event)&&this.Ui("event")}catch(n){gr.error("Could not activate event trigger",n)}}))}overrideLinkedFlag(){this.Qt.linkedFlagSeen=!0,this.Fi(),this.ki("linked_flag_overridden")}overrideSampling(){var e;(e=this._instance.persistence)==null||e.register({[Uf]:!0}),this.Fi(),this.ki("sampling_overridden")}overrideTrigger(e){this.Ui(e)}ki(e,n){this._instance.register_for_session({$session_recording_start_reason:e}),gr.info(e.replace("_"," "),n),It(["recording_initialized","session_id_changed"],e)||this.hi(e,n)}get sdkDebugProperties(){var{sessionStartTimestamp:e}=this.Dt.checkAndGetSessionAndWindowId(!0);return{$recording_status:this.status,$sdk_debug_replay_internal_buffer_length:this.B.data.length,$sdk_debug_replay_internal_buffer_size:this.B.size,$sdk_debug_current_session_duration:this.zt,$sdk_debug_session_start:e}}}var Qw=br("[SegmentIntegration]");function rxe(t,e){var n=t.config.segment;if(!n)return e();(function(r,s){var i=r.config.segment;if(!i)return s();var o=u=>{var d=()=>u.anonymousId()||Eo();r.config.get_device_id=d,u.id()&&(r.register({distinct_id:u.id(),$device_id:d()}),r.persistence.set_property(wa,"identified")),s()},c=i.user();"then"in c&&Zs(c.then)?c.then(u=>o(u)):o(c)})(t,()=>{n.register((r=>{Promise&&Promise.resolve||Qw.warn("This browser does not have Promise support, and can not use the segment integration");var s=(i,o)=>{if(!o)return i;i.event.userId||i.event.anonymousId===r.get_distinct_id()||(Qw.info("No userId set, resetting PostHog"),r.reset()),i.event.userId&&i.event.userId!==r.get_distinct_id()&&(Qw.info("UserId set, identifying with PostHog"),r.identify(i.event.userId));var c=r.calculateEventProperties(o,i.event.properties);return i.event.properties=Object.assign({},c,i.event.properties),i};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:()=>!0,load:()=>Promise.resolve(),track:i=>s(i,i.event.event),page:i=>s(i,"$pageview"),identify:i=>s(i,"$identify"),screen:i=>s(i,"$screen")}})(t)).then(()=>{e()})})}var qU="posthog-js";function HU(t,e){var{organization:n,projectId:r,prefix:s,severityAllowList:i=["error"]}=e===void 0?{}:e;return o=>{var c,u,d,p,m;if(!(i==="*"||i.includes(o.level))||!t.__loaded)return o;o.tags||(o.tags={});var v=t.requestRouter.endpointFor("ui","/project/"+t.config.token+"/person/"+t.get_distinct_id());o.tags["PostHog Person URL"]=v,t.sessionRecordingStarted()&&(o.tags["PostHog Recording URL"]=t.get_session_replay_url({withTimestamp:!0}));var y=((c=o.exception)==null?void 0:c.values)||[],x=y.map(k=>Fe({},k,{stacktrace:k.stacktrace?Fe({},k.stacktrace,{type:"raw",frames:(k.stacktrace.frames||[]).map(S=>Fe({},S,{platform:"web:javascript"}))}):void 0})),w={$exception_message:((u=y[0])==null?void 0:u.value)||o.message,$exception_type:(d=y[0])==null?void 0:d.type,$exception_personURL:v,$exception_level:o.level,$exception_list:x,$sentry_event_id:o.event_id,$sentry_exception:o.exception,$sentry_exception_message:((p=y[0])==null?void 0:p.value)||o.message,$sentry_exception_type:(m=y[0])==null?void 0:m.type,$sentry_tags:o.tags};return n&&r&&(w.$sentry_url=(s||"https://sentry.io/organizations/")+n+"/issues/?project="+r+"&query="+o.event_id),t.exceptions.sendExceptionEvent(w),o}}class sxe{constructor(e,n,r,s,i){this.name=qU,this.setupOnce=function(o){o(HU(e,{organization:n,projectId:r,prefix:s,severityAllowList:i}))}}}var ixe=ye!=null&&ye.location?_v(ye.location.hash,"__posthog")||_v(location.hash,"state"):null,fD="_postHogToolbarParams",hD=br("[Toolbar]"),vo=function(t){return t[t.UNINITIALIZED=0]="UNINITIALIZED",t[t.LOADING=1]="LOADING",t[t.LOADED=2]="LOADED",t}(vo||{});class axe{constructor(e){this.instance=e}Wi(e){bt.ph_toolbar_state=e}Gi(){var e;return(e=bt.ph_toolbar_state)!==null&&e!==void 0?e:vo.UNINITIALIZED}maybeLoadToolbar(e,n,r){if(e===void 0&&(e=void 0),n===void 0&&(n=void 0),r===void 0&&(r=void 0),!ye||!Ue)return!1;e=e??ye.location,r=r??ye.history;try{if(!n){try{ye.localStorage.setItem("test","test"),ye.localStorage.removeItem("test")}catch{return!1}n=ye?.localStorage}var s,i=ixe||_v(e.hash,"__posthog")||_v(e.hash,"state"),o=i?OM(()=>JSON.parse(atob(decodeURIComponent(i))))||OM(()=>JSON.parse(decodeURIComponent(i))):null;return o&&o.action==="ph_authorize"?((s=o).source="url",s&&Object.keys(s).length>0&&(o.desiredHash?e.hash=o.desiredHash:r?r.replaceState(r.state,"",e.pathname+e.search):e.hash="")):((s=JSON.parse(n.getItem(fD)||"{}")).source="localstorage",delete s.userIntent),!(!s.token||this.instance.config.token!==s.token)&&(this.loadToolbar(s),!0)}catch{return!1}}Ji(e){var n=bt.ph_load_toolbar||bt.ph_load_editor;!Zt(n)&&Zs(n)?n(e,this.instance):hD.warn("No toolbar load function found")}loadToolbar(e){var n=!(Ue==null||!Ue.getElementById(vU));if(!ye||n)return!1;var r=this.instance.requestRouter.region==="custom"&&this.instance.config.advanced_disable_toolbar_metrics,s=Fe({token:this.instance.config.token},e,{apiURL:this.instance.requestRouter.endpointFor("ui")},r?{instrument:!1}:{});if(ye.localStorage.setItem(fD,JSON.stringify(Fe({},s,{source:void 0}))),this.Gi()===vo.LOADED)this.Ji(s);else if(this.Gi()===vo.UNINITIALIZED){var i;this.Wi(vo.LOADING),(i=bt.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this.instance,"toolbar",o=>{if(o)return hD.error("[Toolbar] Failed to load",o),void this.Wi(vo.UNINITIALIZED);this.Wi(vo.LOADED),this.Ji(s)}),In(ye,"turbolinks:load",()=>{this.Wi(vo.UNINITIALIZED),this.loadToolbar(s)})}return!0}Vi(e){return this.loadToolbar(e)}maybeLoadEditor(e,n,r){return e===void 0&&(e=void 0),n===void 0&&(n=void 0),r===void 0&&(r=void 0),this.maybeLoadToolbar(e,n,r)}}var oxe=br("[TracingHeaders]");class lxe{constructor(e){this.Ki=void 0,this.Yi=void 0,this.ot=()=>{var n,r;Me(this.Ki)&&((n=bt.__PosthogExtensions__)==null||(n=n.tracingHeadersPatchFns)==null||n._patchXHR(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager)),Me(this.Yi)&&((r=bt.__PosthogExtensions__)==null||(r=r.tracingHeadersPatchFns)==null||r._patchFetch(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager))},this._instance=e}st(e){var n,r;(n=bt.__PosthogExtensions__)!=null&&n.tracingHeadersPatchFns&&e(),(r=bt.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,"tracing-headers",s=>{if(s)return oxe.error("failed to load script",s);e()})}startIfEnabledOrStop(){var e,n;this._instance.config.__add_tracing_headers?this.st(this.ot):((e=this.Ki)==null||e.call(this),(n=this.Yi)==null||n.call(this),this.Ki=void 0,this.Yi=void 0)}}var uo=br("[Web Vitals]"),pD=9e5;class cxe{constructor(e){var n;this.Xi=!1,this.T=!1,this.B={url:void 0,metrics:[],firstMetricTimestamp:void 0},this.Qi=()=>{clearTimeout(this.Zi),this.B.metrics.length!==0&&(this._instance.capture("$web_vitals",this.B.metrics.reduce((r,s)=>Fe({},r,{["$web_vitals_"+s.name+"_event"]:Fe({},s),["$web_vitals_"+s.name+"_value"]:s.value}),{})),this.B={url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.te=r=>{var s,i=(s=this._instance.sessionManager)==null?void 0:s.checkAndGetSessionAndWindowId(!0);if(Me(i))uo.error("Could not read session ID. Dropping metrics!");else{this.B=this.B||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var o=this.ie();Me(o)||(Zt(r?.name)||Zt(r?.value)?uo.error("Invalid metric received",r):this.ee&&r.value>=this.ee?uo.error("Ignoring metric with value >= "+this.ee,r):(this.B.url!==o&&(this.Qi(),this.Zi=setTimeout(this.Qi,this.flushToCaptureTimeoutMs)),Me(this.B.url)&&(this.B.url=o),this.B.firstMetricTimestamp=Me(this.B.firstMetricTimestamp)?Date.now():this.B.firstMetricTimestamp,r.attribution&&r.attribution.interactionTargetElement&&(r.attribution.interactionTargetElement=void 0),this.B.metrics.push(Fe({},r,{$current_url:o,$session_id:i.sessionId,$window_id:i.windowId,timestamp:Date.now()})),this.B.metrics.length===this.allowedMetrics.length&&this.Qi()))}},this.ot=()=>{var r,s,i,o,c=bt.__PosthogExtensions__;Me(c)||Me(c.postHogWebVitalsCallbacks)||({onLCP:r,onCLS:s,onFCP:i,onINP:o}=c.postHogWebVitalsCallbacks),r&&s&&i&&o?(this.allowedMetrics.indexOf("LCP")>-1&&r(this.te.bind(this)),this.allowedMetrics.indexOf("CLS")>-1&&s(this.te.bind(this)),this.allowedMetrics.indexOf("FCP")>-1&&i(this.te.bind(this)),this.allowedMetrics.indexOf("INP")>-1&&o(this.te.bind(this)),this.T=!0):uo.error("web vitals callbacks not loaded - not starting")},this._instance=e,this.Xi=!((n=this._instance.persistence)==null||!n.props[IM]),this.startIfEnabled()}get allowedMetrics(){var e,n,r=Bn(this._instance.config.capture_performance)?(e=this._instance.config.capture_performance)==null?void 0:e.web_vitals_allowed_metrics:void 0;return Me(r)?((n=this._instance.persistence)==null?void 0:n.props[LM])||["CLS","FCP","INP","LCP"]:r}get flushToCaptureTimeoutMs(){return(Bn(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals_delayed_flush_ms:void 0)||5e3}get ee(){var e=Bn(this._instance.config.capture_performance)&&Ir(this._instance.config.capture_performance.__web_vitals_max_value)?this._instance.config.capture_performance.__web_vitals_max_value:pD;return 0<e&&e<=6e4?pD:e}get isEnabled(){var e=ls?.protocol;if(e!=="http:"&&e!=="https:")return uo.info("Web Vitals are disabled on non-http/https protocols"),!1;var n=Bn(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals:$i(this._instance.config.capture_performance)?this._instance.config.capture_performance:void 0;return $i(n)?n:this.Xi}startIfEnabled(){this.isEnabled&&!this.T&&(uo.info("enabled, starting..."),this.st(this.ot))}onRemoteConfig(e){var n=Bn(e.capturePerformance)&&!!e.capturePerformance.web_vitals,r=Bn(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[IM]:n}),this._instance.persistence.register({[LM]:r})),this.Xi=n,this.startIfEnabled()}st(e){var n,r;(n=bt.__PosthogExtensions__)!=null&&n.postHogWebVitalsCallbacks&&e(),(r=bt.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,"web-vitals",s=>{s?uo.error("failed to load script",s):e()})}ie(){var e=ye?ye.location.href:void 0;return e||uo.error("Could not determine current URL"),e}}var uxe=br("[Heatmaps]");function mD(t){return Bn(t)&&"clientX"in t&&"clientY"in t&&Ir(t.clientX)&&Ir(t.clientY)}class dxe{constructor(e){var n;this.rageclicks=new RU,this.Xi=!1,this.T=!1,this.re=null,this.instance=e,this.Xi=!((n=this.instance.persistence)==null||!n.props[l1])}get flushIntervalMilliseconds(){var e=5e3;return Bn(this.instance.config.capture_heatmaps)&&this.instance.config.capture_heatmaps.flush_interval_milliseconds&&(e=this.instance.config.capture_heatmaps.flush_interval_milliseconds),e}get isEnabled(){return Me(this.instance.config.capture_heatmaps)?Me(this.instance.config.enable_heatmaps)?this.Xi:this.instance.config.enable_heatmaps:this.instance.config.capture_heatmaps!==!1}startIfEnabled(){if(this.isEnabled){if(this.T)return;uxe.info("starting..."),this.se(),this.re=setInterval(this.ne.bind(this),this.flushIntervalMilliseconds)}else{var e,n;clearInterval((e=this.re)!==null&&e!==void 0?e:void 0),(n=this.oe)==null||n.stop(),this.getAndClearBuffer()}}onRemoteConfig(e){var n=!!e.heatmaps;this.instance.persistence&&this.instance.persistence.register({[l1]:n}),this.Xi=n,this.startIfEnabled()}getAndClearBuffer(){var e=this.B;return this.B=void 0,e}ae(e){this.le(e.originalEvent,"deadclick")}se(){ye&&Ue&&(In(ye,"beforeunload",this.ne.bind(this)),In(Ue,"click",e=>this.le(e||ye?.event),{capture:!0}),In(Ue,"mousemove",e=>this.ue(e||ye?.event),{capture:!0}),this.oe=new NU(this.instance,gye,this.ae.bind(this)),this.oe.startIfEnabled(),this.T=!0)}he(e,n){var r=this.instance.scrollManager.scrollY(),s=this.instance.scrollManager.scrollX(),i=this.instance.scrollManager.scrollElement(),o=function(c,u,d){for(var p=c;p&&Ry(p)&&!No(p,"body");){if(p===d)return!1;if(It(u,ye?.getComputedStyle(p).position))return!0;p=_U(p)}return!1}(wU(e),["fixed","sticky"],i);return{x:e.clientX+(o?0:s),y:e.clientY+(o?0:r),target_fixed:o,type:n}}le(e,n){var r;if(n===void 0&&(n="click"),!HM(e.target)&&mD(e)){var s=this.he(e,n);(r=this.rageclicks)!=null&&r.isRageClick(e.clientX,e.clientY,new Date().getTime())&&this.de(Fe({},s,{type:"rageclick"})),this.de(s)}}ue(e){!HM(e.target)&&mD(e)&&(clearTimeout(this.ve),this.ve=setTimeout(()=>{this.de(this.he(e,"mousemove"))},500))}de(e){if(ye){var n=ye.location.href;this.B=this.B||{},this.B[n]||(this.B[n]=[]),this.B[n].push(e)}}ne(){this.B&&!hu(this.B)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}}class fxe{constructor(e){this._instance=e}doPageView(e,n){var r,s=this.ce(e,n);return this.fe={pathname:(r=ye?.location.pathname)!==null&&r!==void 0?r:"",pageViewId:n,timestamp:e},this._instance.scrollManager.resetContext(),s}doPageLeave(e){var n;return this.ce(e,(n=this.fe)==null?void 0:n.pageViewId)}doEvent(){var e;return{$pageview_id:(e=this.fe)==null?void 0:e.pageViewId}}ce(e,n){var r=this.fe;if(!r)return{$pageview_id:n};var s={$pageview_id:n,$prev_pageview_id:r.pageViewId},i=this._instance.scrollManager.getContext();if(i&&!this._instance.config.disable_scroll_properties){var{maxScrollHeight:o,lastScrollY:c,maxScrollY:u,maxContentHeight:d,lastContentY:p,maxContentY:m}=i;if(!(Me(o)||Me(c)||Me(u)||Me(d)||Me(p)||Me(m))){o=Math.ceil(o),c=Math.ceil(c),u=Math.ceil(u),d=Math.ceil(d),p=Math.ceil(p),m=Math.ceil(m);var v=o<=1?1:js(c/o,0,1,$e),y=o<=1?1:js(u/o,0,1,$e),x=d<=1?1:js(p/d,0,1,$e),w=d<=1?1:js(m/d,0,1,$e);s=Xn(s,{$prev_pageview_last_scroll:c,$prev_pageview_last_scroll_percentage:v,$prev_pageview_max_scroll:u,$prev_pageview_max_scroll_percentage:y,$prev_pageview_last_content:p,$prev_pageview_last_content_percentage:x,$prev_pageview_max_content:m,$prev_pageview_max_content_percentage:w})}}return r.pathname&&(s.$prev_pageview_pathname=r.pathname),r.timestamp&&(s.$prev_pageview_duration=(e.getTime()-r.timestamp.getTime())/1e3),s}}var hxe=function(t){var e,n,r,s,i="";for(e=n=0,r=(t=(t+"").replace(/\r\n/g,`
1766
1766
  `).replace(/\r/g,`
1767
- `)).length,s=0;s<r;s++){var o=t.charCodeAt(s),c=null;o<128?n++:c=o>127&&o<2048?String.fromCharCode(o>>6|192,63&o|128):String.fromCharCode(o>>12|224,o>>6&63|128,63&o|128),Ko(c)||(n>e&&(i+=t.substring(e,n)),i+=c,e=n=s+1)}return n>e&&(i+=t.substring(e,t.length)),i},pxe=!!i1||!!s1,gD="text/plain",Cv=(t,e)=>{var[n,r]=t.split("?"),s=Fe({},e);r?.split("&").forEach(o=>{var[c]=o.split("=");delete s[c]});var i=rye(s);return n+"?"+(i=i?(r?r+"&":"")+i:r)},Hf=(t,e)=>JSON.stringify(t,(n,r)=>typeof r=="bigint"?r.toString():r,e),Xw=t=>{var{data:e,compression:n}=t;if(e){if(n===Ta.GZipJS){var r=FU(UU(Hf(e)),{mtime:0}),s=new Blob([r],{type:gD});return{contentType:gD,body:s,estimatedSize:s.size}}if(n===Ta.Base64){var i=function(u){var d,p,m,v,y,x="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",w=0,k=0,S="",R=[];if(!u)return u;u=hxe(u);do d=(y=u.charCodeAt(w++)<<16|u.charCodeAt(w++)<<8|u.charCodeAt(w++))>>18&63,p=y>>12&63,m=y>>6&63,v=63&y,R[k++]=x.charAt(d)+x.charAt(p)+x.charAt(m)+x.charAt(v);while(w<u.length);switch(S=R.join(""),u.length%3){case 1:S=S.slice(0,-2)+"==";break;case 2:S=S.slice(0,-1)+"="}return S}(Hf(e)),o=(u=>"data="+encodeURIComponent(typeof u=="string"?u:Hf(u)))(i);return{contentType:"application/x-www-form-urlencoded",body:o,estimatedSize:new Blob([o]).size}}var c=Hf(e);return{contentType:"application/json",body:c,estimatedSize:new Blob([c]).size}}},fh=[];s1&&fh.push({transport:"fetch",method:t=>{var e,n,{contentType:r,body:s,estimatedSize:i}=(e=Xw(t))!==null&&e!==void 0?e:{},o=new Headers;mn(t.headers,function(p,m){o.append(m,p)}),r&&o.append("Content-Type",r);var c=t.url,u=null;if(NM){var d=new NM;u={signal:d.signal,timeout:setTimeout(()=>d.abort(),t.timeout)}}s1(c,Fe({method:t?.method||"GET",headers:o,keepalive:t.method==="POST"&&(i||0)<52428.8,body:s,signal:(n=u)==null?void 0:n.signal},t.fetchOptions)).then(p=>p.text().then(m=>{var v={statusCode:p.status,text:m};if(p.status===200)try{v.json=JSON.parse(m)}catch(y){$e.error(y)}t.callback==null||t.callback(v)})).catch(p=>{$e.error(p),t.callback==null||t.callback({statusCode:0,text:p})}).finally(()=>u?clearTimeout(u.timeout):null)}}),i1&&fh.push({transport:"XHR",method:t=>{var e,n=new i1;n.open(t.method||"GET",t.url,!0);var{contentType:r,body:s}=(e=Xw(t))!==null&&e!==void 0?e:{};mn(t.headers,function(i,o){n.setRequestHeader(o,i)}),r&&n.setRequestHeader("Content-Type",r),t.timeout&&(n.timeout=t.timeout),n.withCredentials=!0,n.onreadystatechange=()=>{if(n.readyState===4){var i={statusCode:n.status,text:n.responseText};if(n.status===200)try{i.json=JSON.parse(n.responseText)}catch{}t.callback==null||t.callback(i)}},n.send(s)}}),Ns!=null&&Ns.sendBeacon&&fh.push({transport:"sendBeacon",method:t=>{var e=Cv(t.url,{beacon:"1"});try{var n,{contentType:r,body:s}=(n=Xw(t))!==null&&n!==void 0?n:{},i=typeof s=="string"?new Blob([s],{type:r}):s;Ns.sendBeacon(e,i)}catch{}}});var Wu=function(t,e){if(!function(n){try{new RegExp(n)}catch{return!1}return!0}(e))return!1;try{return new RegExp(e).test(t)}catch{return!1}};function vD(t,e,n){return Hf({distinct_id:t,userPropertiesToSet:e,userPropertiesToSetOnce:n})}var mxe={exact:(t,e)=>e.some(n=>t.some(r=>n===r)),is_not:(t,e)=>e.every(n=>t.every(r=>n!==r)),regex:(t,e)=>e.some(n=>t.some(r=>Wu(n,r))),not_regex:(t,e)=>e.every(n=>t.every(r=>!Wu(n,r))),icontains:(t,e)=>e.map(rg).some(n=>t.map(rg).some(r=>n.includes(r))),not_icontains:(t,e)=>e.map(rg).every(n=>t.map(rg).every(r=>!n.includes(r)))},rg=t=>t.toLowerCase(),yD=br("[Error tracking]");class gxe{constructor(e){var n,r;this.pe=[],this._instance=e,this.pe=(n=(r=this._instance.persistence)==null?void 0:r.get_property(c1))!==null&&n!==void 0?n:[]}onRemoteConfig(e){var n,r,s,i=(n=(r=e.errorTracking)==null?void 0:r.suppressionRules)!==null&&n!==void 0?n:[],o=(s=e.errorTracking)==null?void 0:s.captureExtensionExceptions;this.pe=i,this._instance.persistence&&this._instance.persistence.register({[c1]:this.pe,[DM]:o})}get ge(){var e,n=!!this._instance.get_property(DM),r=this._instance.config.error_tracking.captureExtensionExceptions;return(e=r??n)!==null&&e!==void 0&&e}sendExceptionEvent(e){if(this._e(e))yD.info("Skipping exception capture because a suppression rule matched");else{if(this.ge||!this.me(e))return this._instance.capture("$exception",e,{_noTruncate:!0,_batchKey:"exceptionEvent"});yD.info("Skipping exception capture because it was thrown by an extension")}}_e(e){var n=e.$exception_list;if(!n||!kn(n)||n.length===0)return!1;var r=n.reduce((s,i)=>{var{type:o,value:c}=i;return qn(o)&&o.length>0&&s.$exception_types.push(o),qn(c)&&c.length>0&&s.$exception_values.push(c),s},{$exception_types:[],$exception_values:[]});return this.pe.some(s=>{var i=s.values.map(o=>{var c,u=mxe[o.operator],d=kn(o.value)?o.value:[o.value],p=(c=r[o.key])!==null&&c!==void 0?c:[];return d.length>0&&u(d,p)});return s.type==="OR"?i.some(Boolean):i.every(Boolean)})}me(e){var n=e.$exception_list;return!(!n||!kn(n))&&n.flatMap(r=>{var s,i;return(s=(i=r.stacktrace)==null?void 0:i.frames)!==null&&s!==void 0?s:[]}).some(r=>r.filename&&r.filename.startsWith("chrome-extension://"))}}var ei="Mobile",Rv="iOS",Fi="Android",Bh="Tablet",GU=Fi+" "+Bh,YU="iPad",WU="Apple",KU=WU+" Watch",qh="Safari",Ku="BlackBerry",QU="Samsung",XU=QU+"Browser",ZU=QU+" Internet",Jl="Chrome",vxe=Jl+" OS",JU=Jl+" "+Rv,_T="Internet Explorer",e6=_T+" "+ei,ST="Opera",yxe=ST+" Mini",ET="Edge",t6="Microsoft "+ET,ju="Firefox",n6=ju+" "+Rv,Hh="Nintendo",Gh="PlayStation",Ou="Xbox",r6=Fi+" "+ei,s6=ei+" "+qh,Gf="Windows",R1=Gf+" Phone",xD="Nokia",A1="Ouya",i6="Generic",xxe=i6+" "+ei.toLowerCase(),a6=i6+" "+Bh.toLowerCase(),N1="Konqueror",Yr="(\\d+(\\.\\d+)?)",Zw=new RegExp("Version/"+Yr),bxe=new RegExp(Ou,"i"),wxe=new RegExp(Gh+" \\w+","i"),_xe=new RegExp(Hh+" \\w+","i"),kT=new RegExp(Ku+"|PlayBook|BB10","i"),Sxe={"NT3.51":"NT 3.11","NT4.0":"NT 4.0","5.0":"2000",5.1:"XP",5.2:"XP","6.0":"Vista",6.1:"7",6.2:"8",6.3:"8.1",6.4:"10","10.0":"10"},Exe=(t,e)=>e&&It(e,WU)||function(n){return It(n,qh)&&!It(n,Jl)&&!It(n,Fi)}(t),o6=function(t,e){return e=e||"",It(t," OPR/")&&It(t,"Mini")?yxe:It(t," OPR/")?ST:kT.test(t)?Ku:It(t,"IE"+ei)||It(t,"WPDesktop")?e6:It(t,XU)?ZU:It(t,ET)||It(t,"Edg/")?t6:It(t,"FBIOS")?"Facebook "+ei:It(t,"UCWEB")||It(t,"UCBrowser")?"UC Browser":It(t,"CriOS")?JU:It(t,"CrMo")||It(t,Jl)?Jl:It(t,Fi)&&It(t,qh)?r6:It(t,"FxiOS")?n6:It(t.toLowerCase(),N1.toLowerCase())?N1:Exe(t,e)?It(t,ei)?s6:qh:It(t,ju)?ju:It(t,"MSIE")||It(t,"Trident/")?_T:It(t,"Gecko")?ju:""},kxe={[e6]:[new RegExp("rv:"+Yr)],[t6]:[new RegExp(ET+"?\\/"+Yr)],[Jl]:[new RegExp("("+Jl+"|CrMo)\\/"+Yr)],[JU]:[new RegExp("CriOS\\/"+Yr)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+Yr)],[qh]:[Zw],[s6]:[Zw],[ST]:[new RegExp("(Opera|OPR)\\/"+Yr)],[ju]:[new RegExp(ju+"\\/"+Yr)],[n6]:[new RegExp("FxiOS\\/"+Yr)],[N1]:[new RegExp("Konqueror[:/]?"+Yr,"i")],[Ku]:[new RegExp(Ku+" "+Yr),Zw],[r6]:[new RegExp("android\\s"+Yr,"i")],[ZU]:[new RegExp(XU+"\\/"+Yr)],[_T]:[new RegExp("(rv:|MSIE )"+Yr)],Mozilla:[new RegExp("rv:"+Yr)]},Txe=function(t,e){var n=o6(t,e),r=kxe[n];if(Me(r))return null;for(var s=0;s<r.length;s++){var i=r[s],o=t.match(i);if(o)return parseFloat(o[o.length-2])}return null},bD=[[new RegExp(Ou+"; "+Ou+" (.*?)[);]","i"),t=>[Ou,t&&t[1]||""]],[new RegExp(Hh,"i"),[Hh,""]],[new RegExp(Gh,"i"),[Gh,""]],[kT,[Ku,""]],[new RegExp(Gf,"i"),(t,e)=>{if(/Phone/.test(e)||/WPDesktop/.test(e))return[R1,""];if(new RegExp(ei).test(e)&&!/IEMobile\b/.test(e))return[Gf+" "+ei,""];var n=/Windows NT ([0-9.]+)/i.exec(e);if(n&&n[1]){var r=n[1],s=Sxe[r]||"";return/arm/i.test(e)&&(s="RT"),[Gf,s]}return[Gf,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,t=>{if(t&&t[3]){var e=[t[3],t[4],t[5]||"0"];return[Rv,e.join(".")]}return[Rv,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,t=>{var e="";return t&&t.length>=3&&(e=Me(t[2])?t[3]:t[2]),["watchOS",e]}],[new RegExp("("+Fi+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+Fi+")","i"),t=>{if(t&&t[2]){var e=[t[2],t[3],t[4]||"0"];return[Fi,e.join(".")]}return[Fi,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,t=>{var e=["Mac OS X",""];if(t&&t[1]){var n=[t[1],t[2],t[3]||"0"];e[1]=n.join(".")}return e}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[vxe,""]],[/Linux|debian/i,["Linux",""]]],wD=function(t){return _xe.test(t)?Hh:wxe.test(t)?Gh:bxe.test(t)?Ou:new RegExp(A1,"i").test(t)?A1:new RegExp("("+R1+"|WPDesktop)","i").test(t)?R1:/iPad/.test(t)?YU:/iPod/.test(t)?"iPod Touch":/iPhone/.test(t)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(t)?KU:kT.test(t)?Ku:/(kobo)\s(ereader|touch)/i.test(t)?"Kobo":new RegExp(xD,"i").test(t)?xD:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(t)||/(kf[a-z]+)( bui|\)).+silk\//i.test(t)?"Kindle Fire":/(Android|ZTE)/i.test(t)?!new RegExp(ei).test(t)||/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(t)?/pixel[\daxl ]{1,6}/i.test(t)&&!/pixel c/i.test(t)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(t)||/lmy47v/i.test(t)&&!/QTAQZ3/i.test(t)?Fi:GU:Fi:new RegExp("(pda|"+ei+")","i").test(t)?xxe:new RegExp(Bh,"i").test(t)&&!new RegExp(Bh+" pc","i").test(t)?a6:""},sg="https?://(.*)",Ny=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],Cxe=Cy(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],Ny),TT="<masked>",Rxe=["li_fat_id"];function l6(t,e,n){if(!Ue)return{};var r,s=e?Cy([],Ny,n||[]):[],i=c6(mT(Ue.URL,s,TT),t),o=(r={},mn(Rxe,function(c){var u=Yi.J(c);r[c]=u||null}),r);return Xn(o,i)}function c6(t,e){var n=Cxe.concat(e||[]),r={};return mn(n,function(s){var i=wv(t,s);r[s]=i||null}),r}function u6(t){var e=function(i){return i?i.search(sg+"google.([^/?]*)")===0?"google":i.search(sg+"bing.com")===0?"bing":i.search(sg+"yahoo.com")===0?"yahoo":i.search(sg+"duckduckgo.com")===0?"duckduckgo":null:null}(t),n=e!="yahoo"?"q":"p",r={};if(!Ko(e)){r.$search_engine=e;var s=Ue?wv(Ue.referrer,n):"";s.length&&(r.ph_keyword=s)}return r}function _D(){return navigator.language||navigator.userLanguage}function d6(){return Ue?.referrer||"$direct"}function f6(t,e){var n=t?Cy([],Ny,e||[]):[],r=ls?.href.substring(0,1e3);return{r:d6().substring(0,1e3),u:r?mT(r,n,TT):void 0}}function h6(t){var e,{r:n,u:r}=t,s={$referrer:n,$referring_domain:n==null?void 0:n=="$direct"?"$direct":(e=Gu(n))==null?void 0:e.host};if(r){s.$current_url=r;var i=Gu(r);s.$host=i?.host,s.$pathname=i?.pathname;var o=c6(r);Xn(s,o)}if(n){var c=u6(n);Xn(s,c)}return s}function p6(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function Axe(){try{return new Date().getTimezoneOffset()}catch{return}}function Nxe(t,e){if(!os)return{};var n,r,s,i=t?Cy([],Ny,e||[]):[],[o,c]=function(u){for(var d=0;d<bD.length;d++){var[p,m]=bD[d],v=p.exec(u),y=v&&(Zs(m)?m(v,u):m);if(y)return y}return["",""]}(os);return Xn(hT({$os:o,$os_version:c,$browser:o6(os,navigator.vendor),$device:wD(os),$device_type:(r=os,s=wD(r),s===YU||s===GU||s==="Kobo"||s==="Kindle Fire"||s===a6?Bh:s===Hh||s===Ou||s===Gh||s===A1?"Console":s===KU?"Wearable":s?ei:"Desktop"),$timezone:p6(),$timezone_offset:Axe()}),{$current_url:mT(ls?.href,i,TT),$host:ls?.host,$pathname:ls?.pathname,$raw_user_agent:os.length>1e3?os.substring(0,997)+"...":os,$browser_version:Txe(os,navigator.vendor),$browser_language:_D(),$browser_language_prefix:(n=_D(),typeof n=="string"?n.split("-")[0]:void 0),$screen_height:ye?.screen.height,$screen_width:ye?.screen.width,$viewport_height:ye?.innerHeight,$viewport_width:ye?.innerWidth,$lib:"web",$lib_version:Ea.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})}var Oi=br("[FeatureFlags]"),Jw="$active_feature_flags",Wc="$override_feature_flags",SD="$feature_flag_payloads",kf="$override_feature_flag_payloads",ED="$feature_flag_request_id",kD=t=>{var e={};for(var[n,r]of yg(t||{}))r&&(e[n]=r);return e},jxe=t=>{var e=t.flags;return e?(t.featureFlags=Object.fromEntries(Object.keys(e).map(n=>{var r;return[n,(r=e[n].variant)!==null&&r!==void 0?r:e[n].enabled]})),t.featureFlagPayloads=Object.fromEntries(Object.keys(e).filter(n=>e[n].enabled).filter(n=>{var r;return(r=e[n].metadata)==null?void 0:r.payload}).map(n=>{var r;return[n,(r=e[n].metadata)==null?void 0:r.payload]}))):Oi.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),t},Oxe=function(t){return t.FeatureFlags="feature_flags",t.Recordings="recordings",t}({});class Pxe{constructor(e){this.be=!1,this.ye=!1,this.we=!1,this.Se=!1,this.$e=!1,this.xe=!1,this.ke=!1,this._instance=e,this.featureFlagEventHandlers=[]}flags(){if(this._instance.config.__preview_remote_config)this.xe=!0;else{var e=!this.Ee&&(this._instance.config.advanced_disable_feature_flags||this._instance.config.advanced_disable_feature_flags_on_first_load);this.Ie({disableFlags:e})}}get hasLoadedFlags(){return this.ye}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var e=this._instance.get_property(h1),n=this._instance.get_property(Wc),r=this._instance.get_property(kf);if(!r&&!n)return e||{};var s=Xn({},e||{}),i=[...new Set([...Object.keys(r||{}),...Object.keys(n||{})])];for(var o of i){var c,u,d=s[o],p=n?.[o],m=Me(p)?(c=d?.enabled)!==null&&c!==void 0&&c:!!p,v=Me(p)?d.variant:typeof p=="string"?p:void 0,y=r?.[o],x=Fe({},d,{enabled:m,variant:m?v??d?.variant:void 0});m!==d?.enabled&&(x.original_enabled=d?.enabled),v!==d?.variant&&(x.original_variant=d?.variant),y&&(x.metadata=Fe({},d?.metadata,{payload:y,original_payload:d==null||(u=d.metadata)==null?void 0:u.payload})),s[o]=x}return this.be||(Oi.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:r,finalDetails:s}),this.be=!0),s}getFlagVariants(){var e=this._instance.get_property(pu),n=this._instance.get_property(Wc);if(!n)return e||{};for(var r=Xn({},e),s=Object.keys(n),i=0;i<s.length;i++)r[s[i]]=n[s[i]];return this.be||(Oi.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:n,finalFlags:r}),this.be=!0),r}getFlagPayloads(){var e=this._instance.get_property(SD),n=this._instance.get_property(kf);if(!n)return e||{};for(var r=Xn({},e||{}),s=Object.keys(n),i=0;i<s.length;i++)r[s[i]]=n[s[i]];return this.be||(Oi.warn(" Overriding feature flag payloads!",{flagPayloads:e,overriddenPayloads:n,finalPayloads:r}),this.be=!0),r}reloadFeatureFlags(){this.Se||this._instance.config.advanced_disable_feature_flags||this.Ee||(this.Ee=setTimeout(()=>{this.Ie()},5))}Pe(){clearTimeout(this.Ee),this.Ee=void 0}ensureFlagsLoaded(){this.ye||this.we||this.Ee||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this.Se=e}Ie(e){var n;if(this.Pe(),!this._instance.j())if(this.we)this.$e=!0;else{var r={token:this._instance.config.token,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:Fe({},((n=this._instance.persistence)==null?void 0:n.get_initial_props())||{},this._instance.get_property(Bf)||{}),group_properties:this._instance.get_property(Tl)};(e!=null&&e.disableFlags||this._instance.config.advanced_disable_feature_flags)&&(r.disable_flags=!0);var s=this._instance.config.__preview_remote_config,i=s?"/flags/?v=2":"/flags/?v=2&config=true",o=this._instance.config.advanced_only_evaluate_survey_feature_flags?"&only_evaluate_survey_feature_flags=true":"",c=this._instance.requestRouter.endpointFor("api",i+o);s&&(r.timezone=p6()),this.we=!0,this._instance.Re({method:"POST",url:c,data:r,compression:this._instance.config.disable_compression?void 0:Ta.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:u=>{var d,p,m=!0;if(u.statusCode===200&&(this.$e||(this.$anon_distinct_id=void 0),m=!1),this.we=!1,this.xe||(this.xe=!0,this._instance.Te((p=u.json)!==null&&p!==void 0?p:{})),!r.disable_flags||this.$e)if(this.ke=!m,u.json&&(d=u.json.quotaLimited)!=null&&d.includes(Oxe.FeatureFlags))Oi.warn("You have hit your feature flags quota limit, and will not be able to load feature flags until the quota is reset. Please visit https://posthog.com/docs/billing/limits-alerts to learn more.");else{var v;r.disable_flags||this.receivedFeatureFlags((v=u.json)!==null&&v!==void 0?v:{},m),this.$e&&(this.$e=!1,this.Ie())}}})}}getFeatureFlag(e,n){if(n===void 0&&(n={}),this.ye||this.getFlags()&&this.getFlags().length>0){var r=this.getFlagVariants()[e],s=""+r,i=this._instance.get_property(ED)||void 0,o=this._instance.get_property(vv)||{};if((n.send_event||!("send_event"in n))&&(!(e in o)||!o[e].includes(s))){var c,u,d,p,m,v,y,x,w;kn(o[e])?o[e].push(s):o[e]=[s],(c=this._instance.persistence)==null||c.register({[vv]:o});var k=this.getFeatureFlagDetails(e),S={$feature_flag:e,$feature_flag_response:r,$feature_flag_payload:this.getFeatureFlagPayload(e)||null,$feature_flag_request_id:i,$feature_flag_bootstrapped_response:((u=this._instance.config.bootstrap)==null||(u=u.featureFlags)==null?void 0:u[e])||null,$feature_flag_bootstrapped_payload:((d=this._instance.config.bootstrap)==null||(d=d.featureFlagPayloads)==null?void 0:d[e])||null,$used_bootstrap_value:!this.ke};Me(k==null||(p=k.metadata)==null?void 0:p.version)||(S.$feature_flag_version=k.metadata.version);var R,C=(m=k==null||(v=k.reason)==null?void 0:v.description)!==null&&m!==void 0?m:k==null||(y=k.reason)==null?void 0:y.code;C&&(S.$feature_flag_reason=C),k!=null&&(x=k.metadata)!=null&&x.id&&(S.$feature_flag_id=k.metadata.id),Me(k?.original_variant)&&Me(k?.original_enabled)||(S.$feature_flag_original_response=Me(k.original_variant)?k.original_enabled:k.original_variant),k!=null&&(w=k.metadata)!=null&&w.original_payload&&(S.$feature_flag_original_payload=k==null||(R=k.metadata)==null?void 0:R.original_payload),this._instance.capture("$feature_flag_called",S)}return r}Oi.warn('getFeatureFlag for key "'+e+`" failed. Feature flags didn't load in time.`)}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){return this.getFlagPayloads()[e]}getRemoteConfigPayload(e,n){var r=this._instance.config.token;this._instance.Re({method:"POST",url:this._instance.requestRouter.endpointFor("api","/flags/?v=2&config=true"),data:{distinct_id:this._instance.get_distinct_id(),token:r},compression:this._instance.config.disable_compression?void 0:Ta.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:s=>{var i,o=(i=s.json)==null?void 0:i.featureFlagPayloads;n(o?.[e]||void 0)}})}isFeatureEnabled(e,n){if(n===void 0&&(n={}),this.ye||this.getFlags()&&this.getFlags().length>0)return!!this.getFeatureFlag(e,n);Oi.warn('isFeatureEnabled for key "'+e+`" failed. Feature flags didn't load in time.`)}addFeatureFlagsHandler(e){this.featureFlagEventHandlers.push(e)}removeFeatureFlagsHandler(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter(n=>n!==e)}receivedFeatureFlags(e,n){if(this._instance.persistence){this.ye=!0;var r=this.getFlagVariants(),s=this.getFlagPayloads(),i=this.getFlagsWithDetails();(function(o,c,u,d,p){u===void 0&&(u={}),d===void 0&&(d={}),p===void 0&&(p={});var m=jxe(o),v=m.flags,y=m.featureFlags,x=m.featureFlagPayloads;if(y){var w=o.requestId;if(kn(y)){Oi.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var k={};if(y)for(var S=0;S<y.length;S++)k[y[S]]=!0;c&&c.register({[Jw]:y,[pu]:k})}else{var R=y,C=x,A=v;o.errorsWhileComputingFlags&&(R=Fe({},u,R),C=Fe({},d,C),A=Fe({},p,A)),c&&c.register(Fe({[Jw]:Object.keys(kD(R)),[pu]:R||{},[SD]:C||{},[h1]:A||{}},w?{[ED]:w}:{}))}}})(e,this._instance.persistence,r,s,i),this.Ce(n)}}override(e,n){n===void 0&&(n=!1),Oi.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:n})}overrideFeatureFlags(e){if(!this._instance.__loaded||!this._instance.persistence)return Oi.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(e===!1)return this._instance.persistence.unregister(Wc),this._instance.persistence.unregister(kf),void this.Ce();if(e&&typeof e=="object"&&("flags"in e||"payloads"in e)){var n,r=e;if(this.be=!!((n=r.suppressWarning)!==null&&n!==void 0&&n),"flags"in r){if(r.flags===!1)this._instance.persistence.unregister(Wc);else if(r.flags)if(kn(r.flags)){for(var s={},i=0;i<r.flags.length;i++)s[r.flags[i]]=!0;this._instance.persistence.register({[Wc]:s})}else this._instance.persistence.register({[Wc]:r.flags})}return"payloads"in r&&(r.payloads===!1?this._instance.persistence.unregister(kf):r.payloads&&this._instance.persistence.register({[kf]:r.payloads})),void this.Ce()}this.Ce()}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this.ye){var{flags:n,flagVariants:r}=this.Me();e(n,r)}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,n,r){var s,i=(this._instance.get_property(Vf)||[]).find(d=>d.flagKey===e),o={["$feature_enrollment/"+e]:n},c={$feature_flag:e,$feature_enrollment:n,$set:o};i&&(c.$early_access_feature_name=i.name),r&&(c.$feature_enrollment_stage=r),this._instance.capture("$feature_enrollment_update",c),this.setPersonPropertiesForFlags(o,!1);var u=Fe({},this.getFlagVariants(),{[e]:n});(s=this._instance.persistence)==null||s.register({[Jw]:Object.keys(kD(u)),[pu]:u}),this.Ce()}getEarlyAccessFeatures(e,n,r){n===void 0&&(n=!1);var s=this._instance.get_property(Vf),i=r?"&"+r.map(o=>"stage="+o).join("&"):"";if(s&&!n)return e(s);this._instance.Re({url:this._instance.requestRouter.endpointFor("api","/api/early_access_features/?token="+this._instance.config.token+i),method:"GET",callback:o=>{var c,u;if(o.json){var d=o.json.earlyAccessFeatures;return(c=this._instance.persistence)==null||c.unregister(Vf),(u=this._instance.persistence)==null||u.register({[Vf]:d}),e(d)}}})}Me(){var e=this.getFlags(),n=this.getFlagVariants();return{flags:e.filter(r=>n[r]),flagVariants:Object.keys(n).filter(r=>n[r]).reduce((r,s)=>(r[s]=n[s],r),{})}}Ce(e){var{flags:n,flagVariants:r}=this.Me();this.featureFlagEventHandlers.forEach(s=>s(n,r,{errorsLoading:e}))}setPersonPropertiesForFlags(e,n){n===void 0&&(n=!0);var r=this._instance.get_property(Bf)||{};this._instance.register({[Bf]:Fe({},r,e)}),n&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister(Bf)}setGroupPropertiesForFlags(e,n){n===void 0&&(n=!0);var r=this._instance.get_property(Tl)||{};Object.keys(r).length!==0&&Object.keys(r).forEach(s=>{r[s]=Fe({},r[s],e[s]),delete e[s]}),this._instance.register({[Tl]:Fe({},r,e)}),n&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var n=this._instance.get_property(Tl)||{};this._instance.register({[Tl]:Fe({},n,{[e]:{}})})}else this._instance.unregister(Tl)}reset(){this.ye=!1,this.we=!1,this.Se=!1,this.$e=!1,this.xe=!1,this.ke=!1,this.$anon_distinct_id=void 0,this.Pe(),this.be=!1}}var Mxe=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"];class e_{constructor(e,n){this.O=e,this.props={},this.Fe=!1,this.Oe=(r=>{var s="";return r.token&&(s=r.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),r.persistence_name?"ph_"+r.persistence_name:"ph_"+s+"_posthog"})(e),this.tt=this.Ae(e),this.load(),e.debug&&$e.info("Persistence loaded",e.persistence,Fe({},this.props)),this.update_config(e,e,n),this.save()}isDisabled(){return!!this.De}Ae(e){Mxe.indexOf(e.persistence.toLowerCase())===-1&&($e.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var n=e.persistence.toLowerCase();return n==="localstorage"&&dr.W()?dr:n==="localstorage+cookie"&&Xm.W()?Xm:n==="sessionstorage"&&Rr.W()?Rr:n==="memory"?pye:n==="cookie"?Yi:Xm.W()?Xm:Yi}properties(){var e={};return mn(this.props,function(n,r){if(r===pu&&Bn(n))for(var s=Object.keys(n),i=0;i<s.length;i++)e["$feature/"+s[i]]=n[s[i]];else c=r,u=!1,(Ko(o=Yve)?u:AM&&o.indexOf===AM?o.indexOf(c)!=-1:(mn(o,function(d){if(u||(u=d===c))return mv}),u))||(e[r]=n);var o,c,u}),e}load(){if(!this.De){var e=this.tt.V(this.Oe);e&&(this.props=Xn({},e))}}save(){this.De||this.tt.K(this.Oe,this.props,this.je,this.Le,this.Ne,this.O.debug)}remove(){this.tt.Y(this.Oe,!1),this.tt.Y(this.Oe,!0)}clear(){this.remove(),this.props={}}register_once(e,n,r){if(Bn(e)){Me(n)&&(n="None"),this.je=Me(r)?this.ze:r;var s=!1;if(mn(e,(i,o)=>{this.props.hasOwnProperty(o)&&this.props[o]!==n||(this.props[o]=i,s=!0)}),s)return this.save(),!0}return!1}register(e,n){if(Bn(e)){this.je=Me(n)?this.ze:n;var r=!1;if(mn(e,(s,i)=>{e.hasOwnProperty(i)&&this.props[i]!==s&&(this.props[i]=s,r=!0)}),r)return this.save(),!0}return!1}unregister(e){e in this.props&&(delete this.props[e],this.save())}update_campaign_params(){if(!this.Fe){var e=l6(this.O.custom_campaign_params,this.O.mask_personal_data_properties,this.O.custom_personal_data_properties);hu(hT(e))||this.register(e),this.Fe=!0}}update_search_keyword(){var e;this.register((e=Ue?.referrer)?u6(e):{})}update_referrer_info(){var e;this.register_once({$referrer:d6(),$referring_domain:Ue!=null&&Ue.referrer&&((e=Gu(Ue.referrer))==null?void 0:e.host)||"$direct"},void 0)}set_initial_person_info(){this.props[v1]||this.props[y1]||this.register_once({[yv]:f6(this.O.mask_personal_data_properties,this.O.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};mn([y1,v1],o=>{var c=this.props[o];c&&mn(c,function(u,d){e["$initial_"+a1(d)]=u})});var n,r,s=this.props[yv];if(s){var i=(n=h6(s),r={},mn(n,function(o,c){r["$initial_"+a1(c)]=o}),r);Xn(e,i)}return e}safe_merge(e){return mn(this.props,function(n,r){r in e||(e[r]=n)}),e}update_config(e,n,r){if(this.ze=this.je=e.cookie_expiration,this.set_disabled(e.disable_persistence||!!r),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),e.persistence!==n.persistence){var s=this.Ae(e),i=this.props;this.clear(),this.tt=s,this.props=i,this.save()}}set_disabled(e){this.De=e,this.De?this.remove():this.save()}set_cross_subdomain(e){e!==this.Le&&(this.Le=e,this.remove(),this.save())}set_secure(e){e!==this.Ne&&(this.Ne=e,this.remove(),this.save())}set_event_timer(e,n){var r=this.props[Ff]||{};r[e]=n,this.props[Ff]=r,this.save()}remove_event_timer(e){var n=(this.props[Ff]||{})[e];return Me(n)||(delete this.props[Ff][e],this.save()),n}get_property(e){return this.props[e]}set_property(e,n){this.props[e]=n,this.save()}}class m6{constructor(){this.Ue={},this.Ue={}}on(e,n){return this.Ue[e]||(this.Ue[e]=[]),this.Ue[e].push(n),()=>{this.Ue[e]=this.Ue[e].filter(r=>r!==n)}}emit(e,n){for(var r of this.Ue[e]||[])r(n);for(var s of this.Ue["*"]||[])s(e,n)}}class Cl{constructor(e){this.qe=new m6,this.Be=(n,r)=>this.He(n,r)&&this.We(n,r)&&this.Ge(n,r),this.He=(n,r)=>r==null||!r.event||n?.event===r?.event,this._instance=e,this.Je=new Set,this.Ve=new Set}init(){var e;if(!Me((e=this._instance)==null?void 0:e.Ke)){var n;(n=this._instance)==null||n.Ke((r,s)=>{this.on(r,s)})}}register(e){var n,r;if(!Me((n=this._instance)==null?void 0:n.Ke)&&(e.forEach(o=>{var c,u;(c=this.Ve)==null||c.add(o),(u=o.steps)==null||u.forEach(d=>{var p;(p=this.Je)==null||p.add(d?.event||"")})}),(r=this._instance)!=null&&r.autocapture)){var s,i=new Set;e.forEach(o=>{var c;(c=o.steps)==null||c.forEach(u=>{u!=null&&u.selector&&i.add(u?.selector)})}),(s=this._instance)==null||s.autocapture.setElementSelectors(i)}}on(e,n){var r;n!=null&&e.length!=0&&(this.Je.has(e)||this.Je.has(n?.event))&&this.Ve&&((r=this.Ve)==null?void 0:r.size)>0&&this.Ve.forEach(s=>{this.Ye(n,s)&&this.qe.emit("actionCaptured",s.name)})}Xe(e){this.onAction("actionCaptured",n=>e(n))}Ye(e,n){if(n?.steps==null)return!1;for(var r of n.steps)if(this.Be(e,r))return!0;return!1}onAction(e,n){return this.qe.on(e,n)}We(e,n){if(n!=null&&n.url){var r,s=e==null||(r=e.properties)==null?void 0:r.$current_url;if(!s||typeof s!="string"||!Cl.Qe(s,n?.url,n?.url_matching||"contains"))return!1}return!0}static Qe(e,n,r){switch(r){case"regex":return!!ye&&Wu(e,n);case"exact":return n===e;case"contains":var s=Cl.Ze(n).replace(/_/g,".").replace(/%/g,".*");return Wu(e,s);default:return!1}}static Ze(e){return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}Ge(e,n){if((n!=null&&n.href||n!=null&&n.tag_name||n!=null&&n.text)&&!this.tr(e).some(i=>!(n!=null&&n.href&&!Cl.Qe(i.href||"",n?.href,n?.href_matching||"exact"))&&(n==null||!n.tag_name||i.tag_name===n?.tag_name)&&!(n!=null&&n.text&&!Cl.Qe(i.text||"",n?.text,n?.text_matching||"exact")&&!Cl.Qe(i.$el_text||"",n?.text,n?.text_matching||"exact"))))return!1;if(n!=null&&n.selector){var r,s=e==null||(r=e.properties)==null?void 0:r.$element_selectors;if(!s||!s.includes(n?.selector))return!1}return!0}tr(e){return e?.properties.$elements==null?[]:e?.properties.$elements}}(function(t){return t.Button="button",t.Tab="tab",t.Selector="selector",t})({});(function(t){return t.TopLeft="top_left",t.TopRight="top_right",t.TopCenter="top_center",t.MiddleLeft="middle_left",t.MiddleRight="middle_right",t.MiddleCenter="middle_center",t.Left="left",t.Center="center",t.Right="right",t.NextToTrigger="next_to_trigger",t})({});var t_=function(t){return t.Popover="popover",t.API="api",t.Widget="widget",t.ExternalSurvey="external_survey",t}({});(function(t){return t.Open="open",t.MultipleChoice="multiple_choice",t.SingleChoice="single_choice",t.Rating="rating",t.Link="link",t})({});(function(t){return t.NextQuestion="next_question",t.End="end",t.ResponseBased="response_based",t.SpecificQuestion="specific_question",t})({});(function(t){return t.Once="once",t.Recurring="recurring",t.Always="always",t})({});var n_=function(t){return t.SHOWN="survey shown",t.DISMISSED="survey dismissed",t.SENT="survey sent",t}({}),TD=function(t){return t.SURVEY_ID="$survey_id",t.SURVEY_NAME="$survey_name",t.SURVEY_RESPONSE="$survey_response",t.SURVEY_ITERATION="$survey_iteration",t.SURVEY_ITERATION_START_DATE="$survey_iteration_start_date",t.SURVEY_PARTIALLY_COMPLETED="$survey_partially_completed",t.SURVEY_SUBMISSION_ID="$survey_submission_id",t.SURVEY_QUESTIONS="$survey_questions",t.SURVEY_COMPLETED="$survey_completed",t}({}),tr=br("[Surveys]"),j1="seenSurvey_",Dxe=(t,e)=>{var n="$survey_"+e+"/"+t.id;return t.current_iteration&&t.current_iteration>0&&(n="$survey_"+e+"/"+t.id+"/"+t.current_iteration),n},CD=t=>{var e=""+j1+t.id;return t.current_iteration&&t.current_iteration>0&&(e=""+j1+t.id+"_"+t.current_iteration),e},Ixe=[t_.Popover,t_.Widget,t_.API];class Lxe{constructor(e){this._instance=e,this.ir=new Map,this.er=new Map}register(e){var n;Me((n=this._instance)==null?void 0:n.Ke)||(this.rr(e),this.sr(e))}sr(e){var n=e.filter(r=>{var s,i;return((s=r.conditions)==null?void 0:s.actions)&&((i=r.conditions)==null||(i=i.actions)==null||(i=i.values)==null?void 0:i.length)>0});n.length!==0&&(this.nr==null&&(this.nr=new Cl(this._instance),this.nr.init(),this.nr.Xe(r=>{this.onAction(r)})),n.forEach(r=>{var s,i,o,c,u;r.conditions&&(s=r.conditions)!=null&&s.actions&&(i=r.conditions)!=null&&(i=i.actions)!=null&&i.values&&((o=r.conditions)==null||(o=o.actions)==null||(o=o.values)==null?void 0:o.length)>0&&((c=this.nr)==null||c.register(r.conditions.actions.values),(u=r.conditions)==null||(u=u.actions)==null||(u=u.values)==null||u.forEach(d=>{if(d&&d.name){var p=this.er.get(d.name);p&&p.push(r.id),this.er.set(d.name,p||[r.id])}}))}))}rr(e){var n;e.filter(r=>{var s,i;return((s=r.conditions)==null?void 0:s.events)&&((i=r.conditions)==null||(i=i.events)==null||(i=i.values)==null?void 0:i.length)>0}).length!==0&&((n=this._instance)==null||n.Ke((r,s)=>{this.onEvent(r,s)}),e.forEach(r=>{var s;(s=r.conditions)==null||(s=s.events)==null||(s=s.values)==null||s.forEach(i=>{if(i&&i.name){var o=this.ir.get(i.name);o&&o.push(r.id),this.ir.set(i.name,o||[r.id])}})}))}onEvent(e,n){var r,s=((r=this._instance)==null||(r=r.persistence)==null?void 0:r.props[Qm])||[];if(e==="survey shown"&&n&&s.length>0){var i;tr.info("survey event matched, removing survey from activated surveys",{event:e,eventPayload:n,existingActivatedSurveys:s});var o=n==null||(i=n.properties)==null?void 0:i.$survey_id;if(o){var c=s.indexOf(o);c>=0&&(s.splice(c,1),this.ar(s))}}else this.ir.has(e)&&(tr.info("survey event matched, updating activated surveys",{event:e,surveys:this.ir.get(e)}),this.ar(s.concat(this.ir.get(e)||[])))}onAction(e){var n,r=((n=this._instance)==null||(n=n.persistence)==null?void 0:n.props[Qm])||[];this.er.has(e)&&this.ar(r.concat(this.er.get(e)||[]))}ar(e){var n;(n=this._instance)==null||(n=n.persistence)==null||n.register({[Qm]:[...new Set(e)]})}getSurveys(){var e,n=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[Qm];return n||[]}getEventToSurveys(){return this.ir}lr(){return this.nr}}class zxe{constructor(e){this.ur=void 0,this._surveyManager=null,this.hr=!1,this.dr=!1,this.vr=[],this._instance=e,this._surveyEventReceiver=null}onRemoteConfig(e){var n=e.surveys;if(Zt(n))return tr.warn("Flags not loaded yet. Not loading surveys.");var r=kn(n);this.ur=r?n.length>0:n,tr.info("flags response received, isSurveysEnabled: "+this.ur),this.loadIfEnabled()}reset(){localStorage.removeItem("lastSeenSurveyDate");for(var e=[],n=0;n<localStorage.length;n++){var r=localStorage.key(n);(r!=null&&r.startsWith(j1)||r!=null&&r.startsWith("inProgressSurvey_"))&&e.push(r)}e.forEach(s=>localStorage.removeItem(s))}loadIfEnabled(){if(!this._surveyManager)if(this.dr)tr.info("Already initializing surveys, skipping...");else if(this._instance.config.disable_surveys)tr.info("Disabled. Not loading surveys.");else if(this._instance.config.cookieless_mode)tr.info("Not loading surveys in cookieless mode.");else{var e=bt?.__PosthogExtensions__;if(e){if(!Me(this.ur)||this._instance.config.advanced_enable_surveys){var n=this.ur||this._instance.config.advanced_enable_surveys;this.dr=!0;try{var r=e.generateSurveys;if(r)return void this.cr(r,n);var s=e.loadExternalDependency;if(!s)return void this.pr("PostHog loadExternalDependency extension not found.");s(this._instance,"surveys",i=>{i||!e.generateSurveys?this.pr("Could not load surveys script",i):this.cr(e.generateSurveys,n)})}catch(i){throw this.pr("Error initializing surveys",i),i}finally{this.dr=!1}}}else tr.error("PostHog Extensions not found.")}}cr(e,n){this._surveyManager=e(this._instance,n),this._surveyEventReceiver=new Lxe(this._instance),tr.info("Surveys loaded successfully"),this.gr({isLoaded:!0})}pr(e,n){tr.error(e,n),this.gr({isLoaded:!1,error:e})}onSurveysLoaded(e){return this.vr.push(e),this._surveyManager&&this.gr({isLoaded:!0}),()=>{this.vr=this.vr.filter(n=>n!==e)}}getSurveys(e,n){if(n===void 0&&(n=!1),this._instance.config.disable_surveys)return tr.info("Disabled. Not loading surveys."),e([]);var r=this._instance.get_property(p1);if(r&&!n)return e(r,{isLoaded:!0});if(this.hr)return e([],{isLoaded:!1,error:"Surveys are already being loaded"});try{this.hr=!0,this._instance.Re({url:this._instance.requestRouter.endpointFor("api","/api/surveys/?token="+this._instance.config.token),method:"GET",timeout:this._instance.config.surveys_request_timeout_ms,callback:s=>{var i;this.hr=!1;var o=s.statusCode;if(o!==200||!s.json){var c="Surveys API could not be loaded, status: "+o;return tr.error(c),e([],{isLoaded:!1,error:c})}var u,d=s.json.surveys||[],p=d.filter(m=>function(v){return!(!v.start_date||v.end_date)}(m)&&(function(v){var y;return!((y=v.conditions)==null||(y=y.events)==null||(y=y.values)==null||!y.length)}(m)||function(v){var y;return!((y=v.conditions)==null||(y=y.actions)==null||(y=y.values)==null||!y.length)}(m)));return p.length>0&&((u=this._surveyEventReceiver)==null||u.register(p)),(i=this._instance.persistence)==null||i.register({[p1]:d}),e(d,{isLoaded:!0})}})}catch(s){throw this.hr=!1,s}}gr(e){for(var n of this.vr)try{if(!e.isLoaded)return n([],e);this.getSurveys(n)}catch(r){tr.error("Error in survey callback",r)}}getActiveMatchingSurveys(e,n){if(n===void 0&&(n=!1),!Zt(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,n);tr.warn("init was not called")}_r(e){var n=null;return this.getSurveys(r=>{var s;n=(s=r.find(i=>i.id===e))!==null&&s!==void 0?s:null}),n}mr(e){if(Zt(this._surveyManager))return{eligible:!1,reason:"SDK is not enabled or survey functionality is not yet loaded"};var n=typeof e=="string"?this._r(e):e;return n?this._surveyManager.checkSurveyEligibility(n):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(e){if(Zt(this._surveyManager))return tr.warn("init was not called"),{visible:!1,disabledReason:"SDK is not enabled or survey functionality is not yet loaded"};var n=this.mr(e);return{visible:n.eligible,disabledReason:n.reason}}canRenderSurveyAsync(e,n){return Zt(this._surveyManager)?(tr.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:"SDK is not enabled or survey functionality is not yet loaded"})):new Promise(r=>{this.getSurveys(s=>{var i,o=(i=s.find(u=>u.id===e))!==null&&i!==void 0?i:null;if(o){var c=this.mr(o);r({visible:c.eligible,disabledReason:c.reason})}else r({visible:!1,disabledReason:"Survey not found"})},n)})}renderSurvey(e,n){if(Zt(this._surveyManager))tr.warn("init was not called");else{var r=this._r(e);if(r)if(Ixe.includes(r.type)){var s=Ue?.querySelector(n);s?this._surveyManager.renderSurvey(r,s):tr.warn("Survey element not found")}else tr.warn("Surveys of type "+r.type+" cannot be rendered in the app");else tr.warn("Survey not found")}}}var RD=br("[RateLimiter]");class $xe{constructor(e){var n,r;this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=s=>{var i=s.text;if(i&&i.length)try{(JSON.parse(i).quota_limited||[]).forEach(o=>{RD.info((o||"events")+" is quota limited."),this.serverLimits[o]=new Date().getTime()+6e4})}catch(o){return void RD.warn('could not rate limit - continuing. Error: "'+o?.message+'"',{text:i})}},this.instance=e,this.captureEventsPerSecond=((n=e.config.rate_limiting)==null?void 0:n.events_per_second)||10,this.captureEventsBurstLimit=Math.max(((r=e.config.rate_limiting)==null?void 0:r.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond),this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}clientRateLimitContext(e){var n,r,s;e===void 0&&(e=!1);var i=new Date().getTime(),o=(n=(r=this.instance.persistence)==null?void 0:r.get_property(g1))!==null&&n!==void 0?n:{tokens:this.captureEventsBurstLimit,last:i};o.tokens+=(i-o.last)/1e3*this.captureEventsPerSecond,o.last=i,o.tokens>this.captureEventsBurstLimit&&(o.tokens=this.captureEventsBurstLimit);var c=o.tokens<1;return c||e||(o.tokens=Math.max(0,o.tokens-1)),!c||this.lastEventRateLimited||e||this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited. Config is set to "+this.captureEventsPerSecond+" events per second and "+this.captureEventsBurstLimit+" events burst limit."},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=c,(s=this.instance.persistence)==null||s.set_property(g1,o),{isRateLimited:c,remainingTokens:o.tokens}}isServerRateLimited(e){var n=this.serverLimits[e||"events"]||!1;return n!==!1&&new Date().getTime()<n}}var Sl=br("[RemoteConfig]");class Fxe{constructor(e){this._instance=e}get remoteConfig(){var e;return(e=bt._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.config}br(e){var n,r;(n=bt.__PosthogExtensions__)!=null&&n.loadExternalDependency?(r=bt.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,"remote-config",()=>e(this.remoteConfig)):(Sl.error("PostHog Extensions not found. Cannot load remote config."),e())}yr(e){this._instance.Re({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback:n=>{e(n.json)}})}load(){try{if(this.remoteConfig)return Sl.info("Using preloaded remote config",this.remoteConfig),void this.Te(this.remoteConfig);if(this._instance.j())return void Sl.warn("Remote config is disabled. Falling back to local config.");this.br(e=>{if(!e)return Sl.info("No config found after loading remote JS config. Falling back to JSON."),void this.yr(n=>{this.Te(n)});this.Te(e)})}catch(e){Sl.error("Error loading remote config",e)}}Te(e){e?this._instance.config.__preview_remote_config?(this._instance.Te(e),e.hasFeatureFlags!==!1&&this._instance.featureFlags.ensureFlagsLoaded()):Sl.info("__preview_remote_config is disabled. Logging config instead",e):Sl.error("Failed to fetch remote config from PostHog.")}}var O1=3e3;class Uxe{constructor(e,n){this.wr=!0,this.Sr=[],this.$r=js(n?.flush_interval_ms||O1,250,5e3,$e.createLogger("flush interval"),O1),this.kr=e}enqueue(e){this.Sr.push(e),this.Er||this.Ir()}unload(){this.Pr();var e=this.Sr.length>0?this.Rr():{},n=Object.values(e);[...n.filter(r=>r.url.indexOf("/e")===0),...n.filter(r=>r.url.indexOf("/e")!==0)].map(r=>{this.kr(Fe({},r,{transport:"sendBeacon"}))})}enable(){this.wr=!1,this.Ir()}Ir(){var e=this;this.wr||(this.Er=setTimeout(()=>{if(this.Pr(),this.Sr.length>0){var n=this.Rr(),r=function(){var i=n[s],o=new Date().getTime();i.data&&kn(i.data)&&mn(i.data,c=>{c.offset=Math.abs(c.timestamp-o),delete c.timestamp}),e.kr(i)};for(var s in n)r()}},this.$r))}Pr(){clearTimeout(this.Er),this.Er=void 0}Rr(){var e={};return mn(this.Sr,n=>{var r,s=n,i=(s?s.batchKey:null)||s.url;Me(e[i])&&(e[i]=Fe({},s,{data:[]})),(r=e[i].data)==null||r.push(s.data)}),this.Sr=[],e}}var Vxe=["retriesPerformedSoFar"];class Bxe{constructor(e){this.Tr=!1,this.Cr=3e3,this.Sr=[],this._instance=e,this.Sr=[],this.Mr=!0,!Me(ye)&&"onLine"in ye.navigator&&(this.Mr=ye.navigator.onLine,In(ye,"online",()=>{this.Mr=!0,this.ne()}),In(ye,"offline",()=>{this.Mr=!1}))}get length(){return this.Sr.length}retriableRequest(e){var{retriesPerformedSoFar:n}=e,r=cU(e,Vxe);Ir(n)&&n>0&&(r.url=Cv(r.url,{retry_count:n})),this._instance.Re(Fe({},r,{callback:s=>{s.statusCode!==200&&(s.statusCode<400||s.statusCode>=500)&&(n??0)<10?this.Fr(Fe({retriesPerformedSoFar:n},r)):r.callback==null||r.callback(s)}}))}Fr(e){var n=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=n+1;var r=function(o){var c=3e3*Math.pow(2,o),u=c/2,d=Math.min(18e5,c),p=(Math.random()-.5)*(d-u);return Math.ceil(d+p)}(n),s=Date.now()+r;this.Sr.push({retryAt:s,requestOptions:e});var i="Enqueued failed request for retry in "+r;navigator.onLine||(i+=" (Browser is offline)"),$e.warn(i),this.Tr||(this.Tr=!0,this.Or())}Or(){this.Ar&&clearTimeout(this.Ar),this.Ar=setTimeout(()=>{this.Mr&&this.Sr.length>0&&this.ne(),this.Or()},this.Cr)}ne(){var e=Date.now(),n=[],r=this.Sr.filter(i=>i.retryAt<e||(n.push(i),!1));if(this.Sr=n,r.length>0)for(var{requestOptions:s}of r)this.retriableRequest(s)}unload(){for(var{requestOptions:e}of(this.Ar&&(clearTimeout(this.Ar),this.Ar=void 0),this.Sr))try{this._instance.Re(Fe({},e,{transport:"sendBeacon"}))}catch(n){$e.error(n)}this.Sr=[]}}class qxe{constructor(e){this.Dr=()=>{var n,r,s,i;this.jr||(this.jr={});var o=this.scrollElement(),c=this.scrollY(),u=o?Math.max(0,o.scrollHeight-o.clientHeight):0,d=c+(o?.clientHeight||0),p=o?.scrollHeight||0;this.jr.lastScrollY=Math.ceil(c),this.jr.maxScrollY=Math.max(c,(n=this.jr.maxScrollY)!==null&&n!==void 0?n:0),this.jr.maxScrollHeight=Math.max(u,(r=this.jr.maxScrollHeight)!==null&&r!==void 0?r:0),this.jr.lastContentY=d,this.jr.maxContentY=Math.max(d,(s=this.jr.maxContentY)!==null&&s!==void 0?s:0),this.jr.maxContentHeight=Math.max(p,(i=this.jr.maxContentHeight)!==null&&i!==void 0?i:0)},this._instance=e}getContext(){return this.jr}resetContext(){var e=this.jr;return setTimeout(this.Dr,0),e}startMeasuringScrollPosition(){In(ye,"scroll",this.Dr,{capture:!0}),In(ye,"scrollend",this.Dr,{capture:!0}),In(ye,"resize",this.Dr)}scrollElement(){if(!this._instance.config.scroll_root_selector)return ye?.document.documentElement;var e=kn(this._instance.config.scroll_root_selector)?this._instance.config.scroll_root_selector:[this._instance.config.scroll_root_selector];for(var n of e){var r=ye?.document.querySelector(n);if(r)return r}}scrollY(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollTop||0}return ye&&(ye.scrollY||ye.pageYOffset||ye.document.documentElement.scrollTop)||0}scrollX(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollLeft||0}return ye&&(ye.scrollX||ye.pageXOffset||ye.document.documentElement.scrollLeft)||0}}var Hxe=t=>f6(t?.config.mask_personal_data_properties,t?.config.custom_personal_data_properties);class AD{constructor(e,n,r,s){this.Lr=i=>{var o=this.Nr();if(!o||o.sessionId!==i){var c={sessionId:i,props:this.zr(this._instance)};this.Ur.register({[m1]:c})}},this._instance=e,this.qr=n,this.Ur=r,this.zr=s||Hxe,this.qr.onSessionId(this.Lr)}Nr(){return this.Ur.props[m1]}getSetOnceProps(){var e,n=(e=this.Nr())==null?void 0:e.props;return n?"r"in n?h6(n):{$referring_domain:n.referringDomain,$pathname:n.initialPathName,utm_source:n.utm_source,utm_campaign:n.utm_campaign,utm_medium:n.utm_medium,utm_content:n.utm_content,utm_term:n.utm_term}:{}}getSessionProps(){var e={};return mn(hT(this.getSetOnceProps()),(n,r)=>{r==="$current_url"&&(r="url"),e["$session_entry_"+a1(r)]=n}),e}}var r_=br("[SessionId]");class ND{constructor(e,n,r){var s;if(this.Br=[],this.Hr=(p,m)=>Math.abs(p-m)>this.sessionTimeoutMs,!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(e.config.cookieless_mode==="always")throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this.O=e.config,this.Ur=e.persistence,this.pi=void 0,this.Ft=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this.Wr=n||Eo,this.Gr=r||Eo;var i=this.O.persistence_name||this.O.token,o=this.O.session_idle_timeout_seconds||1800;if(this._sessionTimeoutMs=1e3*js(o,60,36e3,r_.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.Jr(),this.Vr="ph_"+i+"_window_id",this.Kr="ph_"+i+"_primary_window_exists",this.Yr()){var c=Rr.V(this.Vr),u=Rr.V(this.Kr);c&&!u?this.pi=c:Rr.Y(this.Vr),Rr.K(this.Kr,!0)}if((s=this.O.bootstrap)!=null&&s.sessionID)try{var d=(p=>{var m=p.replace(/-/g,"");if(m.length!==32)throw new Error("Not a valid UUID");if(m[12]!=="7")throw new Error("Not a UUIDv7");return parseInt(m.substring(0,12),16)})(this.O.bootstrap.sessionID);this.Xr(this.O.bootstrap.sessionID,new Date().getTime(),d)}catch(p){r_.error("Invalid sessionID in bootstrap",p)}this.Qr()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return Me(this.Br)&&(this.Br=[]),this.Br.push(e),this.Ft&&e(this.Ft,this.pi),()=>{this.Br=this.Br.filter(n=>n!==e)}}Yr(){return this.O.persistence!=="memory"&&!this.Ur.De&&Rr.W()}Zr(e){e!==this.pi&&(this.pi=e,this.Yr()&&Rr.K(this.Vr,e))}ts(){return this.pi?this.pi:this.Yr()?Rr.V(this.Vr):null}Xr(e,n,r){e===this.Ft&&n===this._sessionActivityTimestamp&&r===this._sessionStartTimestamp||(this._sessionStartTimestamp=r,this._sessionActivityTimestamp=n,this.Ft=e,this.Ur.register({[gv]:[n,e,r]}))}es(){if(this.Ft&&this._sessionActivityTimestamp&&this._sessionStartTimestamp)return[this._sessionActivityTimestamp,this.Ft,this._sessionStartTimestamp];var e=this.Ur.props[gv];return kn(e)&&e.length===2&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this.Xr(null,null,null)}Qr(){In(ye,"beforeunload",()=>{this.Yr()&&Rr.Y(this.Kr)},{capture:!1})}checkAndGetSessionAndWindowId(e,n){if(e===void 0&&(e=!1),n===void 0&&(n=null),this.O.cookieless_mode==="always")throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var r=n||new Date().getTime(),[s,i,o]=this.es(),c=this.ts(),u=Ir(o)&&o>0&&Math.abs(r-o)>864e5,d=!1,p=!i,m=!e&&this.Hr(r,s);p||m||u?(i=this.Wr(),c=this.Gr(),r_.info("new session ID generated",{sessionId:i,windowId:c,changeReason:{noSessionId:p,activityTimeout:m,sessionPastMaximumLength:u}}),o=r,d=!0):c||(c=this.Gr(),d=!0);var v=s===0||!e||u?r:s,y=o===0?new Date().getTime():o;return this.Zr(c),this.Xr(i,v,y),e||this.Jr(),d&&this.Br.forEach(x=>x(i,c,d?{noSessionId:p,activityTimeout:m,sessionPastMaximumLength:u}:void 0)),{sessionId:i,windowId:c,sessionStartTimestamp:y,changeReason:d?{noSessionId:p,activityTimeout:m,sessionPastMaximumLength:u}:void 0,lastActivityTimestamp:s}}Jr(){clearTimeout(this.rs),this.rs=setTimeout(()=>{var[e]=this.es();this.Hr(new Date().getTime(),e)&&this.resetSessionId()},1.1*this.sessionTimeoutMs)}}var Gxe=["$set_once","$set"],fo=br("[SiteApps]");class Yxe{constructor(e){this._instance=e,this.ss=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}ns(e,n){if(n){var r=this.globalsForEvent(n);this.ss.push(r),this.ss.length>1e3&&(this.ss=this.ss.slice(10))}}get siteAppLoaders(){var e;return(e=bt._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.siteApps}init(){if(this.isEnabled){var e=this._instance.Ke(this.ns.bind(this));this.os=()=>{e(),this.ss=[],this.os=void 0}}}globalsForEvent(e){var n,r,s,i,o,c,u;if(!e)throw new Error("Event payload is required");var d={},p=this._instance.get_property("$groups")||[],m=this._instance.get_property("$stored_group_properties")||{};for(var[v,y]of Object.entries(m))d[v]={id:p[v],type:v,properties:y};var{$set_once:x,$set:w}=e;return{event:Fe({},cU(e,Gxe),{properties:Fe({},e.properties,w?{$set:Fe({},(n=(r=e.properties)==null?void 0:r.$set)!==null&&n!==void 0?n:{},w)}:{},x?{$set_once:Fe({},(s=(i=e.properties)==null?void 0:i.$set_once)!==null&&s!==void 0?s:{},x)}:{}),elements_chain:(o=(c=e.properties)==null?void 0:c.$elements_chain)!==null&&o!==void 0?o:"",distinct_id:(u=e.properties)==null?void 0:u.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:d}}setupSiteApp(e){var n=this.apps[e.id],r=()=>{var c;!n.errored&&this.ss.length&&(fo.info("Processing "+this.ss.length+" events for site app with id "+e.id),this.ss.forEach(u=>n.processEvent==null?void 0:n.processEvent(u)),n.processedBuffer=!0),Object.values(this.apps).every(u=>u.processedBuffer||u.errored)&&((c=this.os)==null||c.call(this))},s=!1,i=c=>{n.errored=!c,n.loaded=!0,fo.info("Site app with id "+e.id+" "+(c?"loaded":"errored")),s&&r()};try{var{processEvent:o}=e.init({posthog:this._instance,callback:c=>{i(c)}});o&&(n.processEvent=o),s=!0}catch(c){fo.error("Error while initializing PostHog app with config id "+e.id,c),i(!1)}if(s&&n.loaded)try{r()}catch(c){fo.error("Error while processing buffered events PostHog app with config id "+e.id,c),n.errored=!0}}ls(){var e=this.siteAppLoaders||[];for(var n of e)this.apps[n.id]={id:n.id,loaded:!1,errored:!1,processedBuffer:!1};for(var r of e)this.setupSiteApp(r)}us(e){if(Object.keys(this.apps).length!==0){var n=this.globalsForEvent(e);for(var r of Object.values(this.apps))try{r.processEvent==null||r.processEvent(n)}catch(s){fo.error("Error while processing event "+e.event+" for site app "+r.id,s)}}}onRemoteConfig(e){var n,r,s,i=this;if((n=this.siteAppLoaders)!=null&&n.length)return this.isEnabled?(this.ls(),void this._instance.on("eventCaptured",d=>this.us(d))):void fo.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if((r=this.os)==null||r.call(this),(s=e.siteApps)!=null&&s.length)if(this.isEnabled){var o=function(d){var p;bt["__$$ph_site_app_"+d]=i._instance,(p=bt.__PosthogExtensions__)==null||p.loadSiteApp==null||p.loadSiteApp(i._instance,u,m=>{if(m)return fo.error("Error while initializing PostHog app with config id "+d,m)})};for(var{id:c,url:u}of e.siteApps)o(c)}else fo.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}var Wxe=["amazonbot","amazonproductbot","app.hypefactors.com","applebot","archive.org_bot","awariobot","backlinksextendedbot","baiduspider","bingbot","bingpreview","chrome-lighthouse","dataforseobot","deepscan","duckduckbot","facebookexternal","facebookcatalog","http://yandex.com/bots","hubspot","ia_archiver","leikibot","linkedinbot","meta-externalagent","mj12bot","msnbot","nessus","petalbot","pinterest","prerender","rogerbot","screaming frog","sebot-wa","sitebulb","slackbot","slurp","trendictionbot","turnitin","twitterbot","vercel-screenshot","vercelbot","yahoo! slurp","yandexbot","zoombot","bot.htm","bot.php","(bot;","bot/","crawler","ahrefsbot","ahrefssiteaudit","semrushbot","siteauditbot","splitsignalbot","gptbot","oai-searchbot","chatgpt-user","perplexitybot","better uptime bot","sentryuptimebot","uptimerobot","headlesschrome","cypress","google-hoteladsverifier","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleother","google-cloudvertexbot","googleweblight","mediapartners-google","storebot-google","google-inspectiontool","bytespider"],jD=function(t,e){if(!t)return!1;var n=t.toLowerCase();return Wxe.concat(e||[]).some(r=>{var s=r.toLowerCase();return n.indexOf(s)!==-1})},g6=function(t,e){if(!t)return!1;var n=t.userAgent;if(n&&jD(n,e))return!0;try{var r=t?.userAgentData;if(r!=null&&r.brands&&r.brands.some(s=>jD(s?.brand,e)))return!0}catch{}return!!t.webdriver},Yf=function(t){return t.US="us",t.EU="eu",t.CUSTOM="custom",t}({}),OD="i.posthog.com";class Kxe{constructor(e){this.hs={},this.instance=e}get apiHost(){var e=this.instance.config.api_host.trim().replace(/\/$/,"");return e==="https://app.posthog.com"?"https://us.i.posthog.com":e}get uiHost(){var e,n=(e=this.instance.config.ui_host)==null?void 0:e.replace(/\/$/,"");return n||(n=this.apiHost.replace("."+OD,".posthog.com")),n==="https://app.posthog.com"?"https://us.posthog.com":n}get region(){return this.hs[this.apiHost]||(/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this.hs[this.apiHost]=Yf.US:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this.hs[this.apiHost]=Yf.EU:this.hs[this.apiHost]=Yf.CUSTOM),this.hs[this.apiHost]}endpointFor(e,n){if(n===void 0&&(n=""),n&&(n=n[0]==="/"?n:"/"+n),e==="ui")return this.uiHost+n;if(this.region===Yf.CUSTOM)return this.apiHost+n;var r=OD+n;switch(e){case"assets":return"https://"+this.region+"-assets."+r;case"api":return"https://"+this.region+"."+r}}}var Qxe={icontains:(t,e)=>!!ye&&e.href.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,e)=>!!ye&&e.href.toLowerCase().indexOf(t.toLowerCase())===-1,regex:(t,e)=>!!ye&&Wu(e.href,t),not_regex:(t,e)=>!!ye&&!Wu(e.href,t),exact:(t,e)=>e.href===t,is_not:(t,e)=>e.href!==t};class Dr{constructor(e){var n=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(r){r===void 0&&(r=!1),n.getWebExperiments(s=>{Dr.ds("retrieved web experiments from the server"),n.vs=new Map,s.forEach(i=>{if(i.feature_flag_key){var o;n.vs&&(Dr.ds("setting flag key ",i.feature_flag_key," to web experiment ",i),(o=n.vs)==null||o.set(i.feature_flag_key,i));var c=n._instance.getFeatureFlag(i.feature_flag_key);qn(c)&&i.variants[c]&&n.cs(i.name,c,i.variants[c].transforms)}else if(i.variants)for(var u in i.variants){var d=i.variants[u];Dr.fs(d)&&n.cs(i.name,u,d.transforms)}})},r)},this._instance=e,this._instance.onFeatureFlags(r=>{this.onFeatureFlags(r)})}onFeatureFlags(e){if(this._is_bot())Dr.ds("Refusing to render web experiment since the viewer is a likely bot");else if(!this._instance.config.disable_web_experiments){if(Zt(this.vs))return this.vs=new Map,this.loadIfEnabled(),void this.previewWebExperiment();Dr.ds("applying feature flags",e),e.forEach(n=>{var r;if(this.vs&&(r=this.vs)!=null&&r.has(n)){var s,i=this._instance.getFeatureFlag(n),o=(s=this.vs)==null?void 0:s.get(n);i&&o!=null&&o.variants[i]&&this.cs(o.name,i,o.variants[i].transforms)}})}}previewWebExperiment(){var e=Dr.getWindowLocation();if(e!=null&&e.search){var n=wv(e?.search,"__experiment_id"),r=wv(e?.search,"__experiment_variant");n&&r&&(Dr.ds("previewing web experiments "+n+" && "+r),this.getWebExperiments(s=>{this.ps(parseInt(n),r,s)},!1,!0))}}loadIfEnabled(){this._instance.config.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,n,r){if(this._instance.config.disable_web_experiments&&!r)return e([]);var s=this._instance.get_property("$web_experiments");if(s&&!n)return e(s);this._instance.Re({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this._instance.config.token),method:"GET",callback:i=>{if(i.statusCode!==200||!i.json)return e([]);var o=i.json.experiments||[];return e(o)}})}ps(e,n,r){var s=r.filter(i=>i.id===e);s&&s.length>0&&(Dr.ds("Previewing web experiment ["+s[0].name+"] with variant ["+n+"]"),this.cs(s[0].name,n,s[0].variants[n].transforms))}static fs(e){return!Zt(e.conditions)&&Dr.gs(e)&&Dr._s(e)}static gs(e){var n;if(Zt(e.conditions)||Zt((n=e.conditions)==null?void 0:n.url))return!0;var r,s,i,o=Dr.getWindowLocation();return!!o&&((r=e.conditions)==null||!r.url||Qxe[(s=(i=e.conditions)==null?void 0:i.urlMatchType)!==null&&s!==void 0?s:"icontains"](e.conditions.url,o))}static getWindowLocation(){return ye?.location}static _s(e){var n;if(Zt(e.conditions)||Zt((n=e.conditions)==null?void 0:n.utm))return!0;var r=l6();if(r.utm_source){var s,i,o,c,u,d,p,m,v=(s=e.conditions)==null||(s=s.utm)==null||!s.utm_campaign||((i=e.conditions)==null||(i=i.utm)==null?void 0:i.utm_campaign)==r.utm_campaign,y=(o=e.conditions)==null||(o=o.utm)==null||!o.utm_source||((c=e.conditions)==null||(c=c.utm)==null?void 0:c.utm_source)==r.utm_source,x=(u=e.conditions)==null||(u=u.utm)==null||!u.utm_medium||((d=e.conditions)==null||(d=d.utm)==null?void 0:d.utm_medium)==r.utm_medium,w=(p=e.conditions)==null||(p=p.utm)==null||!p.utm_term||((m=e.conditions)==null||(m=m.utm)==null?void 0:m.utm_term)==r.utm_term;return v&&x&&w&&y}return!1}static ds(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),s=1;s<n;s++)r[s-1]=arguments[s];$e.info("[WebExperiments] "+e,r)}cs(e,n,r){this._is_bot()?Dr.ds("Refusing to render web experiment since the viewer is a likely bot"):n!=="control"?r.forEach(s=>{if(s.selector){var i;Dr.ds("applying transform of variant "+n+" for experiment "+e+" ",s);var o=(i=document)==null?void 0:i.querySelectorAll(s.selector);o?.forEach(c=>{var u=c;s.html&&(u.innerHTML=s.html),s.css&&u.setAttribute("style",s.css)})}}):Dr.ds("Control variants leave the page unmodified.")}_is_bot(){return Ns&&this._instance?g6(Ns,this._instance.config.custom_blocked_useragents):void 0}}var Xxe=br("[PostHog ExternalIntegrations]"),Zxe={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};class Jxe{constructor(e){this._instance=e}st(e,n){var r;(r=bt.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,e,s=>{if(s)return Xxe.error("failed to load script",s);n()})}startIfEnabledOrStop(){var e=this,n=function(o){var c,u,d;!s||(c=bt.__PosthogExtensions__)!=null&&(c=c.integrations)!=null&&c[o]||e.st(Zxe[o],()=>{var p;(p=bt.__PosthogExtensions__)==null||(p=p.integrations)==null||(p=p[o])==null||p.start(e._instance)}),!s&&(u=bt.__PosthogExtensions__)!=null&&(u=u.integrations)!=null&&u[o]&&((d=bt.__PosthogExtensions__)==null||(d=d.integrations)==null||(d=d[o])==null||d.stop())};for(var[r,s]of Object.entries((i=this._instance.config.integrations)!==null&&i!==void 0?i:{})){var i;n(r)}}}var hh={},P1=()=>{},ru="posthog",v6=!pxe&&os?.indexOf("MSIE")===-1&&os?.indexOf("Mozilla")===-1,PD=t=>{var e;return{api_host:"https://us.i.posthog.com",ui_host:null,token:"",autocapture:!0,rageclick:!0,cross_subdomain_cookie:Gve(Ue?.location),persistence:"localStorage+cookie",persistence_name:"",loaded:P1,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageview:t!=="2025-05-24"||"history_change",capture_pageleave:"if_capture_pageview",defaults:t??"unset",debug:ls&&qn(ls?.search)&&ls.search.indexOf("__posthog_debug=true")!==-1||!1,cookie_expiration:365,upgrade:!1,disable_session_recording:!1,disable_persistence:!1,disable_web_experiments:!0,disable_surveys:!1,disable_surveys_automatic_display:!1,disable_external_dependency_loading:!1,enable_recording_console_log:void 0,secure_cookie:(ye==null||(e=ye.location)==null?void 0:e.protocol)==="https:",ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,session_recording:{},mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_flags:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_only_evaluate_survey_feature_flags:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,surveys_request_timeout_ms:1e4,on_request_error:n=>{var r="Bad HTTP status: "+n.statusCode+" "+n.text;$e.error(r)},get_device_id:n=>n,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:"identified_only",before_send:void 0,request_queue_config:{flush_interval_ms:O1},error_tracking:{},_onCapture:P1}},MD=t=>{var e={};Me(t.process_person)||(e.person_profiles=t.process_person),Me(t.xhr_headers)||(e.request_headers=t.xhr_headers),Me(t.cookie_name)||(e.persistence_name=t.cookie_name),Me(t.disable_cookie)||(e.disable_persistence=t.disable_cookie),Me(t.store_google)||(e.save_campaign_params=t.store_google),Me(t.verbose)||(e.debug=t.verbose);var n=Xn({},e,t);return kn(t.property_blacklist)&&(Me(t.property_denylist)?n.property_denylist=t.property_blacklist:kn(t.property_denylist)?n.property_denylist=[...t.property_blacklist,...t.property_denylist]:$e.error("Invalid value for property_denylist config: "+t.property_denylist)),n};class ebe{constructor(){this.__forceAllowLocalhost=!1}get bs(){return this.__forceAllowLocalhost}set bs(e){$e.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}}class jy{get decideEndpointWasHit(){var e,n;return(e=(n=this.featureFlags)==null?void 0:n.hasLoadedFlags)!==null&&e!==void 0&&e}get flagsEndpointWasHit(){var e,n;return(e=(n=this.featureFlags)==null?void 0:n.hasLoadedFlags)!==null&&e!==void 0&&e}constructor(){this.webPerformance=new ebe,this.ys=!1,this.version=Ea.LIB_VERSION,this.ws=new m6,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=PD(),this.SentryIntegration=sxe,this.sentryIntegration=e=>function(n,r){var s=HU(n,r);return{name:qU,processEvent:i=>s(i)}}(this,e),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.Ss=!1,this.$s=null,this.xs=null,this.ks=null,this.featureFlags=new Pxe(this),this.toolbar=new axe(this),this.scrollManager=new qxe(this),this.pageViewManager=new fxe(this),this.surveys=new zxe(this),this.experiments=new Dr(this),this.exceptions=new gxe(this),this.rateLimiter=new $xe(this),this.requestRouter=new Kxe(this),this.consent=new mye(this),this.externalIntegrations=new Jxe(this),this.people={set:(e,n,r)=>{var s=qn(e)?{[e]:n}:e;this.setPersonProperties(s),r?.({})},set_once:(e,n,r)=>{var s=qn(e)?{[e]:n}:e;this.setPersonProperties(void 0,s),r?.({})}},this.on("eventCaptured",e=>$e.info('send "'+e?.event+'"',e))}init(e,n,r){if(r&&r!==ru){var s,i=(s=hh[r])!==null&&s!==void 0?s:new jy;return i._init(e,n,r),hh[r]=i,hh[ru][r]=i,i}return this._init(e,n,r)}_init(e,n,r){var s,i;if(n===void 0&&(n={}),Me(e)||o1(e))return $e.critical("PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()"),this;if(this.__loaded)return $e.warn("You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config={},this.Es=n,this.Is=[],n.person_profiles&&(this.xs=n.person_profiles),this.set_config(Xn({},PD(n.defaults),MD(n),{name:r,token:e})),this.config.on_xhr_error&&$e.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=n.disable_compression?void 0:Ta.GZipJS;var o=this.Ps();this.persistence=new e_(this.config,o),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new e_(Fe({},this.config,{persistence:"sessionStorage"}),o);var c=Fe({},this.persistence.props),u=Fe({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.Rs=new Uxe(C=>this.Ts(C),this.config.request_queue_config),this.Cs=new Bxe(this),this.__request_queue=[];var d=this.config.cookieless_mode==="always"||this.config.cookieless_mode==="on_reject"&&this.consent.isExplicitlyOptedOut();if(d||(this.sessionManager=new ND(this),this.sessionPropsManager=new AD(this,this.sessionManager,this.persistence)),new lxe(this).startIfEnabledOrStop(),this.siteApps=new Yxe(this),(s=this.siteApps)==null||s.init(),d||(this.sessionRecording=new dD(this),this.sessionRecording.startIfEnabledOrStop()),this.config.disable_scroll_properties||this.scrollManager.startMeasuringScrollPosition(),this.autocapture=new oye(this),this.autocapture.startIfEnabled(),this.surveys.loadIfEnabled(),this.heatmaps=new dxe(this),this.heatmaps.startIfEnabled(),this.webVitalsAutocapture=new cxe(this),this.exceptionObserver=new yye(this),this.exceptionObserver.startIfEnabled(),this.deadClicksAutocapture=new NU(this,vye),this.deadClicksAutocapture.startIfEnabled(),this.historyAutocapture=new Oye(this),this.historyAutocapture.startIfEnabled(),Ea.DEBUG=Ea.DEBUG||this.config.debug,Ea.DEBUG&&$e.info("Starting in debug mode",{this:this,config:n,thisC:Fe({},this.config),p:c,s:u}),((i=n.bootstrap)==null?void 0:i.distinctID)!==void 0){var p,m,v=this.config.get_device_id(Eo()),y=(p=n.bootstrap)!=null&&p.isIdentifiedID?v:n.bootstrap.distinctID;this.persistence.set_property(wa,(m=n.bootstrap)!=null&&m.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:n.bootstrap.distinctID,$device_id:y})}if(this.Ms()){var x,w,k=Object.keys(((x=n.bootstrap)==null?void 0:x.featureFlags)||{}).filter(C=>{var A;return!((A=n.bootstrap)==null||(A=A.featureFlags)==null||!A[C])}).reduce((C,A)=>{var D;return C[A]=((D=n.bootstrap)==null||(D=D.featureFlags)==null?void 0:D[A])||!1,C},{}),S=Object.keys(((w=n.bootstrap)==null?void 0:w.featureFlagPayloads)||{}).filter(C=>k[C]).reduce((C,A)=>{var D,T;return(D=n.bootstrap)!=null&&(D=D.featureFlagPayloads)!=null&&D[A]&&(C[A]=(T=n.bootstrap)==null||(T=T.featureFlagPayloads)==null?void 0:T[A]),C},{});this.featureFlags.receivedFeatureFlags({featureFlags:k,featureFlagPayloads:S})}if(d)this.register_once({distinct_id:bf,$device_id:null},"");else if(!this.get_distinct_id()){var R=this.config.get_device_id(Eo());this.register_once({distinct_id:R,$device_id:R},""),this.persistence.set_property(wa,"anonymous")}return In(ye,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),this.toolbar.maybeLoadToolbar(),n.segment?rxe(this,()=>this.Fs()):this.Fs(),Zs(this.config._onCapture)&&this.config._onCapture!==P1&&($e.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",C=>this.config._onCapture(C.event,C))),this.config.ip&&$e.warn('The `ip` config option has NO EFFECT AT ALL and has been deprecated. Use a custom transformation or "Discard IP data" project setting instead. See https://posthog.com/tutorials/web-redact-properties#hiding-customer-ip-address for more information.'),this}Te(e){var n,r,s,i,o,c,u,d;if(!Ue||!Ue.body)return $e.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout(()=>{this.Te(e)},500);this.compression=void 0,e.supportedCompression&&!this.config.disable_compression&&(this.compression=It(e.supportedCompression,Ta.GZipJS)?Ta.GZipJS:It(e.supportedCompression,Ta.Base64)?Ta.Base64:void 0),(n=e.analytics)!=null&&n.endpoint&&(this.analyticsDefaultEndpoint=e.analytics.endpoint),this.set_config({person_profiles:this.xs?this.xs:"identified_only"}),(r=this.siteApps)==null||r.onRemoteConfig(e),(s=this.sessionRecording)==null||s.onRemoteConfig(e),(i=this.autocapture)==null||i.onRemoteConfig(e),(o=this.heatmaps)==null||o.onRemoteConfig(e),this.surveys.onRemoteConfig(e),(c=this.webVitalsAutocapture)==null||c.onRemoteConfig(e),(u=this.exceptionObserver)==null||u.onRemoteConfig(e),this.exceptions.onRemoteConfig(e),(d=this.deadClicksAutocapture)==null||d.onRemoteConfig(e)}Fs(){try{this.config.loaded(this)}catch(e){$e.critical("`loaded` function failed",e)}this.Os(),this.config.capture_pageview&&setTimeout(()=>{this.consent.isOptedIn()&&this.As()},1),new Fxe(this).load(),this.featureFlags.flags()}Os(){var e;this.is_capturing()&&this.config.request_batching&&((e=this.Rs)==null||e.enable())}_dom_loaded(){this.is_capturing()&&Ao(this.__request_queue,e=>this.Ts(e)),this.__request_queue=[],this.Os()}_handle_unload(){var e,n;this.config.request_batching?(this.Ds()&&this.capture("$pageleave"),(e=this.Rs)==null||e.unload(),(n=this.Cs)==null||n.unload()):this.Ds()&&this.capture("$pageleave",null,{transport:"sendBeacon"})}Re(e){this.__loaded&&(v6?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=Cv(e.url,{ip:this.config.ip?1:0}),e.headers=Fe({},this.config.request_headers),e.compression=e.compression==="best-available"?this.compression:e.compression,e.fetchOptions=e.fetchOptions||this.config.fetch_options,(n=>{var r,s,i,o=Fe({},n);o.timeout=o.timeout||6e4,o.url=Cv(o.url,{_:new Date().getTime().toString(),ver:Ea.LIB_VERSION,compression:o.compression});var c=(r=o.transport)!==null&&r!==void 0?r:"fetch",u=(s=(i=pU(fh,d=>d.transport===c))==null?void 0:i.method)!==null&&s!==void 0?s:fh[0].method;if(!u)throw new Error("No available transport method");u(o)})(Fe({},e,{callback:n=>{var r,s;this.rateLimiter.checkForLimiting(n),n.statusCode>=400&&((r=(s=this.config).on_request_error)==null||r.call(s,n)),e.callback==null||e.callback(n)}}))))}Ts(e){this.Cs?this.Cs.retriableRequest(e):this.Re(e)}_execute_array(e){var n,r=[],s=[],i=[];Ao(e,c=>{c&&(n=c[0],kn(n)?i.push(c):Zs(c)?c.call(this):kn(c)&&n==="alias"?r.push(c):kn(c)&&n.indexOf("capture")!==-1&&Zs(this[n])?i.push(c):s.push(c))});var o=function(c,u){Ao(c,function(d){if(kn(d[0])){var p=u;mn(d,function(m){p=p[m[0]].apply(p,m.slice(1))})}else this[d[0]].apply(this,d.slice(1))},u)};o(r,this),o(s,this),o(i,this)}Ms(){var e,n;return((e=this.config.bootstrap)==null?void 0:e.featureFlags)&&Object.keys((n=this.config.bootstrap)==null?void 0:n.featureFlags).length>0||!1}push(e){this._execute_array([e])}capture(e,n,r){var s;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.Rs){if(this.is_capturing())if(!Me(e)&&qn(e)){if(this.config.opt_out_useragent_filter||!this._is_bot()){var i=r!=null&&r.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(i==null||!i.isRateLimited){n!=null&&n.$current_url&&!qn(n?.$current_url)&&($e.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),n==null||delete n.$current_url),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&this.sessionPersistence.update_campaign_params(),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();var o=new Date,c=r?.timestamp||o,u=Eo(),d={uuid:u,event:e,properties:this.calculateEventProperties(e,n||{},c,u)};i&&(d.properties.$lib_rate_limit_remaining_tokens=i.remainingTokens),r?.$set&&(d.$set=r?.$set);var p,m=this.js(r?.$set_once);if(m&&(d.$set_once=m),(d=qve(d,r!=null&&r._noTruncate?null:this.config.properties_string_max_length)).timestamp=c,Me(r?.timestamp)||(d.properties.$event_time_override_provided=!0,d.properties.$event_time_override_system_time=o),e===n_.DISMISSED||e===n_.SENT){var v=n?.[TD.SURVEY_ID],y=n?.[TD.SURVEY_ITERATION];p={id:v,current_iteration:y},localStorage.getItem(CD(p))||localStorage.setItem(CD(p),"true"),d.$set=Fe({},d.$set,{[Dxe({id:v,current_iteration:y},e===n_.SENT?"responded":"dismissed")]:!0})}var x=Fe({},d.properties.$set,d.$set);if(hu(x)||this.setPersonPropertiesForFlags(x),!Zt(this.config.before_send)){var w=this.Ls(d);if(!w)return;d=w}this.ws.emit("eventCaptured",d);var k={method:"POST",url:(s=r?._url)!==null&&s!==void 0?s:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:d,compression:"best-available",batchKey:r?._batchKey};return!this.config.request_batching||r&&(r==null||!r._batchKey)||r!=null&&r.send_instantly?this.Ts(k):this.Rs.enqueue(k),d}$e.critical("This capture call is ignored due to client rate limiting.")}}else $e.error("No event name provided to posthog.capture")}else $e.uninitializedWarning("posthog.capture")}Ke(e){return this.on("eventCaptured",n=>e(n.event,n))}calculateEventProperties(e,n,r,s,i){if(r=r||new Date,!this.persistence||!this.sessionPersistence)return n;var o=i?void 0:this.persistence.remove_event_timer(e),c=Fe({},n);if(c.token=this.config.token,c.$config_defaults=this.config.defaults,(this.config.cookieless_mode=="always"||this.config.cookieless_mode=="on_reject"&&this.consent.isExplicitlyOptedOut())&&(c.$cookieless_mode=!0),e==="$snapshot"){var u=Fe({},this.persistence.properties(),this.sessionPersistence.properties());return c.distinct_id=u.distinct_id,(!qn(c.distinct_id)&&!Ir(c.distinct_id)||o1(c.distinct_id))&&$e.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),c}var d,p=Nxe(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties);if(this.sessionManager){var{sessionId:m,windowId:v}=this.sessionManager.checkAndGetSessionAndWindowId(i,r.getTime());c.$session_id=m,c.$window_id=v}this.sessionPropsManager&&Xn(c,this.sessionPropsManager.getSessionProps());try{var y;this.sessionRecording&&Xn(c,this.sessionRecording.sdkDebugProperties),c.$sdk_debug_retry_queue_size=(y=this.Cs)==null?void 0:y.length}catch(S){c.$sdk_debug_error_capturing_properties=String(S)}if(this.requestRouter.region===Yf.CUSTOM&&(c.$lib_custom_api_host=this.config.api_host),d=e!=="$pageview"||i?e!=="$pageleave"||i?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(r):this.pageViewManager.doPageView(r,s),c=Xn(c,d),e==="$pageview"&&Ue&&(c.title=Ue.title),!Me(o)){var x=r.getTime()-o;c.$duration=parseFloat((x/1e3).toFixed(3))}os&&this.config.opt_out_useragent_filter&&(c.$browser_type=this._is_bot()?"bot":"browser"),(c=Xn({},p,this.persistence.properties(),this.sessionPersistence.properties(),c)).$is_identified=this._isIdentified(),kn(this.config.property_denylist)?mn(this.config.property_denylist,function(S){delete c[S]}):$e.error("Invalid value for property_denylist config: "+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var w=this.config.sanitize_properties;w&&($e.error("sanitize_properties is deprecated. Use before_send instead"),c=w(c,e));var k=this.Ns();return c.$process_person_profile=k,k&&!i&&this.zs("_calculate_event_properties"),c}js(e){var n;if(!this.persistence||!this.Ns()||this.ys)return e;var r=this.persistence.get_initial_props(),s=(n=this.sessionPropsManager)==null?void 0:n.getSetOnceProps(),i=Xn({},r,s||{},e||{}),o=this.config.sanitize_properties;return o&&($e.error("sanitize_properties is deprecated. Use before_send instead"),i=o(i,"$set_once")),this.ys=!0,hu(i)?void 0:i}register(e,n){var r;(r=this.persistence)==null||r.register(e,n)}register_once(e,n,r){var s;(s=this.persistence)==null||s.register_once(e,n,r)}register_for_session(e){var n;(n=this.sessionPersistence)==null||n.register(e)}unregister(e){var n;(n=this.persistence)==null||n.unregister(e)}unregister_for_session(e){var n;(n=this.sessionPersistence)==null||n.unregister(e)}Us(e,n){this.register({[e]:n})}getFeatureFlag(e,n){return this.featureFlags.getFeatureFlag(e,n)}getFeatureFlagPayload(e){var n=this.featureFlags.getFeatureFlagPayload(e);try{return JSON.parse(n)}catch{return n}}isFeatureEnabled(e,n){return this.featureFlags.isFeatureEnabled(e,n)}reloadFeatureFlags(){this.featureFlags.reloadFeatureFlags()}updateEarlyAccessFeatureEnrollment(e,n,r){this.featureFlags.updateEarlyAccessFeatureEnrollment(e,n,r)}getEarlyAccessFeatures(e,n,r){return n===void 0&&(n=!1),this.featureFlags.getEarlyAccessFeatures(e,n,r)}on(e,n){return this.ws.on(e,n)}onFeatureFlags(e){return this.featureFlags.onFeatureFlags(e)}onSurveysLoaded(e){return this.surveys.onSurveysLoaded(e)}onSessionId(e){var n,r;return(n=(r=this.sessionManager)==null?void 0:r.onSessionId(e))!==null&&n!==void 0?n:()=>{}}getSurveys(e,n){n===void 0&&(n=!1),this.surveys.getSurveys(e,n)}getActiveMatchingSurveys(e,n){n===void 0&&(n=!1),this.surveys.getActiveMatchingSurveys(e,n)}renderSurvey(e,n){this.surveys.renderSurvey(e,n)}canRenderSurvey(e){return this.surveys.canRenderSurvey(e)}canRenderSurveyAsync(e,n){return n===void 0&&(n=!1),this.surveys.canRenderSurveyAsync(e,n)}identify(e,n,r){if(!this.__loaded||!this.persistence)return $e.uninitializedWarning("posthog.identify");if(Ir(e)&&(e=e.toString(),$e.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),e)if(["distinct_id","distinctid"].includes(e.toLowerCase()))$e.critical('The string "'+e+'" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.');else if(e!==bf){if(this.zs("posthog.identify")){var s=this.get_distinct_id();if(this.register({$user_id:e}),!this.get_property("$device_id")){var i=s;this.register_once({$had_persisted_distinct_id:!0,$device_id:i},"")}e!==s&&e!==this.get_property($f)&&(this.unregister($f),this.register({distinct_id:e}));var o=(this.persistence.get_property(wa)||"anonymous")==="anonymous";e!==s&&o?(this.persistence.set_property(wa,"identified"),this.setPersonPropertiesForFlags(Fe({},r||{},n||{}),!1),this.capture("$identify",{distinct_id:e,$anon_distinct_id:s},{$set:n||{},$set_once:r||{}}),this.ks=vD(e,n,r),this.featureFlags.setAnonymousDistinctId(s)):(n||r)&&this.setPersonProperties(n,r),e!==s&&(this.reloadFeatureFlags(),this.unregister(vv))}}else $e.critical('The string "'+bf+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.');else $e.error("Unique user id has not been set in posthog.identify")}setPersonProperties(e,n){if((e||n)&&this.zs("posthog.setPersonProperties")){var r=vD(this.get_distinct_id(),e,n);this.ks!==r?(this.setPersonPropertiesForFlags(Fe({},n||{},e||{})),this.capture("$set",{$set:e||{},$set_once:n||{}}),this.ks=r):$e.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}group(e,n,r){if(e&&n){if(this.zs("posthog.group")){var s=this.getGroups();s[e]!==n&&this.resetGroupPropertiesForFlags(e),this.register({$groups:Fe({},s,{[e]:n})}),r&&(this.capture("$groupidentify",{$group_type:e,$group_key:n,$group_set:r}),this.setGroupPropertiesForFlags({[e]:r})),s[e]===n||r||this.reloadFeatureFlags()}}else $e.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,n){n===void 0&&(n=!0),this.featureFlags.setPersonPropertiesForFlags(e,n)}resetPersonPropertiesForFlags(){this.featureFlags.resetPersonPropertiesForFlags()}setGroupPropertiesForFlags(e,n){n===void 0&&(n=!0),this.zs("posthog.setGroupPropertiesForFlags")&&this.featureFlags.setGroupPropertiesForFlags(e,n)}resetGroupPropertiesForFlags(e){this.featureFlags.resetGroupPropertiesForFlags(e)}reset(e){var n,r,s,i;if($e.info("reset"),!this.__loaded)return $e.uninitializedWarning("posthog.reset");var o=this.get_property("$device_id");if(this.consent.reset(),(n=this.persistence)==null||n.clear(),(r=this.sessionPersistence)==null||r.clear(),this.surveys.reset(),this.featureFlags.reset(),(s=this.persistence)==null||s.set_property(wa,"anonymous"),(i=this.sessionManager)==null||i.resetSessionId(),this.ks=null,this.config.cookieless_mode==="always")this.register_once({distinct_id:bf,$device_id:null},"");else{var c=this.config.get_device_id(Eo());this.register_once({distinct_id:c,$device_id:e?c:o},"")}this.register({$last_posthog_reset:new Date().toISOString()},1)}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var e,n;return(e=(n=this.sessionManager)==null?void 0:n.checkAndGetSessionAndWindowId(!0).sessionId)!==null&&e!==void 0?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";var{sessionId:n,sessionStartTimestamp:r}=this.sessionManager.checkAndGetSessionAndWindowId(!0),s=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+n);if(e!=null&&e.withTimestamp&&r){var i,o=(i=e.timestampLookBack)!==null&&i!==void 0?i:10;if(!r)return s;s+="?t="+Math.max(Math.floor((new Date().getTime()-r)/1e3)-o,0)}return s}alias(e,n){return e===this.get_property(mU)?($e.critical("Attempting to create alias for existing People user - aborting."),-2):this.zs("posthog.alias")?(Me(n)&&(n=this.get_distinct_id()),e!==n?(this.Us($f,e),this.capture("$create_alias",{alias:e,distinct_id:n})):($e.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var n=Fe({},this.config);if(Bn(e)){var r,s,i,o,c;Xn(this.config,MD(e));var u=this.Ps();(r=this.persistence)==null||r.update_config(this.config,n,u),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new e_(Fe({},this.config,{persistence:"sessionStorage"}),u),dr.W()&&dr.J("ph_debug")==="true"&&(this.config.debug=!0),this.config.debug&&(Ea.DEBUG=!0,$e.info("set_config",{config:e,oldConfig:n,newConfig:Fe({},this.config)})),(s=this.sessionRecording)==null||s.startIfEnabledOrStop(),(i=this.autocapture)==null||i.startIfEnabled(),(o=this.heatmaps)==null||o.startIfEnabled(),this.surveys.loadIfEnabled(),this.qs(),(c=this.externalIntegrations)==null||c.startIfEnabledOrStop()}}startSessionRecording(e){var n=e===!0,r={sampling:n||!(e==null||!e.sampling),linked_flag:n||!(e==null||!e.linked_flag),url_trigger:n||!(e==null||!e.url_trigger),event_trigger:n||!(e==null||!e.event_trigger)};if(Object.values(r).some(Boolean)){var s,i,o,c,u;(s=this.sessionManager)==null||s.checkAndGetSessionAndWindowId(),r.sampling&&((i=this.sessionRecording)==null||i.overrideSampling()),r.linked_flag&&((o=this.sessionRecording)==null||o.overrideLinkedFlag()),r.url_trigger&&((c=this.sessionRecording)==null||c.overrideTrigger("url")),r.event_trigger&&((u=this.sessionRecording)==null||u.overrideTrigger("event"))}this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var e;return!((e=this.sessionRecording)==null||!e.started)}captureException(e,n){var r=new Error("PostHog syntheticException");return this.exceptions.sendExceptionEvent(Fe({},jye((s=>s instanceof Error)(e)?{error:e,event:e.message}:{event:e},{syntheticException:r}),n))}loadToolbar(e){return this.toolbar.loadToolbar(e)}get_property(e){var n;return(n=this.persistence)==null?void 0:n.props[e]}getSessionProperty(e){var n;return(n=this.sessionPersistence)==null?void 0:n.props[e]}toString(){var e,n=(e=this.config.name)!==null&&e!==void 0?e:ru;return n!==ru&&(n=ru+"."+n),n}_isIdentified(){var e,n;return((e=this.persistence)==null?void 0:e.get_property(wa))==="identified"||((n=this.sessionPersistence)==null?void 0:n.get_property(wa))==="identified"}Ns(){var e,n;return!(this.config.person_profiles==="never"||this.config.person_profiles==="identified_only"&&!this._isIdentified()&&hu(this.getGroups())&&((e=this.persistence)==null||(e=e.props)==null||!e[$f])&&((n=this.persistence)==null||(n=n.props)==null||!n[xv]))}Ds(){return this.config.capture_pageleave===!0||this.config.capture_pageleave==="if_capture_pageview"&&(this.config.capture_pageview===!0||this.config.capture_pageview==="history_change")}createPersonProfile(){this.Ns()||this.zs("posthog.createPersonProfile")&&this.setPersonProperties({},{})}zs(e){return this.config.person_profiles==="never"?($e.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.Us(xv,!0),!0)}Ps(){if(this.config.cookieless_mode==="always")return!0;var e=this.consent.isOptedOut(),n=this.config.opt_out_persistence_by_default||this.config.cookieless_mode==="on_reject";return this.config.disable_persistence||e&&!!n}qs(){var e,n,r,s,i=this.Ps();return((e=this.persistence)==null?void 0:e.De)!==i&&((r=this.persistence)==null||r.set_disabled(i)),((n=this.sessionPersistence)==null?void 0:n.De)!==i&&((s=this.sessionPersistence)==null||s.set_disabled(i)),i}opt_in_capturing(e){if(this.config.cookieless_mode!=="always"){var n;this.config.cookieless_mode==="on_reject"&&this.consent.isExplicitlyOptedOut()&&(this.reset(!0),this.sessionManager=new ND(this),this.persistence&&(this.sessionPropsManager=new AD(this,this.sessionManager,this.persistence)),this.sessionRecording=new dD(this),this.sessionRecording.startIfEnabledOrStop()),this.consent.optInOut(!0),this.qs(),(Me(e?.captureEventName)||e!=null&&e.captureEventName)&&this.capture((n=e?.captureEventName)!==null&&n!==void 0?n:"$opt_in",e?.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.As()}else $e.warn('Consent opt in/out is not valid with cookieless_mode="always" and will be ignored')}opt_out_capturing(){var e;this.config.cookieless_mode!=="always"?(this.config.cookieless_mode==="on_reject"&&this.consent.isOptedIn()&&this.reset(!0),this.consent.optInOut(!1),this.qs(),this.config.cookieless_mode==="on_reject"&&(this.register({distinct_id:bf,$device_id:null}),this.sessionManager=void 0,this.sessionPropsManager=void 0,(e=this.sessionRecording)==null||e.stopRecording(),this.sessionRecording=void 0,this.As())):$e.warn('Consent opt in/out is not valid with cookieless_mode="always" and will be ignored')}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}is_capturing(){return this.config.cookieless_mode==="always"||(this.config.cookieless_mode==="on_reject"?this.consent.isExplicitlyOptedOut()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this.qs()}_is_bot(){return Ns?g6(Ns,this.config.custom_blocked_useragents):void 0}As(){Ue&&(Ue.visibilityState==="visible"?this.Ss||(this.Ss=!0,this.capture("$pageview",{title:Ue.title},{send_instantly:!0}),this.$s&&(Ue.removeEventListener("visibilitychange",this.$s),this.$s=null)):this.$s||(this.$s=this.As.bind(this),In(Ue,"visibilitychange",this.$s)))}debug(e){e===!1?(ye?.console.log("You've disabled debug mode."),localStorage&&localStorage.removeItem("ph_debug"),this.set_config({debug:!1})):(ye?.console.log("You're now in debug mode. All calls to PostHog will be logged in your console.\nYou can disable this with `posthog.debug(false)`."),localStorage&&localStorage.setItem("ph_debug","true"),this.set_config({debug:!0}))}j(){var e,n,r,s,i,o,c,u=this.Es||{};return"advanced_disable_flags"in u?!!u.advanced_disable_flags:this.config.advanced_disable_flags!==!1?!!this.config.advanced_disable_flags:this.config.advanced_disable_decide===!0?($e.warn("Config field 'advanced_disable_decide' is deprecated. Please use 'advanced_disable_flags' instead. The old field will be removed in a future major version."),!0):(r="advanced_disable_decide",s=!1,i=$e,o=(n="advanced_disable_flags")in(e=u)&&!Me(e[n]),c=r in e&&!Me(e[r]),o?e[n]:c?(i&&i.warn("Config field '"+r+"' is deprecated. Please use '"+n+"' instead. The old field will be removed in a future major version."),e[r]):s)}Ls(e){if(Zt(this.config.before_send))return e;var n=kn(this.config.before_send)?this.config.before_send:[this.config.before_send],r=e;for(var s of n){if(r=s(r),Zt(r)){var i="Event '"+e.event+"' was rejected in beforeSend function";return Uve(e.event)?$e.warn(i+". This can cause unexpected behavior."):$e.info(i),null}r.properties&&!hu(r.properties)||$e.warn("Event '"+e.event+"' has no properties after beforeSend function, this is likely an error.")}return r}getPageViewId(){var e;return(e=this.pageViewManager.fe)==null?void 0:e.pageViewId}captureTraceFeedback(e,n){this.capture("$ai_feedback",{$ai_trace_id:String(e),$ai_feedback_text:n})}captureTraceMetric(e,n,r){this.capture("$ai_metric",{$ai_trace_id:String(e),$ai_metric_name:n,$ai_metric_value:String(r)})}}(function(t,e){for(var n=0;n<e.length;n++)t.prototype[e[n]]=Bve(t.prototype[e[n]])})(jy,["identify"]);var DD,su=(DD=hh[ru]=new jy,function(){function t(){t.done||(t.done=!0,v6=!1,mn(hh,function(e){e._dom_loaded()}))}Ue!=null&&Ue.addEventListener?Ue.readyState==="complete"?t():In(Ue,"DOMContentLoaded",t,{capture:!1}):ye&&$e.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}(),DD),y6=_.createContext({client:su});function x6(t,e,n){if(n===void 0&&(n=new WeakMap),t===e)return!0;if(typeof t!="object"||t===null||typeof e!="object"||e===null)return!1;if(n.has(t)&&n.get(t)===e)return!0;n.set(t,e);var r=Object.keys(t),s=Object.keys(e);if(r.length!==s.length)return!1;for(var i=0,o=r;i<o.length;i++){var c=o[i];if(!s.includes(c)||!x6(t[c],e[c],n))return!1}return!0}function tbe(t){var e=t.children,n=t.client,r=t.apiKey,s=t.options,i=_.useRef(null),o=_.useMemo(function(){return n?(r&&console.warn("[PostHog.js] You have provided both `client` and `apiKey` to `PostHogProvider`. `apiKey` will be ignored in favour of `client`."),s&&console.warn("[PostHog.js] You have provided both `client` and `options` to `PostHogProvider`. `options` will be ignored in favour of `client`."),n):(r||console.warn("[PostHog.js] No `apiKey` or `client` were provided to `PostHogProvider`. Using default global `window.posthog` instance. You must initialize it manually. This is not recommended behavior."),su)},[n,r,JSON.stringify(s)]);return _.useEffect(function(){if(!n){var c=i.current;c?(r!==c.apiKey&&console.warn("[PostHog.js] You have provided a different `apiKey` to `PostHogProvider` than the one that was already initialized. This is not supported by our provider and we'll keep using the previous key. If you need to toggle between API Keys you need to control the `client` yourself and pass it in as a prop rather than an `apiKey` prop."),s&&!x6(s,c.options)&&su.set_config(s),i.current={apiKey:r,options:s??{}}):(su.__loaded&&console.warn("[PostHog.js] `posthog` was already loaded elsewhere. This may cause issues."),su.init(r,s),i.current={apiKey:r,options:s??{}})}},[n,r,JSON.stringify(s)]),ke.createElement(y6.Provider,{value:{client:o}},e)}var M1=function(t,e){return M1=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(n[s]=r[s])},M1(t,e)};function nbe(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");M1(t,e);function n(){this.constructor=t}t.prototype=e===null?Object.create(e):(n.prototype=e.prototype,new n)}var s_=function(t){return typeof t=="function"},rbe={componentStack:null,exceptionEvent:null,error:null},sbe={INVALID_FALLBACK:"[PostHog.js][PostHogErrorBoundary] Invalid fallback prop, provide a valid React element or a function that returns a valid React element."};(function(t){nbe(e,t);function e(n){var r=t.call(this,n)||this;return r.state=rbe,r}return e.prototype.componentDidCatch=function(n,r){var s=this.props.additionalProperties,i;s_(s)?i=s(n):typeof s=="object"&&(i=s);var o=this.context.client,c=o.captureException(n,i),u=r.componentStack;this.setState({error:n,componentStack:u,exceptionEvent:c})},e.prototype.render=function(){var n=this.props,r=n.children,s=n.fallback,i=this.state;if(i.componentStack==null)return s_(r)?r():r;var o=s_(s)?ke.createElement(s,{error:i.error,componentStack:i.componentStack,exceptionEvent:i.exceptionEvent}):s;return ke.isValidElement(o)?o:(console.warn(sbe.INVALID_FALLBACK),ke.createElement(ke.Fragment,null))},e.contextType=y6,e})(ke.Component);function ibe({children:t,client:e,useAuth:n}){const r=abe(n);return h.jsx(eq,{client:e,useAuth:r,children:t})}function abe(t){return _.useMemo(()=>function(){const{isLoading:n,user:r,getAccessToken:s}=t(),i=_.useCallback(async()=>{try{return await s()}catch{return null}},[s]);return _.useMemo(()=>({isLoading:n,isAuthenticated:!!r,fetchAccessToken:i}),[n,r,i])},[t])}const obe=void 0,lbe=void 0,cbe=typeof window>"u"?"/callback":window.location.protocol==="http:"||window.location.protocol==="https:"?`${window.location.origin}/callback`:window?.isElectron?"mcpjam://oauth/callback":`${window.location.origin}/callback`;console.warn("[main] VITE_CONVEX_URL is not set; Convex features may not work.");console.warn("[main] VITE_WORKOS_CLIENT_ID is not set; authentication will not work.");const ube=new XB(obe),dbe=PV.createRoot(document.getElementById("root")),fbe=h.jsx(Rve,{clientId:lbe,redirectUri:cbe,children:h.jsx(ibe,{client:ube,useAuth:oU,children:h.jsx(Ove,{})})});dbe.render(h.jsx(_.StrictMode,{children:h.jsx(tbe,{apiKey:Ive(),options:Lve(),children:fbe})}));
1768
- //# sourceMappingURL=index-DvbqjJFH.js.map
1767
+ `)).length,s=0;s<r;s++){var o=t.charCodeAt(s),c=null;o<128?n++:c=o>127&&o<2048?String.fromCharCode(o>>6|192,63&o|128):String.fromCharCode(o>>12|224,o>>6&63|128,63&o|128),Ko(c)||(n>e&&(i+=t.substring(e,n)),i+=c,e=n=s+1)}return n>e&&(i+=t.substring(e,t.length)),i},pxe=!!i1||!!s1,gD="text/plain",Cv=(t,e)=>{var[n,r]=t.split("?"),s=Fe({},e);r?.split("&").forEach(o=>{var[c]=o.split("=");delete s[c]});var i=rye(s);return n+"?"+(i=i?(r?r+"&":"")+i:r)},Hf=(t,e)=>JSON.stringify(t,(n,r)=>typeof r=="bigint"?r.toString():r,e),Xw=t=>{var{data:e,compression:n}=t;if(e){if(n===Ta.GZipJS){var r=FU(UU(Hf(e)),{mtime:0}),s=new Blob([r],{type:gD});return{contentType:gD,body:s,estimatedSize:s.size}}if(n===Ta.Base64){var i=function(u){var d,p,m,v,y,x="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",w=0,k=0,S="",R=[];if(!u)return u;u=hxe(u);do d=(y=u.charCodeAt(w++)<<16|u.charCodeAt(w++)<<8|u.charCodeAt(w++))>>18&63,p=y>>12&63,m=y>>6&63,v=63&y,R[k++]=x.charAt(d)+x.charAt(p)+x.charAt(m)+x.charAt(v);while(w<u.length);switch(S=R.join(""),u.length%3){case 1:S=S.slice(0,-2)+"==";break;case 2:S=S.slice(0,-1)+"="}return S}(Hf(e)),o=(u=>"data="+encodeURIComponent(typeof u=="string"?u:Hf(u)))(i);return{contentType:"application/x-www-form-urlencoded",body:o,estimatedSize:new Blob([o]).size}}var c=Hf(e);return{contentType:"application/json",body:c,estimatedSize:new Blob([c]).size}}},fh=[];s1&&fh.push({transport:"fetch",method:t=>{var e,n,{contentType:r,body:s,estimatedSize:i}=(e=Xw(t))!==null&&e!==void 0?e:{},o=new Headers;mn(t.headers,function(p,m){o.append(m,p)}),r&&o.append("Content-Type",r);var c=t.url,u=null;if(NM){var d=new NM;u={signal:d.signal,timeout:setTimeout(()=>d.abort(),t.timeout)}}s1(c,Fe({method:t?.method||"GET",headers:o,keepalive:t.method==="POST"&&(i||0)<52428.8,body:s,signal:(n=u)==null?void 0:n.signal},t.fetchOptions)).then(p=>p.text().then(m=>{var v={statusCode:p.status,text:m};if(p.status===200)try{v.json=JSON.parse(m)}catch(y){$e.error(y)}t.callback==null||t.callback(v)})).catch(p=>{$e.error(p),t.callback==null||t.callback({statusCode:0,text:p})}).finally(()=>u?clearTimeout(u.timeout):null)}}),i1&&fh.push({transport:"XHR",method:t=>{var e,n=new i1;n.open(t.method||"GET",t.url,!0);var{contentType:r,body:s}=(e=Xw(t))!==null&&e!==void 0?e:{};mn(t.headers,function(i,o){n.setRequestHeader(o,i)}),r&&n.setRequestHeader("Content-Type",r),t.timeout&&(n.timeout=t.timeout),n.withCredentials=!0,n.onreadystatechange=()=>{if(n.readyState===4){var i={statusCode:n.status,text:n.responseText};if(n.status===200)try{i.json=JSON.parse(n.responseText)}catch{}t.callback==null||t.callback(i)}},n.send(s)}}),Ns!=null&&Ns.sendBeacon&&fh.push({transport:"sendBeacon",method:t=>{var e=Cv(t.url,{beacon:"1"});try{var n,{contentType:r,body:s}=(n=Xw(t))!==null&&n!==void 0?n:{},i=typeof s=="string"?new Blob([s],{type:r}):s;Ns.sendBeacon(e,i)}catch{}}});var Wu=function(t,e){if(!function(n){try{new RegExp(n)}catch{return!1}return!0}(e))return!1;try{return new RegExp(e).test(t)}catch{return!1}};function vD(t,e,n){return Hf({distinct_id:t,userPropertiesToSet:e,userPropertiesToSetOnce:n})}var mxe={exact:(t,e)=>e.some(n=>t.some(r=>n===r)),is_not:(t,e)=>e.every(n=>t.every(r=>n!==r)),regex:(t,e)=>e.some(n=>t.some(r=>Wu(n,r))),not_regex:(t,e)=>e.every(n=>t.every(r=>!Wu(n,r))),icontains:(t,e)=>e.map(rg).some(n=>t.map(rg).some(r=>n.includes(r))),not_icontains:(t,e)=>e.map(rg).every(n=>t.map(rg).every(r=>!n.includes(r)))},rg=t=>t.toLowerCase(),yD=br("[Error tracking]");class gxe{constructor(e){var n,r;this.pe=[],this._instance=e,this.pe=(n=(r=this._instance.persistence)==null?void 0:r.get_property(c1))!==null&&n!==void 0?n:[]}onRemoteConfig(e){var n,r,s,i=(n=(r=e.errorTracking)==null?void 0:r.suppressionRules)!==null&&n!==void 0?n:[],o=(s=e.errorTracking)==null?void 0:s.captureExtensionExceptions;this.pe=i,this._instance.persistence&&this._instance.persistence.register({[c1]:this.pe,[DM]:o})}get ge(){var e,n=!!this._instance.get_property(DM),r=this._instance.config.error_tracking.captureExtensionExceptions;return(e=r??n)!==null&&e!==void 0&&e}sendExceptionEvent(e){if(this._e(e))yD.info("Skipping exception capture because a suppression rule matched");else{if(this.ge||!this.me(e))return this._instance.capture("$exception",e,{_noTruncate:!0,_batchKey:"exceptionEvent"});yD.info("Skipping exception capture because it was thrown by an extension")}}_e(e){var n=e.$exception_list;if(!n||!kn(n)||n.length===0)return!1;var r=n.reduce((s,i)=>{var{type:o,value:c}=i;return qn(o)&&o.length>0&&s.$exception_types.push(o),qn(c)&&c.length>0&&s.$exception_values.push(c),s},{$exception_types:[],$exception_values:[]});return this.pe.some(s=>{var i=s.values.map(o=>{var c,u=mxe[o.operator],d=kn(o.value)?o.value:[o.value],p=(c=r[o.key])!==null&&c!==void 0?c:[];return d.length>0&&u(d,p)});return s.type==="OR"?i.some(Boolean):i.every(Boolean)})}me(e){var n=e.$exception_list;return!(!n||!kn(n))&&n.flatMap(r=>{var s,i;return(s=(i=r.stacktrace)==null?void 0:i.frames)!==null&&s!==void 0?s:[]}).some(r=>r.filename&&r.filename.startsWith("chrome-extension://"))}}var ei="Mobile",Rv="iOS",Fi="Android",Bh="Tablet",GU=Fi+" "+Bh,YU="iPad",WU="Apple",KU=WU+" Watch",qh="Safari",Ku="BlackBerry",QU="Samsung",XU=QU+"Browser",ZU=QU+" Internet",Jl="Chrome",vxe=Jl+" OS",JU=Jl+" "+Rv,_T="Internet Explorer",e6=_T+" "+ei,ST="Opera",yxe=ST+" Mini",ET="Edge",t6="Microsoft "+ET,ju="Firefox",n6=ju+" "+Rv,Hh="Nintendo",Gh="PlayStation",Ou="Xbox",r6=Fi+" "+ei,s6=ei+" "+qh,Gf="Windows",R1=Gf+" Phone",xD="Nokia",A1="Ouya",i6="Generic",xxe=i6+" "+ei.toLowerCase(),a6=i6+" "+Bh.toLowerCase(),N1="Konqueror",Yr="(\\d+(\\.\\d+)?)",Zw=new RegExp("Version/"+Yr),bxe=new RegExp(Ou,"i"),wxe=new RegExp(Gh+" \\w+","i"),_xe=new RegExp(Hh+" \\w+","i"),kT=new RegExp(Ku+"|PlayBook|BB10","i"),Sxe={"NT3.51":"NT 3.11","NT4.0":"NT 4.0","5.0":"2000",5.1:"XP",5.2:"XP","6.0":"Vista",6.1:"7",6.2:"8",6.3:"8.1",6.4:"10","10.0":"10"},Exe=(t,e)=>e&&It(e,WU)||function(n){return It(n,qh)&&!It(n,Jl)&&!It(n,Fi)}(t),o6=function(t,e){return e=e||"",It(t," OPR/")&&It(t,"Mini")?yxe:It(t," OPR/")?ST:kT.test(t)?Ku:It(t,"IE"+ei)||It(t,"WPDesktop")?e6:It(t,XU)?ZU:It(t,ET)||It(t,"Edg/")?t6:It(t,"FBIOS")?"Facebook "+ei:It(t,"UCWEB")||It(t,"UCBrowser")?"UC Browser":It(t,"CriOS")?JU:It(t,"CrMo")||It(t,Jl)?Jl:It(t,Fi)&&It(t,qh)?r6:It(t,"FxiOS")?n6:It(t.toLowerCase(),N1.toLowerCase())?N1:Exe(t,e)?It(t,ei)?s6:qh:It(t,ju)?ju:It(t,"MSIE")||It(t,"Trident/")?_T:It(t,"Gecko")?ju:""},kxe={[e6]:[new RegExp("rv:"+Yr)],[t6]:[new RegExp(ET+"?\\/"+Yr)],[Jl]:[new RegExp("("+Jl+"|CrMo)\\/"+Yr)],[JU]:[new RegExp("CriOS\\/"+Yr)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+Yr)],[qh]:[Zw],[s6]:[Zw],[ST]:[new RegExp("(Opera|OPR)\\/"+Yr)],[ju]:[new RegExp(ju+"\\/"+Yr)],[n6]:[new RegExp("FxiOS\\/"+Yr)],[N1]:[new RegExp("Konqueror[:/]?"+Yr,"i")],[Ku]:[new RegExp(Ku+" "+Yr),Zw],[r6]:[new RegExp("android\\s"+Yr,"i")],[ZU]:[new RegExp(XU+"\\/"+Yr)],[_T]:[new RegExp("(rv:|MSIE )"+Yr)],Mozilla:[new RegExp("rv:"+Yr)]},Txe=function(t,e){var n=o6(t,e),r=kxe[n];if(Me(r))return null;for(var s=0;s<r.length;s++){var i=r[s],o=t.match(i);if(o)return parseFloat(o[o.length-2])}return null},bD=[[new RegExp(Ou+"; "+Ou+" (.*?)[);]","i"),t=>[Ou,t&&t[1]||""]],[new RegExp(Hh,"i"),[Hh,""]],[new RegExp(Gh,"i"),[Gh,""]],[kT,[Ku,""]],[new RegExp(Gf,"i"),(t,e)=>{if(/Phone/.test(e)||/WPDesktop/.test(e))return[R1,""];if(new RegExp(ei).test(e)&&!/IEMobile\b/.test(e))return[Gf+" "+ei,""];var n=/Windows NT ([0-9.]+)/i.exec(e);if(n&&n[1]){var r=n[1],s=Sxe[r]||"";return/arm/i.test(e)&&(s="RT"),[Gf,s]}return[Gf,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,t=>{if(t&&t[3]){var e=[t[3],t[4],t[5]||"0"];return[Rv,e.join(".")]}return[Rv,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,t=>{var e="";return t&&t.length>=3&&(e=Me(t[2])?t[3]:t[2]),["watchOS",e]}],[new RegExp("("+Fi+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+Fi+")","i"),t=>{if(t&&t[2]){var e=[t[2],t[3],t[4]||"0"];return[Fi,e.join(".")]}return[Fi,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,t=>{var e=["Mac OS X",""];if(t&&t[1]){var n=[t[1],t[2],t[3]||"0"];e[1]=n.join(".")}return e}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[vxe,""]],[/Linux|debian/i,["Linux",""]]],wD=function(t){return _xe.test(t)?Hh:wxe.test(t)?Gh:bxe.test(t)?Ou:new RegExp(A1,"i").test(t)?A1:new RegExp("("+R1+"|WPDesktop)","i").test(t)?R1:/iPad/.test(t)?YU:/iPod/.test(t)?"iPod Touch":/iPhone/.test(t)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(t)?KU:kT.test(t)?Ku:/(kobo)\s(ereader|touch)/i.test(t)?"Kobo":new RegExp(xD,"i").test(t)?xD:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(t)||/(kf[a-z]+)( bui|\)).+silk\//i.test(t)?"Kindle Fire":/(Android|ZTE)/i.test(t)?!new RegExp(ei).test(t)||/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(t)?/pixel[\daxl ]{1,6}/i.test(t)&&!/pixel c/i.test(t)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(t)||/lmy47v/i.test(t)&&!/QTAQZ3/i.test(t)?Fi:GU:Fi:new RegExp("(pda|"+ei+")","i").test(t)?xxe:new RegExp(Bh,"i").test(t)&&!new RegExp(Bh+" pc","i").test(t)?a6:""},sg="https?://(.*)",Ny=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],Cxe=Cy(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],Ny),TT="<masked>",Rxe=["li_fat_id"];function l6(t,e,n){if(!Ue)return{};var r,s=e?Cy([],Ny,n||[]):[],i=c6(mT(Ue.URL,s,TT),t),o=(r={},mn(Rxe,function(c){var u=Yi.J(c);r[c]=u||null}),r);return Xn(o,i)}function c6(t,e){var n=Cxe.concat(e||[]),r={};return mn(n,function(s){var i=wv(t,s);r[s]=i||null}),r}function u6(t){var e=function(i){return i?i.search(sg+"google.([^/?]*)")===0?"google":i.search(sg+"bing.com")===0?"bing":i.search(sg+"yahoo.com")===0?"yahoo":i.search(sg+"duckduckgo.com")===0?"duckduckgo":null:null}(t),n=e!="yahoo"?"q":"p",r={};if(!Ko(e)){r.$search_engine=e;var s=Ue?wv(Ue.referrer,n):"";s.length&&(r.ph_keyword=s)}return r}function _D(){return navigator.language||navigator.userLanguage}function d6(){return Ue?.referrer||"$direct"}function f6(t,e){var n=t?Cy([],Ny,e||[]):[],r=ls?.href.substring(0,1e3);return{r:d6().substring(0,1e3),u:r?mT(r,n,TT):void 0}}function h6(t){var e,{r:n,u:r}=t,s={$referrer:n,$referring_domain:n==null?void 0:n=="$direct"?"$direct":(e=Gu(n))==null?void 0:e.host};if(r){s.$current_url=r;var i=Gu(r);s.$host=i?.host,s.$pathname=i?.pathname;var o=c6(r);Xn(s,o)}if(n){var c=u6(n);Xn(s,c)}return s}function p6(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function Axe(){try{return new Date().getTimezoneOffset()}catch{return}}function Nxe(t,e){if(!os)return{};var n,r,s,i=t?Cy([],Ny,e||[]):[],[o,c]=function(u){for(var d=0;d<bD.length;d++){var[p,m]=bD[d],v=p.exec(u),y=v&&(Zs(m)?m(v,u):m);if(y)return y}return["",""]}(os);return Xn(hT({$os:o,$os_version:c,$browser:o6(os,navigator.vendor),$device:wD(os),$device_type:(r=os,s=wD(r),s===YU||s===GU||s==="Kobo"||s==="Kindle Fire"||s===a6?Bh:s===Hh||s===Ou||s===Gh||s===A1?"Console":s===KU?"Wearable":s?ei:"Desktop"),$timezone:p6(),$timezone_offset:Axe()}),{$current_url:mT(ls?.href,i,TT),$host:ls?.host,$pathname:ls?.pathname,$raw_user_agent:os.length>1e3?os.substring(0,997)+"...":os,$browser_version:Txe(os,navigator.vendor),$browser_language:_D(),$browser_language_prefix:(n=_D(),typeof n=="string"?n.split("-")[0]:void 0),$screen_height:ye?.screen.height,$screen_width:ye?.screen.width,$viewport_height:ye?.innerHeight,$viewport_width:ye?.innerWidth,$lib:"web",$lib_version:Ea.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})}var Oi=br("[FeatureFlags]"),Jw="$active_feature_flags",Wc="$override_feature_flags",SD="$feature_flag_payloads",kf="$override_feature_flag_payloads",ED="$feature_flag_request_id",kD=t=>{var e={};for(var[n,r]of yg(t||{}))r&&(e[n]=r);return e},jxe=t=>{var e=t.flags;return e?(t.featureFlags=Object.fromEntries(Object.keys(e).map(n=>{var r;return[n,(r=e[n].variant)!==null&&r!==void 0?r:e[n].enabled]})),t.featureFlagPayloads=Object.fromEntries(Object.keys(e).filter(n=>e[n].enabled).filter(n=>{var r;return(r=e[n].metadata)==null?void 0:r.payload}).map(n=>{var r;return[n,(r=e[n].metadata)==null?void 0:r.payload]}))):Oi.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),t},Oxe=function(t){return t.FeatureFlags="feature_flags",t.Recordings="recordings",t}({});class Pxe{constructor(e){this.be=!1,this.ye=!1,this.we=!1,this.Se=!1,this.$e=!1,this.xe=!1,this.ke=!1,this._instance=e,this.featureFlagEventHandlers=[]}flags(){if(this._instance.config.__preview_remote_config)this.xe=!0;else{var e=!this.Ee&&(this._instance.config.advanced_disable_feature_flags||this._instance.config.advanced_disable_feature_flags_on_first_load);this.Ie({disableFlags:e})}}get hasLoadedFlags(){return this.ye}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var e=this._instance.get_property(h1),n=this._instance.get_property(Wc),r=this._instance.get_property(kf);if(!r&&!n)return e||{};var s=Xn({},e||{}),i=[...new Set([...Object.keys(r||{}),...Object.keys(n||{})])];for(var o of i){var c,u,d=s[o],p=n?.[o],m=Me(p)?(c=d?.enabled)!==null&&c!==void 0&&c:!!p,v=Me(p)?d.variant:typeof p=="string"?p:void 0,y=r?.[o],x=Fe({},d,{enabled:m,variant:m?v??d?.variant:void 0});m!==d?.enabled&&(x.original_enabled=d?.enabled),v!==d?.variant&&(x.original_variant=d?.variant),y&&(x.metadata=Fe({},d?.metadata,{payload:y,original_payload:d==null||(u=d.metadata)==null?void 0:u.payload})),s[o]=x}return this.be||(Oi.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:r,finalDetails:s}),this.be=!0),s}getFlagVariants(){var e=this._instance.get_property(pu),n=this._instance.get_property(Wc);if(!n)return e||{};for(var r=Xn({},e),s=Object.keys(n),i=0;i<s.length;i++)r[s[i]]=n[s[i]];return this.be||(Oi.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:n,finalFlags:r}),this.be=!0),r}getFlagPayloads(){var e=this._instance.get_property(SD),n=this._instance.get_property(kf);if(!n)return e||{};for(var r=Xn({},e||{}),s=Object.keys(n),i=0;i<s.length;i++)r[s[i]]=n[s[i]];return this.be||(Oi.warn(" Overriding feature flag payloads!",{flagPayloads:e,overriddenPayloads:n,finalPayloads:r}),this.be=!0),r}reloadFeatureFlags(){this.Se||this._instance.config.advanced_disable_feature_flags||this.Ee||(this.Ee=setTimeout(()=>{this.Ie()},5))}Pe(){clearTimeout(this.Ee),this.Ee=void 0}ensureFlagsLoaded(){this.ye||this.we||this.Ee||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this.Se=e}Ie(e){var n;if(this.Pe(),!this._instance.j())if(this.we)this.$e=!0;else{var r={token:this._instance.config.token,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:Fe({},((n=this._instance.persistence)==null?void 0:n.get_initial_props())||{},this._instance.get_property(Bf)||{}),group_properties:this._instance.get_property(Tl)};(e!=null&&e.disableFlags||this._instance.config.advanced_disable_feature_flags)&&(r.disable_flags=!0);var s=this._instance.config.__preview_remote_config,i=s?"/flags/?v=2":"/flags/?v=2&config=true",o=this._instance.config.advanced_only_evaluate_survey_feature_flags?"&only_evaluate_survey_feature_flags=true":"",c=this._instance.requestRouter.endpointFor("api",i+o);s&&(r.timezone=p6()),this.we=!0,this._instance.Re({method:"POST",url:c,data:r,compression:this._instance.config.disable_compression?void 0:Ta.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:u=>{var d,p,m=!0;if(u.statusCode===200&&(this.$e||(this.$anon_distinct_id=void 0),m=!1),this.we=!1,this.xe||(this.xe=!0,this._instance.Te((p=u.json)!==null&&p!==void 0?p:{})),!r.disable_flags||this.$e)if(this.ke=!m,u.json&&(d=u.json.quotaLimited)!=null&&d.includes(Oxe.FeatureFlags))Oi.warn("You have hit your feature flags quota limit, and will not be able to load feature flags until the quota is reset. Please visit https://posthog.com/docs/billing/limits-alerts to learn more.");else{var v;r.disable_flags||this.receivedFeatureFlags((v=u.json)!==null&&v!==void 0?v:{},m),this.$e&&(this.$e=!1,this.Ie())}}})}}getFeatureFlag(e,n){if(n===void 0&&(n={}),this.ye||this.getFlags()&&this.getFlags().length>0){var r=this.getFlagVariants()[e],s=""+r,i=this._instance.get_property(ED)||void 0,o=this._instance.get_property(vv)||{};if((n.send_event||!("send_event"in n))&&(!(e in o)||!o[e].includes(s))){var c,u,d,p,m,v,y,x,w;kn(o[e])?o[e].push(s):o[e]=[s],(c=this._instance.persistence)==null||c.register({[vv]:o});var k=this.getFeatureFlagDetails(e),S={$feature_flag:e,$feature_flag_response:r,$feature_flag_payload:this.getFeatureFlagPayload(e)||null,$feature_flag_request_id:i,$feature_flag_bootstrapped_response:((u=this._instance.config.bootstrap)==null||(u=u.featureFlags)==null?void 0:u[e])||null,$feature_flag_bootstrapped_payload:((d=this._instance.config.bootstrap)==null||(d=d.featureFlagPayloads)==null?void 0:d[e])||null,$used_bootstrap_value:!this.ke};Me(k==null||(p=k.metadata)==null?void 0:p.version)||(S.$feature_flag_version=k.metadata.version);var R,C=(m=k==null||(v=k.reason)==null?void 0:v.description)!==null&&m!==void 0?m:k==null||(y=k.reason)==null?void 0:y.code;C&&(S.$feature_flag_reason=C),k!=null&&(x=k.metadata)!=null&&x.id&&(S.$feature_flag_id=k.metadata.id),Me(k?.original_variant)&&Me(k?.original_enabled)||(S.$feature_flag_original_response=Me(k.original_variant)?k.original_enabled:k.original_variant),k!=null&&(w=k.metadata)!=null&&w.original_payload&&(S.$feature_flag_original_payload=k==null||(R=k.metadata)==null?void 0:R.original_payload),this._instance.capture("$feature_flag_called",S)}return r}Oi.warn('getFeatureFlag for key "'+e+`" failed. Feature flags didn't load in time.`)}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){return this.getFlagPayloads()[e]}getRemoteConfigPayload(e,n){var r=this._instance.config.token;this._instance.Re({method:"POST",url:this._instance.requestRouter.endpointFor("api","/flags/?v=2&config=true"),data:{distinct_id:this._instance.get_distinct_id(),token:r},compression:this._instance.config.disable_compression?void 0:Ta.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:s=>{var i,o=(i=s.json)==null?void 0:i.featureFlagPayloads;n(o?.[e]||void 0)}})}isFeatureEnabled(e,n){if(n===void 0&&(n={}),this.ye||this.getFlags()&&this.getFlags().length>0)return!!this.getFeatureFlag(e,n);Oi.warn('isFeatureEnabled for key "'+e+`" failed. Feature flags didn't load in time.`)}addFeatureFlagsHandler(e){this.featureFlagEventHandlers.push(e)}removeFeatureFlagsHandler(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter(n=>n!==e)}receivedFeatureFlags(e,n){if(this._instance.persistence){this.ye=!0;var r=this.getFlagVariants(),s=this.getFlagPayloads(),i=this.getFlagsWithDetails();(function(o,c,u,d,p){u===void 0&&(u={}),d===void 0&&(d={}),p===void 0&&(p={});var m=jxe(o),v=m.flags,y=m.featureFlags,x=m.featureFlagPayloads;if(y){var w=o.requestId;if(kn(y)){Oi.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var k={};if(y)for(var S=0;S<y.length;S++)k[y[S]]=!0;c&&c.register({[Jw]:y,[pu]:k})}else{var R=y,C=x,A=v;o.errorsWhileComputingFlags&&(R=Fe({},u,R),C=Fe({},d,C),A=Fe({},p,A)),c&&c.register(Fe({[Jw]:Object.keys(kD(R)),[pu]:R||{},[SD]:C||{},[h1]:A||{}},w?{[ED]:w}:{}))}}})(e,this._instance.persistence,r,s,i),this.Ce(n)}}override(e,n){n===void 0&&(n=!1),Oi.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:n})}overrideFeatureFlags(e){if(!this._instance.__loaded||!this._instance.persistence)return Oi.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(e===!1)return this._instance.persistence.unregister(Wc),this._instance.persistence.unregister(kf),void this.Ce();if(e&&typeof e=="object"&&("flags"in e||"payloads"in e)){var n,r=e;if(this.be=!!((n=r.suppressWarning)!==null&&n!==void 0&&n),"flags"in r){if(r.flags===!1)this._instance.persistence.unregister(Wc);else if(r.flags)if(kn(r.flags)){for(var s={},i=0;i<r.flags.length;i++)s[r.flags[i]]=!0;this._instance.persistence.register({[Wc]:s})}else this._instance.persistence.register({[Wc]:r.flags})}return"payloads"in r&&(r.payloads===!1?this._instance.persistence.unregister(kf):r.payloads&&this._instance.persistence.register({[kf]:r.payloads})),void this.Ce()}this.Ce()}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this.ye){var{flags:n,flagVariants:r}=this.Me();e(n,r)}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,n,r){var s,i=(this._instance.get_property(Vf)||[]).find(d=>d.flagKey===e),o={["$feature_enrollment/"+e]:n},c={$feature_flag:e,$feature_enrollment:n,$set:o};i&&(c.$early_access_feature_name=i.name),r&&(c.$feature_enrollment_stage=r),this._instance.capture("$feature_enrollment_update",c),this.setPersonPropertiesForFlags(o,!1);var u=Fe({},this.getFlagVariants(),{[e]:n});(s=this._instance.persistence)==null||s.register({[Jw]:Object.keys(kD(u)),[pu]:u}),this.Ce()}getEarlyAccessFeatures(e,n,r){n===void 0&&(n=!1);var s=this._instance.get_property(Vf),i=r?"&"+r.map(o=>"stage="+o).join("&"):"";if(s&&!n)return e(s);this._instance.Re({url:this._instance.requestRouter.endpointFor("api","/api/early_access_features/?token="+this._instance.config.token+i),method:"GET",callback:o=>{var c,u;if(o.json){var d=o.json.earlyAccessFeatures;return(c=this._instance.persistence)==null||c.unregister(Vf),(u=this._instance.persistence)==null||u.register({[Vf]:d}),e(d)}}})}Me(){var e=this.getFlags(),n=this.getFlagVariants();return{flags:e.filter(r=>n[r]),flagVariants:Object.keys(n).filter(r=>n[r]).reduce((r,s)=>(r[s]=n[s],r),{})}}Ce(e){var{flags:n,flagVariants:r}=this.Me();this.featureFlagEventHandlers.forEach(s=>s(n,r,{errorsLoading:e}))}setPersonPropertiesForFlags(e,n){n===void 0&&(n=!0);var r=this._instance.get_property(Bf)||{};this._instance.register({[Bf]:Fe({},r,e)}),n&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister(Bf)}setGroupPropertiesForFlags(e,n){n===void 0&&(n=!0);var r=this._instance.get_property(Tl)||{};Object.keys(r).length!==0&&Object.keys(r).forEach(s=>{r[s]=Fe({},r[s],e[s]),delete e[s]}),this._instance.register({[Tl]:Fe({},r,e)}),n&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var n=this._instance.get_property(Tl)||{};this._instance.register({[Tl]:Fe({},n,{[e]:{}})})}else this._instance.unregister(Tl)}reset(){this.ye=!1,this.we=!1,this.Se=!1,this.$e=!1,this.xe=!1,this.ke=!1,this.$anon_distinct_id=void 0,this.Pe(),this.be=!1}}var Mxe=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"];class e_{constructor(e,n){this.O=e,this.props={},this.Fe=!1,this.Oe=(r=>{var s="";return r.token&&(s=r.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),r.persistence_name?"ph_"+r.persistence_name:"ph_"+s+"_posthog"})(e),this.tt=this.Ae(e),this.load(),e.debug&&$e.info("Persistence loaded",e.persistence,Fe({},this.props)),this.update_config(e,e,n),this.save()}isDisabled(){return!!this.De}Ae(e){Mxe.indexOf(e.persistence.toLowerCase())===-1&&($e.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var n=e.persistence.toLowerCase();return n==="localstorage"&&dr.W()?dr:n==="localstorage+cookie"&&Xm.W()?Xm:n==="sessionstorage"&&Rr.W()?Rr:n==="memory"?pye:n==="cookie"?Yi:Xm.W()?Xm:Yi}properties(){var e={};return mn(this.props,function(n,r){if(r===pu&&Bn(n))for(var s=Object.keys(n),i=0;i<s.length;i++)e["$feature/"+s[i]]=n[s[i]];else c=r,u=!1,(Ko(o=Yve)?u:AM&&o.indexOf===AM?o.indexOf(c)!=-1:(mn(o,function(d){if(u||(u=d===c))return mv}),u))||(e[r]=n);var o,c,u}),e}load(){if(!this.De){var e=this.tt.V(this.Oe);e&&(this.props=Xn({},e))}}save(){this.De||this.tt.K(this.Oe,this.props,this.je,this.Le,this.Ne,this.O.debug)}remove(){this.tt.Y(this.Oe,!1),this.tt.Y(this.Oe,!0)}clear(){this.remove(),this.props={}}register_once(e,n,r){if(Bn(e)){Me(n)&&(n="None"),this.je=Me(r)?this.ze:r;var s=!1;if(mn(e,(i,o)=>{this.props.hasOwnProperty(o)&&this.props[o]!==n||(this.props[o]=i,s=!0)}),s)return this.save(),!0}return!1}register(e,n){if(Bn(e)){this.je=Me(n)?this.ze:n;var r=!1;if(mn(e,(s,i)=>{e.hasOwnProperty(i)&&this.props[i]!==s&&(this.props[i]=s,r=!0)}),r)return this.save(),!0}return!1}unregister(e){e in this.props&&(delete this.props[e],this.save())}update_campaign_params(){if(!this.Fe){var e=l6(this.O.custom_campaign_params,this.O.mask_personal_data_properties,this.O.custom_personal_data_properties);hu(hT(e))||this.register(e),this.Fe=!0}}update_search_keyword(){var e;this.register((e=Ue?.referrer)?u6(e):{})}update_referrer_info(){var e;this.register_once({$referrer:d6(),$referring_domain:Ue!=null&&Ue.referrer&&((e=Gu(Ue.referrer))==null?void 0:e.host)||"$direct"},void 0)}set_initial_person_info(){this.props[v1]||this.props[y1]||this.register_once({[yv]:f6(this.O.mask_personal_data_properties,this.O.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};mn([y1,v1],o=>{var c=this.props[o];c&&mn(c,function(u,d){e["$initial_"+a1(d)]=u})});var n,r,s=this.props[yv];if(s){var i=(n=h6(s),r={},mn(n,function(o,c){r["$initial_"+a1(c)]=o}),r);Xn(e,i)}return e}safe_merge(e){return mn(this.props,function(n,r){r in e||(e[r]=n)}),e}update_config(e,n,r){if(this.ze=this.je=e.cookie_expiration,this.set_disabled(e.disable_persistence||!!r),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),e.persistence!==n.persistence){var s=this.Ae(e),i=this.props;this.clear(),this.tt=s,this.props=i,this.save()}}set_disabled(e){this.De=e,this.De?this.remove():this.save()}set_cross_subdomain(e){e!==this.Le&&(this.Le=e,this.remove(),this.save())}set_secure(e){e!==this.Ne&&(this.Ne=e,this.remove(),this.save())}set_event_timer(e,n){var r=this.props[Ff]||{};r[e]=n,this.props[Ff]=r,this.save()}remove_event_timer(e){var n=(this.props[Ff]||{})[e];return Me(n)||(delete this.props[Ff][e],this.save()),n}get_property(e){return this.props[e]}set_property(e,n){this.props[e]=n,this.save()}}class m6{constructor(){this.Ue={},this.Ue={}}on(e,n){return this.Ue[e]||(this.Ue[e]=[]),this.Ue[e].push(n),()=>{this.Ue[e]=this.Ue[e].filter(r=>r!==n)}}emit(e,n){for(var r of this.Ue[e]||[])r(n);for(var s of this.Ue["*"]||[])s(e,n)}}class Cl{constructor(e){this.qe=new m6,this.Be=(n,r)=>this.He(n,r)&&this.We(n,r)&&this.Ge(n,r),this.He=(n,r)=>r==null||!r.event||n?.event===r?.event,this._instance=e,this.Je=new Set,this.Ve=new Set}init(){var e;if(!Me((e=this._instance)==null?void 0:e.Ke)){var n;(n=this._instance)==null||n.Ke((r,s)=>{this.on(r,s)})}}register(e){var n,r;if(!Me((n=this._instance)==null?void 0:n.Ke)&&(e.forEach(o=>{var c,u;(c=this.Ve)==null||c.add(o),(u=o.steps)==null||u.forEach(d=>{var p;(p=this.Je)==null||p.add(d?.event||"")})}),(r=this._instance)!=null&&r.autocapture)){var s,i=new Set;e.forEach(o=>{var c;(c=o.steps)==null||c.forEach(u=>{u!=null&&u.selector&&i.add(u?.selector)})}),(s=this._instance)==null||s.autocapture.setElementSelectors(i)}}on(e,n){var r;n!=null&&e.length!=0&&(this.Je.has(e)||this.Je.has(n?.event))&&this.Ve&&((r=this.Ve)==null?void 0:r.size)>0&&this.Ve.forEach(s=>{this.Ye(n,s)&&this.qe.emit("actionCaptured",s.name)})}Xe(e){this.onAction("actionCaptured",n=>e(n))}Ye(e,n){if(n?.steps==null)return!1;for(var r of n.steps)if(this.Be(e,r))return!0;return!1}onAction(e,n){return this.qe.on(e,n)}We(e,n){if(n!=null&&n.url){var r,s=e==null||(r=e.properties)==null?void 0:r.$current_url;if(!s||typeof s!="string"||!Cl.Qe(s,n?.url,n?.url_matching||"contains"))return!1}return!0}static Qe(e,n,r){switch(r){case"regex":return!!ye&&Wu(e,n);case"exact":return n===e;case"contains":var s=Cl.Ze(n).replace(/_/g,".").replace(/%/g,".*");return Wu(e,s);default:return!1}}static Ze(e){return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}Ge(e,n){if((n!=null&&n.href||n!=null&&n.tag_name||n!=null&&n.text)&&!this.tr(e).some(i=>!(n!=null&&n.href&&!Cl.Qe(i.href||"",n?.href,n?.href_matching||"exact"))&&(n==null||!n.tag_name||i.tag_name===n?.tag_name)&&!(n!=null&&n.text&&!Cl.Qe(i.text||"",n?.text,n?.text_matching||"exact")&&!Cl.Qe(i.$el_text||"",n?.text,n?.text_matching||"exact"))))return!1;if(n!=null&&n.selector){var r,s=e==null||(r=e.properties)==null?void 0:r.$element_selectors;if(!s||!s.includes(n?.selector))return!1}return!0}tr(e){return e?.properties.$elements==null?[]:e?.properties.$elements}}(function(t){return t.Button="button",t.Tab="tab",t.Selector="selector",t})({});(function(t){return t.TopLeft="top_left",t.TopRight="top_right",t.TopCenter="top_center",t.MiddleLeft="middle_left",t.MiddleRight="middle_right",t.MiddleCenter="middle_center",t.Left="left",t.Center="center",t.Right="right",t.NextToTrigger="next_to_trigger",t})({});var t_=function(t){return t.Popover="popover",t.API="api",t.Widget="widget",t.ExternalSurvey="external_survey",t}({});(function(t){return t.Open="open",t.MultipleChoice="multiple_choice",t.SingleChoice="single_choice",t.Rating="rating",t.Link="link",t})({});(function(t){return t.NextQuestion="next_question",t.End="end",t.ResponseBased="response_based",t.SpecificQuestion="specific_question",t})({});(function(t){return t.Once="once",t.Recurring="recurring",t.Always="always",t})({});var n_=function(t){return t.SHOWN="survey shown",t.DISMISSED="survey dismissed",t.SENT="survey sent",t}({}),TD=function(t){return t.SURVEY_ID="$survey_id",t.SURVEY_NAME="$survey_name",t.SURVEY_RESPONSE="$survey_response",t.SURVEY_ITERATION="$survey_iteration",t.SURVEY_ITERATION_START_DATE="$survey_iteration_start_date",t.SURVEY_PARTIALLY_COMPLETED="$survey_partially_completed",t.SURVEY_SUBMISSION_ID="$survey_submission_id",t.SURVEY_QUESTIONS="$survey_questions",t.SURVEY_COMPLETED="$survey_completed",t}({}),tr=br("[Surveys]"),j1="seenSurvey_",Dxe=(t,e)=>{var n="$survey_"+e+"/"+t.id;return t.current_iteration&&t.current_iteration>0&&(n="$survey_"+e+"/"+t.id+"/"+t.current_iteration),n},CD=t=>{var e=""+j1+t.id;return t.current_iteration&&t.current_iteration>0&&(e=""+j1+t.id+"_"+t.current_iteration),e},Ixe=[t_.Popover,t_.Widget,t_.API];class Lxe{constructor(e){this._instance=e,this.ir=new Map,this.er=new Map}register(e){var n;Me((n=this._instance)==null?void 0:n.Ke)||(this.rr(e),this.sr(e))}sr(e){var n=e.filter(r=>{var s,i;return((s=r.conditions)==null?void 0:s.actions)&&((i=r.conditions)==null||(i=i.actions)==null||(i=i.values)==null?void 0:i.length)>0});n.length!==0&&(this.nr==null&&(this.nr=new Cl(this._instance),this.nr.init(),this.nr.Xe(r=>{this.onAction(r)})),n.forEach(r=>{var s,i,o,c,u;r.conditions&&(s=r.conditions)!=null&&s.actions&&(i=r.conditions)!=null&&(i=i.actions)!=null&&i.values&&((o=r.conditions)==null||(o=o.actions)==null||(o=o.values)==null?void 0:o.length)>0&&((c=this.nr)==null||c.register(r.conditions.actions.values),(u=r.conditions)==null||(u=u.actions)==null||(u=u.values)==null||u.forEach(d=>{if(d&&d.name){var p=this.er.get(d.name);p&&p.push(r.id),this.er.set(d.name,p||[r.id])}}))}))}rr(e){var n;e.filter(r=>{var s,i;return((s=r.conditions)==null?void 0:s.events)&&((i=r.conditions)==null||(i=i.events)==null||(i=i.values)==null?void 0:i.length)>0}).length!==0&&((n=this._instance)==null||n.Ke((r,s)=>{this.onEvent(r,s)}),e.forEach(r=>{var s;(s=r.conditions)==null||(s=s.events)==null||(s=s.values)==null||s.forEach(i=>{if(i&&i.name){var o=this.ir.get(i.name);o&&o.push(r.id),this.ir.set(i.name,o||[r.id])}})}))}onEvent(e,n){var r,s=((r=this._instance)==null||(r=r.persistence)==null?void 0:r.props[Qm])||[];if(e==="survey shown"&&n&&s.length>0){var i;tr.info("survey event matched, removing survey from activated surveys",{event:e,eventPayload:n,existingActivatedSurveys:s});var o=n==null||(i=n.properties)==null?void 0:i.$survey_id;if(o){var c=s.indexOf(o);c>=0&&(s.splice(c,1),this.ar(s))}}else this.ir.has(e)&&(tr.info("survey event matched, updating activated surveys",{event:e,surveys:this.ir.get(e)}),this.ar(s.concat(this.ir.get(e)||[])))}onAction(e){var n,r=((n=this._instance)==null||(n=n.persistence)==null?void 0:n.props[Qm])||[];this.er.has(e)&&this.ar(r.concat(this.er.get(e)||[]))}ar(e){var n;(n=this._instance)==null||(n=n.persistence)==null||n.register({[Qm]:[...new Set(e)]})}getSurveys(){var e,n=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[Qm];return n||[]}getEventToSurveys(){return this.ir}lr(){return this.nr}}class zxe{constructor(e){this.ur=void 0,this._surveyManager=null,this.hr=!1,this.dr=!1,this.vr=[],this._instance=e,this._surveyEventReceiver=null}onRemoteConfig(e){var n=e.surveys;if(Zt(n))return tr.warn("Flags not loaded yet. Not loading surveys.");var r=kn(n);this.ur=r?n.length>0:n,tr.info("flags response received, isSurveysEnabled: "+this.ur),this.loadIfEnabled()}reset(){localStorage.removeItem("lastSeenSurveyDate");for(var e=[],n=0;n<localStorage.length;n++){var r=localStorage.key(n);(r!=null&&r.startsWith(j1)||r!=null&&r.startsWith("inProgressSurvey_"))&&e.push(r)}e.forEach(s=>localStorage.removeItem(s))}loadIfEnabled(){if(!this._surveyManager)if(this.dr)tr.info("Already initializing surveys, skipping...");else if(this._instance.config.disable_surveys)tr.info("Disabled. Not loading surveys.");else if(this._instance.config.cookieless_mode)tr.info("Not loading surveys in cookieless mode.");else{var e=bt?.__PosthogExtensions__;if(e){if(!Me(this.ur)||this._instance.config.advanced_enable_surveys){var n=this.ur||this._instance.config.advanced_enable_surveys;this.dr=!0;try{var r=e.generateSurveys;if(r)return void this.cr(r,n);var s=e.loadExternalDependency;if(!s)return void this.pr("PostHog loadExternalDependency extension not found.");s(this._instance,"surveys",i=>{i||!e.generateSurveys?this.pr("Could not load surveys script",i):this.cr(e.generateSurveys,n)})}catch(i){throw this.pr("Error initializing surveys",i),i}finally{this.dr=!1}}}else tr.error("PostHog Extensions not found.")}}cr(e,n){this._surveyManager=e(this._instance,n),this._surveyEventReceiver=new Lxe(this._instance),tr.info("Surveys loaded successfully"),this.gr({isLoaded:!0})}pr(e,n){tr.error(e,n),this.gr({isLoaded:!1,error:e})}onSurveysLoaded(e){return this.vr.push(e),this._surveyManager&&this.gr({isLoaded:!0}),()=>{this.vr=this.vr.filter(n=>n!==e)}}getSurveys(e,n){if(n===void 0&&(n=!1),this._instance.config.disable_surveys)return tr.info("Disabled. Not loading surveys."),e([]);var r=this._instance.get_property(p1);if(r&&!n)return e(r,{isLoaded:!0});if(this.hr)return e([],{isLoaded:!1,error:"Surveys are already being loaded"});try{this.hr=!0,this._instance.Re({url:this._instance.requestRouter.endpointFor("api","/api/surveys/?token="+this._instance.config.token),method:"GET",timeout:this._instance.config.surveys_request_timeout_ms,callback:s=>{var i;this.hr=!1;var o=s.statusCode;if(o!==200||!s.json){var c="Surveys API could not be loaded, status: "+o;return tr.error(c),e([],{isLoaded:!1,error:c})}var u,d=s.json.surveys||[],p=d.filter(m=>function(v){return!(!v.start_date||v.end_date)}(m)&&(function(v){var y;return!((y=v.conditions)==null||(y=y.events)==null||(y=y.values)==null||!y.length)}(m)||function(v){var y;return!((y=v.conditions)==null||(y=y.actions)==null||(y=y.values)==null||!y.length)}(m)));return p.length>0&&((u=this._surveyEventReceiver)==null||u.register(p)),(i=this._instance.persistence)==null||i.register({[p1]:d}),e(d,{isLoaded:!0})}})}catch(s){throw this.hr=!1,s}}gr(e){for(var n of this.vr)try{if(!e.isLoaded)return n([],e);this.getSurveys(n)}catch(r){tr.error("Error in survey callback",r)}}getActiveMatchingSurveys(e,n){if(n===void 0&&(n=!1),!Zt(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,n);tr.warn("init was not called")}_r(e){var n=null;return this.getSurveys(r=>{var s;n=(s=r.find(i=>i.id===e))!==null&&s!==void 0?s:null}),n}mr(e){if(Zt(this._surveyManager))return{eligible:!1,reason:"SDK is not enabled or survey functionality is not yet loaded"};var n=typeof e=="string"?this._r(e):e;return n?this._surveyManager.checkSurveyEligibility(n):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(e){if(Zt(this._surveyManager))return tr.warn("init was not called"),{visible:!1,disabledReason:"SDK is not enabled or survey functionality is not yet loaded"};var n=this.mr(e);return{visible:n.eligible,disabledReason:n.reason}}canRenderSurveyAsync(e,n){return Zt(this._surveyManager)?(tr.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:"SDK is not enabled or survey functionality is not yet loaded"})):new Promise(r=>{this.getSurveys(s=>{var i,o=(i=s.find(u=>u.id===e))!==null&&i!==void 0?i:null;if(o){var c=this.mr(o);r({visible:c.eligible,disabledReason:c.reason})}else r({visible:!1,disabledReason:"Survey not found"})},n)})}renderSurvey(e,n){if(Zt(this._surveyManager))tr.warn("init was not called");else{var r=this._r(e);if(r)if(Ixe.includes(r.type)){var s=Ue?.querySelector(n);s?this._surveyManager.renderSurvey(r,s):tr.warn("Survey element not found")}else tr.warn("Surveys of type "+r.type+" cannot be rendered in the app");else tr.warn("Survey not found")}}}var RD=br("[RateLimiter]");class $xe{constructor(e){var n,r;this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=s=>{var i=s.text;if(i&&i.length)try{(JSON.parse(i).quota_limited||[]).forEach(o=>{RD.info((o||"events")+" is quota limited."),this.serverLimits[o]=new Date().getTime()+6e4})}catch(o){return void RD.warn('could not rate limit - continuing. Error: "'+o?.message+'"',{text:i})}},this.instance=e,this.captureEventsPerSecond=((n=e.config.rate_limiting)==null?void 0:n.events_per_second)||10,this.captureEventsBurstLimit=Math.max(((r=e.config.rate_limiting)==null?void 0:r.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond),this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}clientRateLimitContext(e){var n,r,s;e===void 0&&(e=!1);var i=new Date().getTime(),o=(n=(r=this.instance.persistence)==null?void 0:r.get_property(g1))!==null&&n!==void 0?n:{tokens:this.captureEventsBurstLimit,last:i};o.tokens+=(i-o.last)/1e3*this.captureEventsPerSecond,o.last=i,o.tokens>this.captureEventsBurstLimit&&(o.tokens=this.captureEventsBurstLimit);var c=o.tokens<1;return c||e||(o.tokens=Math.max(0,o.tokens-1)),!c||this.lastEventRateLimited||e||this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited. Config is set to "+this.captureEventsPerSecond+" events per second and "+this.captureEventsBurstLimit+" events burst limit."},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=c,(s=this.instance.persistence)==null||s.set_property(g1,o),{isRateLimited:c,remainingTokens:o.tokens}}isServerRateLimited(e){var n=this.serverLimits[e||"events"]||!1;return n!==!1&&new Date().getTime()<n}}var Sl=br("[RemoteConfig]");class Fxe{constructor(e){this._instance=e}get remoteConfig(){var e;return(e=bt._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.config}br(e){var n,r;(n=bt.__PosthogExtensions__)!=null&&n.loadExternalDependency?(r=bt.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,"remote-config",()=>e(this.remoteConfig)):(Sl.error("PostHog Extensions not found. Cannot load remote config."),e())}yr(e){this._instance.Re({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback:n=>{e(n.json)}})}load(){try{if(this.remoteConfig)return Sl.info("Using preloaded remote config",this.remoteConfig),void this.Te(this.remoteConfig);if(this._instance.j())return void Sl.warn("Remote config is disabled. Falling back to local config.");this.br(e=>{if(!e)return Sl.info("No config found after loading remote JS config. Falling back to JSON."),void this.yr(n=>{this.Te(n)});this.Te(e)})}catch(e){Sl.error("Error loading remote config",e)}}Te(e){e?this._instance.config.__preview_remote_config?(this._instance.Te(e),e.hasFeatureFlags!==!1&&this._instance.featureFlags.ensureFlagsLoaded()):Sl.info("__preview_remote_config is disabled. Logging config instead",e):Sl.error("Failed to fetch remote config from PostHog.")}}var O1=3e3;class Uxe{constructor(e,n){this.wr=!0,this.Sr=[],this.$r=js(n?.flush_interval_ms||O1,250,5e3,$e.createLogger("flush interval"),O1),this.kr=e}enqueue(e){this.Sr.push(e),this.Er||this.Ir()}unload(){this.Pr();var e=this.Sr.length>0?this.Rr():{},n=Object.values(e);[...n.filter(r=>r.url.indexOf("/e")===0),...n.filter(r=>r.url.indexOf("/e")!==0)].map(r=>{this.kr(Fe({},r,{transport:"sendBeacon"}))})}enable(){this.wr=!1,this.Ir()}Ir(){var e=this;this.wr||(this.Er=setTimeout(()=>{if(this.Pr(),this.Sr.length>0){var n=this.Rr(),r=function(){var i=n[s],o=new Date().getTime();i.data&&kn(i.data)&&mn(i.data,c=>{c.offset=Math.abs(c.timestamp-o),delete c.timestamp}),e.kr(i)};for(var s in n)r()}},this.$r))}Pr(){clearTimeout(this.Er),this.Er=void 0}Rr(){var e={};return mn(this.Sr,n=>{var r,s=n,i=(s?s.batchKey:null)||s.url;Me(e[i])&&(e[i]=Fe({},s,{data:[]})),(r=e[i].data)==null||r.push(s.data)}),this.Sr=[],e}}var Vxe=["retriesPerformedSoFar"];class Bxe{constructor(e){this.Tr=!1,this.Cr=3e3,this.Sr=[],this._instance=e,this.Sr=[],this.Mr=!0,!Me(ye)&&"onLine"in ye.navigator&&(this.Mr=ye.navigator.onLine,In(ye,"online",()=>{this.Mr=!0,this.ne()}),In(ye,"offline",()=>{this.Mr=!1}))}get length(){return this.Sr.length}retriableRequest(e){var{retriesPerformedSoFar:n}=e,r=cU(e,Vxe);Ir(n)&&n>0&&(r.url=Cv(r.url,{retry_count:n})),this._instance.Re(Fe({},r,{callback:s=>{s.statusCode!==200&&(s.statusCode<400||s.statusCode>=500)&&(n??0)<10?this.Fr(Fe({retriesPerformedSoFar:n},r)):r.callback==null||r.callback(s)}}))}Fr(e){var n=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=n+1;var r=function(o){var c=3e3*Math.pow(2,o),u=c/2,d=Math.min(18e5,c),p=(Math.random()-.5)*(d-u);return Math.ceil(d+p)}(n),s=Date.now()+r;this.Sr.push({retryAt:s,requestOptions:e});var i="Enqueued failed request for retry in "+r;navigator.onLine||(i+=" (Browser is offline)"),$e.warn(i),this.Tr||(this.Tr=!0,this.Or())}Or(){this.Ar&&clearTimeout(this.Ar),this.Ar=setTimeout(()=>{this.Mr&&this.Sr.length>0&&this.ne(),this.Or()},this.Cr)}ne(){var e=Date.now(),n=[],r=this.Sr.filter(i=>i.retryAt<e||(n.push(i),!1));if(this.Sr=n,r.length>0)for(var{requestOptions:s}of r)this.retriableRequest(s)}unload(){for(var{requestOptions:e}of(this.Ar&&(clearTimeout(this.Ar),this.Ar=void 0),this.Sr))try{this._instance.Re(Fe({},e,{transport:"sendBeacon"}))}catch(n){$e.error(n)}this.Sr=[]}}class qxe{constructor(e){this.Dr=()=>{var n,r,s,i;this.jr||(this.jr={});var o=this.scrollElement(),c=this.scrollY(),u=o?Math.max(0,o.scrollHeight-o.clientHeight):0,d=c+(o?.clientHeight||0),p=o?.scrollHeight||0;this.jr.lastScrollY=Math.ceil(c),this.jr.maxScrollY=Math.max(c,(n=this.jr.maxScrollY)!==null&&n!==void 0?n:0),this.jr.maxScrollHeight=Math.max(u,(r=this.jr.maxScrollHeight)!==null&&r!==void 0?r:0),this.jr.lastContentY=d,this.jr.maxContentY=Math.max(d,(s=this.jr.maxContentY)!==null&&s!==void 0?s:0),this.jr.maxContentHeight=Math.max(p,(i=this.jr.maxContentHeight)!==null&&i!==void 0?i:0)},this._instance=e}getContext(){return this.jr}resetContext(){var e=this.jr;return setTimeout(this.Dr,0),e}startMeasuringScrollPosition(){In(ye,"scroll",this.Dr,{capture:!0}),In(ye,"scrollend",this.Dr,{capture:!0}),In(ye,"resize",this.Dr)}scrollElement(){if(!this._instance.config.scroll_root_selector)return ye?.document.documentElement;var e=kn(this._instance.config.scroll_root_selector)?this._instance.config.scroll_root_selector:[this._instance.config.scroll_root_selector];for(var n of e){var r=ye?.document.querySelector(n);if(r)return r}}scrollY(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollTop||0}return ye&&(ye.scrollY||ye.pageYOffset||ye.document.documentElement.scrollTop)||0}scrollX(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollLeft||0}return ye&&(ye.scrollX||ye.pageXOffset||ye.document.documentElement.scrollLeft)||0}}var Hxe=t=>f6(t?.config.mask_personal_data_properties,t?.config.custom_personal_data_properties);class AD{constructor(e,n,r,s){this.Lr=i=>{var o=this.Nr();if(!o||o.sessionId!==i){var c={sessionId:i,props:this.zr(this._instance)};this.Ur.register({[m1]:c})}},this._instance=e,this.qr=n,this.Ur=r,this.zr=s||Hxe,this.qr.onSessionId(this.Lr)}Nr(){return this.Ur.props[m1]}getSetOnceProps(){var e,n=(e=this.Nr())==null?void 0:e.props;return n?"r"in n?h6(n):{$referring_domain:n.referringDomain,$pathname:n.initialPathName,utm_source:n.utm_source,utm_campaign:n.utm_campaign,utm_medium:n.utm_medium,utm_content:n.utm_content,utm_term:n.utm_term}:{}}getSessionProps(){var e={};return mn(hT(this.getSetOnceProps()),(n,r)=>{r==="$current_url"&&(r="url"),e["$session_entry_"+a1(r)]=n}),e}}var r_=br("[SessionId]");class ND{constructor(e,n,r){var s;if(this.Br=[],this.Hr=(p,m)=>Math.abs(p-m)>this.sessionTimeoutMs,!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(e.config.cookieless_mode==="always")throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this.O=e.config,this.Ur=e.persistence,this.pi=void 0,this.Ft=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this.Wr=n||Eo,this.Gr=r||Eo;var i=this.O.persistence_name||this.O.token,o=this.O.session_idle_timeout_seconds||1800;if(this._sessionTimeoutMs=1e3*js(o,60,36e3,r_.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.Jr(),this.Vr="ph_"+i+"_window_id",this.Kr="ph_"+i+"_primary_window_exists",this.Yr()){var c=Rr.V(this.Vr),u=Rr.V(this.Kr);c&&!u?this.pi=c:Rr.Y(this.Vr),Rr.K(this.Kr,!0)}if((s=this.O.bootstrap)!=null&&s.sessionID)try{var d=(p=>{var m=p.replace(/-/g,"");if(m.length!==32)throw new Error("Not a valid UUID");if(m[12]!=="7")throw new Error("Not a UUIDv7");return parseInt(m.substring(0,12),16)})(this.O.bootstrap.sessionID);this.Xr(this.O.bootstrap.sessionID,new Date().getTime(),d)}catch(p){r_.error("Invalid sessionID in bootstrap",p)}this.Qr()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return Me(this.Br)&&(this.Br=[]),this.Br.push(e),this.Ft&&e(this.Ft,this.pi),()=>{this.Br=this.Br.filter(n=>n!==e)}}Yr(){return this.O.persistence!=="memory"&&!this.Ur.De&&Rr.W()}Zr(e){e!==this.pi&&(this.pi=e,this.Yr()&&Rr.K(this.Vr,e))}ts(){return this.pi?this.pi:this.Yr()?Rr.V(this.Vr):null}Xr(e,n,r){e===this.Ft&&n===this._sessionActivityTimestamp&&r===this._sessionStartTimestamp||(this._sessionStartTimestamp=r,this._sessionActivityTimestamp=n,this.Ft=e,this.Ur.register({[gv]:[n,e,r]}))}es(){if(this.Ft&&this._sessionActivityTimestamp&&this._sessionStartTimestamp)return[this._sessionActivityTimestamp,this.Ft,this._sessionStartTimestamp];var e=this.Ur.props[gv];return kn(e)&&e.length===2&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this.Xr(null,null,null)}Qr(){In(ye,"beforeunload",()=>{this.Yr()&&Rr.Y(this.Kr)},{capture:!1})}checkAndGetSessionAndWindowId(e,n){if(e===void 0&&(e=!1),n===void 0&&(n=null),this.O.cookieless_mode==="always")throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var r=n||new Date().getTime(),[s,i,o]=this.es(),c=this.ts(),u=Ir(o)&&o>0&&Math.abs(r-o)>864e5,d=!1,p=!i,m=!e&&this.Hr(r,s);p||m||u?(i=this.Wr(),c=this.Gr(),r_.info("new session ID generated",{sessionId:i,windowId:c,changeReason:{noSessionId:p,activityTimeout:m,sessionPastMaximumLength:u}}),o=r,d=!0):c||(c=this.Gr(),d=!0);var v=s===0||!e||u?r:s,y=o===0?new Date().getTime():o;return this.Zr(c),this.Xr(i,v,y),e||this.Jr(),d&&this.Br.forEach(x=>x(i,c,d?{noSessionId:p,activityTimeout:m,sessionPastMaximumLength:u}:void 0)),{sessionId:i,windowId:c,sessionStartTimestamp:y,changeReason:d?{noSessionId:p,activityTimeout:m,sessionPastMaximumLength:u}:void 0,lastActivityTimestamp:s}}Jr(){clearTimeout(this.rs),this.rs=setTimeout(()=>{var[e]=this.es();this.Hr(new Date().getTime(),e)&&this.resetSessionId()},1.1*this.sessionTimeoutMs)}}var Gxe=["$set_once","$set"],fo=br("[SiteApps]");class Yxe{constructor(e){this._instance=e,this.ss=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}ns(e,n){if(n){var r=this.globalsForEvent(n);this.ss.push(r),this.ss.length>1e3&&(this.ss=this.ss.slice(10))}}get siteAppLoaders(){var e;return(e=bt._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.siteApps}init(){if(this.isEnabled){var e=this._instance.Ke(this.ns.bind(this));this.os=()=>{e(),this.ss=[],this.os=void 0}}}globalsForEvent(e){var n,r,s,i,o,c,u;if(!e)throw new Error("Event payload is required");var d={},p=this._instance.get_property("$groups")||[],m=this._instance.get_property("$stored_group_properties")||{};for(var[v,y]of Object.entries(m))d[v]={id:p[v],type:v,properties:y};var{$set_once:x,$set:w}=e;return{event:Fe({},cU(e,Gxe),{properties:Fe({},e.properties,w?{$set:Fe({},(n=(r=e.properties)==null?void 0:r.$set)!==null&&n!==void 0?n:{},w)}:{},x?{$set_once:Fe({},(s=(i=e.properties)==null?void 0:i.$set_once)!==null&&s!==void 0?s:{},x)}:{}),elements_chain:(o=(c=e.properties)==null?void 0:c.$elements_chain)!==null&&o!==void 0?o:"",distinct_id:(u=e.properties)==null?void 0:u.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:d}}setupSiteApp(e){var n=this.apps[e.id],r=()=>{var c;!n.errored&&this.ss.length&&(fo.info("Processing "+this.ss.length+" events for site app with id "+e.id),this.ss.forEach(u=>n.processEvent==null?void 0:n.processEvent(u)),n.processedBuffer=!0),Object.values(this.apps).every(u=>u.processedBuffer||u.errored)&&((c=this.os)==null||c.call(this))},s=!1,i=c=>{n.errored=!c,n.loaded=!0,fo.info("Site app with id "+e.id+" "+(c?"loaded":"errored")),s&&r()};try{var{processEvent:o}=e.init({posthog:this._instance,callback:c=>{i(c)}});o&&(n.processEvent=o),s=!0}catch(c){fo.error("Error while initializing PostHog app with config id "+e.id,c),i(!1)}if(s&&n.loaded)try{r()}catch(c){fo.error("Error while processing buffered events PostHog app with config id "+e.id,c),n.errored=!0}}ls(){var e=this.siteAppLoaders||[];for(var n of e)this.apps[n.id]={id:n.id,loaded:!1,errored:!1,processedBuffer:!1};for(var r of e)this.setupSiteApp(r)}us(e){if(Object.keys(this.apps).length!==0){var n=this.globalsForEvent(e);for(var r of Object.values(this.apps))try{r.processEvent==null||r.processEvent(n)}catch(s){fo.error("Error while processing event "+e.event+" for site app "+r.id,s)}}}onRemoteConfig(e){var n,r,s,i=this;if((n=this.siteAppLoaders)!=null&&n.length)return this.isEnabled?(this.ls(),void this._instance.on("eventCaptured",d=>this.us(d))):void fo.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if((r=this.os)==null||r.call(this),(s=e.siteApps)!=null&&s.length)if(this.isEnabled){var o=function(d){var p;bt["__$$ph_site_app_"+d]=i._instance,(p=bt.__PosthogExtensions__)==null||p.loadSiteApp==null||p.loadSiteApp(i._instance,u,m=>{if(m)return fo.error("Error while initializing PostHog app with config id "+d,m)})};for(var{id:c,url:u}of e.siteApps)o(c)}else fo.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}var Wxe=["amazonbot","amazonproductbot","app.hypefactors.com","applebot","archive.org_bot","awariobot","backlinksextendedbot","baiduspider","bingbot","bingpreview","chrome-lighthouse","dataforseobot","deepscan","duckduckbot","facebookexternal","facebookcatalog","http://yandex.com/bots","hubspot","ia_archiver","leikibot","linkedinbot","meta-externalagent","mj12bot","msnbot","nessus","petalbot","pinterest","prerender","rogerbot","screaming frog","sebot-wa","sitebulb","slackbot","slurp","trendictionbot","turnitin","twitterbot","vercel-screenshot","vercelbot","yahoo! slurp","yandexbot","zoombot","bot.htm","bot.php","(bot;","bot/","crawler","ahrefsbot","ahrefssiteaudit","semrushbot","siteauditbot","splitsignalbot","gptbot","oai-searchbot","chatgpt-user","perplexitybot","better uptime bot","sentryuptimebot","uptimerobot","headlesschrome","cypress","google-hoteladsverifier","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleother","google-cloudvertexbot","googleweblight","mediapartners-google","storebot-google","google-inspectiontool","bytespider"],jD=function(t,e){if(!t)return!1;var n=t.toLowerCase();return Wxe.concat(e||[]).some(r=>{var s=r.toLowerCase();return n.indexOf(s)!==-1})},g6=function(t,e){if(!t)return!1;var n=t.userAgent;if(n&&jD(n,e))return!0;try{var r=t?.userAgentData;if(r!=null&&r.brands&&r.brands.some(s=>jD(s?.brand,e)))return!0}catch{}return!!t.webdriver},Yf=function(t){return t.US="us",t.EU="eu",t.CUSTOM="custom",t}({}),OD="i.posthog.com";class Kxe{constructor(e){this.hs={},this.instance=e}get apiHost(){var e=this.instance.config.api_host.trim().replace(/\/$/,"");return e==="https://app.posthog.com"?"https://us.i.posthog.com":e}get uiHost(){var e,n=(e=this.instance.config.ui_host)==null?void 0:e.replace(/\/$/,"");return n||(n=this.apiHost.replace("."+OD,".posthog.com")),n==="https://app.posthog.com"?"https://us.posthog.com":n}get region(){return this.hs[this.apiHost]||(/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this.hs[this.apiHost]=Yf.US:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this.hs[this.apiHost]=Yf.EU:this.hs[this.apiHost]=Yf.CUSTOM),this.hs[this.apiHost]}endpointFor(e,n){if(n===void 0&&(n=""),n&&(n=n[0]==="/"?n:"/"+n),e==="ui")return this.uiHost+n;if(this.region===Yf.CUSTOM)return this.apiHost+n;var r=OD+n;switch(e){case"assets":return"https://"+this.region+"-assets."+r;case"api":return"https://"+this.region+"."+r}}}var Qxe={icontains:(t,e)=>!!ye&&e.href.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,e)=>!!ye&&e.href.toLowerCase().indexOf(t.toLowerCase())===-1,regex:(t,e)=>!!ye&&Wu(e.href,t),not_regex:(t,e)=>!!ye&&!Wu(e.href,t),exact:(t,e)=>e.href===t,is_not:(t,e)=>e.href!==t};class Dr{constructor(e){var n=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(r){r===void 0&&(r=!1),n.getWebExperiments(s=>{Dr.ds("retrieved web experiments from the server"),n.vs=new Map,s.forEach(i=>{if(i.feature_flag_key){var o;n.vs&&(Dr.ds("setting flag key ",i.feature_flag_key," to web experiment ",i),(o=n.vs)==null||o.set(i.feature_flag_key,i));var c=n._instance.getFeatureFlag(i.feature_flag_key);qn(c)&&i.variants[c]&&n.cs(i.name,c,i.variants[c].transforms)}else if(i.variants)for(var u in i.variants){var d=i.variants[u];Dr.fs(d)&&n.cs(i.name,u,d.transforms)}})},r)},this._instance=e,this._instance.onFeatureFlags(r=>{this.onFeatureFlags(r)})}onFeatureFlags(e){if(this._is_bot())Dr.ds("Refusing to render web experiment since the viewer is a likely bot");else if(!this._instance.config.disable_web_experiments){if(Zt(this.vs))return this.vs=new Map,this.loadIfEnabled(),void this.previewWebExperiment();Dr.ds("applying feature flags",e),e.forEach(n=>{var r;if(this.vs&&(r=this.vs)!=null&&r.has(n)){var s,i=this._instance.getFeatureFlag(n),o=(s=this.vs)==null?void 0:s.get(n);i&&o!=null&&o.variants[i]&&this.cs(o.name,i,o.variants[i].transforms)}})}}previewWebExperiment(){var e=Dr.getWindowLocation();if(e!=null&&e.search){var n=wv(e?.search,"__experiment_id"),r=wv(e?.search,"__experiment_variant");n&&r&&(Dr.ds("previewing web experiments "+n+" && "+r),this.getWebExperiments(s=>{this.ps(parseInt(n),r,s)},!1,!0))}}loadIfEnabled(){this._instance.config.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,n,r){if(this._instance.config.disable_web_experiments&&!r)return e([]);var s=this._instance.get_property("$web_experiments");if(s&&!n)return e(s);this._instance.Re({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this._instance.config.token),method:"GET",callback:i=>{if(i.statusCode!==200||!i.json)return e([]);var o=i.json.experiments||[];return e(o)}})}ps(e,n,r){var s=r.filter(i=>i.id===e);s&&s.length>0&&(Dr.ds("Previewing web experiment ["+s[0].name+"] with variant ["+n+"]"),this.cs(s[0].name,n,s[0].variants[n].transforms))}static fs(e){return!Zt(e.conditions)&&Dr.gs(e)&&Dr._s(e)}static gs(e){var n;if(Zt(e.conditions)||Zt((n=e.conditions)==null?void 0:n.url))return!0;var r,s,i,o=Dr.getWindowLocation();return!!o&&((r=e.conditions)==null||!r.url||Qxe[(s=(i=e.conditions)==null?void 0:i.urlMatchType)!==null&&s!==void 0?s:"icontains"](e.conditions.url,o))}static getWindowLocation(){return ye?.location}static _s(e){var n;if(Zt(e.conditions)||Zt((n=e.conditions)==null?void 0:n.utm))return!0;var r=l6();if(r.utm_source){var s,i,o,c,u,d,p,m,v=(s=e.conditions)==null||(s=s.utm)==null||!s.utm_campaign||((i=e.conditions)==null||(i=i.utm)==null?void 0:i.utm_campaign)==r.utm_campaign,y=(o=e.conditions)==null||(o=o.utm)==null||!o.utm_source||((c=e.conditions)==null||(c=c.utm)==null?void 0:c.utm_source)==r.utm_source,x=(u=e.conditions)==null||(u=u.utm)==null||!u.utm_medium||((d=e.conditions)==null||(d=d.utm)==null?void 0:d.utm_medium)==r.utm_medium,w=(p=e.conditions)==null||(p=p.utm)==null||!p.utm_term||((m=e.conditions)==null||(m=m.utm)==null?void 0:m.utm_term)==r.utm_term;return v&&x&&w&&y}return!1}static ds(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),s=1;s<n;s++)r[s-1]=arguments[s];$e.info("[WebExperiments] "+e,r)}cs(e,n,r){this._is_bot()?Dr.ds("Refusing to render web experiment since the viewer is a likely bot"):n!=="control"?r.forEach(s=>{if(s.selector){var i;Dr.ds("applying transform of variant "+n+" for experiment "+e+" ",s);var o=(i=document)==null?void 0:i.querySelectorAll(s.selector);o?.forEach(c=>{var u=c;s.html&&(u.innerHTML=s.html),s.css&&u.setAttribute("style",s.css)})}}):Dr.ds("Control variants leave the page unmodified.")}_is_bot(){return Ns&&this._instance?g6(Ns,this._instance.config.custom_blocked_useragents):void 0}}var Xxe=br("[PostHog ExternalIntegrations]"),Zxe={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};class Jxe{constructor(e){this._instance=e}st(e,n){var r;(r=bt.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,e,s=>{if(s)return Xxe.error("failed to load script",s);n()})}startIfEnabledOrStop(){var e=this,n=function(o){var c,u,d;!s||(c=bt.__PosthogExtensions__)!=null&&(c=c.integrations)!=null&&c[o]||e.st(Zxe[o],()=>{var p;(p=bt.__PosthogExtensions__)==null||(p=p.integrations)==null||(p=p[o])==null||p.start(e._instance)}),!s&&(u=bt.__PosthogExtensions__)!=null&&(u=u.integrations)!=null&&u[o]&&((d=bt.__PosthogExtensions__)==null||(d=d.integrations)==null||(d=d[o])==null||d.stop())};for(var[r,s]of Object.entries((i=this._instance.config.integrations)!==null&&i!==void 0?i:{})){var i;n(r)}}}var hh={},P1=()=>{},ru="posthog",v6=!pxe&&os?.indexOf("MSIE")===-1&&os?.indexOf("Mozilla")===-1,PD=t=>{var e;return{api_host:"https://us.i.posthog.com",ui_host:null,token:"",autocapture:!0,rageclick:!0,cross_subdomain_cookie:Gve(Ue?.location),persistence:"localStorage+cookie",persistence_name:"",loaded:P1,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageview:t!=="2025-05-24"||"history_change",capture_pageleave:"if_capture_pageview",defaults:t??"unset",debug:ls&&qn(ls?.search)&&ls.search.indexOf("__posthog_debug=true")!==-1||!1,cookie_expiration:365,upgrade:!1,disable_session_recording:!1,disable_persistence:!1,disable_web_experiments:!0,disable_surveys:!1,disable_surveys_automatic_display:!1,disable_external_dependency_loading:!1,enable_recording_console_log:void 0,secure_cookie:(ye==null||(e=ye.location)==null?void 0:e.protocol)==="https:",ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,session_recording:{},mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_flags:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_only_evaluate_survey_feature_flags:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,surveys_request_timeout_ms:1e4,on_request_error:n=>{var r="Bad HTTP status: "+n.statusCode+" "+n.text;$e.error(r)},get_device_id:n=>n,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:"identified_only",before_send:void 0,request_queue_config:{flush_interval_ms:O1},error_tracking:{},_onCapture:P1}},MD=t=>{var e={};Me(t.process_person)||(e.person_profiles=t.process_person),Me(t.xhr_headers)||(e.request_headers=t.xhr_headers),Me(t.cookie_name)||(e.persistence_name=t.cookie_name),Me(t.disable_cookie)||(e.disable_persistence=t.disable_cookie),Me(t.store_google)||(e.save_campaign_params=t.store_google),Me(t.verbose)||(e.debug=t.verbose);var n=Xn({},e,t);return kn(t.property_blacklist)&&(Me(t.property_denylist)?n.property_denylist=t.property_blacklist:kn(t.property_denylist)?n.property_denylist=[...t.property_blacklist,...t.property_denylist]:$e.error("Invalid value for property_denylist config: "+t.property_denylist)),n};class ebe{constructor(){this.__forceAllowLocalhost=!1}get bs(){return this.__forceAllowLocalhost}set bs(e){$e.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}}class jy{get decideEndpointWasHit(){var e,n;return(e=(n=this.featureFlags)==null?void 0:n.hasLoadedFlags)!==null&&e!==void 0&&e}get flagsEndpointWasHit(){var e,n;return(e=(n=this.featureFlags)==null?void 0:n.hasLoadedFlags)!==null&&e!==void 0&&e}constructor(){this.webPerformance=new ebe,this.ys=!1,this.version=Ea.LIB_VERSION,this.ws=new m6,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=PD(),this.SentryIntegration=sxe,this.sentryIntegration=e=>function(n,r){var s=HU(n,r);return{name:qU,processEvent:i=>s(i)}}(this,e),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.Ss=!1,this.$s=null,this.xs=null,this.ks=null,this.featureFlags=new Pxe(this),this.toolbar=new axe(this),this.scrollManager=new qxe(this),this.pageViewManager=new fxe(this),this.surveys=new zxe(this),this.experiments=new Dr(this),this.exceptions=new gxe(this),this.rateLimiter=new $xe(this),this.requestRouter=new Kxe(this),this.consent=new mye(this),this.externalIntegrations=new Jxe(this),this.people={set:(e,n,r)=>{var s=qn(e)?{[e]:n}:e;this.setPersonProperties(s),r?.({})},set_once:(e,n,r)=>{var s=qn(e)?{[e]:n}:e;this.setPersonProperties(void 0,s),r?.({})}},this.on("eventCaptured",e=>$e.info('send "'+e?.event+'"',e))}init(e,n,r){if(r&&r!==ru){var s,i=(s=hh[r])!==null&&s!==void 0?s:new jy;return i._init(e,n,r),hh[r]=i,hh[ru][r]=i,i}return this._init(e,n,r)}_init(e,n,r){var s,i;if(n===void 0&&(n={}),Me(e)||o1(e))return $e.critical("PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()"),this;if(this.__loaded)return $e.warn("You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config={},this.Es=n,this.Is=[],n.person_profiles&&(this.xs=n.person_profiles),this.set_config(Xn({},PD(n.defaults),MD(n),{name:r,token:e})),this.config.on_xhr_error&&$e.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=n.disable_compression?void 0:Ta.GZipJS;var o=this.Ps();this.persistence=new e_(this.config,o),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new e_(Fe({},this.config,{persistence:"sessionStorage"}),o);var c=Fe({},this.persistence.props),u=Fe({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.Rs=new Uxe(C=>this.Ts(C),this.config.request_queue_config),this.Cs=new Bxe(this),this.__request_queue=[];var d=this.config.cookieless_mode==="always"||this.config.cookieless_mode==="on_reject"&&this.consent.isExplicitlyOptedOut();if(d||(this.sessionManager=new ND(this),this.sessionPropsManager=new AD(this,this.sessionManager,this.persistence)),new lxe(this).startIfEnabledOrStop(),this.siteApps=new Yxe(this),(s=this.siteApps)==null||s.init(),d||(this.sessionRecording=new dD(this),this.sessionRecording.startIfEnabledOrStop()),this.config.disable_scroll_properties||this.scrollManager.startMeasuringScrollPosition(),this.autocapture=new oye(this),this.autocapture.startIfEnabled(),this.surveys.loadIfEnabled(),this.heatmaps=new dxe(this),this.heatmaps.startIfEnabled(),this.webVitalsAutocapture=new cxe(this),this.exceptionObserver=new yye(this),this.exceptionObserver.startIfEnabled(),this.deadClicksAutocapture=new NU(this,vye),this.deadClicksAutocapture.startIfEnabled(),this.historyAutocapture=new Oye(this),this.historyAutocapture.startIfEnabled(),Ea.DEBUG=Ea.DEBUG||this.config.debug,Ea.DEBUG&&$e.info("Starting in debug mode",{this:this,config:n,thisC:Fe({},this.config),p:c,s:u}),((i=n.bootstrap)==null?void 0:i.distinctID)!==void 0){var p,m,v=this.config.get_device_id(Eo()),y=(p=n.bootstrap)!=null&&p.isIdentifiedID?v:n.bootstrap.distinctID;this.persistence.set_property(wa,(m=n.bootstrap)!=null&&m.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:n.bootstrap.distinctID,$device_id:y})}if(this.Ms()){var x,w,k=Object.keys(((x=n.bootstrap)==null?void 0:x.featureFlags)||{}).filter(C=>{var A;return!((A=n.bootstrap)==null||(A=A.featureFlags)==null||!A[C])}).reduce((C,A)=>{var D;return C[A]=((D=n.bootstrap)==null||(D=D.featureFlags)==null?void 0:D[A])||!1,C},{}),S=Object.keys(((w=n.bootstrap)==null?void 0:w.featureFlagPayloads)||{}).filter(C=>k[C]).reduce((C,A)=>{var D,T;return(D=n.bootstrap)!=null&&(D=D.featureFlagPayloads)!=null&&D[A]&&(C[A]=(T=n.bootstrap)==null||(T=T.featureFlagPayloads)==null?void 0:T[A]),C},{});this.featureFlags.receivedFeatureFlags({featureFlags:k,featureFlagPayloads:S})}if(d)this.register_once({distinct_id:bf,$device_id:null},"");else if(!this.get_distinct_id()){var R=this.config.get_device_id(Eo());this.register_once({distinct_id:R,$device_id:R},""),this.persistence.set_property(wa,"anonymous")}return In(ye,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),this.toolbar.maybeLoadToolbar(),n.segment?rxe(this,()=>this.Fs()):this.Fs(),Zs(this.config._onCapture)&&this.config._onCapture!==P1&&($e.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",C=>this.config._onCapture(C.event,C))),this.config.ip&&$e.warn('The `ip` config option has NO EFFECT AT ALL and has been deprecated. Use a custom transformation or "Discard IP data" project setting instead. See https://posthog.com/tutorials/web-redact-properties#hiding-customer-ip-address for more information.'),this}Te(e){var n,r,s,i,o,c,u,d;if(!Ue||!Ue.body)return $e.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout(()=>{this.Te(e)},500);this.compression=void 0,e.supportedCompression&&!this.config.disable_compression&&(this.compression=It(e.supportedCompression,Ta.GZipJS)?Ta.GZipJS:It(e.supportedCompression,Ta.Base64)?Ta.Base64:void 0),(n=e.analytics)!=null&&n.endpoint&&(this.analyticsDefaultEndpoint=e.analytics.endpoint),this.set_config({person_profiles:this.xs?this.xs:"identified_only"}),(r=this.siteApps)==null||r.onRemoteConfig(e),(s=this.sessionRecording)==null||s.onRemoteConfig(e),(i=this.autocapture)==null||i.onRemoteConfig(e),(o=this.heatmaps)==null||o.onRemoteConfig(e),this.surveys.onRemoteConfig(e),(c=this.webVitalsAutocapture)==null||c.onRemoteConfig(e),(u=this.exceptionObserver)==null||u.onRemoteConfig(e),this.exceptions.onRemoteConfig(e),(d=this.deadClicksAutocapture)==null||d.onRemoteConfig(e)}Fs(){try{this.config.loaded(this)}catch(e){$e.critical("`loaded` function failed",e)}this.Os(),this.config.capture_pageview&&setTimeout(()=>{this.consent.isOptedIn()&&this.As()},1),new Fxe(this).load(),this.featureFlags.flags()}Os(){var e;this.is_capturing()&&this.config.request_batching&&((e=this.Rs)==null||e.enable())}_dom_loaded(){this.is_capturing()&&Ao(this.__request_queue,e=>this.Ts(e)),this.__request_queue=[],this.Os()}_handle_unload(){var e,n;this.config.request_batching?(this.Ds()&&this.capture("$pageleave"),(e=this.Rs)==null||e.unload(),(n=this.Cs)==null||n.unload()):this.Ds()&&this.capture("$pageleave",null,{transport:"sendBeacon"})}Re(e){this.__loaded&&(v6?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=Cv(e.url,{ip:this.config.ip?1:0}),e.headers=Fe({},this.config.request_headers),e.compression=e.compression==="best-available"?this.compression:e.compression,e.fetchOptions=e.fetchOptions||this.config.fetch_options,(n=>{var r,s,i,o=Fe({},n);o.timeout=o.timeout||6e4,o.url=Cv(o.url,{_:new Date().getTime().toString(),ver:Ea.LIB_VERSION,compression:o.compression});var c=(r=o.transport)!==null&&r!==void 0?r:"fetch",u=(s=(i=pU(fh,d=>d.transport===c))==null?void 0:i.method)!==null&&s!==void 0?s:fh[0].method;if(!u)throw new Error("No available transport method");u(o)})(Fe({},e,{callback:n=>{var r,s;this.rateLimiter.checkForLimiting(n),n.statusCode>=400&&((r=(s=this.config).on_request_error)==null||r.call(s,n)),e.callback==null||e.callback(n)}}))))}Ts(e){this.Cs?this.Cs.retriableRequest(e):this.Re(e)}_execute_array(e){var n,r=[],s=[],i=[];Ao(e,c=>{c&&(n=c[0],kn(n)?i.push(c):Zs(c)?c.call(this):kn(c)&&n==="alias"?r.push(c):kn(c)&&n.indexOf("capture")!==-1&&Zs(this[n])?i.push(c):s.push(c))});var o=function(c,u){Ao(c,function(d){if(kn(d[0])){var p=u;mn(d,function(m){p=p[m[0]].apply(p,m.slice(1))})}else this[d[0]].apply(this,d.slice(1))},u)};o(r,this),o(s,this),o(i,this)}Ms(){var e,n;return((e=this.config.bootstrap)==null?void 0:e.featureFlags)&&Object.keys((n=this.config.bootstrap)==null?void 0:n.featureFlags).length>0||!1}push(e){this._execute_array([e])}capture(e,n,r){var s;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.Rs){if(this.is_capturing())if(!Me(e)&&qn(e)){if(this.config.opt_out_useragent_filter||!this._is_bot()){var i=r!=null&&r.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(i==null||!i.isRateLimited){n!=null&&n.$current_url&&!qn(n?.$current_url)&&($e.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),n==null||delete n.$current_url),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&this.sessionPersistence.update_campaign_params(),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();var o=new Date,c=r?.timestamp||o,u=Eo(),d={uuid:u,event:e,properties:this.calculateEventProperties(e,n||{},c,u)};i&&(d.properties.$lib_rate_limit_remaining_tokens=i.remainingTokens),r?.$set&&(d.$set=r?.$set);var p,m=this.js(r?.$set_once);if(m&&(d.$set_once=m),(d=qve(d,r!=null&&r._noTruncate?null:this.config.properties_string_max_length)).timestamp=c,Me(r?.timestamp)||(d.properties.$event_time_override_provided=!0,d.properties.$event_time_override_system_time=o),e===n_.DISMISSED||e===n_.SENT){var v=n?.[TD.SURVEY_ID],y=n?.[TD.SURVEY_ITERATION];p={id:v,current_iteration:y},localStorage.getItem(CD(p))||localStorage.setItem(CD(p),"true"),d.$set=Fe({},d.$set,{[Dxe({id:v,current_iteration:y},e===n_.SENT?"responded":"dismissed")]:!0})}var x=Fe({},d.properties.$set,d.$set);if(hu(x)||this.setPersonPropertiesForFlags(x),!Zt(this.config.before_send)){var w=this.Ls(d);if(!w)return;d=w}this.ws.emit("eventCaptured",d);var k={method:"POST",url:(s=r?._url)!==null&&s!==void 0?s:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:d,compression:"best-available",batchKey:r?._batchKey};return!this.config.request_batching||r&&(r==null||!r._batchKey)||r!=null&&r.send_instantly?this.Ts(k):this.Rs.enqueue(k),d}$e.critical("This capture call is ignored due to client rate limiting.")}}else $e.error("No event name provided to posthog.capture")}else $e.uninitializedWarning("posthog.capture")}Ke(e){return this.on("eventCaptured",n=>e(n.event,n))}calculateEventProperties(e,n,r,s,i){if(r=r||new Date,!this.persistence||!this.sessionPersistence)return n;var o=i?void 0:this.persistence.remove_event_timer(e),c=Fe({},n);if(c.token=this.config.token,c.$config_defaults=this.config.defaults,(this.config.cookieless_mode=="always"||this.config.cookieless_mode=="on_reject"&&this.consent.isExplicitlyOptedOut())&&(c.$cookieless_mode=!0),e==="$snapshot"){var u=Fe({},this.persistence.properties(),this.sessionPersistence.properties());return c.distinct_id=u.distinct_id,(!qn(c.distinct_id)&&!Ir(c.distinct_id)||o1(c.distinct_id))&&$e.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),c}var d,p=Nxe(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties);if(this.sessionManager){var{sessionId:m,windowId:v}=this.sessionManager.checkAndGetSessionAndWindowId(i,r.getTime());c.$session_id=m,c.$window_id=v}this.sessionPropsManager&&Xn(c,this.sessionPropsManager.getSessionProps());try{var y;this.sessionRecording&&Xn(c,this.sessionRecording.sdkDebugProperties),c.$sdk_debug_retry_queue_size=(y=this.Cs)==null?void 0:y.length}catch(S){c.$sdk_debug_error_capturing_properties=String(S)}if(this.requestRouter.region===Yf.CUSTOM&&(c.$lib_custom_api_host=this.config.api_host),d=e!=="$pageview"||i?e!=="$pageleave"||i?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(r):this.pageViewManager.doPageView(r,s),c=Xn(c,d),e==="$pageview"&&Ue&&(c.title=Ue.title),!Me(o)){var x=r.getTime()-o;c.$duration=parseFloat((x/1e3).toFixed(3))}os&&this.config.opt_out_useragent_filter&&(c.$browser_type=this._is_bot()?"bot":"browser"),(c=Xn({},p,this.persistence.properties(),this.sessionPersistence.properties(),c)).$is_identified=this._isIdentified(),kn(this.config.property_denylist)?mn(this.config.property_denylist,function(S){delete c[S]}):$e.error("Invalid value for property_denylist config: "+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var w=this.config.sanitize_properties;w&&($e.error("sanitize_properties is deprecated. Use before_send instead"),c=w(c,e));var k=this.Ns();return c.$process_person_profile=k,k&&!i&&this.zs("_calculate_event_properties"),c}js(e){var n;if(!this.persistence||!this.Ns()||this.ys)return e;var r=this.persistence.get_initial_props(),s=(n=this.sessionPropsManager)==null?void 0:n.getSetOnceProps(),i=Xn({},r,s||{},e||{}),o=this.config.sanitize_properties;return o&&($e.error("sanitize_properties is deprecated. Use before_send instead"),i=o(i,"$set_once")),this.ys=!0,hu(i)?void 0:i}register(e,n){var r;(r=this.persistence)==null||r.register(e,n)}register_once(e,n,r){var s;(s=this.persistence)==null||s.register_once(e,n,r)}register_for_session(e){var n;(n=this.sessionPersistence)==null||n.register(e)}unregister(e){var n;(n=this.persistence)==null||n.unregister(e)}unregister_for_session(e){var n;(n=this.sessionPersistence)==null||n.unregister(e)}Us(e,n){this.register({[e]:n})}getFeatureFlag(e,n){return this.featureFlags.getFeatureFlag(e,n)}getFeatureFlagPayload(e){var n=this.featureFlags.getFeatureFlagPayload(e);try{return JSON.parse(n)}catch{return n}}isFeatureEnabled(e,n){return this.featureFlags.isFeatureEnabled(e,n)}reloadFeatureFlags(){this.featureFlags.reloadFeatureFlags()}updateEarlyAccessFeatureEnrollment(e,n,r){this.featureFlags.updateEarlyAccessFeatureEnrollment(e,n,r)}getEarlyAccessFeatures(e,n,r){return n===void 0&&(n=!1),this.featureFlags.getEarlyAccessFeatures(e,n,r)}on(e,n){return this.ws.on(e,n)}onFeatureFlags(e){return this.featureFlags.onFeatureFlags(e)}onSurveysLoaded(e){return this.surveys.onSurveysLoaded(e)}onSessionId(e){var n,r;return(n=(r=this.sessionManager)==null?void 0:r.onSessionId(e))!==null&&n!==void 0?n:()=>{}}getSurveys(e,n){n===void 0&&(n=!1),this.surveys.getSurveys(e,n)}getActiveMatchingSurveys(e,n){n===void 0&&(n=!1),this.surveys.getActiveMatchingSurveys(e,n)}renderSurvey(e,n){this.surveys.renderSurvey(e,n)}canRenderSurvey(e){return this.surveys.canRenderSurvey(e)}canRenderSurveyAsync(e,n){return n===void 0&&(n=!1),this.surveys.canRenderSurveyAsync(e,n)}identify(e,n,r){if(!this.__loaded||!this.persistence)return $e.uninitializedWarning("posthog.identify");if(Ir(e)&&(e=e.toString(),$e.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),e)if(["distinct_id","distinctid"].includes(e.toLowerCase()))$e.critical('The string "'+e+'" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.');else if(e!==bf){if(this.zs("posthog.identify")){var s=this.get_distinct_id();if(this.register({$user_id:e}),!this.get_property("$device_id")){var i=s;this.register_once({$had_persisted_distinct_id:!0,$device_id:i},"")}e!==s&&e!==this.get_property($f)&&(this.unregister($f),this.register({distinct_id:e}));var o=(this.persistence.get_property(wa)||"anonymous")==="anonymous";e!==s&&o?(this.persistence.set_property(wa,"identified"),this.setPersonPropertiesForFlags(Fe({},r||{},n||{}),!1),this.capture("$identify",{distinct_id:e,$anon_distinct_id:s},{$set:n||{},$set_once:r||{}}),this.ks=vD(e,n,r),this.featureFlags.setAnonymousDistinctId(s)):(n||r)&&this.setPersonProperties(n,r),e!==s&&(this.reloadFeatureFlags(),this.unregister(vv))}}else $e.critical('The string "'+bf+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.');else $e.error("Unique user id has not been set in posthog.identify")}setPersonProperties(e,n){if((e||n)&&this.zs("posthog.setPersonProperties")){var r=vD(this.get_distinct_id(),e,n);this.ks!==r?(this.setPersonPropertiesForFlags(Fe({},n||{},e||{})),this.capture("$set",{$set:e||{},$set_once:n||{}}),this.ks=r):$e.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}group(e,n,r){if(e&&n){if(this.zs("posthog.group")){var s=this.getGroups();s[e]!==n&&this.resetGroupPropertiesForFlags(e),this.register({$groups:Fe({},s,{[e]:n})}),r&&(this.capture("$groupidentify",{$group_type:e,$group_key:n,$group_set:r}),this.setGroupPropertiesForFlags({[e]:r})),s[e]===n||r||this.reloadFeatureFlags()}}else $e.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,n){n===void 0&&(n=!0),this.featureFlags.setPersonPropertiesForFlags(e,n)}resetPersonPropertiesForFlags(){this.featureFlags.resetPersonPropertiesForFlags()}setGroupPropertiesForFlags(e,n){n===void 0&&(n=!0),this.zs("posthog.setGroupPropertiesForFlags")&&this.featureFlags.setGroupPropertiesForFlags(e,n)}resetGroupPropertiesForFlags(e){this.featureFlags.resetGroupPropertiesForFlags(e)}reset(e){var n,r,s,i;if($e.info("reset"),!this.__loaded)return $e.uninitializedWarning("posthog.reset");var o=this.get_property("$device_id");if(this.consent.reset(),(n=this.persistence)==null||n.clear(),(r=this.sessionPersistence)==null||r.clear(),this.surveys.reset(),this.featureFlags.reset(),(s=this.persistence)==null||s.set_property(wa,"anonymous"),(i=this.sessionManager)==null||i.resetSessionId(),this.ks=null,this.config.cookieless_mode==="always")this.register_once({distinct_id:bf,$device_id:null},"");else{var c=this.config.get_device_id(Eo());this.register_once({distinct_id:c,$device_id:e?c:o},"")}this.register({$last_posthog_reset:new Date().toISOString()},1)}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var e,n;return(e=(n=this.sessionManager)==null?void 0:n.checkAndGetSessionAndWindowId(!0).sessionId)!==null&&e!==void 0?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";var{sessionId:n,sessionStartTimestamp:r}=this.sessionManager.checkAndGetSessionAndWindowId(!0),s=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+n);if(e!=null&&e.withTimestamp&&r){var i,o=(i=e.timestampLookBack)!==null&&i!==void 0?i:10;if(!r)return s;s+="?t="+Math.max(Math.floor((new Date().getTime()-r)/1e3)-o,0)}return s}alias(e,n){return e===this.get_property(mU)?($e.critical("Attempting to create alias for existing People user - aborting."),-2):this.zs("posthog.alias")?(Me(n)&&(n=this.get_distinct_id()),e!==n?(this.Us($f,e),this.capture("$create_alias",{alias:e,distinct_id:n})):($e.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var n=Fe({},this.config);if(Bn(e)){var r,s,i,o,c;Xn(this.config,MD(e));var u=this.Ps();(r=this.persistence)==null||r.update_config(this.config,n,u),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new e_(Fe({},this.config,{persistence:"sessionStorage"}),u),dr.W()&&dr.J("ph_debug")==="true"&&(this.config.debug=!0),this.config.debug&&(Ea.DEBUG=!0,$e.info("set_config",{config:e,oldConfig:n,newConfig:Fe({},this.config)})),(s=this.sessionRecording)==null||s.startIfEnabledOrStop(),(i=this.autocapture)==null||i.startIfEnabled(),(o=this.heatmaps)==null||o.startIfEnabled(),this.surveys.loadIfEnabled(),this.qs(),(c=this.externalIntegrations)==null||c.startIfEnabledOrStop()}}startSessionRecording(e){var n=e===!0,r={sampling:n||!(e==null||!e.sampling),linked_flag:n||!(e==null||!e.linked_flag),url_trigger:n||!(e==null||!e.url_trigger),event_trigger:n||!(e==null||!e.event_trigger)};if(Object.values(r).some(Boolean)){var s,i,o,c,u;(s=this.sessionManager)==null||s.checkAndGetSessionAndWindowId(),r.sampling&&((i=this.sessionRecording)==null||i.overrideSampling()),r.linked_flag&&((o=this.sessionRecording)==null||o.overrideLinkedFlag()),r.url_trigger&&((c=this.sessionRecording)==null||c.overrideTrigger("url")),r.event_trigger&&((u=this.sessionRecording)==null||u.overrideTrigger("event"))}this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var e;return!((e=this.sessionRecording)==null||!e.started)}captureException(e,n){var r=new Error("PostHog syntheticException");return this.exceptions.sendExceptionEvent(Fe({},jye((s=>s instanceof Error)(e)?{error:e,event:e.message}:{event:e},{syntheticException:r}),n))}loadToolbar(e){return this.toolbar.loadToolbar(e)}get_property(e){var n;return(n=this.persistence)==null?void 0:n.props[e]}getSessionProperty(e){var n;return(n=this.sessionPersistence)==null?void 0:n.props[e]}toString(){var e,n=(e=this.config.name)!==null&&e!==void 0?e:ru;return n!==ru&&(n=ru+"."+n),n}_isIdentified(){var e,n;return((e=this.persistence)==null?void 0:e.get_property(wa))==="identified"||((n=this.sessionPersistence)==null?void 0:n.get_property(wa))==="identified"}Ns(){var e,n;return!(this.config.person_profiles==="never"||this.config.person_profiles==="identified_only"&&!this._isIdentified()&&hu(this.getGroups())&&((e=this.persistence)==null||(e=e.props)==null||!e[$f])&&((n=this.persistence)==null||(n=n.props)==null||!n[xv]))}Ds(){return this.config.capture_pageleave===!0||this.config.capture_pageleave==="if_capture_pageview"&&(this.config.capture_pageview===!0||this.config.capture_pageview==="history_change")}createPersonProfile(){this.Ns()||this.zs("posthog.createPersonProfile")&&this.setPersonProperties({},{})}zs(e){return this.config.person_profiles==="never"?($e.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.Us(xv,!0),!0)}Ps(){if(this.config.cookieless_mode==="always")return!0;var e=this.consent.isOptedOut(),n=this.config.opt_out_persistence_by_default||this.config.cookieless_mode==="on_reject";return this.config.disable_persistence||e&&!!n}qs(){var e,n,r,s,i=this.Ps();return((e=this.persistence)==null?void 0:e.De)!==i&&((r=this.persistence)==null||r.set_disabled(i)),((n=this.sessionPersistence)==null?void 0:n.De)!==i&&((s=this.sessionPersistence)==null||s.set_disabled(i)),i}opt_in_capturing(e){if(this.config.cookieless_mode!=="always"){var n;this.config.cookieless_mode==="on_reject"&&this.consent.isExplicitlyOptedOut()&&(this.reset(!0),this.sessionManager=new ND(this),this.persistence&&(this.sessionPropsManager=new AD(this,this.sessionManager,this.persistence)),this.sessionRecording=new dD(this),this.sessionRecording.startIfEnabledOrStop()),this.consent.optInOut(!0),this.qs(),(Me(e?.captureEventName)||e!=null&&e.captureEventName)&&this.capture((n=e?.captureEventName)!==null&&n!==void 0?n:"$opt_in",e?.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.As()}else $e.warn('Consent opt in/out is not valid with cookieless_mode="always" and will be ignored')}opt_out_capturing(){var e;this.config.cookieless_mode!=="always"?(this.config.cookieless_mode==="on_reject"&&this.consent.isOptedIn()&&this.reset(!0),this.consent.optInOut(!1),this.qs(),this.config.cookieless_mode==="on_reject"&&(this.register({distinct_id:bf,$device_id:null}),this.sessionManager=void 0,this.sessionPropsManager=void 0,(e=this.sessionRecording)==null||e.stopRecording(),this.sessionRecording=void 0,this.As())):$e.warn('Consent opt in/out is not valid with cookieless_mode="always" and will be ignored')}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}is_capturing(){return this.config.cookieless_mode==="always"||(this.config.cookieless_mode==="on_reject"?this.consent.isExplicitlyOptedOut()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this.qs()}_is_bot(){return Ns?g6(Ns,this.config.custom_blocked_useragents):void 0}As(){Ue&&(Ue.visibilityState==="visible"?this.Ss||(this.Ss=!0,this.capture("$pageview",{title:Ue.title},{send_instantly:!0}),this.$s&&(Ue.removeEventListener("visibilitychange",this.$s),this.$s=null)):this.$s||(this.$s=this.As.bind(this),In(Ue,"visibilitychange",this.$s)))}debug(e){e===!1?(ye?.console.log("You've disabled debug mode."),localStorage&&localStorage.removeItem("ph_debug"),this.set_config({debug:!1})):(ye?.console.log("You're now in debug mode. All calls to PostHog will be logged in your console.\nYou can disable this with `posthog.debug(false)`."),localStorage&&localStorage.setItem("ph_debug","true"),this.set_config({debug:!0}))}j(){var e,n,r,s,i,o,c,u=this.Es||{};return"advanced_disable_flags"in u?!!u.advanced_disable_flags:this.config.advanced_disable_flags!==!1?!!this.config.advanced_disable_flags:this.config.advanced_disable_decide===!0?($e.warn("Config field 'advanced_disable_decide' is deprecated. Please use 'advanced_disable_flags' instead. The old field will be removed in a future major version."),!0):(r="advanced_disable_decide",s=!1,i=$e,o=(n="advanced_disable_flags")in(e=u)&&!Me(e[n]),c=r in e&&!Me(e[r]),o?e[n]:c?(i&&i.warn("Config field '"+r+"' is deprecated. Please use '"+n+"' instead. The old field will be removed in a future major version."),e[r]):s)}Ls(e){if(Zt(this.config.before_send))return e;var n=kn(this.config.before_send)?this.config.before_send:[this.config.before_send],r=e;for(var s of n){if(r=s(r),Zt(r)){var i="Event '"+e.event+"' was rejected in beforeSend function";return Uve(e.event)?$e.warn(i+". This can cause unexpected behavior."):$e.info(i),null}r.properties&&!hu(r.properties)||$e.warn("Event '"+e.event+"' has no properties after beforeSend function, this is likely an error.")}return r}getPageViewId(){var e;return(e=this.pageViewManager.fe)==null?void 0:e.pageViewId}captureTraceFeedback(e,n){this.capture("$ai_feedback",{$ai_trace_id:String(e),$ai_feedback_text:n})}captureTraceMetric(e,n,r){this.capture("$ai_metric",{$ai_trace_id:String(e),$ai_metric_name:n,$ai_metric_value:String(r)})}}(function(t,e){for(var n=0;n<e.length;n++)t.prototype[e[n]]=Bve(t.prototype[e[n]])})(jy,["identify"]);var DD,su=(DD=hh[ru]=new jy,function(){function t(){t.done||(t.done=!0,v6=!1,mn(hh,function(e){e._dom_loaded()}))}Ue!=null&&Ue.addEventListener?Ue.readyState==="complete"?t():In(Ue,"DOMContentLoaded",t,{capture:!1}):ye&&$e.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}(),DD),y6=_.createContext({client:su});function x6(t,e,n){if(n===void 0&&(n=new WeakMap),t===e)return!0;if(typeof t!="object"||t===null||typeof e!="object"||e===null)return!1;if(n.has(t)&&n.get(t)===e)return!0;n.set(t,e);var r=Object.keys(t),s=Object.keys(e);if(r.length!==s.length)return!1;for(var i=0,o=r;i<o.length;i++){var c=o[i];if(!s.includes(c)||!x6(t[c],e[c],n))return!1}return!0}function tbe(t){var e=t.children,n=t.client,r=t.apiKey,s=t.options,i=_.useRef(null),o=_.useMemo(function(){return n?(r&&console.warn("[PostHog.js] You have provided both `client` and `apiKey` to `PostHogProvider`. `apiKey` will be ignored in favour of `client`."),s&&console.warn("[PostHog.js] You have provided both `client` and `options` to `PostHogProvider`. `options` will be ignored in favour of `client`."),n):(r||console.warn("[PostHog.js] No `apiKey` or `client` were provided to `PostHogProvider`. Using default global `window.posthog` instance. You must initialize it manually. This is not recommended behavior."),su)},[n,r,JSON.stringify(s)]);return _.useEffect(function(){if(!n){var c=i.current;c?(r!==c.apiKey&&console.warn("[PostHog.js] You have provided a different `apiKey` to `PostHogProvider` than the one that was already initialized. This is not supported by our provider and we'll keep using the previous key. If you need to toggle between API Keys you need to control the `client` yourself and pass it in as a prop rather than an `apiKey` prop."),s&&!x6(s,c.options)&&su.set_config(s),i.current={apiKey:r,options:s??{}}):(su.__loaded&&console.warn("[PostHog.js] `posthog` was already loaded elsewhere. This may cause issues."),su.init(r,s),i.current={apiKey:r,options:s??{}})}},[n,r,JSON.stringify(s)]),ke.createElement(y6.Provider,{value:{client:o}},e)}var M1=function(t,e){return M1=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(n[s]=r[s])},M1(t,e)};function nbe(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");M1(t,e);function n(){this.constructor=t}t.prototype=e===null?Object.create(e):(n.prototype=e.prototype,new n)}var s_=function(t){return typeof t=="function"},rbe={componentStack:null,exceptionEvent:null,error:null},sbe={INVALID_FALLBACK:"[PostHog.js][PostHogErrorBoundary] Invalid fallback prop, provide a valid React element or a function that returns a valid React element."};(function(t){nbe(e,t);function e(n){var r=t.call(this,n)||this;return r.state=rbe,r}return e.prototype.componentDidCatch=function(n,r){var s=this.props.additionalProperties,i;s_(s)?i=s(n):typeof s=="object"&&(i=s);var o=this.context.client,c=o.captureException(n,i),u=r.componentStack;this.setState({error:n,componentStack:u,exceptionEvent:c})},e.prototype.render=function(){var n=this.props,r=n.children,s=n.fallback,i=this.state;if(i.componentStack==null)return s_(r)?r():r;var o=s_(s)?ke.createElement(s,{error:i.error,componentStack:i.componentStack,exceptionEvent:i.exceptionEvent}):s;return ke.isValidElement(o)?o:(console.warn(sbe.INVALID_FALLBACK),ke.createElement(ke.Fragment,null))},e.contextType=y6,e})(ke.Component);function ibe({children:t,client:e,useAuth:n}){const r=abe(n);return h.jsx(eq,{client:e,useAuth:r,children:t})}function abe(t){return _.useMemo(()=>function(){const{isLoading:n,user:r,getAccessToken:s}=t(),i=_.useCallback(async()=>{try{return await s()}catch{return null}},[s]);return _.useMemo(()=>({isLoading:n,isAuthenticated:!!r,fetchAccessToken:i}),[n,r,i])},[t])}const obe="https://outstanding-fennec-304.convex.cloud",lbe="client_01K4C1TVPBE7JTBFQJF9SDW9P9",cbe=(()=>{const t="mcpjam://oauth/callback";return typeof window>"u"?t:window.location.protocol==="http:"||window.location.protocol==="https:"?`${window.location.origin}/callback`:t})(),ube=new XB(obe),dbe=PV.createRoot(document.getElementById("root")),fbe=h.jsx(Rve,{clientId:lbe,redirectUri:cbe,children:h.jsx(ibe,{client:ube,useAuth:oU,children:h.jsx(Ove,{})})});dbe.render(h.jsx(_.StrictMode,{children:h.jsx(tbe,{apiKey:Ive(),options:Lve(),children:fbe})}));
1768
+ //# sourceMappingURL=index-D65VQjeC.js.map