posthog-js 1.429.2 → 1.429.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/all-external-dependencies.js +1 -1
- package/dist/all-external-dependencies.js.map +1 -1
- package/dist/array.full.es5.js +1 -1
- package/dist/array.full.es5.js.map +1 -1
- package/dist/array.full.js +1 -1
- package/dist/array.full.js.map +1 -1
- package/dist/array.full.no-external.js +1 -1
- package/dist/array.full.no-external.js.map +1 -1
- package/dist/array.js +1 -1
- package/dist/array.js.map +1 -1
- package/dist/array.no-external.js +1 -1
- package/dist/array.no-external.js.map +1 -1
- package/dist/conversations.js +1 -1
- package/dist/customizations.d.ts +2 -0
- package/dist/customizations.full.js +1 -1
- package/dist/customizations.js +1 -1
- package/dist/dead-clicks-autocapture.js +1 -1
- package/dist/default-extensions.js +1 -1
- package/dist/default-extensions.js.map +1 -1
- package/dist/exception-autocapture.js +1 -1
- package/dist/extension-bundles.js +1 -1
- package/dist/extension-bundles.js.map +1 -1
- package/dist/lazy-recorder.js +1 -1
- package/dist/main.d.ts +2 -0
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/module.d.ts +2 -0
- package/dist/module.full.d.ts +2 -0
- package/dist/module.full.js +1 -1
- package/dist/module.full.js.map +1 -1
- package/dist/module.full.no-external.d.ts +2 -0
- package/dist/module.full.no-external.js +1 -1
- package/dist/module.full.no-external.js.map +1 -1
- package/dist/module.js +1 -1
- package/dist/module.js.map +1 -1
- package/dist/module.mjs +1 -1
- package/dist/module.mjs.map +1 -1
- package/dist/module.no-external.d.ts +2 -0
- package/dist/module.no-external.js +1 -1
- package/dist/module.no-external.js.map +1 -1
- package/dist/module.slim.js +1 -1
- package/dist/module.slim.js.map +1 -1
- package/dist/module.slim.no-external.d.ts +2 -0
- package/dist/module.slim.no-external.js +1 -1
- package/dist/module.slim.no-external.js.map +1 -1
- package/dist/posthog-recorder.js +1 -1
- package/dist/product-tours.js +1 -1
- package/dist/src/extensions/surveys.d.ts +2 -0
- package/dist/surveys-preview.js.map +1 -1
- package/dist/surveys.d.ts +2 -0
- package/dist/surveys.js +1 -1
- package/dist/surveys.js.map +1 -1
- package/lib/package.json +1 -1
- package/lib/src/extensions/surveys.d.ts +2 -0
- package/lib/src/extensions/surveys.js +18 -1
- package/lib/src/extensions/surveys.js.map +1 -1
- package/lib/src/feature-flags-config.js +5 -5
- package/lib/src/feature-flags-config.js.map +1 -1
- package/lib/src/posthog-core.js +3 -7
- package/lib/src/posthog-core.js.map +1 -1
- package/package.json +4 -4
package/dist/array.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(){const t="u">typeof window?window:void 0,i="u">typeof globalThis?globalThis:t,e=null==i?void 0:i.navigator,s=null==i?void 0:i.document,n=null==i?void 0:i.location,r=null==i?void 0:i.fetch,o=(null==i?void 0:i.XMLHttpRequest)&&"withCredentials"in new i.XMLHttpRequest?i.XMLHttpRequest:void 0,l=null==i?void 0:i.AbortController,a=null==i?void 0:i.CompressionStream,u=null==e?void 0:e.userAgent;function h(){return!(!t||!1===t.navigator.onLine)}const d="undefined"!=typeof globalThis?globalThis:t;d&&"undefined"==typeof self&&(d.self=d),d&&"undefined"==typeof File&&(d.File=function(){});const c=null!=t?t:{},v="0.8.2",f={DEBUG:!1,LIB_VERSION:v,LIB_NAME:"browser-common",JS_SDK_VERSION:v};var p=function(t){return t.AnonymousId="anonymous_id",t.DistinctId="distinct_id",t.Props="props",t.EnablePersonProcessing="enable_person_processing",t.PersonMode="person_mode",t.FeatureFlagDetails="feature_flag_details",t.FeatureFlags="feature_flags",t.FeatureFlagPayloads="feature_flag_payloads",t.BootstrapFeatureFlagDetails="bootstrap_feature_flag_details",t.BootstrapFeatureFlags="bootstrap_feature_flags",t.BootstrapFeatureFlagPayloads="bootstrap_feature_flag_payloads",t.OverrideFeatureFlags="override_feature_flags",t.Queue="queue",t.AiQueue="ai_queue",t.AiCaptureQueue="ai_capture_queue",t.LogsQueue="logs_queue",t.OptedOut="opted_out",t.SessionId="session_id",t.SessionStartTimestamp="session_start_timestamp",t.SessionLastTimestamp="session_timestamp",t.PersonProperties="person_properties",t.GroupProperties="group_properties",t.InstalledAppBuild="installed_app_build",t.InstalledAppVersion="installed_app_version",t.SessionReplay="session_replay",t.PushRegistered="push_registered",t.SessionReplayEventTriggerActivatedSession="session_replay_event_trigger_activated_session",t.SurveyLastSeenDate="survey_last_seen_date",t.SurveysSeen="surveys_seen",t.Surveys="surveys",t.RemoteConfig="remote_config",t.FlagsEndpointWasHit="flags_endpoint_was_hit",t.DeviceId="device_id",t}({}),g=function(t){return t.GZipJS="gzip-js",t.Base64="base64",t}({});const _=["$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"],m=["token"];function b(t,i){return-1!==t.indexOf(i)}const y=function(t){return t.trim()},w=function(t){return t.replace(/^\$/,"")};function x(t){var i;const e=[];return null!==(i=JSON.stringify(t,function(t,i){if("bigint"==typeof i)return i.toString();if("function"!=typeof i&&"symbol"!=typeof i){if(i instanceof Error)return{name:i.name,message:i.message,stack:i.stack};if(i&&"object"==typeof i){for(;e.length>0&&e[e.length-1]!==this;)e.pop();if(e.includes(i))return"[Circular]";e.push(i)}return i}}))&&void 0!==i?i:"null"}const S=Object.prototype,k=S.hasOwnProperty,E=S.toString,P=Array.isArray||function(t){return"[object Array]"===E.call(t)},T=t=>"function"==typeof t,C=t=>t===Object(t)&&!P(t),F=t=>{if(C(t)){for(const i in t)if(k.call(t,i))return!1;return!0}return!1},I=t=>void 0===t,O=t=>"[object String]"==E.call(t),R=t=>O(t)&&0===t.trim().length,A=t=>null===t,M=t=>I(t)||A(t),D=t=>"[object Number]"==E.call(t)&&t==t,j=t=>D(t)&&t>0,B=t=>"[object Boolean]"===E.call(t),L=t=>b(_,t),N=t=>b(m,t);function z(t){return null===t||"object"!=typeof t}function U(t,i){return{}.toString.call(t)===`[object ${i}]`}function H(t){switch({}.toString.call(t)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object DOMError]":case"[object WebAssembly.Exception]":return!0;default:return V(t,Error)}}function q(t){return"u">typeof Event&&V(t,Event)}function V(t,i){try{return t instanceof i}catch(t){return!1}}const W=[!0,"true",1,"1","yes"],G=t=>b(W,t),K=[!1,"false",0,"0","no"];function J(t,i,e,s,n,r,o){try{var l=t[r](o),a=l.value}catch(t){return void e(t)}l.done?i(a):Promise.resolve(a).then(s,n)}function Y(t){return function(){var i=this,e=arguments;return new Promise(function(s,n){var r=t.apply(i,e);function o(t){J(r,s,n,o,l,"next",t)}function l(t){J(r,s,n,o,l,"throw",t)}o(void 0)})}}const X=["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"],Z=function(t,i=[]){if(!t)return!1;const e=t.toLowerCase();return X.concat(i).some(t=>{const i=t.toLowerCase();return-1!==e.indexOf(i)})};function Q(t,i,e,s,n){return i>e&&(s.warn("min cannot be greater than max."),i=e),D(t)?t>e?(s.warn(" cannot be greater than max: "+e+". Using max value instead."),e):i>t?(s.warn(" cannot be less than min: "+i+". Using min value instead."),i):t:(s.warn(" must be a number. using max or fallback. max: "+e+", fallback: "+n),Q(null!=n?n:e,i,e,s))}var tt=class{constructor(t){this.C={},this.I=t.I,this.R=Q(t.bucketSize,0,100,t.$),this.A=Q(t.refillRate,0,this.R,t.$),this.O=Q(t.refillInterval,0,864e5,t.$)}F(t,i){const e=Math.floor((i-t.lastAccess)/this.O);e>0&&(t.tokens=Math.min(t.tokens+e*this.A,this.R),t.lastAccess=t.lastAccess+e*this.O)}consumeRateLimit(t){var i;const e=Date.now(),s=String(t);let n=this.C[s];return n?this.F(n,e):(n={tokens:this.R,lastAccess:e},this.C[s]=n),0===n.tokens||(n.tokens--,0===n.tokens&&(null===(i=this.I)||void 0===i||i.call(this,t)),0===n.tokens)}stop(){this.C={}}};const it="Mobile",et="Android",st="Tablet",nt="Android Tablet",rt="iPad",ot="Apple Watch",lt="Safari",at="BlackBerry",ut="Samsung Internet",ht="Chrome",dt="Chrome iOS",ct="Internet Explorer",vt="Internet Explorer Mobile",ft="Opera",pt="Microsoft Edge",gt="Firefox",_t="Firefox iOS",mt="Nintendo",bt="PlayStation",yt="Xbox",wt="Android Mobile",$t="Mobile Safari",xt="Windows",St="Windows Phone",kt="Nokia",Et="Ouya",Pt="Generic "+it.toLowerCase(),Tt="Generic "+st.toLowerCase(),Ct="Konqueror",Ft="Oculus Browser",It="Vivaldi",Ot="Yandex",Rt="Whale",At="DuckDuckGo",Mt="Pale Moon",Dt="Waterfox",jt="Brave",Bt="Claude",Lt="Codex",Nt="ChatGPT",zt="Google Search App",Ut=new RegExp("Version/(\\d+(\\.\\d+)?)"),Ht=new RegExp("(Claude|Codex|ChatGPT)\\/(\\d+(\\.\\d+)?)"),qt=new RegExp(yt,"i"),Vt=new RegExp("PlayStation \\w+","i"),Wt=new RegExp("Nintendo \\w+","i"),Gt=new RegExp("BlackBerry|PlayBook|BB10","i"),Kt={"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"},Jt=function(t,i,e,s){i=i||"";const n=function(t){return(null==t?void 0:t.brave)?jt:null}(e);return n||((null==s?void 0:s.detectGoogleSearchApp)&&b(t,"GSA/")?zt:b(t," OPR/")&&b(t,"Mini")?"Opera Mini":b(t," OPR/")?ft:Gt.test(t)?at:b(t,"IEMobile")||b(t,"WPDesktop")?vt:b(t,"OculusBrowser")?Ft:b(t,"SamsungBrowser")?ut:b(t,"Edge")||b(t,"Edg/")?pt:b(t,"Vivaldi/")?It:b(t,"YaBrowser/")?Ot:b(t,"Whale/")?Rt:b(t,"DuckDuckGo/")||b(t,"Ddg/")?At:b(t,"Claude/")?Bt:b(t,"Codex/")?Lt:b(t,"ChatGPT/")?Nt:b(t,"FBIOS")?"Facebook Mobile":b(t,"UCWEB")||b(t,"UCBrowser")?"UC Browser":b(t,"CriOS")?dt:b(t,"CrMo")||b(t,ht)?ht:b(t,et)&&b(t,lt)?wt:b(t,"FxiOS")?_t:b(t.toLowerCase(),Ct.toLowerCase())?Ct:b(t,"Brave/")?jt:((t,i)=>i&&b(i,"Apple")||function(t){return b(t,lt)&&!b(t,ht)&&!b(t,et)}(t))(t,i)?b(t,it)?$t:lt:b(t,"PaleMoon/")?Mt:b(t,"Waterfox/")?Dt:b(t,gt)?gt:b(t,"MSIE")||b(t,"Trident/")?ct:b(t,"Gecko")?gt:"")},Yt={[vt]:[new RegExp("rv:(\\d+(\\.\\d+)?)")],[pt]:[new RegExp("Edge?\\/(\\d+(\\.\\d+)?)")],[ht]:[new RegExp("(Chrome|CrMo)\\/(\\d+(\\.\\d+)?)")],[dt]:[new RegExp("CriOS\\/(\\d+(\\.\\d+)?)")],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/(\\d+(\\.\\d+)?)")],[lt]:[Ut],[$t]:[Ut],[ft]:[new RegExp("(Opera|OPR)\\/(\\d+(\\.\\d+)?)")],[gt]:[new RegExp("Firefox\\/(\\d+(\\.\\d+)?)")],[_t]:[new RegExp("FxiOS\\/(\\d+(\\.\\d+)?)")],[Ct]:[new RegExp("Konqueror[:/]?(\\d+(\\.\\d+)?)","i")],[at]:[new RegExp("BlackBerry (\\d+(\\.\\d+)?)"),Ut],[wt]:[new RegExp("android\\s(\\d+(\\.\\d+)?)","i")],[ut]:[new RegExp("SamsungBrowser\\/(\\d+(\\.\\d+)?)")],[Ft]:[new RegExp("OculusBrowser\\/(\\d+(\\.\\d+)?)")],[It]:[new RegExp("Vivaldi\\/(\\d+(\\.\\d+)?)")],[Ot]:[new RegExp("YaBrowser\\/(\\d+(\\.\\d+)?)")],[Rt]:[new RegExp("Whale\\/(\\d+(\\.\\d+)?)")],[jt]:[new RegExp("Brave\\/(\\d+(\\.\\d+)?)")],[Bt]:[Ht],[Lt]:[Ht],[Nt]:[Ht],[At]:[new RegExp("(DuckDuckGo|Ddg)\\/(\\d+(\\.\\d+)?)")],[Mt]:[new RegExp("PaleMoon\\/(\\d+(\\.\\d+)?)")],[Dt]:[new RegExp("Waterfox\\/(\\d+(\\.\\d+)?)")],[zt]:[new RegExp("GSA\\/(\\d+(\\.\\d+)?)")],[ct]:[new RegExp("(rv:|MSIE )(\\d+(\\.\\d+)?)")],Mozilla:[new RegExp("rv:(\\d+(\\.\\d+)?)")]},Xt=function(t,i,e,s){const n=Jt(t,i,e,s),r=Yt[n];if(I(r))return null;for(let i=0;r.length>i;i++){const e=t.match(r[i]);if(e)return parseFloat(e[e.length-2])}return null},Zt=[[new RegExp("Xbox; Xbox (.*?)[);]","i"),t=>[yt,t&&t[1]||""]],[new RegExp(mt,"i"),[mt,""]],[new RegExp(bt,"i"),[bt,""]],[Gt,[at,""]],[new RegExp(xt,"i"),(t,i)=>{if(/Phone/.test(i)||/WPDesktop/.test(i))return[St,""];if(new RegExp(it).test(i)&&!/IEMobile\b/.test(i))return["Windows Mobile",""];const e=/Windows NT ([0-9.]+)/i.exec(i);if(e&&e[1]){let t=Kt[e[1]]||"";return/arm/i.test(i)&&(t="RT"),[xt,t]}return[xt,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,t=>t&&t[3]?["iOS",[t[3],t[4],t[5]||"0"].join(".")]:["iOS",""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,t=>{let i="";return t&&t.length>=3&&(i=I(t[2])?t[3]:t[2]),["watchOS",i]}],[new RegExp("(Android (\\d+)\\.(\\d+)\\.?(\\d+)?|Android)","i"),t=>t&&t[2]?[et,[t[2],t[3],t[4]||"0"].join(".")]:[et,""]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,t=>{const i=["Mac OS X",""];return t&&t[1]&&(i[1]=[t[1],t[2],t[3]||"0"].join(".")),i}],[/Mac/i,["Mac OS X",""]],[/CrOS/,["Chrome OS",""]],[/Linux|debian/i,["Linux",""]]],Qt=function(t){for(let i=0;Zt.length>i;i++){const[e,s]=Zt[i],n=e.exec(t),r=n&&(T(s)?s(n,t):s);if(r)return r}return["",""]},ti=function(t){return Wt.test(t)?mt:Vt.test(t)?bt:qt.test(t)?yt:new RegExp(Et,"i").test(t)?Et:new RegExp("(Windows Phone|WPDesktop)","i").test(t)?St:/iPad/.test(t)?rt:/iPod/.test(t)?"iPod Touch":/iPhone/.test(t)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(t)?ot:Gt.test(t)?at:/(kobo)\s(ereader|touch)/i.test(t)?"Kobo":new RegExp(kt,"i").test(t)?kt:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(t)||/(kf[a-z]+)( bui|\)).+silk\//i.test(t)?"Kindle Fire":/(Android|ZTE)/i.test(t)?new RegExp(it).test(t)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(t)||/pixel[\daxl ]{1,6}/i.test(t)&&!/pixel c/i.test(t)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(t)||/lmy47v/i.test(t)&&!/QTAQZ3/i.test(t)?et:nt:new RegExp("(pda|Mobile)","i").test(t)?Pt:new RegExp(st,"i").test(t)&&!new RegExp("Tablet pc","i").test(t)?Tt:""},ii=function(t,i){var e;const s=ti(t);return s===rt||s===nt||"Kobo"===s||"Kindle Fire"===s||s===Tt?st:s===mt||s===yt||s===bt||s===Et?"Console":s===ot?"Wearable":s?it:"Android"===(null==i?void 0:i.userAgentDataPlatform)&&(null!==(e=null==i?void 0:i.maxTouchPoints)&&void 0!==e?e:0)>0?600>Math.min(null!==(n=null==i?void 0:i.screenWidth)&&void 0!==n?n:0,null!==(r=null==i?void 0:i.screenHeight)&&void 0!==r?r:0)/(null!==(o=null==i?void 0:i.devicePixelRatio)&&void 0!==o?o:1)?it:st:"Desktop";var n,r,o},ei=/\bFBAV\/(\d+(?:\.\d+)*)/i,si=[[/\bInstagram(?:[ /](\d+(?:\.\d+)*))?\b/i,"Instagram"],[/\bBarcelona[ /](\d+(?:\.\d+)*)?/i,"Threads"],[/\b(?:MessengerForiOS|(?:FBAN|FB_IAB)\/Orca-Android)\b/i,"Messenger",ei],[/\bFBAN\/EMA\b/i,"Facebook Lite",ei],[/\b(?:FBIOS|(?:FBAN|FB_IAB)\/(?:FB4A|FBIOS))\b/i,"Facebook",ei],[/\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"]],ni="[Truncated]",ri="[Unserializable]";function oi(t){let i="";for(let e=0;t.length>e;e++){const s=t.charCodeAt(e);if(55296>s||s>56319)i+=56320>s||s>57343?t[e]:"�";else{const s=t.charCodeAt(e+1);56320>s||s>57343?i+="�":(i+=t[e]+t[e+1],e++)}}return i}Date,Date;const li=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function ai(t,i){return"string"==typeof(e=t)&&li.test(e)?t:i();var e}function ui(t,i){const e=new Error(i);try{Object.defineProperty(e,"name",{value:t,writable:!0,enumerable:!0,configurable:!0})}catch(t){}return e}function hi(t){return t?t.split("#")[0]:t}function di(t,i){const e=setTimeout(t,i);return null!=e&&e.unref&&(null==e||e.unref()),e}function ci(t,i,e){return vi.apply(this,arguments)}function vi(){return(vi=Y(function*(t,i,e){let s;try{return yield Promise.race([t,new Promise((t,n)=>{s=di(()=>{try{null==e||e(),t()}catch(t){n(t)}},i)})])}finally{clearTimeout(s)}})).apply(this,arguments)}let fi,pi,gi;function _i(t){const i=globalThis._posthogChunkIds;if(!i)return;const e=Object.keys(i);return gi&&e.length===pi||(pi=e.length,gi=e.reduce((e,s)=>{fi||(fi={});const n=fi[s];if(n)e[n[0]]=n[1];else{const n=t(s);for(let t=n.length-1;t>=0;t--){const r=n[t],o=null==r?void 0:r.filename,l=i[s];if(o&&l){e[o]=l,fi[s]=[o,l];break}}}return e},{})),gi}function mi(t){return mi="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},mi(t)}function bi(t,i,e){return(i=function(t){var i=function(t){if("object"!=mi(t)||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var e=i.call(t,"string");if("object"!=mi(e))return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==mi(i)?i:i+""}(i))in t?Object.defineProperty(t,i,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[i]=e,t}function yi(t,i){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);i&&(s=s.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),e.push.apply(e,s)}return e}function wi(t){for(var i=1;arguments.length>i;i++){var e=null!=arguments[i]?arguments[i]:{};i%2?yi(Object(e),!0).forEach(function(i){bi(t,i,e[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):yi(Object(e)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(e,i))})}return t}var $i=class{constructor(t,i,e=[]){this.coercers=t,this.stackParser=i,this.modifiers=e}buildFromUnknown(t,i={}){const e=i&&i.mechanism||{handled:!0,type:"generic"},s=this.buildCoercingContext(e,i,0).apply(t),n=this.buildParsingContext(i),r=this.parseStacktrace(s,n);return{$exception_list:this.convertToExceptionList(r,e),$exception_level:"error"}}modifyFrames(t){var i=this;return Y(function*(){for(const e of t)e.stacktrace&&e.stacktrace.frames&&P(e.stacktrace.frames)&&(e.stacktrace.frames=yield i.applyModifiers(e.stacktrace.frames));return t})()}coerceFallback(t){var i;return{type:"Error",value:"Unknown error",stack:null===(i=t.syntheticException)||void 0===i?void 0:i.stack,synthetic:!0}}parseStacktrace(t,i){let e,s;return null!=t.cause&&(e=this.parseStacktrace(t.cause,i)),""!=t.stack&&null!=t.stack&&(s=this.applyChunkIds(this.stackParser(t.stack,t.synthetic?i.skipFirstLines:0),i.chunkIdMap)),wi(wi({},t),{},{cause:e,stack:s})}applyChunkIds(t,i){return t.map(t=>(t.filename&&i&&(t.chunk_id=i[t.filename]),t))}applyCoercers(t,i){for(const e of this.coercers)if(e.match(t))return e.coerce(t,i);return this.coerceFallback(i)}applyModifiers(t){var i=this;return Y(function*(){let e=t;for(const t of i.modifiers)e=yield t(e);return e})()}convertToExceptionList(t,i){var e,s,n;const r={type:t.type,value:t.value,mechanism:{type:null!==(e=i.type)&&void 0!==e?e:"generic",handled:null===(s=i.handled)||void 0===s||s,synthetic:null!==(n=t.synthetic)&&void 0!==n&&n}};t.stack&&(r.stacktrace={type:"raw",frames:t.stack});const o=[r];return null!=t.cause&&o.push(...this.convertToExceptionList(t.cause,wi(wi({},i),{},{handled:!0}))),o}buildParsingContext(t){var i;return{chunkIdMap:_i(this.stackParser),skipFirstLines:null!==(i=t.skipFirstLines)&&void 0!==i?i:1}}buildCoercingContext(t,i,e=0){const s=(e,s)=>{if(4>=s){const n=this.buildCoercingContext(t,i,s);return this.applyCoercers(e,n)}};return wi(wi({},i),{},{syntheticException:0==e?i.syntheticException:void 0,mechanism:t,apply:t=>s(t,e),next:t=>s(t,e+1)})}};function xi(t,i,e,s,n){const r={platform:t,filename:i,function:"<anonymous>"===e?"?":e,in_app:!!i&&!i.startsWith("webkit-masked-url://")&&"<anonymous>"!==i};return I(s)||(r.lineno=s),I(n)||(r.colno=n),r}const Si=(t,i)=>{const e=-1!==t.indexOf("safari-extension"),s=-1!==t.indexOf("safari-web-extension");return e||s?[-1!==t.indexOf("@")?t.split("@")[0]:"?",e?`safari-extension:${i}`:`safari-web-extension:${i}`]:[t,i]},ki=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,Ei=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,Pi=/\((\S*)(?::(\d+))(?::(\d+))\)/,Ti=(t,i)=>{const e=ki.exec(t);if(e){const[,t,s,n]=e;return xi(i,t,"?",+s,+n)}const s=Ei.exec(t);if(s){if(s[2]&&0===s[2].indexOf("eval")){const t=Pi.exec(s[2]);t&&(s[2]=t[1],s[3]=t[2],s[4]=t[3])}const[t,e]=Si(s[1]||"?",s[2]);return xi(i,e,t,s[3]?+s[3]:void 0,s[4]?+s[4]:void 0)}},Ci=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,Fi=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,Ii=(t,i)=>{const e=Ci.exec(t);if(e){if(e[3]&&e[3].indexOf(" > eval")>-1){const t=Fi.exec(e[3]);t&&(e[1]=e[1]||"eval",e[3]=t[1],e[4]=t[2],e[5]="")}let t=e[3],s=e[1]||"?";return[s,t]=Si(s,t),xi(i,t,s,e[4]?+e[4]:void 0,e[5]?+e[5]:void 0)}},Oi=/\(error: (.*)\)/;function Ri(t,i){return t.filename===i.filename&&t.function===i.function&&t.module===i.module&&t.lineno===i.lineno&&t.colno===i.colno}function Ai(t){for(let i=1;10>=i;i++){const e=t.length-2*i;if(0>e)break;let s=!0;for(let n=0;i>n;n++)if(!Ri(t[e+n],t[e+i+n])){s=!1;break}if(s){for(let s=0;i>s;s++)t[e+s]=t[e+i+s];return t.length=e+i,{start:e,length:i}}}}function Mi(t,i){const e=i.start+i.length,s=ji(t,i);s&&t.splice(e+s===t.length?e:i.start,s)}function Di(t,i){let e=i.start;for(;e>0&&Ri(t[e-1],t[e-1+i.length]);)e--;return i.start-e}function ji(t,i){const e=i.start+i.length;let s=e;for(;t.length>s&&Ri(t[s],t[s-i.length]);)s++;return s-e}function Bi(t,i){const e=i[0];let s=t.length-(e?Di(t,e):0);for(const e of i)s-=ji(t,e);return s}function Li(t,i,e){for(let s=0;t.length>s;s++){const n=t[(i+s)%t.length],r=t[(e+s)%t.length];if(n!==r)return r>n}return!1}var Ni=class{match(t){return this.isDOMException(t)||this.isDOMError(t)}coerce(t,i){const e=O(t.stack);return{type:this.getType(t),value:this.getValue(t),stack:e?t.stack:void 0,cause:t.cause?i.next(t.cause):void 0,synthetic:!1}}getType(t){return this.isDOMError(t)?"DOMError":"DOMException"}getValue(t){const i=t.name||(this.isDOMError(t)?"DOMError":"DOMException");return t.message?`${i}: ${t.message}`:i}isDOMException(t){return U(t,"DOMException")}isDOMError(t){return U(t,"DOMError")}},zi=class{match(t){return H(t)}coerce(t,i){var e;const s=this.getStack(t),n=void 0===s;return{type:this.getType(t),value:this.getMessage(t,i),stack:null!=s?s:null===(e=i.syntheticException)||void 0===e?void 0:e.stack,cause:t.cause?i.next(t.cause):void 0,synthetic:n}}getType(t){return t.name||t.constructor.name}getMessage(t,i){const e=t.message;return String(e.error&&"string"==typeof e.error.message?e.error.message:e)}getStack(t){return t.stacktrace||t.stack||void 0}},Ui=class{match(t){return!!U(t,"ErrorEvent")&&(null!=t.error||this.sr(t))}coerce(t,i){var e;if(null!=t.error)return i.apply(t.error);const s=i.apply(t.message);return wi(wi({},s),{},{stack:null!==(e=this.ar(t))&&void 0!==e?e:s.stack,synthetic:!0})}sr(t){return O(t.message)&&t.message.length>0}ar(t){var i,e;const s=t,n=null!==(i=s.lineno)&&void 0!==i?i:0,r=null!==(e=s.colno)&&void 0!==e?e:0;if(O(s.filename)&&0!==s.filename.length&&0!==n)return`Error\n at ${s.filename}:${n}:${r}`}};const Hi=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;var qi=class{match(t){return"string"==typeof t}coerce(t,i){var e;const[s,n]=this.getInfos(t);return{type:null!=s?s:"Error",value:null!=n?n:t,stack:null===(e=i.syntheticException)||void 0===e?void 0:e.stack,synthetic:!0}}getInfos(t){let i="Error",e=t;const s=t.match(Hi);return s&&(i=s[1],e=s[2]),[i,e]}};const Vi=["fatal","error","warning","log","info","debug"];function Wi(t,i=40){const e=Object.keys(t);if(e.sort(),!e.length)return"[object has no keys]";for(let t=e.length;t>0;t--){const s=e.slice(0,t).join(", ");if(i>=s.length)return t===e.length?s:s.length>i?`${s.slice(0,i)}...`:s}return""}var Gi=class{match(t){return"object"==typeof t&&null!==t}coerce(t,i){var e,s;const n=this.getErrorPropertyFromObject(t);return n?i.apply(n):{type:this.getType(t),value:this.getValue(t),stack:null!==(e=this.getStack(t))&&void 0!==e?e:null===(s=i.syntheticException)||void 0===s?void 0:s.stack,level:this.isSeverityLevel(t.level)?t.level:"error",synthetic:!0}}getType(t){if(q(t))return t.constructor.name;const i="name"in t?t.name:void 0;return O(i)&&!R(i)?i:"Error"}getValue(t){if("name"in t&&"string"==typeof t.name){let i=`'${t.name}' captured as exception`;return"message"in t&&"string"==typeof t.message&&(i+=` with message: '${t.message}'`),i}if("message"in t&&"string"==typeof t.message)return t.message;const i=this.getObjectClassName(t);return`${i&&"Object"!==i?`'${i}'`:"Object"} captured as exception with keys: ${Wi(t)}`}isSeverityLevel(t){return O(t)&&!R(t)&&Vi.indexOf(t)>=0}getStack(t){try{return O(t.stacktrace)&&t.stacktrace.length>0?t.stacktrace:O(t.stack)&&t.stack.length>0?t.stack:void 0}catch(t){return}}getErrorPropertyFromObject(t){for(const i in t)if({}.hasOwnProperty.call(t,i)){const e=t[i];if(H(e))return e}}getObjectClassName(t){try{const i=Object.getPrototypeOf(t);return i?i.constructor.name:void 0}catch(t){return}}},Ki=class{match(t){return q(t)}coerce(t,i){var e;const s=t.constructor.name;return{type:s,value:`${s} captured as exception with keys: ${Wi(t)}`,stack:null===(e=i.syntheticException)||void 0===e?void 0:e.stack,synthetic:!0}}},Ji=class{match(t){return z(t)}coerce(t,i){var e;return{type:"Error",value:`Primitive value captured as exception: ${String(t)}`,stack:null===(e=i.syntheticException)||void 0===e?void 0:e.stack,synthetic:!0}}},Yi=class{match(t){return U(t,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(t)}isCustomEventWrappingRejection(t){if(!q(t))return!1;try{const i=t.detail;return null!=i&&"object"==typeof i&&"reason"in i}catch(t){return!1}}coerce(t,i){var e;const s=this.getUnhandledRejectionReason(t);return z(s)?{type:"UnhandledRejection",value:`Non-Error promise rejection captured with value: ${String(s)}`,stack:null===(e=i.syntheticException)||void 0===e?void 0:e.stack,synthetic:!0}:i.apply(s)}getUnhandledRejectionReason(t){try{if("reason"in t)return t.reason;if("detail"in t&&null!=t.detail&&"object"==typeof t.detail&&"reason"in t.detail)return t.detail.reason}catch(t){}return t}};const Xi="$message",Zi="$timestamp",Qi=new Set([Xi,Zi]),te={enabled:!0,max_bytes:32768};function ie(t){var i;return t?{enabled:null!==(i=t.enabled)&&void 0!==i?i:te.enabled,max_bytes:se(t.max_bytes,te.max_bytes)}:wi({},te)}var ee=class{constructor(t){this.ts=[],this.es=0,this.Sr=ie(t)}setConfig(t){this.Sr=ie(t),this.ns()}add(t){const i=function(t){let i;try{i=x(t)}catch(t){return}try{const t=JSON.parse(i);if(!C(t))return;const e=t,s=e[Xi],n=e[Zi];if(!O(s)||0===s.trim().length)return;if(!O(n)&&!D(n))return;return{step:e,json:i}}catch(t){return}}(t);if(!i)return;const e=function(t){if("u">typeof TextEncoder)return(new TextEncoder).encode(t).length;const i=encodeURIComponent(t);let e=0;for(let t=0;i.length>t;t++)"%"===i[t]?(e+=1,t+=2):e+=1;return e}(i.json);e>this.Sr.max_bytes||(this.ts.push({step:i.step,bytes:e}),this.es+=e,this.ns())}getAttachable(){return this.ts.map(t=>t.step)}clear(){this.ts=[],this.es=0}size(){return this.ts.length}ns(){for(;this.es>this.Sr.max_bytes&&this.ts.length>0;){const t=this.ts.shift();t&&(this.es-=t.bytes)}}};function se(t,i){if(!D(t)||1/0===t||-1/0===t)return i;const e=Math.floor(t);return 0>e?i:e}const ne=t=>{if("string"!=typeof t)return t;try{return JSON.parse(t)}catch(i){return t}};function re(t){return"string"==typeof t||t}function oe(t){return"string"==typeof t?t:void 0}const le=["$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"],ae="NativeGzipValidationError",ue=t=>t.length>=2&&31===t[0]&&139===t[1],he=(t,i)=>t===g.GZipJS||i===g.GZipJS||"gzip"===i,de=t=>!(!t||"object"!=typeof t)&&"NotReadableError"===("name"in t?String(t.name):"");let ce;const ve=t=>{throw ui(ae,`Native gzip produced invalid output: ${t}`)},fe=(pe=Y(function*(t,i){18>t.size&&ve("too-short");const e=new Uint8Array(yield t.slice(0,10).arrayBuffer());ue(e)&&8===e[2]||ve("invalid-header");const s=new DataView(yield t.slice(t.size-8).arrayBuffer());s.getUint32(0,!0)!==(t=>{const i=(()=>{if(ce)return ce;ce=[];for(let t=0;256>t;t++){let i=t;for(let t=0;8>t;t++)i=1&i?3988292384^i>>>1:i>>>1;ce[t]=i>>>0}return ce})();let e=4294967295;for(let s=0;t.length>s;s++)e=i[255&(e^t[s])]^e>>>8;return(4294967295^e)>>>0})(i)&&ve("invalid-crc");const n=i.length>>>0;s.getUint32(4,!0)!==n&&ve("invalid-size")}),function(t,i){return pe.apply(this,arguments)});var pe;function ge(){return ge=Y(function*(t,i=!0,e){try{const i=(new TextEncoder).encode(t),e=new globalThis.CompressionStream("gzip"),n=e.writable.getWriter(),r=n.write(i).then(()=>n.close()).catch((s=Y(function*(t){try{yield n.abort(t)}catch(t){}throw t}),function(t){return s.apply(this,arguments)})),o=new Response(e.readable).blob(),[l]=yield Promise.all([o,r]);return yield fe(l,i),l}catch(t){if(null==e?void 0:e.rethrow)throw t;return i&&console.error("Failed to gzip compress data",t),null}var s}),ge.apply(this,arguments)}function _e(t,i){if(null==t)return{};var e,s,n=function(t,i){if(null==t)return{};var e={};for(var s in t)if({}.hasOwnProperty.call(t,s)){if(i.includes(s))continue;e[s]=t[s]}return e}(t,i);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);for(s=0;r.length>s;s++)i.includes(e=r[s])||{}.propertyIsEnumerable.call(t,e)&&(n[e]=t[e])}return n}const me={}.propertyIsEnumerable;function be(t,i){try{return $e(t,i,{ancestors:new WeakSet,remainingNodes:1e4},0)}catch(t){return[]}}function ye(t,i,e,s){if(0>=e.remainingNodes)return{stringValue:ni};if(e.remainingNodes--,B(t))return{boolValue:t};if("bigint"==typeof t)return function(t,i){const e=t.toString(),s=BigInt("9223372036854775808");return t>=s||-s>t?(null==i||i.debug(`Attribute ${e} is outside the int64 range; encoding it as a string`),{stringValue:e}):{intValue:e}}(t,i);if("number"==typeof t){if(!Number.isFinite(t))return{stringValue:String(t)};if(Number.isInteger(t)){if(Number.isSafeInteger(t))return{intValue:String(t)};if(typeof BigInt>"u")return{stringValue:String(t)};const e=BigInt(t).toString();return t>=0x8000000000000000||-0x8000000000000000>t?(null==i||i.debug(`Attribute ${e} is outside the int64 range; encoding it as a string`),{stringValue:e}):{intValue:e}}return{doubleValue:t}}if("string"==typeof t)return{stringValue:oi(t)};if("function"==typeof t)return{stringValue:"[Function]"};if("symbol"==typeof t)return{stringValue:String(t)};if("object"==typeof t&&null!==t){if(e.ancestors.has(t))return{stringValue:"[Circular]"};if(s>=20)return{stringValue:ni};if(t instanceof Date){const i=t.getTime(),e=Number.isFinite(i)?t.toISOString():String(t);return{stringValue:"string"==typeof e?oi(e):String(e)}}e.ancestors.add(t);try{try{const n=t.toJSON;if("function"==typeof n)return ye(n.call(t),i,e,s+1)}catch(t){}return P(t)?{arrayValue:{values:we(t,i,e,s+1)}}:{kvlistValue:{values:$e(t,i,e,s+1)}}}finally{e.ancestors.delete(t)}}return{stringValue:oi(String(t))}}function we(t,i,e,s){const n=[],r=Math.min(t.length,1e3);let o=0;for(;r>o&&e.remainingNodes>0;o++)try{const r=o in t?t[o]:void 0;if(M(r))continue;n.push(ye(r,i,e,s))}catch(t){n.push({stringValue:ri})}return t.length>o&&n.push({stringValue:ni}),n}function $e(t,i,e,s){const n=[];for(const r in t)if(me.call(t,r)){if(!r){null==i||i.debug("Dropping an attribute with an empty key");continue}if(n.length>=1e3||0>=e.remainingNodes){null==i||i.debug("Attributes truncated: the value exceeds the OTLP encoder budget");break}try{const o=t[r];if(A(o)||I(o))continue;n.push({key:oi(r),value:ye(o,i,e,s)})}catch(t){n.push({key:oi(r),value:{stringValue:ri}})}}return n}function xe(t,i,e){return wi(wi(wi(wi({},t.resourceAttributes),{},{"service.name":t.serviceName||"unknown_service"},t.environment&&{"deployment.environment":t.environment}),t.serviceVersion&&{"service.version":t.serviceVersion}),{},{"telemetry.sdk.name":i,"telemetry.sdk.version":e})}const Se={darwin:"macOS",win32:"Windows",linux:"Linux",android:"Android",freebsd:"FreeBSD",openbsd:"OpenBSD",sunos:"SunOS",aix:"AIX","Mac OS X":"macOS"};const ke={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}},Ee=ke.info;function Pe(t){try{return oi(String(t))}catch(t){return ri}}function Te(t,i,e,s){const n=t.level||"info",{text:r,number:o}=ke[n]||Ee,l=function(t=Date.now()){return String(t)+"000000"}(D(s)?s:void 0),a={};i.distinctId&&(a.posthogDistinctId=i.distinctId),i.sessionId&&(a.sessionId=i.sessionId),i.windowId&&(a["window.id"]=i.windowId),M(i.sessionStartTimestamp)||(a.sessionStartTimestamp=String(i.sessionStartTimestamp)),M(i.lastActivityTimestamp)||(a.lastActivityTimestamp=String(i.lastActivityTimestamp)),i.currentUrl&&(a["url.full"]=i.currentUrl),i.screenName&&(a["screen.name"]=i.screenName),i.appState&&(a["app.state"]=i.appState),i.activeFeatureFlags&&i.activeFeatureFlags.length>0&&(a.feature_flags=i.activeFeatureFlags);const u=wi({},a),h=t.attributes;if(h){let t=[];try{t=Object.keys(h)}catch(i){t=[]}for(const i of t){let t;try{t=h[i]}catch(i){t=ri}Object.defineProperty(u,i,{value:t,enumerable:!0,writable:!0,configurable:!0})}}const d={timeUnixNano:l,observedTimeUnixNano:l,severityNumber:o,severityText:r,body:{stringValue:Pe(t.body)},attributes:be(u,e)};return t.trace_id&&(d.traceId=t.trace_id),t.span_id&&(d.spanId=t.span_id),I(t.trace_flags)||(d.flags=t.trace_flags),d}function Ce(t,i,e){return xe(t,i,e)}function Fe(t,i,e,s){return{resourceLogs:[{resource:{attributes:be(i)},scopeLogs:[{scope:{name:e,version:s},logRecords:t}]}]}}var Ie=class{constructor(t,i,e,s,n,r=()=>Promise.resolve(),o){var l;this._instance=t,this.Sr=i,this.$=e,this.ss=s,this.rs=n,this.ls=r,this.us=o,this.hs=null,this.cs=0,this.ds=0,this.vs=0,this.fs=0,this.ps=0,this.gs=!1,this.ys=i.maxBufferSize,this.bs=Math.max(null!==(l=i.maxQueueSize)&&void 0!==l?l:i.maxBufferSize,i.maxBufferSize),this._s=i.flushIntervalMs,this.ws=i.maxBatchRecordsPerPost,this.ks=i.rateCapWindowMs,this.Ss=i.maxLogsPerInterval}clearQueue(){this.ds++,this._instance.setPersistedProperty(p.LogsQueue,[])}reset(){this.xs(),this.fs=0,this.ps=0,this.gs=!1,this.vs=0,this.ws=this.Sr.maxBatchRecordsPerPost}onReconnect(){this.vs=0,this.Cs()}captureLog(t,i){var e;if(this._instance.isDisabled)return;if(this._instance.optedOut)return;if(!(null==t?void 0:t.body))return;const s=this.$s(t);if(null===s)return;if(!s.body)return void this.$.info("Log was rejected in beforeSend function");if(!this.Ts())return;const n={record:Te(s,null!==(e=null==i?void 0:i.context)&&void 0!==e?e:this.ss(),this.$,null==i?void 0:i.occurredAtMs)};this.rs(()=>this.Is(n))}$s(t){const i=this.Sr.beforeSend;if(!i)return t;const e=P(i)?i:[i];let s=t;for(const t of e)try{const i=t(s);if(!i)return this.$.info("Log was rejected in beforeSend function"),null;s=i}catch(t){return this.$.error("Error in beforeSend function for log:",t),null}return s}Ts(){if(void 0===this.Ss)return!0;const t=Date.now(),i=t-this.fs;return this.ks>i&&i>=0||(this.fs=t,this.ps=0,this.gs=!1),this.Ss>this.ps?(this.ps++,!0):(this.gs||(this.$.warn(`captureLog dropping logs: exceeded ${this.Ss} logs per ${this.ks}ms`),this.gs=!0),!1)}flush(){var t=this;return Y(function*(){if(!t._instance.isDisabled)return t.hs||(t.hs=t.Ms().finally(()=>{t.hs=null})),t.hs})()}Ms(){var t=this;return Y(function*(){var i;t.xs();let e=null!==(i=t._instance.getPersistedProperty(p.LogsQueue))&&void 0!==i?i:[];if(0===e.length)return;const s=e.length;let n=0;for(;e.length>0&&s>n;){var r,o;const i=t.ds;t.cs=0;const s=Math.min(e.length,t.ws),l=e.slice(0,s),a=Fe(l.map(t=>t.record),t.Es(),null!==(r=t.us)&&void 0!==r?r:t._instance.getLibraryId(),t._instance.getLibraryVersion()),u=yield t._instance.Ps(a);if(t.ds!==i)return;if("too-large"===u.kind&&l.length>1)t.ws=Math.max(1,Math.floor(l.length/2)),t.$.warn(`Received 413 when sending logs batch of size ${l.length}, reducing batch size to ${t.ws}`);else{if("retry-later"===u.kind)throw u.error;if("too-large"===u.kind?t.$.warn("Dropping a single log record after 413 with batch size 1 — the record is larger than the server cap and cannot be split further."):"ok"===u.kind&&t.Sr.maxBatchRecordsPerPost>t.ws&&(t.ws=Math.min(t.Sr.maxBatchRecordsPerPost,t.ws+1)),yield t.Rs(l.length),e=null!==(o=t._instance.getPersistedProperty(p.LogsQueue))&&void 0!==o?o:[],n+=l.length,"fatal"===u.kind)throw u.error}}})()}Rs(t){var i=this;return Y(function*(){var e;const s=Math.max(0,t-i.cs),n=null!==(e=i._instance.getPersistedProperty(p.LogsQueue))&&void 0!==e?e:[];i._instance.setPersistedProperty(p.LogsQueue,n.slice(s)),yield i.ls()})()}Es(){return Ce(this.Sr,this._instance.getLibraryId(),this._instance.getLibraryVersion())}Is(t){var i;if(this._instance.optedOut)return;const e=null!==(i=this._instance.getPersistedProperty(p.LogsQueue))&&void 0!==i?i:[];this.bs>e.length||(e.shift(),this.cs++,this.$.info("Logs queue is full, dropping oldest record.")),e.push(t),this._instance.setPersistedProperty(p.LogsQueue,e),this.ys>e.length?this.As():this.Cs()}As(t=this._s){this.Fs||(this.Fs=di(()=>{this.Fs=void 0,this.Cs()},t))}Os(){const t=Math.min(Math.max(0,this.vs-1),6);return this._s*Math.pow(2,t)}Ds(){const t=this._instance.getPersistedProperty(p.LogsQueue);return!!t&&t.length>0}shutdown(t){var i=this;return Y(function*(){i.xs();const e=i.flush().catch(()=>{});void 0!==t?yield ci(e,t):yield e})()}flushWithTimeout(t){var i=this;return Y(function*(){const e=i.flush();yield ci(e,t,()=>{e.catch(()=>{})})})()}Cs(){this.flush().then(()=>{this.vs=0},t=>{this.vs++,this.$.error("PostHog logs flush failed:",t)}).finally(()=>{!this._instance.isDisabled&&this.Ds()&&this.As(this.Os())})}xs(){this.Fs&&(clearTimeout(this.Fs),this.Fs=void 0)}};const Oe=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function Re(t){return String(t)+"000000"}function Ae(t,i,e,s){let n="";return s&&(n=Object.keys(s).sort().map(t=>`${JSON.stringify(t)}:${JSON.stringify(s[t])}`).join(",")),`${t}\0${i}\0${null!=e?e:""}\0${n}`}var Me=class{constructor(t,i,e){this._instance=t,this.Sr=i,this.$=e,this.Ls=new Map,this.hs=null,this.Ns=!1,this.qs=new Map,this.js=new Set,this.Bs=0}count(t,i=1,e){this.Hs({name:t,type:"count",value:i,unit:null==e?void 0:e.unit,attributes:null==e?void 0:e.attributes})}gauge(t,i,e){this.Hs({name:t,type:"gauge",value:i,unit:null==e?void 0:e.unit,attributes:null==e?void 0:e.attributes})}histogram(t,i,e){this.Hs({name:t,type:"histogram",value:i,unit:null==e?void 0:e.unit,attributes:null==e?void 0:e.attributes})}flush(){var t=this;const i=this.hs,e=function(){var e=Y(function*(){i&&(yield i.catch(()=>{})),yield t.zs()});return function(){return e.apply(this,arguments)}}()().finally(()=>{this.hs===e&&(this.hs=null)});return this.hs=e,e}drainWindow(){if(0===this.Ls.size)return null;const t=this.Ls;return this.Ls=new Map,this.Ns=!1,this.qs=new Map,this.js=new Set,this.Us(t)}reset(){this.Bs++,this.xs(),this.Ls=new Map,this.hs=null,this.Ns=!1,this.qs=new Map,this.js=new Set}Hs(t){if(this._instance.isDisabled||this._instance.optedOut)return;const i=this.$s(t);if(null===i)return;if(!i.name||"string"!=typeof i.name)return void this.$.warn("Dropping metric with empty name");if("number"!=typeof i.value||!Number.isFinite(i.value))return void this.$.warn(`Dropping metric '${i.name}': value must be a finite number`);if("count"===i.type&&0>i.value)return void this.$.warn(`Dropping count '${i.name}': counters are monotonic, value must be >= 0`);let e,s;try{e=i.attributes?wi({},i.attributes):void 0,s=Ae(i.type,i.name,i.unit,e)}catch(t){return void this.$.warn(`Dropping metric '${i.name}': attributes could not be serialized`,t)}let n=this.Ls.get(s);if(!n){if(!this.Ws())return;n={name:i.name,type:i.type,unit:i.unit,attributes:e,windowStartMs:Date.now()},this.Ls.set(s,n)}const r=this.qs.get(i.name);void 0===r?this.qs.set(i.name,i.type):r===i.type||this.js.has(i.name)||(this.js.add(i.name),this.$.warn(`Metric name '${i.name}' is already used as a ${r}; recording it as a ${i.type} too will blend both series in charts. Use a distinct name.`)),this.Vs(n,i.value),this.As()}Ws(){return this.Sr.maxSeriesPerFlush>this.Ls.size||(this.Ns||(this.Ns=!0,this.$.warn(`Metric series cap reached (${this.Sr.maxSeriesPerFlush} per flush window); dropping new series until the next flush. Reduce attribute cardinality.`)),!1)}Vs(t,i){switch(t.type){case"count":var e;t.total=(null!==(e=t.total)&&void 0!==e?e:0)+i;break;case"gauge":t.last=i;break;case"histogram":{t.hist||(t.hist={count:0,sum:0,min:i,max:i,bucketCounts:new Array(Oe.length+1).fill(0)});const e=t.hist;e.count+=1,e.sum+=i,e.min=Math.min(e.min,i),e.max=Math.max(e.max,i),e.bucketCounts[function(t,i){for(let e=0;i.length>e;e++)if(i[e]>=t)return e;return i.length}(i,Oe)]+=1;break}}}$s(t){const i=this.Sr.beforeSend;if(!i)return t;const e=P(i)?i:[i];let s=t;for(const t of e)try{const i=t(s);if(!i)return this.$.info("Metric was rejected in beforeSend function"),null;s=i}catch(t){return this.$.error("Error in beforeSend function for metric:",t),null}return s}As(){this.Fs||(this.Fs=di(()=>{this.Fs=void 0,this.flush().catch(t=>{this.$.error("Metrics flush failed:",t)})},this.Sr.flushIntervalMs))}xs(){this.Fs&&(clearTimeout(this.Fs),this.Fs=void 0)}zs(){var t=this;return Y(function*(){if(0===t.Ls.size)return;const i=t.Ls;t.Ls=new Map,t.Ns=!1,t.qs=new Map,t.js=new Set;const e=t.Bs,s=yield t._instance.Gs(t.Us(i));if(e===t.Bs)switch(s.kind){case"ok":return;case"retry-later":return t.Zs(i),void t.As();case"too-large":return void t.$.warn("Metrics batch exceeded the server size limit and was dropped");case"fatal":return void t.$.error("Failed to send metrics batch:",s.error)}})()}Us(t){return i=this.Qs(t),e=function(t,i,e){return xe(t,i,e)}(this.Sr,this._instance.getLibraryId(),this._instance.getLibraryVersion()),s=this._instance.getLibraryId(),n=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:be(e)},scopeMetrics:[{scope:{name:s,version:n},metrics:i}]}]};var i,e,s,n}Qs(t){const i=Re(Date.now()),e=new Map;for(const o of t.values()){var s;const t=Ae(o.type,o.name,o.unit,void 0);let l=e.get(t);l||(l=wi({name:o.name},o.unit&&{unit:o.unit}),"count"===o.type?l.sum={aggregationTemporality:1,isMonotonic:!0,dataPoints:[]}:"gauge"===o.type?l.gauge={dataPoints:[]}:l.histogram={aggregationTemporality:1,dataPoints:[]},e.set(t,l));const a=be(null!==(s=o.attributes)&&void 0!==s?s:{},this.$),u=Re(o.windowStartMs);if("count"===o.type){var n;const t={attributes:a,startTimeUnixNano:u,timeUnixNano:i,asDouble:null!==(n=o.total)&&void 0!==n?n:0};l.sum.dataPoints.push(t)}else if("gauge"===o.type){var r;const t={attributes:a,timeUnixNano:i,asDouble:null!==(r=o.last)&&void 0!==r?r:0};l.gauge.dataPoints.push(t)}else o.hist&&l.histogram.dataPoints.push({attributes:a,startTimeUnixNano:u,timeUnixNano:i,count:o.hist.count,sum:o.hist.sum,min:o.hist.min,max:o.hist.max,bucketCounts:o.hist.bucketCounts,explicitBounds:Oe})}return Array.from(e.values())}Zs(t){for(const[s,n]of t){const t=this.Ls.get(s);if(t)switch(t.windowStartMs=Math.min(t.windowStartMs,n.windowStartMs),t.type){case"count":var i,e;t.total=(null!==(i=t.total)&&void 0!==i?i:0)+(null!==(e=n.total)&&void 0!==e?e:0);break;case"gauge":break;case"histogram":if(n.hist)if(t.hist){t.hist.count+=n.hist.count,t.hist.sum+=n.hist.sum,t.hist.min=Math.min(t.hist.min,n.hist.min),t.hist.max=Math.max(t.hist.max,n.hist.max);for(let i=0;t.hist.bucketCounts.length>i;i++)t.hist.bucketCounts[i]+=n.hist.bucketCounts[i]}else t.hist=n.hist}else this.Ws()&&this.Ls.set(s,n)}}};const De=(i,{debugEnabled:e}={})=>{const s={N(s,...n){t&&(f.DEBUG||t.POSTHOG_DEBUG||e)&&!I(t.console)&&t.console&&("__rrweb_original__"in t.console[s]?t.console[s].__rrweb_original__:t.console[s])(i,...n)},debug(...t){s.N("debug",...t)},info(...t){s.N("log",...t)},warn(...t){s.N("warn",...t)},error(...t){s.N("error",...t)},critical(...t){console.error(i,...t)},uninitializedWarning(t){s.error(`You must initialize PostHog before calling ${t}`)},createLogger:(t,e)=>De(`${i} ${t}`,e)};return s},je=De("[PostHog.js]"),Be=je.createLogger,Le=Be("[ExternalScriptsLoader]"),Ne=t=>{const i=null==s?void 0:s.querySelectorAll("script");if(i)for(let e=0;i.length>e;e++)if(i[e].src===t||i[e].getAttribute("src")===t)return i[e]},ze=(t,i,e)=>{if(t.config.disable_external_dependency_loading)return Le.warn(`${i} was requested but loading of external scripts is disabled.`),e("Loading of external scripts is disabled");const n=Ne(i);if(n){if(n.__posthog_loading_callback_fired)return e();const t=n.__posthog_loading_error;return t?e(t):(n.addEventListener("load",t=>{n.__posthog_loading_callback_fired=!0,e(void 0,t)}),void n.addEventListener("error",t=>{n.__posthog_loading_error=t,e(t)}))}const r=()=>{if(!s)return e("document not found");if(Ne(i))return ze(t,i,e);let n=s.createElement("script");if(n.type="text/javascript",n.crossOrigin="anonymous",n.src=i,n.onload=t=>{n.__posthog_loading_callback_fired=!0,e(void 0,t)},n.onerror=t=>{n.__posthog_loading_error=t,e(t)},t.config.prepare_external_dependency_script&&(n=t.config.prepare_external_dependency_script(n)),!n)return e("prepare_external_dependency_script returned null");if("head"===t.config.external_scripts_inject_target)s.head.appendChild(n);else{const t=s.querySelectorAll("body > script");var r;t.length>0?null===(r=t[0].parentNode)||void 0===r||r.insertBefore(n,t[0]):s.body.appendChild(n)}};(null==s?void 0:s.body)?r():null==s||s.addEventListener("DOMContentLoaded",r)},Ue={},He=(t,i)=>{let e=`/static/${i}.js?v=${t.version}`;if("toolbar"===i){const t=3e5;e=`${e}&t=${Math.floor(Date.now()/t)*t}`}return t.requestRouter.endpointFor("assets",e)};c.__PosthogExtensions__=c.__PosthogExtensions__||{},c.__PosthogExtensions__.loadExternalDependency=(t,i,e)=>{if("remote-config"===i){const i=t.requestRouter.endpointFor("assets",`/array/${t.config.token}/config.js`);return void ze(t,i,e)}const s=t.config.strict_script_versioning;if(s){const n=t.requestRouter.endpointFor("assets",`/static/${t.version}/${i}.js`),r=Ue[n];if("fallback"===s&&r){if(Ne(r))return void ze(t,r,e);delete Ue[n]}return void ze(t,n,"fallback"===s?(s,r)=>{if(s)if("string"==typeof s)e(s);else{var o;const s=He(t,i);Ue[n]=s;const r=Ne(n);null==r||null===(o=r.parentNode)||void 0===o||o.removeChild(r),ze(t,s,e)}else e(void 0,r)}:e)}ze(t,He(t,i),e)},c.__PosthogExtensions__.loadSiteApp=(t,i,e)=>{const s=t.requestRouter.endpointFor("api",i);ze(t,s,e)},f.DEBUG=!1,f.LIB_VERSION="1.429.2",f.LIB_NAME="web";var qe=f;const Ve="$people_distinct_id",We="distinct_id",Ge="$device_id",Ke="$device_model",Je="__alias",Ye="__cmpns",Xe="$fbc",Ze="$fbc_persistence",Qe="__timers",ts="$autocapture_disabled_server_side",is="$heatmaps_enabled_server_side",es="$exception_capture_enabled_server_side",ss="$error_tracking_suppression_rules",ns="$error_tracking_capture_extension_exceptions",rs="$web_vitals_enabled_server_side",os="$dead_clicks_enabled_server_side",ls="$product_tours_enabled_server_side",as="$logs_capture_enabled_server_side",us="$web_vitals_allowed_metrics",hs="$session_recording_remote_config",ds="$session_recording_enabled_server_side",cs="$replay_sample_rate",vs="$replay_override_sampling",fs="$replay_override_linked_flag",ps="$replay_override_url_trigger",gs="$replay_override_event_trigger",_s="$sesid",ms="$session_is_sampled",bs="$session_past_minimum_duration",ys="$session_recording_url_trigger_activated_session",ws="$session_recording_event_trigger_activated_session",$s="$debug_first_full_snapshot_timestamp",xs="$sess_rec_flush_size",Ss="$enabled_feature_flags",ks="$active_feature_flags",Es="$early_access_features",Ps="$feature_flag_details",Ts="$feature_flag_payloads",Cs="$feature_flag_request_id",Fs="$minimal_flag_called_events",Is="$override_feature_flags",Os="$override_feature_flag_payloads",Rs="$stored_person_properties",As="$stored_group_properties",Ms="$groups",Ds="$surveys",js="$surveys_loaded_at",Bs="$surveys_activated",Ls="$surveys_activated_session",Ns="$surveys_activated_timestamps",zs="ph_product_tours",Us="$product_tours_activated",Hs="$product_tours_activated_session",qs="$conversations_widget_session_id",Vs="$conversations_ticket_id",Ws="$conversations_widget_state",Gs="$conversations_user_traits",Ks="$flag_call_reported",Js="$flag_call_reported_session_id",Ys="$feature_flag_errors",Xs="$feature_flag_evaluated_at",Zs="$user_state",Qs="$client_session_props",tn="$capture_rate_limit",en="$initial_campaign_params",sn="$initial_referrer_info",nn="$initial_person_info",rn="$epp",on="$posthog_cookieless",ln="$cookieless_mode",an="$sdk_debug_extensions_init_method",un="$sdk_debug_extensions_init_time_ms",hn="$sdk_debug_recording_script_not_loaded",dn="$sdk_debug_replay_event_trigger_status",cn="$sdk_debug_replay_linked_flag_trigger_status",vn="$sdk_debug_replay_matched_recording_trigger_groups",fn="$sdk_debug_replay_pending_trigger_conditions",pn="$sdk_debug_replay_remote_trigger_matching_config",gn="$sdk_debug_replay_trigger_groups_count",_n="$sdk_debug_replay_url_trigger_status",mn="$session_recording_start_reason",bn="PostHog loadExternalDependency extension not found.",yn="anonymous",wn="identified",$n="identified_only",xn="visibilitychange",Sn="beforeunload",kn="$pageview",En="$pageleave",Pn="$identify",Tn="$groupidentify";function Cn(t,i){P(t)&&t.forEach(i)}function Fn(t,i){if(!M(t))if(P(t))t.forEach(i);else if((t=>t instanceof FormData)(t))t.forEach((t,e)=>i(t,e));else for(const e in t)k.call(t,e)&&i(t[e],e)}const In=function(t,...i){for(const e of i)for(const i in e)void 0!==e[i]&&(t[i]=e[i]);return t};function On(t){const i=Object.keys(t);let e=i.length;const s=new Array(e);for(;e--;)s[e]=[i[e],t[i[e]]];return s}const Rn=function(t){try{return t()}catch(t){return}},An=function(t){return function(...i){try{return t.apply(this,i)}catch(t){je.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),je.critical(t)}}},Mn=function(t){const i={};return Fn(t,function(t,e){(O(t)&&t.length>0||D(t))&&(i[e]=t)}),i};function Dn(t){const i=wi({},t);for(const e of["name","message","stack","cause","errors"])try{e in t&&(i[e]=t[e])}catch(t){}return i}const jn=["herokuapp.com","vercel.app","netlify.app"];function Bn(t){const i=null==t?void 0:t.hostname;if(!O(i))return!1;const e=i.split(".").slice(-2).join(".");for(const t of jn)if(e===t)return!1;return!0}function Ln(t,i,e,s){const{capture:n=!1,passive:r=!0}=null!=s?s:{};null==t||t.addEventListener(i,e,{capture:n,passive:r})}function Nn(t){return"ph_toolbar_internal"===t.name}const zn=t=>{if(s){try{const i=t+"=",e=s.cookie.split(";").filter(t=>t.length);for(let t=0;e.length>t;t++){let s=e[t];for(;" "==s.charAt(0);)s=s.substring(1,s.length);if(0===s.indexOf(i))return decodeURIComponent(s.substring(i.length,s.length))}}catch(t){}return null}};Math.trunc||(Math.trunc=function(t){return 0>t?Math.ceil(t):Math.floor(t)}),Number.isInteger||(Number.isInteger=function(t){return D(t)&&isFinite(t)&&Math.floor(t)===t});var Un=class t{constructor(t){if(this.bytes=t,16!==t.length)throw new TypeError("not 128-bit length")}static fromFieldsV7(i,e,s,n){if(!Number.isInteger(i)||!Number.isInteger(e)||!Number.isInteger(s)||!Number.isInteger(n)||0>i||0>e||0>s||0>n||i>0xffffffffffff||e>4095||s>1073741823||n>4294967295)throw new RangeError("invalid field value");const r=new Uint8Array(16);return r[0]=i/Math.pow(2,40),r[1]=i/Math.pow(2,32),r[2]=i/Math.pow(2,24),r[3]=i/Math.pow(2,16),r[4]=i/256,r[5]=i,r[6]=112|e>>>8,r[7]=e,r[8]=128|s>>>24,r[9]=s>>>16,r[10]=s>>>8,r[11]=s,r[12]=n>>>24,r[13]=n>>>16,r[14]=n>>>8,r[15]=n,new t(r)}toString(){let t="";for(let i=0;this.bytes.length>i;i++)t=t+(this.bytes[i]>>>4).toString(16)+(15&this.bytes[i]).toString(16),3!==i&&5!==i&&7!==i&&9!==i||(t+="-");if(36!==t.length)throw new Error("Invalid UUIDv7 was generated");return t}clone(){return new t(this.bytes.slice(0))}equals(t){return 0===this.compareTo(t)}compareTo(t){for(let i=0;16>i;i++){const e=this.bytes[i]-t.bytes[i];if(0!==e)return Math.sign(e)}return 0}},Hn=class{generate(){const t=this.generateOrAbort();if(!I(t))return t;{this.Ct=0;const t=this.generateOrAbort();if(I(t))throw new Error("Could not generate UUID after timestamp reset");return t}}generateOrAbort(){const t=(()=>{const t=Date.now();return D(t)&&isFinite(t)?Math.min(Math.max(Math.floor(t),0),0xffffffffffff):0})();if(t>this.Ct)this.Ct=t,this.Mt();else{if(this.Ct>=t+1e4)return;this.It++,this.It>4398046511103&&(this.Ct++,this.Mt())}return Un.fromFieldsV7(this.Ct,Math.trunc(this.It/Math.pow(2,30)),this.It&Math.pow(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 Vn}};let qn=t=>{if("u">typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(let i=0;t.length>i;i++)t[i]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return t};t&&!I(t.crypto)&&crypto.getRandomValues&&(qn=t=>crypto.getRandomValues(t));var Vn=class{nextUint32(){return this.Rt.length>this.$t||(qn(this.Rt),this.$t=0),this.Rt[this.$t++]}constructor(){this.Rt=new Uint32Array(8),this.$t=1/0}};let Wn;const Gn=()=>Kn().toString(),Kn=()=>(Wn||(Wn=new Hn)).generate();let Jn="";const Yn=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;let Xn=null;const Zn={Et(){if(!A(Xn))return Xn;if(Xn=!1,s)try{const t=`__ph_cookie_support_${Gn()}`;Zn.At(t,"xyz"),Xn='"xyz"'===zn(t),Zn.Lt(t)}catch(t){Xn=!1}return Xn},Pt(t){je.error("cookieStore error: "+t)},Ot:zn,Dt(t){let i;try{i=JSON.parse(Zn.Ot(t))||{}}catch(t){}return i},At(t,i,e,n,r){if(!s)return!1;try{let o="",l="";const a=function(t,i){if(i){let i=function(t,i=s){if(Jn)return Jn;if(!i)return"";if(["localhost","127.0.0.1"].includes(t))return"";const e=t.split(".");let n=Math.min(e.length,8);const r="dmn_chk_"+Gn();for(;!Jn&&n--;){const t=e.slice(n).join("."),s=r+"=1;domain=."+t+";path=/";i.cookie=s+";max-age=3",i.cookie.includes(r)&&(i.cookie=s+";max-age=0",Jn=t)}return Jn}(t);if(!i){const e=(t=>{const i=t.match(Yn);return i?i[0]:""})(t);e!==i&&je.info("Warning: cookie subdomain discovery mismatch",e,i),i=e}return i?"; domain=."+i:""}return""}(s.location.hostname,n);if(e){const t=new Date;t.setTime(t.getTime()+864e5*e),o="; expires="+t.toUTCString()}r&&(l="; secure");const u=t+"="+encodeURIComponent(JSON.stringify(i))+o+"; SameSite=Lax; path=/"+a+l;return u.length>3686.4&&je.warn("cookieStore warning: large cookie, len="+u.length),s.cookie=u,!0}catch(t){return!1}},Lt(t,i){if(null==s?void 0:s.cookie)try{Zn.At(t,"",-1,i)}catch(t){return}}};let Qn=null;const tr={Et(){if(!A(Qn))return Qn;let i=!0;if(I(t))i=!1;else try{const t="__mplssupport__";tr.At(t,"xyz"),'"xyz"'!==tr.Ot(t)&&(i=!1),tr.Lt(t)}catch(t){i=!1}return i||je.error("localStorage unsupported; falling back to cookie store"),Qn=i,i},Pt(t){je.error("localStorage error: "+t)},Ot(i){try{return null==t?void 0:t.localStorage.getItem(i)}catch(t){tr.Pt(t)}return null},Dt(t){try{return JSON.parse(tr.Ot(t))||{}}catch(t){}return null},At(i,e){try{return null==t||t.localStorage.setItem(i,JSON.stringify(e)),!0}catch(t){tr.Pt(t)}return!1},Lt(i){try{null==t||t.localStorage.removeItem(i)}catch(t){tr.Pt(t)}}},ir=[Rs,ks,Ss,Ps,Ts,Cs,Xs,Ys,Ks],er=[Ge,We,_s,ms,rn,nn,Ze,Zs],sr=t=>t+"_cpm",nr=["__proto__","constructor","prototype"],rr=t=>{if(!C(t))return{};const i={};return Object.keys(t).forEach(e=>{-1===nr.indexOf(e)&&(i[e]=t[e])}),i},or=(t,i=[])=>{const e={};return[...er,...i].forEach(i=>{const s=t[i];I(s)||A(s)||""===s||(e[i]=s)}),e},lr=t=>{let i=5381,e=2166136261;for(let s=0;t.length>s;s++){const n=t.charCodeAt(s);i=33*i^n,e=Math.imul(e^n,16777619)}return t.length.toString(36)+"."+(i>>>0).toString(36)+"."+(e>>>0).toString(36)},ar=(t,i)=>({p:i,f:lr(JSON.stringify(t))}),ur=(t,i)=>{if(!i)return{properties:[],isValid:!1};try{const e=Zn.Dt(sr(t)),s=(null==e?void 0:e.f)===lr(i)&&P(e.p);return{properties:s?e.p:[],isValid:s}}catch(t){return{properties:[],isValid:!1}}},hr=(t,i)=>i+"|"+(Zn.Ot(sr(t))||""),dr={},cr={Et:()=>!0,Pt(t){je.error("memoryStorage error: "+t)},Ot:t=>t in dr?dr[t]:null,Dt:t=>t in dr?dr[t]:null,At:(t,i)=>(dr[t]=i,!0),Lt(t){delete dr[t]}};let vr=null;const fr={Et(){if(!A(vr))return vr;if(vr=!0,I(t))vr=!1;else try{const t="__support__";fr.At(t,"xyz"),'"xyz"'!==fr.Ot(t)&&(vr=!1),fr.Lt(t)}catch(t){vr=!1}return vr},Pt(t){je.error("sessionStorage error: ",t)},Ot(i){try{return null==t?void 0:t.sessionStorage.getItem(i)}catch(t){fr.Pt(t)}return null},Dt(t){try{return JSON.parse(fr.Ot(t))||null}catch(t){}return null},At(i,e){try{return null==t||t.sessionStorage.setItem(i,JSON.stringify(e)),!0}catch(t){fr.Pt(t)}return!1},Lt(i){try{null==t||t.sessionStorage.removeItem(i)}catch(t){fr.Pt(t)}}};var pr=class{constructor(t){this._instance=t}get Sr(){return this._instance.config}get consent(){return this.xo()?0:this.Co}isOptedOut(){return"always"===this.Sr.cookieless_mode||this.isRejected()||-1===this.consent&&"on_reject"===this.Sr.cookieless_mode}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return 0===this.consent}isRejected(){return 0===this.consent||-1===this.consent&&this.Sr.opt_out_capturing_by_default}optInOut(t){this.$o.At(this.To,t?1:0,this.Sr.cookie_expiration,this.Sr.cross_subdomain_cookie,this.Sr.secure_cookie)}reset(){this.$o.Lt(this.To,this.Sr.cross_subdomain_cookie)}get To(){const{token:t,opt_out_capturing_cookie_prefix:i,consent_persistence_name:e}=this._instance.config;return e||(i?i+t:"__ph_opt_in_out_"+t)}get Co(){const t=this.$o.Ot(this.To);return G(t)?1:b(K,t)?0:-1}get $o(){const t=this.Sr.opt_out_capturing_persistence_type,i="localStorage"===t?tr:Zn,e=i.Et()?i:cr;if(!this.Io||this.Io!==e){this.Io=e;const i="localStorage"===t?Zn:tr;i.Ot(this.To)&&(this.Io.Ot(this.To)||this.optInOut(G(i.Ot(this.To))),i.Lt(this.To,this.Sr.cross_subdomain_cookie))}return this.Io}xo(){return!!this.Sr.respect_dnt&&[null==e?void 0:e.doNotTrack,null==e?void 0:e.msDoNotTrack,c.doNotTrack,null==e?void 0:e.globalPrivacyControl].some(t=>G(t))}};function gr(t,i){var e;const s=null==t||null===(e=t.config)||void 0===e?void 0:e.get_current_url;if(!T(s))return i;try{const t=s(i);return O(t)&&t?t:i}catch(t){return je.error("Error in get_current_url, falling back to window.location.href",t),i}}function _r(t){var i;return t instanceof Element&&("__POSTHOG_TOOLBAR__"===t.id||!!(null===(i=t.closest)||void 0===i?void 0:i.call(t,".toolbar-global-fade-container")))}function mr(t){return!!t&&1===t.nodeType}function br(t,i){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===i.toLowerCase()}function yr(t){return!!t&&3===t.nodeType}function wr(t){return!!t&&11===t.nodeType&&mr(t.host)}function $r(t){return t?y(t).split(/\s+/):[]}function xr(i,e){const s=function(i){var e;const s=null==t||null===(e=t.location)||void 0===e?void 0:e.href;return I(s)?void 0:gr(i,s)}(e);return!!(s&&i&&i.some(t=>s.match(t)))}function Sr(t){let i="";switch(typeof t.className){case"string":i=t.className;break;case"object":i=(t.className&&"baseVal"in t.className?t.className.baseVal:null)||t.getAttribute("class")||"";break;default:i=""}return $r(i)}function kr(t){return M(t)?null:y(t).split(/(\s+)/).filter(t=>Yr(t)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Er(t){let i="";return zr(t)&&!Ur(t)&&t.childNodes&&t.childNodes.length&&Fn(t.childNodes,function(t){var e;yr(t)&&t.textContent&&(i+=null!==(e=kr(t.textContent))&&void 0!==e?e:"")}),y(i)}function Pr(t){var i;return I(t.target)?t.srcElement||null:(null===(i=t.target)||void 0===i?void 0:i.shadowRoot)?t.composedPath()[0]||null:t.target||null}const Tr=["a","button","form","input","select","textarea","label"];function Cr(t,i){const e=t.matches||t.matchesSelector||t.msMatchesSelector||t.mozMatchesSelector||t.webkitMatchesSelector||t.oMatchesSelector;try{return!!e&&e.call(t,i)}catch(t){return!1}}function Fr(t,i){if(I(i))return!0;for(const e of t)if(i.some(t=>Cr(e,t)))return!0;return!1}function Ir(t){const i=t.parentNode;return!(!i||!mr(i))&&i}const Or=[".ph-no-autocapture","[data-ph-no-autocapture]"],Rr=["next","previous","prev",">","<"],Ar=[...Rr,"+","-","−","–"],Mr=(t,i)=>/[a-z0-9]/i.test(i)?t.includes(i):t===i,Dr=[".ph-no-rageclick",".ph-no-capture"],jr=["","text","search","email","password","url","tel","number"];function Br(i,e){if(!t||Lr(i))return!1;let s,n,r;var o,l;if(B(e)?(s=!!e&&Dr,n=void 0,r=!1):(s=null!==(o=null==e?void 0:e.css_selector_ignorelist)&&void 0!==o?o:Dr,n=null==e?void 0:e.content_ignorelist,r=null!==(l=null==e?void 0:e.ignore_text_selection)&&void 0!==l&&l),!1===s)return!1;if(r&&function(t){return!(!t||!mr(t))&&(!!br(t,"textarea")||(br(t,"input")?b(jr,(t.getAttribute("type")||"").toLowerCase()):function(t){var i;if(t.isContentEditable)return!0;const e=null===(i=t.getAttribute)||void 0===i?void 0:i.call(t,"contenteditable");return"true"===e||""===e}(t)))}(i))return!1;const{targetElementList:a}=Nr(i,!1);return!function(t,i){if(!1===t||I(t))return!1;let e;if(!0===t)e=Rr;else{if(!P(t))return!1;if(t.length>10)return je.error("[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching."),!1;e=t.map(t=>t.toLowerCase())}return i.some(({safeText:t,ariaLabel:i})=>e.some(e=>Mr(t,e)||Mr(i,e)))}(n,a.map(t=>{var i;return{safeText:Er(t).toLowerCase(),ariaLabel:(null===(i=t.getAttribute("aria-label"))||void 0===i?void 0:i.toLowerCase().trim())||""}}))&&!Fr(a,s)}const Lr=t=>!t||br(t,"html")||!mr(t),Nr=(i,e)=>{if(!t||Lr(i))return{parentIsUsefulElement:!1,targetElementList:[]};let s=!1;const n=[i];let r=i;for(;r.parentNode&&!br(r,"body");){if(wr(r.parentNode)){n.push(r.parentNode.host),r=r.parentNode.host;continue}const i=Ir(r);if(!i)break;if(e||Tr.indexOf(i.tagName.toLowerCase())>-1)s=!0;else try{const e=t.getComputedStyle(i);e&&"pointer"===e.getPropertyValue("cursor")&&(s=!0)}catch(t){}n.push(i),r=i}return{parentIsUsefulElement:s,targetElementList:n}};function zr(t){const i=new Set;let e=0;for(let s=t;s.parentNode&&!br(s,"body");s=s.parentNode){if(e++>=1e3||i.has(s))return!1;i.add(s);const t=Sr(s);if(b(t,"ph-sensitive")||b(t,"ph-no-capture"))return!1}if(b(Sr(t),"ph-include"))return!0;const s=t.type||"";if(O(s))switch(s.toLowerCase()){case"hidden":case"password":return!1}const n=t.name||t.id||"";return!O(n)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(n.replace(/[^a-zA-Z0-9]/g,""))}function Ur(t){return!!(br(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||br(t,"select")||br(t,"textarea")||"true"===t.getAttribute("contenteditable"))}const Hr=new 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}))$"),qr=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,Vr=[16,15,14,13],Wr=new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),Gr=new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),Kr=/[0-9A-Za-z_]/;function Jr(t){let i=0,e=!1;for(let s=t.length-1;s>=0;s--){let n=t.charCodeAt(s)-48;e&&(n*=2,n>9&&(n-=9)),i+=n,e=!e}return i%10==0}function Yr(t,i=!0){if(M(t))return!1;if(O(t)){if(t=y(t),i?Hr.test((t||"").replace(/[- ]/g,"")):function(t){let i;for(qr.lastIndex=0;i=qr.exec(t);){const t=i[2];if(!t)continue;const e=t.replace(/[- ]/g,"");for(let t=0;e.length>t;t++)for(const i of Vr){const s=t+i;if(e.length>=s){const i=e.slice(t,s);if(Hr.test(i)&&Jr(i))return!0}}}return!1}(t))return!1;if(i?Wr.test(t):function(t){let i;for(Gr.lastIndex=0;i=Gr.exec(t);){const t=i[1],e=i[3];if(!(t&&e&&Kr.test(t)&&Kr.test(e)))return!0}return!1}(t))return!1}return!0}function Xr(t){let i=Er(t);return i=`${i} ${Zr(t)}`.trim(),Yr(i)?i:""}function Zr(t){let i="";return t&&t.childNodes&&t.childNodes.length&&Fn(t.childNodes,function(t){var e;if(t&&"span"===(null===(e=t.tagName)||void 0===e?void 0:e.toLowerCase()))try{const e=Er(t);i=`${i} ${e}`.trim(),t.childNodes&&t.childNodes.length&&(i=`${i} ${Zr(t)}`.trim())}catch(t){je.error("[AutoCapture]",t)}}),i}function Qr(t){return t.replace(/"|\\"/g,'\\"')}function to(t){const i=t.attr__class;if(i)return P(i)?i:$r(i)}const io=Be("[Dead Clicks]"),eo=()=>!0,so=t=>{var i;const e=!!(null===(i=t.instance.persistence)||void 0===i?void 0:i.get_property(os)),s=t.instance.config.capture_dead_clicks;return B(s)?s:!!C(s)||e};var no=class{get lazyLoadedDeadClicksAutocapture(){return this.Mo}constructor(t,i,e){this.instance=t,this.isEnabled=i,this.onCapture=e,this.startIfEnabledOrStop()}onRemoteConfig(t){if(!t.ok)return;const i=t.config;"captureDeadClicks"in i&&(this.instance.persistence&&this.instance.persistence.register({[os]:i.captureDeadClicks}),this.startIfEnabledOrStop())}startIfEnabledOrStop(){this.isEnabled(this)?this.Eo(()=>{this.Po()}):this.stop()}Eo(t){var i,e,s;(null===(i=c.__PosthogExtensions__)||void 0===i?void 0:i.initDeadClicksAutocapture)?t():null===(e=c.__PosthogExtensions__)||void 0===e||null===(s=e.loadExternalDependency)||void 0===s||s.call(e,this.instance,"dead-clicks-autocapture",i=>{i?io.error("failed to load script",i):t()})}Po(){var t;if(s){if(!this.Mo&&(null===(t=c.__PosthogExtensions__)||void 0===t?void 0:t.initDeadClicksAutocapture)){const t=C(this.instance.config.capture_dead_clicks)?wi({},this.instance.config.capture_dead_clicks):{};t.__onCapture=this.onCapture,this.onCapture&&(t.capture_dead_swipes=!1),this.Mo=c.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this.Mo.start(s),io.info("starting...")}}else io.error("`document` not found. Cannot start.")}stop(){this.Mo&&(this.Mo.stop(),this.Mo=void 0,io.info("stopping..."))}};const ro=Be("[SegmentIntegration]");function oo(t,i,e=!0){const s=t.config.segment;if(!s)return i();const{analytics:n,filterProperties:r}=(t=>T(t.register))(o=s)?{analytics:o}:o;var o;!function(t,i,e,s){const n=i=>{const n=()=>i.anonymousId()||Gn();t.config.get_device_id=n,s&&i.id()&&(t.register({distinct_id:i.id(),$device_id:n()}),t.persistence.set_property(Zs,wn)),e(s?void 0:i.anonymousId()||void 0)},r=i.user();"then"in r&&T(r.then)?r.then(n):n(r)}(t,n,e=>{n.register(((t,i,{filterProperties:e}={})=>{"undefined"!=typeof Promise&&Promise.resolve||ro.warn("This browser does not have Promise support, and can not use the segment integration");const s=(s,n)=>{if(!n)return s;const r=!!i&&s.event.anonymousId===i&&!s.event.userId;r||s.event.userId||s.event.anonymousId===t.get_distinct_id()||(ro.info("No userId set, resetting PostHog"),t.reset()),r||(i=void 0),s.event.userId&&s.event.userId!==t.get_distinct_id()&&(ro.info("UserId set, identifying with PostHog"),t.identify(s.event.userId));let o=t.calculateEventProperties(n,s.event.properties);if(!M(e)){const t=s.event.properties||{},i={};for(const e of Object.keys(o))k.call(t,e)||(i[e]=o[e]);const n=((t,i)=>{const e=P(t)?t:[t];let s=wi({},i);for(const t of e)try{if(s=t(s),M(s))return null}catch(t){return ro.error("Error in Segment filterProperties:",t),null}return s})(e,i);if(M(n))return s;o=n}return s.event.properties=Object.assign({},o,s.event.properties),s};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded(){return!0},load(){return Promise.resolve()},track(t){return s(t,t.event.event)},page(t){return s(t,kn)},identify(t){return s(t,Pn)},screen(t){return s(t,"$screen")}}})(t,e,{filterProperties:r})).then(()=>{i()},t=>{ro.error("Failed to register the Segment integration",t),i()})},e)}const lo="posthog-js";function ao(t,{organization:i,projectId:e,prefix:s,severityAllowList:n=["error"],sendExceptionsToPostHog:r=!0}={}){return o=>{var l,a,u,h,d;if("*"!==n&&!n.includes(o.level)||!t.__loaded)return o;o.tags||(o.tags={});const c=t.requestRouter.endpointFor("ui",`/project/${t.config.token}/person/${t.get_distinct_id()}`);o.tags["PostHog Person URL"]=c,t.sessionRecordingStarted()&&(o.tags["PostHog Recording URL"]=t.get_session_replay_url({withTimestamp:!0}));const v=(null===(l=o.exception)||void 0===l?void 0:l.values)||[],f=v.map(t=>wi(wi({},t),{},{stacktrace:t.stacktrace?wi(wi({},t.stacktrace),{},{type:"raw",frames:(t.stacktrace.frames||[]).map(t=>wi(wi({},t),{},{platform:"web:javascript"}))}):void 0})),p={$exception_message:(null===(a=v[0])||void 0===a?void 0:a.value)||o.message,$exception_type:null===(u=v[0])||void 0===u?void 0:u.type,$exception_level:o.level,$exception_list:f,$sentry_event_id:o.event_id,$sentry_exception:o.exception,$sentry_exception_message:(null===(h=v[0])||void 0===h?void 0:h.value)||o.message,$sentry_exception_type:null===(d=v[0])||void 0===d?void 0:d.type,$sentry_tags:o.tags};var g;return i&&e&&(p.$sentry_url=(s||"https://sentry.io/organizations/")+i+"/issues/?project="+e+"&query="+o.event_id),r&&(null===(g=t.exceptions)||void 0===g||g.sendExceptionEvent(p)),o}}var uo=class{constructor(t,i,e,s,n,r){this.name=lo,this.setupOnce=function(o){o(ao(t,{organization:i,projectId:e,prefix:s,severityAllowList:n,sendExceptionsToPostHog:null==r||r}))}}},ho=class{constructor(t){this.Ro=(t,i,e)=>{e&&(e.noSessionId||e.activityTimeout||e.sessionPastMaximumLength||e.crossTabAdoption)&&(je.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:t,changeReason:e}),this.Ao=void 0,this._instance.scrollManager.resetContext())},this._instance=t,this.Fo()}Fo(){var t;this.Oo=null===(t=this._instance.sessionManager)||void 0===t?void 0:t.onSessionId(this.Ro)}destroy(){var t;null===(t=this.Oo)||void 0===t||t.call(this),this.Oo=void 0}doPageView(i,e){var s;const n=this.Do(i,e);return this.Ao={pathname:null!==(s=null==t?void 0:t.location.pathname)&&void 0!==s?s:"",pageViewId:e,timestamp:i},this._instance.scrollManager.resetContext(),n}doPageLeave(t){var i;return this.Do(t,null===(i=this.Ao)||void 0===i?void 0:i.pageViewId)}doEvent(){var t;return{$pageview_id:null===(t=this.Ao)||void 0===t?void 0:t.pageViewId}}Do(t,i){const e=this.Ao;if(!e)return{$pageview_id:i};let s={$pageview_id:i,$prev_pageview_id:e.pageViewId};const n=this._instance.scrollManager.getContext();if(n&&!this._instance.config.disable_scroll_properties){let{maxScrollHeight:t,lastScrollY:i,maxScrollY:e,maxContentHeight:r,lastContentY:o,maxContentY:l}=n;if(!(I(t)||I(i)||I(e)||I(r)||I(o)||I(l))){t=Math.ceil(t),i=Math.ceil(i),e=Math.ceil(e),r=Math.ceil(r),o=Math.ceil(o),l=Math.ceil(l);const n=t>1?Q(i/t,0,1,je):1,a=t>1?Q(e/t,0,1,je):1,u=r>1?Q(o/r,0,1,je):1,h=r>1?Q(l/r,0,1,je):1;s=In(s,{$prev_pageview_last_scroll:i,$prev_pageview_last_scroll_percentage:n,$prev_pageview_max_scroll:e,$prev_pageview_max_scroll_percentage:a,$prev_pageview_last_content:o,$prev_pageview_last_content_percentage:u,$prev_pageview_max_content:l,$prev_pageview_max_content_percentage:h})}}return e.pathname&&(s.$prev_pageview_pathname=e.pathname),e.timestamp&&(s.$prev_pageview_duration=(t.getTime()-e.timestamp.getTime())/1e3),s}};const co=["flags","surveys"],vo={[Ve]:{exposure:"hidden"},[Je]:{exposure:"hidden"},[Ye]:{exposure:"hidden"},[Qe]:{exposure:"hidden"},[Ze]:{exposure:"hidden"},[ts]:{exposure:"event"},[is]:{exposure:"hidden"},[as]:{exposure:"hidden"},[es]:{exposure:"event"},[ss]:{exposure:"hidden"},[ns]:{exposure:"event"},[rs]:{exposure:"event"},[os]:{exposure:"event"},[ls]:{exposure:"hidden"},[us]:{exposure:"event"},[hs]:{exposure:"hidden"},[ds]:{exposure:"hidden"},[_s]:{exposure:"hidden"},[ms]:{exposure:"event"},[cs]:{exposure:"event",shouldSkipFromEventProperties:t=>A(t)},[bs]:{exposure:"event"},[ys]:{exposure:"event"},[ws]:{exposure:"event"},[$s]:{exposure:"event"},[xs]:{exposure:"hidden"},[Ss]:{exposure:"hidden",storageGroup:"flags"},[ks]:{exposure:"hidden",storageGroup:"flags"},[Es]:{exposure:"hidden"},[Ps]:{exposure:"hidden",storageGroup:"flags"},[Ts]:{exposure:"hidden",storageGroup:"flags"},[Cs]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[Fs]:{exposure:"hidden",storageGroup:"flags"},[Is]:{exposure:"hidden"},[Os]:{exposure:"hidden"},[Rs]:{exposure:"hidden"},[As]:{exposure:"hidden"},[Ds]:{exposure:"hidden",storageGroup:"surveys"},[js]:{exposure:"hidden",storageGroup:"surveys",volatile:!0},[Bs]:{exposure:"event"},[Ls]:{exposure:"hidden"},[Ns]:{exposure:"hidden"},[zs]:{exposure:"hidden"},[Us]:{exposure:"hidden"},[Hs]:{exposure:"hidden"},[qs]:{exposure:"event"},[Vs]:{exposure:"event"},[Ws]:{exposure:"event"},[Gs]:{exposure:"event"},[Ks]:{exposure:"hidden"},[Js]:{exposure:"hidden"},[Ms]:{exposure:"event"},[Ys]:{exposure:"hidden"},[Xs]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[Zs]:{exposure:"hidden"},[Qs]:{exposure:"hidden"},[tn]:{exposure:"hidden"},[en]:{exposure:"hidden"},[sn]:{exposure:"hidden"},[nn]:{exposure:"hidden"},[rn]:{exposure:"hidden"},[vs]:{exposure:"event"},[fs]:{exposure:"event"},[ps]:{exposure:"event"},[gs]:{exposure:"event"},[an]:{exposure:"event"},[un]:{exposure:"event"},[hn]:{exposure:"event"},[dn]:{exposure:"event"},[cn]:{exposure:"event"},[vn]:{exposure:"event"},[fn]:{exposure:"event"},[pn]:{exposure:"event"},[gn]:{exposure:"event"},[_n]:{exposure:"event"},[mn]:{exposure:"event"}},fo=[["$posthog_sr_group_event_trigger_",{exposure:"hidden"}],["$posthog_sr_group_url_trigger_",{exposure:"hidden"}],["$posthog_sr_group_sampling_",{exposure:"hidden"}]],po=t=>{const i=vo[t];if(i)return i;for(const[i,e]of fo)if(0===t.indexOf(i))return e},go=(t,i)=>{try{let e;return JSON.stringify(t,(t,i)=>{var s;return H(i)?(null!==(s=e)&&void 0!==s||(e=new WeakMap),e.has(i)||e.set(i,Dn(i)),e.get(i)):"bigint"==typeof i?i.toString():i},i)}catch(i){return x(t)}},_o=t=>{const i=null==s?void 0:s.createElement("a");return I(i)?null:(i.href=t,i)},mo=function(t,i){const e=((t.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&");let s;for(let t=0;e.length>t;t++){const n=e[t].split("=");if(n[0]===i){s=n;break}}if(!P(s)||2>s.length)return"";{let t=s[1];try{t=decodeURIComponent(t)}catch(i){je.error("Skipping decoding for malformed query param: "+t)}return t.replace(/\+/g," ")}},bo=function(t,i,e){if(!t||!i||!i.length)return t;const s=t.split("#"),n=s[1],r=(s[0]||"").split("?"),o=r[1],l=r[0],a=(o||"").split("&"),u=[];for(let t=0;a.length>t;t++){const s=a[t].split("=");P(s)&&(i.includes(s[0])?u.push(s[0]+"="+e):u.push(a[t]))}let h=l;return null!=o&&(h+="?"+u.join("&")),null!=n&&(h+="#"+n),h},yo=function(t,i){const e=t.match(new RegExp(i+"=([^&]*)"));return e?e[1]:null},wo=(t,i)=>t>=i&&h(),$o=(t,i,e,s)=>{if(0===t){if(h()){const t=i+1;return t===e&&s(),t}return i}return 0},xo=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],So=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...xo],ko="<masked>",Eo=["li_fat_id"];function Po(t,i,e){if(!s)return{};const n=i?[...xo,...e||[]]:[],r=To(bo(s.URL,n,ko),t),o=function(){const t={};return Fn(Eo,function(i){const e=zn(i);t[i]=e||null}),t}();return In(o,r)}function To(t,i){const e=So.concat(i||[]),s={};return Fn(e,function(i){const e=mo(t,i);s[i]=e||null}),s}function Co(t){const i=function(t){return t?0===t.search("https?://(.*)google.([^/?]*)")?"google":0===t.search("https?://(.*)bing.com")?"bing":0===t.search("https?://(.*)yahoo.com")?"yahoo":0===t.search("https?://(.*)duckduckgo.com")?"duckduckgo":null:null}(t),e="yahoo"!=i?"q":"p",n={};if(!A(i)){n.$search_engine=i;const t=s?mo(s.referrer,e):"";t.length&&(n.ph_keyword=t)}return n}function Fo(){return navigator.language||navigator.userLanguage}function Io(){const t=Fo();return"string"==typeof t?t.split("-")[0]:void 0}const Oo="$direct";function Ro(){return(null==s?void 0:s.referrer)||Oo}function Ao(t,i,e=!1){const s=t?[...xo,...i||[]]:[],r=e?hi(null==n?void 0:n.href):null==n?void 0:n.href,o=null==r?void 0:r.substring(0,1e3);return{r:Ro().substring(0,1e3),u:o?bo(o,s,ko):void 0}}function Mo(t,i=!1){var e;const{r:s,u:n}=t,r=i?hi(n):n,o={$referrer:s,$referring_domain:null==s?void 0:s==Oo?Oo:null===(e=_o(s))||void 0===e?void 0:e.host};if(r){o.$current_url=r;const t=_o(r);o.$host=null==t?void 0:t.host,o.$pathname=null==t?void 0:t.pathname;const i=To(r);In(o,i)}if(s){const t=Co(s);In(o,t)}return o}function Do(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(t){return}}function jo(){try{return(new Date).getTimezoneOffset()}catch(t){return}}const Bo={flags:Xs,surveys:js},Lo=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],No=t=>`${t}_cookie_identity_change_pending`,zo=t=>{let i="",e=0;for(const s of t){const t=encodeURIComponent(JSON.stringify(s).slice(1,-1)).length;if(e+t>1e3)break;i+=s,e+=t}return i},Uo="main",Ho=[Ss,ks,Ps,Ts,Cs,Xs,Fs,Rs],qo=t=>-1!==Ho.indexOf(t),Vo=(t,i)=>{try{return JSON.stringify(t)===JSON.stringify(i)}catch(e){return t===i}},Wo=t=>{if(!t)return{};const i=JSON.parse(t);return C(i)?i:{}},Go=(t,i)=>{Fn(t,(e,s)=>{const n=po(s);n&&"event"!==n.exposure||{}.hasOwnProperty.call(i,s)||delete t[s]})};var Ko=class{constructor(i,e,s=!0){if(this.Lo={},this.No=!1,this.qo=!1,this.jo=!1,this.Bo=!1,this.Ho=!1,this.zo=new Map,this.Uo=!1,this.Wo=!1,this.Vo=!1,this.Go=!1,this.Zo=new Set,this.Sr=i,this.Qo=s,this.props={},this.Jo=void 0,this.Ko=(t=>{let i="";return t.token&&(i=t.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),t.persistence_name?"ph_"+t.persistence_name:"ph_"+i+"_posthog"})(i),this.$o=this.Yo(i),this.jo=this.Xo(i),this.load(),this.tl(),i.debug&&je.info("Persistence loaded",i.persistence,wi({},this.props)),this.update_config(i,i,e),this.save(),t){const i=()=>this.flush();Ln(t,"beforeunload",i,{capture:!1}),Ln(t,"pagehide",i,{capture:!1}),this.el=i=>{if(this.No&&(!i.storageArea||i.storageArea===(null==t?void 0:t.localStorage))&&i.key)if(i.key!==this.Ko){if(this.jo){const t=co.find(t=>i.key===this.il(t));t&&this.nl(i.key,t)}}else this.nl(i.key,Uo)},Ln(t,"storage",this.el)}}markCrossTabFeatureFlagChanges(t){Object.entries(t).forEach(([t,i])=>{const e=this.zo.get(t);if(!qo(t)||!0===e)return;if(!0===i)return void this.sl(t,!0);const s=new Set(e||[]);i.forEach(t=>s.add(t)),s.size&&this.sl(t,s)})}onCrossTabFeatureFlagChange(t){return this.Zo.add(t),()=>this.Zo.delete(t)}destroy(){this.el&&t&&(t.removeEventListener("storage",this.el),this.el=void 0),this.Zo.clear()}nl(t,i,e=!0){if(this.pi)return!1;let s,n;try{if(n=tr.Ot(t),A(n)){const t=this.rl(i);return t.storageValue=null,i!==Uo&&(t.persisted=!1),!1}s=Wo(n)}catch(t){return!1}const r=i===Uo?s:tr.Dt(this.Ko);if(r&&this.ol(r))return!1;const o=this.ll(s,i,e);return i===Uo&&this.jo&&!Vo(this.al().main,s)||this.ul(s,i,!0,n),o}ol(t){const i=this.props[We],e=t[We];return!I(i)&&!I(e)&&i!==e}ul(t,i,e,s){const n=this.rl(i);n.storageValue=s,i!==Uo&&(n.persisted=e);try{n.fingerprint=this.hl(t,i)}catch(t){n.fingerprint=void 0}}ll(t,i,e){let s=!1;return Ho.forEach(e=>{var n;const r=null===(n=po(e))||void 0===n?void 0:n.storageGroup;if(i===Uo&&this.jo&&r||i!==Uo&&r!==i)return;const o=e in t,l=this.cl(e,o?t[e]:void 0),a=this.zo.has(e)?e in this.props:o;a===e in this.props&&Vo(l,this.props[e])||(a?this.dl(e,l,!1):this.vl(e,!1),s=!0)}),s&&e&&this.Zo.forEach(t=>t()),s}fl(){if(!this.No)return!1;try{this.Vo=!1;const t=tr.Ot(this.Ko),i=this.rl(Uo);let e,s=!1,n=!1;if(t!==i.storageValue)if(A(t))i.storageValue=null;else{if(e=Wo(t),this.Vo=!this.Wo&&this.ol(e),this.Vo)return!1;n=this.ll(e,Uo,!1),!this.jo||Vo(this.al().main,e)?this.ul(e,Uo,!0,t):i.storageValue=t,s=!0}return this.jo&&co.forEach(t=>{const i=tr.Ot(this.il(t)),r=this.rl(t),o=e||{},l=s&&Ho.some(i=>{var e;return(null===(e=po(i))||void 0===e?void 0:e.storageGroup)===t&&i in o});if(i===r.storageValue&&!l)return;if(A(i))return r.storageValue=null,r.persisted=!1,void(l&&(n=this.ll(o,t,!1)||n));const a=Wo(i);n=this.ll(a,t,!1)||n,this.ul(a,t,!0,i)}),n}catch(t){return!1}}sl(t,i){this.zo.set(t,i);const e=po(t);(null==e?void 0:e.volatile)||(this.rl((this.jo?null==e?void 0:e.storageGroup:void 0)||Uo).fingerprint=void 0,this.pl(t))}gl(){Ho.forEach(t=>this.zo.set(t,!0))}tl(){if(this.No)try{const t=tr.Ot(this.Ko),i=Wo(t);this.rl(Uo).storageValue=t,Ho.forEach(t=>{var e;const s=this.jo?null===(e=po(t))||void 0===e?void 0:e.storageGroup:void 0,n=s?tr.Ot(this.il(s)):null;if(s){const t=this.rl(s);t.storageValue=n,t.persisted=!A(n)}const r=s&&!A(n)?Wo(n):i;t in this.props?this.ml(t,r[t],this.props[t]):t in r&&this.sl(t,!0)})}catch(t){}}cl(t,i){const e=this.zo.get(t);if(!e)return i;if(!0===e)return this.props[t];if("$active_feature_flags"===t){const s=new Set(P(i)?i:[]),n=new Set(P(this.props[t])?this.props[t]:[]);return e.forEach(t=>n.has(t)?s.add(t):s.delete(t)),Array.from(s)}const s=C(i)?wi({},i):{},n=C(this.props[t])?this.props[t]:{};return e.forEach(t=>{t in n?s[t]=n[t]:delete s[t]}),s}ml(t,i,e){if(!qo(t))return;const s=this.zo.get(t);if(!0===s)return;let n=i;if(this.No)try{var r;const i=this.jo?null===(r=po(t))||void 0===r?void 0:r.storageGroup:void 0,e=i?this.il(i):this.Ko;n=Wo(tr.Ot(e))[t]}catch(t){}const o=new Set(s||[]);if("$active_feature_flags"===t){if(!I(i)&&!P(i)||!I(n)&&!P(n)||!P(e))return void this.sl(t,!0);const s=new Set(i||[]),r=new Set(n||[]),l=new Set(e);new Set([...s,...l]).forEach(t=>{s.has(t)!==l.has(t)&&o.add(t)}),o.forEach(t=>{r.has(t)===l.has(t)&&o.delete(t)})}else{if(!C(e))return void(Vo(n,e)?this.zo.delete(t):this.sl(t,!0));{if(!I(i)&&!C(i)||I(i)&&F(e)&&I(n))return void this.sl(t,!0);const s=C(i)?i:{},r=C(n)?n:{};new Set([...Object.keys(s),...Object.keys(e)]).forEach(t=>{t in s==t in e&&Vo(s[t],e[t])||o.add(t)}),o.forEach(t=>{t in r==t in e&&Vo(r[t],e[t])&&o.delete(t)})}}o.size?this.sl(t,o):this.zo.delete(t)}yl(){var t;const i=null===(t=this.Sr)||void 0===t?void 0:t.persistence_save_debounce_ms;return D(i)&&i>0?i:0}bl(t){if(this.Sr.cookieWinsOnConflict&&"localstorage+cookie"===this.Sr.persistence.toLowerCase())if(t)try{const i=or(t,this.Sr.cookie_persisted_properties||[]),e=ar(i,this.Sr.cookie_persisted_properties||[]),s=JSON.stringify(i)+"|"+JSON.stringify(e),n=Zn.Ot(this.Ko)||void 0;n&&hr(this.Ko,n)===s&&(this._l=s,this.wl=n)}catch(t){}else try{const t=Zn.Ot(this.Ko)||void 0;this._l=t?hr(this.Ko,t):void 0,this.wl=t}catch(t){}}syncCookieProperties(){return this.kl(this.Sr)}kl(t,i=!1){if(this.pi&&!i||this.Ho||!t.cookieWinsOnConflict||"localstorage+cookie"!==t.persistence.toLowerCase())return!1;let e;try{e=Zn.Ot(this.Ko)||void 0}catch(t){}if(!e||e===this.wl)return!1;const s=hr(this.Ko,e);let n;try{n=rr(JSON.parse(e))}catch(t){return!1}if((Zn.Ot(this.Ko)||void 0)!==e)return!1;this._l=s,this.wl=e;const r=ur(this.Ko,e),o=[...er,...r.properties],l={};if(Object.keys(n).forEach(t=>{const i=n[t];(I(i)||A(i)||""===i||"$user_state"===t&&"anonymous"!==i&&"identified"!==i)&&(l[t]=!0,delete n[t])}),F(n))return!1;const a="distinct_id"in n||"anonymous"===n.$user_state||"identified"===n.$user_state,u=this.props,h=u[We],d=u[Zs],c=In({},u);[...er,...t.cookie_persisted_properties||[]].forEach(t=>{if(-1!==o.indexOf(t)&&!(t in n)&&!l[t]&&(a||"distinct_id"!==t&&"$user_state"!==t)){const i=c[t];(r.isValid||-1===er.indexOf(t)||!1!==i&&0!==i)&&delete c[t]}}),this.props=In(c,n),Ho.forEach(t=>{const i=t in this.props;t in u===i&&Vo(u[t],this.props[t])||(i?this.ml(t,u[t],this.props[t]):this.sl(t,!0))}),!a||"$user_state"in n||"$user_state"in this.props||this.dl(Zs,yn);const v=this.props[We],f=this.props[Zs];return!a||v===h&&f===d||(this.Wo=!0,this.Bo=!0,fr.At(No(this.Ko),!0),this.vl(Rs),this.vl(ks),this.vl(Ss),this.vl(Ps),this.vl(Ts),this.vl(Cs),this.vl(Xs),this.vl(Ys),this.vl(Ks),"anonymous"!==f||"identified"!==d&&"anonymous"!==n.$user_state&&(I(h)||v===h)||(Go(this.props,n),this.vl(As)),"identified"===f?this.props.$user_id=v:delete this.props.$user_id,this.vl(Je)),!0}consumeCookieIdentityChange(){const t=No(this.Ko),i=this.Bo||!!fr.Ot(t);return this.Bo=!1,i&&fr.Lt(t),i}Sl(t=!1){return!(this.Ho||this.pi&&!t||!this.Sr.cookieWinsOnConflict||"localstorage+cookie"!==this.Sr.persistence.toLowerCase()||(this.Ho=!0,0))}xl(){this.Ho&&(I(this.Cl)||(clearTimeout(this.Cl),this.Cl=void 0),delete this.Lo[Uo],this.$l(!0))}Tl(t=!0){if(this.Ho)try{t?this.xl():I(this.Cl)||(clearTimeout(this.Cl),this.Cl=void 0)}finally{this.Ho=!1}}isDisabled(){return!!this.pi}Yo(i){-1===Lo.indexOf(i.persistence.toLowerCase())&&(je.critical("Unknown persistence type "+i.persistence+"; falling back to localStorage+cookie"),i.persistence="localStorage+cookie");const e=((i=[],e=!1)=>{const s=[...er,...i];return wi(wi({},tr),{},{Dt(t){try{let n,r={};try{n=Zn.Ot(t)||void 0,r=n?rr(JSON.parse(n)):{}}catch(t){}const o=JSON.parse(tr.Ot(t)||"{}");let l;if(e){const e=ur(t,n),a=[...er,...e.properties],u={};Object.keys(r).forEach(t=>{const i=r[t];A(i)||""===i||"$user_state"===t&&"anonymous"!==i&&"identified"!==i||(u[t]=i)});const h="distinct_id"in u||"anonymous"===u.$user_state||"identified"===u.$user_state;if(Object.keys(u).length>0){var i;const t=o[We],n=null!==(i=o.$user_state)&&void 0!==i?i:yn;s.forEach(t=>{if(-1!==a.indexOf(t)&&!(t in r)&&(h||"distinct_id"!==t&&"$user_state"!==t)){const i=o[t];(e.isValid||-1===er.indexOf(t)||!1!==i&&0!==i)&&delete o[t]}}),!h||"$user_state"in r||"$user_state"in o||(o[Zs]=yn),!h||("distinct_id"in u?u[We]:o[We])===t&&("$user_state"in u?u[Zs]:o[Zs])===n||(ir.forEach(t=>delete o[t]),"identified"===u.$user_state&&"distinct_id"in u?o.$user_id=u[We]:delete o.$user_id,"identified"!==u.$user_state&&(delete o[Ms],delete o[As]),delete o.__alias)}l=In(o,u)}else l=In(r,o);return tr.At(t,l),l}catch(t){}return null},At(t,s,n,r,o,l){const a=tr.At(t,s,void 0,void 0,l);try{const u=or(s,i);if(Object.keys(u).length){if(e){const e=sr(t),h=ar(u,i);if(Zn.At(e,h,n,r,o,l),Zn.Ot(e)!==JSON.stringify(h)){Zn.Lt(e,r);const i=or(s);return Zn.At(t,i,n,r,o,l),a}}Zn.At(t,u,n,r,o,l)}}catch(t){tr.Pt(t)}return a},Lt(i,e){try{null==t||t.localStorage.removeItem(i),Zn.Lt(i,e),Zn.Lt(sr(i),e)}catch(t){tr.Pt(t)}}})})(i.cookie_persisted_properties||[],i.cookieWinsOnConflict);let s,n=!1,r=!1;const o=i.persistence.toLowerCase();return"localstorage"===o&&tr.Et()?(s=tr,r=!0):"localstorage+cookie"===o&&e.Et()?(s=e,r=!0,n=!0):"sessionstorage"===o&&fr.Et()?s=fr:"memory"===o?s=cr:"cookie"===o&&Zn.Et()?(s=Zn,n=!0):e.Et()?(s=e,r=!0,n=!0):Zn.Et()?(s=Zn,n=!0):s=cr,this.No=r,this.qo=n,s}il(t){return`${this.Ko}__${t}`}Xo(t){return this.No&&!!t.split_storage}properties(){const t={};return Fn(this.props,(i,e)=>{const s=po(e);if(!s||"event"===s.exposure){var n;if(null==s||null===(n=s.shouldSkipFromEventProperties)||void 0===n?void 0:n.call(s,i))return;t[e]=i}}),t}load(t=!1){if(this.pi&&!t)return;const i=this.Sr.cookieWinsOnConflict&&"localstorage+cookie"===this.Sr.persistence.toLowerCase(),e=i?tr.Dt(this.Ko):null;let s={};if(i)try{s=rr(Zn.Dt(this.Ko)),Fn(s,(t,i)=>{(I(t)||A(t)||""===t)&&delete s[i]})}catch(t){}const n=this.$o.Dt(this.Ko);if(n&&(this.props=In({},n)),this.jo&&this.Il(),i&&n){var r,o;const t=null==e?void 0:e[We],i=null!==(r=null==e?void 0:e.$user_state)&&void 0!==r?r:yn,l=n[We],a=null!==(o=n.$user_state)&&void 0!==o?o:yn;if(l!==t||a!==i){this.Bo=!0,fr.At(No(this.Ko),!0);const e=In({},this.props);ir.forEach(t=>delete e[t]),"anonymous"!==a||"identified"!==i&&"anonymous"!==s.$user_state&&(I(t)||l===t)||(Go(e,s),delete e[As]),this.props=e;const n=new Set;ir.forEach(t=>{var i;const e=null===(i=po(t))||void 0===i?void 0:i.storageGroup;e&&n.add(e)}),n.forEach(t=>{const i={};Fn(this.props,(e,s)=>{var n;(null===(n=po(s))||void 0===n?void 0:n.storageGroup)===t&&(i[s]=e)}),F(i)?(tr.Lt(this.il(t)),this.Lo[t]={}):tr.At(this.il(t),i)&&(this.Lo[t]={persisted:!0,fingerprint:this.hl(i,t)})})}}fr.Ot(No(this.Ko))&&(this.Bo=!0)}Il(){for(const t of co){const i=tr.Dt(this.il(t));if(i&&!F(i)){const e=this.rl(t);e.persisted=!0,this.Ml(t)||(e.fingerprint=this.hl(i,t)),this.El(t,i)||In(this.props,i)}}}Ml(t){return Object.keys(this.props).some(i=>{var e;return(null===(e=po(i))||void 0===e?void 0:e.storageGroup)===t})}El(t,i){const e=Bo[t];if(!e)return!1;const s=i[e],n=this.props[e];return D(s)&&D(n)&&n>s}refreshKey(t){var i;if(this.pi)return;if("$fbc_persistence"===t&&this.Go)return;const e=this.jo?null===(i=po(t))||void 0===i?void 0:i.storageGroup:void 0,s=e?tr.Dt(this.il(e)):this.$o.Dt(this.Ko);if(s&&t in s)this.dl(t,s[t],!1);else{if(e){const i=this.$o.Dt(this.Ko);if(i&&t in i)return void this.dl(t,i[t],!1)}this.vl(t,!1)}}save(){if(this.pi)return;const t=this.yl();t>0?I(this.Cl)&&(this.Cl=setTimeout(()=>{this.Cl=void 0,this.$l()},t)):this.$l()}flush(){I(this.Cl)||(clearTimeout(this.Cl),this.Cl=void 0,this.$l())}$l(t=!1){if(this.pi||this.Ho&&!t)return;t||(this.syncCookieProperties(),this.Go||this.Sr.cookieWinsOnConflict&&"localstorage+cookie"===this.Sr.persistence.toLowerCase()||this.refreshKey(Ze));const i=!t&&!this.Uo;i||(this.Vo=!1);const e=!!i&&this.fl();if(this.Vo)return void(this.Sr.debug&&je.warn("skipping persistence write because storage belongs to a different distinct ID"));if(this.jo)return this.Pl(),void(e&&this.Zo.forEach(t=>t()));const s=this.Rl(this.$o,this.Ko,this.props,Uo);"written"===s&&this.bl(this.props),"failed"!==s&&(this.zo.clear(),this.Wo=!1,this.Go=!1),e&&this.Zo.forEach(t=>t())}Pl(){const{main:t,groups:i}=this.al(),e=this.Rl(this.$o,this.Ko,t,Uo);"written"===e&&this.bl(t),"failed"!==e&&(this.Wo=!1,this.Go=!1,Ho.forEach(t=>{var i;(null===(i=po(t))||void 0===i?void 0:i.storageGroup)||this.zo.delete(t)}));for(const t of co){var s;const e=i[t];if(F(e)&&!(null===(s=this.Lo[t])||void 0===s?void 0:s.persisted)){Ho.forEach(i=>{var e;(null===(e=po(i))||void 0===e?void 0:e.storageGroup)===t&&this.zo.delete(i)});continue}const n=this.Rl(tr,this.il(t),e,t);"failed"!==n&&Ho.forEach(i=>{const e=po(i);(null==e?void 0:e.storageGroup)!==t||"written"!==n&&e.volatile||this.zo.delete(i)})}}al(){const t={},i={flags:{},surveys:{}};return Fn(this.props,(e,s)=>{var n;const r=null===(n=po(s))||void 0===n?void 0:n.storageGroup;r?i[r][s]=e:t[s]=e}),{main:t,groups:i}}hl(t,i){if(i===Uo)return JSON.stringify(t)+"|"+this.Al+"|"+this.Fl+"|"+this.Ol;const e={};return Fn(t,(t,i)=>{var s;e[i]=(null===(s=po(i))||void 0===s?void 0:s.volatile)?"__volatile__":t}),JSON.stringify(e)}Rl(t,i,e,s){const n=this.rl(s);if(s!==Uo&&!n.dirty&&!I(n.fingerprint))return"skipped";let r;try{if(r=this.hl(e,s),r===n.fingerprint)return n.dirty=!1,"skipped"}catch(t){r=void 0}return t.At(i,e,this.Al,this.Fl,this.Ol,this.Sr.debug)?(n.dirty=!1,s!==Uo&&(n.persisted=!0),I(r)||(n.fingerprint=r),this.No&&(n.storageValue=tr.Ot(i)),"written"):(this.Sr.debug&&je.warn(`failed to persist storage entry "${i}"; will retry on next save`),"failed")}remove({keepGroupEntries:t=!1}={}){if(this.gl(),I(this.Cl)||(clearTimeout(this.Cl),this.Cl=void 0),this.$o.Lt(this.Ko,!1),this.$o.Lt(this.Ko,!0),!t&&this.Qo)for(const t of co)tr.Lt(this.il(t));t?delete this.Lo[Uo]:this.Lo={},this._l=void 0,this.wl=void 0}clear(){this.remove(),this.props={}}register_once(t,i,e){if(C(t)){this.syncCookieProperties(),I(i)&&(i="None"),this.Al=I(e)?this.Dl:e;let s=!1;if(Fn(t,(t,e)=>{this.props.hasOwnProperty(e)&&this.props[e]!==i||(this.dl(e,t),s=!0)}),s)return this.save(),!0}return!1}register(t,i){if(C(t)){this.syncCookieProperties(),this.Al=I(i)?this.Dl:i;let e=!1;if(Fn(t,(i,s)=>{t.hasOwnProperty(s)&&(this.props[s]!==i||C(i)||P(i))&&(this.dl(s,i),e=!0)}),e)return this.save(),!0}return!1}unregister(t){this.syncCookieProperties();const i="string"==typeof t?[t]:t;let e=!1;for(const t of i)t in this.props&&(this.vl(t),e=!0);e&&this.save()}update_campaign_params(){const t=null==s?void 0:s.URL;if(t===this.Jo)return;const i=Po(this.Sr.custom_campaign_params,this.Sr.mask_personal_data_properties,this.Sr.custom_personal_data_properties),e=!F(Mn(i));return e&&this.register(i),this.Jo=t,e?i:void 0}update_search_keyword(){this.register(function(){const t=null==s?void 0:s.referrer;return t?Co(t):{}}())}update_referrer_info(){var t;this.register_once({$referrer:Ro(),$referring_domain:(null==s?void 0:s.referrer)&&(null===(t=_o(s.referrer))||void 0===t?void 0:t.host)||Oo},void 0)}set_initial_person_info(){if(this.props.$initial_campaign_params||this.props.$initial_referrer_info)return;const t=Ao(this.Sr.mask_personal_data_properties,this.Sr.custom_personal_data_properties,this.Sr.disable_capture_url_hashes);this.register_once({[nn]:this.qo?{r:zo(t.r),u:t.u?zo(t.u):void 0}:t},void 0)}get_initial_props(){const t={};Fn([sn,en],i=>{const e=this.props[i];e&&Fn(e,function(i,e){t["$initial_"+w(e)]=i})});const i=this.props[nn];if(i){const e=function(t,i=!1){const e=Mo(t,i),s={};return Fn(e,function(t,i){s[`$initial_${w(i)}`]=t}),s}(i,this.Sr.disable_capture_url_hashes);In(t,e)}return t}safe_merge(t){return Fn(this.props,function(i,e){e in t||(t[e]=i)}),t}update_config(t,i,e){const s=t.persistence!==i.persistence,n=!((t,i)=>{if(t.length!==i.length)return!1;const e=[...t].sort(),s=[...i].sort();return e.every((t,i)=>t===s[i])})(t.cookie_persisted_properties||[],i.cookie_persisted_properties||[]),r=s||n,o=t.cookieWinsOnConflict!==i.cookieWinsOnConflict,l=t.disable_persistence||!!e,a=!!this.pi&&!l;l||this.kl(i,a),this.Sr=t,!l&&(s||n||o)&&(this._l=void 0,this.wl=void 0,this.kl(wi(wi({},t),{},{cookie_persisted_properties:i.cookie_persisted_properties}),a));const u=r||o?this.Yo(t):this.$o;this.Ll();const h=this.Xo(t),d=r||h!==this.jo,c=!l&&(d||t.cross_subdomain_cookie!==this.Fl||t.secure_cookie!==this.Ol)&&this.Sl(a);this.Uo=d;try{if(this.Dl=this.Al=t.cookie_expiration,this.set_disabled(l),this.set_cross_subdomain(t.cross_subdomain_cookie),this.set_secure(t.secure_cookie),d){const t=this.props;this.clear(),this.$o=u,this.jo=h,this.props=t,this.save()}else o&&(this.$o=u,l||(delete this.Lo[Uo],this.$l()))}finally{this.Uo=!1,c&&this.Tl()}}Ll(){const t=this.props[nn];if(!this.qo||!C(t)||"string"!=typeof t.r)return;const i=zo(t.r),e="string"==typeof t.u?zo(t.u):t.u;i===t.r&&e===t.u||this.dl(nn,wi(wi({},t),{},{r:i,u:e}))}set_disabled(t){this.pi=t,this.pi?this.remove():this.save()}set_cross_subdomain(t){t!==this.Fl&&(this.Fl=t,this.remove({keepGroupEntries:!0}),this.save())}set_secure(t){t!==this.Ol&&(this.Ol=t,this.remove({keepGroupEntries:!0}),this.save())}set_event_timer(t,i){const e=this.props.__timers||{};e[t]=i,this.dl(Qe,e),this.save()}remove_event_timer(t){const i=this.props.__timers||{},e=i[t];return I(e)||(delete i[t],this.dl(Qe,i),this.save()),e}get_property(t){return this.props[t]}set_property(t,i){this.dl(t,i),this.save()}dl(t,i,e=!0){var s;const n=this.props[t];this.props[t]=i,e&&("distinct_id"!==t&&"$user_state"!==t||n===i||(this.Wo=!0),"$fbc_persistence"!==t||Vo(n,i)||(this.Go=!0),this.ml(t,n,i),(null===(s=po(t))||void 0===s?void 0:s.volatile)||this.pl(t))}vl(t,i=!0){delete this.props[t],i&&(qo(t)&&this.sl(t,!0),"$fbc_persistence"===t&&(this.Go=!0),this.pl(t))}pl(t){var i;const e=null===(i=po(t))||void 0===i?void 0:i.storageGroup;e&&(this.rl(e).dirty=!0)}rl(t){return this.Lo[t]||(this.Lo[t]={})}};const Jo="gzip-js",Yo="base64",Xo="events",Zo="cancelEvents",Qo="survey shown",tl="survey dismissed",il="survey sent",el="$survey_last_seen_date",sl="popover";function nl(t){let i=!0;return{dispose(){if(i){i=!1;const e=t();e&&T(e.then)&&e.then(void 0,()=>{})}}}}const rl=Be("[RateLimiter]");var ol=class{constructor(t){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=t=>{const i=t.text;if(i&&i.length)try{(JSON.parse(i).quota_limited||[]).forEach(t=>{rl.info(`${t||"events"} is quota limited.`),this.serverLimits[t]=(new Date).getTime()+6e4})}catch(t){return void rl.warn(`could not rate limit - continuing. Error: "${null==t?void 0:t.message}"`,{text:i})}},this.instance=t,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var t;return(null===(t=this.instance.config.rate_limiting)||void 0===t?void 0:t.events_per_second)||10}get captureEventsBurstLimit(){var t;return Math.max((null===(t=this.instance.config.rate_limiting)||void 0===t?void 0:t.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(t=!1){var i,e,s;const{captureEventsBurstLimit:n,captureEventsPerSecond:r}=this,o=(new Date).getTime(),l=null!==(i=null===(e=this.instance.persistence)||void 0===e?void 0:e.get_property("$capture_rate_limit"))&&void 0!==i?i:{tokens:n,last:o};l.tokens+=(o-l.last)/1e3*r,l.last=o,l.tokens>n&&(l.tokens=n);const a=1>l.tokens;if(a||t||(l.tokens=Math.max(0,l.tokens-1)),a&&!t){const t=(D(l.dropped)?l.dropped:0)+1;l.dropped=t,!this.lastEventRateLimited&&this.Nl(t)&&(l.dropped=0)}return this.lastEventRateLimited=a,null===(s=this.instance.persistence)||void 0===s||s.set_property("$capture_rate_limit",l),{isRateLimited:a,remainingTokens:l.tokens}}ql(t){const i=this.instance.config.property_denylist;return!P(i)||!i.includes(t)}jl(){var t;if(this.ql("$current_url")&&this.ql("$pathname")&&(null==n?void 0:n.pathname))return`${null!==(t=n.origin)&&void 0!==t?t:""}${n.pathname}`}Nl(t){var i,e;const{captureEventsBurstLimit:s,captureEventsPerSecond:n}=this,r=this.jl(),o=this.ql("$session_id")?null===(i=(e=this.instance).get_session_id)||void 0===i?void 0:i.call(e):void 0,l=[`${t} event(s) dropped since the last warning`,r?`triggered on ${r}`:void 0,o?`session ${o}`:void 0].filter(Boolean).join(", ");return!!this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:`posthog-js client rate limited: ${l}. Config is set to ${n} events per second and ${s} events burst limit.`},{skip_client_rate_limiting:!0})}isServerRateLimited(t){const i=this.serverLimits[t||"events"]||!1;return!1!==i&&(new Date).getTime()<i}};const ll=Be("[RemoteConfig]");var al=class{constructor(t){this._instance=t}get remoteConfig(){var t;return null===(t=c._POSTHOG_REMOTE_CONFIG)||void 0===t||null===(t=t[this._instance.config.token])||void 0===t?void 0:t.config}Bl(t){var i,e,s;(null===(i=c.__PosthogExtensions__)||void 0===i?void 0:i.loadExternalDependency)?null===(e=c.__PosthogExtensions__)||void 0===e||null===(s=e.loadExternalDependency)||void 0===s||s.call(e,this._instance,"remote-config",()=>t(this.remoteConfig)):t()}Hl(t){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets",`/array/${this._instance.config.token}/config`),callback:t})}load(){try{if(this.remoteConfig)return ll.info("Using preloaded remote config",this.remoteConfig),void this.zl(this.remoteConfig);if(this._instance.Ul())return void ll.warn("Remote config is disabled. Falling back to local config.");this.Bl(t=>{if(!t)return ll.info("No config found after loading remote JS config. Falling back to JSON."),void this.Hl(t=>{this.zl(t.json,t)});this.zl(t)})}catch(t){ll.error("Error loading remote config",t),this.zl()}}zl(t,i){!t&&i&&(0===i.statusCode?i.error||ll.warn("Failed to fetch remote config from PostHog."):ll.error("Failed to fetch remote config from PostHog."));try{this._instance.zl(t?{ok:!0,config:t}:{ok:!1})}catch(t){ll.error("Error applying remote config",t)}if(!1!==(null==t?void 0:t.hasFeatureFlags)&&!this._instance.config.advanced_disable_feature_flags_on_first_load)try{var e;null===(e=this._instance.featureFlags)||void 0===e||e.ensureFlagsLoaded()}catch(t){ll.error("Error loading feature flags",t)}}},ul=Uint8Array,hl=Uint16Array,dl=Uint32Array,cl=new ul([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]),vl=new ul([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]),fl=new ul([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),pl=function(t,i){for(var e=new hl(31),s=0;31>s;++s)e[s]=i+=1<<t[s-1];var n=new dl(e[30]);for(s=1;30>s;++s)for(var r=e[s];e[s+1]>r;++r)n[r]=r-e[s]<<5|s;return[e,n]},gl=pl(cl,2),_l=gl[1];gl[0][28]=258,_l[258]=28;for(var ml=pl(vl,0)[1],bl=new hl(32768),yl=0;32768>yl;++yl){var wl=(43690&yl)>>>1|(21845&yl)<<1;bl[yl]=((65280&(wl=(61680&(wl=(52428&wl)>>>2|(13107&wl)<<2))>>>4|(3855&wl)<<4))>>>8|(255&wl)<<8)>>>1}var $l=function(t,i,e){for(var s=t.length,n=0,r=new hl(i);s>n;++n)++r[t[n]-1];var o,l=new hl(i);for(n=0;i>n;++n)l[n]=l[n-1]+r[n-1]<<1;if(e){o=new hl(1<<i);var a=15-i;for(n=0;s>n;++n)if(t[n])for(var u=n<<4|t[n],h=i-t[n],d=l[t[n]-1]++<<h,c=d|(1<<h)-1;c>=d;++d)o[bl[d]>>>a]=u}else for(o=new hl(s),n=0;s>n;++n)o[n]=bl[l[t[n]-1]++]>>>15-t[n];return o},xl=new ul(288);for(yl=0;144>yl;++yl)xl[yl]=8;for(yl=144;256>yl;++yl)xl[yl]=9;for(yl=256;280>yl;++yl)xl[yl]=7;for(yl=280;288>yl;++yl)xl[yl]=8;var Sl=new ul(32);for(yl=0;32>yl;++yl)Sl[yl]=5;var kl=$l(xl,9,0),El=$l(Sl,5,0),Pl=function(t){return(t/8|0)+(7&t&&1)},Tl=function(t,i,e){(null==i||0>i)&&(i=0),(null==e||e>t.length)&&(e=t.length);var s=new(t instanceof hl?hl:t instanceof dl?dl:ul)(e-i);return s.set(t.subarray(i,e)),s},Cl=function(t,i,e){var s=i/8|0;t[s]|=e<<=7&i,t[s+1]|=e>>>8},Fl=function(t,i,e){var s=i/8|0;t[s]|=e<<=7&i,t[s+1]|=e>>>8,t[s+2]|=e>>>16},Il=function(t,i){for(var e=[],s=0;t.length>s;++s)t[s]&&e.push({s:s,f:t[s]});var n=e.length,r=e.slice();if(!n)return[new ul(0),0];if(1==n){var o=new ul(e[0].s+1);return o[e[0].s]=1,[o,1]}e.sort(function(t,i){return t.f-i.f}),e.push({s:-1,f:25001});var l=e[0],a=e[1],u=0,h=1,d=2;for(e[0]={s:-1,f:l.f+a.f,l:l,r:a};h!=n-1;)l=e[e[d].f>e[u].f?u++:d++],a=e[u!=h&&e[d].f>e[u].f?u++:d++],e[h++]={s:-1,f:l.f+a.f,l:l,r:a};var c=r[0].s;for(s=1;n>s;++s)r[s].s>c&&(c=r[s].s);var v=new hl(c+1),f=Ol(e[h-1],v,0);if(f>i){s=0;var p=0,g=f-i,_=1<<g;for(r.sort(function(t,i){return v[i.s]-v[t.s]||t.f-i.f});n>s;++s){var m=r[s].s;if(i>=v[m])break;p+=_-(1<<f-v[m]),v[m]=i}for(p>>>=g;p>0;){var b=r[s].s;i>v[b]?p-=1<<i-v[b]++-1:++s}for(;s>=0&&p;--s){var y=r[s].s;v[y]==i&&(--v[y],++p)}f=i}return[new ul(v),f]},Ol=function(t,i,e){return-1==t.s?Math.max(Ol(t.l,i,e+1),Ol(t.r,i,e+1)):i[t.s]=e},Rl=function(t){for(var i=t.length;i&&!t[--i];);for(var e=new hl(++i),s=0,n=t[0],r=1,o=function(t){e[s++]=t},l=1;i>=l;++l)if(t[l]==n&&l!=i)++r;else{if(!n&&r>2){for(;r>138;r-=138)o(32754);r>2&&(o(r>10?r-11<<5|28690:r-3<<5|12305),r=0)}else if(r>3){for(o(n),--r;r>6;r-=6)o(8304);r>2&&(o(r-3<<5|8208),r=0)}for(;r--;)o(n);r=1,n=t[l]}return[e.subarray(0,s),i]},Al=function(t,i){for(var e=0,s=0;i.length>s;++s)e+=t[s]*i[s];return e},Ml=function(t,i,e){var s=e.length,n=Pl(i+2);t[n]=255&s,t[n+1]=s>>>8,t[n+2]=255^t[n],t[n+3]=255^t[n+1];for(var r=0;s>r;++r)t[n+r+4]=e[r];return 8*(n+4+s)},Dl=function(t,i,e,s,n,r,o,l,a,u,h){Cl(i,h++,e),++n[256];for(var d=Il(n,15),c=d[0],v=d[1],f=Il(r,15),p=f[0],g=f[1],_=Rl(c),m=_[0],b=_[1],y=Rl(p),w=y[0],x=y[1],S=new hl(19),k=0;m.length>k;++k)S[31&m[k]]++;for(k=0;w.length>k;++k)S[31&w[k]]++;for(var E=Il(S,7),P=E[0],T=E[1],C=19;C>4&&!P[fl[C-1]];--C);var F,I,O,R,A=u+5<<3,M=Al(n,xl)+Al(r,Sl)+o,D=Al(n,c)+Al(r,p)+o+14+3*C+Al(S,P)+(2*S[16]+3*S[17]+7*S[18]);if(M>=A&&D>=A)return Ml(i,h,t.subarray(a,a+u));if(Cl(i,h,1+(M>D)),h+=2,M>D){F=$l(c,v,0),I=c,O=$l(p,g,0),R=p;var j=$l(P,T,0);for(Cl(i,h,b-257),Cl(i,h+5,x-1),Cl(i,h+10,C-4),h+=14,k=0;C>k;++k)Cl(i,h+3*k,P[fl[k]]);h+=3*C;for(var B=[m,w],L=0;2>L;++L){var N=B[L];for(k=0;N.length>k;++k)Cl(i,h,j[z=31&N[k]]),h+=P[z],z>15&&(Cl(i,h,N[k]>>>5&127),h+=N[k]>>>12)}}else F=kl,I=xl,O=El,R=Sl;for(k=0;l>k;++k)if(s[k]>255){var z;Fl(i,h,F[257+(z=s[k]>>>18&31)]),h+=I[z+257],z>7&&(Cl(i,h,s[k]>>>23&31),h+=cl[z]);var U=31&s[k];Fl(i,h,O[U]),h+=R[U],U>3&&(Fl(i,h,s[k]>>>5&8191),h+=vl[U])}else Fl(i,h,F[s[k]]),h+=I[s[k]];return Fl(i,h,F[256]),h+I[256]},jl=new dl([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Bl=new ul(0),Ll=function(){for(var t=new dl(256),i=0;256>i;++i){for(var e=i,s=9;--s;)e=(1&e&&3988292384)^e>>>1;t[i]=e}return t}(),Nl=function(t,i,e){for(;e;++i)t[i]=e,e>>>=8};function zl(t,i){void 0===i&&(i={});var e=function(){var t=4294967295;return{p(i){for(var e=t,s=0;i.length>s;++s)e=Ll[255&e^i[s]]^e>>>8;t=e},d(){return 4294967295^t}}}(),s=t.length;e.p(t);var n,r,o,l,a,u,h=(l=10+((n=i).filename&&n.filename.length+1||0),a=8,function(t,i,e,s,n,r){var o=t.length,l=new ul(s+o+5*(1+Math.floor(o/7e3))+n),a=l.subarray(s,l.length-n),u=0;if(!i||8>o)for(var h=0;o>=h;h+=65535){var d=h+65535;o>d?u=Ml(a,u,t.subarray(h,d)):(a[h]=r,u=Ml(a,u,t.subarray(h,o)))}else{for(var c=jl[i-1],v=c>>>13,f=8191&c,p=(1<<e)-1,g=new hl(32768),_=new hl(p+1),m=Math.ceil(e/3),b=2*m,y=function(i){return(t[i]^t[i+1]<<m^t[i+2]<<b)&p},w=new dl(25e3),x=new hl(288),S=new hl(32),k=0,E=0,P=(h=0,0),T=0,C=0;o>h;++h){var F=y(h),I=32767&h,O=_[F];if(g[I]=O,_[F]=I,h>=T){var R=o-h;if((k>7e3||P>24576)&&R>423){u=Dl(t,a,0,w,x,S,E,P,C,h-C,u),P=k=E=0,C=h;for(var A=0;286>A;++A)x[A]=0;for(A=0;30>A;++A)S[A]=0}var M=2,D=0,j=f,B=I-O&32767;if(R>2&&F==y(h-B))for(var L=Math.min(v,R)-1,N=Math.min(32767,h),z=Math.min(258,R);N>=B&&--j&&I!=O;){if(t[h+M]==t[h+M-B]){for(var U=0;z>U&&t[h+U]==t[h+U-B];++U);if(U>M){if(M=U,D=B,U>L)break;var H=Math.min(B,U-2),q=0;for(A=0;H>A;++A){var V=h-B+A+32768&32767,W=V-g[V]+32768&32767;W>q&&(q=W,O=V)}}}B+=(I=O)-(O=g[I])+32768&32767}if(D){w[P++]=268435456|_l[M]<<18|ml[D];var G=31&_l[M],K=31&ml[D];E+=cl[G]+vl[K],++x[257+G],++S[K],T=h+M,++k}else w[P++]=t[h],++x[t[h]]}}u=Dl(t,a,r,w,x,S,E,P,C,h-C,u),r||(u=Ml(a,u,Bl))}return Tl(l,0,s+Pl(u)+n)}(r=t,null==(o=i).level?6:o.level,null==o.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(r.length)))):12+o.mem,l,a,!u)),d=h.length;return function(t,i){var e=i.filename;if(t[0]=31,t[1]=139,t[2]=8,t[8]=2>i.level?4:9==i.level?2:0,t[9]=3,0!=i.mtime&&Nl(t,4,Math.floor(new Date(i.mtime||Date.now())/1e3)),e){t[3]=8;for(var s=0;e.length>=s;++s)t[s+10]=e.charCodeAt(s)}}(h,i),Nl(h,d-8,e.d()),Nl(h,d-4,s),h}const Ul=!!o||!!r,Hl="text/plain";let ql=!1;const Vl=(t,i)=>{const[e,s]=t.split("#"),[n,r]=e.split("?");if(!r)return t;const o=r.split("&").filter(t=>t.split("=")[0]!==i).join("&");return`${n}${o?`?${o}`:""}${s?`#${s}`:""}`},Wl=(t,i,e=!0)=>{var s;const[n,r]=t.split("?"),o=wi({},i),l=null!==(s=null==r?void 0:r.split("&").map(t=>{var i;const[s,n]=t.split("="),r=e&&null!==(i=o[s])&&void 0!==i?i:n;return delete o[s],`${s}=${r}`}))&&void 0!==s?s:[],a=function(t,i="&"){let e,s;const n=[];return Fn(t,function(t,i){I(t)||I(i)||"undefined"===i||(e=encodeURIComponent((t=>t instanceof File)(t)?t.name:t.toString()),s=encodeURIComponent(i),n[n.length]=s+"="+e)}),n.join(i)}(o);return a&&l.push(a),l.length>0?`${n}?${l.join("&")}`:n},Gl=t=>{if(t.Wl)return t.Wl;const{data:i,compression:e}=t;if(!i)return;if(e===Jo){const t=zl(function(t){var i=t.length;if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(t);for(var e=new ul(t.length+(t.length>>>1)),s=0,n=function(t){e[s++]=t},r=0;i>r;++r){if(s+5>e.length){var o=new ul(s+8+(i-r<<1));o.set(e),e=o}var l=t.charCodeAt(r);128>l?n(l):2048>l?(n(192|l>>>6),n(128|63&l)):l>55295&&57344>l?(n(240|(l=65536+(1047552&l)|1023&t.charCodeAt(++r))>>>18),n(128|l>>>12&63),n(128|l>>>6&63),n(128|63&l)):(n(224|l>>>12),n(128|l>>>6&63),n(128|63&l))}return Tl(e,0,s)}(go(i)),{mtime:0});return{contentType:Hl,body:t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength),estimatedSize:t.byteLength}}if(e===Yo){const t=function(t){return t?btoa(encodeURIComponent(t).replace(/%([0-9A-F]{2})/g,(t,i)=>String.fromCharCode(parseInt(i,16)))):t}(go(i)),e=(t=>"data="+encodeURIComponent("string"==typeof t?t:go(t)))(t);return{contentType:"application/x-www-form-urlencoded",body:e,estimatedSize:new Blob([e]).size}}const s=go(i);return{contentType:"application/json",body:s,estimatedSize:new Blob([s]).size}},Kl=t=>{const i=()=>"sendBeacon"===t.transport?{url:Wl(t.url,{compression:Yo}),encodedBody:Gl(wi(wi({},t),{},{compression:Yo,Wl:void 0}))}:{url:Vl(t.url,"compression"),encodedBody:Gl(wi(wi({},t),{},{compression:void 0,Wl:void 0}))};let e;try{e=Gl(t)}catch(e){if(he(t.compression,mo(t.url,"compression")))return je.error("Failed to gzip request body, sending uncompressed payload",e),i();throw e}return e&&he(t.compression,mo(t.url,"compression"))&&!((s=e.body)instanceof ArrayBuffer?ue(new Uint8Array(s)):ArrayBuffer.isView(s)&&ue(new Uint8Array(s.buffer,s.byteOffset,s.byteLength)))?(ql=!0,i()):{url:t.url,encodedBody:e};var s},Jl=t=>{try{return Kl(t)}catch(e){var i;return je.error(e),void(null===(i=t.callback)||void 0===i||i.call(t,{statusCode:0,error:e}))}},Yl=function(){var t=Y(function*(t){const i=yield function(t){return ge.apply(this,arguments)}(go(t.data),qe.DEBUG,{rethrow:!0});if(!i)return t;const e=yield i.arrayBuffer();return wi(wi({},t),{},{Wl:{contentType:Hl,body:e,estimatedSize:e.byteLength}})});return function(i){return t.apply(this,arguments)}}(),Xl=/Failed to fetch|NetworkError|Load failed/i,Zl=t=>"TypeError"===(null==t?void 0:t.name)&&Xl.test((null==t?void 0:t.message)||""),Ql=t=>{const i=Jl(t);if(!i)return;const e=new o,{url:s,encodedBody:n}=i;e.open(t.method||"GET",s,!0);const{contentType:r,body:l}=null!=n?n:{};Fn(t.headers,function(t,i){e.setRequestHeader(i,t)}),r&&e.setRequestHeader("Content-Type",r),t.timeout&&(e.timeout=t.timeout),e.onreadystatechange=()=>{if(4===e.readyState){var i;const s={statusCode:e.status,text:e.responseText};if(200===e.status)try{s.json=JSON.parse(e.responseText)}catch(t){}null===(i=t.callback)||void 0===i||i.call(t,s)}},e.send(l)},ta=t=>{const i=Jl(t);if(!i)return;const{url:e,encodedBody:s}=i,{contentType:n,body:o,estimatedSize:a}=null!=s?s:{},u=new Headers;Fn(t.headers,function(t,i){u.append(i,t)}),n&&u.append("Content-Type",n);let h=null,d=!1;if(l){const i=new l;h={signal:i.signal,timeout:setTimeout(()=>{var e;d=!0,i.abort(ui("AbortError","PostHog request timed out"+((e=t.timeout)?` after ${e}ms`:"")))},t.timeout)}}const c=i=>{var e;d&&"AbortError"===(null==i?void 0:i.name)||Zl(i)?je.warn(i):je.error(i),null===(e=t.callback)||void 0===e||e.call(t,{statusCode:0,error:i})};try{r(e,wi({method:(null==t?void 0:t.method)||"GET",headers:u,keepalive:"POST"===t.method&&!t.Vl&&52428.8>(a||0),body:o,signal:null==h?void 0:h.signal},t.fetchOptions)).then(i=>i.text().then(e=>{var s;const n={statusCode:i.status,text:e};if(200===i.status)try{n.json=JSON.parse(e)}catch(t){je.error(t)}null===(s=t.callback)||void 0===s||s.call(t,n)})).catch(c).finally(()=>h?clearTimeout(h.timeout):null)}catch(t){h&&clearTimeout(h.timeout),c(t)}},ia=t=>{try{var i;const{url:s,encodedBody:n}=Kl(t),{contentType:o,body:l,estimatedSize:a}=null!=n?n:{};if(!l)return;const u=l instanceof Blob?l:new Blob([l],{type:o});if(e.sendBeacon(s,u))return;const h=P(t.data)?t.data:null===(i=t.data)||void 0===i?void 0:i.batch;if(P(h)&&h.length>1&&(null!=a?a:0)>16384){const i=Math.ceil(h.length/2),e=i=>P(t.data)?i:wi(wi({},t.data),{},{batch:i});return ia(wi(wi({},t),{},{data:e(h.slice(0,i))})),void ia(wi(wi({},t),{},{data:e(h.slice(i))}))}je.warn(`Beacon of ~${null!=a?a:0} bytes was rejected by the browser, falling back to ${r?"fetch":"XHR"}`),r?ta(wi(wi({},t),{},{Vl:!0})):Ql(t)}catch(t){je.warn("Beacon send failed",t)}},ea=(t,i,e,s)=>{const n="query"===s?"POST"===i?"sent_at":"_":void 0;return Wl(e===Jo?Vl(t,"compression"):t,wi(wi({},n?{[n]:Date.now().toString()}:{}),e===Jo?{}:{compression:e}))},sa=(()=>{const t=[];return r&&t.push({transport:"fetch",method:ta}),o&&t.push({transport:"XHR",method:Ql}),(null==e?void 0:e.sendBeacon)&&t.push({transport:"sendBeacon",method:ia}),t})();var na=class{constructor(t,i){this.Gl=!0,this.Zl=[],this.Ql=Q((null==i?void 0:i.flush_interval_ms)||3e3,250,5e3,je.createLogger("flush interval"),3e3),this.Jl=t}enqueue(t){this.Zl.push(t),this.Kl||this.Yl()}unload(){this.Xl();const t=this.Zl.length>0?this.ta():{},i=Object.values(t);[...i.filter(t=>0===t.url.indexOf("/e")),...i.filter(t=>0!==t.url.indexOf("/e"))].map(t=>{this.ea(wi(wi({},t),{},{transport:"sendBeacon"}))})}enable(){this.Gl=!1,this.Yl()}Yl(){this.Gl||(this.Kl=setTimeout(()=>{if(this.Xl(),this.Zl.length>0){const t=this.ta();for(const i in t){const e=t[i],s=(new Date).getTime();e.data&&P(e.data)&&Fn(e.data,t=>{t.offset=Math.abs(t.timestamp-s),delete t.timestamp}),this.ea(e)}}},this.Ql))}ea(t){try{this.Jl(t)}catch(t){je.error(t)}}Xl(){clearTimeout(this.Kl),this.Kl=void 0}ta(){const t={};return Fn(this.Zl,i=>{var e;const s=i,n=(s?s.batchKey:null)||s.url;I(t[n])&&(t[n]=wi(wi({},s),{},{data:[]})),null===(e=t[n].data)||void 0===e||e.push(s.data)}),this.Zl=[],t}};const ra=["retriesPerformedSoFar"];var oa=class{constructor(t){this._instance=t,this.ia=!1,this.na=3e3,this.Zl=[],this.Zl=[],this.sa=!0,this.resume()}resume(){if(!I(t)&&"onLine"in t.navigator){if(this.sa=t.navigator.onLine,this.ra)return;this.ra=()=>{this.sa=!0,this.oa()},this.la=()=>{this.sa=!1},Ln(t,"online",this.ra),Ln(t,"offline",this.la)}}get length(){return this.Zl.length}retriableRequest(t){let{retriesPerformedSoFar:i}=t,e=_e(t,ra);j(i)&&(e.url=Wl(e.url,{retry_count:i})),this._instance._send_request(wi(wi({},e),{},{callback:t=>{var s;if(200!==t.statusCode&&(400>t.statusCode||t.statusCode>=500)){if((0===t.statusCode?3:10)>(null!=i?i:0))return void this.Is(wi({retriesPerformedSoFar:i},e));0===t.statusCode&&je.warn(`Request failed before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped retrying after ${null!=i?i:0} retries.`)}null===(s=e.callback)||void 0===s||s.call(e,t)}}))}Is(t){const i=t.retriesPerformedSoFar||0;t.retriesPerformedSoFar=i+1;const e=function(t){const i=3e3*Math.pow(2,t),e=i/2,s=Math.min(18e5,i),n=(Math.random()-.5)*(s-e);return Math.ceil(s+n)}(i),s=Date.now()+e;this.Zl.push({retryAt:s,requestOptions:t});let n=`Enqueued failed request for retry in ${e}`;navigator.onLine||(n+=" (Browser is offline)"),je.warn(n),this.ia||(this.ia=!0,this.aa())}aa(){if(this.ua&&clearTimeout(this.ua),0===this.Zl.length)return this.ia=!1,void(this.ua=void 0);this.ua=setTimeout(()=>{this.sa&&this.Zl.length>0&&this.oa(),this.aa()},this.na)}oa(){const t=Date.now(),i=[],e=this.Zl.filter(e=>t>e.retryAt||(i.push(e),!1));if(this.Zl=i,e.length>0)for(const{requestOptions:t}of e)this.retriableRequest(t)}unload(){this.ua&&(clearTimeout(this.ua),this.ua=void 0),this.ia=!1,I(t)||(this.ra&&(t.removeEventListener("online",this.ra),this.ra=void 0),this.la&&(t.removeEventListener("offline",this.la),this.la=void 0));for(const{requestOptions:t}of this.Zl)try{this._instance._send_request(wi(wi({},t),{},{transport:"sendBeacon"}))}catch(t){je.error(t)}this.Zl=[]}},la=class{constructor(t){this._instance=t,this.ha=()=>{var t,i,e,s;this.ca||(this.ca={});const n=this.scrollElement(),r=this.scrollY(),o=n?Math.max(0,n.scrollHeight-n.clientHeight):0,l=r+((null==n?void 0:n.clientHeight)||0),a=(null==n?void 0:n.scrollHeight)||0;this.ca.lastScrollY=Math.ceil(r),this.ca.maxScrollY=Math.max(r,null!==(t=this.ca.maxScrollY)&&void 0!==t?t:0),this.ca.maxScrollHeight=Math.max(o,null!==(i=this.ca.maxScrollHeight)&&void 0!==i?i:0),this.ca.lastContentY=l,this.ca.maxContentY=Math.max(l,null!==(e=this.ca.maxContentY)&&void 0!==e?e:0),this.ca.maxContentHeight=Math.max(a,null!==(s=this.ca.maxContentHeight)&&void 0!==s?s:0)}}get da(){return this._instance.config.scroll_root_selector}getContext(){return this.ca}resetContext(){const t=this.ca;return setTimeout(this.ha,0),t}startMeasuringScrollPosition(){Ln(t,"scroll",this.ha,{capture:!0}),Ln(t,"scrollend",this.ha,{capture:!0}),Ln(t,"resize",this.ha)}scrollElement(){if(this.da){const e=P(this.da)?this.da:[this.da];for(const s of e){var i;const e=null==t||null===(i=t.document)||void 0===i?void 0:i.querySelector(s);if(e)return e}return}var e;return null==t||null===(e=t.document)||void 0===e?void 0:e.documentElement}va(i){var e,s;const n="y"===i?"scrollTop":"scrollLeft";if(this.da){const t=this.scrollElement();return t&&t[n]||0}return t?"y"===i?t.scrollY||t.pageYOffset||(null===(e=t.document)||void 0===e||null===(e=e.documentElement)||void 0===e?void 0:e.scrollTop)||0:t.scrollX||t.pageXOffset||(null===(s=t.document)||void 0===s||null===(s=s.documentElement)||void 0===s?void 0:s.scrollLeft)||0:0}scrollY(){return this.va("y")}scrollX(){return this.va("x")}};const aa=t=>Ao(null==t?void 0:t.config.mask_personal_data_properties,null==t?void 0:t.config.custom_personal_data_properties,null==t?void 0:t.config.disable_capture_url_hashes);var ua=class{constructor(t,i,e,s){this.je=t=>{const i=this.fa();if(i&&i.sessionId===t)return;const e={sessionId:t,props:this.pa(this._instance)};this.ga.register({[Qs]:e})},this._instance=t,this.ma=i,this.ga=e,this.pa=s||aa,this.ma.onSessionId(this.je)}fa(){return this.ga.props[Qs]}getSetOnceProps(){var t;const i=null===(t=this.fa())||void 0===t?void 0:t.props;return i?"r"in i?Mo(i,this._instance.config.disable_capture_url_hashes):{$referring_domain:i.referringDomain,$pathname:i.initialPathName,utm_source:i.utm_source,utm_campaign:i.utm_campaign,utm_medium:i.utm_medium,utm_content:i.utm_content,utm_term:i.utm_term}:{}}getSessionProps(){const t={};return Fn(Mn(this.getSetOnceProps()),(i,e)=>{"$current_url"===e&&(e="url"),t[`$session_entry_${w(e)}`]=i}),t}},ha=class{on(t,i){return this.ya[t]||(this.ya[t]=[]),this.ya[t].push(i),()=>{this.ya[t]=this.ya[t].filter(t=>t!==i)}}emit(t,i){for(const e of this.ya[t]||[])e(i);for(const e of this.ya["*"]||[])e(t,i)}constructor(){this.ya={}}};const da=Be("[SessionId]"),ca=864e5;var va=class{on(t,i){return this.ba.on(t,i)}constructor(t,i,e){var s;if(this._a=null,this.wa=null,this.ka=[],this.Sa=void 0,this.xa=!1,this.ba=new ha,this.Ca=(t,i)=>!(!j(t)||!j(i))&&Math.abs(t-i)>this.sessionTimeoutMs,!t.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if("always"===t.config.cookieless_mode)throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this.Sr=t.config,this.ga=t.persistence,this.Be=void 0,this.Xt=void 0,this._sessionStartTimestamp=null,this.$a=void 0,this._sessionActivityTimestamp=null,this.Ta=i||Gn,this.Ia=e||Gn;const n=this.Sr.persistence_name||this.Sr.token;if(this._sessionTimeoutMs=1e3*Q(this.Sr.session_idle_timeout_seconds||1800,60,36e3,da.createLogger("session_idle_timeout_seconds"),1800),t.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.Ma(),this.Ea="ph_"+n+"_window_id",this.Pa="ph_"+n+"_primary_window_exists",this.Ra()){const t=fr.Dt(this.Ea),i=fr.Dt(this.Pa);t&&!i?this.Be=t:fr.Lt(this.Ea),fr.At(this.Pa,!0)}(null===(s=this.Sr.bootstrap)||void 0===s?void 0:s.sessionID)&&this.setBootstrapSessionId(this.Sr.bootstrap.sessionID),this.Aa()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(t){return I(this.ka)&&(this.ka=[]),this.ka.push(t),this.Xt&&t(this.Xt,this.Be),()=>{this.ka=this.ka.filter(i=>i!==t)}}Ra(){return"memory"!==this.Sr.persistence&&!this.ga.pi&&fr.Et()}Fa(t){t!==this.Be&&(this.Be=t,this.Ra()&&fr.At(this.Ea,t))}Oa(){return this.Be?this.Be:this.Ra()?fr.Dt(this.Ea):null}Da(t){const i=this._a;return!A(i)&&!A(t)&&5e3>Math.abs(t-i)}La(t,i,e){const s=i!==this._sessionActivityTimestamp,n=!(t!==this.Xt||e!==this._sessionStartTimestamp);this._sessionStartTimestamp=e,this._sessionActivityTimestamp=i,this.Xt=t,n&&!s||n&&this.Da(i)||(this._a=i,this.ga.register({[_s]:[i,t,e]}))}Na(){var t;const i=null===(t=this.Sr)||void 0===t?void 0:t.persistence_save_debounce_ms;return j(i)&&i>0}qa(){this.Na()?this.ga.refreshKey(_s):(this.ga.flush(),this.ga.load())}ja(){var t;if(A(this._sessionActivityTimestamp)||this._sessionActivityTimestamp===this._a)return;this.qa();const[,i,e]=this.Ba();i===this.Xt&&e===this._sessionStartTimestamp&&(this._a=this._sessionActivityTimestamp,this.ga.register({[_s]:[this._sessionActivityTimestamp,null!==(t=this.Xt)&&void 0!==t?t:null,this._sessionStartTimestamp]}),this.ga.flush())}Ha(){const[t]=this.Ba(),i=j(t)?t:0,e=j(this._sessionActivityTimestamp)?this._sessionActivityTimestamp:0;return Math.max(i,e)}za(t){return this.qa(),this.Ca(t,this.Ha())}Ba(){const t=this.ga.props[_s];return P(t)&&2===t.length&&t.push(t[0]),t||[0,null,0]}resetSessionId(){this._a=null,this.$a=void 0,clearTimeout(this.Ua),this.Ua=void 0,this.La(null,null,null)}setBootstrapSessionId(t,i=!1){const e=((t,i=(new Date).getTime())=>{try{const e=(t=>{const i=t.replace(/-/g,"");if(32!==i.length)throw new Error("Not a valid UUID");if("7"!==i[12])throw new Error("Not a UUIDv7");return parseInt(i.substring(0,12),16)})(t);return e>i+6e4?void da.error("Bootstrap sessionID cannot be in the future"):e}catch(t){return void da.error("Invalid sessionID in bootstrap",t)}})(t);return!I(e)&&(i?this.$a={sessionId:t,sessionStartTimestamp:e}:this.La(t,(new Date).getTime(),e),!0)}destroy(){this.xa=!0,this.ja(),clearTimeout(this.Ua),this.Ua=void 0,this.Sa&&t&&(t.removeEventListener(Sn,this.Sa,{capture:!1}),this.Sa=void 0),this.ka=[]}Aa(){this.Sa=()=>{this.ja(),this.Ra()&&fr.Lt(this.Pa)},Ln(t,Sn,this.Sa,{capture:!1})}checkAndGetSessionAndWindowId(t=!1,i=null,e=!1){if("always"===this.Sr.cookieless_mode)throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');const s=i||(new Date).getTime(),n=this.Xt;if(e)this.wa=s;else if(A(this.wa)||this.wa>s||s-this.wa>=1e3){var r,o;null===(r=(o=this.ga).syncCookieProperties)||void 0===r||r.call(o),this.wa=s}let[,l,a]=this.Ba();const u=!I(n)&&l!==n,h=this.Ha();let d=this.Oa();const c=this.$a,v=!!c&&(c.sessionStartTimestamp>s+6e4||s-c.sessionStartTimestamp>ca),f=c?v:j(a)&&Math.abs(s-a)>ca;let p=!1,g=u;const _=!l||!!c,m=l;let b=!_&&!t&&this.Ca(s,h);if(b&&(b=this.za(s),b||da.info("cross-tab refresh kept the session alive",{sessionId:l}),[,l,a]=this.Ba()),_||b||f){g=!1;const t=c&&!v;l=t?c.sessionId:this.Ta(),d=this.Ia(),da.info("new session ID assigned",{sessionId:l,windowId:d,bootstrapped:!!t,changeReason:{noSessionId:_,activityTimeout:b,sessionPastMaximumLength:f}}),a=t?c.sessionStartTimestamp:s,this.$a=void 0,p=!0}else d||(d=this.Ia(),p=!0),g=g||l!==m,g&&(da.info("adopted cross-tab session id",{sessionId:l,windowId:d}),p=!0);const y=j(h)&&t&&!f?h:s,w=j(a)?a:(new Date).getTime();this.Fa(d),this.La(l,y,w),t||this.Ma();const x={noSessionId:_,activityTimeout:b,sessionPastMaximumLength:f,crossTabAdoption:g};return p&&this.ka.forEach(t=>t(l,d,x)),{sessionId:l,windowId:d,sessionStartTimestamp:w,changeReason:p?x:void 0,lastActivityTimestamp:h}}Ma(){this.xa||(clearTimeout(this.Ua),this.Ua=setTimeout(()=>{if(!this.xa)if(this.za((new Date).getTime())){const t=this.Xt;this.resetSessionId(),this.ba.emit("forcedIdleReset",{idleSessionId:t})}else this.Ma()},1.1*this.sessionTimeoutMs))}};const fa=function(t,i){if(!t)return!1;const e=t.userAgent;if(e&&Z(e,i))return!0;try{const e=null==t?void 0:t.userAgentData;if((null==e?void 0:e.brands)&&e.brands.some(t=>Z(null==t?void 0:t.brand,i)))return!0}catch(t){}return!!t.webdriver};function pa(){return(pa=Y(function*(){const t=null==e?void 0:e.userAgentData;if(null==t?void 0:t.getHighEntropyValues)try{const i=yield t.getHighEntropyValues(["model"]),e=null==i?void 0:i.model;return O(e)&&e.length>0?e:void 0}catch(t){return void je.info("Unable to resolve $device_model from userAgentData.getHighEntropyValues",t)}})).apply(this,arguments)}function ga(t,i){let e=`$survey_${i}/${t.id}`;return t.current_iteration&&t.current_iteration>0&&(e=`$survey_${i}/${t.id}/${t.current_iteration}`),e}function _a(t){var i;return!!(null===(i=t.conditions)||void 0===i||null===(i=i.events)||void 0===i||null===(i=i.values)||void 0===i?void 0:i.length)}const ma=(t,i)=>{if(!(t=>{try{new RegExp(t)}catch(t){return!1}return!0})(i))return!1;try{return new RegExp(i).test(t)}catch(t){return!1}},ba=t=>t.toLowerCase(),ya={exact:(t,i)=>i.some(i=>t.some(t=>i===t)),is_not:(t,i)=>i.every(i=>t.every(t=>i!==t)),regex:(t,i)=>i.some(i=>t.some(t=>ma(i,t))),not_regex:(t,i)=>i.every(i=>t.every(t=>!ma(i,t))),icontains:(t,i)=>i.map(ba).some(i=>t.map(ba).some(t=>i.includes(t))),not_icontains:(t,i)=>i.map(ba).every(i=>t.map(ba).every(t=>!i.includes(t))),gt:(t,i)=>i.some(i=>{const e=parseFloat(i);return!isNaN(e)&&t.some(t=>e>parseFloat(t))}),lt:(t,i)=>i.some(i=>{const e=parseFloat(i);return!isNaN(e)&&t.some(t=>e<parseFloat(t))})};function wa(t,i){return!t||Object.entries(t).every(([t,e])=>{const s=null==i?void 0:i[t];if(null==s)return!1;const n=ya[e.operator];return!!n&&n(e.values,[String(s)])})}function $a(t,i,e){return go({distinct_id:t,userPropertiesToSet:i,userPropertiesToSetOnce:e})}const xa="custom",Sa="i.posthog.com",ka=/^\/static\//,Ea=["/s/","/e/","/i/"];var Pa=class{constructor(t){this.Wa={},this.instance=t}get apiHost(){const t=this.instance.config.api_host.trim().replace(/\/$/,"");return"https://app.posthog.com"===t?"https://us.i.posthog.com":t}get flagsApiHost(){const t=this.instance.config.flags_api_host;return t?t.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var t;let i=null===(t=this.instance.config.ui_host)||void 0===t?void 0:t.replace(/\/$/,"");return i||(i=this.apiHost.replace(`.${Sa}`,".posthog.com")),"https://app.posthog.com"===i?"https://us.posthog.com":i}get region(){return this.Wa[this.apiHost]||(this.Wa[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":xa),this.Wa[this.apiHost]}Va(t){if(!ka.test(t))return;const i=this.instance.config.asset_host;return"string"==typeof i&&i.trim().replace(/\/$/,"")||void 0}Ga(t){const i=_o(t);return i?i.protocol+"//"+i.host+i.pathname:void 0}Za(t,i,e){if("ui"===t)return e;let s=e;const n=this.instance.config.rewriteRequestPath;if(n){var r;const t=(null===(r=_o(e))||void 0===r?void 0:r.href)||e;s=n(new URL(t)).toString()}if(n&&"api"===t&&Ea.some(t=>0===i.indexOf(t))){const t=this.Ga(s);if(t){const i=this.apiHost;let e=this.Qa;(null==e?void 0:e.apiHost)===i&&e.rewriteRequestPath===n||(e={apiHost:i,rewriteRequestPath:n,urls:new Set},this.Qa=e),e.urls.add(t)}}return s}isIngestionEndpoint(t){const i=this.Qa,e=this.Ga(t);return(null==i?void 0:i.apiHost)===this.apiHost&&i.rewriteRequestPath===this.instance.config.rewriteRequestPath&&!!e&&i.urls.has(e)}endpointFor(t,i=""){if(i&&(i="/"===i[0]?i:`/${i}`),"ui"===t)return this.Za(t,i,this.uiHost+i);if("flags"===t)return this.Za(t,i,this.flagsApiHost+i);if("assets"===t){const e=this.Va(i);if(e)return this.Za(t,i,`${e}${i}`)}if(this.region===xa)return this.Za(t,i,this.apiHost+i);const e=Sa+i;switch(t){case"assets":return this.Za(t,i,`https://${this.region}-assets.${e}`);case"api":return this.Za(t,i,`https://${this.region}.${e}`)}}};const Ta=Be("[Surveys]"),Ca=t=>{try{const i=(t=>((t,i)=>`seenSurvey_${function(t){return t.current_iteration&&t.current_iteration>0?`${t.id}_${t.current_iteration}`:t.id}(i)}`)(0,t))(t);if(localStorage.getItem(i))return;localStorage.setItem(i,"true")}catch(t){Ta.error("Failed to persist survey seen state",t)}},Fa=["popover","widget","api"],Ia={ignoreConditions:!1,ignoreDelay:!1,displayType:sl},Oa=Be("[PostHog ExternalIntegrations]"),Ra={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};var Aa=class{constructor(t){this._instance=t}Eo(t,i){var e,s;null===(e=c.__PosthogExtensions__)||void 0===e||null===(s=e.loadExternalDependency)||void 0===s||s.call(e,this._instance,t,t=>{if(t)return Oa.error("failed to load script",t);i()})}startIfEnabledOrStop(){var t;for(const[n,r]of Object.entries(null!==(t=this._instance.config.integrations)&&void 0!==t?t:{})){var i,e,s;r&&!(null===(i=c.__PosthogExtensions__)||void 0===i||null===(i=i.integrations)||void 0===i?void 0:i[n])&&this.Eo(Ra[n],()=>{var t;null===(t=c.__PosthogExtensions__)||void 0===t||null===(t=t.integrations)||void 0===t||null===(t=t[n])||void 0===t||t.start(this._instance)}),!r&&(null===(e=c.__PosthogExtensions__)||void 0===e||null===(e=e.integrations)||void 0===e?void 0:e[n])&&(null===(s=c.__PosthogExtensions__)||void 0===s||null===(s=s.integrations)||void 0===s||null===(s=s[n])||void 0===s||s.stop())}}},Ma=class{constructor(t,i){this.$=t,this.lo=i,this.Ja=new Map,this.fo=!1}add(t){var i=this;return Y(function*(){if(i.fo)throw new Error("Cannot add an extension to a disposed ExtensionRuntime");if(i.Ja.has(t.name))throw new Error(`Browser extension "${t.name}" is already registered`);i.Ja.set(t.name,t);try{const e=t.setup(i.lo);e&&(yield e)}catch(e){const s=i.Ja.get(t.name)===t;s&&i.Ja.delete(t.name),i.$.error(`Failed to set up browser extension "${t.name}"`,e),s&&i.Ka(t)}})()}getExtension(t){return this.Ja.get(t)}dispose(){if(this.fo)return;this.fo=!0;const t=Array.from(this.Ja.values()).reverse();this.Ja.clear();for(const i of t)this.Ka(i)}Ka(t){try{var i;const e=null===(i=t.dispose)||void 0===i?void 0:i.call(t);e&&T(e.then)&&e.then(void 0,i=>{this.$.error(`Failed to dispose browser extension "${t.name}"`,i)})}catch(i){this.$.error(`Failed to dispose browser extension "${t.name}"`,i)}}},Da=class{constructor(t){this._instance=t}initialize(){}get(t){const i=this._instance.persistence;if("string"==typeof t)return null==i?void 0:i.get_property(t);const e={};for(const s of t){const t=null==i?void 0:i.get_property(s);I(t)||(e[s]=t)}return e}set(t,i){var e;null===(e=this._instance.persistence)||void 0===e||e.register("string"==typeof t?{[t]:i}:t)}remove(t){var i;null===(i=this._instance.persistence)||void 0===i||i.unregister(t)}};const ja="extensionsRemoteConfig";var Ba=class{constructor(t){this.instance=t,this.fo=!1,this.$=je,this.Ya=t.Xa,this.kv=new Da(t),this.onEvent=t=>nl(this.instance.on("eventCaptured",i=>{try{t({event:i.event,properties:i.properties})}catch(t){this.$.error("Browser extension event listener failed",t)}})),this.onRemoteConfig=t=>{if(this.fo)return nl(()=>{});const i=i=>{try{t(i)}catch(t){this.$.error("Browser extension remote config listener failed",t)}},e=this.instance.tu.on(ja,i);return this.Ya&&i(this.Ya),nl(e)},this.eu=new Ma(je.createLogger("[BrowserExtensions]"),this)}get logger(){return this.$}get distinctId(){return this.instance.get_distinct_id()}get anonymousId(){var t;return null!==(t=this.instance.get_property("$device_id"))&&void 0!==t?t:this.distinctId}get deviceId(){const t=this.instance.get_property(Ge);return"string"==typeof t?t:void 0}get library(){return{name:qe.LIB_NAME,version:qe.LIB_VERSION}}get initialPersonProperties(){var t,i;return null!==(t=null===(i=this.instance.persistence)||void 0===i?void 0:i.get_initial_props())&&void 0!==t?t:{}}get groups(){return this.instance.getGroups()}get session(){try{var t,i,e,s;const n=null===(t=this.instance.sessionManager)||void 0===t?void 0:t.checkAndGetSessionAndWindowId(!0);return{sessionId:null!==(i=null==n?void 0:n.sessionId)&&void 0!==i?i:"",windowId:null!==(e=null==n?void 0:n.windowId)&&void 0!==e?e:"",sessionStartTimestamp:null!==(s=null==n?void 0:n.sessionStartTimestamp)&&void 0!==s?s:0}}catch(t){return{sessionId:"",windowId:"",sessionStartTimestamp:0}}}get canCapture(){return this.instance.is_capturing()}get projectToken(){return this.instance.config.token}add(t){return this.eu.add(t)}getExtension(t){return this.eu.getExtension(t)}capture(t,i,e){var s=this;return Y(function*(){e?s.instance.capture(t,i,{timestamp:e.timestamp,uuid:e.uuid,$set:e.set,$set_once:e.setOnce}):s.instance.capture(t,i)})()}registerDynamicEventProperties(t){return nl(this.instance.iu(t))}handleRemoteConfig(t){this.fo||(this.Ya=t,this.instance.tu.emit(ja,t))}sendRequest(t){var i=this;return Y(function*(t,e={}){var s;const n=i.instance.requestRouter.endpointFor(null!==(s=e.target)&&void 0!==s?s:"api",t),r={method:e.method,url:e.query?Wl(n,e.query):n,data:e.body,headers:e.headers,timeout:e.timeoutMs,fireCallbackOnDrop:!0,transport:e.transport,compression:e.compression,compressionFallback:"flags"===e.target&&"best-available"===e.compression?g.Base64:void 0,timestampMode:e.sentAt};return"sendBeacon"===e.transport?(i.instance._send_request(r),{statusCode:202}):new Promise(t=>{r.callback=t,i.instance._send_request(r)})}).apply(this,arguments)}dispose(){this.fo||(this.fo=!0,this.eu.dispose())}};const La={};let Na=0;const za=()=>{},Ua='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',Ha="Surveys module not available",qa="sanitize_properties is deprecated. Use before_send instead",Va="Invalid value for property_denylist config: ",Wa=/^[A-Za-z0-9_-]{1,400}$/,Ga=/^fb\.[0-9]+\.[0-9]+\.[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)?$/,Ka=["token","distinct_id",ln],Ja="posthog";let Ya=!Ul&&-1===(null==u?void 0:u.indexOf("MSIE"))&&-1===(null==u?void 0:u.indexOf("Mozilla"));const Xa=t=>{const i={};return t&&"unset"!==t?("2025-11-30">t||(i.strictMinimumDuration=!0),"2026-05-30">t||(i.canvasCapture={resolutionScale:.6}),"2026-06-25">t||(i.streamNetworkBody=!0),"2026-08-30">t||(i.captureJsonLd=!0),i):i},Za=i=>{var e;return wi({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,asset_host:null,token:"",autocapture:!0,cross_subdomain_cookie:Bn(null==s?void 0:s.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:za,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:null!=i?i:"unset",__preview_deferred_init_extensions:!1,__preview_external_dependency_versioned_paths:!1,__preview_cookie_wins_on_conflict:!1,debug:n&&O(null==n?void 0:n.search)&&-1!==n.search.indexOf("__posthog_debug=true")||!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:"https:"===(null==t||null===(e=t.location)||void 0===e?void 0:e.protocol),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(t){je.error("Bad HTTP status: "+t.statusCode+" "+t.text)},get_device_id:t=>t,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:$n,before_send:void 0,get_current_url:void 0,request_queue_config:{flush_interval_ms:3e3},error_tracking:{},_onCapture:za},(t=>({rageclick:t&&t>="2026-05-30"?{content_ignorelist:Ar,ignore_text_selection:!0}:!t||"2025-11-30">t||{content_ignorelist:!0},capture_pageview:!t||"2025-05-24">t||"history_change",session_recording:Xa(t),external_scripts_inject_target:t&&t>="2026-01-30"?"head":"body",internal_or_test_user_hostname:t&&t>="2026-01-30"?/^(localhost|127\.0\.0\.1)$/:void 0,persistence_save_debounce_ms:t&&t>="2026-05-30"?250:0,split_storage:!(!t||"2026-05-30">t),detect_google_search_app:!(!t||"2026-05-30">t),disable_capture_url_hashes:!(!t||"2026-06-25">t),cookieWinsOnConflict:!(!t||"unset"===t||"2026-08-29">t)}))(i))},Qa=[["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"]],tu=t=>{const i={};for(const[e,s]of Qa)I(t[e])||(i[s]=t[e]);const e=In({},i,t),s=t.__preview_external_dependency_versioned_paths;return I(s)||(I(t.strict_script_versioning)&&(e.strict_script_versioning=!!s),O(s)&&I(t.asset_host)&&(e.asset_host=s)),P(t.property_blacklist)&&(I(t.property_denylist)?e.property_denylist=t.property_blacklist:P(t.property_denylist)?e.property_denylist=[...t.property_blacklist,...t.property_denylist]:je.error(Va+t.property_denylist)),e};var iu=class{constructor(){this.__forceAllowLocalhost=!1}get nu(){return this.__forceAllowLocalhost}set nu(t){je.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=t}},eu=class i{su(t){if(!t)return;const i=this.Ja.indexOf(t);-1!==i&&this.Ja.splice(i,1)}ru(t,i){var e;return this.su(t),this.Ja.push(i),null===(e=i.initialize)||void 0===e||e.call(i),i}ou(){return"always"===this.config.cookieless_mode||"on_reject"===this.config.cookieless_mode&&this.consent.isRejected()}lu(){if(this.au)return;if(this.config.reuseAnonymousId)return;if(this.config.segment)return;if(this.ou())return;const t="memory"===this.config.persistence||"sessionStorage"===this.config.persistence;if(!t&&!this.config.disable_persistence)return;if(this.uu)return;let i,e,s;t?(i=`persistence is set to '${this.config.persistence}'`,e="memory"===this.config.persistence?"on every page load":"for every new browser tab or window",s="Either set persistence to 'localStorage+cookie', keep this persistence and pass a stable ID through bootstrap.distinctID, or enable reuseAnonymousId."):(i="persistence is disabled (disable_persistence is true)",e="on every page load",s="Either set disable_persistence to false, keep persistence disabled and pass a stable ID through bootstrap.distinctID, or enable reuseAnonymousId."),this.au=!0,console.warn("[PostHog.js]",`${i} but no bootstrap.distinctID was provided. PostHog will mint a new distinct ID ${e}, 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. ${s}`)}hu(){if(this.ou()||"$posthog_cookieless"!==this.get_distinct_id())return;const t=this.persistence;if(!t)return;this.cu()||t.load(!0);const i=this.get_distinct_id();if(!i||"$posthog_cookieless"===i){const i=this.config.get_device_id(Gn());this.register({distinct_id:i,$device_id:i}),t.set_property(Zs,yn)}this.du()}get decideEndpointWasHit(){var t,i;return null!==(t=null===(i=this.featureFlags)||void 0===i?void 0:i.hasLoadedFlags)&&void 0!==t&&t}get flagsEndpointWasHit(){var t,i;return null!==(t=null===(i=this.featureFlags)||void 0===i?void 0:i.hasLoadedFlags)&&void 0!==t&&t}constructor(){var t;this.vu=!1,this.fu=!1,this.webPerformance=new iu,this.pu=!1,this.version=qe.LIB_VERSION,this.gu=new Set,this.mu="",this.tu=new ha,this.Ja=[],this.yu=[],this.uu=!1,this.au=!1,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=Za(),this.SentryIntegration=uo,this.sentryIntegration=t=>function(t,i){const e=ao(t,i);return{name:lo,processEvent:t=>e(t)}}(this,t),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.bu=!1,this._u=null,this.wu=null,this.ku=null,this.scrollManager=new la(this),this.pageViewManager=new ho(this),this.rateLimiter=new ol(this),this.requestRouter=new Pa(this),this.consent=new pr(this),this.externalIntegrations=new Aa(this);const e=null!==(t=i.__defaultExtensionClasses)&&void 0!==t?t:{};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:(t,i,e)=>{const s=O(t)?{[t]:i}:t;this.setPersonProperties(s),null==e||e({})},set_once:(t,i,e)=>{const s=O(t)?{[t]:i}:t;this.setPersonProperties(void 0,s),null==e||e({})}},this.on("eventCaptured",t=>je.info(`send "${null==t?void 0:t.event}"`,t))}init(t,e,s){if(s&&s!==Ja){var n;const r=null!==(n=La[s])&&void 0!==n?n:new i;return r._init(t,e,s),La[s]=r,La[Ja][s]=r,r}return this._init(t,e,s)}_init(i,e={},s){var n,r,o;const l=O(i)?i.trim():"";if(!l)return je.critical("PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()"),this;var a;if(this.__loaded)return l!==(null===(a=this.config)||void 0===a?void 0:a.token)?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('${l}', { ... }, 'project2')`):console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config=Za(e.defaults),e.debug=this.Su(e.debug),this.xu=e,this.Cu=[],e.person_profiles?this.wu=e.person_profiles:e.process_person&&(this.wu=e.process_person);const u=Za(e.defaults),h=tu(e),d=In({},u,h,{name:s,token:l});C(u.rageclick)&&C(h.rageclick)&&(d.rageclick=In({},u.rageclick,h.rageclick)),C(u.session_recording)&&C(h.session_recording)&&(d.session_recording=In({},u.session_recording,h.session_recording)),this.set_config(d),this.config.on_xhr_error&&je.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=e.disable_compression?void 0:Jo;const c=this.cu();if(this.persistence=new Ko(this.config,c),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new Ko(wi(wi({},this.config),{},{persistence:"sessionStorage"}),c,!1),this.mu="ph_"+(this.config.persistence_name||this.config.token)+"_session_registered_properties","memory"!==this.config.persistence&&!c&&fr.Et()){const t=fr.Dt(this.mu);P(t)&&t.forEach(t=>{O(t)&&this.gu.add(t)})}else fr.Lt(this.mu);const v=wi({},this.persistence.props),f=wi({},this.sessionPersistence.props);this.register({$initialization_time:(new Date).toISOString()}),this.$u=new na(t=>this.Tu(t),this.config.request_queue_config),this.Iu=new oa(this),this.__request_queue=[];const p=this.ou();p||(this.sessionManager=new va(this),this.sessionPropsManager=new ua(this,this.sessionManager,this.persistence),this.sessionManager.onSessionId((t,i,e)=>{((null==e?void 0:e.activityTimeout)||(null==e?void 0:e.sessionPastMaximumLength)||(null==e?void 0:e.crossTabAdoption))&&this.Mu()})),this.Eu(),this.config.__preview_deferred_init_extensions?(je.info("Deferring extension initialization to improve startup performance"),setTimeout(()=>{this.Pu(p)},0)):(je.info("Initializing extensions synchronously"),this.Pu(p)),qe.DEBUG=qe.DEBUG||this.config.debug,qe.DEBUG&&je.info("Starting in debug mode",{this:this,config:e,thisC:wi({},this.config),p:v,s:f}),this.config.identity_distinct_id&&!(null===(n=e.bootstrap)||void 0===n?void 0:n.distinctID)&&(e.bootstrap=wi(wi({},e.bootstrap),{},{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0}));const g=null===(r=e.bootstrap)||void 0===r?void 0:r.distinctID;if(this.uu=!!g&&!R(g),void 0!==(null===(o=e.bootstrap)||void 0===o?void 0:o.distinctID)){const t=e.bootstrap.distinctID,i=this.get_distinct_id(),s=this.persistence.get_property(Zs);if(e.bootstrap.isIdentifiedID&&null!=i&&i!==t&&"anonymous"===s)this.identify(t);else if(e.bootstrap.isIdentifiedID&&null!=i&&i!==t&&"identified"===s)je.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{const i=this.config.get_device_id(Gn()),s=e.bootstrap.isIdentifiedID?i:t;this.persistence.set_property(Zs,e.bootstrap.isIdentifiedID?wn:yn),this.register({distinct_id:t,$device_id:s})}}if(p)this.register_once({distinct_id:on,$device_id:null},"");else if(!this.get_distinct_id()){const t=this.config.get_device_id(Gn());this.register_once({distinct_id:t,$device_id:t},""),this.persistence.set_property(Zs,yn)}return Ln(t,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),Ln(t,"pageshow",()=>{var t;this.vu=!1,this.fu||null===(t=this.Iu)||void 0===t||t.resume()}),e.segment?oo(this,()=>this.Ru()):this.Ru(),T(this.config._onCapture)&&this.config._onCapture!==za&&(je.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",t=>this.config._onCapture(t.event,t))),this.config.ip&&je.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 pa.apply(this,arguments)}().then(t=>{t&&this.register({[Ke]:t})}).catch(za),this}Au(t){const i=t;return O(i.name)&&T(i.setup)}Fu(t,i){this.Au(t)?i.push(()=>{this.Ou().add(t).catch(()=>{var i;return null===(i=t.dispose)||void 0===i?void 0:i.call(t)}).catch(i=>{je.error(`Failed to dispose browser extension "${t.name}"`,i)})}):this.Ja.push(t)}Eu(){var t,e,s;const n=null!==(t=null===(e=this.config.__extensionClasses)||void 0===e?void 0:e.featureFlags)&&void 0!==t?t:null===(s=i.__defaultExtensionClasses)||void 0===s?void 0:s.featureFlags;var r,o,l;n&&(this.featureFlags&&this.featureFlags instanceof n||(null===(r=this.Du)||void 0===r||r.call(this),this.Du=void 0,this.featureFlags=new n(this)),T(this.featureFlags.onReloading)&&T(this.featureFlags.setup)?this.Du||(this.Du=this.featureFlags.onReloading(()=>{this.tu.emit("featureFlagsReloading",!0)}),this.Ou().add(this.featureFlags)):null===(o=(l=this.featureFlags).initialize)||void 0===o||o.call(l))}Pu(t){const e=performance.now(),s=wi(wi({},i.__defaultExtensionClasses),this.config.__extensionClasses),n=[];var r,o,l,a,u,h,d;s.exceptions&&this.Ja.push(this.exceptions=null!==(r=this.exceptions)&&void 0!==r?r:new s.exceptions(this)),s.historyAutocapture&&this.Ja.push(this.historyAutocapture=new s.historyAutocapture(this)),s.tracingHeaders&&this.Ja.push(this.tracingHeaders=new s.tracingHeaders(this)),s.siteApps&&this.Ja.push(this.siteApps=new s.siteApps(this)),s.sessionRecording&&!t&&this.Ja.push(this.sessionRecording=new s.sessionRecording(this)),this.config.disable_scroll_properties||n.push(()=>{this.scrollManager.startMeasuringScrollPosition()}),s.autocapture&&this.Fu(this.autocapture=new s.autocapture(this),n),s.surveys&&this.Fu(this.surveys=null!==(o=this.surveys)&&void 0!==o?o:new s.surveys(this),n),s.logs&&this.Fu(this.logs=null!==(l=this.logs)&&void 0!==l?l:new s.logs(this),n),s.metrics&&this.Ja.push(this.metrics=null!==(a=this.metrics)&&void 0!==a?a:new s.metrics(this)),s.conversations&&this.Ja.push(this.conversations=null!==(u=this.conversations)&&void 0!==u?u:new s.conversations(this)),s.productTours&&this.Ja.push(this.productTours=new s.productTours(this)),s.heatmaps&&this.Ja.push(this.heatmaps=new s.heatmaps(this)),s.webVitalsAutocapture&&this.Ja.push(this.webVitalsAutocapture=new s.webVitalsAutocapture(this)),s.exceptionObserver&&this.Ja.push(this.exceptionObserver=new s.exceptionObserver(this)),s.deadClicksAutocapture&&this.Ja.push(this.deadClicksAutocapture=new s.deadClicksAutocapture(this,so)),s.toolbar&&this.Ja.push(this.toolbar=null!==(h=this.toolbar)&&void 0!==h?h:new s.toolbar(this)),s.experiments&&this.Ja.push(this.experiments=null!==(d=this.experiments)&&void 0!==d?d:new s.experiments(this)),this.Ja.forEach(t=>{t.initialize&&n.push(()=>{var i;null===(i=t.initialize)||void 0===i||i.call(t)})}),n.push(()=>{if(this.Lu){const t=this.Lu;this.Lu=void 0,this.Ja.forEach(i=>{var e;return null===(e=i.onRemoteConfig)||void 0===e?void 0:e.call(i,t)})}}),this.Nu(n,e)}Nu(t,i){for(;t.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-i>=30&&t.length>0)return void setTimeout(()=>{this.Nu(t,i)},0);const e=t.shift();if(e)try{e()}catch(t){je.error("Error initializing extension:",t)}}const e=Math.round(performance.now()-i);this.register_for_session({[an]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[un]:e}),this.config.__preview_deferred_init_extensions&&je.info(`PostHog extensions initialized (${e}ms)`)}zl(t){var i;if(!s||!s.body)return je.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout(()=>{this.zl(t)},500);if(this.config.__preview_deferred_init_extensions&&(this.Lu=t),this.Xa=t,this.compression=void 0,t.ok){var e;const i=t.config;i.supportedCompression&&!this.config.disable_compression&&(this.compression=b(i.supportedCompression,Jo)?Jo:b(i.supportedCompression,Yo)?Yo:void 0),(null===(e=i.analytics)||void 0===e?void 0:e.endpoint)&&(this.analyticsDefaultEndpoint=i.analytics.endpoint)}this.set_config({person_profiles:this.wu?this.wu:$n}),null===(i=this.qu)||void 0===i||i.handleRemoteConfig(t),this.Ja.forEach(i=>{var e;return null===(e=i.onRemoteConfig)||void 0===e?void 0:e.call(i,t)})}Ru(){try{this.config.loaded(this)}catch(t){je.critical("`loaded` function failed",t)}if(this.ju(),this.config.internal_or_test_user_hostname&&(null==n?void 0:n.hostname)){const t=n.hostname,i=this.config.internal_or_test_user_hostname;("string"==typeof i?t===i:i.test(t))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout(()=>{(this.consent.isOptedIn()||this.ou())&&this.Bu()},1),this.Hu=new al(this),this.Hu.load()}ju(){var t;this.is_capturing()&&this.config.request_batching&&(null===(t=this.$u)||void 0===t||t.enable())}_dom_loaded(){this.is_capturing()&&Cn(this.__request_queue,t=>this.Tu(t)),this.__request_queue=[],this.ju()}_handle_unload(){var t,i,e,s,n,r;this.vu=!0,null===(t=this.surveys)||void 0===t||null===(i=t.handlePageUnload)||void 0===i||i.call(t),null===(e=this.metrics)||void 0===e||e.flush("sendBeacon"),this.config.request_batching?(this.zu()&&this.capture(En),null===(s=this.logs)||void 0===s||s.flushLogs("sendBeacon"),null===(n=this.$u)||void 0===n||n.unload(),null===(r=this.Iu)||void 0===r||r.unload()):this.zu()&&this.capture(En,null,{transport:"sendBeacon"})}_send_request(t){var i,e,s;this.__loaded?Ya?this.__request_queue.push(t):this.rateLimiter.isServerRateLimited(t.batchKey)?t.fireCallbackOnDrop&&(null===(e=t.callback)||void 0===e||e.call(t,{statusCode:429})):(t.transport=t.transport||this.config.api_transport,t.headers=wi(wi({},this.config.request_headers),t.headers),t.compression="best-available"===t.compression?null!==(i=this.compression)&&void 0!==i?i:t.compressionFallback:t.compression,(I(this.config.disable_beacon)?this.config.__preview_disable_beacon:this.config.disable_beacon)&&(t.disableTransport=["sendBeacon"]),t.fetchOptions=t.fetchOptions||this.config.fetch_options,(t=>{var i,e,s;const n=wi({},t);n.timeout=n.timeout||6e4;const r=null!==(i=n.transport)&&void 0!==i?i:"fetch";"sendBeacon"===r&&I(n.compression)&&n.data&&(n.compression=Yo),"POST"===n.method&&n.data&&("capture-body"===n.timestampMode?n.data=(t=>{var i,e;const s=(P(t)?t:[t]).map(t=>wi(wi({},t),t.timestamp instanceof Date&&!isNaN(t.timestamp.getTime())?{timestamp:t.timestamp.toISOString()}:{})),n=s[0];return{api_key:null!==(i=null==n||null===(e=n.properties)||void 0===e?void 0:e.token)&&void 0!==i?i:null==n?void 0:n.token,batch:s,sent_at:(new Date).toISOString()}})(n.data):"body"===n.timestampMode&&(n.data=((t,i=(new Date).toISOString())=>P(t)?t.map(t=>wi(wi({},t),{},{sent_at:i})):wi(wi({},t),{},{sent_at:i}))(n.data))),n.url=ea(n.url,n.method,n.compression,n.timestampMode);const o=sa.filter(t=>!n.disableTransport||!t.transport||!n.disableTransport.includes(t.transport)),l=null!==(e=null===(s=function(t,i){for(let e=0;t.length>e;e++)if(i(t[e]))return t[e]}(o,t=>t.transport===r))||void 0===s?void 0:s.method)&&void 0!==e?e:o[0].method;if(!l)throw new Error("No available transport method");const u=t=>{try{l(t)}catch(t){var i;Zl(t)?je.warn(t):je.error(t),null===(i=n.callback)||void 0===i||i.call(n,{statusCode:0,error:t})}};"sendBeacon"!==r&&n.data&&n.compression===Jo&&a&&"undefined"!=typeof Promise&&!ql?Yl(n).then(t=>{u(t)}).catch(i=>{if(de(i))return ql=!0,void u(wi(wi({},n),{},{compression:void 0,url:ea(t.url,t.method,void 0,t.timestampMode)}));(t=>{if(!t||"object"!=typeof t)return!1;const i="name"in t?String(t.name):"";return de(t)||i===ae})(i)&&(ql=!0),u(n)}):l(n)})(wi(wi({},t),{},{callback:i=>{var e,s,n;this.rateLimiter.checkForLimiting(i),400>i.statusCode||null===(s=(n=this.config).on_request_error)||void 0===s||s.call(n,i),null===(e=t.callback)||void 0===e||e.call(t,i)}}))):t.fireCallbackOnDrop&&(null===(s=t.callback)||void 0===s||s.call(t,{statusCode:0}))}Tu(t){this.Iu?this.Iu.retriableRequest(t):this._send_request(t)}_execute_array(t){Na++;try{let i;const e=[],s=[],n=[];Cn(t,t=>{if(t)if(i=t[0],P(i))n.push(t);else if(T(t))try{t.call(this)}catch(i){je.error("Error executing queued PostHog call",t,i)}else P(t)&&"alias"===i?e.push(t):P(t)&&-1!==i.indexOf("capture")&&T(this[i])?n.push(t):s.push(t)});const r=function(t,i){Cn(t,function(t){try{if(P(t[0])){let e=i;Fn(t,function(t){e=e[t[0]].apply(e,t.slice(1))})}else i[t[0]].apply(i,t.slice(1))}catch(i){je.error("Error executing queued PostHog call",t,i)}})};r(e,this),r(s,this),r(n,this)}finally{Na--}}push(t){if(Na>0&&P(t)&&O(t[0])){const e=i.prototype[t[0]];return void(T(e)&&e.apply(this,t.slice(1)))}this._execute_array([t])}Uu(){var t;const i=null===(t=this.persistence)||void 0===t?void 0:t.get_property(Ze);return O(i)&&Ga.test(i)?{value:i,delivered:!1}:C(i)&&O(i.value)&&Ga.test(i.value)?{value:i.value,delivered:!0===i.delivered}:void 0}Wu(t,i,e,s){if(!this.persistence)return;this.persistence.refreshKey(Ze);const n=this.Uu();if(!s){if(e)return O(i)&&Ga.test(i)?(i!==(null==n?void 0:n.value)&&this.persistence.register({[Ze]:{value:i,delivered:!1}}),{value:i,pending:i!==(null==n?void 0:n.value)||!n.delivered}):void this.persistence.unregister(Ze);if(O(t)&&Wa.test(t)){if((null==n?void 0:n.value.split(".")[3])===t)return{value:n.value,pending:!n.delivered};const i=`fb.1.${Date.now()}.${t}`;return this.persistence.register({[Ze]:{value:i,delivered:!1}}),{value:i,pending:!0}}return n?{value:n.value,pending:!n.delivered}:void 0}this.persistence.unregister(Ze)}Vu(t){if(!this.persistence)return;this.persistence.refreshKey(Ze);const i=this.Uu();(null==i?void 0:i.value)!==t||i.delivered||this.persistence.register({[Ze]:{value:t,delivered:!0}})}capture(t,i,e){var s,n,r,o,l;if(!(this.__loaded&&this.persistence&&this.sessionPersistence&&this.$u))return void je.uninitializedWarning("posthog.capture");if(!this.is_capturing())return;if(I(t)||!O(t))return void je.error("No event name provided to posthog.capture");this.hu();const a=!this.config.opt_out_useragent_filter&&this._is_bot();if(a&&!this.config.__preview_capture_bot_pageviews)return;const u=(null==e?void 0:e.skip_client_rate_limiting)?void 0:this.rateLimiter.clientRateLimitContext();if(null==u?void 0:u.isRateLimited)return void je.critical("This capture call is ignored due to client rate limiting.");let h;(null==i?void 0:i.$current_url)&&!O(null==i?void 0:i.$current_url)&&(je.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),null==i||delete i.$current_url),"$exception"!==t||(null==e?void 0:e.Gu)||je.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&&(h=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();const d=new Date,c=(null==e?void 0:e.timestamp)||d,v=ai(null==e?void 0:e.uuid,Gn);let f={uuid:v,event:t,properties:this.calculateEventProperties(t,i||{},c,v)};"$pageview"===t&&this.config.__preview_capture_bot_pageviews&&a&&(f.event="$bot_pageview",f.properties.$browser_type="bot"),u&&(f.properties.$lib_rate_limit_remaining_tokens=u.remainingTokens);const p="$feature_flag_called"===t&&!1===f.properties.$feature_flag_has_experiment&&!0===this.get_property("$minimal_flag_called_events");(null==e?void 0:e.$set)&&!p&&(f.$set=null==e?void 0:e.$set);const g=C(null==i?void 0:i.$set)?i.$set:void 0,_=!!(null==e?void 0:e.$set)&&"$fbc"in e.$set,m=_||!!g&&"$fbc"in g,b=_?null==e||null===(s=e.$set)||void 0===s?void 0:s[Xe]:null==g?void 0:g[Xe],y=P(null==i?void 0:i.$unset)?i.$unset:[],w=(null==e?void 0:e.$unset)||[],x=-1!==y.indexOf("$fbc")||-1!==w.indexOf("$fbc"),S=this.Wu(null==h?void 0:h.fbclid,b,m,x);S&&!0===f.properties.$process_person_profile&&S.pending&&!m&&!p&&(f.$set=wi({[Xe]:S.value},f.$set));const k=null==e?void 0:e.$unset;k&&(f.$unset=k);const E=p?void 0:this.Zu(null==e?void 0:e.$set_once,t!==Tn,t===Pn);if(E&&(f.$set_once=E),(null==e?void 0:e._noTruncate)||(T=this.config.properties_string_max_length,f=function(t,i){const e=new Set;return function t(s,n){if(s!==Object(s))return i?i(s):s;if(e.has(s))return;let r;if(e.add(s),P(s))r=[],Cn(s,i=>{r.push(t(i))});else{const i={};Fn(H(s)?Dn(s):s,(s,n)=>{e.has(s)||(i[n]=t(s,n))}),r=i}return r}(t)}(f,t=>O(t)?t.slice(0,T):t)),f.timestamp=c,I(null==e?void 0:e.timestamp)||(f.properties.$event_time_override_provided=!0,f.properties.$event_time_override_system_time=d),p&&(f.properties=((t,i=[])=>{const e={},s=i=>{void 0!==t[i]&&(e[i]=t[i])};return le.forEach(s),i.forEach(s),e})(f.properties,Ka)),t===tl||t===il){const e=null==i?void 0:i.$survey_id,s=null==i?void 0:i.$survey_iteration;Ca({id:e,current_iteration:s}),f.$set=wi(wi({},f.$set),{},{[ga({id:e,current_iteration:s},t===il?"responded":"dismissed")]:!0})}else t===Qo&&(f.$set=wi(wi({},f.$set),{},{[el]:(new Date).toISOString()}));var T;if("product tour shown"===t){const t=null==i?void 0:i.$product_tour_type;t&&(f.$set=wi(wi({},f.$set),{},{[`$product_tour_last_seen_date/${t}`]:(new Date).toISOString()}))}const R=wi(wi({},f.properties.$set),f.$set);if(F(R)||this.setPersonPropertiesForFlags(R),!M(this.config.before_send)){const t=this.$s(f);if(!t)return;f=t,f.uuid=ai(f.uuid,Gn)}const A=null!==(n=null===(r=f.$set)||void 0===r?void 0:r.$fbc)&&void 0!==n?n:C(null===(o=f.properties)||void 0===o?void 0:o.$set)?f.properties.$set[Xe]:void 0,D=(null==S?void 0:S.pending)&&A===S.value?S.value:void 0;this.tu.emit("eventCaptured",f);const j=null!==(l=null==e?void 0:e._url)&&void 0!==l?l:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),B=wi(wi({method:"POST",url:j,data:f,compression:"best-available",timestampMode:"recordings"===(null==e?void 0:e._batchKey)||/\/s\/(?:\?|$)/.test(j)?"body":"capture-body",batchKey:null==e?void 0:e._batchKey},(null==e?void 0:e.transport)?{transport:e.transport}:{}),D?{fireCallbackOnDrop:!0,callback:t=>{t.statusCode>=200&&300>t.statusCode&&this.Vu(D)}}:{});var L;return!this.config.request_batching||e&&!(null==e?void 0:e._batchKey)||(null==e?void 0:e.send_instantly)||D?(!B.transport&&!B.callback&&F(null!==(L=this.config.request_headers)&&void 0!==L?L:{})&&this.vu&&(B.transport="sendBeacon"),this.Tu(B)):this.$u.enqueue(B),f}_addCaptureHook(t){return this.on("eventCaptured",i=>t(i.event,i))}getExtension(t){var i;return null===(i=this.qu)||void 0===i?void 0:i.getExtension(t)}Ou(){var t;return null!==(t=this.qu)&&void 0!==t?t:this.qu=new Ba(this)}iu(t){this.yu.push(t);let i=!0;return()=>{if(!i)return;i=!1;const e=this.yu.indexOf(t);-1!==e&&this.yu.splice(e,1)}}Qu(t=!0){var i,e,s;return!!(null===(i=this.persistence)||void 0===i?void 0:i.consumeCookieIdentityChange())&&(this.ku=null,"anonymous"===this.persistence.get_property("$user_state")&&(null===(s=this.sessionPersistence)||void 0===s||s.clear(),this.gu.clear(),this.Ju()),null===(e=this.featureFlags)||void 0===e||e.reset(),t&&this.reloadFeatureFlags(),!0)}calculateEventProperties(i,e,r,o,l){if(r=r||new Date,!this.persistence||!this.sessionPersistence)return e;this.persistence.syncCookieProperties(),this.Qu();const a=l?void 0:this.persistence.remove_event_timer(i);let h=wi({},e);if(h.token=this.config.token,h.$config_defaults=this.config.defaults,this.ou()&&(h[ln]=!0),"$snapshot"===i){const t=wi(wi({},this.persistence.properties()),this.sessionPersistence.properties());return h.distinct_id=t.distinct_id,(!O(h.distinct_id)&&!D(h.distinct_id)||R(h.distinct_id))&&je.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),h}const d=function(i,e,s,r=!1){var o,l,a,h;if(!u)return{};const d=i?[...xo,...e||[]]:[],[c,v]=Qt(u),[p,g]=function(t){for(let i=0;si.length>i;i++){const[e,s,n]=si[i],r=t.match(e);if(r){const i=n&&t.match(n)||r;return[s,(null==i?void 0:i[1])||""]}}return["",""]}(u),_=function(){const t="u">typeof navigator?navigator:void 0;return(null==t?void 0:t.brave)?{brave:!0}:{}}(),m={};I(s)||(m.detectGoogleSearchApp=s);const b={},y=null===(o=navigator)||void 0===o||null===(o=o.userAgentData)||void 0===o?void 0:o.platform,w=null===(l=navigator)||void 0===l?void 0:l.maxTouchPoints,x=null==t||null===(a=t.screen)||void 0===a?void 0:a.width,S=null==t||null===(h=t.screen)||void 0===h?void 0:h.height,k=null==t?void 0:t.devicePixelRatio;I(y)||(b.userAgentDataPlatform=y),I(w)||(b.maxTouchPoints=w),I(x)||(b.screenWidth=x),I(S)||(b.screenHeight=S),I(k)||(b.devicePixelRatio=k);const E=In(Mn({$os:c,$os_version:v,$browser:Jt(u,navigator.vendor,_,m),$webview_app:p,$webview_app_version:g,$device:ti(u),$device_type:ii(u,b),$timezone:Do(),$timezone_offset:jo()}),{$current_url:bo(r?hi(null==n?void 0:n.href):null==n?void 0:n.href,d,ko),$host:null==n?void 0:n.host,$pathname:null==n?void 0:n.pathname,$raw_user_agent:u.length>1e3?u.substring(0,997)+"...":u,$browser_version:Xt(u,navigator.vendor,_,m),$browser_language:Fo(),$browser_language_prefix:Io(),$screen_height:null==t?void 0:t.screen.height,$screen_width:null==t?void 0:t.screen.width,$viewport_height:null==t?void 0:t.innerHeight,$viewport_width:null==t?void 0:t.innerWidth,$lib:f.LIB_NAME,$lib_version:f.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3});return f.SDK_DIST_CHANNEL&&(E.$sdk_dist_channel=f.SDK_DIST_CHANNEL),E}(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){const{sessionId:t,windowId:i}=this.sessionManager.checkAndGetSessionAndWindowId(l,r.getTime(),!0);h.$session_id=t,h.$window_id=i}this.sessionPropsManager&&In(h,this.sessionPropsManager.getSessionProps());try{var c;this.sessionRecording&&In(h,this.sessionRecording.sdkDebugProperties),h.$sdk_debug_retry_queue_size=null===(c=this.Iu)||void 0===c?void 0:c.length}catch(t){h.$sdk_debug_error_capturing_properties=String(t)}let v;if(this.requestRouter.region===xa&&(h.$lib_custom_api_host=this.config.api_host),v="$pageview"!==i||l?"$pageleave"!==i||l?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(r):this.pageViewManager.doPageView(r,o),h=In(h,v),"$pageview"===i&&s&&(h.title=s.title),!I(a)){const t=r.getTime()-a;h.$duration=parseFloat((t/1e3).toFixed(3))}u&&this.config.opt_out_useragent_filter&&(h.$browser_type=this._is_bot()?"bot":"browser");const p=this.persistence.properties(),g=this.sessionPersistence.properties(),_=h.$groups,m=p.$groups;C(_)&&!F(_)&&(h.$groups=wi(wi({},C(m)?m:{}),_)),Fn(["$referrer","$referring_domain"],t=>{t in p&&delete g[t]});const b={};if(this.yu.length>0)for(const t of this.yu.slice())try{In(b,t())}catch(t){je.error("Failed to produce browser extension event properties",t)}h=In({},d,p,g,wi(wi({},b),h)),h.$is_identified=this._isIdentified(),P(this.config.property_denylist)?Fn(this.config.property_denylist,function(t){delete h[t]}):je.error(Va+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);const y=this.config.sanitize_properties;y&&(je.error(qa),h=y(h,i));const w=this.Ku();return h.$process_person_profile=w,w&&!l&&this.Yu("_calculate_event_properties"),h}Zu(t,i=!0,e=!1){var s;if(!this.persistence||!this.Ku())return t;if(this.pu&&!e)return t;const n=this.persistence.get_initial_props(),r=null===(s=this.sessionPropsManager)||void 0===s?void 0:s.getSetOnceProps();let o=In({},n,r||{},t||{});const l=this.config.sanitize_properties;return l&&(je.error(qa),o=l(o,"$set_once")),i&&(this.pu=!0),F(o)?void 0:o}register(t,i){var e;null===(e=this.persistence)||void 0===e||e.register(t,i)}register_once(t,i,e){var s;null===(s=this.persistence)||void 0===s||s.register_once(t,i,e)}register_for_session(t){var i,e;null===(i=this.persistence)||void 0===i||i.syncCookieProperties(),this.Qu(),null===(e=this.sessionPersistence)||void 0===e||e.register(t),Object.keys(t).forEach(t=>this.gu.add(t)),this.Ju()}unregister(t){var i;null===(i=this.persistence)||void 0===i||i.unregister(t)}unregister_for_session(t){var i;null===(i=this.sessionPersistence)||void 0===i||i.unregister(t),this.gu.delete(t),this.Ju()}Xu(t,i){this.register({[t]:i})}Mu(){this.gu.forEach(t=>{var i;null===(i=this.sessionPersistence)||void 0===i||i.unregister(t)}),this.gu.clear(),this.Ju()}Ju(){var t;if(!this.mu)return;if("memory"===this.config.persistence||(null===(t=this.sessionPersistence)||void 0===t?void 0:t.pi)||!fr.Et())return void fr.Lt(this.mu);const i=[];this.gu.forEach(t=>i.push(t)),i.length>0?fr.At(this.mu,i):fr.Lt(this.mu)}getFeatureFlag(t,i){var e;return null===(e=this.featureFlags)||void 0===e?void 0:e.getFeatureFlag(t,i)}getFeatureFlagPayload(t){var i;return null===(i=this.featureFlags)||void 0===i?void 0:i.getFeatureFlagPayload(t)}getFeatureFlagResult(t,i){var e;return null===(e=this.featureFlags)||void 0===e?void 0:e.getFeatureFlagResult(t,i)}getAllFeatureFlags(){var t,i;return null!==(t=null===(i=this.featureFlags)||void 0===i?void 0:i.getAllFeatureFlags())&&void 0!==t?t:[]}isFeatureEnabled(t,i){var e,s;return null!==(e=null===(s=this.featureFlags)||void 0===s?void 0:s.isFeatureEnabled(t,i))&&void 0!==e?e:null==i?void 0:i.defaultValue}reloadFeatureFlags(){var t;null===(t=this.featureFlags)||void 0===t||t.reloadFeatureFlags()}updateFlags(t,i,e){var s;null===(s=this.featureFlags)||void 0===s||s.updateFlags(t,i,e)}updateEarlyAccessFeatureEnrollment(t,i,e){var s;null===(s=this.featureFlags)||void 0===s||s.updateEarlyAccessFeatureEnrollment(t,i,e)}getEarlyAccessFeatures(t,i=!1,e){var s;return null===(s=this.featureFlags)||void 0===s?void 0:s.getEarlyAccessFeatures(t,i,e)}on(t,i){return this.tu.on(t,i)}onFeatureFlags(t){return this.featureFlags?this.featureFlags.onFeatureFlags(t):(t([],{},{errorsLoading:!0}),()=>{})}onSurveysLoaded(t){return this.surveys?this.surveys.onSurveysLoaded(t):(t([],{isLoaded:!1,error:Ha}),()=>{})}onSessionId(t){var i,e;return null!==(i=null===(e=this.sessionManager)||void 0===e?void 0:e.onSessionId(t))&&void 0!==i?i:()=>{}}getSurveys(t,i=!1){this.surveys?this.surveys.getSurveys(t,i):t([],{isLoaded:!1,error:Ha})}getActiveMatchingSurveys(t,i=!1){this.surveys?this.surveys.getActiveMatchingSurveys(t,i):t([],{isLoaded:!1,error:Ha})}renderSurvey(t,i){var e;null===(e=this.surveys)||void 0===e||e.renderSurvey(t,i)}displaySurvey(t,i=Ia){var e;null===(e=this.surveys)||void 0===e||e.displaySurvey(t,i)}cancelPendingSurvey(t){var i;null===(i=this.surveys)||void 0===i||i.cancelPendingSurvey(t)}canRenderSurvey(t){var i,e;return null!==(i=null===(e=this.surveys)||void 0===e?void 0:e.canRenderSurvey(t))&&void 0!==i?i:{visible:!1,disabledReason:Ha}}canRenderSurveyAsync(t,i=!1){var e,s;return null!==(e=null===(s=this.surveys)||void 0===s?void 0:s.canRenderSurveyAsync(t,i))&&void 0!==e?e:Promise.resolve({visible:!1,disabledReason:Ha})}th(t){return!t||R(t)?(je.critical("Unique user id has not been set in posthog.identify"),!1):"$posthog_cookieless"===t?(je.critical(`The string "${t}" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.`),!1):!["distinct_id","distinctid"].includes(t.toLowerCase())&&!["undefined","null"].includes(t.toLowerCase())||(je.critical(`The string "${t}" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.`),!1)}identify(t,i,e){if(!this.__loaded||!this.persistence)return je.uninitializedWarning("posthog.identify");if(D(t)&&(t=t.toString(),je.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),!this.th(t))return;if(!this.Yu("posthog.identify"))return;this.hu();const s=this.get_distinct_id(),n=this.persistence.syncCookieProperties()&&this.get_distinct_id()!==s,r=this.Qu(!1),o=this.persistence.Sl();let l=!1;try{const s=this.get_distinct_id();this.register({$user_id:t}),this.get_property("$device_id")||this.register_once({$had_persisted_distinct_id:!0,$device_id:s},""),t!==s&&t!==this.get_property("__alias")&&(this.unregister(Je),this.register({distinct_id:t}));const o=(this.persistence.get_property("$user_state")||"anonymous")===yn,u=t!==s,h=!u&&o;if(u&&o){var a;const n=this.config.reuseAnonymousId?{distinct_id:t}:{distinct_id:t,$anon_distinct_id:s};this.persistence.set_property(Zs,wn),this.setPersonPropertiesForFlags({$set:i||{},$set_once:e||{}},!1),this.config.cookieWinsOnConflict&&this.persistence.xl(),this.capture(Pn,n,{$set:i||{},$set_once:e||{}}),this.ku=$a(t,i,e),null===(a=this.featureFlags)||void 0===a||a.setAnonymousDistinctId(this.config.reuseAnonymousId?void 0:s)}else if(h){this.persistence.set_property(Zs,wn);const s=i||{},n=e||{};this.setPersonPropertiesForFlags({$set:s,$set_once:n},!1),this.config.cookieWinsOnConflict&&this.persistence.xl(),this.capture("$set",{$set:s,$set_once:n}),this.ku=$a(t,i,e)}else(i||e)&&this.setPersonProperties(i,e);u||n||r?(this.reloadFeatureFlags(),this.featureFlags?this.featureFlags.resetFlagCallReported():this.unregister(Ks)):h&&(i||e)&&this.reloadFeatureFlags(),l=!0}finally{o&&this.persistence.Tl(l)}}setPersonProperties(t,i){if(!t&&!i)return;if(!this.Yu("posthog.setPersonProperties"))return;const e=$a(this.get_distinct_id(),t,i);this.ku!==e?(this.setPersonPropertiesForFlags({$set:t||{},$set_once:i||{}},!0),this.capture("$set",{$set:t||{},$set_once:i||{}}),this.ku=e):je.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}unsetPersonProperties(t){var i;const e=(P(t)?t:[t]).filter(t=>O(t)&&t.length>0);0!==e.length&&this.Yu("posthog.unsetPersonProperties")&&(null===(i=this.featureFlags)||void 0===i||i.unsetPersonPropertiesForFlags(e,!0),this.capture("$set",{$unset:e}),this.ku=null)}group(t,i,e){var s;if(!t||!i)return void je.error("posthog.group requires a group type and group key");null===(s=this.persistence)||void 0===s||s.syncCookieProperties(),this.Qu();const n=this.getGroups(),r=n[t]!==i;if(r&&this.resetGroupPropertiesForFlags(t),this.register({$groups:wi(wi({},n),{},{[t]:i})}),(r||e)&&this.Ku()){const s={$group_type:t,$group_key:i};e&&(s.$group_set=e),this.capture(Tn,s)}e&&this.setGroupPropertiesForFlags({[t]:e}),r&&!e&&this.reloadFeatureFlags()}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(t,i=!0){var e;null===(e=this.featureFlags)||void 0===e||e.setPersonPropertiesForFlags(t,i)}resetPersonPropertiesForFlags(t=!0){var i;null===(i=this.featureFlags)||void 0===i||i.resetPersonPropertiesForFlags(t)}setGroupPropertiesForFlags(t,i=!0){var e;this.Yu("posthog.setGroupPropertiesForFlags")&&(null===(e=this.featureFlags)||void 0===e||e.setGroupPropertiesForFlags(t,i))}resetGroupPropertiesForFlags(t){var i;null===(i=this.featureFlags)||void 0===i||i.resetGroupPropertiesForFlags(t)}reset(t){const i=B(t)?t:null==t?void 0:t.resetDeviceID,e=B(t)||null==t?void 0:t.bootstrap;this.eh(i,!1,e)}eh(t,i=!1,e){var s,n,r,o,l,a;if(je.info("reset"),!this.__loaded)return je.uninitializedWarning("posthog.reset");const u=null==e?void 0:e.sessionID;this.config.bootstrap=e||(null===(s=this.xu)||void 0===s?void 0:s.bootstrap)||{},null===(n=this.featureFlags)||void 0===n||null===(r=n.updateConfig)||void 0===r||r.call(n,this.config,this.Ul());const h=this.get_property(Ge),d=this.get_property(Ke),c=this.get_property(hs);null===(o=this.sessionRecording)||void 0===o||o.flushBeforeIdentityReset();const v=this.is_capturing();this.consent.reset(),i||!v||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.");const f=null===(l=this.persistence)||void 0===l||null===(a=l.Sl)||void 0===a?void 0:a.call(l);let p=!1;try{var g,_,m,b,y,w,x,S,k,E,P,T,C;if(null===(g=this.persistence)||void 0===g||g.clear(),null===(_=this.sessionPersistence)||void 0===_||_.clear(),this.gu.clear(),this.Ju(),I(c)||null===(E=this.persistence)||void 0===E||E.register({$session_recording_remote_config:c}),null===(m=this.surveys)||void 0===m||m.reset(),null===(b=this.featureFlags)||void 0===b||b.reset(),null===(y=this.conversations)||void 0===y||y.reset(),null===(w=this.logs)||void 0===w||w.reset(),null===(x=this.metrics)||void 0===x||x.reset(),null===(S=this.persistence)||void 0===S||S.set_property("$user_state","anonymous"),null===(k=this.sessionManager)||void 0===k||k.resetSessionId(),this.ku=null,"always"===this.config.cookieless_mode)this.register_once({distinct_id:on,$device_id:null},"");else{const i=this.config.get_device_id(Gn());this.register_once({distinct_id:i,$device_id:t?i:h},""),t||I(d)||this.register({[Ke]:d})}if(this.register({$last_posthog_reset:(new Date).toISOString()},1),e)if(void 0===e.distinctID||this.ou()||(null===(C=this.persistence)||void 0===C||C.set_property("$user_state",e.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:e.distinctID})),null===(P=this.featureFlags)||void 0===P||P.initialize(),!I(u)&&!(null===(T=this.sessionManager)||void 0===T?void 0:T.setBootstrapSessionId(u,!0))){const t=wi({},e);delete t.sessionID,this.config.bootstrap=t}delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,p=!0}finally{var F,O;f&&(null===(F=this.persistence)||void 0===F||null===(O=F.Tl)||void 0===O||O.call(F,p))}this.reloadFeatureFlags()}shutdown(t){var i=this;return Y(function*(){var t,e,s,n,r,o,l;if(i.__loaded){i.fu=!0,i.Ou().dispose(),null===(t=i.sessionRecording)||void 0===t||t.dispose(),null===(e=i.logs)||void 0===e||e.flushLogs("sendBeacon"),null===(s=i.metrics)||void 0===s||s.flush("sendBeacon"),null===(n=i.$u)||void 0===n||n.unload(),null===(r=i.Iu)||void 0===r||r.unload();try{var a;null===(a=i.featureFlags)||void 0===a||a.destroy()}catch(t){je.error("Error while destroying feature flags",t)}null===(o=i.persistence)||void 0===o||o.destroy(),null===(l=i.sessionPersistence)||void 0===l||l.destroy()}else je.uninitializedWarning("posthog.shutdown")})()}setIdentity(t,i){var e;delete this.config.identity_claims,this.config.identity_distinct_id=t,this.config.identity_hash=i,this.alias(t),null===(e=this.conversations)||void 0===e||e.ih()}clearIdentity(){var t;delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,null===(t=this.conversations)||void 0===t||t.nh()}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var t,i;return null!==(t=null===(i=this.sessionManager)||void 0===i?void 0:i.checkAndGetSessionAndWindowId(!0).sessionId)&&void 0!==t?t:""}get_session_replay_url(t){if(!this.sessionManager)return"";const{sessionId:i,sessionStartTimestamp:e}=this.sessionManager.checkAndGetSessionAndWindowId(!0);let s=this.requestRouter.endpointFor("ui",`/project/${this.config.token}/replay/${i}`);if((null==t?void 0:t.withTimestamp)&&e){var n;const i=null!==(n=t.timestampLookBack)&&void 0!==n?n:10;if(!e)return s;s+=`?t=${Math.max(Math.floor(((new Date).getTime()-e)/1e3)-i,0)}`}return s}alias(t,i){return t===this.get_property("$people_distinct_id")?(je.critical("Attempting to create alias for existing People user - aborting."),-2):this.Yu("posthog.alias")?(I(i)&&(i=this.get_distinct_id()),t!==i?(this.Xu(Je,t),this.capture("$create_alias",{alias:t,distinct_id:i})):(je.warn("alias matches current distinct_id - skipping api call."),this.identify(t),-1)):void 0}set_config(t){const i=wi({},this.config);if(C(t)){var e,s,n,r,o,l,a,u,h,d,c,v,f;In(this.config,tu(t));const g=this.cu();null===(e=this.persistence)||void 0===e||e.update_config(this.config,i,g),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new Ko(wi(wi({},this.config),{},{persistence:"sessionStorage"}),g,!1);const _=this.Su(this.config.debug);var p;B(_)&&(this.config.debug=_),B(this.config.debug)&&(this.config.debug?(qe.DEBUG=!0,tr.Et()&&tr.At("ph_debug",!0),je.info("set_config",{config:t,oldConfig:i,newConfig:wi({},this.config)})):(qe.DEBUG=!1,tr.Et()&&tr.Lt("ph_debug"))),null===(s=this.featureFlags)||void 0===s||null===(n=s.updateConfig)||void 0===n||n.call(s,this.config,this.Ul()),null===(r=this.exceptionObserver)||void 0===r||r.onConfigChange(),null===(o=this.exceptions)||void 0===o||o.onConfigChange(),null===(l=this.sessionRecording)||void 0===l||l.startIfEnabledOrStop(),null===(a=this.tracingHeaders)||void 0===a||a.startIfEnabledOrStop(),null===(u=this.autocapture)||void 0===u||u.startIfEnabled(),null===(h=this.heatmaps)||void 0===h||h.startIfEnabled(),("capture_pageview"in t||"disable_capture_url_hashes"in t)&&(null===(p=this.historyAutocapture)||void 0===p||p.startIfEnabledOrStop()),null===(d=this.exceptionObserver)||void 0===d||d.startIfEnabledOrStop(),null===(c=this.deadClicksAutocapture)||void 0===c||c.startIfEnabledOrStop(),null===(v=this.surveys)||void 0===v||v.loadIfEnabled(),this.du(),null===(f=this.externalIntegrations)||void 0===f||f.startIfEnabledOrStop(),!i.segment&&this.config.segment&&this.persistence&&oo(this,za,!1)}}_overrideSDKInfo(t,i){qe.LIB_NAME=t,qe.LIB_VERSION=i}startSessionRecording(t){const i=!0===t,e={sampling:i||!!(null==t?void 0:t.sampling),linked_flag:i||!!(null==t?void 0:t.linked_flag),url_trigger:i||!!(null==t?void 0:t.url_trigger),event_trigger:i||!!(null==t?void 0:t.event_trigger)};var s,n,r,o,l;Object.values(e).some(Boolean)&&(null===(s=this.sessionManager)||void 0===s||s.checkAndGetSessionAndWindowId(),e.sampling&&(null===(n=this.sessionRecording)||void 0===n||n.overrideSampling()),e.linked_flag&&(null===(r=this.sessionRecording)||void 0===r||r.overrideLinkedFlag()),e.url_trigger&&(null===(o=this.sessionRecording)||void 0===o||o.overrideTrigger("url")),e.event_trigger&&(null===(l=this.sessionRecording)||void 0===l||l.overrideTrigger("event")));this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var t;return!!(null===(t=this.sessionRecording)||void 0===t?void 0:t.started)}captureException(t,i){try{if(!this.exceptions)return;const e=this.exceptions.buildProperties(t,{handled:!0,syntheticException:new Error("PostHog syntheticException")});return this.exceptions.sendExceptionEvent(wi(wi({},e),i))}catch(t){return}}addExceptionStep(t,i){var e;null===(e=this.exceptions)||void 0===e||e.addExceptionStep(t,i)}captureLog(t){var i;null===(i=this.logs)||void 0===i||i.captureLog(t)}get logger(){var t,e;return null!==(t=null===(e=this.logs)||void 0===e?void 0:e.logger)&&void 0!==t?t:i.sh}startExceptionAutocapture(t){this.set_config({capture_exceptions:null==t||t})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(t){var i,e;return null!==(i=null===(e=this.toolbar)||void 0===e?void 0:e.loadToolbar(t))&&void 0!==i&&i}get_property(t){var i;return null===(i=this.persistence)||void 0===i?void 0:i.props[t]}getSessionProperty(t){var i;return null===(i=this.sessionPersistence)||void 0===i?void 0:i.props[t]}toString(){var t;let i=null!==(t=this.config.name)&&void 0!==t?t:Ja;return i!==Ja&&(i="posthog."+i),i}_isIdentified(){var t,i;return"identified"===(null===(t=this.persistence)||void 0===t?void 0:t.get_property("$user_state"))||"identified"===(null===(i=this.sessionPersistence)||void 0===i?void 0:i.get_property("$user_state"))}Ku(){var t,i;return!("never"===this.config.person_profiles||"identified_only"===this.config.person_profiles&&!this._isIdentified()&&F(this.getGroups())&&!(null===(t=this.persistence)||void 0===t||null===(t=t.props)||void 0===t?void 0:t.__alias)&&!(null===(i=this.persistence)||void 0===i||null===(i=i.props)||void 0===i?void 0:i.$epp))}zu(){return!0===this.config.capture_pageleave||"if_capture_pageview"===this.config.capture_pageleave&&!!this.config.capture_pageview}createPersonProfile(){this.Ku()||this.Yu("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.Yu("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}Yu(t){return"never"===this.config.person_profiles?(je.error(t+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.lu(),this.Xu(rn,!0),!0)}cu(){if("always"===this.config.cookieless_mode)return!0;const t=this.consent.isOptedOut();return this.config.disable_persistence||t&&!(!this.config.opt_out_persistence_by_default&&"on_reject"!==this.config.cookieless_mode)}du(){var t,i;const e=this.cu();var s,n,r;return this.is_capturing()||null===(s=this.logs)||void 0===s||s.rh(),(null===(t=this.persistence)||void 0===t?void 0:t.pi)!==e&&(null===(n=this.persistence)||void 0===n||n.set_disabled(e)),(null===(i=this.sessionPersistence)||void 0===i?void 0:i.pi)!==e&&(null===(r=this.sessionPersistence)||void 0===r||r.set_disabled(e)),e&&(this.gu.clear(),this.Ju()),e}opt_in_capturing(t){var e;if("always"!==this.config.cookieless_mode){if(this.ou()){var s,n,r,o,l,a;null===(s=this.sessionRecording)||void 0===s||s.dispose({discardBufferedEvents:!0}),this.eh(!0,!0),null===(n=this.sessionManager)||void 0===n||n.destroy(),null===(r=this.pageViewManager)||void 0===r||r.destroy(),this.sessionManager=new va(this),this.pageViewManager=new ho(this),this.persistence&&(this.sessionPropsManager=new ua(this,this.sessionManager,this.persistence));const t=null!==(o=null===(l=this.config.__extensionClasses)||void 0===l?void 0:l.sessionRecording)&&void 0!==o?o:null===(a=i.__defaultExtensionClasses)||void 0===a?void 0:a.sessionRecording;var u,h;t&&(this.sessionRecording=this.ru(this.sessionRecording,new t(this)),this.Xa&&(null===(u=this.sessionRecording)||void 0===u||null===(h=u.onRemoteConfig)||void 0===h||h.call(u,this.Xa)))}var d,c;this.consent.optInOut(!0),this.du(),this.ju(),null===(e=this.sessionRecording)||void 0===e||e.startIfEnabledOrStop(),"on_reject"==this.config.cookieless_mode&&(null===(d=this.surveys)||void 0===d||d.loadIfEnabled()),(I(null==t?void 0:t.captureEventName)||(null==t?void 0:t.captureEventName))&&this.capture(null!==(c=null==t?void 0:t.captureEventName)&&void 0!==c?c:"$opt_in",null==t?void 0:t.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.Bu()}else je.warn(Ua)}opt_out_capturing(){if("always"===this.config.cookieless_mode)return void je.warn(Ua);const t="on_reject"===this.config.cookieless_mode?this.sessionRecording:void 0;var i,e;null==t||t.dispose({discardBufferedEvents:!0}),"on_reject"===this.config.cookieless_mode&&this.consent.isOptedIn()&&this.eh(!0,!0),this.consent.optInOut(!1),this.du(),"on_reject"===this.config.cookieless_mode&&(this.register({distinct_id:on,$device_id:null}),this.su(t),this.sessionRecording=void 0,null===(i=this.sessionManager)||void 0===i||i.destroy(),null===(e=this.pageViewManager)||void 0===e||e.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,this.config.capture_pageview&&this.Bu(),this.ju())}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){const t=this.consent.consent;return 1===t?"granted":0===t?"denied":"pending"}is_capturing(){return"always"===this.config.cookieless_mode||("on_reject"===this.config.cookieless_mode?this.consent.isRejected()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this.du()}_is_bot(){return e?fa(e,this.config.custom_blocked_useragents):void 0}Bu(){s&&("visible"===s.visibilityState?this.bu||(this.bu=!0,this.capture(kn,{title:s.title},{send_instantly:!0}),this._u&&(s.removeEventListener(xn,this._u),this._u=null)):this._u||(this._u=this.Bu.bind(this),Ln(s,xn,this._u)))}debug(i){!1===i?(null==t||t.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(null==t||t.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}))}Ul(){const t=this.xu||{};return"advanced_disable_flags"in t?!!t.advanced_disable_flags:!1!==this.config.advanced_disable_flags?!!this.config.advanced_disable_flags:!0===this.config.advanced_disable_decide?(je.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(t,i,e,s,n){const r=i in t&&!M(t[i]),o=e in t&&!M(t[e]);return r?t[i]:!!o&&(n&&n.warn(`Config field '${e}' is deprecated. Please use '${i}' instead. The old field will be removed in a future major version.`),t[e])}(t,"advanced_disable_flags","advanced_disable_decide",0,je)}$s(t){var i;if(M(this.config.before_send))return t;const e=Object.keys(null!==(i=t.properties)&&void 0!==i?i:{}).filter(N),s=P(this.config.before_send)?this.config.before_send:[this.config.before_send];let n=t;for(const i of s)try{if(n=i(n),M(n)){const i=`Event '${t.event}' was rejected in beforeSend function`;return L(t.event)?je.warn(`${i}. This can cause unexpected behavior.`):je.info(i),null}n.properties&&!F(n.properties)||je.warn(`Event '${t.event}' has no properties after beforeSend function, this is likely an error.`)}catch(i){return je.error(`Error in beforeSend function for event '${t.event}':`,i),null}for(const i of e)if(n.properties&&M(n.properties[i]))return je.warn(`Event '${t.event}' had its '${i}' property removed in a beforeSend function. This property is required for ingestion, so the event will be dropped.`),null;return n}getPageViewId(){var t;return null===(t=this.pageViewManager.Ao)||void 0===t?void 0:t.pageViewId}captureTraceFeedback(t,i){this.capture("$ai_feedback",{$ai_trace_id:String(t),$ai_feedback_text:i})}captureTraceMetric(t,i,e){this.capture("$ai_metric",{$ai_trace_id:String(t),$ai_metric_name:i,$ai_metric_value:String(e)})}Su(t){const i=B(t)&&!t,e=tr.Et()&&"true"===tr.Ot("ph_debug");return!i&&(!!e||t)}};eu.__defaultExtensionClasses={},eu.sh=(()=>{const t=()=>{};return{trace:t,debug:t,info:t,warn:t,error:t,fatal:t}})(),function(t,i){for(let e=0;i.length>e;e++)t.prototype[i[e]]=An(t.prototype[i[e]])}(eu,["identify"]);var su=class{constructor(t){this.disabled=!1===t;const i=C(t)?t:{};this.thresholdPx=i.threshold_px||30,this.timeoutMs=i.timeout_ms||1e3,this.clickCount=i.click_count||3,this.clicks=[]}isRageClick(t,i,e){if(this.disabled)return!1;const s=this.clicks[this.clicks.length-1];if(s&&Math.abs(t-s.x)+Math.abs(i-s.y)<this.thresholdPx&&this.timeoutMs>e-s.timestamp){if(this.clicks.push({x:t,y:i,timestamp:e}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:t,y:i,timestamp:e}];return!1}};const nu="$copy_autocapture",ru=Be("[AutoCapture]");function ou(t,i){return i.length>t?i.slice(0,t)+"...":i}function lu(t){if(t.previousElementSibling)return t.previousElementSibling;let i=t;do{i=i.previousSibling}while(i&&!mr(i));return i}function au(i,{e:e,maskAllElementAttributes:s,maskAllText:n,elementAttributeIgnoreList:r,elementsChainAsString:o,disableCaptureUrlHashes:l}){var a,u;if(!mr(i))return{props:{}};const h=[i],d=new Set([i]);let c=i;for(;c.parentNode&&!br(c,"body")&&1e3>h.length;){if(wr(c.parentNode)){const t=c.parentNode.host;if(d.has(t))break;d.add(t),h.push(t),c=t;continue}if(!mr(c.parentNode))break;if(d.has(c.parentNode))break;d.add(c.parentNode),h.push(c.parentNode),c=c.parentNode}const v="click"===e.type&&"http://www.w3.org/2000/svg"===i.namespaceURI?h.findIndex(t=>br(t,"button")||br(t,"a")):-1;v>0&&(n=n||h.slice(0,v+1).some(t=>!zr(t)||Ur(t)));const f=[],p={};let g,_=!1,m=!1;if(Fn(h,t=>{const i=zr(t);if(br(t,"a")){const e=t.getAttribute("href");_=!!(i&&e&&Yr(e))&&(l?hi(e):e)}b(Sr(t),"ph-no-capture")&&(m=!0),f.push(function(t,i,e,s,n=!1){const r=t.tagName.toLowerCase(),o={tag_name:r};Tr.indexOf(r)>-1&&!e&&(o.$el_text="a"===r.toLowerCase()||"button"===r.toLowerCase()?ou(1024,Xr(t)):ou(1024,Er(t)));const l=Sr(t);l.length>0&&(o.classes=l.filter(function(t){return""!==t})),Fn(t.attributes,function(e){var r;if((!Ur(t)||-1!==["name","id","class","aria-label"].indexOf(e.name))&&!(null==s?void 0:s.includes(e.name))&&!i&&Yr(e.value)&&(!O(r=e.name)||"_ngcontent"!==r.substring(0,10)&&"_nghost"!==r.substring(0,7))){let t=e.value;"class"===e.name&&(t=$r(t).join(" ")),o["attr__"+e.name]=ou(1024,"href"===e.name&&n?hi(t):t)}});let a=1,u=1,h=t;for(;h=lu(h);)a++,h.tagName===t.tagName&&u++;return o.nth_child=a,o.nth_of_type=u,o}(t,s,n,r,l)),Fn(function(t){if(!zr(t))return{};const i={};return Fn(t.attributes,function(t){if(t.name&&0===t.name.indexOf("data-ph-capture-attribute")){const e=t.name.replace("data-ph-capture-attribute-",""),s=t.value;e&&s&&Yr(s)&&(i[e]=s)}}),i}(t),(t,i)=>{({}).hasOwnProperty.call(p,i)||(p[i]=t)})}),m)return{props:{},explicitNoCapture:m};if(v>0&&(i=h[v],f.splice(0,v)),n||(f[0].$el_text=br(i,"a")||br(i,"button")?Xr(i):Er(i)),_){var y,w;f[0].attr__href=_;const i=null===(y=_o(_))||void 0===y?void 0:y.host,e=null==t||null===(w=t.location)||void 0===w?void 0:w.host;i&&e&&i!==e&&(g=_)}return{props:In((S=e.type,{$event_type:S,$ce_version:1}),o?{}:{$elements:f},{$elements_chain:(x=f,P(x)?function(t){return t.map(t=>{var i,e;let s="";if(t.tag_name&&(s+=t.tag_name),t.attr_class){t.attr_class.sort();for(const i of t.attr_class)s+=`.${i.replace(/"/g,"")}`}const n=wi(wi(wi(wi({},t.text?{text:t.text}:{}),{},{"nth-child":null!==(i=t.nth_child)&&void 0!==i?i:0,"nth-of-type":null!==(e=t.nth_of_type)&&void 0!==e?e:0},t.href?{href:t.href}:{}),t.attr_id?{attr_id:t.attr_id}:{}),t.attributes),r={};return On(n).sort(([t],[i])=>function(t,i){return i>t?-1:t>i?1:0}(t,i)).forEach(([t,i])=>r[Qr(t.toString())]=Qr(i.toString())),s+=":",s+=On(r).map(([t,i])=>`${t}="${i}"`).join(""),s}).join(";")}(function(t){return t.map(t=>{var i,e;const s={text:null===(i=t.$el_text)||void 0===i?void 0:i.slice(0,400),tag_name:t.tag_name,href:null===(e=t.attr__href)||void 0===e?void 0:e.slice(0,2048),attr_class:to(t),attr_id:t.attr__id,nth_child:t.nth_child,nth_of_type:t.nth_of_type,attributes:{}};return On(t).filter(([t])=>0===t.indexOf("attr__")).forEach(([t,i])=>s.attributes[t]=i),s})}(x)):"")},(null===(a=f[0])||void 0===a?void 0:a.$el_text)?{$el_text:null===(u=f[0])||void 0===u?void 0:u.$el_text}:{},g&&"click"===e.type?{$external_click_url:g}:{},p),target:i};var x,S}var uu=class{Js(){this.Ks=void 0,clearTimeout(this.Ys),this.Ys=void 0}Xs(t){var i;if(!zr(t))return!0;const e=null!==(i=this.so().css_selector_ignorelist)&&void 0!==i?i:Or,s=new Set;let n=t;for(;n;){if(s.size>=1e3||s.has(n))return!0;s.add(n);const t=n,i=Sr(t);if(b(i,"ph-no-capture")||b(i,"ph-sensitive")||Ur(t)||e.some(i=>Cr(t,i)))return!0;const r=n.parentNode;n=wr(r)?r.host:r&&mr(r)?r:null}return!1}oo(t){if(!this.isEnabled||"pointercancel"===t.type)return void this.Js();if("pointerdown"===t.type){this.Js();const e=Pr(t);var i;return void(t.isPrimary&&0===t.button&&!t.ctrlKey&&e&&mr(e)&&(this.Ks={target:e,excluded:this.Xs(e),id:t.pointerId,x:t.clientX,y:t.clientY,released:!1,distinctId:null===(i=this.lo)||void 0===i?void 0:i.distinctId}))}const e=this.Ks;e&&(t.pointerId!==e.id||Math.abs(t.clientX-e.x)>5||Math.abs(t.clientY-e.y)>5?this.Js():"pointerup"===t.type&&(e.released=!0,this.Ys=setTimeout(()=>this.Js(),0)))}ao(t){var i;const e=this.Ks;this.Js();const n=Pr(t);if((null==e?void 0:e.released)&&e.target.isConnected&&e.distinctId===(null===(i=this.lo)||void 0===i?void 0:i.distinctId)&&t.pointerId===e.id&&(t.detail>0||"touch"===t.pointerType||"pen"===t.pointerType)&&0===t.button&&5>=Math.abs(t.clientX-e.x)&&5>=Math.abs(t.clientY-e.y)&&n&&(br(n,"html")||br(n,"body"))){var r;if(e.excluded)return null;const t=null!==(r=this.so().css_selector_ignorelist)&&void 0!==r?r:Or;return[n,null==s?void 0:s.documentElement,null==s?void 0:s.body].some(i=>{if(!i)return!1;const e=Sr(i);return b(e,"ph-no-capture")||b(e,"ph-sensitive")||!zr(i)||Ur(i)||t.some(t=>Cr(i,t))})?null:e.target}}constructor(t){this.uo=t,this.name="autocapture",this.ho=!1,this.co=null,this.do=!1,this.vo=!1,this.Sr={enabled:!1,rageclick:!1,maskAllElementAttributes:!1,maskAllText:!1,disableCaptureUrlHashes:!1,remoteRequestsDisabled:!1},this.fo=!1,this.uo.refresh(this.Sr),this.rageclicks=new su(this.Sr.rageclick),this.po=null}setup(t){this.mo(),this.lo=t;const i=t.onRemoteConfig(this.onRemoteConfig.bind(this));this.fo?i.dispose():(this.yo=i,this.startIfEnabled())}dispose(){var t;this.fo||(this.fo=!0,this.lo=void 0,null===(t=this.yo)||void 0===t||t.dispose(),this.yo=void 0,this.bo())}so(){return this.uo.refresh(this.Sr),this.Sr}mo(){var t,i;return this.so(),this.Sr.url_allowlist=null===(t=this.Sr.url_allowlist)||void 0===t?void 0:t.map(t=>new RegExp(t)),this.Sr.url_ignorelist=null===(i=this.Sr.url_ignorelist)||void 0===i?void 0:i.map(t=>new RegExp(t)),this.Sr}_o(){if(!this.isBrowserSupported())return void ru.info("Disabling Automatic Event Collection because this browser is not supported");if(!t||!s)return;const i=this.wo=i=>{i=i||(null==t?void 0:t.event);try{if("blur"===i.type)return void this.Js();if(0===i.type.indexOf("pointer"))return void this.oo(i);const t="click"===i.type?this.ao(i):void 0;if(A(t))return;this.ko(i,"$autocapture",t)}catch(t){ru.error("Failed to capture event",t)}};if(Ln(t,"blur",i),Ln(s,"submit",i,{capture:!0}),Ln(s,"change",i,{capture:!0}),Ln(s,"click",i,{capture:!0}),Fn(["pointerdown","pointermove","pointerup","pointercancel"],t=>{Ln(s,t,i,{capture:!0})}),this.so().capture_copied_text){const i=this.So=i=>{i=i||(null==t?void 0:t.event);try{this.ko(i,nu)}catch(t){ru.error("Failed to capture clipboard event",t)}};Ln(s,"copy",i,{capture:!0}),Ln(s,"cut",i,{capture:!0}),Ln(s,"paste",i,{capture:!0})}}bo(){this.Js(),this.wo&&(null==t||t.removeEventListener("blur",this.wo),Fn(["pointerdown","pointermove","pointerup","pointercancel"],t=>{null==s||s.removeEventListener(t,this.wo,!0)}),null==s||s.removeEventListener("submit",this.wo,!0),null==s||s.removeEventListener("change",this.wo,!0),null==s||s.removeEventListener("click",this.wo,!0),this.wo=void 0),this.So&&(null==s||s.removeEventListener("copy",this.So,!0),null==s||s.removeEventListener("cut",this.So,!0),null==s||s.removeEventListener("paste",this.So,!0),this.So=void 0),this.ho=!1}startIfEnabled(){this.isEnabled||this.Js(),!this.fo&&this.lo&&this.isEnabled&&!this.ho&&(this._o(),this.ho=!0)}onRemoteConfig(t){if(this.fo)return;if(this.do=!0,!t.ok)return void this.startIfEnabled();const i=t.config;i.elementsChainAsString&&(this.vo=i.elementsChainAsString);const e=i.autocapture_opt_out;var s;B(e)&&(null===(s=this.lo)||void 0===s||s.kv.set("$autocapture_disabled_server_side",e),this.co=e),this.startIfEnabled()}setElementSelectors(t){this.po=t}getElementSelectors(t,i){var e;const n=[];return null===(e=this.po)||void 0===e||e.forEach(e=>{const r=null==s?void 0:s.querySelectorAll(e);null==r||r.forEach(s=>{t!==s&&i!==s||b(n,e)||n.push(e)})}),n}get isEnabled(){var t,i;if(this.fo)return!1;const e=null===(t=this.lo)||void 0===t?void 0:t.kv.get(ts),s=this.co,n=this.so();if(!n.remoteRequestsDisabled&&!this.do)return!1;const r=n.remoteRequestsDisabled&&!this.do;if(A(s)&&!B(e)&&!r)return!1;const o=null!==(i=this.co)&&void 0!==i?i:!!e;return!!n.enabled&&!o}ko(i,e="$autocapture",s){if(!this.isEnabled)return void this.Js();let n=s||Pr(i);yr(n)&&(n=n.parentNode||null);const r=this.mo();var o;"$autocapture"===e&&"click"===i.type&&i instanceof MouseEvent&&r.rageclick&&(null===(o=this.rageclicks)||void 0===o?void 0:o.isRageClick(i.clientX,i.clientY,i.timeStamp||(new Date).getTime()))&&Br(n,r.rageclick)&&this.ko(i,"$rageclick",s);const l=e===nu,a=l?wi(wi({},r),{},{dom_event_allowlist:void 0}):r;if(n&&function(i,e,s,n,r,o){var l;if(!t||Lr(i))return!1;if((null==s?void 0:s.url_allowlist)&&!xr(s.url_allowlist,o))return!1;if((null==s?void 0:s.url_ignorelist)&&xr(s.url_ignorelist,o))return!1;if(null==s?void 0:s.dom_event_allowlist){const t=s.dom_event_allowlist;if(t&&!t.some(t=>e.type===t))return!1}const{parentIsUsefulElement:a,targetElementList:u}=Nr(i,n);if(!function(t,i){const e=null==i?void 0:i.element_allowlist;if(I(e))return!0;for(const i of t)if(e.some(t=>i.tagName.toLowerCase()===t))return!0;return!1}(u,s))return!1;if(!Fr(u,null==s?void 0:s.css_selector_allowlist))return!1;if(Fr(u,null!==(l=null==s?void 0:s.css_selector_ignorelist)&&void 0!==l?l:Or))return!1;try{const s=t.getComputedStyle(i);if(s&&"pointer"===s.getPropertyValue("cursor")&&"click"===e.type)return!0}catch(t){}const h=i.tagName.toLowerCase();switch(h){case"html":return!1;case"form":return(r||["submit"]).indexOf(e.type)>=0;case"input":case"select":case"textarea":return(r||["change","click"]).indexOf(e.type)>=0;default:return a?(r||["click"]).indexOf(e.type)>=0:(r||["click"]).indexOf(e.type)>=0&&(Tr.indexOf(h)>-1||"true"===i.getAttribute("contenteditable"))}}(n,i,a,l,l?["copy","cut","paste"]:void 0,{config:{get_current_url:r.getCurrentUrl}})){var u;const{props:s,explicitNoCapture:o,target:l}=au(n,{e:i,maskAllElementAttributes:r.maskAllElementAttributes,maskAllText:r.maskAllText,elementAttributeIgnoreList:r.element_attribute_ignorelist,elementsChainAsString:this.vo,disableCaptureUrlHashes:r.disableCaptureUrlHashes});if(o)return!1;const a=this.getElementSelectors(n,l);if(a&&a.length>0&&(s.$element_selectors=a),e===nu){const e=i.type||"clipboard";if("paste"!==e){var h,d;const i=null==t||null===(h=t.getSelection())||void 0===h?void 0:h.toString(),e=kr(i);if(!e)return!1;s.$selected_content=e,s.$clipboard_text_length=null!==(d=null==i?void 0:i.length)&&void 0!==d?d:0}s.$copy_type=e}return null===(u=this.lo)||void 0===u||u.capture(e,s).catch(t=>ru.error("Failed to capture event",t)),!0}}isBrowserSupported(){return T(null==s?void 0:s.querySelectorAll)}},hu=class{constructor(t){this._instance=t}refresh(t){const i=this._instance.config,e=C(i.autocapture)?i.autocapture:void 0;t.enabled=!!i.autocapture,t.rageclick=i.rageclick,t.maskAllElementAttributes=i.mask_all_element_attributes,t.maskAllText=i.mask_all_text,t.disableCaptureUrlHashes=i.disable_capture_url_hashes,t.getCurrentUrl=i.get_current_url,t.remoteRequestsDisabled=this._instance.Ul(),t.url_allowlist=null==e?void 0:e.url_allowlist,t.url_ignorelist=null==e?void 0:e.url_ignorelist,t.dom_event_allowlist=null==e?void 0:e.dom_event_allowlist,t.element_allowlist=null==e?void 0:e.element_allowlist,t.css_selector_allowlist=null==e?void 0:e.css_selector_allowlist,t.css_selector_ignorelist=null==e?void 0:e.css_selector_ignorelist,t.element_attribute_ignorelist=null==e?void 0:e.element_attribute_ignorelist,t.capture_copied_text=null==e?void 0:e.capture_copied_text}};const du=Be("[ExceptionAutocapture]"),cu=()=>{},vu=t=>{var i;if(T(t))return null!==(i=t.__posthog_layer__)&&void 0!==i?i:t.__rrweb_layer__};function fu(t,i,e){try{if(!(i in t))return cu;const s={next:t[i]},n=e(function(...t){return s.next.apply(this,t)});return T(n)&&(n.prototype=n.prototype||{},Object.defineProperties(n,{__posthog_wrapped__:{enumerable:!1,value:!0},__posthog_layer__:{enumerable:!1,value:s}})),t[i]=n,()=>{if(t[i]===n)return void(t[i]=s.next);let e=t[i],r=vu(e);for(;r;){if(r.next===n)return void(r.next=s.next);e=r.next,r=vu(e)}}}catch(t){return cu}}const pu=Be("[TracingHeaders]"),gu=Be("[Web Vitals]"),_u=9e5,mu=["CLS","FCP","INP","LCP"],bu=["INP","LCP"],yu=["interactionTarget","interactionType","inputDelay","processingDuration","presentationDelay","loadState","target","url","timeToFirstByte","resourceLoadDelay","resourceLoadDuration","elementRenderDelay","largestShiftTarget","largestShiftTime","largestShiftValue","firstByteToFCP"],wu="disabled",$u="lazy_loading",xu=Be("[SessionRecording]"),Su=Be("[Heatmaps]");function ku(t){return C(t)&&"clientX"in t&&"clientY"in t&&D(t.clientX)&&D(t.clientY)}const Eu=Be("[Product Tours]"),Pu=t=>{var i;return!t.config.disable_product_tours&&!!(null===(i=t.persistence)||void 0===i?void 0:i.get_property(ls))},Tu=["$set_once","$set"],Cu=Be("[SiteApps]"),Fu="Error while initializing PostHog app with config id ",Iu=(t,i)=>(null==t?void 0:t.then)?t.then(i):i(t),Ou="SDK is not enabled or survey functionality is not yet loaded",Ru="Disabled. Not loading surveys.";var Au=class{constructor(t,i){this.uo=t,this.oh=i,this.name="surveys",this._surveyEventReceiver=null,this._surveyManager=null,this.ah=!1,this.uh=[],this.hh=null,this.dh=null,this.fo=!1,this.fh=new Set,this.onRemoteConfig=t=>{if(this.fo)return;if(this.Sr.disableSurveys)return;if(!t.ok)return Ta.warn("Remote config unavailable. Not loading surveys.");const i=t.config.surveys;if(M(i))return Ta.warn("Flags not loaded yet. Not loading surveys.");this.ph=B(i)?i:i.length>0,Ta.info(`flags response received, isSurveysEnabled: ${this.ph}`),this.loadIfEnabled()}}setup(t){if(!this.fo)return this.gh=t,Iu(t.kv.initialize(),()=>{if(this.gh!==t||this.fo)return;this.gh=void 0,this.lo=t;const i=t.onRemoteConfig(this.onRemoteConfig);this.fo?i.dispose():(this.yo=i,this.loadIfEnabled())})}dispose(){var t,i,e,s;this.fo||(this.fo=!0,this.gh=void 0,this.lo=void 0,null===(t=this.yo)||void 0===t||t.dispose(),this.yo=void 0,null===(i=this._surveyEventReceiver)||void 0===i||i.dispose(),this._surveyEventReceiver=null,null===(e=this._surveyManager)||void 0===e||null===(s=e.dispose)||void 0===s||s.call(e),this._surveyManager=null,this.uh=[],this.hh=null,this.fh.forEach(t=>clearTimeout(t)),this.fh.clear())}get Sr(){return this.uo.get()}initialize(){this.loadIfEnabled()}reset(){try{var t;null===(t=this._surveyEventReceiver)||void 0===t||t.reset(),localStorage.removeItem("lastSeenSurveyDate");const i=[];for(let t=0;t<localStorage.length;t++){const e=localStorage.key(t);((null==e?void 0:e.startsWith("seenSurvey_"))||(null==e?void 0:e.startsWith("inProgressSurvey_")))&&i.push(e)}i.forEach(t=>localStorage.removeItem(t))}catch(t){}}loadIfEnabled(){if(this.fo||!this.lo)return;const t=this.Sr;if(this._surveyManager)return;if(this.ah)return void Ta.info("Already initializing surveys, skipping...");if(t.disableSurveys)return void Ta.info(Ru);if(t.cookielessMode&&this.uo.isOptedOut())return void Ta.info("Not loading surveys in cookieless mode without consent.");const i=this.uo.getExtensions();if(!i)return void Ta.error("PostHog Extensions not found.");if(I(this.ph)&&!t.advancedEnableSurveys)return;const e=this.ph||t.advancedEnableSurveys;this.ah=!0;try{const t=i.generateSurveys;if(t)return this.mh(t,e),void(this.ah=!1);const s=i.loadExternalDependency;if(!s)return this.yh(bn),void(this.ah=!1);s(t=>{try{if(this.fo)return;const i=this.uo.getExtensions();t||!(null==i?void 0:i.generateSurveys)?this.yh("Could not load surveys script",t):this.mh(i.generateSurveys,e)}finally{this.ah=!1}})}catch(t){throw this.ah=!1,this.yh("Error initializing surveys",t),t}}mh(t,i){this.fo||(this._surveyManager=t(i),this._surveyEventReceiver=this.uo.createEventReceiver(),Ta.info("Surveys loaded successfully"),this.bh({isLoaded:!0}))}yh(t,i){Ta.error(t,i),this.bh({isLoaded:!1,error:t})}onSurveysLoaded(t){return this.uh.push(t),this._surveyManager&&this.bh({isLoaded:!0}),()=>{this.uh=this.uh.filter(i=>i!==t)}}getSurveys(t,i=!1){var e;const s=null!==(e=this.lo)&&void 0!==e?e:this.oh;if(!s||this.fo)return;if(this.Sr.disableSurveys)return Ta.info(Ru),t([]);const n=s.kv.get(Ds);if(n&&!i)return t(n,{isLoaded:!0}),void(this._h()&&this.getSurveys(()=>{},!0));if(this.hh)return void this.hh.then(({surveys:i,context:e})=>{this.fo||t(i,e)}).catch(t=>Ta.error("Error in survey callback",t));const r=this.wh("/api/surveys/",{method:"GET",query:{token:s.projectToken},sentAt:"query",timeoutMs:this.Sr.requestTimeoutMs}).then(t=>{try{return this.kh(s,t)}catch(t){return Ta.error("Error processing surveys response",t),this.kh(s,{statusCode:0,error:t})}},t=>this.kh(s,{statusCode:0,error:t}));this.hh=r;const o=()=>{this.hh===r&&(this.hh=null)};r.then(i=>{o(),this.fo||t(i.surveys,i.context)},o).catch(t=>Ta.error("Error in survey callback",t))}wh(t,i){const e=this.lo;return e?e.sendRequest(t,i):new Promise(t=>t({statusCode:0,error:new Error(Ou)}))}kh(t,i){if(this.fo)return{surveys:[],context:{isLoaded:!1,error:Ou}};const e=i.statusCode;if(200!==e||!i.json){const t=`Surveys API could not be loaded, status: ${e}`;return 0!==e?Ta.error(t):i.error||Ta.warn(t),this.dh=Date.now(),{surveys:[],context:{isLoaded:!1,error:t}}}this.dh=null;const s=i.json.surveys||[],n=s.filter(t=>function(t){return!(!t.start_date||t.end_date)}(t)&&(_a(t)||function(t){var i;return!!(null===(i=t.conditions)||void 0===i||null===(i=i.actions)||void 0===i||null===(i=i.values)||void 0===i?void 0:i.length)}(t)));var r;return n.length>0&&(null===(r=this._surveyEventReceiver)||void 0===r||r.register(n)),t.kv.set({[Ds]:s,[js]:Date.now()}),{surveys:s,context:{isLoaded:!0}}}_h(){return this.Sh()&&!this.hh&&!this.xh()}Sh(){var t,i;const e=null===(t=null!==(i=this.lo)&&void 0!==i?i:this.oh)||void 0===t?void 0:t.kv.get(js);return D(e)&&Date.now()-e>3e5}xh(){return D(this.dh)&&3e5>Date.now()-this.dh}markSurveyAsSeen(t,i){var e;const s={id:t,current_iteration:null!==(e=null==i?void 0:i.iteration)&&void 0!==e?e:null};Ca(s);try{localStorage.setItem("lastSeenSurveyDate",(new Date).toISOString())}catch(t){}}bh(t){for(const i of this.uh)try{if(!t.isLoaded)return i([],t);this.getSurveys(i)}catch(t){Ta.error("Error in survey callback",t)}}getActiveMatchingSurveys(t,i=!1){if(!M(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(t,i);Ta.warn("init was not called")}Ch(t){let i=null;return this.getSurveys(e=>{var s;i=null!==(s=e.find(i=>i.id===t))&&void 0!==s?s:null}),i}$h(t){if(M(this._surveyManager))return{eligible:!1,reason:Ou};const i="string"==typeof t?this.Ch(t):t;return i?this._surveyManager.checkSurveyEligibility(i):{eligible:!1,reason:"Survey not found"}}Th(t){if(!this.uo.isCapturing())return{eligible:!1,reason:"PostHog is not capturing, so a survey response cannot be recorded"};if(M(this._surveyManager))return{eligible:!1,reason:Ou};const i="string"==typeof t?this.Ch(t):t;return i?this._surveyManager.checkSurveyRenderability(i):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(t){if(M(this._surveyManager))return Ta.warn("init was not called"),{visible:!1,disabledReason:Ou};const i=this.Th(t);return{visible:i.eligible,disabledReason:i.reason}}canRenderSurveyAsync(t,i){return M(this._surveyManager)?(Ta.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:Ou})):new Promise(e=>{this.getSurveys(i=>{var s;const n=null!==(s=i.find(i=>i.id===t))&&void 0!==s?s:null;if(n){const t=this.Th(n);e({visible:t.eligible,disabledReason:t.reason})}else e({visible:!1,disabledReason:"Survey not found"})},i)})}renderSurvey(t,i,e){var n;if(!this.uo.isCapturing())return;if(M(this._surveyManager))return void Ta.warn("init was not called");const r="string"==typeof t?this.Ch(t):t;if(!(null==r?void 0:r.id))return void Ta.warn("Survey not found");if(!Fa.includes(r.type))return void Ta.warn(`Surveys of type ${r.type} cannot be rendered in the app`);const o=null==s?void 0:s.querySelector(i);if(o){if(null===(n=r.appearance)||void 0===n?void 0:n.surveyPopupDelaySeconds){Ta.info(`Rendering survey ${r.id} with delay of ${r.appearance.surveyPopupDelaySeconds} seconds`);const t=setTimeout(()=>{var i,s;this.fh.delete(t),!this.fo&&this.uo.isCapturing()&&(Ta.info(`Rendering survey ${r.id} with delay of ${null===(i=r.appearance)||void 0===i?void 0:i.surveyPopupDelaySeconds} seconds`),null===(s=this._surveyManager)||void 0===s||s.renderSurvey(r,o,e),Ta.info(`Survey ${r.id} rendered`))},1e3*r.appearance.surveyPopupDelaySeconds);return void this.fh.add(t)}this._surveyManager.renderSurvey(r,o,e)}else Ta.warn("Survey element not found")}displaySurvey(t,i){var e;if(!this.uo.isCapturing())return;if(M(this._surveyManager))return void Ta.warn("init was not called");const s=this.Ch(t);if(!s)return void Ta.warn("Survey not found");let n=s;if((null===(e=s.appearance)||void 0===e?void 0:e.surveyPopupDelaySeconds)&&i.ignoreDelay&&(n=wi(wi({},s),{},{appearance:wi(wi({},s.appearance),{},{surveyPopupDelaySeconds:0})})),i.displayType!==sl&&i.initialResponses&&Ta.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),!1===i.ignoreConditions){const t=this.$h(s);if(!t.eligible)return void Ta.warn("Survey is not eligible to be displayed: ",t.reason)}"inline"!==i.displayType?this._surveyManager.handlePopoverSurvey(n,i):this.renderSurvey(n,i.selector,i.properties)}cancelPendingSurvey(t){M(this._surveyManager)?Ta.warn("init was not called"):this._surveyManager.cancelSurvey(t)}handlePageUnload(){var t,i;null===(t=this._surveyManager)||void 0===t||null===(i=t.handlePageUnload)||void 0===i||i.call(t)}};function Mu(t,i,e){if(M(t))return!1;switch(e){case"exact":return t===i;case"contains":{const e=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(e,"i").test(t)}case"regex":try{return new RegExp(i).test(t)}catch(t){return!1}default:return!1}}var Du=class{constructor(t){this._instance=t,this.Ih=new Set,this.Mh=new Set,this.Eh=new ha,this.Ph=(t,i)=>this.Rh(t,i)&&this.Ah(t,i)&&this.Fh(t,i)&&this.Oh(t,i),this.Rh=(t,i)=>!(null==i?void 0:i.event)||(null==t?void 0:t.event)===(null==i?void 0:i.event)}init(){var t,i;I(null===(t=this._instance)||void 0===t?void 0:t._addCaptureHook)||(this.Dh=null===(i=this._instance)||void 0===i?void 0:i._addCaptureHook((t,i)=>{this.on(t,i)}))}dispose(){var t;null===(t=this.Dh)||void 0===t||t.call(this),this.Dh=void 0,this.Eh=new ha}register(t){var i,e;if(!I(null===(i=this._instance)||void 0===i?void 0:i._addCaptureHook)&&(t.forEach(t=>{var i;this.Ih.add(t),null===(i=t.steps)||void 0===i||i.forEach(t=>{this.Mh.add((null==t?void 0:t.event)||"")})}),null===(e=this._instance)||void 0===e?void 0:e.autocapture)){const t=new Set;this.Ih.forEach(i=>{var e;null===(e=i.steps)||void 0===e||e.forEach(i=>{(null==i?void 0:i.selector)&&t.add(i.selector)})}),this._instance.autocapture.setElementSelectors(t)}}replace(t){this.Ih.clear(),this.Mh.clear(),this.register(t)}on(t,i){null!=i&&0!=t.length&&(this.Mh.has(t)||this.Mh.has(i.event))&&this.Ih.forEach(t=>{this.Lh(i,t)&&this.Eh.emit("actionCaptured",t.name)})}Nh(t){this.onAction("actionCaptured",i=>t(i))}Lh(t,i){if(null==(null==i?void 0:i.steps))return!1;for(const e of i.steps)if(this.Ph(t,e))return!0;return!1}onAction(t,i){return this.Eh.on(t,i)}Ah(t,i){if(null==i?void 0:i.url){var e;const s=null==t||null===(e=t.properties)||void 0===e?void 0:e.$current_url;if(!s||"string"!=typeof s)return!1;if(!Mu(s,i.url,i.url_matching||"contains"))return!1}return!0}Fh(t,i){return!!this.qh(t,i)&&!!this.jh(t,i)&&!!this.Bh(t,i)}qh(t,i){var e;if(!(null==i?void 0:i.href))return!0;const s=this.Hh(t);if(s.length>0)return s.some(t=>Mu(t.href,i.href,i.href_matching||"exact"));const n=(null==t||null===(e=t.properties)||void 0===e?void 0:e.$elements_chain)||"";return!!n&&Mu(function(t){const i=t.match(/(?::|")href="(.*?)"/);return i?i[1]:""}(n),i.href,i.href_matching||"exact")}jh(t,i){var e;if(!(null==i?void 0:i.text))return!0;const s=this.Hh(t);if(s.length>0)return s.some(t=>Mu(t.text,i.text,i.text_matching||"exact")||Mu(t.$el_text,i.text,i.text_matching||"exact"));const n=(null==t||null===(e=t.properties)||void 0===e?void 0:e.$elements_chain)||"";return!!n&&(r=function(t){const i=[],e=/(?::|")text="(.*?)"/g;let s;for(;!M(s=e.exec(t));)i.includes(s[1])||i.push(s[1]);return i}(n),o=i.text,l=i.text_matching||"exact",r.some(t=>Mu(t,o,l)));var r,o,l}Bh(t,i){var e,s;if(!(null==i?void 0:i.selector))return!0;const n=null==t||null===(e=t.properties)||void 0===e?void 0:e.$element_selectors;if(null==n?void 0:n.includes(i.selector))return!0;const r=(null==t||null===(s=t.properties)||void 0===s?void 0:s.$elements_chain)||"";if(i.selector_regex&&r)try{return new RegExp(i.selector_regex).test(r)}catch(t){return!1}return!1}Hh(t){var i;return null==(null==t||null===(i=t.properties)||void 0===i?void 0:i.$elements)?[]:null==t?void 0:t.properties.$elements}Oh(t,i){return!(null==i?void 0:i.properties)||0===i.properties.length||wa(i.properties.reduce((t,i)=>{const e=P(i.value)?i.value.map(String):null!=i.value?[String(i.value)]:[];return t[i.key]={values:e,operator:i.operator||"exact"},t},{}),null==t?void 0:t.properties)}},ju=class{constructor(t){var i,e;this.zh=[],this._instance=t,this.Uh=new Map,this.Wh=new Map,this.Vh=new Map,this.Gh=null===(i=this._instance)||void 0===i||null===(e=i.onSessionId)||void 0===e?void 0:e.call(i,t=>this.Zh(t))}Qh(t){return!1}Jh(){return null}Kh(t){}Yh(){}Xh(t,i){return!!t&&wa(t.propertyFilters,null==i?void 0:i.properties)}tc(t,i){const e=new Map;return t.forEach(t=>{var s;null===(s=t.conditions)||void 0===s||null===(s=s[i])||void 0===s||null===(s=s.values)||void 0===s||s.forEach(i=>{if(null==i?void 0:i.name){const s=e.get(i.name)||[];s.push(t.id),e.set(i.name,s)}})}),e}ec(t,i,e){const s=(e===Xo?this.Uh:this.Wh).get(t);let n=[];return this.nc(t=>{n=t.filter(t=>null==s?void 0:s.includes(t.id))}),n.filter(s=>{var n;const r=null===(n=s.conditions)||void 0===n||null===(n=n[e])||void 0===n||null===(n=n.values)||void 0===n?void 0:n.find(i=>i.name===t);return this.Xh(r,i)})}register(t){this.sc(t,!1)}replace(t){this.sc(t,!0)}sc(t,i){var e;I(null===(e=this._instance)||void 0===e?void 0:e._addCaptureHook)||(this.rc(t,i),this.oc(t,i))}oc(t,i){const e=t.filter(t=>{var i;return null===(i=t.conditions)||void 0===i||null===(i=i.actions)||void 0===i||null===(i=i.values)||void 0===i?void 0:i.length});var s;if(i&&this.Vh.clear(),0===e.length)return void(i&&(null===(s=this.lc)||void 0===s||s.replace([])));this.lc||(this.lc=new Du(this._instance),this.lc.init(),this.lc.Nh(t=>this.onAction(t)));const n=[];e.forEach(t=>{var i;null===(i=t.conditions)||void 0===i||null===(i=i.actions)||void 0===i||i.values.forEach(i=>{if(n.push(i),i.name){var e;const s=null!==(e=this.Vh.get(i.name))&&void 0!==e?e:[];s.includes(t.id)||s.push(t.id),this.Vh.set(i.name,s)}})}),i?this.lc.replace(n):this.lc.register(n)}ac(t,i){i.forEach((i,e)=>{var s;const n=null!==(s=t.get(e))&&void 0!==s?s:[];i.forEach(t=>{n.includes(t)||n.push(t)}),t.set(e,n)})}rc(t,i){var e,s;const n=t.filter(t=>{var i,e;return(null===(i=t.conditions)||void 0===i?void 0:i.events)&&(null===(e=t.conditions)||void 0===e||null===(e=e.events)||void 0===e||null===(e=e.values)||void 0===e?void 0:e.length)>0}),r=t.filter(t=>{var i,e;return(null===(i=t.conditions)||void 0===i?void 0:i.cancelEvents)&&(null===(e=t.conditions)||void 0===e||null===(e=e.cancelEvents)||void 0===e||null===(e=e.values)||void 0===e?void 0:e.length)>0}),o=this.tc(t,Xo),l=this.tc(t,Zo);i?(this.Uh=o,this.Wh=l):(this.ac(this.Uh,o),this.ac(this.Wh,l)),(0!==n.length||0!==r.length)&&(null!==(e=this.Dh)&&void 0!==e||(this.Dh=null===(s=this._instance)||void 0===s?void 0:s._addCaptureHook((t,i)=>{this.onEvent(t,i)})))}onEvent(t,i){var e,s;const n=this.uc(),r=(null==i||null===(e=i.properties)||void 0===e?void 0:e.$survey_id)||(null==i||null===(s=i.properties)||void 0===s?void 0:s.$product_tour_id);if(r&&this.getActivatedIds().includes(r)){const i=this.hc(t,r);if("consume"===i)return n.info("event consumed activated item, removing it",{event:t,itemId:r}),void this.cc([r]);if("persist"===i)return n.info("shown item promoted to persisted activation",{event:t,itemId:r}),this.dc(r),void this.vc([r])}if(this.Wh.has(t)){const e=this.ec(t,i,Zo);e.length>0&&(n.info("cancel event matched, cancelling items",{event:t,itemsToCancel:e.map(t=>t.id)}),this.cc(e.map(t=>t.id)),e.forEach(t=>this.fc(t.id)))}if(!this.Uh.has(t))return;n.info("event name matched",{event:t,eventPayload:i,items:this.Uh.get(t)});const o=this.ec(t,i,Xo);this.gc(o.map(t=>t.id))}onAction(t){this.Vh.has(t)&&this.gc(this.Vh.get(t)||[])}gc(t){var i,e;if(0===t.length)return;const s=!!(null===(i=this._instance)||void 0===i||null===(e=i.get_session_id)||void 0===e?void 0:e.call(i)),n=[];for(const i of t)s&&this.Qh(i)?this.dc(i)&&this.mc(i):n.push(i);n.length>0&&(this.zh=[...new Set([...this.zh,...n])]),this.uc().info("updating activated items",{activatedItems:this.getActivatedIds()})}dc(t){this.zh=this.zh.filter(i=>i!==t);const i=this.yc();return!i.includes(t)&&(this.bc([...i,t]),this._c(),!0)}cc(t){const i=new Set(t);this.zh=this.zh.filter(t=>!i.has(t));const e=this.wc(),s=e.filter(t=>!i.has(t));s.length!==e.length&&(this.bc(s),0===s.length&&this.kc()),this.vc(t)}Sc(){var t;const i=this.Jh();if(!i)return{};const e=null===(t=this._instance)||void 0===t||null===(t=t.persistence)||void 0===t?void 0:t.props[i];return e&&"object"==typeof e?e:{}}mc(t){if(!this.Jh())return;const i=this.Sc();this.Kh(wi(wi({},i),{},{[t]:Date.now()}))}vc(t){if(!this.Jh())return;const i=this.Sc(),e={};let s=!1;for(const[n,r]of Object.entries(i))t.includes(n)?s=!0:e[n]=r;s&&(F(e)?this.Yh():this.Kh(e))}xc(){this.Jh()&&this.Yh()}getActivationTimestamp(t){if(!this.yc().includes(t))return;const i=this.Sc()[t];return D(i)?i:void 0}wc(){var t;const i=this.Cc();return(null===(t=this._instance)||void 0===t||null===(t=t.persistence)||void 0===t?void 0:t.props[i])||[]}yc(){var t,i,e;const s=this.wc();if(0===s.length)return[];const n=null===(t=this._instance)||void 0===t||null===(t=t.persistence)||void 0===t?void 0:t.props[this.$c()],r=null===(i=this._instance)||void 0===i||null===(e=i.get_session_id)||void 0===e?void 0:e.call(i);return r&&n===r?s:[]}_c(){var t,i;const e=null===(t=this._instance)||void 0===t||null===(i=t.get_session_id)||void 0===i?void 0:i.call(t);e&&this.Tc(e)}kc(){this.Ic()}Zh(t){var i;const e=null===(i=this._instance)||void 0===i||null===(i=i.persistence)||void 0===i?void 0:i.props[this.$c()];if(e&&e!==t){const t=this.wc(),i=this.Sc();t.length>0&&(this.bc([]),t.filter(t=>D(i[t])).forEach(t=>this.fc(t))),this.kc(),this.xc()}}getActivatedIds(){return[...new Set([...this.yc(),...this.zh])].filter(t=>!this.Mc(t))}dispose(){var t,i,e;null===(t=this.Gh)||void 0===t||t.call(this),this.Gh=void 0,null===(i=this.Dh)||void 0===i||i.call(this),this.Dh=void 0,null===(e=this.lc)||void 0===e||e.dispose(),this.lc=void 0}reset(){this.zh=[],this.wc().length>0&&this.bc([]),this.kc(),this.xc()}getEventToItemsMap(){return this.Uh}Ec(){return this.lc}},Bu=class extends ju{constructor(t){super(t)}Cc(){return Bs}$c(){return Ls}Jh(){return Ns}Kh(t){var i;null===(i=this._instance)||void 0===i||null===(i=i.persistence)||void 0===i||i.register({$surveys_activated_timestamps:t})}Yh(){var t;null===(t=this._instance)||void 0===t||null===(t=t.persistence)||void 0===t||t.unregister("$surveys_activated_timestamps")}Qh(t){var i;let e;this.nc(i=>{e=i.find(i=>i.id===t)});const s=null==e||null===(i=e.appearance)||void 0===i?void 0:i.surveyPopupDelaySeconds;return D(s)&&s>0}Pc(){return Qo}nc(t){var i;null===(i=this._instance)||void 0===i||i.getSurveys(t)}fc(t){var i;null===(i=this._instance)||void 0===i||i.cancelPendingSurvey(t)}uc(){return Ta}bc(t){var i;null===(i=this._instance)||void 0===i||null===(i=i.persistence)||void 0===i||i.register({$surveys_activated:t})}Tc(t){var i;null===(i=this._instance)||void 0===i||null===(i=i.persistence)||void 0===i||i.register({$surveys_activated_session:t})}Ic(){var t;null===(t=this._instance)||void 0===t||null===(t=t.persistence)||void 0===t||t.unregister("$surveys_activated_session")}Mc(){return!1}hc(t,i){let e;return this.nc(t=>{e=t.find(t=>t.id===i)}),!e||function(t){var i;return _a(t)&&!!(null===(i=t.conditions)||void 0===i||null===(i=i.events)||void 0===i?void 0:i.repeatedActivation)||"always"===t.schedule}(e)?t===Qo?"consume":"ignore":t===Qo?"persist":t===tl||t===il?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},Lu=class{constructor(t){this._instance=t}initialize(){}get(t){if("string"==typeof t)return this._instance.get_property(t);const i={};for(const e of t){const t=this._instance.get_property(e);I(t)||(i[e]=t)}return i}set(t,i){this._instance.register("string"==typeof t?{[t]:i}:t)}remove(t){"string"!=typeof t?t.forEach(t=>this._instance.unregister(t)):this._instance.unregister(t)}},Nu=class{constructor(t){this._instance=t}get(){const t=this._instance.config;return{disableSurveys:t.disable_surveys,cookielessMode:!!t.cookieless_mode,advancedEnableSurveys:t.advanced_enable_surveys,requestTimeoutMs:t.surveys_request_timeout_ms}}isOptedOut(){return this._instance.consent.isOptedOut()}isCapturing(){return this._instance.is_capturing()}getExtensions(){const t=null==c?void 0:c.__PosthogExtensions__;if(!t)return;const{generateSurveys:i,loadExternalDependency:e}=t;return{generateSurveys:i?t=>i(this._instance,t):void 0,loadExternalDependency:e?t=>e(this._instance,"surveys",t):void 0}}createEventReceiver(){return new Bu(this._instance)}};const zu=(null==t?void 0:t.location)?yo(t.location.hash,"__posthog")||yo(location.hash,"state"):null,Uu="_postHogToolbarParams",Hu=Be("[Toolbar]"),qu=Be("[FeatureFlags]");var Vu=class{constructor(t,i=!1){this.Rc=!1,this.update(t,i)}update(t,i){this.Ac=((t,i)=>{var e,s,n,r,o;return{bootstrap:{featureFlags:null===(e=t.bootstrap)||void 0===e?void 0:e.featureFlags,featureFlagPayloads:null===(s=t.bootstrap)||void 0===s?void 0:s.featureFlagPayloads},remoteRequestsDisabled:i,featureFlagsDisabled:!!t.advanced_disable_feature_flags,onlyEvaluateSurveyFeatureFlags:!!t.advanced_only_evaluate_survey_feature_flags,deduplicateCallsPerSession:!!t.advanced_feature_flags_dedup_per_session,cacheTtlMs:t.feature_flag_cache_ttl_ms,refreshIntervalMs:null!==(n=t.remote_config_refresh_interval_ms)&&void 0!==n?n:3e5,requestTimeoutMs:t.feature_flag_request_timeout_ms,compression:t.disable_compression?void 0:"best-available",evaluationContexts:null!==(r=null!==(o=t.evaluation_contexts)&&void 0!==o?o:t.evaluation_environments)&&void 0!==r?r:[],flagKeys:P(t.flag_keys)?t.flag_keys:void 0}})(t,i),!t.evaluation_environments||t.evaluation_contexts||this.Rc||(qu.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.Rc=!0),I(t.flag_keys)||P(t.flag_keys)||qu.error("Invalid flag_keys found:",t.flag_keys,"Expected array of non-empty strings")}get(){return this.Ac}};const Wu=Be("[FeatureFlags]"),Gu=Be("[FeatureFlags]",{debugEnabled:!0}),Ku="\" failed. Feature flags didn't load in time.",Ju="connection_error",Yu=t=>{const i={};for(let e=0;t.length>e;e++)i[t[e]]=!0;return i},Xu=t=>{const i={};for(const[e,s]of On(t||{}))s&&(i[e]=s);return i},Zu=t=>H(t)&&("RangeError"===t.name&&0===t.message.indexOf("Maximum call stack size exceeded")||"InternalError"===t.name&&"too much recursion"===t.message),Qu=Be("[Error tracking]"),th="webkit-masked-url:",ih=[{value:"isolatedAPI.contexts.topHostname",exact:!1},{value:"No response from target",exact:!0}],eh=["chrome-extension://","moz-extension://","safari-extension:","safari-web-extension:",th],sh=["__firefox__","__gCrWeb"],nh="Refusing to render web experiment since the viewer is a likely bot",rh={icontains:(t,i)=>i.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,i)=>-1===i.toLowerCase().indexOf(t.toLowerCase()),regex:(t,i)=>ma(i,t),not_regex:(t,i)=>!ma(i,t),exact:(t,i)=>i===t,is_not:(t,i)=>i!==t},oh=Be("[Conversations]"),lh="Conversations not available yet.";function ah(t,i){var s,n,r,o,l,a,u;const h=null!==(s=null==t?void 0:t.flushIntervalMs)&&void 0!==s?s:3e3,d=null!==(n=null==t?void 0:t.maxBufferSize)&&void 0!==n?n:100,c=(null==i?void 0:i.consoleCapture)?void 0:null!==(r=null==t?void 0:t.maxLogsPerInterval)&&void 0!==r?r:1e3,v=I(c)?Math.max(d,2048):Math.max(d,c),f=wi(wi({},function(){let t="",i="";try{const s=null==e?void 0:e.userAgent;s&&([t,i]=Qt(s))}catch(t){}return function(t,i){const e=function(t){if(t)return{}.hasOwnProperty.call(Se,t)?Se[t]:t}(t);return wi(wi({},e?{"os.name":e}:{}),i?{"os.version":i}:{})}(t,i)}()),null==t?void 0:t.resourceAttributes);return{serviceName:null!==(o=null!==(l=null==f?void 0:f["service.name"])&&void 0!==l?l:null==t?void 0:t.serviceName)&&void 0!==o?o:null==i?void 0:i.serviceNameDefault,serviceVersion:null!==(a=null==f?void 0:f["service.version"])&&void 0!==a?a:null==t?void 0:t.serviceVersion,environment:null!==(u=null==f?void 0:f["deployment.environment"])&&void 0!==u?u:null==t?void 0:t.environment,resourceAttributes:f,beforeSend:null==t?void 0:t.beforeSend,flushIntervalMs:h,maxBufferSize:d,maxQueueSize:v,maxBatchRecordsPerPost:100,rateCapWindowMs:h,maxLogsPerInterval:c,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}}const uh=["debug","log","warn","error","info"],hh=t=>{for(;null==t?void 0:t.__rrweb_original__;)t=t.__rrweb_original__;return t},dh="console",ch="__posthogHandledLogsRequestError",vh=(t,i)=>{const e=t instanceof Error?t:new Error(i);return e[ch]=!0,e},fh=t=>!!t&&"object"==typeof t&&!0===t[ch],ph={featureFlags:class{constructor(t){this.name="featureFlags",this.Fc=!1,this.featureFlagEventHandlers=[],this.$=Wu,this.Oc={},this.Dc={},this.Lc=[],this.Nc=!1,this.qc=!1,this.jc=0,this.Bc=!1,this.Hc=!1,this.zc=!1,this.Uc=!1,this.Wc=0,this.sn=()=>{const t=this.Vc();this.Wc=0,t&&this.reloadFeatureFlags()},this.Gc=()=>{var t;const i=this.Zc;I(i)||this.Sr.remoteRequestsDisabled||!s||"hidden"===s.visibilityState||Date.now()-(null!==(t=this.Qc)&&void 0!==t?t:0)<i||(this.reloadFeatureFlags(),this.Jc())},this.an=()=>{"visible"===(null==s?void 0:s.visibilityState)&&this.Gc()},"get"in t?this.uo=t:(this._instance=t,this.Kc=new Vu(t.config,t.Ul()),this.uo=this.Kc)}updateConfig(t,i){var e;null===(e=this.Kc)||void 0===e||e.update(t,i),this.lo&&this.Yc()}setup(t){return this.gh=t,this.$=t.logger.createLogger("[FeatureFlags]"),Iu(t.kv.initialize(),()=>{this.gh===t&&(this.gh=void 0,this.lo=t,this.Xc(t))})}Xc(i){var e;if(this.lo===i)return t&&Ln(t,"online",this.sn),this.Yc(),this.td=i.registerDynamicEventProperties(()=>this.ed()?this.Oc:this.Dc),this.nd=null===(e=this._instance)||void 0===e||null===(e=e.persistence)||void 0===e?void 0:e.onCrossTabFeatureFlagChange(()=>{this.sd(),this.rd(),this.od()}),this.rd(),this.initialize()}Yc(){const t=this.Sr.refreshIntervalMs,i=!this.Sr.remoteRequestsDisabled&&s&&!I(t)&&t>0?t:void 0;i!==this.Zc&&(this.ld(),I(i)||(this.Zc=i,this.Jc(),(null==s?void 0:s.addEventListener)&&Ln(s,xn,this.an)))}Jc(){I(this.Zc)||(I(this.ad)||clearInterval(this.ad),this.Qc=Date.now(),this.ad=setInterval(this.Gc,this.Zc))}ld(){var t;I(this.ad)||(clearInterval(this.ad),this.ad=void 0,null==s||null===(t=s.removeEventListener)||void 0===t||t.call(s,"visibilitychange",this.an)),this.Zc=void 0,this.Qc=void 0}destroy(){this.ud()}dispose(){this.ud()}ud(){var i,e;this.ld(),this.jc++,this.Hc=!1,this.gh=void 0,this.lo&&(this.hd(),null===(i=this.td)||void 0===i||i.dispose(),this.td=void 0,null===(e=this.nd)||void 0===e||e.call(this),this.nd=void 0,this.Lc=[],null==t||t.removeEventListener("online",this.sn),this.lo=void 0)}get Sr(){return this.uo.get()}dd(t){var i;return this.vd&&t in this.vd?this.vd[t]:null===(i=this.lo)||void 0===i?void 0:i.kv.get(t)}sd(){return!!this.vd&&(this.vd=void 0,!0)}fd(){var t;return!I(null===(t=this.lo)||void 0===t?void 0:t.kv.get("$enabled_feature_flags"))&&this.sd()}At(t){this.pd(()=>{var i;return null===(i=this.lo)||void 0===i?void 0:i.kv.set(t)})}gd(t,i,e){var s;if(!(null===(s=this._instance)||void 0===s?void 0:s.persistence)||!t.$enabled_feature_flags)return;const n=this.dd("$enabled_feature_flags")||{},r=t.$enabled_feature_flags||{},o=i.flags||i.featureFlags,l=i.flags?Object.entries(i.flags).filter(([,t])=>!(null==t?void 0:t.failed)).map(([t])=>t):[],a=!!i.errorsWhileComputingFlags&&!!i.flags,u=a?l:e&&!P(o)?Object.keys(o||{}):Array.from(new Set([...Object.keys(n),...Object.keys(r)])),h=this.dd("$feature_flag_payloads")||{},d=t.$feature_flag_payloads||{},c=a||e?u:Array.from(new Set([...Object.keys(h),...Object.keys(d)])),v=!a&&!e,f=!!v||u,p=!!v||c,g={[ks]:f,[Ss]:f,[Ts]:p};t.$feature_flag_details&&(g[Ps]=f);for(const i of[Cs,Xs,Fs])I(t[i])||(g[i]=!0);this._instance.persistence.markCrossTabFeatureFlagChanges(g)}Lt(t){this.pd(()=>{var i;return null===(i=this.lo)||void 0===i?void 0:i.kv.remove(t)})}pd(t){try{t()}catch(t){this.$.error("Failed to update feature flag persistence",t)}}rd(){const t={};for(const i of[ks,Ts,Cs,Is]){const e=this.dd(i);I(e)||(t[i]=e)}this.Oc=t;const i=wi({},t),e=this.dd(Ss);if(e)for(const[t,s]of Object.entries(e))i[`$feature/${t}`]=s;this.Dc=i}ed(){const t=this.Sr.cacheTtlMs;if(!t||0>=t)return!1;const i=this.dd(Xs);return"number"!=typeof i||Date.now()-i>t}md(){return!!this.ed()&&(this.Uc||this.qc||(this.Uc=!0,this.$.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}yd(){const t=this.Sr.evaluationContexts;return(null==t?void 0:t.length)?t.filter(t=>{const i=t&&"string"==typeof t&&t.trim().length>0;return i||this.$.error("Invalid evaluation context found:",t,"Expected non-empty string"),i}):[]}bd(){const t=this.Sr.flagKeys;if(!I(t))return t.filter(t=>{const i=t&&"string"==typeof t&&t.trim().length>0;return i||this.$.error("Invalid flag key found:",t,"Expected non-empty string"),i})}initialize(){var t,i;const e=this.Sr,s=null!==(t=null===(i=e.bootstrap)||void 0===i?void 0:i.featureFlags)&&void 0!==t?t:{};if(Object.keys(s).length){var n,r;const t=null!==(n=null===(r=e.bootstrap)||void 0===r?void 0:r.featureFlagPayloads)&&void 0!==n?n:{},i=Object.keys(s).filter(t=>!I(s[t])).reduce((t,i)=>(t[i]=s[i],t),{}),o=Object.keys(t).filter(t=>i[t]).reduce((i,e)=>(i[e]=t[e],i),{});return this._d({featureFlags:i,featureFlagPayloads:o},void 0,{persist:!1})}}updateFlags(t,i,e){var s,n;const r=(null==e?void 0:e.merge)&&null!==(s=this.dd("$enabled_feature_flags"))&&void 0!==s?s:{},o=(null==e?void 0:e.merge)&&null!==(n=this.dd("$feature_flag_payloads"))&&void 0!==n?n:{},l=wi(wi({},r),t),a=wi(wi({},o),i),u={};for(const[t,i]of Object.entries(l))u[t]={key:t,enabled:re(i),variant:oe(i),reason:void 0,metadata:I(null==a?void 0:a[t])?void 0:{id:0,version:void 0,description:void 0,payload:a[t]}};this._d({flags:u})}get hasLoadedFlags(){return this.Nc}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){const t=this.dd(Ps),i=this.dd(Is),e=this.dd(Os);if(!e&&!i)return t||{};const s=In({},t||{}),n=[...new Set([...Object.keys(e||{}),...Object.keys(i||{})])];for(const t of n){var r;const n=s[t],l=null==i?void 0:i[t],a=I(l)?null!==(r=null==n?void 0:n.enabled)&&void 0!==r&&r:!!l,u=I(l)?null==n?void 0:n.variant:"string"==typeof l?l:void 0,h=null==e?void 0:e[t],d=wi(wi({},n),{},{enabled:a,variant:a?null!=u?u:null==n?void 0:n.variant:void 0});var o;a!==(null==n?void 0:n.enabled)&&(d.original_enabled=null==n?void 0:n.enabled),u!==(null==n?void 0:n.variant)&&(d.original_variant=null==n?void 0:n.variant),h&&(d.metadata=wi(wi({},null==n?void 0:n.metadata),{},{payload:h,original_payload:null==n||null===(o=n.metadata)||void 0===o?void 0:o.payload})),s[t]=d}return this.Fc||(this.$.warn(" Overriding feature flag details!",{flagDetails:t,overriddenPayloads:e,finalDetails:s}),this.Fc=!0),s}getAllFeatureFlags(){const t=this.getFlagVariants(),i=this.getFlagPayloads();return Object.keys(t).map(e=>{const s=t[e];return{key:e,enabled:re(s),variant:oe(s),payload:ne(i[e])}})}getFlagVariants(){const t=this.dd(Ss),i=this.dd(Is);if(!i)return t||{};const e=In({},t||{}),s=Object.keys(i);for(let t=0;s.length>t;t++)e[s[t]]=i[s[t]];return this.Fc||(this.$.warn(" Overriding feature flags!",{enabledFlags:t,overriddenFlags:i,finalFlags:e}),this.Fc=!0),e}getFlagPayloads(){const t=this.dd(Ts),i=this.dd(Os);if(!i)return t||{};const e=In({},t||{}),s=Object.keys(i);for(let t=0;s.length>t;t++)e[s[t]]=i[s[t]];return this.Fc||(this.$.warn(" Overriding feature flag payloads!",{flagPayloads:t,overriddenPayloads:i,finalPayloads:e}),this.Fc=!0),e}reloadFeatureFlags(){this.Bc||this.Sr.featureFlagsDisabled||this.Vc()||(this.qc&&(this.Hc=!0),this.wd||(this.Lc.slice().forEach(t=>{try{t()}catch(t){this.$.error("Error while running feature flags reloading callback",t)}}),this.wd=setTimeout(()=>{this.kd()},5)))}hd(){clearTimeout(this.wd),this.wd=void 0}onReloading(t){return this.Lc.push(t),()=>{this.Lc=this.Lc.filter(i=>i!==t)}}ensureFlagsLoaded(){this.Nc||this.qc||this.wd||this.reloadFeatureFlags()}setAnonymousDistinctId(t){this.$anon_distinct_id=t}setReloadingPaused(t){this.Bc=t}resetFlagCallReported(){this.Lt(Ks)}kd(t){this.hd();const i=this.lo;if(!i||this.Sr.remoteRequestsDisabled||this.Vc())return;if(this.qc)return void(this.Hc=!0);const e={token:i.projectToken,distinct_id:i.distinctId,groups:i.groups,$anon_distinct_id:this.$anon_distinct_id,person_properties:wi(wi(wi({},i.initialPersonProperties),this.dd("$stored_person_properties")||{}),{},{$lib:i.library.name,$lib_version:i.library.version}),group_properties:this.dd(As),timezone:Do()};I(i.deviceId)||(e.$device_id=i.deviceId),((null==t?void 0:t.disableFlags)||this.Sr.featureFlagsDisabled)&&(e.disable_flags=!0);const s=this.yd();s.length&&(e.evaluation_contexts=s);const n=this.bd();I(n)||(e.flag_keys=n);const r=this.Sr.onlyEvaluateSurveyFeatureFlags,o="/flags/?v=2"+(r?"&only_evaluate_survey_feature_flags=true":""),l=this.jc;this.qc=!0;const a=()=>{this.Hc&&(this.Hc=!1,this.kd())},u=t=>{var i,s;const n=null!==(i=t.json)&&void 0!==i?i:{},o=200!==t.statusCode;if(this.qc=!1,l!==this.jc)return void a();if(this.Sd(t.statusCode),o||this.Hc||(this.$anon_distinct_id=void 0),e.disable_flags&&!this.Hc)return;this.zc=!o;const u=[];t.error?u.push(t.error instanceof Error&&"AbortError"===t.error.name?"timeout":t.error instanceof Error?Ju:"unknown_error"):200!==t.statusCode&&u.push(`api_error_${t.statusCode}`),n.errorsWhileComputingFlags&&u.push("errors_while_computing_flags");const h=!!(null===(s=n.quotaLimited)||void 0===s?void 0:s.includes("feature_flags"));h&&u.push("quota_limited"),this.At({[Ys]:u}),h?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."):e.disable_flags||this._d(n,o,{partialResponse:r}),a()},h=t=>{this.qc=!1,l===this.jc?(this.At({[Ys]:[Ju]}),this.$.error("Feature flag request failed",t),this.fd()&&this.od(!0),a()):a()};try{i.sendRequest(o,{target:"flags",method:"POST",body:e,compression:this.Sr.compression,sentAt:"body",timeoutMs:this.Sr.requestTimeoutMs}).then(u).catch(h)}catch(t){h(t)}}Vc(){return wo(this.Wc,3)}Sd(t){this.Wc=$o(t,this.Wc,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(t,i={}){var e;if(i.fresh&&!this.zc)return;if(!(this.Nc||this.getFlags()&&this.getFlags().length>0))return void this.$.warn('getFeatureFlag for key "'+t+Ku);if(this.md())return;const s=this.getFeatureFlagResult(t,i);return null!==(e=null==s?void 0:s.variant)&&void 0!==e?e:null==s?void 0:s.enabled}getFeatureFlagDetails(t){return this.getFlagsWithDetails()[t]}getFeatureFlagPayload(t){const i=this.getFeatureFlagResult(t,{send_event:!1});return null==i?void 0:i.payload}getFeatureFlagResult(t,i={}){if(i.fresh&&!this.zc)return;if(!(this.Nc||this.getFlags()&&this.getFlags().length>0))return void this.$.warn('getFeatureFlagResult for key "'+t+Ku);if(this.md())return;const e=this.getFlagVariants(),s=t in e,n=e[t],r=this.getFlagPayloads()[t],o=String(n),l=this.dd("$feature_flag_request_id")||void 0,a=this.dd("$feature_flag_evaluated_at")||void 0;let u,h=this.dd("$flag_call_reported")||{};if(this.Sr.deduplicateCallsPerSession){var d;const t=null===(d=this.lo)||void 0===d?void 0:d.session.sessionId,i=this.dd(Js);t&&t!==i&&(h={},u=t)}if(i.send_event||!("send_event"in i))if(t in h&&h[t].includes(o))u&&this.At({[Ks]:h,[Js]:u});else{var c,v,f,p,g,_,m,b,y,w,x,S;P(h[t])?h[t].push(o):h[t]=[o],this.At(wi({[Ks]:h},u?{[Js]:u}:{}));const i=this.getFeatureFlagDetails(t),e=[...null!==(c=this.dd("$feature_flag_errors"))&&void 0!==c?c:[]];I(n)&&e.push("flag_missing");const s={$feature_flag:t,$feature_flag_response:n,$feature_flag_payload:null!=r?r:null,$feature_flag_request_id:l,$feature_flag_evaluated_at:a,$feature_flag_bootstrapped_response:null!==(v=null===(f=this.Sr.bootstrap)||void 0===f||null===(f=f.featureFlags)||void 0===f?void 0:f[t])&&void 0!==v?v:null,$feature_flag_bootstrapped_payload:null!==(p=null===(g=this.Sr.bootstrap)||void 0===g||null===(g=g.featureFlagPayloads)||void 0===g?void 0:g[t])&&void 0!==p?p:null,$used_bootstrap_value:!this.zc};I(null==i||null===(_=i.metadata)||void 0===_?void 0:_.has_experiment)||(s.$feature_flag_has_experiment=i.metadata.has_experiment),I(null==i||null===(m=i.metadata)||void 0===m?void 0:m.version)||(s.$feature_flag_version=i.metadata.version);const d=null!==(b=null==i||null===(y=i.reason)||void 0===y?void 0:y.description)&&void 0!==b?b:null==i||null===(w=i.reason)||void 0===w?void 0:w.code;var k;d&&(s.$feature_flag_reason=d),(null==i||null===(x=i.metadata)||void 0===x?void 0:x.id)&&(s.$feature_flag_id=i.metadata.id),I(null==i?void 0:i.original_variant)&&I(null==i?void 0:i.original_enabled)||(s.$feature_flag_original_response=I(i.original_variant)?i.original_enabled:i.original_variant),(null==i||null===(S=i.metadata)||void 0===S?void 0:S.original_payload)&&(s.$feature_flag_original_payload=null==i||null===(k=i.metadata)||void 0===k?void 0:k.original_payload),e.length&&(s.$feature_flag_error=e.join(",")),this.xd(s)}else u&&this.At({[Ks]:h,[Js]:u});return s?{key:t,enabled:!!n,variant:"string"==typeof n?n:void 0,payload:ne(r)}:void 0}xd(t){try{var i;null===(i=this.lo)||void 0===i||i.capture("$feature_flag_called",t).catch(t=>{this.$.error("Failed to capture feature flag call",t)})}catch(t){this.$.error("Failed to capture feature flag call",t)}}getRemoteConfigPayload(t,i){this.Cd(t,i)}Cd(t,i){var e=this;return Y(function*(){const s=e.lo;if(!s)return;const n={distinct_id:s.distinctId,token:s.projectToken,person_properties:{$lib:s.library.name,$lib_version:s.library.version}},r=e.yd();r.length&&(n.evaluation_contexts=r);const o=e.bd();let l;I(o)||(n.flag_keys=o);try{var a;const i=null===(a=(yield s.sendRequest("/flags/?v=2",{target:"flags",method:"POST",body:n,compression:e.Sr.compression,sentAt:"body",timeoutMs:e.Sr.requestTimeoutMs})).json)||void 0===a?void 0:a.featureFlagPayloads;l=(null==i?void 0:i[t])||void 0}catch(t){return void e.$.error("Remote config feature flag request failed",t)}try{i(l)}catch(t){e.$.error("Remote config feature flag callback failed",t)}})()}isFeatureEnabled(t,i={}){if(i.fresh&&!this.zc)return i.defaultValue;if(!(this.Nc||this.getFlags()&&this.getFlags().length>0))return this.$.warn('isFeatureEnabled for key "'+t+Ku),i.defaultValue;const e=this.getFeatureFlag(t,i);return I(e)?i.defaultValue:!!e}addFeatureFlagsHandler(t){this.featureFlagEventHandlers.push(t)}removeFeatureFlagsHandler(t){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter(i=>i!==t)}receivedFeatureFlags(t,i,e){this._d(t,i,e)}_d(t,i,e){if(!this.lo)return;this.Nc=!0;const s=((t,i={},e={},s={},n,r=Wu)=>{const o=((t,i)=>{const e=t.flags;if(e){const i=Object.fromEntries(Object.keys(e).map(t=>{var i;return[t,null!==(i=e[t].variant)&&void 0!==i?i:e[t].enabled]})),s=Object.fromEntries(Object.keys(e).filter(t=>e[t].enabled).filter(t=>{var i;return!I(null===(i=e[t].metadata)||void 0===i?void 0:i.payload)}).map(t=>{var i;return[t,null===(i=e[t].metadata)||void 0===i?void 0:i.payload]}));return wi(wi({},t),{},{featureFlags:i,featureFlagPayloads:s})}return t.featureFlags&&i.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),t})(t,r),l=o.flags,a=o.featureFlags,u=o.featureFlagPayloads;if(!a)return;const h=t.requestId,d=t.evaluatedAt;if(P(a)){r.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");const t={};if(a)for(let i=0;a.length>i;i++)t[a[i]]=!0;return{[ks]:a,[Ss]:t,[Fs]:!1}}let c=a,v=u,f=l;if(null==n?void 0:n.partialResponse){const t=Object.keys(c),n=v||{};c=wi(wi({},i),c),v=wi(wi({},e),n),t.forEach(t=>{t in n||null==v||delete v[t]}),f=wi(wi({},s),f)}else if(t.errorsWhileComputingFlags)if(l){const t=new Set(Object.keys(l).filter(t=>{var i;return!(null===(i=l[t])||void 0===i?void 0:i.failed)}));c=wi(wi({},i),Object.fromEntries(Object.entries(c).filter(([i])=>t.has(i))));const n=Object.fromEntries(Object.entries(v||{}).filter(([i])=>t.has(i)));v=wi(wi({},e),n),t.forEach(t=>{t in n||null==v||delete v[t]}),f=wi(wi({},s),Object.fromEntries(Object.entries(f||{}).filter(([i])=>t.has(i))))}else c=wi(wi({},i),c),v=wi(wi({},e),v),f=wi(wi({},s),f);return wi(wi({[ks]:Object.keys(Xu(c)),[Ss]:c||{},[Ts]:v||{},[Ps]:f||{},[Fs]:!0===t.minimalFlagCalledEvents},h?{[Cs]:h}:{}),d?{[Xs]:d}:{})})(t,this.getFlagVariants(),this.getFlagPayloads(),this.getFlagsWithDetails(),e,this.$);if(s)if(!1===(null==e?void 0:e.persist)){const t=!I(this.lo.kv.get(Ss));this.vd=s,t||this.At(s)}else this.sd(),this.gd(s,t,!!(null==e?void 0:e.partialResponse)),this.At(s);else i&&this.fd();i||(this.Uc=!1),this.od(i)}override(t,i=!1){this.$.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:t,suppressWarning:i})}overrideFeatureFlags(t){this.$d(t)}$d(t){if(this.lo){if(!1===t)return this.Lt([Is,Os]),this.od(),void Gu.info("All overrides cleared");if(P(t))return this.At({[Is]:Yu(t)}),this.od(),void Gu.info("Flag overrides set",{flags:t});if(t&&"object"==typeof t&&("flags"in t||"payloads"in t)){var i;const e=t;this.Fc=Boolean(null!==(i=e.suppressWarning)&&void 0!==i&&i);const s={},n=e.flags,r=e.payloads;return n&&(s[Is]=P(n)?Yu(n):n),r&&(s[Os]=r),Object.keys(s).length&&this.At(s),!1===n&&!1===r?this.Lt([Is,Os]):!1===n?this.Lt(Is):!1===r&&this.Lt(Os),this.od(),!1===n?Gu.info("Flag overrides cleared"):n&&Gu.info("Flag overrides set",{flags:n}),void(!1===r?Gu.info("Payload overrides cleared"):r&&Gu.info("Payload overrides set",{payloads:r}))}if(t&&"object"==typeof t)return this.At({[Is]:t}),this.od(),void Gu.info("Flag overrides set",{flags:t});this.$.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:t})}else this.$.warn("posthog.featureFlags.overrideFeatureFlags called before feature flags were ready")}onFeatureFlags(t){if(this.addFeatureFlagsHandler(t),this.Nc){const{flags:i,flagVariants:e}=this.Td();try{t(i,e)}catch(t){this.$.error("Error while running feature flags callback",t)}}return()=>this.removeFeatureFlagsHandler(t)}updateEarlyAccessFeatureEnrollment(t,i,e){var s;const n=(this.dd("$early_access_features")||[]).find(i=>i.flagKey===t),r={[`$feature_enrollment/${t}`]:i},o={$feature_flag:t,$feature_enrollment:i,$set:r};n&&(o.$early_access_feature_name=n.name),e&&(o.$feature_enrollment_stage=e);const l=wi(wi({},this.getFlagVariants()),{},{[t]:i});null===(s=this._instance)||void 0===s||null===(s=s.persistence)||void 0===s||s.markCrossTabFeatureFlagChanges({$active_feature_flags:[t],$enabled_feature_flags:[t],$stored_person_properties:Object.keys(r)}),this.At({[ks]:Object.keys(Xu(l)),[Ss]:l,[Rs]:wi(wi({},this.dd("$stored_person_properties")||{}),r)}),this.od();try{var a;null===(a=this.lo)||void 0===a||a.capture("$feature_enrollment_update",o).catch(t=>{this.$.error("Failed to capture early access feature enrollment",t)})}catch(t){this.$.error("Failed to capture early access feature enrollment",t)}}getEarlyAccessFeatures(t,i=!1,e){const s=this.dd(Es);!s||i?this.Id(t,e):t(s)}Id(t,i){var e=this;return Y(function*(){const s=e.lo;if(!s)return;const n=i?`&${i.map(t=>`stage=${t}`).join("&")}`:"";let r;try{const t=yield s.sendRequest(`/api/early_access_features/?token=${s.projectToken}${n}`,{target:"api",method:"GET",sentAt:"query"});if(!t.json)return;r=t.json.earlyAccessFeatures,e.At({[Es]:r})}catch(t){return void e.$.error("Early access feature request failed",t)}try{t(r)}catch(t){e.$.error("Early access feature callback failed",t)}})()}Td(){const t=this.getFlags(),i=this.getFlagVariants();return{flags:t.filter(t=>i[t]),flagVariants:Object.keys(i).filter(t=>i[t]).reduce((t,e)=>(t[e]=i[e],t),{})}}od(t){this.rd();const{flags:i,flagVariants:e}=this.Td();this.featureFlagEventHandlers.forEach(s=>{try{s(i,e,{errorsLoading:t})}catch(t){this.$.error("Error while running feature flags callback",t)}})}setPersonPropertiesForFlags(t,i=!0){this.Md(t,i)}Md(t,i=!0){const e=this.dd("$stored_person_properties")||{},s=(null==t?void 0:t.$set)||((null==t?void 0:t.$set_once)?{}:t),n=null==t?void 0:t.$set_once,r={};if(n)for(const t in n)({}).hasOwnProperty.call(n,t)&&(t in e||(r[t]=n[t]));this.At({[Rs]:wi(wi(wi({},e),r),s)}),i&&this.reloadFeatureFlags()}unsetPersonPropertiesForFlags(t,i=!0){const e=wi({},this.dd("$stored_person_properties")||{});t.forEach(t=>{delete e[t]}),this.At({[Rs]:e}),i&&this.reloadFeatureFlags()}resetPersonPropertiesForFlags(t=!0){this.Lt(Rs),t&&this.reloadFeatureFlags()}setGroupPropertiesForFlags(t,i=!0){const e=this.dd("$stored_group_properties")||{},s=wi({},e);for(const i of Object.keys(t))s[i]=wi(wi({},e[i]),t[i]);this.At({[As]:s}),i&&this.reloadFeatureFlags()}resetGroupPropertiesForFlags(t){if(t){const i=this.dd("$stored_group_properties")||{};this.At({[As]:wi(wi({},i),{},{[t]:{}})})}else this.Lt(As)}reset(){this.jc++,this.Hc=!1,this.Oc={},this.Dc={},this.vd=void 0,this.Nc=!1,this.Bc=!1,this.zc=!1,this.$anon_distinct_id=void 0,this.hd(),this.Fc=!1,this.Wc=0}}},gh={sessionRecording:class{get Sr(){return this._instance.config}get ga(){return this._instance.persistence}get started(){var t;return!!(null===(t=this.Ed)||void 0===t?void 0:t.isStarted)}get status(){var t,i;return"awaiting_config"===this.Pd||"missing_config"===this.Pd?this.Pd:null!==(t=null===(i=this.Ed)||void 0===i?void 0:i.status)&&void 0!==t?t:this.Pd}constructor(i){if(this._instance=i,this._forceAllowLocalhostNetworkCapture=!1,this.Pd=wu,this.Rd=void 0,this.Ad=!1,this.Ke=(()=>{var i,e;if(!(null==s?void 0:s.visibilityState)||"visible"===s.visibilityState)return!0;const n=null==t||null===(i=t.performance)||void 0===i||null===(e=i.getEntriesByType)||void 0===e?void 0:e.call(i,"visibility-state");return!(null==n?void 0:n.length)||n.some(t=>"visible"===t.name)})(),this.an=()=>{var t,i;"visible"===(null==s?void 0:s.visibilityState)&&(this.Ke=!0,null===(t=this.Ed)||void 0===t||null===(i=t.setDocumentWasEverVisible)||void 0===i||i.call(t,!0))},!this._instance.sessionManager)throw xu.error("started without valid sessionManager"),new Error("[SessionRecording] started without valid sessionManager. This is a bug.");if("always"===this.Sr.cookieless_mode)throw new Error('[SessionRecording] cannot be used with cookieless_mode="always"');(null==s?void 0:s.addEventListener)&&Ln(s,"visibilitychange",this.an)}initialize(){this.startIfEnabledOrStop()}dispose({discardBufferedEvents:t=!1}={}){var i;this.Ad=!0,null==s||null===(i=s.removeEventListener)||void 0===i||i.call(s,"visibilitychange",this.an),t?this.Fd(!0):this.stopRecording()}get Od(){var i;const e=!!(null===(i=this._instance.get_property("$session_recording_remote_config"))||void 0===i?void 0:i.enabled),s=!this.Sr.disable_session_recording,n=this.Sr.disable_session_recording||this._instance.consent.isOptedOut();return t&&e&&s&&!n}startIfEnabledOrStop(t){var i;if(this.Ad)return;if(this.Od&&(null===(i=this.Ed)||void 0===i?void 0:i.isStarted))return;const e=!I(Object.assign)&&!I(Array.from);this.Od&&e?(this.Dd(t),xu.info("starting")):(this.Pd=wu,this.stopRecording())}Dd(t){var i,e;if(this.Od)if("awaiting_config"!==this.Pd&&"missing_config"!==this.Pd&&(this.Pd=$u),(null==c||null===(i=c.__PosthogExtensions__)||void 0===i||null===(i=i.rrweb)||void 0===i?void 0:i.record)&&(null===(e=c.__PosthogExtensions__)||void 0===e?void 0:e.initSessionRecording))this.Ld(t);else{var s,n;const i=this._instance.sessionManager;null===(s=c.__PosthogExtensions__)||void 0===s||null===(n=s.loadExternalDependency)||void 0===n||n.call(s,this._instance,this.Nd,e=>{if(!this.Ad&&this.Od&&this._instance.sessionManager===i)return e?(this._instance.register_for_session({$sdk_debug_recording_script_not_loaded:!0}),xu.error("could not load recorder",e)):void this.Ld(t);this.Pd="disabled"})}}stopRecording(){var t,i;null===(t=this.Rd)||void 0===t||t.call(this),this.Rd=void 0,null===(i=this.Ed)||void 0===i||i.stop()}Fd(t=!1){var i,e;null===(i=this.Rd)||void 0===i||i.call(this),this.Rd=void 0,null===(e=this.Ed)||void 0===e||e.discard({discardProducerEvents:t})}qd(){var t,i;null===(t=this.ga)||void 0===t||t.unregister("$session_is_sampled"),null===(i=this.ga)||void 0===i||i.unregister("$replay_sample_rate")}jd(t,i){if(M(t))return null;const e=D(t)?t:parseFloat(t);return"number"!=typeof(s=e)||!Number.isFinite(s)||0>s||s>1?(xu.warn(`${i} must be between 0 and 1. Ignoring invalid value:`,t),null):e;var s}Bd(t){if(this.ga){var i,e;const s=this.ga,n=()=>{var i;const e=!1===t.sessionRecording?void 0:t.sessionRecording,n=this.jd(null===(i=this.Sr.session_recording)||void 0===i?void 0:i.sampleRate,"session_recording.sampleRate"),r=this.jd(null==e?void 0:e.sampleRate,"remote config sampleRate"),o=null!=n?n:r;M(o)&&this.qd();const l=null==e?void 0:e.minimumDurationMilliseconds;s.register({[hs]:wi(wi({cache_timestamp:Date.now(),enabled:!!e},e),{},{networkPayloadCapture:wi({capturePerformance:t.capturePerformance},null==e?void 0:e.networkPayloadCapture),canvasRecording:{enabled:null==e?void 0:e.recordCanvas,fps:null==e?void 0:e.canvasFps,quality:null==e?void 0:e.canvasQuality},sampleRate:o,minimumDurationMilliseconds:I(l)?null:l,endpoint:null==e?void 0:e.endpoint,triggerMatchType:null==e?void 0:e.triggerMatchType,masking:null==e?void 0:e.masking,urlTriggers:null==e?void 0:e.urlTriggers,version:null==e?void 0:e.version,triggerGroups:null==e?void 0:e.triggerGroups})})};n(),null===(i=this.Rd)||void 0===i||i.call(this),this.Rd=null===(e=this._instance.sessionManager)||void 0===e?void 0:e.onSessionId(n)}}onRemoteConfig(t){const i=t.ok?t.config:void 0;return i&&"sessionRecording"in i?!1===i.sessionRecording?(this.Bd(i),void this.Fd()):(this.Bd(i),void this.startIfEnabledOrStop()):("awaiting_config"===this.Pd&&(this.Pd="missing_config",xu.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(t,i="log"){var e;(null===(e=this.Ed)||void 0===e?void 0:e.log)?this.Ed.log(t,i):xu.warn("log called before recorder was ready")}get Nd(){var t,i;const e=null===(t=this._instance)||void 0===t||null===(t=t.persistence)||void 0===t?void 0:t.get_property(hs);return(null==e||null===(i=e.scriptConfig)||void 0===i?void 0:i.script)||"lazy-recorder"}Hd(){const t=this._instance.get_property(hs);if(!t)return!1;let i;try{i="object"==typeof t?t:JSON.parse(t)}catch(t){return xu.warn("persisted remote config for session recording is invalid and will be ignored",t),!1}return!M(i.cache_timestamp)&&36e5>=Date.now()-i.cache_timestamp}Ld(t){var i,e,s;if(!this.Ad&&this.Od&&this._instance.sessionManager){if(!(null===(i=c.__PosthogExtensions__)||void 0===i?void 0:i.initSessionRecording))return xu.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[hn]:!0});var n;if(this.Ed||(this.Ed=null===(n=c.__PosthogExtensions__)||void 0===n?void 0:n.initSessionRecording(this._instance,this.Ke),this.Ed._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.Hd()){if("missing_config"===this.Pd||"awaiting_config"===this.Pd)return;return this.Pd="awaiting_config",xu.info("persisted remote config is stale, requesting fresh config before starting"),void new al(this._instance).load()}this.Pd=$u,null===(e=(s=this.Ed).setDocumentWasEverVisible)||void 0===e||e.call(s,this.Ke),this.Ed.start(t)}else this.Pd=wu}onRRwebEmit(t){var i,e;null===(i=this.Ed)||void 0===i||null===(e=i.onRRwebEmit)||void 0===e||e.call(i,t)}overrideLinkedFlag(){var t,i;this.Ed||null===(i=this.ga)||void 0===i||i.register({$replay_override_linked_flag:!0}),null===(t=this.Ed)||void 0===t||t.overrideLinkedFlag()}overrideSampling(){var t,i;this.Ed||null===(i=this.ga)||void 0===i||i.register({$replay_override_sampling:!0}),null===(t=this.Ed)||void 0===t||t.overrideSampling()}overrideTrigger(t){var i,e;this.Ed||null===(e=this.ga)||void 0===e||e.register({["url"===t?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),null===(i=this.Ed)||void 0===i||i.overrideTrigger(t)}get sdkDebugProperties(){var t;return(null===(t=this.Ed)||void 0===t?void 0:t.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(t,i){var e;return!!(null===(e=this.Ed)||void 0===e?void 0:e.tryAddCustomEvent(t,i))}flushBeforeIdentityReset(){var t,i;null===(t=this.Ed)||void 0===t||null===(i=t.flushBeforeIdentityReset)||void 0===i||i.call(t)}}},_h={autocapture:class extends uu{constructor(t){super(new hu(t)),this.instance=t}},historyAutocapture:class{constructor(t){this._instance=t,this.zd=this.Ud()}initialize(){this.startIfEnabled()}get isEnabled(){const t=this.Wd();return!!(t.path||t.search||this.Vd(t))}startIfEnabled(){this.isEnabled&&(je.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}startIfEnabledOrStop(){this.stop(),this.zd=this.Ud(),this.startIfEnabled()}stop(){this.Gd&&this.Gd(),this.Gd=void 0,this.Zd&&this.Zd(),this.Zd=void 0,je.info("History API monitoring stopped")}monitorHistoryChanges(){t&&t.history&&(this.Qd("pushState"),this.Qd("replaceState"),this.Jd(),this.Vd()&&this.Kd())}Qd(i){var e;if(!t||(null===(e=t.history[i])||void 0===e?void 0:e.__posthog_wrapped__))return;const s=this;fu(t.history,i,t=>function(e,n,r){t.call(this,e,n,r),s.Yd(i)})}Ud(){const i=null==t?void 0:t.location;if(null==i?void 0:i.pathname)return{pathname:i.pathname,search:i.search,hash:i.hash}}Wd(){const t=this._instance.config.capture_pageview;return"history_change"===t?{path:!0}:C(t)?t:{}}Vd(t=this.Wd()){return!!t.hash&&!this._instance.config.disable_capture_url_hashes}Xd(t){const i=this.Wd(),e=this.zd;return!(!e||!(i.path&&t.pathname!==e.pathname||i.search&&t.search!==e.search||this.Vd(i)&&t.hash!==e.hash))}Yd(t){try{const i=this.Ud();if(!i)return;this.Xd(i)&&this._instance.capture(kn,{navigation_type:t}),this.zd=i}catch(i){je.error(`Error capturing ${t} pageview`,i)}}Jd(){if(this.Gd)return;const i=()=>{this.Yd("popstate")};Ln(t,"popstate",i),this.Gd=()=>{t&&t.removeEventListener("popstate",i)}}Kd(){if(this.Zd)return;const i=()=>{this.Yd("hashchange")};Ln(t,"hashchange",i),this.Zd=()=>{t&&t.removeEventListener("hashchange",i)}}},heatmaps:class{get Sr(){return this.instance.config}constructor(t){var i;this.tv=!1,this.ho=!1,this.ev=null,this.instance=t,this.tv=!!(null===(i=this.instance.persistence)||void 0===i?void 0:i.props[is]),this.rageclicks=new su(t.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){let t=5e3;return C(this.Sr.capture_heatmaps)&&this.Sr.capture_heatmaps.flush_interval_milliseconds&&(t=this.Sr.capture_heatmaps.flush_interval_milliseconds),t}get isEnabled(){return M(this.Sr.capture_heatmaps)?M(this.Sr.enable_heatmaps)?this.tv:this.Sr.enable_heatmaps:!1!==this.Sr.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this.ho)return;Su.info("starting..."),this.iv(),this.an()}else{var t;clearInterval(null!==(t=this.ev)&&void 0!==t?t:void 0),this.nv(),this.getAndClearBuffer()}}onRemoteConfig(t){if(!t.ok)return;const i=t.config;if(!("heatmaps"in i))return;const e=!!i.heatmaps;this.instance.persistence&&this.instance.persistence.register({[is]:e}),this.tv=e,this.startIfEnabled()}getAndClearBuffer(){const t=this.Rt;return this.Rt=void 0,t}sv(t){ku(t.originalEvent)&&this._r(t.originalEvent,"deadclick")}an(){this.ev&&clearInterval(this.ev),this.ev=function(t){return"visible"===(null==t?void 0:t.visibilityState)}(s)?setInterval(this.oa.bind(this),this.flushIntervalMilliseconds):null}iv(){t&&s&&(this.rv=this.oa.bind(this),Ln(t,Sn,this.rv),this.ov=i=>this._r(i||(null==t?void 0:t.event)),Ln(s,"click",this.ov,{capture:!0}),this.lv=i=>this.av(i||(null==t?void 0:t.event)),Ln(s,"mousemove",this.lv,{capture:!0}),this.uv=new no(this.instance,eo,this.sv.bind(this)),this.uv.startIfEnabledOrStop(),this.hv=this.an.bind(this),Ln(s,xn,this.hv),this.ho=!0)}nv(){var i;t&&s&&(this.rv&&t.removeEventListener(Sn,this.rv),this.ov&&s.removeEventListener("click",this.ov,{capture:!0}),this.lv&&s.removeEventListener("mousemove",this.lv,{capture:!0}),this.hv&&s.removeEventListener(xn,this.hv),clearTimeout(this.dv),null===(i=this.uv)||void 0===i||i.stop(),this.ho=!1)}vv(i,e){const s=this.instance.scrollManager.scrollY(),n=this.instance.scrollManager.scrollX(),r=this.instance.scrollManager.scrollElement(),o=function(i,e,s){let n=i;for(;n&&mr(n)&&!br(n,"body");){if(n===s)return!1;let i;try{var r,o,l;i=null===(r=null!==(o=null===(l=n.ownerDocument)||void 0===l?void 0:l.defaultView)&&void 0!==o?o:t)||void 0===r?void 0:r.getComputedStyle(n).position}catch(t){return!1}if(b(e,i))return!0;n=Ir(n)}return!1}(Pr(i),["fixed","sticky"],r);return{x:i.clientX+(o?0:n),y:i.clientY+(o?0:s),target_fixed:o,type:e}}_r(t,i="click"){var e;if(_r(t.target)||!ku(t))return;const s=this.vv(t,i);(null===(e=this.rageclicks)||void 0===e?void 0:e.isRageClick(t.clientX,t.clientY,(new Date).getTime()))&&Br(Pr(t),this.instance.config.rageclick)&&this.Hs(wi(wi({},s),{},{type:"rageclick"})),this.Hs(s)}av(t){!_r(t.target)&&ku(t)&&(clearTimeout(this.dv),this.dv=setTimeout(()=>{this.Hs(this.vv(t,"mousemove"))},500))}Hs(i){if(!t)return;const e=this.Sr.disable_capture_url_hashes?hi(t.location.href):t.location.href,s=this.Sr.custom_personal_data_properties,n=this.Sr.mask_personal_data_properties?[...xo,...s||[]]:[],r=bo(e,n,ko);this.Rt=this.Rt||{},this.Rt[r]||(this.Rt[r]=[]),this.Rt[r].push(i)}oa(){this.Rt&&!F(this.Rt)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:no,webVitalsAutocapture:class{constructor(t){var i;this._instance=t,this.tv=!1,this.ho=!1,this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this.fv=()=>{clearTimeout(this.pv),this.pv=void 0,0!==this.Rt.metrics.length&&(this._instance.capture("$web_vitals",wi({$current_url:this.Rt.url},this.Rt.metrics.reduce((t,i)=>wi(wi({},t),{},{[`$web_vitals_${i.name}_event`]:wi({},i),[`$web_vitals_${i.name}_value`]:i.value}),{}))),this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.gv=t=>{var i;if(this.Rt=this.Rt||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},M(null==t?void 0:t.name)||M(null==t?void 0:t.value))return void gu.error("Invalid metric received",t);const e="string"==typeof t.navigationURL?t.navigationURL:void 0,s=this.mv(e);if(I(s))return;const n=D(t.navigationId)||"string"==typeof t.navigationId?`navigation:${t.navigationId}`:`url:${s}`;if(this.yv&&t.value>=this.yv)return void gu.error("Ignoring metric with value >= "+this.yv,t);this.Rt.navigationKey!==n&&(this.fv(),this.pv=setTimeout(this.fv,this.flushToCaptureTimeoutMs)),I(this.Rt.navigationKey)&&(this.Rt.navigationKey=n,this.Rt.url=s),this.Rt.firstMetricTimestamp=I(this.Rt.firstMetricTimestamp)?Date.now():this.Rt.firstMetricTimestamp;const r=null===(i=this._instance.sessionManager)||void 0===i?void 0:i.checkAndGetSessionAndWindowId(!0),o=wi(wi(wi({},t),e?{navigationURL:s}:{}),{},{$current_url:s,timestamp:Date.now()});if(delete o.entries,C(t.attribution)&&this.attributionMetrics.indexOf(t.name)>-1){const i={};for(const e of yu){const s="url"===e&&"string"==typeof t.attribution[e]?this.mv(t.attribution[e]):t.attribution[e];I(s)||(i[e]=s)}o.attribution=i}else delete o.attribution;I(r)||(o.$session_id=r.sessionId,o.$window_id=r.windowId),this.Rt.metrics.push(o),this.Rt.metrics.length===this.allowedMetrics.length&&this.fv()},this.bv=()=>{if(this.ho)return;let t,i,e,s,n=!1;const r=c.__PosthogExtensions__,o=null==r?void 0:r.postHogWebVitalsCallbacksByFlavor,l=(null==o?void 0:o[this._v])||("web-vitals"===this._v&&I(o)?null==r?void 0:r.postHogWebVitalsCallbacks:void 0);if(!I(l)){const r=l.withoutAttribution,o=this.attributionMetrics;n=!I(r),t=o.indexOf("LCP")>-1?l.onLCP:(null==r?void 0:r.onLCP)||l.onLCP,i=o.indexOf("CLS")>-1?l.onCLS:(null==r?void 0:r.onCLS)||l.onCLS,e=o.indexOf("FCP")>-1?l.onFCP:(null==r?void 0:r.onFCP)||l.onFCP,s=o.indexOf("INP")>-1?l.onINP:(null==r?void 0:r.onINP)||l.onINP}if(!(t&&i&&e&&s))return void gu.error("web vitals callbacks not loaded - not starting");const a={reportSoftNavs:this.useSoftNavs},u=n&&this.attributionMetrics.indexOf("INP")>-1?wi(wi({},a),{},{includeProcessedEventEntries:!1}):a;this.allowedMetrics.indexOf("LCP")>-1&&t(this.gv.bind(this),a),this.allowedMetrics.indexOf("CLS")>-1&&i(this.gv.bind(this),a),this.allowedMetrics.indexOf("FCP")>-1&&e(this.gv.bind(this),a),this.allowedMetrics.indexOf("INP")>-1&&s(this.gv.bind(this),u),this.ho=!0},this.tv=!!(null===(i=this._instance.persistence)||void 0===i?void 0:i.props[rs]),this.startIfEnabled()}get wv(){return this._instance.config.capture_performance}get allowedMetrics(){var t,i;const e=C(this.wv)?null===(t=this.wv)||void 0===t?void 0:t.web_vitals_allowed_metrics:void 0;return M(e)?(null===(i=this._instance.persistence)||void 0===i?void 0:i.props.$web_vitals_allowed_metrics)||mu:e}get flushToCaptureTimeoutMs(){return(C(this.wv)?this.wv.web_vitals_delayed_flush_ms:void 0)||5e3}get attributionMetrics(){const t=C(this.wv)?this.wv.web_vitals_attribution:void 0;return B(t)?t?mu:[]:P(t)?t:bu}get useAttribution(){return this.attributionMetrics.length>0}get useSoftNavs(){const t=C(this.wv)?this.wv.__preview_web_vitals_soft_navs:void 0;return null!=t&&t}get yv(){const t=C(this.wv)&&D(this.wv.__web_vitals_max_value)?this.wv.__web_vitals_max_value:_u;return t>0&&6e4>=t?_u:t}get isEnabled(){const t=null==n?void 0:n.protocol;if("http:"!==t&&"https:"!==t)return gu.info("Web Vitals are disabled on non-http/https protocols"),!1;const i=C(this.wv)?this.wv.web_vitals:B(this.wv)?this.wv:void 0;return B(i)?i:this.tv}startIfEnabled(){this.isEnabled&&!this.ho&&(gu.info("enabled, starting..."),this.Eo(this.bv))}onRemoteConfig(t){if(!t.ok)return;const i=t.config;if(!("capturePerformance"in i))return;const e=C(i.capturePerformance)&&!!i.capturePerformance.web_vitals,s=C(i.capturePerformance)?i.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[rs]:e}),this._instance.persistence.register({[us]:s})),this.tv=e,this.startIfEnabled()}get _v(){return this.useSoftNavs?this.useAttribution?"web-vitals-with-attribution-soft-navs":"web-vitals-soft-navs":this.useAttribution?"web-vitals-with-attribution":"web-vitals"}Eo(t){var i;const e=c.__PosthogExtensions__,s=this._v,n=null==e?void 0:e.postHogWebVitalsCallbacksByFlavor;(null==n?void 0:n[s])||"web-vitals"===s&&I(n)&&(null==e?void 0:e.postHogWebVitalsCallbacks)?t():null==e||null===(i=e.loadExternalDependency)||void 0===i||i.call(e,this._instance,s,i=>{i?gu.error("failed to load script",i):t()})}mv(i){const e=i||(null==t?void 0:t.location.href);if(!e)return void gu.error("Could not determine current URL");const s=this._instance.config.disable_capture_url_hashes?hi(e):e,n=this._instance.config.custom_personal_data_properties,r=this._instance.config.mask_personal_data_properties?[...xo,...n||[]]:[];return bo(s,r,ko)}}},mh={exceptionObserver:class{constructor(i){var e;this.bv=()=>{var i;if(!t||!this.isEnabled||!(null===(i=c.__PosthogExtensions__)||void 0===i?void 0:i.errorWrappingFunctions))return;const e=c.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,s=c.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,n=c.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.Sv&&this.Sr.capture_unhandled_errors&&(this.Sv=e(this.captureException.bind(this))),!this.xv&&this.Sr.capture_unhandled_rejections&&(this.xv=s(this.captureException.bind(this))),!this.Cv&&this.Sr.capture_console_errors&&(this.Cv=n(this.captureException.bind(this)))}catch(t){du.error("failed to start",t),this.$v()}},this._instance=i,this.Tv=!!(null===(e=this._instance.persistence)||void 0===e?void 0:e.props[es]),this.wt=new tt(wi(wi({},function(t={}){var i,e,s,n;return{refillRate:null!==(i=null!==(e=t.exceptionRateLimiterRefillRate)&&void 0!==e?e:t.__exceptionRateLimiterRefillRate)&&void 0!==i?i:1,bucketSize:null!==(s=null!==(n=t.exceptionRateLimiterBucketSize)&&void 0!==n?n:t.__exceptionRateLimiterBucketSize)&&void 0!==s?s:10}}(this._instance.config.error_tracking)),{},{refillInterval:1e4,$:du})),this.Sr=this.Iv(),this.startIfEnabledOrStop()}Iv(){const t=this._instance.config.capture_exceptions;let i={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return C(t)?i=wi(wi({},i),t):(I(t)?this.Tv:t)&&(i=wi(wi({},i),{},{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),i}get isEnabled(){return this.Sr.capture_console_errors||this.Sr.capture_unhandled_errors||this.Sr.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(du.info("enabled"),this.$v(),this.Eo(this.bv)):this.$v()}Eo(t){var i,e,s;(null===(i=c.__PosthogExtensions__)||void 0===i?void 0:i.errorWrappingFunctions)?t():null===(e=c.__PosthogExtensions__)||void 0===e||null===(s=e.loadExternalDependency)||void 0===s||s.call(e,this._instance,"exception-autocapture",i=>{if(i)return du.error("failed to load script",i);t()})}$v(){var t,i,e;null===(t=this.Sv)||void 0===t||t.call(this),this.Sv=void 0,null===(i=this.xv)||void 0===i||i.call(this),this.xv=void 0,null===(e=this.Cv)||void 0===e||e.call(this),this.Cv=void 0}onRemoteConfig(t){if(!t.ok)return;const i=t.config;"autocaptureExceptions"in i&&(this.Tv=!!i.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[es]:this.Tv}),this.Sr=this.Iv(),this.startIfEnabledOrStop())}onConfigChange(){this.Sr=this.Iv()}captureException(t){try{var i,e,s;const n=null!==(i=null==t||null===(e=t.$exception_list)||void 0===e||null===(e=e[0])||void 0===e?void 0:e.type)&&void 0!==i?i:"Exception";if(this.wt.consumeRateLimit(n))return void du.info("Skipping exception capture because of client rate limiting.",{exception:n});null===(s=this._instance.exceptions)||void 0===s||s.sendExceptionEvent(t)}catch(t){}}},exceptions:class{constructor(t){var i,e;this.Mv=[],this.Ev=new $i([new Ni,new Yi,new Ui,new zi,new Ki,new Gi,new qi,new Ji],function(t,...i){return(e,s=0)=>{const n=[],r=e.split("\n"),o=Math.min(r.length,s+1e3),l=[];for(let e=s;o>e;e++){const s=r[e];if(s.length>1024)continue;const o=Oi.test(s)?s.replace(Oi,"$1"):s;if(!o.match(/\S*Error: /)){for(const e of i){const i=e(o,t);if(i){n.push(i);const t=Ai(n);if(t){for(let i=l.length-1;i>=0;i--){const e=l[i];if(t.start>=e.start+e.length)break;l.pop()}l.push(t)}break}}if(Bi(n,l)>=50)break}}const a=[...l].sort((t,i)=>i.start-t.start),u=a[a.length-1];if(u){const t=Di(n,u);n.splice(u.start-t,t);for(const i of a)i.start-=t}for(const t of a)Mi(n,t);return l.some(t=>0===t.start&&n.length===t.length)&&function(t){const i=t.map(t=>`${t.function}|${t.filename}|${t.lineno}|${t.colno}|${t.module}`);let e=0;for(let t=1;i.length>t;t++)Li(i,t,e)&&(e=t);t.push(...t.splice(0,e))}(n),function(t){if(!t.length)return[];const i=Array.from(t);return i.reverse(),i.slice(0,50).map(t=>{return wi(wi({},t),{},{filename:t.filename||(e=i,e[e.length-1]||{}).filename,function:t.function||"?"});var e})}(n)}}("web:javascript",Ti,Ii)),this._instance=t,this.Mv=null!==(i=null===(e=this._instance.persistence)||void 0===e?void 0:e.get_property("$error_tracking_suppression_rules"))&&void 0!==i?i:[],this.Pv=ie(this.Rv()),this.Av=new ee(this.Pv)}onConfigChange(){this.Pv=ie(this.Rv()),this.Av.setConfig(this.Pv)}onRemoteConfig(t){var i,e,s;if(!t.ok)return;const n=t.config;if(!("errorTracking"in n))return;const r=null!==(i=null===(e=n.errorTracking)||void 0===e?void 0:e.suppressionRules)&&void 0!==i?i:[],o=null===(s=n.errorTracking)||void 0===s?void 0:s.captureExtensionExceptions;this.Mv=r,this._instance.persistence&&this._instance.persistence.register({[ss]:this.Mv,[ns]:o})}get Fv(){var t;const i=!!this._instance.get_property(ns),e=this._instance.config.error_tracking.captureExtensionExceptions;return null!==(t=null!=e?e:i)&&void 0!==t&&t}buildProperties(t,i){return this.Ev.buildFromUnknown(t,{syntheticException:null==i?void 0:i.syntheticException,mechanism:{handled:null==i?void 0:i.handled}})}addExceptionStep(t,i){if(this.Pv.enabled)try{if(!O(t)||0===t.trim().length)return void Qu.warn("Ignoring exception step because message must be a non-empty string");const{sanitizedProperties:e,droppedKeys:s}=function(t){if(!t)return{sanitizedProperties:{},droppedKeys:[]};const i=[];return{sanitizedProperties:Object.keys(t).reduce((e,s)=>Qi.has(s)?(i.push(s),e):(e[s]=t[s],e),{}),droppedKeys:i}}(this.Ov(i));s.length>0&&Qu.warn("Ignoring reserved exception step fields",{droppedKeys:s}),this.Av.add(wi({[Xi]:t,[Zi]:(new Date).toISOString()},e))}catch(t){Qu.error("Failed to add exception step. Ignoring breadcrumb.",t)}}sendExceptionEvent(t){try{const i=t.$exception_list;if(this.Dv(i)){if(this.Lv(i))return this.Nv("Exception dropped: matched a suppression rule"),void Qu.info("Skipping exception capture because a suppression rule matched");if(!this.Fv&&this.qv(i))return this.Nv("Exception dropped: thrown by a browser extension"),void Qu.info("Skipping exception capture because it was thrown by an extension");if(!this.Fv&&this.jv(i))return this.Nv("Exception dropped: thrown by an injected browser script"),void Qu.info("Skipping exception capture because it was thrown by an injected browser script");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.Bv(i))return this.Nv("Exception dropped: thrown by the PostHog SDK"),void Qu.info("Skipping exception capture because it was thrown by the PostHog SDK")}const e=this.Pv.enabled&&M(t.$exception_steps)?this.Hv(t):t,s=function(){const t=globalThis._posthogReleaseId;return"string"==typeof t&&t.length>0?t:void 0}();s&&(e.$release_id=s);try{const t=this._instance.capture("$exception",e,{_noTruncate:!0,_batchKey:"exceptionEvent",Gu:!0});return t&&this.Av.clear(),t}catch(t){return Zu(t)||Qu.error("Failed to capture exception event. Dropping this exception.",t),void this.Av.clear()}}catch(t){return void(Zu(t)||Qu.error("Failed to process exception event. Ignoring this exception.",t))}}Hv(t){try{const i=this.Av.getAttachable();return 0===i.length?t:wi(wi({},t),{},{$exception_steps:i})}catch(i){return Qu.error("Failed to read buffered exception steps. Capturing exception without steps.",i),t}}Nv(t){this.Pv.enabled&&this.Av.add({[Xi]:t,[Zi]:(new Date).toISOString()})}Ov(t){return C(t)?wi({},t):{}}Rv(){var t,i;return null!==(t=null===(i=this._instance.config.error_tracking)||void 0===i?void 0:i.exception_steps)&&void 0!==t?t:{}}Lv(t){if(0===t.length)return!1;try{const i=t.reduce((t,{type:i,value:e})=>(O(i)&&i.length>0&&t.$exception_types.push(i),O(e)&&e.length>0&&t.$exception_values.push(e),t),{$exception_types:[],$exception_values:[]});return this.Mv.some(t=>{const e=t.values.map(t=>{const e=ya[t.operator],s=i[t.key];if(!e||!s)return!1;const n=P(t.value)?t.value:[t.value];return n.length>0&&e(n,s)});return"OR"===t.type?e.some(Boolean):e.every(Boolean)})}catch(t){return Qu.warn("Failed to evaluate suppression rules. Capturing the exception.",t),!1}}qv(t){const i=t.flatMap(t=>{var i,e;return null!==(i=null===(e=t.stacktrace)||void 0===e?void 0:e.frames)&&void 0!==i?i:[]}),e=i.filter(({filename:t})=>!!t&&eh.some(i=>t.startsWith(i)));return 0!==e.length&&(!e.every(({filename:t})=>!!t&&t.startsWith(th))||t.some(({type:t,value:i})=>"NoResponse"===t||O(i)&&ih.some(({value:t,exact:e})=>e?i===t:i.includes(t)))&&!i.some(({in_app:t,filename:i})=>t&&!(null==i?void 0:i.startsWith(th))))}jv(t){return t.some(({value:t})=>O(t)&&sh.some(i=>t.includes(i)))}Bv(t){if(t.length>0){var i,e,s,n;const r=null!==(i=null===(e=t[0].stacktrace)||void 0===e?void 0:e.frames)&&void 0!==i?i:[],o=r[r.length-1];return null!==(s=null==o||null===(n=o.filename)||void 0===n?void 0:n.includes("posthog.com/static"))&&void 0!==s&&s}return!1}Dv(t){return!M(t)&&P(t)}}},bh=wi({productTours:class{get ga(){return this._instance.persistence}constructor(t){this.zv=null,this.Uv=null,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!t.ok)return;const i=t.config;if("productTours"in i){var e,s;if(this.ga&&this.ga.register({[ls]:!!i.productTours}),!Pu(this._instance))return!this.zv&&M(null===(e=this.ga)||void 0===e?void 0:e.props.ph_product_tours)||Eu.info("product tours disabled; stopping and clearing cached tours"),null===(s=this.zv)||void 0===s||s.stop(),this.zv=null,void this.clearCache();this.loadIfEnabled()}}loadIfEnabled(){!this.zv&&Pu(this._instance)&&this.Eo(()=>this.Wv())}Eo(t){var i,e,s;(null===(i=c.__PosthogExtensions__)||void 0===i?void 0:i.generateProductTours)?t():null===(e=c.__PosthogExtensions__)||void 0===e||null===(s=e.loadExternalDependency)||void 0===s||s.call(e,this._instance,"product-tours",i=>{i?Eu.error("Could not load product tours script",i):t()})}Wv(){var t;!this.zv&&(null===(t=c.__PosthogExtensions__)||void 0===t?void 0:t.generateProductTours)&&(this.zv=c.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(t,i=!1){if(P(this.Uv)&&!i)return void t(this.Uv,{isLoaded:!0});const e=this.ga;if(e){const s=e.props[zs];if(P(s)&&!i)return this.Uv=s,void t(s,{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:i=>{if(!Pu(this._instance))return void t([],{isLoaded:!0});const s=i.statusCode;if(200!==s||!i.json){const e=`Product Tours API could not be loaded, status: ${s}`;return 0===s?i.error||Eu.warn(e):Eu.error(e),void t([],{isLoaded:!1,error:e})}const n=P(i.json.product_tours)?i.json.product_tours:[];this.Uv=n,e&&e.register({[zs]:n}),t(n,{isLoaded:!0})}})}getActiveProductTours(t){M(this.zv)?t([],{isLoaded:!1,error:"Product tours not loaded"}):this.zv.getActiveProductTours(t)}showProductTour(t){var i;null===(i=this.zv)||void 0===i||i.showTourById(t)}previewTour(t){this.zv?this.zv.previewTour(t):this.Eo(()=>{var i;this.Wv(),null===(i=this.zv)||void 0===i||i.previewTour(t)})}dismissProductTour(){var t;null===(t=this.zv)||void 0===t||t.dismissTour("user_clicked_skip")}nextStep(){var t;null===(t=this.zv)||void 0===t||t.nextStep()}previousStep(){var t;null===(t=this.zv)||void 0===t||t.previousStep()}clearCache(){var t;this.Uv=null,null===(t=this.ga)||void 0===t||t.unregister("ph_product_tours")}resetTour(t){var i;null===(i=this.zv)||void 0===i||i.resetTour(t)}resetAllTours(){var t;null===(t=this.zv)||void 0===t||t.resetAllTours()}cancelPendingTour(t){var i;null===(i=this.zv)||void 0===i||i.cancelPendingTour(t)}}},ph),yh={siteApps:class{constructor(t){this._instance=t,this.Vv=0,this.Gv=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}Zv(t,i){if(!i)return;const e=this.globalsForEvent(i);this.Gv.push(e),this.Gv.length>1e3&&(this.Gv=this.Gv.slice(10))}get siteAppLoaders(){var t;return null===(t=c._POSTHOG_REMOTE_CONFIG)||void 0===t||null===(t=t[this._instance.config.token])||void 0===t?void 0:t.siteApps}initialize(){if(this.isEnabled){const t=this._instance._addCaptureHook(this.Zv.bind(this));this.Qv=()=>{t(),this.Gv=[],this.Qv=void 0}}}globalsForEvent(t){var i,e,s,n,r,o,l;if(!t)throw new Error("Event payload is required");const a={},u=this._instance.get_property("$groups")||[],h=this._instance.get_property("$stored_group_properties")||{};for(const[t,i]of Object.entries(h))a[t]={id:u[t],type:t,properties:i};const{$set_once:d,$set:c}=t;return{event:wi(wi({},_e(t,Tu)),{},{properties:wi(wi(wi({},t.properties),c?{$set:wi(wi({},null!==(i=null===(e=t.properties)||void 0===e?void 0:e.$set)&&void 0!==i?i:{}),c)}:{}),d?{$set_once:wi(wi({},null!==(s=null===(n=t.properties)||void 0===n?void 0:n.$set_once)&&void 0!==s?s:{}),d)}:{}),elements_chain:null!==(r=null===(o=t.properties)||void 0===o?void 0:o.$elements_chain)&&void 0!==r?r:"",distinct_id:null===(l=t.properties)||void 0===l?void 0:l.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:a}}Jv(t){var i;const e=null===(i=t.tagName)||void 0===i?void 0:i.toLowerCase();if("style"===e&&this._instance.config.prepare_external_dependency_stylesheet){return this._instance.config.prepare_external_dependency_stylesheet(t)||(Cu.error("prepare_external_dependency_stylesheet returned null"),null)}if("script"===e&&this._instance.config.prepare_external_dependency_script){return this._instance.config.prepare_external_dependency_script(t)||(Cu.error("prepare_external_dependency_script returned null"),null)}return t}Kv(){var t,i,e,n,r,o,l,a;if(!this._instance.config.prepare_external_dependency_stylesheet&&!this._instance.config.prepare_external_dependency_script)return()=>{};const u=null==s?void 0:s.defaultView,h=null==u||null===(t=u.Node)||void 0===t?void 0:t.prototype;if(!u||!h)return()=>{};if(this.Vv++,this.Yv)return this.Xv();const d=[],c=this,v=new WeakSet,f=(t,i,e)=>{if(!(null==t?void 0:t[i]))return;const s=t[i];t[i]=e(s),d.push(()=>{t[i]=s})},p=t=>{if(v.has(t))return t;const i=c.Jv(t);return i&&v.add(i),i},g=t=>t.map(t=>"string"==typeof t?t:p(t)).filter(t=>!A(t));return f(h,"appendChild",t=>function(i){const e=p(i);return e?t.call(this,e):i}),f(h,"insertBefore",t=>function(i,e){const s=p(i);return s?t.call(this,s,e):i}),f(h,"replaceChild",t=>function(i,e){const s=p(i);return s?t.call(this,s,e):e}),[null===(i=u.Element)||void 0===i?void 0:i.prototype,null===(e=u.Document)||void 0===e?void 0:e.prototype,null===(n=u.DocumentFragment)||void 0===n?void 0:n.prototype].forEach(t=>{f(t,"append",t=>function(...i){return t.apply(this,g(i))}),f(t,"prepend",t=>function(...i){return t.apply(this,g(i))})}),[null===(r=u.Element)||void 0===r?void 0:r.prototype,null===(o=u.CharacterData)||void 0===o?void 0:o.prototype,null===(l=u.DocumentType)||void 0===l?void 0:l.prototype].forEach(t=>{f(t,"before",t=>function(...i){return t.apply(this,g(i))}),f(t,"after",t=>function(...i){return t.apply(this,g(i))}),f(t,"replaceWith",t=>function(...i){const e=g(i);return i.length&&!e.length?void 0:t.apply(this,e)})}),f(null===(a=u.Element)||void 0===a?void 0:a.prototype,"insertAdjacentElement",t=>function(i,e){const s=p(e);return s?t.call(this,i,s):null}),this.Yv=()=>{d.forEach(t=>t()),this.Yv=void 0},this.Xv()}Xv(){let t=!1;return()=>{var i;t||(t=!0,this.Vv--,0===this.Vv&&(null===(i=this.Yv)||void 0===i||i.call(this)))}}tf(t,i=!0){const e=this.Kv();try{const s=t(e);return i&&e(),s}catch(t){throw e(),t}}setupSiteApp(t){const i=this.apps[t.id],e=()=>{var e;!i.errored&&this.Gv.length&&(Cu.info(`Processing ${this.Gv.length} events for site app with id ${t.id}`),this.Gv.forEach(t=>this.tf(()=>{var e;return null===(e=i.processEvent)||void 0===e?void 0:e.call(i,t)})),i.processedBuffer=!0),Object.values(this.apps).every(t=>t.processedBuffer||t.errored)&&(null===(e=this.Qv)||void 0===e||e.call(this))};let s=!1;const n=n=>{i.errored=!n,i.loaded=!0,Cu.info(`Site app with id ${t.id} ${n?"loaded":"errored"}`),s&&e()};try{const{processEvent:e}=this.tf(i=>t.init({posthog:this._instance,callback(t){i(),n(t)}}),!1);e&&(i.processEvent=e),s=!0}catch(i){Cu.error(Fu+t.id,i),n(!1)}if(s&&i.loaded)try{e()}catch(e){Cu.error(`Error while processing buffered events PostHog app with config id ${t.id}`,e),i.errored=!0}}ef(){const t=this.siteAppLoaders||[];for(const i of t)this.apps[i.id]={id:i.id,loaded:!1,errored:!1,processedBuffer:!1};for(const i of t)this.setupSiteApp(i)}if(t){if(0===Object.keys(this.apps).length)return;const i=this.globalsForEvent(t);for(const e of Object.values(this.apps))try{this.tf(()=>{var t;return null===(t=e.processEvent)||void 0===t?void 0:t.call(e,i)})}catch(i){Cu.error(`Error while processing event ${t.event} for site app ${e.id}`,i)}}onRemoteConfig(t){var i,e,s;if(null===(i=this.siteAppLoaders)||void 0===i?void 0:i.length)return this.isEnabled?(this.ef(),void this._instance.on("eventCaptured",t=>this.if(t))):void Cu.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null===(e=this.Qv)||void 0===e||e.call(this),!t.ok)return;const n=t.config;if(null===(s=n.siteApps)||void 0===s?void 0:s.length)if(this.isEnabled)for(const{id:t,url:i}of n.siteApps){var r,o;c[`__$$ph_site_app_${t}`]=this._instance,null===(r=c.__PosthogExtensions__)||void 0===r||null===(o=r.loadSiteApp)||void 0===o||o.call(r,this._instance,i,i=>{if(i)return Cu.error(Fu+t,i)})}else Cu.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}},wh={tracingHeaders:class{constructor(t){this._instance=t,this.nf=void 0,this.sf=void 0,this.rf=void 0,this.bv=()=>{const t=this.lf();var i,e;t?(I(this.nf)&&(this.nf=null===(i=c.__PosthogExtensions__)||void 0===i||null===(i=i.tracingHeadersPatchFns)||void 0===i?void 0:i._patchXHR(t,()=>this._instance.get_distinct_id(),this._instance.sessionManager)),I(this.sf)&&(this.sf=null===(e=c.__PosthogExtensions__)||void 0===e||null===(e=e.tracingHeadersPatchFns)||void 0===e?void 0:e._patchFetch(t,()=>this._instance.get_distinct_id(),this._instance.sessionManager))):this.$v()}}initialize(){this.startIfEnabledOrStop()}Eo(t){var i,e,s;(null===(i=c.__PosthogExtensions__)||void 0===i?void 0:i.tracingHeadersPatchFns)?t():null===(e=c.__PosthogExtensions__)||void 0===e||null===(s=e.loadExternalDependency)||void 0===s||s.call(e,this._instance,"tracing-headers",i=>{if(i)return pu.error("failed to load script",i);t()})}af(){var t,i;return null!==(t=null!==(i=this._instance.config.tracing_headers)&&void 0!==i?i:this._instance.config.addTracingHeaders)&&void 0!==t?t:this._instance.config.__add_tracing_headers}lf(){const t=this.af();return P(t)?(P(this.rf)?this.rf.splice(0,this.rf.length,...t):this.rf=[...t],t.length>0?this.rf:void 0):(P(this.rf)&&this.rf.splice(0),this.rf=t||void 0,this.rf)}$v(){var t,i;null===(t=this.nf)||void 0===t||t.call(this),null===(i=this.sf)||void 0===i||i.call(this),this.nf=void 0,this.sf=void 0}startIfEnabledOrStop(){this.lf()?this.Eo(this.bv):this.$v()}}},$h=wi({surveys:class extends Au{constructor(t){var i;super(new Nu(t),(i=t,{get projectToken(){return i.config.token},kv:new Lu(i)})),this._instance=t}wh(t,i){const e=i.query?Wl(t,i.query):t;return new Promise(t=>{var s;this._instance._send_request({method:i.method,url:this._instance.requestRouter.endpointFor(null!==(s=i.target)&&void 0!==s?s:"api",e),data:i.body,headers:i.headers,timeout:i.timeoutMs,fireCallbackOnDrop:!0,transport:i.transport,compression:i.compression,timestampMode:i.sentAt,callback:t})})}}},ph),xh={toolbar:class{constructor(t){this.instance=t}uf(t){c.ph_toolbar_state=t}hf(){var t;return null!==(t=c.ph_toolbar_state)&&void 0!==t?t:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(i=void 0,e=void 0,n=void 0){var r,o;if(Nn(this.instance.config))return!1;if(!t||!s)return!1;i=null!==(r=i)&&void 0!==r?r:t.location,n=null!==(o=n)&&void 0!==o?o:t.history;try{if(!e){try{t.localStorage.setItem("test","test"),t.localStorage.removeItem("test")}catch(t){return!1}e=null==t?void 0:t.localStorage}const s=zu||yo(i.hash,"__posthog")||yo(i.hash,"state");let r;const o=s?Rn(()=>JSON.parse(atob(decodeURIComponent(s))))||Rn(()=>JSON.parse(decodeURIComponent(s))):null;return o&&"ph_authorize"===o.action?(r=o,r.source="url",r&&Object.keys(r).length>0&&(o.desiredHash?i.hash=o.desiredHash:n?n.replaceState(n.state,"",i.pathname+i.search):i.hash="")):(r=JSON.parse(e.getItem(Uu)||"{}"),r.source="localstorage",delete r.userIntent),!(!r.token||this.instance.config.token!==r.token||(this.loadToolbar(r),0))}catch(t){return!1}}cf(t){const i=c.ph_load_toolbar||c.ph_load_editor;!M(i)&&T(i)?i(t,this.instance):Hu.warn("No toolbar load function found")}loadToolbar(i){const e=!!(null==s?void 0:s.getElementById("__POSTHOG_TOOLBAR__"));if(!t||e)return!1;const n="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,r=wi(wi({token:this.instance.config.token},i),{},{apiURL:this.instance.requestRouter.endpointFor("ui")},n?{instrument:!1}:{});if(t.localStorage.setItem(Uu,JSON.stringify(wi(wi({},r),{},{source:void 0}))),2===this.hf())this.cf(r);else if(0===this.hf()){var o,l;this.uf(1),null===(o=c.__PosthogExtensions__)||void 0===o||null===(l=o.loadExternalDependency)||void 0===l||l.call(o,this.instance,"toolbar",t=>{if(t)return Hu.error("[Toolbar] Failed to load",t),void this.uf(0);this.uf(2),this.cf(r)}),Ln(t,"turbolinks:load",()=>{this.uf(0),this.loadToolbar(r)})}return!0}df(t){return this.loadToolbar(t)}maybeLoadEditor(t=void 0,i=void 0,e=void 0){return this.maybeLoadToolbar(t,i,e)}}},Sh=wi({experiments:class i{get Sr(){return this._instance.config}constructor(t){this._instance=t,this.getWebExperimentsAndEvaluateDisplayLogic=(t=!1)=>{this.getWebExperiments(t=>{i.vf("retrieved web experiments from the server"),this.ff=new Map,t.forEach(t=>{if(t.feature_flag_key){var e;this.ff&&(i.vf("setting flag key ",t.feature_flag_key," to web experiment ",t),null===(e=this.ff)||void 0===e||e.set(t.feature_flag_key,t));const s=this._instance.getFeatureFlag(t.feature_flag_key);O(s)&&t.variants[s]&&this.pf(t.name,s,t.variants[s].transforms)}else if(t.variants)for(const e in t.variants){const s=t.variants[e];i.gf(s,this._instance)&&this.pf(t.name,e,s.transforms)}})},t)},this._instance.onFeatureFlags(t=>{this.onFeatureFlags(t)})}initialize(){}onFeatureFlags(t){if(this._is_bot())i.vf(nh);else if(!this.Sr.disable_web_experiments){if(M(this.ff))return this.ff=new Map,this.loadIfEnabled(),void this.previewWebExperiment();i.vf("applying feature flags",t),t.forEach(t=>{var i;if(this.ff&&(null===(i=this.ff)||void 0===i?void 0:i.has(t))){var e;const i=this._instance.getFeatureFlag(t),s=null===(e=this.ff)||void 0===e?void 0:e.get(t);i&&(null==s?void 0:s.variants[i])&&this.pf(s.name,i,s.variants[i].transforms)}})}}previewWebExperiment(){const t=i.getWindowLocation();if(null==t?void 0:t.search){const e=mo(null==t?void 0:t.search,"__experiment_id"),s=mo(null==t?void 0:t.search,"__experiment_variant");e&&s&&(i.vf(`previewing web experiments ${e} && ${s}`),this.getWebExperiments(t=>{this.mf(parseInt(e),s,t)},!1,!0))}}loadIfEnabled(){this.Sr.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(t,i,e){if(this.Sr.disable_web_experiments&&!e)return t([]);const s=this._instance.get_property("$web_experiments");if(s&&!i)return t(s);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api",`/api/web_experiments/?token=${this.Sr.token}`),method:"GET",timestampMode:"query",callback:i=>t(200===i.statusCode&&i.json&&i.json.experiments||[])})}mf(t,e,s){const n=s.filter(i=>i.id===t);n&&n.length>0&&(i.vf(`Previewing web experiment [${n[0].name}] with variant [${e}]`),this.pf(n[0].name,e,n[0].variants[e].transforms))}static gf(t,e){return!M(t.conditions)&&i.yf(t,e)&&i.bf(t)}static yf(t,e){var s;if(M(t.conditions)||M(null===(s=t.conditions)||void 0===s?void 0:s.url))return!0;const n=i.getWindowLocation();if(n){var r,o,l;const i=gr(e,n.href);return!(null===(r=t.conditions)||void 0===r?void 0:r.url)||rh[null!==(o=null===(l=t.conditions)||void 0===l?void 0:l.urlMatchType)&&void 0!==o?o:"icontains"](t.conditions.url,i)}return!1}static getWindowLocation(){return null==t?void 0:t.location}static bf(t){var i;if(M(t.conditions)||M(null===(i=t.conditions)||void 0===i?void 0:i.utm))return!0;const e=Po();if(e.utm_source){var s,n,r,o,l,a,u,h;const i=!(null===(s=t.conditions)||void 0===s||null===(s=s.utm)||void 0===s?void 0:s.utm_campaign)||(null===(n=t.conditions)||void 0===n||null===(n=n.utm)||void 0===n?void 0:n.utm_campaign)==e.utm_campaign,d=!(null===(r=t.conditions)||void 0===r||null===(r=r.utm)||void 0===r?void 0:r.utm_source)||(null===(o=t.conditions)||void 0===o||null===(o=o.utm)||void 0===o?void 0:o.utm_source)==e.utm_source,c=!(null===(l=t.conditions)||void 0===l||null===(l=l.utm)||void 0===l?void 0:l.utm_medium)||(null===(a=t.conditions)||void 0===a||null===(a=a.utm)||void 0===a?void 0:a.utm_medium)==e.utm_medium,v=!(null===(u=t.conditions)||void 0===u||null===(u=u.utm)||void 0===u?void 0:u.utm_term)||(null===(h=t.conditions)||void 0===h||null===(h=h.utm)||void 0===h?void 0:h.utm_term)==e.utm_term;return i&&c&&v&&d}return!1}static vf(t,...i){je.info(`[WebExperiments] ${t}`,i)}pf(t,e,s){this._is_bot()?i.vf(nh):"control"!==e?s.forEach(s=>{if(s.selector){var n;i.vf(`applying transform of variant ${e} for experiment ${t} `,s);const r=null===(n=document)||void 0===n?void 0:n.querySelectorAll(s.selector);null==r||r.forEach(t=>{const i=t;s.html&&(i.innerHTML=s.html),s.css&&i.setAttribute("style",s.css)})}}):i.vf("Control variants leave the page unmodified.")}_is_bot(){return e&&this._instance?fa(e,this.Sr.custom_blocked_useragents):void 0}}},ph),kh={conversations:class{constructor(t){this._instance=t,this._f=void 0,this._conversationsManager=null,this.wf=!1,this.ne=null,this.kf=!1}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(this._instance.config.disable_conversations)return;if(this.Sf=t.ok,!t.ok)return;const i=t.config.conversations;M(i)||(B(i)?this._f=i:(this._f=i.enabled,this.ne=i),this.loadIfEnabled())}reset(){var t;null===(t=this._conversationsManager)||void 0===t||t.reset(),this._conversationsManager=null,this._f=void 0,this.ne=null,this.Sf=void 0,this.kf=!1}loadIfEnabled(){if(this._conversationsManager)return;if(this.wf)return;if(this._instance.config.disable_conversations)return;if(Nn(this._instance.config))return;if(this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())return;const t=null==c?void 0:c.__PosthogExtensions__;if(t&&!I(this._f)&&this._f)if(this.ne&&this.ne.token){this.wf=!0;try{const i=t.initConversations;if(i)return this.xf(i),void(this.wf=!1);const e=t.loadExternalDependency;if(!e)return void this.Cf(bn);e(this._instance,"conversations",i=>{i||!t.initConversations?this.Cf("Could not load conversations script",i):this.xf(t.initConversations),this.wf=!1})}catch(t){this.Cf("Error initializing conversations",t),this.wf=!1}}else oh.error("Conversations enabled but missing token in remote config.")}xf(t){if(this.ne)try{this._conversationsManager=t(this.ne,this._instance),this.kf=!1,oh.info("Conversations loaded successfully")}catch(t){this.Cf("Error completing conversations initialization",t)}else oh.error("Cannot complete initialization: remote config is null")}Cf(t,i){oh.error(t,i),this._conversationsManager=null,this.wf=!1,this.kf=!0}show(){this._conversationsManager?this._conversationsManager.show():oh.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this._f&&!A(this._conversationsManager)}getUnavailableReason(){return this.isAvailable()?null:this._instance.config.disable_conversations?"disabled_by_config":Nn(this._instance.config)?"disabled_for_toolbar":this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut()?"consent_opted_out":!1===this.Sf?"remote_config_failed":I(this._f)?this.Sf?"disabled_in_project":"remote_config_pending":this._f?M(this.ne)||!this.ne.token?"missing_token":(null==c?void 0:c.__PosthogExtensions__)?this.wf?"initializing":this.kf?"load_failed":"not_loaded":"extensions_unavailable":"disabled_in_project"}isVisible(){var t,i;return null!==(t=null===(i=this._conversationsManager)||void 0===i?void 0:i.isVisible())&&void 0!==t&&t}sendMessage(t,i,e){var s=this;return Y(function*(){return s._conversationsManager?s._conversationsManager.sendMessage(t,i,e):(oh.warn(lh),null)})()}getMessages(t,i){var e=this;return Y(function*(){return e._conversationsManager?e._conversationsManager.getMessages(t,i):(oh.warn(lh),null)})()}markAsRead(t){var i=this;return Y(function*(){return i._conversationsManager?i._conversationsManager.markAsRead(t):(oh.warn(lh),null)})()}getTickets(t){var i=this;return Y(function*(){return i._conversationsManager?i._conversationsManager.getTickets(t):(oh.warn(lh),null)})()}requestRestoreLink(t){var i=this;return Y(function*(){return i._conversationsManager?i._conversationsManager.requestRestoreLink(t):(oh.warn(lh),null)})()}restoreFromToken(t){var i=this;return Y(function*(){return i._conversationsManager?i._conversationsManager.restoreFromToken(t):(oh.warn(lh),null)})()}restoreFromUrlToken(){var t=this;return Y(function*(){return t._conversationsManager?t._conversationsManager.restoreFromUrlToken():(oh.warn(lh),null)})()}getCurrentTicketId(){var t,i;return null!==(t=null===(i=this._conversationsManager)||void 0===i?void 0:i.getCurrentTicketId())&&void 0!==t?t:null}getWidgetSessionId(){var t,i;return null!==(t=null===(i=this._conversationsManager)||void 0===i?void 0:i.getWidgetSessionId())&&void 0!==t?t:null}ih(){var t;null===(t=this._conversationsManager)||void 0===t||t.setIdentity()}nh(){var t;null===(t=this._conversationsManager)||void 0===t||t.clearIdentity()}}},Eh={logs:class{constructor(i){var e;this._instance=i,this.name="logs",this.$f=!1,this.Tf=!1,this.If=!1,this.$=Be("[logs]"),this.Mf=wi(wi({},this.$),{},{error:(...t)=>{t.some(fh)||this.$.error(...t)}}),this.Zl=[],this.Ef=[],this.Wc=0,this.fo=!1,this.Pf=[],this.Rf=[],this.Af=!1,this.Ff=!1,this.Of=()=>{var t,i;this.fo||(this.Wc=0,null===(t=this.Df)||void 0===t||t.onReconnect(),null===(i=this.Lf)||void 0===i||i.onReconnect())},this._instance&&(null===(e=this._instance.config.logs)||void 0===e?void 0:e.captureConsoleLogs)&&(this.$f=!0),t&&Ln(t,"online",this.Of)}Nf(t,i,e,s){var n;const r=ah(null===(n=this._instance)||void 0===n||null===(n=n.config)||void 0===n?void 0:n.logs,e);return[new Ie(this.qf(t,i),r,this.Mf,()=>this.jf(),t=>t(),void 0,s),r]}Bf(){var t;const i=null===(t=this._instance)||void 0===t||null===(t=t.config)||void 0===t?void 0:t.logs;var e;return this.Df&&this.Hf===i||(null===(e=this.Df)||void 0===e||e.reset(),this.Hf=i,[this.Df,this.zf]=this.Nf(()=>this.Zl,t=>{this.Zl=t})),this.Df}Uf(){var t;const i=null===(t=this._instance)||void 0===t||null===(t=t.config)||void 0===t?void 0:t.logs;var e;return this.Lf&&this.Wf===i||(null===(e=this.Lf)||void 0===e||e.reset(),this.Wf=i,[this.Lf,this.Vf]=this.Nf(()=>this.Ef,t=>{this.Ef=t},{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},dh)),this.Lf}setup(t){var i;if(this.fo)return;this.lo=t,(null===(i=this._instance)||void 0===i||null===(i=i.config)||void 0===i||null===(i=i.logs)||void 0===i?void 0:i.captureConsoleLogs)&&(this.$f=!0),(this.$f||this.Gf()&&this.Zf())&&this.Qf();let e=!1;const s=t.onRemoteConfig(t=>{var i;e=t.ok&&!0===(null===(i=t.config.logs)||void 0===i?void 0:i.captureConsoleLogs),this.onRemoteConfig(t)});this.fo?s.dispose():(this.yo=s,e||this.loadIfEnabled())}dispose(){var i,e,s,n;this.fo||(this.fo=!0,this.Jf(),null===(i=this.yo)||void 0===i||i.dispose(),this.yo=void 0,this.lo=void 0,this.If=!1,null==t||t.removeEventListener("online",this.Of),null===(e=this.Kf)||void 0===e||e.call(this),this.Kf=void 0,null===(s=this.Df)||void 0===s||s.reset(),null===(n=this.Lf)||void 0===n||n.reset())}onRemoteConfig(t){var i,e;if(this.fo)return;const s=t.ok?null===(i=t.config.logs)||void 0===i?void 0:i.captureConsoleLogs:void 0;M(s)?this.Yf():(null===(e=this._instance)||void 0===e||null===(e=e.persistence)||void 0===e||e.register({$logs_capture_enabled_server_side:!!s}),s?(this.$f=!0,this.Tf||this.Qf(),this.loadIfEnabled()):this.Yf())}reset(){var t,i,e,s;this.Jf(),null===(t=this.Df)||void 0===t||t.clearQueue(),this.Zl=[],null===(i=this.Df)||void 0===i||i.reset(),null===(e=this.Lf)||void 0===e||e.clearQueue(),this.Ef=[],null===(s=this.Lf)||void 0===s||s.reset(),this.Wc=0}captureLog(t){this.fo||this.Bf().captureLog(t)}captureConsoleLog(t){this.fo||this.Uf().captureLog(t)}captureBufferedConsoleLog(t,i,e){this.fo||this.Uf().captureLog(t,{context:i,occurredAtMs:e})}Zf(){var t;return!!(null===(t=this._instance)||void 0===t||null===(t=t.persistence)||void 0===t||null===(t=t.props)||void 0===t?void 0:t[as])}Gf(){var t,i,e;return!(null===(t=this._instance)||void 0===t||null===(i=t.Ul)||void 0===i?void 0:i.call(t))||!!(null===(e=c._POSTHOG_REMOTE_CONFIG)||void 0===e||null===(e=e[this._instance.config.token])||void 0===e?void 0:e.config)}rh(){var t;this.Jf(),null===(t=this.Lf)||void 0===t||t.clearQueue(),this.Ef=[]}Yf(){this.$f||this.Jf()}Qf(){var t;if(this.Af||!(null==c?void 0:c.console))return;const i=ah(null===(t=this._instance)||void 0===t||null===(t=t.config)||void 0===t?void 0:t.logs).maxBufferSize;for(const t of uh){let e;try{e=hh(c.console[t])}catch(t){continue}e&&this.Rf.push(fu(c.console,t,s=>{const n=(...e)=>{try{this.Xf(t,e,i)}catch(t){}return s.apply(c.console,e)};return n.__rrweb_original__=e,n}))}this.Af=!0,this.tp=setTimeout(()=>{this.Jf()},3e4)}Xf(t,i,e){var s;if(this.Af&&!this.Ff&&0!==i.length)if(null===(s=this._instance)||void 0===s?void 0:s.is_capturing()){if(e>this.Pf.length){this.Ff=!0;try{this.Pf.push({level:t,args:i,occurredAtMs:Date.now(),context:this.jf()})}finally{this.Ff=!1}}}else this.Jf()}Jf(){if(this.Pf=[],this.Af){this.Af=!1,this.tp&&(clearTimeout(this.tp),this.tp=void 0);for(const t of this.Rf)t();this.Rf=[]}}ep(){const t=this.Pf;return this.Jf(),t}get logger(){return this.np||(this.np={trace:(t,i)=>this.captureLog({body:t,level:"trace",attributes:i}),debug:(t,i)=>this.captureLog({body:t,level:"debug",attributes:i}),info:(t,i)=>this.captureLog({body:t,level:"info",attributes:i}),warn:(t,i)=>this.captureLog({body:t,level:"warn",attributes:i}),error:(t,i)=>this.captureLog({body:t,level:"error",attributes:i}),fatal:(t,i)=>this.captureLog({body:t,level:"fatal",attributes:i})}),this.np}flushLogs(t){t?this.sp(t):(this.Df&&this.Df.flush().catch(t=>this.rp(t)),this.Lf&&this.Lf.flush().catch(t=>this.rp(t)))}rp(t){fh(t)||this.$.error("PostHog logs flush failed:",t)}loadIfEnabled(){if(this.fo||!this.$f||this.Tf||this.If)return;const t=null==c?void 0:c.__PosthogExtensions__;if(!t)return this.$.error("PostHog Extensions not found."),void this.Jf();const i=t.loadExternalDependency;if(!i)return this.$.error(bn),void this.Jf();this.If=!0;try{i(this._instance,"logs",i=>{if(this.If=!1,this.fo||!this.$f)return;const e=t.logs;if(i||!(null==e?void 0:e.initializeLogs))this.$.error("Could not load logs script",i),this.Jf();else{var s;const t=this.ep();var n,r;this.Kf=e.initializeLogs(null!==(s=this.lo)&&void 0!==s?s:this._instance),this.Tf=!0,t.length>0&&(null===(n=e.replayConsoleBuffer)||void 0===n||n.call(e,null!==(r=this.lo)&&void 0!==r?r:this._instance,t))}})}catch(t){throw this.If=!1,t}}qf(t,i){const e=this._instance;return{get isDisabled(){return!1},get optedOut(){return!e.is_capturing()},getPersistedProperty:i=>i===p.LogsQueue?t():void 0,setPersistedProperty(t,e){var s;t===p.LogsQueue&&i(null!==(s=e)&&void 0!==s?s:[])},Ps:t=>this.Ps(t),getLibraryId:()=>qe.LIB_NAME,getLibraryVersion:()=>qe.LIB_VERSION}}Ps(t){return new Promise(i=>{if(wo(this.Wc,3))return void i({kind:"fatal",error:vh(void 0,"logs endpoint is unreachable, dropping batch")});let e=!1;const s=t=>{e||(e=!0,clearTimeout(n),i(t))},n=setTimeout(()=>{this.$.warn("Logs request timed out before receiving a response"),s({kind:"retry-later",error:vh(void 0,"logs request timed out")})},9e4);this._instance._send_request({method:"POST",url:this.op(),data:t,compression:"best-available",batchKey:"logs",fireCallbackOnDrop:!0,callback:t=>{const i=t.statusCode;if(this.lp(i),i>=200&&300>i)s({kind:"ok"});else if(413===i)s({kind:"too-large"});else if(0!==i&&408!==i&&429!==i&&500>i)s({kind:"fatal",error:new Error(`logs request failed with status ${i}`)});else{var e;0===i?(t.error||this.$.warn("Logs request failed before receiving an HTTP response"),s({kind:"retry-later",error:vh(t.error,"logs request failed before receiving an HTTP response")})):s({kind:"retry-later",error:null!==(e=t.error)&&void 0!==e?e:new Error(`logs request failed with status ${i}`)})}}})})}lp(t){(0!==t||this._instance.__loaded)&&(this.Wc=$o(t,this.Wc,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.")))}sp(t){this.Zl.length>0&&this.ap(t,this.Zl,this.zf,qe.LIB_NAME,t=>{this.Zl=t}),this.Ef.length>0&&this.ap(t,this.Ef,this.Vf,dh,t=>{this.Ef=t})}ap(t,i,e,s,n){if(0===i.length)return;const r=i.map(t=>t.record);n([]);const o=Fe(r,Ce(e,qe.LIB_NAME,qe.LIB_VERSION),s,qe.LIB_VERSION);this._instance._send_request({method:"POST",url:this.op(),data:o,compression:"best-available",batchKey:"logs",transport:t})}op(){return this._instance.requestRouter.endpointFor("api","/i/v1/logs")+"?token="+encodeURIComponent(this._instance.config.token)}jf(){var t;const i={};if(i.distinctId=this._instance.get_distinct_id(),this._instance.sessionManager){const{sessionId:t,windowId:e,sessionStartTimestamp:s,lastActivityTimestamp:n}=this._instance.sessionManager.checkAndGetSessionAndWindowId(!0);i.sessionId=t,i.windowId=e,M(s)||(i.sessionStartTimestamp=s),M(n)||(i.lastActivityTimestamp=n)}if((null==c||null===(t=c.location)||void 0===t?void 0:t.href)&&(i.currentUrl=this._instance.config.disable_capture_url_hashes?hi(c.location.href):c.location.href),this._instance.featureFlags){const t=this._instance.featureFlags.getFlags();t&&t.length>0&&(i.activeFeatureFlags=t)}return i}}},Ph={metrics:class{constructor(t){this._instance=t,this.$=Be("[metrics]")}initialize(){}Bf(){var t;const i=null===(t=this._instance)||void 0===t||null===(t=t.config)||void 0===t?void 0:t.metrics;var e;return this.Df&&this.Hf===i||(null===(e=this.Df)||void 0===e||e.reset(),this.Hf=i,this.Df=new Me(this.qf(),function(t){var i,e,s,n,r;const o=null==t?void 0:t.resourceAttributes;return{serviceName:null!==(i=null==o?void 0:o["service.name"])&&void 0!==i?i:null==t?void 0:t.serviceName,serviceVersion:null!==(e=null==o?void 0:o["service.version"])&&void 0!==e?e:null==t?void 0:t.serviceVersion,environment:null!==(s=null==o?void 0:o["deployment.environment"])&&void 0!==s?s:null==t?void 0:t.environment,resourceAttributes:o,beforeSend:null==t?void 0:t.beforeSend,flushIntervalMs:null!==(n=null==t?void 0:t.flushIntervalMs)&&void 0!==n?n:1e4,maxSeriesPerFlush:null!==(r=null==t?void 0:t.maxSeriesPerFlush)&&void 0!==r?r:1e3}}(i),this.$)),this.Df}count(t,i=1,e){this.Bf().count(t,i,e)}gauge(t,i,e){this.Bf().gauge(t,i,e)}histogram(t,i,e){this.Bf().histogram(t,i,e)}flush(t){if(!this.Df)return Promise.resolve();if(t){const i=this.Df.drainWindow();return i&&this.Gs(i,t),Promise.resolve()}return this.Df.flush().catch(t=>this.$.error("PostHog metrics flush failed:",t))}reset(){var t;null===(t=this.Df)||void 0===t||t.reset()}qf(){const t=this._instance,i=this;return{get isDisabled(){return!1},get optedOut(){return!t.is_capturing()},Gs:t=>i.Gs(t),getLibraryId:()=>qe.LIB_NAME,getLibraryVersion:()=>qe.LIB_VERSION}}Gs(t,i){return new Promise(e=>{let s=!1;const n=t=>{s||(s=!0,clearTimeout(r),e(t))},r=setTimeout(()=>n({kind:"retry-later",error:new Error("metrics request timed out")}),9e4);this._instance._send_request(wi(wi({method:"POST",url:this.up(),data:t,compression:"best-available",batchKey:"metrics"},i&&{transport:i}),{},{fireCallbackOnDrop:!0,callback(t){const i=t.statusCode;if(i>=200&&300>i)n({kind:"ok"});else if(413===i)n({kind:"too-large"});else if(0!==i&&408!==i&&429!==i&&500>i)n({kind:"fatal",error:new Error(`metrics request failed with status ${i}`)});else{var e;n({kind:"retry-later",error:null!==(e=t.error)&&void 0!==e?e:new Error(`metrics request failed with status ${i}`)})}}}))})}up(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}}};eu.__defaultExtensionClasses=wi({},wi(wi(wi(wi(wi(wi(wi(wi(wi(wi(wi(wi(wi({},ph),gh),_h),mh),bh),yh),$h),wh),xh),Sh),kh),Eh),Ph)),function(){qe.SDK_DIST_CHANNEL="cdn";const i=c.posthog;if(i&&!P(i._i))return;const e=La[Ja]=new eu;if(i){const t=[];Fn(i._i,function(s){if(s&&P(s)){const n=e.init(s[0],s[1],s[2]),r=i[s[2]]||i;n.__loaded&&-1===t.indexOf(r)&&(t.push(r),n._execute_array.call(n.people,r.people),n._execute_array(r))}})}e.__SV=1,c.posthog=e,function(){function i(){i.done||(i.done=!0,Ya=!1,Fn(La,function(t){t._dom_loaded()}))}(null==s?void 0:s.addEventListener)?"complete"===s.readyState?i():Ln(s,"DOMContentLoaded",i,{capture:!1}):t&&je.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}()}()}();
|
|
1
|
+
!function(){const t="u">typeof window?window:void 0,i="u">typeof globalThis?globalThis:t,e=null==i?void 0:i.navigator,s=null==i?void 0:i.document,n=null==i?void 0:i.location,r=null==i?void 0:i.fetch,o=(null==i?void 0:i.XMLHttpRequest)&&"withCredentials"in new i.XMLHttpRequest?i.XMLHttpRequest:void 0,l=null==i?void 0:i.AbortController,a=null==i?void 0:i.CompressionStream,u=null==e?void 0:e.userAgent;function h(){return!(!t||!1===t.navigator.onLine)}const d="undefined"!=typeof globalThis?globalThis:t;d&&"undefined"==typeof self&&(d.self=d),d&&"undefined"==typeof File&&(d.File=function(){});const c=null!=t?t:{},v="0.8.2",f={DEBUG:!1,LIB_VERSION:v,LIB_NAME:"browser-common",JS_SDK_VERSION:v};var p=function(t){return t.AnonymousId="anonymous_id",t.DistinctId="distinct_id",t.Props="props",t.EnablePersonProcessing="enable_person_processing",t.PersonMode="person_mode",t.FeatureFlagDetails="feature_flag_details",t.FeatureFlags="feature_flags",t.FeatureFlagPayloads="feature_flag_payloads",t.BootstrapFeatureFlagDetails="bootstrap_feature_flag_details",t.BootstrapFeatureFlags="bootstrap_feature_flags",t.BootstrapFeatureFlagPayloads="bootstrap_feature_flag_payloads",t.OverrideFeatureFlags="override_feature_flags",t.Queue="queue",t.AiQueue="ai_queue",t.AiCaptureQueue="ai_capture_queue",t.LogsQueue="logs_queue",t.OptedOut="opted_out",t.SessionId="session_id",t.SessionStartTimestamp="session_start_timestamp",t.SessionLastTimestamp="session_timestamp",t.PersonProperties="person_properties",t.GroupProperties="group_properties",t.InstalledAppBuild="installed_app_build",t.InstalledAppVersion="installed_app_version",t.SessionReplay="session_replay",t.PushRegistered="push_registered",t.SessionReplayEventTriggerActivatedSession="session_replay_event_trigger_activated_session",t.SurveyLastSeenDate="survey_last_seen_date",t.SurveysSeen="surveys_seen",t.Surveys="surveys",t.RemoteConfig="remote_config",t.FlagsEndpointWasHit="flags_endpoint_was_hit",t.DeviceId="device_id",t}({}),g=function(t){return t.GZipJS="gzip-js",t.Base64="base64",t}({});const _=["$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"],m=["token"];function b(t,i){return-1!==t.indexOf(i)}const y=function(t){return t.trim()},w=function(t){return t.replace(/^\$/,"")};function x(t){var i;const e=[];return null!==(i=JSON.stringify(t,function(t,i){if("bigint"==typeof i)return i.toString();if("function"!=typeof i&&"symbol"!=typeof i){if(i instanceof Error)return{name:i.name,message:i.message,stack:i.stack};if(i&&"object"==typeof i){for(;e.length>0&&e[e.length-1]!==this;)e.pop();if(e.includes(i))return"[Circular]";e.push(i)}return i}}))&&void 0!==i?i:"null"}const S=Object.prototype,k=S.hasOwnProperty,E=S.toString,P=Array.isArray||function(t){return"[object Array]"===E.call(t)},T=t=>"function"==typeof t,C=t=>t===Object(t)&&!P(t),F=t=>{if(C(t)){for(const i in t)if(k.call(t,i))return!1;return!0}return!1},I=t=>void 0===t,O=t=>"[object String]"==E.call(t),R=t=>O(t)&&0===t.trim().length,A=t=>null===t,M=t=>I(t)||A(t),D=t=>"[object Number]"==E.call(t)&&t==t,j=t=>D(t)&&t>0,B=t=>"[object Boolean]"===E.call(t),L=t=>b(_,t),N=t=>b(m,t);function z(t){return null===t||"object"!=typeof t}function U(t,i){return{}.toString.call(t)===`[object ${i}]`}function H(t){switch({}.toString.call(t)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object DOMError]":case"[object WebAssembly.Exception]":return!0;default:return V(t,Error)}}function q(t){return"u">typeof Event&&V(t,Event)}function V(t,i){try{return t instanceof i}catch(t){return!1}}const W=[!0,"true",1,"1","yes"],G=t=>b(W,t),K=[!1,"false",0,"0","no"];function J(t,i,e,s,n,r,o){try{var l=t[r](o),a=l.value}catch(t){return void e(t)}l.done?i(a):Promise.resolve(a).then(s,n)}function Y(t){return function(){var i=this,e=arguments;return new Promise(function(s,n){var r=t.apply(i,e);function o(t){J(r,s,n,o,l,"next",t)}function l(t){J(r,s,n,o,l,"throw",t)}o(void 0)})}}const X=["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"],Z=function(t,i=[]){if(!t)return!1;const e=t.toLowerCase();return X.concat(i).some(t=>{const i=t.toLowerCase();return-1!==e.indexOf(i)})};function Q(t,i,e,s,n){return i>e&&(s.warn("min cannot be greater than max."),i=e),D(t)?t>e?(s.warn(" cannot be greater than max: "+e+". Using max value instead."),e):i>t?(s.warn(" cannot be less than min: "+i+". Using min value instead."),i):t:(s.warn(" must be a number. using max or fallback. max: "+e+", fallback: "+n),Q(null!=n?n:e,i,e,s))}var tt=class{constructor(t){this.C={},this.I=t.I,this.R=Q(t.bucketSize,0,100,t.$),this.A=Q(t.refillRate,0,this.R,t.$),this.O=Q(t.refillInterval,0,864e5,t.$)}F(t,i){const e=Math.floor((i-t.lastAccess)/this.O);e>0&&(t.tokens=Math.min(t.tokens+e*this.A,this.R),t.lastAccess=t.lastAccess+e*this.O)}consumeRateLimit(t){var i;const e=Date.now(),s=String(t);let n=this.C[s];return n?this.F(n,e):(n={tokens:this.R,lastAccess:e},this.C[s]=n),0===n.tokens||(n.tokens--,0===n.tokens&&(null===(i=this.I)||void 0===i||i.call(this,t)),0===n.tokens)}stop(){this.C={}}};const it="Mobile",et="Android",st="Tablet",nt="Android Tablet",rt="iPad",ot="Apple Watch",lt="Safari",at="BlackBerry",ut="Samsung Internet",ht="Chrome",dt="Chrome iOS",ct="Internet Explorer",vt="Internet Explorer Mobile",ft="Opera",pt="Microsoft Edge",gt="Firefox",_t="Firefox iOS",mt="Nintendo",bt="PlayStation",yt="Xbox",wt="Android Mobile",$t="Mobile Safari",xt="Windows",St="Windows Phone",kt="Nokia",Et="Ouya",Pt="Generic "+it.toLowerCase(),Tt="Generic "+st.toLowerCase(),Ct="Konqueror",Ft="Oculus Browser",It="Vivaldi",Ot="Yandex",Rt="Whale",At="DuckDuckGo",Mt="Pale Moon",Dt="Waterfox",jt="Brave",Bt="Claude",Lt="Codex",Nt="ChatGPT",zt="Google Search App",Ut=new RegExp("Version/(\\d+(\\.\\d+)?)"),Ht=new RegExp("(Claude|Codex|ChatGPT)\\/(\\d+(\\.\\d+)?)"),qt=new RegExp(yt,"i"),Vt=new RegExp("PlayStation \\w+","i"),Wt=new RegExp("Nintendo \\w+","i"),Gt=new RegExp("BlackBerry|PlayBook|BB10","i"),Kt={"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"},Jt=function(t,i,e,s){i=i||"";const n=function(t){return(null==t?void 0:t.brave)?jt:null}(e);return n||((null==s?void 0:s.detectGoogleSearchApp)&&b(t,"GSA/")?zt:b(t," OPR/")&&b(t,"Mini")?"Opera Mini":b(t," OPR/")?ft:Gt.test(t)?at:b(t,"IEMobile")||b(t,"WPDesktop")?vt:b(t,"OculusBrowser")?Ft:b(t,"SamsungBrowser")?ut:b(t,"Edge")||b(t,"Edg/")?pt:b(t,"Vivaldi/")?It:b(t,"YaBrowser/")?Ot:b(t,"Whale/")?Rt:b(t,"DuckDuckGo/")||b(t,"Ddg/")?At:b(t,"Claude/")?Bt:b(t,"Codex/")?Lt:b(t,"ChatGPT/")?Nt:b(t,"FBIOS")?"Facebook Mobile":b(t,"UCWEB")||b(t,"UCBrowser")?"UC Browser":b(t,"CriOS")?dt:b(t,"CrMo")||b(t,ht)?ht:b(t,et)&&b(t,lt)?wt:b(t,"FxiOS")?_t:b(t.toLowerCase(),Ct.toLowerCase())?Ct:b(t,"Brave/")?jt:((t,i)=>i&&b(i,"Apple")||function(t){return b(t,lt)&&!b(t,ht)&&!b(t,et)}(t))(t,i)?b(t,it)?$t:lt:b(t,"PaleMoon/")?Mt:b(t,"Waterfox/")?Dt:b(t,gt)?gt:b(t,"MSIE")||b(t,"Trident/")?ct:b(t,"Gecko")?gt:"")},Yt={[vt]:[new RegExp("rv:(\\d+(\\.\\d+)?)")],[pt]:[new RegExp("Edge?\\/(\\d+(\\.\\d+)?)")],[ht]:[new RegExp("(Chrome|CrMo)\\/(\\d+(\\.\\d+)?)")],[dt]:[new RegExp("CriOS\\/(\\d+(\\.\\d+)?)")],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/(\\d+(\\.\\d+)?)")],[lt]:[Ut],[$t]:[Ut],[ft]:[new RegExp("(Opera|OPR)\\/(\\d+(\\.\\d+)?)")],[gt]:[new RegExp("Firefox\\/(\\d+(\\.\\d+)?)")],[_t]:[new RegExp("FxiOS\\/(\\d+(\\.\\d+)?)")],[Ct]:[new RegExp("Konqueror[:/]?(\\d+(\\.\\d+)?)","i")],[at]:[new RegExp("BlackBerry (\\d+(\\.\\d+)?)"),Ut],[wt]:[new RegExp("android\\s(\\d+(\\.\\d+)?)","i")],[ut]:[new RegExp("SamsungBrowser\\/(\\d+(\\.\\d+)?)")],[Ft]:[new RegExp("OculusBrowser\\/(\\d+(\\.\\d+)?)")],[It]:[new RegExp("Vivaldi\\/(\\d+(\\.\\d+)?)")],[Ot]:[new RegExp("YaBrowser\\/(\\d+(\\.\\d+)?)")],[Rt]:[new RegExp("Whale\\/(\\d+(\\.\\d+)?)")],[jt]:[new RegExp("Brave\\/(\\d+(\\.\\d+)?)")],[Bt]:[Ht],[Lt]:[Ht],[Nt]:[Ht],[At]:[new RegExp("(DuckDuckGo|Ddg)\\/(\\d+(\\.\\d+)?)")],[Mt]:[new RegExp("PaleMoon\\/(\\d+(\\.\\d+)?)")],[Dt]:[new RegExp("Waterfox\\/(\\d+(\\.\\d+)?)")],[zt]:[new RegExp("GSA\\/(\\d+(\\.\\d+)?)")],[ct]:[new RegExp("(rv:|MSIE )(\\d+(\\.\\d+)?)")],Mozilla:[new RegExp("rv:(\\d+(\\.\\d+)?)")]},Xt=function(t,i,e,s){const n=Jt(t,i,e,s),r=Yt[n];if(I(r))return null;for(let i=0;r.length>i;i++){const e=t.match(r[i]);if(e)return parseFloat(e[e.length-2])}return null},Zt=[[new RegExp("Xbox; Xbox (.*?)[);]","i"),t=>[yt,t&&t[1]||""]],[new RegExp(mt,"i"),[mt,""]],[new RegExp(bt,"i"),[bt,""]],[Gt,[at,""]],[new RegExp(xt,"i"),(t,i)=>{if(/Phone/.test(i)||/WPDesktop/.test(i))return[St,""];if(new RegExp(it).test(i)&&!/IEMobile\b/.test(i))return["Windows Mobile",""];const e=/Windows NT ([0-9.]+)/i.exec(i);if(e&&e[1]){let t=Kt[e[1]]||"";return/arm/i.test(i)&&(t="RT"),[xt,t]}return[xt,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,t=>t&&t[3]?["iOS",[t[3],t[4],t[5]||"0"].join(".")]:["iOS",""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,t=>{let i="";return t&&t.length>=3&&(i=I(t[2])?t[3]:t[2]),["watchOS",i]}],[new RegExp("(Android (\\d+)\\.(\\d+)\\.?(\\d+)?|Android)","i"),t=>t&&t[2]?[et,[t[2],t[3],t[4]||"0"].join(".")]:[et,""]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,t=>{const i=["Mac OS X",""];return t&&t[1]&&(i[1]=[t[1],t[2],t[3]||"0"].join(".")),i}],[/Mac/i,["Mac OS X",""]],[/CrOS/,["Chrome OS",""]],[/Linux|debian/i,["Linux",""]]],Qt=function(t){for(let i=0;Zt.length>i;i++){const[e,s]=Zt[i],n=e.exec(t),r=n&&(T(s)?s(n,t):s);if(r)return r}return["",""]},ti=function(t){return Wt.test(t)?mt:Vt.test(t)?bt:qt.test(t)?yt:new RegExp(Et,"i").test(t)?Et:new RegExp("(Windows Phone|WPDesktop)","i").test(t)?St:/iPad/.test(t)?rt:/iPod/.test(t)?"iPod Touch":/iPhone/.test(t)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(t)?ot:Gt.test(t)?at:/(kobo)\s(ereader|touch)/i.test(t)?"Kobo":new RegExp(kt,"i").test(t)?kt:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(t)||/(kf[a-z]+)( bui|\)).+silk\//i.test(t)?"Kindle Fire":/(Android|ZTE)/i.test(t)?new RegExp(it).test(t)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(t)||/pixel[\daxl ]{1,6}/i.test(t)&&!/pixel c/i.test(t)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(t)||/lmy47v/i.test(t)&&!/QTAQZ3/i.test(t)?et:nt:new RegExp("(pda|Mobile)","i").test(t)?Pt:new RegExp(st,"i").test(t)&&!new RegExp("Tablet pc","i").test(t)?Tt:""},ii=function(t,i){var e;const s=ti(t);return s===rt||s===nt||"Kobo"===s||"Kindle Fire"===s||s===Tt?st:s===mt||s===yt||s===bt||s===Et?"Console":s===ot?"Wearable":s?it:"Android"===(null==i?void 0:i.userAgentDataPlatform)&&(null!==(e=null==i?void 0:i.maxTouchPoints)&&void 0!==e?e:0)>0?600>Math.min(null!==(n=null==i?void 0:i.screenWidth)&&void 0!==n?n:0,null!==(r=null==i?void 0:i.screenHeight)&&void 0!==r?r:0)/(null!==(o=null==i?void 0:i.devicePixelRatio)&&void 0!==o?o:1)?it:st:"Desktop";var n,r,o},ei=/\bFBAV\/(\d+(?:\.\d+)*)/i,si=[[/\bInstagram(?:[ /](\d+(?:\.\d+)*))?\b/i,"Instagram"],[/\bBarcelona[ /](\d+(?:\.\d+)*)?/i,"Threads"],[/\b(?:MessengerForiOS|(?:FBAN|FB_IAB)\/Orca-Android)\b/i,"Messenger",ei],[/\bFBAN\/EMA\b/i,"Facebook Lite",ei],[/\b(?:FBIOS|(?:FBAN|FB_IAB)\/(?:FB4A|FBIOS))\b/i,"Facebook",ei],[/\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"]],ni="[Truncated]",ri="[Unserializable]";function oi(t){let i="";for(let e=0;t.length>e;e++){const s=t.charCodeAt(e);if(55296>s||s>56319)i+=56320>s||s>57343?t[e]:"�";else{const s=t.charCodeAt(e+1);56320>s||s>57343?i+="�":(i+=t[e]+t[e+1],e++)}}return i}Date,Date;const li=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function ai(t,i){return"string"==typeof(e=t)&&li.test(e)?t:i();var e}function ui(t,i){const e=new Error(i);try{Object.defineProperty(e,"name",{value:t,writable:!0,enumerable:!0,configurable:!0})}catch(t){}return e}function hi(t){return t?t.split("#")[0]:t}function di(t,i){const e=setTimeout(t,i);return null!=e&&e.unref&&(null==e||e.unref()),e}function ci(t,i,e){return vi.apply(this,arguments)}function vi(){return(vi=Y(function*(t,i,e){let s;try{return yield Promise.race([t,new Promise((t,n)=>{s=di(()=>{try{null==e||e(),t()}catch(t){n(t)}},i)})])}finally{clearTimeout(s)}})).apply(this,arguments)}let fi,pi,gi;function _i(t){const i=globalThis._posthogChunkIds;if(!i)return;const e=Object.keys(i);return gi&&e.length===pi||(pi=e.length,gi=e.reduce((e,s)=>{fi||(fi={});const n=fi[s];if(n)e[n[0]]=n[1];else{const n=t(s);for(let t=n.length-1;t>=0;t--){const r=n[t],o=null==r?void 0:r.filename,l=i[s];if(o&&l){e[o]=l,fi[s]=[o,l];break}}}return e},{})),gi}function mi(t){return mi="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},mi(t)}function bi(t,i,e){return(i=function(t){var i=function(t){if("object"!=mi(t)||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var e=i.call(t,"string");if("object"!=mi(e))return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==mi(i)?i:i+""}(i))in t?Object.defineProperty(t,i,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[i]=e,t}function yi(t,i){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);i&&(s=s.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),e.push.apply(e,s)}return e}function wi(t){for(var i=1;arguments.length>i;i++){var e=null!=arguments[i]?arguments[i]:{};i%2?yi(Object(e),!0).forEach(function(i){bi(t,i,e[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):yi(Object(e)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(e,i))})}return t}var $i=class{constructor(t,i,e=[]){this.coercers=t,this.stackParser=i,this.modifiers=e}buildFromUnknown(t,i={}){const e=i&&i.mechanism||{handled:!0,type:"generic"},s=this.buildCoercingContext(e,i,0).apply(t),n=this.buildParsingContext(i),r=this.parseStacktrace(s,n);return{$exception_list:this.convertToExceptionList(r,e),$exception_level:"error"}}modifyFrames(t){var i=this;return Y(function*(){for(const e of t)e.stacktrace&&e.stacktrace.frames&&P(e.stacktrace.frames)&&(e.stacktrace.frames=yield i.applyModifiers(e.stacktrace.frames));return t})()}coerceFallback(t){var i;return{type:"Error",value:"Unknown error",stack:null===(i=t.syntheticException)||void 0===i?void 0:i.stack,synthetic:!0}}parseStacktrace(t,i){let e,s;return null!=t.cause&&(e=this.parseStacktrace(t.cause,i)),""!=t.stack&&null!=t.stack&&(s=this.applyChunkIds(this.stackParser(t.stack,t.synthetic?i.skipFirstLines:0),i.chunkIdMap)),wi(wi({},t),{},{cause:e,stack:s})}applyChunkIds(t,i){return t.map(t=>(t.filename&&i&&(t.chunk_id=i[t.filename]),t))}applyCoercers(t,i){for(const e of this.coercers)if(e.match(t))return e.coerce(t,i);return this.coerceFallback(i)}applyModifiers(t){var i=this;return Y(function*(){let e=t;for(const t of i.modifiers)e=yield t(e);return e})()}convertToExceptionList(t,i){var e,s,n;const r={type:t.type,value:t.value,mechanism:{type:null!==(e=i.type)&&void 0!==e?e:"generic",handled:null===(s=i.handled)||void 0===s||s,synthetic:null!==(n=t.synthetic)&&void 0!==n&&n}};t.stack&&(r.stacktrace={type:"raw",frames:t.stack});const o=[r];return null!=t.cause&&o.push(...this.convertToExceptionList(t.cause,wi(wi({},i),{},{handled:!0}))),o}buildParsingContext(t){var i;return{chunkIdMap:_i(this.stackParser),skipFirstLines:null!==(i=t.skipFirstLines)&&void 0!==i?i:1}}buildCoercingContext(t,i,e=0){const s=(e,s)=>{if(4>=s){const n=this.buildCoercingContext(t,i,s);return this.applyCoercers(e,n)}};return wi(wi({},i),{},{syntheticException:0==e?i.syntheticException:void 0,mechanism:t,apply:t=>s(t,e),next:t=>s(t,e+1)})}};function xi(t,i,e,s,n){const r={platform:t,filename:i,function:"<anonymous>"===e?"?":e,in_app:!!i&&!i.startsWith("webkit-masked-url://")&&"<anonymous>"!==i};return I(s)||(r.lineno=s),I(n)||(r.colno=n),r}const Si=(t,i)=>{const e=-1!==t.indexOf("safari-extension"),s=-1!==t.indexOf("safari-web-extension");return e||s?[-1!==t.indexOf("@")?t.split("@")[0]:"?",e?`safari-extension:${i}`:`safari-web-extension:${i}`]:[t,i]},ki=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,Ei=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,Pi=/\((\S*)(?::(\d+))(?::(\d+))\)/,Ti=(t,i)=>{const e=ki.exec(t);if(e){const[,t,s,n]=e;return xi(i,t,"?",+s,+n)}const s=Ei.exec(t);if(s){if(s[2]&&0===s[2].indexOf("eval")){const t=Pi.exec(s[2]);t&&(s[2]=t[1],s[3]=t[2],s[4]=t[3])}const[t,e]=Si(s[1]||"?",s[2]);return xi(i,e,t,s[3]?+s[3]:void 0,s[4]?+s[4]:void 0)}},Ci=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,Fi=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,Ii=(t,i)=>{const e=Ci.exec(t);if(e){if(e[3]&&e[3].indexOf(" > eval")>-1){const t=Fi.exec(e[3]);t&&(e[1]=e[1]||"eval",e[3]=t[1],e[4]=t[2],e[5]="")}let t=e[3],s=e[1]||"?";return[s,t]=Si(s,t),xi(i,t,s,e[4]?+e[4]:void 0,e[5]?+e[5]:void 0)}},Oi=/\(error: (.*)\)/;function Ri(t,i){return t.filename===i.filename&&t.function===i.function&&t.module===i.module&&t.lineno===i.lineno&&t.colno===i.colno}function Ai(t){for(let i=1;10>=i;i++){const e=t.length-2*i;if(0>e)break;let s=!0;for(let n=0;i>n;n++)if(!Ri(t[e+n],t[e+i+n])){s=!1;break}if(s){for(let s=0;i>s;s++)t[e+s]=t[e+i+s];return t.length=e+i,{start:e,length:i}}}}function Mi(t,i){const e=i.start+i.length,s=ji(t,i);s&&t.splice(e+s===t.length?e:i.start,s)}function Di(t,i){let e=i.start;for(;e>0&&Ri(t[e-1],t[e-1+i.length]);)e--;return i.start-e}function ji(t,i){const e=i.start+i.length;let s=e;for(;t.length>s&&Ri(t[s],t[s-i.length]);)s++;return s-e}function Bi(t,i){const e=i[0];let s=t.length-(e?Di(t,e):0);for(const e of i)s-=ji(t,e);return s}function Li(t,i,e){for(let s=0;t.length>s;s++){const n=t[(i+s)%t.length],r=t[(e+s)%t.length];if(n!==r)return r>n}return!1}var Ni=class{match(t){return this.isDOMException(t)||this.isDOMError(t)}coerce(t,i){const e=O(t.stack);return{type:this.getType(t),value:this.getValue(t),stack:e?t.stack:void 0,cause:t.cause?i.next(t.cause):void 0,synthetic:!1}}getType(t){return this.isDOMError(t)?"DOMError":"DOMException"}getValue(t){const i=t.name||(this.isDOMError(t)?"DOMError":"DOMException");return t.message?`${i}: ${t.message}`:i}isDOMException(t){return U(t,"DOMException")}isDOMError(t){return U(t,"DOMError")}},zi=class{match(t){return H(t)}coerce(t,i){var e;const s=this.getStack(t),n=void 0===s;return{type:this.getType(t),value:this.getMessage(t,i),stack:null!=s?s:null===(e=i.syntheticException)||void 0===e?void 0:e.stack,cause:t.cause?i.next(t.cause):void 0,synthetic:n}}getType(t){return t.name||t.constructor.name}getMessage(t,i){const e=t.message;return String(e.error&&"string"==typeof e.error.message?e.error.message:e)}getStack(t){return t.stacktrace||t.stack||void 0}},Ui=class{match(t){return!!U(t,"ErrorEvent")&&(null!=t.error||this.lr(t))}coerce(t,i){var e;if(null!=t.error)return i.apply(t.error);const s=i.apply(t.message);return wi(wi({},s),{},{stack:null!==(e=this.ur(t))&&void 0!==e?e:s.stack,synthetic:!0})}lr(t){return O(t.message)&&t.message.length>0}ur(t){var i,e;const s=t,n=null!==(i=s.lineno)&&void 0!==i?i:0,r=null!==(e=s.colno)&&void 0!==e?e:0;if(O(s.filename)&&0!==s.filename.length&&0!==n)return`Error\n at ${s.filename}:${n}:${r}`}};const Hi=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;var qi=class{match(t){return"string"==typeof t}coerce(t,i){var e;const[s,n]=this.getInfos(t);return{type:null!=s?s:"Error",value:null!=n?n:t,stack:null===(e=i.syntheticException)||void 0===e?void 0:e.stack,synthetic:!0}}getInfos(t){let i="Error",e=t;const s=t.match(Hi);return s&&(i=s[1],e=s[2]),[i,e]}};const Vi=["fatal","error","warning","log","info","debug"];function Wi(t,i=40){const e=Object.keys(t);if(e.sort(),!e.length)return"[object has no keys]";for(let t=e.length;t>0;t--){const s=e.slice(0,t).join(", ");if(i>=s.length)return t===e.length?s:s.length>i?`${s.slice(0,i)}...`:s}return""}var Gi=class{match(t){return"object"==typeof t&&null!==t}coerce(t,i){var e,s;const n=this.getErrorPropertyFromObject(t);return n?i.apply(n):{type:this.getType(t),value:this.getValue(t),stack:null!==(e=this.getStack(t))&&void 0!==e?e:null===(s=i.syntheticException)||void 0===s?void 0:s.stack,level:this.isSeverityLevel(t.level)?t.level:"error",synthetic:!0}}getType(t){if(q(t))return t.constructor.name;const i="name"in t?t.name:void 0;return O(i)&&!R(i)?i:"Error"}getValue(t){if("name"in t&&"string"==typeof t.name){let i=`'${t.name}' captured as exception`;return"message"in t&&"string"==typeof t.message&&(i+=` with message: '${t.message}'`),i}if("message"in t&&"string"==typeof t.message)return t.message;const i=this.getObjectClassName(t);return`${i&&"Object"!==i?`'${i}'`:"Object"} captured as exception with keys: ${Wi(t)}`}isSeverityLevel(t){return O(t)&&!R(t)&&Vi.indexOf(t)>=0}getStack(t){try{return O(t.stacktrace)&&t.stacktrace.length>0?t.stacktrace:O(t.stack)&&t.stack.length>0?t.stack:void 0}catch(t){return}}getErrorPropertyFromObject(t){for(const i in t)if({}.hasOwnProperty.call(t,i)){const e=t[i];if(H(e))return e}}getObjectClassName(t){try{const i=Object.getPrototypeOf(t);return i?i.constructor.name:void 0}catch(t){return}}},Ki=class{match(t){return q(t)}coerce(t,i){var e;const s=t.constructor.name;return{type:s,value:`${s} captured as exception with keys: ${Wi(t)}`,stack:null===(e=i.syntheticException)||void 0===e?void 0:e.stack,synthetic:!0}}},Ji=class{match(t){return z(t)}coerce(t,i){var e;return{type:"Error",value:`Primitive value captured as exception: ${String(t)}`,stack:null===(e=i.syntheticException)||void 0===e?void 0:e.stack,synthetic:!0}}},Yi=class{match(t){return U(t,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(t)}isCustomEventWrappingRejection(t){if(!q(t))return!1;try{const i=t.detail;return null!=i&&"object"==typeof i&&"reason"in i}catch(t){return!1}}coerce(t,i){var e;const s=this.getUnhandledRejectionReason(t);return z(s)?{type:"UnhandledRejection",value:`Non-Error promise rejection captured with value: ${String(s)}`,stack:null===(e=i.syntheticException)||void 0===e?void 0:e.stack,synthetic:!0}:i.apply(s)}getUnhandledRejectionReason(t){try{if("reason"in t)return t.reason;if("detail"in t&&null!=t.detail&&"object"==typeof t.detail&&"reason"in t.detail)return t.detail.reason}catch(t){}return t}};const Xi="$message",Zi="$timestamp",Qi=new Set([Xi,Zi]),te={enabled:!0,max_bytes:32768};function ie(t){var i;return t?{enabled:null!==(i=t.enabled)&&void 0!==i?i:te.enabled,max_bytes:se(t.max_bytes,te.max_bytes)}:wi({},te)}var ee=class{constructor(t){this.ts=[],this.es=0,this.Mr=ie(t)}setConfig(t){this.Mr=ie(t),this.ns()}add(t){const i=function(t){let i;try{i=x(t)}catch(t){return}try{const t=JSON.parse(i);if(!C(t))return;const e=t,s=e[Xi],n=e[Zi];if(!O(s)||0===s.trim().length)return;if(!O(n)&&!D(n))return;return{step:e,json:i}}catch(t){return}}(t);if(!i)return;const e=function(t){if("u">typeof TextEncoder)return(new TextEncoder).encode(t).length;const i=encodeURIComponent(t);let e=0;for(let t=0;i.length>t;t++)"%"===i[t]?(e+=1,t+=2):e+=1;return e}(i.json);e>this.Mr.max_bytes||(this.ts.push({step:i.step,bytes:e}),this.es+=e,this.ns())}getAttachable(){return this.ts.map(t=>t.step)}clear(){this.ts=[],this.es=0}size(){return this.ts.length}ns(){for(;this.es>this.Mr.max_bytes&&this.ts.length>0;){const t=this.ts.shift();t&&(this.es-=t.bytes)}}};function se(t,i){if(!D(t)||1/0===t||-1/0===t)return i;const e=Math.floor(t);return 0>e?i:e}const ne=t=>{if("string"!=typeof t)return t;try{return JSON.parse(t)}catch(i){return t}};function re(t){return"string"==typeof t||t}function oe(t){return"string"==typeof t?t:void 0}const le=["$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"],ae="NativeGzipValidationError",ue=t=>t.length>=2&&31===t[0]&&139===t[1],he=(t,i)=>t===g.GZipJS||i===g.GZipJS||"gzip"===i,de=t=>!(!t||"object"!=typeof t)&&"NotReadableError"===("name"in t?String(t.name):"");let ce;const ve=t=>{throw ui(ae,`Native gzip produced invalid output: ${t}`)},fe=(pe=Y(function*(t,i){18>t.size&&ve("too-short");const e=new Uint8Array(yield t.slice(0,10).arrayBuffer());ue(e)&&8===e[2]||ve("invalid-header");const s=new DataView(yield t.slice(t.size-8).arrayBuffer());s.getUint32(0,!0)!==(t=>{const i=(()=>{if(ce)return ce;ce=[];for(let t=0;256>t;t++){let i=t;for(let t=0;8>t;t++)i=1&i?3988292384^i>>>1:i>>>1;ce[t]=i>>>0}return ce})();let e=4294967295;for(let s=0;t.length>s;s++)e=i[255&(e^t[s])]^e>>>8;return(4294967295^e)>>>0})(i)&&ve("invalid-crc");const n=i.length>>>0;s.getUint32(4,!0)!==n&&ve("invalid-size")}),function(t,i){return pe.apply(this,arguments)});var pe;function ge(){return ge=Y(function*(t,i=!0,e){try{const i=(new TextEncoder).encode(t),e=new globalThis.CompressionStream("gzip"),n=e.writable.getWriter(),r=n.write(i).then(()=>n.close()).catch((s=Y(function*(t){try{yield n.abort(t)}catch(t){}throw t}),function(t){return s.apply(this,arguments)})),o=new Response(e.readable).blob(),[l]=yield Promise.all([o,r]);return yield fe(l,i),l}catch(t){if(null==e?void 0:e.rethrow)throw t;return i&&console.error("Failed to gzip compress data",t),null}var s}),ge.apply(this,arguments)}function _e(t,i){if(null==t)return{};var e,s,n=function(t,i){if(null==t)return{};var e={};for(var s in t)if({}.hasOwnProperty.call(t,s)){if(i.includes(s))continue;e[s]=t[s]}return e}(t,i);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);for(s=0;r.length>s;s++)i.includes(e=r[s])||{}.propertyIsEnumerable.call(t,e)&&(n[e]=t[e])}return n}const me={}.propertyIsEnumerable;function be(t,i){try{return $e(t,i,{ancestors:new WeakSet,remainingNodes:1e4},0)}catch(t){return[]}}function ye(t,i,e,s){if(0>=e.remainingNodes)return{stringValue:ni};if(e.remainingNodes--,B(t))return{boolValue:t};if("bigint"==typeof t)return function(t,i){const e=t.toString(),s=BigInt("9223372036854775808");return t>=s||-s>t?(null==i||i.debug(`Attribute ${e} is outside the int64 range; encoding it as a string`),{stringValue:e}):{intValue:e}}(t,i);if("number"==typeof t){if(!Number.isFinite(t))return{stringValue:String(t)};if(Number.isInteger(t)){if(Number.isSafeInteger(t))return{intValue:String(t)};if(typeof BigInt>"u")return{stringValue:String(t)};const e=BigInt(t).toString();return t>=0x8000000000000000||-0x8000000000000000>t?(null==i||i.debug(`Attribute ${e} is outside the int64 range; encoding it as a string`),{stringValue:e}):{intValue:e}}return{doubleValue:t}}if("string"==typeof t)return{stringValue:oi(t)};if("function"==typeof t)return{stringValue:"[Function]"};if("symbol"==typeof t)return{stringValue:String(t)};if("object"==typeof t&&null!==t){if(e.ancestors.has(t))return{stringValue:"[Circular]"};if(s>=20)return{stringValue:ni};if(t instanceof Date){const i=t.getTime(),e=Number.isFinite(i)?t.toISOString():String(t);return{stringValue:"string"==typeof e?oi(e):String(e)}}e.ancestors.add(t);try{try{const n=t.toJSON;if("function"==typeof n)return ye(n.call(t),i,e,s+1)}catch(t){}return P(t)?{arrayValue:{values:we(t,i,e,s+1)}}:{kvlistValue:{values:$e(t,i,e,s+1)}}}finally{e.ancestors.delete(t)}}return{stringValue:oi(String(t))}}function we(t,i,e,s){const n=[],r=Math.min(t.length,1e3);let o=0;for(;r>o&&e.remainingNodes>0;o++)try{const r=o in t?t[o]:void 0;if(M(r))continue;n.push(ye(r,i,e,s))}catch(t){n.push({stringValue:ri})}return t.length>o&&n.push({stringValue:ni}),n}function $e(t,i,e,s){const n=[];for(const r in t)if(me.call(t,r)){if(!r){null==i||i.debug("Dropping an attribute with an empty key");continue}if(n.length>=1e3||0>=e.remainingNodes){null==i||i.debug("Attributes truncated: the value exceeds the OTLP encoder budget");break}try{const o=t[r];if(A(o)||I(o))continue;n.push({key:oi(r),value:ye(o,i,e,s)})}catch(t){n.push({key:oi(r),value:{stringValue:ri}})}}return n}function xe(t,i,e){return wi(wi(wi(wi({},t.resourceAttributes),{},{"service.name":t.serviceName||"unknown_service"},t.environment&&{"deployment.environment":t.environment}),t.serviceVersion&&{"service.version":t.serviceVersion}),{},{"telemetry.sdk.name":i,"telemetry.sdk.version":e})}const Se={darwin:"macOS",win32:"Windows",linux:"Linux",android:"Android",freebsd:"FreeBSD",openbsd:"OpenBSD",sunos:"SunOS",aix:"AIX","Mac OS X":"macOS"};const ke={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}},Ee=ke.info;function Pe(t){try{return oi(String(t))}catch(t){return ri}}function Te(t,i,e,s){const n=t.level||"info",{text:r,number:o}=ke[n]||Ee,l=function(t=Date.now()){return String(t)+"000000"}(D(s)?s:void 0),a={};i.distinctId&&(a.posthogDistinctId=i.distinctId),i.sessionId&&(a.sessionId=i.sessionId),i.windowId&&(a["window.id"]=i.windowId),M(i.sessionStartTimestamp)||(a.sessionStartTimestamp=String(i.sessionStartTimestamp)),M(i.lastActivityTimestamp)||(a.lastActivityTimestamp=String(i.lastActivityTimestamp)),i.currentUrl&&(a["url.full"]=i.currentUrl),i.screenName&&(a["screen.name"]=i.screenName),i.appState&&(a["app.state"]=i.appState),i.activeFeatureFlags&&i.activeFeatureFlags.length>0&&(a.feature_flags=i.activeFeatureFlags);const u=wi({},a),h=t.attributes;if(h){let t=[];try{t=Object.keys(h)}catch(i){t=[]}for(const i of t){let t;try{t=h[i]}catch(i){t=ri}Object.defineProperty(u,i,{value:t,enumerable:!0,writable:!0,configurable:!0})}}const d={timeUnixNano:l,observedTimeUnixNano:l,severityNumber:o,severityText:r,body:{stringValue:Pe(t.body)},attributes:be(u,e)};return t.trace_id&&(d.traceId=t.trace_id),t.span_id&&(d.spanId=t.span_id),I(t.trace_flags)||(d.flags=t.trace_flags),d}function Ce(t,i,e){return xe(t,i,e)}function Fe(t,i,e,s){return{resourceLogs:[{resource:{attributes:be(i)},scopeLogs:[{scope:{name:e,version:s},logRecords:t}]}]}}var Ie=class{constructor(t,i,e,s,n,r=()=>Promise.resolve(),o){var l;this._instance=t,this.Mr=i,this.$=e,this.ss=s,this.rs=n,this.ls=r,this.us=o,this.hs=null,this.cs=0,this.ds=0,this.vs=0,this.fs=0,this.ps=0,this.gs=!1,this.ys=i.maxBufferSize,this.bs=Math.max(null!==(l=i.maxQueueSize)&&void 0!==l?l:i.maxBufferSize,i.maxBufferSize),this._s=i.flushIntervalMs,this.ws=i.maxBatchRecordsPerPost,this.ks=i.rateCapWindowMs,this.Ss=i.maxLogsPerInterval}clearQueue(){this.ds++,this._instance.setPersistedProperty(p.LogsQueue,[])}reset(){this.xs(),this.fs=0,this.ps=0,this.gs=!1,this.vs=0,this.ws=this.Mr.maxBatchRecordsPerPost}onReconnect(){this.vs=0,this.Cs()}captureLog(t,i){var e;if(this._instance.isDisabled)return;if(this._instance.optedOut)return;if(!(null==t?void 0:t.body))return;const s=this.$s(t);if(null===s)return;if(!s.body)return void this.$.info("Log was rejected in beforeSend function");if(!this.Ts())return;const n={record:Te(s,null!==(e=null==i?void 0:i.context)&&void 0!==e?e:this.ss(),this.$,null==i?void 0:i.occurredAtMs)};this.rs(()=>this.Is(n))}$s(t){const i=this.Mr.beforeSend;if(!i)return t;const e=P(i)?i:[i];let s=t;for(const t of e)try{const i=t(s);if(!i)return this.$.info("Log was rejected in beforeSend function"),null;s=i}catch(t){return this.$.error("Error in beforeSend function for log:",t),null}return s}Ts(){if(void 0===this.Ss)return!0;const t=Date.now(),i=t-this.fs;return this.ks>i&&i>=0||(this.fs=t,this.ps=0,this.gs=!1),this.Ss>this.ps?(this.ps++,!0):(this.gs||(this.$.warn(`captureLog dropping logs: exceeded ${this.Ss} logs per ${this.ks}ms`),this.gs=!0),!1)}flush(){var t=this;return Y(function*(){if(!t._instance.isDisabled)return t.hs||(t.hs=t.Ms().finally(()=>{t.hs=null})),t.hs})()}Ms(){var t=this;return Y(function*(){var i;t.xs();let e=null!==(i=t._instance.getPersistedProperty(p.LogsQueue))&&void 0!==i?i:[];if(0===e.length)return;const s=e.length;let n=0;for(;e.length>0&&s>n;){var r,o;const i=t.ds;t.cs=0;const s=Math.min(e.length,t.ws),l=e.slice(0,s),a=Fe(l.map(t=>t.record),t.Es(),null!==(r=t.us)&&void 0!==r?r:t._instance.getLibraryId(),t._instance.getLibraryVersion()),u=yield t._instance.Ps(a);if(t.ds!==i)return;if("too-large"===u.kind&&l.length>1)t.ws=Math.max(1,Math.floor(l.length/2)),t.$.warn(`Received 413 when sending logs batch of size ${l.length}, reducing batch size to ${t.ws}`);else{if("retry-later"===u.kind)throw u.error;if("too-large"===u.kind?t.$.warn("Dropping a single log record after 413 with batch size 1 — the record is larger than the server cap and cannot be split further."):"ok"===u.kind&&t.Mr.maxBatchRecordsPerPost>t.ws&&(t.ws=Math.min(t.Mr.maxBatchRecordsPerPost,t.ws+1)),yield t.Rs(l.length),e=null!==(o=t._instance.getPersistedProperty(p.LogsQueue))&&void 0!==o?o:[],n+=l.length,"fatal"===u.kind)throw u.error}}})()}Rs(t){var i=this;return Y(function*(){var e;const s=Math.max(0,t-i.cs),n=null!==(e=i._instance.getPersistedProperty(p.LogsQueue))&&void 0!==e?e:[];i._instance.setPersistedProperty(p.LogsQueue,n.slice(s)),yield i.ls()})()}Es(){return Ce(this.Mr,this._instance.getLibraryId(),this._instance.getLibraryVersion())}Is(t){var i;if(this._instance.optedOut)return;const e=null!==(i=this._instance.getPersistedProperty(p.LogsQueue))&&void 0!==i?i:[];this.bs>e.length||(e.shift(),this.cs++,this.$.info("Logs queue is full, dropping oldest record.")),e.push(t),this._instance.setPersistedProperty(p.LogsQueue,e),this.ys>e.length?this.As():this.Cs()}As(t=this._s){this.Fs||(this.Fs=di(()=>{this.Fs=void 0,this.Cs()},t))}Os(){const t=Math.min(Math.max(0,this.vs-1),6);return this._s*Math.pow(2,t)}Ds(){const t=this._instance.getPersistedProperty(p.LogsQueue);return!!t&&t.length>0}shutdown(t){var i=this;return Y(function*(){i.xs();const e=i.flush().catch(()=>{});void 0!==t?yield ci(e,t):yield e})()}flushWithTimeout(t){var i=this;return Y(function*(){const e=i.flush();yield ci(e,t,()=>{e.catch(()=>{})})})()}Cs(){this.flush().then(()=>{this.vs=0},t=>{this.vs++,this.$.error("PostHog logs flush failed:",t)}).finally(()=>{!this._instance.isDisabled&&this.Ds()&&this.As(this.Os())})}xs(){this.Fs&&(clearTimeout(this.Fs),this.Fs=void 0)}};const Oe=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function Re(t){return String(t)+"000000"}function Ae(t,i,e,s){let n="";return s&&(n=Object.keys(s).sort().map(t=>`${JSON.stringify(t)}:${JSON.stringify(s[t])}`).join(",")),`${t}\0${i}\0${null!=e?e:""}\0${n}`}var Me=class{constructor(t,i,e){this._instance=t,this.Mr=i,this.$=e,this.Ls=new Map,this.hs=null,this.Ns=!1,this.qs=new Map,this.js=new Set,this.Bs=0}count(t,i=1,e){this.Hs({name:t,type:"count",value:i,unit:null==e?void 0:e.unit,attributes:null==e?void 0:e.attributes})}gauge(t,i,e){this.Hs({name:t,type:"gauge",value:i,unit:null==e?void 0:e.unit,attributes:null==e?void 0:e.attributes})}histogram(t,i,e){this.Hs({name:t,type:"histogram",value:i,unit:null==e?void 0:e.unit,attributes:null==e?void 0:e.attributes})}flush(){var t=this;const i=this.hs,e=function(){var e=Y(function*(){i&&(yield i.catch(()=>{})),yield t.zs()});return function(){return e.apply(this,arguments)}}()().finally(()=>{this.hs===e&&(this.hs=null)});return this.hs=e,e}drainWindow(){if(0===this.Ls.size)return null;const t=this.Ls;return this.Ls=new Map,this.Ns=!1,this.qs=new Map,this.js=new Set,this.Us(t)}reset(){this.Bs++,this.xs(),this.Ls=new Map,this.hs=null,this.Ns=!1,this.qs=new Map,this.js=new Set}Hs(t){if(this._instance.isDisabled||this._instance.optedOut)return;const i=this.$s(t);if(null===i)return;if(!i.name||"string"!=typeof i.name)return void this.$.warn("Dropping metric with empty name");if("number"!=typeof i.value||!Number.isFinite(i.value))return void this.$.warn(`Dropping metric '${i.name}': value must be a finite number`);if("count"===i.type&&0>i.value)return void this.$.warn(`Dropping count '${i.name}': counters are monotonic, value must be >= 0`);let e,s;try{e=i.attributes?wi({},i.attributes):void 0,s=Ae(i.type,i.name,i.unit,e)}catch(t){return void this.$.warn(`Dropping metric '${i.name}': attributes could not be serialized`,t)}let n=this.Ls.get(s);if(!n){if(!this.Ws())return;n={name:i.name,type:i.type,unit:i.unit,attributes:e,windowStartMs:Date.now()},this.Ls.set(s,n)}const r=this.qs.get(i.name);void 0===r?this.qs.set(i.name,i.type):r===i.type||this.js.has(i.name)||(this.js.add(i.name),this.$.warn(`Metric name '${i.name}' is already used as a ${r}; recording it as a ${i.type} too will blend both series in charts. Use a distinct name.`)),this.Vs(n,i.value),this.As()}Ws(){return this.Mr.maxSeriesPerFlush>this.Ls.size||(this.Ns||(this.Ns=!0,this.$.warn(`Metric series cap reached (${this.Mr.maxSeriesPerFlush} per flush window); dropping new series until the next flush. Reduce attribute cardinality.`)),!1)}Vs(t,i){switch(t.type){case"count":var e;t.total=(null!==(e=t.total)&&void 0!==e?e:0)+i;break;case"gauge":t.last=i;break;case"histogram":{t.hist||(t.hist={count:0,sum:0,min:i,max:i,bucketCounts:new Array(Oe.length+1).fill(0)});const e=t.hist;e.count+=1,e.sum+=i,e.min=Math.min(e.min,i),e.max=Math.max(e.max,i),e.bucketCounts[function(t,i){for(let e=0;i.length>e;e++)if(i[e]>=t)return e;return i.length}(i,Oe)]+=1;break}}}$s(t){const i=this.Mr.beforeSend;if(!i)return t;const e=P(i)?i:[i];let s=t;for(const t of e)try{const i=t(s);if(!i)return this.$.info("Metric was rejected in beforeSend function"),null;s=i}catch(t){return this.$.error("Error in beforeSend function for metric:",t),null}return s}As(){this.Fs||(this.Fs=di(()=>{this.Fs=void 0,this.flush().catch(t=>{this.$.error("Metrics flush failed:",t)})},this.Mr.flushIntervalMs))}xs(){this.Fs&&(clearTimeout(this.Fs),this.Fs=void 0)}zs(){var t=this;return Y(function*(){if(0===t.Ls.size)return;const i=t.Ls;t.Ls=new Map,t.Ns=!1,t.qs=new Map,t.js=new Set;const e=t.Bs,s=yield t._instance.Gs(t.Us(i));if(e===t.Bs)switch(s.kind){case"ok":return;case"retry-later":return t.Zs(i),void t.As();case"too-large":return void t.$.warn("Metrics batch exceeded the server size limit and was dropped");case"fatal":return void t.$.error("Failed to send metrics batch:",s.error)}})()}Us(t){return i=this.Qs(t),e=function(t,i,e){return xe(t,i,e)}(this.Mr,this._instance.getLibraryId(),this._instance.getLibraryVersion()),s=this._instance.getLibraryId(),n=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:be(e)},scopeMetrics:[{scope:{name:s,version:n},metrics:i}]}]};var i,e,s,n}Qs(t){const i=Re(Date.now()),e=new Map;for(const o of t.values()){var s;const t=Ae(o.type,o.name,o.unit,void 0);let l=e.get(t);l||(l=wi({name:o.name},o.unit&&{unit:o.unit}),"count"===o.type?l.sum={aggregationTemporality:1,isMonotonic:!0,dataPoints:[]}:"gauge"===o.type?l.gauge={dataPoints:[]}:l.histogram={aggregationTemporality:1,dataPoints:[]},e.set(t,l));const a=be(null!==(s=o.attributes)&&void 0!==s?s:{},this.$),u=Re(o.windowStartMs);if("count"===o.type){var n;const t={attributes:a,startTimeUnixNano:u,timeUnixNano:i,asDouble:null!==(n=o.total)&&void 0!==n?n:0};l.sum.dataPoints.push(t)}else if("gauge"===o.type){var r;const t={attributes:a,timeUnixNano:i,asDouble:null!==(r=o.last)&&void 0!==r?r:0};l.gauge.dataPoints.push(t)}else o.hist&&l.histogram.dataPoints.push({attributes:a,startTimeUnixNano:u,timeUnixNano:i,count:o.hist.count,sum:o.hist.sum,min:o.hist.min,max:o.hist.max,bucketCounts:o.hist.bucketCounts,explicitBounds:Oe})}return Array.from(e.values())}Zs(t){for(const[s,n]of t){const t=this.Ls.get(s);if(t)switch(t.windowStartMs=Math.min(t.windowStartMs,n.windowStartMs),t.type){case"count":var i,e;t.total=(null!==(i=t.total)&&void 0!==i?i:0)+(null!==(e=n.total)&&void 0!==e?e:0);break;case"gauge":break;case"histogram":if(n.hist)if(t.hist){t.hist.count+=n.hist.count,t.hist.sum+=n.hist.sum,t.hist.min=Math.min(t.hist.min,n.hist.min),t.hist.max=Math.max(t.hist.max,n.hist.max);for(let i=0;t.hist.bucketCounts.length>i;i++)t.hist.bucketCounts[i]+=n.hist.bucketCounts[i]}else t.hist=n.hist}else this.Ws()&&this.Ls.set(s,n)}}};const De=(i,{debugEnabled:e}={})=>{const s={N(s,...n){t&&(f.DEBUG||t.POSTHOG_DEBUG||e)&&!I(t.console)&&t.console&&("__rrweb_original__"in t.console[s]?t.console[s].__rrweb_original__:t.console[s])(i,...n)},debug(...t){s.N("debug",...t)},info(...t){s.N("log",...t)},warn(...t){s.N("warn",...t)},error(...t){s.N("error",...t)},critical(...t){console.error(i,...t)},uninitializedWarning(t){s.error(`You must initialize PostHog before calling ${t}`)},createLogger:(t,e)=>De(`${i} ${t}`,e)};return s},je=De("[PostHog.js]"),Be=je.createLogger,Le=Be("[ExternalScriptsLoader]"),Ne=t=>{const i=null==s?void 0:s.querySelectorAll("script");if(i)for(let e=0;i.length>e;e++)if(i[e].src===t||i[e].getAttribute("src")===t)return i[e]},ze=(t,i,e)=>{if(t.config.disable_external_dependency_loading)return Le.warn(`${i} was requested but loading of external scripts is disabled.`),e("Loading of external scripts is disabled");const n=Ne(i);if(n){if(n.__posthog_loading_callback_fired)return e();const t=n.__posthog_loading_error;return t?e(t):(n.addEventListener("load",t=>{n.__posthog_loading_callback_fired=!0,e(void 0,t)}),void n.addEventListener("error",t=>{n.__posthog_loading_error=t,e(t)}))}const r=()=>{if(!s)return e("document not found");if(Ne(i))return ze(t,i,e);let n=s.createElement("script");if(n.type="text/javascript",n.crossOrigin="anonymous",n.src=i,n.onload=t=>{n.__posthog_loading_callback_fired=!0,e(void 0,t)},n.onerror=t=>{n.__posthog_loading_error=t,e(t)},t.config.prepare_external_dependency_script&&(n=t.config.prepare_external_dependency_script(n)),!n)return e("prepare_external_dependency_script returned null");if("head"===t.config.external_scripts_inject_target)s.head.appendChild(n);else{const t=s.querySelectorAll("body > script");var r;t.length>0?null===(r=t[0].parentNode)||void 0===r||r.insertBefore(n,t[0]):s.body.appendChild(n)}};(null==s?void 0:s.body)?r():null==s||s.addEventListener("DOMContentLoaded",r)},Ue={},He=(t,i)=>{let e=`/static/${i}.js?v=${t.version}`;if("toolbar"===i){const t=3e5;e=`${e}&t=${Math.floor(Date.now()/t)*t}`}return t.requestRouter.endpointFor("assets",e)};c.__PosthogExtensions__=c.__PosthogExtensions__||{},c.__PosthogExtensions__.loadExternalDependency=(t,i,e)=>{if("remote-config"===i){const i=t.requestRouter.endpointFor("assets",`/array/${t.config.token}/config.js`);return void ze(t,i,e)}const s=t.config.strict_script_versioning;if(s){const n=t.requestRouter.endpointFor("assets",`/static/${t.version}/${i}.js`),r=Ue[n];if("fallback"===s&&r){if(Ne(r))return void ze(t,r,e);delete Ue[n]}return void ze(t,n,"fallback"===s?(s,r)=>{if(s)if("string"==typeof s)e(s);else{var o;const s=He(t,i);Ue[n]=s;const r=Ne(n);null==r||null===(o=r.parentNode)||void 0===o||o.removeChild(r),ze(t,s,e)}else e(void 0,r)}:e)}ze(t,He(t,i),e)},c.__PosthogExtensions__.loadSiteApp=(t,i,e)=>{const s=t.requestRouter.endpointFor("api",i);ze(t,s,e)},f.DEBUG=!1,f.LIB_VERSION="1.429.3",f.LIB_NAME="web";var qe=f;const Ve="$people_distinct_id",We="distinct_id",Ge="$device_id",Ke="$device_model",Je="__alias",Ye="__cmpns",Xe="$fbc",Ze="$fbc_persistence",Qe="__timers",ts="$autocapture_disabled_server_side",is="$heatmaps_enabled_server_side",es="$exception_capture_enabled_server_side",ss="$error_tracking_suppression_rules",ns="$error_tracking_capture_extension_exceptions",rs="$web_vitals_enabled_server_side",os="$dead_clicks_enabled_server_side",ls="$product_tours_enabled_server_side",as="$logs_capture_enabled_server_side",us="$web_vitals_allowed_metrics",hs="$session_recording_remote_config",ds="$session_recording_enabled_server_side",cs="$replay_sample_rate",vs="$replay_override_sampling",fs="$replay_override_linked_flag",ps="$replay_override_url_trigger",gs="$replay_override_event_trigger",_s="$sesid",ms="$session_is_sampled",bs="$session_past_minimum_duration",ys="$session_recording_url_trigger_activated_session",ws="$session_recording_event_trigger_activated_session",$s="$debug_first_full_snapshot_timestamp",xs="$sess_rec_flush_size",Ss="$enabled_feature_flags",ks="$active_feature_flags",Es="$early_access_features",Ps="$feature_flag_details",Ts="$feature_flag_payloads",Cs="$feature_flag_request_id",Fs="$minimal_flag_called_events",Is="$override_feature_flags",Os="$override_feature_flag_payloads",Rs="$stored_person_properties",As="$stored_group_properties",Ms="$groups",Ds="$surveys",js="$surveys_loaded_at",Bs="$surveys_activated",Ls="$surveys_activated_session",Ns="$surveys_activated_timestamps",zs="ph_product_tours",Us="$product_tours_activated",Hs="$product_tours_activated_session",qs="$conversations_widget_session_id",Vs="$conversations_ticket_id",Ws="$conversations_widget_state",Gs="$conversations_user_traits",Ks="$flag_call_reported",Js="$flag_call_reported_session_id",Ys="$feature_flag_errors",Xs="$feature_flag_evaluated_at",Zs="$user_state",Qs="$client_session_props",tn="$capture_rate_limit",en="$initial_campaign_params",sn="$initial_referrer_info",nn="$initial_person_info",rn="$epp",on="$posthog_cookieless",ln="$cookieless_mode",an="$sdk_debug_extensions_init_method",un="$sdk_debug_extensions_init_time_ms",hn="$sdk_debug_recording_script_not_loaded",dn="$sdk_debug_replay_event_trigger_status",cn="$sdk_debug_replay_linked_flag_trigger_status",vn="$sdk_debug_replay_matched_recording_trigger_groups",fn="$sdk_debug_replay_pending_trigger_conditions",pn="$sdk_debug_replay_remote_trigger_matching_config",gn="$sdk_debug_replay_trigger_groups_count",_n="$sdk_debug_replay_url_trigger_status",mn="$session_recording_start_reason",bn="PostHog loadExternalDependency extension not found.",yn="anonymous",wn="identified",$n="identified_only",xn="visibilitychange",Sn="beforeunload",kn="$pageview",En="$pageleave",Pn="$identify",Tn="$groupidentify";function Cn(t,i){P(t)&&t.forEach(i)}function Fn(t,i){if(!M(t))if(P(t))t.forEach(i);else if((t=>t instanceof FormData)(t))t.forEach((t,e)=>i(t,e));else for(const e in t)k.call(t,e)&&i(t[e],e)}const In=function(t,...i){for(const e of i)for(const i in e)void 0!==e[i]&&(t[i]=e[i]);return t};function On(t){const i=Object.keys(t);let e=i.length;const s=new Array(e);for(;e--;)s[e]=[i[e],t[i[e]]];return s}const Rn=function(t){try{return t()}catch(t){return}},An=function(t){return function(...i){try{return t.apply(this,i)}catch(t){je.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),je.critical(t)}}},Mn=function(t){const i={};return Fn(t,function(t,e){(O(t)&&t.length>0||D(t))&&(i[e]=t)}),i};function Dn(t){const i=wi({},t);for(const e of["name","message","stack","cause","errors"])try{e in t&&(i[e]=t[e])}catch(t){}return i}const jn=["herokuapp.com","vercel.app","netlify.app"];function Bn(t){const i=null==t?void 0:t.hostname;if(!O(i))return!1;const e=i.split(".").slice(-2).join(".");for(const t of jn)if(e===t)return!1;return!0}function Ln(t,i,e,s){const{capture:n=!1,passive:r=!0}=null!=s?s:{};null==t||t.addEventListener(i,e,{capture:n,passive:r})}function Nn(t){return"ph_toolbar_internal"===t.name}const zn=t=>{if(s){try{const i=t+"=",e=s.cookie.split(";").filter(t=>t.length);for(let t=0;e.length>t;t++){let s=e[t];for(;" "==s.charAt(0);)s=s.substring(1,s.length);if(0===s.indexOf(i))return decodeURIComponent(s.substring(i.length,s.length))}}catch(t){}return null}};Math.trunc||(Math.trunc=function(t){return 0>t?Math.ceil(t):Math.floor(t)}),Number.isInteger||(Number.isInteger=function(t){return D(t)&&isFinite(t)&&Math.floor(t)===t});var Un=class t{constructor(t){if(this.bytes=t,16!==t.length)throw new TypeError("not 128-bit length")}static fromFieldsV7(i,e,s,n){if(!Number.isInteger(i)||!Number.isInteger(e)||!Number.isInteger(s)||!Number.isInteger(n)||0>i||0>e||0>s||0>n||i>0xffffffffffff||e>4095||s>1073741823||n>4294967295)throw new RangeError("invalid field value");const r=new Uint8Array(16);return r[0]=i/Math.pow(2,40),r[1]=i/Math.pow(2,32),r[2]=i/Math.pow(2,24),r[3]=i/Math.pow(2,16),r[4]=i/256,r[5]=i,r[6]=112|e>>>8,r[7]=e,r[8]=128|s>>>24,r[9]=s>>>16,r[10]=s>>>8,r[11]=s,r[12]=n>>>24,r[13]=n>>>16,r[14]=n>>>8,r[15]=n,new t(r)}toString(){let t="";for(let i=0;this.bytes.length>i;i++)t=t+(this.bytes[i]>>>4).toString(16)+(15&this.bytes[i]).toString(16),3!==i&&5!==i&&7!==i&&9!==i||(t+="-");if(36!==t.length)throw new Error("Invalid UUIDv7 was generated");return t}clone(){return new t(this.bytes.slice(0))}equals(t){return 0===this.compareTo(t)}compareTo(t){for(let i=0;16>i;i++){const e=this.bytes[i]-t.bytes[i];if(0!==e)return Math.sign(e)}return 0}},Hn=class{generate(){const t=this.generateOrAbort();if(!I(t))return t;{this.Ct=0;const t=this.generateOrAbort();if(I(t))throw new Error("Could not generate UUID after timestamp reset");return t}}generateOrAbort(){const t=(()=>{const t=Date.now();return D(t)&&isFinite(t)?Math.min(Math.max(Math.floor(t),0),0xffffffffffff):0})();if(t>this.Ct)this.Ct=t,this.Mt();else{if(this.Ct>=t+1e4)return;this.It++,this.It>4398046511103&&(this.Ct++,this.Mt())}return Un.fromFieldsV7(this.Ct,Math.trunc(this.It/Math.pow(2,30)),this.It&Math.pow(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 Vn}};let qn=t=>{if("u">typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(let i=0;t.length>i;i++)t[i]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return t};t&&!I(t.crypto)&&crypto.getRandomValues&&(qn=t=>crypto.getRandomValues(t));var Vn=class{nextUint32(){return this.Rt.length>this.$t||(qn(this.Rt),this.$t=0),this.Rt[this.$t++]}constructor(){this.Rt=new Uint32Array(8),this.$t=1/0}};let Wn;const Gn=()=>Kn().toString(),Kn=()=>(Wn||(Wn=new Hn)).generate();let Jn="";const Yn=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;let Xn=null;const Zn={Et(){if(!A(Xn))return Xn;if(Xn=!1,s)try{const t=`__ph_cookie_support_${Gn()}`;Zn.At(t,"xyz"),Xn='"xyz"'===zn(t),Zn.Lt(t)}catch(t){Xn=!1}return Xn},Pt(t){je.error("cookieStore error: "+t)},Ot:zn,Dt(t){let i;try{i=JSON.parse(Zn.Ot(t))||{}}catch(t){}return i},At(t,i,e,n,r){if(!s)return!1;try{let o="",l="";const a=function(t,i){if(i){let i=function(t,i=s){if(Jn)return Jn;if(!i)return"";if(["localhost","127.0.0.1"].includes(t))return"";const e=t.split(".");let n=Math.min(e.length,8);const r="dmn_chk_"+Gn();for(;!Jn&&n--;){const t=e.slice(n).join("."),s=r+"=1;domain=."+t+";path=/";i.cookie=s+";max-age=3",i.cookie.includes(r)&&(i.cookie=s+";max-age=0",Jn=t)}return Jn}(t);if(!i){const e=(t=>{const i=t.match(Yn);return i?i[0]:""})(t);e!==i&&je.info("Warning: cookie subdomain discovery mismatch",e,i),i=e}return i?"; domain=."+i:""}return""}(s.location.hostname,n);if(e){const t=new Date;t.setTime(t.getTime()+864e5*e),o="; expires="+t.toUTCString()}r&&(l="; secure");const u=t+"="+encodeURIComponent(JSON.stringify(i))+o+"; SameSite=Lax; path=/"+a+l;return u.length>3686.4&&je.warn("cookieStore warning: large cookie, len="+u.length),s.cookie=u,!0}catch(t){return!1}},Lt(t,i){if(null==s?void 0:s.cookie)try{Zn.At(t,"",-1,i)}catch(t){return}}};let Qn=null;const tr={Et(){if(!A(Qn))return Qn;let i=!0;if(I(t))i=!1;else try{const t="__mplssupport__";tr.At(t,"xyz"),'"xyz"'!==tr.Ot(t)&&(i=!1),tr.Lt(t)}catch(t){i=!1}return i||je.error("localStorage unsupported; falling back to cookie store"),Qn=i,i},Pt(t){je.error("localStorage error: "+t)},Ot(i){try{return null==t?void 0:t.localStorage.getItem(i)}catch(t){tr.Pt(t)}return null},Dt(t){try{return JSON.parse(tr.Ot(t))||{}}catch(t){}return null},At(i,e){try{return null==t||t.localStorage.setItem(i,JSON.stringify(e)),!0}catch(t){tr.Pt(t)}return!1},Lt(i){try{null==t||t.localStorage.removeItem(i)}catch(t){tr.Pt(t)}}},ir=[Rs,ks,Ss,Ps,Ts,Cs,Xs,Ys,Ks],er=[Ge,We,_s,ms,rn,nn,Ze,Zs],sr=t=>t+"_cpm",nr=["__proto__","constructor","prototype"],rr=t=>{if(!C(t))return{};const i={};return Object.keys(t).forEach(e=>{-1===nr.indexOf(e)&&(i[e]=t[e])}),i},or=(t,i=[])=>{const e={};return[...er,...i].forEach(i=>{const s=t[i];I(s)||A(s)||""===s||(e[i]=s)}),e},lr=t=>{let i=5381,e=2166136261;for(let s=0;t.length>s;s++){const n=t.charCodeAt(s);i=33*i^n,e=Math.imul(e^n,16777619)}return t.length.toString(36)+"."+(i>>>0).toString(36)+"."+(e>>>0).toString(36)},ar=(t,i)=>({p:i,f:lr(JSON.stringify(t))}),ur=(t,i)=>{if(!i)return{properties:[],isValid:!1};try{const e=Zn.Dt(sr(t)),s=(null==e?void 0:e.f)===lr(i)&&P(e.p);return{properties:s?e.p:[],isValid:s}}catch(t){return{properties:[],isValid:!1}}},hr=(t,i)=>i+"|"+(Zn.Ot(sr(t))||""),dr={},cr={Et:()=>!0,Pt(t){je.error("memoryStorage error: "+t)},Ot:t=>t in dr?dr[t]:null,Dt:t=>t in dr?dr[t]:null,At:(t,i)=>(dr[t]=i,!0),Lt(t){delete dr[t]}};let vr=null;const fr={Et(){if(!A(vr))return vr;if(vr=!0,I(t))vr=!1;else try{const t="__support__";fr.At(t,"xyz"),'"xyz"'!==fr.Ot(t)&&(vr=!1),fr.Lt(t)}catch(t){vr=!1}return vr},Pt(t){je.error("sessionStorage error: ",t)},Ot(i){try{return null==t?void 0:t.sessionStorage.getItem(i)}catch(t){fr.Pt(t)}return null},Dt(t){try{return JSON.parse(fr.Ot(t))||null}catch(t){}return null},At(i,e){try{return null==t||t.sessionStorage.setItem(i,JSON.stringify(e)),!0}catch(t){fr.Pt(t)}return!1},Lt(i){try{null==t||t.sessionStorage.removeItem(i)}catch(t){fr.Pt(t)}}};var pr=class{constructor(t){this._instance=t}get Mr(){return this._instance.config}get consent(){return this.$o()?0:this.To}isOptedOut(){return"always"===this.Mr.cookieless_mode||this.isRejected()||-1===this.consent&&"on_reject"===this.Mr.cookieless_mode}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return 0===this.consent}isRejected(){return 0===this.consent||-1===this.consent&&this.Mr.opt_out_capturing_by_default}optInOut(t){this.Io.At(this.Mo,t?1:0,this.Mr.cookie_expiration,this.Mr.cross_subdomain_cookie,this.Mr.secure_cookie)}reset(){this.Io.Lt(this.Mo,this.Mr.cross_subdomain_cookie)}get Mo(){const{token:t,opt_out_capturing_cookie_prefix:i,consent_persistence_name:e}=this._instance.config;return e||(i?i+t:"__ph_opt_in_out_"+t)}get To(){const t=this.Io.Ot(this.Mo);return G(t)?1:b(K,t)?0:-1}get Io(){const t=this.Mr.opt_out_capturing_persistence_type,i="localStorage"===t?tr:Zn,e=i.Et()?i:cr;if(!this.Eo||this.Eo!==e){this.Eo=e;const i="localStorage"===t?Zn:tr;i.Ot(this.Mo)&&(this.Eo.Ot(this.Mo)||this.optInOut(G(i.Ot(this.Mo))),i.Lt(this.Mo,this.Mr.cross_subdomain_cookie))}return this.Eo}$o(){return!!this.Mr.respect_dnt&&[null==e?void 0:e.doNotTrack,null==e?void 0:e.msDoNotTrack,c.doNotTrack,null==e?void 0:e.globalPrivacyControl].some(t=>G(t))}};function gr(t,i){var e;const s=null==t||null===(e=t.config)||void 0===e?void 0:e.get_current_url;if(!T(s))return i;try{const t=s(i);return O(t)&&t?t:i}catch(t){return je.error("Error in get_current_url, falling back to window.location.href",t),i}}function _r(t){var i;return t instanceof Element&&("__POSTHOG_TOOLBAR__"===t.id||!!(null===(i=t.closest)||void 0===i?void 0:i.call(t,".toolbar-global-fade-container")))}function mr(t){return!!t&&1===t.nodeType}function br(t,i){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===i.toLowerCase()}function yr(t){return!!t&&3===t.nodeType}function wr(t){return!!t&&11===t.nodeType&&mr(t.host)}function $r(t){return t?y(t).split(/\s+/):[]}function xr(i,e){const s=function(i){var e;const s=null==t||null===(e=t.location)||void 0===e?void 0:e.href;return I(s)?void 0:gr(i,s)}(e);return!!(s&&i&&i.some(t=>s.match(t)))}function Sr(t){let i="";switch(typeof t.className){case"string":i=t.className;break;case"object":i=(t.className&&"baseVal"in t.className?t.className.baseVal:null)||t.getAttribute("class")||"";break;default:i=""}return $r(i)}function kr(t){return M(t)?null:y(t).split(/(\s+)/).filter(t=>Yr(t)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Er(t){let i="";return zr(t)&&!Ur(t)&&t.childNodes&&t.childNodes.length&&Fn(t.childNodes,function(t){var e;yr(t)&&t.textContent&&(i+=null!==(e=kr(t.textContent))&&void 0!==e?e:"")}),y(i)}function Pr(t){var i;return I(t.target)?t.srcElement||null:(null===(i=t.target)||void 0===i?void 0:i.shadowRoot)?t.composedPath()[0]||null:t.target||null}const Tr=["a","button","form","input","select","textarea","label"];function Cr(t,i){const e=t.matches||t.matchesSelector||t.msMatchesSelector||t.mozMatchesSelector||t.webkitMatchesSelector||t.oMatchesSelector;try{return!!e&&e.call(t,i)}catch(t){return!1}}function Fr(t,i){if(I(i))return!0;for(const e of t)if(i.some(t=>Cr(e,t)))return!0;return!1}function Ir(t){const i=t.parentNode;return!(!i||!mr(i))&&i}const Or=[".ph-no-autocapture","[data-ph-no-autocapture]"],Rr=["next","previous","prev",">","<"],Ar=[...Rr,"+","-","−","–"],Mr=(t,i)=>/[a-z0-9]/i.test(i)?t.includes(i):t===i,Dr=[".ph-no-rageclick",".ph-no-capture"],jr=["","text","search","email","password","url","tel","number"];function Br(i,e){if(!t||Lr(i))return!1;let s,n,r;var o,l;if(B(e)?(s=!!e&&Dr,n=void 0,r=!1):(s=null!==(o=null==e?void 0:e.css_selector_ignorelist)&&void 0!==o?o:Dr,n=null==e?void 0:e.content_ignorelist,r=null!==(l=null==e?void 0:e.ignore_text_selection)&&void 0!==l&&l),!1===s)return!1;if(r&&function(t){return!(!t||!mr(t))&&(!!br(t,"textarea")||(br(t,"input")?b(jr,(t.getAttribute("type")||"").toLowerCase()):function(t){var i;if(t.isContentEditable)return!0;const e=null===(i=t.getAttribute)||void 0===i?void 0:i.call(t,"contenteditable");return"true"===e||""===e}(t)))}(i))return!1;const{targetElementList:a}=Nr(i,!1);return!function(t,i){if(!1===t||I(t))return!1;let e;if(!0===t)e=Rr;else{if(!P(t))return!1;if(t.length>10)return je.error("[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching."),!1;e=t.map(t=>t.toLowerCase())}return i.some(({safeText:t,ariaLabel:i})=>e.some(e=>Mr(t,e)||Mr(i,e)))}(n,a.map(t=>{var i;return{safeText:Er(t).toLowerCase(),ariaLabel:(null===(i=t.getAttribute("aria-label"))||void 0===i?void 0:i.toLowerCase().trim())||""}}))&&!Fr(a,s)}const Lr=t=>!t||br(t,"html")||!mr(t),Nr=(i,e)=>{if(!t||Lr(i))return{parentIsUsefulElement:!1,targetElementList:[]};let s=!1;const n=[i];let r=i;for(;r.parentNode&&!br(r,"body");){if(wr(r.parentNode)){n.push(r.parentNode.host),r=r.parentNode.host;continue}const i=Ir(r);if(!i)break;if(e||Tr.indexOf(i.tagName.toLowerCase())>-1)s=!0;else try{const e=t.getComputedStyle(i);e&&"pointer"===e.getPropertyValue("cursor")&&(s=!0)}catch(t){}n.push(i),r=i}return{parentIsUsefulElement:s,targetElementList:n}};function zr(t){const i=new Set;let e=0;for(let s=t;s.parentNode&&!br(s,"body");s=s.parentNode){if(e++>=1e3||i.has(s))return!1;i.add(s);const t=Sr(s);if(b(t,"ph-sensitive")||b(t,"ph-no-capture"))return!1}if(b(Sr(t),"ph-include"))return!0;const s=t.type||"";if(O(s))switch(s.toLowerCase()){case"hidden":case"password":return!1}const n=t.name||t.id||"";return!O(n)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(n.replace(/[^a-zA-Z0-9]/g,""))}function Ur(t){return!!(br(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||br(t,"select")||br(t,"textarea")||"true"===t.getAttribute("contenteditable"))}const Hr=new 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}))$"),qr=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,Vr=[16,15,14,13],Wr=new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),Gr=new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),Kr=/[0-9A-Za-z_]/;function Jr(t){let i=0,e=!1;for(let s=t.length-1;s>=0;s--){let n=t.charCodeAt(s)-48;e&&(n*=2,n>9&&(n-=9)),i+=n,e=!e}return i%10==0}function Yr(t,i=!0){if(M(t))return!1;if(O(t)){if(t=y(t),i?Hr.test((t||"").replace(/[- ]/g,"")):function(t){let i;for(qr.lastIndex=0;i=qr.exec(t);){const t=i[2];if(!t)continue;const e=t.replace(/[- ]/g,"");for(let t=0;e.length>t;t++)for(const i of Vr){const s=t+i;if(e.length>=s){const i=e.slice(t,s);if(Hr.test(i)&&Jr(i))return!0}}}return!1}(t))return!1;if(i?Wr.test(t):function(t){let i;for(Gr.lastIndex=0;i=Gr.exec(t);){const t=i[1],e=i[3];if(!(t&&e&&Kr.test(t)&&Kr.test(e)))return!0}return!1}(t))return!1}return!0}function Xr(t){let i=Er(t);return i=`${i} ${Zr(t)}`.trim(),Yr(i)?i:""}function Zr(t){let i="";return t&&t.childNodes&&t.childNodes.length&&Fn(t.childNodes,function(t){var e;if(t&&"span"===(null===(e=t.tagName)||void 0===e?void 0:e.toLowerCase()))try{const e=Er(t);i=`${i} ${e}`.trim(),t.childNodes&&t.childNodes.length&&(i=`${i} ${Zr(t)}`.trim())}catch(t){je.error("[AutoCapture]",t)}}),i}function Qr(t){return t.replace(/"|\\"/g,'\\"')}function to(t){const i=t.attr__class;if(i)return P(i)?i:$r(i)}const io=Be("[Dead Clicks]"),eo=()=>!0,so=t=>{var i;const e=!!(null===(i=t.instance.persistence)||void 0===i?void 0:i.get_property(os)),s=t.instance.config.capture_dead_clicks;return B(s)?s:!!C(s)||e};var no=class{get lazyLoadedDeadClicksAutocapture(){return this.Po}constructor(t,i,e){this.instance=t,this.isEnabled=i,this.onCapture=e,this.startIfEnabledOrStop()}onRemoteConfig(t){if(!t.ok)return;const i=t.config;"captureDeadClicks"in i&&(this.instance.persistence&&this.instance.persistence.register({[os]:i.captureDeadClicks}),this.startIfEnabledOrStop())}startIfEnabledOrStop(){this.isEnabled(this)?this.Ro(()=>{this.Ao()}):this.stop()}Ro(t){var i,e,s;(null===(i=c.__PosthogExtensions__)||void 0===i?void 0:i.initDeadClicksAutocapture)?t():null===(e=c.__PosthogExtensions__)||void 0===e||null===(s=e.loadExternalDependency)||void 0===s||s.call(e,this.instance,"dead-clicks-autocapture",i=>{i?io.error("failed to load script",i):t()})}Ao(){var t;if(s){if(!this.Po&&(null===(t=c.__PosthogExtensions__)||void 0===t?void 0:t.initDeadClicksAutocapture)){const t=C(this.instance.config.capture_dead_clicks)?wi({},this.instance.config.capture_dead_clicks):{};t.__onCapture=this.onCapture,this.onCapture&&(t.capture_dead_swipes=!1),this.Po=c.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this.Po.start(s),io.info("starting...")}}else io.error("`document` not found. Cannot start.")}stop(){this.Po&&(this.Po.stop(),this.Po=void 0,io.info("stopping..."))}};const ro=Be("[SegmentIntegration]");function oo(t,i,e=!0){const s=t.config.segment;if(!s)return i();const{analytics:n,filterProperties:r}=(t=>T(t.register))(o=s)?{analytics:o}:o;var o;!function(t,i,e,s){const n=i=>{const n=()=>i.anonymousId()||Gn();t.config.get_device_id=n,s&&i.id()&&(t.register({distinct_id:i.id(),$device_id:n()}),t.persistence.set_property(Zs,wn)),e(s?void 0:i.anonymousId()||void 0)},r=i.user();"then"in r&&T(r.then)?r.then(n):n(r)}(t,n,e=>{n.register(((t,i,{filterProperties:e}={})=>{"undefined"!=typeof Promise&&Promise.resolve||ro.warn("This browser does not have Promise support, and can not use the segment integration");const s=(s,n)=>{if(!n)return s;const r=!!i&&s.event.anonymousId===i&&!s.event.userId;r||s.event.userId||s.event.anonymousId===t.get_distinct_id()||(ro.info("No userId set, resetting PostHog"),t.reset()),r||(i=void 0),s.event.userId&&s.event.userId!==t.get_distinct_id()&&(ro.info("UserId set, identifying with PostHog"),t.identify(s.event.userId));let o=t.calculateEventProperties(n,s.event.properties);if(!M(e)){const t=s.event.properties||{},i={};for(const e of Object.keys(o))k.call(t,e)||(i[e]=o[e]);const n=((t,i)=>{const e=P(t)?t:[t];let s=wi({},i);for(const t of e)try{if(s=t(s),M(s))return null}catch(t){return ro.error("Error in Segment filterProperties:",t),null}return s})(e,i);if(M(n))return s;o=n}return s.event.properties=Object.assign({},o,s.event.properties),s};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded(){return!0},load(){return Promise.resolve()},track(t){return s(t,t.event.event)},page(t){return s(t,kn)},identify(t){return s(t,Pn)},screen(t){return s(t,"$screen")}}})(t,e,{filterProperties:r})).then(()=>{i()},t=>{ro.error("Failed to register the Segment integration",t),i()})},e)}const lo="posthog-js";function ao(t,{organization:i,projectId:e,prefix:s,severityAllowList:n=["error"],sendExceptionsToPostHog:r=!0}={}){return o=>{var l,a,u,h,d;if("*"!==n&&!n.includes(o.level)||!t.__loaded)return o;o.tags||(o.tags={});const c=t.requestRouter.endpointFor("ui",`/project/${t.config.token}/person/${t.get_distinct_id()}`);o.tags["PostHog Person URL"]=c,t.sessionRecordingStarted()&&(o.tags["PostHog Recording URL"]=t.get_session_replay_url({withTimestamp:!0}));const v=(null===(l=o.exception)||void 0===l?void 0:l.values)||[],f=v.map(t=>wi(wi({},t),{},{stacktrace:t.stacktrace?wi(wi({},t.stacktrace),{},{type:"raw",frames:(t.stacktrace.frames||[]).map(t=>wi(wi({},t),{},{platform:"web:javascript"}))}):void 0})),p={$exception_message:(null===(a=v[0])||void 0===a?void 0:a.value)||o.message,$exception_type:null===(u=v[0])||void 0===u?void 0:u.type,$exception_level:o.level,$exception_list:f,$sentry_event_id:o.event_id,$sentry_exception:o.exception,$sentry_exception_message:(null===(h=v[0])||void 0===h?void 0:h.value)||o.message,$sentry_exception_type:null===(d=v[0])||void 0===d?void 0:d.type,$sentry_tags:o.tags};var g;return i&&e&&(p.$sentry_url=(s||"https://sentry.io/organizations/")+i+"/issues/?project="+e+"&query="+o.event_id),r&&(null===(g=t.exceptions)||void 0===g||g.sendExceptionEvent(p)),o}}var uo=class{constructor(t,i,e,s,n,r){this.name=lo,this.setupOnce=function(o){o(ao(t,{organization:i,projectId:e,prefix:s,severityAllowList:n,sendExceptionsToPostHog:null==r||r}))}}},ho=class{constructor(t){this.Fo=(t,i,e)=>{e&&(e.noSessionId||e.activityTimeout||e.sessionPastMaximumLength||e.crossTabAdoption)&&(je.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:t,changeReason:e}),this.Oo=void 0,this._instance.scrollManager.resetContext())},this._instance=t,this.Do()}Do(){var t;this.Lo=null===(t=this._instance.sessionManager)||void 0===t?void 0:t.onSessionId(this.Fo)}destroy(){var t;null===(t=this.Lo)||void 0===t||t.call(this),this.Lo=void 0}doPageView(i,e){var s;const n=this.No(i,e);return this.Oo={pathname:null!==(s=null==t?void 0:t.location.pathname)&&void 0!==s?s:"",pageViewId:e,timestamp:i},this._instance.scrollManager.resetContext(),n}doPageLeave(t){var i;return this.No(t,null===(i=this.Oo)||void 0===i?void 0:i.pageViewId)}doEvent(){var t;return{$pageview_id:null===(t=this.Oo)||void 0===t?void 0:t.pageViewId}}No(t,i){const e=this.Oo;if(!e)return{$pageview_id:i};let s={$pageview_id:i,$prev_pageview_id:e.pageViewId};const n=this._instance.scrollManager.getContext();if(n&&!this._instance.config.disable_scroll_properties){let{maxScrollHeight:t,lastScrollY:i,maxScrollY:e,maxContentHeight:r,lastContentY:o,maxContentY:l}=n;if(!(I(t)||I(i)||I(e)||I(r)||I(o)||I(l))){t=Math.ceil(t),i=Math.ceil(i),e=Math.ceil(e),r=Math.ceil(r),o=Math.ceil(o),l=Math.ceil(l);const n=t>1?Q(i/t,0,1,je):1,a=t>1?Q(e/t,0,1,je):1,u=r>1?Q(o/r,0,1,je):1,h=r>1?Q(l/r,0,1,je):1;s=In(s,{$prev_pageview_last_scroll:i,$prev_pageview_last_scroll_percentage:n,$prev_pageview_max_scroll:e,$prev_pageview_max_scroll_percentage:a,$prev_pageview_last_content:o,$prev_pageview_last_content_percentage:u,$prev_pageview_max_content:l,$prev_pageview_max_content_percentage:h})}}return e.pathname&&(s.$prev_pageview_pathname=e.pathname),e.timestamp&&(s.$prev_pageview_duration=(t.getTime()-e.timestamp.getTime())/1e3),s}};const co=["flags","surveys"],vo={[Ve]:{exposure:"hidden"},[Je]:{exposure:"hidden"},[Ye]:{exposure:"hidden"},[Qe]:{exposure:"hidden"},[Ze]:{exposure:"hidden"},[ts]:{exposure:"event"},[is]:{exposure:"hidden"},[as]:{exposure:"hidden"},[es]:{exposure:"event"},[ss]:{exposure:"hidden"},[ns]:{exposure:"event"},[rs]:{exposure:"event"},[os]:{exposure:"event"},[ls]:{exposure:"hidden"},[us]:{exposure:"event"},[hs]:{exposure:"hidden"},[ds]:{exposure:"hidden"},[_s]:{exposure:"hidden"},[ms]:{exposure:"event"},[cs]:{exposure:"event",shouldSkipFromEventProperties:t=>A(t)},[bs]:{exposure:"event"},[ys]:{exposure:"event"},[ws]:{exposure:"event"},[$s]:{exposure:"event"},[xs]:{exposure:"hidden"},[Ss]:{exposure:"hidden",storageGroup:"flags"},[ks]:{exposure:"hidden",storageGroup:"flags"},[Es]:{exposure:"hidden"},[Ps]:{exposure:"hidden",storageGroup:"flags"},[Ts]:{exposure:"hidden",storageGroup:"flags"},[Cs]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[Fs]:{exposure:"hidden",storageGroup:"flags"},[Is]:{exposure:"hidden"},[Os]:{exposure:"hidden"},[Rs]:{exposure:"hidden"},[As]:{exposure:"hidden"},[Ds]:{exposure:"hidden",storageGroup:"surveys"},[js]:{exposure:"hidden",storageGroup:"surveys",volatile:!0},[Bs]:{exposure:"event"},[Ls]:{exposure:"hidden"},[Ns]:{exposure:"hidden"},[zs]:{exposure:"hidden"},[Us]:{exposure:"hidden"},[Hs]:{exposure:"hidden"},[qs]:{exposure:"event"},[Vs]:{exposure:"event"},[Ws]:{exposure:"event"},[Gs]:{exposure:"event"},[Ks]:{exposure:"hidden"},[Js]:{exposure:"hidden"},[Ms]:{exposure:"event"},[Ys]:{exposure:"hidden"},[Xs]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[Zs]:{exposure:"hidden"},[Qs]:{exposure:"hidden"},[tn]:{exposure:"hidden"},[en]:{exposure:"hidden"},[sn]:{exposure:"hidden"},[nn]:{exposure:"hidden"},[rn]:{exposure:"hidden"},[vs]:{exposure:"event"},[fs]:{exposure:"event"},[ps]:{exposure:"event"},[gs]:{exposure:"event"},[an]:{exposure:"event"},[un]:{exposure:"event"},[hn]:{exposure:"event"},[dn]:{exposure:"event"},[cn]:{exposure:"event"},[vn]:{exposure:"event"},[fn]:{exposure:"event"},[pn]:{exposure:"event"},[gn]:{exposure:"event"},[_n]:{exposure:"event"},[mn]:{exposure:"event"}},fo=[["$posthog_sr_group_event_trigger_",{exposure:"hidden"}],["$posthog_sr_group_url_trigger_",{exposure:"hidden"}],["$posthog_sr_group_sampling_",{exposure:"hidden"}]],po=t=>{const i=vo[t];if(i)return i;for(const[i,e]of fo)if(0===t.indexOf(i))return e},go=(t,i)=>{try{let e;return JSON.stringify(t,(t,i)=>{var s;return H(i)?(null!==(s=e)&&void 0!==s||(e=new WeakMap),e.has(i)||e.set(i,Dn(i)),e.get(i)):"bigint"==typeof i?i.toString():i},i)}catch(i){return x(t)}},_o=t=>{const i=null==s?void 0:s.createElement("a");return I(i)?null:(i.href=t,i)},mo=function(t,i){const e=((t.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&");let s;for(let t=0;e.length>t;t++){const n=e[t].split("=");if(n[0]===i){s=n;break}}if(!P(s)||2>s.length)return"";{let t=s[1];try{t=decodeURIComponent(t)}catch(i){je.error("Skipping decoding for malformed query param: "+t)}return t.replace(/\+/g," ")}},bo=function(t,i,e){if(!t||!i||!i.length)return t;const s=t.split("#"),n=s[1],r=(s[0]||"").split("?"),o=r[1],l=r[0],a=(o||"").split("&"),u=[];for(let t=0;a.length>t;t++){const s=a[t].split("=");P(s)&&(i.includes(s[0])?u.push(s[0]+"="+e):u.push(a[t]))}let h=l;return null!=o&&(h+="?"+u.join("&")),null!=n&&(h+="#"+n),h},yo=function(t,i){const e=t.match(new RegExp(i+"=([^&]*)"));return e?e[1]:null},wo=(t,i)=>t>=i&&h(),$o=(t,i,e,s)=>{if(0===t){if(h()){const t=i+1;return t===e&&s(),t}return i}return 0},xo=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],So=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...xo],ko="<masked>",Eo=["li_fat_id"];function Po(t,i,e){if(!s)return{};const n=i?[...xo,...e||[]]:[],r=To(bo(s.URL,n,ko),t),o=function(){const t={};return Fn(Eo,function(i){const e=zn(i);t[i]=e||null}),t}();return In(o,r)}function To(t,i){const e=So.concat(i||[]),s={};return Fn(e,function(i){const e=mo(t,i);s[i]=e||null}),s}function Co(t){const i=function(t){return t?0===t.search("https?://(.*)google.([^/?]*)")?"google":0===t.search("https?://(.*)bing.com")?"bing":0===t.search("https?://(.*)yahoo.com")?"yahoo":0===t.search("https?://(.*)duckduckgo.com")?"duckduckgo":null:null}(t),e="yahoo"!=i?"q":"p",n={};if(!A(i)){n.$search_engine=i;const t=s?mo(s.referrer,e):"";t.length&&(n.ph_keyword=t)}return n}function Fo(){return navigator.language||navigator.userLanguage}function Io(){const t=Fo();return"string"==typeof t?t.split("-")[0]:void 0}const Oo="$direct";function Ro(){return(null==s?void 0:s.referrer)||Oo}function Ao(t,i,e=!1){const s=t?[...xo,...i||[]]:[],r=e?hi(null==n?void 0:n.href):null==n?void 0:n.href,o=null==r?void 0:r.substring(0,1e3);return{r:Ro().substring(0,1e3),u:o?bo(o,s,ko):void 0}}function Mo(t,i=!1){var e;const{r:s,u:n}=t,r=i?hi(n):n,o={$referrer:s,$referring_domain:null==s?void 0:s==Oo?Oo:null===(e=_o(s))||void 0===e?void 0:e.host};if(r){o.$current_url=r;const t=_o(r);o.$host=null==t?void 0:t.host,o.$pathname=null==t?void 0:t.pathname;const i=To(r);In(o,i)}if(s){const t=Co(s);In(o,t)}return o}function Do(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(t){return}}function jo(){try{return(new Date).getTimezoneOffset()}catch(t){return}}const Bo={flags:Xs,surveys:js},Lo=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],No=t=>`${t}_cookie_identity_change_pending`,zo=t=>{let i="",e=0;for(const s of t){const t=encodeURIComponent(JSON.stringify(s).slice(1,-1)).length;if(e+t>1e3)break;i+=s,e+=t}return i},Uo="main",Ho=[Ss,ks,Ps,Ts,Cs,Xs,Fs,Rs],qo=t=>-1!==Ho.indexOf(t),Vo=(t,i)=>{try{return JSON.stringify(t)===JSON.stringify(i)}catch(e){return t===i}},Wo=t=>{if(!t)return{};const i=JSON.parse(t);return C(i)?i:{}},Go=(t,i)=>{Fn(t,(e,s)=>{const n=po(s);n&&"event"!==n.exposure||{}.hasOwnProperty.call(i,s)||delete t[s]})};var Ko=class{constructor(i,e,s=!0){if(this.qo={},this.jo=!1,this.Bo=!1,this.Ho=!1,this.zo=!1,this.Uo=!1,this.Wo=new Map,this.Vo=!1,this.Go=!1,this.Zo=!1,this.Qo=!1,this.Jo=new Set,this.Mr=i,this.Ko=s,this.props={},this.Yo=void 0,this.Xo=(t=>{let i="";return t.token&&(i=t.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),t.persistence_name?"ph_"+t.persistence_name:"ph_"+i+"_posthog"})(i),this.Io=this.tl(i),this.Ho=this.el(i),this.load(),this.il(),i.debug&&je.info("Persistence loaded",i.persistence,wi({},this.props)),this.update_config(i,i,e),this.save(),t){const i=()=>this.flush();Ln(t,"beforeunload",i,{capture:!1}),Ln(t,"pagehide",i,{capture:!1}),this.nl=i=>{if(this.jo&&(!i.storageArea||i.storageArea===(null==t?void 0:t.localStorage))&&i.key)if(i.key!==this.Xo){if(this.Ho){const t=co.find(t=>i.key===this.sl(t));t&&this.rl(i.key,t)}}else this.rl(i.key,Uo)},Ln(t,"storage",this.nl)}}markCrossTabFeatureFlagChanges(t){Object.entries(t).forEach(([t,i])=>{const e=this.Wo.get(t);if(!qo(t)||!0===e)return;if(!0===i)return void this.ol(t,!0);const s=new Set(e||[]);i.forEach(t=>s.add(t)),s.size&&this.ol(t,s)})}onCrossTabFeatureFlagChange(t){return this.Jo.add(t),()=>this.Jo.delete(t)}destroy(){this.nl&&t&&(t.removeEventListener("storage",this.nl),this.nl=void 0),this.Jo.clear()}rl(t,i,e=!0){if(this.pi)return!1;let s,n;try{if(n=tr.Ot(t),A(n)){const t=this.ll(i);return t.storageValue=null,i!==Uo&&(t.persisted=!1),!1}s=Wo(n)}catch(t){return!1}const r=i===Uo?s:tr.Dt(this.Xo);if(r&&this.al(r))return!1;const o=this.ul(s,i,e);return i===Uo&&this.Ho&&!Vo(this.hl().main,s)||this.cl(s,i,!0,n),o}al(t){const i=this.props[We],e=t[We];return!I(i)&&!I(e)&&i!==e}cl(t,i,e,s){const n=this.ll(i);n.storageValue=s,i!==Uo&&(n.persisted=e);try{n.fingerprint=this.dl(t,i)}catch(t){n.fingerprint=void 0}}ul(t,i,e){let s=!1;return Ho.forEach(e=>{var n;const r=null===(n=po(e))||void 0===n?void 0:n.storageGroup;if(i===Uo&&this.Ho&&r||i!==Uo&&r!==i)return;const o=e in t,l=this.vl(e,o?t[e]:void 0),a=this.Wo.has(e)?e in this.props:o;a===e in this.props&&Vo(l,this.props[e])||(a?this.fl(e,l,!1):this.pl(e,!1),s=!0)}),s&&e&&this.Jo.forEach(t=>t()),s}gl(){if(!this.jo)return!1;try{this.Zo=!1;const t=tr.Ot(this.Xo),i=this.ll(Uo);let e,s=!1,n=!1;if(t!==i.storageValue)if(A(t))i.storageValue=null;else{if(e=Wo(t),this.Zo=!this.Go&&this.al(e),this.Zo)return!1;n=this.ul(e,Uo,!1),!this.Ho||Vo(this.hl().main,e)?this.cl(e,Uo,!0,t):i.storageValue=t,s=!0}return this.Ho&&co.forEach(t=>{const i=tr.Ot(this.sl(t)),r=this.ll(t),o=e||{},l=s&&Ho.some(i=>{var e;return(null===(e=po(i))||void 0===e?void 0:e.storageGroup)===t&&i in o});if(i===r.storageValue&&!l)return;if(A(i))return r.storageValue=null,r.persisted=!1,void(l&&(n=this.ul(o,t,!1)||n));const a=Wo(i);n=this.ul(a,t,!1)||n,this.cl(a,t,!0,i)}),n}catch(t){return!1}}ol(t,i){this.Wo.set(t,i);const e=po(t);(null==e?void 0:e.volatile)||(this.ll((this.Ho?null==e?void 0:e.storageGroup:void 0)||Uo).fingerprint=void 0,this.ml(t))}yl(){Ho.forEach(t=>this.Wo.set(t,!0))}il(){if(this.jo)try{const t=tr.Ot(this.Xo),i=Wo(t);this.ll(Uo).storageValue=t,Ho.forEach(t=>{var e;const s=this.Ho?null===(e=po(t))||void 0===e?void 0:e.storageGroup:void 0,n=s?tr.Ot(this.sl(s)):null;if(s){const t=this.ll(s);t.storageValue=n,t.persisted=!A(n)}const r=s&&!A(n)?Wo(n):i;t in this.props?this.bl(t,r[t],this.props[t]):t in r&&this.ol(t,!0)})}catch(t){}}vl(t,i){const e=this.Wo.get(t);if(!e)return i;if(!0===e)return this.props[t];if("$active_feature_flags"===t){const s=new Set(P(i)?i:[]),n=new Set(P(this.props[t])?this.props[t]:[]);return e.forEach(t=>n.has(t)?s.add(t):s.delete(t)),Array.from(s)}const s=C(i)?wi({},i):{},n=C(this.props[t])?this.props[t]:{};return e.forEach(t=>{t in n?s[t]=n[t]:delete s[t]}),s}bl(t,i,e){if(!qo(t))return;const s=this.Wo.get(t);if(!0===s)return;let n=i;if(this.jo)try{var r;const i=this.Ho?null===(r=po(t))||void 0===r?void 0:r.storageGroup:void 0,e=i?this.sl(i):this.Xo;n=Wo(tr.Ot(e))[t]}catch(t){}const o=new Set(s||[]);if("$active_feature_flags"===t){if(!I(i)&&!P(i)||!I(n)&&!P(n)||!P(e))return void this.ol(t,!0);const s=new Set(i||[]),r=new Set(n||[]),l=new Set(e);new Set([...s,...l]).forEach(t=>{s.has(t)!==l.has(t)&&o.add(t)}),o.forEach(t=>{r.has(t)===l.has(t)&&o.delete(t)})}else{if(!C(e))return void(Vo(n,e)?this.Wo.delete(t):this.ol(t,!0));{if(!I(i)&&!C(i)||I(i)&&F(e)&&I(n))return void this.ol(t,!0);const s=C(i)?i:{},r=C(n)?n:{};new Set([...Object.keys(s),...Object.keys(e)]).forEach(t=>{t in s==t in e&&Vo(s[t],e[t])||o.add(t)}),o.forEach(t=>{t in r==t in e&&Vo(r[t],e[t])&&o.delete(t)})}}o.size?this.ol(t,o):this.Wo.delete(t)}_l(){var t;const i=null===(t=this.Mr)||void 0===t?void 0:t.persistence_save_debounce_ms;return D(i)&&i>0?i:0}wl(t){if(this.Mr.cookieWinsOnConflict&&"localstorage+cookie"===this.Mr.persistence.toLowerCase())if(t)try{const i=or(t,this.Mr.cookie_persisted_properties||[]),e=ar(i,this.Mr.cookie_persisted_properties||[]),s=JSON.stringify(i)+"|"+JSON.stringify(e),n=Zn.Ot(this.Xo)||void 0;n&&hr(this.Xo,n)===s&&(this.kl=s,this.Sl=n)}catch(t){}else try{const t=Zn.Ot(this.Xo)||void 0;this.kl=t?hr(this.Xo,t):void 0,this.Sl=t}catch(t){}}syncCookieProperties(){return this.xl(this.Mr)}xl(t,i=!1){if(this.pi&&!i||this.Uo||!t.cookieWinsOnConflict||"localstorage+cookie"!==t.persistence.toLowerCase())return!1;let e;try{e=Zn.Ot(this.Xo)||void 0}catch(t){}if(!e||e===this.Sl)return!1;const s=hr(this.Xo,e);let n;try{n=rr(JSON.parse(e))}catch(t){return!1}if((Zn.Ot(this.Xo)||void 0)!==e)return!1;this.kl=s,this.Sl=e;const r=ur(this.Xo,e),o=[...er,...r.properties],l={};if(Object.keys(n).forEach(t=>{const i=n[t];(I(i)||A(i)||""===i||"$user_state"===t&&"anonymous"!==i&&"identified"!==i)&&(l[t]=!0,delete n[t])}),F(n))return!1;const a="distinct_id"in n||"anonymous"===n.$user_state||"identified"===n.$user_state,u=this.props,h=u[We],d=u[Zs],c=In({},u);[...er,...t.cookie_persisted_properties||[]].forEach(t=>{if(-1!==o.indexOf(t)&&!(t in n)&&!l[t]&&(a||"distinct_id"!==t&&"$user_state"!==t)){const i=c[t];(r.isValid||-1===er.indexOf(t)||!1!==i&&0!==i)&&delete c[t]}}),this.props=In(c,n),Ho.forEach(t=>{const i=t in this.props;t in u===i&&Vo(u[t],this.props[t])||(i?this.bl(t,u[t],this.props[t]):this.ol(t,!0))}),!a||"$user_state"in n||"$user_state"in this.props||this.fl(Zs,yn);const v=this.props[We],f=this.props[Zs];return!a||v===h&&f===d||(this.Go=!0,this.zo=!0,fr.At(No(this.Xo),!0),this.pl(Rs),this.pl(ks),this.pl(Ss),this.pl(Ps),this.pl(Ts),this.pl(Cs),this.pl(Xs),this.pl(Ys),this.pl(Ks),"anonymous"!==f||"identified"!==d&&"anonymous"!==n.$user_state&&(I(h)||v===h)||(Go(this.props,n),this.pl(As)),"identified"===f?this.props.$user_id=v:delete this.props.$user_id,this.pl(Je)),!0}consumeCookieIdentityChange(){const t=No(this.Xo),i=this.zo||!!fr.Ot(t);return this.zo=!1,i&&fr.Lt(t),i}Cl(t=!1){return!(this.Uo||this.pi&&!t||!this.Mr.cookieWinsOnConflict||"localstorage+cookie"!==this.Mr.persistence.toLowerCase()||(this.Uo=!0,0))}$l(){this.Uo&&(I(this.Tl)||(clearTimeout(this.Tl),this.Tl=void 0),delete this.qo[Uo],this.Il(!0))}Ml(t=!0){if(this.Uo)try{t?this.$l():I(this.Tl)||(clearTimeout(this.Tl),this.Tl=void 0)}finally{this.Uo=!1}}isDisabled(){return!!this.pi}tl(i){-1===Lo.indexOf(i.persistence.toLowerCase())&&(je.critical("Unknown persistence type "+i.persistence+"; falling back to localStorage+cookie"),i.persistence="localStorage+cookie");const e=((i=[],e=!1)=>{const s=[...er,...i];return wi(wi({},tr),{},{Dt(t){try{let n,r={};try{n=Zn.Ot(t)||void 0,r=n?rr(JSON.parse(n)):{}}catch(t){}const o=JSON.parse(tr.Ot(t)||"{}");let l;if(e){const e=ur(t,n),a=[...er,...e.properties],u={};Object.keys(r).forEach(t=>{const i=r[t];A(i)||""===i||"$user_state"===t&&"anonymous"!==i&&"identified"!==i||(u[t]=i)});const h="distinct_id"in u||"anonymous"===u.$user_state||"identified"===u.$user_state;if(Object.keys(u).length>0){var i;const t=o[We],n=null!==(i=o.$user_state)&&void 0!==i?i:yn;s.forEach(t=>{if(-1!==a.indexOf(t)&&!(t in r)&&(h||"distinct_id"!==t&&"$user_state"!==t)){const i=o[t];(e.isValid||-1===er.indexOf(t)||!1!==i&&0!==i)&&delete o[t]}}),!h||"$user_state"in r||"$user_state"in o||(o[Zs]=yn),!h||("distinct_id"in u?u[We]:o[We])===t&&("$user_state"in u?u[Zs]:o[Zs])===n||(ir.forEach(t=>delete o[t]),"identified"===u.$user_state&&"distinct_id"in u?o.$user_id=u[We]:delete o.$user_id,"identified"!==u.$user_state&&(delete o[Ms],delete o[As]),delete o.__alias)}l=In(o,u)}else l=In(r,o);return tr.At(t,l),l}catch(t){}return null},At(t,s,n,r,o,l){const a=tr.At(t,s,void 0,void 0,l);try{const u=or(s,i);if(Object.keys(u).length){if(e){const e=sr(t),h=ar(u,i);if(Zn.At(e,h,n,r,o,l),Zn.Ot(e)!==JSON.stringify(h)){Zn.Lt(e,r);const i=or(s);return Zn.At(t,i,n,r,o,l),a}}Zn.At(t,u,n,r,o,l)}}catch(t){tr.Pt(t)}return a},Lt(i,e){try{null==t||t.localStorage.removeItem(i),Zn.Lt(i,e),Zn.Lt(sr(i),e)}catch(t){tr.Pt(t)}}})})(i.cookie_persisted_properties||[],i.cookieWinsOnConflict);let s,n=!1,r=!1;const o=i.persistence.toLowerCase();return"localstorage"===o&&tr.Et()?(s=tr,r=!0):"localstorage+cookie"===o&&e.Et()?(s=e,r=!0,n=!0):"sessionstorage"===o&&fr.Et()?s=fr:"memory"===o?s=cr:"cookie"===o&&Zn.Et()?(s=Zn,n=!0):e.Et()?(s=e,r=!0,n=!0):Zn.Et()?(s=Zn,n=!0):s=cr,this.jo=r,this.Bo=n,s}sl(t){return`${this.Xo}__${t}`}el(t){return this.jo&&!!t.split_storage}properties(){const t={};return Fn(this.props,(i,e)=>{const s=po(e);if(!s||"event"===s.exposure){var n;if(null==s||null===(n=s.shouldSkipFromEventProperties)||void 0===n?void 0:n.call(s,i))return;t[e]=i}}),t}load(t=!1){if(this.pi&&!t)return;const i=this.Mr.cookieWinsOnConflict&&"localstorage+cookie"===this.Mr.persistence.toLowerCase(),e=i?tr.Dt(this.Xo):null;let s={};if(i)try{s=rr(Zn.Dt(this.Xo)),Fn(s,(t,i)=>{(I(t)||A(t)||""===t)&&delete s[i]})}catch(t){}const n=this.Io.Dt(this.Xo);if(n&&(this.props=In({},n)),this.Ho&&this.El(),i&&n){var r,o;const t=null==e?void 0:e[We],i=null!==(r=null==e?void 0:e.$user_state)&&void 0!==r?r:yn,l=n[We],a=null!==(o=n.$user_state)&&void 0!==o?o:yn;if(l!==t||a!==i){this.zo=!0,fr.At(No(this.Xo),!0);const e=In({},this.props);ir.forEach(t=>delete e[t]),"anonymous"!==a||"identified"!==i&&"anonymous"!==s.$user_state&&(I(t)||l===t)||(Go(e,s),delete e[As]),this.props=e;const n=new Set;ir.forEach(t=>{var i;const e=null===(i=po(t))||void 0===i?void 0:i.storageGroup;e&&n.add(e)}),n.forEach(t=>{const i={};Fn(this.props,(e,s)=>{var n;(null===(n=po(s))||void 0===n?void 0:n.storageGroup)===t&&(i[s]=e)}),F(i)?(tr.Lt(this.sl(t)),this.qo[t]={}):tr.At(this.sl(t),i)&&(this.qo[t]={persisted:!0,fingerprint:this.dl(i,t)})})}}fr.Ot(No(this.Xo))&&(this.zo=!0)}El(){for(const t of co){const i=tr.Dt(this.sl(t));if(i&&!F(i)){const e=this.ll(t);e.persisted=!0,this.Pl(t)||(e.fingerprint=this.dl(i,t)),this.Rl(t,i)||In(this.props,i)}}}Pl(t){return Object.keys(this.props).some(i=>{var e;return(null===(e=po(i))||void 0===e?void 0:e.storageGroup)===t})}Rl(t,i){const e=Bo[t];if(!e)return!1;const s=i[e],n=this.props[e];return D(s)&&D(n)&&n>s}refreshKey(t){var i;if(this.pi)return;if("$fbc_persistence"===t&&this.Qo)return;const e=this.Ho?null===(i=po(t))||void 0===i?void 0:i.storageGroup:void 0,s=e?tr.Dt(this.sl(e)):this.Io.Dt(this.Xo);if(s&&t in s)this.fl(t,s[t],!1);else{if(e){const i=this.Io.Dt(this.Xo);if(i&&t in i)return void this.fl(t,i[t],!1)}this.pl(t,!1)}}save(){if(this.pi)return;const t=this._l();t>0?I(this.Tl)&&(this.Tl=setTimeout(()=>{this.Tl=void 0,this.Il()},t)):this.Il()}flush(){I(this.Tl)||(clearTimeout(this.Tl),this.Tl=void 0,this.Il())}Il(t=!1){if(this.pi||this.Uo&&!t)return;t||(this.syncCookieProperties(),this.Qo||this.Mr.cookieWinsOnConflict&&"localstorage+cookie"===this.Mr.persistence.toLowerCase()||this.refreshKey(Ze));const i=!t&&!this.Vo;i||(this.Zo=!1);const e=!!i&&this.gl();if(this.Zo)return void(this.Mr.debug&&je.warn("skipping persistence write because storage belongs to a different distinct ID"));if(this.Ho)return this.Al(),void(e&&this.Jo.forEach(t=>t()));const s=this.Fl(this.Io,this.Xo,this.props,Uo);"written"===s&&this.wl(this.props),"failed"!==s&&(this.Wo.clear(),this.Go=!1,this.Qo=!1),e&&this.Jo.forEach(t=>t())}Al(){const{main:t,groups:i}=this.hl(),e=this.Fl(this.Io,this.Xo,t,Uo);"written"===e&&this.wl(t),"failed"!==e&&(this.Go=!1,this.Qo=!1,Ho.forEach(t=>{var i;(null===(i=po(t))||void 0===i?void 0:i.storageGroup)||this.Wo.delete(t)}));for(const t of co){var s;const e=i[t];if(F(e)&&!(null===(s=this.qo[t])||void 0===s?void 0:s.persisted)){Ho.forEach(i=>{var e;(null===(e=po(i))||void 0===e?void 0:e.storageGroup)===t&&this.Wo.delete(i)});continue}const n=this.Fl(tr,this.sl(t),e,t);"failed"!==n&&Ho.forEach(i=>{const e=po(i);(null==e?void 0:e.storageGroup)!==t||"written"!==n&&e.volatile||this.Wo.delete(i)})}}hl(){const t={},i={flags:{},surveys:{}};return Fn(this.props,(e,s)=>{var n;const r=null===(n=po(s))||void 0===n?void 0:n.storageGroup;r?i[r][s]=e:t[s]=e}),{main:t,groups:i}}dl(t,i){if(i===Uo)return JSON.stringify(t)+"|"+this.Ol+"|"+this.Dl+"|"+this.Ll;const e={};return Fn(t,(t,i)=>{var s;e[i]=(null===(s=po(i))||void 0===s?void 0:s.volatile)?"__volatile__":t}),JSON.stringify(e)}Fl(t,i,e,s){const n=this.ll(s);if(s!==Uo&&!n.dirty&&!I(n.fingerprint))return"skipped";let r;try{if(r=this.dl(e,s),r===n.fingerprint)return n.dirty=!1,"skipped"}catch(t){r=void 0}return t.At(i,e,this.Ol,this.Dl,this.Ll,this.Mr.debug)?(n.dirty=!1,s!==Uo&&(n.persisted=!0),I(r)||(n.fingerprint=r),this.jo&&(n.storageValue=tr.Ot(i)),"written"):(this.Mr.debug&&je.warn(`failed to persist storage entry "${i}"; will retry on next save`),"failed")}remove({keepGroupEntries:t=!1}={}){if(this.yl(),I(this.Tl)||(clearTimeout(this.Tl),this.Tl=void 0),this.Io.Lt(this.Xo,!1),this.Io.Lt(this.Xo,!0),!t&&this.Ko)for(const t of co)tr.Lt(this.sl(t));t?delete this.qo[Uo]:this.qo={},this.kl=void 0,this.Sl=void 0}clear(){this.remove(),this.props={}}register_once(t,i,e){if(C(t)){this.syncCookieProperties(),I(i)&&(i="None"),this.Ol=I(e)?this.Nl:e;let s=!1;if(Fn(t,(t,e)=>{this.props.hasOwnProperty(e)&&this.props[e]!==i||(this.fl(e,t),s=!0)}),s)return this.save(),!0}return!1}register(t,i){if(C(t)){this.syncCookieProperties(),this.Ol=I(i)?this.Nl:i;let e=!1;if(Fn(t,(i,s)=>{t.hasOwnProperty(s)&&(this.props[s]!==i||C(i)||P(i))&&(this.fl(s,i),e=!0)}),e)return this.save(),!0}return!1}unregister(t){this.syncCookieProperties();const i="string"==typeof t?[t]:t;let e=!1;for(const t of i)t in this.props&&(this.pl(t),e=!0);e&&this.save()}update_campaign_params(){const t=null==s?void 0:s.URL;if(t===this.Yo)return;const i=Po(this.Mr.custom_campaign_params,this.Mr.mask_personal_data_properties,this.Mr.custom_personal_data_properties),e=!F(Mn(i));return e&&this.register(i),this.Yo=t,e?i:void 0}update_search_keyword(){this.register(function(){const t=null==s?void 0:s.referrer;return t?Co(t):{}}())}update_referrer_info(){var t;this.register_once({$referrer:Ro(),$referring_domain:(null==s?void 0:s.referrer)&&(null===(t=_o(s.referrer))||void 0===t?void 0:t.host)||Oo},void 0)}set_initial_person_info(){if(this.props.$initial_campaign_params||this.props.$initial_referrer_info)return;const t=Ao(this.Mr.mask_personal_data_properties,this.Mr.custom_personal_data_properties,this.Mr.disable_capture_url_hashes);this.register_once({[nn]:this.Bo?{r:zo(t.r),u:t.u?zo(t.u):void 0}:t},void 0)}get_initial_props(){const t={};Fn([sn,en],i=>{const e=this.props[i];e&&Fn(e,function(i,e){t["$initial_"+w(e)]=i})});const i=this.props[nn];if(i){const e=function(t,i=!1){const e=Mo(t,i),s={};return Fn(e,function(t,i){s[`$initial_${w(i)}`]=t}),s}(i,this.Mr.disable_capture_url_hashes);In(t,e)}return t}safe_merge(t){return Fn(this.props,function(i,e){e in t||(t[e]=i)}),t}update_config(t,i,e){const s=t.persistence!==i.persistence,n=!((t,i)=>{if(t.length!==i.length)return!1;const e=[...t].sort(),s=[...i].sort();return e.every((t,i)=>t===s[i])})(t.cookie_persisted_properties||[],i.cookie_persisted_properties||[]),r=s||n,o=t.cookieWinsOnConflict!==i.cookieWinsOnConflict,l=t.disable_persistence||!!e,a=!!this.pi&&!l;l||this.xl(i,a),this.Mr=t,!l&&(s||n||o)&&(this.kl=void 0,this.Sl=void 0,this.xl(wi(wi({},t),{},{cookie_persisted_properties:i.cookie_persisted_properties}),a));const u=r||o?this.tl(t):this.Io;this.ql();const h=this.el(t),d=r||h!==this.Ho,c=!l&&(d||t.cross_subdomain_cookie!==this.Dl||t.secure_cookie!==this.Ll)&&this.Cl(a);this.Vo=d;try{if(this.Nl=this.Ol=t.cookie_expiration,this.set_disabled(l),this.set_cross_subdomain(t.cross_subdomain_cookie),this.set_secure(t.secure_cookie),d){const t=this.props;this.clear(),this.Io=u,this.Ho=h,this.props=t,this.save()}else o&&(this.Io=u,l||(delete this.qo[Uo],this.Il()))}finally{this.Vo=!1,c&&this.Ml()}}ql(){const t=this.props[nn];if(!this.Bo||!C(t)||"string"!=typeof t.r)return;const i=zo(t.r),e="string"==typeof t.u?zo(t.u):t.u;i===t.r&&e===t.u||this.fl(nn,wi(wi({},t),{},{r:i,u:e}))}set_disabled(t){this.pi=t,this.pi?this.remove():this.save()}set_cross_subdomain(t){t!==this.Dl&&(this.Dl=t,this.remove({keepGroupEntries:!0}),this.save())}set_secure(t){t!==this.Ll&&(this.Ll=t,this.remove({keepGroupEntries:!0}),this.save())}set_event_timer(t,i){const e=this.props.__timers||{};e[t]=i,this.fl(Qe,e),this.save()}remove_event_timer(t){const i=this.props.__timers||{},e=i[t];return I(e)||(delete i[t],this.fl(Qe,i),this.save()),e}get_property(t){return this.props[t]}set_property(t,i){this.fl(t,i),this.save()}fl(t,i,e=!0){var s;const n=this.props[t];this.props[t]=i,e&&("distinct_id"!==t&&"$user_state"!==t||n===i||(this.Go=!0),"$fbc_persistence"!==t||Vo(n,i)||(this.Qo=!0),this.bl(t,n,i),(null===(s=po(t))||void 0===s?void 0:s.volatile)||this.ml(t))}pl(t,i=!0){delete this.props[t],i&&(qo(t)&&this.ol(t,!0),"$fbc_persistence"===t&&(this.Qo=!0),this.ml(t))}ml(t){var i;const e=null===(i=po(t))||void 0===i?void 0:i.storageGroup;e&&(this.ll(e).dirty=!0)}ll(t){return this.qo[t]||(this.qo[t]={})}};const Jo="gzip-js",Yo="base64",Xo="events",Zo="cancelEvents",Qo="survey shown",tl="survey dismissed",il="survey sent",el="$survey_last_seen_date",sl="popover";function nl(t){let i=!0;return{dispose(){if(i){i=!1;const e=t();e&&T(e.then)&&e.then(void 0,()=>{})}}}}const rl=Be("[RateLimiter]");var ol=class{constructor(t){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=t=>{const i=t.text;if(i&&i.length)try{(JSON.parse(i).quota_limited||[]).forEach(t=>{rl.info(`${t||"events"} is quota limited.`),this.serverLimits[t]=(new Date).getTime()+6e4})}catch(t){return void rl.warn(`could not rate limit - continuing. Error: "${null==t?void 0:t.message}"`,{text:i})}},this.instance=t,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var t;return(null===(t=this.instance.config.rate_limiting)||void 0===t?void 0:t.events_per_second)||10}get captureEventsBurstLimit(){var t;return Math.max((null===(t=this.instance.config.rate_limiting)||void 0===t?void 0:t.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(t=!1){var i,e,s;const{captureEventsBurstLimit:n,captureEventsPerSecond:r}=this,o=(new Date).getTime(),l=null!==(i=null===(e=this.instance.persistence)||void 0===e?void 0:e.get_property("$capture_rate_limit"))&&void 0!==i?i:{tokens:n,last:o};l.tokens+=(o-l.last)/1e3*r,l.last=o,l.tokens>n&&(l.tokens=n);const a=1>l.tokens;if(a||t||(l.tokens=Math.max(0,l.tokens-1)),a&&!t){const t=(D(l.dropped)?l.dropped:0)+1;l.dropped=t,!this.lastEventRateLimited&&this.jl(t)&&(l.dropped=0)}return this.lastEventRateLimited=a,null===(s=this.instance.persistence)||void 0===s||s.set_property("$capture_rate_limit",l),{isRateLimited:a,remainingTokens:l.tokens}}Bl(t){const i=this.instance.config.property_denylist;return!P(i)||!i.includes(t)}Hl(){var t;if(this.Bl("$current_url")&&this.Bl("$pathname")&&(null==n?void 0:n.pathname))return`${null!==(t=n.origin)&&void 0!==t?t:""}${n.pathname}`}jl(t){var i,e;const{captureEventsBurstLimit:s,captureEventsPerSecond:n}=this,r=this.Hl(),o=this.Bl("$session_id")?null===(i=(e=this.instance).get_session_id)||void 0===i?void 0:i.call(e):void 0,l=[`${t} event(s) dropped since the last warning`,r?`triggered on ${r}`:void 0,o?`session ${o}`:void 0].filter(Boolean).join(", ");return!!this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:`posthog-js client rate limited: ${l}. Config is set to ${n} events per second and ${s} events burst limit.`},{skip_client_rate_limiting:!0})}isServerRateLimited(t){const i=this.serverLimits[t||"events"]||!1;return!1!==i&&(new Date).getTime()<i}};const ll=Be("[RemoteConfig]");var al=class{constructor(t){this._instance=t}get remoteConfig(){var t;return null===(t=c._POSTHOG_REMOTE_CONFIG)||void 0===t||null===(t=t[this._instance.config.token])||void 0===t?void 0:t.config}zl(t){var i,e,s;(null===(i=c.__PosthogExtensions__)||void 0===i?void 0:i.loadExternalDependency)?null===(e=c.__PosthogExtensions__)||void 0===e||null===(s=e.loadExternalDependency)||void 0===s||s.call(e,this._instance,"remote-config",()=>t(this.remoteConfig)):t()}Ul(t){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets",`/array/${this._instance.config.token}/config`),callback:t})}load(){try{if(this.remoteConfig)return ll.info("Using preloaded remote config",this.remoteConfig),void this.Wl(this.remoteConfig);if(this._instance.Vl())return void ll.warn("Remote config is disabled. Falling back to local config.");this.zl(t=>{if(!t)return ll.info("No config found after loading remote JS config. Falling back to JSON."),void this.Ul(t=>{this.Wl(t.json,t)});this.Wl(t)})}catch(t){ll.error("Error loading remote config",t),this.Wl()}}Wl(t,i){!t&&i&&(0===i.statusCode?i.error||ll.warn("Failed to fetch remote config from PostHog."):ll.error("Failed to fetch remote config from PostHog."));try{this._instance.Wl(t?{ok:!0,config:t}:{ok:!1})}catch(t){ll.error("Error applying remote config",t)}if(!1!==(null==t?void 0:t.hasFeatureFlags)&&!this._instance.config.advanced_disable_feature_flags_on_first_load)try{var e;null===(e=this._instance.featureFlags)||void 0===e||e.ensureFlagsLoaded()}catch(t){ll.error("Error loading feature flags",t)}}},ul=Uint8Array,hl=Uint16Array,dl=Uint32Array,cl=new ul([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]),vl=new ul([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]),fl=new ul([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),pl=function(t,i){for(var e=new hl(31),s=0;31>s;++s)e[s]=i+=1<<t[s-1];var n=new dl(e[30]);for(s=1;30>s;++s)for(var r=e[s];e[s+1]>r;++r)n[r]=r-e[s]<<5|s;return[e,n]},gl=pl(cl,2),_l=gl[1];gl[0][28]=258,_l[258]=28;for(var ml=pl(vl,0)[1],bl=new hl(32768),yl=0;32768>yl;++yl){var wl=(43690&yl)>>>1|(21845&yl)<<1;bl[yl]=((65280&(wl=(61680&(wl=(52428&wl)>>>2|(13107&wl)<<2))>>>4|(3855&wl)<<4))>>>8|(255&wl)<<8)>>>1}var $l=function(t,i,e){for(var s=t.length,n=0,r=new hl(i);s>n;++n)++r[t[n]-1];var o,l=new hl(i);for(n=0;i>n;++n)l[n]=l[n-1]+r[n-1]<<1;if(e){o=new hl(1<<i);var a=15-i;for(n=0;s>n;++n)if(t[n])for(var u=n<<4|t[n],h=i-t[n],d=l[t[n]-1]++<<h,c=d|(1<<h)-1;c>=d;++d)o[bl[d]>>>a]=u}else for(o=new hl(s),n=0;s>n;++n)o[n]=bl[l[t[n]-1]++]>>>15-t[n];return o},xl=new ul(288);for(yl=0;144>yl;++yl)xl[yl]=8;for(yl=144;256>yl;++yl)xl[yl]=9;for(yl=256;280>yl;++yl)xl[yl]=7;for(yl=280;288>yl;++yl)xl[yl]=8;var Sl=new ul(32);for(yl=0;32>yl;++yl)Sl[yl]=5;var kl=$l(xl,9,0),El=$l(Sl,5,0),Pl=function(t){return(t/8|0)+(7&t&&1)},Tl=function(t,i,e){(null==i||0>i)&&(i=0),(null==e||e>t.length)&&(e=t.length);var s=new(t instanceof hl?hl:t instanceof dl?dl:ul)(e-i);return s.set(t.subarray(i,e)),s},Cl=function(t,i,e){var s=i/8|0;t[s]|=e<<=7&i,t[s+1]|=e>>>8},Fl=function(t,i,e){var s=i/8|0;t[s]|=e<<=7&i,t[s+1]|=e>>>8,t[s+2]|=e>>>16},Il=function(t,i){for(var e=[],s=0;t.length>s;++s)t[s]&&e.push({s:s,f:t[s]});var n=e.length,r=e.slice();if(!n)return[new ul(0),0];if(1==n){var o=new ul(e[0].s+1);return o[e[0].s]=1,[o,1]}e.sort(function(t,i){return t.f-i.f}),e.push({s:-1,f:25001});var l=e[0],a=e[1],u=0,h=1,d=2;for(e[0]={s:-1,f:l.f+a.f,l:l,r:a};h!=n-1;)l=e[e[d].f>e[u].f?u++:d++],a=e[u!=h&&e[d].f>e[u].f?u++:d++],e[h++]={s:-1,f:l.f+a.f,l:l,r:a};var c=r[0].s;for(s=1;n>s;++s)r[s].s>c&&(c=r[s].s);var v=new hl(c+1),f=Ol(e[h-1],v,0);if(f>i){s=0;var p=0,g=f-i,_=1<<g;for(r.sort(function(t,i){return v[i.s]-v[t.s]||t.f-i.f});n>s;++s){var m=r[s].s;if(i>=v[m])break;p+=_-(1<<f-v[m]),v[m]=i}for(p>>>=g;p>0;){var b=r[s].s;i>v[b]?p-=1<<i-v[b]++-1:++s}for(;s>=0&&p;--s){var y=r[s].s;v[y]==i&&(--v[y],++p)}f=i}return[new ul(v),f]},Ol=function(t,i,e){return-1==t.s?Math.max(Ol(t.l,i,e+1),Ol(t.r,i,e+1)):i[t.s]=e},Rl=function(t){for(var i=t.length;i&&!t[--i];);for(var e=new hl(++i),s=0,n=t[0],r=1,o=function(t){e[s++]=t},l=1;i>=l;++l)if(t[l]==n&&l!=i)++r;else{if(!n&&r>2){for(;r>138;r-=138)o(32754);r>2&&(o(r>10?r-11<<5|28690:r-3<<5|12305),r=0)}else if(r>3){for(o(n),--r;r>6;r-=6)o(8304);r>2&&(o(r-3<<5|8208),r=0)}for(;r--;)o(n);r=1,n=t[l]}return[e.subarray(0,s),i]},Al=function(t,i){for(var e=0,s=0;i.length>s;++s)e+=t[s]*i[s];return e},Ml=function(t,i,e){var s=e.length,n=Pl(i+2);t[n]=255&s,t[n+1]=s>>>8,t[n+2]=255^t[n],t[n+3]=255^t[n+1];for(var r=0;s>r;++r)t[n+r+4]=e[r];return 8*(n+4+s)},Dl=function(t,i,e,s,n,r,o,l,a,u,h){Cl(i,h++,e),++n[256];for(var d=Il(n,15),c=d[0],v=d[1],f=Il(r,15),p=f[0],g=f[1],_=Rl(c),m=_[0],b=_[1],y=Rl(p),w=y[0],x=y[1],S=new hl(19),k=0;m.length>k;++k)S[31&m[k]]++;for(k=0;w.length>k;++k)S[31&w[k]]++;for(var E=Il(S,7),P=E[0],T=E[1],C=19;C>4&&!P[fl[C-1]];--C);var F,I,O,R,A=u+5<<3,M=Al(n,xl)+Al(r,Sl)+o,D=Al(n,c)+Al(r,p)+o+14+3*C+Al(S,P)+(2*S[16]+3*S[17]+7*S[18]);if(M>=A&&D>=A)return Ml(i,h,t.subarray(a,a+u));if(Cl(i,h,1+(M>D)),h+=2,M>D){F=$l(c,v,0),I=c,O=$l(p,g,0),R=p;var j=$l(P,T,0);for(Cl(i,h,b-257),Cl(i,h+5,x-1),Cl(i,h+10,C-4),h+=14,k=0;C>k;++k)Cl(i,h+3*k,P[fl[k]]);h+=3*C;for(var B=[m,w],L=0;2>L;++L){var N=B[L];for(k=0;N.length>k;++k)Cl(i,h,j[z=31&N[k]]),h+=P[z],z>15&&(Cl(i,h,N[k]>>>5&127),h+=N[k]>>>12)}}else F=kl,I=xl,O=El,R=Sl;for(k=0;l>k;++k)if(s[k]>255){var z;Fl(i,h,F[257+(z=s[k]>>>18&31)]),h+=I[z+257],z>7&&(Cl(i,h,s[k]>>>23&31),h+=cl[z]);var U=31&s[k];Fl(i,h,O[U]),h+=R[U],U>3&&(Fl(i,h,s[k]>>>5&8191),h+=vl[U])}else Fl(i,h,F[s[k]]),h+=I[s[k]];return Fl(i,h,F[256]),h+I[256]},jl=new dl([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Bl=new ul(0),Ll=function(){for(var t=new dl(256),i=0;256>i;++i){for(var e=i,s=9;--s;)e=(1&e&&3988292384)^e>>>1;t[i]=e}return t}(),Nl=function(t,i,e){for(;e;++i)t[i]=e,e>>>=8};function zl(t,i){void 0===i&&(i={});var e=function(){var t=4294967295;return{p(i){for(var e=t,s=0;i.length>s;++s)e=Ll[255&e^i[s]]^e>>>8;t=e},d(){return 4294967295^t}}}(),s=t.length;e.p(t);var n,r,o,l,a,u,h=(l=10+((n=i).filename&&n.filename.length+1||0),a=8,function(t,i,e,s,n,r){var o=t.length,l=new ul(s+o+5*(1+Math.floor(o/7e3))+n),a=l.subarray(s,l.length-n),u=0;if(!i||8>o)for(var h=0;o>=h;h+=65535){var d=h+65535;o>d?u=Ml(a,u,t.subarray(h,d)):(a[h]=r,u=Ml(a,u,t.subarray(h,o)))}else{for(var c=jl[i-1],v=c>>>13,f=8191&c,p=(1<<e)-1,g=new hl(32768),_=new hl(p+1),m=Math.ceil(e/3),b=2*m,y=function(i){return(t[i]^t[i+1]<<m^t[i+2]<<b)&p},w=new dl(25e3),x=new hl(288),S=new hl(32),k=0,E=0,P=(h=0,0),T=0,C=0;o>h;++h){var F=y(h),I=32767&h,O=_[F];if(g[I]=O,_[F]=I,h>=T){var R=o-h;if((k>7e3||P>24576)&&R>423){u=Dl(t,a,0,w,x,S,E,P,C,h-C,u),P=k=E=0,C=h;for(var A=0;286>A;++A)x[A]=0;for(A=0;30>A;++A)S[A]=0}var M=2,D=0,j=f,B=I-O&32767;if(R>2&&F==y(h-B))for(var L=Math.min(v,R)-1,N=Math.min(32767,h),z=Math.min(258,R);N>=B&&--j&&I!=O;){if(t[h+M]==t[h+M-B]){for(var U=0;z>U&&t[h+U]==t[h+U-B];++U);if(U>M){if(M=U,D=B,U>L)break;var H=Math.min(B,U-2),q=0;for(A=0;H>A;++A){var V=h-B+A+32768&32767,W=V-g[V]+32768&32767;W>q&&(q=W,O=V)}}}B+=(I=O)-(O=g[I])+32768&32767}if(D){w[P++]=268435456|_l[M]<<18|ml[D];var G=31&_l[M],K=31&ml[D];E+=cl[G]+vl[K],++x[257+G],++S[K],T=h+M,++k}else w[P++]=t[h],++x[t[h]]}}u=Dl(t,a,r,w,x,S,E,P,C,h-C,u),r||(u=Ml(a,u,Bl))}return Tl(l,0,s+Pl(u)+n)}(r=t,null==(o=i).level?6:o.level,null==o.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(r.length)))):12+o.mem,l,a,!u)),d=h.length;return function(t,i){var e=i.filename;if(t[0]=31,t[1]=139,t[2]=8,t[8]=2>i.level?4:9==i.level?2:0,t[9]=3,0!=i.mtime&&Nl(t,4,Math.floor(new Date(i.mtime||Date.now())/1e3)),e){t[3]=8;for(var s=0;e.length>=s;++s)t[s+10]=e.charCodeAt(s)}}(h,i),Nl(h,d-8,e.d()),Nl(h,d-4,s),h}const Ul=!!o||!!r,Hl="text/plain";let ql=!1;const Vl=(t,i)=>{const[e,s]=t.split("#"),[n,r]=e.split("?");if(!r)return t;const o=r.split("&").filter(t=>t.split("=")[0]!==i).join("&");return`${n}${o?`?${o}`:""}${s?`#${s}`:""}`},Wl=(t,i,e=!0)=>{var s;const[n,r]=t.split("?"),o=wi({},i),l=null!==(s=null==r?void 0:r.split("&").map(t=>{var i;const[s,n]=t.split("="),r=e&&null!==(i=o[s])&&void 0!==i?i:n;return delete o[s],`${s}=${r}`}))&&void 0!==s?s:[],a=function(t,i="&"){let e,s;const n=[];return Fn(t,function(t,i){I(t)||I(i)||"undefined"===i||(e=encodeURIComponent((t=>t instanceof File)(t)?t.name:t.toString()),s=encodeURIComponent(i),n[n.length]=s+"="+e)}),n.join(i)}(o);return a&&l.push(a),l.length>0?`${n}?${l.join("&")}`:n},Gl=t=>{if(t.Gl)return t.Gl;const{data:i,compression:e}=t;if(!i)return;if(e===Jo){const t=zl(function(t){var i=t.length;if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(t);for(var e=new ul(t.length+(t.length>>>1)),s=0,n=function(t){e[s++]=t},r=0;i>r;++r){if(s+5>e.length){var o=new ul(s+8+(i-r<<1));o.set(e),e=o}var l=t.charCodeAt(r);128>l?n(l):2048>l?(n(192|l>>>6),n(128|63&l)):l>55295&&57344>l?(n(240|(l=65536+(1047552&l)|1023&t.charCodeAt(++r))>>>18),n(128|l>>>12&63),n(128|l>>>6&63),n(128|63&l)):(n(224|l>>>12),n(128|l>>>6&63),n(128|63&l))}return Tl(e,0,s)}(go(i)),{mtime:0});return{contentType:Hl,body:t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength),estimatedSize:t.byteLength}}if(e===Yo){const t=function(t){return t?btoa(encodeURIComponent(t).replace(/%([0-9A-F]{2})/g,(t,i)=>String.fromCharCode(parseInt(i,16)))):t}(go(i)),e=(t=>"data="+encodeURIComponent("string"==typeof t?t:go(t)))(t);return{contentType:"application/x-www-form-urlencoded",body:e,estimatedSize:new Blob([e]).size}}const s=go(i);return{contentType:"application/json",body:s,estimatedSize:new Blob([s]).size}},Kl=t=>{const i=()=>"sendBeacon"===t.transport?{url:Wl(t.url,{compression:Yo}),encodedBody:Gl(wi(wi({},t),{},{compression:Yo,Gl:void 0}))}:{url:Vl(t.url,"compression"),encodedBody:Gl(wi(wi({},t),{},{compression:void 0,Gl:void 0}))};let e;try{e=Gl(t)}catch(e){if(he(t.compression,mo(t.url,"compression")))return je.error("Failed to gzip request body, sending uncompressed payload",e),i();throw e}return e&&he(t.compression,mo(t.url,"compression"))&&!((s=e.body)instanceof ArrayBuffer?ue(new Uint8Array(s)):ArrayBuffer.isView(s)&&ue(new Uint8Array(s.buffer,s.byteOffset,s.byteLength)))?(ql=!0,i()):{url:t.url,encodedBody:e};var s},Jl=t=>{try{return Kl(t)}catch(e){var i;return je.error(e),void(null===(i=t.callback)||void 0===i||i.call(t,{statusCode:0,error:e}))}},Yl=function(){var t=Y(function*(t){const i=yield function(t){return ge.apply(this,arguments)}(go(t.data),qe.DEBUG,{rethrow:!0});if(!i)return t;const e=yield i.arrayBuffer();return wi(wi({},t),{},{Gl:{contentType:Hl,body:e,estimatedSize:e.byteLength}})});return function(i){return t.apply(this,arguments)}}(),Xl=/Failed to fetch|NetworkError|Load failed/i,Zl=t=>"TypeError"===(null==t?void 0:t.name)&&Xl.test((null==t?void 0:t.message)||""),Ql=t=>{const i=Jl(t);if(!i)return;const e=new o,{url:s,encodedBody:n}=i;e.open(t.method||"GET",s,!0);const{contentType:r,body:l}=null!=n?n:{};Fn(t.headers,function(t,i){e.setRequestHeader(i,t)}),r&&e.setRequestHeader("Content-Type",r),t.timeout&&(e.timeout=t.timeout),e.onreadystatechange=()=>{if(4===e.readyState){var i;const s={statusCode:e.status,text:e.responseText};if(200===e.status)try{s.json=JSON.parse(e.responseText)}catch(t){}null===(i=t.callback)||void 0===i||i.call(t,s)}},e.send(l)},ta=t=>{const i=Jl(t);if(!i)return;const{url:e,encodedBody:s}=i,{contentType:n,body:o,estimatedSize:a}=null!=s?s:{},u=new Headers;Fn(t.headers,function(t,i){u.append(i,t)}),n&&u.append("Content-Type",n);let h=null,d=!1;if(l){const i=new l;h={signal:i.signal,timeout:setTimeout(()=>{var e;d=!0,i.abort(ui("AbortError","PostHog request timed out"+((e=t.timeout)?` after ${e}ms`:"")))},t.timeout)}}const c=i=>{var e;d&&"AbortError"===(null==i?void 0:i.name)||Zl(i)?je.warn(i):je.error(i),null===(e=t.callback)||void 0===e||e.call(t,{statusCode:0,error:i})};try{r(e,wi({method:(null==t?void 0:t.method)||"GET",headers:u,keepalive:"POST"===t.method&&!t.Zl&&52428.8>(a||0),body:o,signal:null==h?void 0:h.signal},t.fetchOptions)).then(i=>i.text().then(e=>{var s;const n={statusCode:i.status,text:e};if(200===i.status)try{n.json=JSON.parse(e)}catch(t){je.error(t)}null===(s=t.callback)||void 0===s||s.call(t,n)})).catch(c).finally(()=>h?clearTimeout(h.timeout):null)}catch(t){h&&clearTimeout(h.timeout),c(t)}},ia=t=>{try{var i;const{url:s,encodedBody:n}=Kl(t),{contentType:o,body:l,estimatedSize:a}=null!=n?n:{};if(!l)return;const u=l instanceof Blob?l:new Blob([l],{type:o});if(e.sendBeacon(s,u))return;const h=P(t.data)?t.data:null===(i=t.data)||void 0===i?void 0:i.batch;if(P(h)&&h.length>1&&(null!=a?a:0)>16384){const i=Math.ceil(h.length/2),e=i=>P(t.data)?i:wi(wi({},t.data),{},{batch:i});return ia(wi(wi({},t),{},{data:e(h.slice(0,i))})),void ia(wi(wi({},t),{},{data:e(h.slice(i))}))}je.warn(`Beacon of ~${null!=a?a:0} bytes was rejected by the browser, falling back to ${r?"fetch":"XHR"}`),r?ta(wi(wi({},t),{},{Zl:!0})):Ql(t)}catch(t){je.warn("Beacon send failed",t)}},ea=(t,i,e,s)=>{const n="query"===s?"POST"===i?"sent_at":"_":void 0;return Wl(e===Jo?Vl(t,"compression"):t,wi(wi({},n?{[n]:Date.now().toString()}:{}),e===Jo?{}:{compression:e}))},sa=(()=>{const t=[];return r&&t.push({transport:"fetch",method:ta}),o&&t.push({transport:"XHR",method:Ql}),(null==e?void 0:e.sendBeacon)&&t.push({transport:"sendBeacon",method:ia}),t})();var na=class{constructor(t,i){this.Ql=!0,this.Jl=[],this.Kl=Q((null==i?void 0:i.flush_interval_ms)||3e3,250,5e3,je.createLogger("flush interval"),3e3),this.Yl=t}enqueue(t){this.Jl.push(t),this.Xl||this.ta()}unload(){this.ea();const t=this.Jl.length>0?this.ia():{},i=Object.values(t);[...i.filter(t=>0===t.url.indexOf("/e")),...i.filter(t=>0!==t.url.indexOf("/e"))].map(t=>{this.na(wi(wi({},t),{},{transport:"sendBeacon"}))})}enable(){this.Ql=!1,this.ta()}ta(){this.Ql||(this.Xl=setTimeout(()=>{if(this.ea(),this.Jl.length>0){const t=this.ia();for(const i in t){const e=t[i],s=(new Date).getTime();e.data&&P(e.data)&&Fn(e.data,t=>{t.offset=Math.abs(t.timestamp-s),delete t.timestamp}),this.na(e)}}},this.Kl))}na(t){try{this.Yl(t)}catch(t){je.error(t)}}ea(){clearTimeout(this.Xl),this.Xl=void 0}ia(){const t={};return Fn(this.Jl,i=>{var e;const s=i,n=(s?s.batchKey:null)||s.url;I(t[n])&&(t[n]=wi(wi({},s),{},{data:[]})),null===(e=t[n].data)||void 0===e||e.push(s.data)}),this.Jl=[],t}};const ra=["retriesPerformedSoFar"];var oa=class{constructor(t){this._instance=t,this.sa=!1,this.ra=3e3,this.Jl=[],this.Jl=[],this.oa=!0,this.resume()}resume(){if(!I(t)&&"onLine"in t.navigator){if(this.oa=t.navigator.onLine,this.la)return;this.la=()=>{this.oa=!0,this.aa()},this.ua=()=>{this.oa=!1},Ln(t,"online",this.la),Ln(t,"offline",this.ua)}}get length(){return this.Jl.length}retriableRequest(t){let{retriesPerformedSoFar:i}=t,e=_e(t,ra);j(i)&&(e.url=Wl(e.url,{retry_count:i})),this._instance._send_request(wi(wi({},e),{},{callback:t=>{var s;if(200!==t.statusCode&&(400>t.statusCode||t.statusCode>=500)){if((0===t.statusCode?3:10)>(null!=i?i:0))return void this.Is(wi({retriesPerformedSoFar:i},e));0===t.statusCode&&je.warn(`Request failed before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped retrying after ${null!=i?i:0} retries.`)}null===(s=e.callback)||void 0===s||s.call(e,t)}}))}Is(t){const i=t.retriesPerformedSoFar||0;t.retriesPerformedSoFar=i+1;const e=function(t){const i=3e3*Math.pow(2,t),e=i/2,s=Math.min(18e5,i),n=(Math.random()-.5)*(s-e);return Math.ceil(s+n)}(i),s=Date.now()+e;this.Jl.push({retryAt:s,requestOptions:t});let n=`Enqueued failed request for retry in ${e}`;navigator.onLine||(n+=" (Browser is offline)"),je.warn(n),this.sa||(this.sa=!0,this.ha())}ha(){if(this.ca&&clearTimeout(this.ca),0===this.Jl.length)return this.sa=!1,void(this.ca=void 0);this.ca=setTimeout(()=>{this.oa&&this.Jl.length>0&&this.aa(),this.ha()},this.ra)}aa(){const t=Date.now(),i=[],e=this.Jl.filter(e=>t>e.retryAt||(i.push(e),!1));if(this.Jl=i,e.length>0)for(const{requestOptions:t}of e)this.retriableRequest(t)}unload(){this.ca&&(clearTimeout(this.ca),this.ca=void 0),this.sa=!1,I(t)||(this.la&&(t.removeEventListener("online",this.la),this.la=void 0),this.ua&&(t.removeEventListener("offline",this.ua),this.ua=void 0));for(const{requestOptions:t}of this.Jl)try{this._instance._send_request(wi(wi({},t),{},{transport:"sendBeacon"}))}catch(t){je.error(t)}this.Jl=[]}},la=class{constructor(t){this._instance=t,this.da=()=>{var t,i,e,s;this.va||(this.va={});const n=this.scrollElement(),r=this.scrollY(),o=n?Math.max(0,n.scrollHeight-n.clientHeight):0,l=r+((null==n?void 0:n.clientHeight)||0),a=(null==n?void 0:n.scrollHeight)||0;this.va.lastScrollY=Math.ceil(r),this.va.maxScrollY=Math.max(r,null!==(t=this.va.maxScrollY)&&void 0!==t?t:0),this.va.maxScrollHeight=Math.max(o,null!==(i=this.va.maxScrollHeight)&&void 0!==i?i:0),this.va.lastContentY=l,this.va.maxContentY=Math.max(l,null!==(e=this.va.maxContentY)&&void 0!==e?e:0),this.va.maxContentHeight=Math.max(a,null!==(s=this.va.maxContentHeight)&&void 0!==s?s:0)}}get fa(){return this._instance.config.scroll_root_selector}getContext(){return this.va}resetContext(){const t=this.va;return setTimeout(this.da,0),t}startMeasuringScrollPosition(){Ln(t,"scroll",this.da,{capture:!0}),Ln(t,"scrollend",this.da,{capture:!0}),Ln(t,"resize",this.da)}scrollElement(){if(this.fa){const e=P(this.fa)?this.fa:[this.fa];for(const s of e){var i;const e=null==t||null===(i=t.document)||void 0===i?void 0:i.querySelector(s);if(e)return e}return}var e;return null==t||null===(e=t.document)||void 0===e?void 0:e.documentElement}pa(i){var e,s;const n="y"===i?"scrollTop":"scrollLeft";if(this.fa){const t=this.scrollElement();return t&&t[n]||0}return t?"y"===i?t.scrollY||t.pageYOffset||(null===(e=t.document)||void 0===e||null===(e=e.documentElement)||void 0===e?void 0:e.scrollTop)||0:t.scrollX||t.pageXOffset||(null===(s=t.document)||void 0===s||null===(s=s.documentElement)||void 0===s?void 0:s.scrollLeft)||0:0}scrollY(){return this.pa("y")}scrollX(){return this.pa("x")}};const aa=t=>Ao(null==t?void 0:t.config.mask_personal_data_properties,null==t?void 0:t.config.custom_personal_data_properties,null==t?void 0:t.config.disable_capture_url_hashes);var ua=class{constructor(t,i,e,s){this.je=t=>{const i=this.ga();if(i&&i.sessionId===t)return;const e={sessionId:t,props:this.ma(this._instance)};this.ya.register({[Qs]:e})},this._instance=t,this.ba=i,this.ya=e,this.ma=s||aa,this.ba.onSessionId(this.je)}ga(){return this.ya.props[Qs]}getSetOnceProps(){var t;const i=null===(t=this.ga())||void 0===t?void 0:t.props;return i?"r"in i?Mo(i,this._instance.config.disable_capture_url_hashes):{$referring_domain:i.referringDomain,$pathname:i.initialPathName,utm_source:i.utm_source,utm_campaign:i.utm_campaign,utm_medium:i.utm_medium,utm_content:i.utm_content,utm_term:i.utm_term}:{}}getSessionProps(){const t={};return Fn(Mn(this.getSetOnceProps()),(i,e)=>{"$current_url"===e&&(e="url"),t[`$session_entry_${w(e)}`]=i}),t}},ha=class{on(t,i){return this._a[t]||(this._a[t]=[]),this._a[t].push(i),()=>{this._a[t]=this._a[t].filter(t=>t!==i)}}emit(t,i){for(const e of this._a[t]||[])e(i);for(const e of this._a["*"]||[])e(t,i)}constructor(){this._a={}}};const da=Be("[SessionId]"),ca=864e5;var va=class{on(t,i){return this.wa.on(t,i)}constructor(t,i,e){var s;if(this.ka=null,this.Sa=null,this.xa=[],this.Ca=void 0,this.$a=!1,this.wa=new ha,this.Ta=(t,i)=>!(!j(t)||!j(i))&&Math.abs(t-i)>this.sessionTimeoutMs,!t.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if("always"===t.config.cookieless_mode)throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this.Mr=t.config,this.ya=t.persistence,this.Be=void 0,this.Xt=void 0,this._sessionStartTimestamp=null,this.Ia=void 0,this._sessionActivityTimestamp=null,this.Ma=i||Gn,this.Ea=e||Gn;const n=this.Mr.persistence_name||this.Mr.token;if(this._sessionTimeoutMs=1e3*Q(this.Mr.session_idle_timeout_seconds||1800,60,36e3,da.createLogger("session_idle_timeout_seconds"),1800),t.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.Pa(),this.Ra="ph_"+n+"_window_id",this.Aa="ph_"+n+"_primary_window_exists",this.Fa()){const t=fr.Dt(this.Ra),i=fr.Dt(this.Aa);t&&!i?this.Be=t:fr.Lt(this.Ra),fr.At(this.Aa,!0)}(null===(s=this.Mr.bootstrap)||void 0===s?void 0:s.sessionID)&&this.setBootstrapSessionId(this.Mr.bootstrap.sessionID),this.Oa()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(t){return I(this.xa)&&(this.xa=[]),this.xa.push(t),this.Xt&&t(this.Xt,this.Be),()=>{this.xa=this.xa.filter(i=>i!==t)}}Fa(){return"memory"!==this.Mr.persistence&&!this.ya.pi&&fr.Et()}Da(t){t!==this.Be&&(this.Be=t,this.Fa()&&fr.At(this.Ra,t))}La(){return this.Be?this.Be:this.Fa()?fr.Dt(this.Ra):null}Na(t){const i=this.ka;return!A(i)&&!A(t)&&5e3>Math.abs(t-i)}qa(t,i,e){const s=i!==this._sessionActivityTimestamp,n=!(t!==this.Xt||e!==this._sessionStartTimestamp);this._sessionStartTimestamp=e,this._sessionActivityTimestamp=i,this.Xt=t,n&&!s||n&&this.Na(i)||(this.ka=i,this.ya.register({[_s]:[i,t,e]}))}ja(){var t;const i=null===(t=this.Mr)||void 0===t?void 0:t.persistence_save_debounce_ms;return j(i)&&i>0}Ba(){this.ja()?this.ya.refreshKey(_s):(this.ya.flush(),this.ya.load())}Ha(){var t;if(A(this._sessionActivityTimestamp)||this._sessionActivityTimestamp===this.ka)return;this.Ba();const[,i,e]=this.za();i===this.Xt&&e===this._sessionStartTimestamp&&(this.ka=this._sessionActivityTimestamp,this.ya.register({[_s]:[this._sessionActivityTimestamp,null!==(t=this.Xt)&&void 0!==t?t:null,this._sessionStartTimestamp]}),this.ya.flush())}Ua(){const[t]=this.za(),i=j(t)?t:0,e=j(this._sessionActivityTimestamp)?this._sessionActivityTimestamp:0;return Math.max(i,e)}Wa(t){return this.Ba(),this.Ta(t,this.Ua())}za(){const t=this.ya.props[_s];return P(t)&&2===t.length&&t.push(t[0]),t||[0,null,0]}resetSessionId(){this.ka=null,this.Ia=void 0,clearTimeout(this.Va),this.Va=void 0,this.qa(null,null,null)}setBootstrapSessionId(t,i=!1){const e=((t,i=(new Date).getTime())=>{try{const e=(t=>{const i=t.replace(/-/g,"");if(32!==i.length)throw new Error("Not a valid UUID");if("7"!==i[12])throw new Error("Not a UUIDv7");return parseInt(i.substring(0,12),16)})(t);return e>i+6e4?void da.error("Bootstrap sessionID cannot be in the future"):e}catch(t){return void da.error("Invalid sessionID in bootstrap",t)}})(t);return!I(e)&&(i?this.Ia={sessionId:t,sessionStartTimestamp:e}:this.qa(t,(new Date).getTime(),e),!0)}destroy(){this.$a=!0,this.Ha(),clearTimeout(this.Va),this.Va=void 0,this.Ca&&t&&(t.removeEventListener(Sn,this.Ca,{capture:!1}),this.Ca=void 0),this.xa=[]}Oa(){this.Ca=()=>{this.Ha(),this.Fa()&&fr.Lt(this.Aa)},Ln(t,Sn,this.Ca,{capture:!1})}checkAndGetSessionAndWindowId(t=!1,i=null,e=!1){if("always"===this.Mr.cookieless_mode)throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');const s=i||(new Date).getTime(),n=this.Xt;if(e)this.Sa=s;else if(A(this.Sa)||this.Sa>s||s-this.Sa>=1e3){var r,o;null===(r=(o=this.ya).syncCookieProperties)||void 0===r||r.call(o),this.Sa=s}let[,l,a]=this.za();const u=!I(n)&&l!==n,h=this.Ua();let d=this.La();const c=this.Ia,v=!!c&&(c.sessionStartTimestamp>s+6e4||s-c.sessionStartTimestamp>ca),f=c?v:j(a)&&Math.abs(s-a)>ca;let p=!1,g=u;const _=!l||!!c,m=l;let b=!_&&!t&&this.Ta(s,h);if(b&&(b=this.Wa(s),b||da.info("cross-tab refresh kept the session alive",{sessionId:l}),[,l,a]=this.za()),_||b||f){g=!1;const t=c&&!v;l=t?c.sessionId:this.Ma(),d=this.Ea(),da.info("new session ID assigned",{sessionId:l,windowId:d,bootstrapped:!!t,changeReason:{noSessionId:_,activityTimeout:b,sessionPastMaximumLength:f}}),a=t?c.sessionStartTimestamp:s,this.Ia=void 0,p=!0}else d||(d=this.Ea(),p=!0),g=g||l!==m,g&&(da.info("adopted cross-tab session id",{sessionId:l,windowId:d}),p=!0);const y=j(h)&&t&&!f?h:s,w=j(a)?a:(new Date).getTime();this.Da(d),this.qa(l,y,w),t||this.Pa();const x={noSessionId:_,activityTimeout:b,sessionPastMaximumLength:f,crossTabAdoption:g};return p&&this.xa.forEach(t=>t(l,d,x)),{sessionId:l,windowId:d,sessionStartTimestamp:w,changeReason:p?x:void 0,lastActivityTimestamp:h}}Pa(){this.$a||(clearTimeout(this.Va),this.Va=setTimeout(()=>{if(!this.$a)if(this.Wa((new Date).getTime())){const t=this.Xt;this.resetSessionId(),this.wa.emit("forcedIdleReset",{idleSessionId:t})}else this.Pa()},1.1*this.sessionTimeoutMs))}};const fa=function(t,i){if(!t)return!1;const e=t.userAgent;if(e&&Z(e,i))return!0;try{const e=null==t?void 0:t.userAgentData;if((null==e?void 0:e.brands)&&e.brands.some(t=>Z(null==t?void 0:t.brand,i)))return!0}catch(t){}return!!t.webdriver};function pa(){return(pa=Y(function*(){const t=null==e?void 0:e.userAgentData;if(null==t?void 0:t.getHighEntropyValues)try{const i=yield t.getHighEntropyValues(["model"]),e=null==i?void 0:i.model;return O(e)&&e.length>0?e:void 0}catch(t){return void je.info("Unable to resolve $device_model from userAgentData.getHighEntropyValues",t)}})).apply(this,arguments)}function ga(t,i){let e=`$survey_${i}/${t.id}`;return t.current_iteration&&t.current_iteration>0&&(e=`$survey_${i}/${t.id}/${t.current_iteration}`),e}function _a(t){var i;return!!(null===(i=t.conditions)||void 0===i||null===(i=i.events)||void 0===i||null===(i=i.values)||void 0===i?void 0:i.length)}const ma=(t,i)=>{if(!(t=>{try{new RegExp(t)}catch(t){return!1}return!0})(i))return!1;try{return new RegExp(i).test(t)}catch(t){return!1}},ba=t=>t.toLowerCase(),ya={exact:(t,i)=>i.some(i=>t.some(t=>i===t)),is_not:(t,i)=>i.every(i=>t.every(t=>i!==t)),regex:(t,i)=>i.some(i=>t.some(t=>ma(i,t))),not_regex:(t,i)=>i.every(i=>t.every(t=>!ma(i,t))),icontains:(t,i)=>i.map(ba).some(i=>t.map(ba).some(t=>i.includes(t))),not_icontains:(t,i)=>i.map(ba).every(i=>t.map(ba).every(t=>!i.includes(t))),gt:(t,i)=>i.some(i=>{const e=parseFloat(i);return!isNaN(e)&&t.some(t=>e>parseFloat(t))}),lt:(t,i)=>i.some(i=>{const e=parseFloat(i);return!isNaN(e)&&t.some(t=>e<parseFloat(t))})};function wa(t,i){return!t||Object.entries(t).every(([t,e])=>{const s=null==i?void 0:i[t];if(null==s)return!1;const n=ya[e.operator];return!!n&&n(e.values,[String(s)])})}function $a(t,i,e){return go({distinct_id:t,userPropertiesToSet:i,userPropertiesToSetOnce:e})}const xa="custom",Sa="i.posthog.com",ka=/^\/static\//,Ea=["/s/","/e/","/i/"];var Pa=class{constructor(t){this.Ga={},this.instance=t}get apiHost(){const t=this.instance.config.api_host.trim().replace(/\/$/,"");return"https://app.posthog.com"===t?"https://us.i.posthog.com":t}get flagsApiHost(){const t=this.instance.config.flags_api_host;return t?t.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var t;let i=null===(t=this.instance.config.ui_host)||void 0===t?void 0:t.replace(/\/$/,"");return i||(i=this.apiHost.replace(`.${Sa}`,".posthog.com")),"https://app.posthog.com"===i?"https://us.posthog.com":i}get region(){return this.Ga[this.apiHost]||(this.Ga[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":xa),this.Ga[this.apiHost]}Za(t){if(!ka.test(t))return;const i=this.instance.config.asset_host;return"string"==typeof i&&i.trim().replace(/\/$/,"")||void 0}Qa(t){const i=_o(t);return i?i.protocol+"//"+i.host+i.pathname:void 0}Ja(t,i,e){if("ui"===t)return e;let s=e;const n=this.instance.config.rewriteRequestPath;if(n){var r;const t=(null===(r=_o(e))||void 0===r?void 0:r.href)||e;s=n(new URL(t)).toString()}if(n&&"api"===t&&Ea.some(t=>0===i.indexOf(t))){const t=this.Qa(s);if(t){const i=this.apiHost;let e=this.Ka;(null==e?void 0:e.apiHost)===i&&e.rewriteRequestPath===n||(e={apiHost:i,rewriteRequestPath:n,urls:new Set},this.Ka=e),e.urls.add(t)}}return s}isIngestionEndpoint(t){const i=this.Ka,e=this.Qa(t);return(null==i?void 0:i.apiHost)===this.apiHost&&i.rewriteRequestPath===this.instance.config.rewriteRequestPath&&!!e&&i.urls.has(e)}endpointFor(t,i=""){if(i&&(i="/"===i[0]?i:`/${i}`),"ui"===t)return this.Ja(t,i,this.uiHost+i);if("flags"===t)return this.Ja(t,i,this.flagsApiHost+i);if("assets"===t){const e=this.Za(i);if(e)return this.Ja(t,i,`${e}${i}`)}if(this.region===xa)return this.Ja(t,i,this.apiHost+i);const e=Sa+i;switch(t){case"assets":return this.Ja(t,i,`https://${this.region}-assets.${e}`);case"api":return this.Ja(t,i,`https://${this.region}.${e}`)}}};const Ta=Be("[Surveys]"),Ca=t=>{try{const i=(t=>((t,i)=>`seenSurvey_${function(t){return t.current_iteration&&t.current_iteration>0?`${t.id}_${t.current_iteration}`:t.id}(i)}`)(0,t))(t);if(localStorage.getItem(i))return;localStorage.setItem(i,"true")}catch(t){Ta.error("Failed to persist survey seen state",t)}},Fa=["popover","widget","api"],Ia={ignoreConditions:!1,ignoreDelay:!1,displayType:sl},Oa=Be("[PostHog ExternalIntegrations]"),Ra={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};var Aa=class{constructor(t){this._instance=t}Ro(t,i){var e,s;null===(e=c.__PosthogExtensions__)||void 0===e||null===(s=e.loadExternalDependency)||void 0===s||s.call(e,this._instance,t,t=>{if(t)return Oa.error("failed to load script",t);i()})}startIfEnabledOrStop(){var t;for(const[n,r]of Object.entries(null!==(t=this._instance.config.integrations)&&void 0!==t?t:{})){var i,e,s;r&&!(null===(i=c.__PosthogExtensions__)||void 0===i||null===(i=i.integrations)||void 0===i?void 0:i[n])&&this.Ro(Ra[n],()=>{var t;null===(t=c.__PosthogExtensions__)||void 0===t||null===(t=t.integrations)||void 0===t||null===(t=t[n])||void 0===t||t.start(this._instance)}),!r&&(null===(e=c.__PosthogExtensions__)||void 0===e||null===(e=e.integrations)||void 0===e?void 0:e[n])&&(null===(s=c.__PosthogExtensions__)||void 0===s||null===(s=s.integrations)||void 0===s||null===(s=s[n])||void 0===s||s.stop())}}},Ma=class{constructor(t,i){this.$=t,this.uo=i,this.Ya=new Map,this.mo=!1}add(t){var i=this;return Y(function*(){if(i.mo)throw new Error("Cannot add an extension to a disposed ExtensionRuntime");if(i.Ya.has(t.name))throw new Error(`Browser extension "${t.name}" is already registered`);i.Ya.set(t.name,t);try{const e=t.setup(i.uo);e&&(yield e)}catch(e){const s=i.Ya.get(t.name)===t;s&&i.Ya.delete(t.name),i.$.error(`Failed to set up browser extension "${t.name}"`,e),s&&i.Xa(t)}})()}getExtension(t){return this.Ya.get(t)}dispose(){if(this.mo)return;this.mo=!0;const t=Array.from(this.Ya.values()).reverse();this.Ya.clear();for(const i of t)this.Xa(i)}Xa(t){try{var i;const e=null===(i=t.dispose)||void 0===i?void 0:i.call(t);e&&T(e.then)&&e.then(void 0,i=>{this.$.error(`Failed to dispose browser extension "${t.name}"`,i)})}catch(i){this.$.error(`Failed to dispose browser extension "${t.name}"`,i)}}},Da=class{constructor(t){this._instance=t}initialize(){}get(t){const i=this._instance.persistence;if("string"==typeof t)return null==i?void 0:i.get_property(t);const e={};for(const s of t){const t=null==i?void 0:i.get_property(s);I(t)||(e[s]=t)}return e}set(t,i){var e;null===(e=this._instance.persistence)||void 0===e||e.register("string"==typeof t?{[t]:i}:t)}remove(t){var i;null===(i=this._instance.persistence)||void 0===i||i.unregister(t)}};const ja="extensionsRemoteConfig";var Ba=class{constructor(t){this.instance=t,this.mo=!1,this.$=je,this.tu=t.eu,this.kv=new Da(t),this.onEvent=t=>nl(this.instance.on("eventCaptured",i=>{try{t({event:i.event,properties:i.properties})}catch(t){this.$.error("Browser extension event listener failed",t)}})),this.onRemoteConfig=t=>{if(this.mo)return nl(()=>{});const i=i=>{try{t(i)}catch(t){this.$.error("Browser extension remote config listener failed",t)}},e=this.instance.iu.on(ja,i);return this.tu&&i(this.tu),nl(e)},this.nu=new Ma(je.createLogger("[BrowserExtensions]"),this)}get logger(){return this.$}get distinctId(){return this.instance.get_distinct_id()}get anonymousId(){var t;return null!==(t=this.instance.get_property("$device_id"))&&void 0!==t?t:this.distinctId}get deviceId(){const t=this.instance.get_property(Ge);return"string"==typeof t?t:void 0}get library(){return{name:qe.LIB_NAME,version:qe.LIB_VERSION}}get initialPersonProperties(){var t,i;return null!==(t=null===(i=this.instance.persistence)||void 0===i?void 0:i.get_initial_props())&&void 0!==t?t:{}}get groups(){return this.instance.getGroups()}get session(){try{var t,i,e,s;const n=null===(t=this.instance.sessionManager)||void 0===t?void 0:t.checkAndGetSessionAndWindowId(!0);return{sessionId:null!==(i=null==n?void 0:n.sessionId)&&void 0!==i?i:"",windowId:null!==(e=null==n?void 0:n.windowId)&&void 0!==e?e:"",sessionStartTimestamp:null!==(s=null==n?void 0:n.sessionStartTimestamp)&&void 0!==s?s:0}}catch(t){return{sessionId:"",windowId:"",sessionStartTimestamp:0}}}get canCapture(){return this.instance.is_capturing()}get projectToken(){return this.instance.config.token}add(t){return this.nu.add(t)}getExtension(t){return this.nu.getExtension(t)}capture(t,i,e){var s=this;return Y(function*(){e?s.instance.capture(t,i,{timestamp:e.timestamp,uuid:e.uuid,$set:e.set,$set_once:e.setOnce}):s.instance.capture(t,i)})()}registerDynamicEventProperties(t){return nl(this.instance.su(t))}handleRemoteConfig(t){this.mo||(this.tu=t,this.instance.iu.emit(ja,t))}sendRequest(t){var i=this;return Y(function*(t,e={}){var s;const n=i.instance.requestRouter.endpointFor(null!==(s=e.target)&&void 0!==s?s:"api",t),r={method:e.method,url:e.query?Wl(n,e.query):n,data:e.body,headers:e.headers,timeout:e.timeoutMs,fireCallbackOnDrop:!0,transport:e.transport,compression:e.compression,compressionFallback:"flags"===e.target&&"best-available"===e.compression?g.Base64:void 0,timestampMode:e.sentAt};return"sendBeacon"===e.transport?(i.instance._send_request(r),{statusCode:202}):new Promise(t=>{r.callback=t,i.instance._send_request(r)})}).apply(this,arguments)}dispose(){this.mo||(this.mo=!0,this.nu.dispose())}};const La={};let Na=0;const za=()=>{},Ua='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',Ha="Surveys module not available",qa="sanitize_properties is deprecated. Use before_send instead",Va="Invalid value for property_denylist config: ",Wa=/^[A-Za-z0-9_-]{1,400}$/,Ga=/^fb\.[0-9]+\.[0-9]+\.[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)?$/,Ka=["token","distinct_id",ln],Ja="posthog";let Ya=!Ul&&-1===(null==u?void 0:u.indexOf("MSIE"))&&-1===(null==u?void 0:u.indexOf("Mozilla"));const Xa=t=>{const i={};return t&&"unset"!==t?("2025-11-30">t||(i.strictMinimumDuration=!0),"2026-05-30">t||(i.canvasCapture={resolutionScale:.6}),"2026-06-25">t||(i.streamNetworkBody=!0),"2026-08-30">t||(i.captureJsonLd=!0),i):i},Za=i=>{var e;return wi({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,asset_host:null,token:"",autocapture:!0,cross_subdomain_cookie:Bn(null==s?void 0:s.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:za,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:null!=i?i:"unset",__preview_deferred_init_extensions:!1,__preview_external_dependency_versioned_paths:!1,__preview_cookie_wins_on_conflict:!1,debug:n&&O(null==n?void 0:n.search)&&-1!==n.search.indexOf("__posthog_debug=true")||!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:"https:"===(null==t||null===(e=t.location)||void 0===e?void 0:e.protocol),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(t){je.error("Bad HTTP status: "+t.statusCode+" "+t.text)},get_device_id:t=>t,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:$n,before_send:void 0,get_current_url:void 0,request_queue_config:{flush_interval_ms:3e3},error_tracking:{},_onCapture:za},(t=>({rageclick:t&&t>="2026-05-30"?{content_ignorelist:Ar,ignore_text_selection:!0}:!t||"2025-11-30">t||{content_ignorelist:!0},capture_pageview:!t||"2025-05-24">t||"history_change",session_recording:Xa(t),external_scripts_inject_target:t&&t>="2026-01-30"?"head":"body",internal_or_test_user_hostname:t&&t>="2026-01-30"?/^(localhost|127\.0\.0\.1)$/:void 0,persistence_save_debounce_ms:t&&t>="2026-05-30"?250:0,split_storage:!(!t||"2026-05-30">t),detect_google_search_app:!(!t||"2026-05-30">t),disable_capture_url_hashes:!(!t||"2026-06-25">t),cookieWinsOnConflict:!(!t||"unset"===t||"2026-08-29">t)}))(i))},Qa=[["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"]],tu=t=>{const i={};for(const[e,s]of Qa)I(t[e])||(i[s]=t[e]);const e=In({},i,t),s=t.__preview_external_dependency_versioned_paths;return I(s)||(I(t.strict_script_versioning)&&(e.strict_script_versioning=!!s),O(s)&&I(t.asset_host)&&(e.asset_host=s)),P(t.property_blacklist)&&(I(t.property_denylist)?e.property_denylist=t.property_blacklist:P(t.property_denylist)?e.property_denylist=[...t.property_blacklist,...t.property_denylist]:je.error(Va+t.property_denylist)),e};var iu=class{constructor(){this.__forceAllowLocalhost=!1}get ru(){return this.__forceAllowLocalhost}set ru(t){je.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=t}},eu=class i{ou(t){if(!t)return;const i=this.Ya.indexOf(t);-1!==i&&this.Ya.splice(i,1)}lu(t,i){var e;return this.ou(t),this.Ya.push(i),null===(e=i.initialize)||void 0===e||e.call(i),i}au(){return"always"===this.config.cookieless_mode||"on_reject"===this.config.cookieless_mode&&this.consent.isRejected()}uu(){if(this.hu)return;if(this.config.reuseAnonymousId)return;if(this.config.segment)return;if(this.au())return;const t="memory"===this.config.persistence||"sessionStorage"===this.config.persistence;if(!t&&!this.config.disable_persistence)return;if(this.cu)return;let i,e,s;t?(i=`persistence is set to '${this.config.persistence}'`,e="memory"===this.config.persistence?"on every page load":"for every new browser tab or window",s="Either set persistence to 'localStorage+cookie', keep this persistence and pass a stable ID through bootstrap.distinctID, or enable reuseAnonymousId."):(i="persistence is disabled (disable_persistence is true)",e="on every page load",s="Either set disable_persistence to false, keep persistence disabled and pass a stable ID through bootstrap.distinctID, or enable reuseAnonymousId."),this.hu=!0,console.warn("[PostHog.js]",`${i} but no bootstrap.distinctID was provided. PostHog will mint a new distinct ID ${e}, 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. ${s}`)}du(){if(this.au()||"$posthog_cookieless"!==this.get_distinct_id())return;const t=this.persistence;if(!t)return;this.vu()||t.load(!0);const i=this.get_distinct_id();if(!i||"$posthog_cookieless"===i){const i=this.config.get_device_id(Gn());this.register({distinct_id:i,$device_id:i}),t.set_property(Zs,yn)}this.fu()}get decideEndpointWasHit(){var t,i;return null!==(t=null===(i=this.featureFlags)||void 0===i?void 0:i.hasLoadedFlags)&&void 0!==t&&t}get flagsEndpointWasHit(){var t,i;return null!==(t=null===(i=this.featureFlags)||void 0===i?void 0:i.hasLoadedFlags)&&void 0!==t&&t}constructor(){var t;this.pu=!1,this.gu=!1,this.webPerformance=new iu,this.mu=!1,this.version=qe.LIB_VERSION,this.yu=new Set,this.bu="",this.iu=new ha,this.Ya=[],this._u=[],this.cu=!1,this.hu=!1,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=Za(),this.SentryIntegration=uo,this.sentryIntegration=t=>function(t,i){const e=ao(t,i);return{name:lo,processEvent:t=>e(t)}}(this,t),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.wu=!1,this.ku=null,this.Su=null,this.xu=null,this.scrollManager=new la(this),this.pageViewManager=new ho(this),this.rateLimiter=new ol(this),this.requestRouter=new Pa(this),this.consent=new pr(this),this.externalIntegrations=new Aa(this);const e=null!==(t=i.__defaultExtensionClasses)&&void 0!==t?t:{};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:(t,i,e)=>{const s=O(t)?{[t]:i}:t;this.setPersonProperties(s),null==e||e({})},set_once:(t,i,e)=>{const s=O(t)?{[t]:i}:t;this.setPersonProperties(void 0,s),null==e||e({})}},this.on("eventCaptured",t=>je.info(`send "${null==t?void 0:t.event}"`,t))}init(t,e,s){if(s&&s!==Ja){var n;const r=null!==(n=La[s])&&void 0!==n?n:new i;return r._init(t,e,s),La[s]=r,La[Ja][s]=r,r}return this._init(t,e,s)}_init(i,e={},s){var n,r,o;const l=O(i)?i.trim():"";if(!l)return je.critical("PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()"),this;var a;if(this.__loaded)return l!==(null===(a=this.config)||void 0===a?void 0:a.token)?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('${l}', { ... }, 'project2')`):console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config=Za(e.defaults),e.debug=this.Cu(e.debug),this.$u=e,this.Tu=[],e.person_profiles?this.Su=e.person_profiles:e.process_person&&(this.Su=e.process_person);const u=Za(e.defaults),h=tu(e),d=In({},u,h,{name:s,token:l});C(u.rageclick)&&C(h.rageclick)&&(d.rageclick=In({},u.rageclick,h.rageclick)),C(u.session_recording)&&C(h.session_recording)&&(d.session_recording=In({},u.session_recording,h.session_recording)),this.set_config(d),this.config.on_xhr_error&&je.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=e.disable_compression?void 0:Jo;const c=this.vu();if(this.persistence=new Ko(this.config,c),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new Ko(wi(wi({},this.config),{},{persistence:"sessionStorage"}),c,!1),this.bu="ph_"+(this.config.persistence_name||this.config.token)+"_session_registered_properties","memory"!==this.config.persistence&&!c&&fr.Et()){const t=fr.Dt(this.bu);P(t)&&t.forEach(t=>{O(t)&&this.yu.add(t)})}else fr.Lt(this.bu);const v=wi({},this.persistence.props),f=wi({},this.sessionPersistence.props);this.register({$initialization_time:(new Date).toISOString()}),this.Iu=new na(t=>this.Mu(t),this.config.request_queue_config),this.Eu=new oa(this),this.__request_queue=[];const p=this.au();p||(this.sessionManager=new va(this),this.sessionPropsManager=new ua(this,this.sessionManager,this.persistence),this.sessionManager.onSessionId((t,i,e)=>{((null==e?void 0:e.activityTimeout)||(null==e?void 0:e.sessionPastMaximumLength)||(null==e?void 0:e.crossTabAdoption))&&this.Pu()})),this.Ru(),this.config.__preview_deferred_init_extensions?(je.info("Deferring extension initialization to improve startup performance"),setTimeout(()=>{this.Au(p)},0)):(je.info("Initializing extensions synchronously"),this.Au(p)),qe.DEBUG=qe.DEBUG||this.config.debug,qe.DEBUG&&je.info("Starting in debug mode",{this:this,config:e,thisC:wi({},this.config),p:v,s:f}),this.config.identity_distinct_id&&!(null===(n=e.bootstrap)||void 0===n?void 0:n.distinctID)&&(e.bootstrap=wi(wi({},e.bootstrap),{},{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0}));const g=null===(r=e.bootstrap)||void 0===r?void 0:r.distinctID;if(this.cu=!!g&&!R(g),null===(o=e.bootstrap)||void 0===o?void 0:o.distinctID){const t=e.bootstrap.distinctID,i=this.get_distinct_id(),s=this.persistence.get_property(Zs);if(e.bootstrap.isIdentifiedID&&null!=i&&i!==t&&"anonymous"===s)this.identify(t);else if(e.bootstrap.isIdentifiedID&&null!=i&&i!==t&&"identified"===s)je.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{const i=this.config.get_device_id(Gn()),s=e.bootstrap.isIdentifiedID?i:t;this.persistence.set_property(Zs,e.bootstrap.isIdentifiedID?wn:yn),this.register({distinct_id:t,$device_id:s})}}if(p)this.register_once({distinct_id:on,$device_id:null},"");else if(!this.get_distinct_id()){const t=this.config.get_device_id(Gn());this.register_once({distinct_id:t,$device_id:t},""),this.persistence.set_property(Zs,yn)}return Ln(t,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),Ln(t,"pageshow",()=>{var t;this.pu=!1,this.gu||null===(t=this.Eu)||void 0===t||t.resume()}),e.segment?oo(this,()=>this.Fu()):this.Fu(),T(this.config._onCapture)&&this.config._onCapture!==za&&(je.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",t=>this.config._onCapture(t.event,t))),this.config.ip&&je.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 pa.apply(this,arguments)}().then(t=>{t&&this.register({[Ke]:t})}).catch(za),this}Ou(t){const i=t;return O(i.name)&&T(i.setup)}Du(t,i){this.Ou(t)?i.push(()=>{this.Lu().add(t).catch(()=>{var i;return null===(i=t.dispose)||void 0===i?void 0:i.call(t)}).catch(i=>{je.error(`Failed to dispose browser extension "${t.name}"`,i)})}):this.Ya.push(t)}Ru(){var t,e,s;const n=null!==(t=null===(e=this.config.__extensionClasses)||void 0===e?void 0:e.featureFlags)&&void 0!==t?t:null===(s=i.__defaultExtensionClasses)||void 0===s?void 0:s.featureFlags;var r,o,l;n&&(this.featureFlags&&this.featureFlags instanceof n||(null===(r=this.Nu)||void 0===r||r.call(this),this.Nu=void 0,this.featureFlags=new n(this)),T(this.featureFlags.onReloading)&&T(this.featureFlags.setup)?this.Nu||(this.Nu=this.featureFlags.onReloading(()=>{this.iu.emit("featureFlagsReloading",!0)}),this.Lu().add(this.featureFlags)):null===(o=(l=this.featureFlags).initialize)||void 0===o||o.call(l))}Au(t){const e=performance.now(),s=wi(wi({},i.__defaultExtensionClasses),this.config.__extensionClasses),n=[];var r,o,l,a,u,h,d;s.exceptions&&this.Ya.push(this.exceptions=null!==(r=this.exceptions)&&void 0!==r?r:new s.exceptions(this)),s.historyAutocapture&&this.Ya.push(this.historyAutocapture=new s.historyAutocapture(this)),s.tracingHeaders&&this.Ya.push(this.tracingHeaders=new s.tracingHeaders(this)),s.siteApps&&this.Ya.push(this.siteApps=new s.siteApps(this)),s.sessionRecording&&!t&&this.Ya.push(this.sessionRecording=new s.sessionRecording(this)),this.config.disable_scroll_properties||n.push(()=>{this.scrollManager.startMeasuringScrollPosition()}),s.autocapture&&this.Du(this.autocapture=new s.autocapture(this),n),s.surveys&&this.Du(this.surveys=null!==(o=this.surveys)&&void 0!==o?o:new s.surveys(this),n),s.logs&&this.Du(this.logs=null!==(l=this.logs)&&void 0!==l?l:new s.logs(this),n),s.metrics&&this.Ya.push(this.metrics=null!==(a=this.metrics)&&void 0!==a?a:new s.metrics(this)),s.conversations&&this.Ya.push(this.conversations=null!==(u=this.conversations)&&void 0!==u?u:new s.conversations(this)),s.productTours&&this.Ya.push(this.productTours=new s.productTours(this)),s.heatmaps&&this.Ya.push(this.heatmaps=new s.heatmaps(this)),s.webVitalsAutocapture&&this.Ya.push(this.webVitalsAutocapture=new s.webVitalsAutocapture(this)),s.exceptionObserver&&this.Ya.push(this.exceptionObserver=new s.exceptionObserver(this)),s.deadClicksAutocapture&&this.Ya.push(this.deadClicksAutocapture=new s.deadClicksAutocapture(this,so)),s.toolbar&&this.Ya.push(this.toolbar=null!==(h=this.toolbar)&&void 0!==h?h:new s.toolbar(this)),s.experiments&&this.Ya.push(this.experiments=null!==(d=this.experiments)&&void 0!==d?d:new s.experiments(this)),this.Ya.forEach(t=>{t.initialize&&n.push(()=>{var i;null===(i=t.initialize)||void 0===i||i.call(t)})}),n.push(()=>{if(this.qu){const t=this.qu;this.qu=void 0,this.Ya.forEach(i=>{var e;return null===(e=i.onRemoteConfig)||void 0===e?void 0:e.call(i,t)})}}),this.ju(n,e)}ju(t,i){for(;t.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-i>=30&&t.length>0)return void setTimeout(()=>{this.ju(t,i)},0);const e=t.shift();if(e)try{e()}catch(t){je.error("Error initializing extension:",t)}}const e=Math.round(performance.now()-i);this.register_for_session({[an]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[un]:e}),this.config.__preview_deferred_init_extensions&&je.info(`PostHog extensions initialized (${e}ms)`)}Wl(t){var i;if(!s||!s.body)return je.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout(()=>{this.Wl(t)},500);if(this.config.__preview_deferred_init_extensions&&(this.qu=t),this.eu=t,this.compression=void 0,t.ok){var e;const i=t.config;i.supportedCompression&&!this.config.disable_compression&&(this.compression=b(i.supportedCompression,Jo)?Jo:b(i.supportedCompression,Yo)?Yo:void 0),(null===(e=i.analytics)||void 0===e?void 0:e.endpoint)&&(this.analyticsDefaultEndpoint=i.analytics.endpoint)}this.set_config({person_profiles:this.Su?this.Su:$n}),null===(i=this.Bu)||void 0===i||i.handleRemoteConfig(t),this.Ya.forEach(i=>{var e;return null===(e=i.onRemoteConfig)||void 0===e?void 0:e.call(i,t)})}Fu(){try{this.config.loaded(this)}catch(t){je.critical("`loaded` function failed",t)}if(this.Hu(),this.config.internal_or_test_user_hostname&&(null==n?void 0:n.hostname)){const t=n.hostname,i=this.config.internal_or_test_user_hostname;("string"==typeof i?t===i:i.test(t))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout(()=>{(this.consent.isOptedIn()||this.au())&&this.zu()},1),this.Uu=new al(this),this.Uu.load()}Hu(){var t;this.is_capturing()&&this.config.request_batching&&(null===(t=this.Iu)||void 0===t||t.enable())}_dom_loaded(){this.is_capturing()&&Cn(this.__request_queue,t=>this.Mu(t)),this.__request_queue=[],this.Hu()}_handle_unload(){var t,i,e,s,n,r;this.pu=!0,null===(t=this.surveys)||void 0===t||null===(i=t.handlePageUnload)||void 0===i||i.call(t),null===(e=this.metrics)||void 0===e||e.flush("sendBeacon"),this.config.request_batching?(this.Wu()&&this.capture(En),null===(s=this.logs)||void 0===s||s.flushLogs("sendBeacon"),null===(n=this.Iu)||void 0===n||n.unload(),null===(r=this.Eu)||void 0===r||r.unload()):this.Wu()&&this.capture(En,null,{transport:"sendBeacon"})}_send_request(t){var i,e,s;this.__loaded?Ya?this.__request_queue.push(t):this.rateLimiter.isServerRateLimited(t.batchKey)?t.fireCallbackOnDrop&&(null===(e=t.callback)||void 0===e||e.call(t,{statusCode:429})):(t.transport=t.transport||this.config.api_transport,t.headers=wi(wi({},this.config.request_headers),t.headers),t.compression="best-available"===t.compression?null!==(i=this.compression)&&void 0!==i?i:t.compressionFallback:t.compression,(I(this.config.disable_beacon)?this.config.__preview_disable_beacon:this.config.disable_beacon)&&(t.disableTransport=["sendBeacon"]),t.fetchOptions=t.fetchOptions||this.config.fetch_options,(t=>{var i,e,s;const n=wi({},t);n.timeout=n.timeout||6e4;const r=null!==(i=n.transport)&&void 0!==i?i:"fetch";"sendBeacon"===r&&I(n.compression)&&n.data&&(n.compression=Yo),"POST"===n.method&&n.data&&("capture-body"===n.timestampMode?n.data=(t=>{var i,e;const s=(P(t)?t:[t]).map(t=>wi(wi({},t),t.timestamp instanceof Date&&!isNaN(t.timestamp.getTime())?{timestamp:t.timestamp.toISOString()}:{})),n=s[0];return{api_key:null!==(i=null==n||null===(e=n.properties)||void 0===e?void 0:e.token)&&void 0!==i?i:null==n?void 0:n.token,batch:s,sent_at:(new Date).toISOString()}})(n.data):"body"===n.timestampMode&&(n.data=((t,i=(new Date).toISOString())=>P(t)?t.map(t=>wi(wi({},t),{},{sent_at:i})):wi(wi({},t),{},{sent_at:i}))(n.data))),n.url=ea(n.url,n.method,n.compression,n.timestampMode);const o=sa.filter(t=>!n.disableTransport||!t.transport||!n.disableTransport.includes(t.transport)),l=null!==(e=null===(s=function(t,i){for(let e=0;t.length>e;e++)if(i(t[e]))return t[e]}(o,t=>t.transport===r))||void 0===s?void 0:s.method)&&void 0!==e?e:o[0].method;if(!l)throw new Error("No available transport method");const u=t=>{try{l(t)}catch(t){var i;Zl(t)?je.warn(t):je.error(t),null===(i=n.callback)||void 0===i||i.call(n,{statusCode:0,error:t})}};"sendBeacon"!==r&&n.data&&n.compression===Jo&&a&&"undefined"!=typeof Promise&&!ql?Yl(n).then(t=>{u(t)}).catch(i=>{if(de(i))return ql=!0,void u(wi(wi({},n),{},{compression:void 0,url:ea(t.url,t.method,void 0,t.timestampMode)}));(t=>{if(!t||"object"!=typeof t)return!1;const i="name"in t?String(t.name):"";return de(t)||i===ae})(i)&&(ql=!0),u(n)}):l(n)})(wi(wi({},t),{},{callback:i=>{var e,s,n;this.rateLimiter.checkForLimiting(i),400>i.statusCode||null===(s=(n=this.config).on_request_error)||void 0===s||s.call(n,i),null===(e=t.callback)||void 0===e||e.call(t,i)}}))):t.fireCallbackOnDrop&&(null===(s=t.callback)||void 0===s||s.call(t,{statusCode:0}))}Mu(t){this.Eu?this.Eu.retriableRequest(t):this._send_request(t)}_execute_array(t){Na++;try{let i;const e=[],s=[],n=[];Cn(t,t=>{if(t)if(i=t[0],P(i))n.push(t);else if(T(t))try{t.call(this)}catch(i){je.error("Error executing queued PostHog call",t,i)}else P(t)&&"alias"===i?e.push(t):P(t)&&-1!==i.indexOf("capture")&&T(this[i])?n.push(t):s.push(t)});const r=function(t,i){Cn(t,function(t){try{if(P(t[0])){let e=i;Fn(t,function(t){e=e[t[0]].apply(e,t.slice(1))})}else i[t[0]].apply(i,t.slice(1))}catch(i){je.error("Error executing queued PostHog call",t,i)}})};r(e,this),r(s,this),r(n,this)}finally{Na--}}push(t){if(Na>0&&P(t)&&O(t[0])){const e=i.prototype[t[0]];return void(T(e)&&e.apply(this,t.slice(1)))}this._execute_array([t])}Vu(){var t;const i=null===(t=this.persistence)||void 0===t?void 0:t.get_property(Ze);return O(i)&&Ga.test(i)?{value:i,delivered:!1}:C(i)&&O(i.value)&&Ga.test(i.value)?{value:i.value,delivered:!0===i.delivered}:void 0}Gu(t,i,e,s){if(!this.persistence)return;this.persistence.refreshKey(Ze);const n=this.Vu();if(!s){if(e)return O(i)&&Ga.test(i)?(i!==(null==n?void 0:n.value)&&this.persistence.register({[Ze]:{value:i,delivered:!1}}),{value:i,pending:i!==(null==n?void 0:n.value)||!n.delivered}):void this.persistence.unregister(Ze);if(O(t)&&Wa.test(t)){if((null==n?void 0:n.value.split(".")[3])===t)return{value:n.value,pending:!n.delivered};const i=`fb.1.${Date.now()}.${t}`;return this.persistence.register({[Ze]:{value:i,delivered:!1}}),{value:i,pending:!0}}return n?{value:n.value,pending:!n.delivered}:void 0}this.persistence.unregister(Ze)}Zu(t){if(!this.persistence)return;this.persistence.refreshKey(Ze);const i=this.Vu();(null==i?void 0:i.value)!==t||i.delivered||this.persistence.register({[Ze]:{value:t,delivered:!0}})}capture(t,i,e){var s,n,r,o,l;if(!(this.__loaded&&this.persistence&&this.sessionPersistence&&this.Iu))return void je.uninitializedWarning("posthog.capture");if(!this.is_capturing())return;if(I(t)||!O(t))return void je.error("No event name provided to posthog.capture");this.du();const a=!this.config.opt_out_useragent_filter&&this._is_bot();if(a&&!this.config.__preview_capture_bot_pageviews)return;const u=(null==e?void 0:e.skip_client_rate_limiting)?void 0:this.rateLimiter.clientRateLimitContext();if(null==u?void 0:u.isRateLimited)return void je.critical("This capture call is ignored due to client rate limiting.");let h;(null==i?void 0:i.$current_url)&&!O(null==i?void 0:i.$current_url)&&(je.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),null==i||delete i.$current_url),"$exception"!==t||(null==e?void 0:e.Qu)||je.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&&(h=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();const d=new Date,c=(null==e?void 0:e.timestamp)||d,v=ai(null==e?void 0:e.uuid,Gn);let f={uuid:v,event:t,properties:this.calculateEventProperties(t,i||{},c,v)};"$pageview"===t&&this.config.__preview_capture_bot_pageviews&&a&&(f.event="$bot_pageview",f.properties.$browser_type="bot"),u&&(f.properties.$lib_rate_limit_remaining_tokens=u.remainingTokens);const p="$feature_flag_called"===t&&!1===f.properties.$feature_flag_has_experiment&&!0===this.get_property("$minimal_flag_called_events");(null==e?void 0:e.$set)&&!p&&(f.$set=null==e?void 0:e.$set);const g=C(null==i?void 0:i.$set)?i.$set:void 0,_=!!(null==e?void 0:e.$set)&&"$fbc"in e.$set,m=_||!!g&&"$fbc"in g,b=_?null==e||null===(s=e.$set)||void 0===s?void 0:s[Xe]:null==g?void 0:g[Xe],y=P(null==i?void 0:i.$unset)?i.$unset:[],w=(null==e?void 0:e.$unset)||[],x=-1!==y.indexOf("$fbc")||-1!==w.indexOf("$fbc"),S=this.Gu(null==h?void 0:h.fbclid,b,m,x);S&&!0===f.properties.$process_person_profile&&S.pending&&!m&&!p&&(f.$set=wi({[Xe]:S.value},f.$set));const k=null==e?void 0:e.$unset;k&&(f.$unset=k);const E=p?void 0:this.Ju(null==e?void 0:e.$set_once,t!==Tn,t===Pn);if(E&&(f.$set_once=E),(null==e?void 0:e._noTruncate)||(T=this.config.properties_string_max_length,f=function(t,i){const e=new Set;return function t(s,n){if(s!==Object(s))return i?i(s):s;if(e.has(s))return;let r;if(e.add(s),P(s))r=[],Cn(s,i=>{r.push(t(i))});else{const i={};Fn(H(s)?Dn(s):s,(s,n)=>{e.has(s)||(i[n]=t(s,n))}),r=i}return r}(t)}(f,t=>O(t)?t.slice(0,T):t)),f.timestamp=c,I(null==e?void 0:e.timestamp)||(f.properties.$event_time_override_provided=!0,f.properties.$event_time_override_system_time=d),p&&(f.properties=((t,i=[])=>{const e={},s=i=>{void 0!==t[i]&&(e[i]=t[i])};return le.forEach(s),i.forEach(s),e})(f.properties,Ka)),t===tl||t===il){const e=null==i?void 0:i.$survey_id,s=null==i?void 0:i.$survey_iteration;Ca({id:e,current_iteration:s}),f.$set=wi(wi({},f.$set),{},{[ga({id:e,current_iteration:s},t===il?"responded":"dismissed")]:!0})}else t===Qo&&(f.$set=wi(wi({},f.$set),{},{[el]:(new Date).toISOString()}));var T;if("product tour shown"===t){const t=null==i?void 0:i.$product_tour_type;t&&(f.$set=wi(wi({},f.$set),{},{[`$product_tour_last_seen_date/${t}`]:(new Date).toISOString()}))}const R=wi(wi({},f.properties.$set),f.$set);if(F(R)||this.setPersonPropertiesForFlags(R),!M(this.config.before_send)){const t=this.$s(f);if(!t)return;f=t,f.uuid=ai(f.uuid,Gn)}const A=null!==(n=null===(r=f.$set)||void 0===r?void 0:r.$fbc)&&void 0!==n?n:C(null===(o=f.properties)||void 0===o?void 0:o.$set)?f.properties.$set[Xe]:void 0,D=(null==S?void 0:S.pending)&&A===S.value?S.value:void 0;this.iu.emit("eventCaptured",f);const j=null!==(l=null==e?void 0:e._url)&&void 0!==l?l:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),B=wi(wi({method:"POST",url:j,data:f,compression:"best-available",timestampMode:"recordings"===(null==e?void 0:e._batchKey)||/\/s\/(?:\?|$)/.test(j)?"body":"capture-body",batchKey:null==e?void 0:e._batchKey},(null==e?void 0:e.transport)?{transport:e.transport}:{}),D?{fireCallbackOnDrop:!0,callback:t=>{t.statusCode>=200&&300>t.statusCode&&this.Zu(D)}}:{});var L;return!this.config.request_batching||e&&!(null==e?void 0:e._batchKey)||(null==e?void 0:e.send_instantly)||D?(!B.transport&&!B.callback&&F(null!==(L=this.config.request_headers)&&void 0!==L?L:{})&&this.pu&&(B.transport="sendBeacon"),this.Mu(B)):this.Iu.enqueue(B),f}_addCaptureHook(t){return this.on("eventCaptured",i=>t(i.event,i))}getExtension(t){var i;return null===(i=this.Bu)||void 0===i?void 0:i.getExtension(t)}Lu(){var t;return null!==(t=this.Bu)&&void 0!==t?t:this.Bu=new Ba(this)}su(t){this._u.push(t);let i=!0;return()=>{if(!i)return;i=!1;const e=this._u.indexOf(t);-1!==e&&this._u.splice(e,1)}}Ku(t=!0){var i,e,s;return!!(null===(i=this.persistence)||void 0===i?void 0:i.consumeCookieIdentityChange())&&(this.xu=null,"anonymous"===this.persistence.get_property("$user_state")&&(null===(s=this.sessionPersistence)||void 0===s||s.clear(),this.yu.clear(),this.Yu()),null===(e=this.featureFlags)||void 0===e||e.reset(),t&&this.reloadFeatureFlags(),!0)}calculateEventProperties(i,e,r,o,l){if(r=r||new Date,!this.persistence||!this.sessionPersistence)return e;this.persistence.syncCookieProperties(),this.Ku();const a=l?void 0:this.persistence.remove_event_timer(i);let h=wi({},e);if(h.token=this.config.token,h.$config_defaults=this.config.defaults,this.au()&&(h[ln]=!0),"$snapshot"===i){const t=wi(wi({},this.persistence.properties()),this.sessionPersistence.properties());return h.distinct_id=t.distinct_id,(!O(h.distinct_id)&&!D(h.distinct_id)||R(h.distinct_id))&&je.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),h}const d=function(i,e,s,r=!1){var o,l,a,h;if(!u)return{};const d=i?[...xo,...e||[]]:[],[c,v]=Qt(u),[p,g]=function(t){for(let i=0;si.length>i;i++){const[e,s,n]=si[i],r=t.match(e);if(r){const i=n&&t.match(n)||r;return[s,(null==i?void 0:i[1])||""]}}return["",""]}(u),_=function(){const t="u">typeof navigator?navigator:void 0;return(null==t?void 0:t.brave)?{brave:!0}:{}}(),m={};I(s)||(m.detectGoogleSearchApp=s);const b={},y=null===(o=navigator)||void 0===o||null===(o=o.userAgentData)||void 0===o?void 0:o.platform,w=null===(l=navigator)||void 0===l?void 0:l.maxTouchPoints,x=null==t||null===(a=t.screen)||void 0===a?void 0:a.width,S=null==t||null===(h=t.screen)||void 0===h?void 0:h.height,k=null==t?void 0:t.devicePixelRatio;I(y)||(b.userAgentDataPlatform=y),I(w)||(b.maxTouchPoints=w),I(x)||(b.screenWidth=x),I(S)||(b.screenHeight=S),I(k)||(b.devicePixelRatio=k);const E=In(Mn({$os:c,$os_version:v,$browser:Jt(u,navigator.vendor,_,m),$webview_app:p,$webview_app_version:g,$device:ti(u),$device_type:ii(u,b),$timezone:Do(),$timezone_offset:jo()}),{$current_url:bo(r?hi(null==n?void 0:n.href):null==n?void 0:n.href,d,ko),$host:null==n?void 0:n.host,$pathname:null==n?void 0:n.pathname,$raw_user_agent:u.length>1e3?u.substring(0,997)+"...":u,$browser_version:Xt(u,navigator.vendor,_,m),$browser_language:Fo(),$browser_language_prefix:Io(),$screen_height:null==t?void 0:t.screen.height,$screen_width:null==t?void 0:t.screen.width,$viewport_height:null==t?void 0:t.innerHeight,$viewport_width:null==t?void 0:t.innerWidth,$lib:f.LIB_NAME,$lib_version:f.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3});return f.SDK_DIST_CHANNEL&&(E.$sdk_dist_channel=f.SDK_DIST_CHANNEL),E}(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){const{sessionId:t,windowId:i}=this.sessionManager.checkAndGetSessionAndWindowId(l,r.getTime(),!0);h.$session_id=t,h.$window_id=i}this.sessionPropsManager&&In(h,this.sessionPropsManager.getSessionProps());try{var c;this.sessionRecording&&In(h,this.sessionRecording.sdkDebugProperties),h.$sdk_debug_retry_queue_size=null===(c=this.Eu)||void 0===c?void 0:c.length}catch(t){h.$sdk_debug_error_capturing_properties=String(t)}let v;if(this.requestRouter.region===xa&&(h.$lib_custom_api_host=this.config.api_host),v="$pageview"!==i||l?"$pageleave"!==i||l?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(r):this.pageViewManager.doPageView(r,o),h=In(h,v),"$pageview"===i&&s&&(h.title=s.title),!I(a)){const t=r.getTime()-a;h.$duration=parseFloat((t/1e3).toFixed(3))}u&&this.config.opt_out_useragent_filter&&(h.$browser_type=this._is_bot()?"bot":"browser");const p=this.persistence.properties(),g=this.sessionPersistence.properties(),_=h.$groups,m=p.$groups;C(_)&&!F(_)&&(h.$groups=wi(wi({},C(m)?m:{}),_)),Fn(["$referrer","$referring_domain"],t=>{t in p&&delete g[t]});const b={};if(this._u.length>0)for(const t of this._u.slice())try{In(b,t())}catch(t){je.error("Failed to produce browser extension event properties",t)}h=In({},d,p,g,wi(wi({},b),h)),h.$is_identified=this._isIdentified(),P(this.config.property_denylist)?Fn(this.config.property_denylist,function(t){delete h[t]}):je.error(Va+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);const y=this.config.sanitize_properties;y&&(je.error(qa),h=y(h,i));const w=this.Xu();return h.$process_person_profile=w,w&&!l&&this.th("_calculate_event_properties"),h}Ju(t,i=!0,e=!1){var s;if(!this.persistence||!this.Xu())return t;if(this.mu&&!e)return t;const n=this.persistence.get_initial_props(),r=null===(s=this.sessionPropsManager)||void 0===s?void 0:s.getSetOnceProps();let o=In({},n,r||{},t||{});const l=this.config.sanitize_properties;return l&&(je.error(qa),o=l(o,"$set_once")),i&&(this.mu=!0),F(o)?void 0:o}register(t,i){var e;null===(e=this.persistence)||void 0===e||e.register(t,i)}register_once(t,i,e){var s;null===(s=this.persistence)||void 0===s||s.register_once(t,i,e)}register_for_session(t){var i,e;null===(i=this.persistence)||void 0===i||i.syncCookieProperties(),this.Ku(),null===(e=this.sessionPersistence)||void 0===e||e.register(t),Object.keys(t).forEach(t=>this.yu.add(t)),this.Yu()}unregister(t){var i;null===(i=this.persistence)||void 0===i||i.unregister(t)}unregister_for_session(t){var i;null===(i=this.sessionPersistence)||void 0===i||i.unregister(t),this.yu.delete(t),this.Yu()}eh(t,i){this.register({[t]:i})}Pu(){this.yu.forEach(t=>{var i;null===(i=this.sessionPersistence)||void 0===i||i.unregister(t)}),this.yu.clear(),this.Yu()}Yu(){var t;if(!this.bu)return;if("memory"===this.config.persistence||(null===(t=this.sessionPersistence)||void 0===t?void 0:t.pi)||!fr.Et())return void fr.Lt(this.bu);const i=[];this.yu.forEach(t=>i.push(t)),i.length>0?fr.At(this.bu,i):fr.Lt(this.bu)}getFeatureFlag(t,i){var e;return null===(e=this.featureFlags)||void 0===e?void 0:e.getFeatureFlag(t,i)}getFeatureFlagPayload(t){var i;return null===(i=this.featureFlags)||void 0===i?void 0:i.getFeatureFlagPayload(t)}getFeatureFlagResult(t,i){var e;return null===(e=this.featureFlags)||void 0===e?void 0:e.getFeatureFlagResult(t,i)}getAllFeatureFlags(){var t,i;return null!==(t=null===(i=this.featureFlags)||void 0===i?void 0:i.getAllFeatureFlags())&&void 0!==t?t:[]}isFeatureEnabled(t,i){var e,s;return null!==(e=null===(s=this.featureFlags)||void 0===s?void 0:s.isFeatureEnabled(t,i))&&void 0!==e?e:null==i?void 0:i.defaultValue}reloadFeatureFlags(){var t;null===(t=this.featureFlags)||void 0===t||t.reloadFeatureFlags()}updateFlags(t,i,e){var s;null===(s=this.featureFlags)||void 0===s||s.updateFlags(t,i,e)}updateEarlyAccessFeatureEnrollment(t,i,e){var s;null===(s=this.featureFlags)||void 0===s||s.updateEarlyAccessFeatureEnrollment(t,i,e)}getEarlyAccessFeatures(t,i=!1,e){var s;return null===(s=this.featureFlags)||void 0===s?void 0:s.getEarlyAccessFeatures(t,i,e)}on(t,i){return this.iu.on(t,i)}onFeatureFlags(t){return this.featureFlags?this.featureFlags.onFeatureFlags(t):(t([],{},{errorsLoading:!0}),()=>{})}onSurveysLoaded(t){return this.surveys?this.surveys.onSurveysLoaded(t):(t([],{isLoaded:!1,error:Ha}),()=>{})}onSessionId(t){var i,e;return null!==(i=null===(e=this.sessionManager)||void 0===e?void 0:e.onSessionId(t))&&void 0!==i?i:()=>{}}getSurveys(t,i=!1){this.surveys?this.surveys.getSurveys(t,i):t([],{isLoaded:!1,error:Ha})}getActiveMatchingSurveys(t,i=!1){this.surveys?this.surveys.getActiveMatchingSurveys(t,i):t([],{isLoaded:!1,error:Ha})}renderSurvey(t,i){var e;null===(e=this.surveys)||void 0===e||e.renderSurvey(t,i)}displaySurvey(t,i=Ia){var e;null===(e=this.surveys)||void 0===e||e.displaySurvey(t,i)}cancelPendingSurvey(t){var i;null===(i=this.surveys)||void 0===i||i.cancelPendingSurvey(t)}canRenderSurvey(t){var i,e;return null!==(i=null===(e=this.surveys)||void 0===e?void 0:e.canRenderSurvey(t))&&void 0!==i?i:{visible:!1,disabledReason:Ha}}canRenderSurveyAsync(t,i=!1){var e,s;return null!==(e=null===(s=this.surveys)||void 0===s?void 0:s.canRenderSurveyAsync(t,i))&&void 0!==e?e:Promise.resolve({visible:!1,disabledReason:Ha})}ih(t){return!t||R(t)?(je.critical("Unique user id has not been set in posthog.identify"),!1):"$posthog_cookieless"===t?(je.critical(`The string "${t}" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.`),!1):!["distinct_id","distinctid"].includes(t.toLowerCase())&&!["undefined","null"].includes(t.toLowerCase())||(je.critical(`The string "${t}" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.`),!1)}identify(t,i,e){if(!this.__loaded||!this.persistence)return je.uninitializedWarning("posthog.identify");if(D(t)&&(t=t.toString(),je.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),!this.ih(t))return;if(!this.th("posthog.identify"))return;this.du();const s=this.get_distinct_id(),n=this.persistence.syncCookieProperties()&&this.get_distinct_id()!==s,r=this.Ku(!1),o=this.persistence.Cl();let l=!1;try{const s=this.get_distinct_id();this.register({$user_id:t}),this.get_property("$device_id")||this.register_once({$had_persisted_distinct_id:!0,$device_id:s},""),t!==s&&t!==this.get_property("__alias")&&(this.unregister(Je),this.register({distinct_id:t}));const o=(this.persistence.get_property("$user_state")||"anonymous")===yn,u=t!==s,h=!u&&o;if(u&&o){var a;const n=this.config.reuseAnonymousId?{distinct_id:t}:{distinct_id:t,$anon_distinct_id:s};this.persistence.set_property(Zs,wn),this.setPersonPropertiesForFlags({$set:i||{},$set_once:e||{}},!1),this.config.cookieWinsOnConflict&&this.persistence.$l(),this.capture(Pn,n,{$set:i||{},$set_once:e||{}}),this.xu=$a(t,i,e),null===(a=this.featureFlags)||void 0===a||a.setAnonymousDistinctId(this.config.reuseAnonymousId?void 0:s)}else if(h){this.persistence.set_property(Zs,wn);const s=i||{},n=e||{};this.setPersonPropertiesForFlags({$set:s,$set_once:n},!1),this.config.cookieWinsOnConflict&&this.persistence.$l(),this.capture("$set",{$set:s,$set_once:n}),this.xu=$a(t,i,e)}else(i||e)&&this.setPersonProperties(i,e);u||n||r?(this.reloadFeatureFlags(),this.featureFlags?this.featureFlags.resetFlagCallReported():this.unregister(Ks)):h&&(i||e)&&this.reloadFeatureFlags(),l=!0}finally{o&&this.persistence.Ml(l)}}setPersonProperties(t,i){if(!t&&!i)return;if(!this.th("posthog.setPersonProperties"))return;const e=$a(this.get_distinct_id(),t,i);this.xu!==e?(this.setPersonPropertiesForFlags({$set:t||{},$set_once:i||{}},!0),this.capture("$set",{$set:t||{},$set_once:i||{}}),this.xu=e):je.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}unsetPersonProperties(t){var i;const e=(P(t)?t:[t]).filter(t=>O(t)&&t.length>0);0!==e.length&&this.th("posthog.unsetPersonProperties")&&(null===(i=this.featureFlags)||void 0===i||i.unsetPersonPropertiesForFlags(e,!0),this.capture("$set",{$unset:e}),this.xu=null)}group(t,i,e){var s;if(!t||!i)return void je.error("posthog.group requires a group type and group key");null===(s=this.persistence)||void 0===s||s.syncCookieProperties(),this.Ku();const n=this.getGroups(),r=n[t]!==i;if(r&&this.resetGroupPropertiesForFlags(t),this.register({$groups:wi(wi({},n),{},{[t]:i})}),(r||e)&&this.Xu()){const s={$group_type:t,$group_key:i};e&&(s.$group_set=e),this.capture(Tn,s)}e&&this.setGroupPropertiesForFlags({[t]:e}),r&&!e&&this.reloadFeatureFlags()}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(t,i=!0){var e;null===(e=this.featureFlags)||void 0===e||e.setPersonPropertiesForFlags(t,i)}resetPersonPropertiesForFlags(t=!0){var i;null===(i=this.featureFlags)||void 0===i||i.resetPersonPropertiesForFlags(t)}setGroupPropertiesForFlags(t,i=!0){var e;this.th("posthog.setGroupPropertiesForFlags")&&(null===(e=this.featureFlags)||void 0===e||e.setGroupPropertiesForFlags(t,i))}resetGroupPropertiesForFlags(t){var i;null===(i=this.featureFlags)||void 0===i||i.resetGroupPropertiesForFlags(t)}reset(t){const i=B(t)?t:null==t?void 0:t.resetDeviceID,e=B(t)||null==t?void 0:t.bootstrap;this.nh(i,!1,e)}nh(t,i=!1,e){var s,n,r,o,l,a;if(je.info("reset"),!this.__loaded)return je.uninitializedWarning("posthog.reset");const u=null==e?void 0:e.sessionID;this.config.bootstrap=e||(null===(s=this.$u)||void 0===s?void 0:s.bootstrap)||{},null===(n=this.featureFlags)||void 0===n||null===(r=n.updateConfig)||void 0===r||r.call(n,this.config,this.Vl());const h=this.get_property(Ge),d=this.get_property(Ke),c=this.get_property(hs);null===(o=this.sessionRecording)||void 0===o||o.flushBeforeIdentityReset();const v=this.is_capturing();this.consent.reset(),i||!v||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.");const f=null===(l=this.persistence)||void 0===l||null===(a=l.Cl)||void 0===a?void 0:a.call(l);let p=!1;try{var g,_,m,b,y,w,x,S,k,E,P,T,C;if(null===(g=this.persistence)||void 0===g||g.clear(),null===(_=this.sessionPersistence)||void 0===_||_.clear(),this.yu.clear(),this.Yu(),I(c)||null===(E=this.persistence)||void 0===E||E.register({$session_recording_remote_config:c}),null===(m=this.surveys)||void 0===m||m.reset(),null===(b=this.featureFlags)||void 0===b||b.reset(),null===(y=this.conversations)||void 0===y||y.reset(),null===(w=this.logs)||void 0===w||w.reset(),null===(x=this.metrics)||void 0===x||x.reset(),null===(S=this.persistence)||void 0===S||S.set_property("$user_state","anonymous"),null===(k=this.sessionManager)||void 0===k||k.resetSessionId(),this.xu=null,"always"===this.config.cookieless_mode)this.register_once({distinct_id:on,$device_id:null},"");else{const i=this.config.get_device_id(Gn());this.register_once({distinct_id:i,$device_id:t?i:h},""),t||I(d)||this.register({[Ke]:d})}if(this.register({$last_posthog_reset:(new Date).toISOString()},1),e)if(e.distinctID&&!this.au()&&(null===(C=this.persistence)||void 0===C||C.set_property("$user_state",e.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:e.distinctID})),null===(P=this.featureFlags)||void 0===P||P.initialize(),!M(u)&&!(null===(T=this.sessionManager)||void 0===T?void 0:T.setBootstrapSessionId(u,!0))){const t=wi({},e);delete t.sessionID,this.config.bootstrap=t}delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,p=!0}finally{var F,O;f&&(null===(F=this.persistence)||void 0===F||null===(O=F.Ml)||void 0===O||O.call(F,p))}this.reloadFeatureFlags()}shutdown(t){var i=this;return Y(function*(){var t,e,s,n,r,o,l;if(i.__loaded){i.gu=!0,i.Lu().dispose(),null===(t=i.sessionRecording)||void 0===t||t.dispose(),null===(e=i.logs)||void 0===e||e.flushLogs("sendBeacon"),null===(s=i.metrics)||void 0===s||s.flush("sendBeacon"),null===(n=i.Iu)||void 0===n||n.unload(),null===(r=i.Eu)||void 0===r||r.unload();try{var a;null===(a=i.featureFlags)||void 0===a||a.destroy()}catch(t){je.error("Error while destroying feature flags",t)}null===(o=i.persistence)||void 0===o||o.destroy(),null===(l=i.sessionPersistence)||void 0===l||l.destroy()}else je.uninitializedWarning("posthog.shutdown")})()}setIdentity(t,i){var e;delete this.config.identity_claims,this.config.identity_distinct_id=t,this.config.identity_hash=i,this.alias(t),null===(e=this.conversations)||void 0===e||e.sh()}clearIdentity(){var t;delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,null===(t=this.conversations)||void 0===t||t.rh()}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var t,i;return null!==(t=null===(i=this.sessionManager)||void 0===i?void 0:i.checkAndGetSessionAndWindowId(!0).sessionId)&&void 0!==t?t:""}get_session_replay_url(t){if(!this.sessionManager)return"";const{sessionId:i,sessionStartTimestamp:e}=this.sessionManager.checkAndGetSessionAndWindowId(!0);let s=this.requestRouter.endpointFor("ui",`/project/${this.config.token}/replay/${i}`);if((null==t?void 0:t.withTimestamp)&&e){var n;const i=null!==(n=t.timestampLookBack)&&void 0!==n?n:10;if(!e)return s;s+=`?t=${Math.max(Math.floor(((new Date).getTime()-e)/1e3)-i,0)}`}return s}alias(t,i){return t===this.get_property("$people_distinct_id")?(je.critical("Attempting to create alias for existing People user - aborting."),-2):this.th("posthog.alias")?(I(i)&&(i=this.get_distinct_id()),t!==i?(this.eh(Je,t),this.capture("$create_alias",{alias:t,distinct_id:i})):(je.warn("alias matches current distinct_id - skipping api call."),this.identify(t),-1)):void 0}set_config(t){const i=wi({},this.config);if(C(t)){var e,s,n,r,o,l,a,u,h,d,c,v,f;In(this.config,tu(t));const g=this.vu();null===(e=this.persistence)||void 0===e||e.update_config(this.config,i,g),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new Ko(wi(wi({},this.config),{},{persistence:"sessionStorage"}),g,!1);const _=this.Cu(this.config.debug);var p;B(_)&&(this.config.debug=_),B(this.config.debug)&&(this.config.debug?(qe.DEBUG=!0,tr.Et()&&tr.At("ph_debug",!0),je.info("set_config",{config:t,oldConfig:i,newConfig:wi({},this.config)})):(qe.DEBUG=!1,tr.Et()&&tr.Lt("ph_debug"))),null===(s=this.featureFlags)||void 0===s||null===(n=s.updateConfig)||void 0===n||n.call(s,this.config,this.Vl()),null===(r=this.exceptionObserver)||void 0===r||r.onConfigChange(),null===(o=this.exceptions)||void 0===o||o.onConfigChange(),null===(l=this.sessionRecording)||void 0===l||l.startIfEnabledOrStop(),null===(a=this.tracingHeaders)||void 0===a||a.startIfEnabledOrStop(),null===(u=this.autocapture)||void 0===u||u.startIfEnabled(),null===(h=this.heatmaps)||void 0===h||h.startIfEnabled(),("capture_pageview"in t||"disable_capture_url_hashes"in t)&&(null===(p=this.historyAutocapture)||void 0===p||p.startIfEnabledOrStop()),null===(d=this.exceptionObserver)||void 0===d||d.startIfEnabledOrStop(),null===(c=this.deadClicksAutocapture)||void 0===c||c.startIfEnabledOrStop(),null===(v=this.surveys)||void 0===v||v.loadIfEnabled(),this.fu(),null===(f=this.externalIntegrations)||void 0===f||f.startIfEnabledOrStop(),!i.segment&&this.config.segment&&this.persistence&&oo(this,za,!1)}}_overrideSDKInfo(t,i){qe.LIB_NAME=t,qe.LIB_VERSION=i}startSessionRecording(t){const i=!0===t,e={sampling:i||!!(null==t?void 0:t.sampling),linked_flag:i||!!(null==t?void 0:t.linked_flag),url_trigger:i||!!(null==t?void 0:t.url_trigger),event_trigger:i||!!(null==t?void 0:t.event_trigger)};var s,n,r,o,l;Object.values(e).some(Boolean)&&(null===(s=this.sessionManager)||void 0===s||s.checkAndGetSessionAndWindowId(),e.sampling&&(null===(n=this.sessionRecording)||void 0===n||n.overrideSampling()),e.linked_flag&&(null===(r=this.sessionRecording)||void 0===r||r.overrideLinkedFlag()),e.url_trigger&&(null===(o=this.sessionRecording)||void 0===o||o.overrideTrigger("url")),e.event_trigger&&(null===(l=this.sessionRecording)||void 0===l||l.overrideTrigger("event")));this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var t;return!!(null===(t=this.sessionRecording)||void 0===t?void 0:t.started)}captureException(t,i){try{if(!this.exceptions)return;const e=this.exceptions.buildProperties(t,{handled:!0,syntheticException:new Error("PostHog syntheticException")});return this.exceptions.sendExceptionEvent(wi(wi({},e),i))}catch(t){return}}addExceptionStep(t,i){var e;null===(e=this.exceptions)||void 0===e||e.addExceptionStep(t,i)}captureLog(t){var i;null===(i=this.logs)||void 0===i||i.captureLog(t)}get logger(){var t,e;return null!==(t=null===(e=this.logs)||void 0===e?void 0:e.logger)&&void 0!==t?t:i.oh}startExceptionAutocapture(t){this.set_config({capture_exceptions:null==t||t})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(t){var i,e;return null!==(i=null===(e=this.toolbar)||void 0===e?void 0:e.loadToolbar(t))&&void 0!==i&&i}get_property(t){var i;return null===(i=this.persistence)||void 0===i?void 0:i.props[t]}getSessionProperty(t){var i;return null===(i=this.sessionPersistence)||void 0===i?void 0:i.props[t]}toString(){var t;let i=null!==(t=this.config.name)&&void 0!==t?t:Ja;return i!==Ja&&(i="posthog."+i),i}_isIdentified(){var t,i;return"identified"===(null===(t=this.persistence)||void 0===t?void 0:t.get_property("$user_state"))||"identified"===(null===(i=this.sessionPersistence)||void 0===i?void 0:i.get_property("$user_state"))}Xu(){var t,i;return!("never"===this.config.person_profiles||"identified_only"===this.config.person_profiles&&!this._isIdentified()&&F(this.getGroups())&&!(null===(t=this.persistence)||void 0===t||null===(t=t.props)||void 0===t?void 0:t.__alias)&&!(null===(i=this.persistence)||void 0===i||null===(i=i.props)||void 0===i?void 0:i.$epp))}Wu(){return!0===this.config.capture_pageleave||"if_capture_pageview"===this.config.capture_pageleave&&!!this.config.capture_pageview}createPersonProfile(){this.Xu()||this.th("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.th("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}th(t){return"never"===this.config.person_profiles?(je.error(t+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.uu(),this.eh(rn,!0),!0)}vu(){if("always"===this.config.cookieless_mode)return!0;const t=this.consent.isOptedOut();return this.config.disable_persistence||t&&!(!this.config.opt_out_persistence_by_default&&"on_reject"!==this.config.cookieless_mode)}fu(){var t,i;const e=this.vu();var s,n,r;return this.is_capturing()||null===(s=this.logs)||void 0===s||s.ah(),(null===(t=this.persistence)||void 0===t?void 0:t.pi)!==e&&(null===(n=this.persistence)||void 0===n||n.set_disabled(e)),(null===(i=this.sessionPersistence)||void 0===i?void 0:i.pi)!==e&&(null===(r=this.sessionPersistence)||void 0===r||r.set_disabled(e)),e&&(this.yu.clear(),this.Yu()),e}opt_in_capturing(t){var e;if("always"!==this.config.cookieless_mode){if(this.au()){var s,n,r,o,l,a;null===(s=this.sessionRecording)||void 0===s||s.dispose({discardBufferedEvents:!0}),this.nh(!0,!0),null===(n=this.sessionManager)||void 0===n||n.destroy(),null===(r=this.pageViewManager)||void 0===r||r.destroy(),this.sessionManager=new va(this),this.pageViewManager=new ho(this),this.persistence&&(this.sessionPropsManager=new ua(this,this.sessionManager,this.persistence));const t=null!==(o=null===(l=this.config.__extensionClasses)||void 0===l?void 0:l.sessionRecording)&&void 0!==o?o:null===(a=i.__defaultExtensionClasses)||void 0===a?void 0:a.sessionRecording;var u,h;t&&(this.sessionRecording=this.lu(this.sessionRecording,new t(this)),this.eu&&(null===(u=this.sessionRecording)||void 0===u||null===(h=u.onRemoteConfig)||void 0===h||h.call(u,this.eu)))}var d,c;this.consent.optInOut(!0),this.fu(),this.Hu(),null===(e=this.sessionRecording)||void 0===e||e.startIfEnabledOrStop(),"on_reject"==this.config.cookieless_mode&&(null===(d=this.surveys)||void 0===d||d.loadIfEnabled()),(I(null==t?void 0:t.captureEventName)||(null==t?void 0:t.captureEventName))&&this.capture(null!==(c=null==t?void 0:t.captureEventName)&&void 0!==c?c:"$opt_in",null==t?void 0:t.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.zu()}else je.warn(Ua)}opt_out_capturing(){if("always"===this.config.cookieless_mode)return void je.warn(Ua);const t="on_reject"===this.config.cookieless_mode?this.sessionRecording:void 0;var i,e;null==t||t.dispose({discardBufferedEvents:!0}),"on_reject"===this.config.cookieless_mode&&this.consent.isOptedIn()&&this.nh(!0,!0),this.consent.optInOut(!1),this.fu(),"on_reject"===this.config.cookieless_mode&&(this.register({distinct_id:on,$device_id:null}),this.ou(t),this.sessionRecording=void 0,null===(i=this.sessionManager)||void 0===i||i.destroy(),null===(e=this.pageViewManager)||void 0===e||e.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,this.config.capture_pageview&&this.zu(),this.Hu())}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){const t=this.consent.consent;return 1===t?"granted":0===t?"denied":"pending"}is_capturing(){return"always"===this.config.cookieless_mode||("on_reject"===this.config.cookieless_mode?this.consent.isRejected()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this.fu()}_is_bot(){return e?fa(e,this.config.custom_blocked_useragents):void 0}zu(){s&&("visible"===s.visibilityState?this.wu||(this.wu=!0,this.capture(kn,{title:s.title},{send_instantly:!0}),this.ku&&(s.removeEventListener(xn,this.ku),this.ku=null)):this.ku||(this.ku=this.zu.bind(this),Ln(s,xn,this.ku)))}debug(i){!1===i?(null==t||t.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(null==t||t.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}))}Vl(){const t=this.$u||{};return"advanced_disable_flags"in t?!!t.advanced_disable_flags:!1!==this.config.advanced_disable_flags?!!this.config.advanced_disable_flags:!0===this.config.advanced_disable_decide?(je.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(t,i,e,s,n){const r=i in t&&!M(t[i]),o=e in t&&!M(t[e]);return r?t[i]:!!o&&(n&&n.warn(`Config field '${e}' is deprecated. Please use '${i}' instead. The old field will be removed in a future major version.`),t[e])}(t,"advanced_disable_flags","advanced_disable_decide",0,je)}$s(t){var i;if(M(this.config.before_send))return t;const e=Object.keys(null!==(i=t.properties)&&void 0!==i?i:{}).filter(N),s=P(this.config.before_send)?this.config.before_send:[this.config.before_send];let n=t;for(const i of s)try{if(n=i(n),M(n)){const i=`Event '${t.event}' was rejected in beforeSend function`;return L(t.event)?je.warn(`${i}. This can cause unexpected behavior.`):je.info(i),null}n.properties&&!F(n.properties)||je.warn(`Event '${t.event}' has no properties after beforeSend function, this is likely an error.`)}catch(i){return je.error(`Error in beforeSend function for event '${t.event}':`,i),null}for(const i of e)if(n.properties&&M(n.properties[i]))return je.warn(`Event '${t.event}' had its '${i}' property removed in a beforeSend function. This property is required for ingestion, so the event will be dropped.`),null;return n}getPageViewId(){var t;return null===(t=this.pageViewManager.Oo)||void 0===t?void 0:t.pageViewId}captureTraceFeedback(t,i){this.capture("$ai_feedback",{$ai_trace_id:String(t),$ai_feedback_text:i})}captureTraceMetric(t,i,e){this.capture("$ai_metric",{$ai_trace_id:String(t),$ai_metric_name:i,$ai_metric_value:String(e)})}Cu(t){const i=B(t)&&!t,e=tr.Et()&&"true"===tr.Ot("ph_debug");return!i&&(!!e||t)}};eu.__defaultExtensionClasses={},eu.oh=(()=>{const t=()=>{};return{trace:t,debug:t,info:t,warn:t,error:t,fatal:t}})(),function(t,i){for(let e=0;i.length>e;e++)t.prototype[i[e]]=An(t.prototype[i[e]])}(eu,["identify"]);var su=class{constructor(t){this.disabled=!1===t;const i=C(t)?t:{};this.thresholdPx=i.threshold_px||30,this.timeoutMs=i.timeout_ms||1e3,this.clickCount=i.click_count||3,this.clicks=[]}isRageClick(t,i,e){if(this.disabled)return!1;const s=this.clicks[this.clicks.length-1];if(s&&Math.abs(t-s.x)+Math.abs(i-s.y)<this.thresholdPx&&this.timeoutMs>e-s.timestamp){if(this.clicks.push({x:t,y:i,timestamp:e}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:t,y:i,timestamp:e}];return!1}};const nu="$copy_autocapture",ru=Be("[AutoCapture]");function ou(t,i){return i.length>t?i.slice(0,t)+"...":i}function lu(t){if(t.previousElementSibling)return t.previousElementSibling;let i=t;do{i=i.previousSibling}while(i&&!mr(i));return i}function au(i,{e:e,maskAllElementAttributes:s,maskAllText:n,elementAttributeIgnoreList:r,elementsChainAsString:o,disableCaptureUrlHashes:l}){var a,u;if(!mr(i))return{props:{}};const h=[i],d=new Set([i]);let c=i;for(;c.parentNode&&!br(c,"body")&&1e3>h.length;){if(wr(c.parentNode)){const t=c.parentNode.host;if(d.has(t))break;d.add(t),h.push(t),c=t;continue}if(!mr(c.parentNode))break;if(d.has(c.parentNode))break;d.add(c.parentNode),h.push(c.parentNode),c=c.parentNode}const v="click"===e.type&&"http://www.w3.org/2000/svg"===i.namespaceURI?h.findIndex(t=>br(t,"button")||br(t,"a")):-1;v>0&&(n=n||h.slice(0,v+1).some(t=>!zr(t)||Ur(t)));const f=[],p={};let g,_=!1,m=!1;if(Fn(h,t=>{const i=zr(t);if(br(t,"a")){const e=t.getAttribute("href");_=!!(i&&e&&Yr(e))&&(l?hi(e):e)}b(Sr(t),"ph-no-capture")&&(m=!0),f.push(function(t,i,e,s,n=!1){const r=t.tagName.toLowerCase(),o={tag_name:r};Tr.indexOf(r)>-1&&!e&&(o.$el_text="a"===r.toLowerCase()||"button"===r.toLowerCase()?ou(1024,Xr(t)):ou(1024,Er(t)));const l=Sr(t);l.length>0&&(o.classes=l.filter(function(t){return""!==t})),Fn(t.attributes,function(e){var r;if((!Ur(t)||-1!==["name","id","class","aria-label"].indexOf(e.name))&&!(null==s?void 0:s.includes(e.name))&&!i&&Yr(e.value)&&(!O(r=e.name)||"_ngcontent"!==r.substring(0,10)&&"_nghost"!==r.substring(0,7))){let t=e.value;"class"===e.name&&(t=$r(t).join(" ")),o["attr__"+e.name]=ou(1024,"href"===e.name&&n?hi(t):t)}});let a=1,u=1,h=t;for(;h=lu(h);)a++,h.tagName===t.tagName&&u++;return o.nth_child=a,o.nth_of_type=u,o}(t,s,n,r,l)),Fn(function(t){if(!zr(t))return{};const i={};return Fn(t.attributes,function(t){if(t.name&&0===t.name.indexOf("data-ph-capture-attribute")){const e=t.name.replace("data-ph-capture-attribute-",""),s=t.value;e&&s&&Yr(s)&&(i[e]=s)}}),i}(t),(t,i)=>{({}).hasOwnProperty.call(p,i)||(p[i]=t)})}),m)return{props:{},explicitNoCapture:m};if(v>0&&(i=h[v],f.splice(0,v)),n||(f[0].$el_text=br(i,"a")||br(i,"button")?Xr(i):Er(i)),_){var y,w;f[0].attr__href=_;const i=null===(y=_o(_))||void 0===y?void 0:y.host,e=null==t||null===(w=t.location)||void 0===w?void 0:w.host;i&&e&&i!==e&&(g=_)}return{props:In((S=e.type,{$event_type:S,$ce_version:1}),o?{}:{$elements:f},{$elements_chain:(x=f,P(x)?function(t){return t.map(t=>{var i,e;let s="";if(t.tag_name&&(s+=t.tag_name),t.attr_class){t.attr_class.sort();for(const i of t.attr_class)s+=`.${i.replace(/"/g,"")}`}const n=wi(wi(wi(wi({},t.text?{text:t.text}:{}),{},{"nth-child":null!==(i=t.nth_child)&&void 0!==i?i:0,"nth-of-type":null!==(e=t.nth_of_type)&&void 0!==e?e:0},t.href?{href:t.href}:{}),t.attr_id?{attr_id:t.attr_id}:{}),t.attributes),r={};return On(n).sort(([t],[i])=>function(t,i){return i>t?-1:t>i?1:0}(t,i)).forEach(([t,i])=>r[Qr(t.toString())]=Qr(i.toString())),s+=":",s+=On(r).map(([t,i])=>`${t}="${i}"`).join(""),s}).join(";")}(function(t){return t.map(t=>{var i,e;const s={text:null===(i=t.$el_text)||void 0===i?void 0:i.slice(0,400),tag_name:t.tag_name,href:null===(e=t.attr__href)||void 0===e?void 0:e.slice(0,2048),attr_class:to(t),attr_id:t.attr__id,nth_child:t.nth_child,nth_of_type:t.nth_of_type,attributes:{}};return On(t).filter(([t])=>0===t.indexOf("attr__")).forEach(([t,i])=>s.attributes[t]=i),s})}(x)):"")},(null===(a=f[0])||void 0===a?void 0:a.$el_text)?{$el_text:null===(u=f[0])||void 0===u?void 0:u.$el_text}:{},g&&"click"===e.type?{$external_click_url:g}:{},p),target:i};var x,S}var uu=class{Js(){this.Ks=void 0,clearTimeout(this.Ys),this.Ys=void 0}Xs(t){var i;if(!zr(t))return!0;const e=null!==(i=this.lo().css_selector_ignorelist)&&void 0!==i?i:Or,s=new Set;let n=t;for(;n;){if(s.size>=1e3||s.has(n))return!0;s.add(n);const t=n,i=Sr(t);if(b(i,"ph-no-capture")||b(i,"ph-sensitive")||Ur(t)||e.some(i=>Cr(t,i)))return!0;const r=n.parentNode;n=wr(r)?r.host:r&&mr(r)?r:null}return!1}ao(t){if(!this.isEnabled||"pointercancel"===t.type)return void this.Js();if("pointerdown"===t.type){this.Js();const e=Pr(t);var i;return void(t.isPrimary&&0===t.button&&!t.ctrlKey&&e&&mr(e)&&(this.Ks={target:e,excluded:this.Xs(e),id:t.pointerId,x:t.clientX,y:t.clientY,released:!1,distinctId:null===(i=this.uo)||void 0===i?void 0:i.distinctId}))}const e=this.Ks;e&&(t.pointerId!==e.id||Math.abs(t.clientX-e.x)>5||Math.abs(t.clientY-e.y)>5?this.Js():"pointerup"===t.type&&(e.released=!0,this.Ys=setTimeout(()=>this.Js(),0)))}ho(t){var i;const e=this.Ks;this.Js();const n=Pr(t);if((null==e?void 0:e.released)&&e.target.isConnected&&e.distinctId===(null===(i=this.uo)||void 0===i?void 0:i.distinctId)&&t.pointerId===e.id&&(t.detail>0||"touch"===t.pointerType||"pen"===t.pointerType)&&0===t.button&&5>=Math.abs(t.clientX-e.x)&&5>=Math.abs(t.clientY-e.y)&&n&&(br(n,"html")||br(n,"body"))){var r;if(e.excluded)return null;const t=null!==(r=this.lo().css_selector_ignorelist)&&void 0!==r?r:Or;return[n,null==s?void 0:s.documentElement,null==s?void 0:s.body].some(i=>{if(!i)return!1;const e=Sr(i);return b(e,"ph-no-capture")||b(e,"ph-sensitive")||!zr(i)||Ur(i)||t.some(t=>Cr(i,t))})?null:e.target}}constructor(t){this.co=t,this.name="autocapture",this.do=!1,this.vo=null,this.fo=!1,this.po=!1,this.Mr={enabled:!1,rageclick:!1,maskAllElementAttributes:!1,maskAllText:!1,disableCaptureUrlHashes:!1,remoteRequestsDisabled:!1},this.mo=!1,this.co.refresh(this.Mr),this.rageclicks=new su(this.Mr.rageclick),this.yo=null}setup(t){this.bo(),this.uo=t;const i=t.onRemoteConfig(this.onRemoteConfig.bind(this));this.mo?i.dispose():(this._o=i,this.startIfEnabled())}dispose(){var t;this.mo||(this.mo=!0,this.uo=void 0,null===(t=this._o)||void 0===t||t.dispose(),this._o=void 0,this.wo())}lo(){return this.co.refresh(this.Mr),this.Mr}bo(){var t,i;return this.lo(),this.Mr.url_allowlist=null===(t=this.Mr.url_allowlist)||void 0===t?void 0:t.map(t=>new RegExp(t)),this.Mr.url_ignorelist=null===(i=this.Mr.url_ignorelist)||void 0===i?void 0:i.map(t=>new RegExp(t)),this.Mr}ko(){if(!this.isBrowserSupported())return void ru.info("Disabling Automatic Event Collection because this browser is not supported");if(!t||!s)return;const i=this.So=i=>{i=i||(null==t?void 0:t.event);try{if("blur"===i.type)return void this.Js();if(0===i.type.indexOf("pointer"))return void this.ao(i);const t="click"===i.type?this.ho(i):void 0;if(A(t))return;this.xo(i,"$autocapture",t)}catch(t){ru.error("Failed to capture event",t)}};if(Ln(t,"blur",i),Ln(s,"submit",i,{capture:!0}),Ln(s,"change",i,{capture:!0}),Ln(s,"click",i,{capture:!0}),Fn(["pointerdown","pointermove","pointerup","pointercancel"],t=>{Ln(s,t,i,{capture:!0})}),this.lo().capture_copied_text){const i=this.Co=i=>{i=i||(null==t?void 0:t.event);try{this.xo(i,nu)}catch(t){ru.error("Failed to capture clipboard event",t)}};Ln(s,"copy",i,{capture:!0}),Ln(s,"cut",i,{capture:!0}),Ln(s,"paste",i,{capture:!0})}}wo(){this.Js(),this.So&&(null==t||t.removeEventListener("blur",this.So),Fn(["pointerdown","pointermove","pointerup","pointercancel"],t=>{null==s||s.removeEventListener(t,this.So,!0)}),null==s||s.removeEventListener("submit",this.So,!0),null==s||s.removeEventListener("change",this.So,!0),null==s||s.removeEventListener("click",this.So,!0),this.So=void 0),this.Co&&(null==s||s.removeEventListener("copy",this.Co,!0),null==s||s.removeEventListener("cut",this.Co,!0),null==s||s.removeEventListener("paste",this.Co,!0),this.Co=void 0),this.do=!1}startIfEnabled(){this.isEnabled||this.Js(),!this.mo&&this.uo&&this.isEnabled&&!this.do&&(this.ko(),this.do=!0)}onRemoteConfig(t){if(this.mo)return;if(this.fo=!0,!t.ok)return void this.startIfEnabled();const i=t.config;i.elementsChainAsString&&(this.po=i.elementsChainAsString);const e=i.autocapture_opt_out;var s;B(e)&&(null===(s=this.uo)||void 0===s||s.kv.set("$autocapture_disabled_server_side",e),this.vo=e),this.startIfEnabled()}setElementSelectors(t){this.yo=t}getElementSelectors(t,i){var e;const n=[];return null===(e=this.yo)||void 0===e||e.forEach(e=>{const r=null==s?void 0:s.querySelectorAll(e);null==r||r.forEach(s=>{t!==s&&i!==s||b(n,e)||n.push(e)})}),n}get isEnabled(){var t,i;if(this.mo)return!1;const e=null===(t=this.uo)||void 0===t?void 0:t.kv.get(ts),s=this.vo,n=this.lo();if(!n.remoteRequestsDisabled&&!this.fo)return!1;const r=n.remoteRequestsDisabled&&!this.fo;if(A(s)&&!B(e)&&!r)return!1;const o=null!==(i=this.vo)&&void 0!==i?i:!!e;return!!n.enabled&&!o}xo(i,e="$autocapture",s){if(!this.isEnabled)return void this.Js();let n=s||Pr(i);yr(n)&&(n=n.parentNode||null);const r=this.bo();var o;"$autocapture"===e&&"click"===i.type&&i instanceof MouseEvent&&r.rageclick&&(null===(o=this.rageclicks)||void 0===o?void 0:o.isRageClick(i.clientX,i.clientY,i.timeStamp||(new Date).getTime()))&&Br(n,r.rageclick)&&this.xo(i,"$rageclick",s);const l=e===nu,a=l?wi(wi({},r),{},{dom_event_allowlist:void 0}):r;if(n&&function(i,e,s,n,r,o){var l;if(!t||Lr(i))return!1;if((null==s?void 0:s.url_allowlist)&&!xr(s.url_allowlist,o))return!1;if((null==s?void 0:s.url_ignorelist)&&xr(s.url_ignorelist,o))return!1;if(null==s?void 0:s.dom_event_allowlist){const t=s.dom_event_allowlist;if(t&&!t.some(t=>e.type===t))return!1}const{parentIsUsefulElement:a,targetElementList:u}=Nr(i,n);if(!function(t,i){const e=null==i?void 0:i.element_allowlist;if(I(e))return!0;for(const i of t)if(e.some(t=>i.tagName.toLowerCase()===t))return!0;return!1}(u,s))return!1;if(!Fr(u,null==s?void 0:s.css_selector_allowlist))return!1;if(Fr(u,null!==(l=null==s?void 0:s.css_selector_ignorelist)&&void 0!==l?l:Or))return!1;try{const s=t.getComputedStyle(i);if(s&&"pointer"===s.getPropertyValue("cursor")&&"click"===e.type)return!0}catch(t){}const h=i.tagName.toLowerCase();switch(h){case"html":return!1;case"form":return(r||["submit"]).indexOf(e.type)>=0;case"input":case"select":case"textarea":return(r||["change","click"]).indexOf(e.type)>=0;default:return a?(r||["click"]).indexOf(e.type)>=0:(r||["click"]).indexOf(e.type)>=0&&(Tr.indexOf(h)>-1||"true"===i.getAttribute("contenteditable"))}}(n,i,a,l,l?["copy","cut","paste"]:void 0,{config:{get_current_url:r.getCurrentUrl}})){var u;const{props:s,explicitNoCapture:o,target:l}=au(n,{e:i,maskAllElementAttributes:r.maskAllElementAttributes,maskAllText:r.maskAllText,elementAttributeIgnoreList:r.element_attribute_ignorelist,elementsChainAsString:this.po,disableCaptureUrlHashes:r.disableCaptureUrlHashes});if(o)return!1;const a=this.getElementSelectors(n,l);if(a&&a.length>0&&(s.$element_selectors=a),e===nu){const e=i.type||"clipboard";if("paste"!==e){var h,d;const i=null==t||null===(h=t.getSelection())||void 0===h?void 0:h.toString(),e=kr(i);if(!e)return!1;s.$selected_content=e,s.$clipboard_text_length=null!==(d=null==i?void 0:i.length)&&void 0!==d?d:0}s.$copy_type=e}return null===(u=this.uo)||void 0===u||u.capture(e,s).catch(t=>ru.error("Failed to capture event",t)),!0}}isBrowserSupported(){return T(null==s?void 0:s.querySelectorAll)}},hu=class{constructor(t){this._instance=t}refresh(t){const i=this._instance.config,e=C(i.autocapture)?i.autocapture:void 0;t.enabled=!!i.autocapture,t.rageclick=i.rageclick,t.maskAllElementAttributes=i.mask_all_element_attributes,t.maskAllText=i.mask_all_text,t.disableCaptureUrlHashes=i.disable_capture_url_hashes,t.getCurrentUrl=i.get_current_url,t.remoteRequestsDisabled=this._instance.Vl(),t.url_allowlist=null==e?void 0:e.url_allowlist,t.url_ignorelist=null==e?void 0:e.url_ignorelist,t.dom_event_allowlist=null==e?void 0:e.dom_event_allowlist,t.element_allowlist=null==e?void 0:e.element_allowlist,t.css_selector_allowlist=null==e?void 0:e.css_selector_allowlist,t.css_selector_ignorelist=null==e?void 0:e.css_selector_ignorelist,t.element_attribute_ignorelist=null==e?void 0:e.element_attribute_ignorelist,t.capture_copied_text=null==e?void 0:e.capture_copied_text}};const du=Be("[ExceptionAutocapture]"),cu=()=>{},vu=t=>{var i;if(T(t))return null!==(i=t.__posthog_layer__)&&void 0!==i?i:t.__rrweb_layer__};function fu(t,i,e){try{if(!(i in t))return cu;const s={next:t[i]},n=e(function(...t){return s.next.apply(this,t)});return T(n)&&(n.prototype=n.prototype||{},Object.defineProperties(n,{__posthog_wrapped__:{enumerable:!1,value:!0},__posthog_layer__:{enumerable:!1,value:s}})),t[i]=n,()=>{if(t[i]===n)return void(t[i]=s.next);let e=t[i],r=vu(e);for(;r;){if(r.next===n)return void(r.next=s.next);e=r.next,r=vu(e)}}}catch(t){return cu}}const pu=Be("[TracingHeaders]"),gu=Be("[Web Vitals]"),_u=9e5,mu=["CLS","FCP","INP","LCP"],bu=["INP","LCP"],yu=["interactionTarget","interactionType","inputDelay","processingDuration","presentationDelay","loadState","target","url","timeToFirstByte","resourceLoadDelay","resourceLoadDuration","elementRenderDelay","largestShiftTarget","largestShiftTime","largestShiftValue","firstByteToFCP"],wu="disabled",$u="lazy_loading",xu=Be("[SessionRecording]"),Su=Be("[Heatmaps]");function ku(t){return C(t)&&"clientX"in t&&"clientY"in t&&D(t.clientX)&&D(t.clientY)}const Eu=Be("[Product Tours]"),Pu=t=>{var i;return!t.config.disable_product_tours&&!!(null===(i=t.persistence)||void 0===i?void 0:i.get_property(ls))},Tu=["$set_once","$set"],Cu=Be("[SiteApps]"),Fu="Error while initializing PostHog app with config id ",Iu=(t,i)=>(null==t?void 0:t.then)?t.then(i):i(t),Ou="SDK is not enabled or survey functionality is not yet loaded",Ru="Disabled. Not loading surveys.";var Au=class{constructor(t,i){this.co=t,this.uh=i,this.name="surveys",this._surveyEventReceiver=null,this._surveyManager=null,this.hh=!1,this.dh=[],this.fh=null,this.ph=null,this.mo=!1,this.gh=new Set,this.onRemoteConfig=t=>{if(this.mo)return;if(this.Mr.disableSurveys)return;if(!t.ok)return Ta.warn("Remote config unavailable. Not loading surveys.");const i=t.config.surveys;if(M(i))return Ta.warn("Flags not loaded yet. Not loading surveys.");this.mh=B(i)?i:i.length>0,Ta.info(`flags response received, isSurveysEnabled: ${this.mh}`),this.loadIfEnabled()}}setup(t){if(!this.mo)return this.yh=t,Iu(t.kv.initialize(),()=>{if(this.yh!==t||this.mo)return;this.yh=void 0,this.uo=t;const i=t.onRemoteConfig(this.onRemoteConfig);this.mo?i.dispose():(this._o=i,this.loadIfEnabled())})}dispose(){var t,i,e,s;this.mo||(this.mo=!0,this.yh=void 0,this.uo=void 0,null===(t=this._o)||void 0===t||t.dispose(),this._o=void 0,null===(i=this._surveyEventReceiver)||void 0===i||i.dispose(),this._surveyEventReceiver=null,null===(e=this._surveyManager)||void 0===e||null===(s=e.dispose)||void 0===s||s.call(e),this._surveyManager=null,this.dh=[],this.fh=null,this.gh.forEach(t=>clearTimeout(t)),this.gh.clear())}get Mr(){return this.co.get()}initialize(){this.loadIfEnabled()}reset(){try{var t;null===(t=this._surveyEventReceiver)||void 0===t||t.reset(),localStorage.removeItem("lastSeenSurveyDate");const i=[];for(let t=0;t<localStorage.length;t++){const e=localStorage.key(t);((null==e?void 0:e.startsWith("seenSurvey_"))||(null==e?void 0:e.startsWith("inProgressSurvey_")))&&i.push(e)}i.forEach(t=>localStorage.removeItem(t))}catch(t){}}loadIfEnabled(){if(this.mo||!this.uo)return;const t=this.Mr;if(this._surveyManager)return;if(this.hh)return void Ta.info("Already initializing surveys, skipping...");if(t.disableSurveys)return void Ta.info(Ru);if(t.cookielessMode&&this.co.isOptedOut())return void Ta.info("Not loading surveys in cookieless mode without consent.");const i=this.co.getExtensions();if(!i)return void Ta.error("PostHog Extensions not found.");if(I(this.mh)&&!t.advancedEnableSurveys)return;const e=this.mh||t.advancedEnableSurveys;this.hh=!0;try{const t=i.generateSurveys;if(t)return this.bh(t,e),void(this.hh=!1);const s=i.loadExternalDependency;if(!s)return this._h(bn),void(this.hh=!1);s(t=>{try{if(this.mo)return;const i=this.co.getExtensions();t||!(null==i?void 0:i.generateSurveys)?this._h("Could not load surveys script",t):this.bh(i.generateSurveys,e)}finally{this.hh=!1}})}catch(t){throw this.hh=!1,this._h("Error initializing surveys",t),t}}bh(t,i){this.mo||(this._surveyManager=t(i),this._surveyEventReceiver=this.co.createEventReceiver(),Ta.info("Surveys loaded successfully"),this.wh({isLoaded:!0}))}_h(t,i){Ta.error(t,i),this.wh({isLoaded:!1,error:t})}onSurveysLoaded(t){return this.dh.push(t),this._surveyManager&&this.wh({isLoaded:!0}),()=>{this.dh=this.dh.filter(i=>i!==t)}}getSurveys(t,i=!1){var e;const s=null!==(e=this.uo)&&void 0!==e?e:this.uh;if(!s||this.mo)return;if(this.Mr.disableSurveys)return Ta.info(Ru),t([]);const n=s.kv.get(Ds);if(n&&!i)return t(n,{isLoaded:!0}),void(this.kh()&&this.getSurveys(()=>{},!0));if(this.fh)return void this.fh.then(({surveys:i,context:e})=>{this.mo||t(i,e)}).catch(t=>Ta.error("Error in survey callback",t));const r=this.Sh("/api/surveys/",{method:"GET",query:{token:s.projectToken},sentAt:"query",timeoutMs:this.Mr.requestTimeoutMs}).then(t=>{try{return this.xh(s,t)}catch(t){return Ta.error("Error processing surveys response",t),this.xh(s,{statusCode:0,error:t})}},t=>this.xh(s,{statusCode:0,error:t}));this.fh=r;const o=()=>{this.fh===r&&(this.fh=null)};r.then(i=>{o(),this.mo||t(i.surveys,i.context)},o).catch(t=>Ta.error("Error in survey callback",t))}Sh(t,i){const e=this.uo;return e?e.sendRequest(t,i):new Promise(t=>t({statusCode:0,error:new Error(Ou)}))}xh(t,i){if(this.mo)return{surveys:[],context:{isLoaded:!1,error:Ou}};const e=i.statusCode;if(200!==e||!i.json){const t=`Surveys API could not be loaded, status: ${e}`;return 0!==e?Ta.error(t):i.error||Ta.warn(t),this.ph=Date.now(),{surveys:[],context:{isLoaded:!1,error:t}}}this.ph=null;const s=i.json.surveys||[],n=s.filter(t=>function(t){return!(!t.start_date||t.end_date)}(t)&&(_a(t)||function(t){var i;return!!(null===(i=t.conditions)||void 0===i||null===(i=i.actions)||void 0===i||null===(i=i.values)||void 0===i?void 0:i.length)}(t)));var r;return n.length>0&&(null===(r=this._surveyEventReceiver)||void 0===r||r.register(n)),t.kv.set({[Ds]:s,[js]:Date.now()}),{surveys:s,context:{isLoaded:!0}}}kh(){return this.Ch()&&!this.fh&&!this.$h()}Ch(){var t,i;const e=null===(t=null!==(i=this.uo)&&void 0!==i?i:this.uh)||void 0===t?void 0:t.kv.get(js);return D(e)&&Date.now()-e>3e5}$h(){return D(this.ph)&&3e5>Date.now()-this.ph}markSurveyAsSeen(t,i){var e;const s={id:t,current_iteration:null!==(e=null==i?void 0:i.iteration)&&void 0!==e?e:null};Ca(s);try{localStorage.setItem("lastSeenSurveyDate",(new Date).toISOString())}catch(t){}}wh(t){for(const i of this.dh)try{if(!t.isLoaded)return i([],t);this.getSurveys(i)}catch(t){Ta.error("Error in survey callback",t)}}getActiveMatchingSurveys(t,i=!1){if(!M(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(t,i);Ta.warn("init was not called")}Th(t){let i=null;return this.getSurveys(e=>{var s;i=null!==(s=e.find(i=>i.id===t))&&void 0!==s?s:null}),i}Ih(t){if(M(this._surveyManager))return{eligible:!1,reason:Ou};const i="string"==typeof t?this.Th(t):t;return i?this._surveyManager.checkSurveyEligibility(i):{eligible:!1,reason:"Survey not found"}}Mh(t){if(!this.co.isCapturing())return{eligible:!1,reason:"PostHog is not capturing, so a survey response cannot be recorded"};if(M(this._surveyManager))return{eligible:!1,reason:Ou};const i="string"==typeof t?this.Th(t):t;return i?this._surveyManager.checkSurveyRenderability(i):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(t){if(M(this._surveyManager))return Ta.warn("init was not called"),{visible:!1,disabledReason:Ou};const i=this.Mh(t);return{visible:i.eligible,disabledReason:i.reason}}canRenderSurveyAsync(t,i){return M(this._surveyManager)?(Ta.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:Ou})):new Promise(e=>{this.getSurveys(i=>{var s;const n=null!==(s=i.find(i=>i.id===t))&&void 0!==s?s:null;if(n){const t=this.Mh(n);e({visible:t.eligible,disabledReason:t.reason})}else e({visible:!1,disabledReason:"Survey not found"})},i)})}renderSurvey(t,i,e){var n;if(!this.co.isCapturing())return;if(M(this._surveyManager))return void Ta.warn("init was not called");const r="string"==typeof t?this.Th(t):t;if(!(null==r?void 0:r.id))return void Ta.warn("Survey not found");if(!Fa.includes(r.type))return void Ta.warn(`Surveys of type ${r.type} cannot be rendered in the app`);const o=null==s?void 0:s.querySelector(i);if(o){if(null===(n=r.appearance)||void 0===n?void 0:n.surveyPopupDelaySeconds){Ta.info(`Rendering survey ${r.id} with delay of ${r.appearance.surveyPopupDelaySeconds} seconds`);const t=setTimeout(()=>{var i,s;this.gh.delete(t),!this.mo&&this.co.isCapturing()&&(Ta.info(`Rendering survey ${r.id} with delay of ${null===(i=r.appearance)||void 0===i?void 0:i.surveyPopupDelaySeconds} seconds`),null===(s=this._surveyManager)||void 0===s||s.renderSurvey(r,o,e),Ta.info(`Survey ${r.id} rendered`))},1e3*r.appearance.surveyPopupDelaySeconds);return void this.gh.add(t)}this._surveyManager.renderSurvey(r,o,e)}else Ta.warn("Survey element not found")}displaySurvey(t,i){var e;if(!this.co.isCapturing())return;if(M(this._surveyManager))return void Ta.warn("init was not called");const s=this.Th(t);if(!s)return void Ta.warn("Survey not found");let n=s;if((null===(e=s.appearance)||void 0===e?void 0:e.surveyPopupDelaySeconds)&&i.ignoreDelay&&(n=wi(wi({},s),{},{appearance:wi(wi({},s.appearance),{},{surveyPopupDelaySeconds:0})})),i.displayType!==sl&&i.initialResponses&&Ta.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),!1===i.ignoreConditions){const t=this.Ih(s);if(!t.eligible)return void Ta.warn("Survey is not eligible to be displayed: ",t.reason)}"inline"!==i.displayType?this._surveyManager.handlePopoverSurvey(n,i):this.renderSurvey(n,i.selector,i.properties)}cancelPendingSurvey(t){M(this._surveyManager)?Ta.warn("init was not called"):this._surveyManager.cancelSurvey(t)}handlePageUnload(){var t,i;null===(t=this._surveyManager)||void 0===t||null===(i=t.handlePageUnload)||void 0===i||i.call(t)}};function Mu(t,i,e){if(M(t))return!1;switch(e){case"exact":return t===i;case"contains":{const e=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(e,"i").test(t)}case"regex":try{return new RegExp(i).test(t)}catch(t){return!1}default:return!1}}var Du=class{constructor(t){this._instance=t,this.Eh=new Set,this.Ph=new Set,this.Rh=new ha,this.Ah=(t,i)=>this.Fh(t,i)&&this.Oh(t,i)&&this.Dh(t,i)&&this.Lh(t,i),this.Fh=(t,i)=>!(null==i?void 0:i.event)||(null==t?void 0:t.event)===(null==i?void 0:i.event)}init(){var t,i;I(null===(t=this._instance)||void 0===t?void 0:t._addCaptureHook)||(this.Nh=null===(i=this._instance)||void 0===i?void 0:i._addCaptureHook((t,i)=>{this.on(t,i)}))}dispose(){var t;null===(t=this.Nh)||void 0===t||t.call(this),this.Nh=void 0,this.Rh=new ha}register(t){var i,e;if(!I(null===(i=this._instance)||void 0===i?void 0:i._addCaptureHook)&&(t.forEach(t=>{var i;this.Eh.add(t),null===(i=t.steps)||void 0===i||i.forEach(t=>{this.Ph.add((null==t?void 0:t.event)||"")})}),null===(e=this._instance)||void 0===e?void 0:e.autocapture)){const t=new Set;this.Eh.forEach(i=>{var e;null===(e=i.steps)||void 0===e||e.forEach(i=>{(null==i?void 0:i.selector)&&t.add(i.selector)})}),this._instance.autocapture.setElementSelectors(t)}}replace(t){this.Eh.clear(),this.Ph.clear(),this.register(t)}on(t,i){null!=i&&0!=t.length&&(this.Ph.has(t)||this.Ph.has(i.event))&&this.Eh.forEach(t=>{this.qh(i,t)&&this.Rh.emit("actionCaptured",t.name)})}jh(t){this.onAction("actionCaptured",i=>t(i))}qh(t,i){if(null==(null==i?void 0:i.steps))return!1;for(const e of i.steps)if(this.Ah(t,e))return!0;return!1}onAction(t,i){return this.Rh.on(t,i)}Oh(t,i){if(null==i?void 0:i.url){var e;const s=null==t||null===(e=t.properties)||void 0===e?void 0:e.$current_url;if(!s||"string"!=typeof s)return!1;if(!Mu(s,i.url,i.url_matching||"contains"))return!1}return!0}Dh(t,i){return!!this.Bh(t,i)&&!!this.Hh(t,i)&&!!this.zh(t,i)}Bh(t,i){var e;if(!(null==i?void 0:i.href))return!0;const s=this.Uh(t);if(s.length>0)return s.some(t=>Mu(t.href,i.href,i.href_matching||"exact"));const n=(null==t||null===(e=t.properties)||void 0===e?void 0:e.$elements_chain)||"";return!!n&&Mu(function(t){const i=t.match(/(?::|")href="(.*?)"/);return i?i[1]:""}(n),i.href,i.href_matching||"exact")}Hh(t,i){var e;if(!(null==i?void 0:i.text))return!0;const s=this.Uh(t);if(s.length>0)return s.some(t=>Mu(t.text,i.text,i.text_matching||"exact")||Mu(t.$el_text,i.text,i.text_matching||"exact"));const n=(null==t||null===(e=t.properties)||void 0===e?void 0:e.$elements_chain)||"";return!!n&&(r=function(t){const i=[],e=/(?::|")text="(.*?)"/g;let s;for(;!M(s=e.exec(t));)i.includes(s[1])||i.push(s[1]);return i}(n),o=i.text,l=i.text_matching||"exact",r.some(t=>Mu(t,o,l)));var r,o,l}zh(t,i){var e,s;if(!(null==i?void 0:i.selector))return!0;const n=null==t||null===(e=t.properties)||void 0===e?void 0:e.$element_selectors;if(null==n?void 0:n.includes(i.selector))return!0;const r=(null==t||null===(s=t.properties)||void 0===s?void 0:s.$elements_chain)||"";if(i.selector_regex&&r)try{return new RegExp(i.selector_regex).test(r)}catch(t){return!1}return!1}Uh(t){var i;return null==(null==t||null===(i=t.properties)||void 0===i?void 0:i.$elements)?[]:null==t?void 0:t.properties.$elements}Lh(t,i){return!(null==i?void 0:i.properties)||0===i.properties.length||wa(i.properties.reduce((t,i)=>{const e=P(i.value)?i.value.map(String):null!=i.value?[String(i.value)]:[];return t[i.key]={values:e,operator:i.operator||"exact"},t},{}),null==t?void 0:t.properties)}},ju=class{constructor(t){var i,e;this.Wh=[],this._instance=t,this.Vh=new Map,this.Gh=new Map,this.Zh=new Map,this.Qh=null===(i=this._instance)||void 0===i||null===(e=i.onSessionId)||void 0===e?void 0:e.call(i,t=>this.Jh(t))}Kh(t){return!1}Yh(){return null}Xh(t){}tc(){}ec(t,i){return!!t&&wa(t.propertyFilters,null==i?void 0:i.properties)}nc(t,i){const e=new Map;return t.forEach(t=>{var s;null===(s=t.conditions)||void 0===s||null===(s=s[i])||void 0===s||null===(s=s.values)||void 0===s||s.forEach(i=>{if(null==i?void 0:i.name){const s=e.get(i.name)||[];s.push(t.id),e.set(i.name,s)}})}),e}sc(t,i,e){const s=(e===Xo?this.Vh:this.Gh).get(t);let n=[];return this.rc(t=>{n=t.filter(t=>null==s?void 0:s.includes(t.id))}),n.filter(s=>{var n;const r=null===(n=s.conditions)||void 0===n||null===(n=n[e])||void 0===n||null===(n=n.values)||void 0===n?void 0:n.find(i=>i.name===t);return this.ec(r,i)})}register(t){this.oc(t,!1)}replace(t){this.oc(t,!0)}oc(t,i){var e;I(null===(e=this._instance)||void 0===e?void 0:e._addCaptureHook)||(this.lc(t,i),this.ac(t,i))}ac(t,i){const e=t.filter(t=>{var i;return null===(i=t.conditions)||void 0===i||null===(i=i.actions)||void 0===i||null===(i=i.values)||void 0===i?void 0:i.length});var s;if(i&&this.Zh.clear(),0===e.length)return void(i&&(null===(s=this.uc)||void 0===s||s.replace([])));this.uc||(this.uc=new Du(this._instance),this.uc.init(),this.uc.jh(t=>this.onAction(t)));const n=[];e.forEach(t=>{var i;null===(i=t.conditions)||void 0===i||null===(i=i.actions)||void 0===i||i.values.forEach(i=>{if(n.push(i),i.name){var e;const s=null!==(e=this.Zh.get(i.name))&&void 0!==e?e:[];s.includes(t.id)||s.push(t.id),this.Zh.set(i.name,s)}})}),i?this.uc.replace(n):this.uc.register(n)}hc(t,i){i.forEach((i,e)=>{var s;const n=null!==(s=t.get(e))&&void 0!==s?s:[];i.forEach(t=>{n.includes(t)||n.push(t)}),t.set(e,n)})}lc(t,i){var e,s;const n=t.filter(t=>{var i,e;return(null===(i=t.conditions)||void 0===i?void 0:i.events)&&(null===(e=t.conditions)||void 0===e||null===(e=e.events)||void 0===e||null===(e=e.values)||void 0===e?void 0:e.length)>0}),r=t.filter(t=>{var i,e;return(null===(i=t.conditions)||void 0===i?void 0:i.cancelEvents)&&(null===(e=t.conditions)||void 0===e||null===(e=e.cancelEvents)||void 0===e||null===(e=e.values)||void 0===e?void 0:e.length)>0}),o=this.nc(t,Xo),l=this.nc(t,Zo);i?(this.Vh=o,this.Gh=l):(this.hc(this.Vh,o),this.hc(this.Gh,l)),(0!==n.length||0!==r.length)&&(null!==(e=this.Nh)&&void 0!==e||(this.Nh=null===(s=this._instance)||void 0===s?void 0:s._addCaptureHook((t,i)=>{this.onEvent(t,i)})))}onEvent(t,i){var e,s;const n=this.cc(),r=(null==i||null===(e=i.properties)||void 0===e?void 0:e.$survey_id)||(null==i||null===(s=i.properties)||void 0===s?void 0:s.$product_tour_id);if(r&&this.getActivatedIds().includes(r)){const i=this.dc(t,r);if("consume"===i)return n.info("event consumed activated item, removing it",{event:t,itemId:r}),void this.vc([r]);if("persist"===i)return n.info("shown item promoted to persisted activation",{event:t,itemId:r}),this.fc(r),void this.gc([r])}if(this.Gh.has(t)){const e=this.sc(t,i,Zo);e.length>0&&(n.info("cancel event matched, cancelling items",{event:t,itemsToCancel:e.map(t=>t.id)}),this.vc(e.map(t=>t.id)),e.forEach(t=>this.mc(t.id)))}if(!this.Vh.has(t))return;n.info("event name matched",{event:t,eventPayload:i,items:this.Vh.get(t)});const o=this.sc(t,i,Xo);this.yc(o.map(t=>t.id))}onAction(t){this.Zh.has(t)&&this.yc(this.Zh.get(t)||[])}yc(t){var i,e;if(0===t.length)return;const s=!!(null===(i=this._instance)||void 0===i||null===(e=i.get_session_id)||void 0===e?void 0:e.call(i)),n=[];for(const i of t)s&&this.Kh(i)?this.fc(i)&&this.bc(i):n.push(i);n.length>0&&(this.Wh=[...new Set([...this.Wh,...n])]),this.cc().info("updating activated items",{activatedItems:this.getActivatedIds()})}fc(t){this.Wh=this.Wh.filter(i=>i!==t);const i=this._c();return!i.includes(t)&&(this.wc([...i,t]),this.kc(),!0)}vc(t){const i=new Set(t);this.Wh=this.Wh.filter(t=>!i.has(t));const e=this.Sc(),s=e.filter(t=>!i.has(t));s.length!==e.length&&(this.wc(s),0===s.length&&this.xc()),this.gc(t)}Cc(){var t;const i=this.Yh();if(!i)return{};const e=null===(t=this._instance)||void 0===t||null===(t=t.persistence)||void 0===t?void 0:t.props[i];return e&&"object"==typeof e?e:{}}bc(t){if(!this.Yh())return;const i=this.Cc();this.Xh(wi(wi({},i),{},{[t]:Date.now()}))}gc(t){if(!this.Yh())return;const i=this.Cc(),e={};let s=!1;for(const[n,r]of Object.entries(i))t.includes(n)?s=!0:e[n]=r;s&&(F(e)?this.tc():this.Xh(e))}$c(){this.Yh()&&this.tc()}getActivationTimestamp(t){if(!this._c().includes(t))return;const i=this.Cc()[t];return D(i)?i:void 0}Sc(){var t;const i=this.Tc();return(null===(t=this._instance)||void 0===t||null===(t=t.persistence)||void 0===t?void 0:t.props[i])||[]}_c(){var t,i,e;const s=this.Sc();if(0===s.length)return[];const n=null===(t=this._instance)||void 0===t||null===(t=t.persistence)||void 0===t?void 0:t.props[this.Ic()],r=null===(i=this._instance)||void 0===i||null===(e=i.get_session_id)||void 0===e?void 0:e.call(i);return r&&n===r?s:[]}kc(){var t,i;const e=null===(t=this._instance)||void 0===t||null===(i=t.get_session_id)||void 0===i?void 0:i.call(t);e&&this.Mc(e)}xc(){this.Ec()}Jh(t){var i;const e=null===(i=this._instance)||void 0===i||null===(i=i.persistence)||void 0===i?void 0:i.props[this.Ic()];if(e&&e!==t){const t=this.Sc(),i=this.Cc();t.length>0&&(this.wc([]),t.filter(t=>D(i[t])).forEach(t=>this.mc(t))),this.xc(),this.$c()}}getActivatedIds(){return[...new Set([...this._c(),...this.Wh])].filter(t=>!this.Pc(t))}dispose(){var t,i,e;null===(t=this.Qh)||void 0===t||t.call(this),this.Qh=void 0,null===(i=this.Nh)||void 0===i||i.call(this),this.Nh=void 0,null===(e=this.uc)||void 0===e||e.dispose(),this.uc=void 0}reset(){this.Wh=[],this.Sc().length>0&&this.wc([]),this.xc(),this.$c()}getEventToItemsMap(){return this.Vh}Rc(){return this.uc}},Bu=class extends ju{constructor(t){super(t)}Tc(){return Bs}Ic(){return Ls}Yh(){return Ns}Xh(t){var i;null===(i=this._instance)||void 0===i||null===(i=i.persistence)||void 0===i||i.register({$surveys_activated_timestamps:t})}tc(){var t;null===(t=this._instance)||void 0===t||null===(t=t.persistence)||void 0===t||t.unregister("$surveys_activated_timestamps")}Kh(t){var i;let e;this.rc(i=>{e=i.find(i=>i.id===t)});const s=null==e||null===(i=e.appearance)||void 0===i?void 0:i.surveyPopupDelaySeconds;return D(s)&&s>0}Ac(){return Qo}rc(t){var i;null===(i=this._instance)||void 0===i||i.getSurveys(t)}mc(t){var i;null===(i=this._instance)||void 0===i||i.cancelPendingSurvey(t)}cc(){return Ta}wc(t){var i;null===(i=this._instance)||void 0===i||null===(i=i.persistence)||void 0===i||i.register({$surveys_activated:t})}Mc(t){var i;null===(i=this._instance)||void 0===i||null===(i=i.persistence)||void 0===i||i.register({$surveys_activated_session:t})}Ec(){var t;null===(t=this._instance)||void 0===t||null===(t=t.persistence)||void 0===t||t.unregister("$surveys_activated_session")}Pc(){return!1}dc(t,i){let e;return this.rc(t=>{e=t.find(t=>t.id===i)}),!e||function(t){var i;return _a(t)&&!!(null===(i=t.conditions)||void 0===i||null===(i=i.events)||void 0===i?void 0:i.repeatedActivation)||"always"===t.schedule}(e)?t===Qo?"consume":"ignore":t===Qo?"persist":t===tl||t===il?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},Lu=class{constructor(t){this._instance=t}initialize(){}get(t){if("string"==typeof t)return this._instance.get_property(t);const i={};for(const e of t){const t=this._instance.get_property(e);I(t)||(i[e]=t)}return i}set(t,i){this._instance.register("string"==typeof t?{[t]:i}:t)}remove(t){"string"!=typeof t?t.forEach(t=>this._instance.unregister(t)):this._instance.unregister(t)}},Nu=class{constructor(t){this._instance=t}get(){const t=this._instance.config;return{disableSurveys:t.disable_surveys,cookielessMode:!!t.cookieless_mode,advancedEnableSurveys:t.advanced_enable_surveys,requestTimeoutMs:t.surveys_request_timeout_ms}}isOptedOut(){return this._instance.consent.isOptedOut()}isCapturing(){return this._instance.is_capturing()}getExtensions(){const t=null==c?void 0:c.__PosthogExtensions__;if(!t)return;const{generateSurveys:i,loadExternalDependency:e}=t;return{generateSurveys:i?t=>i(this._instance,t):void 0,loadExternalDependency:e?t=>e(this._instance,"surveys",t):void 0}}createEventReceiver(){return new Bu(this._instance)}};const zu=(null==t?void 0:t.location)?yo(t.location.hash,"__posthog")||yo(location.hash,"state"):null,Uu="_postHogToolbarParams",Hu=Be("[Toolbar]"),qu=Be("[FeatureFlags]");var Vu=class{constructor(t,i=!1){this.Fc=!1,this.update(t,i)}update(t,i){this.Oc=((t,i)=>{var e,s,n,r,o,l,a;return{bootstrap:{featureFlags:null!==(e=null===(s=t.bootstrap)||void 0===s?void 0:s.featureFlags)&&void 0!==e?e:void 0,featureFlagPayloads:null!==(n=null===(r=t.bootstrap)||void 0===r?void 0:r.featureFlagPayloads)&&void 0!==n?n:void 0},remoteRequestsDisabled:i,featureFlagsDisabled:!!t.advanced_disable_feature_flags,onlyEvaluateSurveyFeatureFlags:!!t.advanced_only_evaluate_survey_feature_flags,deduplicateCallsPerSession:!!t.advanced_feature_flags_dedup_per_session,cacheTtlMs:t.feature_flag_cache_ttl_ms,refreshIntervalMs:null!==(o=t.remote_config_refresh_interval_ms)&&void 0!==o?o:3e5,requestTimeoutMs:t.feature_flag_request_timeout_ms,compression:t.disable_compression?void 0:"best-available",evaluationContexts:null!==(l=null!==(a=t.evaluation_contexts)&&void 0!==a?a:t.evaluation_environments)&&void 0!==l?l:[],flagKeys:P(t.flag_keys)?t.flag_keys:void 0}})(t,i),!t.evaluation_environments||t.evaluation_contexts||this.Fc||(qu.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.Fc=!0),I(t.flag_keys)||P(t.flag_keys)||qu.error("Invalid flag_keys found:",t.flag_keys,"Expected array of non-empty strings")}get(){return this.Oc}};const Wu=Be("[FeatureFlags]"),Gu=Be("[FeatureFlags]",{debugEnabled:!0}),Ku="\" failed. Feature flags didn't load in time.",Ju="connection_error",Yu=t=>{const i={};for(let e=0;t.length>e;e++)i[t[e]]=!0;return i},Xu=t=>{const i={};for(const[e,s]of On(t||{}))s&&(i[e]=s);return i},Zu=t=>H(t)&&("RangeError"===t.name&&0===t.message.indexOf("Maximum call stack size exceeded")||"InternalError"===t.name&&"too much recursion"===t.message),Qu=Be("[Error tracking]"),th="webkit-masked-url:",ih=[{value:"isolatedAPI.contexts.topHostname",exact:!1},{value:"No response from target",exact:!0}],eh=["chrome-extension://","moz-extension://","safari-extension:","safari-web-extension:",th],sh=["__firefox__","__gCrWeb"],nh="Refusing to render web experiment since the viewer is a likely bot",rh={icontains:(t,i)=>i.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,i)=>-1===i.toLowerCase().indexOf(t.toLowerCase()),regex:(t,i)=>ma(i,t),not_regex:(t,i)=>!ma(i,t),exact:(t,i)=>i===t,is_not:(t,i)=>i!==t},oh=Be("[Conversations]"),lh="Conversations not available yet.";function ah(t,i){var s,n,r,o,l,a,u;const h=null!==(s=null==t?void 0:t.flushIntervalMs)&&void 0!==s?s:3e3,d=null!==(n=null==t?void 0:t.maxBufferSize)&&void 0!==n?n:100,c=(null==i?void 0:i.consoleCapture)?void 0:null!==(r=null==t?void 0:t.maxLogsPerInterval)&&void 0!==r?r:1e3,v=I(c)?Math.max(d,2048):Math.max(d,c),f=wi(wi({},function(){let t="",i="";try{const s=null==e?void 0:e.userAgent;s&&([t,i]=Qt(s))}catch(t){}return function(t,i){const e=function(t){if(t)return{}.hasOwnProperty.call(Se,t)?Se[t]:t}(t);return wi(wi({},e?{"os.name":e}:{}),i?{"os.version":i}:{})}(t,i)}()),null==t?void 0:t.resourceAttributes);return{serviceName:null!==(o=null!==(l=null==f?void 0:f["service.name"])&&void 0!==l?l:null==t?void 0:t.serviceName)&&void 0!==o?o:null==i?void 0:i.serviceNameDefault,serviceVersion:null!==(a=null==f?void 0:f["service.version"])&&void 0!==a?a:null==t?void 0:t.serviceVersion,environment:null!==(u=null==f?void 0:f["deployment.environment"])&&void 0!==u?u:null==t?void 0:t.environment,resourceAttributes:f,beforeSend:null==t?void 0:t.beforeSend,flushIntervalMs:h,maxBufferSize:d,maxQueueSize:v,maxBatchRecordsPerPost:100,rateCapWindowMs:h,maxLogsPerInterval:c,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}}const uh=["debug","log","warn","error","info"],hh=t=>{for(;null==t?void 0:t.__rrweb_original__;)t=t.__rrweb_original__;return t},dh="console",ch="__posthogHandledLogsRequestError",vh=(t,i)=>{const e=t instanceof Error?t:new Error(i);return e[ch]=!0,e},fh=t=>!!t&&"object"==typeof t&&!0===t[ch],ph={featureFlags:class{constructor(t){this.name="featureFlags",this.Dc=!1,this.featureFlagEventHandlers=[],this.$=Wu,this.Lc={},this.Nc={},this.qc=[],this.jc=!1,this.Bc=!1,this.Hc=0,this.zc=!1,this.Uc=!1,this.Wc=!1,this.Vc=!1,this.Gc=0,this.sn=()=>{const t=this.Zc();this.Gc=0,t&&this.reloadFeatureFlags()},this.Qc=()=>{var t;const i=this.Jc;I(i)||this.Mr.remoteRequestsDisabled||!s||"hidden"===s.visibilityState||Date.now()-(null!==(t=this.Kc)&&void 0!==t?t:0)<i||(this.reloadFeatureFlags(),this.Yc())},this.an=()=>{"visible"===(null==s?void 0:s.visibilityState)&&this.Qc()},"get"in t?this.co=t:(this._instance=t,this.Xc=new Vu(t.config,t.Vl()),this.co=this.Xc)}updateConfig(t,i){var e;null===(e=this.Xc)||void 0===e||e.update(t,i),this.uo&&this.td()}setup(t){return this.yh=t,this.$=t.logger.createLogger("[FeatureFlags]"),Iu(t.kv.initialize(),()=>{this.yh===t&&(this.yh=void 0,this.uo=t,this.ed(t))})}ed(i){var e;if(this.uo===i)return t&&Ln(t,"online",this.sn),this.td(),this.nd=i.registerDynamicEventProperties(()=>this.sd()?this.Lc:this.Nc),this.rd=null===(e=this._instance)||void 0===e||null===(e=e.persistence)||void 0===e?void 0:e.onCrossTabFeatureFlagChange(()=>{this.od(),this.ld(),this.ad()}),this.ld(),this.initialize()}td(){const t=this.Mr.refreshIntervalMs,i=!this.Mr.remoteRequestsDisabled&&s&&!I(t)&&t>0?t:void 0;i!==this.Jc&&(this.ud(),I(i)||(this.Jc=i,this.Yc(),(null==s?void 0:s.addEventListener)&&Ln(s,xn,this.an)))}Yc(){I(this.Jc)||(I(this.hd)||clearInterval(this.hd),this.Kc=Date.now(),this.hd=setInterval(this.Qc,this.Jc))}ud(){var t;I(this.hd)||(clearInterval(this.hd),this.hd=void 0,null==s||null===(t=s.removeEventListener)||void 0===t||t.call(s,"visibilitychange",this.an)),this.Jc=void 0,this.Kc=void 0}destroy(){this.dd()}dispose(){this.dd()}dd(){var i,e;this.ud(),this.Hc++,this.Uc=!1,this.yh=void 0,this.uo&&(this.vd(),null===(i=this.nd)||void 0===i||i.dispose(),this.nd=void 0,null===(e=this.rd)||void 0===e||e.call(this),this.rd=void 0,this.qc=[],null==t||t.removeEventListener("online",this.sn),this.uo=void 0)}get Mr(){return this.co.get()}fd(t){var i;return this.pd&&t in this.pd?this.pd[t]:null===(i=this.uo)||void 0===i?void 0:i.kv.get(t)}od(){return!!this.pd&&(this.pd=void 0,!0)}gd(){var t;return!I(null===(t=this.uo)||void 0===t?void 0:t.kv.get("$enabled_feature_flags"))&&this.od()}At(t){this.md(()=>{var i;return null===(i=this.uo)||void 0===i?void 0:i.kv.set(t)})}yd(t,i,e){var s;if(!(null===(s=this._instance)||void 0===s?void 0:s.persistence)||!t.$enabled_feature_flags)return;const n=this.fd("$enabled_feature_flags")||{},r=t.$enabled_feature_flags||{},o=i.flags||i.featureFlags,l=i.flags?Object.entries(i.flags).filter(([,t])=>!(null==t?void 0:t.failed)).map(([t])=>t):[],a=!!i.errorsWhileComputingFlags&&!!i.flags,u=a?l:e&&!P(o)?Object.keys(o||{}):Array.from(new Set([...Object.keys(n),...Object.keys(r)])),h=this.fd("$feature_flag_payloads")||{},d=t.$feature_flag_payloads||{},c=a||e?u:Array.from(new Set([...Object.keys(h),...Object.keys(d)])),v=!a&&!e,f=!!v||u,p=!!v||c,g={[ks]:f,[Ss]:f,[Ts]:p};t.$feature_flag_details&&(g[Ps]=f);for(const i of[Cs,Xs,Fs])I(t[i])||(g[i]=!0);this._instance.persistence.markCrossTabFeatureFlagChanges(g)}Lt(t){this.md(()=>{var i;return null===(i=this.uo)||void 0===i?void 0:i.kv.remove(t)})}md(t){try{t()}catch(t){this.$.error("Failed to update feature flag persistence",t)}}ld(){const t={};for(const i of[ks,Ts,Cs,Is]){const e=this.fd(i);I(e)||(t[i]=e)}this.Lc=t;const i=wi({},t),e=this.fd(Ss);if(e)for(const[t,s]of Object.entries(e))i[`$feature/${t}`]=s;this.Nc=i}sd(){const t=this.Mr.cacheTtlMs;if(!t||0>=t)return!1;const i=this.fd(Xs);return"number"!=typeof i||Date.now()-i>t}bd(){return!!this.sd()&&(this.Vc||this.Bc||(this.Vc=!0,this.$.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}_d(){const t=this.Mr.evaluationContexts;return(null==t?void 0:t.length)?t.filter(t=>{const i=t&&"string"==typeof t&&t.trim().length>0;return i||this.$.error("Invalid evaluation context found:",t,"Expected non-empty string"),i}):[]}wd(){const t=this.Mr.flagKeys;if(!I(t))return t.filter(t=>{const i=t&&"string"==typeof t&&t.trim().length>0;return i||this.$.error("Invalid flag key found:",t,"Expected non-empty string"),i})}initialize(){var t,i;const e=this.Mr,s=null!==(t=null===(i=e.bootstrap)||void 0===i?void 0:i.featureFlags)&&void 0!==t?t:{};if(Object.keys(s).length){var n,r;const t=null!==(n=null===(r=e.bootstrap)||void 0===r?void 0:r.featureFlagPayloads)&&void 0!==n?n:{},i=Object.keys(s).filter(t=>!I(s[t])).reduce((t,i)=>(t[i]=s[i],t),{}),o=Object.keys(t).filter(t=>i[t]).reduce((i,e)=>(i[e]=t[e],i),{});return this.kd({featureFlags:i,featureFlagPayloads:o},void 0,{persist:!1})}}updateFlags(t,i,e){var s,n;const r=(null==e?void 0:e.merge)&&null!==(s=this.fd("$enabled_feature_flags"))&&void 0!==s?s:{},o=(null==e?void 0:e.merge)&&null!==(n=this.fd("$feature_flag_payloads"))&&void 0!==n?n:{},l=wi(wi({},r),t),a=wi(wi({},o),i),u={};for(const[t,i]of Object.entries(l))u[t]={key:t,enabled:re(i),variant:oe(i),reason:void 0,metadata:I(null==a?void 0:a[t])?void 0:{id:0,version:void 0,description:void 0,payload:a[t]}};this.kd({flags:u})}get hasLoadedFlags(){return this.jc}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){const t=this.fd(Ps),i=this.fd(Is),e=this.fd(Os);if(!e&&!i)return t||{};const s=In({},t||{}),n=[...new Set([...Object.keys(e||{}),...Object.keys(i||{})])];for(const t of n){var r;const n=s[t],l=null==i?void 0:i[t],a=I(l)?null!==(r=null==n?void 0:n.enabled)&&void 0!==r&&r:!!l,u=I(l)?null==n?void 0:n.variant:"string"==typeof l?l:void 0,h=null==e?void 0:e[t],d=wi(wi({},n),{},{enabled:a,variant:a?null!=u?u:null==n?void 0:n.variant:void 0});var o;a!==(null==n?void 0:n.enabled)&&(d.original_enabled=null==n?void 0:n.enabled),u!==(null==n?void 0:n.variant)&&(d.original_variant=null==n?void 0:n.variant),h&&(d.metadata=wi(wi({},null==n?void 0:n.metadata),{},{payload:h,original_payload:null==n||null===(o=n.metadata)||void 0===o?void 0:o.payload})),s[t]=d}return this.Dc||(this.$.warn(" Overriding feature flag details!",{flagDetails:t,overriddenPayloads:e,finalDetails:s}),this.Dc=!0),s}getAllFeatureFlags(){const t=this.getFlagVariants(),i=this.getFlagPayloads();return Object.keys(t).map(e=>{const s=t[e];return{key:e,enabled:re(s),variant:oe(s),payload:ne(i[e])}})}getFlagVariants(){const t=this.fd(Ss),i=this.fd(Is);if(!i)return t||{};const e=In({},t||{}),s=Object.keys(i);for(let t=0;s.length>t;t++)e[s[t]]=i[s[t]];return this.Dc||(this.$.warn(" Overriding feature flags!",{enabledFlags:t,overriddenFlags:i,finalFlags:e}),this.Dc=!0),e}getFlagPayloads(){const t=this.fd(Ts),i=this.fd(Os);if(!i)return t||{};const e=In({},t||{}),s=Object.keys(i);for(let t=0;s.length>t;t++)e[s[t]]=i[s[t]];return this.Dc||(this.$.warn(" Overriding feature flag payloads!",{flagPayloads:t,overriddenPayloads:i,finalPayloads:e}),this.Dc=!0),e}reloadFeatureFlags(){this.zc||this.Mr.featureFlagsDisabled||this.Zc()||(this.Bc&&(this.Uc=!0),this.Sd||(this.qc.slice().forEach(t=>{try{t()}catch(t){this.$.error("Error while running feature flags reloading callback",t)}}),this.Sd=setTimeout(()=>{this.xd()},5)))}vd(){clearTimeout(this.Sd),this.Sd=void 0}onReloading(t){return this.qc.push(t),()=>{this.qc=this.qc.filter(i=>i!==t)}}ensureFlagsLoaded(){this.jc||this.Bc||this.Sd||this.reloadFeatureFlags()}setAnonymousDistinctId(t){this.$anon_distinct_id=t}setReloadingPaused(t){this.zc=t}resetFlagCallReported(){this.Lt(Ks)}xd(t){this.vd();const i=this.uo;if(!i||this.Mr.remoteRequestsDisabled||this.Zc())return;if(this.Bc)return void(this.Uc=!0);const e={token:i.projectToken,distinct_id:i.distinctId,groups:i.groups,$anon_distinct_id:this.$anon_distinct_id,person_properties:wi(wi(wi({},i.initialPersonProperties),this.fd("$stored_person_properties")||{}),{},{$lib:i.library.name,$lib_version:i.library.version}),group_properties:this.fd(As),timezone:Do()};I(i.deviceId)||(e.$device_id=i.deviceId),((null==t?void 0:t.disableFlags)||this.Mr.featureFlagsDisabled)&&(e.disable_flags=!0);const s=this._d();s.length&&(e.evaluation_contexts=s);const n=this.wd();I(n)||(e.flag_keys=n);const r=this.Mr.onlyEvaluateSurveyFeatureFlags,o="/flags/?v=2"+(r?"&only_evaluate_survey_feature_flags=true":""),l=this.Hc;this.Bc=!0;const a=()=>{this.Uc&&(this.Uc=!1,this.xd())},u=t=>{var i,s;const n=null!==(i=t.json)&&void 0!==i?i:{},o=200!==t.statusCode;if(this.Bc=!1,l!==this.Hc)return void a();if(this.Cd(t.statusCode),o||this.Uc||(this.$anon_distinct_id=void 0),e.disable_flags&&!this.Uc)return;this.Wc=!o;const u=[];t.error?u.push(t.error instanceof Error&&"AbortError"===t.error.name?"timeout":t.error instanceof Error?Ju:"unknown_error"):200!==t.statusCode&&u.push(`api_error_${t.statusCode}`),n.errorsWhileComputingFlags&&u.push("errors_while_computing_flags");const h=!!(null===(s=n.quotaLimited)||void 0===s?void 0:s.includes("feature_flags"));h&&u.push("quota_limited"),this.At({[Ys]:u}),h?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."):e.disable_flags||this.kd(n,o,{partialResponse:r}),a()},h=t=>{this.Bc=!1,l===this.Hc?(this.At({[Ys]:[Ju]}),this.$.error("Feature flag request failed",t),this.gd()&&this.ad(!0),a()):a()};try{i.sendRequest(o,{target:"flags",method:"POST",body:e,compression:this.Mr.compression,sentAt:"body",timeoutMs:this.Mr.requestTimeoutMs}).then(u).catch(h)}catch(t){h(t)}}Zc(){return wo(this.Gc,3)}Cd(t){this.Gc=$o(t,this.Gc,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(t,i={}){var e;if(i.fresh&&!this.Wc)return;if(!(this.jc||this.getFlags()&&this.getFlags().length>0))return void this.$.warn('getFeatureFlag for key "'+t+Ku);if(this.bd())return;const s=this.getFeatureFlagResult(t,i);return null!==(e=null==s?void 0:s.variant)&&void 0!==e?e:null==s?void 0:s.enabled}getFeatureFlagDetails(t){return this.getFlagsWithDetails()[t]}getFeatureFlagPayload(t){const i=this.getFeatureFlagResult(t,{send_event:!1});return null==i?void 0:i.payload}getFeatureFlagResult(t,i={}){if(i.fresh&&!this.Wc)return;if(!(this.jc||this.getFlags()&&this.getFlags().length>0))return void this.$.warn('getFeatureFlagResult for key "'+t+Ku);if(this.bd())return;const e=this.getFlagVariants(),s=t in e,n=e[t],r=this.getFlagPayloads()[t],o=String(n),l=this.fd("$feature_flag_request_id")||void 0,a=this.fd("$feature_flag_evaluated_at")||void 0;let u,h=this.fd("$flag_call_reported")||{};if(this.Mr.deduplicateCallsPerSession){var d;const t=null===(d=this.uo)||void 0===d?void 0:d.session.sessionId,i=this.fd(Js);t&&t!==i&&(h={},u=t)}if(i.send_event||!("send_event"in i))if(t in h&&h[t].includes(o))u&&this.At({[Ks]:h,[Js]:u});else{var c,v,f,p,g,_,m,b,y,w,x,S;P(h[t])?h[t].push(o):h[t]=[o],this.At(wi({[Ks]:h},u?{[Js]:u}:{}));const i=this.getFeatureFlagDetails(t),e=[...null!==(c=this.fd("$feature_flag_errors"))&&void 0!==c?c:[]];I(n)&&e.push("flag_missing");const s={$feature_flag:t,$feature_flag_response:n,$feature_flag_payload:null!=r?r:null,$feature_flag_request_id:l,$feature_flag_evaluated_at:a,$feature_flag_bootstrapped_response:null!==(v=null===(f=this.Mr.bootstrap)||void 0===f||null===(f=f.featureFlags)||void 0===f?void 0:f[t])&&void 0!==v?v:null,$feature_flag_bootstrapped_payload:null!==(p=null===(g=this.Mr.bootstrap)||void 0===g||null===(g=g.featureFlagPayloads)||void 0===g?void 0:g[t])&&void 0!==p?p:null,$used_bootstrap_value:!this.Wc};I(null==i||null===(_=i.metadata)||void 0===_?void 0:_.has_experiment)||(s.$feature_flag_has_experiment=i.metadata.has_experiment),I(null==i||null===(m=i.metadata)||void 0===m?void 0:m.version)||(s.$feature_flag_version=i.metadata.version);const d=null!==(b=null==i||null===(y=i.reason)||void 0===y?void 0:y.description)&&void 0!==b?b:null==i||null===(w=i.reason)||void 0===w?void 0:w.code;var k;d&&(s.$feature_flag_reason=d),(null==i||null===(x=i.metadata)||void 0===x?void 0:x.id)&&(s.$feature_flag_id=i.metadata.id),I(null==i?void 0:i.original_variant)&&I(null==i?void 0:i.original_enabled)||(s.$feature_flag_original_response=I(i.original_variant)?i.original_enabled:i.original_variant),(null==i||null===(S=i.metadata)||void 0===S?void 0:S.original_payload)&&(s.$feature_flag_original_payload=null==i||null===(k=i.metadata)||void 0===k?void 0:k.original_payload),e.length&&(s.$feature_flag_error=e.join(",")),this.$d(s)}else u&&this.At({[Ks]:h,[Js]:u});return s?{key:t,enabled:!!n,variant:"string"==typeof n?n:void 0,payload:ne(r)}:void 0}$d(t){try{var i;null===(i=this.uo)||void 0===i||i.capture("$feature_flag_called",t).catch(t=>{this.$.error("Failed to capture feature flag call",t)})}catch(t){this.$.error("Failed to capture feature flag call",t)}}getRemoteConfigPayload(t,i){this.Td(t,i)}Td(t,i){var e=this;return Y(function*(){const s=e.uo;if(!s)return;const n={distinct_id:s.distinctId,token:s.projectToken,person_properties:{$lib:s.library.name,$lib_version:s.library.version}},r=e._d();r.length&&(n.evaluation_contexts=r);const o=e.wd();let l;I(o)||(n.flag_keys=o);try{var a;const i=null===(a=(yield s.sendRequest("/flags/?v=2",{target:"flags",method:"POST",body:n,compression:e.Mr.compression,sentAt:"body",timeoutMs:e.Mr.requestTimeoutMs})).json)||void 0===a?void 0:a.featureFlagPayloads;l=(null==i?void 0:i[t])||void 0}catch(t){return void e.$.error("Remote config feature flag request failed",t)}try{i(l)}catch(t){e.$.error("Remote config feature flag callback failed",t)}})()}isFeatureEnabled(t,i={}){if(i.fresh&&!this.Wc)return i.defaultValue;if(!(this.jc||this.getFlags()&&this.getFlags().length>0))return this.$.warn('isFeatureEnabled for key "'+t+Ku),i.defaultValue;const e=this.getFeatureFlag(t,i);return I(e)?i.defaultValue:!!e}addFeatureFlagsHandler(t){this.featureFlagEventHandlers.push(t)}removeFeatureFlagsHandler(t){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter(i=>i!==t)}receivedFeatureFlags(t,i,e){this.kd(t,i,e)}kd(t,i,e){if(!this.uo)return;this.jc=!0;const s=((t,i={},e={},s={},n,r=Wu)=>{const o=((t,i)=>{const e=t.flags;if(e){const i=Object.fromEntries(Object.keys(e).map(t=>{var i;return[t,null!==(i=e[t].variant)&&void 0!==i?i:e[t].enabled]})),s=Object.fromEntries(Object.keys(e).filter(t=>e[t].enabled).filter(t=>{var i;return!I(null===(i=e[t].metadata)||void 0===i?void 0:i.payload)}).map(t=>{var i;return[t,null===(i=e[t].metadata)||void 0===i?void 0:i.payload]}));return wi(wi({},t),{},{featureFlags:i,featureFlagPayloads:s})}return t.featureFlags&&i.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),t})(t,r),l=o.flags,a=o.featureFlags,u=o.featureFlagPayloads;if(!a)return;const h=t.requestId,d=t.evaluatedAt;if(P(a)){r.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");const t={};if(a)for(let i=0;a.length>i;i++)t[a[i]]=!0;return{[ks]:a,[Ss]:t,[Fs]:!1}}let c=a,v=u,f=l;if(null==n?void 0:n.partialResponse){const t=Object.keys(c),n=v||{};c=wi(wi({},i),c),v=wi(wi({},e),n),t.forEach(t=>{t in n||null==v||delete v[t]}),f=wi(wi({},s),f)}else if(t.errorsWhileComputingFlags)if(l){const t=new Set(Object.keys(l).filter(t=>{var i;return!(null===(i=l[t])||void 0===i?void 0:i.failed)}));c=wi(wi({},i),Object.fromEntries(Object.entries(c).filter(([i])=>t.has(i))));const n=Object.fromEntries(Object.entries(v||{}).filter(([i])=>t.has(i)));v=wi(wi({},e),n),t.forEach(t=>{t in n||null==v||delete v[t]}),f=wi(wi({},s),Object.fromEntries(Object.entries(f||{}).filter(([i])=>t.has(i))))}else c=wi(wi({},i),c),v=wi(wi({},e),v),f=wi(wi({},s),f);return wi(wi({[ks]:Object.keys(Xu(c)),[Ss]:c||{},[Ts]:v||{},[Ps]:f||{},[Fs]:!0===t.minimalFlagCalledEvents},h?{[Cs]:h}:{}),d?{[Xs]:d}:{})})(t,this.getFlagVariants(),this.getFlagPayloads(),this.getFlagsWithDetails(),e,this.$);if(s)if(!1===(null==e?void 0:e.persist)){const t=!I(this.uo.kv.get(Ss));this.pd=s,t||this.At(s)}else this.od(),this.yd(s,t,!!(null==e?void 0:e.partialResponse)),this.At(s);else i&&this.gd();i||(this.Vc=!1),this.ad(i)}override(t,i=!1){this.$.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:t,suppressWarning:i})}overrideFeatureFlags(t){this.Id(t)}Id(t){if(this.uo){if(!1===t)return this.Lt([Is,Os]),this.ad(),void Gu.info("All overrides cleared");if(P(t))return this.At({[Is]:Yu(t)}),this.ad(),void Gu.info("Flag overrides set",{flags:t});if(t&&"object"==typeof t&&("flags"in t||"payloads"in t)){var i;const e=t;this.Dc=Boolean(null!==(i=e.suppressWarning)&&void 0!==i&&i);const s={},n=e.flags,r=e.payloads;return n&&(s[Is]=P(n)?Yu(n):n),r&&(s[Os]=r),Object.keys(s).length&&this.At(s),!1===n&&!1===r?this.Lt([Is,Os]):!1===n?this.Lt(Is):!1===r&&this.Lt(Os),this.ad(),!1===n?Gu.info("Flag overrides cleared"):n&&Gu.info("Flag overrides set",{flags:n}),void(!1===r?Gu.info("Payload overrides cleared"):r&&Gu.info("Payload overrides set",{payloads:r}))}if(t&&"object"==typeof t)return this.At({[Is]:t}),this.ad(),void Gu.info("Flag overrides set",{flags:t});this.$.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:t})}else this.$.warn("posthog.featureFlags.overrideFeatureFlags called before feature flags were ready")}onFeatureFlags(t){if(this.addFeatureFlagsHandler(t),this.jc){const{flags:i,flagVariants:e}=this.Md();try{t(i,e)}catch(t){this.$.error("Error while running feature flags callback",t)}}return()=>this.removeFeatureFlagsHandler(t)}updateEarlyAccessFeatureEnrollment(t,i,e){var s;const n=(this.fd("$early_access_features")||[]).find(i=>i.flagKey===t),r={[`$feature_enrollment/${t}`]:i},o={$feature_flag:t,$feature_enrollment:i,$set:r};n&&(o.$early_access_feature_name=n.name),e&&(o.$feature_enrollment_stage=e);const l=wi(wi({},this.getFlagVariants()),{},{[t]:i});null===(s=this._instance)||void 0===s||null===(s=s.persistence)||void 0===s||s.markCrossTabFeatureFlagChanges({$active_feature_flags:[t],$enabled_feature_flags:[t],$stored_person_properties:Object.keys(r)}),this.At({[ks]:Object.keys(Xu(l)),[Ss]:l,[Rs]:wi(wi({},this.fd("$stored_person_properties")||{}),r)}),this.ad();try{var a;null===(a=this.uo)||void 0===a||a.capture("$feature_enrollment_update",o).catch(t=>{this.$.error("Failed to capture early access feature enrollment",t)})}catch(t){this.$.error("Failed to capture early access feature enrollment",t)}}getEarlyAccessFeatures(t,i=!1,e){const s=this.fd(Es);!s||i?this.Ed(t,e):t(s)}Ed(t,i){var e=this;return Y(function*(){const s=e.uo;if(!s)return;const n=i?`&${i.map(t=>`stage=${t}`).join("&")}`:"";let r;try{const t=yield s.sendRequest(`/api/early_access_features/?token=${s.projectToken}${n}`,{target:"api",method:"GET",sentAt:"query"});if(!t.json)return;r=t.json.earlyAccessFeatures,e.At({[Es]:r})}catch(t){return void e.$.error("Early access feature request failed",t)}try{t(r)}catch(t){e.$.error("Early access feature callback failed",t)}})()}Md(){const t=this.getFlags(),i=this.getFlagVariants();return{flags:t.filter(t=>i[t]),flagVariants:Object.keys(i).filter(t=>i[t]).reduce((t,e)=>(t[e]=i[e],t),{})}}ad(t){this.ld();const{flags:i,flagVariants:e}=this.Md();this.featureFlagEventHandlers.forEach(s=>{try{s(i,e,{errorsLoading:t})}catch(t){this.$.error("Error while running feature flags callback",t)}})}setPersonPropertiesForFlags(t,i=!0){this.Pd(t,i)}Pd(t,i=!0){const e=this.fd("$stored_person_properties")||{},s=(null==t?void 0:t.$set)||((null==t?void 0:t.$set_once)?{}:t),n=null==t?void 0:t.$set_once,r={};if(n)for(const t in n)({}).hasOwnProperty.call(n,t)&&(t in e||(r[t]=n[t]));this.At({[Rs]:wi(wi(wi({},e),r),s)}),i&&this.reloadFeatureFlags()}unsetPersonPropertiesForFlags(t,i=!0){const e=wi({},this.fd("$stored_person_properties")||{});t.forEach(t=>{delete e[t]}),this.At({[Rs]:e}),i&&this.reloadFeatureFlags()}resetPersonPropertiesForFlags(t=!0){this.Lt(Rs),t&&this.reloadFeatureFlags()}setGroupPropertiesForFlags(t,i=!0){const e=this.fd("$stored_group_properties")||{},s=wi({},e);for(const i of Object.keys(t))s[i]=wi(wi({},e[i]),t[i]);this.At({[As]:s}),i&&this.reloadFeatureFlags()}resetGroupPropertiesForFlags(t){if(t){const i=this.fd("$stored_group_properties")||{};this.At({[As]:wi(wi({},i),{},{[t]:{}})})}else this.Lt(As)}reset(){this.Hc++,this.Uc=!1,this.Lc={},this.Nc={},this.pd=void 0,this.jc=!1,this.zc=!1,this.Wc=!1,this.$anon_distinct_id=void 0,this.vd(),this.Dc=!1,this.Gc=0}}},gh={sessionRecording:class{get Mr(){return this._instance.config}get ya(){return this._instance.persistence}get started(){var t;return!!(null===(t=this.Rd)||void 0===t?void 0:t.isStarted)}get status(){var t,i;return"awaiting_config"===this.Ad||"missing_config"===this.Ad?this.Ad:null!==(t=null===(i=this.Rd)||void 0===i?void 0:i.status)&&void 0!==t?t:this.Ad}constructor(i){if(this._instance=i,this._forceAllowLocalhostNetworkCapture=!1,this.Ad=wu,this.Fd=void 0,this.Od=!1,this.Ke=(()=>{var i,e;if(!(null==s?void 0:s.visibilityState)||"visible"===s.visibilityState)return!0;const n=null==t||null===(i=t.performance)||void 0===i||null===(e=i.getEntriesByType)||void 0===e?void 0:e.call(i,"visibility-state");return!(null==n?void 0:n.length)||n.some(t=>"visible"===t.name)})(),this.an=()=>{var t,i;"visible"===(null==s?void 0:s.visibilityState)&&(this.Ke=!0,null===(t=this.Rd)||void 0===t||null===(i=t.setDocumentWasEverVisible)||void 0===i||i.call(t,!0))},!this._instance.sessionManager)throw xu.error("started without valid sessionManager"),new Error("[SessionRecording] started without valid sessionManager. This is a bug.");if("always"===this.Mr.cookieless_mode)throw new Error('[SessionRecording] cannot be used with cookieless_mode="always"');(null==s?void 0:s.addEventListener)&&Ln(s,"visibilitychange",this.an)}initialize(){this.startIfEnabledOrStop()}dispose({discardBufferedEvents:t=!1}={}){var i;this.Od=!0,null==s||null===(i=s.removeEventListener)||void 0===i||i.call(s,"visibilitychange",this.an),t?this.Dd(!0):this.stopRecording()}get Ld(){var i;const e=!!(null===(i=this._instance.get_property("$session_recording_remote_config"))||void 0===i?void 0:i.enabled),s=!this.Mr.disable_session_recording,n=this.Mr.disable_session_recording||this._instance.consent.isOptedOut();return t&&e&&s&&!n}startIfEnabledOrStop(t){var i;if(this.Od)return;if(this.Ld&&(null===(i=this.Rd)||void 0===i?void 0:i.isStarted))return;const e=!I(Object.assign)&&!I(Array.from);this.Ld&&e?(this.Nd(t),xu.info("starting")):(this.Ad=wu,this.stopRecording())}Nd(t){var i,e;if(this.Ld)if("awaiting_config"!==this.Ad&&"missing_config"!==this.Ad&&(this.Ad=$u),(null==c||null===(i=c.__PosthogExtensions__)||void 0===i||null===(i=i.rrweb)||void 0===i?void 0:i.record)&&(null===(e=c.__PosthogExtensions__)||void 0===e?void 0:e.initSessionRecording))this.qd(t);else{var s,n;const i=this._instance.sessionManager;null===(s=c.__PosthogExtensions__)||void 0===s||null===(n=s.loadExternalDependency)||void 0===n||n.call(s,this._instance,this.jd,e=>{if(!this.Od&&this.Ld&&this._instance.sessionManager===i)return e?(this._instance.register_for_session({$sdk_debug_recording_script_not_loaded:!0}),xu.error("could not load recorder",e)):void this.qd(t);this.Ad="disabled"})}}stopRecording(){var t,i;null===(t=this.Fd)||void 0===t||t.call(this),this.Fd=void 0,null===(i=this.Rd)||void 0===i||i.stop()}Dd(t=!1){var i,e;null===(i=this.Fd)||void 0===i||i.call(this),this.Fd=void 0,null===(e=this.Rd)||void 0===e||e.discard({discardProducerEvents:t})}Bd(){var t,i;null===(t=this.ya)||void 0===t||t.unregister("$session_is_sampled"),null===(i=this.ya)||void 0===i||i.unregister("$replay_sample_rate")}Hd(t,i){if(M(t))return null;const e=D(t)?t:parseFloat(t);return"number"!=typeof(s=e)||!Number.isFinite(s)||0>s||s>1?(xu.warn(`${i} must be between 0 and 1. Ignoring invalid value:`,t),null):e;var s}zd(t){if(this.ya){var i,e;const s=this.ya,n=()=>{var i;const e=!1===t.sessionRecording?void 0:t.sessionRecording,n=this.Hd(null===(i=this.Mr.session_recording)||void 0===i?void 0:i.sampleRate,"session_recording.sampleRate"),r=this.Hd(null==e?void 0:e.sampleRate,"remote config sampleRate"),o=null!=n?n:r;M(o)&&this.Bd();const l=null==e?void 0:e.minimumDurationMilliseconds;s.register({[hs]:wi(wi({cache_timestamp:Date.now(),enabled:!!e},e),{},{networkPayloadCapture:wi({capturePerformance:t.capturePerformance},null==e?void 0:e.networkPayloadCapture),canvasRecording:{enabled:null==e?void 0:e.recordCanvas,fps:null==e?void 0:e.canvasFps,quality:null==e?void 0:e.canvasQuality},sampleRate:o,minimumDurationMilliseconds:I(l)?null:l,endpoint:null==e?void 0:e.endpoint,triggerMatchType:null==e?void 0:e.triggerMatchType,masking:null==e?void 0:e.masking,urlTriggers:null==e?void 0:e.urlTriggers,version:null==e?void 0:e.version,triggerGroups:null==e?void 0:e.triggerGroups})})};n(),null===(i=this.Fd)||void 0===i||i.call(this),this.Fd=null===(e=this._instance.sessionManager)||void 0===e?void 0:e.onSessionId(n)}}onRemoteConfig(t){const i=t.ok?t.config:void 0;return i&&"sessionRecording"in i?!1===i.sessionRecording?(this.zd(i),void this.Dd()):(this.zd(i),void this.startIfEnabledOrStop()):("awaiting_config"===this.Ad&&(this.Ad="missing_config",xu.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(t,i="log"){var e;(null===(e=this.Rd)||void 0===e?void 0:e.log)?this.Rd.log(t,i):xu.warn("log called before recorder was ready")}get jd(){var t,i;const e=null===(t=this._instance)||void 0===t||null===(t=t.persistence)||void 0===t?void 0:t.get_property(hs);return(null==e||null===(i=e.scriptConfig)||void 0===i?void 0:i.script)||"lazy-recorder"}Ud(){const t=this._instance.get_property(hs);if(!t)return!1;let i;try{i="object"==typeof t?t:JSON.parse(t)}catch(t){return xu.warn("persisted remote config for session recording is invalid and will be ignored",t),!1}return!M(i.cache_timestamp)&&36e5>=Date.now()-i.cache_timestamp}qd(t){var i,e,s;if(!this.Od&&this.Ld&&this._instance.sessionManager){if(!(null===(i=c.__PosthogExtensions__)||void 0===i?void 0:i.initSessionRecording))return xu.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[hn]:!0});var n;if(this.Rd||(this.Rd=null===(n=c.__PosthogExtensions__)||void 0===n?void 0:n.initSessionRecording(this._instance,this.Ke),this.Rd._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.Ud()){if("missing_config"===this.Ad||"awaiting_config"===this.Ad)return;return this.Ad="awaiting_config",xu.info("persisted remote config is stale, requesting fresh config before starting"),void new al(this._instance).load()}this.Ad=$u,null===(e=(s=this.Rd).setDocumentWasEverVisible)||void 0===e||e.call(s,this.Ke),this.Rd.start(t)}else this.Ad=wu}onRRwebEmit(t){var i,e;null===(i=this.Rd)||void 0===i||null===(e=i.onRRwebEmit)||void 0===e||e.call(i,t)}overrideLinkedFlag(){var t,i;this.Rd||null===(i=this.ya)||void 0===i||i.register({$replay_override_linked_flag:!0}),null===(t=this.Rd)||void 0===t||t.overrideLinkedFlag()}overrideSampling(){var t,i;this.Rd||null===(i=this.ya)||void 0===i||i.register({$replay_override_sampling:!0}),null===(t=this.Rd)||void 0===t||t.overrideSampling()}overrideTrigger(t){var i,e;this.Rd||null===(e=this.ya)||void 0===e||e.register({["url"===t?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),null===(i=this.Rd)||void 0===i||i.overrideTrigger(t)}get sdkDebugProperties(){var t;return(null===(t=this.Rd)||void 0===t?void 0:t.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(t,i){var e;return!!(null===(e=this.Rd)||void 0===e?void 0:e.tryAddCustomEvent(t,i))}flushBeforeIdentityReset(){var t,i;null===(t=this.Rd)||void 0===t||null===(i=t.flushBeforeIdentityReset)||void 0===i||i.call(t)}}},_h={autocapture:class extends uu{constructor(t){super(new hu(t)),this.instance=t}},historyAutocapture:class{constructor(t){this._instance=t,this.Wd=this.Vd()}initialize(){this.startIfEnabled()}get isEnabled(){const t=this.Gd();return!!(t.path||t.search||this.Zd(t))}startIfEnabled(){this.isEnabled&&(je.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}startIfEnabledOrStop(){this.stop(),this.Wd=this.Vd(),this.startIfEnabled()}stop(){this.Qd&&this.Qd(),this.Qd=void 0,this.Jd&&this.Jd(),this.Jd=void 0,je.info("History API monitoring stopped")}monitorHistoryChanges(){t&&t.history&&(this.Kd("pushState"),this.Kd("replaceState"),this.Yd(),this.Zd()&&this.Xd())}Kd(i){var e;if(!t||(null===(e=t.history[i])||void 0===e?void 0:e.__posthog_wrapped__))return;const s=this;fu(t.history,i,t=>function(e,n,r){t.call(this,e,n,r),s.tv(i)})}Vd(){const i=null==t?void 0:t.location;if(null==i?void 0:i.pathname)return{pathname:i.pathname,search:i.search,hash:i.hash}}Gd(){const t=this._instance.config.capture_pageview;return"history_change"===t?{path:!0}:C(t)?t:{}}Zd(t=this.Gd()){return!!t.hash&&!this._instance.config.disable_capture_url_hashes}ev(t){const i=this.Gd(),e=this.Wd;return!(!e||!(i.path&&t.pathname!==e.pathname||i.search&&t.search!==e.search||this.Zd(i)&&t.hash!==e.hash))}tv(t){try{const i=this.Vd();if(!i)return;this.ev(i)&&this._instance.capture(kn,{navigation_type:t}),this.Wd=i}catch(i){je.error(`Error capturing ${t} pageview`,i)}}Yd(){if(this.Qd)return;const i=()=>{this.tv("popstate")};Ln(t,"popstate",i),this.Qd=()=>{t&&t.removeEventListener("popstate",i)}}Xd(){if(this.Jd)return;const i=()=>{this.tv("hashchange")};Ln(t,"hashchange",i),this.Jd=()=>{t&&t.removeEventListener("hashchange",i)}}},heatmaps:class{get Mr(){return this.instance.config}constructor(t){var i;this.iv=!1,this.do=!1,this.nv=null,this.instance=t,this.iv=!!(null===(i=this.instance.persistence)||void 0===i?void 0:i.props[is]),this.rageclicks=new su(t.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){let t=5e3;return C(this.Mr.capture_heatmaps)&&this.Mr.capture_heatmaps.flush_interval_milliseconds&&(t=this.Mr.capture_heatmaps.flush_interval_milliseconds),t}get isEnabled(){return M(this.Mr.capture_heatmaps)?M(this.Mr.enable_heatmaps)?this.iv:this.Mr.enable_heatmaps:!1!==this.Mr.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this.do)return;Su.info("starting..."),this.sv(),this.an()}else{var t;clearInterval(null!==(t=this.nv)&&void 0!==t?t:void 0),this.rv(),this.getAndClearBuffer()}}onRemoteConfig(t){if(!t.ok)return;const i=t.config;if(!("heatmaps"in i))return;const e=!!i.heatmaps;this.instance.persistence&&this.instance.persistence.register({[is]:e}),this.iv=e,this.startIfEnabled()}getAndClearBuffer(){const t=this.Rt;return this.Rt=void 0,t}ov(t){ku(t.originalEvent)&&this.Cr(t.originalEvent,"deadclick")}an(){this.nv&&clearInterval(this.nv),this.nv=function(t){return"visible"===(null==t?void 0:t.visibilityState)}(s)?setInterval(this.aa.bind(this),this.flushIntervalMilliseconds):null}sv(){t&&s&&(this.lv=this.aa.bind(this),Ln(t,Sn,this.lv),this.av=i=>this.Cr(i||(null==t?void 0:t.event)),Ln(s,"click",this.av,{capture:!0}),this.uv=i=>this.hv(i||(null==t?void 0:t.event)),Ln(s,"mousemove",this.uv,{capture:!0}),this.dv=new no(this.instance,eo,this.ov.bind(this)),this.dv.startIfEnabledOrStop(),this.vv=this.an.bind(this),Ln(s,xn,this.vv),this.do=!0)}rv(){var i;t&&s&&(this.lv&&t.removeEventListener(Sn,this.lv),this.av&&s.removeEventListener("click",this.av,{capture:!0}),this.uv&&s.removeEventListener("mousemove",this.uv,{capture:!0}),this.vv&&s.removeEventListener(xn,this.vv),clearTimeout(this.fv),null===(i=this.dv)||void 0===i||i.stop(),this.do=!1)}pv(i,e){const s=this.instance.scrollManager.scrollY(),n=this.instance.scrollManager.scrollX(),r=this.instance.scrollManager.scrollElement(),o=function(i,e,s){let n=i;for(;n&&mr(n)&&!br(n,"body");){if(n===s)return!1;let i;try{var r,o,l;i=null===(r=null!==(o=null===(l=n.ownerDocument)||void 0===l?void 0:l.defaultView)&&void 0!==o?o:t)||void 0===r?void 0:r.getComputedStyle(n).position}catch(t){return!1}if(b(e,i))return!0;n=Ir(n)}return!1}(Pr(i),["fixed","sticky"],r);return{x:i.clientX+(o?0:n),y:i.clientY+(o?0:s),target_fixed:o,type:e}}Cr(t,i="click"){var e;if(_r(t.target)||!ku(t))return;const s=this.pv(t,i);(null===(e=this.rageclicks)||void 0===e?void 0:e.isRageClick(t.clientX,t.clientY,(new Date).getTime()))&&Br(Pr(t),this.instance.config.rageclick)&&this.Hs(wi(wi({},s),{},{type:"rageclick"})),this.Hs(s)}hv(t){!_r(t.target)&&ku(t)&&(clearTimeout(this.fv),this.fv=setTimeout(()=>{this.Hs(this.pv(t,"mousemove"))},500))}Hs(i){if(!t)return;const e=this.Mr.disable_capture_url_hashes?hi(t.location.href):t.location.href,s=this.Mr.custom_personal_data_properties,n=this.Mr.mask_personal_data_properties?[...xo,...s||[]]:[],r=bo(e,n,ko);this.Rt=this.Rt||{},this.Rt[r]||(this.Rt[r]=[]),this.Rt[r].push(i)}aa(){this.Rt&&!F(this.Rt)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:no,webVitalsAutocapture:class{constructor(t){var i;this._instance=t,this.iv=!1,this.do=!1,this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this.gv=()=>{clearTimeout(this.mv),this.mv=void 0,0!==this.Rt.metrics.length&&(this._instance.capture("$web_vitals",wi({$current_url:this.Rt.url},this.Rt.metrics.reduce((t,i)=>wi(wi({},t),{},{[`$web_vitals_${i.name}_event`]:wi({},i),[`$web_vitals_${i.name}_value`]:i.value}),{}))),this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.yv=t=>{var i;if(this.Rt=this.Rt||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},M(null==t?void 0:t.name)||M(null==t?void 0:t.value))return void gu.error("Invalid metric received",t);const e="string"==typeof t.navigationURL?t.navigationURL:void 0,s=this.bv(e);if(I(s))return;const n=D(t.navigationId)||"string"==typeof t.navigationId?`navigation:${t.navigationId}`:`url:${s}`;if(this._v&&t.value>=this._v)return void gu.error("Ignoring metric with value >= "+this._v,t);this.Rt.navigationKey!==n&&(this.gv(),this.mv=setTimeout(this.gv,this.flushToCaptureTimeoutMs)),I(this.Rt.navigationKey)&&(this.Rt.navigationKey=n,this.Rt.url=s),this.Rt.firstMetricTimestamp=I(this.Rt.firstMetricTimestamp)?Date.now():this.Rt.firstMetricTimestamp;const r=null===(i=this._instance.sessionManager)||void 0===i?void 0:i.checkAndGetSessionAndWindowId(!0),o=wi(wi(wi({},t),e?{navigationURL:s}:{}),{},{$current_url:s,timestamp:Date.now()});if(delete o.entries,C(t.attribution)&&this.attributionMetrics.indexOf(t.name)>-1){const i={};for(const e of yu){const s="url"===e&&"string"==typeof t.attribution[e]?this.bv(t.attribution[e]):t.attribution[e];I(s)||(i[e]=s)}o.attribution=i}else delete o.attribution;I(r)||(o.$session_id=r.sessionId,o.$window_id=r.windowId),this.Rt.metrics.push(o),this.Rt.metrics.length===this.allowedMetrics.length&&this.gv()},this.wv=()=>{if(this.do)return;let t,i,e,s,n=!1;const r=c.__PosthogExtensions__,o=null==r?void 0:r.postHogWebVitalsCallbacksByFlavor,l=(null==o?void 0:o[this.Sv])||("web-vitals"===this.Sv&&I(o)?null==r?void 0:r.postHogWebVitalsCallbacks:void 0);if(!I(l)){const r=l.withoutAttribution,o=this.attributionMetrics;n=!I(r),t=o.indexOf("LCP")>-1?l.onLCP:(null==r?void 0:r.onLCP)||l.onLCP,i=o.indexOf("CLS")>-1?l.onCLS:(null==r?void 0:r.onCLS)||l.onCLS,e=o.indexOf("FCP")>-1?l.onFCP:(null==r?void 0:r.onFCP)||l.onFCP,s=o.indexOf("INP")>-1?l.onINP:(null==r?void 0:r.onINP)||l.onINP}if(!(t&&i&&e&&s))return void gu.error("web vitals callbacks not loaded - not starting");const a={reportSoftNavs:this.useSoftNavs},u=n&&this.attributionMetrics.indexOf("INP")>-1?wi(wi({},a),{},{includeProcessedEventEntries:!1}):a;this.allowedMetrics.indexOf("LCP")>-1&&t(this.yv.bind(this),a),this.allowedMetrics.indexOf("CLS")>-1&&i(this.yv.bind(this),a),this.allowedMetrics.indexOf("FCP")>-1&&e(this.yv.bind(this),a),this.allowedMetrics.indexOf("INP")>-1&&s(this.yv.bind(this),u),this.do=!0},this.iv=!!(null===(i=this._instance.persistence)||void 0===i?void 0:i.props[rs]),this.startIfEnabled()}get xv(){return this._instance.config.capture_performance}get allowedMetrics(){var t,i;const e=C(this.xv)?null===(t=this.xv)||void 0===t?void 0:t.web_vitals_allowed_metrics:void 0;return M(e)?(null===(i=this._instance.persistence)||void 0===i?void 0:i.props.$web_vitals_allowed_metrics)||mu:e}get flushToCaptureTimeoutMs(){return(C(this.xv)?this.xv.web_vitals_delayed_flush_ms:void 0)||5e3}get attributionMetrics(){const t=C(this.xv)?this.xv.web_vitals_attribution:void 0;return B(t)?t?mu:[]:P(t)?t:bu}get useAttribution(){return this.attributionMetrics.length>0}get useSoftNavs(){const t=C(this.xv)?this.xv.__preview_web_vitals_soft_navs:void 0;return null!=t&&t}get _v(){const t=C(this.xv)&&D(this.xv.__web_vitals_max_value)?this.xv.__web_vitals_max_value:_u;return t>0&&6e4>=t?_u:t}get isEnabled(){const t=null==n?void 0:n.protocol;if("http:"!==t&&"https:"!==t)return gu.info("Web Vitals are disabled on non-http/https protocols"),!1;const i=C(this.xv)?this.xv.web_vitals:B(this.xv)?this.xv:void 0;return B(i)?i:this.iv}startIfEnabled(){this.isEnabled&&!this.do&&(gu.info("enabled, starting..."),this.Ro(this.wv))}onRemoteConfig(t){if(!t.ok)return;const i=t.config;if(!("capturePerformance"in i))return;const e=C(i.capturePerformance)&&!!i.capturePerformance.web_vitals,s=C(i.capturePerformance)?i.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[rs]:e}),this._instance.persistence.register({[us]:s})),this.iv=e,this.startIfEnabled()}get Sv(){return this.useSoftNavs?this.useAttribution?"web-vitals-with-attribution-soft-navs":"web-vitals-soft-navs":this.useAttribution?"web-vitals-with-attribution":"web-vitals"}Ro(t){var i;const e=c.__PosthogExtensions__,s=this.Sv,n=null==e?void 0:e.postHogWebVitalsCallbacksByFlavor;(null==n?void 0:n[s])||"web-vitals"===s&&I(n)&&(null==e?void 0:e.postHogWebVitalsCallbacks)?t():null==e||null===(i=e.loadExternalDependency)||void 0===i||i.call(e,this._instance,s,i=>{i?gu.error("failed to load script",i):t()})}bv(i){const e=i||(null==t?void 0:t.location.href);if(!e)return void gu.error("Could not determine current URL");const s=this._instance.config.disable_capture_url_hashes?hi(e):e,n=this._instance.config.custom_personal_data_properties,r=this._instance.config.mask_personal_data_properties?[...xo,...n||[]]:[];return bo(s,r,ko)}}},mh={exceptionObserver:class{constructor(i){var e;this.wv=()=>{var i;if(!t||!this.isEnabled||!(null===(i=c.__PosthogExtensions__)||void 0===i?void 0:i.errorWrappingFunctions))return;const e=c.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,s=c.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,n=c.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.Cv&&this.Mr.capture_unhandled_errors&&(this.Cv=e(this.captureException.bind(this))),!this.$v&&this.Mr.capture_unhandled_rejections&&(this.$v=s(this.captureException.bind(this))),!this.Tv&&this.Mr.capture_console_errors&&(this.Tv=n(this.captureException.bind(this)))}catch(t){du.error("failed to start",t),this.Iv()}},this._instance=i,this.Mv=!!(null===(e=this._instance.persistence)||void 0===e?void 0:e.props[es]),this.wt=new tt(wi(wi({},function(t={}){var i,e,s,n;return{refillRate:null!==(i=null!==(e=t.exceptionRateLimiterRefillRate)&&void 0!==e?e:t.__exceptionRateLimiterRefillRate)&&void 0!==i?i:1,bucketSize:null!==(s=null!==(n=t.exceptionRateLimiterBucketSize)&&void 0!==n?n:t.__exceptionRateLimiterBucketSize)&&void 0!==s?s:10}}(this._instance.config.error_tracking)),{},{refillInterval:1e4,$:du})),this.Mr=this.Ev(),this.startIfEnabledOrStop()}Ev(){const t=this._instance.config.capture_exceptions;let i={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return C(t)?i=wi(wi({},i),t):(I(t)?this.Mv:t)&&(i=wi(wi({},i),{},{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),i}get isEnabled(){return this.Mr.capture_console_errors||this.Mr.capture_unhandled_errors||this.Mr.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(du.info("enabled"),this.Iv(),this.Ro(this.wv)):this.Iv()}Ro(t){var i,e,s;(null===(i=c.__PosthogExtensions__)||void 0===i?void 0:i.errorWrappingFunctions)?t():null===(e=c.__PosthogExtensions__)||void 0===e||null===(s=e.loadExternalDependency)||void 0===s||s.call(e,this._instance,"exception-autocapture",i=>{if(i)return du.error("failed to load script",i);t()})}Iv(){var t,i,e;null===(t=this.Cv)||void 0===t||t.call(this),this.Cv=void 0,null===(i=this.$v)||void 0===i||i.call(this),this.$v=void 0,null===(e=this.Tv)||void 0===e||e.call(this),this.Tv=void 0}onRemoteConfig(t){if(!t.ok)return;const i=t.config;"autocaptureExceptions"in i&&(this.Mv=!!i.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[es]:this.Mv}),this.Mr=this.Ev(),this.startIfEnabledOrStop())}onConfigChange(){this.Mr=this.Ev()}captureException(t){try{var i,e,s;const n=null!==(i=null==t||null===(e=t.$exception_list)||void 0===e||null===(e=e[0])||void 0===e?void 0:e.type)&&void 0!==i?i:"Exception";if(this.wt.consumeRateLimit(n))return void du.info("Skipping exception capture because of client rate limiting.",{exception:n});null===(s=this._instance.exceptions)||void 0===s||s.sendExceptionEvent(t)}catch(t){}}},exceptions:class{constructor(t){var i,e;this.Pv=[],this.Rv=new $i([new Ni,new Yi,new Ui,new zi,new Ki,new Gi,new qi,new Ji],function(t,...i){return(e,s=0)=>{const n=[],r=e.split("\n"),o=Math.min(r.length,s+1e3),l=[];for(let e=s;o>e;e++){const s=r[e];if(s.length>1024)continue;const o=Oi.test(s)?s.replace(Oi,"$1"):s;if(!o.match(/\S*Error: /)){for(const e of i){const i=e(o,t);if(i){n.push(i);const t=Ai(n);if(t){for(let i=l.length-1;i>=0;i--){const e=l[i];if(t.start>=e.start+e.length)break;l.pop()}l.push(t)}break}}if(Bi(n,l)>=50)break}}const a=[...l].sort((t,i)=>i.start-t.start),u=a[a.length-1];if(u){const t=Di(n,u);n.splice(u.start-t,t);for(const i of a)i.start-=t}for(const t of a)Mi(n,t);return l.some(t=>0===t.start&&n.length===t.length)&&function(t){const i=t.map(t=>`${t.function}|${t.filename}|${t.lineno}|${t.colno}|${t.module}`);let e=0;for(let t=1;i.length>t;t++)Li(i,t,e)&&(e=t);t.push(...t.splice(0,e))}(n),function(t){if(!t.length)return[];const i=Array.from(t);return i.reverse(),i.slice(0,50).map(t=>{return wi(wi({},t),{},{filename:t.filename||(e=i,e[e.length-1]||{}).filename,function:t.function||"?"});var e})}(n)}}("web:javascript",Ti,Ii)),this._instance=t,this.Pv=null!==(i=null===(e=this._instance.persistence)||void 0===e?void 0:e.get_property("$error_tracking_suppression_rules"))&&void 0!==i?i:[],this.Av=ie(this.Fv()),this.Ov=new ee(this.Av)}onConfigChange(){this.Av=ie(this.Fv()),this.Ov.setConfig(this.Av)}onRemoteConfig(t){var i,e,s;if(!t.ok)return;const n=t.config;if(!("errorTracking"in n))return;const r=null!==(i=null===(e=n.errorTracking)||void 0===e?void 0:e.suppressionRules)&&void 0!==i?i:[],o=null===(s=n.errorTracking)||void 0===s?void 0:s.captureExtensionExceptions;this.Pv=r,this._instance.persistence&&this._instance.persistence.register({[ss]:this.Pv,[ns]:o})}get Dv(){var t;const i=!!this._instance.get_property(ns),e=this._instance.config.error_tracking.captureExtensionExceptions;return null!==(t=null!=e?e:i)&&void 0!==t&&t}buildProperties(t,i){return this.Rv.buildFromUnknown(t,{syntheticException:null==i?void 0:i.syntheticException,mechanism:{handled:null==i?void 0:i.handled}})}addExceptionStep(t,i){if(this.Av.enabled)try{if(!O(t)||0===t.trim().length)return void Qu.warn("Ignoring exception step because message must be a non-empty string");const{sanitizedProperties:e,droppedKeys:s}=function(t){if(!t)return{sanitizedProperties:{},droppedKeys:[]};const i=[];return{sanitizedProperties:Object.keys(t).reduce((e,s)=>Qi.has(s)?(i.push(s),e):(e[s]=t[s],e),{}),droppedKeys:i}}(this.Lv(i));s.length>0&&Qu.warn("Ignoring reserved exception step fields",{droppedKeys:s}),this.Ov.add(wi({[Xi]:t,[Zi]:(new Date).toISOString()},e))}catch(t){Qu.error("Failed to add exception step. Ignoring breadcrumb.",t)}}sendExceptionEvent(t){try{const i=t.$exception_list;if(this.Nv(i)){if(this.qv(i))return this.jv("Exception dropped: matched a suppression rule"),void Qu.info("Skipping exception capture because a suppression rule matched");if(!this.Dv&&this.Bv(i))return this.jv("Exception dropped: thrown by a browser extension"),void Qu.info("Skipping exception capture because it was thrown by an extension");if(!this.Dv&&this.Hv(i))return this.jv("Exception dropped: thrown by an injected browser script"),void Qu.info("Skipping exception capture because it was thrown by an injected browser script");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.zv(i))return this.jv("Exception dropped: thrown by the PostHog SDK"),void Qu.info("Skipping exception capture because it was thrown by the PostHog SDK")}const e=this.Av.enabled&&M(t.$exception_steps)?this.Uv(t):t,s=function(){const t=globalThis._posthogReleaseId;return"string"==typeof t&&t.length>0?t:void 0}();s&&(e.$release_id=s);try{const t=this._instance.capture("$exception",e,{_noTruncate:!0,_batchKey:"exceptionEvent",Qu:!0});return t&&this.Ov.clear(),t}catch(t){return Zu(t)||Qu.error("Failed to capture exception event. Dropping this exception.",t),void this.Ov.clear()}}catch(t){return void(Zu(t)||Qu.error("Failed to process exception event. Ignoring this exception.",t))}}Uv(t){try{const i=this.Ov.getAttachable();return 0===i.length?t:wi(wi({},t),{},{$exception_steps:i})}catch(i){return Qu.error("Failed to read buffered exception steps. Capturing exception without steps.",i),t}}jv(t){this.Av.enabled&&this.Ov.add({[Xi]:t,[Zi]:(new Date).toISOString()})}Lv(t){return C(t)?wi({},t):{}}Fv(){var t,i;return null!==(t=null===(i=this._instance.config.error_tracking)||void 0===i?void 0:i.exception_steps)&&void 0!==t?t:{}}qv(t){if(0===t.length)return!1;try{const i=t.reduce((t,{type:i,value:e})=>(O(i)&&i.length>0&&t.$exception_types.push(i),O(e)&&e.length>0&&t.$exception_values.push(e),t),{$exception_types:[],$exception_values:[]});return this.Pv.some(t=>{const e=t.values.map(t=>{const e=ya[t.operator],s=i[t.key];if(!e||!s)return!1;const n=P(t.value)?t.value:[t.value];return n.length>0&&e(n,s)});return"OR"===t.type?e.some(Boolean):e.every(Boolean)})}catch(t){return Qu.warn("Failed to evaluate suppression rules. Capturing the exception.",t),!1}}Bv(t){const i=t.flatMap(t=>{var i,e;return null!==(i=null===(e=t.stacktrace)||void 0===e?void 0:e.frames)&&void 0!==i?i:[]}),e=i.filter(({filename:t})=>!!t&&eh.some(i=>t.startsWith(i)));return 0!==e.length&&(!e.every(({filename:t})=>!!t&&t.startsWith(th))||t.some(({type:t,value:i})=>"NoResponse"===t||O(i)&&ih.some(({value:t,exact:e})=>e?i===t:i.includes(t)))&&!i.some(({in_app:t,filename:i})=>t&&!(null==i?void 0:i.startsWith(th))))}Hv(t){return t.some(({value:t})=>O(t)&&sh.some(i=>t.includes(i)))}zv(t){if(t.length>0){var i,e,s,n;const r=null!==(i=null===(e=t[0].stacktrace)||void 0===e?void 0:e.frames)&&void 0!==i?i:[],o=r[r.length-1];return null!==(s=null==o||null===(n=o.filename)||void 0===n?void 0:n.includes("posthog.com/static"))&&void 0!==s&&s}return!1}Nv(t){return!M(t)&&P(t)}}},bh=wi({productTours:class{get ya(){return this._instance.persistence}constructor(t){this.Wv=null,this.Vv=null,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!t.ok)return;const i=t.config;if("productTours"in i){var e,s;if(this.ya&&this.ya.register({[ls]:!!i.productTours}),!Pu(this._instance))return!this.Wv&&M(null===(e=this.ya)||void 0===e?void 0:e.props.ph_product_tours)||Eu.info("product tours disabled; stopping and clearing cached tours"),null===(s=this.Wv)||void 0===s||s.stop(),this.Wv=null,void this.clearCache();this.loadIfEnabled()}}loadIfEnabled(){!this.Wv&&Pu(this._instance)&&this.Ro(()=>this.Gv())}Ro(t){var i,e,s;(null===(i=c.__PosthogExtensions__)||void 0===i?void 0:i.generateProductTours)?t():null===(e=c.__PosthogExtensions__)||void 0===e||null===(s=e.loadExternalDependency)||void 0===s||s.call(e,this._instance,"product-tours",i=>{i?Eu.error("Could not load product tours script",i):t()})}Gv(){var t;!this.Wv&&(null===(t=c.__PosthogExtensions__)||void 0===t?void 0:t.generateProductTours)&&(this.Wv=c.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(t,i=!1){if(P(this.Vv)&&!i)return void t(this.Vv,{isLoaded:!0});const e=this.ya;if(e){const s=e.props[zs];if(P(s)&&!i)return this.Vv=s,void t(s,{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:i=>{if(!Pu(this._instance))return void t([],{isLoaded:!0});const s=i.statusCode;if(200!==s||!i.json){const e=`Product Tours API could not be loaded, status: ${s}`;return 0===s?i.error||Eu.warn(e):Eu.error(e),void t([],{isLoaded:!1,error:e})}const n=P(i.json.product_tours)?i.json.product_tours:[];this.Vv=n,e&&e.register({[zs]:n}),t(n,{isLoaded:!0})}})}getActiveProductTours(t){M(this.Wv)?t([],{isLoaded:!1,error:"Product tours not loaded"}):this.Wv.getActiveProductTours(t)}showProductTour(t){var i;null===(i=this.Wv)||void 0===i||i.showTourById(t)}previewTour(t){this.Wv?this.Wv.previewTour(t):this.Ro(()=>{var i;this.Gv(),null===(i=this.Wv)||void 0===i||i.previewTour(t)})}dismissProductTour(){var t;null===(t=this.Wv)||void 0===t||t.dismissTour("user_clicked_skip")}nextStep(){var t;null===(t=this.Wv)||void 0===t||t.nextStep()}previousStep(){var t;null===(t=this.Wv)||void 0===t||t.previousStep()}clearCache(){var t;this.Vv=null,null===(t=this.ya)||void 0===t||t.unregister("ph_product_tours")}resetTour(t){var i;null===(i=this.Wv)||void 0===i||i.resetTour(t)}resetAllTours(){var t;null===(t=this.Wv)||void 0===t||t.resetAllTours()}cancelPendingTour(t){var i;null===(i=this.Wv)||void 0===i||i.cancelPendingTour(t)}}},ph),yh={siteApps:class{constructor(t){this._instance=t,this.Zv=0,this.Qv=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}Jv(t,i){if(!i)return;const e=this.globalsForEvent(i);this.Qv.push(e),this.Qv.length>1e3&&(this.Qv=this.Qv.slice(10))}get siteAppLoaders(){var t;return null===(t=c._POSTHOG_REMOTE_CONFIG)||void 0===t||null===(t=t[this._instance.config.token])||void 0===t?void 0:t.siteApps}initialize(){if(this.isEnabled){const t=this._instance._addCaptureHook(this.Jv.bind(this));this.Kv=()=>{t(),this.Qv=[],this.Kv=void 0}}}globalsForEvent(t){var i,e,s,n,r,o,l;if(!t)throw new Error("Event payload is required");const a={},u=this._instance.get_property("$groups")||[],h=this._instance.get_property("$stored_group_properties")||{};for(const[t,i]of Object.entries(h))a[t]={id:u[t],type:t,properties:i};const{$set_once:d,$set:c}=t;return{event:wi(wi({},_e(t,Tu)),{},{properties:wi(wi(wi({},t.properties),c?{$set:wi(wi({},null!==(i=null===(e=t.properties)||void 0===e?void 0:e.$set)&&void 0!==i?i:{}),c)}:{}),d?{$set_once:wi(wi({},null!==(s=null===(n=t.properties)||void 0===n?void 0:n.$set_once)&&void 0!==s?s:{}),d)}:{}),elements_chain:null!==(r=null===(o=t.properties)||void 0===o?void 0:o.$elements_chain)&&void 0!==r?r:"",distinct_id:null===(l=t.properties)||void 0===l?void 0:l.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:a}}Yv(t){var i;const e=null===(i=t.tagName)||void 0===i?void 0:i.toLowerCase();if("style"===e&&this._instance.config.prepare_external_dependency_stylesheet){return this._instance.config.prepare_external_dependency_stylesheet(t)||(Cu.error("prepare_external_dependency_stylesheet returned null"),null)}if("script"===e&&this._instance.config.prepare_external_dependency_script){return this._instance.config.prepare_external_dependency_script(t)||(Cu.error("prepare_external_dependency_script returned null"),null)}return t}Xv(){var t,i,e,n,r,o,l,a;if(!this._instance.config.prepare_external_dependency_stylesheet&&!this._instance.config.prepare_external_dependency_script)return()=>{};const u=null==s?void 0:s.defaultView,h=null==u||null===(t=u.Node)||void 0===t?void 0:t.prototype;if(!u||!h)return()=>{};if(this.Zv++,this.tf)return this.ef();const d=[],c=this,v=new WeakSet,f=(t,i,e)=>{if(!(null==t?void 0:t[i]))return;const s=t[i];t[i]=e(s),d.push(()=>{t[i]=s})},p=t=>{if(v.has(t))return t;const i=c.Yv(t);return i&&v.add(i),i},g=t=>t.map(t=>"string"==typeof t?t:p(t)).filter(t=>!A(t));return f(h,"appendChild",t=>function(i){const e=p(i);return e?t.call(this,e):i}),f(h,"insertBefore",t=>function(i,e){const s=p(i);return s?t.call(this,s,e):i}),f(h,"replaceChild",t=>function(i,e){const s=p(i);return s?t.call(this,s,e):e}),[null===(i=u.Element)||void 0===i?void 0:i.prototype,null===(e=u.Document)||void 0===e?void 0:e.prototype,null===(n=u.DocumentFragment)||void 0===n?void 0:n.prototype].forEach(t=>{f(t,"append",t=>function(...i){return t.apply(this,g(i))}),f(t,"prepend",t=>function(...i){return t.apply(this,g(i))})}),[null===(r=u.Element)||void 0===r?void 0:r.prototype,null===(o=u.CharacterData)||void 0===o?void 0:o.prototype,null===(l=u.DocumentType)||void 0===l?void 0:l.prototype].forEach(t=>{f(t,"before",t=>function(...i){return t.apply(this,g(i))}),f(t,"after",t=>function(...i){return t.apply(this,g(i))}),f(t,"replaceWith",t=>function(...i){const e=g(i);return i.length&&!e.length?void 0:t.apply(this,e)})}),f(null===(a=u.Element)||void 0===a?void 0:a.prototype,"insertAdjacentElement",t=>function(i,e){const s=p(e);return s?t.call(this,i,s):null}),this.tf=()=>{d.forEach(t=>t()),this.tf=void 0},this.ef()}ef(){let t=!1;return()=>{var i;t||(t=!0,this.Zv--,0===this.Zv&&(null===(i=this.tf)||void 0===i||i.call(this)))}}if(t,i=!0){const e=this.Xv();try{const s=t(e);return i&&e(),s}catch(t){throw e(),t}}setupSiteApp(t){const i=this.apps[t.id],e=()=>{var e;!i.errored&&this.Qv.length&&(Cu.info(`Processing ${this.Qv.length} events for site app with id ${t.id}`),this.Qv.forEach(t=>this.if(()=>{var e;return null===(e=i.processEvent)||void 0===e?void 0:e.call(i,t)})),i.processedBuffer=!0),Object.values(this.apps).every(t=>t.processedBuffer||t.errored)&&(null===(e=this.Kv)||void 0===e||e.call(this))};let s=!1;const n=n=>{i.errored=!n,i.loaded=!0,Cu.info(`Site app with id ${t.id} ${n?"loaded":"errored"}`),s&&e()};try{const{processEvent:e}=this.if(i=>t.init({posthog:this._instance,callback(t){i(),n(t)}}),!1);e&&(i.processEvent=e),s=!0}catch(i){Cu.error(Fu+t.id,i),n(!1)}if(s&&i.loaded)try{e()}catch(e){Cu.error(`Error while processing buffered events PostHog app with config id ${t.id}`,e),i.errored=!0}}nf(){const t=this.siteAppLoaders||[];for(const i of t)this.apps[i.id]={id:i.id,loaded:!1,errored:!1,processedBuffer:!1};for(const i of t)this.setupSiteApp(i)}sf(t){if(0===Object.keys(this.apps).length)return;const i=this.globalsForEvent(t);for(const e of Object.values(this.apps))try{this.if(()=>{var t;return null===(t=e.processEvent)||void 0===t?void 0:t.call(e,i)})}catch(i){Cu.error(`Error while processing event ${t.event} for site app ${e.id}`,i)}}onRemoteConfig(t){var i,e,s;if(null===(i=this.siteAppLoaders)||void 0===i?void 0:i.length)return this.isEnabled?(this.nf(),void this._instance.on("eventCaptured",t=>this.sf(t))):void Cu.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null===(e=this.Kv)||void 0===e||e.call(this),!t.ok)return;const n=t.config;if(null===(s=n.siteApps)||void 0===s?void 0:s.length)if(this.isEnabled)for(const{id:t,url:i}of n.siteApps){var r,o;c[`__$$ph_site_app_${t}`]=this._instance,null===(r=c.__PosthogExtensions__)||void 0===r||null===(o=r.loadSiteApp)||void 0===o||o.call(r,this._instance,i,i=>{if(i)return Cu.error(Fu+t,i)})}else Cu.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}},wh={tracingHeaders:class{constructor(t){this._instance=t,this.rf=void 0,this.lf=void 0,this.af=void 0,this.wv=()=>{const t=this.uf();var i,e;t?(I(this.rf)&&(this.rf=null===(i=c.__PosthogExtensions__)||void 0===i||null===(i=i.tracingHeadersPatchFns)||void 0===i?void 0:i._patchXHR(t,()=>this._instance.get_distinct_id(),this._instance.sessionManager)),I(this.lf)&&(this.lf=null===(e=c.__PosthogExtensions__)||void 0===e||null===(e=e.tracingHeadersPatchFns)||void 0===e?void 0:e._patchFetch(t,()=>this._instance.get_distinct_id(),this._instance.sessionManager))):this.Iv()}}initialize(){this.startIfEnabledOrStop()}Ro(t){var i,e,s;(null===(i=c.__PosthogExtensions__)||void 0===i?void 0:i.tracingHeadersPatchFns)?t():null===(e=c.__PosthogExtensions__)||void 0===e||null===(s=e.loadExternalDependency)||void 0===s||s.call(e,this._instance,"tracing-headers",i=>{if(i)return pu.error("failed to load script",i);t()})}hf(){var t,i;return null!==(t=null!==(i=this._instance.config.tracing_headers)&&void 0!==i?i:this._instance.config.addTracingHeaders)&&void 0!==t?t:this._instance.config.__add_tracing_headers}uf(){const t=this.hf();return P(t)?(P(this.af)?this.af.splice(0,this.af.length,...t):this.af=[...t],t.length>0?this.af:void 0):(P(this.af)&&this.af.splice(0),this.af=t||void 0,this.af)}Iv(){var t,i;null===(t=this.rf)||void 0===t||t.call(this),null===(i=this.lf)||void 0===i||i.call(this),this.rf=void 0,this.lf=void 0}startIfEnabledOrStop(){this.uf()?this.Ro(this.wv):this.Iv()}}},$h=wi({surveys:class extends Au{constructor(t){var i;super(new Nu(t),(i=t,{get projectToken(){return i.config.token},kv:new Lu(i)})),this._instance=t}Sh(t,i){const e=i.query?Wl(t,i.query):t;return new Promise(t=>{var s;this._instance._send_request({method:i.method,url:this._instance.requestRouter.endpointFor(null!==(s=i.target)&&void 0!==s?s:"api",e),data:i.body,headers:i.headers,timeout:i.timeoutMs,fireCallbackOnDrop:!0,transport:i.transport,compression:i.compression,timestampMode:i.sentAt,callback:t})})}}},ph),xh={toolbar:class{constructor(t){this.instance=t}cf(t){c.ph_toolbar_state=t}df(){var t;return null!==(t=c.ph_toolbar_state)&&void 0!==t?t:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(i=void 0,e=void 0,n=void 0){var r,o;if(Nn(this.instance.config))return!1;if(!t||!s)return!1;i=null!==(r=i)&&void 0!==r?r:t.location,n=null!==(o=n)&&void 0!==o?o:t.history;try{if(!e){try{t.localStorage.setItem("test","test"),t.localStorage.removeItem("test")}catch(t){return!1}e=null==t?void 0:t.localStorage}const s=zu||yo(i.hash,"__posthog")||yo(i.hash,"state");let r;const o=s?Rn(()=>JSON.parse(atob(decodeURIComponent(s))))||Rn(()=>JSON.parse(decodeURIComponent(s))):null;return o&&"ph_authorize"===o.action?(r=o,r.source="url",r&&Object.keys(r).length>0&&(o.desiredHash?i.hash=o.desiredHash:n?n.replaceState(n.state,"",i.pathname+i.search):i.hash="")):(r=JSON.parse(e.getItem(Uu)||"{}"),r.source="localstorage",delete r.userIntent),!(!r.token||this.instance.config.token!==r.token||(this.loadToolbar(r),0))}catch(t){return!1}}vf(t){const i=c.ph_load_toolbar||c.ph_load_editor;!M(i)&&T(i)?i(t,this.instance):Hu.warn("No toolbar load function found")}loadToolbar(i){const e=!!(null==s?void 0:s.getElementById("__POSTHOG_TOOLBAR__"));if(!t||e)return!1;const n="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,r=wi(wi({token:this.instance.config.token},i),{},{apiURL:this.instance.requestRouter.endpointFor("ui")},n?{instrument:!1}:{});if(t.localStorage.setItem(Uu,JSON.stringify(wi(wi({},r),{},{source:void 0}))),2===this.df())this.vf(r);else if(0===this.df()){var o,l;this.cf(1),null===(o=c.__PosthogExtensions__)||void 0===o||null===(l=o.loadExternalDependency)||void 0===l||l.call(o,this.instance,"toolbar",t=>{if(t)return Hu.error("[Toolbar] Failed to load",t),void this.cf(0);this.cf(2),this.vf(r)}),Ln(t,"turbolinks:load",()=>{this.cf(0),this.loadToolbar(r)})}return!0}ff(t){return this.loadToolbar(t)}maybeLoadEditor(t=void 0,i=void 0,e=void 0){return this.maybeLoadToolbar(t,i,e)}}},Sh=wi({experiments:class i{get Mr(){return this._instance.config}constructor(t){this._instance=t,this.getWebExperimentsAndEvaluateDisplayLogic=(t=!1)=>{this.getWebExperiments(t=>{i.pf("retrieved web experiments from the server"),this.gf=new Map,t.forEach(t=>{if(t.feature_flag_key){var e;this.gf&&(i.pf("setting flag key ",t.feature_flag_key," to web experiment ",t),null===(e=this.gf)||void 0===e||e.set(t.feature_flag_key,t));const s=this._instance.getFeatureFlag(t.feature_flag_key);O(s)&&t.variants[s]&&this.mf(t.name,s,t.variants[s].transforms)}else if(t.variants)for(const e in t.variants){const s=t.variants[e];i.yf(s,this._instance)&&this.mf(t.name,e,s.transforms)}})},t)},this._instance.onFeatureFlags(t=>{this.onFeatureFlags(t)})}initialize(){}onFeatureFlags(t){if(this._is_bot())i.pf(nh);else if(!this.Mr.disable_web_experiments){if(M(this.gf))return this.gf=new Map,this.loadIfEnabled(),void this.previewWebExperiment();i.pf("applying feature flags",t),t.forEach(t=>{var i;if(this.gf&&(null===(i=this.gf)||void 0===i?void 0:i.has(t))){var e;const i=this._instance.getFeatureFlag(t),s=null===(e=this.gf)||void 0===e?void 0:e.get(t);i&&(null==s?void 0:s.variants[i])&&this.mf(s.name,i,s.variants[i].transforms)}})}}previewWebExperiment(){const t=i.getWindowLocation();if(null==t?void 0:t.search){const e=mo(null==t?void 0:t.search,"__experiment_id"),s=mo(null==t?void 0:t.search,"__experiment_variant");e&&s&&(i.pf(`previewing web experiments ${e} && ${s}`),this.getWebExperiments(t=>{this.bf(parseInt(e),s,t)},!1,!0))}}loadIfEnabled(){this.Mr.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(t,i,e){if(this.Mr.disable_web_experiments&&!e)return t([]);const s=this._instance.get_property("$web_experiments");if(s&&!i)return t(s);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api",`/api/web_experiments/?token=${this.Mr.token}`),method:"GET",timestampMode:"query",callback:i=>t(200===i.statusCode&&i.json&&i.json.experiments||[])})}bf(t,e,s){const n=s.filter(i=>i.id===t);n&&n.length>0&&(i.pf(`Previewing web experiment [${n[0].name}] with variant [${e}]`),this.mf(n[0].name,e,n[0].variants[e].transforms))}static yf(t,e){return!M(t.conditions)&&i._f(t,e)&&i.wf(t)}static _f(t,e){var s;if(M(t.conditions)||M(null===(s=t.conditions)||void 0===s?void 0:s.url))return!0;const n=i.getWindowLocation();if(n){var r,o,l;const i=gr(e,n.href);return!(null===(r=t.conditions)||void 0===r?void 0:r.url)||rh[null!==(o=null===(l=t.conditions)||void 0===l?void 0:l.urlMatchType)&&void 0!==o?o:"icontains"](t.conditions.url,i)}return!1}static getWindowLocation(){return null==t?void 0:t.location}static wf(t){var i;if(M(t.conditions)||M(null===(i=t.conditions)||void 0===i?void 0:i.utm))return!0;const e=Po();if(e.utm_source){var s,n,r,o,l,a,u,h;const i=!(null===(s=t.conditions)||void 0===s||null===(s=s.utm)||void 0===s?void 0:s.utm_campaign)||(null===(n=t.conditions)||void 0===n||null===(n=n.utm)||void 0===n?void 0:n.utm_campaign)==e.utm_campaign,d=!(null===(r=t.conditions)||void 0===r||null===(r=r.utm)||void 0===r?void 0:r.utm_source)||(null===(o=t.conditions)||void 0===o||null===(o=o.utm)||void 0===o?void 0:o.utm_source)==e.utm_source,c=!(null===(l=t.conditions)||void 0===l||null===(l=l.utm)||void 0===l?void 0:l.utm_medium)||(null===(a=t.conditions)||void 0===a||null===(a=a.utm)||void 0===a?void 0:a.utm_medium)==e.utm_medium,v=!(null===(u=t.conditions)||void 0===u||null===(u=u.utm)||void 0===u?void 0:u.utm_term)||(null===(h=t.conditions)||void 0===h||null===(h=h.utm)||void 0===h?void 0:h.utm_term)==e.utm_term;return i&&c&&v&&d}return!1}static pf(t,...i){je.info(`[WebExperiments] ${t}`,i)}mf(t,e,s){this._is_bot()?i.pf(nh):"control"!==e?s.forEach(s=>{if(s.selector){var n;i.pf(`applying transform of variant ${e} for experiment ${t} `,s);const r=null===(n=document)||void 0===n?void 0:n.querySelectorAll(s.selector);null==r||r.forEach(t=>{const i=t;s.html&&(i.innerHTML=s.html),s.css&&i.setAttribute("style",s.css)})}}):i.pf("Control variants leave the page unmodified.")}_is_bot(){return e&&this._instance?fa(e,this.Mr.custom_blocked_useragents):void 0}}},ph),kh={conversations:class{constructor(t){this._instance=t,this.kf=void 0,this._conversationsManager=null,this.Sf=!1,this.ne=null,this.xf=!1}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(this._instance.config.disable_conversations)return;if(this.Cf=t.ok,!t.ok)return;const i=t.config.conversations;M(i)||(B(i)?this.kf=i:(this.kf=i.enabled,this.ne=i),this.loadIfEnabled())}reset(){var t;null===(t=this._conversationsManager)||void 0===t||t.reset(),this._conversationsManager=null,this.kf=void 0,this.ne=null,this.Cf=void 0,this.xf=!1}loadIfEnabled(){if(this._conversationsManager)return;if(this.Sf)return;if(this._instance.config.disable_conversations)return;if(Nn(this._instance.config))return;if(this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())return;const t=null==c?void 0:c.__PosthogExtensions__;if(t&&!I(this.kf)&&this.kf)if(this.ne&&this.ne.token){this.Sf=!0;try{const i=t.initConversations;if(i)return this.$f(i),void(this.Sf=!1);const e=t.loadExternalDependency;if(!e)return void this.Tf(bn);e(this._instance,"conversations",i=>{i||!t.initConversations?this.Tf("Could not load conversations script",i):this.$f(t.initConversations),this.Sf=!1})}catch(t){this.Tf("Error initializing conversations",t),this.Sf=!1}}else oh.error("Conversations enabled but missing token in remote config.")}$f(t){if(this.ne)try{this._conversationsManager=t(this.ne,this._instance),this.xf=!1,oh.info("Conversations loaded successfully")}catch(t){this.Tf("Error completing conversations initialization",t)}else oh.error("Cannot complete initialization: remote config is null")}Tf(t,i){oh.error(t,i),this._conversationsManager=null,this.Sf=!1,this.xf=!0}show(){this._conversationsManager?this._conversationsManager.show():oh.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this.kf&&!A(this._conversationsManager)}getUnavailableReason(){return this.isAvailable()?null:this._instance.config.disable_conversations?"disabled_by_config":Nn(this._instance.config)?"disabled_for_toolbar":this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut()?"consent_opted_out":!1===this.Cf?"remote_config_failed":I(this.kf)?this.Cf?"disabled_in_project":"remote_config_pending":this.kf?M(this.ne)||!this.ne.token?"missing_token":(null==c?void 0:c.__PosthogExtensions__)?this.Sf?"initializing":this.xf?"load_failed":"not_loaded":"extensions_unavailable":"disabled_in_project"}isVisible(){var t,i;return null!==(t=null===(i=this._conversationsManager)||void 0===i?void 0:i.isVisible())&&void 0!==t&&t}sendMessage(t,i,e){var s=this;return Y(function*(){return s._conversationsManager?s._conversationsManager.sendMessage(t,i,e):(oh.warn(lh),null)})()}getMessages(t,i){var e=this;return Y(function*(){return e._conversationsManager?e._conversationsManager.getMessages(t,i):(oh.warn(lh),null)})()}markAsRead(t){var i=this;return Y(function*(){return i._conversationsManager?i._conversationsManager.markAsRead(t):(oh.warn(lh),null)})()}getTickets(t){var i=this;return Y(function*(){return i._conversationsManager?i._conversationsManager.getTickets(t):(oh.warn(lh),null)})()}requestRestoreLink(t){var i=this;return Y(function*(){return i._conversationsManager?i._conversationsManager.requestRestoreLink(t):(oh.warn(lh),null)})()}restoreFromToken(t){var i=this;return Y(function*(){return i._conversationsManager?i._conversationsManager.restoreFromToken(t):(oh.warn(lh),null)})()}restoreFromUrlToken(){var t=this;return Y(function*(){return t._conversationsManager?t._conversationsManager.restoreFromUrlToken():(oh.warn(lh),null)})()}getCurrentTicketId(){var t,i;return null!==(t=null===(i=this._conversationsManager)||void 0===i?void 0:i.getCurrentTicketId())&&void 0!==t?t:null}getWidgetSessionId(){var t,i;return null!==(t=null===(i=this._conversationsManager)||void 0===i?void 0:i.getWidgetSessionId())&&void 0!==t?t:null}sh(){var t;null===(t=this._conversationsManager)||void 0===t||t.setIdentity()}rh(){var t;null===(t=this._conversationsManager)||void 0===t||t.clearIdentity()}}},Eh={logs:class{constructor(i){var e;this._instance=i,this.name="logs",this.If=!1,this.Mf=!1,this.Ef=!1,this.$=Be("[logs]"),this.Pf=wi(wi({},this.$),{},{error:(...t)=>{t.some(fh)||this.$.error(...t)}}),this.Jl=[],this.Rf=[],this.Gc=0,this.mo=!1,this.Af=[],this.Ff=[],this.Of=!1,this.Df=!1,this.Lf=()=>{var t,i;this.mo||(this.Gc=0,null===(t=this.Nf)||void 0===t||t.onReconnect(),null===(i=this.qf)||void 0===i||i.onReconnect())},this._instance&&(null===(e=this._instance.config.logs)||void 0===e?void 0:e.captureConsoleLogs)&&(this.If=!0),t&&Ln(t,"online",this.Lf)}jf(t,i,e,s){var n;const r=ah(null===(n=this._instance)||void 0===n||null===(n=n.config)||void 0===n?void 0:n.logs,e);return[new Ie(this.Bf(t,i),r,this.Pf,()=>this.Hf(),t=>t(),void 0,s),r]}zf(){var t;const i=null===(t=this._instance)||void 0===t||null===(t=t.config)||void 0===t?void 0:t.logs;var e;return this.Nf&&this.Uf===i||(null===(e=this.Nf)||void 0===e||e.reset(),this.Uf=i,[this.Nf,this.Wf]=this.jf(()=>this.Jl,t=>{this.Jl=t})),this.Nf}Vf(){var t;const i=null===(t=this._instance)||void 0===t||null===(t=t.config)||void 0===t?void 0:t.logs;var e;return this.qf&&this.Gf===i||(null===(e=this.qf)||void 0===e||e.reset(),this.Gf=i,[this.qf,this.Zf]=this.jf(()=>this.Rf,t=>{this.Rf=t},{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},dh)),this.qf}setup(t){var i;if(this.mo)return;this.uo=t,(null===(i=this._instance)||void 0===i||null===(i=i.config)||void 0===i||null===(i=i.logs)||void 0===i?void 0:i.captureConsoleLogs)&&(this.If=!0),(this.If||this.Qf()&&this.Jf())&&this.Kf();let e=!1;const s=t.onRemoteConfig(t=>{var i;e=t.ok&&!0===(null===(i=t.config.logs)||void 0===i?void 0:i.captureConsoleLogs),this.onRemoteConfig(t)});this.mo?s.dispose():(this._o=s,e||this.loadIfEnabled())}dispose(){var i,e,s,n;this.mo||(this.mo=!0,this.Yf(),null===(i=this._o)||void 0===i||i.dispose(),this._o=void 0,this.uo=void 0,this.Ef=!1,null==t||t.removeEventListener("online",this.Lf),null===(e=this.Xf)||void 0===e||e.call(this),this.Xf=void 0,null===(s=this.Nf)||void 0===s||s.reset(),null===(n=this.qf)||void 0===n||n.reset())}onRemoteConfig(t){var i,e;if(this.mo)return;const s=t.ok?null===(i=t.config.logs)||void 0===i?void 0:i.captureConsoleLogs:void 0;M(s)?this.tp():(null===(e=this._instance)||void 0===e||null===(e=e.persistence)||void 0===e||e.register({$logs_capture_enabled_server_side:!!s}),s?(this.If=!0,this.Mf||this.Kf(),this.loadIfEnabled()):this.tp())}reset(){var t,i,e,s;this.Yf(),null===(t=this.Nf)||void 0===t||t.clearQueue(),this.Jl=[],null===(i=this.Nf)||void 0===i||i.reset(),null===(e=this.qf)||void 0===e||e.clearQueue(),this.Rf=[],null===(s=this.qf)||void 0===s||s.reset(),this.Gc=0}captureLog(t){this.mo||this.zf().captureLog(t)}captureConsoleLog(t){this.mo||this.Vf().captureLog(t)}captureBufferedConsoleLog(t,i,e){this.mo||this.Vf().captureLog(t,{context:i,occurredAtMs:e})}Jf(){var t;return!!(null===(t=this._instance)||void 0===t||null===(t=t.persistence)||void 0===t||null===(t=t.props)||void 0===t?void 0:t[as])}Qf(){var t,i,e;return!(null===(t=this._instance)||void 0===t||null===(i=t.Vl)||void 0===i?void 0:i.call(t))||!!(null===(e=c._POSTHOG_REMOTE_CONFIG)||void 0===e||null===(e=e[this._instance.config.token])||void 0===e?void 0:e.config)}ah(){var t;this.Yf(),null===(t=this.qf)||void 0===t||t.clearQueue(),this.Rf=[]}tp(){this.If||this.Yf()}Kf(){var t;if(this.Of||!(null==c?void 0:c.console))return;const i=ah(null===(t=this._instance)||void 0===t||null===(t=t.config)||void 0===t?void 0:t.logs).maxBufferSize;for(const t of uh){let e;try{e=hh(c.console[t])}catch(t){continue}e&&this.Ff.push(fu(c.console,t,s=>{const n=(...e)=>{try{this.ep(t,e,i)}catch(t){}return s.apply(c.console,e)};return n.__rrweb_original__=e,n}))}this.Of=!0,this.np=setTimeout(()=>{this.Yf()},3e4)}ep(t,i,e){var s;if(this.Of&&!this.Df&&0!==i.length)if(null===(s=this._instance)||void 0===s?void 0:s.is_capturing()){if(e>this.Af.length){this.Df=!0;try{this.Af.push({level:t,args:i,occurredAtMs:Date.now(),context:this.Hf()})}finally{this.Df=!1}}}else this.Yf()}Yf(){if(this.Af=[],this.Of){this.Of=!1,this.np&&(clearTimeout(this.np),this.np=void 0);for(const t of this.Ff)t();this.Ff=[]}}sp(){const t=this.Af;return this.Yf(),t}get logger(){return this.rp||(this.rp={trace:(t,i)=>this.captureLog({body:t,level:"trace",attributes:i}),debug:(t,i)=>this.captureLog({body:t,level:"debug",attributes:i}),info:(t,i)=>this.captureLog({body:t,level:"info",attributes:i}),warn:(t,i)=>this.captureLog({body:t,level:"warn",attributes:i}),error:(t,i)=>this.captureLog({body:t,level:"error",attributes:i}),fatal:(t,i)=>this.captureLog({body:t,level:"fatal",attributes:i})}),this.rp}flushLogs(t){t?this.op(t):(this.Nf&&this.Nf.flush().catch(t=>this.lp(t)),this.qf&&this.qf.flush().catch(t=>this.lp(t)))}lp(t){fh(t)||this.$.error("PostHog logs flush failed:",t)}loadIfEnabled(){if(this.mo||!this.If||this.Mf||this.Ef)return;const t=null==c?void 0:c.__PosthogExtensions__;if(!t)return this.$.error("PostHog Extensions not found."),void this.Yf();const i=t.loadExternalDependency;if(!i)return this.$.error(bn),void this.Yf();this.Ef=!0;try{i(this._instance,"logs",i=>{if(this.Ef=!1,this.mo||!this.If)return;const e=t.logs;if(i||!(null==e?void 0:e.initializeLogs))this.$.error("Could not load logs script",i),this.Yf();else{var s;const t=this.sp();var n,r;this.Xf=e.initializeLogs(null!==(s=this.uo)&&void 0!==s?s:this._instance),this.Mf=!0,t.length>0&&(null===(n=e.replayConsoleBuffer)||void 0===n||n.call(e,null!==(r=this.uo)&&void 0!==r?r:this._instance,t))}})}catch(t){throw this.Ef=!1,t}}Bf(t,i){const e=this._instance;return{get isDisabled(){return!1},get optedOut(){return!e.is_capturing()},getPersistedProperty:i=>i===p.LogsQueue?t():void 0,setPersistedProperty(t,e){var s;t===p.LogsQueue&&i(null!==(s=e)&&void 0!==s?s:[])},Ps:t=>this.Ps(t),getLibraryId:()=>qe.LIB_NAME,getLibraryVersion:()=>qe.LIB_VERSION}}Ps(t){return new Promise(i=>{if(wo(this.Gc,3))return void i({kind:"fatal",error:vh(void 0,"logs endpoint is unreachable, dropping batch")});let e=!1;const s=t=>{e||(e=!0,clearTimeout(n),i(t))},n=setTimeout(()=>{this.$.warn("Logs request timed out before receiving a response"),s({kind:"retry-later",error:vh(void 0,"logs request timed out")})},9e4);this._instance._send_request({method:"POST",url:this.ap(),data:t,compression:"best-available",batchKey:"logs",fireCallbackOnDrop:!0,callback:t=>{const i=t.statusCode;if(this.up(i),i>=200&&300>i)s({kind:"ok"});else if(413===i)s({kind:"too-large"});else if(0!==i&&408!==i&&429!==i&&500>i)s({kind:"fatal",error:new Error(`logs request failed with status ${i}`)});else{var e;0===i?(t.error||this.$.warn("Logs request failed before receiving an HTTP response"),s({kind:"retry-later",error:vh(t.error,"logs request failed before receiving an HTTP response")})):s({kind:"retry-later",error:null!==(e=t.error)&&void 0!==e?e:new Error(`logs request failed with status ${i}`)})}}})})}up(t){(0!==t||this._instance.__loaded)&&(this.Gc=$o(t,this.Gc,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.")))}op(t){this.Jl.length>0&&this.hp(t,this.Jl,this.Wf,qe.LIB_NAME,t=>{this.Jl=t}),this.Rf.length>0&&this.hp(t,this.Rf,this.Zf,dh,t=>{this.Rf=t})}hp(t,i,e,s,n){if(0===i.length)return;const r=i.map(t=>t.record);n([]);const o=Fe(r,Ce(e,qe.LIB_NAME,qe.LIB_VERSION),s,qe.LIB_VERSION);this._instance._send_request({method:"POST",url:this.ap(),data:o,compression:"best-available",batchKey:"logs",transport:t})}ap(){return this._instance.requestRouter.endpointFor("api","/i/v1/logs")+"?token="+encodeURIComponent(this._instance.config.token)}Hf(){var t;const i={};if(i.distinctId=this._instance.get_distinct_id(),this._instance.sessionManager){const{sessionId:t,windowId:e,sessionStartTimestamp:s,lastActivityTimestamp:n}=this._instance.sessionManager.checkAndGetSessionAndWindowId(!0);i.sessionId=t,i.windowId=e,M(s)||(i.sessionStartTimestamp=s),M(n)||(i.lastActivityTimestamp=n)}if((null==c||null===(t=c.location)||void 0===t?void 0:t.href)&&(i.currentUrl=this._instance.config.disable_capture_url_hashes?hi(c.location.href):c.location.href),this._instance.featureFlags){const t=this._instance.featureFlags.getFlags();t&&t.length>0&&(i.activeFeatureFlags=t)}return i}}},Ph={metrics:class{constructor(t){this._instance=t,this.$=Be("[metrics]")}initialize(){}zf(){var t;const i=null===(t=this._instance)||void 0===t||null===(t=t.config)||void 0===t?void 0:t.metrics;var e;return this.Nf&&this.Uf===i||(null===(e=this.Nf)||void 0===e||e.reset(),this.Uf=i,this.Nf=new Me(this.Bf(),function(t){var i,e,s,n,r;const o=null==t?void 0:t.resourceAttributes;return{serviceName:null!==(i=null==o?void 0:o["service.name"])&&void 0!==i?i:null==t?void 0:t.serviceName,serviceVersion:null!==(e=null==o?void 0:o["service.version"])&&void 0!==e?e:null==t?void 0:t.serviceVersion,environment:null!==(s=null==o?void 0:o["deployment.environment"])&&void 0!==s?s:null==t?void 0:t.environment,resourceAttributes:o,beforeSend:null==t?void 0:t.beforeSend,flushIntervalMs:null!==(n=null==t?void 0:t.flushIntervalMs)&&void 0!==n?n:1e4,maxSeriesPerFlush:null!==(r=null==t?void 0:t.maxSeriesPerFlush)&&void 0!==r?r:1e3}}(i),this.$)),this.Nf}count(t,i=1,e){this.zf().count(t,i,e)}gauge(t,i,e){this.zf().gauge(t,i,e)}histogram(t,i,e){this.zf().histogram(t,i,e)}flush(t){if(!this.Nf)return Promise.resolve();if(t){const i=this.Nf.drainWindow();return i&&this.Gs(i,t),Promise.resolve()}return this.Nf.flush().catch(t=>this.$.error("PostHog metrics flush failed:",t))}reset(){var t;null===(t=this.Nf)||void 0===t||t.reset()}Bf(){const t=this._instance,i=this;return{get isDisabled(){return!1},get optedOut(){return!t.is_capturing()},Gs:t=>i.Gs(t),getLibraryId:()=>qe.LIB_NAME,getLibraryVersion:()=>qe.LIB_VERSION}}Gs(t,i){return new Promise(e=>{let s=!1;const n=t=>{s||(s=!0,clearTimeout(r),e(t))},r=setTimeout(()=>n({kind:"retry-later",error:new Error("metrics request timed out")}),9e4);this._instance._send_request(wi(wi({method:"POST",url:this.cp(),data:t,compression:"best-available",batchKey:"metrics"},i&&{transport:i}),{},{fireCallbackOnDrop:!0,callback(t){const i=t.statusCode;if(i>=200&&300>i)n({kind:"ok"});else if(413===i)n({kind:"too-large"});else if(0!==i&&408!==i&&429!==i&&500>i)n({kind:"fatal",error:new Error(`metrics request failed with status ${i}`)});else{var e;n({kind:"retry-later",error:null!==(e=t.error)&&void 0!==e?e:new Error(`metrics request failed with status ${i}`)})}}}))})}cp(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}}};eu.__defaultExtensionClasses=wi({},wi(wi(wi(wi(wi(wi(wi(wi(wi(wi(wi(wi(wi({},ph),gh),_h),mh),bh),yh),$h),wh),xh),Sh),kh),Eh),Ph)),function(){qe.SDK_DIST_CHANNEL="cdn";const i=c.posthog;if(i&&!P(i._i))return;const e=La[Ja]=new eu;if(i){const t=[];Fn(i._i,function(s){if(s&&P(s)){const n=e.init(s[0],s[1],s[2]),r=i[s[2]]||i;n.__loaded&&-1===t.indexOf(r)&&(t.push(r),n._execute_array.call(n.people,r.people),n._execute_array(r))}})}e.__SV=1,c.posthog=e,function(){function i(){i.done||(i.done=!0,Ya=!1,Fn(La,function(t){t._dom_loaded()}))}(null==s?void 0:s.addEventListener)?"complete"===s.readyState?i():Ln(s,"DOMContentLoaded",i,{capture:!1}):t&&je.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}()}()}();
|
|
2
2
|
//# sourceMappingURL=array.js.map
|