tokentracker-cli 1.5.4 → 1.5.6

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.
Files changed (121) hide show
  1. package/THIRD_PARTY_NOTICES.md +10 -0
  2. package/dashboard/dist/THIRD_PARTY_NOTICES.txt +10 -0
  3. package/dashboard/dist/assets/{AchievementBadge-CKNb_cwg.js → AchievementBadge-NKpY___e.js} +1 -1
  4. package/dashboard/dist/assets/{AchievementsPage-u9P8DXJI.js → AchievementsPage-9nXmSX72.js} +2 -2
  5. package/dashboard/dist/assets/{AchievementsSection-BSCUJ4DR.js → AchievementsSection-DttQciSY.js} +1 -1
  6. package/dashboard/dist/assets/{BadgeDetailModal-Bg7cE3Zq.js → BadgeDetailModal-bvWEdJbe.js} +1 -1
  7. package/dashboard/dist/assets/{BotAnimated-C7D2WbQA.js → BotAnimated-ChuUfph8.js} +1 -1
  8. package/dashboard/dist/assets/{Card-B4IqAhai.js → Card-SWtLDXt1.js} +1 -1
  9. package/dashboard/dist/assets/{CloudCheckoutPage-P75pH9Ym.js → CloudCheckoutPage-c2fNl1Rl.js} +1 -1
  10. package/dashboard/dist/assets/{CloudPage-DDEZfmZg.js → CloudPage-CfwDjZMS.js} +2 -2
  11. package/dashboard/dist/assets/{CommandPalette-CER_AklA.js → CommandPalette-tWgPa295.js} +1 -1
  12. package/dashboard/dist/assets/{CommunityStatsModal-Cbb74eib.js → CommunityStatsModal-D7UaaUdM.js} +1 -1
  13. package/dashboard/dist/assets/{ConfirmModal-Q1ZQdZHt.js → ConfirmModal-BrBcKhfW.js} +1 -1
  14. package/dashboard/dist/assets/{Controls-DaGOfcoz.js → Controls-CcvBkk7W.js} +1 -1
  15. package/dashboard/dist/assets/DashboardPage-DJSgRHGq.js +1 -0
  16. package/dashboard/dist/assets/{DateRangePopover-DSS1Ira_.js → DateRangePopover-BkN_pird.js} +1 -1
  17. package/dashboard/dist/assets/{DevicePage-6zPLYydh.js → DevicePage-BbUL7WwT.js} +1 -1
  18. package/dashboard/dist/assets/{DialogClose-DdCQ36LK.js → DialogClose-BXO8SBFr.js} +1 -1
  19. package/dashboard/dist/assets/DialogDescription-B1HyKP0x.js +1 -0
  20. package/dashboard/dist/assets/{DialogTitle-BjP217Y1.js → DialogTitle-Du332auj.js} +1 -1
  21. package/dashboard/dist/assets/{ElectricLogo-Dhq8PM4h.js → ElectricLogo-CXLYfOt7.js} +1 -1
  22. package/dashboard/dist/assets/{FadeIn-CGNbED4E.js → FadeIn-HSQBOc8B.js} +1 -1
  23. package/dashboard/dist/assets/{HeaderGithubStar-DwqEFzb6.js → HeaderGithubStar-D5tyQDGE.js} +1 -1
  24. package/dashboard/dist/assets/{HoverTooltip-CQZTgyQy.js → HoverTooltip-BhidhbnD.js} +1 -1
  25. package/dashboard/dist/assets/{IpCheckPage-Bz09HXLn.js → IpCheckPage-WMEF1oS3.js} +1 -1
  26. package/dashboard/dist/assets/{LandingPage-DC-lZsYR.js → LandingPage-BmO-59ZP.js} +2 -2
  27. package/dashboard/dist/assets/{LeaderboardPage-D8MpLM_t.js → LeaderboardPage-C2WyniEt.js} +2 -2
  28. package/dashboard/dist/assets/{LeaderboardProBadge-pdXgokhE.js → LeaderboardProBadge-DAZnMRNn.js} +1 -1
  29. package/dashboard/dist/assets/{LeaderboardProfileModal-nHZLiE0m.js → LeaderboardProfileModal-D1BxcloV.js} +3 -3
  30. package/dashboard/dist/assets/{LeaderboardProfilePage-BKv3oIAW.js → LeaderboardProfilePage-RPJDTwpG.js} +1 -1
  31. package/dashboard/dist/assets/{LimitsPage-TmRTgSCb.js → LimitsPage-9ZOhKvn5.js} +1 -1
  32. package/dashboard/dist/assets/{LocalOnlyNotice-aF01udyR.js → LocalOnlyNotice-CH6w4hRw.js} +1 -1
  33. package/dashboard/dist/assets/{LoginCard-BaroD0Ct.js → LoginCard-D24HsRjs.js} +1 -1
  34. package/dashboard/dist/assets/{LoginModal-0jgyMGVM.js → LoginModal-sLvHyi9U.js} +1 -1
  35. package/dashboard/dist/assets/{LoginPage-BUx8U58i.js → LoginPage-PIvLEw1Y.js} +1 -1
  36. package/dashboard/dist/assets/{PetPage-CpOjtJqg.js → PetPage-DYcw_4P1.js} +2 -2
  37. package/dashboard/dist/assets/{PopoverPopup-BYjfer-M.js → PopoverPopup-D7ZCWq5f.js} +1 -1
  38. package/dashboard/dist/assets/{ProviderIcon-NtYa2h0u.js → ProviderIcon-B0kB52K-.js} +1 -1
  39. package/dashboard/dist/assets/{ResetPasswordPage-CYUg7TR1.js → ResetPasswordPage-B_NT4Xfl.js} +1 -1
  40. package/dashboard/dist/assets/{Select-CYP95o5y.js → Select-BtxjjP2Q.js} +1 -1
  41. package/dashboard/dist/assets/{SelectItemText-BCDfusOM.js → SelectItemText-Co1M6XRC.js} +1 -1
  42. package/dashboard/dist/assets/{SelfHostPage-BmVc2rIT.js → SelfHostPage-XadfhFnd.js} +1 -1
  43. package/dashboard/dist/assets/{ServiceStatusPage-Dyp8NwIn.js → ServiceStatusPage-ZEJyAxsQ.js} +1 -1
  44. package/dashboard/dist/assets/{SessionsPage-tGEj6Ztz.js → SessionsPage-Cte1taUu.js} +1 -1
  45. package/dashboard/dist/assets/{SettingsPage-CCMbq5wc.js → SettingsPage-D4qHgIxn.js} +3 -3
  46. package/dashboard/dist/assets/{SkillsPage-C4O4fbaQ.js → SkillsPage-CkQCk2uF.js} +1 -1
  47. package/dashboard/dist/assets/TokenGalaxy-Bx1vr4b0.js +4431 -0
  48. package/dashboard/dist/assets/{TooltipPopup-BJfFYesG.js → TooltipPopup-DQW8FWJO.js} +1 -1
  49. package/dashboard/dist/assets/{TrendMonitor-CElakFSU.js → TrendMonitor-BMNcY3N8.js} +1 -1
  50. package/dashboard/dist/assets/{WidgetsPage-Cvd1LbJm.js → WidgetsPage-luRTge7O.js} +1 -1
  51. package/dashboard/dist/assets/{WrappedPage-wRC1tE_a.js → WrappedPage-B1j3WgXx.js} +1 -1
  52. package/dashboard/dist/assets/{__vite-browser-external-V4TPLCJG.js → __vite-browser-external-CvvpsW-U.js} +3 -3
  53. package/dashboard/dist/assets/{agent-logos-Ba57HF3w.js → agent-logos-DL4fdks6.js} +1 -1
  54. package/dashboard/dist/assets/{arrow-left-B1bKnxXL.js → arrow-left-DiOsjgdu.js} +1 -1
  55. package/dashboard/dist/assets/{arrow-right-DrOlKzX5.js → arrow-right-DBFXV7GU.js} +1 -1
  56. package/dashboard/dist/assets/{arrow-up-right-hlYpo3yw.js → arrow-up-right-BIvpDQHo.js} +1 -1
  57. package/dashboard/dist/assets/{calendar-days-CSY6SEsI.js → calendar-days--psnXUPW.js} +1 -1
  58. package/dashboard/dist/assets/{check-xrP1gLw5.js → check-DLqbsN00.js} +1 -1
  59. package/dashboard/dist/assets/{chevron-down-6-zT5n9d.js → chevron-down-C0P0oLzP.js} +1 -1
  60. package/dashboard/dist/assets/{cloud-checkout-BZymZD4K.js → cloud-checkout-NSmb7QNy.js} +1 -1
  61. package/dashboard/dist/assets/{composite-C9izWafa.js → composite-D7ahPHYQ.js} +1 -1
  62. package/dashboard/dist/assets/{copy-Dkas5wZX.js → copy-COD7vwd6.js} +1 -1
  63. package/dashboard/dist/assets/{download-CagGRs0_.js → download-CpSUX4U-.js} +1 -1
  64. package/dashboard/dist/assets/{external-link-DRl10hxd.js → external-link-DXUjrooT.js} +1 -1
  65. package/dashboard/dist/assets/{flame-CkvmsTFB.js → flame-Dl3ZT9oo.js} +1 -1
  66. package/dashboard/dist/assets/{format-tokens-BtwhO3mV.js → format-tokens-Ci49THbK.js} +1 -1
  67. package/dashboard/dist/assets/{gift-YzjXkMQx.js → gift-DTHCN1Of.js} +1 -1
  68. package/dashboard/dist/assets/{icons-CHhKYs0u.js → icons-CB9s1e1k.js} +1 -1
  69. package/dashboard/dist/assets/index-BGT8ZQyn.js +502 -0
  70. package/dashboard/dist/assets/{index-DojzoMqd.js → index-DFdfNKJM.js} +1 -1
  71. package/dashboard/dist/assets/{index-CJknN9Jd.js → index-DeX4t_5p.js} +1 -1
  72. package/dashboard/dist/assets/{index-B0MQZTrM.js → index-Dozwi-Se.js} +1 -1
  73. package/dashboard/dist/assets/{info-Torep-Ti.js → info-CqM2wmSI.js} +1 -1
  74. package/dashboard/dist/assets/{link-2-DE5Yu-z6.js → link-2-Byo7Rj3t.js} +1 -1
  75. package/dashboard/dist/assets/{loader-circle-BL8LxD9n.js → loader-circle-CMxd78Na.js} +1 -1
  76. package/dashboard/dist/assets/{local-usage-transfer-8X1InWix.js → local-usage-transfer-CBjnoeck.js} +1 -1
  77. package/dashboard/dist/assets/{modifiers.esm-D60-6UQa.js → modifiers.esm-Oowlk_FC.js} +1 -1
  78. package/dashboard/dist/assets/module-BbVsRaE2.js +3 -0
  79. package/dashboard/dist/assets/{monitor-smartphone-C-IFPjqk.js → monitor-smartphone-B2EgB_9q.js} +1 -1
  80. package/dashboard/dist/assets/{play-n6uWrdH9.js → play-BSuP-UBL.js} +1 -1
  81. package/dashboard/dist/assets/{plus-B2f6TaNj.js → plus-BWemSIuC.js} +1 -1
  82. package/dashboard/dist/assets/{provider-display-DWqCEcsP.js → provider-display-BpzWuFDH.js} +1 -1
  83. package/dashboard/dist/assets/{react-B-zfi_j6.js → react-cIJ4zx62.js} +1 -1
  84. package/dashboard/dist/assets/{safePolygon-C2PsvI-v.js → safePolygon-C_ZMtbgL.js} +1 -1
  85. package/dashboard/dist/assets/{search-DZOaTLF9.js → search-BK7eyNds.js} +1 -1
  86. package/dashboard/dist/assets/{server-DIp4Qfsv.js → server-BqQHX-rd.js} +1 -1
  87. package/dashboard/dist/assets/{shield-check-Cs2M8-iT.js → shield-check-CO5U6gRw.js} +1 -1
  88. package/dashboard/dist/assets/{skills-api-CoYy6Tov.js → skills-api-CMye76ag.js} +1 -1
  89. package/dashboard/dist/assets/{sortable.esm-B5_hjIfs.js → sortable.esm-Bvb61Lvj.js} +1 -1
  90. package/dashboard/dist/assets/{store-BLXqtJzb.js → store-CICV1KXb.js} +1 -1
  91. package/dashboard/dist/assets/{terminal-CEMKX3ba.js → terminal-BKMWT1Ux.js} +1 -1
  92. package/dashboard/dist/assets/{trash-DOWYaXjK.js → trash-D2Oqim4r.js} +1 -1
  93. package/dashboard/dist/assets/{use-community-stats-BjRI1Bzz.js → use-community-stats-CEqwmjct.js} +1 -1
  94. package/dashboard/dist/assets/{use-latest-request-guard-T7L5qBU6.js → use-latest-request-guard-CTuzzu3F.js} +1 -1
  95. package/dashboard/dist/assets/{use-limits-display-prefs-vNIrCPZA.js → use-limits-display-prefs-CA2BLWkY.js} +1 -1
  96. package/dashboard/dist/assets/{use-native-settings-Cg5Zb4q_.js → use-native-settings-B54wHSj9.js} +1 -1
  97. package/dashboard/dist/assets/{use-ordered-list-BF-wIvmG.js → use-ordered-list--PU9ekxY.js} +1 -1
  98. package/dashboard/dist/assets/use-reduced-motion-CZ8_YWc2.js +1 -0
  99. package/dashboard/dist/assets/{use-transform-CbJ1IcNc.js → use-transform-BRyR8szg.js} +1 -1
  100. package/dashboard/dist/assets/{use-usage-limits-Dgg3jpC4.js → use-usage-limits-sufKdfDY.js} +1 -1
  101. package/dashboard/dist/assets/{useCurrency-3oBHWfSe.js → useCurrency-6oy7kSX8.js} +1 -1
  102. package/dashboard/dist/assets/{usePositioner-D0YrIW0A.js → usePositioner-ZtDdVdJg.js} +1 -1
  103. package/dashboard/dist/assets/{useTokenFormat-DZAHWE_R.js → useTokenFormat-tiOJ-PeE.js} +1 -1
  104. package/dashboard/dist/assets/{zap-kLub6Jiv.js → zap-Dr1dXUjN.js} +1 -1
  105. package/dashboard/dist/brand-logos/factory.svg +8 -0
  106. package/dashboard/dist/index.html +1 -1
  107. package/dashboard/dist/ip-check.html +1 -1
  108. package/dashboard/dist/leaderboard.html +1 -1
  109. package/dashboard/dist/share.html +1 -1
  110. package/package.json +4 -4
  111. package/src/lib/cursor-config.js +15 -1
  112. package/src/lib/pricing/curated-overrides.json +14 -0
  113. package/src/lib/pricing/seed-snapshot.json +1 -1
  114. package/src/lib/rollout.js +13 -4
  115. package/src/lib/usage-limits.js +266 -10
  116. package/dashboard/dist/assets/DashboardPage-CXI7RmxO.js +0 -1
  117. package/dashboard/dist/assets/DialogDescription-DztHQvj-.js +0 -1
  118. package/dashboard/dist/assets/TokenGalaxy-D2d738xr.js +0 -4426
  119. package/dashboard/dist/assets/index-C2DK8av-.js +0 -502
  120. package/dashboard/dist/assets/module-ZyVsxBG_.js +0 -3
  121. package/dashboard/dist/assets/use-reduced-motion-B9K5mIx4.js +0 -1
@@ -0,0 +1,3 @@
1
+ var Pu={};const w="u">typeof window?window:void 0,ge="u">typeof globalThis?globalThis:w,pe=ge?.navigator,C=ge?.document,Y=ge?.location,ys=ge?.fetch,Rr=ge?.XMLHttpRequest&&"withCredentials"in new ge.XMLHttpRequest?ge.XMLHttpRequest:void 0,cn=ge?.AbortController,Au=ge?.CompressionStream,be=pe?.userAgent,Wt=typeof globalThis<"u"?globalThis:w;Wt&&typeof self>"u"&&(Wt.self=Wt),Wt&&typeof File>"u"&&(Wt.File=function(){});const M=w??{},Cu="0.10.2",Je={DEBUG:!1,LIB_VERSION:Cu,LIB_NAME:"browser-common"};var je=(function(e){return e.AnonymousId="anonymous_id",e.DistinctId="distinct_id",e.Props="props",e.EnablePersonProcessing="enable_person_processing",e.PersonMode="person_mode",e.FeatureFlagDetails="feature_flag_details",e.FeatureFlags="feature_flags",e.FeatureFlagPayloads="feature_flag_payloads",e.BootstrapFeatureFlagDetails="bootstrap_feature_flag_details",e.BootstrapFeatureFlags="bootstrap_feature_flags",e.BootstrapFeatureFlagPayloads="bootstrap_feature_flag_payloads",e.OverrideFeatureFlags="override_feature_flags",e.Queue="queue",e.AiQueue="ai_queue",e.AiCaptureQueue="ai_capture_queue",e.LogsQueue="logs_queue",e.OptedOut="opted_out",e.SessionId="session_id",e.SessionStartTimestamp="session_start_timestamp",e.SessionLastTimestamp="session_timestamp",e.PersonProperties="person_properties",e.GroupProperties="group_properties",e.InstalledAppBuild="installed_app_build",e.InstalledAppVersion="installed_app_version",e.SessionReplay="session_replay",e.PushRegistered="push_registered",e.SessionReplayEventTriggerActivatedSession="session_replay_event_trigger_activated_session",e.SurveyLastSeenDate="survey_last_seen_date",e.SurveysInProgress="surveys_in_progress",e.SurveysSeen="surveys_seen",e.Surveys="surveys",e.RemoteConfig="remote_config",e.FlagsEndpointWasHit="flags_endpoint_was_hit",e.DeviceId="device_id",e})({}),sr=(function(e){return e.GZipJS="gzip-js",e.Base64="base64",e})({});const Fu=["$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"],Iu=["token"];function I(e,t){return e.indexOf(t)!==-1}const Nt=function(e){return e.trim()},ir=function(e){return e.replace(/^\$/,"")};function Yo(e){var t;const s=[];return(t=JSON.stringify(e,function(i,r){if(typeof r=="bigint")return r.toString();if(typeof r!="function"&&typeof r!="symbol"){if(r instanceof Error)return{name:r.name,message:r.message,stack:r.stack};if(r&&typeof r=="object"){for(;s.length>0&&s[s.length-1]!==this;)s.pop();if(s.includes(r))return"[Circular]";s.push(r)}return r}}))!==null&&t!==void 0?t:"null"}const Xo=Object.prototype,Lr=Xo.hasOwnProperty,ci=Xo.toString,O=Array.isArray||function(e){return ci.call(e)==="[object Array]"},ne=e=>typeof e=="function",D=e=>e===Object(e)&&!O(e),ke=e=>{if(D(e)){for(const t in e)if(Lr.call(e,t))return!1;return!0}return!1},x=e=>e===void 0,N=e=>ci.call(e)=="[object String]",as=e=>N(e)&&e.trim().length===0,se=e=>e===null,L=e=>x(e)||se(e),oe=e=>ci.call(e)=="[object Number]"&&e==e,ze=e=>oe(e)&&e>0,we=e=>ci.call(e)==="[object Boolean]",Ou=e=>I(Fu,e),Mu=e=>I(Iu,e);function Qo(e){return e===null||typeof e!="object"}function Vs(e,t){return{}.toString.call(e)===`[object ${t}]`}function Ut(e){switch({}.toString.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object DOMError]":case"[object WebAssembly.Exception]":return!0;default:return Zo(e,Error)}}function Dr(e){return"u">typeof Event&&Zo(e,Event)}function Zo(e,t){try{return e instanceof t}catch{return!1}}const Tu=[!0,"true",1,"1","yes"],_i=e=>I(Tu,e),Ru=[!1,"false",0,"0","no"];function dn(e,t,s,i,r,n,o){try{var a=e[n](o),l=a.value}catch(u){return void s(u)}a.done?t(l):Promise.resolve(l).then(i,r)}function Q(e){return function(){var t=this,s=arguments;return new Promise(function(i,r){var n=e.apply(t,s);function o(l){dn(n,i,r,o,a,"next",l)}function a(l){dn(n,i,r,o,a,"throw",l)}o(void 0)})}}const Lu=["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"],Ss=new Map,hn=function(e,t=[]){if(!e)return!1;const s=(function(o,a){let l="";for(let u=0;a.length>u;u++){const c=a[u];l+=c.length+":"+c}return o.length+":"+o+"|"+a.length+":"+l})(e,t),i=Ss.get(s);if(i!==void 0)return i;const r=e.toLowerCase(),n=Lu.concat(t).some(o=>r.indexOf(o.toLowerCase())!==-1);return 256>Ss.size||Ss.clear(),Ss.set(s,n),n};function qe(e,t,s,i,r){return t>s&&(i.warn("min cannot be greater than max."),t=s),oe(e)?e>s?(i.warn(" cannot be greater than max: "+s+". Using max value instead."),s):t>e?(i.warn(" cannot be less than min: "+t+". Using min value instead."),t):e:(i.warn(" must be a number. using max or fallback. max: "+s+", fallback: "+r),qe(r??s,t,s,i))}var Du=class{constructor(e){this.C={},this.I=e.I,this.R=qe(e.bucketSize,0,100,e.$),this.A=qe(e.refillRate,0,this.R,e.$),this.O=qe(e.refillInterval,0,864e5,e.$)}F(e,t){const s=Math.floor((t-e.lastAccess)/this.O);s>0&&(e.tokens=Math.min(e.tokens+s*this.A,this.R),e.lastAccess=e.lastAccess+s*this.O)}consumeRateLimit(e){var t;const s=Date.now(),i=String(e);let r=this.C[i];return r?this.F(r,s):(r={tokens:this.R,lastAccess:s},this.C[i]=r),r.tokens===0||(r.tokens--,r.tokens===0&&((t=this.I)===null||t===void 0||t.call(this,e)),r.tokens===0)}stop(){this.C={}}};const jt="Mobile",bs="Android",Us="Tablet",ea="Android Tablet",ta="iPad",sa="Apple Watch",Ls="Safari",di="BlackBerry",ia="Samsung Internet",Ds="Chrome",ra="Chrome iOS",na="Internet Explorer",oa="Internet Explorer Mobile",aa="Opera",la="Microsoft Edge",Ns="Firefox",ua="Firefox iOS",Ws="Nintendo",Gs="PlayStation",hi="Xbox",ca="Android Mobile",da="Mobile Safari",mi="Windows",ha="Windows Phone",pn="Nokia",rr="Ouya",Nu="Generic "+jt.toLowerCase(),pa="Generic "+Us.toLowerCase(),nr="Konqueror",fa="Oculus Browser",va="Vivaldi",ga="Yandex",_a="Whale",ma="DuckDuckGo",ya="Pale Moon",ba="Waterfox",or="Brave",wa="Claude",xa="Codex",$a="ChatGPT",ka="Google Search App",yi=new RegExp("Version/(\\d+(\\.\\d+)?)"),bi=new RegExp("(Claude|Codex|ChatGPT)\\/(\\d+(\\.\\d+)?)"),ju=new RegExp(hi,"i"),qu=new RegExp("PlayStation \\w+","i"),Hu=new RegExp("Nintendo \\w+","i"),Nr=new RegExp("BlackBerry|PlayBook|BB10","i"),Bu={"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"},Ea=function(e,t,s,i){return t=t||"",(function(n){return n?.brave?or:null})(s)||(i?.detectGoogleSearchApp&&I(e,"GSA/")?ka:I(e," OPR/")&&I(e,"Mini")?"Opera Mini":I(e," OPR/")?aa:Nr.test(e)?di:I(e,"IEMobile")||I(e,"WPDesktop")?oa:I(e,"OculusBrowser")?fa:I(e,"SamsungBrowser")?ia:I(e,"Edge")||I(e,"Edg/")?la:I(e,"Vivaldi/")?va:I(e,"YaBrowser/")?ga:I(e,"Whale/")?_a:I(e,"DuckDuckGo/")||I(e,"Ddg/")?ma:I(e,"Claude/")?wa:I(e,"Codex/")?xa:I(e,"ChatGPT/")?$a:I(e,"FBIOS")?"Facebook Mobile":I(e,"UCWEB")||I(e,"UCBrowser")?"UC Browser":I(e,"CriOS")?ra:I(e,"CrMo")||I(e,Ds)?Ds:I(e,bs)&&I(e,Ls)?ca:I(e,"FxiOS")?ua:I(e.toLowerCase(),nr.toLowerCase())?nr:I(e,"Brave/")?or:((n,o)=>o&&I(o,"Apple")||(function(a){return I(a,Ls)&&!I(a,Ds)&&!I(a,bs)})(n))(e,t)?I(e,jt)?da:Ls:I(e,"PaleMoon/")?ya:I(e,"Waterfox/")?ba:I(e,Ns)?Ns:I(e,"MSIE")||I(e,"Trident/")?na:I(e,"Gecko")?Ns:"")},zu={[oa]:[new RegExp("rv:(\\d+(\\.\\d+)?)")],[la]:[new RegExp("Edge?\\/(\\d+(\\.\\d+)?)")],[Ds]:[new RegExp("(Chrome|CrMo)\\/(\\d+(\\.\\d+)?)")],[ra]:[new RegExp("CriOS\\/(\\d+(\\.\\d+)?)")],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/(\\d+(\\.\\d+)?)")],[Ls]:[yi],[da]:[yi],[aa]:[new RegExp("(Opera|OPR)\\/(\\d+(\\.\\d+)?)")],[Ns]:[new RegExp("Firefox\\/(\\d+(\\.\\d+)?)")],[ua]:[new RegExp("FxiOS\\/(\\d+(\\.\\d+)?)")],[nr]:[new RegExp("Konqueror[:/]?(\\d+(\\.\\d+)?)","i")],[di]:[new RegExp("BlackBerry (\\d+(\\.\\d+)?)"),yi],[ca]:[new RegExp("android\\s(\\d+(\\.\\d+)?)","i")],[ia]:[new RegExp("SamsungBrowser\\/(\\d+(\\.\\d+)?)")],[fa]:[new RegExp("OculusBrowser\\/(\\d+(\\.\\d+)?)")],[va]:[new RegExp("Vivaldi\\/(\\d+(\\.\\d+)?)")],[ga]:[new RegExp("YaBrowser\\/(\\d+(\\.\\d+)?)")],[_a]:[new RegExp("Whale\\/(\\d+(\\.\\d+)?)")],[or]:[new RegExp("Brave\\/(\\d+(\\.\\d+)?)")],[wa]:[bi],[xa]:[bi],[$a]:[bi],[ma]:[new RegExp("(DuckDuckGo|Ddg)\\/(\\d+(\\.\\d+)?)")],[ya]:[new RegExp("PaleMoon\\/(\\d+(\\.\\d+)?)")],[ba]:[new RegExp("Waterfox\\/(\\d+(\\.\\d+)?)")],[ka]:[new RegExp("GSA\\/(\\d+(\\.\\d+)?)")],[na]:[new RegExp("(rv:|MSIE )(\\d+(\\.\\d+)?)")],Mozilla:[new RegExp("rv:(\\d+(\\.\\d+)?)")]},Vu=function(e,t,s,i){const r=Ea(e,t,s,i),n=zu[r];if(x(n))return null;for(let o=0;n.length>o;o++){const a=e.match(n[o]);if(a)return parseFloat(a[a.length-2])}return null},fn=[[new RegExp("Xbox; Xbox (.*?)[);]","i"),e=>[hi,e&&e[1]||""]],[new RegExp(Ws,"i"),[Ws,""]],[new RegExp(Gs,"i"),[Gs,""]],[Nr,[di,""]],[new RegExp(mi,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[ha,""];if(new RegExp(jt).test(t)&&!/IEMobile\b/.test(t))return["Windows Mobile",""];const s=/Windows NT ([0-9.]+)/i.exec(t);if(s&&s[1]){let i=Bu[s[1]]||"";return/arm/i.test(t)&&(i="RT"),[mi,i]}return[mi,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>e&&e[3]?["iOS",[e[3],e[4],e[5]||"0"].join(".")]:["iOS",""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{let t="";return e&&e.length>=3&&(t=x(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("(Android (\\d+)\\.(\\d+)\\.?(\\d+)?|Android)","i"),e=>e&&e[2]?[bs,[e[2],e[3],e[4]||"0"].join(".")]:[bs,""]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{const t=["Mac OS X",""];return e&&e[1]&&(t[1]=[e[1],e[2],e[3]||"0"].join(".")),t}],[/Mac/i,["Mac OS X",""]],[/CrOS/,["Chrome OS",""]],[/Linux|debian/i,["Linux",""]]],Sa=function(e){for(let t=0;fn.length>t;t++){const[s,i]=fn[t],r=s.exec(e),n=r&&(ne(i)?i(r,e):i);if(n)return n}return["",""]},Pa=function(e){return Hu.test(e)?Ws:qu.test(e)?Gs:ju.test(e)?hi:new RegExp(rr,"i").test(e)?rr:new RegExp("(Windows Phone|WPDesktop)","i").test(e)?ha:/iPad/.test(e)?ta:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?sa:Nr.test(e)?di:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(pn,"i").test(e)?pn:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(e)||/(kf[a-z]+)( bui|\)).+silk\//i.test(e)?"Kindle Fire":/(Android|ZTE)/i.test(e)?new RegExp(jt).test(e)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(e)||/pixel[\daxl ]{1,6}/i.test(e)&&!/pixel c/i.test(e)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(e)||/lmy47v/i.test(e)&&!/QTAQZ3/i.test(e)?bs:ea:new RegExp("(pda|Mobile)","i").test(e)?Nu:new RegExp(Us,"i").test(e)&&!new RegExp("Tablet pc","i").test(e)?pa:""},Uu=function(e,t){var s;const i=Pa(e);return i===ta||i===ea||i==="Kobo"||i==="Kindle Fire"||i===pa?Us:i===Ws||i===hi||i===Gs||i===rr?"Console":i===sa?"Wearable":i?jt:t?.userAgentDataPlatform==="Android"&&((s=t?.maxTouchPoints)!==null&&s!==void 0?s:0)>0?600>Math.min((r=t?.screenWidth)!==null&&r!==void 0?r:0,(n=t?.screenHeight)!==null&&n!==void 0?n:0)/((o=t?.devicePixelRatio)!==null&&o!==void 0?o:1)?jt:Us:"Desktop";var r,n,o},wi=/\bFBAV\/(\d+(?:\.\d+)*)/i,vn=[[/\bInstagram(?:[ /](\d+(?:\.\d+)*))?\b/i,"Instagram"],[/\bBarcelona[ /](\d+(?:\.\d+)*)?/i,"Threads"],[/\b(?:MessengerForiOS|(?:FBAN|FB_IAB)\/Orca-Android)\b/i,"Messenger",wi],[/\bFBAN\/EMA\b/i,"Facebook Lite",wi],[/\b(?:FBIOS|(?:FBAN|FB_IAB)\/(?:FB4A|FBIOS))\b/i,"Facebook",wi],[/\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"]],ar="[Truncated]",Es="[Unserializable]";function Tt(e){let t="";for(let s=0;e.length>s;s++){const i=e.charCodeAt(s);if(55296>i||i>56319)t+=56320>i||i>57343?e[s]:"�";else{const r=e.charCodeAt(s+1);56320>r||r>57343?t+="�":(t+=e[s]+e[s+1],s++)}}return t}function Aa(e,t){if(!t)return e;let s=[];try{s=Object.keys(t)}catch{s=[]}for(const i of s){let r;try{r=t[i]}catch{r=Es}Object.defineProperty(e,i,{value:r,enumerable:!0,writable:!0,configurable:!0})}return e}const xi=3e5;var Ca=class{record(e){if(e.kind==="too-large")return;if(e.kind!=="retry-later")return void this.reset();if(!e.retryAfterMs)return;const t=this.isOpen(),s=Date.now(),i=Math.min(e.retryAfterMs,xi);if(!t)return this.ts=s,void(this.es=s+i);this.es=Math.max(this.es,Math.min(s+i,this.ts+xi))}remainingMs(){const e=Date.now();if(this.ts-5e3>e)return this.reset(),0;const t=Math.min(xi,Math.max(0,this.es-e));return t===0&&this.reset(),t}isOpen(){return this.remainingMs()>0}reset(){this.es=0,this.ts=0}constructor(){this.es=0,this.ts=0}};const Wu=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function gn(e,t){return typeof(s=e)=="string"&&Wu.test(s)?e:t();var s}function Fa(e,t){const s=new Error(t);try{Object.defineProperty(s,"name",{value:e,writable:!0,enumerable:!0,configurable:!0})}catch{}return s}function at(e){return e&&e.split("#")[0]}function _n(e){try{return e()}catch{return}}function Ia(e,t){const s=setTimeout(e,t);return s!=null&&s.unref&&s?.unref(),s}function mn(e,t,s){return Oa.apply(this,arguments)}function Oa(){return(Oa=Q(function*(e,t,s){let i;try{return yield Promise.race([e,new Promise((r,n)=>{i=Ia(()=>{try{s?.(),r()}catch(o){n(o)}},t)})])}finally{clearTimeout(i)}})).apply(this,arguments)}function ls(e){return ls=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ls(e)}function Gu(e,t,s){return(t=(function(i){var r=(function(n){if(ls(n)!="object"||!n)return n;var o=n[Symbol.toPrimitive];if(o!==void 0){var a=o.call(n,"string");if(ls(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)})(i);return ls(r)=="symbol"?r:r+""})(t))in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function yn(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),s.push.apply(s,i)}return s}function f(e){for(var t=1;arguments.length>t;t++){var s=arguments[t]!=null?arguments[t]:{};t%2?yn(Object(s),!0).forEach(function(i){Gu(e,i,s[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):yn(Object(s)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(s,i))})}return e}let Gt,bn,wn,wt;function Ju(e){var t;const s=globalThis._posthogChunkIds,i=globalThis._debugIds;if(!s&&!i)return;const r=s?Object.keys(s):[],n=i?Object.keys(i):[];if(wt&&xn(s,r,bn)&&xn(i,n,wn))return wt;bn=s?f({},s):void 0,wn=i?f({},i):void 0,wt={},(t=Gt)!==null&&t!==void 0||(Gt={});const o=(a,l)=>{for(const c of a){const d=l[c];if(!d)continue;const h=Gt?.[c];if(h){wt[h]=d;continue}const p=e(c);for(let v=p.length-1;v>=0;v--){var u;const m=(u=p[v])===null||u===void 0?void 0:u.filename;if(m){wt[m]=d,Gt[c]=m;break}}}};return i&&o(n,i),s&&o(r,s),wt}function xn(e,t,s){return e&&s?t.length===Object.keys(s).length&&t.every(i=>e[i]===s[i]):e===s}var Ku=class{constructor(e,t,s=[]){this.coercers=e,this.stackParser=t,this.modifiers=s}buildFromUnknown(e,t={}){const s=t&&t.mechanism||{handled:!0,type:"generic"},i=this.buildCoercingContext(s,t,0).apply(e),r=this.buildParsingContext(t),n=this.parseStacktrace(i,r);return{$exception_list:this.convertToExceptionList(n,s),$exception_level:"error"}}modifyFrames(e){var t=this;return Q(function*(){for(const s of e)s.stacktrace&&s.stacktrace.frames&&O(s.stacktrace.frames)&&(s.stacktrace.frames=yield t.applyModifiers(s.stacktrace.frames));return e})()}coerceFallback(e){var t;return{type:"Error",value:"Unknown error",stack:(t=e.syntheticException)===null||t===void 0?void 0:t.stack,synthetic:!0}}parseStacktrace(e,t){var s;let i,r;if(e.cause!=null&&(i=this.parseStacktrace(e.cause,t)),e.stack!=""&&e.stack!=null)try{r=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?t.skipFirstLines:0),t.chunkIdMap)}catch{}return f(f({},e),{},{cause:i,stack:r,errors:(s=e.errors)===null||s===void 0?void 0:s.map(n=>this.parseStacktrace(n,t))})}applyChunkIds(e,t){return e.map(s=>(s.filename&&t&&(s.chunk_id=t[s.filename]),s))}applyCoercers(e,t){for(const s of this.coercers)if(s.match(e))return s.coerce(e,t);return this.coerceFallback(t)}applyModifiers(e){var t=this;return Q(function*(){let s=e;for(const i of t.modifiers)s=yield i(s);return s})()}convertToExceptionList(e,t){const s=[],i=(r,n,o)=>{var a;const l=s.length,u=n===void 0?f(f({type:typeof t.type=="string"&&t.type.length>0?t.type:"generic"},typeof t.handled=="boolean"?{handled:t.handled}:t.handled===void 0?{handled:!0}:{}),{},{synthetic:typeof t.synthetic=="boolean"?t.synthetic:r.synthetic,exception_id:l}):{type:"chained",source:o,synthetic:r.synthetic,exception_id:l,parent_id:n},c={type:r.type,value:r.value,mechanism:u};r.stack&&(c.stacktrace={type:"raw",frames:r.stack}),s.push(c),r.cause&&i(r.cause,l,"cause");for(const d of(a=r.errors)!==null&&a!==void 0?a:[])i(d,l,"member")};return i(e),s}buildParsingContext(e){var t;return{chunkIdMap:Ju(this.stackParser),skipFirstLines:(t=e.skipFirstLines)!==null&&t!==void 0?t:1}}getAggregateErrors(e){try{if(Ut(e)){let s=Object.getPrototypeOf(e);for(let i=0;s&&100>i;i++){var t;const r=(t=Object.getOwnPropertyDescriptor(s,"constructor"))===null||t===void 0?void 0:t.value;if(typeof r=="function"&&r.name==="AggregateError"){const n=e.errors;return O(n)?n:void 0}s=Object.getPrototypeOf(s)}}}catch{}}buildCoercingContext(e,t,s=0){let i=0,r=0,n=!1;const o=new Set,a=[],l={},u=(h,p,v=0)=>{const m=c(p,v),g=m.apply;if(m.apply=S=>{a.push(h);try{return g(S)}finally{a.pop()}},v>4||v>0&&a.indexOf(h)!==-1)return this.coerceFallback(m);const y=typeof h=="object"&&h!==null||typeof h=="function";if(v===0&&i>=50||y&&o.has(h))return;y&&o.add(h),v===0&&i++;const _=this.getAggregateErrors(h);let b,k;n||(n=!!_);try{if(b=this.applyCoercers(h,m),!b)throw l}catch(S){if(S===l)return void(v===0&&i--);if(!n)throw S;b=this.coerceFallback(m)}if(!_||i>=50)return b;try{k=_.length}catch{return b}if(!Number.isInteger(k)||0>k||k>4294967295)return b;const $=[];for(let S=0;50>i&&1e3>r&&k>S;S++){let A;r++;try{A=m.next(_[S])}catch{i++,A=this.coerceFallback(c(p+1))}A&&$.push(A)}return f(f({},b),{},{errors:$})},c=(h,p=0)=>f(f({},t),{},{syntheticException:h==0?t.syntheticException:void 0,mechanism:h==0?e:{},apply(v){const m=u(v,h,p+1);if(!m)throw l;return m},next:v=>u(v,h+1)}),d=c(s);return f(f({},d),{},{apply:h=>{var p;return(p=u(h,s))!==null&&p!==void 0?p:this.coerceFallback(d)}})}};const Yu=/^([a-z][a-z0-9.+-]+):/i,Xu=["http","https","file","blob","app","capacitor","ionic","webpack","webpack-internal","ng"];function Qu(e){if(!e||e==="<anonymous>")return!1;const t=Yu.exec(e);return!t||Xu.includes(t[1].toLowerCase())}function lr(e,t,s,i,r){const n={platform:e,filename:t,function:s==="<anonymous>"?"?":s,in_app:Qu(t)};return x(i)||(n.lineno=i),x(r)||(n.colno=r),n}const Ma=(e,t)=>{const s=e.indexOf("safari-extension")!==-1,i=e.indexOf("safari-web-extension")!==-1;return s||i?[e.indexOf("@")!==-1?e.split("@")[0]:"?",s?`safari-extension:${t}`:`safari-web-extension:${t}`]:[e,t]},Zu=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,ec=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,tc=/\((\S*)(?::(\d+))(?::(\d+))\)/,sc=(e,t)=>{const s=Zu.exec(e);if(s){const[,r,n,o]=s;return lr(t,r,"?",+n,+o)}const i=ec.exec(e);if(i){if(i[2]&&i[2].indexOf("eval")===0){const o=tc.exec(i[2]);o&&(i[2]=o[1],i[3]=o[2],i[4]=o[3])}const[r,n]=Ma(i[1]||"?",i[2]);return lr(t,n,r,i[3]?+i[3]:void 0,i[4]?+i[4]:void 0)}},ic=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,rc=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,nc=(e,t)=>{const s=ic.exec(e);if(s){if(s[3]&&s[3].indexOf(" > eval")>-1){const n=rc.exec(s[3]);n&&(s[1]=s[1]||"eval",s[3]=n[1],s[4]=n[2],s[5]="")}let i=s[3],r=s[1]||"?";return[r,i]=Ma(r,i),lr(t,i,r,s[4]?+s[4]:void 0,s[5]?+s[5]:void 0)}},$n=/\(error: (.*)\)/;function jr(e,t){return e.filename===t.filename&&e.function===t.function&&e.module===t.module&&e.lineno===t.lineno&&e.colno===t.colno}function oc(e){for(let t=1;10>=t;t++){const s=e.length-2*t;if(0>s)break;let i=!0;for(let r=0;t>r;r++)if(!jr(e[s+r],e[s+t+r])){i=!1;break}if(i){for(let r=0;t>r;r++)e[s+r]=e[s+t+r];return e.length=s+t,{start:s,length:t}}}}function ac(e,t){const s=t.start+t.length,i=Ra(e,t);i&&e.splice(s+i===e.length?s:t.start,i)}function Ta(e,t){let s=t.start;for(;s>0&&jr(e[s-1],e[s-1+t.length]);)s--;return t.start-s}function Ra(e,t){const s=t.start+t.length;let i=s;for(;e.length>i&&jr(e[i],e[i-t.length]);)i++;return i-s}function lc(e,t){const s=t[0];let i=e.length-(s?Ta(e,s):0);for(const r of t)i-=Ra(e,r);return i}function uc(e,t,s){for(let i=0;e.length>i;i++){const r=e[(t+i)%e.length],n=e[(s+i)%e.length];if(r!==n)return n>r}return!1}var cc=class{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){const s=N(e.stack);return{type:this.getType(e),value:this.getValue(e),stack:s?e.stack:void 0,cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return this.isDOMError(e)?"DOMError":"DOMException"}getValue(e){const t=e.name||(this.isDOMError(e)?"DOMError":"DOMException");return e.message?`${t}: ${e.message}`:t}isDOMException(e){return Vs(e,"DOMException")}isDOMError(e){return Vs(e,"DOMError")}},dc=class{match(e){return Ut(e)}coerce(e,t){var s;const i=this.getStack(e),r=i===void 0?(s=t.syntheticException)===null||s===void 0?void 0:s.stack:void 0,n=!!r;return{type:this.getType(e),value:this.getMessage(e,t),stack:i??r,cause:e.cause?t.next(e.cause):void 0,synthetic:n}}getType(e){return e.name||e.constructor.name}getMessage(e,t){const s=e.message;return String(s.error&&typeof s.error.message=="string"?s.error.message:s)}getStack(e){try{const t=e.stacktrace;if(typeof t=="string"&&t.length>0)return t;const s=e.stack;return typeof s=="string"&&s.length>0?s:void 0}catch{return}}},hc=class{match(e){return!!Vs(e,"ErrorEvent")&&(e.error!=null||this.hr(e))}coerce(e,t){var s;if(e.error!=null)return t.apply(e.error);const i=t.apply(e.message);return f(f({},i),{},{stack:(s=this.vr(e))!==null&&s!==void 0?s:i.stack,synthetic:!0})}hr(e){return N(e.message)&&e.message.length>0}vr(e){var t,s;const i=e,r=(t=i.lineno)!==null&&t!==void 0?t:0,n=(s=i.colno)!==null&&s!==void 0?s:0;if(N(i.filename)&&i.filename.length!==0&&r!==0)return`Error
2
+ at ${i.filename}:${r}:${n}`}};const pc=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;var fc=class{match(e){return typeof e=="string"}coerce(e,t){var s;const[i,r]=this.getInfos(e);return{type:i??"Error",value:r??e,stack:(s=t.syntheticException)===null||s===void 0?void 0:s.stack,synthetic:!0}}getInfos(e){let t="Error",s=e;const i=e.match(pc);return i&&(t=i[1],s=i[2]),[t,s]}};const vc=["fatal","error","warning","log","info","debug"];function La(e,t=40){const s=Object.keys(e);if(s.sort(),!s.length)return"[object has no keys]";for(let i=s.length;i>0;i--){const r=s.slice(0,i).join(", ");if(t>=r.length)return i===s.length?r:r.length>t?`${r.slice(0,t)}...`:r}return""}var gc=class{match(e){return typeof e=="object"&&e!==null}coerce(e,t){var s,i;const r=this.getErrorPropertyFromObject(e);return r?t.apply(r):{type:this.getType(e),value:this.getValue(e),stack:(s=this.getStack(e))!==null&&s!==void 0?s:(i=t.syntheticException)===null||i===void 0?void 0:i.stack,level:this.isSeverityLevel(e.level)?e.level:"error",synthetic:!0}}getType(e){if(Dr(e))return e.constructor.name;const t="name"in e?e.name:void 0;return N(t)&&!as(t)?t:"Error"}getValue(e){if("name"in e&&typeof e.name=="string"){let s=`'${e.name}' captured as exception`;return"message"in e&&typeof e.message=="string"&&(s+=` with message: '${e.message}'`),s}if("message"in e&&typeof e.message=="string")return e.message;const t=this.getObjectClassName(e);return`${t&&t!=="Object"?`'${t}'`:"Object"} captured as exception with keys: ${La(e)}`}isSeverityLevel(e){return N(e)&&!as(e)&&vc.indexOf(e)>=0}getStack(e){try{return N(e.stacktrace)&&e.stacktrace.length>0?e.stacktrace:N(e.stack)&&e.stack.length>0?e.stack:void 0}catch{return}}getErrorPropertyFromObject(e){for(const t in e)if({}.hasOwnProperty.call(e,t)){const s=e[t];if(Ut(s))return s}}getObjectClassName(e){try{const t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{return}}},_c=class{match(e){return Dr(e)}coerce(e,t){var s;const i=e.constructor.name;return{type:i,value:`${i} captured as exception with keys: ${La(e)}`,stack:(s=t.syntheticException)===null||s===void 0?void 0:s.stack,synthetic:!0}}},mc=class{match(e){return Qo(e)}coerce(e,t){var s;return{type:"Error",value:`Primitive value captured as exception: ${String(e)}`,stack:(s=t.syntheticException)===null||s===void 0?void 0:s.stack,synthetic:!0}}},yc=class{match(e){return Vs(e,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(e)}isCustomEventWrappingRejection(e){if(!Dr(e))return!1;try{const t=e.detail;return t!=null&&typeof t=="object"&&"reason"in t}catch{return!1}}coerce(e,t){var s;const i=this.getUnhandledRejectionReason(e);return Qo(i)?{type:"UnhandledRejection",value:`Non-Error promise rejection captured with value: ${String(i)}`,stack:(s=t.syntheticException)===null||s===void 0?void 0:s.stack,synthetic:!0}:t.apply(i)}getUnhandledRejectionReason(e){try{if("reason"in e)return e.reason;if("detail"in e&&e.detail!=null&&typeof e.detail=="object"&&"reason"in e.detail)return e.detail.reason}catch{}return e}};const Js="$message",Ks="$timestamp",bc=new Set([Js,Ks]),$i={enabled:!0,max_bytes:32768};function Ys(e){var t;return e?{enabled:(t=e.enabled)!==null&&t!==void 0?t:$i.enabled,max_bytes:xc(e.max_bytes,$i.max_bytes)}:f({},$i)}var wc=class{constructor(e){this.ns=[],this.ss=0,this.Ar=Ys(e)}setConfig(e){this.Ar=Ys(e),this.rs()}add(e){const t=(function(i){let r;try{r=Yo(i)}catch{return}try{const n=JSON.parse(r);if(!D(n))return;const o=n,a=o[Js],l=o[Ks];return!N(a)||a.trim().length===0||!N(l)&&!oe(l)?void 0:{step:o,json:r}}catch{return}})(e);if(!t)return;const s=(function(i){if("u">typeof TextEncoder)return new TextEncoder().encode(i).length;const r=encodeURIComponent(i);let n=0;for(let o=0;r.length>o;o++)r[o]==="%"?(n+=1,o+=2):n+=1;return n})(t.json);s>this.Ar.max_bytes||(this.ns.push({step:t.step,bytes:s}),this.ss+=s,this.rs())}getAttachable(){return this.ns.map(e=>e.step)}clear(){this.ns=[],this.ss=0}size(){return this.ns.length}rs(){for(;this.ss>this.Ar.max_bytes&&this.ns.length>0;){const e=this.ns.shift();e&&(this.ss-=e.bytes)}}};function xc(e,t){if(!oe(e)||e===1/0||e===-1/0)return t;const s=Math.floor(e);return 0>s?t:s}const kn=e=>{if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}};function En(e){return typeof e=="string"||e}function Sn(e){return typeof e=="string"?e:void 0}const $c=["$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","oppref","bfcid","irclid","_kx","$session_id","$window_id","$lib","$lib_version","$device_id","$is_server"],Da="NativeGzipValidationError",ur=e=>e.length>=2&&e[0]===31&&e[1]===139,Pn=(e,t)=>e===sr.GZipJS||t===sr.GZipJS||t==="gzip",An=e=>!(!e||typeof e!="object")&&("name"in e?String(e.name):"")==="NotReadableError";let Jt;const Ps=e=>{throw Fa(Da,`Native gzip produced invalid output: ${e}`)},kc=(Cn=Q(function*(e,t){18>e.size&&Ps("too-short");const s=new Uint8Array(yield e.slice(0,10).arrayBuffer());ur(s)&&s[2]===8||Ps("invalid-header");const i=new DataView(yield e.slice(e.size-8).arrayBuffer());i.getUint32(0,!0)!==(n=>{const o=(()=>{if(Jt)return Jt;Jt=[];for(let l=0;256>l;l++){let u=l;for(let c=0;8>c;c++)u=1&u?3988292384^u>>>1:u>>>1;Jt[l]=u>>>0}return Jt})();let a=4294967295;for(let l=0;n.length>l;l++)a=o[255&(a^n[l])]^a>>>8;return(4294967295^a)>>>0})(t)&&Ps("invalid-crc");const r=t.length>>>0;i.getUint32(4,!0)!==r&&Ps("invalid-size")}),function(e,t){return Cn.apply(this,arguments)});var Cn;function cr(){return cr=Q(function*(e,t=!0,s){try{const r=new TextEncoder().encode(e),n=new globalThis.CompressionStream("gzip"),o=n.writable.getWriter(),a=o.write(r).then(()=>o.close()).catch((i=Q(function*(c){try{yield o.abort(c)}catch{}throw c}),function(c){return i.apply(this,arguments)})),l=new Response(n.readable).blob(),[u]=yield Promise.all([l,a]);return yield kc(u,r),u}catch(r){if(s?.rethrow)throw r;return t&&console.error("Failed to gzip compress data",r),null}var i}),cr.apply(this,arguments)}function Na(e,t){if(e==null)return{};var s,i,r=(function(o,a){if(o==null)return{};var l={};for(var u in o)if({}.hasOwnProperty.call(o,u)){if(a.includes(u))continue;l[u]=o[u]}return l})(e,t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);for(i=0;n.length>i;i++)t.includes(s=n[i])||{}.propertyIsEnumerable.call(e,s)&&(r[s]=e[s])}return r}const ve="[redacted]",Ec=/^[A-Za-z0-9+/\n\r]+=*$/,Sc=/^[A-Za-z0-9_-]+={0,2}$/,Pc=/[-_]/,Ac=/^data:[^,\s]*;base64,/i,Cc=/^[A-Za-z0-9+/_-]+={0,2}$/,Fc=/\bph[a-z]_[A-Za-z0-9_-]{20,}\b/g,Ic=/^(authorization|cookie|set-cookie|x-api-key|api[-_]?key|api[-_]?token|access[-_]?token|refresh[-_]?token|token|password|secret|client[-_]?secret|private[-_]?key)$/i,ja=/[a-z][a-z0-9+.-]{0,63}:[^\s<>"]+/gi,Oc=/[\s<>"]/,qa=new RegExp(ja.source,"i"),Ha=/[a-z][a-z0-9+.-]{0,63}:\/\//i,Mc=new RegExp(`^${Ha.source}`,"i"),Tc=new RegExp(Ha.source,"gi"),Rc=/(^|[-_./;])(auth|token|secret|password|passwd|pwd|credential|signature|sig|key|hmac|sas|bearer|jwt|session|sessionid)([-_./;]|$)/i,Lc=/^(code|AWSAccessKeyId|GoogleAccessId|Policy)$/i,Dc=/[\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]/g,Nc=/[A-Za-z0-9._%+-]{1,64}@[A-Za-z0-9.-]{1,255}\.[A-Za-z]{2,24}/g,jc=/\b(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\b/g,qc=/(^|[^\w:])((?:(?:[0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4}|(?:[0-9A-Fa-f]{1,4}:){1,7}:|(?:[0-9A-Fa-f]{1,4}:){1,6}:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4}){0,5}|::(?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4}){0,6})))(?=$|[^\w:])/g,Hc=/\b\d{3}[ .-]\d{2}[ .-]\d{4}\b/g,Bc=/\b\d(?:[ ./-]?\d){12,}\b/g,Fn=/\d+/g,zc=/(^|[^\w+])((?:\+?1[ ./-]?)?(?:\(\d{3}\)[ ./-]?|\d{3}[ ./-])\d{3}[ ./-]\d{4})(?![\w])/g,Vc=/(^|[^\w])(\+\d{1,3}(?:[ ./()-]{0,2}\d){7,13})(?![\w])/g;function dr(e){return(function(t){return Ic.test(t)})(e)||Rc.test(e)||Lc.test(e)}function ki(e){return e.split("&",129).length>128}function Uc(e,t,s){return dr(e)||t.includes(";")&&(function(i){return i.split(";").some(r=>dr(r.split("=",1)[0]))})(t)?ve:qa.test(t)?s?qr(t,{allowNestedUrls:!1,stripPunctuation:!0}):ve:t}function Ba(e,t){const s=new URLSearchParams;let i=!1,r=!1;for(const[n,o]of new URLSearchParams(e)){const a=Xs(n),l=Xs(o);i||(i=a!==n||l!==o);const u=Uc(a,l,t);i||(i=u!==l),r=dr(a)||u!==l,s.append(a,u)}return{changed:i,lastFieldSensitive:r,serialized:s.toString()}}function In(e,t){if(!e.includes("="))return{value:Wc(e,t),lastFieldSensitive:!1};const s=Ba(e,t);return{value:s.changed?s.serialized:e,lastFieldSensitive:s.lastFieldSensitive}}function Wc(e,t){return t?qr(e,{allowNestedUrls:!1,stripPunctuation:!0}):qa.test(e)?ve:e}function Gc(e,t,s){return e==="#"?!t.fragment&&(t.fragment=!0):e==="?"&&(t.fragment?s!=="="&&!t.fragmentQuery&&(t.fragmentQuery=!0):!t.query&&(t.query=!0))}function Ei(e,t){var s;if(e.length>8192&&Mc.test(e))return ve;const{address:i,suffix:r}=t.stripPunctuation?(function(g){let y=g.length;for(;y>0&&".,;:!?)]}'".includes(g[y-1]);)y--;return{address:g.slice(0,y),suffix:g.slice(y)}})(e):{address:e,suffix:""};let n;try{n=new URL(i)}catch{return ve+r}const o=n.search.slice(1),a=n.hash!=="",l=(function(g){const y=g.slice(1),_=y.indexOf("?");return 0>_?{head:y,tail:null}:{head:y.slice(0,_),tail:y.slice(_+1)}})(n.hash);if(ki(o)||ki(l.head)||ki((s=l.tail)!==null&&s!==void 0?s:""))return ve+r;let u=!1;(n.username||n.password)&&(n.username=ve,n.password="",u=!0);const c=Ba(o,t.allowNestedUrls);c.changed&&(n.search=c.serialized,u=!0);const d=In(l.head,t.allowNestedUrls),h=l.tail===null?null:(p=l.tail,d.lastFieldSensitive?{value:p===""?"":ve,lastFieldSensitive:!0}:In(p,t.allowNestedUrls));var p;const v=h===null?d.value:`${d.value}?${h.value}`;v!==n.hash.slice(1)&&(n.hash=v,u=!0);const m=a?h??d:c;return(u?Xs(n.toString()):i)+(m.lastFieldSensitive?"":r)}function qr(e,t){return e.replace(ja,s=>(function(i,r){const n=(function(l){if(!l.includes("://"))return[];const u=[...l.matchAll(Tc)].map(m=>m.index),c=[],d={query:!1,fragment:!1,fragmentQuery:!1};let h=0,p=!1,v="";for(let m=0;l.length>m&&u.length>h;m++){u[h]===m&&(m>0&&v!=="="&&c.push(m),h++);const g=l[m];Gc(g,d,v)?(v=g,p=!0):p&&"=&".includes(g)&&(v=g)}return c})(i);if(n.length===0)return Ei(i,r);let o="",a=0;for(const l of n)o+=Ei(i.slice(a,l),f(f({},r),{},{stripPunctuation:!1})),a=l;return o+Ei(i.slice(a),r)})(s,f(f({},t),{},{stripPunctuation:t.stripPunctuation&&s.length!==e.length})))}function Xs(e){return e.replace(Fc,ve)}function za(e,t){return(function(s){return s.length>=10240&&(Ec.test(s)||(function(i){const r=Ac.exec(i);if(!r)return!1;let n;try{n=decodeURIComponent(i.slice(r[0].length))}catch{return!1}return Cc.test(n.replace(/[\r\n]/g,""))})(s)||Pc.test(s)&&Sc.test(s))})(e)?"[binary data redacted - not supported by PostHog MCP analytics]":(function(s,i,r){const n=4*r.maxStringLength;if(s.length>n){const o=i(s.slice(0,(function(a,l){let u=l;for(;u>0&&!Oc.test(a[u-1]);)u--;return u})(s,n)));if(o.length>=2*r.maxStringLength)return o+r.truncationSuffix}return i(s)})(e,s=>(function(i){return qr(i,{allowNestedUrls:!0,stripPunctuation:!0})})((function(i){let r=i.replace(Dc," ");return r=r.replace(Nc,ve),r=r.replace(jc,ve),r=r.replace(qc,`$1${ve}`),r=r.replace(Bc,Kc),r=r.replace(Hc,ve),r=r.replace(zc,`$1${ve}`),r=r.replace(Vc,`$1${ve}`),r})(Xs(s))),t)}function Jc(e){let t=0,s=!1;for(let i=e.length-1;i>=0;i--){let r=e.charCodeAt(i)-48;if(0>r||r>9)return!1;s&&(r*=2,r>9&&(r-=9)),t+=r,s=!s}return t%10==0}function Kc(e){const t=[];for(let n=Fn.exec(e);n!==null;n=Fn.exec(e))t.push({digits:n[0],start:n.index,end:n.index+n[0].length});let s="",i=0,r=0;for(;t.length>r;){let n="",o=-1;for(let a=r;t.length>a&&(n+=t[a].digits,19>=n.length);a++)n.length>=13&&Jc(n)&&(o=a);0>o?r++:(s+=e.slice(i,t[r].start)+ve,i=t[o].end,r=o+1)}return s+e.slice(i)}const Yc={}.propertyIsEnumerable;function Qs(e,t){try{return Va(e,t,{ancestors:new WeakSet,remainingNodes:1e4},0)}catch{return[]}}function Hr(e,t,s,i){if(0>=s.remainingNodes)return{stringValue:ar};if(s.remainingNodes--,we(e))return{boolValue:e};if(typeof e=="bigint")return(function(r,n){const o=r.toString(),a=BigInt("9223372036854775808");return r>=a||-a>r?(n?.debug(`Attribute ${o} is outside the int64 range; encoding it as a string`),{stringValue:o}):{intValue:o}})(e,t);if(typeof e=="number"){if(!Number.isFinite(e))return{stringValue:String(e)};if(Number.isInteger(e)){if(Number.isSafeInteger(e))return{intValue:String(e)};if(typeof BigInt>"u")return{stringValue:String(e)};const r=BigInt(e).toString();return e>=9223372036854776e3||-9223372036854776e3>e?(t?.debug(`Attribute ${r} is outside the int64 range; encoding it as a string`),{stringValue:r}):{intValue:r}}return{doubleValue:e}}if(typeof e=="string")return{stringValue:Tt(e)};if(typeof e=="function")return{stringValue:"[Function]"};if(typeof e=="symbol")return{stringValue:String(e)};if(typeof e=="object"&&e!==null){if(s.ancestors.has(e))return{stringValue:"[Circular]"};if(i>=20)return{stringValue:ar};if(e instanceof Date){const r=e.getTime(),n=Number.isFinite(r)?e.toISOString():String(e);return{stringValue:typeof n=="string"?Tt(n):String(n)}}s.ancestors.add(e);try{try{const r=e.toJSON;if(typeof r=="function")return Hr(r.call(e),t,s,i+1)}catch{}return O(e)?{arrayValue:{values:Xc(e,t,s,i+1)}}:{kvlistValue:{values:Va(e,t,s,i+1)}}}finally{s.ancestors.delete(e)}}return{stringValue:Tt(String(e))}}function Xc(e,t,s,i){const r=[],n=Math.min(e.length,1e3);let o=0;for(;n>o&&s.remainingNodes>0;o++)try{const a=o in e?e[o]:void 0;if(L(a))continue;r.push(Hr(a,t,s,i))}catch{r.push({stringValue:Es})}return e.length>o&&r.push({stringValue:ar}),r}function Va(e,t,s,i){const r=[];for(const n in e)if(Yc.call(e,n)){if(!n){t?.debug("Dropping an attribute with an empty key");continue}if(r.length>=1e3||0>=s.remainingNodes){t?.debug("Attributes truncated: the value exceeds the OTLP encoder budget");break}try{const o=e[n];if(se(o)||x(o))continue;r.push({key:Tt(n),value:Hr(o,t,s,i)})}catch{r.push({key:Tt(n),value:{stringValue:Es}})}}return r}function Ua(e,t,s){return f(f(f(f({},Aa({},e.resourceAttributes)),{},{"service.name":e.serviceName||"unknown_service"},e.environment&&{"deployment.environment":e.environment}),e.serviceVersion&&{"service.version":e.serviceVersion}),{},{"telemetry.sdk.name":t,"telemetry.sdk.version":s})}const Qc=["service.name","deployment.environment","service.version","telemetry.sdk.name","telemetry.sdk.version"];function Wa(e,t){const s=Aa({},e),i={};for(const r of Qc)({}).hasOwnProperty.call(s,r)&&(i[r]=s[r],delete s[r]);return[...Qs(s,t),...Qs(i,t)]}const On={darwin:"macOS",win32:"Windows",cygwin:"Windows",linux:"Linux",android:"Android",freebsd:"FreeBSD",openbsd:"OpenBSD",netbsd:"NetBSD",sunos:"SunOS",aix:"AIX",haiku:"Haiku","Mac OS X":"macOS"},Ga={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}},Zc=Ga.info;function ed(e){try{return Tt(String(e))}catch{return Es}}function td(e,t,s,i){const r=e.level||"info",{text:n,number:o}=Ga[r]||Zc,a=(function(h=Date.now()){return String(h)+"000000"})(oe(i)?i:void 0),l={};t.distinctId&&(l.posthogDistinctId=t.distinctId),t.sessionId&&(l.sessionId=t.sessionId),t.windowId&&(l["window.id"]=t.windowId),L(t.sessionStartTimestamp)||(l.sessionStartTimestamp=String(t.sessionStartTimestamp)),L(t.lastActivityTimestamp)||(l.lastActivityTimestamp=String(t.lastActivityTimestamp)),t.currentUrl&&(l["url.full"]=t.currentUrl),t.screenName&&(l["screen.name"]=t.screenName),t.appState&&(l["app.state"]=t.appState),t.activeFeatureFlags&&t.activeFeatureFlags.length>0&&(l.feature_flags=t.activeFeatureFlags);const u=f({},l),c=e.attributes;if(c){let h=[];try{h=Object.keys(c)}catch{h=[]}for(const p of h){let v;try{v=c[p]}catch{v=Es}Object.defineProperty(u,p,{value:v,enumerable:!0,writable:!0,configurable:!0})}}const d={timeUnixNano:a,observedTimeUnixNano:a,severityNumber:o,severityText:n,body:{stringValue:ed(e.body)},attributes:Qs(u,s)};return e.trace_id&&(d.traceId=e.trace_id),e.span_id&&(d.spanId=e.span_id),x(e.trace_flags)||(d.flags=e.trace_flags),d}function Ja(e,t,s){return Ua(e,t,s)}function Ka(e,t,s,i){return{resourceLogs:[{resource:{attributes:Wa(t)},scopeLogs:[{scope:{name:s,version:i},logRecords:e}]}]}}var Ya=class{constructor(e){this.ls=e,this.us=0}get pending(){return!!this.cs}arm(e){this.clear(),this.us=Date.now()+e,this.cs=Ia(()=>{this.cs=void 0,this.ls()},e)}armNoEarlierThan(e){this.cs&&Date.now()+e<=this.us||this.arm(e)}clear(){this.cs&&(clearTimeout(this.cs),this.cs=void 0)}};function Xa(){return .75+.5*Math.random()}function Qa(e,t,s,i){const r=Math.min(Math.max(0,t-1),6),n=e*Math.pow(2,r);return Math.round(Math.min(n,Math.max(i,e))*s)}var sd=class{constructor(e,t,s,i,r,n=()=>Promise.resolve(),o){var a;this._instance=e,this.Ar=t,this.$=s,this.hs=i,this.ds=r,this.vs=n,this.fs=o,this.ps=new Ya(()=>this.gs()),this.ys=null,this.bs=0,this._s=0,this.ws=new Ca,this.ks=0,this.Ss=1,this.xs=0,this.$s=0,this.Cs=!1,this.Ts=t.maxBufferSize,this.Is=Math.max((a=t.maxQueueSize)!==null&&a!==void 0?a:t.maxBufferSize,t.maxBufferSize),this.Ms=t.flushIntervalMs,this.Es=t.maxBatchRecordsPerPost,this.Ps=t.rateCapWindowMs,this.Rs=t.maxLogsPerInterval}clearQueue(){this._s++,this._instance.setPersistedProperty(je.LogsQueue,[])}reset(){this.ps.clear(),this.xs=0,this.$s=0,this.Cs=!1,this.ks=0,this.Ss=1,this.ws.reset(),this.Es=this.Ar.maxBatchRecordsPerPost}onReconnect(){this.ks=0,this.Ss=1,this.ws.isOpen()?this.As()&&this.Fs():this.gs()}captureLog(e,t){var s;if(this._instance.isDisabled||this._instance.optedOut||!e?.body)return;const i=this.Os(e);if(i===null)return;if(!i.body)return void this.$.info("Log was rejected in beforeSend function");if(!this.Ds())return;const r={record:td(i,(s=t?.context)!==null&&s!==void 0?s:this.hs(),this.$,t?.occurredAtMs)};this.ds(()=>this.Ls(r))}Os(e){const t=this.Ar.beforeSend;if(!t)return e;const s=O(t)?t:[t];let i=e;for(const r of s)try{const n=r(i);if(!n)return this.$.info("Log was rejected in beforeSend function"),null;i=n}catch(n){return this.$.error("Error in beforeSend function for log:",n),null}return i}Ds(){if(this.Rs===void 0)return!0;const e=Date.now(),t=e-this.xs;return this.Ps>t&&t>=0||(this.xs=e,this.$s=0,this.Cs=!1),this.Rs>this.$s?(this.$s++,!0):(this.Cs||(this.$.warn(`captureLog dropping logs: exceeded ${this.Rs} logs per ${this.Ps}ms`),this.Cs=!0),!1)}flush(){var e=this;return Q(function*(){if(!e._instance.isDisabled)return e.ys||(e.ys=e.Ns().finally(()=>{e.ys=null})),e.ys})()}Ns(){var e=this;return Q(function*(){var t;e.ps.clear();let s=(t=e._instance.getPersistedProperty(je.LogsQueue))!==null&&t!==void 0?t:[];if(s.length===0)return;const i=s.length;let r=0;for(;s.length>0&&i>r;){var n,o;const a=e._s;e.bs=0;const l=Math.min(s.length,e.Es),u=s.slice(0,l),c=Ka(u.map(h=>h.record),e.qs(),(n=e.fs)!==null&&n!==void 0?n:e._instance.getLibraryId(),e._instance.getLibraryVersion()),d=yield e._instance.js(c);if(e._s!==a)return;if(d.kind==="too-large"&&u.length>1)e.Es=Math.max(1,Math.floor(u.length/2)),e.$.warn(`Logs batch of size ${u.length} was too large for the ingestion endpoint, reducing batch size to ${e.Es}`);else if(e.ws.record(d),e.ps.pending&&e.ps.arm(Math.max(e.Ms,e.ws.remainingMs())),d.kind==="retry-later"||(d.kind==="too-large"?e.$.warn("Dropping a single log record with batch size 1 — the record is larger than the server cap and cannot be split further."):d.kind==="ok"&&e.Ar.maxBatchRecordsPerPost>e.Es&&(e.Es=Math.min(e.Ar.maxBatchRecordsPerPost,e.Es+1)),yield e.Bs(u.length),s=(o=e._instance.getPersistedProperty(je.LogsQueue))!==null&&o!==void 0?o:[],r+=u.length,d.kind==="fatal"))throw d.error}})()}Bs(e){var t=this;return Q(function*(){var s;const i=Math.max(0,e-t.bs),r=(s=t._instance.getPersistedProperty(je.LogsQueue))!==null&&s!==void 0?s:[];t._instance.setPersistedProperty(je.LogsQueue,r.slice(i)),yield t.vs()})()}qs(){return Ja(this.Ar,this._instance.getLibraryId(),this._instance.getLibraryVersion())}Ls(e){var t;if(this._instance.optedOut)return;const s=(t=this._instance.getPersistedProperty(je.LogsQueue))!==null&&t!==void 0?t:[];this.Is>s.length||(s.shift(),this.bs++,this.$.info("Logs queue is full, dropping oldest record.")),s.push(e),this._instance.setPersistedProperty(je.LogsQueue,s),this.Ts>s.length||this.ws.isOpen()?this.Fs():this.gs()}Fs(){this.ps.pending||this.ps.arm(Math.max(this.Ms,this.ws.remainingMs()))}zs(){return Math.max(Qa(this.Ms,this.ks,this.Ss,3e4),this.ws.remainingMs())}As(){const e=this._instance.getPersistedProperty(je.LogsQueue);return!!e&&e.length>0}shutdown(e){var t=this;return Q(function*(){t.ps.clear();const s=t.flush().catch(()=>{});e!==void 0?yield mn(s,e):yield s})()}flushWithTimeout(e){var t=this;return Q(function*(){const s=t.flush();yield mn(s,e,()=>{s.catch(()=>{})})})()}gs(){this.flush().then(()=>{this.ks=0,this.Ss=1},e=>{this.ks++,this.Ss=Xa(),this.$.error("PostHog logs flush failed:",e)}).finally(()=>{!this._instance.isDisabled&&this.As()&&this.ps.armNoEarlierThan(this.zs())})}};const id=/^[0-9a-f]+$/;function Mn(e,t,s){return typeof e=="string"&&e.length===t&&e!==s&&id.test(e)}const rd=/^([0-9a-f]{2})-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})(-.*)?$/,nd="00",Si=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function hr(e){return String(e)+"000000"}function Tn(e,t,s,i){let r="";return i&&(r=Object.keys(i).sort().map(n=>`${JSON.stringify(n)}:${JSON.stringify(i[n])}`).join(",")),`${e}\0${t}\0${s??""}\0${r}`}var od=class{constructor(e,t,s){this._instance=e,this.Ar=t,this.$=s,this.Hs=new Map,this.ps=new Ya(()=>this.flush().catch(i=>{this.$.error("Metrics flush failed:",i)})),this.ys=null,this.Us=!1,this.Ws=new Map,this.Vs=new Set,this.ws=new Ca,this.ks=0,this.Ss=1,this.Gs=0}count(e,t=1,s){this.Qs({name:e,type:"count",value:t,unit:s?.unit,attributes:s?.attributes})}gauge(e,t,s){this.Qs({name:e,type:"gauge",value:t,unit:s?.unit,attributes:s?.attributes})}histogram(e,t,s){this.Qs({name:e,type:"histogram",value:t,unit:s?.unit,attributes:s?.attributes})}flush(){var e=this;const t=this.ys,s=(function(){var i=Q(function*(){t&&(yield t.catch(()=>{})),yield e.Zs()});return function(){return i.apply(this,arguments)}})()().finally(()=>{this.ys===s&&(this.ys=null)});return this.ys=s,s}drainWindow(){if(this.Hs.size===0)return null;const e=this.Hs;return this.Hs=new Map,this.Us=!1,this.Ws=new Map,this.Vs=new Set,this.Js(e)}reset(){this.Gs++,this.ws.reset(),this.ks=0,this.Ss=1,this.ps.clear(),this.Hs=new Map,this.ys=null,this.Us=!1,this.Ws=new Map,this.Vs=new Set}Qs(e){if(this._instance.isDisabled||this._instance.optedOut)return;const t=this.Os(e);if(t===null)return;if(!t.name||typeof t.name!="string")return void this.$.warn("Dropping metric with empty name");if(typeof t.value!="number"||!Number.isFinite(t.value))return void this.$.warn(`Dropping metric '${t.name}': value must be a finite number`);if(t.type==="count"&&0>t.value)return void this.$.warn(`Dropping count '${t.name}': counters are monotonic, value must be >= 0`);let s,i;try{s=t.attributes?f({},t.attributes):void 0,i=Tn(t.type,t.name,t.unit,s)}catch(a){return void this.$.warn(`Dropping metric '${t.name}': attributes could not be serialized`,a)}let r=this.Hs.get(i);if(!r){if(!this.Ks())return;r={name:t.name,type:t.type,unit:t.unit,attributes:s,windowStartMs:Date.now()},this.Hs.set(i,r)}const n=this.Ws.get(t.name);n===void 0?this.Ws.set(t.name,t.type):n===t.type||this.Vs.has(t.name)||(this.Vs.add(t.name),this.$.warn(`Metric name '${t.name}' is already used as a ${n}; recording it as a ${t.type} too will blend both series in charts. Use a distinct name.`)),this.Xs(r,t.value);const o=this.Ys();o&&(r.exemplar=f(f({},o),{},{value:t.value,timeMs:Date.now()})),this.Fs()}Ys(){try{var e,t;const s=(function(i){const r=(function(o){if(typeof o!="string")return;const a=rd.exec(o.trim());if(!a)return;const[,l,u,c,d,h]=a;return l==="ff"||l==="00"&&h||!(function(p){return Mn(p,32,"00000000000000000000000000000000")})(u)||!(function(p){return Mn(p,16,"0000000000000000")})(c)?void 0:{version:l,traceId:u,spanId:c,flags:d}})(i);return r&&{traceId:r.traceId,spanId:r.spanId,flags:(n=r.flags,1&parseInt(n,16)?"01":nd)};var n})((e=(t=this._instance).getActiveSpan)===null||e===void 0||(e=e.call(t))===null||e===void 0?void 0:e.traceparent());if(s&&s.flags==="01")return{traceId:s.traceId,spanId:s.spanId}}catch{}}Ks(){return this.Ar.maxSeriesPerFlush>this.Hs.size||(this.Us||(this.Us=!0,this.$.warn(`Metric series cap reached (${this.Ar.maxSeriesPerFlush} per flush window); dropping new series until the next flush. Reduce attribute cardinality.`)),!1)}Xs(e,t){switch(e.type){case"count":var s;e.total=((s=e.total)!==null&&s!==void 0?s:0)+t;break;case"gauge":e.last=t;break;case"histogram":{e.hist||(e.hist={count:0,sum:0,min:t,max:t,bucketCounts:new Array(Si.length+1).fill(0)});const i=e.hist;i.count+=1,i.sum+=t,i.min=Math.min(i.min,t),i.max=Math.max(i.max,t),i.bucketCounts[(function(r,n){for(let o=0;n.length>o;o++)if(n[o]>=r)return o;return n.length})(t,Si)]+=1;break}}}Os(e){const t=this.Ar.beforeSend;if(!t)return e;const s=O(t)?t:[t];let i=e;for(const r of s)try{const n=r(i);if(!n)return this.$.info("Metric was rejected in beforeSend function"),null;i=n}catch(n){return this.$.error("Error in beforeSend function for metric:",n),null}return i}Fs(){this.ps.pending||this.ps.arm(this.zs())}zs(){return Math.max(Qa(this.Ar.flushIntervalMs,this.ks,this.Ss,3e4),this.ws.remainingMs())}Zs(){var e=this;return Q(function*(){if(e.ps.clear(),e.Hs.size===0)return;const t=e.Hs;e.Hs=new Map,e.Us=!1,e.Ws=new Map,e.Vs=new Set;const s=e.Gs,i=yield e._instance.po(e.Js(t));if(s===e.Gs)switch(e.ws.record(i),i.kind==="retry-later"?(e.ks++,e.Ss=Xa()):(e.ks=0,e.Ss=1),e.ps.pending&&e.ps.arm(e.zs()),i.kind){case"ok":return;case"retry-later":return e.mo(t),void e.ps.armNoEarlierThan(e.zs());case"too-large":return void e.$.warn("Metrics batch exceeded the server size limit and was dropped");case"fatal":return void e.$.error("Failed to send metrics batch:",i.error)}})()}Js(e){return t=this.yo(e),s=(function(n,o,a){return Ua(n,o,a)})(this.Ar,this._instance.getLibraryId(),this._instance.getLibraryVersion()),i=this._instance.getLibraryId(),r=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:Wa(s)},scopeMetrics:[{scope:{name:i,version:r},metrics:t}]}]};var t,s,i,r}yo(e){const t=hr(Date.now()),s=new Map;for(const o of e.values()){var i;const a=Tn(o.type,o.name,o.unit,void 0);let l=s.get(a);l||(l=f({name:o.name},o.unit&&{unit:o.unit}),o.type==="count"?l.sum={aggregationTemporality:1,isMonotonic:!0,dataPoints:[]}:o.type==="gauge"?l.gauge={dataPoints:[]}:l.histogram={aggregationTemporality:1,dataPoints:[]},s.set(a,l));const u=Qs((i=o.attributes)!==null&&i!==void 0?i:{},this.$),c=hr(o.windowStartMs),d=ad(o.exemplar);if(o.type==="count"){var r;const h=f({attributes:u,startTimeUnixNano:c,timeUnixNano:t,asDouble:(r=o.total)!==null&&r!==void 0?r:0},d);l.sum.dataPoints.push(h)}else if(o.type==="gauge"){var n;const h=f({attributes:u,timeUnixNano:t,asDouble:(n=o.last)!==null&&n!==void 0?n:0},d);l.gauge.dataPoints.push(h)}else if(o.hist){const h=f({attributes:u,startTimeUnixNano:c,timeUnixNano:t,count:o.hist.count,sum:o.hist.sum,min:o.hist.min,max:o.hist.max,bucketCounts:o.hist.bucketCounts,explicitBounds:Si},d);l.histogram.dataPoints.push(h)}}return Array.from(s.values())}mo(e){for(const[r,n]of e){var t;const o=this.Hs.get(r);if(o)switch(o.windowStartMs=Math.min(o.windowStartMs,n.windowStartMs),o.exemplar=(t=o.exemplar)!==null&&t!==void 0?t:n.exemplar,o.type){case"count":var s,i;o.total=((s=o.total)!==null&&s!==void 0?s:0)+((i=n.total)!==null&&i!==void 0?i:0);break;case"gauge":break;case"histogram":if(n.hist)if(o.hist){o.hist.count+=n.hist.count,o.hist.sum+=n.hist.sum,o.hist.min=Math.min(o.hist.min,n.hist.min),o.hist.max=Math.max(o.hist.max,n.hist.max);for(let a=0;o.hist.bucketCounts.length>a;a++)o.hist.bucketCounts[a]+=n.hist.bucketCounts[a]}else o.hist=n.hist}else this.Ks()&&this.Hs.set(r,n)}}};function ad(e){return e?{exemplars:[{filteredAttributes:[],timeUnixNano:hr(e.timeMs),asDouble:e.value,traceId:e.traceId,spanId:e.spanId}]}:{}}const Za=(e,{debugEnabled:t}={})=>{const s={N(i,...r){let n;try{n=typeof window>"u"?void 0:window}catch{return}n&&(Je.DEBUG||n.POSTHOG_DEBUG||t)&&!x(n.console)&&n.console&&("__rrweb_original__"in n.console[i]?n.console[i].__rrweb_original__:n.console[i])(e,...r)},debug(...i){s.N("debug",...i)},info(...i){s.N("log",...i)},warn(...i){s.N("warn",...i)},error(...i){s.N("error",...i)},critical(...i){console.error(e,...i)},uninitializedWarning(i){s.error(`You must initialize PostHog before calling ${i}`)},createLogger:(i,r)=>Za(`${e} ${i}`,r)};return s},E=Za("[PostHog.js]"),te=E.createLogger,ld=te("[ExternalScriptsLoader]"),Zs=e=>{const t=C?.querySelectorAll("script");if(t){for(let s=0;t.length>s;s++)if(t[s].src===e||t[s].getAttribute("src")===e)return t[s]}},pt=(e,t,s)=>{if(e.config.disable_external_dependency_loading)return ld.warn(`${t} was requested but loading of external scripts is disabled.`),s("Loading of external scripts is disabled");const i=Zs(t);if(i){if(i.__posthog_loading_callback_fired)return s();const n=i.__posthog_loading_error;return n?s(n):(i.addEventListener("load",o=>{i.__posthog_loading_callback_fired=!0,s(void 0,o)}),void i.addEventListener("error",o=>{i.__posthog_loading_error=o,s(o)}))}const r=()=>{if(!C)return s("document not found");if(Zs(t))return pt(e,t,s);let n=C.createElement("script");if(n.type="text/javascript",n.crossOrigin="anonymous",n.src=t,n.onload=a=>{n.__posthog_loading_callback_fired=!0,s(void 0,a)},n.onerror=a=>{n.__posthog_loading_error=a,s(a)},e.config.prepare_external_dependency_script&&(n=e.config.prepare_external_dependency_script(n)),!n)return s("prepare_external_dependency_script returned null");if(e.config.external_scripts_inject_target==="head")C.head.appendChild(n);else{const a=C.querySelectorAll("body > script");var o;a.length>0?(o=a[0].parentNode)===null||o===void 0||o.insertBefore(n,a[0]):C.body.appendChild(n)}};C?.body?r():C?.addEventListener("DOMContentLoaded",r)},Pi={},Rn=(e,t)=>{let s=`/static/${t}.js?v=${e.version}`;return t==="toolbar"&&(s=`${s}&t=${Math.floor(Date.now()/3e5)*3e5}`),e.requestRouter.endpointFor("assets",s)};M.__PosthogExtensions__=M.__PosthogExtensions__||{},M.__PosthogExtensions__.loadExternalDependency=(e,t,s)=>{if(t==="remote-config"){const r=e.requestRouter.endpointFor("assets",`/array/${e.config.token}/config.js`);return void pt(e,r,s)}const i=e.config.strict_script_versioning;if(i){const r=e.requestRouter.endpointFor("assets",`/static/${e.version}/${t}.js`),n=Pi[r];if(i==="fallback"&&n){if(Zs(n))return void pt(e,n,s);delete Pi[r]}return void pt(e,r,i==="fallback"?(o,a)=>{if(o)if(typeof o=="string")s(o);else{var l;const u=Rn(e,t);Pi[r]=u;const c=Zs(r);c==null||(l=c.parentNode)===null||l===void 0||l.removeChild(c),pt(e,u,s)}else s(void 0,a)}:s)}pt(e,Rn(e,t),s)},M.__PosthogExtensions__.loadSiteApp=(e,t,s)=>{const i=e.requestRouter.endpointFor("api",t);pt(e,i,s)},Je.DEBUG=!1,Je.LIB_VERSION="1.444.0",Je.LIB_NAME="web";var $e=Je;const pr="$early_access_features",Ue="$active_feature_flags",gt="$feature_flag_details",ws="$feature_flag_errors",nt="$feature_flag_evaluated_at",_t="$feature_flag_request_id",us="$minimal_flag_called_events",Te="$enabled_feature_flags",st="$stored_group_properties",it="$stored_person_properties",We="$flag_call_reported",is="$flag_call_reported_session_id",rt="$feature_flag_payloads",Ne="$override_feature_flags",ft="$override_feature_flag_payloads",Rt="visibilitychange",el="$autocapture_disabled_server_side",rs="$surveys",ei="$surveys_loaded_at",Br="PostHog loadExternalDependency extension not found.",fr="$surveys_activated",js="$surveys_activated_session",qs="$surveys_activated_timestamps",ud="$people_distinct_id",Fe="distinct_id",zr="$device_id",Ai="$device_model",ti="__alias",cd="__cmpns",Ln="$fbc",Lt="$fbc_persistence",Dn="$fbp",cs="$fbp_persistence",vr="__timers",gr="$heatmaps_enabled_server_side",_r="$exception_capture_enabled_server_side",tl="$error_tracking_suppression_rules",mr="$error_tracking_capture_extension_exceptions",yr="$web_vitals_enabled_server_side",Vr="$dead_clicks_enabled_server_side",Ur="$product_tours_enabled_server_side",sl="$logs_capture_enabled_server_side",il="$web_vitals_allowed_metrics",ds="$session_recording_remote_config",dd="$session_recording_enabled_server_side",hd="$replay_sample_rate",pd="$replay_override_sampling",fd="$replay_override_linked_flag",vd="$replay_override_url_trigger",gd="$replay_override_event_trigger",Ft="$sesid",rl="$session_is_sampled",_d="$session_past_minimum_duration",md="$session_recording_url_trigger_activated_session",yd="$session_recording_event_trigger_activated_session",bd="$debug_first_full_snapshot_timestamp",wd="$sess_rec_flush_size",nl="$groups",br="ph_product_tours",xd="$product_tours_activated",$d="$product_tours_activated_session",kd="$conversations_widget_session_id",Ed="$conversations_ticket_id",Sd="$conversations_widget_state",Pd="$conversations_user_traits",fe="$user_state",wr="$client_session_props",Ad="$capture_rate_limit",ol="$initial_campaign_params",al="$initial_referrer_info",It="$initial_person_info",Wr="$epp",Ci="$posthog_cookieless",ll="$cookieless_mode",ul="$sdk_debug_extensions_init_method",cl="$sdk_debug_extensions_init_time_ms",Gr="$sdk_debug_recording_script_not_loaded",Jr="$sdk_debug_replay_stale_config",dl="$sdk_debug_replay_event_trigger_status",hl="$sdk_debug_replay_linked_flag_trigger_status",pl="$sdk_debug_replay_matched_recording_trigger_groups",fl="$sdk_debug_replay_pending_trigger_conditions",vl="$sdk_debug_replay_remote_trigger_matching_config",gl="$sdk_debug_replay_trigger_groups_count",_l="$sdk_debug_replay_url_trigger_status",Cd="$session_recording_start_reason",Ge="anonymous",Hs="identified",ml="identified_only",si="beforeunload",Kr="$pageview",Nn="$pageleave",yl="$identify",jn="$groupidentify";function Ot(e,t){O(e)&&e.forEach(t)}function J(e,t){if(!L(e))if(O(e))e.forEach(t);else if((s=>s instanceof FormData)(e))e.forEach((s,i)=>t(s,i));else for(const s in e)Lr.call(e,s)&&t(e[s],s)}const ee=function(e,...t){for(const s of t)for(const i in s)s[i]!==void 0&&(e[i]=s[i]);return e};function Bs(e){const t=Object.keys(e);let s=t.length;const i=new Array(s);for(;s--;)i[s]=[t[s],e[t[s]]];return i}const Fd=function(e){return function(...t){try{return e.apply(this,t)}catch(s){E.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),E.critical(s)}}},Yr=function(e){const t={};return J(e,function(s,i){(N(s)&&s.length>0||oe(s))&&(t[i]=s)}),t};function bl(e){const t=f({},e);for(const s of["name","message","stack","cause","errors"])try{s in e&&(t[s]=e[s])}catch{}return t}const Id=["herokuapp.com","vercel.app","netlify.app"];function Od(e){const t=e?.hostname;if(!N(t))return!1;const s=t.split(".").slice(-2).join(".");for(const i of Id)if(s===i)return!1;return!0}function U(e,t,s,i){const{capture:r=!1,passive:n=!0}=i??{};e?.addEventListener(t,s,{capture:r,passive:n})}function xr(e){return e.name==="ph_toolbar_internal"}const hs=e=>{if(C){try{const t=e+"=",s=C.cookie.split(";").filter(i=>i.length);for(let i=0;s.length>i;i++){let r=s[i];for(;r.charAt(0)==" ";)r=r.substring(1,r.length);if(r.indexOf(t)===0)return decodeURIComponent(r.substring(t.length,r.length))}}catch{}return null}};var Md=class $r{constructor(t){if(this.bytes=t,t.length!==16)throw new TypeError("not 128-bit length")}static fromFieldsV7(t,s,i,r){if(!Number.isInteger(t)||!Number.isInteger(s)||!Number.isInteger(i)||!Number.isInteger(r)||0>t||0>s||0>i||0>r||t>0xffffffffffff||s>4095||i>1073741823||r>4294967295)throw new RangeError("invalid field value");const n=new Uint8Array(16);return n[0]=t/Math.pow(2,40),n[1]=t/Math.pow(2,32),n[2]=t/Math.pow(2,24),n[3]=t/Math.pow(2,16),n[4]=t/256,n[5]=t,n[6]=112|s>>>8,n[7]=s,n[8]=128|i>>>24,n[9]=i>>>16,n[10]=i>>>8,n[11]=i,n[12]=r>>>24,n[13]=r>>>16,n[14]=r>>>8,n[15]=r,new $r(n)}toString(){let t="";for(let s=0;this.bytes.length>s;s++)t=t+(this.bytes[s]>>>4).toString(16)+(15&this.bytes[s]).toString(16),s!==3&&s!==5&&s!==7&&s!==9||(t+="-");if(t.length!==36)throw new Error("Invalid UUIDv7 was generated");return t}clone(){return new $r(this.bytes.slice(0))}equals(t){return this.compareTo(t)===0}compareTo(t){for(let s=0;16>s;s++){const i=this.bytes[s]-t.bytes[s];if(i!==0)return Math.sign(i)}return 0}},Td=class{generate(){const e=this.generateOrAbort();if(!x(e))return e;{this.Ct=0;const t=this.generateOrAbort();if(x(t))throw new Error("Could not generate UUID after timestamp reset");return t}}generateOrAbort(){const e=(()=>{const t=Date.now();return oe(t)&&isFinite(t)?Math.min(Math.max(Math.floor(t),0),0xffffffffffff):0})();if(e>this.Ct)this.Ct=e,this.It();else{if(this.Ct>=e+1e4)return;this.Mt++,this.Mt>4398046511103&&(this.Ct++,this.It())}return Md.fromFieldsV7(this.Ct,Math.trunc(this.Mt/Math.pow(2,30)),this.Mt&Math.pow(2,30)-1,this.Tt.nextUint32())}It(){this.Mt=1024*this.Tt.nextUint32()+(1023&this.Tt.nextUint32())}constructor(){this.Ct=0,this.Mt=0,this.Tt=new Rd}};const qn=e=>{if("u">typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(let t=0;e.length>t;t++)e[t]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return e};let Hn;var Rd=class{nextUint32(){var e;return this.Rt.length>this.$t||(((e=Hn)!==null&&e!==void 0?e:Hn="u">typeof window&&!x(window.crypto)&&crypto.getRandomValues?t=>{try{return crypto.getRandomValues(t)}catch{return qn(t)}}:qn)(this.Rt),this.$t=0),this.Rt[this.$t++]}constructor(){this.Rt=new Uint32Array(8),this.$t=1/0}};let Bn;const Re=()=>Ld().toString(),Ld=()=>(Bn||(Bn=new Td)).generate();let Kt="";const Dd=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;let xt=null;const Z={Et(){if(!se(xt))return xt;if(xt=!1,C)try{const e=`__ph_cookie_support_${Re()}`;Z.At(e,"xyz"),xt=hs(e)==='"xyz"',Z.Pt(e)}catch{xt=!1}return xt},Ft(e){E.error("cookieStore error: "+e)},Ot:hs,Lt(e){let t;try{t=JSON.parse(Z.Ot(e))||{}}catch{}return t},At(e,t,s,i,r){if(!C)return!1;try{let n="",o="";const a=(function(u,c){if(c){let d=(function(h,p=C){if(Kt)return Kt;if(!p||["localhost","127.0.0.1"].includes(h))return"";const v=h.split(".");let m=Math.min(v.length,8);const g="dmn_chk_"+Re();for(;!Kt&&m--;){const y=v.slice(m).join("."),_=g+"=1;domain=."+y+";path=/";p.cookie=_+";max-age=3",p.cookie.includes(g)&&(p.cookie=_+";max-age=0",Kt=y)}return Kt})(u);if(!d){const h=(p=>{const v=p.match(Dd);return v?v[0]:""})(u);h!==d&&E.info("Warning: cookie subdomain discovery mismatch",h,d),d=h}return d?"; domain=."+d:""}return""})(C.location.hostname,i);if(s){const u=new Date;u.setTime(u.getTime()+864e5*s),n="; expires="+u.toUTCString()}r&&(o="; secure");const l=e+"="+encodeURIComponent(JSON.stringify(t))+n+"; SameSite=Lax; path=/"+a+o;return l.length>3686.4&&E.warn("cookieStore warning: large cookie, len="+l.length),C.cookie=l,!0}catch{return!1}},Pt(e,t){if(C?.cookie&&(!t||!se(hs(e))))try{Z.At(e,"",-1,t)}catch{return}}};let Fi=null;const z={Et(){if(!se(Fi))return Fi;let e=!0;if(x(w))e=!1;else try{const t="__mplssupport__";z.At(t,"xyz"),z.Ot(t)!=='"xyz"'&&(e=!1),z.Pt(t)}catch{e=!1}return e||E.error("localStorage unsupported; falling back to cookie store"),Fi=e,e},Ft(e){E.error("localStorage error: "+e)},Ot(e){try{return w?.localStorage.getItem(e)}catch(t){z.Ft(t)}return null},Lt(e){try{return JSON.parse(z.Ot(e))||{}}catch{}return null},At(e,t){try{return w?.localStorage.setItem(e,JSON.stringify(t)),!0}catch(s){z.Ft(s)}return!1},Pt(e){try{w?.localStorage.removeItem(e)}catch(t){z.Ft(t)}}},Ii=[it,Ue,Te,gt,rt,_t,nt,ws,We],vt=[zr,Fe,Ft,rl,Wr,It,Lt,fe],ps=e=>e+"_cpm",Nd=["__proto__","constructor","prototype"],Oi=e=>{if(!D(e))return{};const t={};return Object.keys(e).forEach(s=>{Nd.indexOf(s)===-1&&(t[s]=e[s])}),t},Mi=(e,t=[])=>{const s={};return[...vt,...t].forEach(i=>{const r=e[i];x(r)||se(r)||r===""||(s[i]=r)}),s},wl=e=>{let t=5381,s=2166136261;for(let i=0;e.length>i;i++){const r=e.charCodeAt(i);t=33*t^r,s=Math.imul(s^r,16777619)}return e.length.toString(36)+"."+(t>>>0).toString(36)+"."+(s>>>0).toString(36)},zn=(e,t)=>({p:t,f:wl(JSON.stringify(e))}),Vn=(e,t)=>{if(!t)return{properties:[],isValid:!1};try{const s=Z.Lt(ps(e)),i=s?.f===wl(t)&&O(s.p);return{properties:i?s.p:[],isValid:i}}catch{return{properties:[],isValid:!1}}},Ti=(e,t)=>t+"|"+(Z.Ot(ps(e))||""),$t={},kr={Et:()=>!0,Ft(e){E.error("memoryStorage error: "+e)},Ot:e=>e in $t?$t[e]:null,Lt:e=>e in $t?$t[e]:null,At:(e,t)=>($t[e]=t,!0),Pt(e){delete $t[e]}};let ut=null;const X={Et(){if(!se(ut))return ut;if(ut=!0,x(w))ut=!1;else try{const e="__support__";X.At(e,"xyz"),X.Ot(e)!=='"xyz"'&&(ut=!1),X.Pt(e)}catch{ut=!1}return ut},Ft(e){E.error("sessionStorage error: ",e)},Ot(e){try{return w?.sessionStorage.getItem(e)}catch(t){X.Ft(t)}return null},Lt(e){try{return JSON.parse(X.Ot(e))||null}catch{}return null},At(e,t){try{return w?.sessionStorage.setItem(e,JSON.stringify(t)),!0}catch(s){X.Ft(s)}return!1},Pt(e){try{w?.sessionStorage.removeItem(e)}catch(t){X.Ft(t)}}};var jd=class{constructor(e){this._instance=e}get Ar(){return this._instance.config}get consent(){return this.Sl()?0:this.xl}isOptedOut(){return this.Ar.cookieless_mode==="always"||this.isRejected()||this.consent===-1&&this.Ar.cookieless_mode==="on_reject"}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===0}isRejected(){return this.consent===0||this.consent===-1&&this.Ar.opt_out_capturing_by_default}optInOut(e){this.$l.At(this.Cl,e?1:0,this.Ar.cookie_expiration,this.Ar.cross_subdomain_cookie,this.Ar.secure_cookie)}reset(){this.$l.Pt(this.Cl,this.Ar.cross_subdomain_cookie)}get Cl(){const{token:e,opt_out_capturing_cookie_prefix:t,consent_persistence_name:s}=this._instance.config;return s||(t?t+e:"__ph_opt_in_out_"+e)}get xl(){const e=this.$l.Ot(this.Cl);return _i(e)?1:I(Ru,e)?0:-1}get $l(){const e=this.Ar.opt_out_capturing_persistence_type,t=e==="localStorage"?z:Z,s=t.Et()?t:kr;if(!this.Tl||this.Tl!==s){this.Tl=s;const i=e==="localStorage"?Z:z;i.Ot(this.Cl)&&(this.Tl.Ot(this.Cl)||this.optInOut(_i(i.Ot(this.Cl))),i.Pt(this.Cl,this.Ar.cross_subdomain_cookie))}return this.Tl}Sl(){return!!this.Ar.respect_dnt&&[pe?.doNotTrack,pe?.msDoNotTrack,M.doNotTrack,pe?.globalPrivacyControl].some(e=>_i(e))}};function xl(e,t){var s;const i=e==null||(s=e.config)===null||s===void 0?void 0:s.get_current_url;if(!ne(i))return t;try{const r=i(t);return N(r)&&r?r:t}catch(r){return E.error("Error in get_current_url, falling back to window.location.href",r),t}}function Un(e){var t;return e instanceof Element&&(e.id==="__POSTHOG_TOOLBAR__"||!!(!((t=e.closest)===null||t===void 0)&&t.call(e,".toolbar-global-fade-container")))}function Ie(e){return!!e&&e.nodeType===1}function le(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function $l(e){return!!e&&e.nodeType===3}function ii(e){return!!e&&e.nodeType===11&&Ie(e.host)}function Xr(e){return e?Nt(e).split(/\s+/):[]}function Wn(e,t){const s=(function(i){var r;const n=typeof window>"u"?void 0:window,o=n==null||(r=n.location)===null||r===void 0?void 0:r.href;return x(o)?void 0:xl(i,o)})(t);return!!(s&&e&&e.some(i=>s.match(i)))}function mt(e){let t="";switch(typeof e.className){case"string":t=e.className;break;case"object":t=(e.className&&"baseVal"in e.className?e.className.baseVal:null)||e.getAttribute("class")||"";break;default:t=""}return Xr(t)}function kl(e){return L(e)?null:Nt(e).split(/(\s+)/).filter(t=>Dt(t)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function xs(e){let t="";return ot(e)&&!qt(e)&&e.childNodes&&e.childNodes.length&&J(e.childNodes,function(s){var i;$l(s)&&s.textContent&&(t+=(i=kl(s.textContent))!==null&&i!==void 0?i:"")}),Nt(t)}function fs(e){var t;return x(e.target)?e.srcElement||null:!((t=e.target)===null||t===void 0)&&t.shadowRoot?e.composedPath()[0]||null:e.target||null}const Qr=["a","button","form","input","select","textarea","label"];function ns(e,t){const s=e.matches||e.matchesSelector||e.msMatchesSelector||e.mozMatchesSelector||e.webkitMatchesSelector||e.oMatchesSelector;try{return!!s&&s.call(e,t)}catch{return!1}}function Er(e,t){if(x(t))return!0;for(const s of e)if(t.some(i=>ns(s,i)))return!0;return!1}function El(e){const t=e.parentNode;return!(!t||!Ie(t))&&t}const As=[".ph-no-autocapture","[data-ph-no-autocapture]"],Sl=["next","previous","prev",">","<","→","←","›","‹","»","«","▶","◀","❯","❮"],Zr=[...Sl,"+","-","−","–"],Gn=Zr.length+10,qd=["button","a","input","select","textarea","label"],Hd=["button","link","tab","menuitem","option"],Jn=(e,t)=>/[a-z0-9]/i.test(t)?I(Zr,t)?new RegExp(`\\b${t}\\b`).test(e):e.includes(t):e===t,Bd=e=>I(qd,e.tagName.toLowerCase())||I(Hd,(e.getAttribute("role")||"").toLowerCase());function Ri(e){let t="",s="";const i=o=>{Ie(o)&&ot(o)&&!qt(o)&&(t+=` ${xs(o)}`,s=s||o.getAttribute("aria-label")||"",J(o.childNodes,i))};i(e),t=Nt(t.replace(/\s+/g," "));const r=(Dt(t)?t:"").toLowerCase(),n=e.getAttribute("aria-label")||(r?"":s);return{safeText:r,ariaLabel:Nt(n).toLowerCase()}}const Kn=[".ph-no-rageclick",".ph-no-capture"],zd=["","text","search","email","password","url","tel","number"];function Pl(e,t){if(!(!(typeof window>"u")&&window)||en(e))return!1;let s,i,r;var n,o;if(we(t)?(s=!!t&&Kn,i=void 0,r=!1):(s=(n=t?.css_selector_ignorelist)!==null&&n!==void 0?n:Kn,i=t?.content_ignorelist,r=(o=t?.ignore_text_selection)!==null&&o!==void 0&&o),s===!1||r&&(function(l){return!(!l||!Ie(l))&&(!!le(l,"textarea")||(le(l,"input")?I(zd,(l.getAttribute("type")||"").toLowerCase()):(function(u){var c;if(u.isContentEditable)return!0;const d=(c=u.getAttribute)===null||c===void 0?void 0:c.call(u,"contenteditable");return d==="true"||d===""})(l)))})(e))return!1;const{targetElementList:a}=Al(e,!1);return!(i&&(function(l,{safeText:u,ariaLabel:c}){let d;if(l===!0)d=Sl;else{if(!O(l))return!1;if(l.length>Gn)return E.error(`[PostHog] content_ignorelist array cannot exceed ${Gn} items. Use css_selector_ignorelist for more complex matching.`),!1;d=l.map(h=>h.toLowerCase())}return d.some(h=>Jn(u,h)||Jn(c,h))})(i,(function(l,u){for(const d of u)if(Bd(d))return Ri(d);for(const d of u){try{var c;if(((c=window)===null||c===void 0?void 0:c.getComputedStyle(d).getPropertyValue("cursor"))!=="pointer")break}catch{break}const h=Ri(d);if(h.safeText||h.ariaLabel)return h}return Ri(l)})(e,a))||Er(a,s))}const en=e=>!e||le(e,"html")||!Ie(e),Al=(e,t)=>{const s=typeof window>"u"?void 0:window;if(!s||en(e))return{parentIsUsefulElement:!1,targetElementList:[]};let i=!1;const r=[e];let n=e;for(;n.parentNode&&!le(n,"body");){if(ii(n.parentNode)){r.push(n.parentNode.host),n=n.parentNode.host;continue}const o=El(n);if(!o)break;if(t||Qr.indexOf(o.tagName.toLowerCase())>-1)i=!0;else try{const a=s.getComputedStyle(o);a&&a.getPropertyValue("cursor")==="pointer"&&(i=!0)}catch{}r.push(o),n=o}return{parentIsUsefulElement:i,targetElementList:r}};function ot(e){const t=new Set;let s=0;for(let n=e;n.parentNode&&!le(n,"body");n=n.parentNode){if(s++>=1e3||t.has(n))return!1;t.add(n);const o=mt(n);if(I(o,"ph-sensitive")||I(o,"ph-no-capture"))return!1}if(I(mt(e),"ph-include"))return!0;const i=e.type||"";if(N(i))switch(i.toLowerCase()){case"hidden":case"password":return!1}const r=e.name||e.id||"";return!N(r)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(r.replace(/[^a-zA-Z0-9]/g,""))}function qt(e){return!!(le(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||le(e,"select")||le(e,"textarea")||e.getAttribute("contenteditable")==="true")}const Yn=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}))$"),Xn=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,Vd=[16,15,14,13],Ud=new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),Qn=new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),Zn=/[0-9A-Za-z_]/;function Wd(e){let t=0,s=!1;for(let i=e.length-1;i>=0;i--){let r=e.charCodeAt(i)-48;s&&(r*=2,r>9&&(r-=9)),t+=r,s=!s}return t%10==0}function Dt(e,t=!0){return!(L(e)||N(e)&&(e=Nt(e),(t?Yn.test((e||"").replace(/[- ]/g,"")):(function(s){let i;for(Xn.lastIndex=0;i=Xn.exec(s);){const r=i[2];if(!r)continue;const n=r.replace(/[- ]/g,"");for(let o=0;n.length>o;o++)for(const a of Vd){const l=o+a;if(n.length>=l){const u=n.slice(o,l);if(Yn.test(u)&&Wd(u))return!0}}}return!1})(e))||(t?Ud.test(e):(function(s){let i;for(Qn.lastIndex=0;i=Qn.exec(s);){const r=i[1],n=i[3];if(!(r&&n&&Zn.test(r)&&Zn.test(n)))return!0}return!1})(e))))}function eo(e){let t=xs(e);return t=`${t} ${Cl(e)}`.trim(),Dt(t)?t:""}function Cl(e){let t="";return e&&e.childNodes&&e.childNodes.length&&J(e.childNodes,function(s){var i;if(s&&((i=s.tagName)===null||i===void 0?void 0:i.toLowerCase())==="span")try{const r=xs(s);t=`${t} ${r}`.trim(),s.childNodes&&s.childNodes.length&&(t=`${t} ${Cl(s)}`.trim())}catch(r){E.error("[AutoCapture]",r)}}),t}function to(e){return e.replace(/"|\\"/g,'\\"')}function Gd(e){const t=e.attr__class;if(t)return O(t)?t:Xr(t)}const Cs=te("[Dead Clicks]"),Jd=()=>!0,Kd=e=>{var t;const s=!!(!((t=e.instance.persistence)===null||t===void 0)&&t.get_property(Vr)),i=e.instance.config.capture_dead_clicks;return we(i)?i:!!D(i)||s};var so=class{get lazyLoadedDeadClicksAutocapture(){return this.Il}constructor(e,t,s){this.instance=e,this.isEnabled=t,this.onCapture=s,this.startIfEnabledOrStop()}onRemoteConfig(e){if(!e.ok)return;const t=e.config;"captureDeadClicks"in t&&(this.instance.persistence&&this.instance.persistence.register({[Vr]:t.captureDeadClicks}),this.startIfEnabledOrStop())}startIfEnabledOrStop(){this.isEnabled(this)?this.Ml(()=>{this.El()}):this.stop()}Ml(e){var t,s,i;!((t=M.__PosthogExtensions__)===null||t===void 0)&&t.initDeadClicksAutocapture?e():(s=M.__PosthogExtensions__)===null||s===void 0||(i=s.loadExternalDependency)===null||i===void 0||i.call(s,this.instance,"dead-clicks-autocapture",r=>{r?Cs.error("failed to load script",r):e()})}El(){var e;if(C){if(!this.Il&&(!((e=M.__PosthogExtensions__)===null||e===void 0)&&e.initDeadClicksAutocapture)){const t=D(this.instance.config.capture_dead_clicks)?f({},this.instance.config.capture_dead_clicks):{};t.__onCapture=this.onCapture,this.onCapture&&(t.capture_dead_swipes=!1),this.Il=M.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this.Il.start(C),Cs.info("starting...")}}else Cs.error("`document` not found. Cannot start.")}stop(){this.Il&&(this.Il.stop(),this.Il=void 0,Cs.info("stopping..."))}};const Yt=te("[SegmentIntegration]");function io(e,t,s=!0){const i=e.config.segment;if(!i)return t();const{analytics:r,filterProperties:n}=(a=>ne(a.register))(o=i)?{analytics:o}:o;var o;(function(a,l,u,c){const d=p=>{const v=()=>p.anonymousId()||Re();a.config.get_device_id=v,c&&p.id()&&(a.register({distinct_id:p.id(),$device_id:v()}),a.persistence.set_property(fe,Hs)),u(c?void 0:p.anonymousId()||void 0)},h=l.user();"then"in h&&ne(h.then)?h.then(d):d(h)})(e,r,a=>{r.register(((l,u,{filterProperties:c}={})=>{typeof Promise<"u"&&Promise.resolve||Yt.warn("This browser does not have Promise support, and can not use the segment integration");const d=(h,p)=>{if(!p)return h;const v=!!u&&h.event.anonymousId===u&&!h.event.userId;v||h.event.userId||h.event.anonymousId===l.get_distinct_id()||(Yt.info("No userId set, resetting PostHog"),l.reset()),v||(u=void 0),h.event.userId&&h.event.userId!==l.get_distinct_id()&&(Yt.info("UserId set, identifying with PostHog"),l.identify(h.event.userId));let m=l.calculateEventProperties(p,h.event.properties);if(!L(c)){const g=h.event.properties||{},y={};for(const b of Object.keys(m))Lr.call(g,b)||(y[b]=m[b]);const _=((b,k)=>{const $=O(b)?b:[b];let S=f({},k);for(const A of $)try{if(S=A(S),L(S))return null}catch(P){return Yt.error("Error in Segment filterProperties:",P),null}return S})(c,y);if(L(_))return h;m=_}return h.event.properties=Object.assign({},m,h.event.properties),h};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded(){return!0},load(){return Promise.resolve()},track(h){return d(h,h.event.event)},page(h){return d(h,Kr)},identify(h){return d(h,yl)},screen(h){return d(h,"$screen")}}})(e,a,{filterProperties:n})).then(()=>{t()},l=>{Yt.error("Failed to register the Segment integration",l),t()})},s)}const Fl="posthog-js";function Il(e,{organization:t,projectId:s,prefix:i,severityAllowList:r=["error"],sendExceptionsToPostHog:n=!0}={}){return o=>{var a,l,u,c,d;if(r!=="*"&&!r.includes(o.level)||!e.__loaded)return o;o.tags||(o.tags={});const h=e.requestRouter.endpointFor("ui",`/project/${e.config.token}/person/${e.get_distinct_id()}`);o.tags["PostHog Person URL"]=h,e.sessionRecordingStarted()&&(o.tags["PostHog Recording URL"]=e.get_session_replay_url({withTimestamp:!0}));const p=((a=o.exception)===null||a===void 0?void 0:a.values)||[],v=p.map(y=>f(f({},y),{},{stacktrace:y.stacktrace?f(f({},y.stacktrace),{},{type:"raw",frames:(y.stacktrace.frames||[]).map(_=>f(f({},_),{},{platform:"web:javascript"}))}):void 0})),m={$exception_message:((l=p[0])===null||l===void 0?void 0:l.value)||o.message,$exception_type:(u=p[0])===null||u===void 0?void 0:u.type,$exception_level:o.level,$exception_list:v,$sentry_event_id:o.event_id,$sentry_exception:o.exception,$sentry_exception_message:((c=p[0])===null||c===void 0?void 0:c.value)||o.message,$sentry_exception_type:(d=p[0])===null||d===void 0?void 0:d.type,$sentry_tags:o.tags};var g;return t&&s&&(m.$sentry_url=(i||"https://sentry.io/organizations/")+t+"/issues/?project="+s+"&query="+o.event_id),n&&((g=e.exceptions)===null||g===void 0||g.sendExceptionEvent(m)),o}}var Yd=class{constructor(e,t,s,i,r,n){this.name=Fl,this.setupOnce=function(o){o(Il(e,{organization:t,projectId:s,prefix:i,severityAllowList:r,sendExceptionsToPostHog:n==null||n}))}}},ro=class{constructor(e){this.Pl=(t,s,i)=>{i&&(i.noSessionId||i.activityTimeout||i.sessionPastMaximumLength||i.crossTabAdoption)&&(E.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:t,changeReason:i}),this.Rl=void 0,this._instance.scrollManager.resetContext())},this._instance=e,this.Al()}Al(){var e;this.Fl=(e=this._instance.sessionManager)===null||e===void 0?void 0:e.onSessionId(this.Pl)}destroy(){var e;(e=this.Fl)===null||e===void 0||e.call(this),this.Fl=void 0}doPageView(e,t){var s;const i=this.Ol(e,t);return this.Rl={pathname:(s=w?.location.pathname)!==null&&s!==void 0?s:"",pageViewId:t,timestamp:e},this._instance.scrollManager.resetContext(),i}doPageLeave(e){var t;return this.Ol(e,(t=this.Rl)===null||t===void 0?void 0:t.pageViewId)}doEvent(){var e;return{$pageview_id:(e=this.Rl)===null||e===void 0?void 0:e.pageViewId}}Ol(e,t){const s=this.Rl;if(!s)return{$pageview_id:t};let i={$pageview_id:t,$prev_pageview_id:s.pageViewId};const r=this._instance.scrollManager.getContext();if(r&&!this._instance.config.disable_scroll_properties){let{maxScrollHeight:n,lastScrollY:o,maxScrollY:a,maxContentHeight:l,lastContentY:u,maxContentY:c}=r;if(!(x(n)||x(o)||x(a)||x(l)||x(u)||x(c))){n=Math.ceil(n),o=Math.ceil(o),a=Math.ceil(a),l=Math.ceil(l),u=Math.ceil(u),c=Math.ceil(c);const d=n>1?qe(o/n,0,1,E):1,h=n>1?qe(a/n,0,1,E):1,p=l>1?qe(u/l,0,1,E):1,v=l>1?qe(c/l,0,1,E):1;i=ee(i,{$prev_pageview_last_scroll:o,$prev_pageview_last_scroll_percentage:d,$prev_pageview_max_scroll:a,$prev_pageview_max_scroll_percentage:h,$prev_pageview_last_content:u,$prev_pageview_last_content_percentage:p,$prev_pageview_max_content:c,$prev_pageview_max_content_percentage:v})}}return s.pathname&&(i.$prev_pageview_pathname=s.pathname),s.timestamp&&(i.$prev_pageview_duration=(e.getTime()-s.timestamp.getTime())/1e3),i}};const Xt=["flags","surveys"],Xd={[ud]:{exposure:"hidden"},[ti]:{exposure:"hidden"},[cd]:{exposure:"hidden"},[vr]:{exposure:"hidden"},[Lt]:{exposure:"hidden"},[cs]:{exposure:"hidden"},[el]:{exposure:"event"},[gr]:{exposure:"hidden"},[sl]:{exposure:"hidden"},[_r]:{exposure:"event"},[tl]:{exposure:"hidden"},[mr]:{exposure:"event"},[yr]:{exposure:"event"},[Vr]:{exposure:"event"},[Ur]:{exposure:"hidden"},[il]:{exposure:"event"},[ds]:{exposure:"hidden"},[dd]:{exposure:"hidden"},[Ft]:{exposure:"hidden"},[rl]:{exposure:"event"},[hd]:{exposure:"event",shouldSkipFromEventProperties:e=>se(e)},[_d]:{exposure:"event"},[md]:{exposure:"event"},[yd]:{exposure:"event"},[bd]:{exposure:"event"},[wd]:{exposure:"hidden"},[Te]:{exposure:"hidden",storageGroup:"flags"},[Ue]:{exposure:"hidden",storageGroup:"flags"},[pr]:{exposure:"hidden"},[gt]:{exposure:"hidden",storageGroup:"flags"},[rt]:{exposure:"hidden",storageGroup:"flags"},[_t]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[us]:{exposure:"hidden",storageGroup:"flags"},[Ne]:{exposure:"hidden"},[ft]:{exposure:"hidden"},[it]:{exposure:"hidden"},[st]:{exposure:"hidden"},[rs]:{exposure:"hidden",storageGroup:"surveys"},[ei]:{exposure:"hidden",storageGroup:"surveys",volatile:!0},[fr]:{exposure:"event"},[js]:{exposure:"hidden"},[qs]:{exposure:"hidden"},[br]:{exposure:"hidden"},[xd]:{exposure:"hidden"},[$d]:{exposure:"hidden"},[kd]:{exposure:"event"},[Ed]:{exposure:"event"},[Sd]:{exposure:"event"},[Pd]:{exposure:"event"},[We]:{exposure:"hidden"},[is]:{exposure:"hidden"},[nl]:{exposure:"event"},[ws]:{exposure:"hidden"},[nt]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[fe]:{exposure:"hidden"},[wr]:{exposure:"hidden"},[Ad]:{exposure:"hidden"},[ol]:{exposure:"hidden"},[al]:{exposure:"hidden"},[It]:{exposure:"hidden"},[Wr]:{exposure:"hidden"},[pd]:{exposure:"event"},[fd]:{exposure:"event"},[vd]:{exposure:"event"},[gd]:{exposure:"event"},[ul]:{exposure:"event"},[cl]:{exposure:"event"},[Gr]:{exposure:"hidden"},[Jr]:{exposure:"hidden"},[dl]:{exposure:"hidden"},[hl]:{exposure:"hidden"},[pl]:{exposure:"hidden"},[fl]:{exposure:"hidden"},[vl]:{exposure:"hidden"},[gl]:{exposure:"hidden"},[_l]:{exposure:"hidden"},[Cd]:{exposure:"event"}},Qd=[["$posthog_sr_group_event_trigger_",{exposure:"hidden"}],["$posthog_sr_group_url_trigger_",{exposure:"hidden"}],["$posthog_sr_group_sampling_",{exposure:"hidden"}]],de=e=>{const t=Xd[e];if(t)return t;for(const[s,i]of Qd)if(e.indexOf(s)===0)return i};function Ol(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}const Ke=e=>{const t=typeof document>"u"?void 0:document,s=t?.createElement("a");return x(s)?null:(s.href=e,s)},Ml=()=>{try{return"u">typeof window&&window.navigator.onLine!==!1}catch{return!1}},Tl=(e,t)=>e>=t&&Ml(),Rl=(e,t,s,i)=>{if(e===0){if(Ml()){const r=t+1;return r===s&&i(),r}return t}return 0},Mt=(e,t)=>{try{let s;return JSON.stringify(e,(i,r)=>{var n;return Ut(r)?((n=s)!==null&&n!==void 0||(s=new WeakMap),s.has(r)||s.set(r,bl(r)),s.get(r)):typeof r=="bigint"?r.toString():r},t)}catch{return Yo(e)}},Ht=function(e,t){const s=((e.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&");let i;for(let r=0;s.length>r;r++){const n=s[r].split(/=(.*)/);if(n[0]===t){i=n;break}}if(!O(i)||2>i.length)return"";{let r=i[1].replace(/\+/g," ");try{r=decodeURIComponent(r)}catch{E.error("Skipping decoding for malformed query param: "+r)}return r}},$s=function(e,t,s){if(!e||!t||!t.length)return e;const i=e.split(/#(.*)/),r=i[1],n=(i[0]||"").split(/\?(.*)/),o=n[1],a=n[0],l=(o||"").split("&"),u=[];for(let d=0;l.length>d;d++){const h=l[d].split("?");let p=0;for(;h.length>p&&!t.includes(h[p].split("=")[0]);)p++;u.push(h.length>p?h.slice(0,p).concat(h[p].split("=")[0]+"="+s).join("?"):l[d])}let c=a;return o!=null&&(c+="?"+u.join("&")),r!=null&&(c+="#"+r),c},ri=function(e,t){const s=e.match(new RegExp(t+"=([^&]*)"));return s?s[1]:null},Bt=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","oppref","bfcid","irclid","_kx"],Zd=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...Bt],ks="<masked>",eh=["li_fat_id"];function Ll(e,t,s){if(!C)return{};const i=t?[...Bt,...s||[]]:[],r=Dl($s(C.URL,i,ks),e),n=(function(){const o={};return J(eh,function(a){const l=hs(a);o[a]=l||null}),o})();return ee(n,r)}function Dl(e,t){const s=Zd.concat(t||[]),i={};return J(s,function(r){const n=Ht(e,r);i[r]=n||null}),i}function Nl(e){const t=(function(r){return r?r.search("https?://(.*)google.([^/?]*)")===0?"google":r.search("https?://(.*)bing.com")===0?"bing":r.search("https?://(.*)yahoo.com")===0?"yahoo":r.search("https?://(.*)duckduckgo.com")===0?"duckduckgo":null:null})(e),s=t!="yahoo"?"q":"p",i={};if(!se(t)){i.$search_engine=t;const r=C?Ht(C.referrer,s):"";r.length&&(i.ph_keyword=r)}return i}function jl(){return navigator.language||navigator.userLanguage}function th(){const e=jl();return typeof e=="string"?e.split("-")[0]:void 0}const ni="$direct";function ql(){return C?.referrer||ni}function Hl(e,t,s=!1){const i=e?[...Bt,...t||[]]:[],r=s?at(Y?.href):Y?.href,n=r?.substring(0,1e3);return{r:ql().substring(0,1e3),u:n?$s(n,i,ks):void 0}}function Bl(e,t=!1){var s;const{r:i,u:r}=e,n=t?at(r):r,o={$referrer:i,$referring_domain:i==null?void 0:i==ni?ni:(s=Ke(i))===null||s===void 0?void 0:s.host};if(n){o.$current_url=n;const a=Ke(n);o.$host=a?.host,o.$pathname=a?.pathname;const l=Dl(n);ee(o,l)}if(i){const a=Nl(i);ee(o,a)}return o}function sh(){try{return new Date().getTimezoneOffset()}catch{return}}const ih={flags:nt,surveys:ei},rh=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],Fs=e=>`${e}_cookie_identity_change_pending`,Is=e=>{let t="",s=0;for(const i of e){const r=encodeURIComponent(JSON.stringify(i).slice(1,-1)).length;if(s+r>1e3)break;t+=i,s+=r}return t},ue="main",Ve=[Te,Ue,gt,rt,_t,nt,us,it],Li=e=>Ve.indexOf(e)!==-1,zl=[Lt,cs],no=e=>zl.indexOf(e)!==-1,Ze=(e,t)=>{try{return JSON.stringify(e)===JSON.stringify(t)}catch{return e===t}},kt=e=>{if(!e)return{};const t=JSON.parse(e);return D(t)?t:{}},oo=(e,t)=>{J(e,(s,i)=>{const r=de(i);r&&r.exposure!=="event"||{}.hasOwnProperty.call(t,i)||delete e[i]})};var Di=class{constructor(e,t,s=!0,i=!e.cookieless_mode){if(this.Dl={},this.Ll=!1,this.Nl=!1,this.ql=!1,this.jl=!1,this.Bl=!1,this.zl=new Map,this.Hl=!1,this.Ul=!1,this.Wl=!1,this.Vl=new Set,this.Gl=new Set,this.Ar=e,this.Ql=s,this.props={},this.Zl=void 0,this.Jl=(r=>{let n="";return r.token&&(n=r.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),r.persistence_name?"ph_"+r.persistence_name:"ph_"+n+"_posthog"})(e),this.hi=e.disable_persistence||!!t,this.$l=this.Kl(e),this.ql=this.Xl(e),this.load(i),this.Yl(),e.debug&&E.info("Persistence loaded",e.persistence,f({},this.props)),this.update_config(e,e,t),this.save(),w){const r=()=>this.flush();U(w,"beforeunload",r,{capture:!1}),U(w,"pagehide",r,{capture:!1}),this.tu=n=>{if(this.Ll&&(!n.storageArea||n.storageArea===w?.localStorage)&&n.key)if(n.key!==this.Jl){if(this.ql){const o=Xt.find(a=>n.key===this.eu(a));o&&this.iu(n.key,o)}}else this.iu(n.key,ue)},U(w,"storage",this.tu)}}markCrossTabFeatureFlagChanges(e){Object.entries(e).forEach(([t,s])=>{const i=this.zl.get(t);if(!Li(t)||i===!0)return;if(s===!0)return void this.nu(t,!0);const r=new Set(i||[]);s.forEach(n=>r.add(n)),r.size&&this.nu(t,r)})}onCrossTabFeatureFlagChange(e){return this.Gl.add(e),()=>this.Gl.delete(e)}destroy(){this.tu&&w&&(w.removeEventListener("storage",this.tu),this.tu=void 0),this.Gl.clear()}iu(e,t,s=!0){if(this.hi)return!1;let i,r;try{if(r=z.Ot(e),se(r)){const a=this.su(t);return a.storageValue=null,t!==ue&&(a.persisted=!1),!1}i=kt(r)}catch{return!1}const n=t===ue?i:z.Lt(this.Jl);if(n&&this.ru(n))return!1;const o=this.ou(i,t,s);return t===ue&&this.ql&&!Ze(this.au().main,i)||this.lu(i,t,!0,r),o}ru(e){const t=this.props[Fe],s=e[Fe];return!x(t)&&!x(s)&&t!==s}lu(e,t,s,i){const r=this.su(t);r.storageValue=i,t!==ue&&(r.persisted=s);try{r.fingerprint=this.uu(e,t)}catch{r.fingerprint=void 0}}ou(e,t,s){let i=!1;return Ve.forEach(r=>{var n;const o=(n=de(r))===null||n===void 0?void 0:n.storageGroup;if(t===ue&&this.ql&&o||t!==ue&&o!==t)return;const a=r in e,l=this.cu(r,a?e[r]:void 0),u=this.zl.has(r)?r in this.props:a;u===r in this.props&&Ze(l,this.props[r])||(u?this.hu(r,l,!1):this.du(r,!1),i=!0)}),i&&s&&this.Gl.forEach(r=>r()),i}vu(){if(!this.Ll)return!1;try{this.Wl=!1;const e=z.Ot(this.Jl),t=this.su(ue);let s,i=!1,r=!1;if(e!==t.storageValue)if(se(e))t.storageValue=null;else{if(s=kt(e),this.Wl=!this.Ul&&this.ru(s),this.Wl)return!1;r=this.ou(s,ue,!1),!this.ql||Ze(this.au().main,s)?this.lu(s,ue,!0,e):t.storageValue=e,i=!0}return this.ql&&Xt.forEach(n=>{const o=z.Ot(this.eu(n)),a=this.su(n),l=s||{},u=i&&Ve.some(d=>{var h;return((h=de(d))===null||h===void 0?void 0:h.storageGroup)===n&&d in l});if(o===a.storageValue&&!u)return;if(se(o))return a.storageValue=null,a.persisted=!1,void(u&&(r=this.ou(l,n,!1)||r));const c=kt(o);r=this.ou(c,n,!1)||r,this.lu(c,n,!0,o)}),r}catch{return!1}}nu(e,t){this.zl.set(e,t);const s=de(e);s?.volatile||(this.su((this.ql?s?.storageGroup:void 0)||ue).fingerprint=void 0,this.fu(e))}pu(){Ve.forEach(e=>this.zl.set(e,!0))}Yl(){if(this.Ll)try{const e=z.Ot(this.Jl),t=kt(e);this.su(ue).storageValue=e,Ve.forEach(s=>{var i;const r=this.ql?(i=de(s))===null||i===void 0?void 0:i.storageGroup:void 0,n=r?z.Ot(this.eu(r)):null;if(r){const a=this.su(r);a.storageValue=n,a.persisted=!se(n)}const o=r&&!se(n)?kt(n):t;s in this.props?this.gu(s,o[s],this.props[s]):s in o&&this.nu(s,!0)})}catch{}}cu(e,t){const s=this.zl.get(e);if(!s)return t;if(s===!0)return this.props[e];if(e==="$active_feature_flags"){const n=new Set(O(t)?t:[]),o=new Set(O(this.props[e])?this.props[e]:[]);return s.forEach(a=>o.has(a)?n.add(a):n.delete(a)),Array.from(n)}const i=D(t)?f({},t):{},r=D(this.props[e])?this.props[e]:{};return s.forEach(n=>{n in r?i[n]=r[n]:delete i[n]}),i}gu(e,t,s){if(!Li(e))return;const i=this.zl.get(e);if(i===!0)return;let r=t;if(this.Ll)try{var n;const a=this.ql?(n=de(e))===null||n===void 0?void 0:n.storageGroup:void 0,l=a?this.eu(a):this.Jl;r=kt(z.Ot(l))[e]}catch{}const o=new Set(i||[]);if(e==="$active_feature_flags"){if(!x(t)&&!O(t)||!x(r)&&!O(r)||!O(s))return void this.nu(e,!0);const a=new Set(t||[]),l=new Set(r||[]),u=new Set(s);new Set([...a,...u]).forEach(c=>{a.has(c)!==u.has(c)&&o.add(c)}),o.forEach(c=>{l.has(c)===u.has(c)&&o.delete(c)})}else{if(!D(s))return void(Ze(r,s)?this.zl.delete(e):this.nu(e,!0));{if(!x(t)&&!D(t)||x(t)&&ke(s)&&x(r))return void this.nu(e,!0);const a=D(t)?t:{},l=D(r)?r:{};new Set([...Object.keys(a),...Object.keys(s)]).forEach(u=>{u in a==u in s&&Ze(a[u],s[u])||o.add(u)}),o.forEach(u=>{u in l==u in s&&Ze(l[u],s[u])&&o.delete(u)})}}o.size?this.nu(e,o):this.zl.delete(e)}mu(){var e;const t=(e=this.Ar)===null||e===void 0?void 0:e.persistence_save_debounce_ms;return oe(t)&&t>0?t:0}yu(e){if(this.Ar.cookieWinsOnConflict&&this.Ar.persistence.toLowerCase()==="localstorage+cookie")if(e)try{const t=Mi(e,this.Ar.cookie_persisted_properties||[]),s=zn(t,this.Ar.cookie_persisted_properties||[]),i=JSON.stringify(t)+"|"+JSON.stringify(s),r=Z.Ot(this.Jl)||void 0;r&&Ti(this.Jl,r)===i&&(this.bu=i,this._u=r)}catch{}else try{const t=Z.Ot(this.Jl)||void 0;this.bu=t?Ti(this.Jl,t):void 0,this._u=t}catch{}}syncCookieProperties(){return this.wu(this.Ar)}wu(e,t=!1){if(this.hi&&!t||this.Bl||!e.cookieWinsOnConflict||e.persistence.toLowerCase()!=="localstorage+cookie")return!1;let s;try{s=Z.Ot(this.Jl)||void 0}catch{}if(!s||s===this._u)return!1;const i=Ti(this.Jl,s);let r;try{r=Oi(JSON.parse(s))}catch{return!1}if((Z.Ot(this.Jl)||void 0)!==s)return!1;this.bu=i,this._u=s;const n=Vn(this.Jl,s),o=[...vt,...n.properties],a={};if(Object.keys(r).forEach(m=>{const g=r[m];(x(g)||se(g)||g===""||m==="$user_state"&&g!=="anonymous"&&g!=="identified")&&(a[m]=!0,delete r[m])}),ke(r))return!1;const l="distinct_id"in r||r.$user_state==="anonymous"||r.$user_state==="identified",u=this.props,c=u[Fe],d=u[fe],h=ee({},u);[...vt,...e.cookie_persisted_properties||[]].forEach(m=>{if(o.indexOf(m)!==-1&&!(m in r)&&!a[m]&&(l||m!=="distinct_id"&&m!=="$user_state")){const g=h[m];(n.isValid||vt.indexOf(m)===-1||g!==!1&&g!==0)&&delete h[m]}}),this.props=ee(h,r),Ve.forEach(m=>{const g=m in this.props;m in u===g&&Ze(u[m],this.props[m])||(g?this.gu(m,u[m],this.props[m]):this.nu(m,!0))}),!l||"$user_state"in r||"$user_state"in this.props||this.hu(fe,Ge);const p=this.props[Fe],v=this.props[fe];return!l||p===c&&v===d||(this.Ul=!0,this.jl=!0,X.At(Fs(this.Jl),!0),this.du(it),this.du(Ue),this.du(Te),this.du(gt),this.du(rt),this.du(_t),this.du(nt),this.du(ws),this.du(We),v!=="anonymous"||d!=="identified"&&r.$user_state!=="anonymous"&&(x(c)||p===c)||(oo(this.props,r),this.du(st)),v==="identified"?this.props.$user_id=p:delete this.props.$user_id,this.du(ti)),!0}consumeCookieIdentityChange(){const e=Fs(this.Jl),t=this.jl||!!X.Ot(e);return this.jl=!1,t&&X.Pt(e),t}ku(e=!1){return!(this.Bl||this.hi&&!e||!this.Ar.cookieWinsOnConflict||this.Ar.persistence.toLowerCase()!=="localstorage+cookie"||(this.Bl=!0,0))}Su(){this.Bl&&(x(this.xu)||(clearTimeout(this.xu),this.xu=void 0),delete this.Dl[ue],this.$u(!0))}Cu(e=!0){if(this.Bl)try{e?this.Su():x(this.xu)||(clearTimeout(this.xu),this.xu=void 0)}finally{this.Bl=!1}}isDisabled(){return!!this.hi}Kl(e){rh.indexOf(e.persistence.toLowerCase())===-1&&(E.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");const t=((o=[],a=!1,l=()=>!1)=>{const u=[...vt,...o];return f(f({},z),{},{Tu(c){return[Z.Ot(c),Z.Ot(ps(c)),z.Ot(c)].join("\0")},Lt(c){try{let h,p={};try{h=Z.Ot(c)||void 0,p=h?Oi(JSON.parse(h)):{}}catch{}const v=JSON.parse(z.Ot(c)||"{}");let m;if(a){const g=Vn(c,h),y=[...vt,...g.properties],_={};Object.keys(p).forEach(k=>{const $=p[k];se($)||$===""||k==="$user_state"&&$!=="anonymous"&&$!=="identified"||(_[k]=$)});const b="distinct_id"in _||_.$user_state==="anonymous"||_.$user_state==="identified";if(Object.keys(_).length>0){var d;const k=v[Fe],$=(d=v.$user_state)!==null&&d!==void 0?d:Ge;u.forEach(S=>{if(y.indexOf(S)!==-1&&!(S in p)&&(b||S!=="distinct_id"&&S!=="$user_state")){const A=v[S];(g.isValid||vt.indexOf(S)===-1||A!==!1&&A!==0)&&delete v[S]}}),!b||"$user_state"in p||"$user_state"in v||(v[fe]=Ge),!b||("distinct_id"in _?_[Fe]:v[Fe])===k&&("$user_state"in _?_[fe]:v[fe])===$||(Ii.forEach(S=>delete v[S]),_.$user_state==="identified"&&"distinct_id"in _?v.$user_id=_[Fe]:delete v.$user_id,_.$user_state!=="identified"&&(delete v[nl],delete v[st]),delete v.__alias)}m=ee(v,_)}else m=ee(p,v);return l()||z.At(c,m),m}catch{}return null},At(c,d,h,p,v,m){const g=z.At(c,d,void 0,void 0,m);try{const y=Mi(d,o);if(Object.keys(y).length){if(a){const _=ps(c),b=zn(y,o);if(Z.At(_,b,h,p,v,m),Z.Ot(_)!==JSON.stringify(b)){Z.Pt(_,p);const k=Mi(d);return Z.At(c,k,h,p,v,m),g}}Z.At(c,y,h,p,v,m)}}catch(y){z.Ft(y)}return g},Pt(c,d){try{w?.localStorage.removeItem(c),Z.Pt(c,d),Z.Pt(ps(c),d)}catch(h){z.Ft(h)}}})})(e.cookie_persisted_properties||[],e.cookieWinsOnConflict,()=>!!this.hi);let s,i=!1,r=!1;const n=e.persistence.toLowerCase();return n==="localstorage"&&z.Et()?(s=z,r=!0):n==="localstorage+cookie"&&t.Et()?(s=t,r=!0,i=!0):n==="sessionstorage"&&X.Et()?s=X:n==="memory"?s=kr:n==="cookie"&&Z.Et()?(s=Z,i=!0):t.Et()?(s=t,r=!0,i=!0):Z.Et()?(s=Z,i=!0):s=kr,this.Ll=r,this.Nl=i,s}eu(e){return`${this.Jl}__${e}`}Xl(e){return this.Ll&&!!e.split_storage}properties(){const e={};return J(this.props,(t,s)=>{const i=de(s);if(!i||i.exposure==="event"){var r;if(!(i==null||(r=i.shouldSkipFromEventProperties)===null||r===void 0)&&r.call(i,t))return;e[s]=t}}),e}load(e=!1){if(this.hi&&!e)return;const t=this.Ar.cookieWinsOnConflict&&this.Ar.persistence.toLowerCase()==="localstorage+cookie",s=t?z.Lt(this.Jl):null;let i={};if(t)try{i=Oi(Z.Lt(this.Jl)),J(i,(a,l)=>{(x(a)||se(a)||a==="")&&delete i[l]})}catch{}const r=this.$l.Lt(this.Jl);if(r&&(this.props=ee({},r)),this.ql&&this.Iu(),t&&r){var n,o;const a=s?.[Fe],l=(n=s?.$user_state)!==null&&n!==void 0?n:Ge,u=r[Fe],c=(o=r.$user_state)!==null&&o!==void 0?o:Ge;if(u!==a||c!==l){this.jl=!0,this.hi||X.At(Fs(this.Jl),!0);const d=ee({},this.props);Ii.forEach(p=>delete d[p]),c!=="anonymous"||l!=="identified"&&i.$user_state!=="anonymous"&&(x(a)||u===a)||(oo(d,i),delete d[st]),this.props=d;const h=new Set;Ii.forEach(p=>{var v;const m=(v=de(p))===null||v===void 0?void 0:v.storageGroup;m&&h.add(m)}),h.forEach(p=>{if(this.hi)return;const v={};J(this.props,(m,g)=>{var y;((y=de(g))===null||y===void 0?void 0:y.storageGroup)===p&&(v[g]=m)}),ke(v)?(z.Pt(this.eu(p)),this.Dl[p]={}):z.At(this.eu(p),v)&&(this.Dl[p]={persisted:!0,fingerprint:this.uu(v,p)})})}}X.Ot(Fs(this.Jl))&&(this.jl=!0)}Iu(){for(const e of Xt){const t=z.Lt(this.eu(e));if(t&&!ke(t)){const s=this.su(e);s.persisted=!0,this.Mu(e)||(s.fingerprint=this.uu(t,e)),this.Eu(e,t)||ee(this.props,t)}}}Mu(e){return Object.keys(this.props).some(t=>{var s;return((s=de(t))===null||s===void 0?void 0:s.storageGroup)===e})}Eu(e,t){const s=ih[e];if(!s)return!1;const i=t[s],r=this.props[s];return oe(i)&&oe(r)&&r>i}refreshKey(e){this.Pu([e])}Pu(e){if(this.hi)return;let t,s=!1;const i=()=>(s||(t=this.$l.Lt(this.Jl),s=!0),t);e.forEach(r=>{var n;if(this.Vl.has(r))return;const o=this.ql?(n=de(r))===null||n===void 0?void 0:n.storageGroup:void 0,a=o?z.Lt(this.eu(o)):i();if(a&&r in a)this.hu(r,a[r],!1);else{if(o){const l=i();if(l&&r in l)return void this.hu(r,l[r],!1)}this.du(r,!1)}})}refreshMetaIdentifiers(){if(this.hi)return;const e=this.Ru();(x(e)||e!==this.Au)&&(this.Pu(zl),this.Fu(e))}Fu(e=this.Ru()){this.Au=this.Vl.size===0?e:void 0}Ru(){const e=this.$l.Tu?this.$l.Tu(this.Jl):this.$l.Ot(this.Jl);return N(e)?e:void 0}save(){if(this.hi)return;const e=this.mu();e>0?x(this.xu)&&(this.xu=setTimeout(()=>{this.xu=void 0,this.$u()},e)):this.$u()}flush(){x(this.xu)||(clearTimeout(this.xu),this.xu=void 0,this.$u())}$u(e=!1){if(this.hi||this.Bl&&!e)return;e||(this.syncCookieProperties(),this.Ar.cookieWinsOnConflict&&this.Ar.persistence.toLowerCase()==="localstorage+cookie"||this.refreshMetaIdentifiers());const t=!e&&!this.Hl;t||(this.Wl=!1);const s=!!t&&this.vu();if(this.Wl)return void(this.Ar.debug&&E.warn("skipping persistence write because storage belongs to a different distinct ID"));if(this.ql)return this.Ou(),void(s&&this.Gl.forEach(r=>r()));const i=this.Du(this.$l,this.Jl,this.props,ue);i==="written"&&this.yu(this.props),i!=="failed"&&(this.zl.clear(),this.Ul=!1,this.Vl.clear()),i==="written"&&this.Fu(),s&&this.Gl.forEach(r=>r())}Ou(){const{main:e,groups:t}=this.au(),s=this.Du(this.$l,this.Jl,e,ue);s==="written"&&this.yu(e),s!=="failed"&&(this.Ul=!1,this.Vl.clear(),Ve.forEach(r=>{var n;!((n=de(r))===null||n===void 0)&&n.storageGroup||this.zl.delete(r)})),s==="written"&&this.Fu();for(const r of Xt){var i;const n=t[r];if(ke(n)&&!(!((i=this.Dl[r])===null||i===void 0)&&i.persisted)){Ve.forEach(a=>{var l;((l=de(a))===null||l===void 0?void 0:l.storageGroup)===r&&this.zl.delete(a)});continue}const o=this.Du(z,this.eu(r),n,r);o!=="failed"&&Ve.forEach(a=>{const l=de(a);l?.storageGroup!==r||o!=="written"&&l.volatile||this.zl.delete(a)})}}au(){const e={},t={flags:{},surveys:{}};return J(this.props,(s,i)=>{var r;const n=(r=de(i))===null||r===void 0?void 0:r.storageGroup;n?t[n][i]=s:e[i]=s}),{main:e,groups:t}}uu(e,t){if(t===ue)return JSON.stringify(e)+"|"+this.Lu+"|"+this.Nu+"|"+this.qu;const s={};return J(e,(i,r)=>{var n;s[r]=!((n=de(r))===null||n===void 0)&&n.volatile?"__volatile__":i}),JSON.stringify(s)}Du(e,t,s,i){const r=this.su(i);if(i!==ue&&!r.dirty&&!x(r.fingerprint))return"skipped";let n;try{if(n=this.uu(s,i),n===r.fingerprint)return r.dirty=!1,"skipped"}catch{n=void 0}return e.At(t,s,this.Lu,this.Nu,this.qu,this.Ar.debug)?(r.dirty=!1,i!==ue&&(r.persisted=!0),x(n)||(r.fingerprint=n),this.Ll&&(r.storageValue=z.Ot(t)),"written"):(this.Ar.debug&&E.warn(`failed to persist storage entry "${t}"; will retry on next save`),"failed")}remove({keepGroupEntries:e=!1}={}){if(this.pu(),x(this.xu)||(clearTimeout(this.xu),this.xu=void 0),this.$l.Pt(this.Jl,!1),this.$l.Pt(this.Jl,!0),!e&&this.Ql)for(const t of Xt)z.Pt(this.eu(t));e?delete this.Dl[ue]:this.Dl={},this.bu=void 0,this._u=void 0}clear(){this.remove(),this.props={}}register_once(e,t,s){if(D(e)){this.syncCookieProperties(),x(t)&&(t="None"),this.Lu=x(s)?this.ju:s;let i=!1;if(J(e,(r,n)=>{this.props.hasOwnProperty(n)&&this.props[n]!==t||(this.hu(n,r),i=!0)}),i)return this.save(),!0}return!1}register(e,t){if(D(e)){this.syncCookieProperties(),this.Lu=x(t)?this.ju:t;let s=!1;if(J(e,(i,r)=>{e.hasOwnProperty(r)&&(this.props[r]!==i||D(i)||O(i))&&(this.hu(r,i),s=!0)}),s)return this.save(),!0}return!1}unregister(e){this.syncCookieProperties();const t=typeof e=="string"?[e]:e;let s=!1;for(const i of t)i in this.props&&(this.du(i),s=!0);s&&this.save()}update_campaign_params(){const e=C?.URL;if(e===this.Zl)return;const t=Ll(this.Ar.custom_campaign_params,this.Ar.mask_personal_data_properties,this.Ar.custom_personal_data_properties),s=!ke(Yr(t));return s&&this.register(t),this.Zl=e,s?t:void 0}update_search_keyword(){this.register((function(){const e=C?.referrer;return e?Nl(e):{}})())}update_referrer_info(){var e;this.register_once({$referrer:ql(),$referring_domain:C?.referrer&&((e=Ke(C.referrer))===null||e===void 0?void 0:e.host)||ni},void 0)}set_initial_person_info(){if(this.props.$initial_campaign_params||this.props.$initial_referrer_info)return;const e=Hl(this.Ar.mask_personal_data_properties,this.Ar.custom_personal_data_properties,this.Ar.disable_capture_url_hashes);this.register_once({[It]:this.Nl?{r:Is(e.r),u:e.u?Is(e.u):void 0}:e},void 0)}get_initial_props(){const e={};J([al,ol],s=>{const i=this.props[s];i&&J(i,function(r,n){e["$initial_"+ir(n)]=r})});const t=this.props[It];if(t){const s=(function(i,r=!1){const n=Bl(i,r),o={};return J(n,function(a,l){o[`$initial_${ir(l)}`]=a}),o})(t,this.Ar.disable_capture_url_hashes);ee(e,s)}return e}safe_merge(e){return J(this.props,function(t,s){s in e||(e[s]=t)}),e}update_config(e,t,s){const i=e.persistence!==t.persistence,r=!((p,v)=>{if(p.length!==v.length)return!1;const m=[...p].sort(),g=[...v].sort();return m.every((y,_)=>y===g[_])})(e.cookie_persisted_properties||[],t.cookie_persisted_properties||[]),n=i||r,o=e.cookieWinsOnConflict!==t.cookieWinsOnConflict,a=e.disable_persistence||!!s,l=!!this.hi&&!a;a||this.wu(t,l),this.Ar=e,!a&&(i||r||o)&&(this.bu=void 0,this._u=void 0,this.wu(f(f({},e),{},{cookie_persisted_properties:t.cookie_persisted_properties}),l));const u=n||o?this.Kl(e):this.$l;this.Bu();const c=this.Xl(e),d=n||c!==this.ql,h=!a&&(d||e.cross_subdomain_cookie!==this.Nu||e.secure_cookie!==this.qu)&&this.ku(l);this.Hl=d;try{if(this.ju=this.Lu=e.cookie_expiration,this.set_disabled(a),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),d){const p=this.props;this.clear(),this.$l=u,this.ql=c,this.props=p,this.save()}else o&&(this.$l=u,a||(delete this.Dl[ue],this.$u()))}finally{this.Hl=!1,h&&this.Cu()}}Bu(){const e=this.props[It];if(!this.Nl||!D(e)||typeof e.r!="string")return;const t=Is(e.r),s=typeof e.u=="string"?Is(e.u):e.u;t===e.r&&s===e.u||this.hu(It,f(f({},e),{},{r:t,u:s}))}set_disabled(e){this.hi=e,this.hi?this.remove():this.save()}set_cross_subdomain(e){e!==this.Nu&&(this.Nu=e,this.remove({keepGroupEntries:!0}),this.save())}set_secure(e){e!==this.qu&&(this.qu=e,this.remove({keepGroupEntries:!0}),this.save())}set_event_timer(e,t){const s=this.props.__timers||{};s[e]=t,this.hu(vr,s),this.save()}remove_event_timer(e){const t=this.props.__timers||{},s=t[e];return x(s)||(delete t[e],this.hu(vr,t),this.save()),s}get_property(e){return this.props[e]}set_property(e,t){this.hu(e,t),this.save()}hu(e,t,s=!0){var i;const r=this.props[e];this.props[e]=t,s&&(e!=="distinct_id"&&e!=="$user_state"||r===t||(this.Ul=!0),no(e)&&!Ze(r,t)&&this.Vl.add(e),this.gu(e,r,t),!((i=de(e))===null||i===void 0)&&i.volatile||this.fu(e))}du(e,t=!0){delete this.props[e],t&&(Li(e)&&this.nu(e,!0),no(e)&&this.Vl.add(e),this.fu(e))}fu(e){var t;const s=(t=de(e))===null||t===void 0?void 0:t.storageGroup;s&&(this.su(s).dirty=!0)}su(e){return this.Dl[e]||(this.Dl[e]={})}};const Pe={GZipJS:"gzip-js",Base64:"base64"},Qt={Activation:"events",Cancellation:"cancelEvents"},Ni={Popover:"popover",API:"api",Widget:"widget"},Se={SHOWN:"survey shown",DISMISSED:"survey dismissed",SENT:"survey sent"},ji={SURVEY_ID:"$survey_id",SURVEY_ITERATION:"$survey_iteration",SURVEY_LAST_SEEN_DATE:"$survey_last_seen_date"},Sr={Popover:"popover",Inline:"inline"};function Os(e){let t=!0;return{dispose(){if(t){t=!1;const s=e();s&&ne(s.then)&&s.then(void 0,()=>{})}}}}const nh={SHOWN:"product tour shown"},ao={TOUR_LAST_SEEN_DATE:"$product_tour_last_seen_date",TOUR_TYPE:"$product_tour_type"},lo=te("[RateLimiter]");var oh=class{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=t=>{const s=t.text;if(s&&s.length)try{(JSON.parse(s).quota_limited||[]).forEach(i=>{lo.info(`${i||"events"} is quota limited.`),this.serverLimits[i]=new Date().getTime()+6e4})}catch(i){return void lo.warn(`could not rate limit - continuing. Error: "${i?.message}"`,{text:s})}},this.instance=e,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var e;return((e=this.instance.config.rate_limiting)===null||e===void 0?void 0:e.events_per_second)||10}get captureEventsBurstLimit(){var e;return Math.max(((e=this.instance.config.rate_limiting)===null||e===void 0?void 0:e.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(e=!1){var t,s,i;const{captureEventsBurstLimit:r,captureEventsPerSecond:n}=this,o=new Date().getTime(),a=(t=(s=this.instance.persistence)===null||s===void 0?void 0:s.get_property("$capture_rate_limit"))!==null&&t!==void 0?t:{tokens:r,last:o};a.tokens+=Math.max(0,o-a.last)/1e3*n,a.last=Math.max(a.last,o),a.tokens>r&&(a.tokens=r);const l=1>a.tokens;if(l||e||(a.tokens=Math.max(0,a.tokens-1)),l&&!e){const u=(oe(a.dropped)?a.dropped:0)+1;a.dropped=u,!this.lastEventRateLimited&&this.zu(u)&&(a.dropped=0)}return this.lastEventRateLimited=l,(i=this.instance.persistence)===null||i===void 0||i.set_property("$capture_rate_limit",a),{isRateLimited:l,remainingTokens:a.tokens}}Hu(e){const t=this.instance.config.property_denylist;return!O(t)||!t.includes(e)}Uu(){var e;if(this.Hu("$current_url")&&this.Hu("$pathname")&&Y?.pathname)return`${(e=Y.origin)!==null&&e!==void 0?e:""}${Y.pathname}`}zu(e){var t,s;const{captureEventsBurstLimit:i,captureEventsPerSecond:r}=this,n=this.Uu(),o=this.Hu("$session_id")?(t=(s=this.instance).get_session_id)===null||t===void 0?void 0:t.call(s):void 0,a=[`${e} event(s) dropped since the last warning`,n?`triggered on ${n}`: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: ${a}. Config is set to ${r} events per second and ${i} events burst limit.`},{skip_client_rate_limiting:!0})}isServerRateLimited(e){const t=this.serverLimits[e||"events"]||!1;return t!==!1&&new Date().getTime()<t}};const et=te("[RemoteConfig]");var Vl=class{constructor(e){this._instance=e}get remoteConfig(){var e;return(e=M._POSTHOG_REMOTE_CONFIG)===null||e===void 0||(e=e[this._instance.config.token])===null||e===void 0?void 0:e.config}Wu(e){var t,s,i;!((t=M.__PosthogExtensions__)===null||t===void 0)&&t.loadExternalDependency?(s=M.__PosthogExtensions__)===null||s===void 0||(i=s.loadExternalDependency)===null||i===void 0||i.call(s,this._instance,"remote-config",()=>e(this.remoteConfig)):e()}Vu(e){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets",`/array/${this._instance.config.token}/config`),callback:e})}load(){try{if(this.remoteConfig)return et.info("Using preloaded remote config",this.remoteConfig),void this.Gu(this.remoteConfig);if(this._instance.Qu())return void et.warn("Remote config is disabled. Falling back to local config.");this.Wu(e=>{if(!e)return et.info("No config found after loading remote JS config. Falling back to JSON."),void this.Vu(t=>{this.Gu(t.json,t)});this.Gu(e)})}catch(e){et.error("Error loading remote config",e),this.Gu()}}Gu(e,t){!e&&t&&(t.statusCode===0?t.error||et.warn("Failed to fetch remote config from PostHog."):et.error("Failed to fetch remote config from PostHog."));try{this._instance.Gu(e?{ok:!0,config:e}:{ok:!1})}catch(i){et.error("Error applying remote config",i)}if(e?.hasFeatureFlags!==!1&&!this._instance.config.advanced_disable_feature_flags_on_first_load)try{var s;(s=this._instance.featureFlags)===null||s===void 0||s.ensureFlagsLoaded()}catch(i){et.error("Error loading feature flags",i)}}},Oe=Uint8Array,Ee=Uint16Array,zt=Uint32Array,tn=new Oe([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]),sn=new Oe([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]),uo=new Oe([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ul=function(e,t){for(var s=new Ee(31),i=0;31>i;++i)s[i]=t+=1<<e[i-1];var r=new zt(s[30]);for(i=1;30>i;++i)for(var n=s[i];s[i+1]>n;++n)r[n]=n-s[i]<<5|i;return[s,r]},Wl=Ul(tn,2),Pr=Wl[1];Wl[0][28]=258,Pr[258]=28;for(var co=Ul(sn,0)[1],Gl=new Ee(32768),ie=0;32768>ie;++ie){var Et=(43690&ie)>>>1|(21845&ie)<<1;Gl[ie]=((65280&(Et=(61680&(Et=(52428&Et)>>>2|(13107&Et)<<2))>>>4|(3855&Et)<<4))>>>8|(255&Et)<<8)>>>1}var vs=function(e,t,s){for(var i=e.length,r=0,n=new Ee(t);i>r;++r)++n[e[r]-1];var o,a=new Ee(t);for(r=0;t>r;++r)a[r]=a[r-1]+n[r-1]<<1;for(o=new Ee(i),r=0;i>r;++r)o[r]=Gl[a[e[r]-1]++]>>>15-e[r];return o},yt=new Oe(288);for(ie=0;144>ie;++ie)yt[ie]=8;for(ie=144;256>ie;++ie)yt[ie]=9;for(ie=256;280>ie;++ie)yt[ie]=7;for(ie=280;288>ie;++ie)yt[ie]=8;var oi=new Oe(32);for(ie=0;32>ie;++ie)oi[ie]=5;var ah=vs(yt,9),lh=vs(oi,5),Jl=function(e){return(e/8|0)+(7&e&&1)},Kl=function(e,t,s){(s==null||s>e.length)&&(s=e.length);var i=new(e instanceof Ee?Ee:e instanceof zt?zt:Oe)(s-t);return i.set(e.subarray(t,s)),i},He=function(e,t,s){var i=t/8|0;e[i]|=s<<=7&t,e[i+1]|=s>>>8},Zt=function(e,t,s){var i=t/8|0;e[i]|=s<<=7&t,e[i+1]|=s>>>8,e[i+2]|=s>>>16},qi=function(e,t){for(var s=[],i=0;e.length>i;++i)e[i]&&s.push({s:i,f:e[i]});var r=s.length,n=s.slice();if(!r)return[new Oe(0),0];if(r==1){var o=new Oe(s[0].s+1);return o[s[0].s]=1,[o,1]}s.sort(function($,S){return $.f-S.f}),s.push({s:-1,f:25001});var a=s[0],l=s[1],u=0,c=1,d=2;for(s[0]={s:-1,f:a.f+l.f,l:a,r:l};c!=r-1;)a=s[s[d].f>s[u].f?u++:d++],l=s[u!=c&&s[d].f>s[u].f?u++:d++],s[c++]={s:-1,f:a.f+l.f,l:a,r:l};var h=n[0].s;for(i=1;r>i;++i)n[i].s>h&&(h=n[i].s);var p=new Ee(h+1),v=Ar(s[c-1],p,0);if(v>t){i=0;var m=0,g=v-t,y=1<<g;for(n.sort(function($,S){return p[S.s]-p[$.s]||$.f-S.f});r>i;++i){var _=n[i].s;if(t>=p[_])break;m+=y-(1<<v-p[_]),p[_]=t}for(m>>>=g;m>0;){var b=n[i].s;t>p[b]?m-=1<<t-p[b]++-1:++i}for(;i>=0&&m;--i){var k=n[i].s;p[k]==t&&(--p[k],++m)}v=t}return[new Oe(p),v]},Ar=function(e,t,s){return e.s==-1?Math.max(Ar(e.l,t,s+1),Ar(e.r,t,s+1)):t[e.s]=s},ho=function(e){for(var t=e.length;t&&!e[--t];);for(var s=new Ee(++t),i=0,r=e[0],n=1,o=function(l){s[i++]=l},a=1;t>=a;++a)if(e[a]==r&&a!=t)++n;else{if(!r&&n>2){for(;n>138;n-=138)o(32754);n>2&&(o(n>10?n-11<<5|28690:n-3<<5|12305),n=0)}else if(n>3){for(o(r),--n;n>6;n-=6)o(8304);n>2&&(o(n-3<<5|8208),n=0)}for(;n--;)o(r);n=1,r=e[a]}return[s.subarray(0,i),t]},es=function(e,t){for(var s=0,i=0;t.length>i;++i)s+=e[i]*t[i];return s},Cr=function(e,t,s){var i=s.length,r=Jl(t+2);e[r]=255&i,e[r+1]=i>>>8,e[r+2]=255^e[r],e[r+3]=255^e[r+1];for(var n=0;i>n;++n)e[r+n+4]=s[n];return 8*(r+4+i)},po=function(e,t,s,i,r,n,o,a,l,u,c){He(t,c++,s),++r[256];for(var d=qi(r,15),h=d[0],p=d[1],v=qi(n,15),m=v[0],g=v[1],y=ho(h),_=y[0],b=y[1],k=ho(m),$=k[0],S=k[1],A=new Ee(19),P=0;_.length>P;++P)A[31&_[P]]++;for(P=0;$.length>P;++P)A[31&$[P]]++;for(var R=qi(A,7),B=R[0],V=R[1],T=19;T>4&&!B[uo[T-1]];--T);var W,F,j,q,K=u+5<<3,H=es(r,yt)+es(n,oi)+o,re=es(r,h)+es(n,m)+o+14+3*T+es(A,B)+(2*A[16]+3*A[17]+7*A[18]);if(H>=K&&re>=K)return Cr(t,c,e.subarray(l,l+u));if(He(t,c,1+(H>re)),c+=2,H>re){W=vs(h,p),F=h,j=vs(m,g),q=m;var ce=vs(B,V);for(He(t,c,b-257),He(t,c+5,S-1),He(t,c+10,T-4),c+=14,P=0;T>P;++P)He(t,c+3*P,B[uo[P]]);c+=3*T;for(var ae=[_,$],Ae=0;2>Ae;++Ae){var _e=ae[Ae];for(P=0;_e.length>P;++P)He(t,c,ce[he=31&_e[P]]),c+=B[he],he>15&&(He(t,c,_e[P]>>>5&127),c+=_e[P]>>>12)}}else W=ah,F=yt,j=lh,q=oi;for(P=0;a>P;++P)if(i[P]>255){var he;Zt(t,c,W[257+(he=i[P]>>>18&31)]),c+=F[he+257],he>7&&(He(t,c,i[P]>>>23&31),c+=tn[he]);var me=31&i[P];Zt(t,c,j[me]),c+=q[me],me>3&&(Zt(t,c,i[P]>>>5&8191),c+=sn[me])}else Zt(t,c,W[i[P]]),c+=F[i[P]];return Zt(t,c,W[256]),c+F[256]},uh=new zt([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),ch=(function(){for(var e=new zt(256),t=0;256>t;++t){for(var s=t,i=9;--i;)s=(1&s&&3988292384)^s>>>1;e[t]=s}return e})(),Hi=function(e,t,s){for(;s;++t)e[t]=s,s>>>=8};function dh(e,t){t===void 0&&(t={});var s=(function(){var d=4294967295;return{p(h){for(var p=d,v=0;h.length>v;++v)p=ch[255&p^h[v]]^p>>>8;d=p},d(){return 4294967295^d}}})(),i=e.length;s.p(e);var r,n,o,a,l,u=(a=10+((r=t).filename&&r.filename.length+1||0),l=8,(function(d,h,p,v,m,g){var y=d.length,_=new Oe(v+y+5*(1+Math.floor(y/7e3))+m),b=_.subarray(v,_.length-m),k=0;if(!h||8>y)for(var $=0;y>=$;$+=65535){var S=$+65535;y>S?k=Cr(b,k,d.subarray($,S)):(b[$]=g,k=Cr(b,k,d.subarray($,y)))}else{for(var A=uh[h-1],P=A>>>13,R=8191&A,B=(1<<p)-1,V=new Ee(32768),T=new Ee(B+1),W=Math.ceil(p/3),F=2*W,j=function(gi){return(d[gi]^d[gi+1]<<W^d[gi+2]<<F)&B},q=new zt(25e3),K=new Ee(288),H=new Ee(32),re=0,ce=0,ae=($=0,0),Ae=0,_e=0;y>$;++$){var he=j($),me=32767&$,Ye=T[he];if(V[me]=Ye,T[he]=me,$>=Ae){var bt=y-$;if((re>7e3||ae>24576)&&bt>423){k=po(d,b,0,q,K,H,ce,ae,_e,$-_e,k),ae=re=ce=0,_e=$;for(var xe=0;286>xe;++xe)K[xe]=0;for(xe=0;30>xe;++xe)H[xe]=0}var Le=2,lt=0,xu=R,Xe=me-Ye&32767;if(bt>2&&he==j($-Xe))for(var $u=Math.min(P,bt)-1,ku=Math.min(32767,$),Eu=Math.min(258,bt);ku>=Xe&&--xu&&me!=Ye;){if(d[$+Le]==d[$+Le-Xe]){for(var Qe=0;Eu>Qe&&d[$+Qe]==d[$+Qe-Xe];++Qe);if(Qe>Le){if(Le=Qe,lt=Xe,Qe>$u)break;var Su=Math.min(Xe,Qe-2),on=0;for(xe=0;Su>xe;++xe){var vi=$-Xe+xe+32768&32767,an=vi-V[vi]+32768&32767;an>on&&(on=an,Ye=vi)}}}Xe+=(me=Ye)-(Ye=V[me])+32768&32767}if(lt){q[ae++]=268435456|Pr[Le]<<18|co[lt];var ln=31&Pr[Le],un=31&co[lt];ce+=tn[ln]+sn[un],++K[257+ln],++H[un],Ae=$+Le,++re}else q[ae++]=d[$],++K[d[$]]}}k=po(d,b,g,q,K,H,ce,ae,_e,$-_e,k)}return Kl(_,0,v+Jl(k)+m)})(n=e,(o=t).level==null?6:o.level,o.mem==null?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(n.length)))):12+o.mem,a,l,!0)),c=u.length;return(function(d,h){var p=h.filename;if(d[0]=31,d[1]=139,d[2]=8,d[8]=2>h.level?4:h.level==9?2:0,d[9]=3,h.mtime!=0&&Hi(d,4,Math.floor(new Date(h.mtime||Date.now())/1e3)),p){d[3]=8;for(var v=0;p.length>=v;++v)d[v+10]=p.charCodeAt(v)}})(u,t),Hi(u,c-8,s.d()),Hi(u,c-4,i),u}const hh=!!Rr||!!ys,Yl=new WeakMap,Xl="text/plain";let Bi=0,zs=!1;const Ql=(e,t)=>{const[s,i]=e.split("#"),[r,n]=s.split("?");if(!n)return e;const o=n.split("&").filter(a=>a.split("=")[0]!==t).join("&");return`${r}${o?`?${o}`:""}${i?`#${i}`:""}`},pi=(e,t,s=!0)=>{var i;const[r,n]=e.split("?"),o=f({},t),a=(i=n?.split("&").map(u=>{var c;const[d,h]=u.split("="),p=s&&(c=o[d])!==null&&c!==void 0?c:h;return delete o[d],`${d}=${p}`}))!==null&&i!==void 0?i:[],l=(function(u,c="&"){let d,h;const p=[];return J(u,function(v,m){x(v)||x(m)||m==="undefined"||(d=encodeURIComponent((g=>g instanceof File)(v)?v.name:v.toString()),h=encodeURIComponent(m),p[p.length]=h+"="+d)}),p.join(c)})(o);return l&&a.push(l),a.length>0?`${r}?${a.join("&")}`:r},zi=e=>{if(e.lr)return e.lr;const{data:t,compression:s}=e;if(!t)return;if(s===Pe.GZipJS){const r=dh((function(n){var o=n.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(n);for(var a=new Oe(n.length+(n.length>>>1)),l=0,u=function(p){a[l++]=p},c=0;o>c;++c){if(l+5>a.length){var d=new Oe(l+8+(o-c<<1));d.set(a),a=d}var h=n.charCodeAt(c);128>h?u(h):2048>h?(u(192|h>>>6),u(128|63&h)):h>55295&&57344>h?(u(240|(h=65536+(1047552&h)|1023&n.charCodeAt(++c))>>>18),u(128|h>>>12&63),u(128|h>>>6&63),u(128|63&h)):(u(224|h>>>12),u(128|h>>>6&63),u(128|63&h))}return Kl(a,0,l)})(Mt(t)),{mtime:0});return{contentType:Xl,body:r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength),estimatedSize:r.byteLength}}if(s===Pe.Base64){const r=(function(o){return o&&btoa(encodeURIComponent(o).replace(/%([0-9A-F]{2})/g,(a,l)=>String.fromCharCode(parseInt(l,16))))})(Mt(t)),n=(o=>"data="+encodeURIComponent(typeof o=="string"?o:Mt(o)))(r);return{contentType:"application/x-www-form-urlencoded",body:n,estimatedSize:new Blob([n]).size}}const i=Mt(t);return{contentType:"application/json",body:i,estimatedSize:new Blob([i]).size}},Zl=e=>{const t=()=>e.transport==="sendBeacon"?{url:pi(e.url,{compression:Pe.Base64}),encodedBody:zi(f(f({},e),{},{compression:Pe.Base64,lr:void 0}))}:{url:Ql(e.url,"compression"),encodedBody:zi(f(f({},e),{},{compression:void 0,lr:void 0}))};let s;try{s=zi(e)}catch(r){if(Pn(e.compression,Ht(e.url,"compression")))return E.error("Failed to gzip request body, sending uncompressed payload",r),t();throw r}return s&&Pn(e.compression,Ht(e.url,"compression"))&&!((i=s.body)instanceof ArrayBuffer?ur(new Uint8Array(i)):ArrayBuffer.isView(i)&&ur(new Uint8Array(i.buffer,i.byteOffset,i.byteLength)))?(zs=!0,t()):{url:e.url,encodedBody:s};var i},eu=e=>{try{return Zl(e)}catch(s){var t;return E.error(s),void((t=e.callback)===null||t===void 0||t.call(e,{statusCode:0,error:s}))}},ph=(function(){var e=Q(function*(t){const s=yield(function(r){return cr.apply(this,arguments)})(Mt(t.data),$e.DEBUG,{rethrow:!0});if(!s)return t;const i=yield s.arrayBuffer();return f(f({},t),{},{lr:{contentType:Xl,body:i,estimatedSize:i.byteLength}})});return function(t){return e.apply(this,arguments)}})(),fh=/Failed to fetch|NetworkError|Load failed/i,tu=e=>e?.name==="TypeError"&&fh.test(e?.message||""),su=e=>{try{const t=(function(s,i=Date.now(),r=3e5){if(typeof s!="string"||!s)return;const n=s.trim(),o=/^\d+\s*,/.test(n)?n.slice(0,n.indexOf(",")).trim():n;if(/^\d+$/.test(o)){const u=1e3*Math.min(Number(o),r/1e3);return u>0?u:void 0}if(!/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun)[a-z]*[ ,]/.test(o))return;const a=/^\w{3} \w{3} /.test(o)?o+" GMT":o,l=Date.parse(a)-i;return Number.isFinite(l)&&l>0?Math.min(l,r):void 0})(e());return x(t)?void 0:Math.min(t,3e4)}catch{return}},iu=e=>{const t=eu(e);if(!t)return;const s=new Rr;Yl.set(s,!0);const{url:i,encodedBody:r}=t;s.open(e.method||"GET",i,!0);const{contentType:n,body:o}=r??{};J(e.headers,function(a,l){s.setRequestHeader(l,a)}),n&&s.setRequestHeader("Content-Type",n),e.timeout&&(s.timeout=e.timeout),s.onreadystatechange=()=>{if(s.readyState===4){var a;const l={statusCode:s.status,text:s.responseText};if(s.status===200)try{l.json=JSON.parse(s.responseText)}catch{}(a=e.callback)===null||a===void 0||a.call(e,l,su(()=>s.getResponseHeader("Retry-After")))}},s.send(o)},ru=e=>{const t=eu(e);if(!t)return;const{url:s,encodedBody:i}=t,{contentType:r,body:n,estimatedSize:o}=i??{},a=new Headers;J(e.headers,function(v,m){a.append(m,v)}),r&&a.append("Content-Type",r);let l=null,u=!1;if(cn){const v=new cn;l={signal:v.signal,timeout:setTimeout(()=>{u=!0;try{v.abort(Fa("AbortError","PostHog request timed out"+((m=e.timeout)?` after ${m}ms`:"")))}catch(g){d(g)}var m},e.timeout)}}let c=!1;const d=v=>{var m;c||(c=!0,u&&v?.name==="AbortError"||tu(v)?E.warn(v):E.error(v),(m=e.callback)===null||m===void 0||m.call(e,{statusCode:0,error:v}))};let h=0;const p=()=>{Bi-=h,h=0,l&&clearTimeout(l.timeout)};try{const v=f({method:e?.method||"GET",headers:a,referrerPolicy:"strict-origin",body:n,signal:l?.signal},e.fetchOptions),m=o??(x(n)?0:void 0);v.keepalive=v.method==="POST"&&!e.kl&&v.keepalive!==!1&&v.body===n&&!x(m)&&m>=0&&52428.8>Bi+m,v.keepalive&&(h=m,Bi+=h),ys(s,v).then(g=>g.text().then(y=>{var _;if(c)return;const b={statusCode:g.status,text:y};if(g.status===200)try{b.json=JSON.parse(y)}catch(k){E.error(k)}c=!0,p(),(_=e.callback)===null||_===void 0||_.call(e,b,su(()=>g.headers.get("Retry-After")))})).catch(g=>{p(),d(g)}).finally(p)}catch(v){p(),d(v)}},Fr=e=>{try{var t;const{url:s,encodedBody:i}=Zl(e),{contentType:r,body:n,estimatedSize:o}=i??{};if(!n)return;const a=n instanceof Blob?n:new Blob([n],{type:r});if(pe.sendBeacon(s,a))return;const l=O(e.data)?e.data:(t=e.data)===null||t===void 0?void 0:t.batch;if(O(l)&&l.length>1&&(o??0)>16384){const u=Math.ceil(l.length/2),c=d=>O(e.data)?d:f(f({},e.data),{},{batch:d});return Fr(f(f({},e),{},{data:c(l.slice(0,u))})),void Fr(f(f({},e),{},{data:c(l.slice(u))}))}E.warn(`Beacon of ~${o??0} bytes was rejected by the browser, falling back to ${ys?"fetch":"XHR"}`),ys?ru(f(f({},e),{},{kl:!0})):iu(e)}catch(s){E.warn("Beacon send failed",s)}},fo=(e,t,s,i)=>{const r=i==="query"?t==="POST"?"sent_at":"_":void 0;return pi(s===Pe.GZipJS?Ql(e,"compression"):e,f(f({},r?{[r]:Date.now().toString()}:{}),s===Pe.GZipJS?{}:{compression:s}))},vh=(()=>{const e=[];return ys&&e.push({transport:"fetch",method:ru}),Rr&&e.push({transport:"XHR",method:iu}),pe?.sendBeacon&&e.push({transport:"sendBeacon",method:Fr}),e})();let nu=!hh&&be?.indexOf("MSIE")===-1&&be?.indexOf("Mozilla")===-1;function ou(e,t,s){var i,r,n;s&&(t=f(f({},t),{},{callback:o=>s(o)})),e.__loaded?nu?e.__request_queue.push(t):e.rateLimiter.isServerRateLimited(t.batchKey)?t.fireCallbackOnDrop&&((r=t.callback)===null||r===void 0||r.call(t,{statusCode:429})):(t.transport=t.transport||e.config.api_transport,t.headers=f(f({},e.config.request_headers),t.headers),t.compression=t.compression==="best-available"?(i=e.compression)!==null&&i!==void 0?i:t.compressionFallback:t.compression,(x(e.config.disable_beacon)?e.config.__preview_disable_beacon:e.config.disable_beacon)&&(t.disableTransport=["sendBeacon"]),t.fetchOptions=t.fetchOptions||e.config.fetch_options,((o,a)=>{var l,u,c;const d=f(f({},o),{},{callback:a??(g=>{var y;return(y=o.callback)===null||y===void 0?void 0:y.call(o,g)})});d.timeout=d.timeout||6e4;const h=(l=d.transport)!==null&&l!==void 0?l:"fetch";h==="sendBeacon"&&x(d.compression)&&d.data&&(d.compression=Pe.Base64),d.method==="POST"&&d.data&&(d.timestampMode==="capture-body"?d.data=(g=>{var y,_;const b=(O(g)?g:[g]).map($=>f(f({},$),$.timestamp instanceof Date&&!isNaN($.timestamp.getTime())?{timestamp:$.timestamp.toISOString()}:{})),k=b[0];return{api_key:(y=k==null||(_=k.properties)===null||_===void 0?void 0:_.token)!==null&&y!==void 0?y:k?.token,batch:b,sent_at:new Date().toISOString()}})(d.data):d.timestampMode==="body"&&(d.data=((g,y=new Date().toISOString())=>O(g)?g.map(_=>f(f({},_),{},{sent_at:y})):f(f({},g),{},{sent_at:y}))(d.data))),d.url=fo(d.url,d.method,d.compression,d.timestampMode);const p=vh.filter(g=>!d.disableTransport||!g.transport||!d.disableTransport.includes(g.transport)),v=(u=(c=(function(g,y){for(let _=0;g.length>_;_++)if(y(g[_]))return g[_]})(p,g=>g.transport===h))===null||c===void 0?void 0:c.method)!==null&&u!==void 0?u:p[0].method;if(!v)throw new Error("No available transport method");const m=g=>{try{v(g)}catch(_){var y;tu(_)?E.warn(_):E.error(_),(y=d.callback)===null||y===void 0||y.call(d,{statusCode:0,error:_})}};h!=="sendBeacon"&&!d.preferSyncCompression&&d.data&&d.compression===Pe.GZipJS&&Au&&typeof Promise<"u"&&!zs?ph(d).then(g=>{m(g)}).catch(g=>{if(An(g))return zs=!0,void m(f(f({},d),{},{compression:void 0,url:fo(o.url,o.method,void 0,o.timestampMode)}));(y=>{if(!y||typeof y!="object")return!1;const _="name"in y?String(y.name):"";return An(y)||_===Da})(g)&&(zs=!0),m(d)}):m(d)})(t,(o,a)=>{var l,u,c;e.rateLimiter.checkForLimiting(o),400>o.statusCode||(l=(u=e.config).on_request_error)===null||l===void 0||l.call(u,o),s?s(o,a):(c=t.callback)===null||c===void 0||c.call(t,o)})):t.fireCallbackOnDrop&&((n=t.callback)===null||n===void 0||n.call(t,{statusCode:0}))}var gh=class{constructor(e,t){this.Zu=!0,this.Ju=[],this.Ku=qe(t?.flush_interval_ms||3e3,250,5e3,E.createLogger("flush interval"),3e3),this.Xu=e}enqueue(e){this.Ju.push(e),this.Yu||this.tc()}unload(){this.ec();const e=this.Ju.length>0?this.nc():{},t=Object.values(e);[...t.filter(s=>s.url.indexOf("/e")===0),...t.filter(s=>s.url.indexOf("/e")!==0)].map(s=>{this.sc(f(f({},s),{},{callback:void 0}),"sendBeacon")})}enable(){this.Zu=!1,this.tc()}tc(){this.Zu||(this.Yu=setTimeout(()=>{this.ec(),this.rc()},this.Ku))}rc(){if(this.Ju.length>0){const e=this.nc();for(const t in e)this.sc(e[t])}}sc(e,t){try{this.Xu(e,t)}catch(s){E.error(s)}}ec(){clearTimeout(this.Yu),this.Yu=void 0}nc(){const e={},t={};J(this.Ju,s=>{var i;const r=s,n=((r?r.batchKey:null)||r.url)+(r.batchGroup?`:${r.batchGroup}`:"");x(e[n])&&(e[n]=f(f({},r),{},{data:[],callback:void 0,fireCallbackOnDrop:void 0}),t[n]=[]),(i=e[n].data)===null||i===void 0||i.push(r.data),r.callback&&t[n].push(r.callback)});for(const s in t){const i=t[s];i.length&&(e[s].callback=r=>{for(const n of i)n(r)})}return this.Ju=[],e}};const _h=["retriesPerformedSoFar"];var mh=class{constructor(e){this._instance=e,this.oc=!1,this.ac=3e3,this.Ju=[],this.Ju=[],this.lc=!0,this.resume()}resume(){if(!x(w)&&"onLine"in w.navigator){if(this.lc=w.navigator.onLine,this.uc)return;this.uc=()=>{this.lc=!0,this.rc()},this.cc=()=>{this.lc=!1},U(w,"online",this.uc),U(w,"offline",this.cc)}}get length(){return this.Ju.length}retriableRequest(e,t){let{retriesPerformedSoFar:s}=e,i=Na(e,_h);ze(s)&&(i.url=pi(i.url,{retry_count:s})),ou(this._instance,t?f(f({},i),{},{transport:t}):i,(r,n)=>{var o;if(r.statusCode!==200&&(400>r.statusCode||r.statusCode>=500)){if((r.statusCode===0?3:10)>(s??0))return void this.Ls(f({retriesPerformedSoFar:s},i),n);r.statusCode===0&&E.warn(`Request failed before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped retrying after ${s??0} retries.`)}(o=i.callback)===null||o===void 0||o.call(i,r)})}Ls(e,t){const s=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=s+1;const i=Math.max((function(o){const a=3e3*Math.pow(2,o),l=a/2,u=Math.min(18e5,a),c=(Math.random()-.5)*(u-l);return Math.ceil(u+c)})(s),t??0),r=Date.now()+i;this.Ju.push({retryAt:r,requestOptions:e});let n=`Enqueued failed request for retry in ${i}`;navigator.onLine||(n+=" (Browser is offline)"),E.warn(n),this.oc||(this.oc=!0,this.hc())}hc(){if(this.dc&&clearTimeout(this.dc),this.Ju.length===0)return this.oc=!1,void(this.dc=void 0);this.dc=setTimeout(()=>{this.lc&&this.Ju.length>0&&this.rc(),this.hc()},this.ac)}rc(){const e=Date.now(),t=[],s=this.Ju.filter(i=>e>i.retryAt||(t.push(i),!1));if(this.Ju=t,s.length>0)for(const{requestOptions:i}of s)this.retriableRequest(i)}unload(){this.dc&&(clearTimeout(this.dc),this.dc=void 0),this.oc=!1,x(w)||(this.uc&&(w.removeEventListener("online",this.uc),this.uc=void 0),this.cc&&(w.removeEventListener("offline",this.cc),this.cc=void 0));for(const{requestOptions:e}of this.Ju)try{this._instance._send_request(f(f({},e),{},{callback:O(e.data)?void 0:e.callback,transport:"sendBeacon"}))}catch(t){E.error(t)}this.Ju=[]}},yh=class{constructor(e){this._instance=e,this.vc=()=>{var t,s,i,r;this.fc||(this.fc={});const n=this.scrollElement(),o=this.scrollY(),a=n?Math.max(0,n.scrollHeight-n.clientHeight):0,l=o+(n?.clientHeight||0),u=n?.scrollHeight||0;this.fc.lastScrollY=Math.ceil(o),this.fc.maxScrollY=Math.max(o,(t=this.fc.maxScrollY)!==null&&t!==void 0?t:0),this.fc.maxScrollHeight=Math.max(a,(s=this.fc.maxScrollHeight)!==null&&s!==void 0?s:0),this.fc.lastContentY=l,this.fc.maxContentY=Math.max(l,(i=this.fc.maxContentY)!==null&&i!==void 0?i:0),this.fc.maxContentHeight=Math.max(u,(r=this.fc.maxContentHeight)!==null&&r!==void 0?r:0)}}get gc(){return this._instance.config.scroll_root_selector}getContext(){return this.fc}resetContext(){const e=this.fc;return this.fc=void 0,setTimeout(this.vc,0),e}startMeasuringScrollPosition(){U(w,"scroll",this.vc,{capture:!0}),U(w,"scrollend",this.vc,{capture:!0}),U(w,"resize",this.vc)}scrollElement(){if(this.gc){const s=O(this.gc)?this.gc:[this.gc];for(const i of s){var e;const r=w==null||(e=w.document)===null||e===void 0?void 0:e.querySelector(i);if(r)return r}return}var t;return w==null||(t=w.document)===null||t===void 0?void 0:t.documentElement}mc(e){var t,s;const i=e==="y"?"scrollTop":"scrollLeft";if(this.gc){const r=this.scrollElement();return r&&r[i]||0}return w?e==="y"?w.scrollY||w.pageYOffset||((t=w.document)===null||t===void 0||(t=t.documentElement)===null||t===void 0?void 0:t.scrollTop)||0:w.scrollX||w.pageXOffset||((s=w.document)===null||s===void 0||(s=s.documentElement)===null||s===void 0?void 0:s.scrollLeft)||0:0}scrollY(){return this.mc("y")}scrollX(){return this.mc("x")}};const bh=e=>Hl(e?.config.mask_personal_data_properties,e?.config.custom_personal_data_properties,e?.config.disable_capture_url_hashes);var vo=class{constructor(e,t,s,i){this.qe=r=>{const n=this.yc();if(n&&n.sessionId===r)return;const o={sessionId:r,props:this.bc(this._instance)};this._c.register({[wr]:o})},this._instance=e,this.wc=t,this._c=s,this.bc=i||bh,this.wc.onSessionId(this.qe)}yc(){return this._c.props[wr]}getSetOnceProps(){var e;const t=(e=this.yc())===null||e===void 0?void 0:e.props;return t?"r"in t?Bl(t,this._instance.config.disable_capture_url_hashes):{$referring_domain:t.referringDomain,$pathname:t.initialPathName,utm_source:t.utm_source,utm_campaign:t.utm_campaign,utm_medium:t.utm_medium,utm_content:t.utm_content,utm_term:t.utm_term}:{}}getSessionProps(){const e={};return J(Yr(this.getSetOnceProps()),(t,s)=>{s==="$current_url"&&(s="url"),e[`$session_entry_${ir(s)}`]=t}),e}},ai=class{on(e,t){return this.bo[e]||(this.bo[e]=[]),this.bo[e].push(t),()=>{this.bo[e]=this.bo[e].filter(s=>s!==t)}}emit(e,t){for(const s of this.bo[e]||[])s(t);for(const s of this.bo["*"]||[])s(e,t)}constructor(){this.bo={}}};const St=te("[SessionId]"),go=864e5;var _o=class{on(e,t){return this.kc.on(e,t)}constructor(e,t,s){var i;if(this.Sc=null,this.xc=null,this.$c=[],this.Cc=void 0,this.Tc=!1,this.kc=new ai,this.Ic=(n,o)=>!(!ze(n)||!ze(o))&&Math.abs(n-o)>this.sessionTimeoutMs,!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(e.config.cookieless_mode==="always")throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this.Ar=e.config,this._c=e.persistence,this.je=void 0,this.Xt=void 0,this._sessionStartTimestamp=null,this.Mc=void 0,this._sessionActivityTimestamp=null,this.Ec=t||Re,this.Pc=s||Re;const r=this.Ar.persistence_name||this.Ar.token;if(this._sessionTimeoutMs=1e3*qe(this.Ar.session_idle_timeout_seconds||1800,60,36e3,St.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.Rc(),this.Ac="ph_"+r+"_window_id",this.Fc="ph_"+r+"_primary_window_exists",this.Oc()){const n=X.Lt(this.Ac),o=X.Lt(this.Fc);n&&!o?this.je=n:X.Pt(this.Ac),X.At(this.Fc,!0)}!((i=this.Ar.bootstrap)===null||i===void 0)&&i.sessionID&&this.setBootstrapSessionId(this.Ar.bootstrap.sessionID),this.Dc()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return x(this.$c)&&(this.$c=[]),this.$c.push(e),this.Xt&&e(this.Xt,this.je),()=>{this.$c=this.$c.filter(t=>t!==e)}}Oc(){return this.Ar.persistence!=="memory"&&!this._c.hi&&X.Et()}Lc(e){e!==this.je&&(this.je=e,this.Oc()&&X.At(this.Ac,e))}Nc(){return this.je?this.je:this.Oc()?X.Lt(this.Ac):null}qc(e){const t=this.Sc;return!se(t)&&!se(e)&&5e3>Math.abs(e-t)}jc(e,t,s){const i=t!==this._sessionActivityTimestamp,r=!(e!==this.Xt||s!==this._sessionStartTimestamp);this._sessionStartTimestamp=s,this._sessionActivityTimestamp=t,this.Xt=e,r&&!i||r&&this.qc(t)||(this.Sc=t,this._c.register({[Ft]:[t,e,s]}))}Bc(){var e;const t=(e=this.Ar)===null||e===void 0?void 0:e.persistence_save_debounce_ms;return ze(t)&&t>0}zc(){this.Bc()?this._c.refreshKey(Ft):(this._c.flush(),this._c.load())}Hc(){var e;if(se(this._sessionActivityTimestamp)||this._sessionActivityTimestamp===this.Sc)return;this.zc();const[,t,s]=this.Uc();t===this.Xt&&s===this._sessionStartTimestamp&&(this.Sc=this._sessionActivityTimestamp,this._c.register({[Ft]:[this._sessionActivityTimestamp,(e=this.Xt)!==null&&e!==void 0?e:null,this._sessionStartTimestamp]}),this._c.flush())}Wc(){const[e]=this.Uc(),t=ze(e)?e:0,s=ze(this._sessionActivityTimestamp)?this._sessionActivityTimestamp:0;return Math.max(t,s)}Vc(e){return this.zc(),this.Ic(e,this.Wc())}Uc(){const e=this._c.props[Ft];return O(e)&&e.length===2&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this.Sc=null,this.Mc=void 0,clearTimeout(this.Gc),this.Gc=void 0,this.jc(null,null,null)}setBootstrapSessionId(e,t=!1){const s=((i,r=new Date().getTime())=>{try{const n=(o=>{const a=o.replace(/-/g,"");if(a.length!==32)throw new Error("Not a valid UUID");if(a[12]!=="7")throw new Error("Not a UUIDv7");return parseInt(a.substring(0,12),16)})(i);return n>r+6e4?void St.error("Bootstrap sessionID cannot be in the future"):n}catch(n){return void St.error("Invalid sessionID in bootstrap",n)}})(e);return!x(s)&&(t?this.Mc={sessionId:e,sessionStartTimestamp:s}:this.jc(e,new Date().getTime(),s),!0)}destroy(){this.Tc=!0,this.Hc(),clearTimeout(this.Gc),this.Gc=void 0,this.Cc&&w&&(w.removeEventListener(si,this.Cc,{capture:!1}),this.Cc=void 0),this.$c=[]}Dc(){this.Cc=()=>{this.Hc(),this.Oc()&&X.Pt(this.Fc)},U(w,si,this.Cc,{capture:!1})}checkAndGetSessionAndWindowId(e=!1,t=null,s=!1){if(this.Ar.cookieless_mode==="always")throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');const i=t||new Date().getTime(),r=this.Xt;if(s)this.xc=i;else if(se(this.xc)||this.xc>i||i-this.xc>=1e3){var n,o;(n=(o=this._c).syncCookieProperties)===null||n===void 0||n.call(o),this.xc=i}let[,a,l]=this.Uc();const u=!x(r)&&a!==r,c=this.Wc();let d=this.Nc();const h=this.Mc,p=!!h&&(h.sessionStartTimestamp>i+6e4||i-h.sessionStartTimestamp>go),v=h?p:ze(l)&&Math.abs(i-l)>go;let m=!1,g=u,y=!a||!!h;const _=a;let b=!y&&!e&&this.Ic(i,c);if(b&&(b=this.Vc(i),b||St.info("cross-tab refresh kept the session alive",{sessionId:a}),[,a,l]=this.Uc(),b||(y=!a||!!h)),y||b||v){g=!1;const A=h&&!p;a=A?h.sessionId:this.Ec(),d=this.Pc(),St.info("new session ID assigned",{sessionId:a,windowId:d,bootstrapped:!!A,changeReason:{noSessionId:y,activityTimeout:b,sessionPastMaximumLength:v}}),l=A?h.sessionStartTimestamp:i,this.Mc=void 0,m=!0}else d||(d=this.Pc(),m=!0),g=g||a!==_,g&&(St.info("adopted cross-tab session id",{sessionId:a,windowId:d}),m=!0);const k=ze(c)&&e&&!v?c:i,$=ze(l)?l:new Date().getTime();this.Lc(d),this.jc(a,k,$),e||this.Rc();const S={noSessionId:y,activityTimeout:b,sessionPastMaximumLength:v,crossTabAdoption:g};return m&&this.$c.forEach(A=>A(a,d,S)),{sessionId:a,windowId:d,sessionStartTimestamp:$,changeReason:m?S:void 0,lastActivityTimestamp:c}}Rc(){this.Tc||(clearTimeout(this.Gc),this.Gc=setTimeout(()=>{if(!this.Tc)if(this.Vc(new Date().getTime())){const e=this.Xt;this.resetSessionId(),this.kc.emit("forcedIdleReset",{idleSessionId:e})}else this.Rc()},1.1*this.sessionTimeoutMs))}};const mo=Object.freeze(["2026-08-30","2026-08-29","2026-06-25","2026-05-30","2026-01-30","2025-11-30","2025-05-24"]),au=function(e,t){if(!e)return!1;const s=e.userAgent;if(s&&hn(s,t))return!0;try{const i=e?.userAgentData;if(i?.brands&&i.brands.some(r=>hn(r?.brand,t)))return!0}catch{}return!!e.webdriver};function lu(){return(lu=Q(function*(){const e=pe?.userAgentData;if(e?.getHighEntropyValues)try{const t=yield e.getHighEntropyValues(["model"]),s=t?.model;return N(s)&&s.length>0?s:void 0}catch(t){return void E.info("Unable to resolve $device_model from userAgentData.getHighEntropyValues",t)}})).apply(this,arguments)}function wh(e,t){let s=`$survey_${t}/${e.id}`;return e.current_iteration&&e.current_iteration>0&&(s=`$survey_${t}/${e.id}/${e.current_iteration}`),s}function uu(e){var t;return!!(!((t=e.conditions)===null||t===void 0||(t=t.events)===null||t===void 0||(t=t.values)===null||t===void 0)&&t.length)}const li=(e,t)=>{if(!(s=>{try{new RegExp(s)}catch{return!1}return!0})(t))return!1;try{return new RegExp(t).test(e)}catch{return!1}},Ms=e=>e.toLowerCase(),cu={exact:(e,t)=>t.some(s=>e.some(i=>s===i)),is_not:(e,t)=>t.every(s=>e.every(i=>s!==i)),regex:(e,t)=>t.some(s=>e.some(i=>li(s,i))),not_regex:(e,t)=>t.every(s=>e.every(i=>!li(s,i))),icontains:(e,t)=>t.map(Ms).some(s=>e.map(Ms).some(i=>s.includes(i))),not_icontains:(e,t)=>t.map(Ms).every(s=>e.map(Ms).every(i=>!s.includes(i))),gt:(e,t)=>t.some(s=>{const i=parseFloat(s);return!isNaN(i)&&e.some(r=>i>parseFloat(r))}),lt:(e,t)=>t.some(s=>{const i=parseFloat(s);return!isNaN(i)&&e.some(r=>i<parseFloat(r))})};function du(e,t){return!e||Object.entries(e).every(([s,i])=>{const r=t?.[s];if(r==null)return!1;const n=cu[i.operator];return!!n&&n(i.values.map(String),[String(r)])})}function Vi(e,t,s){return Mt({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:s})}const Ir="custom",yo="i.posthog.com",xh=/^\/static\//,$h=["/s/","/e/","/i/"];var kh=class{constructor(e){this.Qc={},this.instance=e}get apiHost(){const e=this.instance.config.api_host.trim().replace(/\/$/,"");return e==="https://app.posthog.com"?"https://us.i.posthog.com":e}get flagsApiHost(){const e=this.instance.config.flags_api_host;return e?e.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var e;let t=(e=this.instance.config.ui_host)===null||e===void 0?void 0:e.replace(/\/$/,"");return t||(t=this.apiHost.replace(`.${yo}`,".posthog.com")),t==="https://app.posthog.com"?"https://us.posthog.com":t}get region(){return this.Qc[this.apiHost]||(this.Qc[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":Ir),this.Qc[this.apiHost]}Zc(e){if(!xh.test(e))return;const t=this.instance.config.asset_host;return typeof t=="string"&&t.trim().replace(/\/$/,"")||void 0}Jc(e){const t=Ke(e);return t?t.protocol+"//"+t.host+t.pathname:void 0}Kc(e,t,s){if(e==="ui")return s;let i=s;const r=this.instance.config.rewriteRequestPath;if(r){var n;const o=((n=Ke(s))===null||n===void 0?void 0:n.href)||s;i=r(new URL(o)).toString()}if(r&&e==="api"&&$h.some(o=>t.indexOf(o)===0)){const o=this.Jc(i);if(o){const a=this.apiHost;let l=this.Xc;l?.apiHost===a&&l.rewriteRequestPath===r||(l={apiHost:a,rewriteRequestPath:r,urls:new Set},this.Xc=l),l.urls.add(o)}}return i}isIngestionEndpoint(e){const t=this.Xc,s=this.Jc(e);return t?.apiHost===this.apiHost&&t.rewriteRequestPath===this.instance.config.rewriteRequestPath&&!!s&&t.urls.has(s)}endpointFor(e,t=""){if(t&&(t=t[0]==="/"?t:`/${t}`),e==="ui")return this.Kc(e,t,this.uiHost+t);if(e==="flags")return this.Kc(e,t,this.flagsApiHost+t);if(e==="assets"){const i=this.Zc(t);if(i)return this.Kc(e,t,`${i}${t}`)}if(this.region===Ir)return this.Kc(e,t,this.apiHost+t);const s=yo+t;switch(e){case"assets":return this.Kc(e,t,`https://${this.region}-assets.${s}`);case"api":return this.Kc(e,t,`https://${this.region}.${s}`)}}};const G=te("[Surveys]"),hu=e=>{try{const t=(s=>((i,r)=>`seenSurvey_${(function(n){return n.current_iteration&&n.current_iteration>0?`${n.id}_${n.current_iteration}`:n.id})(r)}`)(0,s))(e);if(localStorage.getItem(t))return;localStorage.setItem(t,"true")}catch(t){G.error("Failed to persist survey seen state",t)}},Eh=[Ni.Popover,Ni.Widget,Ni.API],Sh={ignoreConditions:!1,ignoreDelay:!1,displayType:Sr.Popover},Ph=te("[PostHog ExternalIntegrations]"),Ah={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};var Ch=class{constructor(e){this._instance=e}Ml(e,t){var s,i;(s=M.__PosthogExtensions__)===null||s===void 0||(i=s.loadExternalDependency)===null||i===void 0||i.call(s,this._instance,e,r=>{if(r)return Ph.error("failed to load script",r);t()})}startIfEnabledOrStop(){var e;for(const[r,n]of Object.entries((e=this._instance.config.integrations)!==null&&e!==void 0?e:{})){var t,s,i;n&&!(!((t=M.__PosthogExtensions__)===null||t===void 0||(t=t.integrations)===null||t===void 0)&&t[r])&&this.Ml(Ah[r],()=>{var o;(o=M.__PosthogExtensions__)===null||o===void 0||(o=o.integrations)===null||o===void 0||(o=o[r])===null||o===void 0||o.start(this._instance)}),!n&&(!((s=M.__PosthogExtensions__)===null||s===void 0||(s=s.integrations)===null||s===void 0)&&s[r])&&((i=M.__PosthogExtensions__)===null||i===void 0||(i=i.integrations)===null||i===void 0||(i=i[r])===null||i===void 0||i.stop())}}},pu=class{constructor(e){this.disabled=e===!1;const t=D(e)?e:{};this.thresholdPx=t.threshold_px||30,this.timeoutMs=t.timeout_ms||1e3,this.clickCount=t.click_count||3,this.clicks=[]}isRageClick(e,t,s){if(this.disabled)return!1;const i=this.clicks[this.clicks.length-1];if(i&&Math.abs(e-i.x)+Math.abs(t-i.y)<this.thresholdPx&&this.timeoutMs>s-i.timestamp){if(this.clicks.push({x:e,y:t,timestamp:s}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:e,y:t,timestamp:s}];return!1}};const Or=()=>typeof window>"u"?void 0:window,ts=()=>typeof document>"u"?void 0:document,Ui="$copy_autocapture",Fh=["password","hidden","file","checkbox","button","submit","reset","image"],Ts=te("[AutoCapture]");function Wi(e,t){return t.length>e?t.slice(0,e)+"...":t}function Ih(e){if(e.previousElementSibling)return e.previousElementSibling;let t=e;do t=t.previousSibling;while(t&&!Ie(t));return t}function Oh(e,{e:t,maskAllElementAttributes:s,maskAllText:i,elementAttributeIgnoreList:r,elementsChainAsString:n,disableCaptureUrlHashes:o}){var a,l;if(!Ie(e))return{props:{}};const u=[e],c=new Set([e]);let d=e;for(;d.parentNode&&!le(d,"body")&&1e3>u.length;){if(ii(d.parentNode)){const S=d.parentNode.host;if(c.has(S))break;c.add(S),u.push(S),d=S;continue}if(!Ie(d.parentNode)||c.has(d.parentNode))break;c.add(d.parentNode),u.push(d.parentNode),d=d.parentNode}const h=t.type==="click"&&e.namespaceURI==="http://www.w3.org/2000/svg"?u.findIndex(S=>le(S,"button")||le(S,"a")):-1;h>0&&(i=i||u.slice(0,h+1).some(S=>!ot(S)||qt(S)));const p=[],v={};let m,g=!1,y=!1;if(J(u,S=>{const A=ot(S);if(le(S,"a")&&!s&&!r?.includes("href")){const P=S.getAttribute("href");g=!!(A&&P&&Dt(P))&&(o?at(P):P)}I(mt(S),"ph-no-capture")&&(y=!0),p.push((function(P,R,B,V,T=!1){const W=P.tagName.toLowerCase(),F={tag_name:W};Qr.indexOf(W)>-1&&!B&&(F.$el_text=W.toLowerCase()==="a"||W.toLowerCase()==="button"?Wi(1024,eo(P)):Wi(1024,xs(P)));const j=mt(P);R||V?.includes("class")||0>=j.length||(F.classes=j.filter(function(re){return re!==""})),J(P.attributes,function(re){var ce;if((!qt(P)||["name","id","class","aria-label"].indexOf(re.name)!==-1)&&!V?.includes(re.name)&&!R&&Dt(re.value)&&(!N(ce=re.name)||ce.substring(0,10)!=="_ngcontent"&&ce.substring(0,7)!=="_nghost")){let ae=re.value;re.name==="class"&&(ae=Xr(ae).join(" ")),F["attr__"+re.name]=Wi(1024,re.name==="href"&&T?at(ae):ae)}});let q=1,K=1,H=P;for(;H=Ih(H);)q++,H.tagName===P.tagName&&K++;return F.nth_child=q,F.nth_of_type=K,F})(S,s,i,r,o)),J((function(P){if(!ot(P))return{};const R={};return J(P.attributes,function(B){if(B.name&&B.name.indexOf("data-ph-capture-attribute")===0){const V=B.name.replace("data-ph-capture-attribute-",""),T=B.value;V&&T&&Dt(T)&&(R[V]=T)}}),R})(S),(P,R)=>{({}).hasOwnProperty.call(v,R)||(v[R]=P)})}),y)return{props:{},explicitNoCapture:y};if(h>0&&(e=u[h],p.splice(0,h)),i||(p[0].$el_text=le(e,"a")||le(e,"button")?eo(e):xs(e)),g){var _,b;p[0].attr__href=g;const S=(_=Ke(g))===null||_===void 0?void 0:_.host,A=(b=Or())===null||b===void 0||(b=b.location)===null||b===void 0?void 0:b.host;S&&A&&S!==A&&(m=g)}return{props:ee(($=t.type,{$event_type:$,$ce_version:1}),n?{}:{$elements:p},{$elements_chain:(k=p,O(k)?(function(S){return S.map(A=>{var P,R;let B="";if(A.tag_name&&(B+=A.tag_name),A.attr_class){A.attr_class.sort();for(const W of A.attr_class)B+=`.${W.replace(/"/g,"")}`}const V=f(f(f(f({},A.text?{text:A.text}:{}),{},{"nth-child":(P=A.nth_child)!==null&&P!==void 0?P:0,"nth-of-type":(R=A.nth_of_type)!==null&&R!==void 0?R:0},A.href?{href:A.href}:{}),A.attr_id?{attr_id:A.attr_id}:{}),A.attributes),T={};return Bs(V).sort(([W],[F])=>(function(j,q){return q>j?-1:j>q?1:0})(W,F)).forEach(([W,F])=>T[to(W.toString())]=to(F.toString())),B+=":",B+=Bs(T).map(([W,F])=>`${W}="${F}"`).join(""),B}).join(";")})((function(S){return S.map(A=>{var P,R;const B={text:(P=A.$el_text)===null||P===void 0?void 0:P.slice(0,400),tag_name:A.tag_name,href:(R=A.attr__href)===null||R===void 0?void 0:R.slice(0,2048),attr_class:Gd(A),attr_id:A.attr__id,nth_child:A.nth_child,nth_of_type:A.nth_of_type,attributes:{}};return Bs(A).filter(([V])=>V.indexOf("attr__")===0).forEach(([V,T])=>B.attributes[V]=T),B})})(k)):"")},!((a=p[0])===null||a===void 0)&&a.$el_text?{$el_text:(l=p[0])===null||l===void 0?void 0:l.$el_text}:{},m&&t.type==="click"?{$external_click_url:m}:{},v),target:e};var k,$}const fu="autocapture";var Mh=class{el(){this.il=void 0,clearTimeout(this.nl),this.nl=void 0}sl(e){var t;if(!ot(e))return!0;const s=(t=this.rl().css_selector_ignorelist)!==null&&t!==void 0?t:As,i=new Set;let r=e;for(;r;){if(i.size>=1e3||i.has(r))return!0;i.add(r);const n=r,o=mt(n);if(I(o,"ph-no-capture")||I(o,"ph-sensitive")||qt(n)||s.some(l=>ns(n,l)))return!0;const a=r.parentNode;r=ii(a)?a.host:a&&Ie(a)?a:null}return!1}ol(e){if(!this.isEnabled||e.type==="pointercancel")return void this.el();if(e.type==="pointerdown"){var t;this.el();const i=fs(e);return void(e.isPrimary&&e.button===0&&!e.ctrlKey&&i&&Ie(i)&&(this.il={target:i,excluded:this.sl(i),id:e.pointerId,x:e.clientX,y:e.clientY,released:!1,distinctId:(t=this.xa)===null||t===void 0?void 0:t.distinctId}))}const s=this.il;s&&(e.pointerId!==s.id||Math.abs(e.clientX-s.x)>5||Math.abs(e.clientY-s.y)>5?this.el():e.type==="pointerup"&&(s.released=!0,this.nl=setTimeout(()=>this.el(),0)))}al(e){var t;const s=this.il;this.el();const i=fs(e);if(s?.released&&s.target.isConnected&&s.distinctId===((t=this.xa)===null||t===void 0?void 0:t.distinctId)&&e.pointerId===s.id&&(e.detail>0||e.pointerType==="touch"||e.pointerType==="pen")&&e.button===0&&5>=Math.abs(e.clientX-s.x)&&5>=Math.abs(e.clientY-s.y)&&i&&(le(i,"html")||le(i,"body"))){var r,n,o;if(s.excluded)return null;const a=(r=this.rl().css_selector_ignorelist)!==null&&r!==void 0?r:As;return[i,(n=ts())===null||n===void 0?void 0:n.documentElement,(o=ts())===null||o===void 0?void 0:o.body].some(l=>{if(!l)return!1;const u=mt(l);return I(u,"ph-no-capture")||I(u,"ph-sensitive")||!ot(l)||qt(l)||a.some(c=>ns(l,c))})?null:s.target}}constructor(e){this.Ta=e,this.name=fu,this.ll=!1,this.ul=null,this.cl=!1,this.hl=new Map,this.dl=!1,this.Ar={enabled:!1,rageclick:!1,maskAllElementAttributes:!1,maskAllText:!1,disableCaptureUrlHashes:!1,remoteRequestsDisabled:!1},this.Ci=!1,this.Ta.refresh(this.Ar),this.rageclicks=new pu(this.Ar.rageclick),this.vl=null}setup(e){this.fl(),this.xa=e;const t=e.onRemoteConfig(this.onRemoteConfig.bind(this));this.Ci?t.dispose():(this.qa=t,this.startIfEnabled())}dispose(){var e;this.Ci||(this.Ci=!0,this.xa=void 0,(e=this.qa)===null||e===void 0||e.dispose(),this.qa=void 0,this.hl.clear(),this.vl=null,this.pl())}rl(){return this.Ta.refresh(this.Ar),this.Ar}fl(){var e,t;return this.rl(),this.Ar.url_allowlist=(e=this.Ar.url_allowlist)===null||e===void 0?void 0:e.map(s=>new RegExp(s)),this.Ar.url_ignorelist=(t=this.Ar.url_ignorelist)===null||t===void 0?void 0:t.map(s=>new RegExp(s)),this.Ar}gl(){const e=Or(),t=ts();if(!this.isBrowserSupported())return void Ts.info("Disabling Automatic Event Collection because this browser is not supported");if(!e||!t)return;this.ml=e,this.yl=t;const s=this.bl=i=>{i=i||e?.event;try{if(i.type==="blur")return void this.el();if(i.type.indexOf("pointer")===0)return void this.ol(i);const r=i.type==="click"?this.al(i):void 0;if(se(r))return;this._l(i,"$autocapture",r)}catch(r){Ts.error("Failed to capture event",r)}};if(U(e,"blur",s),U(t,"submit",s,{capture:!0}),U(t,"change",s,{capture:!0}),U(t,"click",s,{capture:!0}),J(["pointerdown","pointermove","pointerup","pointercancel"],i=>{U(t,i,s,{capture:!0})}),this.rl().capture_copied_text){const i=this.wl=r=>{r=r||e?.event;try{this._l(r,Ui)}catch(n){Ts.error("Failed to capture clipboard event",n)}};U(t,"copy",i,{capture:!0}),U(t,"cut",i,{capture:!0}),U(t,"paste",i,{capture:!0})}}pl(){const e=this.ml,t=this.yl;this.el(),this.bl&&(e?.removeEventListener("blur",this.bl),J(["pointerdown","pointermove","pointerup","pointercancel"],s=>{t?.removeEventListener(s,this.bl,!0)}),t?.removeEventListener("submit",this.bl,!0),t?.removeEventListener("change",this.bl,!0),t?.removeEventListener("click",this.bl,!0),this.bl=void 0),this.wl&&(t?.removeEventListener("copy",this.wl,!0),t?.removeEventListener("cut",this.wl,!0),t?.removeEventListener("paste",this.wl,!0),this.wl=void 0),this.ml=void 0,this.yl=void 0,this.ll=!1}startIfEnabled(){this.isEnabled||this.el(),!this.Ci&&this.xa&&this.isEnabled&&!this.ll&&(this.gl(),this.ll=!0)}onRemoteConfig(e){if(this.Ci)return;if(this.cl=!0,!e.ok)return void this.startIfEnabled();const t=e.config;t.elementsChainAsString&&(this.dl=t.elementsChainAsString);const s=t.autocapture_opt_out;var i;we(s)&&((i=this.xa)===null||i===void 0||i.kv.set("$autocapture_disabled_server_side",s),this.ul=s),this.startIfEnabled()}setElementSelectors(e,t=this){if(this.Ci)return;e.size?this.hl.set(t,new Set(e)):this.hl.delete(t);const s=new Set;this.hl.forEach(i=>{i.forEach(r=>s.add(r))}),this.vl=s}getElementSelectors(e,t){var s;const i=[];return(s=this.vl)===null||s===void 0||s.forEach(r=>{var n;const o=(n=ts())===null||n===void 0?void 0:n.querySelectorAll(r);o?.forEach(a=>{e!==a&&t!==a||I(i,r)||i.push(r)})}),i}get isEnabled(){var e,t;if(this.Ci)return!1;const s=(e=this.xa)===null||e===void 0?void 0:e.kv.get(el),i=this.ul,r=this.rl();if(!r.remoteRequestsDisabled&&!this.cl)return!1;const n=r.remoteRequestsDisabled&&!this.cl;if(se(i)&&!we(s)&&!n)return!1;const o=(t=this.ul)!==null&&t!==void 0?t:!!s;return!!r.enabled&&!o}_l(e,t="$autocapture",s){if(!this.isEnabled)return void this.el();let i=s||fs(e);$l(i)&&(i=i.parentNode||null);const r=this.fl();var n;t==="$autocapture"&&e.type==="click"&&e instanceof MouseEvent&&r.rageclick&&(!((n=this.rageclicks)===null||n===void 0)&&n.isRageClick(e.clientX,e.clientY,e.timeStamp||new Date().getTime()))&&Pl(i,r.rageclick)&&this._l(e,"$rageclick",s);const o=t===Ui,a=o?f(f({},r),{},{dom_event_allowlist:void 0}):r;if(i&&(function(h,p,v,m,g,y){var _;const b=typeof window>"u"?void 0:window;if(!b||en(h)||v?.url_allowlist&&!Wn(v.url_allowlist,y)||v?.url_ignorelist&&Wn(v.url_ignorelist,y))return!1;if(v?.dom_event_allowlist){const A=v.dom_event_allowlist;if(A&&!A.some(P=>p.type===P))return!1}const{parentIsUsefulElement:k,targetElementList:$}=Al(h,m);if(!(function(A,P){const R=P?.element_allowlist;if(x(R))return!0;for(const B of A)if(R.some(V=>B.tagName.toLowerCase()===V))return!0;return!1})($,v)||!Er($,v?.css_selector_allowlist)||Er($,(_=v?.css_selector_ignorelist)!==null&&_!==void 0?_:As))return!1;try{const A=b.getComputedStyle(h);if(A&&A.getPropertyValue("cursor")==="pointer"&&p.type==="click")return!0}catch{}const S=h.tagName.toLowerCase();switch(S){case"html":return!1;case"form":return(g||["submit"]).indexOf(p.type)>=0;case"input":case"select":case"textarea":return(g||["change","click"]).indexOf(p.type)>=0;default:return k?(g||["click"]).indexOf(p.type)>=0:(g||["click"]).indexOf(p.type)>=0&&(Qr.indexOf(S)>-1||h.getAttribute("contenteditable")==="true")}})(i,e,a,o,o?["copy","cut","paste"]:void 0,{config:{get_current_url:r.getCurrentUrl}})){var l;const{props:h,explicitNoCapture:p,target:v}=Oh(i,{e,maskAllElementAttributes:r.maskAllElementAttributes,maskAllText:r.maskAllText,elementAttributeIgnoreList:r.element_attribute_ignorelist,elementsChainAsString:this.dl,disableCaptureUrlHashes:r.disableCaptureUrlHashes});if(p)return!1;const m=this.getElementSelectors(i,v);if(m&&m.length>0&&(h.$element_selectors=m),t===Ui){const g=e.type||"clipboard";if(g!=="paste"){var u,c;const y=(u=Or())===null||u===void 0||(u=u.getSelection())===null||u===void 0?void 0:u.toString(),_=kl(y);if(!_)return!1;h.$selected_content=_,h.$clipboard_text_length=(c=y?.length)!==null&&c!==void 0?c:0}h.$copy_type=g}if(t==="$autocapture"&&e.type==="change"&&r.capture_value_css_selector_allowlist&&!r.maskAllText&&(le(d=i,"input")?!I(Fh,d.type):le(d,"textarea")||le(d,"select")&&!d.multiple)&&(function(g,y){var _;if(!ot(g))return!1;const b=(_=y.css_selector_ignorelist)!==null&&_!==void 0?_:As,k=new Set;let $=g;for(le(g,"select")&&($=g.options[g.selectedIndex]||g);$;){const S=$,A=mt(S);if(k.size>=1e3||k.has($)||I(A,"ph-sensitive")||I(A,"ph-no-capture")||b.some(R=>ns(S,R)))return!1;k.add($);const P=$.assignedSlot||$.parentNode;$=ii(P)?P.host:P&&Ie(P)?P:null}return!0})(i,r)&&!i.querySelector(".ph-no-capture, .ph-sensitive")){const g=r.capture_value_css_selector_allowlist;let y=!1;try{y=ne(g)?!!g(i):O(g)&&g.some(_=>ns(i,_))}catch(_){Ts.error("capture_value_css_selector_allowlist threw",_)}y&&(h.$input_value=i.value)}return(l=this.xa)===null||l===void 0||l.capture(t,h),!0}var d}isBrowserSupported(){var e;return ne((e=ts())===null||e===void 0?void 0:e.querySelectorAll)}};const vu="featureFlags",gu="logs";var Th=class{constructor(e){this._instance=e}initialize(){}get(e){const t=this._instance.persistence;if(typeof e=="string")return t?.get_property(e);const s={};for(const i of e){const r=t?.get_property(i);x(r)||(s[i]=r)}return s}set(e,t){var s;(s=this._instance.persistence)===null||s===void 0||s.register(typeof e=="string"?{[e]:t}:e)}remove(e){var t;(t=this._instance.persistence)===null||t===void 0||t.unregister(e)}},Rh=class{constructor(e){this.instance=e,this.$=E,this.kv=new Th(e),this.onSession=t=>Os(this.instance.onSessionId(s=>{try{t(s)}catch(i){this.$.error("Browser extension session listener failed",i)}})),this.onEvent=t=>Os(this.instance._addCaptureHook((s,i)=>{if(i)try{t({event:s,properties:i.properties})}catch(r){this.$.error("Browser extension event listener failed",r)}})),this.onRemoteConfig=t=>{const s=r=>{try{t(r)}catch(n){this.$.error("Browser extension remote config listener failed",n)}},i=this.instance.ur.on("extensionsRemoteConfig",s);return this.instance.cr&&s(this.instance.cr),Os(i)}}get logger(){return this.$}get distinctId(){return this.instance.get_distinct_id()}get anonymousId(){var e;return(e=this.instance.get_property("$device_id"))!==null&&e!==void 0?e:this.distinctId}get deviceId(){const e=this.instance.get_property(zr);return typeof e=="string"?e:void 0}get library(){return{name:$e.LIB_NAME,version:$e.LIB_VERSION}}get initialPersonProperties(){var e,t;return(e=(t=this.instance.persistence)===null||t===void 0?void 0:t.get_initial_props())!==null&&e!==void 0?e:{}}get groups(){return this.instance.getGroups()}get session(){try{var e,t,s,i,r;const n=(e=this.instance.sessionManager)===null||e===void 0?void 0:e.checkAndGetSessionAndWindowId(!0);return{sessionId:(t=n?.sessionId)!==null&&t!==void 0?t:"",windowId:(s=n?.windowId)!==null&&s!==void 0?s:"",sessionStartTimestamp:(i=n?.sessionStartTimestamp)!==null&&i!==void 0?i:0,lastActivityTimestamp:(r=n?.lastActivityTimestamp)!==null&&r!==void 0?r:0}}catch{return{sessionId:"",windowId:"",sessionStartTimestamp:0,lastActivityTimestamp:0}}}get isOptedOut(){return this.instance.has_opted_out_capturing()}get canCapture(){return ne(this.instance.is_capturing)?this.instance.is_capturing():!this.isOptedOut}get projectToken(){return this.instance.config.token}getExtension(e){let t;switch(e){case vu:case"featureFlagsCommon":t=this.instance.featureFlags;break;case gu:t=this.instance.logs;break;case"surveys":t=this.instance.surveys;break;case fu:t=this.instance.autocapture}return t}capture(e,t,s){if(!s)return void this.instance.capture(e,t);const i=f({timestamp:s.timestamp,uuid:s.uuid,$set:s.set,$set_once:s.setOnce},s.delivery==="unload"?{transport:"sendBeacon",send_instantly:!0}:{});this.instance.capture(e,t,i)}registerDynamicEventProperties(e){return Os(this.instance.dr(e))}sendRequest(e){var t=this;return Q(function*(s,i={}){var r;const n=(r=i.target)!==null&&r!==void 0?r:"api",o=i.query?pi(s,i.query):s,a=t.instance.requestRouter.endpointFor(n,o),l={method:i.method,url:a,data:i.body,headers:i.headers,timeout:i.timeoutMs,fireCallbackOnDrop:!0,transport:i.transport,compression:i.compression,compressionFallback:i.target==="flags"&&i.compression==="best-available"?sr.Base64:void 0,timestampMode:i.sentAt};return n==="api"&&s==="/i/v1/logs"&&(l.batchKey="logs"),i.transport==="sendBeacon"?(t.instance._send_request(l),{statusCode:202}):new Promise(u=>{l.callback=u,t.instance._send_request(l)})}).apply(this,arguments)}};const gs={};let Gi=0;const _s=()=>{},bo='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',Pt="Surveys module not available",wo="sanitize_properties is deprecated. Use before_send instead",_u="Invalid value for property_denylist config: ",Lh=["$recording_status","$sdk_debug_recording_script_not_loaded","$sdk_debug_replay_url_trigger_status","$sdk_debug_replay_event_trigger_status","$sdk_debug_replay_linked_flag_trigger_status","$sdk_debug_replay_rrweb_error","$sdk_debug_replay_internal_buffer_length","$sdk_debug_replay_flushed_size"],Dh=["$feature_flag_called","$$heatmap","$snapshot"],xo=e=>e.charAt(0)==="$"&&!I(Dh,e),Nh=/^[A-Za-z0-9_-]{1,400}$/,$o=/^fb\.[0-9]+\.[0-9]+\.[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)?$/,ko=/^fb\.[0-9]+\.[0-9]+\.[0-9]+$/,jh=["token","distinct_id",ll],os="posthog",qh=[...mo].sort()[mo.length-1],Hh=e=>{const t={};return e&&e!=="unset"&&("2025-11-30">e||(t.strictMinimumDuration=!0),"2026-05-30">e||(t.canvasCapture={resolutionScale:.6}),"2026-06-25">e||(t.streamNetworkBody=!0),"2026-08-30">e||(t.captureJsonLd=!0)),t},Ji=e=>{var t;return f({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,asset_host:null,token:"",autocapture:!0,cross_subdomain_cookie:Od(C?.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:_s,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:e??"unset",__preview_deferred_init_extensions:!1,__preview_replay_sync_fetch:!0,__preview_external_dependency_versioned_paths:!1,__preview_cookie_wins_on_conflict:!1,debug:Y&&N(Y?.search)&&Y.search.indexOf("__posthog_debug=true")!==-1||!1,cookie_expiration:365,upgrade:!1,disable_session_recording:!1,disable_persistence:!1,disable_web_experiments:!0,disable_surveys:!1,disable_surveys_automatic_display:!1,disable_conversations:!1,disable_product_tours:!1,disableDeviceModel:!1,reuseAnonymousId:!1,disable_external_dependency_loading:!1,strict_script_versioning:"fallback",enable_recording_console_log:void 0,secure_cookie:(w==null||(t=w.location)===null||t===void 0?void 0:t.protocol)==="https:",ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_flags:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_only_evaluate_survey_feature_flags:!1,advanced_feature_flags_dedup_per_session:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,feature_flag_request_max_retries:1,surveys_request_timeout_ms:1e4,on_request_error(s){E.error("Bad HTTP status: "+s.statusCode+" "+s.text)},get_device_id:s=>s,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:ml,before_send:void 0,get_current_url:void 0,request_queue_config:{flush_interval_ms:3e3},error_tracking:{},_onCapture:_s},(s=>({rageclick:s&&s>="2026-05-30"?{content_ignorelist:Zr,ignore_text_selection:!0}:!s||"2025-11-30">s||{content_ignorelist:!0},capture_pageview:!s||"2025-05-24">s||"history_change",session_recording:Hh(s),external_scripts_inject_target:s&&s>="2026-01-30"?"head":"body",internal_or_test_user_hostname:s&&s>="2026-01-30"?/^(localhost|127\.0\.0\.1)$/:void 0,persistence_save_debounce_ms:s&&s>="2026-05-30"?250:0,split_storage:!(!s||"2026-05-30">s),detect_google_search_app:!(!s||"2026-05-30">s),disable_capture_url_hashes:!(!s||"2026-06-25">s),cookieWinsOnConflict:!(!s||s==="unset"||"2026-08-29">s)}))(e))},Bh=[["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"]],Eo=e=>{const t={};for(const[r,n]of Bh)x(e[r])||(t[n]=e[r]);const s=ee({},t,e),i=e.__preview_external_dependency_versioned_paths;return x(i)||(x(e.strict_script_versioning)&&(s.strict_script_versioning=!!i),N(i)&&x(e.asset_host)&&(s.asset_host=i)),O(e.property_blacklist)&&(x(e.property_denylist)?s.property_denylist=e.property_blacklist:O(e.property_denylist)?s.property_denylist=[...e.property_blacklist,...e.property_denylist]:E.error(_u+e.property_denylist)),s};var zh=class{constructor(){this.__forceAllowLocalhost=!1}get Yc(){return this.__forceAllowLocalhost}set Yc(e){E.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}},ms=class tt{th(t){if(!t)return;const s=this.eh.indexOf(t);s!==-1&&this.eh.splice(s,1)}ih(t,s){var i;return this.th(t),this.eh.push(s),(i=s.initialize)===null||i===void 0||i.call(s),s}nh(){return this.config.cookieless_mode==="always"||this.config.cookieless_mode==="on_reject"&&this.consent.isRejected()}sh(){if(this.rh||this.config.reuseAnonymousId||this.config.segment||this.nh())return;const t=this.config.persistence==="memory"||this.config.persistence==="sessionStorage";if(!t&&!this.config.disable_persistence||this.oh)return;let s,i,r;t?(s=`persistence is set to '${this.config.persistence}'`,i=this.config.persistence==="memory"?"on every page load":"for every new browser tab or window",r="Either set persistence to 'localStorage+cookie', keep this persistence and pass a stable ID through bootstrap.distinctID, or enable reuseAnonymousId."):(s="persistence is disabled (disable_persistence is true)",i="on every page load",r="Either set disable_persistence to false, keep persistence disabled and pass a stable ID through bootstrap.distinctID, or enable reuseAnonymousId."),this.rh=!0,console.warn("[PostHog.js]",`${s} but no bootstrap.distinctID was provided. PostHog will mint a new distinct ID ${i}, so calling identify() merges a new ID onto the person each time. A person can then pass the distinct-ID limit and its events stop appearing on person pages and the session tab. ${r}`)}ah(){const t=this.persistence;if(!t||this.uh)return;if(this.nh())return void(this.config.cookieless_mode==="on_reject"&&this.get_distinct_id()!=="$posthog_cookieless"&&(this.hh(),this.dh()));if(this.get_distinct_id()!=="$posthog_cookieless")return;this.fh()||t.load(!0);const s=this.get_distinct_id();if(!s||s==="$posthog_cookieless"){const i=this.config.get_device_id(Re());this.register({distinct_id:i,$device_id:i}),t.set_property(fe,Ge)}this.hh()}get decideEndpointWasHit(){var t,s;return(t=(s=this.featureFlags)===null||s===void 0?void 0:s.hasLoadedFlags)!==null&&t!==void 0&&t}get flagsEndpointWasHit(){var t,s;return(t=(s=this.featureFlags)===null||s===void 0?void 0:s.hasLoadedFlags)!==null&&t!==void 0&&t}constructor(){var t;this.ph=!1,this.gh=!1,this.webPerformance=new zh,this.mh=!1,this.version=$e.LIB_VERSION,this.yh=new Set,this.bh="",this.ur=new ai,this.eh=[],this._h=[],this.wh=!1,this.oh=!1,this.rh=!1,this.uh=!1,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=Ji(),this.SentryIntegration=Yd,this.sentryIntegration=i=>(function(r,n){const o=Il(r,n);return{name:Fl,processEvent:a=>o(a)}})(this,i),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.kh=!1,this.Sh=null,this.xh=null,this.$h=null,this.scrollManager=new yh(this),this.pageViewManager=new ro(this),this.rateLimiter=new oh(this),this.requestRouter=new kh(this),this.consent=new jd(this),this.externalIntegrations=new Ch(this);const s=(t=tt.__defaultExtensionClasses)!==null&&t!==void 0?t:{};this.featureFlags=s.featureFlags&&new s.featureFlags(this),this.toolbar=s.toolbar&&new s.toolbar(this),this.surveys=s.surveys&&new s.surveys(this),this.conversations=s.conversations&&new s.conversations(this),this.logs=s.logs&&new s.logs(this),this.metrics=s.metrics&&new s.metrics(this),this.experiments=s.experiments&&new s.experiments(this),this.exceptions=s.exceptions&&new s.exceptions(this),this.people={set:(i,r,n)=>{const o=N(i)?{[i]:r}:i;this.setPersonProperties(o),n?.({})},set_once:(i,r,n)=>{const o=N(i)?{[i]:r}:i;this.setPersonProperties(void 0,o),n?.({})}},this.on("eventCaptured",i=>E.info(`send "${i?.event}"`,i))}init(t,s,i){if(i&&i!==os){var r;const n=(r=gs[i])!==null&&r!==void 0?r:new tt;return n._init(t,s,i),gs[i]=n,gs[os][i]=n,n}return this._init(t,s,i)}_init(t,s={},i){var r,n,o;const a=N(t)?t.trim():"";if(!a)return E.critical("PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()"),this;var l;if(this.__loaded)return a!==((l=this.config)===null||l===void 0?void 0:l.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('${a}', { ... }, 'project2')`):console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config=Ji(s.defaults),s.debug=this.Ch(s.debug),this.Th=s,this.Ih=[],s.person_profiles?this.xh=s.person_profiles:s.process_person&&(this.xh=s.process_person);const u=Ji(s.defaults),c=Eo(s),d=ee({},u,c,{name:i,token:a});D(u.rageclick)&&D(c.rageclick)&&(d.rageclick=ee({},u.rageclick,c.rageclick)),D(u.session_recording)&&D(c.session_recording)&&(d.session_recording=ee({},u.session_recording,c.session_recording)),this.set_config(d),this.config.on_xhr_error&&E.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=s.disable_compression?void 0:Pe.GZipJS;const h=this.fh(),p=!this.nh();if(this.persistence=new Di(this.config,h,!0,p),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new Di(f(f({},this.config),{},{persistence:"sessionStorage"}),h,!1,p),this.bh="ph_"+(this.config.persistence_name||this.config.token)+"_session_registered_properties",this.config.persistence!=="memory"&&!h&&X.Et()){const _=X.Lt(this.bh);O(_)&&_.forEach(b=>{N(b)&&this.yh.add(b)})}else X.Pt(this.bh);const v=f({},this.persistence.props),m=f({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.Mh=new gh((_,b)=>this.Eh(_,b),this.config.request_queue_config),this.Ph=new mh(this),this.__request_queue=[];const g=this.nh();g||(this.sessionManager=new _o(this),this.sessionPropsManager=new vo(this,this.sessionManager,this.persistence),this.sessionManager.onSessionId((_,b,k)=>{(k?.activityTimeout||k?.sessionPastMaximumLength||k?.crossTabAdoption)&&this.Rh()})),this.Ah(),this.config.__preview_deferred_init_extensions?(E.info("Deferring extension initialization to improve startup performance"),this.Fh=setTimeout(()=>{this.Fh=void 0,this.Oh(g)},0)):(E.info("Initializing extensions synchronously"),this.Oh(g)),$e.DEBUG=$e.DEBUG||this.config.debug,$e.DEBUG&&E.info("Starting in debug mode",{this:this,config:s,thisC:f({},this.config),p:v,s:m}),this.config.identity_distinct_id&&!(!((r=s.bootstrap)===null||r===void 0)&&r.distinctID)&&(s.bootstrap=f(f({},s.bootstrap),{},{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0}));const y=(n=s.bootstrap)===null||n===void 0?void 0:n.distinctID;if(this.oh=!!y&&!as(y),(o=s.bootstrap)===null||o===void 0?void 0:o.distinctID){const _=s.bootstrap.distinctID,b=this.get_distinct_id(),k=this.persistence.get_property(fe);if(s.bootstrap.isIdentifiedID&&b!=null&&b!==_&&k==="anonymous")this.identify(_);else if(s.bootstrap.isIdentifiedID&&b!=null&&b!==_&&k==="identified")E.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 $=this.config.get_device_id(Re()),S=s.bootstrap.isIdentifiedID?$:_;this.persistence.set_property(fe,s.bootstrap.isIdentifiedID?Hs:Ge),this.register({distinct_id:_,$device_id:S})}}if(g)this.register_once({distinct_id:Ci,$device_id:null},"");else if(!this.get_distinct_id()){const _=this.config.get_device_id(Re());this.register_once({distinct_id:_,$device_id:_},""),this.persistence.set_property(fe,Ge)}return U(w,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),U(w,"pageshow",_=>{if(this.ph=!1,!this.gh){var b;if(_.persisted&&this.persistence){const k=this.persistence.get_property(Fe),$=this.persistence.get_property(fe);this.persistence.load(),this.Dh()||k===this.persistence.get_property("distinct_id")&&$===this.persistence.get_property("$user_state")||this.Lh()}(b=this.Ph)===null||b===void 0||b.resume()}}),s.segment?io(this,()=>this.Nh()):this.Nh(),ne(this.config._onCapture)&&this.config._onCapture!==_s&&(E.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",_=>this.config._onCapture(_.event,_))),this.config.ip&&E.warn('The `ip` config option has NO EFFECT AT ALL and has been deprecated. Use a custom transformation or "Discard IP data" project setting instead. See https://posthog.com/tutorials/web-redact-properties#hiding-customer-ip-address for more information.'),this.config.disableDeviceModel||(function(){return lu.apply(this,arguments)})().then(_=>{_&&this.register({[Ai]:_})}).catch(_s),this}qh(t){const s=t;return N(s.name)&&ne(s.setup)}jh(t,s){var i=this;this.qh(t)?s.push(Q(function*(){try{yield t.setup(i.Bh())}catch(n){E.error(`Failed to set up extension "${t.name}"`,n);try{var r;yield(r=t.dispose)===null||r===void 0?void 0:r.call(t)}catch(o){E.error(`Failed to dispose extension "${t.name}"`,o)}}})):this.eh.push(t)}Ah(){var t,s,i,r=this;const n=(t=(s=this.config.__extensionClasses)===null||s===void 0?void 0:s.featureFlags)!==null&&t!==void 0?t:(i=tt.__defaultExtensionClasses)===null||i===void 0?void 0:i.featureFlags;var o,a,l;if(n)if(this.featureFlags&&this.featureFlags instanceof n||((o=this.zh)===null||o===void 0||o.call(this),this.zh=void 0,this.featureFlags=new n(this)),ne(this.featureFlags.onReloading)&&ne(this.featureFlags.setup)){if(!this.zh){this.zh=this.featureFlags.onReloading(()=>{this.ur.emit("featureFlagsReloading",!0)});const u=this.featureFlags;Q(function*(){try{yield u.setup(r.Bh())}catch(c){E.error("Failed to set up feature flags",c);const d=r.zh;r.zh=void 0;try{d?.()}catch(h){E.error("Failed to unsubscribe feature flag reloading",h)}try{yield u.dispose()}catch(h){E.error("Failed to dispose feature flags",h)}}})()}}else(a=(l=this.featureFlags).initialize)===null||a===void 0||a.call(l)}Oh(t){const s=performance.now(),i=f(f({},tt.__defaultExtensionClasses),this.config.__extensionClasses),r=[];var n,o,a,l,u,c,d,h;i.exceptions&&this.eh.push(this.exceptions=(n=this.exceptions)!==null&&n!==void 0?n:new i.exceptions(this)),i.historyAutocapture&&this.eh.push(this.historyAutocapture=new i.historyAutocapture(this)),i.tracingHeaders&&this.eh.push(this.tracingHeaders=new i.tracingHeaders(this)),i.siteApps&&this.eh.push(this.siteApps=new i.siteApps(this)),i.sessionRecording&&!t&&this.eh.push(this.sessionRecording=new i.sessionRecording(this)),this.config.disable_scroll_properties||r.push(()=>{this.scrollManager.startMeasuringScrollPosition()}),i.autocapture&&this.jh(this.autocapture=new i.autocapture(this),r),i.surveys&&this.jh(this.surveys=(o=this.surveys)!==null&&o!==void 0?o:new i.surveys(this),r),i.logs&&this.jh(this.logs=(a=this.logs)!==null&&a!==void 0?a:new i.logs(this),r),i.metrics&&this.eh.push(this.metrics=(l=this.metrics)!==null&&l!==void 0?l:new i.metrics(this)),i.conversations&&this.eh.push(this.conversations=(u=this.conversations)!==null&&u!==void 0?u:new i.conversations(this)),i.productTours&&this.eh.push(this.productTours=new i.productTours(this)),i.heatmaps&&this.eh.push(this.heatmaps=new i.heatmaps(this)),i.webVitalsAutocapture&&this.eh.push(this.webVitalsAutocapture=new i.webVitalsAutocapture(this)),i.exceptionObserver&&this.eh.push(this.exceptionObserver=new i.exceptionObserver(this)),i.deadClicksAutocapture&&this.eh.push(this.deadClicksAutocapture=new i.deadClicksAutocapture(this,Kd)),i.toolbar&&this.eh.push(this.toolbar=(c=this.toolbar)!==null&&c!==void 0?c:new i.toolbar(this)),i.experiments&&this.eh.push(this.experiments=(d=this.experiments)!==null&&d!==void 0?d:new i.experiments(this)),i.webMCP&&this.eh.push(this.webMCP=(h=this.webMCP)!==null&&h!==void 0?h:new i.webMCP(this)),this.eh.forEach(p=>{p.initialize&&r.push(()=>{var v;(v=p.initialize)===null||v===void 0||v.call(p)})}),r.push(()=>{if(this.Hh){const p=this.Hh;this.Hh=void 0,this.eh.forEach(v=>{var m;return(m=v.onRemoteConfig)===null||m===void 0?void 0:m.call(v,p)})}}),this.Uh(r,s)}Uh(t,s){for(;t.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-s>=30&&t.length>0)return void(this.Fh=setTimeout(()=>{this.Fh=void 0,this.Uh(t,s)},0));const r=t.shift();if(r)try{r()}catch(n){E.error("Error initializing extension:",n)}}const i=Math.round(performance.now()-s);this.register_for_session({[ul]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[cl]:i}),this.config.__preview_deferred_init_extensions&&E.info(`PostHog extensions initialized (${i}ms)`)}Gu(t){if(!C||!C.body)return E.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout(()=>{this.Gu(t)},500);if(this.config.__preview_deferred_init_extensions&&(this.Hh=t),this.cr=t,this.compression=void 0,t.ok){var s;const i=t.config;i.supportedCompression&&!this.config.disable_compression&&(this.compression=I(i.supportedCompression,Pe.GZipJS)?Pe.GZipJS:I(i.supportedCompression,Pe.Base64)?Pe.Base64:void 0),!((s=i.analytics)===null||s===void 0)&&s.endpoint&&(this.analyticsDefaultEndpoint=i.analytics.endpoint)}this.set_config({person_profiles:this.xh?this.xh:ml}),this.ur.emit("extensionsRemoteConfig",t),this.eh.forEach(i=>{var r;return(r=i.onRemoteConfig)===null||r===void 0?void 0:r.call(i,t)})}Nh(){try{this.config.loaded(this)}catch(t){E.critical("`loaded` function failed",t)}if(this.Wh(),this.config.internal_or_test_user_hostname&&Y?.hostname){const t=Y.hostname,s=this.config.internal_or_test_user_hostname;(typeof s=="string"?t===s:s.test(t))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout(()=>{(this.consent.isOptedIn()||this.nh())&&this.Vh()},1),this.Gh=new Vl(this),this.Gh.load()}Wh(){var t;this.is_capturing()&&this.config.request_batching&&((t=this.Mh)===null||t===void 0||t.enable())}_dom_loaded(){this.is_capturing()&&Ot(this.__request_queue,t=>this.Eh(t)),this.__request_queue=[],this.Wh()}_handle_unload(){var t,s,i,r,n,o;this.ph=!0,(t=this.surveys)===null||t===void 0||(s=t.handlePageUnload)===null||s===void 0||s.call(t),(i=this.metrics)===null||i===void 0||i.flush("sendBeacon"),this.config.request_batching?(this.Qh()&&this.capture(Nn),(r=this.logs)===null||r===void 0||r.flushLogs("sendBeacon"),(n=this.Mh)===null||n===void 0||n.unload(),(o=this.Ph)===null||o===void 0||o.unload()):this.Qh()&&this.capture(Nn,null,{transport:"sendBeacon"})}_send_request(t){ou(this,t)}Eh(t,s){this.Ph?this.Ph.retriableRequest(t,s):this._send_request(s?f(f({},t),{},{transport:s}):t)}_execute_array(t){Gi++;try{let s;const i=[],r=[],n=[];Ot(t,a=>{if(a)if(s=a[0],O(s))n.push(a);else if(ne(a))try{a.call(this)}catch(l){E.error("Error executing queued PostHog call",a,l)}else O(a)&&s==="alias"?i.push(a):O(a)&&s.indexOf("capture")!==-1&&ne(this[s])?n.push(a):r.push(a)});const o=function(a,l){Ot(a,function(u){try{if(O(u[0])){let c=l;J(u,function(d){c=c[d[0]].apply(c,d.slice(1))})}else l[u[0]].apply(l,u.slice(1))}catch(c){E.error("Error executing queued PostHog call",u,c)}})};o(i,this),o(r,this),o(n,this)}finally{Gi--}}push(t){if(Gi>0&&O(t)&&N(t[0])){const s=tt.prototype[t[0]];return void(ne(s)&&s.apply(this,t.slice(1)))}this._execute_array([t])}get Zh(){return{property:Ln,persistenceKey:Lt,cookieName:"_fbc",pattern:$o,register:(t,s)=>{var i;return(i=this.persistence)===null||i===void 0?void 0:i.register({[Lt]:{value:t,delivered:s}})},unregister:()=>{var t;return(t=this.persistence)===null||t===void 0?void 0:t.unregister(Lt)}}}get Jh(){return{property:Dn,persistenceKey:cs,cookieName:"_fbp",pattern:ko,register:(t,s)=>{var i;return(i=this.persistence)===null||i===void 0?void 0:i.register({[cs]:{value:t,delivered:s}})},unregister:()=>{var t;return(t=this.persistence)===null||t===void 0?void 0:t.unregister(cs)}}}Kh(t){var s;const i=(s=this.persistence)===null||s===void 0?void 0:s.get_property(t.persistenceKey);return N(i)&&t.pattern.test(i)?{value:i,delivered:!1}:D(i)&&N(i.value)&&t.pattern.test(i.value)?{value:i.value,delivered:i.delivered===!0}:void 0}Xh(t,s,i){return s===i?.value?{value:s,pending:!i.delivered}:(t.register(s,!1),{value:s,pending:!0})}Yh(t){if(!this.config.save_campaign_params||this.nh())return;const s=hs(t.cookieName);return N(s)&&t.pattern.test(s)?s:void 0}td(t,s,i,r){if(!this.persistence)return;const n=this.Zh;this.persistence.refreshMetaIdentifiers();const o=this.Kh(n);if(r)return void n.unregister();if(i)return N(s)&&$o.test(s)?this.Xh(n,s,o):void n.unregister();const a=N(t)&&Nh.test(t)?t:void 0,l=this.Yh(n);return l&&((u,c,d)=>{const h=u.split(".");if(c)return h[3]===c;if(!d)return!0;const p=d.value.split(".");return h[3]===p[3]||Number(h[2])>Number(p[2])})(l,a,o)?this.Xh(n,l,o):a?o?.value.split(".")[3]===a?{value:o.value,pending:!o.delivered}:this.Xh(n,`fb.1.${Date.now()}.${a}`,o):o?{value:o.value,pending:!o.delivered}:void 0}ed(t,s,i){if(!this.persistence)return;const r=this.Jh;this.persistence.refreshMetaIdentifiers();const n=this.Kh(r);if(i)return void r.unregister();if(s)return N(t)&&ko.test(t)?this.Xh(r,t,n):void r.unregister();const o=this.Yh(r);return o?this.Xh(r,o,n):n?{value:n.value,pending:!n.delivered}:void 0}nd(t,s){if(!this.persistence)return;this.persistence.refreshMetaIdentifiers();const i=this.Kh(t);i?.value!==s||i.delivered||t.register(s,!0)}capture(t,s,i){var r,n;if(!(this.__loaded&&this.persistence&&this.sessionPersistence&&this.Mh))return void E.uninitializedWarning("posthog.capture");if(!this.is_capturing())return void E.info(`Event "${t}" was not captured because capturing is disabled (opted out or consent pending).`);if(x(t)||!N(t))return void E.error("No event name provided to posthog.capture");if(this.ah(),t==="$snapshot"&&this.nh())return;const o=!this.config.opt_out_useragent_filter&&this._is_bot();if(o&&!this.config.__preview_capture_bot_pageviews)return void E.info(`Event "${t}" was not captured because the user agent looks like a bot. Set \`opt_out_useragent_filter: true\` to capture it.`);const a=i?.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(a?.isRateLimited)return void E.critical("This capture call is ignored due to client rate limiting.");let l;s?.$current_url&&!N(s?.$current_url)&&(E.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),s==null||delete s.$current_url),t!=="$exception"||i?.sd||E.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&&(l=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 u=new Date,c=i?.timestamp||u,d=gn(i?.uuid,Re);let h={uuid:d,event:t,properties:this.calculateEventProperties(t,s||{},c,d)};t==="$pageview"&&this.config.__preview_capture_bot_pageviews&&o&&(h.event="$bot_pageview",h.properties.$browser_type="bot"),a&&(h.properties.$lib_rate_limit_remaining_tokens=a.remainingTokens);const p=t==="$feature_flag_called"&&h.properties.$feature_flag_has_experiment===!1&&this.get_property("$minimal_flag_called_events")===!0;i?.$set&&!p&&(h.$set=i?.$set);const v=D(s?.$set)?s.$set:void 0,m=O(s?.$unset)?s.$unset:[],g=i?.$unset||[],y=F=>{var j;const q=!!i?.$set&&F in i.$set;return{hasProvided:q||!!v&&F in v,provided:q?i==null||(j=i.$set)===null||j===void 0?void 0:j[F]:v?.[F],unset:m.indexOf(F)!==-1||g.indexOf(F)!==-1}},_=y(Ln),b=y(Dn),k=[{channel:this.Zh,hasProvided:_.hasProvided,update:this.td(l?.fbclid,_.provided,_.hasProvided,_.unset)},{channel:this.Jh,hasProvided:b.hasProvided,update:this.ed(b.provided,b.hasProvided,b.unset)}];for(const{channel:F,hasProvided:j,update:q}of k)q&&h.properties.$process_person_profile===!0&&q.pending&&!j&&!p&&(h.$set=f({[F.property]:q.value},h.$set));const $=i?.$unset;$&&(h.$unset=$);const S=p?void 0:this.rd(i?.$set_once,t!==jn,t===yl);if(S&&(h.$set_once=S),i?._noTruncate||(A=this.config.properties_string_max_length,h=(function(F,j){const q=new Set;return(function K(H,re){if(H!==Object(H))return j?j(H):H;if(q.has(H))return;let ce;if(q.add(H),O(H))ce=[],Ot(H,ae=>{ce.push(K(ae))});else{const ae={};J(Ut(H)?bl(H):H,(Ae,_e)=>{q.has(Ae)||(ae[_e]=K(Ae))}),ce=ae}return ce})(F)})(h,F=>N(F)?F.slice(0,A):F)),h.timestamp=c,x(i?.timestamp)||(h.properties.$event_time_override_provided=!0,h.properties.$event_time_override_system_time=u),p&&(h.properties=((F,j=[])=>{const q={},K=H=>{F[H]!==void 0&&(q[H]=F[H])};return $c.forEach(K),j.forEach(K),q})(h.properties,jh)),t===Se.DISMISSED||t===Se.SENT){const F=s?.[ji.SURVEY_ID],j=s?.[ji.SURVEY_ITERATION];hu({id:F,current_iteration:j}),h.$set=f(f({},h.$set),{},{[wh({id:F,current_iteration:j},t===Se.SENT?"responded":"dismissed")]:!0})}else t===Se.SHOWN&&(h.$set=f(f({},h.$set),{},{[ji.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));var A;if(t===nh.SHOWN){const F=s?.[ao.TOUR_TYPE];F&&(h.$set=f(f({},h.$set),{},{[`${ao.TOUR_LAST_SEEN_DATE}/${F}`]:new Date().toISOString()}))}const P=f(f({},h.properties.$set),h.$set);if(ke(P)||this.setPersonPropertiesForFlags(P),!L(this.config.before_send)){const F=this.Os(h);if(!F)return;h=F,h.uuid=gn(h.uuid,Re)}this.sessionRecording&&!this.wh&&xo(t)&&(this.wh=!0,setTimeout(()=>this.wh=!1,3e4));const R=k.filter(({channel:F,update:j})=>{var q,K,H;const re=(q=(K=h.$set)===null||K===void 0?void 0:K[F.property])!==null&&q!==void 0?q:D((H=h.properties)===null||H===void 0?void 0:H.$set)?h.properties.$set[F.property]:void 0;return j?.pending&&re===j.value});this.ur.emit("eventCaptured",h);const B=(r=i?._url)!==null&&r!==void 0?r:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),V=i?._batchKey==="recordings"||/\/s\/(?:\?|$)/.test(B),T=f(f(f({method:"POST",url:B,data:h,compression:"best-available",preferSyncCompression:i?.send_instantly,timestampMode:V?"body":"capture-body",batchKey:i?._batchKey},V&&(!((n=h.properties)===null||n===void 0)&&n.$session_id)?{batchGroup:h.properties.$session_id+(h.properties.$window_id?`-${h.properties.$window_id}`:"")}:{}),i?.transport?{transport:i.transport}:{}),R.length?{fireCallbackOnDrop:!0,callback:F=>{if(F.statusCode>=200&&300>F.statusCode)for(const{channel:j,update:q}of R)this.nd(j,q.value)}}:{});if(!this.config.request_batching||i&&!i?._batchKey||i?.send_instantly){var W;let F;!T.transport&&!T.callback&&ke((W=this.config.request_headers)!==null&&W!==void 0?W:{})&&this.ph&&(F="sendBeacon"),this.Eh(T,F)}else this.Mh.enqueue(T);return h}_addCaptureHook(t){return this.on("eventCaptured",s=>t(s.event,s))}getExtension(t){var s;return(s=this.od)===null||s===void 0?void 0:s.getExtension(t)}Bh(){var t;return(t=this.od)!==null&&t!==void 0?t:this.od=new Rh(this)}dr(t){this._h.push(t);let s=!0;return()=>{if(!s)return;s=!1;const i=this._h.indexOf(t);i!==-1&&this._h.splice(i,1)}}Dh(t=!0){var s;return!!(!((s=this.persistence)===null||s===void 0)&&s.consumeCookieIdentityChange())&&(this.Lh(t),!0)}Lh(t=!0){var s,i,r;this.$h=null,((s=this.persistence)===null||s===void 0?void 0:s.get_property("$user_state"))==="anonymous"&&((r=this.sessionPersistence)===null||r===void 0||r.clear(),this.yh.clear(),this.ad()),(i=this.featureFlags)===null||i===void 0||i.reset(),t&&this.reloadFeatureFlags()}calculateEventProperties(t,s,i,r,n){if(i=i||new Date,!this.persistence||!this.sessionPersistence)return s;this.ah(),this.persistence.syncCookieProperties(),this.Dh();const o=n?void 0:this.persistence.remove_event_timer(t);let a=f({},s);if(a.token=this.config.token,a.$config_defaults=this.config.defaults==="latest"?qh:this.config.defaults,this.nh()&&(a[ll]=!0),t==="$snapshot"){const _=f(f({},this.persistence.properties()),this.sessionPersistence.properties());return a.distinct_id=_.distinct_id,(!N(a.distinct_id)&&!oe(a.distinct_id)||as(a.distinct_id))&&E.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),a}const l=(function(_,b,k,$=!1){var S,A,P,R;if(!be)return{};const B=_?[...Bt,...b||[]]:[],[V,T]=Sa(be),[W,F]=(function(he){for(let me=0;vn.length>me;me++){const[Ye,bt,xe]=vn[me],Le=he.match(Ye);if(Le){const lt=xe&&he.match(xe)||Le;return[bt,lt?.[1]||""]}}return["",""]})(be),j=(function(){const he="u">typeof navigator?navigator:void 0;return he?.brave?{brave:!0}:{}})(),q={};x(k)||(q.detectGoogleSearchApp=k);const K={},H=(S=navigator)===null||S===void 0||(S=S.userAgentData)===null||S===void 0?void 0:S.platform,re=(A=navigator)===null||A===void 0?void 0:A.maxTouchPoints,ce=w==null||(P=w.screen)===null||P===void 0?void 0:P.width,ae=w==null||(R=w.screen)===null||R===void 0?void 0:R.height,Ae=w?.devicePixelRatio;x(H)||(K.userAgentDataPlatform=H),x(re)||(K.maxTouchPoints=re),x(ce)||(K.screenWidth=ce),x(ae)||(K.screenHeight=ae),x(Ae)||(K.devicePixelRatio=Ae);const _e=ee(Yr({$os:V,$os_version:T,$browser:Ea(be,navigator.vendor,j,q),$webview_app:W,$webview_app_version:F,$device:Pa(be),$device_type:Uu(be,K),$timezone:Ol(),$timezone_offset:sh()}),{$current_url:$s($?at(Y?.href):Y?.href,B,ks),$host:Y?.host,$pathname:Y?.pathname,$raw_user_agent:be.length>1e3?be.substring(0,997)+"...":be,$browser_version:Vu(be,navigator.vendor,j,q),$browser_language:jl(),$browser_language_prefix:th(),$screen_height:w?.screen.height,$screen_width:w?.screen.width,$viewport_height:w?.innerHeight,$viewport_width:w?.innerWidth,$lib:Je.LIB_NAME,$lib_version:Je.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3});return Je.SDK_DIST_CHANNEL&&(_e.$sdk_dist_channel=Je.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:_,windowId:b}=this.sessionManager.checkAndGetSessionAndWindowId(n,i.getTime(),!0);a.$session_id=_,a.$window_id=b}this.sessionPropsManager&&ee(a,this.sessionPropsManager.getSessionProps());try{var u;if(this.sessionRecording){const _=this.sessionRecording.sdkDebugProperties,b=!this.wh&&xo(t);for(const k in _)(b||I(Lh,k))&&(a[k]=_[k])}a.$sdk_debug_retry_queue_size=(u=this.Ph)===null||u===void 0?void 0:u.length}catch(_){a.$sdk_debug_error_capturing_properties=String(_)}let c;if(this.requestRouter.region===Ir&&(a.$lib_custom_api_host=this.config.api_host),c=t!=="$pageview"||n?t!=="$pageleave"||n?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(i):this.pageViewManager.doPageView(i,r),a=ee(a,c),t==="$pageview"&&C&&(a.title=C.title),!x(o)){const _=i.getTime()-o;a.$duration=parseFloat((_/1e3).toFixed(3))}be&&this.config.opt_out_useragent_filter&&(a.$browser_type=this._is_bot()?"bot":"browser");const d=this.persistence.properties(),h=this.sessionPersistence.properties(),p=a.$groups,v=d.$groups;D(p)&&!ke(p)&&(a.$groups=f(f({},D(v)?v:{}),p)),J(["$referrer","$referring_domain"],_=>{_ in d&&delete h[_]});const m={};if(this._h.length>0)for(const _ of this._h.slice())try{ee(m,_())}catch(b){E.error("Failed to produce browser extension event properties",b)}a=ee({},l,d,h,f(f({},m),a)),a.$is_identified=this._isIdentified(),O(this.config.property_denylist)?J(this.config.property_denylist,function(_){delete a[_]}):E.error(_u+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);const g=this.config.sanitize_properties;g&&(E.error(wo),a=g(a,t));const y=this.ld();return a.$process_person_profile=y,y&&!n&&this.ud("_calculate_event_properties"),a}rd(t,s=!0,i=!1){var r;if(!this.persistence||!this.ld()||this.mh&&!i)return t;const n=this.persistence.get_initial_props(),o=(r=this.sessionPropsManager)===null||r===void 0?void 0:r.getSetOnceProps();let a=ee({},n,o||{},t||{});const l=this.config.sanitize_properties;return l&&(E.error(wo),a=l(a,"$set_once")),s&&(this.mh=!0),ke(a)?void 0:a}register(t,s){var i;(i=this.persistence)===null||i===void 0||i.register(t,s)}register_once(t,s,i){var r;(r=this.persistence)===null||r===void 0||r.register_once(t,s,i)}register_for_session(t){var s,i;(s=this.persistence)===null||s===void 0||s.syncCookieProperties(),this.Dh(),(i=this.sessionPersistence)===null||i===void 0||i.register(t),Object.keys(t).forEach(r=>this.yh.add(r)),this.ad()}unregister(t){var s;(s=this.persistence)===null||s===void 0||s.unregister(t)}unregister_for_session(t){var s;(s=this.sessionPersistence)===null||s===void 0||s.unregister(t),this.yh.delete(t),this.ad()}hd(t,s){this.register({[t]:s})}Rh(){this.yh.forEach(t=>{var s;(s=this.sessionPersistence)===null||s===void 0||s.unregister(t)}),this.yh.clear(),this.ad()}ad(){var t;if(!this.bh)return;if(this.config.persistence==="memory"||!((t=this.sessionPersistence)===null||t===void 0)&&t.hi||!X.Et())return void X.Pt(this.bh);const s=[];this.yh.forEach(i=>s.push(i)),s.length>0?X.At(this.bh,s):X.Pt(this.bh)}getFeatureFlag(t,s){var i;return(i=this.featureFlags)===null||i===void 0?void 0:i.getFeatureFlag(t,s)}getFeatureFlagPayload(t){var s;return(s=this.featureFlags)===null||s===void 0?void 0:s.getFeatureFlagPayload(t)}getFeatureFlagResult(t,s){var i;return(i=this.featureFlags)===null||i===void 0?void 0:i.getFeatureFlagResult(t,s)}getAllFeatureFlags(){var t,s;return(t=(s=this.featureFlags)===null||s===void 0?void 0:s.getAllFeatureFlags())!==null&&t!==void 0?t:[]}isFeatureEnabled(t,s){var i,r;return(i=(r=this.featureFlags)===null||r===void 0?void 0:r.isFeatureEnabled(t,s))!==null&&i!==void 0?i:s?.defaultValue}reloadFeatureFlags(){var t;(t=this.featureFlags)===null||t===void 0||t.reloadFeatureFlags()}updateFlags(t,s,i){var r;(r=this.featureFlags)===null||r===void 0||r.updateFlags(t,s,i)}updateEarlyAccessFeatureEnrollment(t,s,i){var r;(r=this.featureFlags)===null||r===void 0||r.updateEarlyAccessFeatureEnrollment(t,s,i)}getEarlyAccessFeatures(t,s=!1,i){var r;return(r=this.featureFlags)===null||r===void 0?void 0:r.getEarlyAccessFeatures(t,s,i)}on(t,s){return this.ur.on(t,s)}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:Pt}),()=>{})}onSessionId(t){var s,i;return(s=(i=this.sessionManager)===null||i===void 0?void 0:i.onSessionId(t))!==null&&s!==void 0?s:()=>{}}getSurveys(t,s=!1){this.surveys?this.surveys.getSurveys(t,s):t([],{isLoaded:!1,error:Pt})}getActiveMatchingSurveys(t,s=!1){this.surveys?this.surveys.getActiveMatchingSurveys(t,s):t([],{isLoaded:!1,error:Pt})}onActiveMatchingSurveysChanged(t){return this.surveys?this.surveys.onActiveMatchingSurveysChanged(t):(t([],{isLoaded:!1,error:Pt}),()=>{})}renderSurvey(t,s){var i;(i=this.surveys)===null||i===void 0||i.renderSurvey(t,s)}displaySurvey(t,s=Sh){var i;(i=this.surveys)===null||i===void 0||i.displaySurvey(t,s)}cancelPendingSurvey(t){var s;(s=this.surveys)===null||s===void 0||s.cancelPendingSurvey(t)}canRenderSurvey(t){var s,i;return(s=(i=this.surveys)===null||i===void 0?void 0:i.canRenderSurvey(t))!==null&&s!==void 0?s:{visible:!1,disabledReason:Pt}}canRenderSurveyAsync(t,s=!1){var i,r;return(i=(r=this.surveys)===null||r===void 0?void 0:r.canRenderSurveyAsync(t,s))!==null&&i!==void 0?i:Promise.resolve({visible:!1,disabledReason:Pt})}dd(t){return!t||as(t)?(E.critical("Unique user id has not been set in posthog.identify"),!1):t==="$posthog_cookieless"?(E.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())||(E.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,s,i){if(!this.__loaded||!this.persistence)return E.uninitializedWarning("posthog.identify");if(oe(t)&&(t=t.toString(),E.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),!this.dd(t)||!this.ud("posthog.identify"))return;this.ah();const r=this.get_distinct_id(),n=this.persistence.syncCookieProperties()&&this.get_distinct_id()!==r,o=this.Dh(!1),a=this.persistence.ku();let l=!1;try{const c=this.get_distinct_id();this.register({$user_id:t}),this.get_property("$device_id")||this.register_once({$had_persisted_distinct_id:!0,$device_id:c},""),t!==c&&t!==this.get_property("__alias")&&(this.unregister(ti),this.register({distinct_id:t}));const d=(this.persistence.get_property("$user_state")||"anonymous")===Ge,h=t!==c,p=!h&&d;if(h&&d){var u;const v=this.config.reuseAnonymousId?{distinct_id:t}:{distinct_id:t,$anon_distinct_id:c};this.persistence.set_property(fe,Hs),this.setPersonPropertiesForFlags({$set:s||{},$set_once:i||{}},!1),this.config.cookieWinsOnConflict&&this.persistence.Su(),this.capture("$identify",v,{$set:s||{},$set_once:i||{}})&&(this.$h=Vi(t,s,i)),(u=this.featureFlags)===null||u===void 0||u.setAnonymousDistinctId(this.config.reuseAnonymousId?void 0:c)}else if(p){this.persistence.set_property(fe,Hs);const v=s||{},m=i||{};this.setPersonPropertiesForFlags({$set:v,$set_once:m},!1),this.config.cookieWinsOnConflict&&this.persistence.Su(),this.capture("$set",{$set:v,$set_once:m})&&(this.$h=Vi(t,s,i))}else(s||i)&&this.setPersonProperties(s,i);h||n||o?(this.reloadFeatureFlags(),this.featureFlags?this.featureFlags.resetFlagCallReported():this.unregister(We)):p&&(s||i)&&this.reloadFeatureFlags(),l=!0}finally{a&&this.persistence.Cu(l)}}setPersonProperties(t,s){if(!t&&!s||!this.ud("posthog.setPersonProperties"))return;const i=Vi(this.get_distinct_id(),t,s);this.$h!==i?(this.setPersonPropertiesForFlags({$set:t||{},$set_once:s||{}},!0),this.capture("$set",{$set:t||{},$set_once:s||{}})&&(this.$h=i)):E.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}unsetPersonProperties(t){var s;const i=(O(t)?t:[t]).filter(r=>N(r)&&r.length>0);i.length!==0&&this.ud("posthog.unsetPersonProperties")&&((s=this.featureFlags)===null||s===void 0||s.unsetPersonPropertiesForFlags(i,!0),this.capture("$set",{$unset:i}),this.$h=null)}group(t,s,i){var r;if(!t||!s)return void E.error("posthog.group requires a group type and group key");(r=this.persistence)===null||r===void 0||r.syncCookieProperties(),this.Dh();const n=this.getGroups(),o=n[t]!==s;if(o&&this.resetGroupPropertiesForFlags(t),this.register({$groups:f(f({},n),{},{[t]:s})}),(o||i)&&this.ld()){const a={$group_type:t,$group_key:s};i&&(a.$group_set=i),this.capture(jn,a)}i&&this.setGroupPropertiesForFlags({[t]:i}),o&&!i&&this.reloadFeatureFlags()}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(t,s=!0){var i;(i=this.featureFlags)===null||i===void 0||i.setPersonPropertiesForFlags(t,s)}resetPersonPropertiesForFlags(t=!0){var s;(s=this.featureFlags)===null||s===void 0||s.resetPersonPropertiesForFlags(t)}setGroupPropertiesForFlags(t,s=!0){var i;this.ud("posthog.setGroupPropertiesForFlags")&&((i=this.featureFlags)===null||i===void 0||i.setGroupPropertiesForFlags(t,s))}resetGroupPropertiesForFlags(t){var s;(s=this.featureFlags)===null||s===void 0||s.resetGroupPropertiesForFlags(t)}reset(t){const s=we(t)?t:t?.resetDeviceID,i=we(t)||t==null?void 0:t.bootstrap;this.vd(s,!1,i)}vd(t,s=!1,i){var r,n,o,a,l,u;if(E.info("reset"),!this.__loaded)return E.uninitializedWarning("posthog.reset");const c=i?.sessionID;this.config.bootstrap=i||((r=this.Th)===null||r===void 0?void 0:r.bootstrap)||{},(n=this.featureFlags)===null||n===void 0||(o=n.updateConfig)===null||o===void 0||o.call(n,this.config,this.Qu());const d=this.get_property(zr),h=this.get_property(Ai),p=this.get_property(ds);(a=this.sessionRecording)===null||a===void 0||a.flushBeforeIdentityReset();const v=this.is_capturing();s||this.consent.reset(),s||!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 m=(l=this.persistence)===null||l===void 0||(u=l.ku)===null||u===void 0?void 0:u.call(l),g=this.uh;this.uh=g||s;let y=!1;try{var _,b,k,$,S,A,P,R,B,V,T,W,F;if((_=this.persistence)===null||_===void 0||_.clear(),(b=this.sessionPersistence)===null||b===void 0||b.clear(),this.yh.clear(),this.ad(),x(p)||(V=this.persistence)===null||V===void 0||V.register({$session_recording_remote_config:p}),(k=this.surveys)===null||k===void 0||k.reset(),($=this.featureFlags)===null||$===void 0||$.reset(),(S=this.conversations)===null||S===void 0||S.reset(),(A=this.logs)===null||A===void 0||A.reset(),(P=this.metrics)===null||P===void 0||P.reset(),(R=this.persistence)===null||R===void 0||R.set_property("$user_state","anonymous"),(B=this.sessionManager)===null||B===void 0||B.resetSessionId(),this.$h=null,this.config.cookieless_mode==="always")this.register_once({distinct_id:Ci,$device_id:null},"");else{const H=this.config.get_device_id(Re());this.register_once({distinct_id:H,$device_id:t?H:d},""),t||x(h)||this.register({[Ai]:h})}if(this.register({$last_posthog_reset:new Date().toISOString()},1),i&&(i.distinctID&&!this.nh()&&((F=this.persistence)===null||F===void 0||F.set_property("$user_state",i.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:i.distinctID})),(T=this.featureFlags)===null||T===void 0||T.initialize(),!L(c)&&!(!((W=this.sessionManager)===null||W===void 0)&&W.setBootstrapSessionId(c,!0)))){const H=f({},i);delete H.sessionID,this.config.bootstrap=H}delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,y=!0}finally{var j,q;this.uh=g,m&&((j=this.persistence)===null||j===void 0||(q=j.Cu)===null||q===void 0||q.call(j,y))}var K;this.cr&&((K=this.conversations)===null||K===void 0||K.onRemoteConfig(this.cr)),this.reloadFeatureFlags()}shutdown(t){var s=this;return Q(function*(){if(!s.__loaded)return void E.uninitializedWarning("posthog.shutdown");s.gh=!0,clearTimeout(s.Fh),s.Fh=void 0;const i=s.zh;s.zh=void 0;for(const r of[()=>{var n;return(n=s.sessionRecording)===null||n===void 0?void 0:n.dispose()},()=>{var n;return(n=s.logs)===null||n===void 0?void 0:n.flushLogs("sendBeacon")},()=>{var n;return(n=s.metrics)===null||n===void 0?void 0:n.flush("sendBeacon")},()=>{var n;return(n=s.metrics)===null||n===void 0?void 0:n.dispose()},()=>{var n;return(n=s.logs)===null||n===void 0?void 0:n.dispose()},()=>{var n;return(n=s.surveys)===null||n===void 0?void 0:n.dispose()},()=>{var n;return(n=s.autocapture)===null||n===void 0?void 0:n.dispose()},()=>i?.(),()=>{var n;return(n=s.Mh)===null||n===void 0?void 0:n.unload()},()=>{var n;return(n=s.Ph)===null||n===void 0?void 0:n.unload()},()=>{var n;return(n=s.featureFlags)===null||n===void 0?void 0:n.destroy()},()=>{var n;return(n=s.persistence)===null||n===void 0?void 0:n.destroy()},()=>{var n;return(n=s.sessionPersistence)===null||n===void 0?void 0:n.destroy()}])try{const n=r();n&&ne(n.then)&&n.then(void 0,o=>{E.error("Error during shutdown",o)})}catch(n){E.error("Error during shutdown",n)}})()}setIdentity(t,s){var i;delete this.config.identity_claims,this.config.identity_distinct_id=t,this.config.identity_hash=s,this.alias(t),(i=this.conversations)===null||i===void 0||i.fd()}clearIdentity(){var t;delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,(t=this.conversations)===null||t===void 0||t.pd()}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var t,s;return(t=(s=this.sessionManager)===null||s===void 0?void 0:s.checkAndGetSessionAndWindowId(!0).sessionId)!==null&&t!==void 0?t:""}get_session_replay_url(t){if(!this.sessionManager)return"";const{sessionId:s,sessionStartTimestamp:i}=this.sessionManager.checkAndGetSessionAndWindowId(!0);let r=this.requestRouter.endpointFor("ui",`/project/${this.config.token}/replay/${s}`);if(t?.withTimestamp&&i){var n;const o=(n=t.timestampLookBack)!==null&&n!==void 0?n:10;if(!i)return r;r+=`?t=${Math.max(Math.floor((new Date().getTime()-i)/1e3)-o,0)}`}return r}alias(t,s){return t===this.get_property("$people_distinct_id")?(E.critical("Attempting to create alias for existing People user - aborting."),-2):this.ud("posthog.alias")?(x(s)&&(s=this.get_distinct_id()),t!==s?(this.hd(ti,t),this.capture("$create_alias",{alias:t,distinct_id:s})):(E.warn("alias matches current distinct_id - skipping api call."),this.identify(t),-1)):void 0}set_config(t){const s=f({},this.config);if(D(t)){var i,r,n,o,a,l,u,c,d,h,p,v,m,g;ee(this.config,Eo(t));const $=this.fh();if(this.persistence){const A=this.config.persistence==="sessionStorage"||this.config.persistence==="memory";var y,_;if(A&&this.sessionPersistence!==this.persistence&&((y=this.sessionPersistence)===null||y===void 0||y.remove(),(_=this.sessionPersistence)===null||_===void 0||_.destroy()),this.persistence.update_config(this.config,s,$),A)this.sessionPersistence=this.persistence;else if(this.sessionPersistence===this.persistence)this.sessionPersistence=new Di(f(f({},this.config),{},{persistence:"sessionStorage"}),$,!1);else{var b;(b=this.sessionPersistence)===null||b===void 0||b.update_config(f(f({},this.config),{},{persistence:"sessionStorage"}),f(f({},s),{},{persistence:"sessionStorage"}),$)}}const S=this.Ch(this.config.debug);var k;we(S)&&(this.config.debug=S),we(this.config.debug)&&(this.config.debug?($e.DEBUG=!0,z.Et()&&z.At("ph_debug",!0),E.info("set_config",{config:t,oldConfig:s,newConfig:f({},this.config)})):($e.DEBUG=!1,z.Et()&&z.Pt("ph_debug"))),(i=this.featureFlags)===null||i===void 0||(r=i.updateConfig)===null||r===void 0||r.call(i,this.config,this.Qu()),(n=this.exceptionObserver)===null||n===void 0||n.onConfigChange(),(o=this.exceptions)===null||o===void 0||o.onConfigChange(),(a=this.metrics)===null||a===void 0||a.onConfigChange(),(l=this.webMCP)===null||l===void 0||l.startIfEnabled(),(u=this.sessionRecording)===null||u===void 0||u.startIfEnabledOrStop(),(c=this.tracingHeaders)===null||c===void 0||c.startIfEnabledOrStop(),(d=this.autocapture)===null||d===void 0||d.startIfEnabled(),(h=this.heatmaps)===null||h===void 0||h.startIfEnabled(),("capture_pageview"in t||"disable_capture_url_hashes"in t)&&((k=this.historyAutocapture)===null||k===void 0||k.startIfEnabledOrStop()),(p=this.exceptionObserver)===null||p===void 0||p.startIfEnabledOrStop(),(v=this.deadClicksAutocapture)===null||v===void 0||v.startIfEnabledOrStop(),(m=this.surveys)===null||m===void 0||m.loadIfEnabled(),this.hh(),(g=this.externalIntegrations)===null||g===void 0||g.startIfEnabledOrStop(),!s.segment&&this.config.segment&&this.persistence&&io(this,_s,!1)}}_overrideSDKInfo(t,s){$e.LIB_NAME=t,$e.LIB_VERSION=s}startSessionRecording(t){const s=t===!0,i={sampling:s||!!t?.sampling,linked_flag:s||!!t?.linked_flag,url_trigger:s||!!t?.url_trigger,event_trigger:s||!!t?.event_trigger};var r,n,o,a,l;Object.values(i).some(Boolean)&&((r=this.sessionManager)===null||r===void 0||r.checkAndGetSessionAndWindowId(),i.sampling&&((n=this.sessionRecording)===null||n===void 0||n.overrideSampling()),i.linked_flag&&((o=this.sessionRecording)===null||o===void 0||o.overrideLinkedFlag()),i.url_trigger&&((a=this.sessionRecording)===null||a===void 0||a.overrideTrigger("url")),i.event_trigger&&((l=this.sessionRecording)===null||l===void 0||l.overrideTrigger("event"))),this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var t;return!!(!((t=this.sessionRecording)===null||t===void 0)&&t.started)}captureException(t,s){try{if(!this.exceptions)return;const i=this.exceptions.buildProperties(t,{handled:!0,syntheticException:new Error("PostHog syntheticException")});return this.exceptions.sendExceptionEvent(f(f({},i),s))}catch{return}}addExceptionStep(t,s){var i;(i=this.exceptions)===null||i===void 0||i.addExceptionStep(t,s)}captureLog(t){var s;(s=this.logs)===null||s===void 0||s.captureLog(t)}get logger(){var t,s;return(t=(s=this.logs)===null||s===void 0?void 0:s.logger)!==null&&t!==void 0?t:tt.gd}startExceptionAutocapture(t){this.set_config({capture_exceptions:t==null||t})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(t){var s,i;return(s=(i=this.toolbar)===null||i===void 0?void 0:i.loadToolbar(t))!==null&&s!==void 0&&s}get_property(t){var s;return(s=this.persistence)===null||s===void 0?void 0:s.props[t]}getSessionProperty(t){var s;return(s=this.sessionPersistence)===null||s===void 0?void 0:s.props[t]}toString(){var t;let s=(t=this.config.name)!==null&&t!==void 0?t:os;return s!==os&&(s="posthog."+s),s}_isIdentified(){var t,s;return((t=this.persistence)===null||t===void 0?void 0:t.get_property("$user_state"))==="identified"||((s=this.sessionPersistence)===null||s===void 0?void 0:s.get_property("$user_state"))==="identified"}ld(){var t,s;return!(this.config.person_profiles==="never"||this.config.person_profiles==="identified_only"&&!this._isIdentified()&&ke(this.getGroups())&&!(!((t=this.persistence)===null||t===void 0||(t=t.props)===null||t===void 0)&&t.__alias)&&!(!((s=this.persistence)===null||s===void 0||(s=s.props)===null||s===void 0)&&s.$epp))}Qh(){return this.config.capture_pageleave===!0||this.config.capture_pageleave==="if_capture_pageview"&&!!this.config.capture_pageview}createPersonProfile(){this.ld()||this.ud("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.ud("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}ud(t){return this.config.person_profiles==="never"?(E.error(t+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.sh(),this.hd(Wr,!0),!0)}fh(){if(this.config.cookieless_mode==="always")return!0;const t=this.consent.isOptedOut();return this.config.disable_persistence||t&&!(!this.config.opt_out_persistence_by_default&&this.config.cookieless_mode!=="on_reject")}hh(){var t,s;const i=this.fh();var r,n,o;return this.is_capturing()||(r=this.logs)===null||r===void 0||r.md(),((t=this.persistence)===null||t===void 0?void 0:t.hi)!==i&&((n=this.persistence)===null||n===void 0||n.set_disabled(i)),((s=this.sessionPersistence)===null||s===void 0?void 0:s.hi)!==i&&((o=this.sessionPersistence)===null||o===void 0||o.set_disabled(i)),this.ad(),i}opt_in_capturing(t){var s;if(this.config.cookieless_mode!=="always"){if(this.nh()){var i,r,n,o,a,l;(i=this.sessionRecording)===null||i===void 0||i.dispose({discardBufferedEvents:!0}),this.vd(!0,!0),(r=this.sessionManager)===null||r===void 0||r.destroy(),(n=this.pageViewManager)===null||n===void 0||n.destroy(),this.sessionManager=new _o(this),this.pageViewManager=new ro(this),this.persistence&&(this.sessionPropsManager=new vo(this,this.sessionManager,this.persistence));const v=(o=(a=this.config.__extensionClasses)===null||a===void 0?void 0:a.sessionRecording)!==null&&o!==void 0?o:(l=tt.__defaultExtensionClasses)===null||l===void 0?void 0:l.sessionRecording;var u,c;v&&(this.sessionRecording=this.ih(this.sessionRecording,new v(this)),this.cr&&((u=this.sessionRecording)===null||u===void 0||(c=u.onRemoteConfig)===null||c===void 0||c.call(u,this.cr)))}var d,h,p;this.consent.optInOut(!0),this.hh(),this.Wh(),(s=this.sessionRecording)===null||s===void 0||s.startIfEnabledOrStop(),this.config.cookieless_mode=="on_reject"&&((d=this.surveys)===null||d===void 0||d.loadIfEnabled(),(h=this.conversations)===null||h===void 0||h.loadIfEnabled()),(x(t?.captureEventName)||t?.captureEventName)&&this.capture((p=t?.captureEventName)!==null&&p!==void 0?p:"$opt_in",t?.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.Vh()}else E.warn(bo)}opt_out_capturing(){this.config.cookieless_mode!=="always"?(this.consent.optInOut(!1),this.hh(),this.config.cookieless_mode==="on_reject"&&this.dh()):E.warn(bo)}dh(){var t,s;const i=this.sessionRecording;i?.dispose({discardBufferedEvents:!0}),this.get_distinct_id()!=="$posthog_cookieless"&&this.vd(!0,!0),this.register({distinct_id:Ci,$device_id:null}),this.th(i),this.sessionRecording=void 0,(t=this.sessionManager)===null||t===void 0||t.destroy(),(s=this.pageViewManager)===null||s===void 0||s.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,this.config.capture_pageview&&this.Vh(),this.Wh()}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 t===1?"granted":t===0?"denied":"pending"}is_capturing(){return!this.uh&&(this.config.cookieless_mode==="always"||(this.config.cookieless_mode==="on_reject"?this.consent.isRejected()||this.consent.isOptedIn():!this.has_opted_out_capturing()))}clear_opt_in_out_capturing(){this.consent.reset(),this.hh()}_is_bot(){return pe?au(pe,this.config.custom_blocked_useragents):void 0}Vh(){C&&(C.visibilityState==="visible"?this.kh||(this.kh=!0,this.capture(Kr,{title:C.title},{send_instantly:!0}),this.Sh&&(C.removeEventListener(Rt,this.Sh),this.Sh=null)):this.Sh||(this.Sh=this.Vh.bind(this),U(C,Rt,this.Sh)))}debug(t){t===!1?(w?.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(w?.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}))}Qu(){const t=this.Th||{};return"advanced_disable_flags"in t?!!t.advanced_disable_flags:this.config.advanced_disable_flags!==!1?!!this.config.advanced_disable_flags:this.config.advanced_disable_decide===!0?(E.warn("Config field 'advanced_disable_decide' is deprecated. Please use 'advanced_disable_flags' instead. The old field will be removed in a future major version."),!0):(function(s,i,r,n,o){const a=i in s&&!L(s[i]),l=r in s&&!L(s[r]);return a?s[i]:!!l&&(o&&o.warn(`Config field '${r}' is deprecated. Please use '${i}' instead. The old field will be removed in a future major version.`),s[r])})(t,"advanced_disable_flags","advanced_disable_decide",0,E)}Os(t){var s;if(L(this.config.before_send))return t;const i=Object.keys((s=t.properties)!==null&&s!==void 0?s:{}).filter(Mu),r=O(this.config.before_send)?this.config.before_send:[this.config.before_send];let n=t;for(const o of r)try{if(n=o(n),L(n)){const a=`Event '${t.event}' was rejected in beforeSend function`;return Ou(t.event)?E.warn(`${a}. This can cause unexpected behavior.`):E.info(a),null}n.properties&&!ke(n.properties)||E.warn(`Event '${t.event}' has no properties after beforeSend function, this is likely an error.`)}catch(a){return E.error(`Error in beforeSend function for event '${t.event}':`,a),null}for(const o of i)if(n.properties&&L(n.properties[o]))return E.warn(`Event '${t.event}' had its '${o}' 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(t=this.pageViewManager.Rl)===null||t===void 0?void 0:t.pageViewId}captureTraceFeedback(t,s){this.capture("$ai_feedback",{$ai_trace_id:String(t),$ai_feedback_text:s})}captureTraceMetric(t,s,i){this.capture("$ai_metric",{$ai_trace_id:String(t),$ai_metric_name:s,$ai_metric_value:String(i)})}Ch(t){const s=we(t)&&!t,i=z.Et()&&z.Ot("ph_debug")==="true";return!s&&(!!i||t)}};ms.__defaultExtensionClasses={},ms.gd=(()=>{const e=()=>{};return{trace:e,debug:e,info:e,warn:e,error:e,fatal:e}})(),(function(e,t){for(let s=0;t.length>s;s++)e.prototype[t[s]]=Fd(e.prototype[t[s]])})(ms,["identify"]);const Vh=["[data-ph-capture-value]"];var Uh=class{constructor(e){this._instance=e}refresh(e){var t;const s=this._instance.config,i=D(s.autocapture)?s.autocapture:void 0;e.enabled=!!s.autocapture,e.rageclick=s.rageclick,e.maskAllElementAttributes=s.mask_all_element_attributes,e.maskAllText=s.mask_all_text,e.disableCaptureUrlHashes=s.disable_capture_url_hashes,e.getCurrentUrl=s.get_current_url,e.remoteRequestsDisabled=this._instance.Qu(),e.url_allowlist=i?.url_allowlist,e.url_ignorelist=i?.url_ignorelist,e.dom_event_allowlist=i?.dom_event_allowlist,e.element_allowlist=i?.element_allowlist,e.css_selector_allowlist=i?.css_selector_allowlist,e.css_selector_ignorelist=i?.css_selector_ignorelist,e.element_attribute_ignorelist=i?.element_attribute_ignorelist,e.capture_copied_text=i?.capture_copied_text,e.capture_value_css_selector_allowlist=(t=i?.capture_value_css_selector_allowlist)!==null&&t!==void 0?t:Vh}};const ss=te("[ExceptionAutocapture]"),So=()=>{},Po=e=>{var t;if(ne(e))return(t=e.__posthog_layer__)!==null&&t!==void 0?t:e.__rrweb_layer__};function Vt(e,t,s){try{if(!(t in e))return So;const i={next:e[t]},r=s(function(...n){return i.next.apply(this,n)});return ne(r)&&(r.prototype=r.prototype||{},Object.defineProperties(r,{__posthog_wrapped__:{enumerable:!1,value:!0},__posthog_layer__:{enumerable:!1,value:i}})),e[t]=r,()=>{if(e[t]===r)return void(e[t]=i.next);let n=e[t],o=Po(n);for(;o;){if(o.next===r)return void(o.next=i.next);n=o.next,o=Po(n)}}}catch{return So}}const Wh=te("[TracingHeaders]"),ct=te("[Web Vitals]"),Ao=9e5,Co=["CLS","FCP","INP","LCP"],Gh=["INP","LCP"],Jh=["interactionTarget","interactionType","inputDelay","processingDuration","presentationDelay","loadState","target","url","timeToFirstByte","resourceLoadDelay","resourceLoadDuration","elementRenderDelay","largestShiftTarget","largestShiftTime","largestShiftValue","firstByteToFCP"],Ki="disabled",Fo="lazy_loading",Be=te("[SessionRecording]"),Kh=[Gr,Jr,dl,hl,pl,fl,vl,gl,_l],Yh=te("[Heatmaps]");function Yi(e){return D(e)&&"clientX"in e&&"clientY"in e&&oe(e.clientX)&&oe(e.clientY)}const Rs=te("[Product Tours]"),Xi=e=>{var t;return!e.config.disable_product_tours&&!!(!((t=e.persistence)===null||t===void 0)&&t.get_property(Ur))},Xh=["$set_once","$set"],De=te("[SiteApps]"),Io="Error while initializing PostHog app with config id ";function At(e,t,s){if(L(e))return!1;switch(s){case"exact":return e===t;case"contains":{const i=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(i,"i").test(e)}case"regex":try{return new RegExp(t).test(e)}catch{return!1}default:return!1}}var Qh=class{constructor(e){this.Ai=e,this._o=new Set,this.wo=new Set,this.ko=new ai,this.So=(t,s)=>this.xo(t,s)&&this.$o(t,s)&&this.Co(t,s)&&this.To(t,s),this.xo=(t,s)=>!s?.event||t?.event===s?.event}init(){var e,t;x((e=this.Ai)===null||e===void 0?void 0:e.subscribeCapture)||(this.Io=(t=this.Ai)===null||t===void 0?void 0:t.subscribeCapture((s,i)=>{this.on(s,i)}))}dispose(){var e,t,s;(e=this.Io)===null||e===void 0||e.call(this),this.Io=void 0,(t=this.Ai)===null||t===void 0||(s=t.setElementSelectors)===null||s===void 0||s.call(t,new Set,this),this.ko=new ai}register(e){var t,s;if(!x((t=this.Ai)===null||t===void 0?void 0:t.subscribeCapture)&&(e.forEach(i=>{var r;this._o.add(i),(r=i.steps)===null||r===void 0||r.forEach(n=>{this.wo.add(n?.event||"")})}),(s=this.Ai)===null||s===void 0?void 0:s.setElementSelectors)){const i=new Set;this._o.forEach(r=>{var n;(n=r.steps)===null||n===void 0||n.forEach(o=>{o?.selector&&i.add(o.selector)})}),this.Ai.setElementSelectors(i,this)}}replace(e){this._o.clear(),this.wo.clear(),this.register(e)}on(e,t){t!=null&&e.length!=0&&(this.wo.has(e)||this.wo.has(t.event))&&this._o.forEach(s=>{this.Mo(t,s)&&this.ko.emit("actionCaptured",s.name)})}Eo(e){this.onAction("actionCaptured",t=>e(t))}Mo(e,t){if(t?.steps==null)return!1;for(const s of t.steps)if(this.So(e,s))return!0;return!1}onAction(e,t){return this.ko.on(e,t)}$o(e,t){if(t?.url){var s;let n=e==null||(s=e.properties)===null||s===void 0?void 0:s.$current_url;if(!e?.properties||!("$current_url"in e.properties))try{var i,r;n=(i=this.Ai)===null||i===void 0||(r=i.getActionUrl)===null||r===void 0?void 0:r.call(i)}catch{return!1}if(!n||typeof n!="string"||!At(n,t.url,t.url_matching||"contains"))return!1}return!0}Co(e,t){return!!this.Po(e,t)&&!!this.Ro(e,t)&&!!this.Ao(e,t)}Po(e,t){var s;if(!t?.href)return!0;const i=this.Fo(e);if(i.length>0)return i.some(n=>At(n.href,t.href,t.href_matching||"exact"));const r=(e==null||(s=e.properties)===null||s===void 0?void 0:s.$elements_chain)||"";return!!r&&At((function(n){const o=n.match(/(?::|")href="(.*?)"/);return o?o[1]:""})(r),t.href,t.href_matching||"exact")}Ro(e,t){var s;if(!t?.text)return!0;const i=this.Fo(e);if(i.length>0)return i.some(l=>At(l.text,t.text,t.text_matching||"exact")||At(l.$el_text,t.text,t.text_matching||"exact"));const r=(e==null||(s=e.properties)===null||s===void 0?void 0:s.$elements_chain)||"";return!!r&&(n=(function(l){const u=[],c=/(?::|")text="(.*?)"/g;let d;for(;!L(d=c.exec(l));)u.includes(d[1])||u.push(d[1]);return u})(r),o=t.text,a=t.text_matching||"exact",n.some(l=>At(l,o,a)));var n,o,a}Ao(e,t){var s,i;if(!t?.selector)return!0;const r=e==null||(s=e.properties)===null||s===void 0?void 0:s.$element_selectors;if(r?.includes(t.selector))return!0;const n=(e==null||(i=e.properties)===null||i===void 0?void 0:i.$elements_chain)||"";if(t.selector_regex&&n)try{return new RegExp(t.selector_regex).test(n)}catch{}return!1}Fo(e){var t;return(e==null||(t=e.properties)===null||t===void 0?void 0:t.$elements)==null?[]:e?.properties.$elements}To(e,t){return!t?.properties||t.properties.length===0||du(t.properties.reduce((s,i)=>{const r=O(i.value)?i.value.map(String):i.value!=null?[String(i.value)]:[];return s[i.key]={values:r,operator:i.operator||"exact"},s},{}),e?.properties)}},Zh=class{constructor(e,t){this.Oo=t,this.Do=[],this.Ai=e,this.Lo=new Map,this.No=new Map,this.qo=new Map}jo(){var e,t;this.Bo=(e=(t=this.Ai).subscribeSession)===null||e===void 0?void 0:e.call(t,s=>this.zo(s))}Ho(e){return!1}Uo(){return null}Wo(e){}Vo(){}Go(e,t){return!!e&&du(e.propertyFilters,t?.properties)}Qo(e,t){const s=new Map;return e.forEach(i=>{var r;(r=i.conditions)===null||r===void 0||(r=r[t])===null||r===void 0||(r=r.values)===null||r===void 0||r.forEach(n=>{if(n?.name){const o=s.get(n.name)||[];o.push(i.id),s.set(n.name,o)}})}),s}Zo(e,t,s){const i=(s===Qt.Activation?this.Lo:this.No).get(e);let r=[];return this.Jo(n=>{r=n.filter(o=>i?.includes(o.id))}),r.filter(n=>{var o;const a=(o=n.conditions)===null||o===void 0||(o=o[s])===null||o===void 0||(o=o.values)===null||o===void 0?void 0:o.find(l=>l.name===e);return this.Go(a,t)})}register(e){this.Ko(e,!1)}replace(e){this.Ko(e,!0)}Ko(e,t){x(this.Ai.subscribeCapture)||(this.Xo(e,t),this.Yo(e,t))}Yo(e,t){const s=e.filter(n=>{var o;return(o=n.conditions)===null||o===void 0||(o=o.actions)===null||o===void 0||(o=o.values)===null||o===void 0?void 0:o.length});var i;if(t&&this.qo.clear(),s.length===0)return void(t&&((i=this.ta)===null||i===void 0||i.replace([])));this.ta||(this.ta=new Qh(this.Ai),this.ta.init(),this.ta.Eo(n=>this.onAction(n)));const r=[];s.forEach(n=>{var o;(o=n.conditions)===null||o===void 0||(o=o.actions)===null||o===void 0||o.values.forEach(a=>{if(r.push(a),a.name){var l;const u=(l=this.qo.get(a.name))!==null&&l!==void 0?l:[];u.includes(n.id)||u.push(n.id),this.qo.set(a.name,u)}})}),t?this.ta.replace(r):this.ta.register(r)}ea(e,t){t.forEach((s,i)=>{var r;const n=(r=e.get(i))!==null&&r!==void 0?r:[];s.forEach(o=>{n.includes(o)||n.push(o)}),e.set(i,n)})}Xo(e,t){var s,i,r;const n=e.filter(u=>{var c,d;return((c=u.conditions)===null||c===void 0?void 0:c.events)&&((d=u.conditions)===null||d===void 0||(d=d.events)===null||d===void 0||(d=d.values)===null||d===void 0?void 0:d.length)>0}),o=e.filter(u=>{var c,d;return((c=u.conditions)===null||c===void 0?void 0:c.cancelEvents)&&((d=u.conditions)===null||d===void 0||(d=d.cancelEvents)===null||d===void 0||(d=d.values)===null||d===void 0?void 0:d.length)>0}),a=this.Qo(e,Qt.Activation),l=this.Qo(e,Qt.Cancellation);t?(this.Lo=a,this.No=l):(this.ea(this.Lo,a),this.ea(this.No,l)),(n.length!==0||o.length!==0||e.some(u=>{var c;return(c=u.conditions)===null||c===void 0||(c=c.actions)===null||c===void 0||(c=c.values)===null||c===void 0?void 0:c.length}))&&((s=this.Io)!==null&&s!==void 0||(this.Io=(i=(r=this.Ai).subscribeCapture)===null||i===void 0?void 0:i.call(r,(u,c)=>{this.onEvent(u,c)})))}onEvent(e,t){var s,i;const r=this.ia(),n=(t==null||(s=t.properties)===null||s===void 0?void 0:s.$survey_id)||(t==null||(i=t.properties)===null||i===void 0?void 0:i.$product_tour_id);if(n&&this.getActivatedIds().includes(n)){const a=this.na(e,n,t);if(a==="consume")return r.info("event consumed activated item, removing it",{event:e,itemId:n}),void this.sa([n]);if(a==="persist")return r.info("shown item promoted to persisted activation",{event:e,itemId:n}),this.ra(n),void this.oa([n])}if(this.No.has(e)){const a=this.Zo(e,t,Qt.Cancellation);a.length>0&&(r.info("cancel event matched, cancelling items",{event:e,itemsToCancel:a.map(l=>l.id)}),this.sa(a.map(l=>l.id)),a.forEach(l=>this.aa(l.id)))}if(!this.Lo.has(e))return;r.info("event name matched",{event:e,eventPayload:t,items:this.Lo.get(e)});const o=this.Zo(e,t,Qt.Activation);this.la(o.map(a=>a.id))}onAction(e){this.qo.has(e)&&this.la(this.qo.get(e)||[])}la(e){if(e.length===0)return;const t=!!this.Ai.getSessionId(),s=[];for(const i of e)t&&this.Ho(i)?this.ra(i)&&this.ua(i):s.push(i);s.length>0&&(this.Do=[...new Set([...this.Do,...s])]),this.ia().info("updating activated items",{activatedItems:this.getActivatedIds()}),this.ca()}ra(e){this.Do=this.Do.filter(s=>s!==e);const t=this.ha();return!t.includes(e)&&(this.da([...t,e]),this.va(),!0)}sa(e){const t=new Set(e);this.Do=this.Do.filter(r=>!t.has(r));const s=this.fa(),i=s.filter(r=>!t.has(r));i.length!==s.length&&(this.da(i),i.length===0&&this.pa()),this.oa(e),this.ca()}ca(){try{var e;(e=this.Oo)===null||e===void 0||e.call(this)}catch(t){this.ia().error("Error while handling activated items change",t)}}ga(){const e=this.Uo();if(!e)return{};const t=this.Ai.getProperty(e);return t&&typeof t=="object"?t:{}}ua(e){if(!this.Uo())return;const t=this.ga();this.Wo(f(f({},t),{},{[e]:Date.now()}))}oa(e){if(!this.Uo())return;const t=this.ga(),s={};let i=!1;for(const[r,n]of Object.entries(t))e.includes(r)?i=!0:s[r]=n;i&&(ke(s)?this.Vo():this.Wo(s))}ma(){this.Uo()&&this.Vo()}getActivationTimestamp(e){if(!this.ha().includes(e))return;const t=this.ga()[e];return oe(t)?t:void 0}fa(){const e=this.ya();return this.Ai.getProperty(e)||[]}ha(){const e=this.fa();if(e.length===0)return[];const t=this.Ai.getProperty(this.ba()),s=this.Ai.getSessionId();return s&&t===s?e:[]}va(){const e=this.Ai.getSessionId();e&&this._a(e)}pa(){this.wa()}zo(e){const t=this.Ai.getProperty(this.ba());if(t&&t!==e){const s=this.fa(),i=this.ga();s.length>0&&(this.da([]),s.filter(r=>oe(i[r])).forEach(r=>this.aa(r))),this.pa(),this.ma(),s.length>0&&this.ca()}}getActivatedIds(){return[...new Set([...this.ha(),...this.Do])].filter(e=>!this.ka(e))}dispose(){var e,t,s;(e=this.Bo)===null||e===void 0||e.call(this),this.Bo=void 0,(t=this.Io)===null||t===void 0||t.call(this),this.Io=void 0,(s=this.ta)===null||s===void 0||s.dispose(),this.ta=void 0}reset(){this.Do=[],this.fa().length>0&&this.da([]),this.pa(),this.ma(),this.ca()}getEventToItemsMap(){return this.Lo}Sa(){return this.ta}},ep=class extends Zh{constructor(e,t,s,i){var r;super({subscribeCapture(n){const o=e.onEvent(a=>n(a.event,a));return()=>o.dispose()},subscribeSession(n){const o=e.onSession(n);return()=>o.dispose()},getSessionId(){var n;return(n=e.session)===null||n===void 0?void 0:n.sessionId},getProperty:n=>e.kv.get(n),getActionUrl:s?.getActionUrl,setElementSelectors:(r=s?.setElementSelectors)!==null&&r!==void 0?r:(n,o)=>{var a;return(a=e.getExtension("autocapture"))===null||a===void 0?void 0:a.setElementSelectors(n,o)}},i),this.xa=e,this.$a=t,this.jo()}ya(){return fr}ba(){return js}Uo(){return qs}Wo(e){this.xa.kv.set({[qs]:e})}Vo(){this.xa.kv.remove(qs)}Ho(e){var t;let s;this.Jo(r=>{s=r.find(n=>n.id===e)});const i=s==null||(t=s.appearance)===null||t===void 0?void 0:t.surveyPopupDelaySeconds;return oe(i)&&i>0}Ca(){return Se.SHOWN}Jo(e){this.$a.getSurveys(e)}aa(e){this.$a.cancelPendingSurvey(e)}ia(){return G}da(e){this.xa.kv.set({[fr]:e})}_a(e){this.xa.kv.set({[js]:e})}wa(){this.xa.kv.remove(js)}ka(){return!1}na(e,t,s){var i;if(e===Se.SENT&&(s==null||(i=s.properties)===null||i===void 0?void 0:i.$survey_completed)===!1)return"ignore";let r;return this.Jo(n=>{r=n.find(o=>o.id===t)}),!r||(function(n){var o;return uu(n)&&!!(!((o=n.conditions)===null||o===void 0||(o=o.events)===null||o===void 0)&&o.repeatedActivation)||n.schedule==="always"})(r)?e===Se.SHOWN?"consume":"ignore":e===Se.SHOWN?"persist":e===Se.DISMISSED||e===Se.SENT?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}};const rn=(e,t)=>e?.then?e.then(t):t(e),Ct="SDK is not enabled or survey functionality is not yet loaded",Oo="Disabled. Not loading surveys.";var tp=class{constructor(e){this.Ta=e,this.name="surveys",this._surveyEventReceiver=null,this._surveyManager=null,this.Ia=!1,this.Ma=!1,this.Ea=[],this.Pa=[],this.Ra=null,this.Aa=null,this.Ci=!1,this.Fa=new Set,this.onRemoteConfig=t=>{if(this.Ci||this.Ar.disableSurveys)return;if(!t.ok)return this.Ma=!0,this.Oa({isLoaded:!1,error:"Remote config unavailable. Not loading surveys."}),G.warn("Remote config unavailable. Not loading surveys.");const s=t.config.surveys;if(L(s))return G.warn("Flags not loaded yet. Not loading surveys.");this.Da=we(s)?s:s.length>0,G.info(`flags response received, isSurveysEnabled: ${this.Da}`),this.loadIfEnabled()},this.Oa=t=>{this.Pa.slice().forEach(s=>this.La(s,t))}}setup(e){if(!this.Ci)return this.Na=e,rn(e.kv.initialize(),()=>{if(this.Na!==e||this.Ci)return;this.Na=void 0,this.xa=e;const t=e.onRemoteConfig(this.onRemoteConfig);this.Ci?t.dispose():(this.qa=t,this.loadIfEnabled())})}dispose(){var e,t,s,i,r;this.Ci||(this.Ci=!0,this.Na=void 0,this.xa=void 0,(e=this.qa)===null||e===void 0||e.dispose(),this.qa=void 0,(t=this._surveyEventReceiver)===null||t===void 0||t.dispose(),this._surveyEventReceiver=null,(s=this._surveyManager)===null||s===void 0||(i=s.dispose)===null||i===void 0||i.call(s),this._surveyManager=null,this.Ea=[],this.Pa.forEach(n=>{n.active=!1}),this.Pa=[],(r=this.ja)===null||r===void 0||r.call(this),this.ja=void 0,this.Ra=null,this.Fa.forEach(n=>clearTimeout(n)),this.Fa.clear())}get Ar(){return this.Ta.get()}getRenderContext(){if(!this.xa)return;const e=this;return{client:this.xa,get config(){return e.Ar},surveys:e}}initialize(){this.loadIfEnabled()}reset(){var e,t;(e=this._surveyManager)===null||e===void 0||(t=e.clearInMemoryInProgressSurveyState)===null||t===void 0||t.call(e);try{var s;(s=this._surveyEventReceiver)===null||s===void 0||s.reset(),localStorage.removeItem("lastSeenSurveyDate");const i=[];for(let r=0;r<localStorage.length;r++){const n=localStorage.key(r);(n?.startsWith("seenSurvey_")||n?.startsWith("inProgressSurvey_"))&&i.push(n)}i.forEach(r=>localStorage.removeItem(r))}catch{}this.Oa()}loadIfEnabled(){if(this.Ci||!this.xa)return;const e=this.Ar;if(this._surveyManager)return;if(this.Ia)return void G.info("Already initializing surveys, skipping...");if(e.disableSurveys)return void G.info(Oo);if(e.cookielessMode&&this.xa.isOptedOut)return void G.info("Not loading surveys in cookieless mode without consent.");const t=this.Ta.getExtensions();if(!t)return void this.Ba("PostHog Extensions not found.");if(x(this.Da)&&!e.advancedEnableSurveys)return;const s=this.Da||e.advancedEnableSurveys;this.Ia=!0,this.Ma=!1;try{const i=t.generateSurveys;if(i)return this.za(i,s),void(this.Ia=!1);const r=t.loadExternalDependency;if(!r)return this.Ba(Br),void(this.Ia=!1);r(n=>{try{if(this.Ci)return;const o=this.Ta.getExtensions();n||!o?.generateSurveys?this.Ba("Could not load surveys script",n):this.za(o.generateSurveys,s)}finally{this.Ia=!1}})}catch(i){throw this.Ia=!1,this.Ba("Error initializing surveys",i),i}}za(e,t){var s;if(this.Ci)return;this._surveyManager=e(t),this._surveyEventReceiver=this.Ha(this.xa,this.Oa);const i=(s=this.xa)===null||s===void 0?void 0:s.kv.get(rs);i&&this.Ua(i),G.info("Surveys loaded successfully"),this.Wa(),this.Oa(),this.Va({isLoaded:!0})}Ha(e,t){return new ep(e,this,void 0,t)}Ba(e,t){this.Ma=!0,G.error(e,t),this.Oa({isLoaded:!1,error:e}),this.Va({isLoaded:!1,error:e})}onSurveysLoaded(e){return this.Ea.push(e),this._surveyManager&&this.Va({isLoaded:!0}),()=>{this.Ea=this.Ea.filter(t=>t!==e)}}getSurveys(e,t=!1){if(this.Ci)return;const s=this.xa;if(!s)return e([],{isLoaded:!1,error:Ct});if(this.Ar.disableSurveys)return G.info(Oo),e([]);const i=s.kv.get(rs);if(i&&!t)return e(i,{isLoaded:!0}),void(this.Ga()&&this.getSurveys(()=>{},!0));if(this.Ra)return void this.Ra.then(({surveys:o,context:a})=>{this.Ci||e(o,a)}).catch(o=>G.error("Error in survey callback",o));const r=s.sendRequest("/api/surveys/",{method:"GET",query:{token:s.projectToken},sentAt:"query",timeoutMs:this.Ar.requestTimeoutMs}).then(o=>{try{return this.Qa(s,o)}catch(a){return G.error("Error processing surveys response",a),this.Qa(s,{statusCode:0,error:a})}},o=>this.Qa(s,{statusCode:0,error:o}));this.Ra=r;const n=()=>{this.Ra===r&&(this.Ra=null)};r.then(o=>{n(),this.Ci||(this.Oa(o.context),e(o.surveys,o.context))},n).catch(o=>G.error("Error in survey callback",o))}Qa(e,t){if(this.Ci)return{surveys:[],context:{isLoaded:!1,error:Ct}};const s=t.statusCode;if(s!==200||!t.json){const r=`Surveys API could not be loaded, status: ${s}`;return s!==0?G.error(r):t.error||G.warn(r),this.Aa=Date.now(),{surveys:[],context:{isLoaded:!1,error:r}}}this.Aa=null;const i=t.json.surveys||[];return e.kv.set({[rs]:i,[ei]:Date.now()}),this.Ua(i),{surveys:i,context:{isLoaded:!0}}}Ua(e){const t=e.filter(s=>(function(i){return!(!i.start_date||i.end_date)})(s)&&(uu(s)||(function(i){var r;return!!(!((r=i.conditions)===null||r===void 0||(r=r.actions)===null||r===void 0||(r=r.values)===null||r===void 0)&&r.length)})(s)));this.Za(t)}Za(e){var t;(t=this._surveyEventReceiver)===null||t===void 0||t.replace(e)}Ga(){return this.Ja()&&!this.Ra&&!this.Ka()}Ja(){var e;const t=(e=this.xa)===null||e===void 0?void 0:e.kv.get(ei);return oe(t)&&Date.now()-t>3e5}Ka(){return oe(this.Aa)&&3e5>Date.now()-this.Aa}markSurveyAsSeen(e,t){var s;const i={id:e,current_iteration:(s=t?.iteration)!==null&&s!==void 0?s:null};hu(i);try{localStorage.setItem("lastSeenSurveyDate",new Date().toISOString())}catch{}this.Oa()}Va(e){for(const t of this.Ea){if(this.Ci)return;try{e.isLoaded?this.getSurveys(t):t([],e)}catch(s){G.error("Error in survey callback",s)}}}getActiveMatchingSurveys(e,t=!1){if(!L(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);G.warn("init was not called")}onActiveMatchingSurveysChanged(e){var t;if(this.Ci)return()=>{};const s={callback:e,active:!0,revision:0};this.Pa.push(s),this.Wa();const i=(t=this.xa)===null||t===void 0?void 0:t.kv.get(rs);return this.Ar.disableSurveys||!this._surveyManager&&this.Ma&&!this.Ia||!i&&!L(this.Aa)&&!this.Ra?this.La(s,{isLoaded:!1}):this._surveyManager&&this.La(s),()=>{var r;s.active=!1,this.Pa=this.Pa.filter(n=>n!==s),this.Pa.length===0&&((r=this.ja)===null||r===void 0||r.call(this),this.ja=void 0)}}Wa(){var e,t,s;this._surveyManager&&this.Pa.length>0&&((e=this.ja)!==null&&e!==void 0||(this.ja=(t=(s=this.Ta).onMatchingConditionsChanged)===null||t===void 0?void 0:t.call(s,this.Oa)))}La(e,t){if(this.Ci||!e.active)return;const s=++e.revision,i=r=>{if(!this.Ci&&e.active&&s===e.revision)try{const n=t??{isLoaded:!0},o=JSON.stringify([r,n]);if(o===e.lastResult)return;e.lastResult=o,e.callback(r,n)}catch(n){G.error("Error in active matching surveys callback",n)}};try{t&&!t.isLoaded?i([]):this.getActiveMatchingSurveys(i)}catch(r){G.error("Error in active matching surveys callback",r)}}Xa(e){let t=null;return this.getSurveys(s=>{var i;t=(i=s.find(r=>r.id===e))!==null&&i!==void 0?i:null}),t}Ya(e){if(L(this._surveyManager))return{eligible:!1,reason:Ct};const t=typeof e=="string"?this.Xa(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:"Survey not found"}}tl(e){var t;if(!(!((t=this.xa)===null||t===void 0)&&t.canCapture))return{eligible:!1,reason:"PostHog is not capturing, so a survey response cannot be recorded"};if(L(this._surveyManager))return{eligible:!1,reason:Ct};const s=typeof e=="string"?this.Xa(e):e;return s?this._surveyManager.checkSurveyRenderability(s):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(e){if(L(this._surveyManager))return G.warn("init was not called"),{visible:!1,disabledReason:Ct};const t=this.tl(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return L(this._surveyManager)?(G.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:Ct})):new Promise(s=>{this.getSurveys(i=>{var r;const n=(r=i.find(o=>o.id===e))!==null&&r!==void 0?r:null;if(n){const o=this.tl(n);s({visible:o.eligible,disabledReason:o.reason})}else s({visible:!1,disabledReason:"Survey not found"})},t)})}renderSurvey(e,t,s){var i,r,n;if(!(!((i=this.xa)===null||i===void 0)&&i.canCapture))return;if(L(this._surveyManager))return void G.warn("init was not called");const o=typeof e=="string"?this.Xa(e):e;if(!o?.id)return void G.warn("Survey not found");if(!Eh.includes(o.type))return void G.warn(`Surveys of type ${o.type} cannot be rendered in the app`);const a=(r=typeof document>"u"?void 0:document)===null||r===void 0?void 0:r.querySelector(t);if(a){if(!((n=o.appearance)===null||n===void 0)&&n.surveyPopupDelaySeconds){G.info(`Rendering survey ${o.id} with delay of ${o.appearance.surveyPopupDelaySeconds} seconds`);const l=setTimeout(()=>{var u,c,d;this.Fa.delete(l),!this.Ci&&(!((u=this.xa)===null||u===void 0)&&u.canCapture)&&(G.info(`Rendering survey ${o.id} with delay of ${(c=o.appearance)===null||c===void 0?void 0:c.surveyPopupDelaySeconds} seconds`),(d=this._surveyManager)===null||d===void 0||d.renderSurvey(o,a,s),G.info(`Survey ${o.id} rendered`))},1e3*o.appearance.surveyPopupDelaySeconds);return void this.Fa.add(l)}this._surveyManager.renderSurvey(o,a,s)}else G.warn("Survey element not found")}displaySurvey(e,t){var s,i;if(!(!((s=this.xa)===null||s===void 0)&&s.canCapture))return;if(L(this._surveyManager))return void G.warn("init was not called");const r=this.Xa(e);if(!r)return void G.warn("Survey not found");let n=r;if(!((i=r.appearance)===null||i===void 0)&&i.surveyPopupDelaySeconds&&t.ignoreDelay&&(n=f(f({},r),{},{appearance:f(f({},r.appearance),{},{surveyPopupDelaySeconds:0})})),t.displayType!==Sr.Popover&&t.initialResponses&&G.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),t.ignoreConditions===!1){const o=this.Ya(r);if(!o.eligible)return void G.warn("Survey is not eligible to be displayed: ",o.reason)}t.displayType!==Sr.Inline?this._surveyManager.handlePopoverSurvey(n,t):this.renderSurvey(n,t.selector,t.properties)}cancelPendingSurvey(e){L(this._surveyManager)?G.warn("init was not called"):this._surveyManager.cancelSurvey(e)}handlePageUnload(){var e,t;(e=this._surveyManager)===null||e===void 0||(t=e.handlePageUnload)===null||t===void 0||t.call(e)}},sp=class{constructor(e){this._instance=e}get(){var e,t,s,i;const r=(e=this._instance)===null||e===void 0?void 0:e.config;return{disableSurveys:!!r?.disable_surveys,cookielessMode:!!r?.cookieless_mode,advancedEnableSurveys:!!r?.advanced_enable_surveys,requestTimeoutMs:(t=r?.surveys_request_timeout_ms)!==null&&t!==void 0?t:1e4,prefillFromUrl:!!(!(r==null||(s=r.surveys)===null||s===void 0)&&s.prefillFromUrl),automaticDisplay:!r?.disable_surveys_automatic_display,featureFlagEvaluation:!r?.advanced_disable_feature_flags,overrideLanguage:r?.override_display_language,prepareStylesheet:r?.prepare_external_dependency_stylesheet,get_current_url:r?.get_current_url,uiHost:(i=this._instance)===null||i===void 0||(i=i.requestRouter)===null||i===void 0?void 0:i.endpointFor("ui","")}}getExtensions(){const e=M?.__PosthogExtensions__;if(!e||!this._instance)return;const t=this._instance,{generateSurveys:s,loadExternalDependency:i}=e;return{generateSurveys:s?r=>s(t,r):void 0,loadExternalDependency:i?r=>i(t,"surveys",r):void 0}}onMatchingConditionsChanged(e){var t,s;const i=(t=this._instance)===null||t===void 0?void 0:t._addCaptureHook(a=>{a!=="$pageview"&&a!==Se.SHOWN&&a!==Se.DISMISSED&&a!==Se.SENT||e()}),r=()=>e();U(w,"PHSurveyShown",r);let n=!1;const o=(s=this._instance)===null||s===void 0?void 0:s.onFeatureFlags(()=>{n&&e()});return n=!0,()=>{n=!1,i?.(),o?.(),w?.removeEventListener("PHSurveyShown",r)}}};const ip=w?.location?ri(w.location.hash,"__posthog")||ri(location.hash,"state"):null,Mo="_postHogToolbarParams",To=te("[Toolbar]"),Ro=te("[FeatureFlags]"),dt=te("[FeatureFlags]",{debugEnabled:!0}),Qi=`" failed. Feature flags didn't load in time.`,rp=[502,504],Lo=["click","keydown","wheel","touchstart","pointerdown"],Do="connection_error",No=e=>{const t={};for(let s=0;e.length>s;s++)t[e[s]]=!0;return t},jo=e=>{const t={};for(const[s,i]of Bs(e||{}))i&&(t[s]=i);return t};var np=class{constructor(e){this.name="featureFlags",this.yd=!1,this.featureFlagEventHandlers=[],this.$=Ro,this.bd={},this._d={},this.wd=[],this.kd=new Set,this.Sd=new Set,this.xd=!1,this.$d=!1,this.Cd=0,this.Td=!1,this.Id=!1,this.Md=!1,this.Ed=!1,this.Pd=!1,this.Rd=0,this.Ad=!1,this.rn=()=>{const t=this.Fd();this.Rd=0,t&&this.reloadFeatureFlags()},this.Od=()=>{var t,s;const i=this.Dd,r=(t=this.Ld)!==null&&t!==void 0?t:i;x(i)||x(r)||this.Ar.remoteRequestsDisabled||!this.Nd||this.Nd.visibilityState==="hidden"||Date.now()-((s=this.qd)!==null&&s!==void 0?s:0)<r||(this.Ld=this.Ad||!this.Ar.idleRefreshBackoff?i:Math.min(2*r,36e5),this.Ad=!1,this.reloadFeatureFlags(),this.jd())},this.Bd=()=>{this.Ad&&this.Ld===this.Dd||this.zd()},this.sn=()=>{var t;((t=this.Nd)===null||t===void 0?void 0:t.visibilityState)==="visible"&&this.zd()},this.Ta=e}get Hd(){}Ud(){this.xa&&this.Wd()}setup(e){try{this.Vd=typeof window>"u"?void 0:window,this.Nd=typeof document>"u"?void 0:document}catch{this.Vd=void 0,this.Nd=void 0}return this.Na=e,this.$=e.logger.createLogger("[FeatureFlags]"),rn(e.kv.initialize(),()=>{this.Na===e&&(this.Na=void 0,this.xa=e,this.Gd(e))})}Gd(e){var t;if(this.xa===e)return this.Vd&&U(this.Vd,"online",this.rn),this.Wd(),this.Qd=e.registerDynamicEventProperties(()=>this.Zd()?this.bd:this._d),this.Jd=(t=this.Hd)===null||t===void 0?void 0:t.onCrossTabFeatureFlagChange(()=>{this.Kd(),this.Xd(),this.Yd()}),this.Xd(),this.initialize()}zd(){this.Ad=!0,this.Ld=this.Dd,this.Od()}Wd(){var e;const t=this.Ar.refreshIntervalMs,s=!this.Ar.remoteRequestsDisabled&&this.Nd&&!x(t)&&t>0?t:void 0;this.Ar.idleRefreshBackoff||(this.Ld=s),s!==this.Dd&&(this.tv(),x(s)||(this.Dd=s,this.Ld=s,this.jd(),!((e=this.Nd)===null||e===void 0)&&e.addEventListener&&(U(this.Nd,Rt,this.sn),Ot(Lo,i=>{U(this.Nd,i,this.Bd,{capture:!0})}))))}jd(){x(this.Dd)||(x(this.ev)||clearInterval(this.ev),this.qd=Date.now(),this.ev=setInterval(this.Od,this.Dd))}tv(){var e,t;x(this.ev)||(clearInterval(this.ev),this.ev=void 0,(e=this.Nd)===null||e===void 0||(t=e.removeEventListener)===null||t===void 0||t.call(e,"visibilitychange",this.sn),Ot(Lo,s=>{var i,r;(i=this.Nd)===null||i===void 0||(r=i.removeEventListener)===null||r===void 0||r.call(i,s,this.Bd,{capture:!0})})),this.Dd=void 0,this.Ld=void 0,this.Ad=!1,this.qd=void 0}destroy(){this.iv()}dispose(){this.iv()}iv(){var e,t,s;this.tv(),this.Cd++,this.Id=!1,this.Na=void 0,this.nv(this.kd,"cancelled"),this.nv(this.Sd,"cancelled"),this.xa&&(this.sv(),(e=this.Qd)===null||e===void 0||e.dispose(),this.Qd=void 0,(t=this.Jd)===null||t===void 0||t.call(this),this.Jd=void 0,this.wd=[],(s=this.Vd)===null||s===void 0||s.removeEventListener("online",this.rn),this.xa=void 0)}get Ar(){return this.Ta.get()}rv(e){var t;return this.ov&&e in this.ov?this.ov[e]:(t=this.xa)===null||t===void 0?void 0:t.kv.get(e)}Kd(){return!!this.ov&&(this.ov=void 0,!0)}av(){var e;return!x((e=this.xa)===null||e===void 0?void 0:e.kv.get("$enabled_feature_flags"))&&this.Kd()}At(e){this.lv(()=>{var t;return(t=this.xa)===null||t===void 0?void 0:t.kv.set(e)})}uv(e,t,s){if(!this.Hd||!e.$enabled_feature_flags)return;const i=this.rv("$enabled_feature_flags")||{},r=e.$enabled_feature_flags||{},n=t.flags||t.featureFlags,o=t.flags?Object.entries(t.flags).filter(([,g])=>!g?.failed).map(([g])=>g):[],a=!!t.errorsWhileComputingFlags&&!!t.flags,l=a?o:s&&!O(n)?Object.keys(n||{}):Array.from(new Set([...Object.keys(i),...Object.keys(r)])),u=this.rv("$feature_flag_payloads")||{},c=e.$feature_flag_payloads||{},d=a||s?l:Array.from(new Set([...Object.keys(u),...Object.keys(c)])),h=!a&&!s,p=!!h||l,v=!!h||d,m={[Ue]:p,[Te]:p,[rt]:v};e.$feature_flag_details&&(m[gt]=p);for(const g of[_t,nt,us])x(e[g])||(m[g]=!0);this.Hd.markCrossTabFeatureFlagChanges(m)}Pt(e){this.lv(()=>{var t;return(t=this.xa)===null||t===void 0?void 0:t.kv.remove(e)})}lv(e){try{e()}catch(t){this.$.error("Failed to update feature flag persistence",t)}}Xd(){const e={};for(const i of[Ue,rt,_t,Ne]){const r=this.rv(i);x(r)||(e[i]=r)}this.bd=e;const t=f({},e),s=this.rv(Te);if(s)for(const[i,r]of Object.entries(s))t[`$feature/${i}`]=r;this._d=t}Zd(){const e=this.Ar.cacheTtlMs;if(!e||0>=e)return!1;const t=this.rv(nt);return typeof t!="number"||Date.now()-t>e}hv(){return!!this.Zd()&&(this.Pd||this.$d||(this.Pd=!0,this.$.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}dv(){const e=this.Ar.evaluationContexts;return e?.length?e.filter(t=>{const s=t&&typeof t=="string"&&t.trim().length>0;return s||this.$.error("Invalid evaluation context found:",t,"Expected non-empty string"),s}):[]}vv(){const e=this.Ar.flagKeys;if(!x(e))return e.filter(t=>{const s=t&&typeof t=="string"&&t.trim().length>0;return s||this.$.error("Invalid flag key found:",t,"Expected non-empty string"),s})}initialize(){var e,t;const s=this.Ar,i=(e=(t=s.bootstrap)===null||t===void 0?void 0:t.featureFlags)!==null&&e!==void 0?e:{};if(Object.keys(i).length){var r,n;const o=(r=(n=s.bootstrap)===null||n===void 0?void 0:n.featureFlagPayloads)!==null&&r!==void 0?r:{},a=Object.keys(i).filter(u=>!x(i[u])).reduce((u,c)=>(u[c]=i[c],u),{}),l=Object.keys(o).filter(u=>a[u]).reduce((u,c)=>(u[c]=o[c],u),{});return this.fv({featureFlags:a,featureFlagPayloads:l},void 0,{persist:!1})}}updateFlags(e,t,s){var i,r;const n=s?.merge&&(i=this.rv("$enabled_feature_flags"))!==null&&i!==void 0?i:{},o=s?.merge&&(r=this.rv("$feature_flag_payloads"))!==null&&r!==void 0?r:{},a=f(f({},n),e),l=f(f({},o),t),u={};for(const[c,d]of Object.entries(a))u[c]={key:c,enabled:En(d),variant:Sn(d),reason:void 0,metadata:x(l?.[c])?void 0:{id:0,version:void 0,description:void 0,payload:l[c]}};this.fv({flags:u})}get hasLoadedFlags(){return this.xd}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){const e=this.rv(gt),t=this.rv(Ne),s=this.rv(ft);if(!s&&!t)return e||{};const i=ee({},e||{}),r=[...new Set([...Object.keys(s||{}),...Object.keys(t||{})])];for(const a of r){var n,o;const l=i[a],u=t?.[a],c=x(u)?(n=l?.enabled)!==null&&n!==void 0&&n:!!u,d=x(u)?l?.variant:typeof u=="string"?u:void 0,h=s?.[a],p=f(f({},l),{},{enabled:c,variant:c?d??l?.variant:void 0});c!==l?.enabled&&(p.original_enabled=l?.enabled),d!==l?.variant&&(p.original_variant=l?.variant),h&&(p.metadata=f(f({},l?.metadata),{},{payload:h,original_payload:l==null||(o=l.metadata)===null||o===void 0?void 0:o.payload})),i[a]=p}return this.yd||(this.$.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:s,finalDetails:i}),this.yd=!0),i}getAllFeatureFlags(){const e=this.getFlagVariants(),t=this.getFlagPayloads();return Object.keys(e).map(s=>{const i=e[s];return{key:s,enabled:En(i),variant:Sn(i),payload:kn(t[s])}})}getFlagVariants(){const e=this.rv(Te),t=this.rv(Ne);if(!t)return e||{};const s=ee({},e||{}),i=Object.keys(t);for(let r=0;i.length>r;r++)s[i[r]]=t[i[r]];return this.yd||(this.$.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:s}),this.yd=!0),s}getFlagPayloads(){const e=this.rv(rt),t=this.rv(ft);if(!t)return e||{};const s=ee({},e||{}),i=Object.keys(t);for(let r=0;i.length>r;r++)s[i[r]]=t[i[r]];return this.yd||(this.$.warn(" Overriding feature flag payloads!",{flagPayloads:e,overriddenPayloads:t,finalPayloads:s}),this.yd=!0),s}reloadFeatureFlags(){this.Td||this.Ar.featureFlagsDisabled||this.Fd()||(this.Md&&this.$.warn("reloadFeatureFlags() was called inside an onFeatureFlags callback. This callback also runs when flags change in other tabs, so this can cause a request loop."),this.$d&&(this.Id=!0),this.pv||(this.wd.slice().forEach(e=>{try{e()}catch(t){this.$.error("Error while running feature flags reloading callback",t)}}),this.pv=setTimeout(()=>{this.gv()},5)))}reloadFeatureFlagsAsync(){return!this.xa||this.Td||this.Ar.featureFlagsDisabled||this.Ar.remoteRequestsDisabled||this.Fd()?Promise.resolve({status:"skipped"}):new Promise(e=>{this.kd.add(e),this.reloadFeatureFlags()})}nv(e,t){e.forEach(s=>s({status:t})),e.clear()}sv(){clearTimeout(this.pv),this.pv=void 0}onReloading(e){return this.wd.push(e),()=>{this.wd=this.wd.filter(t=>t!==e)}}ensureFlagsLoaded(){this.xd||this.$d||this.pv||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this.Td=e}resetFlagCallReported(){this.Pt(We)}gv(e){var t;this.sv();const s=this.xa;if(!s||this.Ar.remoteRequestsDisabled||this.Fd())return void this.nv(this.kd,"skipped");if(this.$d)return void(this.Id=!0);const i={token:s.projectToken,distinct_id:s.distinctId,groups:s.groups,$anon_distinct_id:this.$anon_distinct_id,person_properties:f(f(f({},s.initialPersonProperties),this.rv("$stored_person_properties")||{}),{},{$lib:s.library.name,$lib_version:s.library.version}),group_properties:this.rv(st),timezone:Ol()};x(s.deviceId)||(i.$device_id=s.deviceId),(e?.disableFlags||this.Ar.featureFlagsDisabled)&&(i.disable_flags=!0);const r=this.dv();r.length&&(i.evaluation_contexts=r);const n=this.vv();x(n)||(i.flag_keys=n);const o=this.Ar.onlyEvaluateSurveyFeatureFlags,a="/flags/?v=2"+(o?"&only_evaluate_survey_feature_flags=true":""),l=this.Cd,u=this.kd;this.kd=new Set,this.Sd=u,this.$d=!0;const c=()=>{this.Id&&(this.Id=!1,this.gv())},d=g=>{var y,_;const b=(y=g.json)!==null&&y!==void 0?y:{},k=g.statusCode!==200;if(this.$d=!1,l!==this.Cd)return void c();if(this.mv(g.statusCode),k||this.Id||(this.$anon_distinct_id=void 0),i.disable_flags&&!this.Id)return void this.nv(u,"skipped");this.Ed=!k;const $=[];g.error?$.push(g.error instanceof Error&&g.error.name==="AbortError"?"timeout":g.error instanceof Error?Do:"unknown_error"):g.statusCode!==200&&$.push(`api_error_${g.statusCode}`),b.errorsWhileComputingFlags&&$.push("errors_while_computing_flags");const S=!!(!((_=b.quotaLimited)===null||_===void 0)&&_.includes("feature_flags"));S&&$.push("quota_limited"),this.At({[ws]:$}),S?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."):i.disable_flags||this.fv(b,k,{partialResponse:o}),this.nv(u,i.disable_flags?"skipped":$.length||!b.flags&&!b.featureFlags?"error":"loaded"),c()},h=g=>{this.$d=!1,l===this.Cd&&(this.At({[ws]:[Do]}),this.$.error("Feature flag request failed",g),this.av()&&this.Yd(!0),this.nv(u,"error")),c()};let p=(t=this.Ar.requestMaxRetries)!==null&&t!==void 0?t:1;const v=()=>p>0&&l===this.Cd,m=()=>{if(l!==this.Cd||!this.xa||this.Ar.remoteRequestsDisabled)return this.$d=!1,this.nv(u,"skipped"),void c();try{s.sendRequest(a,{target:"flags",method:"POST",body:i,compression:this.Ar.compression,sentAt:"body",timeoutMs:this.Ar.requestTimeoutMs}).then(g=>{if((y=>rp.includes(y.statusCode)||(_=>_.statusCode===0&&_.error instanceof Error&&_.error.name==="AbortError")(y))(g)&&v())return p--,void setTimeout(m,500);d(g)}).catch(h)}catch(g){h(g)}};m()}Fd(){return Tl(this.Rd,3)}mv(e){this.Rd=Rl(e,this.Rd,3,()=>this.$.warn("Feature flag requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped refreshing feature flags; will try again when connectivity changes."))}getFeatureFlag(e,t={}){var s;if(t.fresh&&!this.Ed)return;if(!(this.xd||this.getFlags()&&this.getFlags().length>0))return void this.$.warn('getFeatureFlag for key "'+e+Qi);if(this.hv())return;const i=this.getFeatureFlagResult(e,t);return(s=i?.variant)!==null&&s!==void 0?s:i?.enabled}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){const t=this.getFeatureFlagResult(e,{send_event:!1});return t?.payload}getFeatureFlagResult(e,t={}){if(t.fresh&&!this.Ed)return;if(!(this.xd||this.getFlags()&&this.getFlags().length>0))return void this.$.warn('getFeatureFlagResult for key "'+e+Qi);if(this.hv())return;const s=this.getFlagVariants(),i=e in s,r=s[e],n=this.getFlagPayloads()[e],o=String(r),a=this.rv("$feature_flag_request_id")||void 0,l=this.rv("$feature_flag_evaluated_at")||void 0;let u,c=this.rv("$flag_call_reported")||{};if(this.Ar.deduplicateCallsPerSession){var d;const V=(d=this.xa)===null||d===void 0||(d=d.session)===null||d===void 0?void 0:d.sessionId,T=this.rv(is);V&&V!==T&&(c={},u=V)}if(!t.send_event&&"send_event"in t)u&&this.At({[We]:c,[is]:u});else{var h,p;const V=(h=this.xa)===null||h===void 0?void 0:h.canCapture;if(!V&&Object.keys(c).length>0&&(c={},this.At({[We]:c})),V&&!(!((p=c[e])===null||p===void 0)&&p.includes(o))){var v,m,g,y,_,b,k,$,S,A,P,R,B;O(c[e])?c[e].push(o):c[e]=[o],this.At(f({[We]:c},u?{[is]:u}:{}));const T=this.getFeatureFlagDetails(e),W=[...(v=this.rv("$feature_flag_errors"))!==null&&v!==void 0?v:[]];x(r)&&W.push("flag_missing");const F={$feature_flag:e,$feature_flag_response:r,$feature_flag_payload:n??null,$feature_flag_request_id:a,$feature_flag_evaluated_at:l,$feature_flag_bootstrapped_response:(m=(g=this.Ar.bootstrap)===null||g===void 0||(g=g.featureFlags)===null||g===void 0?void 0:g[e])!==null&&m!==void 0?m:null,$feature_flag_bootstrapped_payload:(y=(_=this.Ar.bootstrap)===null||_===void 0||(_=_.featureFlagPayloads)===null||_===void 0?void 0:_[e])!==null&&y!==void 0?y:null,$used_bootstrap_value:!this.Ed};x(T==null||(b=T.metadata)===null||b===void 0?void 0:b.has_experiment)||(F.$feature_flag_has_experiment=T.metadata.has_experiment),x(T==null||(k=T.metadata)===null||k===void 0?void 0:k.version)||(F.$feature_flag_version=T.metadata.version);const j=($=T==null||(S=T.reason)===null||S===void 0?void 0:S.description)!==null&&$!==void 0?$:T==null||(A=T.reason)===null||A===void 0?void 0:A.code;j&&(F.$feature_flag_reason=j),!(T==null||(P=T.metadata)===null||P===void 0)&&P.id&&(F.$feature_flag_id=T.metadata.id),x(T?.original_variant)&&x(T?.original_enabled)||(F.$feature_flag_original_response=x(T.original_variant)?T.original_enabled:T.original_variant),!(T==null||(R=T.metadata)===null||R===void 0)&&R.original_payload&&(F.$feature_flag_original_payload=T==null||(B=T.metadata)===null||B===void 0?void 0:B.original_payload),W.length&&(F.$feature_flag_error=W.join(",")),this.yv(F)}else u&&this.At({[We]:c,[is]:u})}return i?{key:e,enabled:!!r,variant:typeof r=="string"?r:void 0,payload:kn(n)}:void 0}yv(e){try{var t;(t=this.xa)===null||t===void 0||t.capture("$feature_flag_called",e)}catch(s){this.$.error("Failed to capture feature flag call",s)}}getRemoteConfigPayload(e,t){this.bv(e,t)}bv(e,t){var s=this;return Q(function*(){const i=s.xa;if(!i)return;const r={distinct_id:i.distinctId,token:i.projectToken,person_properties:{$lib:i.library.name,$lib_version:i.library.version}},n=s.dv();n.length&&(r.evaluation_contexts=n);const o=s.vv();let a;x(o)||(r.flag_keys=o);try{var l;const u=(l=(yield i.sendRequest("/flags/?v=2",{target:"flags",method:"POST",body:r,compression:s.Ar.compression,sentAt:"body",timeoutMs:s.Ar.requestTimeoutMs})).json)===null||l===void 0?void 0:l.featureFlagPayloads;a=u?.[e]||void 0}catch(u){return void s.$.error("Remote config feature flag request failed",u)}try{t(a)}catch(u){s.$.error("Remote config feature flag callback failed",u)}})()}isFeatureEnabled(e,t={}){if(t.fresh&&!this.Ed)return t.defaultValue;if(!(this.xd||this.getFlags()&&this.getFlags().length>0))return this.$.warn('isFeatureEnabled for key "'+e+Qi),t.defaultValue;const s=this.getFeatureFlag(e,t);return x(s)?t.defaultValue:!!s}addFeatureFlagsHandler(e){this.featureFlagEventHandlers.push(e)}removeFeatureFlagsHandler(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter(t=>t!==e)}receivedFeatureFlags(e,t,s){this.fv(e,t,s)}fv(e,t,s){if(!this.xa)return;this.xd=!0;const i=((r,n={},o={},a={},l,u=Ro)=>{const c=((b,k)=>{const $=b.flags;if($){const S=Object.fromEntries(Object.keys($).map(P=>{var R;return[P,(R=$[P].variant)!==null&&R!==void 0?R:$[P].enabled]})),A=Object.fromEntries(Object.keys($).filter(P=>$[P].enabled).filter(P=>{var R;return!x((R=$[P].metadata)===null||R===void 0?void 0:R.payload)}).map(P=>{var R;return[P,(R=$[P].metadata)===null||R===void 0?void 0:R.payload]}));return f(f({},b),{},{featureFlags:S,featureFlagPayloads:A})}return b.featureFlags&&k.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),b})(r,u),d=c.flags,h=c.featureFlags,p=c.featureFlagPayloads;if(!h)return;const v=r.requestId,m=r.evaluatedAt;if(O(h)){u.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");const b={};if(h)for(let k=0;h.length>k;k++)b[h[k]]=!0;return{[Ue]:h,[Te]:b,[us]:!1}}let g=h,y=p,_=d;if(l?.partialResponse){const b=Object.keys(g),k=y||{};g=f(f({},n),g),y=f(f({},o),k),b.forEach($=>{$ in k||y==null||delete y[$]}),_=f(f({},a),_)}else if(r.errorsWhileComputingFlags)if(d){const b=new Set(Object.keys(d).filter($=>{var S;return!(!((S=d[$])===null||S===void 0)&&S.failed)}));g=f(f({},n),Object.fromEntries(Object.entries(g).filter(([$])=>b.has($))));const k=Object.fromEntries(Object.entries(y||{}).filter(([$])=>b.has($)));y=f(f({},o),k),b.forEach($=>{$ in k||y==null||delete y[$]}),_=f(f({},a),Object.fromEntries(Object.entries(_||{}).filter(([$])=>b.has($))))}else g=f(f({},n),g),y=f(f({},o),y),_=f(f({},a),_);return f(f({[Ue]:Object.keys(jo(g)),[Te]:g||{},[rt]:y||{},[gt]:_||{},[us]:r.minimalFlagCalledEvents===!0},v?{[_t]:v}:{}),m?{[nt]:m}:{})})(e,this.getFlagVariants(),this.getFlagPayloads(),this.getFlagsWithDetails(),s,this.$);if(i)if(s?.persist===!1){const r=!x(this.xa.kv.get(Te));this.ov=i,r||this.At(i)}else this.Kd(),this.uv(i,e,!!s?.partialResponse),this.At(i);else t&&this.av();t||(this.Pd=!1),this.Yd(t)}override(e,t=!1){this.$.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){this._v(e)}_v(e){if(this.xa){if(e===!1)return this.Pt([Ne,ft]),this.Yd(),void dt.info("All overrides cleared");if(O(e))return this.At({[Ne]:No(e)}),this.Yd(),void dt.info("Flag overrides set",{flags:e});if(e&&typeof e=="object"&&("flags"in e||"payloads"in e)){var t;const s=e;this.yd=!!((t=s.suppressWarning)!==null&&t!==void 0&&t);const i={},r=s.flags,n=s.payloads;return r&&(i[Ne]=O(r)?No(r):r),n&&(i[ft]=n),Object.keys(i).length&&this.At(i),r===!1&&n===!1?this.Pt([Ne,ft]):r===!1?this.Pt(Ne):n===!1&&this.Pt(ft),this.Yd(),r===!1?dt.info("Flag overrides cleared"):r&&dt.info("Flag overrides set",{flags:r}),void(n===!1?dt.info("Payload overrides cleared"):n&&dt.info("Payload overrides set",{payloads:n}))}if(e&&typeof e=="object")return this.At({[Ne]:e}),this.Yd(),void dt.info("Flag overrides set",{flags:e});this.$.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:e})}else this.$.warn("posthog.featureFlags.overrideFeatureFlags called before feature flags were ready")}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this.xd){const{flags:t,flagVariants:s}=this.wv();try{e(t,s)}catch(i){this.$.error("Error while running feature flags callback",i)}}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t,s){var i;const r=(this.rv("$early_access_features")||[]).find(u=>u.flagKey===e),n={[`$feature_enrollment/${e}`]:t},o={$feature_flag:e,$feature_enrollment:t,$set:n};r&&(o.$early_access_feature_name=r.name),s&&(o.$feature_enrollment_stage=s);const a=f(f({},this.getFlagVariants()),{},{[e]:t});(i=this.Hd)===null||i===void 0||i.markCrossTabFeatureFlagChanges({$active_feature_flags:[e],$enabled_feature_flags:[e],$stored_person_properties:Object.keys(n)}),this.At({[Ue]:Object.keys(jo(a)),[Te]:a,[it]:f(f({},this.rv("$stored_person_properties")||{}),n)}),this.Yd();try{var l;(l=this.xa)===null||l===void 0||l.capture("$feature_enrollment_update",o)}catch(u){this.$.error("Failed to capture early access feature enrollment",u)}}getEarlyAccessFeatures(e,t=!1,s){const i=this.rv(pr);!i||t?this.Sv(e,s):e(i)}Sv(e,t){var s=this;return Q(function*(){const i=s.xa;if(!i)return;const r=t?`&${t.map(o=>`stage=${o}`).join("&")}`:"";let n;try{const o=yield i.sendRequest(`/api/early_access_features/?token=${i.projectToken}${r}`,{target:"api",method:"GET",sentAt:"query"});if(!o.json)return;n=o.json.earlyAccessFeatures,s.At({[pr]:n})}catch(o){return void s.$.error("Early access feature request failed",o)}try{e(n)}catch(o){s.$.error("Early access feature callback failed",o)}})()}wv(){const e=this.getFlags(),t=this.getFlagVariants();return{flags:e.filter(s=>t[s]),flagVariants:Object.keys(t).filter(s=>t[s]).reduce((s,i)=>(s[i]=t[i],s),{})}}Yd(e){this.Xd();const{flags:t,flagVariants:s}=this.wv(),i=this.Md;this.Md=!0,this.featureFlagEventHandlers.forEach(r=>{try{r(t,s,{errorsLoading:e})}catch(n){this.$.error("Error while running feature flags callback",n)}}),this.Md=i}setPersonPropertiesForFlags(e,t=!0){this.xv(e,t)}xv(e,t=!0){const s=this.rv("$stored_person_properties")||{},i=e?.$set||(e?.$set_once?{}:e),r=e?.$set_once,n={};if(r)for(const o in r)({}).hasOwnProperty.call(r,o)&&(o in s||(n[o]=r[o]));this.At({[it]:f(f(f({},s),n),i)}),t&&this.reloadFeatureFlags()}unsetPersonPropertiesForFlags(e,t=!0){const s=f({},this.rv("$stored_person_properties")||{});e.forEach(i=>{delete s[i]}),this.At({[it]:s}),t&&this.reloadFeatureFlags()}resetPersonPropertiesForFlags(e=!0){this.Pt(it),e&&this.reloadFeatureFlags()}setGroupPropertiesForFlags(e,t=!0){const s=this.rv("$stored_group_properties")||{},i=f({},s);for(const r of Object.keys(e))i[r]=f(f({},s[r]),e[r]);this.At({[st]:i}),t&&this.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){const t=this.rv("$stored_group_properties")||{};this.At({[st]:f(f({},t),{},{[e]:{}})})}else this.Pt(st)}reset(){this.Cd++,this.nv(this.kd,"cancelled"),this.nv(this.Sd,"cancelled"),this.Id=!1,this.bd={},this._d={},this.ov=void 0,this.xd=!1,this.Td=!1,this.Ed=!1,this.$anon_distinct_id=void 0,this.sv(),this.yd=!1,this.Rd=0}};const qo=te("[FeatureFlags]");var op=class{constructor(e,t=!1){this.$v=!1,this.update(e,t)}update(e,t){this.Cv=((s,i)=>{var r,n,o,a,l,u,c,d;return{bootstrap:{featureFlags:(r=(n=s.bootstrap)===null||n===void 0?void 0:n.featureFlags)!==null&&r!==void 0?r:void 0,featureFlagPayloads:(o=(a=s.bootstrap)===null||a===void 0?void 0:a.featureFlagPayloads)!==null&&o!==void 0?o:void 0},remoteRequestsDisabled:i,featureFlagsDisabled:!!s.advanced_disable_feature_flags,onlyEvaluateSurveyFeatureFlags:!!s.advanced_only_evaluate_survey_feature_flags,deduplicateCallsPerSession:!!s.advanced_feature_flags_dedup_per_session,cacheTtlMs:s.feature_flag_cache_ttl_ms,refreshIntervalMs:(l=s.remote_config_refresh_interval_ms)!==null&&l!==void 0?l:3e5,idleRefreshBackoff:x(s.remote_config_refresh_interval_ms),requestTimeoutMs:s.feature_flag_request_timeout_ms,requestMaxRetries:Math.max(0,(u=s.feature_flag_request_max_retries)!==null&&u!==void 0?u:1),compression:s.disable_compression?void 0:"best-available",evaluationContexts:(c=(d=s.evaluation_contexts)!==null&&d!==void 0?d:s.evaluation_environments)!==null&&c!==void 0?c:[],flagKeys:O(s.flag_keys)?s.flag_keys:void 0}})(e,t),!e.evaluation_environments||e.evaluation_contexts||this.$v||(qo.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.$v=!0),x(e.flag_keys)||O(e.flag_keys)||qo.error("Invalid flag_keys found:",e.flag_keys,"Expected array of non-empty strings")}get(){return this.Cv}};const Ho=e=>Ut(e)&&(e.name==="RangeError"&&e.message.indexOf("Maximum call stack size exceeded")===0||e.name==="InternalError"&&e.message==="too much recursion"),Me=te("[Error tracking]"),Mr="webkit-masked-url:",ap=[{value:"isolatedAPI.contexts.topHostname",exact:!1},{value:"No response from target",exact:!0}],lp=["chrome-extension://","moz-extension://","safari-extension:","safari-web-extension:",Mr],up=["__firefox__","__gCrWeb"],Bo="Refusing to render web experiment since the viewer is a likely bot",cp={icontains:(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())>-1,not_icontains:(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())===-1,regex:(e,t)=>li(t,e),not_regex:(e,t)=>!li(t,e),exact:(e,t)=>t===e,is_not:(e,t)=>t!==e},Ce=te("[Conversations]"),ht="Conversations not available yet.";function zo(e,t){var s,i,r,n,o,a,l;const u=(s=e?.flushIntervalMs)!==null&&s!==void 0?s:3e3,c=(i=e?.maxBufferSize)!==null&&i!==void 0?i:100,d=t?.consoleCapture?void 0:(r=e?.maxLogsPerInterval)!==null&&r!==void 0?r:1e3,h=x(d)?Math.max(c,2048):Math.max(c,d),p=f(f({},(function(){let v="",m="";try{var g;const y="u">typeof globalThis?globalThis:"u">typeof window?window:void 0,_=y==null||(g=y.navigator)===null||g===void 0?void 0:g.userAgent;_&&([v,m]=Sa(_))}catch{}return(function(y,_){const b=(function(k){if(k)return{}.hasOwnProperty.call(On,k)?On[k]:k})(y);return f(f({},b?{"os.name":b}:{}),_?{"os.version":_}:{})})(v,m)})()),e?.resourceAttributes);return{serviceName:(n=(o=p?.["service.name"])!==null&&o!==void 0?o:e?.serviceName)!==null&&n!==void 0?n:t?.serviceNameDefault,serviceVersion:(a=p?.["service.version"])!==null&&a!==void 0?a:e?.serviceVersion,environment:(l=p?.["deployment.environment"])!==null&&l!==void 0?l:e?.environment,resourceAttributes:p,beforeSend:e?.beforeSend,flushIntervalMs:u,maxBufferSize:c,maxQueueSize:h,maxBatchRecordsPerPost:100,rateCapWindowMs:u,maxLogsPerInterval:d,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}}const dp=["debug","log","warn","error","info"],hp=e=>{for(;e?.__rrweb_original__;)e=e.__rrweb_original__;return e},Vo="console",mu="__posthogHandledLogsRequestError",Zi=(e,t)=>{const s=e instanceof Error?e:new Error(t);return s[mu]=!0,s},Uo=e=>!!e&&typeof e=="object"&&e[mu]===!0;var pp=class{get Tv(){return f(f({},this.$),{},{error:(...e)=>{e.some(Uo)||this.$.error(...e)}})}constructor(e,t){var s;this.Ta=e,this.Iv=t,this.name="logs",this.Mv=!1,this.Ev=!1,this.Pv=!1,this.$=te("[logs]"),this.Ju=[],this.Rv=[],this.Rd=0,this.Av=!1,this.Ci=!1,this.Fv=[],this.Ov=[],this.Dv=!1,this.Lv=!1,this.Nv=!1,this.qv=()=>{var i,r;this.Ci||(this.Rd=0,(i=this.jv)===null||i===void 0||i.onReconnect(),(r=this.Bv)===null||r===void 0||r.onReconnect())},this.Mv=!!(!((s=e.get())===null||s===void 0)&&s.captureConsoleLogs)}get zv(){return!0}Hv(){}Uv(){if(!this.Nv){try{this.Vd=typeof window>"u"?void 0:window}catch{this.Vd=void 0}this.Vd&&(U(this.Vd,"online",this.qv),this.Nv=!0)}}Wv(e,t,s,i){this.Uv();const r=zo(this.Ta.get(),s);return[new sd(this.Vv(e,t),r,this.Tv,()=>this.Iv(),n=>n(),void 0,i),r]}Gv(){const e=this.Ta.get();var t;return this.jv&&this.Qv===e||((t=this.jv)===null||t===void 0||t.reset(),this.Qv=e,[this.jv,this.Zv]=this.Wv(()=>this.Ju,s=>{this.Ju=s})),this.jv}Jv(){const e=this.Ta.get();var t;return this.Bv&&this.Kv===e||((t=this.Bv)===null||t===void 0||t.reset(),this.Kv=e,[this.Bv,this.Xv]=this.Wv(()=>this.Rv,s=>{this.Rv=s},{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},Vo)),this.Bv}setup(e){if(!this.Ci&&!this.Av)return this.Av=!0,this.xa=e,this.$=e.logger.createLogger("[logs]"),rn(e.kv.initialize(),()=>{this.Ci||this.Gd(e)})}Gd(e){var t;this.Uv(),!((t=this.Ta.get())===null||t===void 0)&&t.captureConsoleLogs&&(this.Mv=!0),(this.Mv||this.Ta.remoteConfigWillArrive&&e.kv.get(this.Ta.captureHintKey))&&this.Yv();let s=!1;const i=e.onRemoteConfig(r=>{var n;s=r.ok&&((n=r.config.logs)===null||n===void 0?void 0:n.captureConsoleLogs)===!0,this.onRemoteConfig(r)});this.Ci?i.dispose():(this.qa=i,s||this.loadIfEnabled())}dispose(){var e,t,s,i,r,n,o;this.Ci||(this.Ci=!0,this.tf(),(e=this.qa)===null||e===void 0||e.dispose(),this.qa=void 0,this.xa=void 0,this.Pv=!1,(t=this.Vd)===null||t===void 0||t.removeEventListener("online",this.qv),(s=this.ef)===null||s===void 0||s.call(this),this.ef=void 0,(i=this.jv)===null||i===void 0||i.clearQueue(),(r=this.Bv)===null||r===void 0||r.clearQueue(),(n=this.jv)===null||n===void 0||n.reset(),(o=this.Bv)===null||o===void 0||o.reset())}onRemoteConfig(e){var t,s;if(this.Ci)return;const i=e.ok?(t=e.config.logs)===null||t===void 0?void 0:t.captureConsoleLogs:void 0;L(i)?this.if():((s=this.xa)===null||s===void 0||s.kv.set(this.Ta.captureHintKey,!!i),i?(this.Mv=!0,this.Ev||this.Yv(),this.loadIfEnabled()):this.if())}reset(){var e,t,s,i;this.tf(),(e=this.jv)===null||e===void 0||e.clearQueue(),this.Ju=[],(t=this.jv)===null||t===void 0||t.reset(),(s=this.Bv)===null||s===void 0||s.clearQueue(),this.Rv=[],(i=this.Bv)===null||i===void 0||i.reset(),this.Rd=0}captureLog(e){!this.Ci&&this.xa&&this.Gv().captureLog(e)}captureConsoleLog(e){!this.Ci&&this.xa&&this.Jv().captureLog(e)}captureBufferedConsoleLog(e,t,s){!this.Ci&&this.xa&&this.Jv().captureLog(e,{context:t,occurredAtMs:s})}md(){var e;this.tf(),(e=this.Bv)===null||e===void 0||e.clearQueue(),this.Rv=[]}if(){this.Mv||this.tf()}Yv(){var e;if(this.Dv||!(!((e=this.Vd)===null||e===void 0)&&e.console))return;const t=zo(this.Ta.get()).maxBufferSize;let s=!0;this.Ov.push(()=>{s=!1});for(const i of dp){let r;try{r=hp(this.Vd.console[i])}catch{continue}r&&this.Ov.push(Vt(this.Vd.console,i,n=>{const o=(...a)=>{try{s&&this.nf(i,a,t)}catch{}return n.apply(this.Vd.console,a)};return o.__rrweb_original__=r,o}))}this.Dv=!0,this.sf=setTimeout(()=>{this.tf()},3e4)}nf(e,t,s){var i;if(this.Dv&&!this.Lv&&t.length!==0)if(!((i=this.xa)===null||i===void 0)&&i.canCapture){if(s>this.Fv.length){this.Lv=!0;try{this.Fv.push({level:e,args:t,occurredAtMs:Date.now(),context:this.Iv()})}finally{this.Lv=!1}}}else this.tf()}tf(){if(this.Fv=[],this.Dv){this.Dv=!1,this.sf&&(clearTimeout(this.sf),this.sf=void 0);for(const e of this.Ov)e();this.Ov=[]}}rf(){const e=this.Fv;return this.tf(),e}get logger(){return this.af||(this.af={trace:(e,t)=>this.captureLog({body:e,level:"trace",attributes:t}),debug:(e,t)=>this.captureLog({body:e,level:"debug",attributes:t}),info:(e,t)=>this.captureLog({body:e,level:"info",attributes:t}),warn:(e,t)=>this.captureLog({body:e,level:"warn",attributes:t}),error:(e,t)=>this.captureLog({body:e,level:"error",attributes:t}),fatal:(e,t)=>this.captureLog({body:e,level:"fatal",attributes:t})}),this.af}flushLogs(e){this.xa&&(e?this.lf(e):(this.jv&&this.jv.flush().catch(t=>this.uf(t)),this.Bv&&this.Bv.flush().catch(t=>this.uf(t))))}flush(){var e=this;return Q(function*(){var t,s;const i=(t=e.jv)===null||t===void 0?void 0:t.flush().catch(n=>e.uf(n)),r=(s=e.Bv)===null||s===void 0?void 0:s.flush().catch(n=>e.uf(n));yield i,yield r})()}uf(e){Uo(e)||this.$.error("PostHog logs flush failed:",e)}loadIfEnabled(){if(this.Ci||!this.Mv||this.Ev||this.Pv)return;const e=this.Hv();if(e){this.Pv=!0;try{e((t,s)=>{if(this.Pv=!1,!this.Ci&&this.Mv)if(t||!s)this.$.error("Could not load logs script",t),this.tf();else{const i=this.rf();this.ef=s.initialize(this.xa),this.Ev=!0,i.length>0&&s.replay(this.xa,i)}})}catch(t){throw this.Pv=!1,t}}else this.tf()}Vv(e,t){const s=this.xa;return{get isDisabled(){return!1},get optedOut(){return!s.canCapture},getPersistedProperty:i=>i===je.LogsQueue?e():void 0,setPersistedProperty(i,r){i===je.LogsQueue&&t(r??[])},js:i=>this.js(i),getLibraryId:()=>s.library.name,getLibraryVersion:()=>s.library.version}}js(e){return new Promise(t=>{if(Tl(this.Rd,3))return void t({kind:"fatal",error:Zi(void 0,"logs endpoint is unreachable, dropping batch")});let s=!1;const i=o=>{s||(s=!0,clearTimeout(r),t(o))},r=setTimeout(()=>{this.$.warn("Logs request timed out before receiving a response"),i({kind:"retry-later",error:Zi(void 0,"logs request timed out")})},9e4),n=this.zv;this.xa.sendRequest("/i/v1/logs",{method:"POST",query:{token:this.xa.projectToken},body:e,compression:"best-available",timeoutMs:6e4}).then(o=>{var a;const l=o.statusCode;this.cf(l,n),l>=200&&300>l?i({kind:"ok"}):l===413?i({kind:"too-large"}):l!==0&&l!==408&&l!==429&&500>l?i({kind:"fatal",error:new Error(`logs request failed with status ${l}`)}):l===0?(o.error||this.$.warn("Logs request failed before receiving an HTTP response"),i({kind:"retry-later",error:Zi(o.error,"logs request failed before receiving an HTTP response")})):i({kind:"retry-later",error:(a=o.error)!==null&&a!==void 0?a:new Error(`logs request failed with status ${l}`)})},o=>{i({kind:"retry-later",error:o})})})}cf(e,t){(e!==0||t)&&(this.Rd=Rl(e,this.Rd,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.")))}lf(e){this.Ju.length>0&&this.hf(e,this.Ju,this.Zv,this.xa.library.name,t=>{this.Ju=t}),this.Rv.length>0&&this.hf(e,this.Rv,this.Xv,Vo,t=>{this.Rv=t})}hf(e,t,s,i,r){if(t.length===0)return;const n=t.map(a=>a.record);r([]);const o=Ka(n,Ja(s,this.xa.library.name,this.xa.library.version),i,this.xa.library.version);this.xa.sendRequest("/i/v1/logs",{method:"POST",query:{token:this.xa.projectToken},body:o,compression:"best-available",transport:e,timeoutMs:6e4}).catch(a=>this.uf(a))}};const ui=te("[NetworkMetrics]"),nn=()=>{var e;return!(w==null||(e=w.performance)===null||e===void 0)&&e.now?w.performance.now():Date.now()},fp={"http:":80,"https:":443},vp=new Set(["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"]),yu=(e,t)=>{var s;const i=String(t);return{method:String(e).toUpperCase(),url:((s=Ke(i))===null||s===void 0?void 0:s.href)||i}},Tr=(e,t,s,i,r,n,o=!1)=>{try{var a,l;const u=r();if(!u)return;const c=s||void 0,d=nn()-i,h=Ke(t.url);if(h&&h.protocol!=="http:"&&h.protocol!=="https:")return;const p={url:h?.href||t.url,method:t.method},v=ne(u.name)?u.name(p):N(u.name)?u.name:"http.client.request.duration";if(!v)return;const m=o&&!c?void 0:((y,_)=>y?400>y?void 0:String(y):_?.name||"_OTHER")(c,n),g=f(f(f(f(f({},(y=>{const _=vp.has(y)?y:"_OTHER";return f({"http.request.method":_},_==="_OTHER"&&y!==_?{"http.request.method_original":y}:{})})(p.method)),h?(y=>{return{"server.address":y.hostname.startsWith("[")&&y.hostname.endsWith("]")?y.hostname.slice(1,-1):y.hostname,"server.port":Number(y.port)||fp[y.protocol],"url.scheme":y.protocol.slice(0,-1),"url.template":(_=y.pathname,_.split("/").map(b=>(k=>/^\d+$/.test(k)||k.length>=8&&/^[0-9a-f-]*\d[0-9a-f-]*$/i.test(k))(b)?":id":b).join("/"))};var _})(h):{}),c?{"http.response.status_code":c}:{}),m?{"error.type":m}:{}),(a=u.attributes)===null||a===void 0?void 0:a.call(u,p,{status:c,durationMs:d}));(l=e.metrics)===null||l===void 0||l.histogram(v,d,{unit:"ms",attributes:g})}catch(u){ui.error("Failed to record network metric",u)}},bu=()=>{},gp=(e,t)=>ne(w?.fetch)?Vt(w,"fetch",s=>function(...i){const r=nn(),n=s.apply(this,i);if(!t())return n;try{var o,a,l;const[u,c]=i,d=yu((o=(a=c?.method)!==null&&a!==void 0?a:u?.method)!==null&&o!==void 0?o:"GET",(l=u?.url)!==null&&l!==void 0?l:u);return n.then(h=>(Tr(e,d,h?.status,r,t,void 0,!0),h),h=>{throw Tr(e,d,void 0,r,t,h),h})}catch(u){return ui.error("Failed to observe fetch",u),n}}):bu,_p=(e,t)=>{var s;const i=w==null||(s=w.XMLHttpRequest)===null||s===void 0?void 0:s.prototype;if(!i)return bu;const r=new WeakMap,n=Vt(i,"open",a=>function(...l){try{Yl.has(this)||r.set(this,yu(l[0],l[1]))}catch(u){ui.error("Failed to observe XHR open",u)}return a.apply(this,l)}),o=Vt(i,"send",a=>function(...l){let u;try{const c=r.get(this);if(c&&t()){const d=nn();u=()=>{this.removeEventListener("loadend",u),Tr(e,c,this.status,d,t)},U(this,"loadend",u)}}catch(c){ui.error("Failed to observe XHR send",c)}try{return a.apply(this,l)}catch(c){throw u&&this.removeEventListener("loadend",u),c}});return()=>{n(),o()}},Wo=new WeakMap,mp=new Set(["$comment","$defs","$id","$schema","additionalProperties","default","definitions","deprecated","description","examples","minProperties","properties","readOnly","required","title","type","writeOnly"]),yp={maxStringLength:2048,truncationSuffix:"..."},bp={maxStringLength:2048,truncationSuffix:"..."};function Go(e){if(e)return e===!0?{intent:!0,model:!0}:{intent:e.intent!==!1,model:e.model!==!1}}function er(e,t){return{}.hasOwnProperty.call(e,t)}function tr(e,t){const s=Object.create(e);return t&&Object.defineProperty(s,"inputSchema",{configurable:!0,enumerable:!0,writable:!0,value:t}),s}function Jo(e,t,s=!1){if(!N(e))return;const i=e.trim();return i?(s?za(i,yp):i).slice(0,t):void 0}function Ko(e){try{return D(e)&&e.isError===!0}catch{return!1}}function wu(e){return za(e||"Unknown error",bp).slice(0,2048)}function wp(e,t){try{return wu(t?(function(s){try{return!D(s)||!O(s.content)?void 0:s.content.filter(i=>D(i)&&i.type==="text"&&N(i.text)).map(i=>i.text).join(" ").trim()||void 0}catch{return}})(e):D(e)&&N(e.message)?e.message:N(e)?e:String(e))}catch{return"Unknown error"}}function xp(e,t,s){return t.errorResult?[{type:"Error",value:s,mechanism:{type:"generic",handled:!0,synthetic:!0,exception_id:0}}]:e.buildProperties(t.error,{handled:!0}).$exception_list.map(i=>f(f({},i),{},{value:wu(i.value)}))}function $p(e,t){if(t)return"Error";try{if(!D(e))return"Error";let s=N(e.name)?e.name.trim():"";const i=e.constructor;return s&&s!=="Error"||!ne(i)||i.name==="Error"||(s=i.name),(s||"Error").slice(0,256)}catch{return"Error"}}function kp(e,t){return{message:wp(e,t),type:$p(e,t)}}const fi={featureFlags:class extends np{constructor(e){const t=new op(e.config,e.Qu());super(t),this.name=vu,this._instance=e,this.df=t}get Hd(){return this._instance.persistence}updateConfig(e,t){this.df.update(e,t),this.Ud()}}},Ep={sessionRecording:class{get Ar(){return this._instance.config}get _c(){return this._instance.persistence}get started(){var e;return!!(!((e=this.vf)===null||e===void 0)&&e.isStarted)}get status(){var e,t;return this.ff==="awaiting_config"||this.ff==="missing_config"?this.ff:(e=(t=this.vf)===null||t===void 0?void 0:t.status)!==null&&e!==void 0?e:this.ff}constructor(e){if(this._instance=e,this._forceAllowLocalhostNetworkCapture=!1,this.ff=Ki,this.pf=void 0,this.gf=!1,this.Je=(()=>{var t,s;if(!C?.visibilityState||C.visibilityState==="visible")return!0;const i=w==null||(t=w.performance)===null||t===void 0||(s=t.getEntriesByType)===null||s===void 0?void 0:s.call(t,"visibility-state");return!i?.length||i.some(r=>r.name==="visible")})(),this.sn=()=>{var t,s;C?.visibilityState==="visible"&&(this.Je=!0,(t=this.vf)===null||t===void 0||(s=t.setDocumentWasEverVisible)===null||s===void 0||s.call(t,!0))},!this._instance.sessionManager)throw Be.error("started without valid sessionManager"),new Error("[SessionRecording] started without valid sessionManager. This is a bug.");if(this.Ar.cookieless_mode==="always")throw new Error('[SessionRecording] cannot be used with cookieless_mode="always"');C?.addEventListener&&U(C,"visibilitychange",this.sn)}initialize(){this.startIfEnabledOrStop()}dispose({discardBufferedEvents:e=!1}={}){var t;this.gf=!0,C==null||(t=C.removeEventListener)===null||t===void 0||t.call(C,"visibilitychange",this.sn),e?this.mf(!0):this.stopRecording()}get yf(){var e;const t=!!(!((e=this._instance.get_property("$session_recording_remote_config"))===null||e===void 0)&&e.enabled),s=!this.Ar.disable_session_recording,i=this.Ar.disable_session_recording||this._instance.consent.isOptedOut();return w&&t&&s&&!i}startIfEnabledOrStop(e){var t;if(this.gf||this.yf&&(!((t=this.vf)===null||t===void 0)&&t.isStarted))return;const s=!x(Object.assign)&&!x(Array.from);this.yf&&s?(this.bf(e),Be.info("starting")):(this.ff=Ki,this.stopRecording())}bf(e){var t,s;if(this.yf)if(this.ff!=="awaiting_config"&&this.ff!=="missing_config"&&(this.ff=Fo),(M==null||(t=M.__PosthogExtensions__)===null||t===void 0||(t=t.rrweb)===null||t===void 0?void 0:t.record)&&((s=M.__PosthogExtensions__)===null||s===void 0?void 0:s.initSessionRecording))this._f(e);else{var i,r;const n=this._instance.sessionManager;(i=M.__PosthogExtensions__)===null||i===void 0||(r=i.loadExternalDependency)===null||r===void 0||r.call(i,this._instance,this.wf,o=>{if(!this.gf&&this.yf&&this._instance.sessionManager===n)return o?(this._instance.register_for_session({$sdk_debug_recording_script_not_loaded:!0}),Be.error("could not load recorder",o)):void this._f(e);this.ff="disabled"})}}stopRecording(){var e,t;(e=this.pf)===null||e===void 0||e.call(this),this.pf=void 0,(t=this.vf)===null||t===void 0||t.stop()}mf(e=!1){var t,s;(t=this.pf)===null||t===void 0||t.call(this),this.pf=void 0,(s=this.vf)===null||s===void 0||s.discard({discardProducerEvents:e})}kf(){var e,t;(e=this._c)===null||e===void 0||e.unregister("$session_is_sampled"),(t=this._c)===null||t===void 0||t.unregister("$replay_sample_rate")}Sf(e,t){if(L(e))return null;const s=oe(e)?e:parseFloat(e);return typeof(i=s)!="number"||!Number.isFinite(i)||0>i||i>1?(Be.warn(`${t} must be between 0 and 1. Ignoring invalid value:`,e),null):s;var i}xf(e){if(this._c){var t,s;const i=this._c,r=()=>{var n;const o=e.sessionRecording===!1?void 0:e.sessionRecording,a=this.Sf((n=this.Ar.session_recording)===null||n===void 0?void 0:n.sampleRate,"session_recording.sampleRate"),l=this.Sf(o?.sampleRate,"remote config sampleRate"),u=a??l;L(u)&&this.kf();const c=o?.minimumDurationMilliseconds;i.register({[ds]:f(f({cache_timestamp:Date.now(),enabled:!!o},o),{},{networkPayloadCapture:f({capturePerformance:e.capturePerformance},o?.networkPayloadCapture),canvasRecording:{enabled:o?.recordCanvas,fps:o?.canvasFps,quality:o?.canvasQuality},sampleRate:u,minimumDurationMilliseconds:x(c)?null:c,endpoint:o?.endpoint,triggerMatchType:o?.triggerMatchType,masking:o?.masking,urlTriggers:o?.urlTriggers,version:o?.version,triggerGroups:o?.triggerGroups})})};r(),(t=this.pf)===null||t===void 0||t.call(this),this.pf=(s=this._instance.sessionManager)===null||s===void 0?void 0:s.onSessionId(r)}}onRemoteConfig(e){const t=e.ok?e.config:void 0;return t&&"sessionRecording"in t?t.sessionRecording===!1?(this.xf(t),void this.mf()):(this.xf(t),void this.startIfEnabledOrStop()):(this.ff==="awaiting_config"&&(this.ff="missing_config",this._instance.register_for_session({[Jr]:!0}),Be.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(e,t="log"){var s;!((s=this.vf)===null||s===void 0)&&s.log?this.vf.log(e,t):Be.warn("log called before recorder was ready")}get wf(){var e,t;const s=(e=this._instance)===null||e===void 0||(e=e.persistence)===null||e===void 0?void 0:e.get_property(ds);return(s==null||(t=s.scriptConfig)===null||t===void 0?void 0:t.script)||"lazy-recorder"}$f(){const e=this._instance.get_property(ds);if(!e)return!1;let t;try{t=typeof e=="object"?e:JSON.parse(e)}catch(s){return Be.warn("persisted remote config for session recording is invalid and will be ignored",s),!1}return!L(t.cache_timestamp)&&36e5>=Date.now()-t.cache_timestamp}_f(e){var t,s,i;if(!this.gf&&this.yf&&this._instance.sessionManager){if(!(!((t=M.__PosthogExtensions__)===null||t===void 0)&&t.initSessionRecording))return Be.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[Gr]:!0});var r;if(this.vf||(this.vf=(r=M.__PosthogExtensions__)===null||r===void 0?void 0:r.initSessionRecording(this._instance,this.Je),this.vf._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.$f())return this.ff==="missing_config"||this.ff==="awaiting_config"?void 0:(this.ff="awaiting_config",Be.info("persisted remote config is stale, requesting fresh config before starting"),void new Vl(this._instance).load());this.ff=Fo,(s=(i=this.vf).setDocumentWasEverVisible)===null||s===void 0||s.call(i,this.Je),this.vf.start(e)}else this.ff=Ki}onRRwebEmit(e){var t,s;(t=this.vf)===null||t===void 0||(s=t.onRRwebEmit)===null||s===void 0||s.call(t,e)}overrideLinkedFlag(){var e,t;this.vf||(t=this._c)===null||t===void 0||t.register({$replay_override_linked_flag:!0}),(e=this.vf)===null||e===void 0||e.overrideLinkedFlag()}overrideSampling(){var e,t;this.vf||(t=this._c)===null||t===void 0||t.register({$replay_override_sampling:!0}),(e=this.vf)===null||e===void 0||e.overrideSampling()}overrideTrigger(e){var t,s;this.vf||(s=this._c)===null||s===void 0||s.register({[e==="url"?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),(t=this.vf)===null||t===void 0||t.overrideTrigger(e)}get sdkDebugProperties(){var e;const t={};for(const i of Kh){var s;const r=(s=this._instance.sessionPersistence)===null||s===void 0?void 0:s.get_property(i);x(r)||(t[i]=r)}return f(f({},t),((e=this.vf)===null||e===void 0?void 0:e.sdkDebugProperties)||{$recording_status:this.status})}tryAddCustomEvent(e,t){var s;return!!(!((s=this.vf)===null||s===void 0)&&s.tryAddCustomEvent(e,t))}flushBeforeIdentityReset(){var e,t;(e=this.vf)===null||e===void 0||(t=e.flushBeforeIdentityReset)===null||t===void 0||t.call(e)}}},Sp={autocapture:class extends Mh{constructor(e){super(new Uh(e)),this.instance=e}},historyAutocapture:class{constructor(e){this.Cf=!1,this._instance=e,this.Tf=this.If()}initialize(){this.startIfEnabled()}get isEnabled(){const e=this.Mf();return!!(e.path||e.search||this.Ef(e))}startIfEnabled(){this.isEnabled&&(E.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}startIfEnabledOrStop(){this.stop(),this.Tf=this.If(),this.startIfEnabled()}stop(){this.Pf&&this.Pf(),this.Pf=void 0,this.Rf&&this.Rf(),this.Rf=void 0,E.info("History API monitoring stopped")}monitorHistoryChanges(){w&&w.history&&(this.Af("pushState"),this.Af("replaceState"),this.Ff(),this.Ef()&&this.Of())}Af(e){var t;if(!w||!((t=w.history[e])===null||t===void 0)&&t.__posthog_wrapped__)return;const s=this;Vt(w.history,e,i=>function(r,n,o){var a;s.Df(o)&&s.Lf(),i.call(this,r,n,o),s.Nf(e,!s.Cf&&(w==null||(a=w.event)===null||a===void 0?void 0:a.type)!=="popstate")})}If(){const e=w?.location;if(e?.pathname)return{pathname:e.pathname,search:e.search,hash:e.hash}}Mf(){const e=this._instance.config.capture_pageview;return e==="history_change"?{path:!0}:D(e)?e:{}}Ef(e=this.Mf()){return!!e.hash&&!this._instance.config.disable_capture_url_hashes}qf(e){const t=this.Mf(),s=this.Tf;return!(!s||!(t.path&&e.pathname!==s.pathname||t.search&&e.search!==s.search||this.Ef(t)&&e.hash!==s.hash))}Nf(e,t=!1){try{t||this.Lf();const s=this.If();if(!s)return;if(this.qf(s)){const i=()=>this._instance.capture(Kr,{navigation_type:e});t?(this.jf=i,Promise.resolve().then(()=>this.Lf())):i()}this.Tf=s}catch(s){E.error(`Error capturing ${e} pageview`,s)}}Df(e){var t,s;return!(L(e)||!w)&&((t=Ke(String(e)))===null||t===void 0?void 0:t.href)!==((s=w.location)===null||s===void 0?void 0:s.href)}Lf(){const e=this.jf;if(e){this.jf=void 0,this.Cf=!0;try{e()}catch(t){E.error("Error capturing deferred pageview",t)}finally{this.Cf=!1}this.Tf=this.If()}}Ff(){if(this.Pf)return;const e=()=>{this.Nf("popstate")};U(w,"popstate",e),this.Pf=()=>{w&&w.removeEventListener("popstate",e)}}Of(){if(this.Rf)return;const e=()=>{this.Nf("hashchange")};U(w,"hashchange",e),this.Rf=()=>{w&&w.removeEventListener("hashchange",e)}}},heatmaps:class{get Ar(){return this.instance.config}constructor(e){var t;this.Bf=!1,this.ll=!1,this.zf=null,this.instance=e,this.Bf=!!(!((t=this.instance.persistence)===null||t===void 0)&&t.props[gr]),this.rageclicks=new pu(e.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){let e=5e3;return D(this.Ar.capture_heatmaps)&&this.Ar.capture_heatmaps.flush_interval_milliseconds&&(e=this.Ar.capture_heatmaps.flush_interval_milliseconds),e}get isEnabled(){return L(this.Ar.capture_heatmaps)?L(this.Ar.enable_heatmaps)?this.Bf:this.Ar.enable_heatmaps:this.Ar.capture_heatmaps!==!1}startIfEnabled(){if(this.isEnabled){if(this.ll)return;Yh.info("starting..."),this.Hf(),this.sn()}else{var e;clearInterval((e=this.zf)!==null&&e!==void 0?e:void 0),this.Uf(),this.getAndClearBuffer()}}onRemoteConfig(e){if(!e.ok)return;const t=e.config;if(!("heatmaps"in t))return;const s=!!t.heatmaps;this.instance.persistence&&this.instance.persistence.register({[gr]:s}),this.Bf=s,this.startIfEnabled()}getAndClearBuffer(){const e=this.Rt;return this.Rt=void 0,e}Wf(e){Yi(e.originalEvent)&&this.Er(e.originalEvent,"deadclick")}sn(){this.zf&&clearInterval(this.zf),this.zf=C?.visibilityState==="visible"?setInterval(this.rc.bind(this),this.flushIntervalMilliseconds):null}Hf(){w&&C&&(this.Vf=this.rc.bind(this),U(w,si,this.Vf),this.Gf=e=>this.Er(e||w?.event),U(C,"click",this.Gf,{capture:!0}),this.Qf=e=>this.Zf(e||w?.event),U(C,"mousemove",this.Qf,{capture:!0}),this.Jf=new so(this.instance,Jd,this.Wf.bind(this)),this.Jf.startIfEnabledOrStop(),this.Kf=this.sn.bind(this),U(C,Rt,this.Kf),this.ll=!0)}Uf(){var e;w&&C&&(this.Vf&&w.removeEventListener(si,this.Vf),this.Gf&&C.removeEventListener("click",this.Gf,{capture:!0}),this.Qf&&C.removeEventListener("mousemove",this.Qf,{capture:!0}),this.Kf&&C.removeEventListener(Rt,this.Kf),clearTimeout(this.Xf),(e=this.Jf)===null||e===void 0||e.stop(),this.ll=!1)}Yf(e,t){const s=this.instance.scrollManager.scrollY(),i=this.instance.scrollManager.scrollX(),r=this.instance.scrollManager.scrollElement(),n=(function(o,a,l){let u=o;for(;u&&Ie(u)&&!le(u,"body");){if(u===l)return!1;let p;try{var c,d,h;p=(c=(d=(h=u.ownerDocument)===null||h===void 0?void 0:h.defaultView)!==null&&d!==void 0?d:w)===null||c===void 0?void 0:c.getComputedStyle(u).position}catch{return!1}if(I(a,p))return!0;u=El(u)}return!1})(fs(e),["fixed","sticky"],r);return{x:e.clientX+(n?0:i),y:e.clientY+(n?0:s),target_fixed:n,type:t}}Er(e,t="click"){var s;if(Un(e.target)||!Yi(e))return;const i=this.Yf(e,t);!((s=this.rageclicks)===null||s===void 0)&&s.isRageClick(e.clientX,e.clientY,new Date().getTime())&&Pl(fs(e),this.instance.config.rageclick)&&this.Qs(f(f({},i),{},{type:"rageclick"})),this.Qs(i)}Zf(e){!Un(e.target)&&Yi(e)&&(clearTimeout(this.Xf),this.Xf=setTimeout(()=>{this.Qs(this.Yf(e,"mousemove"))},500))}Qs(e){if(!w)return;const t=this.Ar.disable_capture_url_hashes?at(w.location.href):w.location.href,s=this.Ar.custom_personal_data_properties,i=this.Ar.mask_personal_data_properties?[...Bt,...s||[]]:[],r=$s(t,i,ks);this.Rt=this.Rt||{},this.Rt[r]||(this.Rt[r]=[]),this.Rt[r].push(e)}rc(){this.Rt&&!ke(this.Rt)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:so,webVitalsAutocapture:class{constructor(e){var t;this._instance=e,this.Bf=!1,this.ll=!1,this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this.tp=(s=!1)=>{clearTimeout(this.ep),this.ep=void 0,this.Rt.metrics.length!==0&&(this._instance.capture("$web_vitals",f({$current_url:this.Rt.url},this.Rt.metrics.reduce((i,r)=>f(f({},i),{},{[`$web_vitals_${r.name}_event`]:f({},r),[`$web_vitals_${r.name}_value`]:r.value}),{})),s?{transport:"sendBeacon",send_instantly:!0}:void 0),this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.np=s=>{var i;if(this.Rt=this.Rt||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},L(s?.name)||L(s?.value))return void ct.error("Invalid metric received",s);const r=typeof s.navigationURL=="string"?s.navigationURL:void 0,n=this.sp(r);if(x(n))return;const o=oe(s.navigationId)||typeof s.navigationId=="string"?`navigation:${s.navigationId}`:`url:${n}`;if(this.rp&&s.value>=this.rp)return void ct.error("Ignoring metric with value >= "+this.rp,s);this.Rt.navigationKey!==o&&(this.tp(),this.ep=setTimeout(this.tp,this.flushToCaptureTimeoutMs)),x(this.Rt.navigationKey)&&(this.Rt.navigationKey=o,this.Rt.url=n),this.Rt.firstMetricTimestamp=x(this.Rt.firstMetricTimestamp)?Date.now():this.Rt.firstMetricTimestamp;const a=(i=this._instance.sessionManager)===null||i===void 0?void 0:i.checkAndGetSessionAndWindowId(!0),l=f(f(f({},s),r?{navigationURL:n}:{}),{},{$current_url:n,timestamp:Date.now()});if(delete l.entries,D(s.attribution)&&this.attributionMetrics.indexOf(s.name)>-1){const u={};for(const c of Jh){const d=c==="url"&&typeof s.attribution[c]=="string"?this.sp(s.attribution[c]):s.attribution[c];x(d)||(u[c]=d)}l.attribution=u}else delete l.attribution;x(a)||(l.$session_id=a.sessionId,l.$window_id=a.windowId),this.Rt.metrics.push(l),this.Rt.metrics.length===this.allowedMetrics.length&&this.tp()},this.op=()=>{if(this.ll)return;let s,i,r,n,o=!1;const a=M.__PosthogExtensions__,l=a?.postHogWebVitalsCallbacksByFlavor,u=l?.[this.ap]||(this.ap==="web-vitals"&&x(l)?a?.postHogWebVitalsCallbacks:void 0);if(!x(u)){const p=u.withoutAttribution,v=this.attributionMetrics;o=!x(p),s=v.indexOf("LCP")>-1?u.onLCP:p?.onLCP||u.onLCP,i=v.indexOf("CLS")>-1?u.onCLS:p?.onCLS||u.onCLS,r=v.indexOf("FCP")>-1?u.onFCP:p?.onFCP||u.onFCP,n=v.indexOf("INP")>-1?u.onINP:p?.onINP||u.onINP}if(!(s&&i&&r&&n))return void ct.error("web vitals callbacks not loaded - not starting");const c={reportSoftNavs:this.useSoftNavs},d=o&&this.attributionMetrics.indexOf("INP")>-1?f(f({},c),{},{includeProcessedEventEntries:!1}):c;this.allowedMetrics.indexOf("LCP")>-1&&s(this.np.bind(this),c),this.allowedMetrics.indexOf("CLS")>-1&&i(this.np.bind(this),c),this.allowedMetrics.indexOf("FCP")>-1&&r(this.np.bind(this),c),this.allowedMetrics.indexOf("INP")>-1&&n(this.np.bind(this),d);const h=w?.document;U(h,Rt,()=>{h?.visibilityState==="hidden"&&this.tp(!0)}),U(w,"pagehide",()=>this.tp(!0)),this.ll=!0},this.Bf=!!(!((t=this._instance.persistence)===null||t===void 0)&&t.props[yr]),this.startIfEnabled()}get lp(){return this._instance.config.capture_performance}get allowedMetrics(){var e,t;const s=D(this.lp)?(e=this.lp)===null||e===void 0?void 0:e.web_vitals_allowed_metrics:void 0;return L(s)?((t=this._instance.persistence)===null||t===void 0?void 0:t.props.$web_vitals_allowed_metrics)||Co:s}get flushToCaptureTimeoutMs(){return(D(this.lp)?this.lp.web_vitals_delayed_flush_ms:void 0)||5e3}get attributionMetrics(){const e=D(this.lp)?this.lp.web_vitals_attribution:void 0;return we(e)?e?Co:[]:O(e)?e:Gh}get useAttribution(){return this.attributionMetrics.length>0}get useSoftNavs(){const e=D(this.lp)?this.lp.__preview_web_vitals_soft_navs:void 0;return e!=null&&e}get rp(){const e=D(this.lp)&&oe(this.lp.__web_vitals_max_value)?this.lp.__web_vitals_max_value:Ao;return e>0&&6e4>=e?Ao:e}get isEnabled(){const e=Y?.protocol;if(e!=="http:"&&e!=="https:")return ct.info("Web Vitals are disabled on non-http/https protocols"),!1;const t=D(this.lp)?this.lp.web_vitals:we(this.lp)?this.lp:void 0;return we(t)?t:this.Bf}startIfEnabled(){this.isEnabled&&!this.ll&&(ct.info("enabled, starting..."),this.Ml(this.op))}onRemoteConfig(e){if(!e.ok)return;const t=e.config;if(!("capturePerformance"in t))return;const s=D(t.capturePerformance)&&!!t.capturePerformance.web_vitals,i=D(t.capturePerformance)?t.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[yr]:s}),this._instance.persistence.register({[il]:i})),this.Bf=s,this.startIfEnabled()}get ap(){return this.useSoftNavs?this.useAttribution?"web-vitals-with-attribution-soft-navs":"web-vitals-soft-navs":this.useAttribution?"web-vitals-with-attribution":"web-vitals"}Ml(e){var t;const s=M.__PosthogExtensions__,i=this.ap,r=s?.postHogWebVitalsCallbacksByFlavor;r?.[i]||i==="web-vitals"&&x(r)&&s?.postHogWebVitalsCallbacks?e():s==null||(t=s.loadExternalDependency)===null||t===void 0||t.call(s,this._instance,i,n=>{n?ct.error("failed to load script",n):e()})}sp(e){const t=e||w?.location.href;if(!t)return void ct.error("Could not determine current URL");const s=this._instance.config.disable_capture_url_hashes?at(t):t,i=this._instance.config.custom_personal_data_properties,r=this._instance.config.mask_personal_data_properties?[...Bt,...i||[]]:[];return $s(s,r,ks)}}},Pp={exceptionObserver:class{constructor(e){var t;this.op=()=>{var s;if(!w||!this.isEnabled||!(!((s=M.__PosthogExtensions__)===null||s===void 0)&&s.errorWrappingFunctions))return;const i=M.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,r=M.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,n=M.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.up&&this.Ar.capture_unhandled_errors&&(this.up=i(this.captureException.bind(this))),!this.cp&&this.Ar.capture_unhandled_rejections&&(this.cp=r(this.captureException.bind(this))),!this.hp&&this.Ar.capture_console_errors&&(this.hp=n(this.captureException.bind(this)))}catch(o){ss.error("failed to start",o),this.dp()}},this._instance=e,this.vp=!!(!((t=this._instance.persistence)===null||t===void 0)&&t.props[_r]),this.wt=new Du(f(f({},(function(s={}){var i,r,n,o;return{refillRate:(i=(r=s.exceptionRateLimiterRefillRate)!==null&&r!==void 0?r:s.__exceptionRateLimiterRefillRate)!==null&&i!==void 0?i:1,bucketSize:(n=(o=s.exceptionRateLimiterBucketSize)!==null&&o!==void 0?o:s.__exceptionRateLimiterBucketSize)!==null&&n!==void 0?n:10}})(this._instance.config.error_tracking)),{},{refillInterval:1e4,$:ss})),this.Ar=this.fp(),this.startIfEnabledOrStop()}fp(){const e=this._instance.config.capture_exceptions;let t={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return D(e)?t=f(f({},t),e):(x(e)?this.vp:e)&&(t=f(f({},t),{},{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),t}get isEnabled(){return this.Ar.capture_console_errors||this.Ar.capture_unhandled_errors||this.Ar.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(ss.info("enabled"),this.dp(),this.Ml(this.op)):this.dp()}Ml(e){var t,s,i;!((t=M.__PosthogExtensions__)===null||t===void 0)&&t.errorWrappingFunctions?e():(s=M.__PosthogExtensions__)===null||s===void 0||(i=s.loadExternalDependency)===null||i===void 0||i.call(s,this._instance,"exception-autocapture",r=>{if(r)return ss.error("failed to load script",r);e()})}dp(){var e,t,s;(e=this.up)===null||e===void 0||e.call(this),this.up=void 0,(t=this.cp)===null||t===void 0||t.call(this),this.cp=void 0,(s=this.hp)===null||s===void 0||s.call(this),this.hp=void 0}onRemoteConfig(e){if(!e.ok)return;const t=e.config;"autocaptureExceptions"in t&&(this.vp=!!t.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[_r]:this.vp}),this.Ar=this.fp(),this.startIfEnabledOrStop())}onConfigChange(){this.Ar=this.fp()}captureException(e){try{var t,s,i;const r=(t=e==null||(s=e.$exception_list)===null||s===void 0||(s=s[0])===null||s===void 0?void 0:s.type)!==null&&t!==void 0?t:"Exception";if(this.wt.consumeRateLimit(r))return void ss.info("Skipping exception capture because of client rate limiting.",{exception:r});(i=this._instance.exceptions)===null||i===void 0||i.sendExceptionEvent(e)}catch{}}},exceptions:class{constructor(e){var t,s;this.pp=[],this.gp=new Ku([new cc,new yc,new hc,new dc,new _c,new gc,new fc,new mc],(function(i,...r){return(n,o=0)=>{const a=[],l=n.split(`
3
+ `),u=Math.min(l.length,o+1e3),c=[];for(let p=o;u>p;p++){const v=l[p];if(v.length>1024)continue;const m=$n.test(v)?v.replace($n,"$1"):v;if(!m.match(/\S*Error: /)){for(const g of r){const y=g(m,i);if(y){a.push(y);const _=oc(a);if(_){for(let b=c.length-1;b>=0;b--){const k=c[b];if(_.start>=k.start+k.length)break;c.pop()}c.push(_)}break}}if(lc(a,c)>=50)break}}const d=[...c].sort((p,v)=>v.start-p.start),h=d[d.length-1];if(h){const p=Ta(a,h);a.splice(h.start-p,p);for(const v of d)v.start-=p}for(const p of d)ac(a,p);return c.some(p=>p.start===0&&a.length===p.length)&&(function(p){const v=p.map(g=>`${g.function}|${g.filename}|${g.lineno}|${g.colno}|${g.module}`);let m=0;for(let g=1;v.length>g;g++)uc(v,g,m)&&(m=g);p.push(...p.splice(0,m))})(a),(function(p){if(!p.length)return[];const v=Array.from(p);return v.reverse(),v.slice(0,50).map(m=>{return f(f({},m),{},{filename:m.filename||(g=v,g[g.length-1]||{}).filename,function:m.function||"?"});var g})})(a)}})("web:javascript",sc,nc)),this._instance=e,this.pp=(t=(s=this._instance.persistence)===null||s===void 0?void 0:s.get_property("$error_tracking_suppression_rules"))!==null&&t!==void 0?t:[],this.mp=Ys(this.yp()),this.bp=new wc(this.mp)}onConfigChange(){this.mp=Ys(this.yp()),this.bp.setConfig(this.mp)}onRemoteConfig(e){var t,s,i;if(!e.ok)return;const r=e.config;if(!("errorTracking"in r))return;const n=(t=(s=r.errorTracking)===null||s===void 0?void 0:s.suppressionRules)!==null&&t!==void 0?t:[],o=(i=r.errorTracking)===null||i===void 0?void 0:i.captureExtensionExceptions;this.pp=n,this._instance.persistence&&this._instance.persistence.register({[tl]:this.pp,[mr]:o})}get _p(){var e;const t=!!this._instance.get_property(mr),s=this._instance.config.error_tracking.captureExtensionExceptions;return(e=s??t)!==null&&e!==void 0&&e}buildProperties(e,t){return this.gp.buildFromUnknown(e,{syntheticException:t?.syntheticException,mechanism:{handled:t?.handled}})}addExceptionStep(e,t){if(this.mp.enabled)try{if(!N(e)||e.trim().length===0)return void Me.warn("Ignoring exception step because message must be a non-empty string");const{sanitizedProperties:s,droppedKeys:i}=(function(r){if(!r)return{sanitizedProperties:{},droppedKeys:[]};const n=[];return{sanitizedProperties:Object.keys(r).reduce((o,a)=>bc.has(a)?(n.push(a),o):(o[a]=r[a],o),{}),droppedKeys:n}})(this.wp(t));i.length>0&&Me.warn("Ignoring reserved exception step fields",{droppedKeys:i}),this.bp.add(f({[Js]:e,[Ks]:new Date().toISOString()},s))}catch(s){Me.error("Failed to add exception step. Ignoring breadcrumb.",s)}}sendExceptionEvent(e){try{const t=e.$exception_list;if(this.kp(t)){if(this.Sp(t))return this.xp("Exception dropped: matched a suppression rule"),void Me.info("Skipping exception capture because a suppression rule matched");if(!this._p&&this.$p(t))return this.xp("Exception dropped: thrown by a browser extension"),void Me.info("Skipping exception capture because it was thrown by an extension");if(!this._p&&this.Cp(t))return this.xp("Exception dropped: thrown by an injected browser script"),void Me.info("Skipping exception capture because it was thrown by an injected browser script");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.Tp(t))return this.xp("Exception dropped: thrown by the PostHog SDK"),void Me.info("Skipping exception capture because it was thrown by the PostHog SDK")}const s=this.mp.enabled&&L(e.$exception_steps)?this.Ip(e):e,i=(function(){if("u">typeof process){var r;const o=(r=Pu.POSTHOG_RELEASE_ID)===null||r===void 0?void 0:r.trim();if(o)return o}const n=globalThis._posthogReleaseId;return typeof n=="string"&&n.length>0?n:void 0})();i&&(s.$release_id=i);try{const r=this._instance.capture("$exception",s,{_noTruncate:!0,_batchKey:"exceptionEvent",sd:!0});return r&&this.bp.clear(),r}catch(r){return Ho(r)||Me.error("Failed to capture exception event. Dropping this exception.",r),void this.bp.clear()}}catch(t){return void(Ho(t)||Me.error("Failed to process exception event. Ignoring this exception.",t))}}Ip(e){try{const t=this.bp.getAttachable();return t.length===0?e:f(f({},e),{},{$exception_steps:t})}catch(t){return Me.error("Failed to read buffered exception steps. Capturing exception without steps.",t),e}}xp(e){this.mp.enabled&&this.bp.add({[Js]:e,[Ks]:new Date().toISOString()})}wp(e){return D(e)?f({},e):{}}yp(){var e,t;return(e=(t=this._instance.config.error_tracking)===null||t===void 0?void 0:t.exception_steps)!==null&&e!==void 0?e:{}}Sp(e){if(e.length===0)return!1;try{const t=e.reduce((s,{type:i,value:r})=>(N(i)&&i.length>0&&s.$exception_types.push(i),N(r)&&r.length>0&&s.$exception_values.push(r),s),{$exception_types:[],$exception_values:[]});return this.pp.some(s=>{const i=s.values.map(r=>{const n=cu[r.operator],o=t[r.key];if(!n||!o)return!1;const a=O(r.value)?r.value:[r.value];return a.length>0&&n(a,o)});return s.type==="OR"?i.some(Boolean):i.every(Boolean)})}catch(t){return Me.warn("Failed to evaluate suppression rules. Capturing the exception.",t),!1}}$p(e){const t=e.flatMap(i=>{var r,n;return(r=(n=i.stacktrace)===null||n===void 0?void 0:n.frames)!==null&&r!==void 0?r:[]}),s=t.filter(({filename:i})=>!!i&&lp.some(r=>i.startsWith(r)));return s.length!==0&&(!s.every(({filename:i})=>!!i&&i.startsWith(Mr))||e.some(({type:i,value:r})=>i==="NoResponse"||N(r)&&ap.some(({value:n,exact:o})=>o?r===n:r.includes(n)))&&!t.some(({in_app:i,filename:r})=>i&&!r?.startsWith(Mr)))}Cp(e){return e.some(({value:t})=>N(t)&&up.some(s=>t.includes(s)))}Tp(e){if(e.length>0){var t,s,i,r;const n=(t=(s=e[0].stacktrace)===null||s===void 0?void 0:s.frames)!==null&&t!==void 0?t:[],o=n[n.length-1];return(i=o==null||(r=o.filename)===null||r===void 0?void 0:r.includes("posthog.com/static"))!==null&&i!==void 0&&i}return!1}kp(e){return!L(e)&&O(e)}}},Ap=f({productTours:class{get _c(){return this._instance.persistence}constructor(e){this.Mp=null,this.Ep=null,this._instance=e}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(!e.ok)return;const t=e.config;if("productTours"in t){var s,i;if(this._c&&this._c.register({[Ur]:!!t.productTours}),!Xi(this._instance))return!this.Mp&&L((s=this._c)===null||s===void 0?void 0:s.props.ph_product_tours)||Rs.info("product tours disabled; stopping and clearing cached tours"),(i=this.Mp)===null||i===void 0||i.stop(),this.Mp=null,void this.clearCache();this.loadIfEnabled()}}loadIfEnabled(){!this.Mp&&Xi(this._instance)&&this.Ml(()=>this.Pp())}Ml(e){var t,s,i;!((t=M.__PosthogExtensions__)===null||t===void 0)&&t.generateProductTours?e():(s=M.__PosthogExtensions__)===null||s===void 0||(i=s.loadExternalDependency)===null||i===void 0||i.call(s,this._instance,"product-tours",r=>{r?Rs.error("Could not load product tours script",r):e()})}Pp(){var e;!this.Mp&&(!((e=M.__PosthogExtensions__)===null||e===void 0)&&e.generateProductTours)&&(this.Mp=M.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,t=!1){if(O(this.Ep)&&!t)return void e(this.Ep,{isLoaded:!0});const s=this._c;if(s){const i=s.props[br];if(O(i)&&!t)return this.Ep=i,void e(i,{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(!Xi(this._instance))return void e([],{isLoaded:!0});const r=i.statusCode;if(r!==200||!i.json){const o=`Product Tours API could not be loaded, status: ${r}`;return r===0?i.error||Rs.warn(o):Rs.error(o),void e([],{isLoaded:!1,error:o})}const n=O(i.json.product_tours)?i.json.product_tours:[];this.Ep=n,s&&s.register({[br]:n}),e(n,{isLoaded:!0})}})}getActiveProductTours(e){L(this.Mp)?e([],{isLoaded:!1,error:"Product tours not loaded"}):this.Mp.getActiveProductTours(e)}showProductTour(e){var t;(t=this.Mp)===null||t===void 0||t.showTourById(e)}previewTour(e){this.Mp?this.Mp.previewTour(e):this.Ml(()=>{var t;this.Pp(),(t=this.Mp)===null||t===void 0||t.previewTour(e)})}dismissProductTour(){var e;(e=this.Mp)===null||e===void 0||e.dismissTour("user_clicked_skip")}nextStep(){var e;(e=this.Mp)===null||e===void 0||e.nextStep()}previousStep(){var e;(e=this.Mp)===null||e===void 0||e.previousStep()}clearCache(){var e;this.Ep=null,(e=this._c)===null||e===void 0||e.unregister("ph_product_tours")}resetTour(e){var t;(t=this.Mp)===null||t===void 0||t.resetTour(e)}resetAllTours(){var e;(e=this.Mp)===null||e===void 0||e.resetAllTours()}cancelPendingTour(e){var t;(t=this.Mp)===null||t===void 0||t.cancelPendingTour(e)}}},fi),Cp={siteApps:class{constructor(e){this._instance=e,this.Rp=0,this.Ap=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}Fp(e,t){if(!t)return;const s=this.globalsForEvent(t);this.Ap.push(s),this.Ap.length>1e3&&(this.Ap=this.Ap.slice(10))}get siteAppLoaders(){var e;return(e=M._POSTHOG_REMOTE_CONFIG)===null||e===void 0||(e=e[this._instance.config.token])===null||e===void 0?void 0:e.siteApps}initialize(){if(this.isEnabled){const e=this._instance._addCaptureHook(this.Fp.bind(this));this.Op=()=>{e(),this.Ap=[],this.Op=void 0}}}globalsForEvent(e){var t,s,i,r,n,o,a;if(!e)throw new Error("Event payload is required");const l={},u=this._instance.get_property("$groups")||[],c=this._instance.get_property("$stored_group_properties")||{};for(const[p,v]of Object.entries(c))l[p]={id:u[p],type:p,properties:v};const{$set_once:d,$set:h}=e;return{event:f(f({},Na(e,Xh)),{},{properties:f(f(f({},e.properties),h?{$set:f(f({},(t=(s=e.properties)===null||s===void 0?void 0:s.$set)!==null&&t!==void 0?t:{}),h)}:{}),d?{$set_once:f(f({},(i=(r=e.properties)===null||r===void 0?void 0:r.$set_once)!==null&&i!==void 0?i:{}),d)}:{}),elements_chain:(n=(o=e.properties)===null||o===void 0?void 0:o.$elements_chain)!==null&&n!==void 0?n:"",distinct_id:(a=e.properties)===null||a===void 0?void 0:a.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:l}}Dp(e){var t;const s=(t=e.tagName)===null||t===void 0?void 0:t.toLowerCase();return s==="style"&&this._instance.config.prepare_external_dependency_stylesheet?this._instance.config.prepare_external_dependency_stylesheet(e)||(De.error("prepare_external_dependency_stylesheet returned null"),null):s==="script"&&this._instance.config.prepare_external_dependency_script?this._instance.config.prepare_external_dependency_script(e)||(De.error("prepare_external_dependency_script returned null"),null):e}Lp(){var e,t,s,i,r,n,o,a;if(!this._instance.config.prepare_external_dependency_stylesheet&&!this._instance.config.prepare_external_dependency_script)return()=>{};const l=C?.defaultView,u=l==null||(e=l.Node)===null||e===void 0?void 0:e.prototype;if(!l||!u)return()=>{};if(this.Rp++,this.Np)return this.qp();const c=[],d=this,h=new WeakSet,p=(g,y,_)=>{if(!g?.[y])return;const b=g[y];g[y]=_(b),c.push(()=>{g[y]=b})},v=g=>{if(h.has(g))return g;const y=d.Dp(g);return y&&h.add(y),y},m=g=>g.map(y=>typeof y=="string"?y:v(y)).filter(y=>!se(y));return p(u,"appendChild",g=>function(y){const _=v(y);return _?g.call(this,_):y}),p(u,"insertBefore",g=>function(y,_){const b=v(y);return b?g.call(this,b,_):y}),p(u,"replaceChild",g=>function(y,_){const b=v(y);return b?g.call(this,b,_):_}),[(t=l.Element)===null||t===void 0?void 0:t.prototype,(s=l.Document)===null||s===void 0?void 0:s.prototype,(i=l.DocumentFragment)===null||i===void 0?void 0:i.prototype].forEach(g=>{p(g,"append",y=>function(..._){return y.apply(this,m(_))}),p(g,"prepend",y=>function(..._){return y.apply(this,m(_))})}),[(r=l.Element)===null||r===void 0?void 0:r.prototype,(n=l.CharacterData)===null||n===void 0?void 0:n.prototype,(o=l.DocumentType)===null||o===void 0?void 0:o.prototype].forEach(g=>{p(g,"before",y=>function(..._){return y.apply(this,m(_))}),p(g,"after",y=>function(..._){return y.apply(this,m(_))}),p(g,"replaceWith",y=>function(..._){const b=m(_);return _.length&&!b.length?void 0:y.apply(this,b)})}),p((a=l.Element)===null||a===void 0?void 0:a.prototype,"insertAdjacentElement",g=>function(y,_){const b=v(_);return b?g.call(this,y,b):null}),this.Np=()=>{c.forEach(g=>g()),this.Np=void 0},this.qp()}qp(){let e=!1;return()=>{var t;e||(e=!0,this.Rp--,this.Rp===0&&((t=this.Np)===null||t===void 0||t.call(this)))}}jp(e,t=!0){const s=this.Lp();try{const i=e(s);return t&&s(),i}catch(i){throw s(),i}}setupSiteApp(e){const t=this.apps[e.id],s=()=>{var n;!t.errored&&this.Ap.length&&(De.info(`Processing ${this.Ap.length} events for site app with id ${e.id}`),this.Ap.forEach(o=>this.jp(()=>{var a;return(a=t.processEvent)===null||a===void 0?void 0:a.call(t,o)})),t.processedBuffer=!0),Object.values(this.apps).every(o=>o.processedBuffer||o.errored)&&((n=this.Op)===null||n===void 0||n.call(this))};let i=!1;const r=n=>{t.errored=!n,t.loaded=!0,De.info(`Site app with id ${e.id} ${n?"loaded":"errored"}`),i&&s()};try{const{processEvent:n}=this.jp(o=>e.init({posthog:this._instance,callback(a){o(),r(a)}}),!1);n&&(t.processEvent=n),i=!0}catch(n){De.error(Io+e.id,n),r(!1)}if(i&&t.loaded)try{s()}catch(n){De.error(`Error while processing buffered events PostHog app with config id ${e.id}`,n),t.errored=!0}}Bp(){const e=this.siteAppLoaders||[];for(const t of e)this.apps[t.id]={id:t.id,loaded:!1,errored:!1,processedBuffer:!1};for(const t of e)this.setupSiteApp(t)}zp(e){if(Object.keys(this.apps).length===0)return;const t=this.globalsForEvent(e);for(const s of Object.values(this.apps))try{this.jp(()=>{var i;return(i=s.processEvent)===null||i===void 0?void 0:i.call(s,t)})}catch(i){De.error(`Error while processing event ${e.event} for site app ${s.id}`,i)}}onRemoteConfig(e){var t,s,i;if(!((t=this.siteAppLoaders)===null||t===void 0)&&t.length)return this.isEnabled?(this.Bp(),void this._instance.on("eventCaptured",a=>this.zp(a))):void De.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if((s=this.Op)===null||s===void 0||s.call(this),!e.ok)return;const r=e.config;if(!((i=r.siteApps)===null||i===void 0)&&i.length)if(this.isEnabled)for(const{id:a,url:l}of r.siteApps){var n,o;M[`__$$ph_site_app_${a}`]=this._instance,(n=M.__PosthogExtensions__)===null||n===void 0||(o=n.loadSiteApp)===null||o===void 0||o.call(n,this._instance,l,u=>{if(u)return De.error(Io+a,u)})}else De.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}},Fp={tracingHeaders:class{constructor(e){this._instance=e,this.Hp=void 0,this.Up=void 0,this.Wp=void 0,this.op=()=>{const t=this.Vp();var s,i;t?(x(this.Hp)&&(this.Hp=(s=M.__PosthogExtensions__)===null||s===void 0||(s=s.tracingHeadersPatchFns)===null||s===void 0?void 0:s._patchXHR(t,()=>this._instance.get_distinct_id(),this._instance.sessionManager)),x(this.Up)&&(this.Up=(i=M.__PosthogExtensions__)===null||i===void 0||(i=i.tracingHeadersPatchFns)===null||i===void 0?void 0:i._patchFetch(t,()=>this._instance.get_distinct_id(),this._instance.sessionManager))):this.dp()}}initialize(){this.startIfEnabledOrStop()}Ml(e){var t,s,i;!((t=M.__PosthogExtensions__)===null||t===void 0)&&t.tracingHeadersPatchFns?e():(s=M.__PosthogExtensions__)===null||s===void 0||(i=s.loadExternalDependency)===null||i===void 0||i.call(s,this._instance,"tracing-headers",r=>{if(r)return Wh.error("failed to load script",r);e()})}Gp(){var e,t;return(e=(t=this._instance.config.tracing_headers)!==null&&t!==void 0?t:this._instance.config.addTracingHeaders)!==null&&e!==void 0?e:this._instance.config.__add_tracing_headers}Vp(){const e=this.Gp();return O(e)?(O(this.Wp)?this.Wp.splice(0,this.Wp.length,...e):this.Wp=[...e],e.length>0?this.Wp:void 0):(O(this.Wp)&&this.Wp.splice(0),this.Wp=e||void 0,this.Wp)}dp(){var e,t;(e=this.Hp)===null||e===void 0||e.call(this),(t=this.Up)===null||t===void 0||t.call(this),this.Hp=void 0,this.Up=void 0}startIfEnabledOrStop(){this.Vp()?this.Ml(this.op):this.dp()}}},Ip=f({surveys:class extends tp{constructor(e){super(new sp(e))}}},fi),Op={toolbar:class{constructor(e){this.instance=e}Qp(e){M.ph_toolbar_state=e}Zp(){var e;return(e=M.ph_toolbar_state)!==null&&e!==void 0?e:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(e=void 0,t=void 0,s=void 0){var i,r;if(xr(this.instance.config)||!w||!C)return!1;e=(i=e)!==null&&i!==void 0?i:w.location,s=(r=s)!==null&&r!==void 0?r:w.history;try{if(!t){try{w.localStorage.setItem("test","test"),w.localStorage.removeItem("test")}catch{return!1}t=w?.localStorage}const n=ip||ri(e.hash,"__posthog")||ri(e.hash,"state");let o;const a=n?_n(()=>JSON.parse(atob(decodeURIComponent(n))))||_n(()=>JSON.parse(decodeURIComponent(n))):null;return a&&a.action==="ph_authorize"?(o=a,o.source="url",o&&Object.keys(o).length>0&&(a.desiredHash?e.hash=a.desiredHash:s?s.replaceState(s.state,"",e.pathname+e.search):e.hash="")):(o=JSON.parse(t.getItem(Mo)||"{}"),o.source="localstorage",delete o.userIntent),!(!o.token||this.instance.config.token!==o.token||(this.loadToolbar(o),0))}catch{return!1}}Jp(e){const t=M.ph_load_toolbar||M.ph_load_editor;!L(t)&&ne(t)?t(e,this.instance):To.warn("No toolbar load function found")}loadToolbar(e){const t=!!C?.getElementById("__POSTHOG_TOOLBAR__");if(!w||t)return!1;const s=this.instance.requestRouter.region==="custom"&&this.instance.config.advanced_disable_toolbar_metrics,i=f(f({token:this.instance.config.token},e),{},{apiURL:this.instance.requestRouter.endpointFor("ui")},s?{instrument:!1}:{});if(w.localStorage.setItem(Mo,JSON.stringify(f(f({},i),{},{source:void 0}))),this.Zp()===2)this.Jp(i);else if(this.Zp()===0){var r,n;this.Qp(1),(r=M.__PosthogExtensions__)===null||r===void 0||(n=r.loadExternalDependency)===null||n===void 0||n.call(r,this.instance,"toolbar",o=>{if(o)return To.error("[Toolbar] Failed to load",o),void this.Qp(0);this.Qp(2),this.Jp(i)}),U(w,"turbolinks:load",()=>{this.Qp(0),this.loadToolbar(i)})}return!0}Kp(e){return this.loadToolbar(e)}maybeLoadEditor(e=void 0,t=void 0,s=void 0){return this.maybeLoadToolbar(e,t,s)}}},Mp=f({experiments:class ye{get Ar(){return this._instance.config}constructor(t){this._instance=t,this.getWebExperimentsAndEvaluateDisplayLogic=(s=!1)=>{this.getWebExperiments(i=>{ye.Xp("retrieved web experiments from the server"),this.Yp=new Map,i.forEach(r=>{if(r.feature_flag_key){var n;this.Yp&&(ye.Xp("setting flag key ",r.feature_flag_key," to web experiment ",r),(n=this.Yp)===null||n===void 0||n.set(r.feature_flag_key,r));const o=this._instance.getFeatureFlag(r.feature_flag_key);N(o)&&r.variants[o]&&this.tg(r.name,o,r.variants[o].transforms)}else if(r.variants)for(const o in r.variants){const a=r.variants[o];ye.eg(a,this._instance)&&this.tg(r.name,o,a.transforms)}})},s)},this._instance.onFeatureFlags(s=>{this.onFeatureFlags(s)})}initialize(){}onFeatureFlags(t){if(this._is_bot())ye.Xp(Bo);else if(!this.Ar.disable_web_experiments){if(L(this.Yp))return this.Yp=new Map,this.loadIfEnabled(),void this.previewWebExperiment();ye.Xp("applying feature flags",t),t.forEach(s=>{var i;if(this.Yp&&(!((i=this.Yp)===null||i===void 0)&&i.has(s))){var r;const n=this._instance.getFeatureFlag(s),o=(r=this.Yp)===null||r===void 0?void 0:r.get(s);n&&o?.variants[n]&&this.tg(o.name,n,o.variants[n].transforms)}})}}previewWebExperiment(){const t=ye.getWindowLocation();if(t?.search){const s=Ht(t?.search,"__experiment_id"),i=Ht(t?.search,"__experiment_variant");s&&i&&(ye.Xp(`previewing web experiments ${s} && ${i}`),this.getWebExperiments(r=>{this.ig(parseInt(s),i,r)},!1,!0))}}loadIfEnabled(){this.Ar.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(t,s,i){if(this.Ar.disable_web_experiments&&!i)return t([]);const r=this._instance.get_property("$web_experiments");if(r&&!s)return t(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api",`/api/web_experiments/?token=${this.Ar.token}`),method:"GET",timestampMode:"query",callback:n=>t(n.statusCode===200&&n.json&&n.json.experiments||[])})}ig(t,s,i){const r=i.filter(n=>n.id===t);r&&r.length>0&&(ye.Xp(`Previewing web experiment [${r[0].name}] with variant [${s}]`),this.tg(r[0].name,s,r[0].variants[s].transforms))}static eg(t,s){return!L(t.conditions)&&ye.ng(t,s)&&ye.sg(t)}static ng(t,s){var i;if(L(t.conditions)||L((i=t.conditions)===null||i===void 0?void 0:i.url))return!0;const r=ye.getWindowLocation();if(r){var n,o,a;const l=xl(s,r.href);return!(!((n=t.conditions)===null||n===void 0)&&n.url)||cp[(o=(a=t.conditions)===null||a===void 0?void 0:a.urlMatchType)!==null&&o!==void 0?o:"icontains"](t.conditions.url,l)}return!1}static getWindowLocation(){return w?.location}static sg(t){var s;if(L(t.conditions)||L((s=t.conditions)===null||s===void 0?void 0:s.utm))return!0;const i=Ll();if(i.utm_source){var r,n,o,a,l,u,c,d;const h=!(!((r=t.conditions)===null||r===void 0||(r=r.utm)===null||r===void 0)&&r.utm_campaign)||((n=t.conditions)===null||n===void 0||(n=n.utm)===null||n===void 0?void 0:n.utm_campaign)==i.utm_campaign,p=!(!((o=t.conditions)===null||o===void 0||(o=o.utm)===null||o===void 0)&&o.utm_source)||((a=t.conditions)===null||a===void 0||(a=a.utm)===null||a===void 0?void 0:a.utm_source)==i.utm_source,v=!(!((l=t.conditions)===null||l===void 0||(l=l.utm)===null||l===void 0)&&l.utm_medium)||((u=t.conditions)===null||u===void 0||(u=u.utm)===null||u===void 0?void 0:u.utm_medium)==i.utm_medium,m=!(!((c=t.conditions)===null||c===void 0||(c=c.utm)===null||c===void 0)&&c.utm_term)||((d=t.conditions)===null||d===void 0||(d=d.utm)===null||d===void 0?void 0:d.utm_term)==i.utm_term;return h&&v&&m&&p}return!1}static Xp(t,...s){E.info(`[WebExperiments] ${t}`,s)}tg(t,s,i){this._is_bot()?ye.Xp(Bo):s!=="control"?i.forEach(r=>{if(r.selector){var n;ye.Xp(`applying transform of variant ${s} for experiment ${t} `,r);const o=(n=document)===null||n===void 0?void 0:n.querySelectorAll(r.selector);o?.forEach(a=>{const l=a;r.html&&(l.innerHTML=r.html),r.css&&l.setAttribute("style",r.css)})}}):ye.Xp("Control variants leave the page unmodified.")}_is_bot(){return pe&&this._instance?au(pe,this.Ar.custom_blocked_useragents):void 0}}},fi),Tp={conversations:class{constructor(e){this._instance=e,this.rg=void 0,this._conversationsManager=null,this.og=!1,this.ne=null,this.ag=!1,this.lg=0,this.ug=null,this.cg=null}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(this._instance.config.disable_conversations)return void(this.ug=null);if(this.hg=e.ok,!e.ok)return;const t=e.config.conversations;L(t)?this.ug=null:(we(t)?this.rg=t:(this.rg=t.enabled,this.ne=t),this.rg||(this.ug=null),this.loadIfEnabled())}reset(){var e;(e=this._conversationsManager)===null||e===void 0||e.reset(),this._conversationsManager=null,this.lg++,this.rg=void 0,this.ne=null,this.hg=void 0,this.ag=!1,this.ug=null}loadIfEnabled(){if(this._conversationsManager||this.og||this._instance.config.disable_conversations||xr(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())return;const e=M?.__PosthogExtensions__;if(e&&!x(this.rg)&&this.rg)if(this.ne&&this.ne.token){this.og=!0;try{const t=e.initConversations;if(t)return this.dg(t),void(this.og=!1);const s=e.loadExternalDependency;if(!s)return void this.vg(Br);const i=this.lg;s(this._instance,"conversations",r=>{if(i!==this.lg)return this.og=!1,void this.loadIfEnabled();r||!e.initConversations?this.vg("Could not load conversations script",r):this.dg(e.initConversations),this.og=!1})}catch(t){this.vg("Error initializing conversations",t),this.og=!1}}else Ce.error("Conversations enabled but missing token in remote config.")}dg(e){if(this.ne){try{this._conversationsManager=e(this.ne,this._instance),this.ag=!1,Ce.info("Conversations loaded successfully")}catch(t){return void this.vg("Error completing conversations initialization",t)}this.cg&&this._conversationsManager.setTheme(this.cg),this.fg()}else Ce.error("Cannot complete initialization: remote config is null")}fg(){const e=this.ug;this.ug=null,this._conversationsManager&&e&&(e==="open"?this._conversationsManager.open():this._conversationsManager.close())}vg(e,t){Ce.error(e,t),this._conversationsManager=null,this.og=!1,this.ag=!0}show(){this._conversationsManager?this._conversationsManager.show():Ce.warn("Conversations not loaded yet.")}hide(){this.ug==="open"&&(this.ug=null),this._conversationsManager&&this._conversationsManager.hide()}open(){this._conversationsManager?(this.ug=null,this._conversationsManager.open()):this.ug="open"}close(){this._conversationsManager?(this.ug=null,this._conversationsManager.close()):this.ug="close"}setTheme(e){var t,s;this.cg=f(f(f({},this.cg),e),{},{dark:f(f({},(t=this.cg)===null||t===void 0?void 0:t.dark),e?.dark)}),(s=this._conversationsManager)===null||s===void 0||s.setTheme(e)}isAvailable(){return this.rg===!0&&!se(this._conversationsManager)}getUnavailableReason(){return this.isAvailable()?null:this._instance.config.disable_conversations?"disabled_by_config":xr(this._instance.config)?"disabled_for_toolbar":this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut()?"consent_opted_out":this.hg===!1?"remote_config_failed":x(this.rg)?this.hg?"disabled_in_project":"remote_config_pending":this.rg?L(this.ne)||!this.ne.token?"missing_token":M?.__PosthogExtensions__?this.og?"initializing":this.ag?"load_failed":"not_loaded":"extensions_unavailable":"disabled_in_project"}isVisible(){var e,t;return(e=(t=this._conversationsManager)===null||t===void 0?void 0:t.isVisible())!==null&&e!==void 0&&e}sendMessage(e,t,s){var i=this;return Q(function*(){return i._conversationsManager?i._conversationsManager.sendMessage(e,t,s):(Ce.warn(ht),null)})()}getMessages(e,t){var s=this;return Q(function*(){return s._conversationsManager?s._conversationsManager.getMessages(e,t):(Ce.warn(ht),null)})()}markAsRead(e){var t=this;return Q(function*(){return t._conversationsManager?t._conversationsManager.markAsRead(e):(Ce.warn(ht),null)})()}getTickets(e){var t=this;return Q(function*(){return t._conversationsManager?t._conversationsManager.getTickets(e):(Ce.warn(ht),null)})()}requestRestoreLink(e){var t=this;return Q(function*(){return t._conversationsManager?t._conversationsManager.requestRestoreLink(e):(Ce.warn(ht),null)})()}restoreFromToken(e){var t=this;return Q(function*(){return t._conversationsManager?t._conversationsManager.restoreFromToken(e):(Ce.warn(ht),null)})()}restoreFromUrlToken(){var e=this;return Q(function*(){return e._conversationsManager?e._conversationsManager.restoreFromUrlToken():(Ce.warn(ht),null)})()}getCurrentTicketId(){var e,t;return(e=(t=this._conversationsManager)===null||t===void 0?void 0:t.getCurrentTicketId())!==null&&e!==void 0?e:null}getWidgetSessionId(){var e,t;return(e=(t=this._conversationsManager)===null||t===void 0?void 0:t.getWidgetSessionId())!==null&&e!==void 0?e:null}fd(){var e;(e=this._conversationsManager)===null||e===void 0||e.setIdentity()}pd(){var e;(e=this._conversationsManager)===null||e===void 0||e.clearIdentity()}}},Rp={logs:class extends pp{constructor(e){super({get(){var t;return e==null||(t=e.config)===null||t===void 0?void 0:t.logs},captureHintKey:sl,get remoteConfigWillArrive(){var t,s;return!(!((t=e.Qu)===null||t===void 0)&&t.call(e))||!!(!((s=M._POSTHOG_REMOTE_CONFIG)===null||s===void 0||(s=s[e.config.token])===null||s===void 0)&&s.config)}},()=>(function(t){var s;const i={};if(i.distinctId=t.get_distinct_id(),t.sessionManager){const{sessionId:r,windowId:n,sessionStartTimestamp:o,lastActivityTimestamp:a}=t.sessionManager.checkAndGetSessionAndWindowId(!0);i.sessionId=r,i.windowId=n,L(o)||(i.sessionStartTimestamp=o),L(a)||(i.lastActivityTimestamp=a)}if(!(M==null||(s=M.location)===null||s===void 0)&&s.href&&(i.currentUrl=t.config.disable_capture_url_hashes?at(M.location.href):M.location.href),t.featureFlags){const r=t.featureFlags.getFlags();r&&r.length>0&&(i.activeFeatureFlags=r)}return i})(e)),this._instance=e,this.name=gu,this.Uv()}get zv(){return this._instance.__loaded}Hv(){const e=te("[logs]"),t=M?.__PosthogExtensions__;if(!t)return void e.error("PostHog Extensions not found.");const s=t.loadExternalDependency;if(s)return i=>{s(this._instance,"logs",r=>{const n=t.logs;i(r,n?.initializeLogs?{initialize:o=>n.initializeLogs(o),replay(o,a){var l;return(l=n.replayConsoleBuffer)===null||l===void 0?void 0:l.call(n,o,a)}}:void 0)})};e.error(Br)}}},Lp={metrics:class{constructor(e){this._instance=e,this.$=te("[metrics]"),this.Ci=!1}initialize(){this.onConfigChange()}onConfigChange(){var e;if(this.Ci)return;const t=!!(!((e=this._instance.config.metrics)===null||e===void 0)&&e.network);t&&!this.pg?this.pg=(s=>{let i=!0;const r=()=>i?(a=>{var l;const u=(l=a.config.metrics)===null||l===void 0?void 0:l.network;return u===!0?{}:u||void 0})(s):void 0,n=gp(s,r),o=_p(s,r);return()=>{i=!1,n(),o()}})(this._instance):!t&&this.pg&&(this.pg(),this.pg=void 0)}Gv(){var e;const t=(e=this._instance)===null||e===void 0||(e=e.config)===null||e===void 0?void 0:e.metrics;var s;return this.jv&&this.Qv===t||((s=this.jv)===null||s===void 0||s.reset(),this.Qv=t,this.jv=new od(this.Vv(),(function(i){var r,n,o,a,l;const u=i?.resourceAttributes;return{serviceName:(r=u?.["service.name"])!==null&&r!==void 0?r:i?.serviceName,serviceVersion:(n=u?.["service.version"])!==null&&n!==void 0?n:i?.serviceVersion,environment:(o=u?.["deployment.environment"])!==null&&o!==void 0?o:i?.environment,resourceAttributes:u,beforeSend:i?.beforeSend,flushIntervalMs:(a=i?.flushIntervalMs)!==null&&a!==void 0?a:1e4,maxSeriesPerFlush:(l=i?.maxSeriesPerFlush)!==null&&l!==void 0?l:1e3}})(t),this.$)),this.jv}count(e,t=1,s){this.Gv().count(e,t,s)}gauge(e,t,s){this.Gv().gauge(e,t,s)}histogram(e,t,s){this.Gv().histogram(e,t,s)}flush(e){if(!this.jv)return Promise.resolve();if(e){const t=this.jv.drainWindow();return t&&this.po(t,e),Promise.resolve()}return this.jv.flush().catch(t=>this.$.error("PostHog metrics flush failed:",t))}reset(){var e;(e=this.jv)===null||e===void 0||e.reset()}dispose(){var e,t;this.Ci=!0,(e=this.pg)===null||e===void 0||e.call(this),this.pg=void 0,(t=this.jv)===null||t===void 0||t.reset()}Vv(){const e=this._instance,t=this;return{get isDisabled(){return!1},get optedOut(){return!e.is_capturing()},po:s=>t.po(s),getLibraryId:()=>$e.LIB_NAME,getLibraryVersion:()=>$e.LIB_VERSION}}po(e,t){return new Promise(s=>{let i=!1;const r=o=>{i||(i=!0,clearTimeout(n),s(o))},n=setTimeout(()=>r({kind:"retry-later",error:new Error("metrics request timed out")}),9e4);this._instance._send_request(f(f({method:"POST",url:this.gg(),data:e,compression:"best-available",batchKey:"metrics"},t&&{transport:t}),{},{fireCallbackOnDrop:!0,callback(o){const a=o.statusCode;if(a>=200&&300>a)r({kind:"ok"});else if(a===413)r({kind:"too-large"});else if(a!==0&&a!==408&&a!==429&&500>a)r({kind:"fatal",error:new Error(`metrics request failed with status ${a}`)});else{var l;r({kind:"retry-later",error:(l=o.error)!==null&&l!==void 0?l:new Error(`metrics request failed with status ${a}`)})}}}))})}gg(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}}},Dp={webMCP:class{constructor(e){this._instance=e,this.mg=!1}initialize(){this.startIfEnabled()}startIfEnabled(){if(!this._instance.config.capture_webmcp||this.mg)return;const e=C?.modelContext;if(!e||!ne(e.registerTool))return;const t=Wo.get(e);if(t)return t.instances.add(this._instance),void(this.mg=!0);const s={instances:new Set([this._instance])},i=e.registerTool,r=this;Vt(e,"registerTool",n=>{const o=n;return function(a,...l){let u=a;try{u=r.yg(a,s)}catch{return o.call(this,a,...l)}return o.call(this,u,...l)}}),e.registerTool!==i&&(Wo.set(e,s),this.mg=!0)}yg(e,t){if(!e||!ne(e.execute))return e;const s=e.execute,i=this,{tool:r,injected:n}=(function(o,a){const l={intent:!1,model:!1},u=o.inputSchema;if(!(function(v){return!!x(v)||D(v)&&Object.keys(v).every(m=>mp.has(m)||m.startsWith("x-"))&&v.additionalProperties!==!0&&!D(v.additionalProperties)&&(!v.type||v.type==="object")&&(!v.properties||D(v.properties))&&(!v.required||O(v.required))})(u))return{tool:tr(o),injected:l};const c=u?.properties||{},d=v=>er(c,v)||O(u?.required)&&u.required.includes(v);if(l.intent=a.intent&&!d("context"),l.model=a.model&&!d("llm_model"),!l.intent&&!l.model)return{tool:tr(o),injected:l};const h=f({},c),p=O(u?.required)?[...u.required]:[];return l.intent&&(h.context={type:"string",description:`Explain why this tool is called and how it supports the user's goal. Describe the abstract purpose only. Do not include personal or identifying information. Generalize specific entities as roles such as "a customer".`},p.includes("context")||p.push("context")),l.model&&(h.llm_model={type:"string",description:'The exact model identifier you are running as, taken from your system prompt or environment. Pass "unknown" if you do not know it. Never guess.'},p.includes("llm_model")||p.push("llm_model")),{tool:tr(o,f(f({},u),{},{type:u?.type||"object",properties:h,required:p})),injected:l}})(e,(function(o){const a={intent:!1,model:!1};for(const l of o.instances){const u=Go(l.config.capture_webmcp);a.intent||(a.intent=u?.intent===!0),a.model||(a.model=u?.model===!0)}return a})(t));return Object.defineProperty(r,"execute",{configurable:!0,enumerable:!0,writable:!0,value(...o){const a=new Date,l=(function(p,v){if(!D(p))return{};try{const m=v.intent?Jo(p.context,2048,!0):void 0,g=v.model?Jo(p.llm_model,256):void 0;return f(f({},m&&m!=="{}"?{intent:m}:{}),g&&g.toLowerCase()!=="unknown"?{model:g}:{})}catch{return{}}})(o[0],n),u=(function(p,v){const m=p[0];if(!D(m))return p;try{const g=v.intent&&er(m,"context"),y=v.model&&er(m,"llm_model");if(!g&&!y)return p;const _=f({},m);return g&&delete _.context,y&&delete _.llm_model,[_,...p.slice(1)]}catch{return p}})(o,n);let c;try{c=s.apply(this===r?e:this,u)}catch(p){throw i.bg(t,r,a,{error:p,errorResult:!1},l),p}if((d=c)&&typeof d.then=="function")return Promise.resolve(c).then(p=>{const v=Ko(p)?{error:p,errorResult:!0}:void 0;return i.bg(t,r,a,v,l),p},p=>{throw i.bg(t,r,a,{error:p,errorResult:!1},l),p});var d;const h=Ko(c)?{error:c,errorResult:!0}:void 0;return i.bg(t,r,a,h,l),c}}),r}bg(e,t,s,i,r){const n=Date.now()-s.getTime();let o;for(const l of e.instances){var a;const u=Go(l.config.capture_webmcp);if(u){i&&!o&&(o=kp(i.error,i.errorResult));try{l.capture("$mcp_tool_call",f(f(f({$mcp_source:"posthog_mcp_analytics",$mcp_interface:"webmcp",$mcp_tool_name:t.name,$mcp_resource_name:t.name,$mcp_tool_description:t.description,$mcp_server_name:Y?.hostname,$mcp_duration_ms:n,$mcp_is_error:!!i},o?{$mcp_error_type:o.type,$mcp_error_message:o.message}:{}),u.intent&&r.intent?{$mcp_intent:r.intent,$mcp_intent_source:"context_parameter"}:{}),u.model&&r.model?{$mcp_llm_model:r.model,$mcp_llm_model_source:"self_reported"}:{}),{timestamp:s})}catch{continue}if(i&&o&&l.exceptions&&(!((a=l.exceptionObserver)===null||a===void 0)&&a.isEnabled))try{const c={$exception_list:xp(l.exceptions,i,o.message),$exception_level:"error",$exception_source:"mcp.tool_call",$mcp_interface:"webmcp",$mcp_tool_name:t.name,$mcp_resource_name:t.name,$mcp_tool_description:t.description,$mcp_server_name:Y?.hostname};l.exceptionObserver.captureException(c)}catch{}}}}}};ms.__defaultExtensionClasses=f({},f(f(f(f(f(f(f(f(f(f(f(f(f(f({},fi),Ep),Sp),Pp),Ap),Cp),Ip),Fp),Op),Mp),Tp),Rp),Lp),Dp));const Np=(function(){$e.SDK_DIST_CHANNEL="npm";const e=gs[os]=new ms;return(function(){function t(){t.done||(t.done=!0,nu=!1,J(gs,function(s){s._dom_loaded()}))}C?.addEventListener?C.readyState==="complete"?t():U(C,"DOMContentLoaded",t,{capture:!1}):w&&E.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")})(),e})();var jp=Np;export{Pe as Compression,Sr as DisplaySurveyType,ms as PostHog,nh as ProductTourEventName,ao as ProductTourEventProperties,Se as SurveyEventName,ji as SurveyEventProperties,Qt as SurveyEventType,Ni as SurveyType,jp as default,Np as posthog};