1var e=`u`>typeof window?window:void 0,t=`u`>typeof globalThis?globalThis:e,n=t?.navigator,r=t?.document,i=t?.location,a=t?.fetch,o=t?.XMLHttpRequest&&`withCredentials`in new t.XMLHttpRequest?t.XMLHttpRequest:void 0,s=t?.AbortController,c=t?.CompressionStream,l=n?.userAgent;function u(){return!(!e||!1===e.navigator.onLine)}var d=typeof globalThis<`u`?globalThis:e;d&&typeof self>`u`&&(d.self=d),d&&typeof File>`u`&&(d.File=function(){});var f=e??{},p=`0.9.0`,m={DEBUG:!1,LIB_VERSION:p,LIB_NAME:`browser-common`,JS_SDK_VERSION:p},h=function(e){return e.AnonymousId=`anonymous_id`,e.DistinctId=`distinct_id`,e.Props=`props`,e.EnablePersonProcessing=`enable_person_processing`,e.PersonMode=`person_mode`,e.FeatureFlagDetails=`feature_flag_details`,e.FeatureFlags=`feature_flags`,e.FeatureFlagPayloads=`feature_flag_payloads`,e.BootstrapFeatureFlagDetails=`bootstrap_feature_flag_details`,e.BootstrapFeatureFlags=`bootstrap_feature_flags`,e.BootstrapFeatureFlagPayloads=`bootstrap_feature_flag_payloads`,e.OverrideFeatureFlags=`override_feature_flags`,e.Queue=`queue`,e.AiQueue=`ai_queue`,e.AiCaptureQueue=`ai_capture_queue`,e.LogsQueue=`logs_queue`,e.OptedOut=`opted_out`,e.SessionId=`session_id`,e.SessionStartTimestamp=`session_start_timestamp`,e.SessionLastTimestamp=`session_timestamp`,e.PersonProperties=`person_properties`,e.GroupProperties=`group_properties`,e.InstalledAppBuild=`installed_app_build`,e.InstalledAppVersion=`installed_app_version`,e.SessionReplay=`session_replay`,e.PushRegistered=`push_registered`,e.SessionReplayEventTriggerActivatedSession=`session_replay_event_trigger_activated_session`,e.SurveyLastSeenDate=`survey_last_seen_date`,e.SurveysSeen=`surveys_seen`,e.Surveys=`surveys`,e.RemoteConfig=`remote_config`,e.FlagsEndpointWasHit=`flags_endpoint_was_hit`,e.DeviceId=`device_id`,e}({}),g=function(e){return e.GZipJS=`gzip-js`,e.Base64=`base64`,e}({}),_=[`$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`],v=[`token`];function y(e,t){return e.indexOf(t)!==-1}var b=function(e){return e.trim()},x=function(e){return e.replace(/^\$/,``)};function S(e){let t=[];return JSON.stringify(e,function(e,n){if(typeof n==`bigint`)return n.toString();if(typeof n!=`function`&&typeof n!=`symbol`){if(n instanceof Error)return{name:n.name,message:n.message,stack:n.stack};if(n&&typeof n==`object`){for(;t.length>0&&t[t.length-1]!==this;)t.pop();if(t.includes(n))return`[Circular]`;t.push(n)}return n}})??`null`}var C=Object.prototype,w=C.hasOwnProperty,T=C.toString,E=Array.isArray||function(e){return T.call(e)===`[object Array]`},D=e=>typeof e==`function`,O=e=>e===Object(e)&&!E(e),k=e=>{if(O(e)){for(let t in e)if(w.call(e,t))return!1;return!0}return!1},A=e=>e===void 0,j=e=>T.call(e)==`[object String]`,ee=e=>j(e)&&e.trim().length===0,M=e=>e===null,N=e=>A(e)||M(e),P=e=>T.call(e)==`[object Number]`&&e==e,te=e=>P(e)&&e>0,F=e=>T.call(e)===`[object Boolean]`,ne=e=>y(_,e),re=e=>y(v,e);function ie(e){return typeof e!=`object`||!e}function I(e,t){return{}.toString.call(e)===`[object ${t}]`}function ae(e){switch({}.toString.call(e)){case`[object Error]`:case`[object Exception]`:case`[object DOMException]`:case`[object DOMError]`:case`[object WebAssembly.Exception]`:return!0;default:return se(e,Error)}}function oe(e){return`u`>typeof Event&&se(e,Event)}function se(e,t){try{return e instanceof t}catch{return!1}}var ce=[!0,`true`,1,`1`,`yes`],le=e=>y(ce,e),ue=[!1,`false`,0,`0`,`no`];function de(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){n(e);return}s.done?t(c):Promise.resolve(c).then(r,i)}function L(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var a=e.apply(t,n);function o(e){de(a,r,i,o,s,`next`,e)}function s(e){de(a,r,i,o,s,`throw`,e)}o(void 0)})}}var fe=`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,pinterestbot,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`.split(`,`),pe=function(e,t=[]){if(!e)return!1;let n=e.toLowerCase();return fe.concat(t).some(e=>{let t=e.toLowerCase();return n.indexOf(t)!==-1})};function me(e,t,n,r,i){return t>n&&(r.warn(`min cannot be greater than max.`),t=n),P(e)?e>n?(r.warn(` cannot be greater than max: `+n+`. Using max value instead.`),n):t>e?(r.warn(` cannot be less than min: `+t+`. Using min value instead.`),t):e:(r.warn(` must be a number. using max or fallback. max: `+n+`, fallback: `+i),me(i??n,t,n,r))}var he=class{constructor(e){this.C={},this.I=e.I,this.R=me(e.bucketSize,0,100,e.$),this.A=me(e.refillRate,0,this.R,e.$),this.O=me(e.refillInterval,0,864e5,e.$)}F(e,t){let n=Math.floor((t-e.lastAccess)/this.O);n>0&&(e.tokens=Math.min(e.tokens+n*this.A,this.R),e.lastAccess+=n*this.O)}consumeRateLimit(e){var t;let n=Date.now(),r=String(e),i=this.C[r];return i?this.F(i,n):(i={tokens:this.R,lastAccess:n},this.C[r]=i),i.tokens===0||(i.tokens--,i.tokens===0&&((t=this.I)==null||t.call(this,e)),i.tokens===0)}stop(){this.C={}}},ge=`Mobile`,_e=`Android`,ve=`Tablet`,ye=`Android Tablet`,be=`iPad`,xe=`Apple Watch`,Se=`Safari`,Ce=`BlackBerry`,we=`Samsung Internet`,Te=`Chrome`,Ee=`Chrome iOS`,De=`Internet Explorer`,Oe=`Internet Explorer Mobile`,ke=`Opera`,Ae=`Microsoft Edge`,je=`Firefox`,Me=`Firefox iOS`,Ne=`Nintendo`,Pe=`PlayStation`,Fe=`Xbox`,Ie=`Android Mobile`,Le=`Mobile Safari`,Re=`Windows`,ze=`Windows Phone`,Be=`Nokia`,Ve=`Ouya`,He=`Generic `+ge.toLowerCase(),Ue=`Generic `+ve.toLowerCase(),We=`Konqueror`,Ge=`Oculus Browser`,Ke=`Vivaldi`,qe=`Yandex`,Je=`Whale`,Ye=`DuckDuckGo`,Xe=`Pale Moon`,Ze=`Waterfox`,Qe=`Brave`,$e=`Claude`,et=`Codex`,tt=`ChatGPT`,nt=`Google Search App`,rt=RegExp(`Version/(\\d+(\\.\\d+)?)`),it=RegExp(`(Claude|Codex|ChatGPT)\\/(\\d+(\\.\\d+)?)`),at=new RegExp(Fe,`i`),ot=RegExp(`PlayStation \\w+`,`i`),st=RegExp(`Nintendo \\w+`,`i`),ct=RegExp(`BlackBerry|PlayBook|BB10`,`i`),lt={"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`},ut=function(e,t,n,r){return t||=``,function(e){return e?.brave?Qe:null}(n)||(r?.detectGoogleSearchApp&&y(e,`GSA/`)?nt:y(e,` OPR/`)&&y(e,`Mini`)?`Opera Mini`:y(e,` OPR/`)?ke:ct.test(e)?Ce:y(e,`IEMobile`)||y(e,`WPDesktop`)?Oe:y(e,`OculusBrowser`)?Ge:y(e,`SamsungBrowser`)?we:y(e,`Edge`)||y(e,`Edg/`)?Ae:y(e,`Vivaldi/`)?Ke:y(e,`YaBrowser/`)?qe:y(e,`Whale/`)?Je:y(e,`DuckDuckGo/`)||y(e,`Ddg/`)?Ye:y(e,`Claude/`)?$e:y(e,`Codex/`)?et:y(e,`ChatGPT/`)?tt:y(e,`FBIOS`)?`Facebook Mobile`:y(e,`UCWEB`)||y(e,`UCBrowser`)?`UC Browser`:y(e,`CriOS`)?Ee:y(e,`CrMo`)||y(e,Te)?Te:y(e,_e)&&y(e,Se)?Ie:y(e,`FxiOS`)?Me:y(e.toLowerCase(),We.toLowerCase())?We:y(e,`Brave/`)?Qe:((e,t)=>t&&y(t,`Apple`)||function(e){return y(e,Se)&&!y(e,Te)&&!y(e,_e)}(e))(e,t)?y(e,ge)?Le:Se:y(e,`PaleMoon/`)?Xe:y(e,`Waterfox/`)?Ze:y(e,je)?je:y(e,`MSIE`)||y(e,`Trident/`)?De:y(e,`Gecko`)?je:``)},dt={[Oe]:[RegExp(`rv:(\\d+(\\.\\d+)?)`)],[Ae]:[RegExp(`Edge?\\/(\\d+(\\.\\d+)?)`)],[Te]:[RegExp(`(Chrome|CrMo)\\/(\\d+(\\.\\d+)?)`)],[Ee]:[RegExp(`CriOS\\/(\\d+(\\.\\d+)?)`)],"UC Browser":[RegExp(`(UCBrowser|UCWEB)\\/(\\d+(\\.\\d+)?)`)],[Se]:[rt],[Le]:[rt],[ke]:[RegExp(`(Opera|OPR)\\/(\\d+(\\.\\d+)?)`)],[je]:[RegExp(`Firefox\\/(\\d+(\\.\\d+)?)`)],[Me]:[RegExp(`FxiOS\\/(\\d+(\\.\\d+)?)`)],[We]:[RegExp(`Konqueror[:/]?(\\d+(\\.\\d+)?)`,`i`)],[Ce]:[RegExp(`BlackBerry (\\d+(\\.\\d+)?)`),rt],[Ie]:[RegExp(`android\\s(\\d+(\\.\\d+)?)`,`i`)],[we]:[RegExp(`SamsungBrowser\\/(\\d+(\\.\\d+)?)`)],[Ge]:[RegExp(`OculusBrowser\\/(\\d+(\\.\\d+)?)`)],[Ke]:[RegExp(`Vivaldi\\/(\\d+(\\.\\d+)?)`)],[qe]:[RegExp(`YaBrowser\\/(\\d+(\\.\\d+)?)`)],[Je]:[RegExp(`Whale\\/(\\d+(\\.\\d+)?)`)],[Qe]:[RegExp(`Brave\\/(\\d+(\\.\\d+)?)`)],[$e]:[it],[et]:[it],[tt]:[it],[Ye]:[RegExp(`(DuckDuckGo|Ddg)\\/(\\d+(\\.\\d+)?)`)],[Xe]:[RegExp(`PaleMoon\\/(\\d+(\\.\\d+)?)`)],[Ze]:[RegExp(`Waterfox\\/(\\d+(\\.\\d+)?)`)],[nt]:[RegExp(`GSA\\/(\\d+(\\.\\d+)?)`)],[De]:[RegExp(`(rv:|MSIE )(\\d+(\\.\\d+)?)`)],Mozilla:[RegExp(`rv:(\\d+(\\.\\d+)?)`)]},ft=function(e,t,n,r){let i=dt[ut(e,t,n,r)];if(A(i))return null;for(let t=0;i.length>t;t++){let n=e.match(i[t]);if(n)return parseFloat(n[n.length-2])}return null},pt=[[RegExp(`Xbox; Xbox (.*?)[);]`,`i`),e=>[Fe,e&&e[1]||``]],[new RegExp(Ne,`i`),[Ne,``]],[new RegExp(Pe,`i`),[Pe,``]],[ct,[Ce,``]],[new RegExp(Re,`i`),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[ze,``];if(new RegExp(ge).test(t)&&!/IEMobile\b/.test(t))return[`Windows Mobile`,``];let n=/Windows NT ([0-9.]+)/i.exec(t);if(n&&n[1]){let e=lt[n[1]]||``;return/arm/i.test(t)&&(e=`RT`),[Re,e]}return[Re,``]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>e&&e[3]?[`iOS`,[e[3],e[4],e[5]||`0`].join(`.`)]:[`iOS`,``]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{let t=``;return e&&e.length>=3&&(t=A(e[2])?e[3]:e[2]),[`watchOS`,t]}],[RegExp(`(Android (\\d+)\\.(\\d+)\\.?(\\d+)?|Android)`,`i`),e=>e&&e[2]?[_e,[e[2],e[3],e[4]||`0`].join(`.`)]:[_e,``]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{let t=[`Mac OS X`,``];return e&&e[1]&&(t[1]=[e[1],e[2],e[3]||`0`].join(`.`)),t}],[/Mac/i,[`Mac OS X`,``]],[/CrOS/,[`Chrome OS`,``]],[/Linux|debian/i,[`Linux`,``]]],mt=function(e){for(let t=0;pt.length>t;t++){let[n,r]=pt[t],i=n.exec(e),a=i&&(D(r)?r(i,e):r);if(a)return a}return[``,``]},ht=function(e){return st.test(e)?Ne:ot.test(e)?Pe:at.test(e)?Fe:new RegExp(Ve,`i`).test(e)?Ve:Reg
1Exp(`(Windows Phone|WPDesktop)`,`i`).test(e)?ze:/iPad/.test(e)?be:/iPod/.test(e)?`iPod Touch`:/iPhone/.test(e)?`iPhone`:/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?xe:ct.test(e)?Ce:/(kobo)\s(ereader|touch)/i.test(e)?`Kobo`:new RegExp(Be,`i`).test(e)?Be:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(e)||/(kf[a-z]+)( bui|\)).+silk\//i.test(e)?`Kindle Fire`:/(Android|ZTE)/i.test(e)?new RegExp(ge).test(e)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(e)||/pixel[\daxl ]{1,6}/i.test(e)&&!/pixel c/i.test(e)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(e)||/lmy47v/i.test(e)&&!/QTAQZ3/i.test(e)?_e:ye:RegExp(`(pda|Mobile)`,`i`).test(e)?He:new RegExp(ve,`i`).test(e)&&!RegExp(`Tablet pc`,`i`).test(e)?Ue:``},gt=function(e,t){let n=ht(e);return n===be||n===ye||n===`Kobo`||n===`Kindle Fire`||n===Ue?ve:n===Ne||n===Fe||n===Pe||n===Ve?`Console`:n===xe?`Wearable`:n?ge:t?.userAgentDataPlatform===`Android`&&(t?.maxTouchPoints??0)>0?600>Math.min((r=t?.screenWidth)??0,(i=t?.screenHeight)??0)/((a=t?.devicePixelRatio)??1)?ge:ve:`Desktop`;var r,i,a},_t=/\bFBAV\/(\d+(?:\.\d+)*)/i,vt=[[/\bInstagram(?:[ /](\d+(?:\.\d+)*))?\b/i,`Instagram`],[/\bBarcelona[ /](\d+(?:\.\d+)*)?/i,`Threads`],[/\b(?:MessengerForiOS|(?:FBAN|FB_IAB)\/Orca-Android)\b/i,`Messenger`,_t],[/\bFBAN\/EMA\b/i,`Facebook Lite`,_t],[/\b(?:FBIOS|(?:FBAN|FB_IAB)\/(?:FB4A|FBIOS))\b/i,`Facebook`,_t],[/\bLinkedInApp(?:\]?\/(\d+(?:\.\d+)*))?\b/i,`LinkedIn`],[/\bTwitter(?:Android| for (?:iPhone|iPad|Android))(?:\/(\d+(?:\.\d+)*))?\b/i,`Twitter`],[/\b(?:musical_ly|trill)(?:[_/](\d+\.\d+(?:\.\d+)*))?(?=\b|_)/i,`TikTok`,/\bapp_version\/(\d+(?:\.\d+)*)/i],[/\b(?:MicroMessenger|WeChat)\/(\d+(?:\.\d+)*)?/i,`WeChat`],[/\bLine\/(\d+(?:\.\d+)*)?/i,`Line`],[/\bGSA\/(\d+(?:\.\d+)*)?/i,`Google`],[/\[Pinterest\/(?:iOS|Android)\b|\bPinterest(?: for (?:Android(?: Tablet)?|iOS))?\/(\d+(?:\.\d+)*)/i,`Pinterest`],[/\b(?:WA4A|WAiOS)\/(\d+(?:\.\d+)*)?/i,`WhatsApp`],[/\bSnapchat[ /](\d+(?:\.\d+)*)?/i,`Snapchat`],[/\bBing(?:Web|Sapphire)\/(\d+(?:\.\d+)*)?/i,`Bing`],[/\bNAVER\(inapp; search;/i,`Naver`,/\bNAVER\(inapp; search;[^;)]*; (\d+(?:\.\d+)*)/i],[/\bKAKAOTALK[ /](\d+\.\d+(?:\.\d+)*)?/i,`KakaoTalk`]],yt=`[Truncated]`,bt=`[Unserializable]`;function xt(e){let t=``;for(let n=0;e.length>n;n++){let r=e.charCodeAt(n);if(55296>r||r>56319)t+=56320>r||r>57343?e[n]:`�`;else{let r=e.charCodeAt(n+1);56320>r||r>57343?t+=`�`:(t+=e[n]+e[n+1],n++)}}return t}function St(e,t){if(!t)return e;let n=[];try{n=Object.keys(t)}catch{n=[]}for(let r of n){let n;try{n=t[r]}catch{n=bt}Object.defineProperty(e,r,{value:n,enumerable:!0,writable:!0,configurable:!0})}return e}var Ct=3e5,wt=class{record(e){if(e.kind===`too-large`)return;if(e.kind!==`retry-later`)return void this.reset();if(!e.retryAfterMs)return;let t=this.isOpen(),n=Date.now(),r=Math.min(e.retryAfterMs,Ct);if(!t)return this.ts=n,void(this.es=n+r);this.es=Math.max(this.es,Math.min(n+r,this.ts+Ct))}remainingMs(){let e=Date.now();if(this.ts-5e3>e)return this.reset(),0;let t=Math.min(Ct,Math.max(0,this.es-e));return t===0&&this.reset(),t}isOpen(){return this.remainingMs()>0}reset(){this.es=0,this.ts=0}constructor(){this.es=0,this.ts=0}},Tt=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function Et(e,t){return typeof(n=e)==`string`&&Tt.test(n)?e:t();var n}function Dt(e,t){let n=Error(t);try{Object.defineProperty(n,"name",{value:e,writable:!0,enumerable:!0,configurable:!0})}catch{}return n}function Ot(e){return e&&e.split(`#`)[0]}function kt(e){try{return e()}catch{return}}function At(e,t){let n=setTimeout(e,t);return n!=null&&n.unref&&n?.unref(),n}function jt(e,t,n){return Mt.apply(this,arguments)}function Mt(){return(Mt=L(function*(e,t,n){let r;try{return yield Promise.race([e,new Promise((e,i)=>{r=At(()=>{try{n?.(),e()}catch(e){i(e)}},t)})])}finally{clearTimeout(r)}})).apply(this,arguments)}var Nt,Pt,Ft;function It(e){let t=globalThis._posthogChunkIds;if(!t)return;let n=Object.keys(t);return Ft&&n.length===Pt||(Pt=n.length,Ft=n.reduce((n,r)=>{Nt||={};let i=Nt[r];if(i)n[i[0]]=i[1];else{let i=e(r);for(let e=i.length-1;e>=0;e--){let a=i[e]?.filename,o=t[r];if(a&&o){n[a]=o,Nt[r]=[a,o];break}}}return n},{})),Ft}function Lt(e){return Lt=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},Lt(e)}function Rt(e,t,n){return(t=function(e){var t=function(e){if(Lt(e)!=`object`||!e)return e;var t=e[Symbol.toPrimitive];if(t!==void 0){var n=t.call(e,`string`);if(Lt(n)!=`object`)return n;throw TypeError(`@@toPrimitive must return a primitive value.`)}return String(e)}(e);return Lt(t)==`symbol`?t:t+``}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function zt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function R(e){for(var t=1;arguments.length>t;t++){var n=arguments[t]==null?{}:arguments[t];
1t%2?zt(Object(n),!0).forEach(function(t){Rt(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):zt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var Bt=class{constructor(e,t,n=[]){this.coercers=e,this.stackParser=t,this.modifiers=n}buildFromUnknown(e,t={}){let n=t&&t.mechanism||{handled:!0,type:`generic`},r=this.buildCoercingContext(n,t,0).apply(e),i=this.buildParsingContext(t),a=this.parseStacktrace(r,i);return{$exception_list:this.convertToExceptionList(a,n),$exception_level:`error`}}modifyFrames(e){var t=this;return L(function*(){for(let n of e)n.stacktrace&&n.stacktrace.frames&&E(n.stacktrace.frames)&&(n.stacktrace.frames=yield t.applyModifiers(n.stacktrace.frames));return e})()}coerceFallback(e){return{type:`Error`,value:`Unknown error`,stack:e.syntheticException?.stack,synthetic:!0}}parseStacktrace(e,t){let n,r;if(e.cause!=null&&(n=this.parseStacktrace(e.cause,t)),e.stack!=``&&e.stack!=null)try{r=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?t.skipFirstLines:0),t.chunkIdMap)}catch{}return R(R({},e),{},{cause:n,stack:r,errors:e.errors?.map(e=>this.parseStacktrace(e,t))})}applyChunkIds(e,t){return e.map(e=>(e.filename&&t&&(e.chunk_id=t[e.filename]),e))}applyCoercers(e,t){for(let n of this.coercers)if(n.match(e))return n.coerce(e,t);return this.coerceFallback(t)}applyModifiers(e){var t=this;return L(function*(){let n=e;for(let e of t.modifiers)n=yield e(n);return n})()}convertToExceptionList(e,t){let n=[],r=(e,i,a)=>{let o=n.length,s=i===void 0?R(R({type:typeof t.type==`string`&&t.type.length>0?t.type:`generic`},typeof t.handled==`boolean`?{handled:t.handled}:t.handled===void 0?{handled:!0}:{}),{},{synthetic:typeof t.synthetic==`boolean`?t.synthetic:e.synthetic,exception_id:o}):{type:`chained`,source:a,synthetic:e.synthetic,exception_id:o,parent_id:i},c={type:e.type,value:e.value,mechanism:s};e.stack&&(c.stacktrace={type:`raw`,frames:e.stack}),n.push(c),e.cause&&r(e.cause,o,`cause`);for(let t of e.errors??[])r(t,o,`member`)};return r(e),n}buildParsingContext(e){return{chunkIdMap:It(this.stackParser),skipFirstLines:e.skipFirstLines??1}}getAggregateErrors(e){try{if(ae(e)){let t=Object.getPrototypeOf(e);for(let n=0;t&&100>n;n++){let n=Object.getOwnPropertyDescriptor(t,`constructor`)?.value;if(typeof n==`function`&&n.name===`AggregateError`){let t=e.errors;return E(t)?t:void 0}t=Object.getPrototypeOf(t)}}}catch{}}buildCoercingContext(e,t,n=0){let r=0,i=0,a=!1,o=new Set,s=[],c={},l=(e,t,n=0)=>{let l=u(t,n),d=l.apply;if(l.apply=t=>{s.push(e);try{return d(t)}finally{s.pop()}},n>4||n>0&&s.indexOf(e)!==-1)return this.coerceFallback(l);let f=typeof e==`object`&&!!e||typeof e==`function`;if(n===0&&r>=50||f&&o.has(e))return;f&&o.add(e),n===0&&r++;let p=this.getAggregateErrors(e),m,h;a||=!!p;try{if(m=this.applyCoercers(e,l),!m)throw c}catch(e){if(e===c)return void(n===0&&r--);if(!a)throw e;m=this.coerceFallback(l)}if(!p||r>=50)return m;try{h=p.length}catch{return m}if(!Number.isInteger(h)||0>h||h>4294967295)return m;let g=[];for(let e=0;50>r&&1e3>i&&h>e;e++){let n;i++;try{n=l.next(p[e])}catch{r++,n=this.coerceFallback(u(t+1))}n&&g.push(n)}return R(R({},m),{},{errors:g})},u=(n,r=0)=>R(R({},t),{},{syntheticException:n==0?t.syntheticException:void 0,mechanism:n==0?e:{},apply(e){let t=l(e,n,r+1);if(!t)throw c;return t},next:e=>l(e,n+1)}),d=u(n);return R(R({},d),{},{apply:e=>l(e,n)??this.coerceFallback(d)})}},Vt=/^([a-z][a-z0-9.+-]+):/i,Ht=[`http`,`https`,`file`,`blob`,`app`,`capacitor`,`ionic`,`webpack`,`webpack-internal`,`ng`];function Ut(e){if(!e||e===`<anonymous>`)return!1;let t=Vt.exec(e);return!t||Ht.includes(t[1].toLowerCase())}function Wt(e,t,n,r,i){let a={platform:e,filename:t,function:n===`<anonymous>`?`?`:n,in_app:Ut(t)};return A(r)||(a.lineno=r),A(i)||(a.colno=i),a}var Gt=(e,t)=>{let n=e.indexOf(`safari-extension`)!==-1,r=e.indexOf(`safari-web-extension`)!==-1;return n||r?[e.indexOf(`@`)===-1?`?`:e.split(`@`)[0],n?`safari-extension:${t}`:`safari-web-extension:${t}`]:[e,t]},Kt=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,qt=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,Jt=/\((\S*)(?::(\d+))(?::(\d+))\)/,Yt=(e,t)=>{let n=Kt.exec(e);if(n){let[,e,r,i]=n;return Wt(t,e,`?`,+r,+i)}let r=qt.exec(e);if(r){if(r[2]&&r[2].indexOf(`eval`)===0){let e=Jt.exec(r[2]);e&&(r[2]=e[1],r[3]=e[2],r[4]=e[3])}let[e,n]=Gt(r[1]||`?`,r[2]);return Wt(t,n,e,r[3]?+r[3]:void 0,r[4]?+r[4]:void 0)}},Xt=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,Zt=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,Qt=(e,t)=>
1{let n=Xt.exec(e);if(n){if(n[3]&&n[3].indexOf(` > eval`)>-1){let e=Zt.exec(n[3]);e&&(n[1]=n[1]||`eval`,n[3]=e[1],n[4]=e[2],n[5]=``)}let e=n[3],r=n[1]||`?`;return[r,e]=Gt(r,e),Wt(t,e,r,n[4]?+n[4]:void 0,n[5]?+n[5]:void 0)}},$t=/\(error: (.*)\)/;function en(e,t){return e.filename===t.filename&&e.function===t.function&&e.module===t.module&&e.lineno===t.lineno&&e.colno===t.colno}function tn(e){for(let t=1;10>=t;t++){let n=e.length-2*t;if(0>n)break;let r=!0;for(let i=0;t>i;i++)if(!en(e[n+i],e[n+t+i])){r=!1;break}if(r){for(let r=0;t>r;r++)e[n+r]=e[n+t+r];return e.length=n+t,{start:n,length:t}}}}function nn(e,t){let n=t.start+t.length,r=an(e,t);r&&e.splice(n+r===e.length?n:t.start,r)}function rn(e,t){let n=t.start;for(;n>0&&en(e[n-1],e[n-1+t.length]);)n--;return t.start-n}function an(e,t){let n=t.start+t.length,r=n;for(;e.length>r&&en(e[r],e[r-t.length]);)r++;return r-n}function on(e,t){let n=t[0],r=e.length-(n?rn(e,n):0);for(let n of t)r-=an(e,n);return r}function sn(e,t,n){for(let r=0;e.length>r;r++){let i=e[(t+r)%e.length],a=e[(n+r)%e.length];if(i!==a)return a>i}return!1}var cn=class{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){let n=j(e.stack);return{type:this.getType(e),value:this.getValue(e),stack:n?e.stack:void 0,cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return this.isDOMError(e)?`DOMError`:`DOMException`}getValue(e){let t=e.name||(this.isDOMError(e)?`DOMError`:`DOMException`);return e.message?`${t}: ${e.message}`:t}isDOMException(e){return I(e,`DOMException`)}isDOMError(e){return I(e,`DOMError`)}},ln=class{match(e){return ae(e)}coerce(e,t){let n=this.getStack(e),r=n===void 0?t.syntheticException?.stack:void 0,i=!!r;return{type:this.getType(e),value:this.getMessage(e,t),stack:n??r,cause:e.cause?t.next(e.cause):void 0,synthetic:i}}getType(e){return e.name||e.constructor.name}getMessage(e,t){let n=e.message;return String(n.error&&typeof n.error.message==`string`?n.error.message:n)}getStack(e){try{let t=e.stacktrace;if(typeof t==`string`&&t.length>0)return t;let n=e.stack;return typeof n==`string`&&n.length>0?n:void 0}catch{return}}},un=class{match(e){return!!I(e,`ErrorEvent`)&&(e.error!=null||this.ur(e))}coerce(e,t){if(e.error!=null)return t.apply(e.error);let n=t.apply(e.message);return R(R({},n),{},{stack:this.cr(e)??n.stack,synthetic:!0})}ur(e){return j(e.message)&&e.message.length>0}cr(e){let t=e,n=t.lineno??0,r=t.colno??0;if(j(t.filename)&&t.filename.length!==0&&n!==0)return`Error\n at ${t.filename}:${n}:${r}`}},dn=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,fn=class{match(e){return typeof e==`string`}coerce(e,t){let[n,r]=this.getInfos(e);return{type:n??`Error`,value:r??e,stack:t.syntheticException?.stack,synthetic:!0}}getInfos(e){let t=`Error`,n=e,r=e.match(dn);return r&&(t=r[1],n=r[2]),[t,n]}},pn=[`fatal`,`error`,`warning`,`log`,`info`,`debug`];function mn(e,t=40){let n=Object.keys(e);if(n.sort(),!n.length)return`[object has no keys]`;for(let e=n.length;e>0;e--){let r=n.slice(0,e).join(`, `);if(t>=r.length)return e===n.length?r:r.length>t?`${r.slice(0,t)}...`:r}return``}var hn=class{match(e){return typeof e==`object`&&!!e}coerce(e,t){let n=this.getErrorPropertyFromObject(e);return n?t.apply(n):{type:this.getType(e),value:this.getValue(e),stack:this.getStack(e)??t.syntheticException?.stack,level:this.isSeverityLevel(e.level)?e.level:`error`,synthetic:!0}}getType(e){if(oe(e))return e.constructor.name;let t=`name`in e?e.name:void 0;return j(t)&&!ee(t)?t:`Error`}getValue(e){if(`name`in e&&typeof e.name==`string`){let t=`'${e.name}' captured as exception`;return`message`in e&&typeof e.message==`string`&&(t+=` with message: '${e.message}'`),t}if(`message`in e&&typeof e.message==`string`)return e.message;let t=this.getObjectClassName(e);return`${t&&t!==`Object`?`'${t}'`:`Object`} captured as exception with keys: ${mn(e)}`}isSeverityLevel(e){return j(e)&&!ee(e)&&pn.indexOf(e)>=0}getStack(e){try{return j(e.stacktrace)&&e.stacktrace.length>0?e.stacktrace:j(e.stack)&&e.stack.length>0?e.stack:void 0}catch{return}}getErrorPropertyFromObject(e){for(let t in e)if({}.hasOwnProperty.call(e,t)){let n=e[t];if(ae(n))return n}}getObjectClassName(e){try{let t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{return}}},gn=class{match(e){return oe(e)}coerce(e,t){let n=e.constructor.name;return{type:n,value:`${n} captured as exception with keys: ${mn(e)}`,stack:t.syntheticException?.stack,synthetic:!0}}},_n=class{match(e){return ie(e)}coerce(e,t){return{type:`Error`,value:`Primitive value captured as exception: ${String(e)}`,stack:t.syntheticException?.stack,synthetic:!0}}},vn=class{match(e){return I(e,`PromiseRejectionEvent`)||this.isCu
1stomEventWrappingRejection(e)}isCustomEventWrappingRejection(e){if(!oe(e))return!1;try{let t=e.detail;return typeof t==`object`&&!!t&&`reason`in t}catch{return!1}}coerce(e,t){let n=this.getUnhandledRejectionReason(e);return ie(n)?{type:`UnhandledRejection`,value:`Non-Error promise rejection captured with value: ${String(n)}`,stack:t.syntheticException?.stack,synthetic:!0}:t.apply(n)}getUnhandledRejectionReason(e){try{if(`reason`in e)return e.reason;if(`detail`in e&&e.detail!=null&&typeof e.detail==`object`&&`reason`in e.detail)return e.detail.reason}catch{}return e}},yn=`$message`,bn=`$timestamp`,xn=new Set([yn,bn]),Sn={enabled:!0,max_bytes:32768};function Cn(e){return e?{enabled:e.enabled??Sn.enabled,max_bytes:Tn(e.max_bytes,Sn.max_bytes)}:R({},Sn)}var wn=class{constructor(e){this.ns=[],this.ss=0,this.Ir=Cn(e)}setConfig(e){this.Ir=Cn(e),this.rs()}add(e){let t=function(e){let t;try{t=S(e)}catch{return}try{let e=JSON.parse(t);if(!O(e))return;let n=e,r=n[yn],i=n[bn];return!j(r)||r.trim().length===0||!j(i)&&!P(i)?void 0:{step:n,json:t}}catch{return}}(e);if(!t)return;let n=function(e){if(`u`>typeof TextEncoder)return new TextEncoder().encode(e).length;let t=encodeURIComponent(e),n=0;for(let e=0;t.length>e;e++)t[e]===`%`?(n+=1,e+=2):n+=1;return n}(t.json);n>this.Ir.max_bytes||(this.ns.push({step:t.step,bytes:n}),this.ss+=n,this.rs())}getAttachable(){return this.ns.map(e=>e.step)}clear(){this.ns=[],this.ss=0}size(){return this.ns.length}rs(){for(;this.ss>this.Ir.max_bytes&&this.ns.length>0;){let e=this.ns.shift();e&&(this.ss-=e.bytes)}}};function Tn(e,t){if(!P(e)||1/0===e||-1/0===e)return t;let n=Math.floor(e);return 0>n?t:n}var En=e=>{if(typeof e!=`string`)return e;try{return JSON.parse(e)}catch{return e}};function Dn(e){return typeof e==`string`||e}function On(e){return typeof e==`string`?e:void 0}var kn=`$feature_flag.$feature_flag_response.$feature_flag_has_experiment.$feature_flag_id.$feature_flag_version.$feature_flag_reason.$feature_flag_request_id.$feature_flag_evaluated_at.$feature_flag_error.locally_evaluated.$groups.$process_person_profile.$geoip_disable.$current_url.$pathname.$referring_domain.utm_source.utm_medium.utm_campaign.utm_content.utm_term.gad_source.mc_cid.gclid.gclsrc.dclid.gbraid.wbraid.fbclid.msclkid.twclid.li_fat_id.igshid.ttclid.rdt_cid.epik.qclid.sccid.irclid._kx.$session_id.$window_id.$lib.$lib_version.$device_id.$is_server`.split(`.`),An=`NativeGzipValidationError`,jn=e=>e.length>=2&&e[0]===31&&e[1]===139,Mn=(e,t)=>e===g.GZipJS||t===g.GZipJS||t===`gzip`,Nn=e=>!(!e||typeof e!=`object`)&&(`name`in e?String(e.name):``)===`NotReadableError`,Pn,Fn=e=>{throw Dt(An,`Native gzip produced invalid output: ${e}`)},In=(Ln=L(function*(e,t){18>e.size&&Fn(`too-short`);let n=new Uint8Array(yield e.slice(0,10).arrayBuffer());jn(n)&&n[2]===8||Fn(`invalid-header`);let r=new DataView(yield e.slice(e.size-8).arrayBuffer());r.getUint32(0,!0)!==(e=>{let t=(()=>{if(Pn)return Pn;Pn=[];for(let e=0;256>e;e++){let t=e;for(let e=0;8>e;e++)t=1&t?3988292384^t>>>1:t>>>1;Pn[e]=t>>>0}return Pn})(),n=4294967295;for(let r=0;e.length>r;r++)n=t[255&(n^e[r])]^n>>>8;return(4294967295^n)>>>0})(t)&&Fn(`invalid-crc`);let i=t.length>>>0;r.getUint32(4,!0)!==i&&Fn(`invalid-size`)}),function(e,t){return Ln.apply(this,arguments)}),Ln;function Rn(){return Rn=L(function*(e,t=!0,n){try{let t=new TextEncoder().encode(e),n=new globalThis.CompressionStream(`gzip`),i=n.writable.getWriter(),a=i.write(t).then(()=>i.close()).catch((r=L(function*(e){try{yield i.abort(e)}catch{}throw e}),function(e){return r.apply(this,arguments)})),o=new Response(n.readable).blob(),[s]=yield Promise.all([o,a]);return yield In(s,t),s}catch(e){if(n?.rethrow)throw e;return t&&console.error(`Failed to gzip compress data`,e),null}var r}),Rn.apply(this,arguments)}function zn(e,t){if(e==null)return{};var n,r,i=function(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.includes(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;a.length>r;r++)t.includes(n=a[r])||{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}var Bn={}.propertyIsEnumerable;function Vn(e,t){try{return Wn(e,t,{ancestors:new WeakSet,remainingNodes:1e4}
1,0)}catch{return[]}}function Hn(e,t,n,r){if(0>=n.remainingNodes)return{stringValue:yt};if(n.remainingNodes--,F(e))return{boolValue:e};if(typeof e==`bigint`)return function(e,t){let n=e.toString(),r=BigInt(`9223372036854775808`);return e>=r||-r>e?(t?.debug(`Attribute ${n} is outside the int64 range; encoding it as a string`),{stringValue:n}):{intValue:n}}(e,t);if(typeof e==`number`){if(!Number.isFinite(e))return{stringValue:String(e)};if(Number.isInteger(e)){if(Number.isSafeInteger(e))return{intValue:String(e)};if(typeof BigInt>`u`)return{stringValue:String(e)};let n=BigInt(e).toString();return e>=0x8000000000000000||-0x8000000000000000>e?(t?.debug(`Attribute ${n} is outside the int64 range; encoding it as a string`),{stringValue:n}):{intValue:n}}return{doubleValue:e}}if(typeof e==`string`)return{stringValue:xt(e)};if(typeof e==`function`)return{stringValue:`[Function]`};if(typeof e==`symbol`)return{stringValue:String(e)};if(typeof e==`object`&&e){if(n.ancestors.has(e))return{stringValue:`[Circular]`};if(r>=20)return{stringValue:yt};if(e instanceof Date){let t=e.getTime(),n=Number.isFinite(t)?e.toISOString():String(e);return{stringValue:typeof n==`string`?xt(n):String(n)}}n.ancestors.add(e);try{try{let i=e.toJSON;if(typeof i==`function`)return Hn(i.call(e),t,n,r+1)}catch{}return E(e)?{arrayValue:{values:Un(e,t,n,r+1)}}:{kvlistValue:{values:Wn(e,t,n,r+1)}}}finally{n.ancestors.delete(e)}}return{stringValue:xt(String(e))}}function Un(e,t,n,r){let i=[],a=Math.min(e.length,1e3),o=0;for(;a>o&&n.remainingNodes>0;o++)try{let a=o in e?e[o]:void 0;if(N(a))continue;i.push(Hn(a,t,n,r))}catch{i.push({stringValue:bt})}return e.length>o&&i.push({stringValue:yt}),i}function Wn(e,t,n,r){let i=[];for(let a in e)if(Bn.call(e,a)){if(!a){t?.debug(`Dropping an attribute with an empty key`);continue}if(i.length>=1e3||0>=n.remainingNodes){t?.debug(`Attributes truncated: the value exceeds the OTLP encoder budget`);break}try{let o=e[a];if(M(o)||A(o))continue;i.push({key:xt(a),value:Hn(o,t,n,r)})}catch{i.push({key:xt(a),value:{stringValue:bt}})}}return i}function Gn(e,t,n){return R(R(R(R({},St({},e.resourceAttributes)),{},{"service.name":e.serviceName||`unknown_service`},e.environment&&{"deployment.environment":e.environment}),e.serviceVersion&&{"service.version":e.serviceVersion}),{},{"telemetry.sdk.name":t,"telemetry.sdk.version":n})}var Kn=[`service.name`,`deployment.environment`,`service.version`,`telemetry.sdk.name`,`telemetry.sdk.version`];function qn(e,t){let n=St({},e),r={};for(let e of Kn)({}).hasOwnProperty.call(n,e)&&(r[e]=n[e],delete n[e]);return[...Vn(n,t),...Vn(r,t)]}var Jn={darwin:`macOS`,win32:`Windows`,cygwin:`Windows`,linux:`Linux`,android:`Android`,freebsd:`FreeBSD`,openbsd:`OpenBSD`,netbsd:`NetBSD`,sunos:`SunOS`,aix:`AIX`,haiku:`Haiku`,"Mac OS X":`macOS`},Yn={trace:{text:`TRACE`,number:1},debug:{text:`DEBUG`,number:5},info:{text:`INFO`,number:9},warn:{text:`WARN`,number:13},error:{text:`ERROR`,number:17},fatal:{text:`FATAL`,number:21}},Xn=Yn.info;function Zn(e){try{return xt(String(e))}catch{return bt}}function Qn(e,t,n,r){let{text:i,number:a}=Yn[e.level||`info`]||Xn,o=function(e=Date.now()){return String(e)+`000000`}(P(r)?r:void 0),s={};t.distinctId&&(s.posthogDistinctId=t.distinctId),t.sessionId&&(s.sessionId=t.sessionId),t.windowId&&(s[`window.id`]=t.windowId),N(t.sessionStartTimestamp)||(s.sessionStartTimestamp=String(t.sessionStartTimestamp)),N(t.lastActivityTimestamp)||(s.lastActivityTimestamp=String(t.lastActivityTimestamp)),t.currentUrl&&(s[`url.full`]=t.currentUrl),t.screenName&&(s[`screen.name`]=t.screenName),t.appState&&(s[`app.state`]=t.appState),t.activeFeatureFlags&&t.activeFeatureFlags.length>0&&(s.feature_flags=t.activeFeatureFlags);let c=R({},s),l=e.attributes;if(l){let e=[];try{e=Object.keys(l)}catch{e=[]}for(let t of e){let e;try{e=l[t]}catch{e=bt}Object.defineProperty(c,t,{value:e,enumerable:!0,writable:!0,configurable:!0})}}let u={timeUnixNano:o,observedTimeUnixNano:o,severityNumber:a,severityText:i,body:{stringValue:Zn(e.body)},attributes:Vn(c,n)};return e.trace_id&&(u.traceId=e.trace_id),e.span_id&&(u.spanId=e.span_id),A(e.trace_flags)||(u.flags=e.trace_flags),u}function $n(e,t,n){return Gn(e,t,n)}function er(e,t,n,r){return{resourceLogs:[{resource:{attributes:qn(t)},scopeLogs:[{scope:{name:n,version:r},logRecords:e}]}]}}var tr=class{constructor(e){this.ls=e,this.us=0}get pending(){return!!this.hs}arm(e){this.clear(),this.us=Date.now()+e,this.hs=At(()=>{this.hs=void 0,this.ls()},e)}armNoEarlierThan(e){this.hs&&Date.now()+e<=this.us||this.arm(e)}clear(){this.hs&&=(clearTimeout(this.hs),void 0)}};function nr(){return .75+.5*Math.random()}function rr(e,t,n,r){let i=e*2**Math.min(Math.max(0,t-1),6);return Math.round((r===void 0?i:Math.min(i,Math.max(r,e)))*n)}var ir=class{constructor(e,t,n,r,i,a=()=>Promise.resolve(),o){this._instance=e,this.Ir=t,this.$=n,this.cs=r,this.ds=i,this.vs=a,this.fs=o,this.ps=new tr(()=>this.gs()),this.ys=null,this.bs=0,this._s=0,this.ws=new wt,this.ks=0,this.Ss=1,this.xs=0,this.Cs=0,this.$s=!1,this.Ts=t.maxBufferSize,this.Is=Math.max(t.maxQueueSize??t.maxBufferSize,t.maxBufferSize),this.Ms=t.flushIntervalMs,this.Es=t.maxBatchRecordsPerPost,this.Ps=t.rateCapWindowMs,this.Rs=t.maxLogsPerInterval}clearQueue(){this._s++,this._instance.setPersistedProperty(h.LogsQueue,[])}reset(){this.ps.clear(),this.xs=0,this.Cs=0,this.$s=!1,this.ks=0,this.Ss=1,this.ws.reset(),this.Es=this.Ir.maxBatchRecordsPerPost}onReconnect(){this.ks=0,this.Ss=1,this.ws.isOpen()?this.As()&&this.Fs():this.gs()}captureLog(e,t){if(this._instance.isDisabled||this._instance.optedOut||!e?.body)return;let n=this.Os(e);if(n===null)return;if(!n.body)return void this.$.info(`Log was rejected in beforeSend function`);if(!this.Ds())return;let r={record:Qn(n,t?.context??this.cs(),this.$,t?.occurredAtMs)};this.ds(()=>this.Ls(r))}Os(e){let t=this.Ir.beforeSend;if(!t)return e;let n=E(t)?t:[t],r=e;for(let e of n)try{let t=e(r);if(!t)return this.$.info(`Log was rejected in beforeSend function`),null;r=t}catch(e){return this.$.error(`Error in beforeSend function for log:`,e),null}return r}Ds(){if(this.Rs===void 0)return!0;let e=Date.now(),t=e-this.xs;return this.Ps>t&&t>=0||(this.xs=e,this.Cs=0,this.$s=!1),this.Rs>this.Cs?(this.Cs++,!0):(this.$s||=(this.$.warn(`captureLog dropping logs: exceeded ${this.Rs} logs per ${this.Ps}ms`),!0),!1)}flush(){var e=this;return L(function*(){if(!e._instance.isDisabled)return e.ys||=e.Ns().finally(()=>{e.ys=null}),e.ys})()}Ns(){var e=this;
1return L(function*(){e.ps.clear();let t=e._instance.getPersistedProperty(h.LogsQueue)??[];if(t.length===0)return;let n=t.length,r=0;for(;t.length>0&&n>r;){let n=e._s;e.bs=0;let i=Math.min(t.length,e.Es),a=t.slice(0,i),o=er(a.map(e=>e.record),e.qs(),e.fs??e._instance.getLibraryId(),e._instance.getLibraryVersion()),s=yield e._instance.js(o);if(e._s!==n)return;if(s.kind===`too-large`&&a.length>1)e.Es=Math.max(1,Math.floor(a.length/2)),e.$.warn(`Logs batch of size ${a.length} was too large for the ingestion endpoint, reducing batch size to ${e.Es}`);else if(e.ws.record(s),e.ps.pending&&e.ps.arm(Math.max(e.Ms,e.ws.remainingMs())),s.kind===`retry-later`||(s.kind===`too-large`?e.$.warn(`Dropping a single log record with batch size 1 â the record is larger than the server cap and cannot be split further.`):s.kind===`ok`&&e.Ir.maxBatchRecordsPerPost>e.Es&&(e.Es=Math.min(e.Ir.maxBatchRecordsPerPost,e.Es+1)),yield e.Bs(a.length),t=e._instance.getPersistedProperty(h.LogsQueue)??[],r+=a.length,s.kind===`fatal`))throw s.error}})()}Bs(e){var t=this;return L(function*(){let n=Math.max(0,e-t.bs),r=t._instance.getPersistedProperty(h.LogsQueue)??[];t._instance.setPersistedProperty(h.LogsQueue,r.slice(n)),yield t.vs()})()}qs(){return $n(this.Ir,this._instance.getLibraryId(),this._instance.getLibraryVersion())}Ls(e){if(this._instance.optedOut)return;let t=this._instance.getPersistedProperty(h.LogsQueue)??[];this.Is>t.length||(t.shift(),this.bs++,this.$.info(`Logs queue is full, dropping oldest record.`)),t.push(e),this._instance.setPersistedProperty(h.LogsQueue,t),this.Ts>t.length||this.ws.isOpen()?this.Fs():this.gs()}Fs(){this.ps.pending||this.ps.arm(Math.max(this.Ms,this.ws.remainingMs()))}Hs(){return Math.max(rr(this.Ms,this.ks,this.Ss,3e4),this.ws.remainingMs())}As(){let e=this._instance.getPersistedProperty(h.LogsQueue);return!!e&&e.length>0}shutdown(e){var t=this;return L(function*(){t.ps.clear();let n=t.flush().catch(()=>{});e===void 0?yield n:yield jt(n,e)})()}flushWithTimeout(e){var t=this;return L(function*(){let n=t.flush();yield jt(n,e,()=>{n.catch(()=>{})})})()}gs(){this.flush().then(()=>{this.ks=0,this.Ss=1},e=>{this.ks++,this.Ss=nr(),this.$.error(`PostHog logs flush failed:`,e)}).finally(()=>{!this._instance.isDisabled&&this.As()&&this.ps.armNoEarlierThan(this.Hs())})}},ar=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function or(e){return String(e)+`000000`}function sr(e,t,n,r){let i=``;return r&&(i=Object.keys(r).sort().map(e=>`${JSON.stringify(e)}:${JSON.stringify(r[e])}`).join(`,`)),`${e}\0${t}\0${n??``}\0${i}`}var cr=class{constructor(e,t,n){this._instance=e,this.Ir=t,this.$=n,this.zs=new Map,this.ps=new tr(()=>this.flush().catch(e=>{this.$.error(`Metrics flush failed:`,e)})),this.ys=null,this.Us=!1,this.Ws=new Map,this.Vs=new Set,this.ws=new wt,this.ks=0,this.Ss=1,this.Gs=0}count(e,t=1,n){this.Zs({name:e,type:`count`,value:t,unit:n?.unit,attributes:n?.attributes})}gauge(e,t,n){this.Zs({name:e,type:`gauge`,value:t,unit:n?.unit,attributes:n?.attributes})}histogram(e,t,n){this.Zs({name:e,type:`histogram`,value:t,unit:n?.unit,attributes:n?.attributes})}flush(){var e=this;let t=this.ys,n=function(){var n=L(function*(){t&&(yield t.catch(()=>{})),yield e.Qs()});return function(){return n.apply(this,arguments)}}()().finally(()=>{this.ys===n&&(this.ys=null)});return this.ys=n,n}drainWindow(){if(this.zs.size===0)return null;let e=this.zs;return this.zs=new Map,this.Us=!1,this.Ws=new Map,this.Vs=new Set,this.Js(e)}reset(){this.Gs++,this.ws.reset(),this.ks=0,this.Ss=1,this.ps.clear(),this.zs=new Map,this.ys=null,this.Us=!1,this.Ws=new Map,this.Vs=new Set}Zs(e){if(this._instance.isDisabled||this._instance.optedOut)return;let t=this.Os(e);if(t===null)return;if(!t.name||typeof t.name!=`string`)return void this.$.warn(`Dropping metric with empty name`);if(typeof t.value!=`number`||!Number.isFinite(t.value))return void this.$.warn(`Dropping metric '${t.name}': value must be a finite number`);if(t.type===`count`&&0>t.value)return void this.$.warn(`Dropping count '${t.name}': counters are monotonic, value must be >= 0`);let n,r;try{n=t.attributes?R({},t.attributes):void 0,r=sr(t.type,t.name,t.unit,n)}catch(e){this.$.warn(`Dropping metric '${t.name}': attributes could not be serialized`,e);return}let i=this.zs.get(r);if(!i){if(!this.Ks())return;i={name:t.name,type:t.type,unit:t.unit,attributes:n,windowStartMs:Date.now()},this.zs.set(r,i)}let a=this.Ws.get(t.name);a===void 0?this.Ws.set(t.name,t.type):a===t.type||this.Vs.has(t.name)||(this.Vs.add(t.name),this.$.warn(`Metric name '${t.name}' is already used as a ${a}; recording it as a ${t.type} too will blend both series in charts. Use a distinct name.`)),this.Xs(i,t.value),this.Fs()}Ks(){return this.Ir.maxSeriesPerFlush>this.zs.size||(this.Us||(this.Us=!0,this.$.warn(`Metric series cap reached (${this.Ir.maxSeriesPerFlush} per flush window); dropping new series until the next flush. Reduce attribute cardinality.`)),!1)}Xs(e,t){switch(e.type){case`count`:e.total=(e.total??0)+t;break;case`gauge`:e.last=t;break;case`histogram`:{e.hist||={count:0,sum:0,min:t,max:t,bucketCounts:Array(ar.length+1).fill(0)};let n=e.hist;n.count+=1,n.sum+=t,n.min=Math.min(n.min,t),n.max=Math.max(n.max,t),n.bucketCounts[function(e,t){for(let n=0;t.length>n;n++)if(t[n]>=e)return n;return t.length}(t,ar)]+=1;break}}}Os(e){let t=this.Ir.beforeSend;if(!t)return e;let n=E(t)?t:[t],r=e;for(let e of n)try{let t=e(r);if(!t)return this.$.info(`Metric was rejected in beforeSend function`),null;r=t}catch(e){return this.$.error(`Error in beforeSend function for metric:`,e),null}return r}Fs(){this.ps.pending||this.ps.arm(this.Hs())}Hs(){return Math.max(rr(this.Ir.flushIntervalMs,this.ks,this.Ss,3e4),this.ws.remainingMs())}Qs(){var e=this;return L(function*(){if(e.ps.clear(),e.zs.size===0)return;let t=e.zs;e.zs=new Map,e.Us=!1,e.Ws=new Map,e.Vs=new Set;let n=e.Gs,r=yield e._instance.Ys(e.Js(t));if(n===e.Gs)switch(e.ws.record(r),r.kind===`retry-later`?(e.ks++,e.Ss=nr()):(e.ks=0,e.Ss=1),e.ps.pending&&e.ps.arm(e.Hs()),r.kind){case`ok`:return;case`retry-later`:e.lo(t),e.ps.armNoEarlierThan(e.Hs());return;case`too-large`:e.$.warn(`Metrics batch exceeded the server size limit and was dropped`);return;case`fatal`:e.$.error(`Failed to send metrics batch:`,r.error);return}})()}Js(e){return t=this.uo(e),n=function(e,t,n){return Gn(e,t,n)}(this.Ir,this._instance.getLibraryId(),this._instance.getLibraryVersion()),r
1=this._instance.getLibraryId(),i=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:qn(n)},scopeMetrics:[{scope:{name:r,version:i},metrics:t}]}]};var t,n,r,i}uo(e){let t=or(Date.now()),n=new Map;for(let r of e.values()){let e=sr(r.type,r.name,r.unit,void 0),i=n.get(e);i||(i=R({name:r.name},r.unit&&{unit:r.unit}),r.type===`count`?i.sum={aggregationTemporality:1,isMonotonic:!0,dataPoints:[]}:r.type===`gauge`?i.gauge={dataPoints:[]}:i.histogram={aggregationTemporality:1,dataPoints:[]},n.set(e,i));let a=Vn(r.attributes??{},this.$),o=or(r.windowStartMs);if(r.type===`count`){let e={attributes:a,startTimeUnixNano:o,timeUnixNano:t,asDouble:r.total??0};i.sum.dataPoints.push(e)}else if(r.type===`gauge`){let e={attributes:a,timeUnixNano:t,asDouble:r.last??0};i.gauge.dataPoints.push(e)}else r.hist&&i.histogram.dataPoints.push({attributes:a,startTimeUnixNano:o,timeUnixNano:t,count:r.hist.count,sum:r.hist.sum,min:r.hist.min,max:r.hist.max,bucketCounts:r.hist.bucketCounts,explicitBounds:ar})}return Array.from(n.values())}lo(e){for(let[t,n]of e){let e=this.zs.get(t);if(e)switch(e.windowStartMs=Math.min(e.windowStartMs,n.windowStartMs),e.type){case`count`:e.total=(e.total??0)+(n.total??0);break;case`gauge`:break;case`histogram`:if(n.hist){if(e.hist){e.hist.count+=n.hist.count,e.hist.sum+=n.hist.sum,e.hist.min=Math.min(e.hist.min,n.hist.min),e.hist.max=Math.max(e.hist.max,n.hist.max);for(let t=0;e.hist.bucketCounts.length>t;t++)e.hist.bucketCounts[t]+=n.hist.bucketCounts[t]}else e.hist=n.hist}}else this.Ks()&&this.zs.set(t,n)}}},lr=(t,{debugEnabled:n}={})=>{let r={N(r,...i){e&&(m.DEBUG||e.POSTHOG_DEBUG||n)&&!A(e.console)&&e.console&&(`__rrweb_original__`in e.console[r]?e.console[r].__rrweb_original__:e.console[r])(t,...i)},debug(...e){r.N(`debug`,...e)},info(...e){r.N(`log`,...e)},warn(...e){r.N(`warn`,...e)},error(...e){r.N(`error`,...e)},critical(...e){console.error(t,...e)},uninitializedWarning(e){r.error(`You must initialize PostHog before calling ${e}`)},createLogger:(e,n)=>lr(`${t} ${e}`,n)};return r},z=lr(`[PostHog.js]`),B=z.createLogger,ur=B(`[ExternalScriptsLoader]`),dr=e=>{let t=r?.querySelectorAll(`script`);if(t){for(let n=0;t.length>n;n++)if(t[n].src===e||t[n].getAttribute(`src`)===e)return t[n]}},fr=(e,t,n)=>{if(e.config.disable_external_dependency_loading)return ur.warn(`${t} was requested but loading of external scripts is disabled.`),n(`Loading of external scripts is disabled`);let i=dr(t);if(i){if(i.__posthog_loading_callback_fired)return n();let e=i.__posthog_loading_error;return e?n(e):(i.addEventListener(`load`,e=>{i.__posthog_loading_callback_fired=!0,n(void 0,e)}),void i.addEventListener(`error`,e=>{i.__posthog_loading_error=e,n(e)}))}let a=()=>{if(!r)return n(`document not found`);if(dr(t))return fr(e,t,n);let i=r.createElement(`script`);if(i.type=`text/javascript`,i.crossOrigin=`anonymous`,i.src=t,i.onload=e=>{i.__posthog_loading_callback_fired=!0,n(void 0,e)},i.onerror=e=>{i.__posthog_loading_error=e,n(e)},e.config.prepare_external_dependency_script&&(i=e.config.prepare_external_dependency_script(i)),!i)return n(`prepare_external_dependency_script returned null`);if(e.config.external_scripts_inject_target===`head`)r.head.appendChild(i);else{let e=r.querySelectorAll(`body > script`);var a;e.length>0?(a=e[0].parentNode)==null||a.insertBefore(i,e[0]):r.body.appendChild(i)}};r?.body?a():r?.addEventListener(`DOMContentLoaded`,a)},pr={},mr=(e,t)=>{let n=`/static/${t}.js?v=${e.version}`;if(t===`toolbar`){let e=3e5;n=`${n}&t=${Math.floor(Date.now()/e)*e}`}return e.requestRouter.endpointFor(`assets`,n)};f.__PosthogExtensions__=f.__PosthogExtensions__||{},f.__PosthogExtensions__.loadExternalDependency=(e,t,n)=>{if(t===`remote-config`){fr(e,e.requestRouter.endpointFor(`assets`,`/array/${e.config.token}/config.js`),n);return}let r=e.config.strict_script_versioning;if(r){let i=e.requestRouter.endpointFor(`assets`,`/static/${e.version}/${t}.js`),a=pr[i];if(r===`fallback`&&a){if(dr(a))return void fr(e,a,n);delete pr[i]}fr(e,i,r===`fallback`?(r,a)=>{if(r){if(typeof r==`string`)n(r);else{var o;let r=mr(e,t);pr[i]=r;let a=dr(i);a==null||(o=a.parentNode)==null||o.removeChild(a),fr(e,r,n)}}else n(void 0,a)}:n);return}fr(e,mr(e,t),n)},f.__PosthogExtensions__.loadSiteApp=(e,t,n)=>{fr(e,e.requestRouter.endpointFor(`api`,t),n)},m.DEBUG=!1,m.LIB_VERSION=`1.434.0`,m.LIB_NAME=`web`;var V=m,hr=`$people_distinct_id`,gr=`distinct_id`,_r=`$device_id`,vr=`$device_model`,yr=`__alias`,br=`__cmpns`,xr=`$fbc`,Sr=`$fbc_persistence`,Cr=`$fbp`,wr=`$fbp_persistence`,Tr=`__timers`,Er=`$autocapture_disabled_server_side`,Dr=`$heatmaps_enabled_server_side`,Or=`$exception_capture_enabled_server_side`,kr=`$error_tracking_suppression_rules`,Ar=`$error_tracking_capture_extension_exceptions`,jr=`$web_vitals_enabled_server_side`,Mr=`$dead_clicks_enabled_server_side`,Nr=`$product_tours_enabled_server_side`,Pr=`$logs_capture_enabled_server_side`,Fr=`$web_vitals_allowed_metrics`,Ir=`$session_recording_remote_config`,Lr=`$session_recording_enabled_server_side`,Rr=`$replay_sample_rate`,zr=`$replay_override_sampling`,Br=`$replay_override_linked_flag`,Vr=`$replay_override_url_trigger`,Hr=`$replay_override_event_trigger`,Ur=`$sesid`,Wr=`$session_is_sampled`,Gr=`$session_past_minimum_duration`,Kr=`$session_recording_url_trigger_activated_session`,qr=`$session_recording_event_trigger_activated_session`,Jr=`$debug_first_full_snapshot_timestamp`,Yr=`$sess_rec_flush_size`,Xr=`$enabled_feature_flags`,Zr=`$active_feature_flags`,Qr=`$early_access_features`,$r=`$feature_flag_details`,ei=`$feature_flag_payloads`,ti=`$feature_flag_request_id`,ni=`$minimal_flag_called_events`,ri=`$override_feature_flags`,ii=`$override_feature_flag_payloads`,ai=`$stored_person_properties`,oi=`$stored_group_properties`,si=`$groups`,ci=`$surveys`,li=`$surveys_loaded_at`,ui=`$surveys_activated`,di=`$surveys_activated_session`,fi=`$surveys_activated_timestamps`,pi=`ph_product_tours`,mi=`$product_tours_activated`,hi=`$product_tours_activated_session`,gi=`$conversations_widget_session_id`,_i=`$conversations_ticket_id`,vi=`$conversations_widget_state`,yi=`$conversations_user_traits`,bi=`$flag_call_reported`,xi=`$flag_call_reported_session_id`,
1Si=`$feature_flag_errors`,Ci=`$feature_flag_evaluated_at`,H=`$user_state`,wi=`$client_session_props`,Ti=`$capture_rate_limit`,Ei=`$initial_campaign_params`,Di=`$initial_referrer_info`,Oi=`$initial_person_info`,ki=`$epp`,Ai=`$posthog_cookieless`,ji=`$cookieless_mode`,Mi=`$sdk_debug_extensions_init_method`,Ni=`$sdk_debug_extensions_init_time_ms`,Pi=`$sdk_debug_recording_script_not_loaded`,Fi=`$sdk_debug_replay_stale_config`,Ii=`$sdk_debug_replay_event_trigger_status`,Li=`$sdk_debug_replay_linked_flag_trigger_status`,Ri=`$sdk_debug_replay_matched_recording_trigger_groups`,zi=`$sdk_debug_replay_pending_trigger_conditions`,Bi=`$sdk_debug_replay_remote_trigger_matching_config`,Vi=`$sdk_debug_replay_trigger_groups_count`,Hi=`$sdk_debug_replay_url_trigger_status`,Ui=`$session_recording_start_reason`,Wi=`PostHog loadExternalDependency extension not found.`,Gi=`anonymous`,Ki=`identified`,qi=`identified_only`,Ji=`visibilitychange`,Yi=`beforeunload`,Xi=`$pageview`,Zi=`$pageleave`,Qi=`$identify`,$i=`$groupidentify`;function ea(e,t){E(e)&&e.forEach(t)}function U(e,t){if(!N(e)){if(E(e))e.forEach(t);else if((e=>e instanceof FormData)(e))e.forEach((e,n)=>t(e,n));else for(let n in e)w.call(e,n)&&t(e[n],n)}}var W=function(e,...t){for(let n of t)for(let t in n)n[t]!==void 0&&(e[t]=n[t]);return e};function ta(e){let t=Object.keys(e),n=t.length,r=Array(n);for(;n--;)r[n]=[t[n],e[t[n]]];return r}var na=function(e){return function(...t){try{return e.apply(this,t)}catch(e){z.critical(`Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A.`),z.critical(e)}}},ra=function(e){let t={};return U(e,function(e,n){(j(e)&&e.length>0||P(e))&&(t[n]=e)}),t};function ia(e){let t=R({},e);for(let n of[`name`,`message`,`stack`,`cause`,`errors`])try{n in e&&(t[n]=e[n])}catch{}return t}var aa=[`herokuapp.com`,`vercel.app`,`netlify.app`];function oa(e){let t=e?.hostname;if(!j(t))return!1;let n=t.split(`.`).slice(-2).join(`.`);for(let e of aa)if(n===e)return!1;return!0}function G(e,t,n,r){let{capture:i=!1,passive:a=!0}=r??{};e?.addEventListener(t,n,{capture:i,passive:a})}function sa(e){return e.name===`ph_toolbar_internal`}var ca=e=>{if(r){try{let t=e+`=`,n=r.cookie.split(`;`).filter(e=>e.length);for(let e=0;n.length>e;e++){let r=n[e];for(;r.charAt(0)==` `;)r=r.substring(1,r.length);if(r.indexOf(t)===0)return decodeURIComponent(r.substring(t.length,r.length))}}catch{}return null}};Math.trunc||(Math.trunc=function(e){return 0>e?Math.ceil(e):Math.floor(e)}),Number.isInteger||(Number.isInteger=function(e){return P(e)&&isFinite(e)&&Math.floor(e)===e});var la=class e{constructor(e){if(this.bytes=e,e.length!==16)throw TypeError(`not 128-bit length`)}static fromFieldsV7(t,n,r,i){if(!Number.isInteger(t)||!Number.isInteger(n)||!Number.isInteger(r)||!Number.isInteger(i)||0>t||0>n||0>r||0>i||t>0xffffffffffff||n>4095||r>1073741823||i>4294967295)throw RangeError(`invalid field value`);let a=new Uint8Array(16);return a[0]=t/2**40,a[1]=t/2**32,a[2]=t/2**24,a[3]=t/2**16,a[4]=t/256,a[5]=t,a[6]=112|n>>>8,a[7]=n,a[8]=128|r>>>24,a[9]=r>>>16,a[10]=r>>>8,a[11]=r,a[12]=i>>>24,a[13]=i>>>16,a[14]=i>>>8,a[15]=i,new e(a)}toString(){let e=``;for(let t=0;this.bytes.length>t;t++)e=e+(this.bytes[t]>>>4).toString(16)+(15&this.bytes[t]).toString(16),t!==3&&t!==5&&t!==7&&t!==9||(e+=`-`);if(e.length!==36)throw Error(`Invalid UUIDv7 was generated`);return e}clone(){return new e(this.bytes.slice(0))}equals(e){return this.compareTo(e)===0}compareTo(e){for(let t=0;16>t;t++){let n=this.bytes[t]-e.bytes[t];if(n!==0)return Math.sign(n)}return 0}},ua=class{generate(){let e=this.generateOrAbort();if(!A(e))return e;{this.Ct=0;let e=this.generateOrAbort();if(A(e))throw Error(`Could not generate UUID after timestamp reset`);return e}}generateOrAbort(){let e=(()=>{let e=Date.now();return P(e)&&isFinite(e)?Math.min(Math.max(Math.floor(e),0),0xffffffffffff):0})();if(e>this.Ct)this.Ct=e,this.Mt();else{if(this.Ct>=e+1e4)return;this.It++,this.It>4398046511103&&(this.Ct++,this.Mt())}return la.fromFieldsV7(this.Ct,Math.trunc(this.It/2**30),this.It&2**30-1,this.Tt.nextUint32())}Mt(){this.It=1024*this.Tt.nextUint32()+(1023&this.Tt.nextUint32())}constructor(){this.Ct=0,this.It=0,this.Tt=new fa}},da=e=>{if(`u`>typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw Error(`no cryptographically strong RNG available`);for(let t=0;e.length>t;t++)e[t]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return e};e&&!A(e.crypto)&&crypto.getRandomValues&&(da=e=>crypto.getRandomValues(e));var fa=class{nextUint32(){return this.Rt.length>this.$t||(da(this.Rt),this.$t=0),this.Rt[this.$t++]}constructor(){this.Rt=new Uint32Array(8),this.$t=1/0}},pa,ma=()=>ha().toString(),ha=()=>(pa||=new ua).generate(),ga=``,_a=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i,va=null,K={Et(){if(!M(va))return va;if(va=!1,r)try{let e=`__ph_cookie_support_${ma()}`;K.At(e,`xyz`),va=ca(e)===`"xyz"`,K.Lt(e)}catch{va=!1}return va},Pt(e){z.error(`cookieStore error: `+e)},Ot:ca,Dt(e){let t;try{t=JSON.parse(K.Ot(e))||{}}catch{}return t},At(e,t,n,i,a){if(!r)return!1;try{let o=``,s=``,c=function(e,t){if(t){let t=function(e,t=r){if(ga)return ga;if(!t||[`localhost`,`127.0.0.1`].includes(e))return``;let n=e.split(`.`),i=Math.min(n.length,8),a=`dmn_chk_`+ma();for(;!ga&&i--;){let e=n.slice(i).join(`.`),r=a+`=1;domain=.`+e+`;path=/`;
1t.cookie=r+`;max-age=3`,t.cookie.includes(a)&&(t.cookie=r+`;max-age=0`,ga=e)}return ga}(e);if(!t){let n=(e=>{let t=e.match(_a);return t?t[0]:``})(e);n!==t&&z.info(`Warning: cookie subdomain discovery mismatch`,n,t),t=n}return t?`; domain=.`+t:``}return``}(r.location.hostname,i);if(n){let e=new Date;e.setTime(e.getTime()+864e5*n),o=`; expires=`+e.toUTCString()}a&&(s=`; secure`);let l=e+`=`+encodeURIComponent(JSON.stringify(t))+o+`; SameSite=Lax; path=/`+c+s;return l.length>3686.4&&z.warn(`cookieStore warning: large cookie, len=`+l.length),r.cookie=l,!0}catch{return!1}},Lt(e,t){if(r?.cookie)try{K.At(e,``,-1,t)}catch{return}}},ya=null,q={Et(){if(!M(ya))return ya;let t=!0;if(A(e))t=!1;else try{let e=`__mplssupport__`;q.At(e,`xyz`),q.Ot(e)!==`"xyz"`&&(t=!1),q.Lt(e)}catch{t=!1}return t||z.error(`localStorage unsupported; falling back to cookie store`),ya=t,t},Pt(e){z.error(`localStorage error: `+e)},Ot(t){try{return e?.localStorage.getItem(t)}catch(e){q.Pt(e)}return null},Dt(e){try{return JSON.parse(q.Ot(e))||{}}catch{}return null},At(t,n){try{return e?.localStorage.setItem(t,JSON.stringify(n)),!0}catch(e){q.Pt(e)}return!1},Lt(t){try{e?.localStorage.removeItem(t)}catch(e){q.Pt(e)}}},ba=[ai,Zr,Xr,$r,ei,ti,Ci,Si,bi],xa=[_r,gr,Ur,Wr,ki,Oi,Sr,H],Sa=e=>e+`_cpm`,Ca=[`__proto__`,`constructor`,`prototype`],wa=e=>{if(!O(e))return{};let t={};return Object.keys(e).forEach(n=>{Ca.indexOf(n)===-1&&(t[n]=e[n])}),t},Ta=(e,t=[])=>{let n={};return[...xa,...t].forEach(t=>{let r=e[t];A(r)||M(r)||r===``||(n[t]=r)}),n},Ea=e=>{let t=5381,n=2166136261;for(let r=0;e.length>r;r++){let i=e.charCodeAt(r);t=33*t^i,n=Math.imul(n^i,16777619)}return e.length.toString(36)+`.`+(t>>>0).toString(36)+`.`+(n>>>0).toString(36)},Da=(e,t)=>({p:t,f:Ea(JSON.stringify(e))}),Oa=(e,t)=>{if(!t)return{properties:[],isValid:!1};try{let n=K.Dt(Sa(e)),r=n?.f===Ea(t)&&E(n.p);return{properties:r?n.p:[],isValid:r}}catch{return{properties:[],isValid:!1}}},ka=(e,t)=>t+`|`+(K.Ot(Sa(e))||``),Aa={},ja={Et:()=>!0,Pt(e){z.error(`memoryStorage error: `+e)},Ot:e=>e in Aa?Aa[e]:null,Dt:e=>e in Aa?Aa[e]:null,At:(e,t)=>(Aa[e]=t,!0),Lt(e){delete Aa[e]}},Ma=null,J={Et(){if(!M(Ma))return Ma;if(Ma=!0,A(e))Ma=!1;else try{let e=`__support__`;J.At(e,`xyz`),J.Ot(e)!==`"xyz"`&&(Ma=!1),J.Lt(e)}catch{Ma=!1}return Ma},Pt(e){z.error(`sessionStorage error: `,e)},Ot(t){try{return e?.sessionStorage.getItem(t)}catch(e){J.Pt(e)}return null},Dt(e){try{return JSON.parse(J.Ot(e))||null}catch{}return null},At(t,n){try{return e?.sessionStorage.setItem(t,JSON.stringify(n)),!0}catch(e){J.Pt(e)}return!1},Lt(t){try{e?.sessionStorage.removeItem(t)}catch(e){J.Pt(e)}}},Na=class{constructor(e){this._instance=e}get Ir(){return this._instance.config}get consent(){return this.Ao()?0:this.Fo}isOptedOut(){return this.Ir.cookieless_mode===`always`||this.isRejected()||this.consent===-1&&this.Ir.cookieless_mode===`on_reject`}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===0}isRejected(){return this.consent===0||this.consent===-1&&this.Ir.opt_out_capturing_by_default}optInOut(e){this.Oo.At(this.Do,+!!e,this.Ir.cookie_expiration,this.Ir.cross_subdomain_cookie,this.Ir.secure_cookie)}reset(){this.Oo.Lt(this.Do,this.Ir.cross_subdomain_cookie)}get Do(){let{token:e,opt_out_capturing_cookie_prefix:t,consent_persistence_name:n}=this._instance.config;return n||(t?t+e:`__ph_opt_in_out_`+e)}get Fo(){let e=this.Oo.Ot(this.Do);return le(e)?1:y(ue,e)?0:-1}get Oo(){let e=this.Ir.opt_out_capturing_persistence_type,t=e===`localStorage`?q:K,n=t.Et()?t:ja;if(!this.Lo||this.Lo!==n){this.Lo=n;let t=e===`localStorage`?K:q;t.Ot(this.Do)&&(this.Lo.Ot(this.Do)||this.optInOut(le(t.Ot(this.Do))),t.Lt(this.Do,this.Ir.cross_subdomain_cookie))}return this.Lo}Ao(){return!!this.Ir.respect_dnt&&[n?.doNotTrack,n?.msDoNotTrack,f.doNotTrack,n?.globalPrivacyControl].some(e=>le(e))}};function Pa(e,t){var n;let r=e==null||(n=e.config)==null?void 0:n.get_current_url;if(!D(r))return t;try{let e=r(t);return j(e)&&e?e:t}catch(e){return z.error(`Error in get_current_url, falling back to window.location.href`,e),t}}function Fa(e){return e instanceof Element&&(e.id===`__POSTHOG_TOOLBAR__`||!!e.closest?.call(e,`.toolbar-global-fade-container`))}function Ia(e){return!!e&&e.nodeType===1}function Y(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function La(e){return!!e&&e.nodeType===3}function Ra(e){return!!e&&e.nodeType===11&&Ia(e.host)}function za(e){return e?b(e).split(/\s+/):[]}function Ba(t,n){let r=function(t){var n;let r=e==null||(n=e.location)==null?void 0:n.href;return A(r)?void 0:Pa(t,r)}(n);return!!(r&&t&&t.some(e=>r.match(e)))}function Va(e){let t=``;switch(typeof e.className){case`string`:t=e.className;break;case`object`:t=(e.className&&`baseVal`in e.className?e.className.baseVal:null)||e.getAttribute(`class`)||``;break;default:t=``}return za(t)}function Ha(e){return N(e)?null:b(e).split(/(\s+)/).filter(e=>mo(e)).join(``).replace(/[\r\n]/g,` `).replace(/[ ]+/g,` `).substring(0,255)}function Ua(e){let t=``;return io(e)&&!ao(e)&&e.childNodes&&e.childNodes.length&&U(e.childNodes,function(e){La(e)&&e.textContent&&(t+=Ha(e.textContent)??``)}),b(t)}function Wa(e){return A(e.target)?e.srcElement||null:e.target?.shadowRoot?e.composedPath()[0]||null:e.target||null}var Ga=[`a`,`button`,`form`,`input`,`select`,`textarea`,`label`];function Ka(e,t){let n=e.matches||e.matchesSelector||e.msMatchesSelector||e.mozMatchesSelector||e.webkitMatchesSelector||e.oMatchesSelector;try{return!!n&&n.call(e,t)}catch{return!1}}function qa(e,t){if(A(t))return!0;for(let n of e)if(t.some(e=>Ka(n,e)))return!0;return!1}function Ja(e){let t=e.parentNode;return!(!t||!Ia(t))&&t}var Ya=[`.ph-no-autocapture`,`[data-ph-no-autocapture]`],Xa=[`next`,`previous`,`prev`,`>`,`<`],Za=[...Xa,`+`,`-`,`â`,`â`],Qa=(e,t)=>/[a-z0-9]/i.test(t)?e.includes(t):e===t,$a=[`.ph-no-rageclick`,`.ph-no-capture`],eo=[``,`text`,`search`,`email`,`password`,`url`,`tel`,`number`];function to(t,n){if(!e||no(t))return!1;let r,i,a;var o;if(F(n)?(r=!!n&&$a,i=void 0,a=!1):(r=n?.css_selector_ignorelist??$a,i=n?.content_ignorelist,a=(o=n?.ignore_text_selection)!=null&&o),!1===r||a&&function(e){return!(!e||!Ia(e))&&(!!Y(e,`textarea`)||(Y(e,`input`)?y(eo,(e.getAttribute(`type`)||``).toLowerCase()):function(e){if(e.isContentEditable)return!0;let t=e.getAttribute?.call(e,`contenteditable`);return t===`true`||t===``}(e)))}(t))return!1;let{targetElementList:s}=ro(t,!1);return!function(e,t){if(!1===e||A(e))return!1;let n;if(!0===e)n=Xa;else{if(!E(e))return!1;if(e.length>10)return z.error(`[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching.`),!1;n=e.map(e=>e.toLowerCase())}return t.some(({safeText:e,ariaLabel:t})=>n.some(n=>
1Qa(e,n)||Qa(t,n)))}(i,s.map(e=>({safeText:Ua(e).toLowerCase(),ariaLabel:e.getAttribute(`aria-label`)?.toLowerCase().trim()||``})))&&!qa(s,r)}var no=e=>!e||Y(e,`html`)||!Ia(e),ro=(t,n)=>{if(!e||no(t))return{parentIsUsefulElement:!1,targetElementList:[]};let r=!1,i=[t],a=t;for(;a.parentNode&&!Y(a,`body`);){if(Ra(a.parentNode)){i.push(a.parentNode.host),a=a.parentNode.host;continue}let t=Ja(a);if(!t)break;if(n||Ga.indexOf(t.tagName.toLowerCase())>-1)r=!0;else try{let n=e.getComputedStyle(t);n&&n.getPropertyValue(`cursor`)===`pointer`&&(r=!0)}catch{}i.push(t),a=t}return{parentIsUsefulElement:r,targetElementList:i}};function io(e){let t=new Set,n=0;for(let r=e;r.parentNode&&!Y(r,`body`);r=r.parentNode){if(n++>=1e3||t.has(r))return!1;t.add(r);let e=Va(r);if(y(e,`ph-sensitive`)||y(e,`ph-no-capture`))return!1}if(y(Va(e),`ph-include`))return!0;let r=e.type||``;if(j(r))switch(r.toLowerCase()){case`hidden`:case`password`:return!1}let i=e.name||e.id||``;return!j(i)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(i.replace(/[^a-zA-Z0-9]/g,``))}function ao(e){return!!(Y(e,`input`)&&![`button`,`checkbox`,`submit`,`reset`].includes(e.type)||Y(e,`select`)||Y(e,`textarea`)||e.getAttribute(`contenteditable`)===`true`)}var oo=RegExp(`^(?:(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}))$`),so=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,co=[16,15,14,13],lo=RegExp(`^(\\d{3}-?\\d{2}-?\\d{4})$`),uo=RegExp(`(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))`,`g`),fo=/[0-9A-Za-z_]/;function po(e){let t=0,n=!1;for(let r=e.length-1;r>=0;r--){let i=e.charCodeAt(r)-48;n&&(i*=2,i>9&&(i-=9)),t+=i,n=!n}return t%10==0}function mo(e,t=!0){return!(N(e)||j(e)&&(e=b(e),(t?oo.test((e||``).replace(/[- ]/g,``)):function(e){let t;for(so.lastIndex=0;t=so.exec(e);){let e=t[2];if(!e)continue;let n=e.replace(/[- ]/g,``);for(let e=0;n.length>e;e++)for(let t of co){let r=e+t;if(n.length>=r){let t=n.slice(e,r);if(oo.test(t)&&po(t))return!0}}}return!1}(e))||(t?lo.test(e):function(e){let t;for(uo.lastIndex=0;t=uo.exec(e);){let e=t[1],n=t[3];if(!(e&&n&&fo.test(e)&&fo.test(n)))return!0}return!1}(e))))}function ho(e){let t=Ua(e);return t=`${t} ${go(e)}`.trim(),mo(t)?t:``}function go(e){let t=``;return e&&e.childNodes&&e.childNodes.length&&U(e.childNodes,function(e){if(e&&e.tagName?.toLowerCase()===`span`)try{let n=Ua(e);t=`${t} ${n}`.trim(),e.childNodes&&e.childNodes.length&&(t=`${t} ${go(e)}`.trim())}catch(e){z.error(`[AutoCapture]`,e)}}),t}function _o(e){return e.replace(/"|\\"/g,`\\"`)}function vo(e){let t=e.attr__class;if(t)return E(t)?t:za(t)}var yo=B(`[Dead Clicks]`),bo=()=>!0,xo=e=>{let t=!!e.instance.persistence?.get_property(Mr),n=e.instance.config.capture_dead_clicks;return F(n)?n:!!O(n)||t},So=class{get lazyLoadedDeadClicksAutocapture(){return this.No}constructor(e,t,n){this.instance=e,this.isEnabled=t,this.onCapture=n,this.startIfEnabledOrStop()}onRemoteConfig(e){if(!e.ok)return;let t=e.config;`captureDeadClicks`in t&&(this.instance.persistence&&this.instance.persistence.register({[Mr]:t.captureDeadClicks}),this.startIfEnabledOrStop())}startIfEnabledOrStop(){this.isEnabled(this)?this.qo(()=>{this.jo()}):this.stop()}qo(e){var t,n;f.__PosthogExtensions__?.initDeadClicksAutocapture?e():(t=f.__PosthogExtensions__)==null||(n=t.loadExternalDependency)==null||n.call(t,this.instance,`dead-clicks-autocapture`,t=>{t?yo.error(`failed to load script`,t):e()})}jo(){if(r){if(!this.No&&f.__PosthogExtensions__?.initDeadClicksAutocapture){let e=O(this.instance.config.capture_dead_clicks)?R({},this.instance.config.capture_dead_clicks):{};e.__onCapture=this.onCapture,this.onCapture&&(e.capture_dead_swipes=!1),this.No=f.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,e),this.No.start(r),yo.info(`starting...`)}}else yo.error("`document` not found. Cannot start.")}stop(){this.No&&(this.No.stop(),this.No=void 0,yo.info(`stopping...`))}},Co=B(`[SegmentIntegration]`);function wo(e,t,n=!0){let r=e.config.segment;if(!r)return t();let{analytics:i,filterProperties:a}=(e=>D(e.register))(o=r)?{analytics:o}:o;var o;(function(e,t,n,r){let i=t=>{let i=()=>t.anonymousId()||ma();e.config.get_device_id=i,r&&t.id()&&(e.register({distinct_id:t.id(),$device_id:i()}),e.persistence.set_property(H,Ki)),n(r?void 0:t.anonymousId()||void 0)},a=t.user();`then`in a&&D(a.then)?a.then(i):i(a)})(e,i,n=>{i.register(((e,t,{filterProperties:n}={})=>{typeof Promise<`u`&&Promise.resolve||Co.warn(`This browser does not have Promise support, and can not use the segment integration`);let r=(r,i)=>{if(!i)return r;let a=!!t&&r.event.anonymousId===t&&!r.event.userId;a||r.event.userId||r.event.anonymousId===e.get_distinct_id()||(Co.info(`No userId set, resetting PostHog`),e.reset()),a||(t=void 0),r.event.userId&&r.event.userId!==e.get_distinct_id()&&(Co.info(`UserId set, identifying with PostHog`),e.identify(r.event.userId)
1);let o=e.calculateEventProperties(i,r.event.properties);if(!N(n)){let e=r.event.properties||{},t={};for(let n of Object.keys(o))w.call(e,n)||(t[n]=o[n]);let i=((e,t)=>{let n=E(e)?e:[e],r=R({},t);for(let e of n)try{if(r=e(r),N(r))return null}catch(e){return Co.error(`Error in Segment filterProperties:`,e),null}return r})(n,t);if(N(i))return r;o=i}return r.event.properties=Object.assign({},o,r.event.properties),r};return{name:`PostHog JS`,type:`enrichment`,version:`1.0.0`,isLoaded(){return!0},load(){return Promise.resolve()},track(e){return r(e,e.event.event)},page(e){return r(e,Xi)},identify(e){return r(e,Qi)},screen(e){return r(e,`$screen`)}}})(e,n,{filterProperties:a})).then(()=>{t()},e=>{Co.error(`Failed to register the Segment integration`,e),t()})},n)}var To=`posthog-js`;function Eo(e,{organization:t,projectId:n,prefix:r,severityAllowList:i=[`error`],sendExceptionsToPostHog:a=!0}={}){return o=>{if(i!==`*`&&!i.includes(o.level)||!e.__loaded)return o;o.tags||={};let s=e.requestRouter.endpointFor(`ui`,`/project/${e.config.token}/person/${e.get_distinct_id()}`);o.tags[`PostHog Person URL`]=s,e.sessionRecordingStarted()&&(o.tags[`PostHog Recording URL`]=e.get_session_replay_url({withTimestamp:!0}));let c=o.exception?.values||[],l=c.map(e=>R(R({},e),{},{stacktrace:e.stacktrace?R(R({},e.stacktrace),{},{type:`raw`,frames:(e.stacktrace.frames||[]).map(e=>R(R({},e),{},{platform:`web:javascript`}))}):void 0})),u={$exception_message:c[0]?.value||o.message,$exception_type:c[0]?.type,$exception_level:o.level,$exception_list:l,$sentry_event_id:o.event_id,$sentry_exception:o.exception,$sentry_exception_message:c[0]?.value||o.message,$sentry_exception_type:c[0]?.type,$sentry_tags:o.tags};var d;return t&&n&&(u.$sentry_url=(r||`https://sentry.io/organizations/`)+t+`/issues/?project=`+n+`&query=`+o.event_id),a&&((d=e.exceptions)==null||d.sendExceptionEvent(u)),o}}var Do=class{constructor(e,t,n,r,i,a){this.name=To,this.setupOnce=function(o){o(Eo(e,{organization:t,projectId:n,prefix:r,severityAllowList:i,sendExceptionsToPostHog:a==null||a}))}}},Oo=class{constructor(e){this.Bo=(e,t,n)=>{n&&(n.noSessionId||n.activityTimeout||n.sessionPastMaximumLength||n.crossTabAdoption)&&(z.info(`[PageViewManager] Session rotated, clearing pageview state`,{sessionId:e,changeReason:n}),this.Ho=void 0,this._instance.scrollManager.resetContext())},this._instance=e,this.zo()}zo(){this.Uo=this._instance.sessionManager?.onSessionId(this.Bo)}destroy(){var e;(e=this.Uo)==null||e.call(this),this.Uo=void 0}doPageView(t,n){let r=this.Wo(t,n);return this.Ho={pathname:e?.location.pathname??``,pageViewId:n,timestamp:t},this._instance.scrollManager.resetContext(),r}doPageLeave(e){return this.Wo(e,this.Ho?.pageViewId)}doEvent(){return{$pageview_id:this.Ho?.pageViewId}}Wo(e,t){let n=this.Ho;if(!n)return{$pageview_id:t};let r={$pageview_id:t,$prev_pageview_id:n.pageViewId},i=this._instance.scrollManager.getContext();if(i&&!this._instance.config.disable_scroll_properties){let{maxScrollHeight:e,lastScrollY:t,maxScrollY:n,maxContentHeight:a,lastContentY:o,maxContentY:s}=i;if(!(A(e)||A(t)||A(n)||A(a)||A(o)||A(s))){e=Math.ceil(e),t=Math.ceil(t),n=Math.ceil(n),a=Math.ceil(a),o=Math.ceil(o),s=Math.ceil(s);let i=e>1?me(t/e,0,1,z):1,c=e>1?me(n/e,0,1,z):1,l=a>1?me(o/a,0,1,z):1,u=a>1?me(s/a,0,1,z):1;r=W(r,{$prev_pageview_last_scroll:t,$prev_pageview_last_scroll_percentage:i,$prev_pageview_max_scroll:n,$prev_pageview_max_scroll_percentage:c,$prev_pageview_last_content:o,$prev_pageview_last_content_percentage:l,$prev_pageview_max_content:s,$prev_pageview_max_content_percentage:u})}}return n.pathname&&(r.$prev_pageview_pathname=n.pathname),n.timestamp&&(r.$prev_pageview_duration=(e.getTime()-n.timestamp.getTime())/1e3),r}},ko=[`flags`,`surveys`],Ao={[hr]:{exposure:`hidden`},[yr]:{exposure:`hidden`},[br]:{exposure:`hidden`},[Tr]:{exposure:`hidden`},[Sr]:{exposure:`hidden`},[wr]:{exposure:`hidden`},[Er]:{exposure:`event`},[Dr]:{exposure:`hidden`},[Pr]:{exposure:`hidden`},[Or]:{exposure:`event`},[kr]:{exposure:`hidden`},[Ar]:{exposure:`event`},[jr]:{exposure:`event`},[Mr]:{exposure:`event`},[Nr]:{exposure:`hidden`},[Fr]:{exposure:`event`},[Ir]:{exposure:`hidden`},[Lr]:{exposure:`hidden`},[Ur]:{exposure:`hidden`},[Wr]:{exposure:`event`},[Rr]:{exposure:`event`,shouldSkipFromEventProperties:e=>M(e)},[Gr]:{exposure:`event`},[Kr]:{exposure:`event`},[qr]:{exposure:`event`},[Jr]:{exposure:`event`},[Yr]:{exposure:`hidden`},[Xr]:{exposure:`hidden`,storageGroup:`flags`},[Zr]:{exposure:`hidden`,storageGroup:`flags`},[Qr]:{exposure:`hidden`},[$r]:{exposure:`hidden`,storageGroup:`flags`}
1,[ei]:{exposure:`hidden`,storageGroup:`flags`},[ti]:{exposure:`hidden`,storageGroup:`flags`,volatile:!0},[ni]:{exposure:`hidden`,storageGroup:`flags`},[ri]:{exposure:`hidden`},[ii]:{exposure:`hidden`},[ai]:{exposure:`hidden`},[oi]:{exposure:`hidden`},[ci]:{exposure:`hidden`,storageGroup:`surveys`},[li]:{exposure:`hidden`,storageGroup:`surveys`,volatile:!0},[ui]:{exposure:`event`},[di]:{exposure:`hidden`},[fi]:{exposure:`hidden`},[pi]:{exposure:`hidden`},[mi]:{exposure:`hidden`},[hi]:{exposure:`hidden`},[gi]:{exposure:`event`},[_i]:{exposure:`event`},[vi]:{exposure:`event`},[yi]:{exposure:`event`},[bi]:{exposure:`hidden`},[xi]:{exposure:`hidden`},[si]:{exposure:`event`},[Si]:{exposure:`hidden`},[Ci]:{exposure:`hidden`,storageGroup:`flags`,volatile:!0},[H]:{exposure:`hidden`},[wi]:{exposure:`hidden`},[Ti]:{exposure:`hidden`},[Ei]:{exposure:`hidden`},[Di]:{exposure:`hidden`},[Oi]:{exposure:`hidden`},[ki]:{exposure:`hidden`},[zr]:{exposure:`event`},[Br]:{exposure:`event`},[Vr]:{exposure:`event`},[Hr]:{exposure:`event`},[Mi]:{exposure:`event`},[Ni]:{exposure:`event`},[Pi]:{exposure:`event`},[Fi]:{exposure:`event`},[Ii]:{exposure:`event`},[Li]:{exposure:`event`},[Ri]:{exposure:`event`},[zi]:{exposure:`event`},[Bi]:{exposure:`event`},[Vi]:{exposure:`event`},[Hi]:{exposure:`event`},[Ui]:{exposure:`event`}},jo=[[`$posthog_sr_group_event_trigger_`,{exposure:`hidden`}],[`$posthog_sr_group_url_trigger_`,{exposure:`hidden`}],[`$posthog_sr_group_sampling_`,{exposure:`hidden`}]],X=e=>{let t=Ao[e];if(t)return t;for(let[t,n]of jo)if(e.indexOf(t)===0)return n},Mo=(e,t)=>{try{let n;return JSON.stringify(e,(e,t)=>ae(t)?(n??=new WeakMap,n.has(t)||n.set(t,ia(t)),n.get(t)):typeof t==`bigint`?t.toString():t,t)}catch{return S(e)}},No=e=>{let t=r?.createElement(`a`);return A(t)?null:(t.href=e,t)},Po=function(e,t){let n=((e.split(`#`)[0]||``).split(/\?(.*)/)[1]||``).replace(/^\?+/g,``).split(`&`),r;for(let e=0;n.length>e;e++){let i=n[e].split(`=`);
1if(i[0]===t){r=i;break}}if(!E(r)||2>r.length)return``;{let e=r[1];try{e=decodeURIComponent(e)}catch{z.error(`Skipping decoding for malformed query param: `+e)}return e.replace(/\+/g,` `)}},Fo=function(e,t,n){if(!e||!t||!t.length)return e;let r=e.split(`#`),i=r[1],a=(r[0]||``).split(`?`),o=a[1],s=a[0],c=(o||``).split(`&`),l=[];for(let e=0;c.length>e;e++){let r=c[e].split(`=`);E(r)&&(t.includes(r[0])?l.push(r[0]+`=`+n):l.push(c[e]))}let u=s;return o!=null&&(u+=`?`+l.join(`&`)),i!=null&&(u+=`#`+i),u},Io=function(e,t){let n=e.match(RegExp(t+`=([^&]*)`));return n?n[1]:null},Lo=(e,t)=>e>=t&&u(),Ro=(e,t,n,r)=>{if(e===0){if(u()){let e=t+1;return e===n&&r(),e}return t}return 0},zo=[`gclid`,`gclsrc`,`dclid`,`gbraid`,`wbraid`,`fbclid`,`msclkid`,`twclid`,`li_fat_id`,`igshid`,`ttclid`,`rdt_cid`,`epik`,`qclid`,`sccid`,`irclid`,`_kx`],Bo=[`utm_source`,`utm_medium`,`utm_campaign`,`utm_content`,`utm_term`,`gad_source`,`mc_cid`,...zo],Vo=`<masked>`,Ho=[`li_fat_id`];function Uo(e,t,n){if(!r)return{};let i=t?[...zo,...n||[]]:[],a=Wo(Fo(r.URL,i,Vo),e);return W(function(){let e={};return U(Ho,function(t){let n=ca(t);e[t]=n||null}),e}(),a)}function Wo(e,t){let n=Bo.concat(t||[]),r={};return U(n,function(t){let n=Po(e,t);r[t]=n||null}),r}function Go(e){let t=function(e){return e?e.search(`https?://(.*)google.([^/?]*)`)===0?`google`:e.search(`https?://(.*)bing.com`)===0?`bing`:e.search(`https?://(.*)yahoo.com`)===0?`yahoo`:e.search(`https?://(.*)duckduckgo.com`)===0?`duckduckgo`:null:null}(e),n=t==`yahoo`?`p`:`q`,i={};if(!M(t)){i.$search_engine=t;let e=r?Po(r.referrer,n):``;e.length&&(i.ph_keyword=e)}return i}function Ko(){return navigator.language||navigator.userLanguage}function qo(){let e=Ko();return typeof e==`string`?e.split(`-`)[0]:void 0}var Jo=`$direct`;function Yo(){return r?.referrer||Jo}function Xo(e,t,n=!1){let r=e?[...zo,...t||[]]:[],a=(n?Ot(i?.href):i?.href)?.substring(0,1e3);return{r:Yo().substring(0,1e3),u:a?Fo(a,r,Vo):void 0}}function Zo(e,t=!1){let{r:n,u:r}=e,i=t?Ot(r):r,a={$referrer:n,$referring_domain:n==null?void 0:n==Jo?Jo:No(n)?.host};if(i){a.$current_url=i;let e=No(i);a.$host=e?.host,a.$pathname=e?.pathname,W(a,Wo(i))}return n&&W(a,Go(n)),a}function Qo(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function $o(){try{return new Date().getTimezoneOffset()}catch{return}}var es={flags:Ci,surveys:li},ts=[`cookie`,`localstorage`,`localstorage+cookie`,`sessionstorage`,`memory`],ns=e=>`${e}_cookie_identity_change_pending`,rs=e=>{let t=``,n=0;for(let r of e){let e=encodeURIComponent(JSON.stringify(r).slice(1,-1)).length;if(n+e>1e3)break;t+=r,n+=e}return t},Z=`main`,is=[Xr,Zr,$r,ei,ti,Ci,ni,ai],as=e=>is.indexOf(e)!==-1,os=[Sr,wr],ss=e=>os.indexOf(e)!==-1,cs=(e,t)=>{try{return JSON.stringify(e)===JSON.stringify(t)}catch{return e===t}},ls=e=>{if(!e)return{};let t=JSON.parse(e);return O(t)?t:{}},us=(e,t)=>{U(e,(n,r)=>{let i=X(r);i&&i.exposure!==`event`||{}.hasOwnProperty.call(t,r)||delete e[r]})},ds=class{constructor(t,n,r=!0){if(this.Vo={},this.Go=!1,this.Zo=!1,this.Qo=!1,this.Jo=!1,this.Ko=!1,this.Xo=new Map,this.Yo=!1,this.tl=!1,this.el=!1,this.il=new Set,this.nl=new Set,this.Ir=t,this.sl=r,this.props={},this.rl=void 0,this.ol=(e=>{let t=``;return e.token&&(t=e.token.replace(/\+/g,`PL`).replace(/\//g,`SL`).replace(/=/g,`EQ`)),e.persistence_name?`ph_`+e.persistence_name:`ph_`+t+`_posthog`})(t),this.Oo=this.ll(t),this.Qo=this.al(t),this.load(),this.ul(),t.debug&&z.info(`Persistence loaded`,t.persistence,R({},this.props)),this.update_config(t,t,n),this.save(),e){let t=()=>this.flush();G(e,`beforeunload`,t,{capture:!1}),G(e,`pagehide`,t,{capture:!1}),this.hl=t=>{if(this.Go&&(!t.storageArea||t.storageArea===e?.localStorage)&&t.key){if(t.key!==this.ol){if(this.Qo){let e=ko.find(e=>t.key===this.cl(e));e&&this.dl(t.key,e)}}else this.dl(t.key,Z)}},G(e,`storage`,this.hl)}}markCrossTabFeatureFlagChanges(e){Object.entries(e).forEach(([e,t])=>{let n=this.Xo.get(e);if(!as(e)||!0===n)return;if(!0===t)return void this.vl(e,!0);let r=new Set(n||[]);t.forEach(e=>r.add(e)),r.size&&this.vl(e,r)})}onCrossTabFeatureFlagChange(e){return this.nl.add(e),()=>this.nl.delete(e)}destroy(){this.hl&&e&&(e.removeEventListener(`storage`,this.hl),this.hl=void 0),this.nl.clear()}dl(e,t,n=!0){if(this.mi)return!1;let r,i;try{if(i=q.Ot(e),M(i)){let e=this.fl(t);
1return e.storageValue=null,t!==Z&&(e.persisted=!1),!1}r=ls(i)}catch{return!1}let a=t===Z?r:q.Dt(this.ol);if(a&&this.pl(a))return!1;let o=this.gl(r,t,n);return t===Z&&this.Qo&&!cs(this.ml().main,r)||this.yl(r,t,!0,i),o}pl(e){let t=this.props[gr],n=e[gr];return!A(t)&&!A(n)&&t!==n}yl(e,t,n,r){let i=this.fl(t);i.storageValue=r,t!==Z&&(i.persisted=n);try{i.fingerprint=this.bl(e,t)}catch{i.fingerprint=void 0}}gl(e,t,n){let r=!1;return is.forEach(n=>{let i=X(n)?.storageGroup;if(t===Z&&this.Qo&&i||t!==Z&&i!==t)return;let a=n in e,o=this._l(n,a?e[n]:void 0),s=this.Xo.has(n)?n in this.props:a;s===n in this.props&&cs(o,this.props[n])||(s?this.wl(n,o,!1):this.kl(n,!1),r=!0)}),r&&n&&this.nl.forEach(e=>e()),r}Sl(){if(!this.Go)return!1;try{this.el=!1;let e=q.Ot(this.ol),t=this.fl(Z),n,r=!1,i=!1;if(e!==t.storageValue){if(M(e))t.storageValue=null;else{if(n=ls(e),this.el=!this.tl&&this.pl(n),this.el)return!1;i=this.gl(n,Z,!1),!this.Qo||cs(this.ml().main,n)?this.yl(n,Z,!0,e):t.storageValue=e,r=!0}}return this.Qo&&ko.forEach(e=>{let t=q.Ot(this.cl(e)),a=this.fl(e),o=n||{},s=r&&is.some(t=>X(t)?.storageGroup===e&&t in o);if(t===a.storageValue&&!s)return;if(M(t))return a.storageValue=null,a.persisted=!1,void(s&&(i=this.gl(o,e,!1)||i));let c=ls(t);i=this.gl(c,e,!1)||i,this.yl(c,e,!0,t)}),i}catch{return!1}}vl(e,t){this.Xo.set(e,t);let n=X(e);n!=null&&n.volatile||(this.fl((this.Qo?n?.storageGroup:void 0)||Z).fingerprint=void 0,this.xl(e))}Cl(){is.forEach(e=>this.Xo.set(e,!0))}ul(){if(this.Go)try{let e=q.Ot(this.ol),t=ls(e);this.fl(Z).storageValue=e,is.forEach(e=>{let n=this.Qo?X(e)?.storageGroup:void 0,r=n?q.Ot(this.cl(n)):null;if(n){let e=this.fl(n);e.storageValue=r,e.persisted=!M(r)}let i=n&&!M(r)?ls(r):t;e in this.props?this.$l(e,i[e],this.props[e]):e in i&&this.vl(e,!0)})}catch{}}_l(e,t){let n=this.Xo.get(e);if(!n)return t;if(!0===n)return this.props[e];if(e===`$active_feature_flags`){let r=new Set(E(t)?t:[]),i=new Set(E(this.props[e])?this.props[e]:[]);return n.forEach(e=>i.has(e)?r.add(e):r.delete(e)),Array.from(r)}let r=O(t)?R({},t):{},i=O(this.props[e])?this.props[e]:{};return n.forEach(e=>{e in i?r[e]=i[e]:delete r[e]}),r}$l(e,t,n){if(!as(e))return;let r=this.Xo.get(e);if(!0===r)return;let i=t;if(this.Go)try{let t=this.Qo?X(e)?.storageGroup:void 0,n=t?this.cl(t):this.ol;i=ls(q.Ot(n))[e]}catch{}let a=new Set(r||[]);if(e===`$active_feature_flags`){if(!A(t)&&!E(t)||!A(i)&&!E(i)||!E(n))return void this.vl(e,!0);let r=new Set(t||[]),o=new Set(i||[]),s=new Set(n);new Set([...r,...s]).forEach(e=>{r.has(e)!==s.has(e)&&a.add(e)}),a.forEach(e=>{o.has(e)===s.has(e)&&a.delete(e)})}
1else{if(!O(n))return void(cs(i,n)?this.Xo.delete(e):this.vl(e,!0));{if(!A(t)&&!O(t)||A(t)&&k(n)&&A(i))return void this.vl(e,!0);let r=O(t)?t:{},o=O(i)?i:{};new Set([...Object.keys(r),...Object.keys(n)]).forEach(e=>{e in r==e in n&&cs(r[e],n[e])||a.add(e)}),a.forEach(e=>{e in o==e in n&&cs(o[e],n[e])&&a.delete(e)})}}a.size?this.vl(e,a):this.Xo.delete(e)}Tl(){let e=this.Ir?.persistence_save_debounce_ms;return P(e)&&e>0?e:0}Il(e){if(this.Ir.cookieWinsOnConflict&&this.Ir.persistence.toLowerCase()===`localstorage+cookie`){if(e)try{let t=Ta(e,this.Ir.cookie_persisted_properties||[]),n=Da(t,this.Ir.cookie_persisted_properties||[]),r=JSON.stringify(t)+`|`+JSON.stringify(n),i=K.Ot(this.ol)||void 0;i&&ka(this.ol,i)===r&&(this.Ml=r,this.El=i)}catch{}else try{let e=K.Ot(this.ol)||void 0;this.Ml=e?ka(this.ol,e):void 0,this.El=e}catch{}}}syncCookieProperties(){return this.Pl(this.Ir)}Pl(e,t=!1){if(this.mi&&!t||this.Ko||!e.cookieWinsOnConflict||e.persistence.toLowerCase()!==`localstorage+cookie`)return!1;let n;try{n=K.Ot(this.ol)||void 0}catch{}if(!n||n===this.El)return!1;let r=ka(this.ol,n),i;try{i=wa(JSON.parse(n))}catch{return!1}if((K.Ot(this.ol)||void 0)!==n)return!1;this.Ml=r,this.El=n;let a=Oa(this.ol,n),o=[...xa,...a.properties],s={};
1if(Object.keys(i).forEach(e=>{let t=i[e];(A(t)||M(t)||t===``||e===`$user_state`&&t!==`anonymous`&&t!==`identified`)&&(s[e]=!0,delete i[e])}),k(i))return!1;let c=`distinct_id`in i||i.$user_state===`anonymous`||i.$user_state===`identified`,l=this.props,u=l[gr],d=l[H],f=W({},l);[...xa,...e.cookie_persisted_properties||[]].forEach(e=>{if(o.indexOf(e)!==-1&&!(e in i)&&!s[e]&&(c||e!==`distinct_id`&&e!==`$user_state`)){let t=f[e];(a.isValid||xa.indexOf(e)===-1||!1!==t&&t!==0)&&delete f[e]}}),this.props=W(f,i),is.forEach(e=>{let t=e in this.props;e in l===t&&cs(l[e],this.props[e])||(t?this.$l(e,l[e],this.props[e]):this.vl(e,!0))}),!c||`$user_state`in i||`$user_state`in this.props||this.wl(H,Gi);let p=this.props[gr],m=this.props[H];return!c||p===u&&m===d||(this.tl=!0,this.Jo=!0,J.At(ns(this.ol),!0),this.kl(ai),this.kl(Zr),this.kl(Xr),this.kl($r),this.kl(ei),this.kl(ti),this.kl(Ci),this.kl(Si),this.kl(bi),m!==`anonymous`||d!==`identified`&&i.$user_state!==`anonymous`&&(A(u)||p===u)||(us(this.props,i),this.kl(oi)),m===`identified`?this.props.$user_id=p:delete this.props.$user_id,this.kl(yr)),!0}
1consumeCookieIdentityChange(){let e=ns(this.ol),t=this.Jo||!!J.Ot(e);return this.Jo=!1,t&&J.Lt(e),t}Rl(e=!1){return!(this.Ko||this.mi&&!e||!this.Ir.cookieWinsOnConflict||this.Ir.persistence.toLowerCase()!==`localstorage+cookie`||(this.Ko=!0,0))}Al(){this.Ko&&(A(this.Fl)||(clearTimeout(this.Fl),this.Fl=void 0),delete this.Vo[Z],this.Ol(!0))}Dl(e=!0){if(this.Ko)try{e?this.Al():A(this.Fl)||(clearTimeout(this.Fl),this.Fl=void 0)}finally{this.Ko=!1}}isDisabled(){return!!this.mi}ll(t){ts.indexOf(t.persistence.toLowerCase())===-1&&(z.critical(`Unknown persistence type `+t.persistence+`; falling back to localStorage+cookie`),t.persistence=`localStorage+cookie`);let n=((t=[],n=!1)=>{let r=[...xa,...t];return R(R({},q),{},{Dt(e){try{let t,i={};try{t=K.Ot(e)||void 0,i=t?wa(JSON.parse(t)):{}}catch{}let a=JSON.parse(q.Ot(e)||`{}`),o;if(n){let n=Oa(e,t),s=[...xa,...n.properties],c={};Object.keys(i).forEach(e=>{let t=i[e];M(t)||t===``||e===`$user_state`&&t!==`anonymous`&&t!==`identified`||(c[e]=t)});let l=`distinct_id`in c||c.$user_state===`anonymous`||c.$user_state===`identified`;if(Object.keys(c).length>0){let e=a[gr],t=a.$user_state??Gi;r.forEach(e=>{if(s.indexOf(e)!==-1&&!(e in i)&&(l||e!==`distinct_id`&&e!==`$user_state`)){let t=a[e];(n.isValid||xa.indexOf(e)===-1||!1!==t&&t!==0)&&delete a[e]}}),!l||`$user_state`in i||`$user_state`in a||(a[H]=Gi),!l||(`distinct_id`in c?c[gr]:a[gr])===e&&(`$user_state`in c?c[H]:a[H])===t||(ba.forEach(e=>delete a[e]),c.$user_state===`identified`&&`distinct_id`in c?a.$user_id=c[gr]:delete a.$user_id,c.$user_state!==`identified`&&(delete a[si],delete a[oi]),delete a.__alias)}o=W(a,c)}else o=W(i,a);return q.At(e,o),o}catch{}return null},At(e,r,i,a,o,s){let c=q.At(e,r,void 0,void 0,s);try{let l=Ta(r,t);if(Object.keys(l).length){if(n){let n=Sa(e),u=Da(l,t);if(K.At(n,u,i,a,o,s),K.Ot(n)!==JSON.stringify(u)){K.Lt(n,a);let t=Ta(r);return K.At(e,t,i,a,o,s),c}}K.At(e,l,i,a,o,s)}}catch(e){q.Pt(e)}return c},Lt(t,n){try{e?.localStorage.removeItem(t),K.Lt(t,n),K.Lt(Sa(t),n)}catch(e){q.Pt(e)}}})})(t.cookie_persisted_properties||[],t.cookieWinsOnConflict),r,i=!1,a=!1,o=t.persistence.toLowerCase();return o===`localstorage`&&q.Et()?(r=q,a=!0):o===`localstorage+cookie`&&n.Et()?(r=n,a=!0,i=!0):o===`sessionstorage`&&J.Et()?r=J:o===`memory`?r=ja:o===`cookie`&&K.Et()?(r=K,i=!0):n.Et()?(r=n,a=!0,i=!0):K.Et()?(r=K,i=!0):r=ja,this.Go=a,this.Zo=i,r}cl(e){return`${this.ol}__${e}`}al(e){return this.Go&&!!e.split_storage}properties(){let e={};return U(this.props,(t,n)=>{let r=X(n);if(!r||r.exposure===`event`){var i;if(r!=null&&(i=r.shouldSkipFromEventProperties)!=null&&i.call(r,t))return;e[n]=t}}),e}load(e=!1){if(this.mi&&!e)return;let t=this.Ir.cookieWinsOnConflict&&this.Ir.persistence.toLowerCase()===`localstorage+cookie`,n=t?q.Dt(this.ol):null,r={};if(t)try{r=wa(K.Dt(this.ol)),U(r,(e,t)=>{(A(e)||M(e)||e===``)&&delete r[t]})}catch{}let i=this.Oo.Dt(this.ol);if(i&&(this.props=W({},i)),this.Qo&&this.Ll(),t&&i){let e=n?.[gr],t=n?.$user_state??Gi,a=i[gr],o=i.$user_state??Gi;if(a!==e||o!==t){this.Jo=!0,J.At(ns(this.ol),!0);let n=W({},this.props);ba.forEach(e=>delete n[e]),o!==`anonymous`||t!==`identified`&&r.$user_state!==`anonymous`&&(A(e)||a===e)||(us(n,r),delete n[oi]),this.props=n;let i=new Set;ba.forEach(e=>{let t=X(e)?.storageGroup;t&&i.add(t)}),i.forEach(e=>{let t={};U(this.props,(n,r)=>{X(r)?.storageGroup===e&&(t[r]=n)}),k(t)?(q.Lt(this.cl(e)),this.Vo[e]={}):q.At(this.cl(e),t)&&(this.Vo[e]={persisted:!0,fingerprint:this.bl(t,e)})})}}J.Ot(ns(this.ol))&&(this.Jo=!0)}Ll(){for(let e of ko){let t=q.Dt(this.cl(e));if(t&&!k(t)){let n=this.fl(e);n.persisted=!0,this.Nl(e)||(n.fingerprint=this.bl(t,e)),this.ql(e,t)||W(this.props,t)}}}Nl(e){return Object.keys(this.props).some(t=>X(t)?.storageGroup===e)}ql(e,t){let n=es[e];if(!n)return!1;let r=t[n],i=this.props[n];return P(r)&&P(i)&&i>r}refreshKey(e){if(this.mi||this.il.has(e))return;let t=this.Qo?X(e)?.storageGroup:void 0,n=t?q.Dt(this.cl(t)):this.Oo.Dt(this.ol);if(n&&e in n)this.wl(e,n[e],!1);else{if(t){let t=this.Oo.Dt(this.ol);if(t&&e in t)return void this.wl(e,t[e],!1)}this.kl(e,!1)}}save(){if(this.mi)return;let e=this.Tl();e>0?A(this.Fl)&&(this.Fl=setTimeout(()=>{this.Fl=void 0,this.Ol()},e)):this.Ol()}flush(){A(this.Fl)||(clearTimeout(this.Fl),this.Fl=void 0,this.Ol())}Ol(e=!1){if(this.mi||this.Ko&&!e)return;e||(this.syncCookieProperties(),this.Ir.cookieWinsOnConflict&&this.Ir.persistence.toLowerCase()===`localstorage+cookie`||os.forEach(e
1=>this.refreshKey(e)));let t=!e&&!this.Yo;t||(this.el=!1);let n=!!t&&this.Sl();if(this.el)return void(this.Ir.debug&&z.warn(`skipping persistence write because storage belongs to a different distinct ID`));if(this.Qo)return this.jl(),void(n&&this.nl.forEach(e=>e()));let r=this.Bl(this.Oo,this.ol,this.props,Z);r===`written`&&this.Il(this.props),r!==`failed`&&(this.Xo.clear(),this.tl=!1,this.il.clear()),n&&this.nl.forEach(e=>e())}jl(){let{main:e,groups:t}=this.ml(),n=this.Bl(this.Oo,this.ol,e,Z);n===`written`&&this.Il(e),n!==`failed`&&(this.tl=!1,this.il.clear(),is.forEach(e=>{var t;(t=X(e))!=null&&t.storageGroup||this.Xo.delete(e)}));for(let e of ko){let n=t[e];if(k(n)&&!this.Vo[e]?.persisted){is.forEach(t=>{X(t)?.storageGroup===e&&this.Xo.delete(t)});continue}let r=this.Bl(q,this.cl(e),n,e);r!==`failed`&&is.forEach(t=>{let n=X(t);n?.storageGroup!==e||r!==`written`&&n.volatile||this.Xo.delete(t)})}}ml(){let e={},t={flags:{},surveys:{}};return U(this.props,(n,r)=>{let i=X(r)?.storageGroup;i?t[i][r]=n:e[r]=n}),{main:e,groups:t}}bl(e,t){if(t===Z)return JSON.stringify(e)+`|`+this.Hl+`|`+this.zl+`|`+this.Ul;let n={};return U(e,(e,t)=>{n[t]=X(t)?.volatile?`__volatile__`:e}),JSON.stringify(n)}Bl(e,t,n,r){let i=this.fl(r);if(r!==Z&&!i.dirty&&!A(i.fingerprint))return`skipped`;let a;try{if(a=this.bl(n,r),a===i.fingerprint)return i.dirty=!1,`skipped`}catch{a=void 0}return e.At(t,n,this.Hl,this.zl,this.Ul,this.Ir.debug)?(i.dirty=!1,r!==Z&&
1(i.persisted=!0),A(a)||(i.fingerprint=a),this.Go&&(i.storageValue=q.Ot(t)),`written`):(this.Ir.debug&&z.warn(`failed to persist storage entry "${t}"; will retry on next save`),`failed`)}remove({keepGroupEntries:e=!1}={}){if(this.Cl(),A(this.Fl)||(clearTimeout(this.Fl),this.Fl=void 0),this.Oo.Lt(this.ol,!1),this.Oo.Lt(this.ol,!0),!e&&this.sl)for(let e of ko)q.Lt(this.cl(e));e?delete this.Vo[Z]:this.Vo={},this.Ml=void 0,this.El=void 0}clear(){this.remove(),this.props={}}register_once(e,t,n){if(O(e)){this.syncCookieProperties(),A(t)&&(t=`None`),this.Hl=A(n)?this.Wl:n;let r=!1;if(U(e,(e,n)=>{this.props.hasOwnProperty(n)&&this.props[n]!==t||(this.wl(n,e),r=!0)}),r)return this.save(),!0}return!1}register(e,t){if(O(e)){this.syncCookieProperties(),this.Hl=A(t)?this.Wl:t;let n=!1;if(U(e,(t,r)=>{e.hasOwnProperty(r)&&(this.props[r]!==t||O(t)||E(t))&&(this.wl(r,t),n=!0)}),n)return this.save(),!0}return!1}unregister(e){this.syncCookieProperties();let t=typeof e==`string`?[e]:e,n=!1;for(let e of t)e in this.props&&(this.kl(e),n=!0);n&&this.save()}update_campaign_params(){let e=r?.URL;if(e===this.rl)return;let t=Uo(this.Ir.custom_campaign_params,this.Ir.mask_personal_data_properties,this.Ir.custom_personal_data_properties),n=!k(ra(t));return n&&this.register(t),this.rl=e,n?t:void 0}update_search_keyword(){this.register(function(){let e=r?.referrer;return e?Go(e):{}}())}update_referrer_info(){this.register_once({$referrer:Yo(),$referring_domain:r?.referrer&&No(r.referrer)?.host||Jo},void 0)}set_initial_person_info(){if(this.props.$initial_campaign_params||this.props.$initial_referrer_info)return;let e=Xo(this.Ir.mask_personal_data_properties,this.Ir.custom_personal_data_properties,this.Ir.disable_capture_url_hashes);this.register_once({[Oi]:this.Zo?{r:rs(e.r),u:e.u?rs(e.u):void 0}:e},void 0)}get_initial_props(){let e={};U([Di,Ei],t=>{let n=this.props[t];n&&U(n,function(t,n){e[`$initial_`+x(n)]=t})});let t=this.props[Oi];return t&&W(e,function(e,t=!1){let n=Zo(e,t),r={};return U(n,function(e,t){r[`$initial_${x(t)}`]=e}),r}(t,this.Ir.disable_capture_url_hashes)),e}safe_merge(e){return U(this.props,function(t,n){n in e||(e[n]=t)}),e}update_config(e,t,n){let r=e.persistence!==t.persistence,i=!((e,t)=>{if(e.length!==t.length)return!1;let n=[...e].sort(),r=[...t].sort();return n.every((e,t)=>e===r[t])})(e.cookie_persisted_properties||[],t.cookie_persisted_properties||[]),a=r||i,o=e.cookieWinsOnConflict!==t.cookieWinsOnConflict,s=e.disable_persistence||!!n,c=!!this.mi&&!s;s||this.Pl(t,c),this.Ir=e,!s&&(r||i||o)&&(this.Ml=void 0,this.El=void 0,this.Pl(R(R({},e),{},{cookie_persisted_properties:t.cookie_persisted_properties}),c));let l=a||o?this.ll(e):this.Oo;this.Vl();let u=this.al(e),d=a||u!==this.Qo,f=!s&&(d||e.cross_subdomain_cookie!==this.zl||e.secure_cookie!==this.Ul)&&this.Rl(c);this.Yo=d;try{if(this.Wl=this.Hl=e.cookie_expiration,this.set_disabled(s),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),d){let e=this.props;this.clear(),this.Oo=l,this.Qo=u,this.props=e,this.save()}else o&&(this.Oo=l,s||(delete this.Vo[Z],this.Ol()))}finally{this.Yo=!1,f&&this.Dl()}}Vl(){let e=this.props[Oi];if(!this.Zo||!O(e)||typeof e.r!=`string`)return;let t=rs(e.r),n=typeof e.u==`string`?rs(e.u):e.u;t===e.r&&n===e.u||this.wl(Oi,R(R({},e),{},{r:t,u:n}))}set_disabled(e){this.mi=e,this.mi?this.remove():this.save()}set_cross_subdomain(e){e!==this.zl&&(this.zl=e,this.remove({keepGroupEntries:!0}),this.save())}set_secure(e){e!==this.Ul&&(this.Ul=e,this.remove({keepGroupEntries:!0}),this.save())}set_event_timer(e,t){let n=this.props.__timers||{};n[e]=t,this.wl(Tr,n),this.save()}remove_event_timer(e){let t=this.props.__timers||{},n=t[e];return A(n)||(delete t[e],this.wl(Tr,t),this.save()),n}get_property(e){return this.props[e]}set_property(e,t){this.wl(e,t),this.save()}wl(e,t,n=!0){var r;let i=this.props[e];this.props[e]=t,n&&(e!==`distinct_id`&&e!==`$user_state`||i===t||(this.tl=!0),ss(e)&&!cs(i,t)&&this.il.add(e),this.$l(e,i,t),(r=X(e))!=null&&r.volatile||this.xl(e))}kl(e,t=!0){delete this.props[e],t&&(as(e)&&this.vl(e,!0),ss(e)&&this.il.add(e),this.xl(e))}xl(e){let t=X(e)?.storageGroup;t&&(this.fl(t).dirty=!0)}fl(e){return this.Vo[e]||(this.Vo[e]={})}},fs={GZipJS:`gzip-js`,Base64:`base64`},ps={Activation:`events`,Cancellation:`cancelEvents`},ms={Popover:`popover`,API:`api`,Widget:`widget`,ExternalSurvey:`external_survey`},hs={SHOWN:`survey shown`,DISMISSED:`survey dismissed`,SENT:`survey sent`,ABANDONED:`survey abandoned`},gs={SURVEY_ID:`$survey_id`,SURVEY_NAME:`$survey_name`,SURVEY_RESPONSE:`$survey_response`,SURVEY_ITERATION:`$survey_iteration`,SURVEY_ITERATION_
1START_DATE:`$survey_iteration_start_date`,SURVEY_PARTIALLY_COMPLETED:`$survey_partially_completed`,SURVEY_SUBMISSION_ID:`$survey_submission_id`,SURVEY_QUESTIONS:`$survey_questions`,SURVEY_COMPLETED:`$survey_completed`,PRODUCT_TOUR_ID:`$product_tour_id`,SURVEY_LAST_SEEN_DATE:`$survey_last_seen_date`,SURVEY_LANGUAGE:`$survey_language`},_s={Popover:`popover`,Inline:`inline`};function vs(e){let t=!0;return{dispose(){if(t){t=!1;let n=e();n&&D(n.then)&&n.then(void 0,()=>{})}}}}var ys={SHOWN:`product tour shown`,DISMISSED:`product tour dismissed`,COMPLETED:`product tour completed`,STEP_SHOWN:`product tour step shown`,STEP_COMPLETED:`product tour step completed`,BUTTON_CLICKED:`product tour button clicked`,STEP_SELECTOR_FAILED:`product tour step selector failed`,BANNER_CONTAINER_SELECTOR_FAILED:`product tour banner container selector failed`,BANNER_ACTION_CLICKED:`product tour banner action clicked`},bs={TOUR_ID:`$product_tour_id`,TOUR_NAME:`$product_tour_name`,TOUR_ITERATION:`$product_tour_iteration`,TOUR_RENDER_REASON:`$product_tour_render_reason`,TOUR_STEP_ID:`$product_tour_step_id`,TOUR_STEP_ORDER:`$product_tour_step_order`,TOUR_STEP_TYPE:`$product_tour_step_type`,TOUR_DISMISS_REASON:`$product_tour_dismiss_reason`,TOUR_BUTTON_TEXT:`$product_tour_button_text`,TOUR_BUTTON_ACTION:`$product_tour_button_action`,TOUR_BUTTON_LINK:`$product_tour_button_link`,TOUR_BUTTON_TOUR_ID:`$product_tour_button_tour_id`,TOUR_STEPS_COUNT:`$product_tour_steps_count`,TOUR_STEP_SELECTOR:`$product_tour_step_selector`,TOUR_STEP_SELECTOR_FOUND:`$product_tour_step_selector_found`,TOUR_STEP_ELEMENT_TAG:`$product_tour_step_element_tag`,TOUR_STEP_ELEMENT_ID:`$product_tour_step_element_id`,TOUR_STEP_ELEMENT_CLASSES:`$product_tour_step_element_classes`,TOUR_STEP_ELEMENT_TEXT:`$product_tour_step_element_text`,TOUR_ERROR:`$product_tour_error`,TOUR_MATCHES_COUNT:`$product_tour_matches_count`,TOUR_FAILURE_PHASE:`$product_tour_failure_phase`,TOUR_WAITED_FOR_ELEMENT:`$product_tour_waited_for_element`,TOUR_WAIT_DURATION_MS:`$product_tour_wait_duration_ms`,TOUR_BANNER_SELECTOR:`$product_tour_banner_selector`,TOUR_LINKED_SURVEY_ID:`$product_tour_linked_survey_id`,USE_MANUAL_SELECTOR:`$use_manual_selector`,INFERENCE_DATA_PRESENT:`$inference_data_present`,TOUR_LAST_SEEN_DATE:`$product_tour_last_seen_date`,TOUR_TYPE:`$product_tour_type`},xs=B(`[RateLimiter]`),Ss=class{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=e=>{let t=e.text;if(t&&t.length)try{(JSON.parse(t).quota_limited||[]).forEach(e=>{xs.info(`${e||`events`} is quota limited.`),this.serverLimits[e]=new Date().getTime()+6e4})}catch(e){xs.warn(`could not rate limit - continuing. Error: "${e?.message}"`,{text:t});return}},this.instance=e,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){return this.instance.config.rate_limiting?.events_per_second||10}get captureEventsBurstLimit(){return Math.max(this.instance.config.rate_limiting?.events_burst_limit||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(e=!1){var t;let{captureEventsBurstLimit:n,captureEventsPerSecond:r}=this,i=new Date().getTime(),a=this.instance.persistence?.get_property(`$capture_rate_limit`)??{tokens:n,last:i};a.tokens+=(i-a.last)/1e3*r,a.last=i,a.tokens>n&&(a.tokens=n);let o=1>a.tokens;if(o||e||(a.tokens=Math.max(0,a.tokens-1)),o&&!e){let e=(P(a.dropped)?a.dropped:0)+1;a.dropped=e,!this.lastEventRateLimited&&this.Gl(e)&&(a.dropped=0)}return this.lastEventRateLimited=o,(t=this.instance.persistence)==null||t.set_property(`$capture_rate_limit`,a),{isRateLimited:o,remainingTokens:a.tokens}}Zl(e){let t=this.instance.config.property_denylist;return!E(t)||!t.includes(e)}Ql(){if(this.Zl(`$current_url`)&&this.Zl(`$pathname`)&&i?.pathname)return`${i.origin??``}${i.pathname}`}Gl(e){var t;let{captureEventsBurstLimit:n,captureEventsPerSecond:r}=this,i=this.Ql(),a=this.Zl(`$session_id`)?(t=this.instance).get_session_id?.call(t):void 0,o=[`${e} event(s) dropped since the last warning`,i?`triggered on ${i}`:void 0,a?`session ${a}
1`:void 0].filter(Boolean).join(`, `);return!!this.instance.capture(`$$client_ingestion_warning`,{$$client_ingestion_warning_message:`posthog-js client rate limited: ${o}. Config is set to ${r} events per second and ${n} events burst limit.`},{skip_client_rate_limiting:!0})}isServerRateLimited(e){let t=this.serverLimits[e||`events`]||!1;return!1!==t&&new Date().getTime()<t}},Cs=B(`[RemoteConfig]`),ws=class{constructor(e){this._instance=e}get remoteConfig(){var e;return(e=f._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.config}Jl(e){var t,n;f.__PosthogExtensions__?.loadExternalDependency?(t=f.__PosthogExtensions__)==null||(n=t.loadExternalDependency)==null||n.call(t,this._instance,`remote-config`,()=>e(this.remoteConfig)):e()}Kl(e){this._instance._send_request({method:`GET`,url:this._instance.requestRouter.endpointFor(`assets`,`/array/${this._instance.config.token}/config`),callback:e})}load(){try{if(this.remoteConfig)return Cs.info(`Using preloaded remote config`,this.remoteConfig),void this.Xl(this.remoteConfig);if(this._instance.Yl())return void Cs.warn(`Remote config is disabled. Falling back to local config.`);this.Jl(e=>{if(!e)return Cs.info(`No config found after loading remote JS config. Falling back to JSON.`),void this.Kl(e=>{this.Xl(e.json,e)});this.Xl(e)})}catch(e){Cs.error(`Error loading remote config`,e),this.Xl()}}Xl(e,t){!e&&t&&(t.statusCode===0?t.error||Cs.warn(`Failed to fetch remote config from PostHog.`):Cs.error(`Failed to fetch remote config from PostHog.`));try{this._instance.Xl(e?{ok:!0,config:e}:{ok:!1})}catch(e){Cs.error(`Error applying remote config`,e)}if(!1!==e?.hasFeatureFlags&&!this._instance.config.advanced_disable_feature_flags_on_first_load)try{var n;(n=this._instance.featureFlags)==null||n.ensureFlagsLoaded()}catch(e){Cs.error(`Error loading feature flags`,e)}}},Ts=Uint8Array,Es=Uint16Array,Ds=Uint32Array,Os=new Ts([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]),ks=new Ts([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]),As=new Ts([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),js=function(e,t){for(var n=new Es(31),r=0;31>r;++r)n[r]=t+=1<<e[r-1];var i=new Ds(n[30]);for(r=1;30>r;++r)for(var a=n[r];n[r+1]>a;++a)i[a]=a-n[r]<<5|r;return[n,i]},Ms=js(Os,2),Ns=Ms[1];Ms[0][28]=258,Ns[258]=28;for(var Ps=js(ks,0)[1],Fs=new Es(32768),Q=0;32768>Q;++Q){var Is=(43690&Q)>>>1|(21845&Q)<<1;Fs[Q]=((65280&(Is=(61680&(Is=(52428&Is)>>>2|(13107&Is)<<2))>>>4|(3855&Is)<<4))>>>8|(255&Is)<<8)>>>1}var Ls=function(e,t,n){for(var r=e.length,i=0,a=new Es(t);r>i;++i)++a[e[i]-1];var o,s=new Es(t);for(i=0;t>i;++i)s[i]=s[i-1]+a[i-1]<<1;if(n){o=new Es(1<<t);var c=15-t;for(i=0;r>i;++i)if(e[i])for(var l=i<<4|e[i],u=t-e[i],d=s[e[i]-1]++<<u,f=d|(1<<u)-1;f>=d;++d)o[Fs[d]>>>c]=l}else for(o=new Es(r),i=0;r>i;++i)o[i]=Fs[s[e[i]-1]++]>>>15-e[i];return o},Rs=new Ts(288);for(Q=0;144>Q;++Q)Rs[Q]=8;for(Q=144;256>Q;++Q)Rs[Q]=9;for(Q=256;280>Q;++Q)Rs[Q]=7;for(Q=280;288>Q;++Q)Rs[Q]=8;var zs=new Ts(32);for(Q=0;32>Q;++Q)zs[Q]=5;var Bs=Ls(Rs,9,0),Vs=Ls(zs,5,0),Hs=function(e){return(e/8|0)+(7&e&&1)},Us=function(e,t,n){(t==null||0>t)&&(t=0),(n==null||n>e.length)&&(n=e.length);var r=new(e instanceof Es?Es:e instanceof Ds?Ds:Ts)(n-t);return r.set(e.subarray(t,n)),r},Ws=function(e,t,n){var r=t/8|0;e[r]|=n<<=7&t,e[r+1]|=n>>>8},Gs=function(e,t,n){var r=t/8|0;e[r]|=n<<=7&t,e[r+1]|=n>>>8,e[r+2]|=n>>>16},Ks=function(e,t){for(var n=[],r=0;e.length>r;++r)e[r]&&n.push({s:r,f:e[r]});var i=n.length,a=n.slice();if(!i)return[new Ts(0),0];if(i==1){var o=new Ts(n[0].s+1);return o[n[0].s]=1,[o,1]}n.sort(function(e,t){return e.f-t.f}),n.push({s:-1,f:25001});var s=n[0],c=n[1],l=0,u=1,d=2;for(n[0]={s:-1,f:s.f+c.f,l:s,r:c};u!=i-1;)s=n[n[d].f>n[l].f?l++:d++],c=n[l!=u&&n[d].f>n[l].f?l++:d++],n[u++]={s:-1,f:s.f+c.f,l:s,r:c};var f=a[0].s;for(r=1;i>r;++r)a[r].s>f&&(f=a[r].s);var p=new Es(f+1),m=qs(n[u-1],p,0);if(m>t){r=0;var h=0,g=m-t,_=1<<g;for(a.sort(function(e,t){return p[t.s]-p[e.s]||e.f-t.f});i>r;++r){var v=a[r].s;if(t>=p[v])break;h+=_-(1<<m-p[v]),p[v]=t}for(h>>>=g;h>0;){var y=a[r].s;t>p[y]?h-=1<<t-p[y]++-1:++r}for(;r>=0&&h;--r){var b=a[r].s;p[b]==t&&(--p[b],++h)}m=t}return[new Ts(p),m]},qs=function(e,t,n){return e.s==-1?Math.max(qs(e.l,t,n+1),qs(e.r,t,n+1)):t[e.s]=n},Js=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new Es(++t),r=0,i=e[0],a=1,o=function(e){n[r++]=e},s=1;t>=s;++s)if(e[s]==i&&s!=t)++a;else{if(!i&&a>2){for(;a>138;a-=138)o(32754);a>
vendor: 5,122 bytes, line 1
12&&(o(a>10?a-11<<5|28690:a-3<<5|12305),a=0)}else if(a>3){for(o(i),--a;a>6;a-=6)o(8304);a>2&&(o(a-3<<5|8208),a=0)}for(;a--;)o(i);a=1,i=e[s]}return[n.subarray(0,r),t]},Ys=function(e,t){for(var n=0,r=0;t.length>r;++r)n+=e[r]*t[r];return n},Xs=function(e,t,n){var r=n.length,i=Hs(t+2);e[i]=255&r,e[i+1]=r>>>8,e[i+2]=255^e[i],e[i+3]=255^e[i+1];for(var a=0;r>a;++a)e[i+a+4]=n[a];return 8*(i+4+r)},Zs=function(e,t,n,r,i,a,o,s,c,l,u){Ws(t,u++,n),++i[256];for(var d=Ks(i,15),f=d[0],p=d[1],m=Ks(a,15),h=m[0],g=m[1],_=Js(f),v=_[0],y=_[1],b=Js(h),x=b[0],S=b[1],C=new Es(19),w=0;v.length>w;++w)C[31&v[w]]++;for(w=0;x.length>w;++w)C[31&x[w]]++;for(var T=Ks(C,7),E=T[0],D=T[1],O=19;O>4&&!E[As[O-1]];--O);var k,A,j,ee,M=l+5<<3,N=Ys(i,Rs)+Ys(a,zs)+o,P=Ys(i,f)+Ys(a,h)+o+14+3*O+Ys(C,E)+(2*C[16]+3*C[17]+7*C[18]);if(N>=M&&P>=M)return Xs(t,u,e.subarray(c,c+l));if(Ws(t,u,1+(N>P)),u+=2,N>P){k=Ls(f,p,0),A=f,j=Ls(h,g,0),ee=h;var te=Ls(E,D,0);for(Ws(t,u,y-257),Ws(t,u+5,S-1),Ws(t,u+10,O-4),u+=14,w=0;O>w;++w)Ws(t,u+3*w,E[As[w]]);u+=3*O;for(var F=[v,x],ne=0;2>ne;++ne){var re=F[ne];for(w=0;re.length>w;++w)Ws(t,u,te[ie=31&re[w]]),u+=E[ie],ie>15&&(Ws(t,u,re[w]>>>5&127),u+=re[w]>>>12)}}else k=Bs,A=Rs,j=Vs,ee=zs;for(w=0;s>w;++w)if(r[w]>255){var ie;Gs(t,u,k[257+(ie=r[w]>>>18&31)]),u+=A[ie+257],ie>7&&(Ws(t,u,r[w]>>>23&31),u+=Os[ie]);var I=31&r[w];Gs(t,u,j[I]),u+=ee[I],I>3&&(Gs(t,u,r[w]>>>5&8191),u+=ks[I])}else Gs(t,u,k[r[w]]),u+=A[r[w]];return Gs(t,u,k[256]),u+A[256]},Qs=new Ds([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),$s=new Ts(0),ec=function(){for(var e=new Ds(256),t=0;256>t;++t){for(var n=t,r=9;--r;)n=(1&n&&3988292384)^n>>>1;e[t]=n}return e}(),tc=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8};function nc(e,t){t===void 0&&(t={});var n=function(){var e=4294967295;return{p(t){for(var n=e,r=0;t.length>r;++r)n=ec[255&n^t[r]]^n>>>8;e=n},d(){return 4294967295^e}}}(),r=e.length;n.p(e);var i,a,o,s,c,l,u=(s=10+((i=t).filename&&i.filename.length+1||0),c=8,function(e,t,n,r,i,a){var o=e.length,s=new Ts(r+o+5*(1+Math.floor(o/7e3))+i),c=s.subarray(r,s.length-i),l=0;if(!t||8>o)for(var u=0;o>=u;u+=65535){var d=u+65535;o>d?l=Xs(c,l,e.subarray(u,d)):(c[u]=a,l=Xs(c,l,e.subarray(u,o)))}else{for(var f=Qs[t-1],p=f>>>13,m=8191&f,h=(1<<n)-1,g=new Es(32768),_=new Es(h+1),v=Math.ceil(n/3),y=2*v,b=function(t){return(e[t]^e[t+1]<<v^e[t+2]<<y)&h},x=new Ds(25e3),S=new Es(288),C=new Es(32),w=0,T=0,E=(u=0,0),D=0,O=0;o>u;++u){var k=b(u),A=32767&u,j=_[k];if(g[A]=j,_[k]=A,u>=D){var ee=o-u;if((w>7e3||E>24576)&&ee>423){l=Zs(e,c,0,x,S,C,T,E,O,u-O,l),E=w=T=0,O=u;for(var M=0;286>M;++M)S[M]=0;for(M=0;30>M;++M)C[M]=0}var N=2,P=0,te=m,F=A-j&32767;if(ee>2&&k==b(u-F))for(var ne=Math.min(p,ee)-1,re=Math.min(32767,u),ie=Math.min(258,ee);re>=F&&--te&&A!=j;){if(e[u+N]==e[u+N-F]){for(var I=0;ie>I&&e[u+I]==e[u+I-F];++I);if(I>N){if(N=I,P=F,I>ne)break;var ae=Math.min(F,I-2),oe=0;for(M=0;ae>M;++M){var se=u-F+M+32768&32767,ce=se-g[se]+32768&32767;ce>oe&&(oe=ce,j=se)}}}F+=(A=j)-(j=g[A])+32768&32767}if(P){x[E++]=268435456|Ns[N]<<18|Ps[P];var le=31&Ns[N],ue=31&Ps[P];T+=Os[le]+ks[ue],++S[257+le],++C[ue],D=u+N,++w}else x[E++]=e[u],++S[e[u]]}}l=Zs(e,c,a,x,S,C,T,E,O,u-O,l),a||(l=Xs(c,l,$s))}return Us(s,0,r+Hs(l)+i)}(a=e,(o=t).level==null?6:o.level,o.mem==null?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(a.length)))):12+o.mem,s,c,!l)),d=u.length;return function(e,t){var n=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=2>t.level?4:t.level==9?2:0,e[9]=3,t.mtime!=0&&tc(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),n){e[3]=8;for(var r=0;n.length>=r;++r)e[r+10]=n.charCodeAt(r)}}(u,t),tc(u,d-8,n.d()),tc(u,d-4,r),u}var rc=!!o||!!a,ic=new WeakMap,ac=`text/plain`,oc=0,sc=!1,cc=(e,t)=>{let[n,r]=e.split(`#`),[i,a]=n.split(`?`);if(!a)return e;let o=a.split(`&`).filter(e=>e.split(`=`)[0]!==t).join(`&`);return`${i}${o?`?${o}`:``}${r?`#${r}`:``}`},lc=(e,t,n=!0)=>{let[r,i]=e.split(`?`),a=R({},t),o=i?.split(`&`).map(e=>{var t;let[r,i]=e.split(`=`),o=n&&(t=a[r])!=null?t:i;return delete a[r],`${r}=${o}`})??[],s=function(e,t=`&`){let n,r,i=[];return U(e,function(e,t){A(e)||A(t)||t===`undefined`||(n=encodeURIComponent((e=>e instanceof File)(e)?e.name:e.toString()),r=encodeURIComponent(t),i[i.length]=r+`=`+n)}),i.join(t)}(a);return s&&o.push(s),o.length>0?`${r}?${o.join(`&`)}`:r},uc=e=>{if(e.ta)return e.ta;let{data:t,compression:n}=e;if(!t)return;if(n===fs.GZipJS){let e=nc(function(e){var t=e.length;if(typeof TextEncoder<`u`)return new TextEncoder().encode(e);for(var n=new Ts(e.length+(e.length>>>1)),r=0,i=function(e){n[r++]=e},a=0;t>a;++a){if(r+5>n.length){var o=new Ts(r+8+(t-a<<1));o.set(n),n=o}var s=e.charCodeAt(a);128>s?i(s):2048>s?(i(192|s>>>6),i(128|63&s)):s>55295&&57344>s?(i(240|(s=65536+(1047552&s)|1023&e.charCodeAt(++a))>>>18),i(128|s>>>12&63),i(128|s>>>6&63),i(128|63&s)):(i(224|s>>>12),i(128|s>>>6&63),i(128|63&s))}return Us(n,0,r)}(Mo(t)),{mtime:0});return{contentType:ac,body:e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength),estimatedSize:e.byteLength}}if(n===fs.Base64){let e=(e=>`data=`+encodeURIComponent(typeof e==`string`?e:Mo(e)))(function(e){return e&&btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,(e,t)=>
1String.fromCharCode(parseInt(t,16))))}(Mo(t)));return{contentType:`application/x-www-form-urlencoded`,body:e,estimatedSize:new Blob([e]).size}}let r=Mo(t);return{contentType:`application/json`,body:r,estimatedSize:new Blob([r]).size}},dc=e=>{let t=()=>e.transport===`sendBeacon`?{url:lc(e.url,{compression:fs.Base64}),encodedBody:uc(R(R({},e),{},{compression:fs.Base64,ta:void 0}))}:{url:cc(e.url,`compression`),encodedBody:uc(R(R({},e),{},{compression:void 0,ta:void 0}))},n;try{n=uc(e)}catch(n){if(Mn(e.compression,Po(e.url,`compression`)))return z.error(`Failed to gzip request body, sending uncompressed payload`,n),t();throw n}return n&&Mn(e.compression,Po(e.url,`compression`))&&!((r=n.body)instanceof ArrayBuffer?jn(new Uint8Array(r)):ArrayBuffer.isView(r)&&jn(new Uint8Array(r.buffer,r.byteOffset,r.byteLength)))?(sc=!0,t()):{url:e.url,encodedBody:n};var r},fc=e=>{try{return dc(e)}catch(n){var t;z.error(n),(t=e.callback)==null||t.call(e,{statusCode:0,error:n});return}},pc=function(){var e=L(function*(e){let t=yield function(e){return Rn.apply(this,arguments)}(Mo(e.data),V.DEBUG,{rethrow:!0});if(!t)return e;let n=yield t.arrayBuffer();return R(R({},e),{},{ta:{contentType:ac,body:n,estimatedSize:n.byteLength}})});return function(t){return e.apply(this,arguments)}}(),mc=/Failed to fetch|NetworkError|Load failed/i,hc=e=>e?.name===`TypeError`&&mc.test(e?.message||``),gc=e=>{try{let t=function(e,t=Date.now()){if(typeof e!=`string`||!e)return;let n=e.trim(),r=/^\d+\s*,/.test(n)?n.slice(0,n.indexOf(`,`)).trim():n;if(/^\d+$/.test(r)){let e=1e3*Math.min(Number(r),300);return e>0?e:void 0}if(!/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun)[a-z]*[ ,]/.test(r))return;let i=/^\w{3} \w{3} /.test(r)?r+` GMT`:r,a=Date.parse(i)-t;return Number.isFinite(a)&&a>0?Math.min(a,Ct):void 0}(e());return A(t)?void 0:Math.min(t,3e4)}catch{return}},_c=e=>{let t=fc(e);if(!t)return;let n=new o;ic.set(n,!0);let{url:r,encodedBody:i}=t;n.open(e.method||`GET`,r,!0);let{contentType:a,body:s}=i??{};U(e.headers,function(e,t){n.setRequestHeader(t,e)}),a&&n.setRequestHeader(`Content-Type`,a),e.timeout&&(n.timeout=e.timeout),n.onreadystatechange=()=>{if(n.readyState===4){var t;let r={statusCode:n.status,text:n.responseText};if(n.status===200)try{r.json=JSON.parse(n.responseText)}catch{}(t=e.callback)==null||t.call(e,r,gc(()=>n.getResponseHeader(`Retry-After`)))}},n.send(s)},vc=e=>{let t=fc(e);if(!t)return;let{url:n,encodedBody:r}=t,{contentType:i,body:o,estimatedSize:c}=r??{},l=new Headers;U(e.headers,function(e,t){l.append(t,e)}),i&&l.append(`Content-Type`,i);let u=null,d=!1;if(s){let t=new s;u={signal:t.signal,timeout:setTimeout(()=>{d=!0;try{t.abort(Dt(`AbortError`,`PostHog request timed out`+((n=e.timeout)?` after ${n}ms`:``)))}catch(e){p(e)}var n},e.timeout)}}let f=!1,p=t=>{var n;f||(f=!0,d&&t?.name===`AbortError`||hc(t)?z.warn(t):z.error(t),(n=e.callback)==null||n.call(e,{statusCode:0,error:t}))},m=0,h=()=>{oc-=m,m=0,u&&clearTimeout(u.timeout)};try{let t=R({method:e?.method||`GET`,headers:l,referrerPolicy:`strict-origin`,body:o,signal:u?.signal},e.fetchOptions),r=c??(A(o)?0:void 0);t.keepalive=t.method===`POST`&&!e.ea&&!1!==t.keepalive&&t.body===o&&!A(r)&&r>=0&&52428.8>oc+r,t.keepalive&&(m=r,oc+=m),a(n,t).then(t=>t.text().then(n=>{var r;if(f)return;let i={statusCode:t.status,text:n};if(t.status===200)try{i.json=JSON.parse(n)}catch(e){z.error(e)}f=!0,h(),(r=e.callback)==null||r.call(e,i,gc(()=>t.headers.get(`Retry-After`)))})).catch(e=>{h(),p(e)}).finally(h)}catch(e){h(),p(e)}},yc=e=>{try{let{url:t,encodedBody:r}=dc(e),{contentType:i,body:o,estimatedSize:s}=r??{};if(!o)return;let c=o instanceof Blob?o:new Blob([o],{type:i});if(n.sendBeacon(t,c))return;let l=E(e.data)?e.data:e.data?.batch;if(E(l)&&l.length>1&&(s??0)>16384){let t=Math.ceil(l.length/2),n=t=>E(e.data)?t:R(R({},e.data),{},{batch:t});yc(R(R({},e),{},{data:n(l.slice(0,t))})),yc(R(R({},e),{},{data:n(l.slice(t))}));return}z.warn(`Beacon of ~${s??0} bytes was rejected by the browser, falling back to ${a?`fetch`:`XHR`}`),a?vc(R(R({},e),{},{ea:!0})):_c(e)}catch(e){z.warn(`Beacon send failed`,e)}},bc=(e,t,n,r)=>{let i=r===`query`?t===`POST`?`sent_at`:`_`:void 0;return lc(n===fs.GZipJS?cc(e,`compression`):e,R(R({},i?{[i]:Date.now().toString()}:{}),n===fs.GZipJS?{}:{compression:n}))},xc=(()=>{let e=[];return a&&e.push({transport:`fetch`,method:vc}),o&&e.push({transport:`XHR`,method:_c}),n!=null&&n.sendBeacon&&e.push({transport:`sendBeacon`,method:yc}),e}
1)(),Sc=!rc&&l?.indexOf(`MSIE`)===-1&&l?.indexOf(`Mozilla`)===-1;function Cc(e,t,n){var r,i;n&&(t=R(R({},t),{},{callback:e=>n(e)})),e.__loaded?Sc?e.__request_queue.push(t):e.rateLimiter.isServerRateLimited(t.batchKey)?t.fireCallbackOnDrop&&((r=t.callback)==null||r.call(t,{statusCode:429})):(t.transport=t.transport||e.config.api_transport,t.headers=R(R({},e.config.request_headers),t.headers),t.compression=t.compression===`best-available`?e.compression??t.compressionFallback:t.compression,(A(e.config.disable_beacon)?e.config.__preview_disable_beacon:e.config.disable_beacon)&&(t.disableTransport=[`sendBeacon`]),t.fetchOptions=t.fetchOptions||e.config.fetch_options,((e,t)=>{let n=R(R({},e),{},{callback:t??(t=>e.callback?.call(e,t))});n.timeout=n.timeout||6e4;let r=n.transport??`fetch`;r===`sendBeacon`&&A(n.compression)&&n.data&&(n.compression=fs.Base64),n.method===`POST`&&n.data&&(n.timestampMode===`capture-body`?n.data=(e=>{var t;let n=(E(e)?e:[e]).map(e=>R(R({},e),e.timestamp instanceof Date&&!isNaN(e.timestamp.getTime())?{timestamp:e.timestamp.toISOString()}:{})),r=n[0];return{api_key:(r==null||(t=r.properties)==null?void 0:t.token)??r?.token,batch:n,sent_at:new Date().toISOString()}})(n.data):n.timestampMode===`body`&&(n.data=((e,t=new Date().toISOString())=>E(e)?e.map(e=>R(R({},e),{},{sent_at:t})):R(R({},e),{},{sent_at:t}))(n.data))),n.url=bc(n.url,n.method,n.compression,n.timestampMode);let i=xc.filter(e=>!n.disableTransport||!e.transport||!n.disableTransport.includes(e.transport)),a=function(e,t){for(let n=0;e.length>n;n++)if(t(e[n]))return e[n]}(i,e=>e.transport===r)?.method??i[0].method;if(!a)throw Error(`No available transport method`);let o=e=>{try{a(e)}catch(e){var t;hc(e)?z.warn(e):z.error(e),(t=n.callback)==null||t.call(n,{statusCode:0,error:e})}};r!==`sendBeacon`&&!n.preferSyncCompression&&n.data&&n.compression===fs.GZipJS&&c&&typeof Promise<`u`&&!sc?pc(n).then(e=>{o(e)}).catch(t=>{if(Nn(t))return sc=!0,void o(R(R({},n),{},{compression:void 0,url:bc(e.url,e.method,void 0,e.timestampMode)}));(e=>{if(!e||typeof e!=`object`)return!1;let t=`name`in e?String(e.name):``;return Nn(e)||t===An})(t)&&(sc=!0),o(n)}):o(n)})(t,(r,i)=>{var a,o,s;e.rateLimiter.checkForLimiting(r),400>r.statusCode||(a=(o=e.config).on_request_error)==null||a.call(o,r),n?n(r,i):(s=t.callback)==null||s.call(t,r)})):t.fireCallbackOnDrop&&((i=t.callback)==null||i.call(t,{statusCode:0}))}var wc=class{constructor(e,t){this.ia=!0,this.na=[],this.sa=me(t?.flush_interval_ms||3e3,250,5e3,z.createLogger(`flush interval`),3e3),this.ra=e}enqueue(e){this.na.push(e),this.oa||this.la()}unload(){this.aa();let e=this.na.length>0?this.ua():{},t=Object.values(e);[...t.filter(e=>e.url.indexOf(`/e`)===0),...t.filter(e=>e.url.indexOf(`/e`)!==0)].map(e=>{this.ha(e,`sendBeacon`)})}enable(){this.ia=!1,this.la()}la(){this.ia||(this.oa=setTimeout(()=>{if(this.aa(),this.na.length>0){let e=this.ua();for(let t in e)this.ha(e[t])}},this.sa))}ha(e,t){try{this.ra(e,t)}catch(e){z.error(e)}}aa(){clearTimeout(this.oa),this.oa=void 0}ua(){let e={};return U(this.na,t=>{var n;let r=t,i=((r?r.batchKey:null)||r.url)+(r.batchGroup?`:${r.batchGroup}`:``);A(e[i])&&(e[i]=R(R({},r),{},{data:[]})),(n=e[i].data)==null||n.push(r.data)}),this.na=[],e}},Tc=[`retriesPerformedSoFar`],Ec=class{constructor(e){this._instance=e,this.ca=!1,this.da=3e3,this.na=[],this.na=[],this.va=!0,this.resume()}resume(){if(!A(e)&&`onLine`in e.navigator){if(this.va=e.navigator.onLine,this.fa)return;this.fa=()=>{this.va=!0,this.pa()},this.ga=()=>{this.va=!1},G(e,`online`,this.fa),G(e,`offline`,this.ga)}}get length(){return this.na.length}retriableRequest(e,t){let{retriesPerformedSoFar:n}=e,r=zn(e,Tc);te(n)&&(r.url=lc(r.url,{retry_count:n})),Cc(this._instance,t?R(R({},r),{},{transport:t}):r,(e,t)=>{var i;if(e.statusCode!==200&&(400>e.statusCode||e.statusCode>=500)){if((e.statusCode===0?3:10)>(n??0))return void this.Ls(R({retriesPerformedSoFar:n},r),t);e.statusCode===0&&z.warn(`Request failed before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped retrying after ${n??0} retries.`)}(i=r.callback)==null||i.call(r,e)})}Ls(e,t){let n=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=n+1;let r=Math.max(function(e){let t=3e3*2**e,n=t/2,r=Math.min(18e5,t),i=(Math.random()-.5)*(r-n);return Math.ceil(r+i)}(n),t??0),i=Date.now()+r;this.na.push({retryAt:i,requestOptions:e});let a=`Enqueued failed request for retry in ${r}`;navigator.onLine||(a+=` (Browser is offline)`),z.warn(a),this.ca||(this.ca=!0,this.ma())}ma(){if(this.ya&&clearTimeout(this.ya),this.na.length===0)return this.ca=!1,void(this.ya=void 0);this.ya=setTimeout(()=>{this.va&&this.na.length>0&&this.pa(),this.ma()},this.da)}pa(){let e=Date.now(),t=[],n=this.na.filter(n=>e>n.retryAt||(t.push(n),!1));if(this.na=t,n.length>0)for(let{requestOptions:e}of n)this.retriableRequest(e)}unload(){this.ya&&=(clearTimeout(this.ya),void 0),this.ca=!1,A(e)||(this.fa&&=(e.removeEventListener(`online`,this.fa),void 0),this.ga&&=(e.removeEventListener(`offline`,this.ga),void 0));for(let{requestOptions:e}of this.na)try{this._instance._send_request(R(R({},e),{},{transport:`sendBeacon`}))}catch(e){z.error(e)}this.na=[]}},Dc=class{constructor(e){this._instance=e,this.ba=()=>{this._a||={};let e=this.scrollElement(),t=this.scrollY(),n=e?Math.max(0,e.scrollHeight-e.clientHeight):0,r=t+(e?.clientHeight||0),i=e?.scrollHeight||0;this._a.lastScrollY=Math.ceil(t),this._a.maxScrollY=Math.max(t,this._a.maxScrollY??0),this._a.maxScrollHeight=Math.max(n,this._a.maxScrollHeight??0),this._a.lastContentY=r,this._a.maxContentY=Math.max(r,this._a.maxContentY??0),this._a.maxContentHeight=Math.max(i,this._a.maxContentHeight??0)}}get wa(){return this._instance.config.scroll_root_selector}getContext(){return this._a}resetContext(){let e=this._a;return this._a=void 0,setTimeout(this.ba,0),e}startMeasuringScrollPosition(){G(e,`scroll`,this.ba,{capture:!0}),G(e,`scrollend`,this.ba,{capture:!0}),G(e,`resize`,this.ba)}scrollElement(){if(this.wa){let n=E(this.wa)?this.wa:[this.wa];for(let r of n){var t;let n=e==null||(t=e.document)==null?void 0:t.querySelector(r);if(n)return n}return}var n;return e==null||(n=e.document)==null?void 0:n.documentElement}ka(t){var n,r;let i=t===`y`?`scrollTop`:`scrollLeft`;if(this.wa){let e=this.scrollElement();return e&&e[i]||0}return e?t===`y`?e.scrollY||e.pageYOffset||((n=e.document)==null||(n=n.documentElement)==null?void 0:n.scrollTop)||0:e.scrollX||e.pageXOffset||((r=e.document)==null||(r=r.documentElement)==null?void 0:r.scrollLeft)||0:0}scrollY(){return this.ka(`y`)}scrollX(){return this.ka(`x`)}},Oc=e=>Xo(e?.config.mask_personal_data_properties,e?.config.custom_personal_data_properties,e?.config.disable_capture_url_hashes
1),kc=class{constructor(e,t,n,r){this.Be=e=>{let t=this.Sa();if(t&&t.sessionId===e)return;let n={sessionId:e,props:this.xa(this._instance)};this.Ca.register({[wi]:n})},this._instance=e,this.$a=t,this.Ca=n,this.xa=r||Oc,this.$a.onSessionId(this.Be)}Sa(){return this.Ca.props[wi]}getSetOnceProps(){let e=this.Sa()?.props;return e?`r`in e?Zo(e,this._instance.config.disable_capture_url_hashes):{$referring_domain:e.referringDomain,$pathname:e.initialPathName,utm_source:e.utm_source,utm_campaign:e.utm_campaign,utm_medium:e.utm_medium,utm_content:e.utm_content,utm_term:e.utm_term}:{}}getSessionProps(){let e={};return U(ra(this.getSetOnceProps()),(t,n)=>{n===`$current_url`&&(n=`url`),e[`$session_entry_${x(n)}`]=t}),e}},Ac=class{on(e,t){return this.Ta[e]||(this.Ta[e]=[]),this.Ta[e].push(t),()=>{this.Ta[e]=this.Ta[e].filter(e=>e!==t)}}emit(e,t){for(let n of this.Ta[e]||[])n(t);for(let n of this.Ta[`*`]||[])n(e,t)}constructor(){this.Ta={}}},jc=B(`[SessionId]`),Mc=864e5,Nc=class{on(e,t){return this.Ia.on(e,t)}constructor(e,t,n){var r;if(this.Ma=null,this.Ea=null,this.Pa=[],this.Ra=void 0,this.Aa=!1,this.Ia=new Ac,this.Fa=(e,t)=>!(!te(e)||!te(t))&&Math.abs(e-t)>this.sessionTimeoutMs,!e.persistence)throw Error(`SessionIdManager requires a PostHogPersistence instance`);if(e.config.cookieless_mode===`always`)throw Error(`SessionIdManager cannot be used with cookieless_mode="always"`);this.Ir=e.config,this.Ca=e.persistence,this.He=void 0,this.Xt=void 0,this._sessionStartTimestamp=null,this.Oa=void 0,this._sessionActivityTimestamp=null,this.Da=t||ma,this.La=n||ma;let i=this.Ir.persistence_name||this.Ir.token;if(this._sessionTimeoutMs=1e3*me(this.Ir.session_idle_timeout_seconds||1800,60,36e3,jc.createLogger(`session_idle_timeout_seconds`),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.Na(),this.qa=`ph_`+i+`_window_id`,this.ja=`ph_`+i+`_primary_window_exists`,this.Ba()){let e=J.Dt(this.qa),t=J.Dt(this.ja);e&&!t?this.He=e:J.Lt(this.qa),J.At(this.ja,!0)}(r=this.Ir.bootstrap)!=null&&r.sessionID&&this.setBootstrapSessionId(this.Ir.bootstrap.sessionID),this.Ha()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return A(this.Pa)&&(this.Pa=[]),this.Pa.push(e),this.Xt&&e(this.Xt,this.He),()=>{this.Pa=this.Pa.filter(t=>t!==e)}}Ba(){return this.Ir.persistence!==`memory`&&!this.Ca.mi&&J.Et()}za(e){e!==this.He&&(this.He=e,this.Ba()&&J.At(this.qa,e))}Ua(){return this.He?this.He:this.Ba()?J.Dt(this.qa):null}Wa(e){let t=this.Ma;return!M(t)&&!M(e)&&5e3>Math.abs(e-t)}Va(e,t,n){let r=t!==this._sessionActivityTimestamp,i=e===this.Xt&&n===this._sessionStartTimestamp;this._sessionStartTimestamp=n,this._sessionActivityTimestamp=t,this.Xt=e,i&&!r||i&&this.Wa(t)||(this.Ma=t,this.Ca.register({[Ur]:[t,e,n]}))}Ga(){let e=this.Ir?.persistence_save_debounce_ms;return te(e)&&e>0}Za(){this.Ga()?this.Ca.refreshKey(Ur):(this.Ca.flush(),this.Ca.load())}Qa(){if(M(this._sessionActivityTimestamp)||this._sessionActivityTimestamp===this.Ma)return;this.Za();let[,e,t]=this.Ja();e===this.Xt&&t===this._sessionStartTimestamp&&(this.Ma=this._sessionActivityTimestamp,this.Ca.register({[Ur]:[this._sessionActivityTimestamp,this.Xt??null,this._sessionStartTimestamp]}),this.Ca.flush())}Ka(){let[e]=this.Ja(),t=te(e)?e:0,n=te(this._sessionActivityTimestamp)?this._sessionActivityTimestamp:0;return Math.max(t,n)}Xa(e){return this.Za(),this.Fa(e,this.Ka())}Ja(){let e=this.Ca.props[Ur];return E(e)&&e.length===2&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this.Ma=null,this.Oa=void 0,clearTimeout(this.Ya),this.Ya=void 0,this.Va(null,null,null)}setBootstrapSessionId(e,t=!1){let n=((e,t=new Date().getTime())=>{try{let n=(e=>{let t=e.replace(/-/g,``);if(t.length!==32)throw Error(`Not a valid UUID`);if(t[12]!==`7`)throw Error(`Not a UUIDv7`);return parseInt(t.substring(0,12),16)})(e);return n>t+6e4?void jc.error(`Bootstrap sessionID cannot be in the future`):n}catch(e){jc.error(`Invalid sessionID in bootstrap`,e);return}})(e);return!A(n)&&(t?this.Oa={sessionId:e,sessionStartTimestamp:n}:this.Va(e,new Date().getTime(),n),!0)}destroy(){this.Aa=!0,this.Qa(),clearTimeout(this.Ya),this.Ya=void 0,this.Ra&&e&&(e.removeEventListener(Yi,this.Ra,{capture:!1}),this.Ra=void 0),this.Pa=[]}Ha(){this.Ra=()=>{this.Qa(),this.Ba()&&J.Lt(this.ja)},G(e,Yi,this.Ra,{capture:!1})}
1checkAndGetSessionAndWindowId(e=!1,t=null,n=!1){if(this.Ir.cookieless_mode===`always`)throw Error(`checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"`);let r=t||new Date().getTime(),i=this.Xt;if(n)this.Ea=r;else if(M(this.Ea)||this.Ea>r||r-this.Ea>=1e3){var a,o;(a=(o=this.Ca).syncCookieProperties)==null||a.call(o),this.Ea=r}let[,s,c]=this.Ja(),l=!A(i)&&s!==i,u=this.Ka(),d=this.Ua(),f=this.Oa,p=!!f&&(f.sessionStartTimestamp>r+6e4||r-f.sessionStartTimestamp>Mc),m=f?p:te(c)&&Math.abs(r-c)>Mc,h=!1,g=l,_=!s||!!f,v=s,y=!_&&!e&&this.Fa(r,u);if(y&&(y=this.Xa(r),y||jc.info(`cross-tab refresh kept the session alive`,{sessionId:s}),[,s,c]=this.Ja()),_||y||m){g=!1;let e=f&&!p;s=e?f.sessionId:this.Da(),d=this.La(),jc.info(`new session ID assigned`,{sessionId:s,windowId:d,bootstrapped:!!e,changeReason:{noSessionId:_,activityTimeout:y,sessionPastMaximumLength:m}}),c=e?f.sessionStartTimestamp:r,this.Oa=void 0,h=!0}else d||(d=this.La(),h=!0),g||=s!==v,g&&(jc.info(`adopted cross-tab session id`,{sessionId:s,windowId:d}),h=!0);let b=te(u)&&e&&!m?u:r,x=te(c)?c:new Date().getTime();this.za(d),this.Va(s,b,x),e||this.Na();let S={noSessionId:_,activityTimeout:y,sessionPastMaximumLength:m,crossTabAdoption:g};return h&&this.Pa.forEach(e=>e(s,d,S)),{sessionId:s,windowId:d,sessionStartTimestamp:x,changeReason:h?S:void 0,lastActivityTimestamp:u}}Na(){this.Aa||(clearTimeout(this.Ya),this.Ya=setTimeout(()=>{if(!this.Aa){if(this.Xa(new Date().getTime())){let e=this.Xt;this.resetSessionId(),this.Ia.emit(`forcedIdleReset`,{idleSessionId:e})}else this.Na()}},1.1*this.sessionTimeoutMs))}},Pc=function(e,t){if(!e)return!1;let n=e.userAgent;if(n&&pe(n,t))return!0;try{let n=e?.userAgentData;if(n?.brands&&n.brands.some(e=>pe(e?.brand,t)))return!0}catch{}return!!e.webdriver};function Fc(){return(Fc=L(function*(){let e=n?.userAgentData;if(e?.getHighEntropyValues)try{let t=(yield e.getHighEntropyValues([`model`]))?.model;return j(t)&&t.length>0?t:void 0}catch(e){z.info(`Unable to resolve $device_model from userAgentData.getHighEntropyValues`,e);return}})).apply(this,arguments)}function Ic(e,t){let n=`$survey_${t}/${e.id}`;return e.current_iteration&&e.current_iteration>0&&(n=`$survey_${t}/${e.id}/${e.current_iteration}`),n}function Lc(e){var t;return!!((t=e.conditions)!=null&&(t=t.events)!=null&&(t=t.values)!=null&&t.length)}var Rc=(e,t)=>{if(!(e=>{try{new RegExp(e)}catch{return!1}return!0})(t))return!1;try{return new RegExp(t).test(e)}catch{return!1}},zc=e=>e.toLowerCase(),Bc={exact:(e,t)=>t.some(t=>e.some(e=>t===e)),is_not:(e,t)=>t.every(t=>e.every(e=>t!==e)),regex:(e,t)=>t.some(t=>e.some(e=>Rc(t,e))),not_regex:(e,t)=>t.every(t=>e.every(e=>!Rc(t,e))),icontains:(e,t)=>t.map(zc).some(t=>e.map(zc).some(e=>t.includes(e))),not_icontains:(e,t)=>t.map(zc).every(t=>e.map(zc).every(e=>!t.includes(e))),gt:(e,t)=>t.some(t=>{let n=parseFloat(t);return!isNaN(n)&&e.some(e=>n>parseFloat(e))}),lt:(e,t)=>t.some(t=>{let n=parseFloat(t);return!isNaN(n)&&e.some(e=>n<parseFloat(e))})};function Vc(e,t){return!e||Object.entries(e).every(([e,n])=>{let r=t?.[e];if(r==null)return!1;let i=Bc[n.operator];return!!i&&i(n.values,[String(r)])})}function Hc(e,t,n){return Mo({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:n})}var Uc=`custom`,Wc=`i.posthog.com`,Gc=/^\/static\//,Kc=[`/s/`,`/e/`,`/i/`],qc=class{constructor(e){this.tu={},this.instance=e}get apiHost(){let e=this.instance.config.api_host.trim().replace(/\/$/,``);return e===`https://app.posthog.com`?`https://us.i.posthog.com`:e}get flagsApiHost(){let e=this.instance.config.flags_api_host;return e?e.trim().replace(/\/$/,``):this.apiHost}get uiHost(){let e=this.instance.config.ui_host?.replace(/\/$/,``);return e||=this.apiHost.replace(`.${Wc}`,`.posthog.com`),e===`https://app.posthog.com`?`https://us.posthog.com`:e}get region(){return this.tu[this.apiHost]||(this.tu[this.apiHost]=/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?`us`:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?`eu`:Uc),this.tu[this.apiHost]}eu(e){if(!Gc.test(e))return;let t=this.instance.config.asset_host;return typeof t==`string`&&t.trim().replace(/\/$/,``)||void 0}iu(e){let t=No(e);return t?t.protocol+`//`+t.host+t.pathname:void 0}nu(e,t,n){if(e===`ui`)return n;let r=n,i=this.instance.config.rewriteRequestPath;if(i){let e=No(n)?.href||n;r=i(new URL(e)).toString()}if(i&&e===`api`&&Kc.some(e=>t.indexOf(e)===0)){let e=this.iu(r);if(e){let t=this.apiHost,n=this.su;n?.apiHost===t&&n.rewriteRequestPath===i||(n={apiHost:t,rewriteRequestPath:i,urls:new Set},this.su=n),n.urls.add(e)}}return r}isIngestionEndpoint(e){let t=this.su,n=this.iu(e);return t?.apiHost===this.apiHost&&t.rewriteRequestPath===this.instance.config.rewriteRequestPath&&!!n&&t.urls.has(n)}endpointFor(e,t=``){if(t&&=t[0]===`/`?t:`/${t}`,e===`ui`)return this.nu(e,t,this.uiHost+t);if(e===`flags`)return this.nu(e,t,this.flagsApiHost+t);if(e===`assets`){let n=this.eu(t);if(n)return this.nu(e,t,`${n}${t}`)}if(this.region===Uc)return this.nu(e,t,this.apiHost+t);let n=Wc+t;switch(e){case`assets`:return this.nu(e,t,`https://${this.region}-assets.${n}`);case`api`:return this.nu(e,t,`https://${this.region}.${n}`)}}},$=B(`[Surveys]`),Jc=e=>{try{let t=(e=>((e,t)=>`seenSurvey_${function(e){return e.current_iteration&&e.current_iteration>0?`${e.id}_${e.current_iteration}`:e.id}(t)}`)(0,e))(e);if(localStorage.getItem(t))return;localStorage.setItem(t,`true`)}catch(e){$.error(`Failed to persist survey seen state`,e)}},Yc=[ms.Popover,ms.Widget,ms.API],Xc={ignoreConditions:!1,ignoreDelay:!1,displayType:_s.Popover}
1,Zc=B(`[PostHog ExternalIntegrations]`),Qc={intercom:`intercom-integration`,crispChat:`crisp-chat-integration`},$c=class{constructor(e){this._instance=e}qo(e,t){var n,r;(n=f.__PosthogExtensions__)==null||(r=n.loadExternalDependency)==null||r.call(n,this._instance,e,e=>{if(e)return Zc.error(`failed to load script`,e);t()})}startIfEnabledOrStop(){for(let[r,i]of Object.entries(this._instance.config.integrations??{})){var e,t,n;i&&!((e=f.__PosthogExtensions__)!=null&&(e=e.integrations)!=null&&e[r])&&this.qo(Qc[r],()=>{var e;(e=f.__PosthogExtensions__)==null||(e=e.integrations)==null||(e=e[r])==null||e.start(this._instance)}),!i&&(t=f.__PosthogExtensions__)!=null&&(t=t.integrations)!=null&&t[r]&&((n=f.__PosthogExtensions__)==null||(n=n.integrations)==null||(n=n[r])==null||n.stop())}}},el=class{constructor(e,t){this.$=e,this.mo=t,this.ru=new Map,this.xo=!1}add(e){var t=this;return L(function*(){if(t.xo)throw Error(`Cannot add an extension to a disposed ExtensionRuntime`);if(t.ru.has(e.name))throw Error(`Browser extension "${e.name}" is already registered`);t.ru.set(e.name,e);try{let n=e.setup(t.mo);n&&(yield n)}catch(n){let r=t.ru.get(e.name)===e;r&&t.ru.delete(e.name),t.$.error(`Failed to set up browser extension "${e.name}"`,n),r&&t.ou(e)}})()}getExtension(e){return this.ru.get(e)}dispose(){if(this.xo)return;this.xo=!0;let e=Array.from(this.ru.values()).reverse();this.ru.clear();for(let t of e)this.ou(t)}ou(e){try{let t=e.dispose?.call(e);t&&D(t.then)&&t.then(void 0,t=>{this.$.error(`Failed to dispose browser extension "${e.name}"`,t)})}catch(t){this.$.error(`Failed to dispose browser extension "${e.name}"`,t)}}},tl=class{constructor(e){this._instance=e}initialize(){}get(e){let t=this._instance.persistence;if(typeof e==`string`)return t?.get_property(e);let n={};for(let r of e){let e=t?.get_property(r);A(e)||(n[r]=e)}return n}set(e,t){var n;(n=this._instance.persistence)==null||n.register(typeof e==`string`?{[e]:t}:e)}remove(e){var t;(t=this._instance.persistence)==null||t.unregister(e)}},nl=`extensionsRemoteConfig`,rl=class{constructor(e){this.instance=e,this.xo=!1,this.$=z,this.lu=e.au,this.kv=new tl(e),this.onEvent=e=>vs(this.instance.on(`eventCaptured`,t=>{try{e({event:t.event,properties:t.properties})}catch(e){this.$.error(`Browser extension event listener failed`,e)}})),this.onRemoteConfig=e=>{if(this.xo)return vs(()=>{});let t=t=>{try{e(t)}catch(e){this.$.error(`Browser extension remote config listener failed`,e)}},n=this.instance.uu.on(nl,t);return this.lu&&t(this.lu),vs(n)},this.hu=new el(z.createLogger(`[BrowserExtensions]`),this)}get logger(){return this.$}get distinctId(){return this.instance.get_distinct_id()}get anonymousId(){return this.instance.get_property(`$device_id`)??this.distinctId}get deviceId(){let e=this.instance.get_property(_r);return typeof e==`string`?e:void 0}get library(){return{name:V.LIB_NAME,version:V.LIB_VERSION}}get initialPersonProperties(){return this.instance.persistence?.get_initial_props()??{}}get groups(){return this.instance.getGroups()}get session(){try{let e=this.instance.sessionManager?.checkAndGetSessionAndWindowId(!0);return{sessionId:e?.sessionId??``,windowId:e?.windowId??``,sessionStartTimestamp:e?.sessionStartTimestamp??0}}catch{return{sessionId:``,windowId:``,sessionStartTimestamp:0}}}get canCapture(){return this.instance.is_capturing()}get projectToken(){return this.instance.config.token}add(e){return this.hu.add(e)}getExtension(e){return this.hu.getExtension(e)}capture(e,t,n){n?this.instance.capture(e,t,{timestamp:n.timestamp,uuid:n.uuid,$set:n.set,$set_once:n.setOnce}):this.instance.capture(e,t)}registerDynamicEventProperties(e){return vs(this.instance.cu(e))}handleRemoteConfig(e){this.xo||(this.lu=e,this.instance.uu.emit(nl,e))}sendRequest(e){var t=this;return L(function*(e,n={}){let r=t.instance.requestRouter.endpointFor(n.target??`api`,e),i={method:n.method,url:n.query?lc(r,n.query):r,data:n.body,headers:n.headers,timeout:n.timeoutMs,fireCallbackOnDrop:!0,transport:n.transport,compression:n.compression,compressionFallback:n.target===`flags`&&n.compression===`best-available`?g.Base64:void 0,timestampMode:n.sentAt};return n.transport===`sendBeacon`?(t.instance._send_request(i),{statusCode:202}):new Promise(e=>{i.callback=e,t.instance._send_request(i)})}).apply(this,arguments)}dispose(){this.xo||(this.xo=!0,this.hu.dispose())}},il={},al=0,ol=()=>{}
1,sl=`Consent opt in/out is not valid with cookieless_mode="always" and will be ignored`,cl=`Surveys module not available`,ll=`sanitize_properties is deprecated. Use before_send instead`,ul=`Invalid value for property_denylist config: `,dl=/^[A-Za-z0-9_-]{1,400}$/,fl=/^fb\.[0-9]+\.[0-9]+\.[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)?$/,pl=/^fb\.[0-9]+\.[0-9]+\.[0-9]+$/,ml=[`token`,`distinct_id`,ji],hl=`posthog`,gl=e=>{let t={};return e&&e!==`unset`?(`2025-11-30`>e||(t.strictMinimumDuration=!0),`2026-05-30`>e||(t.canvasCapture={resolutionScale:.6}),`2026-06-25`>e||(t.streamNetworkBody=!0),`2026-08-30`>e||(t.captureJsonLd=!0),t):t},_l=t=>{var n;return R({api_host:`https://us.i.posthog.com`,flags_api_host:null,ui_host:null,asset_host:null,token:``,autocapture:!0,cross_subdomain_cookie:oa(r?.location),persistence:`localStorage+cookie`,persistence_name:``,cookie_persisted_properties:[],loaded:ol,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:`if_capture_pageview`,defaults:t??`unset`,__preview_deferred_init_extensions:!1,__preview_external_dependency_versioned_paths:!1,__preview_cookie_wins_on_conflict:!1,debug:i&&j(i?.search)&&i.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_conversations:!1,disable_product_tours:!1,disableDeviceModel:!1,reuseAnonymousId:!1,disable_external_dependency_loading:!1,strict_script_versioning:`fallback`,enable_recording_console_log:void 0,secure_cookie:(e==null||(n=e.location)==null?void 0:n.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,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_feature_flags_dedup_per_session:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,surveys_request_timeout_ms:1e4,on_request_error(e){z.error(`Bad HTTP status: `+e.statusCode+` `+e.text)},get_device_id:e=>e,capture_performance:void 0,name:`posthog`,bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:qi,before_send:void 0,get_current_url:void 0,request_queue_config:{flush_interval_ms:3e3},error_tracking:{},_onCapture:ol},(e=>({rageclick:e&&e>=`2026-05-30`?{content_ignorelist:Za,ignore_text_selection:!0}
1:!e||`2025-11-30`>e||{content_ignorelist:!0},capture_pageview:!e||`2025-05-24`>e||`history_change`,session_recording:gl(e),external_scripts_inject_target:e&&e>=`2026-01-30`?`head`:`body`,internal_or_test_user_hostname:e&&e>=`2026-01-30`?/^(localhost|127\.0\.0\.1)$/:void 0,persistence_save_debounce_ms:e&&e>=`2026-05-30`?250:0,split_storage:!(!e||`2026-05-30`>e),detect_google_search_app:!(!e||`2026-05-30`>e),disable_capture_url_hashes:!(!e||`2026-06-25`>e),cookieWinsOnConflict:!(!e||e===`unset`||`2026-08-29`>e)}))(t))},vl=[[`process_person`,`person_profiles`],[`xhr_headers`,`request_headers`],[`cookie_name`,`persistence_name`],[`disable_cookie`,`disable_persistence`],[`__preview_disable_beacon`,`disable_beacon`],[`store_google`,`save_campaign_params`],[`verbose`,`debug`],[`__preview_cookie_wins_on_conflict`,`cookieWinsOnConflict`]],yl=e=>{let t={};for(let[n,r]of vl)A(e[n])||(t[r]=e[n]);let n=W({},t,e),r=e.__preview_external_dependency_versioned_paths;return A(r)||(A(e.strict_script_versioning)&&(n.strict_script_versioning=!!r),j(r)&&A(e.asset_host)&&(n.asset_host=r)),E(e.property_blacklist)&&(A(e.property_denylist)?n.property_denylist=e.property_blacklist:E(e.property_denylist)?n.property_denylist=[...e.property_blacklist,...e.property_denylist]:z.error(ul+e.property_denylist)),n},bl=class{constructor(){this.__forceAllowLocalhost=!1}get du(){return this.__forceAllowLocalhost}set du(e){z.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}},xl=class t{vu(e){if(!e)return;let t=this.ru.indexOf(e);t!==-1&&this.ru.splice(t,1)}fu(e,t){var n;return this.vu(e),this.ru.push(t),(n=t.initialize)==null||n.call(t),t}pu(){return this.config.cookieless_mode===`always`||this.config.cookieless_mode===`on_reject`&&this.consent.isRejected()}gu(){if(this.mu||this.config.reuseAnonymousId||this.config.segment||this.pu())return;let e=this.config.persistence===`memory`||this.config.persistence===`sessionStorage`;if(!e&&!this.config.disable_persistence||this.yu)return;let t,n,r;e?(t=`persistence is set to '${this.config.persistence}'`,n=this.config.persistence===`memory`?`on every page load`:`for every new browser tab or window`,r=`Either set persistence to 'localStorage+cookie', keep this persistence and pass a stable ID through bootstrap.distinctID, or enable reuseAnonymousId.`):(t=`persistence is disabled (disable_persistence is true)`,n=`on every page load`,r=`Either set disable_persistence to false, keep persistence disabled and pass a stable ID through bootstrap.distinctID, or enable reuseAnonymousId.`),this.mu=!0,console.warn(`[PostHog.js]`,`${t} but no bootstrap.distinctID was provided. PostHog will mint a new distinct ID ${n}, so calling identify() merges a new ID onto the person each time. A person can then pass the distinct-ID limit and its events stop appearing on person pages and the session tab. ${r}`)}bu(){if(this.pu()||this.get_distinct_id()!==`$posthog_cookieless`)return;let e=this.persistence;if(!e)return;this._u()||e.load(!0);let t=this.get_distinct_id();if(!t||t===`$posthog_cookieless`){let t=this.config.get_device_id(ma());this.register({distinct_id:t,$device_id:t}),e.set_property(H,Gi)}this.wu()}get decideEndpointWasHit(){var e;return(e=this.featureFlags?.hasLoadedFlags)!=null&&e}get flagsEndpointWasHit(){var e;return(e=this.featureFlags?.hasLoadedFlags)!=null&&e}constructor(){this.ku=!1,this.Su=!1,this.webPerformance=new bl,this.xu=!1,this.version=V.LIB_VERSION,this.Cu=new Set,this.$u=``,this.uu=new Ac,this.ru=[],this.Tu=[],this.yu=!1,this.mu=!1,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=_l(),this.SentryIntegration=Do,this.sentryIntegration=e=>function(e,t){let n=Eo(e,t);return{name:To,processEvent:e=>n(e)}}(this,e),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint=`/e/`,this.Iu=!1,this.Mu=null,this.Eu=null,this.Pu=null,this.scrollManager=new Dc(this),this.pageViewManager=new Oo(this),this.rateLimiter=new Ss(this),this.requestRouter=new qc(this),this.consent=new Na(this),this.externalIntegrations=new $c(this);let e=t.__defaultExtensionClasses??{};this.featureFlags=e.featureFlags&&new e.featureFlags(this),this.toolbar=e.toolbar&&new e.toolbar(this),this.surveys=e.surveys&&new e.surveys(this),this.conversations=e.conversations&&new e.conversations(this),this.logs=e.logs&&new e.logs(this),this.metrics=e.metrics&&new e.metrics(this),this.experiments=e.experiments&&new e.experiments(this),this.exceptions=e.exceptions&&new e.exceptions(this),this.people={set:(e,t,n)=>{let r=j(e)?{[e]:t}:e;this.setPersonProperties(r),n?.({})},set_once:(e,t,n)=>{let r=j(e)?{[e]:t}:e;this.setPersonProperties(void 0,r),n?.({})}},this.on(`eventCaptured`,e=>z.info(`send "${e?.event}"`,e))}init(e,n,r){if(r&&r!==hl){let i=il[r]??new t;return i._init(e,n,r),il[r]=i,il[hl][r]=i,i}return this._init(e,n,r)}_init(t,n={},r){var i;let a=j(t)?t.trim():``;if(!a)return z.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 a===this.config?.token?console.warn(`[PostHog.js]`,`You have already initialized PostHog! Re-initializing is a no-op`):console.warn(`[PostHog.js]`,`You have already initialized PostHog with a different project token! Re-initializing is a no-op, so events will keep going to the project this instance was initialized with. To capture into a second project, load PostHog once, then initialize a named instance after the SDK has loaded, e.g. posthog.init('${a}', { ... }, 'project2')`),this;this.__loaded=!0,this.config=_l(n.defaults),n.debug=this.Ru(n.debug),this.Au=n,this.Fu=[],n.person_profiles?this.Eu=n.person_profiles:n.process_person&&(this.Eu=n.process_person);let o=_l(n.defaults),s=yl(n),c=W({},o,s,{name:r,token:a});O(o.rageclick)&&O(s.rageclick)&&(c.rageclick=W({},o.rageclick,s.rageclick)),O(o.session_recording)&&O(s.session_recording)&&(c.session_recording=W({},o.session_recording,s.session_recording)),this.set_config(c),this.config.on_xhr_error&&z.error(`on_xhr_error is deprecated. Use on_request_error instead`),this.compression=n.disable_compression?void 0:fs.GZipJS;let l=this._u();if(this.persistence=new ds(this.config,l),this.sessionPersistence=this.config.persistence===`
1sessionStorage`||this.config.persistence===`memory`?this.persistence:new ds(R(R({},this.config),{},{persistence:`sessionStorage`}),l,!1),this.$u=`ph_`+(this.config.persistence_name||this.config.token)+`_session_registered_properties`,this.config.persistence!==`memory`&&!l&&J.Et()){let e=J.Dt(this.$u);E(e)&&e.forEach(e=>{j(e)&&this.Cu.add(e)})}else J.Lt(this.$u);let u=R({},this.persistence.props),d=R({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.Ou=new wc((e,t)=>this.Du(e,t),this.config.request_queue_config),this.Lu=new Ec(this),this.__request_queue=[];let f=this.pu();f||(this.sessionManager=new Nc(this),this.sessionPropsManager=new kc(this,this.sessionManager,this.persistence),this.sessionManager.onSessionId((e,t,n)=>{(n!=null&&n.activityTimeout||n!=null&&n.sessionPastMaximumLength||n!=null&&n.crossTabAdoption)&&this.Nu()})),this.qu(),this.config.__preview_deferred_init_extensions?(z.info(`Deferring extension initialization to improve startup performance`),setTimeout(()=>{this.ju(f)},0)):(z.info(`Initializing extensions synchronously`),this.ju(f)),V.DEBUG=V.DEBUG||this.config.debug,V.DEBUG&&z.info(`Starting in debug mode`,{this:this,config:n,thisC:R({},this.config),p:u,s:d}),this.config.identity_distinct_id&&!((i=n.bootstrap)!=null&&i.distinctID)&&(n.bootstrap=R(R({},n.bootstrap),{},{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0}));let p=n.bootstrap?.distinctID;if(this.yu=!!p&&!ee(p),n.bootstrap?.distinctID){let e=n.bootstrap.distinctID,t=this.get_distinct_id(),r=this.persistence.get_property(H);if(n.bootstrap.isIdentifiedID&&t!=null&&t!==e&&r===`anonymous`)this.identify(e);else if(n.bootstrap.isIdentifiedID&&t!=null&&t!==e&&r===`identified`)z.warn(`Bootstrap distinctID differs from an already-identified user. The existing identity is preserved. Call reset() before reinitializing if you intend to switch users.`);else{let t=this.config.get_device_id(ma()),r=n.bootstrap.isIdentifiedID?t:e;this.persistence.set_property(H,n.bootstrap.isIdentifiedID?Ki:Gi),this.register({distinct_id:e,$device_id:r})}}if(f)this.register_once({distinct_id:Ai,$device_id:null},``);else if(!this.get_distinct_id()){let e=this.config.get_device_id(ma());this.register_once({distinct_id:e,$device_id:e},``),this.persistence.set_property(H,Gi)}return G(e,`onpagehide`in self?`pagehide`:`unload`,this._handle_unload.bind(this),{passive:!1}),G(e,`pageshow`,()=>{var e;this.ku=!1,this.Su||(e=this.Lu)==null||e.resume()}),n.segment?wo(this,()=>this.Bu()):this.Bu(),D(this.config._onCapture)&&this.config._onCapture!==ol&&(z.warn("onCapture is deprecated. Please use `before_send` instead"),this.on(`eventCaptured`,e=>this.config._onCapture(e.event,e))),this.config.ip&&z.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.config.disableDeviceModel||function(){return Fc.apply(this,arguments)}().then(e=>{e&&this.register({[vr]:e})}).catch(ol),this}Hu(e){let t=e;return j(t.name)&&D(t.setup)}zu(e,t){this.Hu(e)?t.push(()=>{this.Uu().add(e).catch(()=>
1e.dispose?.call(e)).catch(t=>{z.error(`Failed to dispose browser extension "${e.name}"`,t)})}):this.ru.push(e)}qu(){let e=this.config.__extensionClasses?.featureFlags??t.__defaultExtensionClasses?.featureFlags;var n,r,i;e&&(this.featureFlags&&this.featureFlags instanceof e||((n=this.Wu)==null||n.call(this),this.Wu=void 0,this.featureFlags=new e(this)),D(this.featureFlags.onReloading)&&D(this.featureFlags.setup)?this.Wu||(this.Wu=this.featureFlags.onReloading(()=>{this.uu.emit(`featureFlagsReloading`,!0)}),this.Uu().add(this.featureFlags)):(r=(i=this.featureFlags).initialize)==null||r.call(i))}ju(e){let n=performance.now(),r=R(R({},t.__defaultExtensionClasses),this.config.__extensionClasses),i=[];r.exceptions&&this.ru.push(this.exceptions=this.exceptions??new r.exceptions(this)),r.historyAutocapture&&this.ru.push(this.historyAutocapture=new r.historyAutocapture(this)),r.tracingHeaders&&this.ru.push(this.tracingHeaders=new r.tracingHeaders(this)),r.siteApps&&this.ru.push(this.siteApps=new r.siteApps(this)),r.sessionRecording&&!e&&this.ru.push(this.sessionRecording=new r.sessionRecording(this)),this.config.disable_scroll_properties||i.push(()=>{this.scrollManager.startMeasuringScrollPosition()}),r.autocapture&&this.zu(this.autocapture=new r.autocapture(this),i),r.surveys&&this.zu(this.surveys=this.surveys??new r.surveys(this),i),r.logs&&this.zu(this.logs=this.logs??new r.logs(this),i),r.metrics&&this.ru.push(this.metrics=this.metrics??new r.metrics(this)),r.conversations&&this.ru.push(this.conversations=this.conversations??new r.conversations(this)),r.productTours&&this.ru.push(this.productTours=new r.productTours(this)),r.heatmaps&&this.ru.push(this.heatmaps=new r.heatmaps(this)),r.webVitalsAutocapture&&this.ru.push(this.webVitalsAutocapture=new r.webVitalsAutocapture(this)),r.exceptionObserver&&this.ru.push(this.exceptionObserver=new r.exceptionObserver(this)),r.deadClicksAutocapture&&this.ru.push(this.deadClicksAutocapture=new r.deadClicksAutocapture(this,xo)),r.toolbar&&this.ru.push(this.toolbar=this.toolbar??new r.toolbar(this)),r.experiments&&this.ru.push(this.experiments=this.experiments??new r.experiments(this)),this.ru.forEach(e=>{e.initialize&&i.push(()=>{var t;(t=e.initialize)==null||t.call(e)})}),i.push(()=>{if(this.Vu){let e=this.Vu;this.Vu=void 0,this.ru.forEach(t=>t.onRemoteConfig?.call(t,e))}}),this.Gu(i,n)}Gu(e,t){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-t>=30&&e.length>0)return void setTimeout(()=>{this.Gu(e,t)},0);let n=e.shift();if(n)try{n()}catch(e){z.error(`Error initializing extension:`,e)}}let n=Math.round(performance.now()-t);this.register_for_session({[Mi]:this.config.__preview_deferred_init_extensions?`deferred`:`synchronous`,[Ni]:n}),this.config.__preview_deferred_init_extensions&&z.info(`PostHog extensions initialized (${n}ms)`)}Xl(e){var t;if(!r||!r.body)return z.info(`document not ready yet, trying again in 500 milliseconds...`),void setTimeout(()=>{this.Xl(e)},500);if(this.config.__preview_deferred_init_extensions&&(this.Vu=e),this.au=e,this.compression=void 0,e.ok){var n;let t=e.config;t.supportedCompression&&!this.config.disable_compression&&(this.compression=y(t.supportedCompression,fs.GZipJS)?fs.GZipJS:y(t.supportedCompression,fs.Base64)?fs.Base64:void 0),(n=t.analytics)!=null&&n.endpoint&&(this.analyticsDefaultEndpoint=t.analytics.endpoint)}this.set_config({person_profiles:this.Eu?this.Eu:qi}),(t=this.Zu)==null||t.handleRemoteConfig(e),this.ru.forEach(t=>t.onRemoteConfig?.call(t,e))}Bu(){try{this.config.loaded(this)}catch(e){z.critical("`loaded` function failed",e)}if(this.Qu(),this.config.internal_or_test_user_hostname&&i?.hostname){let e=i.hostname,t=this.config.internal_or_test_user_hostname;(typeof t==`string`?e===t:t.test(e))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout(()=>{(this.consent.isOptedIn()||this.pu())&&this.Ju()},1),this.Ku=new ws(this),this.Ku.load()}Qu(){var e;this.is_capturing()&&this.config.request_batching&&((e=this.Ou)==null||e.enable())}_dom_loaded(){this.is_capturing()&&ea(this.__request_queue,e=>this.Du(e)),this.__request_queue=[],this.Qu()}_handle_unload(){var e,t,n,r,i,a;this.ku=!0,(e=this.surveys)==null||(t=e.handlePageUnload)==null||t.call(e),(n=this.metrics)==null||n.flush(`sendBeacon`),this.config.request_batching?(this.Xu()&&this.capture(Zi),(r=this.logs)==null||r.flushLogs(`sendBeacon`),(i=this.Ou)==null||i.unload(),(a=this.Lu)==null||a.unload()):this.Xu()&&this.capture(Zi,null,{transport:`sendBeacon`})}_send_request(e){Cc(this,e)}Du(e,t){this.Lu?this.Lu.retriableRequest(e,t):this._send_request(t?R(R({},e),{},{transport:t}):e)}_execute_array(e){al++;try{let t,n=[],r=[],i=[];ea(e,e=>{if(e){if(t=e[0],E(t))i.push(e);else if(D(e))try{e.call(this)}catch(t){z.error(`Error executing queued PostHog call`,e,t)}else E(e)&&t===`alias`?n.push(e):E(e)&&t.indexOf(`capture`)!==-1&&D(this[t])?i.push(e):r.push(e)}});let a=function(e,t){ea(e,function(e){try{if(E(e[0])){let n=t;U(e,function(e){n=n[e[0]].apply(n,e.slice(1))})}else t[e[0]].apply(t,e.slice(1))}catch(t){z.error(`Error executing queued PostHog call`,e,t)}})};a(n,this),a(r,this),a(i,this)}finally{al--}}push(e){if(al>0&&E(e)&&j(e[0])){let n=t.prototype[e[0]];D(n)&&n.apply(this,e.slice(1));return}this._execute_array([e])}get Yu(){return{property:xr,persistenceKey:Sr,cookieName:`_fbc`,pattern:fl,register:(e,t)=>this.persistence?.register({[Sr]:{value:e,delivered:t}}),unregister:()=>this.persistence?.unregister(Sr)}}get th(){return{property:Cr,persistenceKey:wr,cookieName:`_fbp`,pattern:pl,register:(e,t)=>this.persistence?.register({[wr]:{value:e,delivered:t}}),unregister:()=>this.persistence?.unregister(wr)}}eh(e){let t=this.persistence?.get_property(e.persistenceKey);return j(t)&&e.pattern.test(t)?{value:t,delivered:!1}:O(t)&&j(t.value)&&e.pattern.test(t.value)?{value:t.value,delivered:!0===t.delivered}:void 0}ih(e,t,n){return t===n?.value?{value:t,pending:!n.delivered}:(e.register(t,!1),{value:t,pending:!0})}nh(e){if(!this.config.save_campaign_params||this.pu())return;let t=ca(e.cookieName);return j(t)&&e.pattern.test(t)?t:void 0}sh(e,t,n,r){if(!this.persistence)return;let i=this.Yu;this.persistence.refreshKey(i.persistenceKey);let a=this.eh(i);if(r)return void i.unregister();if(n)return j(t)&&fl.test(t)?this.ih(i,t,a):void i.unregister();let o=j(e)&&dl.test(e)?e:void 0,s=this.nh(i);return s&&((e,t,n)=>{let r=e.split(`.`);if(t)return r[3]===t;if(!n)return!0;let i=n.value.split(`.`);return r[3]===i[3]||Number(r[2])>Number(i[2])})(s,o,a)?this.ih(i,s,a):o?a?.value.split(`.`)[3]===o?{value:a.value,pending:!a.delivered}:this.ih(i,`fb.1.${Date.now()}.${o}`,a):a?{value:a.value,pending:!a.delivered}:void 0}rh(e,t,n){if(!this.persistence)return;let r=this.th;this.persistence.refreshKey(r.persistenceKey);let i=this.eh(r);if(n)return void r.unregister();if(t)return j(e)&&pl.test(e)?this.ih(r,e,i):void r.unregister();let a=this.nh(r);return a?this.ih(r,a,i):i?{value:i.value,pending:!i.delivered}:void 0}oh(e,t){if(!this.persistence)return;this.persistence.refreshKey(e.persistenceKey);let n=this.eh(e);n?.value!==t||n.delivered||e.register(t,!0)}capture(e,t,n){if(!(this.__loaded&&this.persistence&&this.sessionPersistence&&this.Ou))return void z.uninitializedWarning(`posthog.capture`);if(!this.is_capturing())return;if(A(e)||!j(e))return void z.error(`No event name provided to posthog.capture`);this.bu();let r=!this.config.opt_out_useragent_filter&&this._is_bot();if(r&&!this.config.__preview_capture_bot_pageviews)return;let i=n?.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(i?.isRateLimited)return void z.critical(`This capture call is ignored due to client rate limiting.`);let a;t!=null&&t.$current_url&&!j(t?.$current_url)&&(z.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),t==null||delete t.$current_url),e!==`$exception`||n!=null&&n.ah||z.warn("Using `posthog.capture('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureException(error)` instead, which attaches required metadata automatically."),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&(a=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();let o=new Date,s=n?.timestamp||o,c=Et(n?.uuid,ma),l={uuid:c,event:e,properties:this.calculateEventProperties(e,t||{},s,c)};e===`$pageview`&&this.config.__preview_capture_bot_pageviews&&r&&(l.event=`$bot_pageview`,l.properties.$browser_type=`bot`),i&&(l.properties.$lib_rate_limit_remaining_tokens=i.remainingTokens);let u=e===`$feature_flag_called`&&!1===l.properties.$feature_flag_has_experiment&&!0===this.get_property(`$minimal_flag_called_events`);n!=null&&n.$set&&!u&&(l.$set=n?.$set);let d=O(t?.$set)?t.$set:void 0,f=E(t?.$unset)?t.$unset:[],p=n?.$unset||[],m=e=>{var t;let r=!!n?.$set&&e in n.$set;return{hasProvided:r||!!d&&e in d,provided:r?n==null||(t=n.$set)==null?void 0:t[e]:d?.[e],unset:f.indexOf(e)!==-1||p.indexOf(e)!==-1}},h=m(xr),g=m(Cr),_=[{channel:this.Yu,hasProvided:h.hasProvided,update:this.sh(a?.fbclid,h.provided,h.hasProvided,h.unset)},{channel:this.th,hasProvided:g.hasProvided,update:this.rh(g.provided,g.hasProvided,g.unset)}];for(let{channel:e,hasProvided:t,update:n}of _)n&&!0===l.properties.$process_person_profile&&n.pending&&!t&&!u&&(l.$set=R({[e.property]:n.value},l.$set));let v=n?.$unset;v&&(l.$unset=v);let y=u?void 0:this.uh(n?.$set_once,e!==$i,e===Qi);if(y&&(l.$set_once=y),n!=null&&n._noTruncate||(b=this.config.properties_string_max_length,l=function(e,t){let n=new Set;return function e(r,i){if(r!==Object(r))return t?t(r):r;if(n.has(r))return;let a;if(n.add(r),E(r))a=[],ea(r,t=>{a.push(e(t))});else{let t={};U(ae(r)?ia(r):r,(r,i)=>{n.has(r)||(t[i]=e(r,i))}),a=t}return a}(e)}(l,e=>j(e)?e.slice(0,b):e)),l.timestamp=s,A(n?.timestamp)||(l.properties.$event_time_override_provided=!0,l.properties.$event_time_override_system_time=o),u&&(l.properties=((e,t=[])=>{let n={},r=t=>{e[t]!==void 0&&(n[t]=e[t])};return kn.forEach(r),t.forEach(r),n})(l.properties,ml)),e===hs.DISMISSED||e===hs.SENT){let n=t?.[gs.SURVEY_ID],r=t?.[gs.SURVEY_ITERATION];Jc({id:n,current_iteration:r}),l.$set=R(R({},l.$set),{},{[Ic({id:n,current_iteration:r},e===hs.SENT?`responded`:`dismissed`)]:!0})}else e===hs.SHOWN&&(l.$set=R(R({},l.$set),{},{[gs.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));var b;if(e===ys.SHOWN){let e=t?.[bs.TOUR_TYPE];e&&(l.$set=R(R({},l.$set),{},{[`${bs.TOUR_LAST_SEEN_DATE}/${e}`]:new Date().toISOString()}))}let x=R(R({},l.properties.$set),l.$set);if(k(x)||this.setPersonPropertiesForFlags(x),!N(this.config.before_send)){let e=this.Os(l);if(!e)return;l=e,l.uuid=Et(l.uuid,ma)}let S=_.filter(({channel:e,update:t})=>{let n=l.$set?.[e.property]??(O(l.properties?.$set)?l.properties.$set[e.property]:void 0);return t?.pending&&n===t.value});this.uu.emit(`eventCaptured`,l);let C=n?._url??this.requestRouter.endpointFor(`api`,this.analyticsDefaultEndpoint),w=n?._batchKey===`recordings`||/\/s\/(?:\?|$)/.test(C),T=R(R(R({method:`POST`,url:C,data:l,compression:`best-available`,preferSyncCompression:n?.send_instantly,timestampMode:w?`body`:`capture-body`,batchKey:n?._batchKey},w&&l.properties?.$session_id?{batchGroup:l.properties.$session_id+(l.properties.$window_id?`-${l.properties.$window_id}`:``)}
1:{}),n?.transport?{transport:n.transport}:{}),S.length?{fireCallbackOnDrop:!0,callback:e=>{if(e.statusCode>=200&&300>e.statusCode)for(let{channel:e,update:t}of S)this.oh(e,t.value)}}:{});if(!this.config.request_batching||n&&!n?._batchKey||n?.send_instantly||S.length){let e;!T.transport&&!T.callback&&k(this.config.request_headers??{})&&this.ku&&(e=`sendBeacon`),this.Du(T,e)}else this.Ou.enqueue(T);return l}_addCaptureHook(e){return this.on(`eventCaptured`,t=>e(t.event,t))}getExtension(e){return this.Zu?.getExtension(e)}Uu(){return this.Zu??=new rl(this)}cu(e){this.Tu.push(e);let t=!0;return()=>{if(!t)return;t=!1;let n=this.Tu.indexOf(e);n!==-1&&this.Tu.splice(n,1)}}hh(e=!0){var t,n;return!!this.persistence?.consumeCookieIdentityChange()&&(this.Pu=null,this.persistence.get_property(`$user_state`)===`anonymous`&&((n=this.sessionPersistence)==null||n.clear(),this.Cu.clear(),this.dh()),(t=this.featureFlags)==null||t.reset(),e&&this.reloadFeatureFlags(),!0)}calculateEventProperties(t,n,a,o,s){if(a||=new Date,!this.persistence||!this.sessionPersistence)return n;this.persistence.syncCookieProperties(),this.hh();let c=s?void 0:this.persistence.remove_event_timer(t),u=R({},n);if(u.token=this.config.token,u.$config_defaults=this.config.defaults,this.pu()&&(u[ji]=!0),t===`$snapshot`){let e=R(R({},this.persistence.properties()),this.sessionPersistence.properties());return u.distinct_id=e.distinct_id,(!j(u.distinct_id)&&!P(u.distinct_id)||ee(u.distinct_id))&&z.error(`Invalid distinct_id for replay event. This indicates a bug in your implementation`),u}let d=function(t,n,r,a=!1){var o,s,c;if(!l)return{};let u=t?[...zo,...n||[]]:[],[d,f]=mt(l),[p,h]=function(e){for(let t=0;vt.length>t;t++){let[n,r,i]=vt[t],a=e.match(n);if(a)return[r,(i&&e.match(i)||a)?.[1]||``]}return[``,``]}(l),g=function(){return(`u`>typeof navigator?navigator:void 0)?.brave?{brave:!0}:{}}(),_={};A(r)||(_.detectGoogleSearchApp=r);let v={},y=(o=navigator)==null||(o=o.userAgentData)==null?void 0:o.platform,b=navigator?.maxTouchPoints,x=e==null||(s=e.screen)==null?void 0:s.width,S=e==null||(c=e.screen)==null?void 0:c.height,C=e?.devicePixelRatio;A(y)||(v.userAgentDataPlatform=y),A(b)||(v.maxTouchPoints=b),A(x)||(v.screenWidth=x),A(S)||(v.screenHeight=S),A(C)||(v.devicePixelRatio=C);let w=W(ra({$os:d,$os_version:f,$browser:ut(l,navigator.vendor,g,_),$webview_app:p,$webview_app_version:h,$device:ht(l),$device_type:gt(l,v),$timezone:Qo(),$timezone_offset:$o()}),{$current_url:Fo(a?Ot(i?.href):i?.href,u,Vo),$host:i?.host,$pathname:i?.pathname,$raw_user_agent:l.length>1e3?l.substring(0,997)+`...`:l,$browser_version:ft(l,navigator.vendor,g,_),$browser_language:Ko(),$browser_language_prefix:qo(),$screen_height:e?.screen.height,$screen_width:e?.screen.width,$viewport_height:e?.innerHeight,$viewport_width:e?.innerWidth,$lib:m.LIB_NAME,$lib_version:m.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3});return m.SDK_DIST_CHANNEL&&(w.$sdk_dist_channel=m.SDK_DIST_CHANNEL),w}(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties,this.config.detect_google_search_app,this.config.disable_capture_url_hashes);if(this.sessionManager){let{sessionId:e,windowId:t}=this.sessionManager.checkAndGetSessionAndWindowId(s,a.getTime(),!0);u.$session_id=e,u.$window_id=t}this.sessionPropsManager&&W(u,this.sessionPropsManager.getSessionProps());try{this.sessionRecording&&W(u,this.sessionRecording.sdkDebugProperties),u.$sdk_debug_retry_queue_size=this.Lu?.length}catch(e){u.$sdk_debug_error_capturing_properties=String(e)}let f;if(this.requestRouter.region===Uc&&(u.$lib_custom_api_host=this.config.api_host),f=t!==`$pageview`||s?t!==`$pageleave`||s?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(a):this.pageViewManager.doPageView(a,o),u=W(u,f),t===`$pageview`&&r&&(u.title=r.title),!A(c)){let e=a.getTime()-c;u.$duration=parseFloat((e/1e3).toFixed(3))}l&&this.config.opt_out_useragent_filter&&(u.$browser_type=this._is_bot()?`bot`:`browser`);let p=this.persistence.properties(),h=this.sessionPersistence.properties(),g=u.$groups,_=p.$groups;O(g)&&!k(g)&&(u.$groups=R(R({},O(_)?_:{}),g)),U([`$referrer`,`$referring_domain`],e=>{e in p&&delete h[e]});let v={};if(this.Tu.length>0)for(let e of this.Tu.slice())try{W(v,e())}catch(e){z.error(`Failed to produce browser extension event properties`,e)}u=W({},d,p,h,R(R({},v),u)),u.$is_identified=this._isIdentified(),E(this.config.property_denylist)?U(this.config.property_denylist,function(e){delete u[e]}):z.error(ul+this.config.property_denylist+` or property_blacklist config: `+this.config.property_blacklist);let y=this.config.sanitize_properties;y&&(z.error(ll),u=y(u,t));let b=this.fh();return u.$process_person_profile=b,b&&!s&&this.ph(`_calculate_event_properties`),u}uh(e,t=!0,n=!1){if(!this.persistence||!this.fh()||this.xu&&!n)return e;let r=this.persistence.get_initial_props(),i=this.sessionPropsManager?.getSetOnceProps(),a=W({},r,i||{},e||{}),o=this.config.sanitize_properties;return o&&(z.error(ll),a=o(a,`$set_once`)),t&&(this.xu=!0),k(a)?void 0:a}register(e,t){var n;(n=this.persistence)==null||n.register(e,t)}register_once(e,t,n){var r;(r=this.persistence)==null||r.register_once(e,t,n)}register_for_session(e){var t,n;(t=this.persistence)==null||t.syncCookieProperties(),this.hh(),(n=this.sessionPersistence)==null||n.register(e),Object.keys(e).forEach(e
1=>this.Cu.add(e)),this.dh()}unregister(e){var t;(t=this.persistence)==null||t.unregister(e)}unregister_for_session(e){var t;(t=this.sessionPersistence)==null||t.unregister(e),this.Cu.delete(e),this.dh()}gh(e,t){this.register({[e]:t})}Nu(){this.Cu.forEach(e=>{var t;(t=this.sessionPersistence)==null||t.unregister(e)}),this.Cu.clear(),this.dh()}dh(){if(!this.$u)return;if(this.config.persistence===`memory`||this.sessionPersistence?.mi||!J.Et())return void J.Lt(this.$u);let e=[];this.Cu.forEach(t=>e.push(t)),e.length>0?J.At(this.$u,e):J.Lt(this.$u)}getFeatureFlag(e,t){return this.featureFlags?.getFeatureFlag(e,t)}getFeatureFlagPayload(e){return this.featureFlags?.getFeatureFlagPayload(e)}getFeatureFlagResult(e,t){return this.featureFlags?.getFeatureFlagResult(e,t)}getAllFeatureFlags(){return this.featureFlags?.getAllFeatureFlags()??[]}isFeatureEnabled(e,t){return this.featureFlags?.isFeatureEnabled(e,t)??t?.defaultValue}reloadFeatureFlags(){var e;(e=this.featureFlags)==null||e.reloadFeatureFlags()}updateFlags(e,t,n){var r;(r=this.featureFlags)==null||r.updateFlags(e,t,n)}updateEarlyAccessFeatureEnrollment(e,t,n){var r;(r=this.featureFlags)==null||r.updateEarlyAccessFeatureEnrollment(e,t,n)}getEarlyAccessFeatures(e,t=!1,n){return this.featureFlags?.getEarlyAccessFeatures(e,t,n)}on(e,t){return this.uu.on(e,t)}onFeatureFlags(e){return this.featureFlags?this.featureFlags.onFeatureFlags(e):(e([],{},{errorsLoading:!0}),()=>{})}onSurveysLoaded(e){return this.surveys?this.surveys.onSurveysLoaded(e):(e([],{isLoaded:!1,error:cl}),()=>{})}onSessionId(e){return this.sessionManager?.onSessionId(e)??(()=>{})}getSurveys(e,t=!1){this.surveys?this.surveys.getSurveys(e,t):e([],{isLoaded:!1,error:cl})}getActiveMatchingSurveys(e,t=!1){this.surveys?this.surveys.getActiveMatchingSurveys(e,t):e([],{isLoaded:!1,error:cl})}renderSurvey(e,t){var n;(n=this.surveys)==null||n.renderSurvey(e,t)}displaySurvey(e,t=Xc){var n;(n=this.surveys)==null||n.displaySurvey(e,t)}cancelPendingSurvey(e){var t;(t=this.surveys)==null||t.cancelPendingSurvey(e)}canRenderSurvey(e){return this.surveys?.canRenderSurvey(e)??{visible:!1,disabledReason:cl}}canRenderSurveyAsync(e,t=!1){return this.surveys?.canRenderSurveyAsync(e,t)??Promise.resolve({visible:!1,disabledReason:cl})}mh(e){return!e||ee(e)?(z.critical(`Unique user id has not been set in posthog.identify`),!1):e===`$posthog_cookieless`?(z.critical(`The string "${e}" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.`),!1):![`distinct_id`,`distinctid`].includes(e.toLowerCase())&&![`undefined`,`null`].includes(e.toLowerCase())||(z.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.`),!1)}identify(e,t,n){if(!this.__loaded||!this.persistence)return z.uninitializedWarning(`posthog.identify`);if(P(e)&&(e=e.toString(),z.warn(`The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.`)),!this.mh(e)||!this.ph(`posthog.identify`))return;this.bu();let r=this.get_distinct_id(),i=this.persistence.syncCookieProperties()&&this.get_distinct_id()!==r,a=this.hh(!1),o=this.persistence.Rl(),s=!1;try{let r=this.get_distinct_id();this.register({$user_id:e}),this.get_property(`$device_id`)||this.register_once({$had_persisted_distinct_id:!0,$device_id:r},``),e!==r&&e!==this.get_property(`__alias`)&&(this.unregister(yr),this.register({distinct_id:e}));let o=(this.persistence.get_property(`$user_state`)||`anonymous`)===Gi,l=e!==r,u=!l&&o;if(l&&o){var c;let i=this.config.reuseAnonymousId?{distinct_id:e}:{distinct_id:e,$anon_distinct_id:r};this.persistence.set_property(H,Ki),this.setPersonPropertiesForFlags({$set:t||{},$set_once:n||{}},!1),this.config.cookieWinsOnConflict&&this.persistence.Al(),this.capture(`$identify`,i,{$set:t||{},$set_once:n||{}})&&(this.Pu=Hc(e,t,n)),(c=this.featureFlags)==null||c.setAnonymousDistinctId(this.config.reuseAnonymousId?void 0:r)}else if(u){this.persistence.set_property(H,Ki);let r=t||{},i=n||{};this.setPersonPropertiesForFlags({$set:r,$set_once:i},!1),this.config.cookieWinsOnConflict&&this.persistence.Al(),this.capture(`$set`,{$set:r,$set_once:i})&&(this.Pu=Hc(e,t,n))}else(t||n)&&this.setPersonProperties(t,n);l||i||a?(this.reloadFeatureFlags(),this.featureFlags?this.featureFlags.resetFlagCallReported():this.unregister(bi)):u&&(t||n)&&this.reloadFeatureFlags(),s=!0}finally{o&&this.persistence.Dl(s)}}setPersonProperties(e,t){if(!e&&!t||!this.ph(`posthog.setPersonProperties`))return;let n=Hc(this.get_distinct_id(),e,t);this.Pu===n?z.info(`A duplicate setPersonProperties call was made with the same properties. It has been ignored.`):(this.setPersonPropertiesForFlags({$set:e||{},$set_once:t||{}},!0),this.capture(`$set`,{$set:e||{},$set_once:t||{}})&&(this.Pu=n))}unsetPersonProperties(e){var t;let n=(E(e)?e:[e]).filter(e=>j(e)&&e.length>0);n.length!==0&&this.ph(`posthog.unsetPersonProperties`)&&((t=this.featureFlags)==null||t.unsetPersonPropertiesForFlags(n,!0),this.capture(`$set`,{$unset:n}),this.Pu=null)}group(e,t,n){var r;if(!e||!t)return void z.error(`posthog.group requires a group type and group key`);(r=this.persistence)==null||r.syncCookieProperties(),this.hh();let i=this.getGroups(),a=i[e]!==t;if(a&&this.resetGroupPropertiesForFlags(e),this.register({$groups:R(R({},i),{},{[e]:t})}),(a||n)&&this.fh()){let r={$group_type:e,$group_key:t};n&&(r.$group_set=n),this.capture($i,r)}n&&this.setGroupPropertiesForFlags({[e]:n}),a&&!n&&this.reloadFeatureFlags()}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,t=!0){var n;(n=this.featureFlags)==null||n.setPersonPropertiesForFlags(e,t)}resetPersonPropertiesForFlags(e=!0){var t;(t=this.featureFlags)==null||t.resetPersonPropertiesForFlags(e)}setGroupPropertiesForFlags(e,t=!0){var n;this.ph(`posthog.setGroupPropertiesForFlags`)&&((n=this.featureFlags)==null||n.setGroupPropertiesForFlags(e,t))}resetGroupPropertiesForFlags(e){var t;(t=this.featureFlags)==null||t.resetGroupPropertiesForFlags(e)}reset(e){let t=F(e)?e:e?.resetDeviceID,n=F(e)||e==null?void 0:e.bootstrap;this.yh(t,!1,n)}yh(e,t=!1,n){var r,i,a,o,s;if(z.info(`reset`),!this.__loaded)return z.uninitializedWarning(`posthog.reset`);let c=n?.sessionID;this.config.bootstrap=n||this.Au?.bootstrap||{},(r=this.featureFlags)==null||(i=r.updateConfig)==null||i.call(r,this.config,this.Yl());let l=this.get_property(_r),u=this.get_property(vr),d=this.get_property(Ir);(a=this.sessionRecording)==null||a.flushBeforeIdentityReset();let f=this.is_capturing();this.consent.reset(),t||!f||this.is_capturing()||console.warn(`[PostHog.js]`,"reset() cleared the stored consent, and capturing is now off because of `opt_out_capturing_by_default`. Call opt_in_capturing() again, and prefer calling reset() before opting in rather than after.");let p=(o=this.persistence)==null||(s=o.Rl)==null?void 0:s.call(o),m=!1;try{var h,g,_,v,y,b,x,S,C,w,T,E;if((h=this.persistence)==null||h.clear(),(g=this.sessionPersistence)==null||g.clear(),this.Cu.clear(),this.dh(),A(d)||(w=this.persistence)==null||w.register({$session_recording_remote_config:d}),(_=this.surveys)==null||_.reset(),(v=this.featureFlags)==null||v.reset(),(y=this.conversations)==null||y.reset(),(b=this.logs)==null||b.reset(),(x=this.metrics)==null||x.reset(),(S=this.persistence)==null||S.set_property(`$user_state`,`anonymous`),(C=this.sessionManager)==null||C.resetSessionId(),this.Pu=null,this.config.cookieless_mode===`always`)this.register_once({distinct_id:Ai,$device_id:null},``);else{let t=this.config.get_device_id(ma());this.register_once({distinct_id:t,$device_id:e?t:l},``),e||A(u)||this.register({[vr]:u})}if(this.register({$last_posthog_reset:new Date().toISOString()},1),n&&(n.distinctID&&!this.pu()&&((E=this.persistence)==null||E.set_property(`$user_state`,n.isIdentifiedID?`identified`:`anonymous`),this.register({distinct_id:n.distinctID})),(T=this.featureFlags)==null||T.initialize(),!N(c)&&!this.sessionManager?.setBootstrapSessionId(c,!0))){let e=R({},n);delete e.sessionID,this.config.bootstrap=e}delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,m=!0}finally{var D,O;p&&((D=this.persistence)==null||(O=D.Dl)==null||O.call(D,m))}this.reloadFeatureFlags()}shutdown(e){var t=this;return L(function*(){var e,n,r,i,a,o,s,c;if(t.__loaded){t.Su=!0,t.Uu().dispose(),(e=t.sessionRecording)==null||e.dispose(),(n=t.logs)==null||n.flushLogs(`sendBeacon`),(r=t.metrics)==null||r.flush(`sendBeacon`),(i=t.metrics)==null||i.dispose(),(a=t.Ou)==null||a.unload(),(o=t.Lu)==null||o.unload();try{var l;(l=t.featureFlags)==null||l.destroy()}catch(e){z.error(`Error while destroying feature flags`,e)}(s=t.persistence)==null||s.destroy(),(c=t.sessionPersistence)==null||c.destroy()}else z.uninitializedWarning(`posthog.shutdown`)})()}setIdentity(e,t){var n;delete this.config.identity_claims,this.config.identity_distinct_id=e,this.config.identity_hash=t,this.alias(e),(n=this.conversations)==null||n.bh()}clearIdentity(){var e;delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,(e=this.conversations)==null||e._h()}get_distinct_id(){return this.get_property(`distinct_id`)}getGroups(){return this.get_property(`$groups`)||{}}get_session_id(){return this.sessionManager?.checkAndGetSessionAndWindowId(!0).sessionId??``}get_session_replay_url(e){if(!this.sessionManager)return``;let{sessionId:t,sessionStartTimestamp:n}=this.sessionManager.checkAndGetSessionAndWindowId(!0),r=this.requestRouter.endpointFor(`ui`,`/project/${this.config.token}/replay/${t}`);if(e?.withTimestamp&&n){let t=e.timestampLookBack??10;if(!n)return r;r+=`?t=${Math.max(Math.floor((new Date().getTime()-n)/1e3)-t,0)}`}return r}alias(e,t){return e===this.get_property(`$people_distinct_id`)?(z.critical(`Attempting to create alias for existing People user - aborting.`),-2):this.ph(`posthog.alias`)?(A(t)&&(t=this.get_distinct_id()),e===t?(z.warn(`alias matches current distinct_id - skipping api call.`),this.identify(e),-1):(this.gh(yr,e),this.capture(`$create_alias`,{alias:e,distinct_id:t}))):void 0}set_config(e){let t=R({},this.config);if(O(e)){var n,r,i,a,o,s,c,l,u,d,f,p,m,h;W(this.config,yl(e));let _=this._u();(n=this.persistence)==null||n.update_config(this.config,t,_),this.sessionPersistence=this.config.persistence===`
1sessionStorage`||this.config.persistence===`memory`?this.persistence:new ds(R(R({},this.config),{},{persistence:`sessionStorage`}),_,!1);let v=this.Ru(this.config.debug);var g;F(v)&&(this.config.debug=v),F(this.config.debug)&&(this.config.debug?(V.DEBUG=!0,q.Et()&&q.At(`ph_debug`,!0),z.info(`set_config`,{config:e,oldConfig:t,newConfig:R({},this.config)})):(V.DEBUG=!1,q.Et()&&q.Lt(`ph_debug`))),(r=this.featureFlags)==null||(i=r.updateConfig)==null||i.call(r,this.config,this.Yl()),(a=this.exceptionObserver)==null||a.onConfigChange(),(o=this.exceptions)==null||o.onConfigChange(),(s=this.metrics)==null||s.onConfigChange(),(c=this.sessionRecording)==null||c.startIfEnabledOrStop(),(l=this.tracingHeaders)==null||l.startIfEnabledOrStop(),(u=this.autocapture)==null||u.startIfEnabled(),(d=this.heatmaps)==null||d.startIfEnabled(),(`capture_pageview`in e||`disable_capture_url_hashes`in e)&&((g=this.historyAutocapture)==null||g.startIfEnabledOrStop()),(f=this.exceptionObserver)==null||f.startIfEnabledOrStop(),(p=this.deadClicksAutocapture)==null||p.startIfEnabledOrStop(),(m=this.surveys)==null||m.loadIfEnabled(),this.wu(),(h=this.externalIntegrations)==null||h.startIfEnabledOrStop(),!t.segment&&this.config.segment&&this.persistence&&wo(this,ol,!1)}}_overrideSDKInfo(e,t){V.LIB_NAME=e,V.LIB_VERSION=t}startSessionRecording(e){let t=!0===e,n={sampling:t||!!e?.sampling,linked_flag:t||!!e?.linked_flag,url_trigger:t||!!e?.url_trigger,event_trigger:t||!!e?.event_trigger};var r,i,a,o,s;Object.values(n).some(Boolean)&&((r=this.sessionManager)==null||r.checkAndGetSessionAndWindowId(),n.sampling&&((i=this.sessionRecording)==null||i.overrideSampling()),n.linked_flag&&((a=this.sessionRecording)==null||a.overrideLinkedFlag()),n.url_trigger&&((o=this.sessionRecording)==null||o.overrideTrigger(`url`)),n.event_trigger&&((s=this.sessionRecording)==null||s.overrideTrigger(`event`))),this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){return!!this.sessionRecording?.started}captureException(e,t){try{if(!this.exceptions)return;let n=this.exceptions.buildProperties(e,{handled:!0,syntheticException:Error(`PostHog syntheticException`)});return this.exceptions.sendExceptionEvent(R(R({},n),t))}catch{return}}addExceptionStep(e,t){var n;(n=this.exceptions)==null||n.addExceptionStep(e,t)}captureLog(e){var t;(t=this.logs)==null||t.captureLog(e)}get logger(){return this.logs?.logger??t.wh}startExceptionAutocapture(e){this.set_config({capture_exceptions:e==null||e})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(e){var t;return(t=this.toolbar?.loadToolbar(e))!=null&&t}get_property(e){return this.persistence?.props[e]}getSessionProperty(e){return this.sessionPersistence?.props[e]}toString(){let e=this.config.name??hl;return e!==hl&&(e=`posthog.`+e),e}_isIdentified(){return this.persistence?.get_property(`$user_state`)===`identified`||this.sessionPersistence?.get_property(`$user_state`)===`identified`}fh(){var e,t;return!(this.config.person_profiles===`never`||this.config.person_profiles===`identified_only`&&!this._isIdentified()&&k(this.getGroups())&&!((e=this.persistence)!=null&&(e=e.props)!=null&&e.__alias)&&!((t=this.persistence)!=null&&(t=t.props)!=null&&t.$epp))}Xu(){return!0===this.config.capture_pageleave||this.config.capture_pageleave===`if_capture_pageview`&&!!this.config.capture_pageview}createPersonProfile(){this.fh()||this.ph(`posthog.createPersonProfile`)&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.ph(`posthog.setInternalOrTestUser`)&&this.setPersonProperties({$internal_or_test_user:!0})}ph(e){return this.config.person_profiles===`never`?(z.error(e+` was called, but process_person is set to "never". This call will be ignored.`),!1):(this.gu(),this.gh(ki,!0),!0)}_u(){if(this.config.cookieless_mode===`always`)return!0;let e=this.consent.isOptedOut();return this.config.disable_persistence||e&&!(!this.config.opt_out_persistence_by_default&&this.config.cookieless_mode!==`on_reject`)}wu(){let e=this._u();var t,n,r;return this.is_capturing()||(t=this.logs)==null||t.kh(),this.persistence?.mi!==e&&((n=this.persistence)==null||n.set_disabled(e)),this.sessionPersistence?.mi!==e&&((r=this.sessionPersistence)==null||r.set_disabled(e)),e&&(this.Cu.clear(),this.dh()),e}opt_in_capturing(e){var n;if(this.config.cookieless_mode!==`always`){if(this.pu()){var r,i,a;(r=this.sessionRecording)==null||r.dispose({discardBufferedEvents:!0}),this.yh(!0,!0),(i=this.sessionManager)==null||i.destroy(),(a=this.pageViewM
1anager)==null||a.destroy(),this.sessionManager=new Nc(this),this.pageViewManager=new Oo(this),this.persistence&&(this.sessionPropsManager=new kc(this,this.sessionManager,this.persistence));let e=this.config.__extensionClasses?.sessionRecording??t.__defaultExtensionClasses?.sessionRecording;var o,s;e&&(this.sessionRecording=this.fu(this.sessionRecording,new e(this)),this.au&&((o=this.sessionRecording)==null||(s=o.onRemoteConfig)==null||s.call(o,this.au)))}var c;this.consent.optInOut(!0),this.wu(),this.Qu(),(n=this.sessionRecording)==null||n.startIfEnabledOrStop(),this.config.cookieless_mode==`on_reject`&&((c=this.surveys)==null||c.loadIfEnabled()),(A(e?.captureEventName)||e!=null&&e.captureEventName)&&this.capture(e?.captureEventName??`$opt_in`,e?.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.Ju()}else z.warn(sl)}opt_out_capturing(){if(this.config.cookieless_mode===`always`)return void z.warn(sl);let e=this.config.cookieless_mode===`on_reject`?this.sessionRecording:void 0;var t,n;e?.dispose({discardBufferedEvents:!0}),this.config.cookieless_mode===`on_reject`&&this.consent.isOptedIn()&&this.yh(!0,!0),this.consent.optInOut(!1),this.wu(),this.config.cookieless_mode===`on_reject`&&(this.register({distinct_id:Ai,$device_id:null}),this.vu(e),this.sessionRecording=void 0,(t=this.sessionManager)==null||t.destroy(),(n=this.pageViewManager)==null||n.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,this.config.capture_pageview&&this.Ju(),this.Qu())}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){let e=this.consent.consent;return e===1?`granted`:e===0?`denied`:`pending`}is_capturing(){return this.config.cookieless_mode===`always`||(this.config.cookieless_mode===`on_reject`?this.consent.isRejected()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this.wu()}_is_bot(){return n?Pc(n,this.config.custom_blocked_useragents):void 0}Ju(){r&&(r.visibilityState===`visible`?this.Iu||(this.Iu=!0,this.capture(Xi,{title:r.title},{send_instantly:!0}),this.Mu&&=(r.removeEventListener(Ji,this.Mu),null)):this.Mu||(this.Mu=this.Ju.bind(this),G(r,Ji,this.Mu)))}debug(t){!1===t?(e?.console.log(`You've disabled debug mode.`),this.set_config({debug:!1})):(e?.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)`."),this.set_config({debug:!0}))}Yl(){let e=this.Au||{};return`advanced_disable_flags`in e?!!e.advanced_disable_flags:!1===this.config.advanced_disable_flags?!0===this.config.advanced_disable_decide?(z.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):function(e,t,n,r,i){let a=t in e&&!N(e[t]),o=n in e&&!N(e[n]);return a?e[t]:!!o&&(i&&i.warn(`Config field '${n}' is deprecated. Please use '${t}' instead. The old field will be removed in a future major version.`),e[n])}(e,`advanced_disable_flags`,`advanced_disable_decide`,0,z):!!this.config.advanced_disable_flags}Os(e){if(N(this.config.before_send))return e;let t=Object.keys(e.properties??{}).filter(re),n=E(this.config.before_send)?this.config.before_send:[this.config.before_send],r=e;for(let t of n)try{if(r=t(r),N(r)){let t=`Event '${e.event}' was rejected in beforeSend function`;return ne(e.event)?z.warn(`${t}. This can cause unexpected behavior.`):z.info(t),null}r.properties&&!k(r.properties)||z.warn(`Event '${e.event}' has no properties after beforeSend function, this is likely an error.`)}catch(t){return z.error(`Error in beforeSend function for event '${e.event}':`,t),null}for(let n of t)if(r.properties&&N(r.properties[n]))return z.warn(`Event '${e.event}' had its '${n}' property removed in a beforeSend function. This property is required for ingestion, so the event will be dropped.`),null;return r}getPageViewId(){return this.pageViewManager.Ho?.pageViewId}captureTraceFeedback(e,t){this.capture(`$ai_feedback`,{$ai_trace_id:String(e),$ai_feedback_text:t})}captureTraceMetric(e,t,n){this.capture(`$ai_metric`,{$ai_trace_id:String(e),$ai_metric_name:t,$ai_metric_value:String(n)})}Ru(e){let t=F(e)&&!e,n=q.Et()&&q.Ot(`ph_debug`)===`true`;return!t&&(!!n||e)}};xl.__defaultExtensionClasses={},xl.wh=(()=>{let e=()=>{};return{trace:e,debug:e,info:e,warn:e,error:e,fatal:e}})(),function(e,t){for(let n=0;t.length>n;n++)e.prototype[t[n]]=na(e.prototype[t[n]])}(xl,[`identify`]);var Sl=class{constructor(e){this.disabled=!1===e;let t=O(e)?e:{};this.thresholdPx=t.threshold_px||30,this.timeoutMs=t.timeout_ms||1e3,this.clickCount=t.click_count||3,this.clicks=[]}isRageClick(e,t,n){if(this.disabled)return!1;let r=this.clicks[this.clicks.length-1];if(r&&Math.abs(e-r.x)+Math.abs(t-r.y)<this.thresholdPx&&this.timeoutMs>n-r.timestamp){if(this.clicks.push({x:e,y:t,timestamp:n}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:e,y:t,timestamp:n}];return!1}},Cl=`$copy_autocapture`,wl=B(`[AutoCapture]`);function Tl(e,t){return t.length>e?t.slice(0,e)+`...`:t}function El(e){if(e.previousElementSibling)return e.previousElementSibling;let t=e;do t=t.previousSibling;while(t&&!Ia(t));return t}function Dl(t,{e:n,maskAllElementAttributes:r,maskAllText:i,elementAttributeIgnoreList:a,elementsC
1hainAsString:o,disableCaptureUrlHashes:s}){if(!Ia(t))return{props:{}};let c=[t],l=new Set([t]),u=t;for(;u.parentNode&&!Y(u,`body`)&&1e3>c.length;){if(Ra(u.parentNode)){let e=u.parentNode.host;if(l.has(e))break;l.add(e),c.push(e),u=e;continue}if(!Ia(u.parentNode)||l.has(u.parentNode))break;l.add(u.parentNode),c.push(u.parentNode),u=u.parentNode}let d=n.type===`click`&&t.namespaceURI===`http://www.w3.org/2000/svg`?c.findIndex(e=>Y(e,`button`)||Y(e,`a`)):-1;d>0&&(i||=c.slice(0,d+1).some(e=>!io(e)||ao(e)));let f=[],p={},m,h=!1,g=!1;if(U(c,e=>{let t=io(e);if(Y(e,`a`)&&!r&&!a?.includes(`href`)){let n=e.getAttribute(`href`);h=!!(t&&n&&mo(n))&&(s?Ot(n):n)}y(Va(e),`ph-no-capture`)&&(g=!0),f.push(function(e,t,n,r,i=!1){let a=e.tagName.toLowerCase(),o={tag_name:a};Ga.indexOf(a)>-1&&!n&&(o.$el_text=a.toLowerCase()===`a`||a.toLowerCase()===`button`?Tl(1024,ho(e)):Tl(1024,Ua(e)));let s=Va(e);t||r!=null&&r.includes(`class`)||0>=s.length||(o.classes=s.filter(function(e){return e!==``})),U(e.attributes,function(n){var a;if((!ao(e)||[`name`,`id`,`class`,`aria-label`].indexOf(n.name)!==-1)&&!r?.includes(n.name)&&!t&&mo(n.value)&&(!j(a=n.name)||a.substring(0,10)!==`_ngcontent`&&a.substring(0,7)!==`_nghost`)){let e=n.value;n.name===`class`&&(e=za(e).join(` `)),o[`attr__`+n.name]=Tl(1024,n.name===`href`&&i?Ot(e):e)}});let c=1,l=1,u=e;for(;u=El(u);)c++,u.tagName===e.tagName&&l++;return o.nth_child=c,o.nth_of_type=l,o}(e,r,i,a,s)),U(function(e){if(!io(e))return{};let t={};return U(e.attributes,function(e){if(e.name&&e.name.indexOf(`data-ph-capture-attribute`)===0){let n=e.name.replace(`data-ph-capture-attribute-`,``),r=e.value;n&&r&&mo(r)&&(t[n]=r)}}),t}(e),(e,t)=>{({}).hasOwnProperty.call(p,t)||(p[t]=e)})}),g)return{props:{},explicitNoCapture:g};if(d>0&&(t=c[d],f.splice(0,d)),i||(f[0].$el_text=Y(t,`a`)||Y(t,`button`)?ho(t):Ua(t)),h){var _;f[0].attr__href=h;let t=No(h)?.host,n=e==null||(_=e.location)==null?void 0:_.host;t&&n&&t!==n&&(m=h)}return{props:W((b=n.type,{$event_type:b,$ce_version:1}),o?{}:{$elements:f},{$elements_chain:(v=f,E(v)?function(e){return e.map(e=>{let t=``;if(e.tag_name&&(t+=e.tag_name),e.attr_class){e.attr_class.sort();for(let n of e.attr_class)t+=`.${n.replace(/"/g,``)}`}let n=R(R(R(R({},e.text?{text:e.text}:{}),{},{"nth-child":e.nth_child??0,"nth-of-type":e.nth_of_type??0},e.href?{href:e.href}:{}),e.attr_id?{attr_id:e.attr_id}:{}),e.attributes),r={};return ta(n).sort(([e],[t])=>function(e,t){return t>e?-1:+(e>t)}(e,t)).forEach(([e,t])=>r[_o(e.toString())]=_o(t.toString())),t+=`:`,t+=ta(r).map(([e,t])=>`${e}="${t}"`).join(``),t}).join(`;`)}(function(e){return e.map(e=>{let t={text:e.$el_text?.slice(0,400),tag_name:e.tag_name,href:e.attr__href?.slice(0,2048),attr_class:vo(e),attr_id:e.attr__id,nth_child:e.nth_child,nth_of_type:e.nth_of_type,attributes:{}};return ta(e).filter(([e])=>e.indexOf(`attr__`)===0).forEach(([e,n])=>t.attributes[e]=n),t})}(v)):``)},f[0]?.$el_text?{$el_text:f[0]?.$el_text}:{},m&&n.type===`click`?{$external_click_url:m}:{},p),target:t};var v,b}var Ol=class{ho(){this.co=void 0,clearTimeout(this.do),this.do=void 0}vo(e){if(!io(e))return!0;let t=this.fo().css_selector_ignorelist??Ya,n=new Set,r=e;for(;r;){if(n.size>=1e3||n.has(r))return!0;n.add(r);let e=r,i=Va(e);if(y(i,`ph-no-capture`)||y(i,`ph-sensitive`)||ao(e)||t.some(t=>Ka(e,t)))return!0;let a=r.parentNode;r=Ra(a)?a.host:a&&Ia(a)?a:null}return!1}po(e){if(!this.isEnabled||e.type===`pointercancel`)return void this.ho();if(e.type===`pointerdown`){this.ho();let t=Wa(e);e.isPrimary&&e.button===0&&!e.ctrlKey&&t&&Ia(t)&&(this.co={target:t,excluded:this.vo(t),id:e.pointerId,x:e.clientX,y:e.clientY,released:!1,distinctId:this.mo?.distinctId});return}let t=this.co;t&&(e.pointerId!==t.id||Math.abs(e.clientX-t.x)>5||Math.abs(e.clientY-t.y)>5?this.ho():e.type===`pointerup`&&(t.released=!0,this.do=setTimeout(()=>this.ho(),0)))}yo(e){let t=this.co;this.ho();let n=Wa(e);if(t?.released&&t.target.isConnected&&t.distinctId===this.mo?.distinctId&&e.pointerId===t.id&&(e.detail>0||e.pointerType===`touch`||e.pointerType===`pen`)&&e.button===0&&5>=Math.abs(e.clientX-t.x)&&5>=Math.abs(e.clientY-t.y)&&n&&(Y(n,`html`)||Y(n,`body`))){if(t.excluded)return null;let e=this.fo().css_selector_ignorelist??Ya;return[n,r?.documentElement,r?.body].some(t=>{if(!t)return!1;let n=Va(t);return y(n,`ph-no-capture`)||y(n,`ph-sensitive`)||!io(t)||ao(t)||e.some(e=>Ka(t,e))})?null:t.target}}constructor(e){this.bo=e,this.name=`autocapture`,this._o=!1,this.wo=null,this.ko=!1,this.So=!1,this.Ir={enabled:!1,rageclick:!1,maskAllElementAttributes:!1,maskAllText:!1,disableCaptureUrlHashes:!1,remoteRequestsDisabled:!1},this.xo=!1,this.bo.refresh(this.Ir),this.rageclicks=new Sl(this.Ir.rageclick),this.Co=null}setup(e){this.$o(),this.mo=e;let t=e.onRemoteConfig(this.onRemoteConfig.bind(this));this.xo?t.dispose():(this.To=t,this.startIfEnabled())}dispose(){var e;this.xo||(this.xo=!0,this.mo=void 0,(e=this.To)==null||e.dispose(),this.To=void 0,this.Io())}fo(){return this.bo.refresh(this.Ir),this.Ir}$o(){return this.fo(),this.Ir.url_allowlist=this.Ir.url_allowlist?.map(e=>new RegExp(e)),this.Ir.url_ignorelist=this.Ir.url_ignorelist?.map(e=>new RegExp(e)),this.Ir}Mo(){if(!this.isBrowserSupported())return void wl.info(`Disabling Automatic Event Collection because this browser is not supported`);if(!e||!r)return;let t=this.Eo=t=>{t||=e?.event;try{if(t.type===`blur`)return void this.ho();if(t.type.indexOf(`pointer`)===0)return void this.po(t);let e=t.type===`click`?this.yo(t):void 0;if(M(e))return;this.Po(t,`$autocapture`,e)}catch(e){wl.error(`Failed to capture event`,e)}};if(G(e,`blur`,t),G(r,`submit`,t,{capture:!0}),G(r,`change`,t,{capture:!0}),G(r,`click`,t,{capture:!0}),U([`pointerdown`,`pointermove`,`pointerup`,`pointercancel`],e=>{G(r,e,t,{capture:!0})}),this.fo().capture_copied_text){let t=this.Ro=t=>{t||=e?.event;try{this.Po(t,Cl)}catch(e){wl.error(`Failed to capture clipboard event`,e)}};G(r,`copy`,t,{capture:!0}),G(r,`cut`,t,{capture:!0}),G(r,`paste`,t,{capture:!0})}}Io(){this.ho(),this.Eo&&=(e?.removeEventListener(`blur`,this.Eo),U([`pointerdown`,`pointermove`,`pointerup`,`pointercancel`],e=>{r?.removeEventListener(e,this.Eo,!0)}),r?.removeEventListener(`submit`,this.Eo,!0),r?.removeEventListener(`change`,this.Eo,!0),r?.removeEventListener(`click`,this.Eo,!0),void 0),this.Ro&&=(r?.removeEventListener(`copy`,this.Ro,!0),r?.removeEventListener(`cut`,this.Ro,!0),r?.removeEventListener(`paste`,this.Ro,!0),void 0),this._o=!1}startIfEnabled(){this.isEnabled||this.ho(),!this.xo&&this.mo&&this.isEnabled&&!this._o&&(this.Mo(),this._o=!0)}onRemoteConfig(e){if(this.xo)return;if(this.ko=!0,!e.ok)return void this.startIfEnabled();let t=e.config;
1t.elementsChainAsString&&(this.So=t.elementsChainAsString);let n=t.autocapture_opt_out;var r;F(n)&&((r=this.mo)==null||r.kv.set(`$autocapture_disabled_server_side`,n),this.wo=n),this.startIfEnabled()}setElementSelectors(e){this.Co=e}getElementSelectors(e,t){var n;let i=[];return(n=this.Co)==null||n.forEach(n=>{(r?.querySelectorAll(n))?.forEach(r=>{e!==r&&t!==r||y(i,n)||i.push(n)})}),i}get isEnabled(){if(this.xo)return!1;let e=this.mo?.kv.get(Er),t=this.wo,n=this.fo();if(!n.remoteRequestsDisabled&&!this.ko)return!1;let r=n.remoteRequestsDisabled&&!this.ko;if(M(t)&&!F(e)&&!r)return!1;let i=this.wo??!!e;return!!n.enabled&&!i}Po(t,n=`$autocapture`,r){if(!this.isEnabled)return void this.ho();let i=r||Wa(t);La(i)&&(i=i.parentNode||null);let a=this.$o();var o;n===`$autocapture`&&t.type===`click`&&t instanceof MouseEvent&&a.rageclick&&(o=this.rageclicks)!=null&&o.isRageClick(t.clientX,t.clientY,t.timeStamp||new Date().getTime())&&to(i,a.rageclick)&&this.Po(t,`$rageclick`,r);let s=n===Cl,c=s?R(R({},a),{},{dom_event_allowlist:void 0}):a;if(i&&function(t,n,r,i,a,o){if(!e||no(t)||r?.url_allowlist&&!Ba(r.url_allowlist,o)||r?.url_ignorelist&&Ba(r.url_ignorelist,o))return!1;if(r?.dom_event_allowlist){let e=r.dom_event_allowlist;if(e&&!e.some(e=>n.type===e))return!1}let{parentIsUsefulElement:s,targetElementList:c}=ro(t,i);if(!function(e,t){let n=t?.element_allowlist;if(A(n))return!0;for(let t of e)if(n.some(e=>t.tagName.toLowerCase()===e))return!0;return!1}(c,r)||!qa(c,r?.css_selector_allowlist)||qa(c,r?.css_selector_ignorelist??Ya))return!1;try{let r=e.getComputedStyle(t);if(r&&r.getPropertyValue(`cursor`)===`pointer`&&n.type===`click`)return!0}catch{}let l=t.tagName.toLowerCase();switch(l){case`html`:return!1;case`form`:return(a||[`submit`]).indexOf(n.type)>=0;case`input`:case`select`:case`textarea`:return(a||[`change`,`click`]).indexOf(n.type)>=0;default:return s?(a||[`click`]).indexOf(n.type)>=0:(a||[`click`]).indexOf(n.type)>=0&&(Ga.indexOf(l)>-1||t.getAttribute(`contenteditable`)===`true`)}}(i,t,c,s,s?[`copy`,`cut`,`paste`]:void 0,{config:{get_current_url:a.getCurrentUrl}})){var l;let{props:r,explicitNoCapture:o,target:s}=Dl(i,{e:t,maskAllElementAttributes:a.maskAllElementAttributes,maskAllText:a.maskAllText,elementAttributeIgnoreList:a.element_attribute_ignorelist,elementsChainAsString:this.So,disableCaptureUrlHashes:a.disableCaptureUrlHashes});if(o)return!1;let c=this.getElementSelectors(i,s);if(c&&c.length>0&&(r.$element_selectors=c),n===Cl){let n=t.type||`clipboard`;if(n!==`paste`){var u;let t=e==null||(u=e.getSelection())==null?void 0:u.toString(),n=Ha(t);if(!n)return!1;r.$selected_content=n,r.$clipboard_text_length=t?.length??0}r.$copy_type=n}return(l=this.mo)==null||l.capture(n,r),!0}}isBrowserSupported(){return D(r?.querySelectorAll)}},kl=class{constructor(e){this._instance=e}refresh(e){let t=this._instance.config,n=O(t.autocapture)?t.autocapture:void 0;e.enabled=!!t.autocapture,e.rageclick=t.rageclick,e.maskAllElementAttributes=t.mask_all_element_attributes,e.maskAllText=t.mask_all_text,e.disableCaptureUrlHashes=t.disable_capture_url_hashes,e.getCurrentUrl=t.get_current_url,e.remoteRequestsDisabled=this._instance.Yl(),e.url_allowlist=n?.url_allowlist,e.url_ignorelist=n?.url_ignorelist,e.dom_event_allowlist=n?.dom_event_allowlist,e.element_allowlist=n?.element_allowlist,e.css_selector_allowlist=n?.css_selector_allowlist,e.css_selector_ignorelist=n?.css_selector_ignorelist,e.element_attribute_ignorelist=n?.element_attribute_ignorelist,e.capture_copied_text=n?.capture_copied_text}},Al=B(`[ExceptionAutocapture]`),jl=()=>{},Ml=e=>{if(D(e))return e.__posthog_layer__??e.__rrweb_layer__};function Nl(e,t,n){try{if(!(t in e))return jl;let r={next:e[t]},i=n(function(...e){return r.next.apply(this,e)});return D(i)&&(i.prototype=i.prototype||{},Object.defineProperties(i,{__posthog_wrapped__:{enumerable:!1,value:!0},__posthog_layer__:{enumerable:!1,value:r}})),e[t]=i,()=>{if(e[t]===i)return void(e[t]=r.next);let n=e[t],a=Ml(n);for(;a;){if(a.next===i)return void(a.next=r.next);n=a.next,a=Ml(n)}}}catch{return jl}}var Pl=B(`[TracingHeaders]`),Fl=B(`[Web Vitals]`),Il=9e5,Ll=[`CLS`,`FCP`,`INP`,`LCP`],Rl=[`INP`,`LCP`],zl=[`interactionTarget`,`interactionType`,`inputDelay`,`processingDuration`,`presentationDelay`,`loadState`,`target`,`url`,`timeToFirstByte`,`resourceLoadDelay`,`resourceLoadDuration`,`elementRenderDelay`,`largestShiftTarget`,`largestShiftTime`,`largestShiftValue`,`firstByteToFCP`],Bl=`disabled`,Vl=`lazy_loading`,Hl=B(`[SessionRecording]`),Ul=B(`[Heatmaps]`);function Wl(e){return O(e)&&`clientX`in e&&`clientY`in e&&P(e.clientX)&&P(e.clientY)}var Gl=B(`[Product Tours]`),Kl=e=>!e.config.disable_product_tours&&!!e.persistence?.get_property(Nr),ql=[`$set_once`,`$set`],Jl=B(`[SiteApps]`),Yl=`Error while initializing PostHog app with config id `,Xl=(e,t)=>
1e?.then?e.then(t):t(e),Zl=`SDK is not enabled or survey functionality is not yet loaded`,Ql=`Disabled. Not loading surveys.`,$l=class{constructor(e,t){this.bo=e,this.Sh=t,this.name=`surveys`,this._surveyEventReceiver=null,this._surveyManager=null,this.xh=!1,this.Ch=[],this.$h=null,this.Th=null,this.xo=!1,this.Ih=new Set,this.onRemoteConfig=e=>{if(this.xo||this.Ir.disableSurveys)return;if(!e.ok)return $.warn(`Remote config unavailable. Not loading surveys.`);let t=e.config.surveys;if(N(t))return $.warn(`Flags not loaded yet. Not loading surveys.`);this.Mh=F(t)?t:t.length>0,$.info(`flags response received, isSurveysEnabled: ${this.Mh}`),this.loadIfEnabled()}}setup(e){if(!this.xo)return this.Eh=e,Xl(e.kv.initialize(),()=>{if(this.Eh!==e||this.xo)return;this.Eh=void 0,this.mo=e;let t=e.onRemoteConfig(this.onRemoteConfig);this.xo?t.dispose():(this.To=t,this.loadIfEnabled())})}dispose(){var e,t,n,r;this.xo||(this.xo=!0,this.Eh=void 0,this.mo=void 0,(e=this.To)==null||e.dispose(),this.To=void 0,(t=this._surveyEventReceiver)==null||t.dispose(),this._surveyEventReceiver=null,(n=this._surveyManager)==null||(r=n.dispose)==null||r.call(n),this._surveyManager=null,this.Ch=[],this.$h=null,this.Ih.forEach(e=>clearTimeout(e)),this.Ih.clear())}get Ir(){return this.bo.get()}initialize(){this.loadIfEnabled()}reset(){var e,t;(e=this._surveyManager)==null||(t=e.clearInMemoryInProgressSurveyState)==null||t.call(e);try{var n;(n=this._surveyEventReceiver)==null||n.reset(),localStorage.removeItem(`lastSeenSurveyDate`);let e=[];for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);(n!=null&&n.startsWith(`seenSurvey_`)||n!=null&&n.startsWith(`inProgressSurvey_`))&&e.push(n)}e.forEach(e=>localStorage.removeItem(e))}catch{}}loadIfEnabled(){if(this.xo||!this.mo)return;let e=this.Ir;if(this._surveyManager)return;if(this.xh)return void $.info(`Already initializing surveys, skipping...`);if(e.disableSurveys)return void $.info(Ql);if(e.cookielessMode&&this.bo.isOptedOut())return void $.info(`Not loading surveys in cookieless mode without consent.`);let t=this.bo.getExtensions();if(!t)return void $.error(`PostHog Extensions not found.`);if(A(this.Mh)&&!e.advancedEnableSurveys)return;let n=this.Mh||e.advancedEnableSurveys;this.xh=!0;try{let e=t.generateSurveys;if(e)return this.Ph(e,n),void(this.xh=!1);let r=t.loadExternalDependency;if(!r)return this.Rh(Wi),void(this.xh=!1);r(e=>{try{if(this.xo)return;let t=this.bo.getExtensions();e||!t?.generateSurveys?this.Rh(`Could not load surveys script`,e):this.Ph(t.generateSurveys,n)}finally{this.xh=!1}})}catch(e){throw this.xh=!1,this.Rh(`Error initializing surveys`,e),e}}Ph(e,t){this.xo||(this._surveyManager=e(t),this._surveyEventReceiver=this.bo.createEventReceiver(),$.info(`Surveys loaded successfully`),this.Ah({isLoaded:!0}))}Rh(e,t){$.error(e,t),this.Ah({isLoaded:!1,error:e})}onSurveysLoaded(e){return this.Ch.push(e),this._surveyManager&&this.Ah({isLoaded:!0}),()=>{this.Ch=this.Ch.filter(t=>t!==e)}}getSurveys(e,t=!1){let n=this.mo??this.Sh;if(!n||this.xo)return;if(this.Ir.disableSurveys)return $.info(Ql),e([]);let r=n.kv.get(ci);if(r&&!t)return e(r,{isLoaded:!0}),void(this.Fh()&&this.getSurveys(()=>{},!0));if(this.$h)return void this.$h.then(({surveys:t,context:n})=>{this.xo||e(t,n)}).catch(e=>$.error(`Error in survey callback`,e));let i=this.Oh(`/api/surveys/`,{method:`GET`,query:{token:n.projectToken},sentAt:`query`,timeoutMs:this.Ir.requestTimeoutMs}).then(e=>{try{return this.Dh(n,e)}catch(e){return $.error(`Error processing surveys response`,e),this.Dh(n,{statusCode:0,error:e})}},e=>this.Dh(n,{statusCode:0,error:e}));this.$h=i;let a=()=>{this.$h===i&&(this.$h=null)};i.then(t=>{a(),this.xo||e(t.surveys,t.context)},a).catch(e=>$.error(`Error in survey callback`,e))}Oh(e,t){let n=this.mo;return n?n.sendRequest(e,t):new Promise(e=>e({statusCode:0,error:Error(Zl)}))}Dh(e,t){if(this.xo)return{surveys:[],context:{isLoaded:!1,error:Zl}};let n=t.statusCode;if(n!==200||!t.json){let e=`Surveys API could not be loaded, status: ${n}`;return n===0?t.error||$.warn(e):$.error(e),this.Th=Date.now(),{surveys:[],context:{isLoaded:!1,error:e}}}this.Th=null;let r=t.json.surveys||[],i=r.filter(e=>function(e){return!(!e.start_date||e.end_date)}(e)&&(Lc(e)||function(e){var t;return!!((t=e.conditions)!=null&&(t=t.actions)!=null&&(t=t.values)!=null&&t.length)}(e)));var a;return i.length>0&&((a=this._surveyEventReceiver)==null||a.register(i)),e.kv.set({[ci]:r,[li]:Date.now()}),{surveys:r,context:{isLoaded:!0}}}Fh(){return this.Lh()&&!this.$h&&!this.Nh()}Lh(){let e=(this.mo??this.Sh)?.kv.get(li);return P(e)&&Date.now()-e>3e5}Nh(){return P(this.Th)&&3e5>Date.now()-this.Th}markSurveyAsSeen(e,t){Jc({id:e,current_iteration:t?.iteration??null});try{localStorage.setItem(`lastSeenSurveyDate`,new Date().toISOString())}catch{}}
1Ah(e){for(let t of this.Ch)try{if(!e.isLoaded)return t([],e);this.getSurveys(t)}catch(e){$.error(`Error in survey callback`,e)}}getActiveMatchingSurveys(e,t=!1){if(!N(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);$.warn(`init was not called`)}qh(e){let t=null;return this.getSurveys(n=>{t=n.find(t=>t.id===e)??null}),t}jh(e){if(N(this._surveyManager))return{eligible:!1,reason:Zl};let t=typeof e==`string`?this.qh(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:`Survey not found`}}Bh(e){if(!this.bo.isCapturing())return{eligible:!1,reason:`PostHog is not capturing, so a survey response cannot be recorded`};if(N(this._surveyManager))return{eligible:!1,reason:Zl};let t=typeof e==`string`?this.qh(e):e;return t?this._surveyManager.checkSurveyRenderability(t):{eligible:!1,reason:`Survey not found`}}canRenderSurvey(e){if(N(this._surveyManager))return $.warn(`init was not called`),{visible:!1,disabledReason:Zl};let t=this.Bh(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return N(this._surveyManager)?($.warn(`init was not called`),Promise.resolve({visible:!1,disabledReason:Zl})):new Promise(n=>{this.getSurveys(t=>{let r=t.find(t=>t.id===e)??null;if(r){let e=this.Bh(r);n({visible:e.eligible,disabledReason:e.reason})}else n({visible:!1,disabledReason:`Survey not found`})},t)})}renderSurvey(e,t,n){if(!this.bo.isCapturing())return;if(N(this._surveyManager))return void $.warn(`init was not called`);let i=typeof e==`string`?this.qh(e):e;if(!i?.id)return void $.warn(`Survey not found`);if(!Yc.includes(i.type))return void $.warn(`Surveys of type ${i.type} cannot be rendered in the app`);let a=r?.querySelector(t);if(a){if(i.appearance?.surveyPopupDelaySeconds){$.info(`Rendering survey ${i.id} with delay of ${i.appearance.surveyPopupDelaySeconds} seconds`);let e=setTimeout(()=>{var t;this.Ih.delete(e),!this.xo&&this.bo.isCapturing()&&($.info(`Rendering survey ${i.id} with delay of ${i.appearance?.surveyPopupDelaySeconds} seconds`),(t=this._surveyManager)==null||t.renderSurvey(i,a,n),$.info(`Survey ${i.id} rendered`))},1e3*i.appearance.surveyPopupDelaySeconds);this.Ih.add(e);return}this._surveyManager.renderSurvey(i,a,n)}else $.warn(`Survey element not found`)}displaySurvey(e,t){var n;if(!this.bo.isCapturing())return;if(N(this._surveyManager))return void $.warn(`init was not called`);let r=this.qh(e);if(!r)return void $.warn(`Survey not found`);let i=r;if((n=r.appearance)!=null&&n.surveyPopupDelaySeconds&&t.ignoreDelay&&(i=R(R({},r),{},{appearance:R(R({},r.appearance),{},{surveyPopupDelaySeconds:0})})),t.displayType!==_s.Popover&&t.initialResponses&&$.warn(`initialResponses is only supported for popover surveys. prefill will not be applied.`),!1===t.ignoreConditions){let e=this.jh(r);if(!e.eligible)return void $.warn(`Survey is not eligible to be displayed: `,e.reason)}t.displayType===_s.Inline?this.renderSurvey(i,t.selector,t.properties):this._surveyManager.handlePopoverSurvey(i,t)}cancelPendingSurvey(e){N(this._surveyManager)?$.warn(`init was not called`):this._surveyManager.cancelSurvey(e)}handlePageUnload(){var e,t;(e=this._surveyManager)==null||(t=e.handlePageUnload)==null||t.call(e)}};function eu(e,t,n){if(N(e))return!1;switch(n){case`exact`:return e===t;case`contains`:{let n=t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`).replace(/_/g,`.`).replace(/%/g,`.*`);return new RegExp(n,`i`).test(e)}case`regex`:try{return new RegExp(t).test(e)}catch{return!1}default:return!1}}var tu=class{constructor(e){this._instance=e,this.Hh=new Set,this.zh=new Set,this.Uh=new Ac,this.Wh=(e,t)=>this.Vh(e,t)&&this.Gh(e,t)&&this.Zh(e,t)&&this.Qh(e,t),this.Vh=(e,t)=>!t?.event||e?.event===t?.event}init(){A(this._instance?._addCaptureHook)||(this.Jh=this._instance?._addCaptureHook((e,t)=>{this.on(e,t)}))}dispose(){var e;(e=this.Jh)==null||e.call(this),this.Jh=void 0,this.Uh=new Ac}register(e){if(!A(this._instance?._addCaptureHook)&&(e.forEach(e=>{var t;this.Hh.add(e),(t=e.steps)==null||t.forEach(e=>{this.zh.add(e?.event||``)})}),this._instance?.autocapture)){let e=new Set;
1this.Hh.forEach(t=>{var n;(n=t.steps)==null||n.forEach(t=>{t!=null&&t.selector&&e.add(t.selector)})}),this._instance.autocapture.setElementSelectors(e)}}replace(e){this.Hh.clear(),this.zh.clear(),this.register(e)}on(e,t){t!=null&&e.length!=0&&(this.zh.has(e)||this.zh.has(t.event))&&this.Hh.forEach(e=>{this.Kh(t,e)&&this.Uh.emit(`actionCaptured`,e.name)})}Xh(e){this.onAction(`actionCaptured`,t=>e(t))}Kh(e,t){if(t?.steps==null)return!1;for(let n of t.steps)if(this.Wh(e,n))return!0;return!1}onAction(e,t){return this.Uh.on(e,t)}Gh(e,t){if(t?.url){var n;let r=e==null||(n=e.properties)==null?void 0:n.$current_url;if(!r||typeof r!=`string`||!eu(r,t.url,t.url_matching||`contains`))return!1}return!0}Zh(e,t){return!!this.Yh(e,t)&&!!this.tc(e,t)&&!!this.ec(e,t)}Yh(e,t){var n;if(!t?.href)return!0;let r=this.nc(e);if(r.length>0)return r.some(e=>eu(e.href,t.href,t.href_matching||`exact`));let i=(e==null||(n=e.properties)==null?void 0:n.$elements_chain)||``;return!!i&&eu(function(e){let t=e.match(/(?::|")href="(.*?)"/);return t?t[1]:``}(i),t.href,t.href_matching||`exact`)}tc(e,t){var n;if(!t?.text)return!0;let r=this.nc(e);if(r.length>0)return r.some(e=>eu(e.text,t.text,t.text_matching||`exact`)||eu(e.$el_text,t.text,t.text_matching||`exact`));let i=(e==null||(n=e.properties)==null?void 0:n.$elements_chain)||``;return!!i&&(a=function(e){let t=[],n=/(?::|")text="(.*?)"/g,r;for(;!N(r=n.exec(e));)t.includes(r[1])||t.push(r[1]);return t}(i),o=t.text,s=t.text_matching||`exact`,a.some(e=>eu(e,o,s)));var a,o,s}ec(e,t){var n,r;if(!t?.selector||(e==null||(n=e.properties)==null?void 0:n.$element_selectors)?.includes(t.selector))return!0;let i=(e==null||(r=e.properties)==null?void 0:r.$elements_chain)||``;if(t.selector_regex&&i)try{return new RegExp(t.selector_regex).test(i)}catch{return!1}return!1}nc(e){var t;return(e==null||(t=e.properties)==null?void 0:t.$elements)==null?[]:e?.properties.$elements}Qh(e,t){return!t?.properties||t.properties.length===0||Vc(t.properties.reduce((e,t)=>{let n=E(t.value)?t.value.map(String):t.value==null?[]:[String(t.value)];return e[t.key]={values:n,operator:t.operator||`exact`},e},{}),e?.properties)}},nu=class{constructor(e){var t,n;this.sc=[],this._instance=e,this.rc=new Map,this.oc=new Map,this.lc=new Map,this.ac=(t=this._instance)==null||(n=t.onSessionId)==null?void 0:n.call(t,e=>this.uc(e))}hc(e){return!1}cc(){return null}dc(e){}vc(){}fc(e,t){return!!e&&Vc(e.propertyFilters,t?.properties)}gc(e,t){let n=new Map;return e.forEach(e=>{var r;(r=e.conditions)==null||(r=r[t])==null||(r=r.values)==null||r.forEach(t=>{if(t?.name){let r=n.get(t.name)||[];r.push(e.id),n.set(t.name,r)}})}),n}mc(e,t,n){let r=(n===ps.Activation?this.rc:this.oc).get(e),i=[];return this.yc(e=>{i=e.filter(e=>r?.includes(e.id))}),i.filter(r=>{var i;let a=(i=r.conditions)==null||(i=i[n])==null||(i=i.values)==null?void 0:i.find(t=>t.name===e);return this.fc(a,t)})}register(e){this.bc(e,!1)}replace(e){this.bc(e,!0)}bc(e,t){A(this._instance?._addCaptureHook)||(this._c(e,t),this.wc(e,t))}wc(e,t){let n=e.filter(e=>{var t;return(t=e.conditions)==null||(t=t.actions)==null||(t=t.values)==null?void 0:t.length});var r;if(t&&this.lc.clear(),n.length===0)return void(t&&((r=this.kc)==null||r.replace([])));this.kc||(this.kc=new tu(this._instance),this.kc.init(),this.kc.Xh(e=>this.onAction(e)));let i=[];n.forEach(e=>{var t;(t=e.conditions)==null||(t=t.actions)==null||t.values.forEach(t=>{if(i.push(t),t.name){let n=this.lc.get(t.name)??[];n.includes(e.id)||n.push(e.id),this.lc.set(t.name,n)}})}),t?this.kc.replace(i):this.kc.register(i)}Sc(e,t){t.forEach((t,n)=>{let r=e.get(n)??[];t.forEach(e=>{r.includes(e)||r.push(e)}),e.set(n,r)})}_c(e,t){let n=e.filter(e=>{var t;return e.conditions?.events&&((t=e.conditions)==null||(t=t.events)==null||(t=t.values)==null?void 0:t.length)>0}),r=e.filter(e=>{var t;return e.conditions?.cancelEvents&&((t=e.conditions)==null||(t=t.cancelEvents)==null||(t=t.values)==null?void 0:t.length)>0}),i=this.gc(e,ps.Activation),a=this.gc(e,ps.Cancellation);t?(this.rc=i,this.oc=a):(this.Sc(this.rc,i),this.Sc(this.oc,a)),(n.length!==0||r.length!==0)&&(this.Jh??=this._instance?._addCaptureHook((e,t)=>{this.onEvent(e,t)}))}onEvent(e,t){var n,r;let i=this.xc(),a=(t==null||(n=t.properties)==null?void 0:n.$survey_id)||(t==null||(r=t.properties)==null?void 0:r.$product_tour_id);if(a&&this.getActivatedIds().includes(a)){let t=this.Cc(e,a);if(t===`consume`)return i.info(`event consumed activated item, remov
1ing it`,{event:e,itemId:a}),void this.$c([a]);if(t===`persist`)return i.info(`shown item promoted to persisted activation`,{event:e,itemId:a}),this.Tc(a),void this.Ic([a])}if(this.oc.has(e)){let n=this.mc(e,t,ps.Cancellation);n.length>0&&(i.info(`cancel event matched, cancelling items`,{event:e,itemsToCancel:n.map(e=>e.id)}),this.$c(n.map(e=>e.id)),n.forEach(e=>this.Mc(e.id)))}if(!this.rc.has(e))return;i.info(`event name matched`,{event:e,eventPayload:t,items:this.rc.get(e)});let o=this.mc(e,t,ps.Activation);this.Ec(o.map(e=>e.id))}onAction(e){this.lc.has(e)&&this.Ec(this.lc.get(e)||[])}Ec(e){var t,n;if(e.length===0)return;let r=!!((t=this._instance)!=null&&(n=t.get_session_id)!=null&&n.call(t)),i=[];for(let t of e)r&&this.hc(t)?this.Tc(t)&&this.Pc(t):i.push(t);i.length>0&&(this.sc=[...new Set([...this.sc,...i])]),this.xc().info(`updating activated items`,{activatedItems:this.getActivatedIds()})}Tc(e){this.sc=this.sc.filter(t=>t!==e);let t=this.Rc();return!t.includes(e)&&(this.Ac([...t,e]),this.Fc(),!0)}$c(e){let t=new Set(e);this.sc=this.sc.filter(e=>!t.has(e));let n=this.Oc(),r=n.filter(e=>!t.has(e));r.length!==n.length&&(this.Ac(r),r.length===0&&this.Dc()),this.Ic(e)}Lc(){var e;let t=this.cc();if(!t)return{};let n=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[t];return n&&typeof n==`object`?n:{}}Pc(e){if(!this.cc())return;let t=this.Lc();this.dc(R(R({},t),{},{[e]:Date.now()}))}Ic(e){if(!this.cc())return;let t=this.Lc(),n={},r=!1;for(let[i,a]of Object.entries(t))e.includes(i)?r=!0:n[i]=a;r&&(k(n)?this.vc():this.dc(n))}Nc(){this.cc()&&this.vc()}getActivationTimestamp(e){if(!this.Rc().includes(e))return;let t=this.Lc()[e];return P(t)?t:void 0}Oc(){var e;let t=this.qc();return((e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[t])||[]}Rc(){var e,t,n;let r=this.Oc();if(r.length===0)return[];let i=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[this.jc()],a=(t=this._instance)==null||(n=t.get_session_id)==null?void 0:n.call(t);return a&&i===a?r:[]}Fc(){var e,t;let n=(e=this._instance)==null||(t=e.get_session_id)==null?void 0:t.call(e);n&&this.Bc(n)}Dc(){this.Hc()}uc(e){var t;let n=(t=this._instance)==null||(t=t.persistence)==null?void 0:t.props[this.jc()];if(n&&n!==e){let e=this.Oc(),t=this.Lc();e.length>0&&(this.Ac([]),e.filter(e=>P(t[e])).forEach(e=>this.Mc(e))),this.Dc(),this.Nc()}}getActivatedIds(){return[...new Set([...this.Rc(),...this.sc])].filter(e=>!this.zc(e))}dispose(){var e,t,n;(e=this.ac)==null||e.call(this),this.ac=void 0,(t=this.Jh)==null||t.call(this),this.Jh=void 0,(n=this.kc)==null||n.dispose(),this.kc=void 0}reset(){this.sc=[],this.Oc().length>0&&this.Ac([]),this.Dc(),this.Nc()}getEventToItemsMap(){return this.rc}Uc(){return this.kc}},ru=class extends nu{constructor(e){super(e)}qc(){return ui}jc(){return di}cc(){return fi}dc(e){var t;(t=this._instance)==null||(t=t.persistence)==null||t.register({$surveys_activated_timestamps:e})}vc(){var e;(e=this._instance)==null||(e=e.persistence)==null||e.unregister(`$surveys_activated_timestamps`)}hc(e){var t;let n;this.yc(t=>{n=t.find(t=>t.id===e)});let r=n==null||(t=n.appearance)==null?void 0:t.surveyPopupDelaySeconds;return P(r)&&r>0}Wc(){return hs.SHOWN}yc(e){var t;(t=this._instance)==null||t.getSurveys(e)}Mc(e){var t;(t=this._instance)==null||t.cancelPendingSurvey(e)}xc(){return $}Ac(e){var t;(t=this._instance)==null||(t=t.persistence)==null||t.register({$surveys_activated:e})}Bc(e){var t;(t=this._instance)==null||(t=t.persistence)==null||t.register({$surveys_activated_session:e})}Hc(){var e;(e=this._instance)==null||(e=e.persistence)==null||e.unregister(`$surveys_activated_session`)}zc(){return!1}Cc(e,t){let n;return this.yc(e=>{n=e.find(e=>e.id===t)}),!n||function(e){var t;return Lc(e)&&!!((t=e.conditions)!=null&&(t=t.events)!=null&&t.repeatedActivation)||e.schedule===`always`}(n)?e===hs.SHOWN?`consume`:`ignore`:e===hs.SHOWN?`persist`:e===hs.DISMISSED||e===hs.SENT?`consume`:`ignore`}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},iu=class{constructor(e){this._instance=e}initialize(){}get(e){if(typeof e==`string`)return this._instance.get_property(e);let t={};for(let n of e){let e=this._instance.get_property(n);A(e)||(t[n]=e)}return t}set(e,t){this._instance.register(typeof e==`string`?{[e]:t}:e)}remove(e){typeof e==`string`?this._instance.unregister(e):e.forEach(e
1=>this._instance.unregister(e))}},au=class{constructor(e){this._instance=e}get(){let e=this._instance.config;return{disableSurveys:e.disable_surveys,cookielessMode:!!e.cookieless_mode,advancedEnableSurveys:e.advanced_enable_surveys,requestTimeoutMs:e.surveys_request_timeout_ms}}isOptedOut(){return this._instance.consent.isOptedOut()}isCapturing(){return this._instance.is_capturing()}getExtensions(){let e=f?.__PosthogExtensions__;if(!e)return;let{generateSurveys:t,loadExternalDependency:n}=e;return{generateSurveys:t?e=>t(this._instance,e):void 0,loadExternalDependency:n?e=>n(this._instance,`surveys`,e):void 0}}createEventReceiver(){return new ru(this._instance)}},ou=e?.location?Io(e.location.hash,`__posthog`)||Io(location.hash,`state`):null,su=`_postHogToolbarParams`,cu=B(`[Toolbar]`),lu=B(`[FeatureFlags]`),uu=class{constructor(e,t=!1){this.Vc=!1,this.update(e,t)}update(e,t){this.Gc=((e,t)=>({bootstrap:{featureFlags:e.bootstrap?.featureFlags??void 0,featureFlagPayloads:e.bootstrap?.featureFlagPayloads??void 0},remoteRequestsDisabled:t,featureFlagsDisabled:!!e.advanced_disable_feature_flags,onlyEvaluateSurveyFeatureFlags:!!e.advanced_only_evaluate_survey_feature_flags,deduplicateCallsPerSession:!!e.advanced_feature_flags_dedup_per_session,cacheTtlMs:e.feature_flag_cache_ttl_ms,refreshIntervalMs:e.remote_config_refresh_interval_ms??3e5,idleRefreshBackoff:A(e.remote_config_refresh_interval_ms),requestTimeoutMs:e.feature_flag_request_timeout_ms,compression:e.disable_compression?void 0:`best-available`,evaluationContexts:e.evaluation_contexts??e.evaluation_environments??[],flagKeys:E(e.flag_keys)?e.flag_keys:void 0}))(e,t),!e.evaluation_environments||e.evaluation_contexts||this.Vc||(lu.warn(`evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version.`),this.Vc=!0),A(e.flag_keys)||E(e.flag_keys)||lu.error(`Invalid flag_keys found:`,e.flag_keys,`Expected array of non-empty strings`)}get(){return this.Gc}},du=B(`[FeatureFlags]`),fu=B(`[FeatureFlags]`,{debugEnabled:!0}),pu=`" failed. Feature flags didn't load in time.`,mu=[`click`,`keydown`,`wheel`,`touchstart`,`pointerdown`],hu=`connection_error`,gu=e=>{let t={};for(let n=0;e.length>n;n++)t[e[n]]=!0;return t},_u=e=>{let t={};for(let[n,r]of ta(e||{}))r&&(t[n]=r);return t},vu=e=>ae(e)&&(e.name===`RangeError`&&e.message.indexOf(`Maximum call stack size exceeded`)===0||e.name===`InternalError`&&e.message===`too much recursion`),yu=B(`[Error tracking]`),bu=`webkit-masked-url:`,xu=[{value:`isolatedAPI.contexts.topHostname`,exact:!1},{value:`No response from target`,exact:!0}],Su=[`chrome-extension://`,`moz-extension://`,`safari-extension:`,`safari-web-extension:`,bu],Cu=[`__firefox__`,`__gCrWeb`],wu=`Refusing to render web experiment since the viewer is a likely bot`,Tu={icontains:(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())>-1,not_icontains:(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())===-1,regex:(e,t)=>Rc(t,e),not_regex:(e,t)=>!Rc(t,e),exact:(e,t)=>t===e,is_not:(e,t)=>t!==e},Eu=B(`[Conversations]`),Du=`Conversations not available yet.`;function Ou(e,t){let r=e?.flushIntervalMs??3e3,i=e?.maxBufferSize??100,a=t?.consoleCapture?void 0:e?.maxLogsPerInterval??1e3,o=A(a)?Math.max(i,2048):Math.max(i,a),s=R(R({},function(){let e=``,t=``;try{let r=n?.userAgent;r&&([e,t]=mt(r))}catch{}return function(e,t){let n=function(e){if(e)return{}.hasOwnProperty.call(Jn,e)?Jn[e]:e}(e);return R(R({},n?{"os.name":n}:{}),t?{"os.version":t}:{})}(e,t)}()),e?.resourceAttributes);return{serviceName:s?.[`service.name`]??e?.serviceName??t?.serviceNameDefault,serviceVersion:s?.[`service.version`]??e?.serviceVersion,environment:s?.[`deployment.environment`]??e?.environment,resourceAttributes:s,beforeSend:e?.beforeSend,flushIntervalMs:r,maxBufferSize:i,maxQueueSize:o,maxBatchRecordsPerPost:100,rateCapWindowMs:r,maxLogsPerInterval:a,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}}var ku=[`debug`,`log`,`warn`,`error`,`info`],Au=e=>{for(;e?.__rrweb_original__;)e=e.__rrweb_original__;return e},ju=`console`,Mu=`__posthogHandledLogsRequestError`,Nu=(e,t)=>{let n=e instanceof Error?e:Error(t);return n[Mu]=!0,n},Pu=e=>
1!!e&&typeof e==`object`&&!0===e[Mu],Fu=B(`[NetworkMetrics]`),Iu=()=>{var t;return e!=null&&(t=e.performance)!=null&&t.now?e.performance.now():Date.now()},Lu={"http:":80,"https:":443},Ru=new Set([`CONNECT`,`DELETE`,`GET`,`HEAD`,`OPTIONS`,`PATCH`,`POST`,`PUT`,`TRACE`]),zu=(e,t)=>{let n=String(t);return{method:String(e).toUpperCase(),url:No(n)?.href||n}},Bu=(e,t,n,r,i,a,o=!1)=>{try{var s;let c=i();if(!c)return;let l=n||void 0,u=Iu()-r,d=No(t.url);if(d&&d.protocol!==`http:`&&d.protocol!==`https:`)return;let f={url:d?.href||t.url,method:t.method},p=D(c.name)?c.name(f):j(c.name)?c.name:`http.client.request.duration`;if(!p)return;let m=o&&!l?void 0:((e,t)=>e?400>e?void 0:String(e):t?.name||`_OTHER`)(l,a),h=R(R(R(R(R({},(e=>{let t=Ru.has(e)?e:`_OTHER`;return R({"http.request.method":t},t===`_OTHER`&&e!==t?{"http.request.method_original":e}:{})})(f.method)),d?(e=>{return{"server.address":e.hostname.startsWith(`[`)&&e.hostname.endsWith(`]`)?e.hostname.slice(1,-1):e.hostname,"server.port":Number(e.port)||Lu[e.protocol],"url.scheme":e.protocol.slice(0,-1),"url.template":(t=e.pathname,t.split(`/`).map(e=>(e=>/^\d+$/.test(e)||e.length>=8&&/^[0-9a-f-]*\d[0-9a-f-]*$/i.test(e))(e)?`:id`:e).join(`/`))};var t})(d):{}),l?{"http.response.status_code":l}:{}),m?{"error.type":m}:{}),c.attributes?.call(c,f,{status:l,durationMs:u}));(s=e.metrics)==null||s.histogram(p,u,{unit:`ms`,attributes:h})}catch(e){Fu.error(`Failed to record network metric`,e)}},Vu=()=>{},Hu=(t,n)=>D(e?.fetch)?Nl(e,`fetch`,e=>function(...r){let i=Iu(),a=e.apply(this,r);if(!n())return a;try{let[e,o]=r,s=zu(o?.method??e?.method??`GET`,e?.url??e);return a.then(e=>(Bu(t,s,e?.status,i,n,void 0,!0),e),e=>{throw Bu(t,s,void 0,i,n,e),e})}catch(e){return Fu.error(`Failed to observe fetch`,e),a}}):Vu,Uu=(t,n)=>{var r;let i=e==null||(r=e.XMLHttpRequest)==null?void 0:r.prototype;if(!i)return Vu;let a=new WeakMap,o=Nl(i,`open`,e=>function(...t){try{ic.has(this)||a.set(this,zu(t[0],t[1]))}catch(e){Fu.error(`Failed to observe XHR open`,e)}return e.apply(this,t)}),s=Nl(i,`send`,e=>function(...r){let i;try{let e=a.get(this);if(e&&n()){let r=Iu();i=()=>{this.removeEventListener(`loadend`,i),Bu(t,e,this.status,r,n)},G(this,`loadend`,i)}}catch(e){Fu.error(`Failed to observe XHR send`,e)}try{return e.apply(this,r)}catch(e){throw i&&this.removeEventListener(`loadend`,i),e}});return()=>{o(),s()}},Wu={featureFlags:class{constructor(e){this.name=`featureFlags`,this.Zc=!1,this.featureFlagEventHandlers=[],this.$=du,this.Qc={},this.Jc={},this.Kc=[],this.Xc=!1,this.Yc=!1,this.td=0,this.ed=!1,this.nd=!1,this.sd=!1,this.rd=!1,this.od=0,this.ld=!1,this.an=()=>{let e=this.ad();this.od=0,e&&this.reloadFeatureFlags()},this.ud=()=>{let e=this.hd,t=this.dd??e;A(e)||A(t)||this.Ir.remoteRequestsDisabled||!r||r.visibilityState===`hidden`||Date.now()-(this.vd??0)<t||(this.dd=this.ld||!this.Ir.idleRefreshBackoff?e:Math.min(2*t,36e5),this.ld=!1,this.reloadFeatureFlags(),this.fd())},this.pd=()=>{this.ld&&this.dd===this.hd||this.gd()},this.ln=()=>{r?.visibilityState===`visible`&&this.gd()},`get`in e?this.bo=e:(this._instance=e,this.md=new uu(e.config,e.Yl()),this.bo=this.md)}updateConfig(e,t){var n;(n=this.md)==null||n.update(e,t),this.mo&&this.yd()}setup(e){return this.Eh=e,this.$=e.logger.createLogger(`[FeatureFlags]`),Xl(e.kv.initialize(),()=>{this.Eh===e&&(this.Eh=void 0,this.mo=e,this.bd(e))})}bd(t){var n;if(this.mo===t)return e&&G(e,`online`,this.an),this.yd(),this._d=t.registerDynamicEventProperties(()=>this.wd()?this.Qc:this.Jc),this.kd=(n=this._instance)==null||(n=n.persistence)==null?void 0:n.onCrossTabFeatureFlagChange(()=>{this.Sd(),this.xd(),this.Cd()}),this.xd(),this.initialize()}gd(){this.ld=!0,this.dd=this.hd,this.ud()}yd(){let e=this.Ir.refreshIntervalMs,t=!this.Ir.remoteRequestsDisabled&&r&&!A(e)&&e>0?e:void 0;this.Ir.idleRefreshBackoff||(this.dd=t),t!==this.hd&&(this.$d(),A(t)||(this.hd=t,this.dd=t,this.fd(),r!=null&&r.addEventListener&&(G(r,Ji,this.ln),ea(mu,e=>{G(r,e,this.pd,{capture:!0})}))))}fd(){A(this.hd)||(A(this.Td)||clearInterval(this.Td),this.vd=Date.now(),this.Td=setInterval(this.ud,this.hd))}$d(){var e;A(this.Td)||(clearInterval(this.Td),this.Td=void 0,r==null||(e=r.removeEventListener)==null||e.call(r,`visibilitychange`,this.ln),ea(mu,e=>{var t;r==null||(t=r.removeEventListener)==null||t.call(r,e,this.pd,{capture:!0})}
1)),this.hd=void 0,this.dd=void 0,this.ld=!1,this.vd=void 0}destroy(){this.Id()}dispose(){this.Id()}Id(){var t,n;this.$d(),this.td++,this.nd=!1,this.Eh=void 0,this.mo&&=(this.Md(),(t=this._d)==null||t.dispose(),this._d=void 0,(n=this.kd)==null||n.call(this),this.kd=void 0,this.Kc=[],e?.removeEventListener(`online`,this.an),void 0)}get Ir(){return this.bo.get()}Ed(e){return this.Pd&&e in this.Pd?this.Pd[e]:this.mo?.kv.get(e)}Sd(){return!!this.Pd&&(this.Pd=void 0,!0)}Rd(){return!A(this.mo?.kv.get(`$enabled_feature_flags`))&&this.Sd()}At(e){this.Ad(()=>this.mo?.kv.set(e))}Fd(e,t,n){if(!this._instance?.persistence||!e.$enabled_feature_flags)return;let r=this.Ed(`$enabled_feature_flags`)||{},i=e.$enabled_feature_flags||{},a=t.flags||t.featureFlags,o=t.flags?Object.entries(t.flags).filter(([,e])=>!e?.failed).map(([e])=>e):[],s=!!t.errorsWhileComputingFlags&&!!t.flags,c=s?o:n&&!E(a)?Object.keys(a||{}):Array.from(new Set([...Object.keys(r),...Object.keys(i)])),l=this.Ed(`$feature_flag_payloads`)||{},u=e.$feature_flag_payloads||{},d=s||n?c:Array.from(new Set([...Object.keys(l),...Object.keys(u)])),f=!s&&!n,p=!!f||c,m=!!f||d,h={[Zr]:p,[Xr]:p,[ei]:m};e.$feature_flag_details&&(h[$r]=p);for(let t of[ti,Ci,ni])A(e[t])||(h[t]=!0);this._instance.persistence.markCrossTabFeatureFlagChanges(h)}Lt(e){this.Ad(()=>this.mo?.kv.remove(e))}Ad(e){try{e()}catch(e){this.$.error(`Failed to update feature flag persistence`,e)}}xd(){let e={};for(let t of[Zr,ei,ti,ri]){let n=this.Ed(t);A(n)||(e[t]=n)}this.Qc=e;let t=R({},e),n=this.Ed(Xr);if(n)for(let[e,r]of Object.entries(n))t[`$feature/${e}`]=r;this.Jc=t}wd(){let e=this.Ir.cacheTtlMs;if(!e||0>=e)return!1;let t=this.Ed(Ci);return typeof t!=`number`||Date.now()-t>e}Od(){return!!this.wd()&&(this.rd||this.Yc||(this.rd=!0,this.$.warn(`Feature flag cache is stale, triggering refresh...`),this.reloadFeatureFlags()),!0)}Dd(){let e=this.Ir.evaluationContexts;return e?.length?e.filter(e=>{let t=e&&typeof e==`string`&&e.trim().length>0;return t||this.$.error(`Invalid evaluation context found:`,e,`Expected non-empty string`),t}):[]}Ld(){let e=this.Ir.flagKeys;if(!A(e))return e.filter(e=>{let t=e&&typeof e==`string`&&e.trim().length>0;return t||this.$.error(`Invalid flag key found:`,e,`Expected non-empty string`),t})}initialize(){let e=this.Ir,t=e.bootstrap?.featureFlags??{};if(Object.keys(t).length){let n=e.bootstrap?.featureFlagPayloads??{},r=Object.keys(t).filter(e=>!A(t[e])).reduce((e,n)=>(e[n]=t[n],e),{}),i=Object.keys(n).filter(e=>r[e]).reduce((e,t)=>(e[t]=n[t],e),{});return this.Nd({featureFlags:r,featureFlagPayloads:i},void 0,{persist:!1})}}updateFlags(e,t,n){var r,i;let a=n?.merge&&(r=this.Ed(`$enabled_feature_flags`))!=null?r:{},o=n?.merge&&(i=this.Ed(`$feature_flag_payloads`))!=null?i:{},s=R(R({},a),e),c=R(R({},o),t),l={};for(let[e,t]of Object.entries(s))l[e]={key:e,enabled:Dn(t),variant:On(t),reason:void 0,metadata:A(c?.[e])?void 0:{id:0,version:void 0,description:void 0,payload:c[e]}};this.Nd({flags:l})}get hasLoadedFlags(){return this.Xc}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){let e=this.Ed($r),t=this.Ed(ri),n=this.Ed(ii);if(!n&&!t)return e||{};let r=W({},e||{}),i=[...new Set([...Object.keys(n||{}),...Object.keys(t||{})])];for(let e of i){var a;let i=r[e],s=t?.[e],c=A(s)?(a=i?.enabled)!=null&&a:!!s,l=A(s)?i?.variant:typeof s==`string`?s:void 0,u=n?.[e],d=R(R({},i),{},{enabled:c,variant:c?l??i?.variant:void 0});var o;c!==i?.enabled&&(d.original_enabled=i?.enabled),l!==i?.variant&&(d.original_variant=i?.variant),u&&(d.metadata=R(R({},i?.metadata),{},{payload:u,original_payload:i==null||(o=i.metadata)==null?void 0:o.payload})),r[e]=d}return this.Zc||=(this.$.warn(` Overriding feature flag details!`,{flagDetails:e,overriddenPayloads:n,finalDetails:r}),!0),r}getAllFeatureFlags(){let e=this.getFlagVariants(),t=this.getFlagPayloads();return Object.keys(e).map(n=>{let r=e[n];return{key:n,enabled:Dn(r),variant:On(r),payload:En(t[n])}})}getFlagVariants(){let e=this.Ed(Xr),t=this.Ed(ri);if(!t)return e||{};let n=W({},e||{}),r=Object.keys(t);for(let e=0;r.length>e;e++)n[r[e]]=t[r[e]];return this.Zc||=(this.$.warn(` Overriding feature flags!`,{enabledFlags:e,overriddenFlags:t,finalFlags:n}),!0),n}getFlagPayloads(){let e=this.Ed(ei),t=this.Ed(ii);if(!t)return e||{};let n=W({},e||{}),r=Object.keys(t);for(let e=0;r.length>e;e++)n[r[e]]=t[r[e]];return this.Zc||=(this.$.warn(` Overriding feature flag payloads!`,{flagPayloads:e,overriddenPayloads:t,finalPayloads:n}),!0),n}reloadFeatureFlags(){this.ed||this.Ir.featureFlagsDisabled||this.ad()||(this.Yc&&(this.nd=!0),this.qd||=(this.Kc.slice().forEac
1h(e=>{try{e()}catch(e){this.$.error(`Error while running feature flags reloading callback`,e)}}),setTimeout(()=>{this.jd()},5)))}Md(){clearTimeout(this.qd),this.qd=void 0}onReloading(e){return this.Kc.push(e),()=>{this.Kc=this.Kc.filter(t=>t!==e)}}ensureFlagsLoaded(){this.Xc||this.Yc||this.qd||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this.ed=e}resetFlagCallReported(){this.Lt(bi)}jd(e){this.Md();let t=this.mo;if(!t||this.Ir.remoteRequestsDisabled||this.ad())return;if(this.Yc)return void(this.nd=!0);let n={token:t.projectToken,distinct_id:t.distinctId,groups:t.groups,$anon_distinct_id:this.$anon_distinct_id,person_properties:R(R(R({},t.initialPersonProperties),this.Ed(`$stored_person_properties`)||{}),{},{$lib:t.library.name,$lib_version:t.library.version}),group_properties:this.Ed(oi),timezone:Qo()};A(t.deviceId)||(n.$device_id=t.deviceId),(e!=null&&e.disableFlags||this.Ir.featureFlagsDisabled)&&(n.disable_flags=!0);let r=this.Dd();r.length&&(n.evaluation_contexts=r);let i=this.Ld();A(i)||(n.flag_keys=i);let a=this.Ir.onlyEvaluateSurveyFeatureFlags,o=`/flags/?v=2`+(a?`&only_evaluate_survey_feature_flags=true`:``),s=this.td;this.Yc=!0;let c=()=>{this.nd&&(this.nd=!1,this.jd())},l=e=>{let t=e.json??{},r=e.statusCode!==200;if(this.Yc=!1,s!==this.td)return void c();if(this.Bd(e.statusCode),r||this.nd||(this.$anon_distinct_id=void 0),n.disable_flags&&!this.nd)return;this.sd=!r;let i=[];e.error?i.push(e.error instanceof Error&&e.error.name===`AbortError`?`timeout`:e.error instanceof Error?hu:`unknown_error`):e.statusCode!==200&&i.push(`api_error_${e.statusCode}`),t.errorsWhileComputingFlags&&i.push(`errors_while_computing_flags`);let o=!!t.quotaLimited?.includes(`feature_flags`);o&&i.push(`quota_limited`),this.At({[Si]:i}),o?this.$.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.`):n.disable_flags||this.Nd(t,r,{partialResponse:a}),c()},u=e=>{this.Yc=!1,s===this.td?(this.At({[Si]:[hu]}),this.$.error(`Feature flag request failed`,e),this.Rd()&&this.Cd(!0),c()):c()};try{t.sendRequest(o,{target:`flags`,method:`POST`,body:n,compression:this.Ir.compression,sentAt:`body`,timeoutMs:this.Ir.requestTimeoutMs}).then(l).catch(u)}catch(e){u(e)}}ad(){return Lo(this.od,3)}Bd(e){this.od=Ro(e,this.od,3,()=>this.$.warn(`Feature flag requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped refreshing feature flags; will try again when connectivity changes.`))}getFeatureFlag(e,t={}){if(t.fresh&&!this.sd)return;if(!(this.Xc||this.getFlags()&&this.getFlags().length>0))return void this.$.warn(`getFeatureFlag for key "`+e+pu);if(this.Od())return;let n=this.getFeatureFlagResult(e,t);return n?.variant??n?.enabled}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){return this.getFeatureFlagResult(e,{send_event:!1})?.payload}getFeatureFlagResult(e,t={}){if(t.fresh&&!this.sd)return;if(!(this.Xc||this.getFlags()&&this.getFlags().length>0))return void this.$.warn(`getFeatureFlagResult for key "`+e+pu);if(this.Od())return;let n=this.getFlagVariants(),r=e in n,i=n[e],a=this.getFlagPayloads()[e],o=String(i),s=this.Ed(`$feature_flag_request_id`)||void 0,c=this.Ed(`$feature_flag_evaluated_at`)||void 0,l,u=this.Ed(`$flag_call_reported`)||{};if(this.Ir.deduplicateCallsPerSession){let e=this.mo?.session.sessionId,t=this.Ed(xi);e&&e!==t&&(u={},l=e)}if(t.send_event||!(`send_event`in t)){if(e in u&&u[e].includes(o))l&&this.At({[bi]:u,[xi]:l});else{var d,f,p,m,h,g,_,v;E(u[e])?u[e].push(o):u[e]=[o],this.At(R({[bi]:u},l?{[xi]:l}:{}));let t=this.getFeatureFlagDetails(e),n=[...this.Ed(`$feature_flag_errors`)??[]];A(i)&&n.push(`flag_missing`);let r={$feature_flag:e,$feature_flag_response:i,$feature_flag_payload:a??null,$feature_flag_request_id:s,$feature_flag_evaluated_at:c,$feature_flag_bootstrapped_response:((d=this.Ir.bootstrap)==null||(d=d.featureFlags)==null?void 0:d[e])??null,$feature_flag_bootstrapped_payload:((f=this.Ir.bootstrap)==null||(f=f.featureFlagPayloads)==null?void 0:f[e])??null,$used_bootstrap_value:!this.sd};A(t==null||(p=t.metadata)==null?void 0:p.has_experiment)||(r.$feature_flag_has_experiment=t.metadata.has_experiment),A(t==null||(m=t.metadata)==null?void 0:m.version)||(r.$feature_flag_version=t.metadata.version);let b=(t==null||(h=t.reason)==null?void 0:h.description)??(t==null||(g=t.reason)==null?void 0:g.code);var y;b&&(r.$feature_flag_reason=b),t!=null&&(_=t.metadata)!=null&&_.id&&(r.$feature_flag_id=t.metadata.id),A(t?.original_variant)&&A(t?.original_enabled)||(r.$feature_flag_original_response=A(t.original_variant)?t.original_enabled:t.original_variant),t!=null&&(v=t.metadata)!=null&&v.original_payload&&(r.$feature_flag_original_payload=t==null||(y=t.metadata)==null?void 0:y.original_payload),n.length&&(r.$feature_flag_error=n.join(`,`)),this.Hd(r)}}else l&&this.At({[bi]:u,[xi]:l});return r?{key:e,enabled:!!i,variant:typeof i==`string`?i:void 0,payload:En(a)}:void 0}Hd(e){try{var t;(t=this.mo)==null||t.capture(`$feature_flag_called`,e)}catch(e){this.$.error(`Failed to capture feature flag call`,e)}}getRemoteConfigPayload(e,t){this.zd(e,t)}zd(e,t){var n=this;return L(function*(){let r=n.mo;if(!r)return;let i={distinct_id:r.distinctId,token:r.projectToken,person_properties:{$lib:r.library.name,$lib_version:r.library.version}},a=n.Dd();a.length&&(i.evaluation_contexts=a);let o=n.Ld(),s;A(o)||(i.flag_keys=o);try{s=(yield r.sendRequest(`/flags/?v=2`,{target:`flags`,method:`POST`,body:i,compression:n.Ir.compression,sentAt:`body`,timeoutMs:n.Ir.requestTimeoutMs})).json?.featureFlagPayloads?.[e]||void 0}catch(e){n.$.error(`Remote config feature flag request failed`,e);return}try{t(s)}catch(e){n.$.error(`Remote config feature flag callback failed`,e)}})()}isFeatureEnabled(e,t={}){if(t.fresh&&!this.sd)return t.defaultValue;if(!(this.Xc||this.getFlags()&&this.getFlags().length>
10))return this.$.warn(`isFeatureEnabled for key "`+e+pu),t.defaultValue;let n=this.getFeatureFlag(e,t);return A(n)?t.defaultValue:!!n}addFeatureFlagsHandler(e){this.featureFlagEventHandlers.push(e)}removeFeatureFlagsHandler(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter(t=>t!==e)}receivedFeatureFlags(e,t,n){this.Nd(e,t,n)}Nd(e,t,n){if(!this.mo)return;this.Xc=!0;let r=((e,t={},n={},r={},i,a=du)=>{let o=((e,t)=>{let n=e.flags;if(n){let t=Object.fromEntries(Object.keys(n).map(e=>[e,n[e].variant??n[e].enabled])),r=Object.fromEntries(Object.keys(n).filter(e=>n[e].enabled).filter(e=>!A(n[e].metadata?.payload)).map(e=>[e,n[e].metadata?.payload]));return R(R({},e),{},{featureFlags:t,featureFlagPayloads:r})}return e.featureFlags&&t.warn(`Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version`),e})(e,a),s=o.flags,c=o.featureFlags,l=o.featureFlagPayloads;if(!c)return;let u=e.requestId,d=e.evaluatedAt;if(E(c)){a.warn(`v1 of the feature flags endpoint is deprecated. Please use the latest version.`);let e={};if(c)for(let t=0;c.length>t;t++)e[c[t]]=!0;return{[Zr]:c,[Xr]:e,[ni]:!1}}let f=c,p=l,m=s;if(i?.partialResponse){let e=Object.keys(f),i=p||{};f=R(R({},t),f),p=R(R({},n),i),e.forEach(e=>{e in i||p==null||delete p[e]}),m=R(R({},r),m)}else if(e.errorsWhileComputingFlags){if(s){let e=new Set(Object.keys(s).filter(e=>!s[e]?.failed));f=R(R({},t),Object.fromEntries(Object.entries(f).filter(([t])=>e.has(t))));let i=Object.fromEntries(Object.entries(p||{}).filter(([t])=>e.has(t)));p=R(R({},n),i),e.forEach(e=>{e in i||p==null||delete p[e]}),m=R(R({},r),Object.fromEntries(Object.entries(m||{}).filter(([t])=>e.has(t))))}else f=R(R({},t),f),p=R(R({},n),p),m=R(R({},r),m)}return R(R({[Zr]:Object.keys(_u(f)),[Xr]:f||{},[ei]:p||{},[$r]:m||{},[ni]:!0===e.minimalFlagCalledEvents},u?{[ti]:u}:{}),d?{[Ci]:d}:{})})(e,this.getFlagVariants(),this.getFlagPayloads(),this.getFlagsWithDetails(),n,this.$);if(r){if(!1===n?.persist){let e=!A(this.mo.kv.get(Xr));this.Pd=r,e||this.At(r)}else this.Sd(),this.Fd(r,e,!!n?.partialResponse),this.At(r)}else t&&this.Rd();t||(this.rd=!1),this.Cd(t)}override(e,t=!1){this.$.warn(`override is deprecated. Please use overrideFeatureFlags instead.`),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){this.Ud(e)}Ud(e){if(this.mo){if(!1===e)return this.Lt([ri,ii]),this.Cd(),void fu.info(`All overrides cleared`);if(E(e))return this.At({[ri]:gu(e)}),this.Cd(),void fu.info(`Flag overrides set`,{flags:e});if(e&&typeof e==`object`&&(`flags`in e||`payloads`in e)){var t;let n=e;this.Zc=!!((t=n.suppressWarning)!=null&&t);let r={},i=n.flags,a=n.payloads;i&&(r[ri]=E(i)?gu(i):i),a&&(r[ii]=a),Object.keys(r).length&&this.At(r),!1===i&&!1===a?this.Lt([ri,ii]):!1===i?this.Lt(ri):!1===a&&this.Lt(ii),this.Cd(),!1===i?fu.info(`Flag overrides cleared`):i&&fu.info(`Flag overrides set`,{flags:i}),!1===a?fu.info(`Payload overrides cleared`):a&&fu.info(`Payload overrides set`,{payloads:a});return}if(e&&typeof e==`object`)return this.At({[ri]:e}),this.Cd(),void fu.info(`Flag overrides set`,{flags:e});this.$.warn(`Invalid overrideOptions provided to overrideFeatureFlags`,{overrideOptions:e})}else this.$.warn(`posthog.featureFlags.overrideFeatureFlags called before feature flags were ready`)}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this.Xc){let{flags:t,flagVariants:n}=this.Wd();try{e(t,n)}catch(e){this.$.error(`Error while running feature flags callback`,e)}}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t,n){var r;let i=(this.Ed(`$early_access_features`)||[]).find(t=>t.flagKey===e),a={[`$feature_enrollment/${e}`]:t},o={$feature_flag:e,$feature_enrollment:t,$set:a};i&&(o.$early_access_feature_name=i.name),n&&(o.$feature_enrollment_stage=n);let s=R(R({},this.getFlagVariants()),{},{[e]:t});(r=this._instance)==null||(r=r.persistence)==null||r.markCrossTabFeatureFlagChanges({$active_feature_flags:[e],$enabled_feature_flags:[e],$stored_person_properties:Object.keys(a)}),this.At({[Zr]:Object.keys(_u(s)),[Xr]:s,[ai]:R(R({},this.Ed(`$stored_person_properties`)||{}),a)}),this.Cd();try{var c;(c=this.mo)==null||c.capture(`$feature_enrollment_update`,o)}catch(e){this.$.error(`Failed to capture early access feature enrollment`,e)}}getEarlyAccessFeatures(e,t=!1,n){let r=this.Ed(Qr);!r||t?this.Vd(e,n):e(r)}Vd(e,t){var n=this;return L(function*(){let r=n.mo;if(!r)return;let i=t?`&${t.map(e=>`stage=${e}`).join(`&`)}`:``,a;try{let e=yield r.sendRequest(`/api/early_access_features/?token=${r.projectToken}${i}`,{target:`api`,method:`GET`,sentAt:`query`});if(!e.json)return;a=e.json.earlyAccessFeatures,n.At({[Qr]:a})}catch(e){n.$.error(`Early access feature request failed`,e);return}try{e(a)}catch(e){n.$.error(`Early access feature callback failed`,e)}})()}Wd(){let e=this.getFlags(),t=this.getFlagVariants();return{flags:e.filter(e=>t[e]),flagVariants:Object.keys(t).filter(e=>t[e]).reduce((e,n)=>(e[n]=t[n],e),{})}}Cd(e){this.xd();let{flags:t,flagVariants:n}=this.Wd();
1this.featureFlagEventHandlers.forEach(r=>{try{r(t,n,{errorsLoading:e})}catch(e){this.$.error(`Error while running feature flags callback`,e)}})}setPersonPropertiesForFlags(e,t=!0){this.Gd(e,t)}Gd(e,t=!0){let n=this.Ed(`$stored_person_properties`)||{},r=e?.$set||(e?.$set_once?{}:e),i=e?.$set_once,a={};if(i)for(let e in i)({}).hasOwnProperty.call(i,e)&&(e in n||(a[e]=i[e]));this.At({[ai]:R(R(R({},n),a),r)}),t&&this.reloadFeatureFlags()}unsetPersonPropertiesForFlags(e,t=!0){let n=R({},this.Ed(`$stored_person_properties`)||{});e.forEach(e=>{delete n[e]}),this.At({[ai]:n}),t&&this.reloadFeatureFlags()}resetPersonPropertiesForFlags(e=!0){this.Lt(ai),e&&this.reloadFeatureFlags()}setGroupPropertiesForFlags(e,t=!0){let n=this.Ed(`$stored_group_properties`)||{},r=R({},n);for(let t of Object.keys(e))r[t]=R(R({},n[t]),e[t]);this.At({[oi]:r}),t&&this.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){let t=this.Ed(`$stored_group_properties`)||{};this.At({[oi]:R(R({},t),{},{[e]:{}})})}else this.Lt(oi)}reset(){this.td++,this.nd=!1,this.Qc={},this.Jc={},this.Pd=void 0,this.Xc=!1,this.ed=!1,this.sd=!1,this.$anon_distinct_id=void 0,this.Md(),this.Zc=!1,this.od=0}}},Gu={sessionRecording:class{get Ir(){return this._instance.config}get Ca(){return this._instance.persistence}get started(){return!!this.Zd?.isStarted}get status(){return this.Qd===`awaiting_config`||this.Qd===`missing_config`?this.Qd:this.Zd?.status??this.Qd}constructor(t){if(this._instance=t,this._forceAllowLocalhostNetworkCapture=!1,this.Qd=Bl,this.Jd=void 0,this.Kd=!1,this.Xe=(()=>{var t,n;if(!r?.visibilityState||r.visibilityState===`visible`)return!0;let i=e==null||(t=e.performance)==null||(n=t.getEntriesByType)==null?void 0:n.call(t,`visibility-state`);return!i?.length||i.some(e=>e.name===`visible`)})(),this.ln=()=>{var e,t;r?.visibilityState===`visible`&&(this.Xe=!0,(e=this.Zd)==null||(t=e.setDocumentWasEverVisible)==null||t.call(e,!0))},!this._instance.sessionManager)throw Hl.error(`started without valid sessionManager`),Error(`[SessionRecording] started without valid sessionManager. This is a bug.`);if(this.Ir.cookieless_mode===`always`)throw Error(`[SessionRecording] cannot be used with cookieless_mode="always"`);r!=null&&r.addEventListener&&G(r,`visibilitychange`,this.ln)}initialize(){this.startIfEnabledOrStop()}dispose({discardBufferedEvents:e=!1}={}){var t;this.Kd=!0,r==null||(t=r.removeEventListener)==null||t.call(r,`visibilitychange`,this.ln),e?this.Xd(!0):this.stopRecording()}get Yd(){let t=!!this._instance.get_property(`$session_recording_remote_config`)?.enabled,n=!this.Ir.disable_session_recording,r=this.Ir.disable_session_recording||this._instance.consent.isOptedOut();return e&&t&&n&&!r}startIfEnabledOrStop(e){if(this.Kd||this.Yd&&this.Zd?.isStarted)return;let t=!A(Object.assign)&&!A(Array.from);this.Yd&&t?(this.tv(e),Hl.info(`starting`)):(this.Qd=Bl,this.stopRecording())}tv(e){var t;if(this.Yd){if(this.Qd!==`awaiting_config`&&this.Qd!==`missing_config`&&(this.Qd=Vl),f!=null&&(t=f.__PosthogExtensions__)!=null&&(t=t.rrweb)!=null&&t.record&&f.__PosthogExtensions__?.initSessionRecording)this.ev(e);else{var n,r;let t=this._instance.sessionManager;(n=f.__PosthogExtensions__)==null||(r=n.loadExternalDependency)==null||r.call(n,this._instance,this.iv,n=>{if(!this.Kd&&this.Yd&&this._instance.sessionManager===t)return n?(this._instance.register_for_session({$sdk_debug_recording_script_not_loaded:!0}),Hl.error(`could not load recorder`,n)):void this.ev(e);this.Qd=`disabled`})}}}stopRecording(){var e,t;(e=this.Jd)==null||e.call(this),this.Jd=void 0,(t=this.Zd)==null||t.stop()}Xd(e=!1){var t,n;(t=this.Jd)==null||t.call(this),this.Jd=void 0,(n=this.Zd)==null||n.discard({discardProducerEvents:e})}nv(){var e,t;(e=this.Ca)==null||e.unregister(`$session_is_sampled`),(t=this.Ca)==null||t.unregister(`$replay_sample_rate`)}sv(e,t){if(N(e))return null;let n=P(e)?e:parseFloat(e);return typeof(r=n)!=`number`||!Number.isFinite(r)||0>r||r>1?(Hl.warn(`${t} must be between 0 and 1. Ignoring invalid value:`,e),null):n;var r}rv(e){if(this.Ca){var t;let n=this.Ca,r=()=>{let t=!1===e.sessionRecording?void 0:e.sessionRecording,r=this.sv(this.Ir.session_recording?.sampleRate,`session_recording.sampleRate`),i=this.sv(t?.sampleRate,`remote config sampleRate`),a=r??i;N(a)&&this.nv();let o=t?.minimumDurationMilliseconds;n.register({[Ir]:R(R({cache_timestamp:Date.now(),enabled:!!t},t),{},{networkPayloadCapture:R({capturePerformance:e.capturePerformance},t?.networkPayloadCapture),canvasRecording:{enabled:t?.recordCanvas,fps:t?.canvasFps,quality:t?.canvasQuality}
1,sampleRate:a,minimumDurationMilliseconds:A(o)?null:o,endpoint:t?.endpoint,triggerMatchType:t?.triggerMatchType,masking:t?.masking,urlTriggers:t?.urlTriggers,version:t?.version,triggerGroups:t?.triggerGroups})})};r(),(t=this.Jd)==null||t.call(this),this.Jd=this._instance.sessionManager?.onSessionId(r)}}onRemoteConfig(e){let t=e.ok?e.config:void 0;t&&`sessionRecording`in t?!1===t.sessionRecording?(this.rv(t),this.Xd()):(this.rv(t),this.startIfEnabledOrStop()):(this.Qd===`awaiting_config`&&(this.Qd=`missing_config`,this._instance.register_for_session({[Fi]:!0}),Hl.warn(`config refresh failed, recording will not start until page reload`)),this.startIfEnabledOrStop())}log(e,t=`log`){this.Zd?.log?this.Zd.log(e,t):Hl.warn(`log called before recorder was ready`)}get iv(){var e,t;let n=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.get_property(Ir);return(n==null||(t=n.scriptConfig)==null?void 0:t.script)||`lazy-recorder`}ov(){let e=this._instance.get_property(Ir);if(!e)return!1;let t;try{t=typeof e==`object`?e:JSON.parse(e)}catch(e){return Hl.warn(`persisted remote config for session recording is invalid and will be ignored`,e),!1}return!N(t.cache_timestamp)&&36e5>=Date.now()-t.cache_timestamp}ev(e){var t,n;if(!this.Kd&&this.Yd&&this._instance.sessionManager){if(!f.__PosthogExtensions__?.initSessionRecording)return Hl.warn(`Called on script loaded before session recording is available. This can be caused by adblockers.`),void this._instance.register_for_session({[Pi]:!0});if(this.Zd||(this.Zd=f.__PosthogExtensions__?.initSessionRecording(this._instance,this.Xe),this.Zd._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.ov()){if(this.Qd===`missing_config`||this.Qd===`awaiting_config`)return;this.Qd=`awaiting_config`,Hl.info(`persisted remote config is stale, requesting fresh config before starting`),new ws(this._instance).load();return}this.Qd=Vl,(t=(n=this.Zd).setDocumentWasEverVisible)==null||t.call(n,this.Xe),this.Zd.start(e)}else this.Qd=Bl}onRRwebEmit(e){var t,n;(t=this.Zd)==null||(n=t.onRRwebEmit)==null||n.call(t,e)}overrideLinkedFlag(){var e,t;this.Zd||(t=this.Ca)==null||t.register({$replay_override_linked_flag:!0}),(e=this.Zd)==null||e.overrideLinkedFlag()}overrideSampling(){var e,t;this.Zd||(t=this.Ca)==null||t.register({$replay_override_sampling:!0}),(e=this.Zd)==null||e.overrideSampling()}overrideTrigger(e){var t,n;this.Zd||(n=this.Ca)==null||n.register({[e===`url`?`$replay_override_url_trigger`:`$replay_override_event_trigger`]:!0}),(t=this.Zd)==null||t.overrideTrigger(e)}get sdkDebugProperties(){return this.Zd?.sdkDebugProperties||{$recording_status:this.status}}tryAddCustomEvent(e,t){return!!this.Zd?.tryAddCustomEvent(e,t)}flushBeforeIdentityReset(){var e,t;(e=this.Zd)==null||(t=e.flushBeforeIdentityReset)==null||t.call(e)}}},Ku={autocapture:class extends Ol{constructor(e){super(new kl(e)),this.instance=e}},historyAutocapture:class{constructor(e){this._instance=e,this.lv=this.av()}initialize(){this.startIfEnabled()}get isEnabled(){let e=this.uv();return!!(e.path||e.search||this.hv(e))}startIfEnabled(){this.isEnabled&&(z.info(`History API monitoring enabled, starting...`),this.monitorHistoryChanges())}startIfEnabledOrStop(){this.stop(),this.lv=this.av(),this.startIfEnabled()}stop(){this.dv&&this.dv(),this.dv=void 0,this.vv&&this.vv(),this.vv=void 0,z.info(`History API monitoring stopped`)}monitorHistoryChanges(){e&&e.history&&(this.fv(`pushState`),this.fv(`replaceState`),this.pv(),this.hv()&&this.gv())}fv(t){if(!e||e.history[t]?.__posthog_wrapped__)return;let n=this;Nl(e.history,t,e=>function(r,i,a){e.call(this,r,i,a),n.mv(t)})}av(){let t=e?.location;if(t?.pathname)return{pathname:t.pathname,search:t.search,hash:t.hash}}uv(){let e=this._instance.config.capture_pageview;return e===`history_change`?{path:!0}:O(e)?e:{}}hv(e=this.uv()){return!!e.hash&&!this._instance.config.disable_capture_url_hashes}yv(e){let t=this.uv(),n=this.lv;return!(!n||!(t.path&&e.pathname!==n.pathname||t.search&&e.search!==n.search||this.hv(t)&&e.hash!==n.hash))}mv(e){try{let t=this.av();if(!t)return;this.yv(t)&&this._instance.capture(Xi,{navigation_type:e}),this.lv=t}catch(t){z.error(`Error capturing ${e} pageview`,t)}}
1pv(){if(this.dv)return;let t=()=>{this.mv(`popstate`)};G(e,`popstate`,t),this.dv=()=>{e&&e.removeEventListener(`popstate`,t)}}gv(){if(this.vv)return;let t=()=>{this.mv(`hashchange`)};G(e,`hashchange`,t),this.vv=()=>{e&&e.removeEventListener(`hashchange`,t)}}},heatmaps:class{get Ir(){return this.instance.config}constructor(e){this.bv=!1,this._o=!1,this._v=null,this.instance=e,this.bv=!!this.instance.persistence?.props[Dr],this.rageclicks=new Sl(e.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){let e=5e3;return O(this.Ir.capture_heatmaps)&&this.Ir.capture_heatmaps.flush_interval_milliseconds&&(e=this.Ir.capture_heatmaps.flush_interval_milliseconds),e}get isEnabled(){return N(this.Ir.capture_heatmaps)?N(this.Ir.enable_heatmaps)?this.bv:this.Ir.enable_heatmaps:!1!==this.Ir.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this._o)return;Ul.info(`starting...`),this.wv(),this.ln()}else clearInterval(this._v??void 0),this.Sv(),this.getAndClearBuffer()}onRemoteConfig(e){if(!e.ok)return;let t=e.config;if(!(`heatmaps`in t))return;let n=!!t.heatmaps;this.instance.persistence&&this.instance.persistence.register({[Dr]:n}),this.bv=n,this.startIfEnabled()}getAndClearBuffer(){let e=this.Rt;return this.Rt=void 0,e}xv(e){Wl(e.originalEvent)&&this.Mr(e.originalEvent,`deadclick`)}ln(){this._v&&clearInterval(this._v),this._v=r?.visibilityState===`visible`?setInterval(this.pa.bind(this),this.flushIntervalMilliseconds):null}wv(){e&&r&&(this.Cv=this.pa.bind(this),G(e,Yi,this.Cv),this.$v=t=>this.Mr(t||e?.event),G(r,`click`,this.$v,{capture:!0}),this.Tv=t=>this.Iv(t||e?.event),G(r,`mousemove`,this.Tv,{capture:!0}),this.Mv=new So(this.instance,bo,this.xv.bind(this)),this.Mv.startIfEnabledOrStop(),this.Ev=this.ln.bind(this),G(r,Ji,this.Ev),this._o=!0)}Sv(){var t;e&&r&&(this.Cv&&e.removeEventListener(Yi,this.Cv),this.$v&&r.removeEventListener(`click`,this.$v,{capture:!0}),this.Tv&&r.removeEventListener(`mousemove`,this.Tv,{capture:!0}),this.Ev&&r.removeEventListener(Ji,this.Ev),clearTimeout(this.Pv),(t=this.Mv)==null||t.stop(),this._o=!1)}Rv(t,n){let r=this.instance.scrollManager.scrollY(),i=this.instance.scrollManager.scrollX(),a=this.instance.scrollManager.scrollElement(),o=function(t,n,r){let i=t;for(;i&&Ia(i)&&!Y(i,`body`);){if(i===r)return!1;let t;try{t=(i.ownerDocument?.defaultView??e)?.getComputedStyle(i).position}catch{return!1}if(y(n,t))return!0;i=Ja(i)}return!1}(Wa(t),[`fixed`,`sticky`],a);return{x:t.clientX+(o?0:i),y:t.clientY+(o?0:r),target_fixed:o,type:n}}Mr(e,t=`click`){var n;if(Fa(e.target)||!Wl(e))return;let r=this.Rv(e,t);(n=this.rageclicks)!=null&&n.isRageClick(e.clientX,e.clientY,new Date().getTime())&&to(Wa(e),this.instance.config.rageclick)&&this.Zs(R(R({},r),{},{type:`rageclick`})),this.Zs(r)}Iv(e){!Fa(e.target)&&Wl(e)&&(clearTimeout(this.Pv),this.Pv=setTimeout(()=>{this.Zs(this.Rv(e,`mousemove`))},500))}Zs(t){if(!e)return;let n=this.Ir.disable_capture_url_hashes?Ot(e.location.href):e.location.href,r=this.Ir.custom_personal_data_properties,i=Fo(n,this.Ir.mask_personal_data_properties?[...zo,...r||[]]:[],Vo);this.Rt=this.Rt||{},this.Rt[i]||(this.Rt[i]=[]),this.Rt[i].push(t)}pa(){this.Rt&&!k(this.Rt)&&this.instance.capture(`$$heatmap`,{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:So,webVitalsAutocapture:class{constructor(e){this._instance=e,this.bv=!1,this._o=!1,this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this.Av=()=>{clearTimeout(this.Fv),this.Fv=void 0,this.Rt.metrics.length!==0&&(this._instance.capture(`$web_vitals`,R({$current_url:this.Rt.url},this.Rt.metrics.reduce((e,t)=>R(R({},e),{},{[`$web_vitals_${t.name}_event`]:R({},t),[`$web_vitals_${t.name}_value`]:t.value}),{}))),this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.Ov=e=>{if(this.Rt=this.Rt||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},N(e?.name)||N(e?.value))return void Fl.error(`Invalid metric received`,e);let t=typeof e.navigationURL==`string`?e.navigationURL:void 0,n=this.Dv(t);if(A(n))return;let r=P(e.navigationId)||typeof e.navigationId==`string`?`navigation:${e.navigationId}`:`url:${n}`;if(this.Lv&&e.value>=this.Lv)return void Fl.error(`Ignoring metric with value >= `+this.Lv,e);
1this.Rt.navigationKey!==r&&(this.Av(),this.Fv=setTimeout(this.Av,this.flushToCaptureTimeoutMs)),A(this.Rt.navigationKey)&&(this.Rt.navigationKey=r,this.Rt.url=n),this.Rt.firstMetricTimestamp=A(this.Rt.firstMetricTimestamp)?Date.now():this.Rt.firstMetricTimestamp;let i=this._instance.sessionManager?.checkAndGetSessionAndWindowId(!0),a=R(R(R({},e),t?{navigationURL:n}:{}),{},{$current_url:n,timestamp:Date.now()});if(delete a.entries,O(e.attribution)&&this.attributionMetrics.indexOf(e.name)>-1){let t={};for(let n of zl){let r=n===`url`&&typeof e.attribution[n]==`string`?this.Dv(e.attribution[n]):e.attribution[n];A(r)||(t[n]=r)}a.attribution=t}else delete a.attribution;A(i)||(a.$session_id=i.sessionId,a.$window_id=i.windowId),this.Rt.metrics.push(a),this.Rt.metrics.length===this.allowedMetrics.length&&this.Av()},this.Nv=()=>{if(this._o)return;let e,t,n,r,i=!1,a=f.__PosthogExtensions__,o=a?.postHogWebVitalsCallbacksByFlavor,s=o?.[this.qv]||(this.qv===`web-vitals`&&A(o)?a?.postHogWebVitalsCallbacks:void 0);if(!A(s)){let a=s.withoutAttribution,o=this.attributionMetrics;i=!A(a),e=o.indexOf(`LCP`)>-1?s.onLCP:a?.onLCP||s.onLCP,t=o.indexOf(`CLS`)>-1?s.onCLS:a?.onCLS||s.onCLS,n=o.indexOf(`FCP`)>-1?s.onFCP:a?.onFCP||s.onFCP,r=o.indexOf(`INP`)>-1?s.onINP:a?.onINP||s.onINP}if(!(e&&t&&n&&r))return void Fl.error(`web vitals callbacks not loaded - not starting`);let c={reportSoftNavs:this.useSoftNavs},l=i&&this.attributionMetrics.indexOf(`INP`)>-1?R(R({},c),{},{includeProcessedEventEntries:!1}):c;this.allowedMetrics.indexOf(`LCP`)>-1&&e(this.Ov.bind(this),c),this.allowedMetrics.indexOf(`CLS`)>-1&&t(this.Ov.bind(this),c),this.allowedMetrics.indexOf(`FCP`)>-1&&n(this.Ov.bind(this),c),this.allowedMetrics.indexOf(`INP`)>-1&&r(this.Ov.bind(this),l),this._o=!0},this.bv=!!this._instance.persistence?.props[jr],this.startIfEnabled()}get jv(){return this._instance.config.capture_performance}get allowedMetrics(){let e=O(this.jv)?this.jv?.web_vitals_allowed_metrics:void 0;return N(e)?this._instance.persistence?.props.$web_vitals_allowed_metrics||Ll:e}get flushToCaptureTimeoutMs(){return(O(this.jv)?this.jv.web_vitals_delayed_flush_ms:void 0)||5e3}get attributionMetrics(){let e=O(this.jv)?this.jv.web_vitals_attribution:void 0;return F(e)?e?Ll:[]:E(e)?e:Rl}get useAttribution(){return this.attributionMetrics.length>0}get useSoftNavs(){let e=O(this.jv)?this.jv.__preview_web_vitals_soft_navs:void 0;return e!=null&&e}get Lv(){let e=O(this.jv)&&P(this.jv.__web_vitals_max_value)?this.jv.__web_vitals_max_value:Il;return e>0&&6e4>=e?Il:e}get isEnabled(){let e=i?.protocol;if(e!==`http:`&&e!==`https:`)return Fl.info(`Web Vitals are disabled on non-http/https protocols`),!1;let t=O(this.jv)?this.jv.web_vitals:F(this.jv)?this.jv:void 0;return F(t)?t:this.bv}startIfEnabled(){this.isEnabled&&!this._o&&(Fl.info(`enabled, starting...`),this.qo(this.Nv))}onRemoteConfig(e){if(!e.ok)return;let t=e.config;if(!(`capturePerformance`in t))return;let n=O(t.capturePerformance)&&!!t.capturePerformance.web_vitals,r=O(t.capturePerformance)?t.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[jr]:n}),this._instance.persistence.register({[Fr]:r})),this.bv=n,this.startIfEnabled()}get qv(){return this.useSoftNavs?this.useAttribution?`web-vitals-with-attribution-soft-navs`:`web-vitals-soft-navs`:this.useAttribution?`web-vitals-with-attribution`:`web-vitals`}qo(e){var t;let n=f.__PosthogExtensions__,r=this.qv,i=n?.postHogWebVitalsCallbacksByFlavor;i?.[r]||r===`web-vitals`&&A(i)&&n?.postHogWebVitalsCallbacks?e():n==null||(t=n.loadExternalDependency)==null||t.call(n,this._instance,r,t=>{t?Fl.error(`failed to load script`,t):e()})}Dv(t){let n=t||e?.location.href;if(!n)return void Fl.error(`Could not determine current URL`);let r=this._instance.config.disable_capture_url_hashes?Ot(n):n,i=this._instance.config.custom_personal_data_properties;return Fo(r,this._instance.config.mask_personal_data_properties?[...zo,...i||[]]:[],Vo)}}},qu={exceptionObserver:class{constructor(t){this.Nv=()=>{if(!e||!this.isEnabled||!f.__PosthogExtensions__?.errorWrappingFunctions)return;let t=f.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,n=f.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,r=f.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.Bv&&this.Ir.capture_unhandled_errors&&(this.Bv=t(this.captureException.bind(this))),!this.Hv&&this.Ir.capture_unhandled_rejections&&(this.Hv=n(this.captureException.bind(this))),!this.zv&&this.Ir.capture_console_errors&&(this.zv=r(this.captureException.bind(this)))}catch(e){Al.error(`failed to start`,e),this.Uv()}},this._instance=t,this.Wv=!!this._instance.persistence?.props[Or],this.wt=new he(R(R({},function(e={}){return{refillRate:e.exceptionRateLimiterRefillRate??e.__exceptionRateLimiterRefillRate??1,bucketSize:e.exceptionRateLimiterBucketSize??e.__exceptionRateLimiterBucketSize??10}}(this._instance.config.error_tracking)),{},{refillInterval:1e4,$:Al})),this.Ir=this.Vv(),this.startIfEnabledOrStop()}Vv(){let e=this._instance.config.capture_exceptions,t={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return O(e)?t=R(R({},t),e):(A(e)?this.Wv:e)&&(t=R(R({},t),{},{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),t}get isEnabled(){return this.Ir.capture_console_errors||this.Ir.capture_unhandled_errors||this.Ir.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(Al.info(`enabled`),this.Uv(),this.qo(this.Nv)):this.Uv()}qo(e){var t,n;f.__PosthogExtensions__?.errorWrappingFunctions?e():(t=f.__PosthogExtensions__)==null||(n=t.loadExternalDependency)==null||n.call(t,this._instance,`exception-autocapture`,t=>{if(t)return Al.error(`failed to load script`,t);
1e()})}Uv(){var e,t,n;(e=this.Bv)==null||e.call(this),this.Bv=void 0,(t=this.Hv)==null||t.call(this),this.Hv=void 0,(n=this.zv)==null||n.call(this),this.zv=void 0}onRemoteConfig(e){if(!e.ok)return;let t=e.config;`autocaptureExceptions`in t&&(this.Wv=!!t.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[Or]:this.Wv}),this.Ir=this.Vv(),this.startIfEnabledOrStop())}onConfigChange(){this.Ir=this.Vv()}captureException(e){try{var t,n;let r=(e==null||(t=e.$exception_list)==null||(t=t[0])==null?void 0:t.type)??`Exception`;if(this.wt.consumeRateLimit(r))return void Al.info(`Skipping exception capture because of client rate limiting.`,{exception:r});(n=this._instance.exceptions)==null||n.sendExceptionEvent(e)}catch{}}},exceptions:class{constructor(e){this.Gv=[],this.Zv=new Bt([new cn,new vn,new un,new ln,new gn,new hn,new fn,new _n],function(e,...t){return(n,r=0)=>{let i=[],a=n.split(` 2`),o=Math.min(a.length,r+1e3),s=[];for(let n=r;o>n;n++){let r=a[n];if(r.length>1024)continue;let o=$t.test(r)?r.replace($t,`$1`):r;if(!o.match(/\S*Error: /)){for(let n of t){let t=n(o,e);if(t){i.push(t);let e=tn(i);if(e){for(let t=s.length-1;t>=0;t--){let n=s[t];if(e.start>=n.start+n.length)break;s.pop()}s.push(e)}break}}if(on(i,s)>=50)break}}let c=[...s].sort((e,t)=>t.start-e.start),l=c[c.length-1];if(l){let e=rn(i,l);i.splice(l.start-e,e);for(let t of c)t.start-=e}for(let e of c)nn(i,e);return s.some(e=>e.start===0&&i.length===e.length)&&function(e){let t=e.map(e=>`${e.function}|${e.filename}|${e.lineno}|${e.colno}|${e.module}`),n=0;for(let e=1;t.length>e;e++)sn(t,e,n)&&(n=e);e.push(...e.splice(0,n))}(i),function(e){if(!e.length)return[];let t=Array.from(e);return t.reverse(),t.slice(0,50).map(e=>{return R(R({},e),{},{filename:e.filename||(n=t,n[n.length-1]||{}).filename,function:e.function||`?`});var n})}(i)}}(`web:javascript`,Yt,Qt)),this._instance=e,this.Gv=this._instance.persistence?.get_property(`$error_tracking_suppression_rules`)??[],this.Qv=Cn(this.Jv()),this.Kv=new wn(this.Qv)}onConfigChange(){this.Qv=Cn(this.Jv()),this.Kv.setConfig(this.Qv)}onRemoteConfig(e){if(!e.ok)return;let t=e.config;if(!(`errorTracking`in t))return;let n=t.errorTracking?.suppressionRules??[],r=t.errorTracking?.captureExtensionExceptions;this.Gv=n,this._instance.persistence&&this._instance.persistence.register({[kr]:this.Gv,[Ar]:r})}get Xv(){var e;let t=!!this._instance.get_property(Ar);return(e=this._instance.config.error_tracking.captureExtensionExceptions??t)!=null&&e}buildProperties(e,t){return this.Zv.buildFromUnknown(e,{syntheticException:t?.syntheticException,mechanism:{handled:t?.handled}})}addExceptionStep(e,t){if(this.Qv.enabled)try{if(!j(e)||e.trim().length===0)return void yu.warn(`Ignoring exception step because message must be a non-empty string`);let{sanitizedProperties:n,droppedKeys:r}=function(e){if(!e)return{sanitizedProperties:{},droppedKeys:[]};let t=[];return{sanitizedProperties:Object.keys(e).reduce((n,r)=>xn.has(r)?(t.push(r),n):(n[r]=e[r],n),{}),droppedKeys:t}}(this.Yv(t));r.length>0&&yu.warn(`Ignoring reserved exception step fields`,{droppedKeys:r}),this.Kv.add(R({[yn]:e,[bn]:new Date().toISOString()},n))}catch(e){yu.error(`Failed to add exception step. Ignoring breadcrumb.`,e)}}sendExceptionEvent(e){try{let t=e.$exception_list;if(this.tf(t)){if(this.ef(t))return this.if(`Exception dropped: matched a suppression rule`),void yu.info(`Skipping exception capture because a suppression rule matched`);if(!this.Xv&&this.nf(t))return this.if(`Exception dropped: thrown by a browser extension`),void yu.info(`Skipping exception capture because it was thrown by an extension`);if(!this.Xv&&this.sf(t))return this.if(`Exception dropped: thrown by an injected browser script`),void yu.info(`Skipping exception capture because it was thrown by an injected browser script`);if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.rf(t))return this.if(`Exception dropped: thrown by the PostHog SDK`),void yu.info(`Skipping exception capture because it was thrown by the PostHog SDK`)}let n=this.Qv.enabled&&N(e.$exception_steps)?this.lf(e):e,r=function(){let e=globalThis._posthogReleaseId;return typeof e==`string`&&e.length>0?e:void 0}();r&&(n.$release_id=r);try{let e=this._instance.capture(`$exception`,n,{_noTruncate:!0,_batchKey:`exceptionEvent`,ah:!0});return e&&this.Kv.clear(),e}catch(e){vu(e)||yu.error(`Failed to capture exception event. Dropping this exception.`,e),this.Kv.clear();return}}catch(e){vu(e)||yu.error(`Failed to process exception event. Ignoring this exception.`,e);return}}lf(e){try{let t=this.Kv.getAttachable();return t.length===0?e:R(R({},e),{},{$exception_steps:t})}catch(t){return yu.error(`Failed to read buffered exception steps. Capturing exception without steps.`,t),e}}if(e){this.Qv.enabled&&this.Kv.add({[yn]:e,[bn]:new Date().toISOString()})}Yv(e){return O(e)?R({},e):{}}Jv(){return this._instance.config.error_tracking?.exception_steps??{}}ef(e){if(e.length===0)return!1;try{let t=e.reduce((e,{type:t,value:n})=>(j(t)&&t.length>0&&e.$exception_types.push(t),j(n)&&n.length>0&&e.$exception_values.push(n),e),{$exception_types:[],$exception_values:[]});return this.Gv.some(e=>{let n=e.values.map(e=>{let n=Bc[e.operator],r=t[e.key];if(!n||!r)return!1;let i=E(e.value)?e.value:[e.value];return i.length>0&&n(i,r)});return e.type===`OR`?n.some(Boolean):n.every(Boolean)})}catch(e){return yu.warn(`Failed to evaluate suppression rules. Capturing the exception.`,e),!1}}nf(e){let t=e.flatMap(e=>e.stacktrace?.frames??[]),n=t.filter(({filename:e})=>!!e&&Su.some(t=>e.startsWith(t)));return n.length!==0&&(!n.every(({filename:e})=>!!e&&e.startsWith(bu))||e.some(({type:e,value:t})=>e===`NoResponse`||j(t)&&xu.some(({value:e,exact:n})=>n?t===e:t.includes(e)))&&!t.some(({in_app:e,filename:t})=>e&&!t?.startsWith(bu)))}sf(e){return e.some(({value:e})=>j(e)&&Cu.some(t=>e.includes(t)))}rf(e){if(e.length>0){var t,n;let r=e[0].stacktrace?.frames??[],i=r[r.length-1];return(t=i==null||(n=i.filename)==null?void 0:n.includes(`posthog.com/static`))!=null&&t}return!1}tf(e){return!N(e)&&E(e)}}},Ju=R({productTours:class{get Ca(){return this._instance.persistence}constructor(e){this.af=null,this.uf=null,this._instance=e}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(!e.ok)return;let t=e.config;if(`productTours`in t){var n;if(this.Ca&&this.Ca.register({[Nr]:!!t.productTours}),!Kl(this._instance))return!this.af&&N(this.Ca?.props.ph_product_tours)||Gl.info(`product tours disabled; stopping and clearing cached tours`),(n=this.af)==null||n.stop(),this.af=null,void this.clearCache();this.loadIfEnabled()}}loadIfEnabled(){!this.af&&Kl(this._instance)&&this.qo(()=>this.hf())}qo(e){var t,n;f.__PosthogExtensions__?.generateProductTours?e():(t=f.__PosthogExtensions__)==null||(n=t.loadExternalDependency)==null||n.call(t,this._instance,`product-tours`,t=>{t?Gl.error(`Could not load product tours script`,t):e()})}hf(){var e;!this.af&&(e=f.__PosthogExtensions__)!=null&&e.generateProductTours&&(this.af=f.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,t=!1){if(E(this.uf)&&!t)return void e(this.uf,{isLoaded:!0});let n=this.Ca;if(n){let r=n.props[pi];if(E(r)&&!t)return this.uf=r,void e(r,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor(`api`,`/api/product_tours/?token=${this._instance.config.token}`),method:`GET`,timestampMode:`query`,callback:t=>{if(!Kl(this._instance))return void e([],{isLoaded:!0});let r=t.statusCode;if(r!==200||!t.json){let n=`Product Tours API could not be loaded, status: ${r}`;r===0?t.error||Gl.warn(n):Gl.error(n),e([],{isLoaded:!1,error:n});return}let i=E(t.json.product_tours)?t.json.product_tours:[];this.uf=i,n&&n.register({[pi]:i}
2),e(i,{isLoaded:!0})}})}getActiveProductTours(e){N(this.af)?e([],{isLoaded:!1,error:`Product tours not loaded`}):this.af.getActiveProductTours(e)}showProductTour(e){var t;(t=this.af)==null||t.showTourById(e)}previewTour(e){this.af?this.af.previewTour(e):this.qo(()=>{var t;this.hf(),(t=this.af)==null||t.previewTour(e)})}dismissProductTour(){var e;(e=this.af)==null||e.dismissTour(`user_clicked_skip`)}nextStep(){var e;(e=this.af)==null||e.nextStep()}previousStep(){var e;(e=this.af)==null||e.previousStep()}clearCache(){var e;this.uf=null,(e=this.Ca)==null||e.unregister(`ph_product_tours`)}resetTour(e){var t;(t=this.af)==null||t.resetTour(e)}resetAllTours(){var e;(e=this.af)==null||e.resetAllTours()}cancelPendingTour(e){var t;(t=this.af)==null||t.cancelPendingTour(e)}}},Wu),Yu={siteApps:class{constructor(e){this._instance=e,this.cf=0,this.df=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}vf(e,t){if(!t)return;let n=this.globalsForEvent(t);this.df.push(n),this.df.length>1e3&&(this.df=this.df.slice(10))}get siteAppLoaders(){var e;return(e=f._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.siteApps}initialize(){if(this.isEnabled){let e=this._instance._addCaptureHook(this.vf.bind(this));this.ff=()=>{e(),this.df=[],this.ff=void 0}}}globalsForEvent(e){if(!e)throw Error(`Event payload is required`);let t={},n=this._instance.get_property(`$groups`)||[],r=this._instance.get_property(`$stored_group_properties`)||{};for(let[e,i]of Object.entries(r))t[e]={id:n[e],type:e,properties:i};let{$set_once:i,$set:a}=e;return{event:R(R({},zn(e,ql)),{},{properties:R(R(R({},e.properties),a?{$set:R(R({},e.properties?.$set??{}),a)}:{}),i?{$set_once:R(R({},e.properties?.$set_once??{}),i)}:{}),elements_chain:e.properties?.$elements_chain??``,distinct_id:e.properties?.distinct_id}),person:{properties:this._instance.get_property(`$stored_person_properties`)},groups:t}}pf(e){let t=e.tagName?.toLowerCase();return t===`style`&&this._instance.config.prepare_external_dependency_stylesheet?this._instance.config.prepare_external_dependency_stylesheet(e)||(Jl.error(`prepare_external_dependency_stylesheet returned null`),null):t===`script`&&this._instance.config.prepare_external_dependency_script?this._instance.config.prepare_external_dependency_script(e)||(Jl.error(`prepare_external_dependency_script returned null`),null):e}gf(){var e;if(!this._instance.config.prepare_external_dependency_stylesheet&&!this._instance.config.prepare_external_dependency_script)return()=>{};let t=r?.defaultView,n=t==null||(e=t.Node)==null?void 0:e.prototype;if(!t||!n)return()=>{};if(this.cf++,this.mf)return this.yf();let i=[],a=this,o=new WeakSet,s=(e,t,n)=>{if(!e?.[t])return;let r=e[t];e[t]=n(r),i.push(()=>{e[t]=r})},c=e=>{if(o.has(e))return e;let t=a.pf(e);return t&&o.add(t),t},l=e=>e.map(e=>typeof e==`string`?e:c(e)).filter(e=>!M(e));return s(n,`appendChild`,e=>function(t){let n=c(t);return n?e.call(this,n):t}),s(n,`insertBefore`,e=>function(t,n){let r=c(t);return r?e.call(this,r,n):t}),s(n,`replaceChild`,e=>function(t,n){let r=c(t);return r?e.call(this,r,n):n}),[t.Element?.prototype,t.Document?.prototype,t.DocumentFragment?.prototype].forEach(e=>{s(e,`append`,e=>function(...t){return e.apply(this,l(t))}),s(e,`prepend`,e=>function(...t){return e.apply(this,l(t))})}),[t.Element?.prototype,t.CharacterData?.prototype,t.DocumentType?.prototype].forEach(e=>{s(e,`before`,e=>function(...t){return e.apply(this,l(t))}),s(e,`after`,e=>function(...t){return e.apply(this,l(t))}),s(e,`replaceWith`,e=>function(...t){let n=l(t);return t.length&&!n.length?void 0:e.apply(this,n)})}),s(t.Element?.prototype,`insertAdjacentElement`,e=>function(t,n){let r=c(n);return r?e.call(this,t,r):null}),this.mf=()=>{i.forEach(e=>e()),this.mf=void 0},this.yf()}yf(){let e=!1;return()=>{var t;e||(e=!0,this.cf--,this.cf===0&&((t=this.mf)==null||t.call(this)))}}bf(e,t=!0){let n=this.gf();try{let r=e(n);return t&&n(),r}catch(e){throw n(),e}}setupSiteApp(e){let t=this.apps[e.id],n=()=>{var n;!t.errored&&this.df.length&&(Jl.info(`Processing ${this.df.length} events for site app with id ${e.id}
2`),this.df.forEach(e=>this.bf(()=>t.processEvent?.call(t,e))),t.processedBuffer=!0),Object.values(this.apps).every(e=>e.processedBuffer||e.errored)&&((n=this.ff)==null||n.call(this))},r=!1,i=i=>{t.errored=!i,t.loaded=!0,Jl.info(`Site app with id ${e.id} ${i?`loaded`:`errored`}`),r&&n()};try{let{processEvent:n}=this.bf(t=>e.init({posthog:this._instance,callback(e){t(),i(e)}}),!1);n&&(t.processEvent=n),r=!0}catch(t){Jl.error(Yl+e.id,t),i(!1)}if(r&&t.loaded)try{n()}catch(n){Jl.error(`Error while processing buffered events PostHog app with config id ${e.id}`,n),t.errored=!0}}_f(){let e=this.siteAppLoaders||[];for(let t of e)this.apps[t.id]={id:t.id,loaded:!1,errored:!1,processedBuffer:!1};for(let t of e)this.setupSiteApp(t)}wf(e){if(Object.keys(this.apps).length===0)return;let t=this.globalsForEvent(e);for(let n of Object.values(this.apps))try{this.bf(()=>n.processEvent?.call(n,t))}catch(t){Jl.error(`Error while processing event ${e.event} for site app ${n.id}`,t)}}onRemoteConfig(e){var t;if(this.siteAppLoaders?.length)return this.isEnabled?(this._f(),void this._instance.on(`eventCaptured`,e=>this.wf(e))):void Jl.error(`PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.`);if((t=this.ff)==null||t.call(this),!e.ok)return;let n=e.config;if(n.siteApps?.length){if(this.isEnabled)for(let{id:e,url:t}of n.siteApps){var r,i;f[`__$$ph_site_app_${e}`]=this._instance,(r=f.__PosthogExtensions__)==null||(i=r.loadSiteApp)==null||i.call(r,this._instance,t,t=>{if(t)return Jl.error(Yl+e,t)})}else Jl.error(`PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.`)}}}},Xu={tracingHeaders:class{constructor(e){this._instance=e,this.kf=void 0,this.Sf=void 0,this.xf=void 0,this.Nv=()=>{let e=this.Cf();var t,n;e?(A(this.kf)&&(this.kf=(t=f.__PosthogExtensions__)==null||(t=t.tracingHeadersPatchFns)==null?void 0:t._patchXHR(e,()=>this._instance.get_distinct_id(),this._instance.sessionManager)),A(this.Sf)&&(this.Sf=(n=f.__PosthogExtensions__)==null||(n=n.tracingHeadersPatchFns)==null?void 0:n._patchFetch(e,()=>this._instance.get_distinct_id(),this._instance.sessionManager))):this.Uv()}}initialize(){this.startIfEnabledOrStop()}qo(e){var t,n;f.__PosthogExtensions__?.tracingHeadersPatchFns?e():(t=f.__PosthogExtensions__)==null||(n=t.loadExternalDependency)==null||n.call(t,this._instance,`tracing-headers`,t=>{if(t)return Pl.error(`failed to load script`,t);e()})}$f(){return this._instance.config.tracing_headers??this._instance.config.addTracingHeaders??this._instance.config.__add_tracing_headers}Cf(){let e=this.$f();return E(e)?(E(this.xf)?this.xf.splice(0,this.xf.length,...e):this.xf=[...e],e.length>0?this.xf:void 0):(E(this.xf)&&this.xf.splice(0),this.xf=e||void 0,this.xf)}Uv(){var e,t;(e=this.kf)==null||e.call(this),(t=this.Sf)==null||t.call(this),this.kf=void 0,this.Sf=void 0}startIfEnabledOrStop(){this.Cf()?this.qo(this.Nv):this.Uv()}}},Zu=R({surveys:class extends $l{constructor(e){var t;super(new au(e),(t=e,{get projectToken(){return t.config.token},kv:new iu(t)})),this._instance=e}Oh(e,t){let n=t.query?lc(e,t.query):e;return new Promise(e=>{this._instance._send_request({method:t.method,url:this._instance.requestRouter.endpointFor(t.target??`api`,n),data:t.body,headers:t.headers,timeout:t.timeoutMs,fireCallbackOnDrop:!0,transport:t.transport,compression:t.compression,timestampMode:t.sentAt,callback:e})})}}},Wu),Qu={toolbar:class{constructor(e){this.instance=e}Tf(e){f.ph_toolbar_state=e}If(){return f.ph_toolbar_state??0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(t=void 0,n=void 0,i=void 0){if(sa(this.instance.config)||!e||!r)return!1;t??=e.location,i??=e.history;try{if(!n){try{e.localStorage.setItem(`test`,`test`),e.localStorage.removeItem(`test`)}catch{return!1}n=e?.localStorage}let r=ou||Io(t.hash,`__posthog`)||Io(t.hash,`state`),a,o=r?kt(()=>JSON.parse(atob(decodeURIComponent(r))))||kt(()=>JSON.parse(decodeURIComponent(r))):null;return o&&o.action===`ph_authorize`?(a=o,a.source=`url`,a&&Object.keys(a).length>0&&(o.desiredHash?t.hash=o.desiredHash:i?i.replaceState(i.state,``,t.pathname+t.search):t.hash=``)):(a=JSON.parse(n.getItem(su)||`{}`),a.source=`localstorage`,delete a.userIntent),!(!a.token||this.instance.config.token!==a.token||(this.loadToolbar(a),0))}catch{return!1}}Mf(e){let t=f.ph_load_toolbar||f.ph_load_editor;!N(t)&&D(t)?t(e,this.instance):cu.warn(`No toolbar load function found`)}loadToolbar(t){let n=!!r?.getElementById(`__POSTHOG_TOOLBAR__`);if(!e||n)return!1;let i=this.instance.requestRouter.region===`custom`&&this.instance.config.advanced_disable_toolbar_metrics,a=R(R({token:this.instance.config.token},t),{},{apiURL:this.instance.requestRouter.endpointFor(`ui`)},i?{instrument:!1}:{});if(e.localStorage.setItem(su,JSON.stringify(R(R({},a),{},{source:void 0}))),this.If()===2)this.Mf(a);else if(this.If()===0){var o,s;this.Tf(1),(o=f.__PosthogExtensions__)==null||(s=o.loadExternalDependency)==null||s.call(o,this.instance,`toolbar`,e=>{if(e)return cu.error(`[Toolbar] Failed to load`,e),void this.Tf(0);this.Tf(2),this.Mf(a)}),G(e,`turbolinks:load`,()=>{this.Tf(0),this.loadToolbar(a)})}return!0}Ef(e){return this.loadToolbar(e)}maybeLoadEditor(e=void 0,t=void 0,n=void 0){return this.maybeLoadToolbar(e,t,n)}}},$u=R({experiments:class t{get Ir(){return this._instance.config}constructor(e){this._instance=e,this.getWebExperimentsAndEvaluateDisplayLogic=(e=!1)=>{this.getWebExperiments(e=>{t.Pf(`retrieved web experiments from the server`),this.Rf=new Map,e.forEach(e
2=>{if(e.feature_flag_key){var n;this.Rf&&(t.Pf(`setting flag key `,e.feature_flag_key,` to web experiment `,e),(n=this.Rf)==null||n.set(e.feature_flag_key,e));let r=this._instance.getFeatureFlag(e.feature_flag_key);j(r)&&e.variants[r]&&this.Af(e.name,r,e.variants[r].transforms)}else if(e.variants)for(let n in e.variants){let r=e.variants[n];t.Ff(r,this._instance)&&this.Af(e.name,n,r.transforms)}})},e)},this._instance.onFeatureFlags(e=>{this.onFeatureFlags(e)})}initialize(){}onFeatureFlags(e){if(this._is_bot())t.Pf(wu);else if(!this.Ir.disable_web_experiments){if(N(this.Rf))return this.Rf=new Map,this.loadIfEnabled(),void this.previewWebExperiment();t.Pf(`applying feature flags`,e),e.forEach(e=>{if(this.Rf&&this.Rf?.has(e)){let t=this._instance.getFeatureFlag(e),n=this.Rf?.get(e);t&&n!=null&&n.variants[t]&&this.Af(n.name,t,n.variants[t].transforms)}})}}previewWebExperiment(){let e=t.getWindowLocation();if(e?.search){let n=Po(e?.search,`__experiment_id`),r=Po(e?.search,`__experiment_variant`);n&&r&&(t.Pf(`previewing web experiments ${n} && ${r}`),this.getWebExperiments(e=>{this.Of(parseInt(n),r,e)},!1,!0))}}loadIfEnabled(){this.Ir.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,t,n){if(this.Ir.disable_web_experiments&&!n)return e([]);let r=this._instance.get_property(`$web_experiments`);if(r&&!t)return e(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor(`api`,`/api/web_experiments/?token=${this.Ir.token}`),method:`GET`,timestampMode:`query`,callback:t=>e(t.statusCode===200&&t.json&&t.json.experiments||[])})}Of(e,n,r){let i=r.filter(t=>t.id===e);i&&i.length>0&&(t.Pf(`Previewing web experiment [${i[0].name}] with variant [${n}]`),this.Af(i[0].name,n,i[0].variants[n].transforms))}static Ff(e,n){return!N(e.conditions)&&t.Df(e,n)&&t.Lf(e)}static Df(e,n){if(N(e.conditions)||N(e.conditions?.url))return!0;let r=t.getWindowLocation();if(r){let t=Pa(n,r.href);return!e.conditions?.url||Tu[e.conditions?.urlMatchType??`icontains`](e.conditions.url,t)}return!1}
2static getWindowLocation(){return e?.location}static Lf(e){if(N(e.conditions)||N(e.conditions?.utm))return!0;let t=Uo();if(t.utm_source){var n,r,i,a,o,s,c,l;let u=!((n=e.conditions)!=null&&(n=n.utm)!=null&&n.utm_campaign)||((r=e.conditions)==null||(r=r.utm)==null?void 0:r.utm_campaign)==t.utm_campaign,d=!((i=e.conditions)!=null&&(i=i.utm)!=null&&i.utm_source)||((a=e.conditions)==null||(a=a.utm)==null?void 0:a.utm_source)==t.utm_source,f=!((o=e.conditions)!=null&&(o=o.utm)!=null&&o.utm_medium)||((s=e.conditions)==null||(s=s.utm)==null?void 0:s.utm_medium)==t.utm_medium,p=!((c=e.conditions)!=null&&(c=c.utm)!=null&&c.utm_term)||((l=e.conditions)==null||(l=l.utm)==null?void 0:l.utm_term)==t.utm_term;return u&&f&&p&&d}return!1}static Pf(e,...t){z.info(`[WebExperiments] ${e}`,t)}Af(e,n,r){this._is_bot()?t.Pf(wu):n===`control`?t.Pf(`Control variants leave the page unmodified.`):r.forEach(r=>{r.selector&&(t.Pf(`applying transform of variant ${n} for experiment ${e} `,r),(document?.querySelectorAll(r.selector))?.forEach(e=>{let t=e;r.html&&(t.innerHTML=r.html),r.css&&t.setAttribute(`style`,r.css)}))})}_is_bot(){return n&&this._instance?Pc(n,this.Ir.custom_blocked_useragents):void 0}}},Wu),ed={conversations:class{constructor(e){this._instance=e,this.Nf=void 0,this._conversationsManager=null,this.qf=!1,this.ne=null,this.jf=!1}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(this._instance.config.disable_conversations||(this.Bf=e.ok,!e.ok))return;let t=e.config.conversations;N(t)||(F(t)?this.Nf=t:(this.Nf=t.enabled,this.ne=t),this.loadIfEnabled())}reset(){var e;(e=this._conversationsManager)==null||e.reset(),this._conversationsManager=null,this.Nf=void 0,this.ne=null,this.Bf=void 0,this.jf=!1}loadIfEnabled(){if(this._conversationsManager||this.qf||this._instance.config.disable_conversations||sa(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())return;let e=f?.__PosthogExtensions__;if(e&&!A(this.Nf)&&this.Nf){if(this.ne&&this.ne.token){this.qf=!0;try{let t=e.initConversations;if(t)return this.Hf(t),void(this.qf=!1);let n=e.loadExternalDependency;if(!n)return void this.zf(Wi);n(this._instance,`conversations`,t=>{t||!e.initConversations?this.zf(`Could not load conversations script`,t):this.Hf(e.initConversations),this.qf=!1})}catch(e){this.zf(`Error initializing conversations`,e),this.qf=!1}}else Eu.error(`Conversations enabled but missing token in remote config.`)}}Hf(e){if(this.ne)try{this._conversationsManager=e(this.ne,this._instance),this.jf=!1,Eu.info(`Conversations loaded successfully`)}catch(e){this.zf(`Error completing conversations initialization`,e)}else Eu.error(`Cannot complete initialization: remote config is null`)}zf(e,t){Eu.error(e,t),this._conversationsManager=null,this.qf=!1,this.jf=!0}show(){this._conversationsManager?this._conversationsManager.show():Eu.warn(`Conversations not loaded yet.`)}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this.Nf&&!M(this._conversationsManager)}getUnavailableReason(){return this.isAvailable()?null:this._instance.config.disable_conversations?`disabled_by_config`:sa(this._instance.config)?`disabled_for_toolbar`:this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut()?`consent_opted_out`:!1===this.Bf?`remote_config_failed`:A(this.Nf)?this.Bf?`disabled_in_project`:`remote_config_pending`:this.Nf?N(this.ne)||!this.ne.token?`missing_token`:f?.__PosthogExtensions__?this.qf?`initializing`:this.jf?`load_failed`:`not_loaded`:`extensions_unavailable`:`disabled_in_project`}isVisible(){var e;return(e=this._conversationsManager?.isVisible())!=null&&e}sendMessage(e,t,n){var r=this;return L(function*(){return r._conversationsManager?r._conversationsManager.sendMessage(e,t,n):(Eu.warn(Du),null)})()}getMessages(e,t){var n=this;return L(function*(){return n._conversationsManager?n._conversationsManager.getMessages(e,t):(Eu.warn(Du),null)})()}markAsRead(e){var t=this;return L(function*(){return t._conversationsManager?t._conversationsManager.markAsRead(e):(Eu.warn(Du),null)})()}getTickets(e){var t=this;return L(function*(){return t._conversationsManager?t._conversationsManager.getTickets(e):(Eu.warn(Du),null)})()}requestRestoreLink(e){var t=this;return L(function*(){return t._conversationsManager?t._conversationsManager.requestRestoreLink(e):(Eu.warn(Du),null)})()}restoreFromToken(e){var t=this;return L(function*(){return t._conversationsManager?t._conversationsManager.restoreFromToken(e):(Eu.warn(Du),null)})()}restoreFromUrlToken(){var e=this;return L(function*(){return e._conversationsManager?e._conversationsManager.restoreFromUrlToken():(Eu.warn(Du),null)})()}getCurrentTicketId(){return this._conversationsManager?.getCurrentTicketId()??null}getWidgetSessionId(){return this._conversationsManager?.getWidgetSessionId()??null}bh(){var e;(e=this._conversationsManager)==null||e.setIdentity()}_h(){var e;(e=this._conversationsManager)==null||e.clearIdentity()}}},td={logs:class{constructor(t){var n;this._instance=t,this.name=`logs`,this.Uf=!1,this.Wf=!1,this.Vf=!1,this.$=B(`[logs]`),this.Gf=R(R({},this.$),{},{error:(...e)=>{e.some(Pu)||this.$.error(...e)}}),this.na=[],this.Zf=[],this.od=0,this.xo=!1,this.Qf=[],this.Jf=[],this.Kf=!1,this.Xf=!1,this.Yf=()=>{var e,t;this.xo||(this.od=0,(e=this.tp)==null||e.onReconnect(),(t=this.ep)==null||t.onReconnect())},this._instance&&(n=this._instance.config.logs)!=null&&n.captureConsoleLogs&&(this.Uf=!0),e&&G(e,`online`,this.Yf)}np(e,t,n,r){var i;let a=Ou((i=this._instance)==null||(i=i.config)==null?void 0:i.logs,n);return[new ir(this.sp(e,t),a,this.Gf,()=>this.rp(),e=>e(),void 0,r),a]}op(){var e;let t=(e=this._instance)==null||(e=e.config)==null?void 0:e.logs;var n;return this.tp&&this.lp===t||((n=this.tp)==null||n.reset(),this.lp=t,[this.tp,this.ap]=this.np(()=>this.na,e=>{this.na=e})),this.tp}up(){var e;let t=(e=this._instance)==null||(e=e.config)==null?void 0:e.logs;var n;return this.ep&&this.hp===t||((n=this.ep)==null||n.reset(),this.hp=t,[this.ep,this.cp]=this.np(()=>this.Zf,e=>{this.Zf=e},{serviceNameDefault:`posthog-browser-logs`,consoleCapture:!0},ju)),this.ep}setup(e){var t;if(this.xo)return;this.mo=e,(t=this._instance)!=null&&(t=t.config)!=null&&(t=t.logs)!=null&&t.captureConsoleLogs&&(this.Uf=!0),(this.Uf||this.dp()&&this.vp())&&this.fp();let n=!1,r=e.onRemoteConfig(e=>{n=e.ok&&!0===e.config.logs?.captureConsoleLogs,this.onRemoteConfig(e)});this.xo?r.dispose():(this.To=r,n||this.loadIfEnabled())}dispose(){var t,n,r,i;
2this.xo||(this.xo=!0,this.pp(),(t=this.To)==null||t.dispose(),this.To=void 0,this.mo=void 0,this.Vf=!1,e?.removeEventListener(`online`,this.Yf),(n=this.gp)==null||n.call(this),this.gp=void 0,(r=this.tp)==null||r.reset(),(i=this.ep)==null||i.reset())}onRemoteConfig(e){var t;if(this.xo)return;let n=e.ok?e.config.logs?.captureConsoleLogs:void 0;N(n)?this.mp():((t=this._instance)==null||(t=t.persistence)==null||t.register({$logs_capture_enabled_server_side:!!n}),n?(this.Uf=!0,this.Wf||this.fp(),this.loadIfEnabled()):this.mp())}reset(){var e,t,n,r;this.pp(),(e=this.tp)==null||e.clearQueue(),this.na=[],(t=this.tp)==null||t.reset(),(n=this.ep)==null||n.clearQueue(),this.Zf=[],(r=this.ep)==null||r.reset(),this.od=0}captureLog(e){this.xo||this.op().captureLog(e)}captureConsoleLog(e){this.xo||this.up().captureLog(e)}captureBufferedConsoleLog(e,t,n){this.xo||this.up().captureLog(e,{context:t,occurredAtMs:n})}vp(){var e;return!!((e=this._instance)!=null&&(e=e.persistence)!=null&&(e=e.props)!=null&&e[Pr])}dp(){var e,t,n;return!((e=this._instance)!=null&&(t=e.Yl)!=null&&t.call(e))||!!((n=f._POSTHOG_REMOTE_CONFIG)!=null&&(n=n[this._instance.config.token])!=null&&n.config)}kh(){var e;this.pp(),(e=this.ep)==null||e.clearQueue(),this.Zf=[]}mp(){this.Uf||this.pp()}fp(){var e;if(this.Kf||!f?.console)return;let t=Ou((e=this._instance)==null||(e=e.config)==null?void 0:e.logs).maxBufferSize,n=!0;this.Jf.push(()=>{n=!1});for(let e of ku){let r;try{r=Au(f.console[e])}catch{continue}r&&this.Jf.push(Nl(f.console,e,i=>{let a=(...r)=>{try{n&&this.yp(e,r,t)}catch{}return i.apply(f.console,r)};return a.__rrweb_original__=r,a}))}this.Kf=!0,this.bp=setTimeout(()=>{this.pp()},3e4)}yp(e,t,n){if(this.Kf&&!this.Xf&&t.length!==0){if(this._instance?.is_capturing()){if(n>this.Qf.length){this.Xf=!0;try{this.Qf.push({level:e,args:t,occurredAtMs:Date.now(),context:this.rp()})}finally{this.Xf=!1}}}else this.pp()}}pp(){if(this.Qf=[],this.Kf){this.Kf=!1,this.bp&&=(clearTimeout(this.bp),void 0);for(let e of this.Jf)e();this.Jf=[]}}_p(){let e=this.Qf;return this.pp(),e}get logger(){return this.wp||={trace:(e,t)=>this.captureLog({body:e,level:`trace`,attributes:t}),debug:(e,t)=>this.captureLog({body:e,level:`debug`,attributes:t}),info:(e,t)=>this.captureLog({body:e,level:`info`,attributes:t}),warn:(e,t)=>this.captureLog({body:e,level:`warn`,attributes:t}),error:(e,t)=>this.captureLog({body:e,level:`error`,attributes:t}),fatal:(e,t)=>this.captureLog({body:e,level:`fatal`,attributes:t})},this.wp}flushLogs(e){e?this.kp(e):(this.tp&&this.tp.flush().catch(e=>this.Sp(e)),this.ep&&this.ep.flush().catch(e=>this.Sp(e)))}Sp(e){Pu(e)||this.$.error(`PostHog logs flush failed:`,e)}loadIfEnabled(){if(this.xo||!this.Uf||this.Wf||this.Vf)return;let e=f?.__PosthogExtensions__;if(!e)return this.$.error(`PostHog Extensions not found.`),void this.pp();let t=e.loadExternalDependency;if(!t)return this.$.error(Wi),void this.pp();this.Vf=!0;try{t(this._instance,`logs`,t=>{if(this.Vf=!1,this.xo||!this.Uf)return;let n=e.logs;if(t||!n?.initializeLogs)this.$.error(`Could not load logs script`,t),this.pp();else{let e=this._p();var r;this.gp=n.initializeLogs(this.mo??this._instance),this.Wf=!0,e.length>0&&((r=n.replayConsoleBuffer)==null||r.call(n,this.mo??this._instance,e))}})}catch(e){throw this.Vf=!1,e}}sp(e,t){let n=this._instance;return{get isDisabled(){return!1},get optedOut(){return!n.is_capturing()},getPersistedProperty:t=>t===h.LogsQueue?e():void 0,setPersistedProperty(e,n){e===h.LogsQueue&&t(n??[])},js:e=>this.js(e),getLibraryId:()=>V.LIB_NAME,getLibraryVersion:()=>V.LIB_VERSION}}js(e){return new Promise(t=>{if(Lo(this.od,3))return void t({kind:`fatal`,error:Nu(void 0,`logs endpoint is unreachable, dropping batch`)});let n=!1,r=e=>{n||(n=!0,clearTimeout(i),t(e))},i=setTimeout(()=>{this.$.warn(`Logs request timed out before receiving a response`),r({kind:`retry-later`,error:Nu(void 0,`logs request timed out`)})},9e4);this._instance._send_request({method:`POST`,url:this.xp(),data:e,compression:`best-available`,batchKey:`logs`,fireCallbackOnDrop:!0,callback:e=>{let t=e.statusCode;this.Cp(t),t>=200&&300>t?r({kind:`ok`}):t===413?r({kind:`too-large`}):t!==0&&t!==408&&t!==429&&500>t?r({kind:`fatal`,error:Error(`logs request failed with status ${t}`)}):t===0?(e.error||this.$.warn(`Logs request failed before receiving an HTTP response`),r({kind:`retry-later`,error:Nu(e.error,`logs request failed before receiving an HTTP response`)})):r({kind:`retry-later`,error:e.error??Error(`logs request failed with status ${t}`)})}})})}Cp(e){(e!==0||this._instance.__loaded)&&(this.od=Ro(e,this.od,3,()=>this.$.warn(`Log requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped sending logs; will try again when connectivity changes.`)))}
2kp(e){this.na.length>0&&this.$p(e,this.na,this.ap,V.LIB_NAME,e=>{this.na=e}),this.Zf.length>0&&this.$p(e,this.Zf,this.cp,ju,e=>{this.Zf=e})}$p(e,t,n,r,i){if(t.length===0)return;let a=t.map(e=>e.record);i([]);let o=er(a,$n(n,V.LIB_NAME,V.LIB_VERSION),r,V.LIB_VERSION);this._instance._send_request({method:`POST`,url:this.xp(),data:o,compression:`best-available`,batchKey:`logs`,transport:e})}xp(){return this._instance.requestRouter.endpointFor(`api`,`/i/v1/logs`)+`?token=`+encodeURIComponent(this._instance.config.token)}rp(){var e;let t={};if(t.distinctId=this._instance.get_distinct_id(),this._instance.sessionManager){let{sessionId:e,windowId:n,sessionStartTimestamp:r,lastActivityTimestamp:i}=this._instance.sessionManager.checkAndGetSessionAndWindowId(!0);t.sessionId=e,t.windowId=n,N(r)||(t.sessionStartTimestamp=r),N(i)||(t.lastActivityTimestamp=i)}if(f!=null&&(e=f.location)!=null&&e.href&&(t.currentUrl=this._instance.config.disable_capture_url_hashes?Ot(f.location.href):f.location.href),this._instance.featureFlags){let e=this._instance.featureFlags.getFlags();e&&e.length>0&&(t.activeFeatureFlags=e)}return t}}},nd={metrics:class{constructor(e){this._instance=e,this.$=B(`[metrics]`),this.xo=!1}initialize(){this.onConfigChange()}onConfigChange(){if(this.xo)return;let e=!!this._instance.config.metrics?.network;e&&!this.Tp?this.Tp=(e=>{let t=!0,n=()=>t?(e=>{let t=e.config.metrics?.network;return!0===t?{}:t||void 0})(e):void 0,r=Hu(e,n),i=Uu(e,n);return()=>{t=!1,r(),i()}})(this._instance):!e&&this.Tp&&(this.Tp(),this.Tp=void 0)}op(){var e;let t=(e=this._instance)==null||(e=e.config)==null?void 0:e.metrics;var n;return this.tp&&this.lp===t||((n=this.tp)==null||n.reset(),this.lp=t,this.tp=new cr(this.sp(),function(e){let t=e?.resourceAttributes;return{serviceName:t?.[`service.name`]??e?.serviceName,serviceVersion:t?.[`service.version`]??e?.serviceVersion,environment:t?.[`deployment.environment`]??e?.environment,resourceAttributes:t,beforeSend:e?.beforeSend,flushIntervalMs:e?.flushIntervalMs??1e4,maxSeriesPerFlush:e?.maxSeriesPerFlush??1e3}}(t),this.$)),this.tp}count(e,t=1,n){this.op().count(e,t,n)}gauge(e,t,n){this.op().gauge(e,t,n)}histogram(e,t,n){this.op().histogram(e,t,n)}flush(e){if(!this.tp)return Promise.resolve();if(e){let t=this.tp.drainWindow();return t&&this.Ys(t,e),Promise.resolve()}return this.tp.flush().catch(e=>this.$.error(`PostHog metrics flush failed:`,e))}reset(){var e;(e=this.tp)==null||e.reset()}dispose(){var e,t;this.xo=!0,(e=this.Tp)==null||e.call(this),this.Tp=void 0,(t=this.tp)==null||t.reset()}sp(){let e=this._instance,t=this;return{get isDisabled(){return!1},get optedOut(){return!e.is_capturing()},Ys:e=>t.Ys(e),getLibraryId:()=>V.LIB_NAME,getLibraryVersion:()=>V.LIB_VERSION}}Ys(e,t){return new Promise(n=>{let r=!1,i=e=>{r||(r=!0,clearTimeout(a),n(e))},a=setTimeout(()=>i({kind:`retry-later`,error:Error(`metrics request timed out`)}),9e4);this._instance._send_request(R(R({method:`POST`,url:this.Ip(),data:e,compression:`best-available`,batchKey:`metrics`},t&&{transport:t}),{},{fireCallbackOnDrop:!0,callback(e){let t=e.statusCode;i(t>=200&&300>t?{kind:`ok`}:t===413?{kind:`too-large`}:t!==0&&t!==408&&t!==429&&500>t?{kind:`fatal`,error:Error(`metrics request failed with status ${t}`)}:{kind:`retry-later`,error:e.error??Error(`metrics request failed with status ${t}`)})}}))})}Ip(){return this._instance.requestRouter.endpointFor(`api`,`/i/v1/metrics`)+`?token=`+encodeURIComponent(this._instance.config.token)}}};xl.__defaultExtensionClasses=R({},R(R(R(R(R(R(R(R(R(R(R(R(R({},Wu),Gu),Ku),qu),Ju),Yu),Zu),Xu),Qu),$u),ed),td),nd));var rd=function(){V.SDK_DIST_CHANNEL=`npm`;let t=il[hl]=new xl;return function(){function t(){t.done||(t.done=!0,Sc=!1,U(il,function(e){e._dom_loaded()}))}r?.addEventListener?r.readyState===`complete`?t():G(r,`DOMContentLoaded`,t,{capture:!1}):e&&z.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}(),t}();export{rd as t};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.