tokentracker-cli 1.3.15 → 1.4.1

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 (136) hide show
  1. package/dashboard/dist/assets/{AchievementBadge-CSXb26DC.js → AchievementBadge-DWECUOAX.js} +1 -1
  2. package/dashboard/dist/assets/{AchievementsPage-Bs6vIpd0.js → AchievementsPage-Bakfwwn_.js} +2 -2
  3. package/dashboard/dist/assets/{AchievementsSection-BO4u-574.js → AchievementsSection-DiEX2_5U.js} +1 -1
  4. package/dashboard/dist/assets/{BadgeDetailModal-ic60vrZX.js → BadgeDetailModal-ClVMnxVW.js} +1 -1
  5. package/dashboard/dist/assets/{BotAnimated-BHHAUEQL.js → BotAnimated-D7eyrAPs.js} +1 -1
  6. package/dashboard/dist/assets/{Card-8t2FYLJV.js → Card-CsAQxZZ8.js} +1 -1
  7. package/dashboard/dist/assets/{CloudCheckoutPage-CXaDDial.js → CloudCheckoutPage-BAN-DtXB.js} +1 -1
  8. package/dashboard/dist/assets/{CloudPage-DN6s_UrT.js → CloudPage-D9sNlUAy.js} +2 -2
  9. package/dashboard/dist/assets/{CommandPalette-D7dHMpHK.js → CommandPalette-D9TNT6un.js} +1 -1
  10. package/dashboard/dist/assets/{CommunityStatsModal-C55r20Vb.js → CommunityStatsModal-CotRRQNH.js} +1 -1
  11. package/dashboard/dist/assets/{ConfirmModal-jSEqSSnW.js → ConfirmModal-C_il5anp.js} +1 -1
  12. package/dashboard/dist/assets/{Controls-CqmoR37l.js → Controls-Bd1kODP4.js} +1 -1
  13. package/dashboard/dist/assets/DashboardPage-De0EL8Hn.js +1 -0
  14. package/dashboard/dist/assets/{DateRangePopover-z89rKqjK.js → DateRangePopover-quw6hpxy.js} +1 -1
  15. package/dashboard/dist/assets/DevicePage-CP20lVYv.js +1 -0
  16. package/dashboard/dist/assets/{DialogClose-imfpTM8a.js → DialogClose-BEUL9bD6.js} +1 -1
  17. package/dashboard/dist/assets/DialogDescription-DpkD2qwW.js +1 -0
  18. package/dashboard/dist/assets/DialogTitle-C--sXGjf.js +1 -0
  19. package/dashboard/dist/assets/{ElectricLogo-CrnDjhtG.js → ElectricLogo-DhP7S1Cu.js} +1 -1
  20. package/dashboard/dist/assets/{FadeIn-CAr2EMcK.js → FadeIn-BPH15_jE.js} +1 -1
  21. package/dashboard/dist/assets/{HeaderGithubStar-UK7qFFNh.js → HeaderGithubStar-DziE8s6w.js} +1 -1
  22. package/dashboard/dist/assets/{HoverTooltip-fs1HBOXB.js → HoverTooltip-tQyY2CuV.js} +1 -1
  23. package/dashboard/dist/assets/{IpCheckPage-Bk-MlPWf.js → IpCheckPage-BjoB05O7.js} +1 -1
  24. package/dashboard/dist/assets/{LandingPage-DJnPCdqP.js → LandingPage-Cav49COr.js} +2 -2
  25. package/dashboard/dist/assets/{LeaderboardPage-wVjwsqyc.js → LeaderboardPage-CHjFKLvs.js} +2 -2
  26. package/dashboard/dist/assets/{LeaderboardProBadge-BaQdHu06.js → LeaderboardProBadge-D97MfK5W.js} +1 -1
  27. package/dashboard/dist/assets/{LeaderboardProfileModal-D5ZZtIPl.js → LeaderboardProfileModal-NNTwtWSu.js} +3 -3
  28. package/dashboard/dist/assets/{LeaderboardProfilePage-BZsBL2jT.js → LeaderboardProfilePage-xI81GH3D.js} +1 -1
  29. package/dashboard/dist/assets/{LimitsPage-Cks_mKSL.js → LimitsPage-BPOo3FOW.js} +1 -1
  30. package/dashboard/dist/assets/{LocalOnlyNotice-DLnC_Tq4.js → LocalOnlyNotice-j8Tijts2.js} +1 -1
  31. package/dashboard/dist/assets/{LoginCard-FXZbjmOY.js → LoginCard-C7_n6J7k.js} +1 -1
  32. package/dashboard/dist/assets/{LoginModal-_R-0ZtpQ.js → LoginModal-DwlNscw5.js} +1 -1
  33. package/dashboard/dist/assets/{LoginPage-MzDRyv1Q.js → LoginPage-BqhWatt2.js} +1 -1
  34. package/dashboard/dist/assets/{PetPage-DJ58EiPT.js → PetPage-CJlC0V0i.js} +2 -2
  35. package/dashboard/dist/assets/PopoverPopup-wleZ4DTI.js +1 -0
  36. package/dashboard/dist/assets/{ProviderIcon-xSNRuia-.js → ProviderIcon-biLVsOGr.js} +1 -1
  37. package/dashboard/dist/assets/{ResetPasswordPage-BcVcWbsW.js → ResetPasswordPage-5Sl45OsN.js} +1 -1
  38. package/dashboard/dist/assets/Select-77l2QNqa.js +1 -0
  39. package/dashboard/dist/assets/SelectItemText-BQbmtjd3.js +1 -0
  40. package/dashboard/dist/assets/{SelfHostPage-BLocCkUo.js → SelfHostPage-C8hlgVu4.js} +1 -1
  41. package/dashboard/dist/assets/{ServiceStatusPage-CzMjS7EQ.js → ServiceStatusPage-DrY9Mef8.js} +1 -1
  42. package/dashboard/dist/assets/{SessionsPage-Dqzuthrd.js → SessionsPage-BDTsH3Mk.js} +2 -2
  43. package/dashboard/dist/assets/SettingsPage-C_id9Go3.js +5 -0
  44. package/dashboard/dist/assets/SkillsPage-kb6_5uUk.js +1 -0
  45. package/dashboard/dist/assets/{TokenGalaxy-B2sMNsM0.js → TokenGalaxy-BoS0yUFS.js} +1 -1
  46. package/dashboard/dist/assets/TooltipPopup-LV1aWIRZ.js +1 -0
  47. package/dashboard/dist/assets/{TrendMonitor-DpMcMWVh.js → TrendMonitor-DN-nwcSA.js} +1 -1
  48. package/dashboard/dist/assets/{WidgetsPage-aKfztwsk.js → WidgetsPage-C6lvwceS.js} +1 -1
  49. package/dashboard/dist/assets/{WrappedPage-NoY2hqbF.js → WrappedPage-CfC39wWP.js} +1 -1
  50. package/dashboard/dist/assets/{__vite-browser-external-kAUz3kFs.css → __vite-browser-external-B0m8a6Te.css} +1 -1
  51. package/dashboard/dist/assets/__vite-browser-external-DpZbUcLL.js +45 -0
  52. package/dashboard/dist/assets/{agent-logos-Oh8CLAYk.js → agent-logos-CvcdCGj5.js} +1 -1
  53. package/dashboard/dist/assets/{arrow-left-Mwggxctm.js → arrow-left-BX4LX5TF.js} +1 -1
  54. package/dashboard/dist/assets/{arrow-right-Crx-kuck.js → arrow-right-Aktjo2RL.js} +1 -1
  55. package/dashboard/dist/assets/{arrow-up-right-uwoo8I0B.js → arrow-up-right-kkQt6Du0.js} +1 -1
  56. package/dashboard/dist/assets/{calendar-days-C6MeKaqh.js → calendar-days-OvLTNZBH.js} +1 -1
  57. package/dashboard/dist/assets/{check-dsWQRYNj.js → check-v5Ie379p.js} +1 -1
  58. package/dashboard/dist/assets/{chevron-down-BIf5bhyB.js → chevron-down-CPlz1cYW.js} +1 -1
  59. package/dashboard/dist/assets/{cloud-checkout-GnFRQdnr.js → cloud-checkout-C_Rhiwno.js} +1 -1
  60. package/dashboard/dist/assets/composite-DD_boZdD.js +1 -0
  61. package/dashboard/dist/assets/{download-B7eyvOxn.js → download-NqHXZ-zn.js} +1 -1
  62. package/dashboard/dist/assets/{external-link-RNTsFDG4.js → external-link-B0D03J0f.js} +1 -1
  63. package/dashboard/dist/assets/{flame-uwCJ6brb.js → flame-av87we58.js} +1 -1
  64. package/dashboard/dist/assets/{format-tokens-Bf7JxB4E.js → format-tokens-B43Ehkbb.js} +1 -1
  65. package/dashboard/dist/assets/{gift-BY7kCGBK.js → gift-CZus7M21.js} +1 -1
  66. package/dashboard/dist/assets/{host-mode-Bs-UHw-7.js → host-mode-Dd9fzAdq.js} +1 -1
  67. package/dashboard/dist/assets/{icons-CrLu8vlW.js → icons-CnScwnf_.js} +1 -1
  68. package/dashboard/dist/assets/{index-CXQag63s.js → index-BZTIoCof.js} +1 -1
  69. package/dashboard/dist/assets/{index-DYIIk93n.js → index-Cj9NdXOj.js} +1 -1
  70. package/dashboard/dist/assets/{index-DieuzFHA.js → index-D3XPaYEL.js} +1 -1
  71. package/dashboard/dist/assets/{info-BteHQN_N.js → info-BUmCmjwd.js} +1 -1
  72. package/dashboard/dist/assets/{link-2-C1RSbOHv.js → link-2-t-wSLB2a.js} +1 -1
  73. package/dashboard/dist/assets/{loader-circle-BM3x6_YL.js → loader-circle-DM-FdXeX.js} +1 -1
  74. package/dashboard/dist/assets/{modifiers.esm-BHzOJfH3.js → modifiers.esm-D5AKZNa7.js} +1 -1
  75. package/dashboard/dist/assets/module-DOCYJaxl.js +3 -0
  76. package/dashboard/dist/assets/{monitor-smartphone-Ps3VptSt.js → monitor-smartphone-CDHFLZS-.js} +1 -1
  77. package/dashboard/dist/assets/{play-7MpFYU7a.js → play-BIQH--yZ.js} +1 -1
  78. package/dashboard/dist/assets/{plus-Dk-p9OaZ.js → plus-CztG5eum.js} +1 -1
  79. package/dashboard/dist/assets/{provider-display-Czwv4ClR.js → provider-display-B2gZ38Oh.js} +1 -1
  80. package/dashboard/dist/assets/{react-D9vco0ZF.js → react-D1u6HsZx.js} +1 -1
  81. package/dashboard/dist/assets/safePolygon-ClG4WM06.js +1 -0
  82. package/dashboard/dist/assets/{search-Z2Hfw99-.js → search-NNy_fIbJ.js} +1 -1
  83. package/dashboard/dist/assets/{server-Dh_OraRG.js → server-N94HJtJY.js} +1 -1
  84. package/dashboard/dist/assets/{shield-check-59NUSZvk.js → shield-check-BGfaKXG9.js} +1 -1
  85. package/dashboard/dist/assets/{skills-api-Bguk8iPD.js → skills-api-CWydQc4G.js} +1 -1
  86. package/dashboard/dist/assets/{sortable.esm-C9M-1k5o.js → sortable.esm-BF83ljWQ.js} +1 -1
  87. package/dashboard/dist/assets/store-l5WfCa7P.js +1 -0
  88. package/dashboard/dist/assets/{terminal-DKTXh9tj.js → terminal-CRBThKUQ.js} +1 -1
  89. package/dashboard/dist/assets/{trash-CQRRKbCs.js → trash-BXN5tg81.js} +1 -1
  90. package/dashboard/dist/assets/{use-community-stats-BoOd2Hhq.js → use-community-stats-dHketgyF.js} +1 -1
  91. package/dashboard/dist/assets/{use-latest-request-guard-vQtFEBIX.js → use-latest-request-guard-CdM1Pn_p.js} +1 -1
  92. package/dashboard/dist/assets/{use-limits-display-prefs-BRTj9_xd.js → use-limits-display-prefs-dOm4SCFU.js} +1 -1
  93. package/dashboard/dist/assets/{use-native-settings-CC6uEn3j.js → use-native-settings-GL9uAidm.js} +1 -1
  94. package/dashboard/dist/assets/{use-ordered-list-BUx6eIN7.js → use-ordered-list-Btz_NSiA.js} +1 -1
  95. package/dashboard/dist/assets/use-reduced-motion-D9n2I_eN.js +1 -0
  96. package/dashboard/dist/assets/{use-session-efficiency-pref-BsUypXPb.js → use-session-efficiency-pref-BPZel3HL.js} +1 -1
  97. package/dashboard/dist/assets/{use-transform-oomGXI86.js → use-transform-D2xePGbE.js} +1 -1
  98. package/dashboard/dist/assets/{use-usage-limits-CXeCKJZ_.js → use-usage-limits-vEmyPwMY.js} +1 -1
  99. package/dashboard/dist/assets/{useCurrency-DIZEXq5g.js → useCurrency-DnhS0llv.js} +1 -1
  100. package/dashboard/dist/assets/usePositioner-7yozJJJ0.js +1 -0
  101. package/dashboard/dist/assets/{useTokenFormat-DKURSOqb.js → useTokenFormat-DvjyXv8i.js} +1 -1
  102. package/dashboard/dist/assets/{zap-BQ8nGK7b.js → zap-CElRpX2w.js} +1 -1
  103. package/dashboard/dist/index.html +2 -2
  104. package/dashboard/dist/ip-check.html +2 -2
  105. package/dashboard/dist/leaderboard.html +2 -2
  106. package/dashboard/dist/share.html +2 -2
  107. package/package.json +2 -2
  108. package/src/commands/status.js +1 -1
  109. package/src/commands/sync.js +34 -4
  110. package/src/lib/cloud-usage-reset.js +115 -0
  111. package/src/lib/diagnostics.js +1 -1
  112. package/src/lib/kimi-model-repair.js +173 -0
  113. package/src/lib/kimi-session.js +216 -0
  114. package/src/lib/local-api.js +46 -1
  115. package/src/lib/pricing/seed-snapshot.json +1 -1
  116. package/src/lib/qoder-cn-cli-limits.js +9 -7
  117. package/src/lib/qoder-limits.js +45 -15
  118. package/src/lib/rollout.js +6 -4
  119. package/src/lib/session-analytics.js +47 -9
  120. package/dashboard/dist/assets/DashboardPage-BLr2XmyZ.js +0 -1
  121. package/dashboard/dist/assets/DevicePage-Ddm5uKOw.js +0 -1
  122. package/dashboard/dist/assets/DialogDescription-BE5CNMW0.js +0 -1
  123. package/dashboard/dist/assets/DialogTitle-Ca1-hka8.js +0 -1
  124. package/dashboard/dist/assets/PopoverPopup-uQa7G-IO.js +0 -1
  125. package/dashboard/dist/assets/Select-Dwix4ZFd.js +0 -1
  126. package/dashboard/dist/assets/SelectItemText-Bz5cn5Gk.js +0 -1
  127. package/dashboard/dist/assets/SettingsPage-DEdNhzKR.js +0 -5
  128. package/dashboard/dist/assets/SkillsPage-CqocOQID.js +0 -1
  129. package/dashboard/dist/assets/TooltipPopup-LzbtjRSA.js +0 -1
  130. package/dashboard/dist/assets/__vite-browser-external-BnGukaND.js +0 -45
  131. package/dashboard/dist/assets/composite-lINFdwLI.js +0 -1
  132. package/dashboard/dist/assets/module-BNnaKM__.js +0 -3
  133. package/dashboard/dist/assets/safePolygon-Ca2iBTNb.js +0 -1
  134. package/dashboard/dist/assets/store-nR9Ah4fr.js +0 -1
  135. package/dashboard/dist/assets/use-reduced-motion-BZBrXeyc.js +0 -1
  136. package/dashboard/dist/assets/usePositioner-Drh2sy7w.js +0 -1
@@ -1,3 +0,0 @@
1
- const b="u">typeof window?window:void 0,fe="u">typeof globalThis?globalThis:b,ce=fe?.navigator,k=fe?.document,ee=fe?.location,us=fe?.fetch,yr=fe?.XMLHttpRequest&&"withCredentials"in new fe.XMLHttpRequest?fe.XMLHttpRequest:void 0,zr=fe?.AbortController,Kl=fe?.CompressionStream,ye=ce?.userAgent;function wo(){return!(!b||b.navigator.onLine===!1)}const jt=typeof globalThis<"u"?globalThis:b;jt&&typeof self>"u"&&(jt.self=jt),jt&&typeof File>"u"&&(jt.File=function(){});const F=b??{},Jl="0.9.1",Ue={DEBUG:!1,LIB_VERSION:Jl,LIB_NAME:"browser-common"};var De=(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})({}),Wi=(function(e){return e.GZipJS="gzip-js",e.Base64="base64",e})({});const Xl=["$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"],Yl=["token"];function C(e,t){return e.indexOf(t)!==-1}const ei=function(e){return e.trim()},Vi=function(e){return e.replace(/^\$/,"")};function xo(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 ko=Object.prototype,br=ko.hasOwnProperty,ti=ko.toString,A=Array.isArray||function(e){return ti.call(e)==="[object Array]"},ue=e=>typeof e=="function",N=e=>e===Object(e)&&!A(e),ke=e=>{if(N(e)){for(const t in e)if(br.call(e,t))return!1;return!0}return!1},x=e=>e===void 0,L=e=>ti.call(e)=="[object String]",Yt=e=>L(e)&&e.trim().length===0,te=e=>e===null,R=e=>x(e)||te(e),ne=e=>ti.call(e)=="[object Number]"&&e==e,He=e=>ne(e)&&e>0,we=e=>ti.call(e)==="[object Boolean]",Zl=e=>C(Xl,e),Ql=e=>C(Yl,e);function Eo(e){return e===null||typeof e!="object"}function Rs(e,t){return{}.toString.call(e)===`[object ${t}]`}function Nt(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 $o(e,Error)}}function wr(e){return"u">typeof Event&&$o(e,Event)}function $o(e,t){try{return e instanceof t}catch{return!1}}const eu=[!0,"true",1,"1","yes"],ai=e=>C(eu,e),tu=[!1,"false",0,"0","no"];function Ur(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 Z(e){return function(){var t=this,s=arguments;return new Promise(function(i,r){var n=e.apply(t,s);function o(l){Ur(n,i,r,o,a,"next",l)}function a(l){Ur(n,i,r,o,a,"throw",l)}o(void 0)})}}const su=["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"],Gr=function(e,t=[]){if(!e)return!1;const s=e.toLowerCase();return su.concat(t).some(i=>{const r=i.toLowerCase();return s.indexOf(r)!==-1})};function Ne(e,t,s,i,r){return t>s&&(i.warn("min cannot be greater than max."),t=s),ne(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),Ne(r??s,t,s,i))}var iu=class{constructor(e){this.C={},this.I=e.I,this.R=Ne(e.bucketSize,0,100,e.A),this.$=Ne(e.refillRate,0,this.R,e.A),this.O=Ne(e.refillInterval,0,864e5,e.A)}F(e,t){const s=Math.floor((t-e.lastAccess)/this.O);s>0&&(e.tokens=Math.min(e.tokens+s*this.$,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 Ct="Mobile",cs="Android",Ls="Tablet",So="Android Tablet",Po="iPad",Mo="Apple Watch",Ms="Safari",si="BlackBerry",Oo="Samsung Internet",Os="Chrome",Io="Chrome iOS",Fo="Internet Explorer",To="Internet Explorer Mobile",Co="Opera",Ao="Microsoft Edge",Is="Firefox",Ro="Firefox iOS",Ds="Nintendo",Ns="PlayStation",ii="Xbox",Lo="Android Mobile",Do="Mobile Safari",li="Windows",No="Windows Phone",Kr="Nokia",zi="Ouya",ru="Generic "+Ct.toLowerCase(),jo="Generic "+Ls.toLowerCase(),Ui="Konqueror",Bo="Oculus Browser",qo="Vivaldi",Ho="Yandex",Wo="Whale",Vo="DuckDuckGo",zo="Pale Moon",Uo="Waterfox",Gi="Brave",Go="Claude",Ko="Codex",Jo="ChatGPT",Xo="Google Search App",ui=new RegExp("Version/(\\d+(\\.\\d+)?)"),ci=new RegExp("(Claude|Codex|ChatGPT)\\/(\\d+(\\.\\d+)?)"),nu=new RegExp(ii,"i"),ou=new RegExp("PlayStation \\w+","i"),au=new RegExp("Nintendo \\w+","i"),xr=new RegExp("BlackBerry|PlayBook|BB10","i"),lu={"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"},Yo=function(e,t,s,i){return t=t||"",(function(n){return n?.brave?Gi:null})(s)||(i?.detectGoogleSearchApp&&C(e,"GSA/")?Xo:C(e," OPR/")&&C(e,"Mini")?"Opera Mini":C(e," OPR/")?Co:xr.test(e)?si:C(e,"IEMobile")||C(e,"WPDesktop")?To:C(e,"OculusBrowser")?Bo:C(e,"SamsungBrowser")?Oo:C(e,"Edge")||C(e,"Edg/")?Ao:C(e,"Vivaldi/")?qo:C(e,"YaBrowser/")?Ho:C(e,"Whale/")?Wo:C(e,"DuckDuckGo/")||C(e,"Ddg/")?Vo:C(e,"Claude/")?Go:C(e,"Codex/")?Ko:C(e,"ChatGPT/")?Jo:C(e,"FBIOS")?"Facebook Mobile":C(e,"UCWEB")||C(e,"UCBrowser")?"UC Browser":C(e,"CriOS")?Io:C(e,"CrMo")||C(e,Os)?Os:C(e,cs)&&C(e,Ms)?Lo:C(e,"FxiOS")?Ro:C(e.toLowerCase(),Ui.toLowerCase())?Ui:C(e,"Brave/")?Gi:((n,o)=>o&&C(o,"Apple")||(function(a){return C(a,Ms)&&!C(a,Os)&&!C(a,cs)})(n))(e,t)?C(e,Ct)?Do:Ms:C(e,"PaleMoon/")?zo:C(e,"Waterfox/")?Uo:C(e,Is)?Is:C(e,"MSIE")||C(e,"Trident/")?Fo:C(e,"Gecko")?Is:"")},uu={[To]:[new RegExp("rv:(\\d+(\\.\\d+)?)")],[Ao]:[new RegExp("Edge?\\/(\\d+(\\.\\d+)?)")],[Os]:[new RegExp("(Chrome|CrMo)\\/(\\d+(\\.\\d+)?)")],[Io]:[new RegExp("CriOS\\/(\\d+(\\.\\d+)?)")],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/(\\d+(\\.\\d+)?)")],[Ms]:[ui],[Do]:[ui],[Co]:[new RegExp("(Opera|OPR)\\/(\\d+(\\.\\d+)?)")],[Is]:[new RegExp("Firefox\\/(\\d+(\\.\\d+)?)")],[Ro]:[new RegExp("FxiOS\\/(\\d+(\\.\\d+)?)")],[Ui]:[new RegExp("Konqueror[:/]?(\\d+(\\.\\d+)?)","i")],[si]:[new RegExp("BlackBerry (\\d+(\\.\\d+)?)"),ui],[Lo]:[new RegExp("android\\s(\\d+(\\.\\d+)?)","i")],[Oo]:[new RegExp("SamsungBrowser\\/(\\d+(\\.\\d+)?)")],[Bo]:[new RegExp("OculusBrowser\\/(\\d+(\\.\\d+)?)")],[qo]:[new RegExp("Vivaldi\\/(\\d+(\\.\\d+)?)")],[Ho]:[new RegExp("YaBrowser\\/(\\d+(\\.\\d+)?)")],[Wo]:[new RegExp("Whale\\/(\\d+(\\.\\d+)?)")],[Gi]:[new RegExp("Brave\\/(\\d+(\\.\\d+)?)")],[Go]:[ci],[Ko]:[ci],[Jo]:[ci],[Vo]:[new RegExp("(DuckDuckGo|Ddg)\\/(\\d+(\\.\\d+)?)")],[zo]:[new RegExp("PaleMoon\\/(\\d+(\\.\\d+)?)")],[Uo]:[new RegExp("Waterfox\\/(\\d+(\\.\\d+)?)")],[Xo]:[new RegExp("GSA\\/(\\d+(\\.\\d+)?)")],[Fo]:[new RegExp("(rv:|MSIE )(\\d+(\\.\\d+)?)")],Mozilla:[new RegExp("rv:(\\d+(\\.\\d+)?)")]},cu=function(e,t,s,i){const r=Yo(e,t,s,i),n=uu[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},Jr=[[new RegExp("Xbox; Xbox (.*?)[);]","i"),e=>[ii,e&&e[1]||""]],[new RegExp(Ds,"i"),[Ds,""]],[new RegExp(Ns,"i"),[Ns,""]],[xr,[si,""]],[new RegExp(li,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[No,""];if(new RegExp(Ct).test(t)&&!/IEMobile\b/.test(t))return["Windows Mobile",""];const s=/Windows NT ([0-9.]+)/i.exec(t);if(s&&s[1]){let i=lu[s[1]]||"";return/arm/i.test(t)&&(i="RT"),[li,i]}return[li,""]}],[/((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]?[cs,[e[2],e[3],e[4]||"0"].join(".")]:[cs,""]],[/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",""]]],Zo=function(e){for(let t=0;Jr.length>t;t++){const[s,i]=Jr[t],r=s.exec(e),n=r&&(ue(i)?i(r,e):i);if(n)return n}return["",""]},Qo=function(e){return au.test(e)?Ds:ou.test(e)?Ns:nu.test(e)?ii:new RegExp(zi,"i").test(e)?zi:new RegExp("(Windows Phone|WPDesktop)","i").test(e)?No:/iPad/.test(e)?Po:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?Mo:xr.test(e)?si:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(Kr,"i").test(e)?Kr:/(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(Ct).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)?cs:So:new RegExp("(pda|Mobile)","i").test(e)?ru:new RegExp(Ls,"i").test(e)&&!new RegExp("Tablet pc","i").test(e)?jo:""},hu=function(e,t){var s;const i=Qo(e);return i===Po||i===So||i==="Kobo"||i==="Kindle Fire"||i===jo?Ls:i===Ds||i===ii||i===Ns||i===zi?"Console":i===Mo?"Wearable":i?Ct: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)?Ct:Ls:"Desktop";var r,n,o},hi=/\bFBAV\/(\d+(?:\.\d+)*)/i,Xr=[[/\bInstagram(?:[ /](\d+(?:\.\d+)*))?\b/i,"Instagram"],[/\bBarcelona[ /](\d+(?:\.\d+)*)?/i,"Threads"],[/\b(?:MessengerForiOS|(?:FBAN|FB_IAB)\/Orca-Android)\b/i,"Messenger",hi],[/\bFBAN\/EMA\b/i,"Facebook Lite",hi],[/\b(?:FBIOS|(?:FBAN|FB_IAB)\/(?:FB4A|FBIOS))\b/i,"Facebook",hi],[/\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"]],Ki="[Truncated]",ms="[Unserializable]";function It(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 ea(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=ms}Object.defineProperty(e,i,{value:r,enumerable:!0,writable:!0,configurable:!0})}return e}const Fs=3e5;var ta=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,Fs);if(!t)return this.ts=s,void(this.es=s+i);this.es=Math.max(this.es,Math.min(s+i,this.ts+Fs))}remainingMs(){const e=Date.now();if(this.ts-5e3>e)return this.reset(),0;const t=Math.min(Fs,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 du=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function Yr(e,t){return typeof(s=e)=="string"&&du.test(s)?e:t();var s}function sa(e,t){const s=new Error(t);try{Object.defineProperty(s,"name",{value:e,writable:!0,enumerable:!0,configurable:!0})}catch{}return s}function nt(e){return e&&e.split("#")[0]}function Zr(e){try{return e()}catch{return}}function ia(e,t){const s=setTimeout(e,t);return s!=null&&s.unref&&s?.unref(),s}function Qr(e,t,s){return ra.apply(this,arguments)}function ra(){return(ra=Z(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)}let bs,en,di;function pu(e){const t=globalThis._posthogChunkIds;if(!t)return;const s=Object.keys(t);return di&&s.length===en||(en=s.length,di=s.reduce((i,r)=>{bs||(bs={});const n=bs[r];if(n)i[n[0]]=n[1];else{const o=e(r);for(let a=o.length-1;a>=0;a--){const l=o[a],u=l?.filename,c=t[r];if(u&&c){i[u]=c,bs[r]=[u,c];break}}}return i},{})),di}function Zt(e){return Zt=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},Zt(e)}function vu(e,t,s){return(t=(function(i){var r=(function(n){if(Zt(n)!="object"||!n)return n;var o=n[Symbol.toPrimitive];if(o!==void 0){var a=o.call(n,"string");if(Zt(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)})(i);return Zt(r)=="symbol"?r:r+""})(t))in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function tn(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 p(e){for(var t=1;arguments.length>t;t++){var s=arguments[t]!=null?arguments[t]:{};t%2?tn(Object(s),!0).forEach(function(i){vu(e,i,s[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):tn(Object(s)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(s,i))})}return e}var fu=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 Z(function*(){for(const s of e)s.stacktrace&&s.stacktrace.frames&&A(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 p(p({},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 Z(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?p(p({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:pu(this.stackParser),skipFirstLines:(t=e.skipFirstLines)!==null&&t!==void 0?t:1}}getAggregateErrors(e){try{if(Nt(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 A(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,v,f=0)=>{const y=c(v,f),g=y.apply;if(y.apply=P=>{a.push(h);try{return g(P)}finally{a.pop()}},f>4||f>0&&a.indexOf(h)!==-1)return this.coerceFallback(y);const m=typeof h=="object"&&h!==null||typeof h=="function";if(f===0&&i>=50||m&&o.has(h))return;m&&o.add(h),f===0&&i++;const _=this.getAggregateErrors(h);let w,$;n||(n=!!_);try{if(w=this.applyCoercers(h,y),!w)throw l}catch(P){if(P===l)return void(f===0&&i--);if(!n)throw P;w=this.coerceFallback(y)}if(!_||i>=50)return w;try{$=_.length}catch{return w}if(!Number.isInteger($)||0>$||$>4294967295)return w;const E=[];for(let P=0;50>i&&1e3>r&&$>P;P++){let I;r++;try{I=y.next(_[P])}catch{i++,I=this.coerceFallback(c(v+1))}I&&E.push(I)}return p(p({},w),{},{errors:E})},c=(h,v=0)=>p(p({},t),{},{syntheticException:h==0?t.syntheticException:void 0,mechanism:h==0?e:{},apply(f){const y=u(f,h,v+1);if(!y)throw l;return y},next:f=>u(f,h+1)}),d=c(s);return p(p({},d),{},{apply:h=>{var v;return(v=u(h,s))!==null&&v!==void 0?v:this.coerceFallback(d)}})}};const gu=/^([a-z][a-z0-9.+-]+):/i,_u=["http","https","file","blob","app","capacitor","ionic","webpack","webpack-internal","ng"];function mu(e){if(!e||e==="<anonymous>")return!1;const t=gu.exec(e);return!t||_u.includes(t[1].toLowerCase())}function Ji(e,t,s,i,r){const n={platform:e,filename:t,function:s==="<anonymous>"?"?":s,in_app:mu(t)};return x(i)||(n.lineno=i),x(r)||(n.colno=r),n}const na=(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]},yu=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,bu=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,wu=/\((\S*)(?::(\d+))(?::(\d+))\)/,xu=(e,t)=>{const s=yu.exec(e);if(s){const[,r,n,o]=s;return Ji(t,r,"?",+n,+o)}const i=bu.exec(e);if(i){if(i[2]&&i[2].indexOf("eval")===0){const o=wu.exec(i[2]);o&&(i[2]=o[1],i[3]=o[2],i[4]=o[3])}const[r,n]=na(i[1]||"?",i[2]);return Ji(t,n,r,i[3]?+i[3]:void 0,i[4]?+i[4]:void 0)}},ku=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,Eu=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,$u=(e,t)=>{const s=ku.exec(e);if(s){if(s[3]&&s[3].indexOf(" > eval")>-1){const n=Eu.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]=na(r,i),Ji(t,i,r,s[4]?+s[4]:void 0,s[5]?+s[5]:void 0)}},sn=/\(error: (.*)\)/;function kr(e,t){return e.filename===t.filename&&e.function===t.function&&e.module===t.module&&e.lineno===t.lineno&&e.colno===t.colno}function Su(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(!kr(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 Pu(e,t){const s=t.start+t.length,i=aa(e,t);i&&e.splice(s+i===e.length?s:t.start,i)}function oa(e,t){let s=t.start;for(;s>0&&kr(e[s-1],e[s-1+t.length]);)s--;return t.start-s}function aa(e,t){const s=t.start+t.length;let i=s;for(;e.length>i&&kr(e[i],e[i-t.length]);)i++;return i-s}function Mu(e,t){const s=t[0];let i=e.length-(s?oa(e,s):0);for(const r of t)i-=aa(e,r);return i}function Ou(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 Iu=class{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){const s=L(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 Rs(e,"DOMException")}isDOMError(e){return Rs(e,"DOMError")}},Fu=class{match(e){return Nt(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}}},Tu=class{match(e){return!!Rs(e,"ErrorEvent")&&(e.error!=null||this.ar(e))}coerce(e,t){var s;if(e.error!=null)return t.apply(e.error);const i=t.apply(e.message);return p(p({},i),{},{stack:(s=this.lr(e))!==null&&s!==void 0?s:i.stack,synthetic:!0})}ar(e){return L(e.message)&&e.message.length>0}lr(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(L(i.filename)&&i.filename.length!==0&&r!==0)return`Error
2
- at ${i.filename}:${r}:${n}`}};const Cu=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;var Au=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(Cu);return i&&(t=i[1],s=i[2]),[t,s]}};const Ru=["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 Lu=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(wr(e))return e.constructor.name;const t="name"in e?e.name:void 0;return L(t)&&!Yt(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 L(e)&&!Yt(e)&&Ru.indexOf(e)>=0}getStack(e){try{return L(e.stacktrace)&&e.stacktrace.length>0?e.stacktrace:L(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(Nt(s))return s}}getObjectClassName(e){try{const t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{return}}},Du=class{match(e){return wr(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}}},Nu=class{match(e){return Eo(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}}},ju=class{match(e){return Rs(e,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(e)}isCustomEventWrappingRejection(e){if(!wr(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 Eo(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",Bs="$timestamp",Bu=new Set([js,Bs]),pi={enabled:!0,max_bytes:32768};function qs(e){var t;return e?{enabled:(t=e.enabled)!==null&&t!==void 0?t:pi.enabled,max_bytes:Hu(e.max_bytes,pi.max_bytes)}:p({},pi)}var qu=class{constructor(e){this.ns=[],this.ss=0,this.Mr=qs(e)}setConfig(e){this.Mr=qs(e),this.rs()}add(e){const t=(function(i){let r;try{r=xo(i)}catch{return}try{const n=JSON.parse(r);if(!N(n))return;const o=n,a=o[js],l=o[Bs];return!L(a)||a.trim().length===0||!L(l)&&!ne(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.Mr.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.Mr.max_bytes&&this.ns.length>0;){const e=this.ns.shift();e&&(this.ss-=e.bytes)}}};function Hu(e,t){if(!ne(e)||e===1/0||e===-1/0)return t;const s=Math.floor(e);return 0>s?t:s}const rn=e=>{if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}};function nn(e){return typeof e=="string"||e}function on(e){return typeof e=="string"?e:void 0}const Wu=["$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","irclid","_kx","$session_id","$window_id","$lib","$lib_version","$device_id","$is_server"],ua="NativeGzipValidationError",Xi=e=>e.length>=2&&e[0]===31&&e[1]===139,an=(e,t)=>e===Wi.GZipJS||t===Wi.GZipJS||t==="gzip",ln=e=>!(!e||typeof e!="object")&&("name"in e?String(e.name):"")==="NotReadableError";let Bt;const ws=e=>{throw sa(ua,`Native gzip produced invalid output: ${e}`)},Vu=(un=Z(function*(e,t){18>e.size&&ws("too-short");const s=new Uint8Array(yield e.slice(0,10).arrayBuffer());Xi(s)&&s[2]===8||ws("invalid-header");const i=new DataView(yield e.slice(e.size-8).arrayBuffer());i.getUint32(0,!0)!==(n=>{const o=(()=>{if(Bt)return Bt;Bt=[];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;Bt[l]=u>>>0}return Bt})();let a=4294967295;for(let l=0;n.length>l;l++)a=o[255&(a^n[l])]^a>>>8;return(4294967295^a)>>>0})(t)&&ws("invalid-crc");const r=t.length>>>0;i.getUint32(4,!0)!==r&&ws("invalid-size")}),function(e,t){return un.apply(this,arguments)});var un;function Yi(){return Yi=Z(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=Z(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 Vu(u,r),u}catch(r){if(s?.rethrow)throw r;return t&&console.error("Failed to gzip compress data",r),null}var i}),Yi.apply(this,arguments)}function ca(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 zu={}.propertyIsEnumerable;function Hs(e,t){try{return ha(e,t,{ancestors:new WeakSet,remainingNodes:1e4},0)}catch{return[]}}function Er(e,t,s,i){if(0>=s.remainingNodes)return{stringValue:Ki};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:It(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:Ki};if(e instanceof Date){const r=e.getTime(),n=Number.isFinite(r)?e.toISOString():String(e);return{stringValue:typeof n=="string"?It(n):String(n)}}s.ancestors.add(e);try{try{const r=e.toJSON;if(typeof r=="function")return Er(r.call(e),t,s,i+1)}catch{}return A(e)?{arrayValue:{values:Uu(e,t,s,i+1)}}:{kvlistValue:{values:ha(e,t,s,i+1)}}}finally{s.ancestors.delete(e)}}return{stringValue:It(String(e))}}function Uu(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(R(a))continue;r.push(Er(a,t,s,i))}catch{r.push({stringValue:ms})}return e.length>o&&r.push({stringValue:Ki}),r}function ha(e,t,s,i){const r=[];for(const n in e)if(zu.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(te(o)||x(o))continue;r.push({key:It(n),value:Er(o,t,s,i)})}catch{r.push({key:It(n),value:{stringValue:ms}})}}return r}function da(e,t,s){return p(p(p(p({},ea({},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 Gu=["service.name","deployment.environment","service.version","telemetry.sdk.name","telemetry.sdk.version"];function pa(e,t){const s=ea({},e),i={};for(const r of Gu)({}).hasOwnProperty.call(s,r)&&(i[r]=s[r],delete s[r]);return[...Hs(s,t),...Hs(i,t)]}const cn={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"},va={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}},Ku=va.info;function Ju(e){try{return It(String(e))}catch{return ms}}function Xu(e,t,s,i){const r=e.level||"info",{text:n,number:o}=va[r]||Ku,a=(function(h=Date.now()){return String(h)+"000000"})(ne(i)?i:void 0),l={};t.distinctId&&(l.posthogDistinctId=t.distinctId),t.sessionId&&(l.sessionId=t.sessionId),t.windowId&&(l["window.id"]=t.windowId),R(t.sessionStartTimestamp)||(l.sessionStartTimestamp=String(t.sessionStartTimestamp)),R(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=p({},l),c=e.attributes;if(c){let h=[];try{h=Object.keys(c)}catch{h=[]}for(const v of h){let f;try{f=c[v]}catch{f=ms}Object.defineProperty(u,v,{value:f,enumerable:!0,writable:!0,configurable:!0})}}const d={timeUnixNano:a,observedTimeUnixNano:a,severityNumber:o,severityText:n,body:{stringValue:Ju(e.body)},attributes:Hs(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 fa(e,t,s){return da(e,t,s)}function ga(e,t,s,i){return{resourceLogs:[{resource:{attributes:pa(t)},scopeLogs:[{scope:{name:s,version:i},logRecords:e}]}]}}var _a=class{constructor(e){this.ls=e,this.us=0}get pending(){return!!this.hs}arm(e){this.clear(),this.us=Date.now()+e,this.hs=ia(()=>{this.hs=void 0,this.ls()},e)}armNoEarlierThan(e){this.hs&&Date.now()+e<=this.us||this.arm(e)}clear(){this.hs&&(clearTimeout(this.hs),this.hs=void 0)}};function ma(){return .75+.5*Math.random()}function ya(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 Yu=class{constructor(e,t,s,i,r,n=()=>Promise.resolve(),o){var a;this._instance=e,this.Mr=t,this.A=s,this.cs=i,this.ds=r,this.vs=n,this.fs=o,this.ps=new _a(()=>this.gs()),this.ys=null,this.bs=0,this._s=0,this.ws=new ta,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(De.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.Mr.maxBatchRecordsPerPost}onReconnect(){this.ks=0,this.Ss=1,this.ws.isOpen()?this.As()&&this.Os():this.gs()}captureLog(e,t){var s;if(this._instance.isDisabled||this._instance.optedOut||!e?.body)return;const i=this.Fs(e);if(i===null)return;if(!i.body)return void this.A.info("Log was rejected in beforeSend function");if(!this.Ds())return;const r={record:Xu(i,(s=t?.context)!==null&&s!==void 0?s:this.cs(),this.A,t?.occurredAtMs)};this.ds(()=>this.Ls(r))}Fs(e){const t=this.Mr.beforeSend;if(!t)return e;const s=A(t)?t:[t];let i=e;for(const r of s)try{const n=r(i);if(!n)return this.A.info("Log was rejected in beforeSend function"),null;i=n}catch(n){return this.A.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.A.warn(`captureLog dropping logs: exceeded ${this.Rs} logs per ${this.Ps}ms`),this.Cs=!0),!1)}flush(){var e=this;return Z(function*(){if(!e._instance.isDisabled)return e.ys||(e.ys=e.Ns().finally(()=>{e.ys=null})),e.ys})()}Ns(){var e=this;return Z(function*(){var t;e.ps.clear();let s=(t=e._instance.getPersistedProperty(De.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=ga(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.A.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.A.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.Mr.maxBatchRecordsPerPost>e.Es&&(e.Es=Math.min(e.Mr.maxBatchRecordsPerPost,e.Es+1)),yield e.Bs(u.length),s=(o=e._instance.getPersistedProperty(De.LogsQueue))!==null&&o!==void 0?o:[],r+=u.length,d.kind==="fatal"))throw d.error}})()}Bs(e){var t=this;return Z(function*(){var s;const i=Math.max(0,e-t.bs),r=(s=t._instance.getPersistedProperty(De.LogsQueue))!==null&&s!==void 0?s:[];t._instance.setPersistedProperty(De.LogsQueue,r.slice(i)),yield t.vs()})()}qs(){return fa(this.Mr,this._instance.getLibraryId(),this._instance.getLibraryVersion())}Ls(e){var t;if(this._instance.optedOut)return;const s=(t=this._instance.getPersistedProperty(De.LogsQueue))!==null&&t!==void 0?t:[];this.Is>s.length||(s.shift(),this.bs++,this.A.info("Logs queue is full, dropping oldest record.")),s.push(e),this._instance.setPersistedProperty(De.LogsQueue,s),this.Ts>s.length||this.ws.isOpen()?this.Os():this.gs()}Os(){this.ps.pending||this.ps.arm(Math.max(this.Ms,this.ws.remainingMs()))}Hs(){return Math.max(ya(this.Ms,this.ks,this.Ss,3e4),this.ws.remainingMs())}As(){const e=this._instance.getPersistedProperty(De.LogsQueue);return!!e&&e.length>0}shutdown(e){var t=this;return Z(function*(){t.ps.clear();const s=t.flush().catch(()=>{});e!==void 0?yield Qr(s,e):yield s})()}flushWithTimeout(e){var t=this;return Z(function*(){const s=t.flush();yield Qr(s,e,()=>{s.catch(()=>{})})})()}gs(){this.flush().then(()=>{this.ks=0,this.Ss=1},e=>{this.ks++,this.Ss=ma(),this.A.error("PostHog logs flush failed:",e)}).finally(()=>{!this._instance.isDisabled&&this.As()&&this.ps.armNoEarlierThan(this.Hs())})}};const vi=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function hn(e){return String(e)+"000000"}function dn(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 Zu=class{constructor(e,t,s){this._instance=e,this.Mr=t,this.A=s,this.zs=new Map,this.ps=new _a(()=>this.flush().catch(i=>{this.A.error("Metrics flush failed:",i)})),this.ys=null,this.Us=!1,this.Ws=new Map,this.Vs=new Set,this.ws=new ta,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=Z(function*(){t&&(yield t.catch(()=>{})),yield e.Js()});return function(){return i.apply(this,arguments)}})()().finally(()=>{this.ys===s&&(this.ys=null)});return this.ys=s,s}drainWindow(){if(this.zs.size===0)return null;const e=this.zs;return this.zs=new Map,this.Us=!1,this.Ws=new Map,this.Vs=new Set,this.Zs(e)}reset(){this.Gs++,this.ws.reset(),this.ks=0,this.Ss=1,this.ps.clear(),this.zs=new Map,this.ys=null,this.Us=!1,this.Ws=new Map,this.Vs=new Set}Qs(e){if(this._instance.isDisabled||this._instance.optedOut)return;const t=this.Fs(e);if(t===null)return;if(!t.name||typeof t.name!="string")return void this.A.warn("Dropping metric with empty name");if(typeof t.value!="number"||!Number.isFinite(t.value))return void this.A.warn(`Dropping metric '${t.name}': value must be a finite number`);if(t.type==="count"&&0>t.value)return void this.A.warn(`Dropping count '${t.name}': counters are monotonic, value must be >= 0`);let s,i;try{s=t.attributes?p({},t.attributes):void 0,i=dn(t.type,t.name,t.unit,s)}catch(o){return void this.A.warn(`Dropping metric '${t.name}': attributes could not be serialized`,o)}let r=this.zs.get(i);if(!r){if(!this.Ks())return;r={name:t.name,type:t.type,unit:t.unit,attributes:s,windowStartMs:Date.now()},this.zs.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.A.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),this.Os()}Ks(){return this.Mr.maxSeriesPerFlush>this.zs.size||(this.Us||(this.Us=!0,this.A.warn(`Metric series cap reached (${this.Mr.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(vi.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,vi)]+=1;break}}}Fs(e){const t=this.Mr.beforeSend;if(!t)return e;const s=A(t)?t:[t];let i=e;for(const r of s)try{const n=r(i);if(!n)return this.A.info("Metric was rejected in beforeSend function"),null;i=n}catch(n){return this.A.error("Error in beforeSend function for metric:",n),null}return i}Os(){this.ps.pending||this.ps.arm(this.Hs())}Hs(){return Math.max(ya(this.Mr.flushIntervalMs,this.ks,this.Ss,3e4),this.ws.remainingMs())}Js(){var e=this;return Z(function*(){if(e.ps.clear(),e.zs.size===0)return;const t=e.zs;e.zs=new Map,e.Us=!1,e.Ws=new Map,e.Vs=new Set;const s=e.Gs,i=yield e._instance.Ys(e.Zs(t));if(s===e.Gs)switch(e.ws.record(i),i.kind==="retry-later"?(e.ks++,e.Ss=ma()):(e.ks=0,e.Ss=1),e.ps.pending&&e.ps.arm(e.Hs()),i.kind){case"ok":return;case"retry-later":return e.ho(t),void e.ps.armNoEarlierThan(e.Hs());case"too-large":return void e.A.warn("Metrics batch exceeded the server size limit and was dropped");case"fatal":return void e.A.error("Failed to send metrics batch:",i.error)}})()}Zs(e){return t=this.co(e),s=(function(n,o,a){return da(n,o,a)})(this.Mr,this._instance.getLibraryId(),this._instance.getLibraryVersion()),i=this._instance.getLibraryId(),r=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:pa(s)},scopeMetrics:[{scope:{name:i,version:r},metrics:t}]}]};var t,s,i,r}co(e){const t=hn(Date.now()),s=new Map;for(const o of e.values()){var i;const a=dn(o.type,o.name,o.unit,void 0);let l=s.get(a);l||(l=p({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=Hs((i=o.attributes)!==null&&i!==void 0?i:{},this.A),c=hn(o.windowStartMs);if(o.type==="count"){var r;const d={attributes:u,startTimeUnixNano:c,timeUnixNano:t,asDouble:(r=o.total)!==null&&r!==void 0?r:0};l.sum.dataPoints.push(d)}else if(o.type==="gauge"){var n;const d={attributes:u,timeUnixNano:t,asDouble:(n=o.last)!==null&&n!==void 0?n:0};l.gauge.dataPoints.push(d)}else o.hist&&l.histogram.dataPoints.push({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:vi})}return Array.from(s.values())}ho(e){for(const[i,r]of e){const n=this.zs.get(i);if(n)switch(n.windowStartMs=Math.min(n.windowStartMs,r.windowStartMs),n.type){case"count":var t,s;n.total=((t=n.total)!==null&&t!==void 0?t:0)+((s=r.total)!==null&&s!==void 0?s:0);break;case"gauge":break;case"histogram":if(r.hist)if(n.hist){n.hist.count+=r.hist.count,n.hist.sum+=r.hist.sum,n.hist.min=Math.min(n.hist.min,r.hist.min),n.hist.max=Math.max(n.hist.max,r.hist.max);for(let o=0;n.hist.bucketCounts.length>o;o++)n.hist.bucketCounts[o]+=r.hist.bucketCounts[o]}else n.hist=r.hist}else this.Ks()&&this.zs.set(i,r)}}};const ba=(e,{debugEnabled:t}={})=>{const s={N(i,...r){b&&(Ue.DEBUG||b.POSTHOG_DEBUG||t)&&!x(b.console)&&b.console&&("__rrweb_original__"in b.console[i]?b.console[i].__rrweb_original__:b.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)=>ba(`${e} ${i}`,r)};return s},S=ba("[PostHog.js]"),ie=S.createLogger,Qu=ie("[ExternalScriptsLoader]"),Ws=e=>{const t=k?.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]}},ht=(e,t,s)=>{if(e.config.disable_external_dependency_loading)return Qu.warn(`${t} was requested but loading of external scripts is disabled.`),s("Loading of external scripts is disabled");const i=Ws(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(!k)return s("document not found");if(Ws(t))return ht(e,t,s);let n=k.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")k.head.appendChild(n);else{const a=k.querySelectorAll("body > script");var o;a.length>0?(o=a[0].parentNode)===null||o===void 0||o.insertBefore(n,a[0]):k.body.appendChild(n)}};k?.body?r():k?.addEventListener("DOMContentLoaded",r)},fi={},pn=(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)};F.__PosthogExtensions__=F.__PosthogExtensions__||{},F.__PosthogExtensions__.loadExternalDependency=(e,t,s)=>{if(t==="remote-config"){const r=e.requestRouter.endpointFor("assets",`/array/${e.config.token}/config.js`);return void ht(e,r,s)}const i=e.config.strict_script_versioning;if(i){const r=e.requestRouter.endpointFor("assets",`/static/${e.version}/${t}.js`),n=fi[r];if(i==="fallback"&&n){if(Ws(n))return void ht(e,n,s);delete fi[r]}return void ht(e,r,i==="fallback"?(o,a)=>{if(o)if(typeof o=="string")s(o);else{var l;const u=pn(e,t);fi[r]=u;const c=Ws(r);c==null||(l=c.parentNode)===null||l===void 0||l.removeChild(c),ht(e,u,s)}else s(void 0,a)}:s)}ht(e,pn(e,t),s)},F.__PosthogExtensions__.loadSiteApp=(e,t,s)=>{const i=e.requestRouter.endpointFor("api",t);ht(e,i,s)},Ue.DEBUG=!1,Ue.LIB_VERSION="1.435.8",Ue.LIB_NAME="web";var le=Ue;const ec="$people_distinct_id",Fe="distinct_id",$r="$device_id",gi="$device_model",Vs="__alias",tc="__cmpns",vn="$fbc",Ft="$fbc_persistence",fn="$fbp",Qt="$fbp_persistence",Zi="__timers",wa="$autocapture_disabled_server_side",Qi="$heatmaps_enabled_server_side",er="$exception_capture_enabled_server_side",xa="$error_tracking_suppression_rules",tr="$error_tracking_capture_extension_exceptions",sr="$web_vitals_enabled_server_side",Sr="$dead_clicks_enabled_server_side",Pr="$product_tours_enabled_server_side",ka="$logs_capture_enabled_server_side",Ea="$web_vitals_allowed_metrics",es="$session_recording_remote_config",sc="$session_recording_enabled_server_side",ic="$replay_sample_rate",rc="$replay_override_sampling",nc="$replay_override_linked_flag",oc="$replay_override_url_trigger",ac="$replay_override_event_trigger",St="$sesid",$a="$session_is_sampled",lc="$session_past_minimum_duration",uc="$session_recording_url_trigger_activated_session",cc="$session_recording_event_trigger_activated_session",hc="$debug_first_full_snapshot_timestamp",dc="$sess_rec_flush_size",Te="$enabled_feature_flags",Ve="$active_feature_flags",ir="$early_access_features",vt="$feature_flag_details",et="$feature_flag_payloads",ft="$feature_flag_request_id",ts="$minimal_flag_called_events",Le="$override_feature_flags",dt="$override_feature_flag_payloads",tt="$stored_person_properties",st="$stored_group_properties",Sa="$groups",Kt="$surveys",zs="$surveys_loaded_at",Pa="$surveys_activated",Ma="$surveys_activated_session",Oa="$surveys_activated_timestamps",rr="ph_product_tours",pc="$product_tours_activated",vc="$product_tours_activated_session",fc="$conversations_widget_session_id",gc="$conversations_ticket_id",_c="$conversations_widget_state",mc="$conversations_user_traits",it="$flag_call_reported",Jt="$flag_call_reported_session_id",hs="$feature_flag_errors",rt="$feature_flag_evaluated_at",be="$user_state",nr="$client_session_props",yc="$capture_rate_limit",Ia="$initial_campaign_params",Fa="$initial_referrer_info",Pt="$initial_person_info",Mr="$epp",_i="$posthog_cookieless",Ta="$cookieless_mode",Ca="$sdk_debug_extensions_init_method",Aa="$sdk_debug_extensions_init_time_ms",Or="$sdk_debug_recording_script_not_loaded",Ir="$sdk_debug_replay_stale_config",Ra="$sdk_debug_replay_event_trigger_status",La="$sdk_debug_replay_linked_flag_trigger_status",Da="$sdk_debug_replay_matched_recording_trigger_groups",Na="$sdk_debug_replay_pending_trigger_conditions",ja="$sdk_debug_replay_remote_trigger_matching_config",Ba="$sdk_debug_replay_trigger_groups_count",qa="$sdk_debug_replay_url_trigger_status",bc="$session_recording_start_reason",Fr="PostHog loadExternalDependency extension not found.",ze="anonymous",Ts="identified",Ha="identified_only",ds="visibilitychange",Us="beforeunload",Tr="$pageview",gn="$pageleave",Wa="$identify",_n="$groupidentify";function Mt(e,t){A(e)&&e.forEach(t)}function K(e,t){if(!R(e))if(A(e))e.forEach(t);else if((s=>s instanceof FormData)(e))e.forEach((s,i)=>t(s,i));else for(const s in e)br.call(e,s)&&t(e[s],s)}const Y=function(e,...t){for(const s of t)for(const i in s)s[i]!==void 0&&(e[i]=s[i]);return e};function Cs(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 wc=function(e){return function(...t){try{return e.apply(this,t)}catch(s){S.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),S.critical(s)}}},Cr=function(e){const t={};return K(e,function(s,i){(L(s)&&s.length>0||ne(s))&&(t[i]=s)}),t};function Va(e){const t=p({},e);for(const s of["name","message","stack","cause","errors"])try{s in e&&(t[s]=e[s])}catch{}return t}const xc=["herokuapp.com","vercel.app","netlify.app"];function kc(e){const t=e?.hostname;if(!L(t))return!1;const s=t.split(".").slice(-2).join(".");for(const i of xc)if(s===i)return!1;return!0}function z(e,t,s,i){const{capture:r=!1,passive:n=!0}=i??{};e?.addEventListener(t,s,{capture:r,passive:n})}function or(e){return e.name==="ph_toolbar_internal"}const ss=e=>{if(k){try{const t=e+"=",s=k.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}};Math.trunc||(Math.trunc=function(e){return 0>e?Math.ceil(e):Math.floor(e)}),Number.isInteger||(Number.isInteger=function(e){return ne(e)&&isFinite(e)&&Math.floor(e)===e});var Ec=class ar{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 ar(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 ar(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}},$c=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 ne(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 Ec.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 Sc}};let za=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};b&&!x(b.crypto)&&crypto.getRandomValues&&(za=e=>crypto.getRandomValues(e));var Sc=class{nextUint32(){return this.Rt.length>this.At||(za(this.Rt),this.At=0),this.Rt[this.At++]}constructor(){this.Rt=new Uint32Array(8),this.At=1/0}};let mn;const Ce=()=>Pc().toString(),Pc=()=>(mn||(mn=new $c)).generate();let qt="";const Mc=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;let mt=null;const Q={Et(){if(!te(mt))return mt;if(mt=!1,k)try{const e=`__ph_cookie_support_${Ce()}`;Q.$t(e,"xyz"),mt=ss(e)==='"xyz"',Q.Pt(e)}catch{mt=!1}return mt},Dt(e){S.error("cookieStore error: "+e)},Ot:ss,Lt(e){let t;try{t=JSON.parse(Q.Ot(e))||{}}catch{}return t},$t(e,t,s,i,r){if(!k)return!1;try{let n="",o="";const a=(function(u,c){if(c){let d=(function(h,v=k){if(qt)return qt;if(!v||["localhost","127.0.0.1"].includes(h))return"";const f=h.split(".");let y=Math.min(f.length,8);const g="dmn_chk_"+Ce();for(;!qt&&y--;){const m=f.slice(y).join("."),_=g+"=1;domain=."+m+";path=/";v.cookie=_+";max-age=3",v.cookie.includes(g)&&(v.cookie=_+";max-age=0",qt=m)}return qt})(u);if(!d){const h=(v=>{const f=v.match(Mc);return f?f[0]:""})(u);h!==d&&S.info("Warning: cookie subdomain discovery mismatch",h,d),d=h}return d?"; domain=."+d:""}return""})(k.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&&S.warn("cookieStore warning: large cookie, len="+l.length),k.cookie=l,!0}catch{return!1}},Pt(e,t){if(k?.cookie&&(!t||!te(ss(e))))try{Q.$t(e,"",-1,t)}catch{return}}};let mi=null;const q={Et(){if(!te(mi))return mi;let e=!0;if(x(b))e=!1;else try{const t="__mplssupport__";q.$t(t,"xyz"),q.Ot(t)!=='"xyz"'&&(e=!1),q.Pt(t)}catch{e=!1}return e||S.error("localStorage unsupported; falling back to cookie store"),mi=e,e},Dt(e){S.error("localStorage error: "+e)},Ot(e){try{return b?.localStorage.getItem(e)}catch(t){q.Dt(t)}return null},Lt(e){try{return JSON.parse(q.Ot(e))||{}}catch{}return null},$t(e,t){try{return b?.localStorage.setItem(e,JSON.stringify(t)),!0}catch(s){q.Dt(s)}return!1},Pt(e){try{b?.localStorage.removeItem(e)}catch(t){q.Dt(t)}}},yi=[tt,Ve,Te,vt,et,ft,rt,hs,it],pt=[$r,Fe,St,$a,Mr,Pt,Ft,be],Gs=e=>e+"_cpm",Oc=["__proto__","constructor","prototype"],bi=e=>{if(!N(e))return{};const t={};return Object.keys(e).forEach(s=>{Oc.indexOf(s)===-1&&(t[s]=e[s])}),t},wi=(e,t=[])=>{const s={};return[...pt,...t].forEach(i=>{const r=e[i];x(r)||te(r)||r===""||(s[i]=r)}),s},Ua=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)},yn=(e,t)=>({p:t,f:Ua(JSON.stringify(e))}),bn=(e,t)=>{if(!t)return{properties:[],isValid:!1};try{const s=Q.Lt(Gs(e)),i=s?.f===Ua(t)&&A(s.p);return{properties:i?s.p:[],isValid:i}}catch{return{properties:[],isValid:!1}}},xi=(e,t)=>t+"|"+(Q.Ot(Gs(e))||""),yt={},lr={Et:()=>!0,Dt(e){S.error("memoryStorage error: "+e)},Ot:e=>e in yt?yt[e]:null,Lt:e=>e in yt?yt[e]:null,$t:(e,t)=>(yt[e]=t,!0),Pt(e){delete yt[e]}};let at=null;const X={Et(){if(!te(at))return at;if(at=!0,x(b))at=!1;else try{const e="__support__";X.$t(e,"xyz"),X.Ot(e)!=='"xyz"'&&(at=!1),X.Pt(e)}catch{at=!1}return at},Dt(e){S.error("sessionStorage error: ",e)},Ot(e){try{return b?.sessionStorage.getItem(e)}catch(t){X.Dt(t)}return null},Lt(e){try{return JSON.parse(X.Ot(e))||null}catch{}return null},$t(e,t){try{return b?.sessionStorage.setItem(e,JSON.stringify(t)),!0}catch(s){X.Dt(s)}return!1},Pt(e){try{b?.sessionStorage.removeItem(e)}catch(t){X.Dt(t)}}};var Ic=class{constructor(e){this._instance=e}get Mr(){return this._instance.config}get consent(){return this.Do()?0:this.Lo}isOptedOut(){return this.Mr.cookieless_mode==="always"||this.isRejected()||this.consent===-1&&this.Mr.cookieless_mode==="on_reject"}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===0}isRejected(){return this.consent===0||this.consent===-1&&this.Mr.opt_out_capturing_by_default}optInOut(e){this.No.$t(this.qo,e?1:0,this.Mr.cookie_expiration,this.Mr.cross_subdomain_cookie,this.Mr.secure_cookie)}reset(){this.No.Pt(this.qo,this.Mr.cross_subdomain_cookie)}get qo(){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 Lo(){const e=this.No.Ot(this.qo);return ai(e)?1:C(tu,e)?0:-1}get No(){const e=this.Mr.opt_out_capturing_persistence_type,t=e==="localStorage"?q:Q,s=t.Et()?t:lr;if(!this.jo||this.jo!==s){this.jo=s;const i=e==="localStorage"?Q:q;i.Ot(this.qo)&&(this.jo.Ot(this.qo)||this.optInOut(ai(i.Ot(this.qo))),i.Pt(this.qo,this.Mr.cross_subdomain_cookie))}return this.jo}Do(){return!!this.Mr.respect_dnt&&[ce?.doNotTrack,ce?.msDoNotTrack,F.doNotTrack,ce?.globalPrivacyControl].some(e=>ai(e))}};function Ga(e,t){var s;const i=e==null||(s=e.config)===null||s===void 0?void 0:s.get_current_url;if(!ue(i))return t;try{const r=i(t);return L(r)&&r?r:t}catch(r){return S.error("Error in get_current_url, falling back to window.location.href",r),t}}function wn(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 je(e){return!!e&&e.nodeType===1}function ve(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function Ka(e){return!!e&&e.nodeType===3}function Ar(e){return!!e&&e.nodeType===11&&je(e.host)}function Rr(e){return e?ei(e).split(/\s+/):[]}function xn(e,t){const s=(function(i){var r;const n=b==null||(r=b.location)===null||r===void 0?void 0:r.href;return x(n)?void 0:Ga(i,n)})(t);return!!(s&&e&&e.some(i=>s.match(i)))}function At(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 Rr(t)}function Ja(e){return R(e)?null:ei(e).split(/(\s+)/).filter(t=>rs(t)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function ps(e){let t="";return Tt(e)&&!vs(e)&&e.childNodes&&e.childNodes.length&&K(e.childNodes,function(s){var i;Ka(s)&&s.textContent&&(t+=(i=Ja(s.textContent))!==null&&i!==void 0?i:"")}),ei(t)}function is(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 Lr=["a","button","form","input","select","textarea","label"];function ur(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 cr(e,t){if(x(t))return!0;for(const s of e)if(t.some(i=>ur(s,i)))return!0;return!1}function Xa(e){const t=e.parentNode;return!(!t||!je(t))&&t}const ki=[".ph-no-autocapture","[data-ph-no-autocapture]"],Ya=["next","previous","prev",">","<"],Fc=[...Ya,"+","-","−","–"],kn=(e,t)=>/[a-z0-9]/i.test(t)?e.includes(t):e===t,En=[".ph-no-rageclick",".ph-no-capture"],Tc=["","text","search","email","password","url","tel","number"];function Za(e,t){if(!b||Dr(e))return!1;let s,i,r;var n,o;if(we(t)?(s=!!t&&En,i=void 0,r=!1):(s=(n=t?.css_selector_ignorelist)!==null&&n!==void 0?n:En,i=t?.content_ignorelist,r=(o=t?.ignore_text_selection)!==null&&o!==void 0&&o),s===!1||r&&(function(l){return!(!l||!je(l))&&(!!ve(l,"textarea")||(ve(l,"input")?C(Tc,(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}=Qa(e,!1);return!(function(l,u){if(l===!1||x(l))return!1;let c;if(l===!0)c=Ya;else{if(!A(l))return!1;if(l.length>10)return S.error("[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching."),!1;c=l.map(d=>d.toLowerCase())}return u.some(({safeText:d,ariaLabel:h})=>c.some(v=>kn(d,v)||kn(h,v)))})(i,a.map(l=>{var u;return{safeText:ps(l).toLowerCase(),ariaLabel:((u=l.getAttribute("aria-label"))===null||u===void 0?void 0:u.toLowerCase().trim())||""}}))&&!cr(a,s)}const Dr=e=>!e||ve(e,"html")||!je(e),Qa=(e,t)=>{if(!b||Dr(e))return{parentIsUsefulElement:!1,targetElementList:[]};let s=!1;const i=[e];let r=e;for(;r.parentNode&&!ve(r,"body");){if(Ar(r.parentNode)){i.push(r.parentNode.host),r=r.parentNode.host;continue}const n=Xa(r);if(!n)break;if(t||Lr.indexOf(n.tagName.toLowerCase())>-1)s=!0;else try{const o=b.getComputedStyle(n);o&&o.getPropertyValue("cursor")==="pointer"&&(s=!0)}catch{}i.push(n),r=n}return{parentIsUsefulElement:s,targetElementList:i}};function Tt(e){const t=new Set;let s=0;for(let n=e;n.parentNode&&!ve(n,"body");n=n.parentNode){if(s++>=1e3||t.has(n))return!1;t.add(n);const o=At(n);if(C(o,"ph-sensitive")||C(o,"ph-no-capture"))return!1}if(C(At(e),"ph-include"))return!0;const i=e.type||"";if(L(i))switch(i.toLowerCase()){case"hidden":case"password":return!1}const r=e.name||e.id||"";return!L(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 vs(e){return!!(ve(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||ve(e,"select")||ve(e,"textarea")||e.getAttribute("contenteditable")==="true")}const $n=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}))$"),Sn=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,Cc=[16,15,14,13],Ac=new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),Pn=new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),Mn=/[0-9A-Za-z_]/;function Rc(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 rs(e,t=!0){return!(R(e)||L(e)&&(e=ei(e),(t?$n.test((e||"").replace(/[- ]/g,"")):(function(s){let i;for(Sn.lastIndex=0;i=Sn.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 Cc){const l=o+a;if(n.length>=l){const u=n.slice(o,l);if($n.test(u)&&Rc(u))return!0}}}return!1})(e))||(t?Ac.test(e):(function(s){let i;for(Pn.lastIndex=0;i=Pn.exec(s);){const r=i[1],n=i[3];if(!(r&&n&&Mn.test(r)&&Mn.test(n)))return!0}return!1})(e))))}function On(e){let t=ps(e);return t=`${t} ${el(e)}`.trim(),rs(t)?t:""}function el(e){let t="";return e&&e.childNodes&&e.childNodes.length&&K(e.childNodes,function(s){var i;if(s&&((i=s.tagName)===null||i===void 0?void 0:i.toLowerCase())==="span")try{const r=ps(s);t=`${t} ${r}`.trim(),s.childNodes&&s.childNodes.length&&(t=`${t} ${el(s)}`.trim())}catch(r){S.error("[AutoCapture]",r)}}),t}function In(e){return e.replace(/"|\\"/g,'\\"')}function Lc(e){const t=e.attr__class;if(t)return A(t)?t:Rr(t)}const xs=ie("[Dead Clicks]"),Dc=()=>!0,Nc=e=>{var t;const s=!!(!((t=e.instance.persistence)===null||t===void 0)&&t.get_property(Sr)),i=e.instance.config.capture_dead_clicks;return we(i)?i:!!N(i)||s};var Fn=class{get lazyLoadedDeadClicksAutocapture(){return this.Bo}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({[Sr]:t.captureDeadClicks}),this.startIfEnabledOrStop())}startIfEnabledOrStop(){this.isEnabled(this)?this.Ho(()=>{this.zo()}):this.stop()}Ho(e){var t,s,i;!((t=F.__PosthogExtensions__)===null||t===void 0)&&t.initDeadClicksAutocapture?e():(s=F.__PosthogExtensions__)===null||s===void 0||(i=s.loadExternalDependency)===null||i===void 0||i.call(s,this.instance,"dead-clicks-autocapture",r=>{r?xs.error("failed to load script",r):e()})}zo(){var e;if(k){if(!this.Bo&&(!((e=F.__PosthogExtensions__)===null||e===void 0)&&e.initDeadClicksAutocapture)){const t=N(this.instance.config.capture_dead_clicks)?p({},this.instance.config.capture_dead_clicks):{};t.__onCapture=this.onCapture,this.onCapture&&(t.capture_dead_swipes=!1),this.Bo=F.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this.Bo.start(k),xs.info("starting...")}}else xs.error("`document` not found. Cannot start.")}stop(){this.Bo&&(this.Bo.stop(),this.Bo=void 0,xs.info("stopping..."))}};const Ht=ie("[SegmentIntegration]");function Tn(e,t,s=!0){const i=e.config.segment;if(!i)return t();const{analytics:r,filterProperties:n}=(a=>ue(a.register))(o=i)?{analytics:o}:o;var o;(function(a,l,u,c){const d=v=>{const f=()=>v.anonymousId()||Ce();a.config.get_device_id=f,c&&v.id()&&(a.register({distinct_id:v.id(),$device_id:f()}),a.persistence.set_property(be,Ts)),u(c?void 0:v.anonymousId()||void 0)},h=l.user();"then"in h&&ue(h.then)?h.then(d):d(h)})(e,r,a=>{r.register(((l,u,{filterProperties:c}={})=>{typeof Promise<"u"&&Promise.resolve||Ht.warn("This browser does not have Promise support, and can not use the segment integration");const d=(h,v)=>{if(!v)return h;const f=!!u&&h.event.anonymousId===u&&!h.event.userId;f||h.event.userId||h.event.anonymousId===l.get_distinct_id()||(Ht.info("No userId set, resetting PostHog"),l.reset()),f||(u=void 0),h.event.userId&&h.event.userId!==l.get_distinct_id()&&(Ht.info("UserId set, identifying with PostHog"),l.identify(h.event.userId));let y=l.calculateEventProperties(v,h.event.properties);if(!R(c)){const g=h.event.properties||{},m={};for(const w of Object.keys(y))br.call(g,w)||(m[w]=y[w]);const _=((w,$)=>{const E=A(w)?w:[w];let P=p({},$);for(const I of E)try{if(P=I(P),R(P))return null}catch(M){return Ht.error("Error in Segment filterProperties:",M),null}return P})(c,m);if(R(_))return h;y=_}return h.event.properties=Object.assign({},y,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,Tr)},identify(h){return d(h,Wa)},screen(h){return d(h,"$screen")}}})(e,a,{filterProperties:n})).then(()=>{t()},l=>{Ht.error("Failed to register the Segment integration",l),t()})},s)}const tl="posthog-js";function sl(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 v=((a=o.exception)===null||a===void 0?void 0:a.values)||[],f=v.map(m=>p(p({},m),{},{stacktrace:m.stacktrace?p(p({},m.stacktrace),{},{type:"raw",frames:(m.stacktrace.frames||[]).map(_=>p(p({},_),{},{platform:"web:javascript"}))}):void 0})),y={$exception_message:((l=v[0])===null||l===void 0?void 0:l.value)||o.message,$exception_type:(u=v[0])===null||u===void 0?void 0:u.type,$exception_level:o.level,$exception_list:f,$sentry_event_id:o.event_id,$sentry_exception:o.exception,$sentry_exception_message:((c=v[0])===null||c===void 0?void 0:c.value)||o.message,$sentry_exception_type:(d=v[0])===null||d===void 0?void 0:d.type,$sentry_tags:o.tags};var g;return t&&s&&(y.$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(y)),o}}var jc=class{constructor(e,t,s,i,r,n){this.name=tl,this.setupOnce=function(o){o(sl(e,{organization:t,projectId:s,prefix:i,severityAllowList:r,sendExceptionsToPostHog:n==null||n}))}}},Cn=class{constructor(e){this.Uo=(t,s,i)=>{i&&(i.noSessionId||i.activityTimeout||i.sessionPastMaximumLength||i.crossTabAdoption)&&(S.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:t,changeReason:i}),this.Wo=void 0,this._instance.scrollManager.resetContext())},this._instance=e,this.Vo()}Vo(){var e;this.Go=(e=this._instance.sessionManager)===null||e===void 0?void 0:e.onSessionId(this.Uo)}destroy(){var e;(e=this.Go)===null||e===void 0||e.call(this),this.Go=void 0}doPageView(e,t){var s;const i=this.Qo(e,t);return this.Wo={pathname:(s=b?.location.pathname)!==null&&s!==void 0?s:"",pageViewId:t,timestamp:e},this._instance.scrollManager.resetContext(),i}doPageLeave(e){var t;return this.Qo(e,(t=this.Wo)===null||t===void 0?void 0:t.pageViewId)}doEvent(){var e;return{$pageview_id:(e=this.Wo)===null||e===void 0?void 0:e.pageViewId}}Qo(e,t){const s=this.Wo;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?Ne(o/n,0,1,S):1,h=n>1?Ne(a/n,0,1,S):1,v=l>1?Ne(u/l,0,1,S):1,f=l>1?Ne(c/l,0,1,S):1;i=Y(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:v,$prev_pageview_max_content:c,$prev_pageview_max_content_percentage:f})}}return s.pathname&&(i.$prev_pageview_pathname=s.pathname),s.timestamp&&(i.$prev_pageview_duration=(e.getTime()-s.timestamp.getTime())/1e3),i}};const Wt=["flags","surveys"],Bc={[ec]:{exposure:"hidden"},[Vs]:{exposure:"hidden"},[tc]:{exposure:"hidden"},[Zi]:{exposure:"hidden"},[Ft]:{exposure:"hidden"},[Qt]:{exposure:"hidden"},[wa]:{exposure:"event"},[Qi]:{exposure:"hidden"},[ka]:{exposure:"hidden"},[er]:{exposure:"event"},[xa]:{exposure:"hidden"},[tr]:{exposure:"event"},[sr]:{exposure:"event"},[Sr]:{exposure:"event"},[Pr]:{exposure:"hidden"},[Ea]:{exposure:"event"},[es]:{exposure:"hidden"},[sc]:{exposure:"hidden"},[St]:{exposure:"hidden"},[$a]:{exposure:"event"},[ic]:{exposure:"event",shouldSkipFromEventProperties:e=>te(e)},[lc]:{exposure:"event"},[uc]:{exposure:"event"},[cc]:{exposure:"event"},[hc]:{exposure:"event"},[dc]:{exposure:"hidden"},[Te]:{exposure:"hidden",storageGroup:"flags"},[Ve]:{exposure:"hidden",storageGroup:"flags"},[ir]:{exposure:"hidden"},[vt]:{exposure:"hidden",storageGroup:"flags"},[et]:{exposure:"hidden",storageGroup:"flags"},[ft]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[ts]:{exposure:"hidden",storageGroup:"flags"},[Le]:{exposure:"hidden"},[dt]:{exposure:"hidden"},[tt]:{exposure:"hidden"},[st]:{exposure:"hidden"},[Kt]:{exposure:"hidden",storageGroup:"surveys"},[zs]:{exposure:"hidden",storageGroup:"surveys",volatile:!0},[Pa]:{exposure:"event"},[Ma]:{exposure:"hidden"},[Oa]:{exposure:"hidden"},[rr]:{exposure:"hidden"},[pc]:{exposure:"hidden"},[vc]:{exposure:"hidden"},[fc]:{exposure:"event"},[gc]:{exposure:"event"},[_c]:{exposure:"event"},[mc]:{exposure:"event"},[it]:{exposure:"hidden"},[Jt]:{exposure:"hidden"},[Sa]:{exposure:"event"},[hs]:{exposure:"hidden"},[rt]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[be]:{exposure:"hidden"},[nr]:{exposure:"hidden"},[yc]:{exposure:"hidden"},[Ia]:{exposure:"hidden"},[Fa]:{exposure:"hidden"},[Pt]:{exposure:"hidden"},[Mr]:{exposure:"hidden"},[rc]:{exposure:"event"},[nc]:{exposure:"event"},[oc]:{exposure:"event"},[ac]:{exposure:"event"},[Ca]:{exposure:"event"},[Aa]:{exposure:"event"},[Or]:{exposure:"hidden"},[Ir]:{exposure:"hidden"},[Ra]:{exposure:"hidden"},[La]:{exposure:"hidden"},[Da]:{exposure:"hidden"},[Na]:{exposure:"hidden"},[ja]:{exposure:"hidden"},[Ba]:{exposure:"hidden"},[qa]:{exposure:"hidden"},[bc]:{exposure:"event"}},qc=[["$posthog_sr_group_event_trigger_",{exposure:"hidden"}],["$posthog_sr_group_url_trigger_",{exposure:"hidden"}],["$posthog_sr_group_sampling_",{exposure:"hidden"}]],de=e=>{const t=Bc[e];if(t)return t;for(const[s,i]of qc)if(e.indexOf(s)===0)return i},Ot=(e,t)=>{try{let s;return JSON.stringify(e,(i,r)=>{var n;return Nt(r)?((n=s)!==null&&n!==void 0||(s=new WeakMap),s.has(r)||s.set(r,Va(r)),s.get(r)):typeof r=="bigint"?r.toString():r},t)}catch{return xo(e)}},Ge=e=>{const t=k?.createElement("a");return x(t)?null:(t.href=e,t)},Rt=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(!A(i)||2>i.length)return"";{let r=i[1];try{r=decodeURIComponent(r)}catch{S.error("Skipping decoding for malformed query param: "+r)}return r.replace(/\+/g," ")}},fs=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("=");A(h)&&(t.includes(h[0])?u.push(h[0]+"="+s):u.push(l[d]))}let c=a;return o!=null&&(c+="?"+u.join("&")),r!=null&&(c+="#"+r),c},Ks=function(e,t){const s=e.match(new RegExp(t+"=([^&]*)"));return s?s[1]:null},il=(e,t)=>e>=t&&wo(),rl=(e,t,s,i)=>{if(e===0){if(wo()){const r=t+1;return r===s&&i(),r}return t}return 0},Lt=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","oppref","irclid","_kx"],Hc=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...Lt],gs="<masked>",Wc=["li_fat_id"];function nl(e,t,s){if(!k)return{};const i=t?[...Lt,...s||[]]:[],r=ol(fs(k.URL,i,gs),e),n=(function(){const o={};return K(Wc,function(a){const l=ss(a);o[a]=l||null}),o})();return Y(n,r)}function ol(e,t){const s=Hc.concat(t||[]),i={};return K(s,function(r){const n=Rt(e,r);i[r]=n||null}),i}function al(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(!te(t)){i.$search_engine=t;const r=k?Rt(k.referrer,s):"";r.length&&(i.ph_keyword=r)}return i}function ll(){return navigator.language||navigator.userLanguage}function Vc(){const e=ll();return typeof e=="string"?e.split("-")[0]:void 0}const Js="$direct";function ul(){return k?.referrer||Js}function cl(e,t,s=!1){const i=e?[...Lt,...t||[]]:[],r=s?nt(ee?.href):ee?.href,n=r?.substring(0,1e3);return{r:ul().substring(0,1e3),u:n?fs(n,i,gs):void 0}}function hl(e,t=!1){var s;const{r:i,u:r}=e,n=t?nt(r):r,o={$referrer:i,$referring_domain:i==null?void 0:i==Js?Js:(s=Ge(i))===null||s===void 0?void 0:s.host};if(n){o.$current_url=n;const a=Ge(n);o.$host=a?.host,o.$pathname=a?.pathname;const l=ol(n);Y(o,l)}if(i){const a=al(i);Y(o,a)}return o}function dl(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function zc(){try{return new Date().getTimezoneOffset()}catch{return}}const Uc={flags:rt,surveys:zs},Gc=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],ks=e=>`${e}_cookie_identity_change_pending`,Es=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},ae="main",We=[Te,Ve,vt,et,ft,rt,ts,tt],Ei=e=>We.indexOf(e)!==-1,pl=[Ft,Qt],An=e=>pl.indexOf(e)!==-1,Ye=(e,t)=>{try{return JSON.stringify(e)===JSON.stringify(t)}catch{return e===t}},bt=e=>{if(!e)return{};const t=JSON.parse(e);return N(t)?t:{}},Rn=(e,t)=>{K(e,(s,i)=>{const r=de(i);r&&r.exposure!=="event"||{}.hasOwnProperty.call(t,i)||delete e[i]})};var $i=class{constructor(e,t,s=!0,i=!e.cookieless_mode){if(this.Jo={},this.Zo=!1,this.Ko=!1,this.Xo=!1,this.Yo=!1,this.ta=!1,this.ea=new Map,this.ia=!1,this.na=!1,this.sa=!1,this.ra=new Set,this.oa=new Set,this.Mr=e,this.aa=s,this.props={},this.la=void 0,this.ua=(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.No=this.ha(e),this.Xo=this.ca(e),this.load(i),this.da(),e.debug&&S.info("Persistence loaded",e.persistence,p({},this.props)),this.update_config(e,e,t),this.save(),b){const r=()=>this.flush();z(b,"beforeunload",r,{capture:!1}),z(b,"pagehide",r,{capture:!1}),this.va=n=>{if(this.Zo&&(!n.storageArea||n.storageArea===b?.localStorage)&&n.key)if(n.key!==this.ua){if(this.Xo){const o=Wt.find(a=>n.key===this.fa(a));o&&this.pa(n.key,o)}}else this.pa(n.key,ae)},z(b,"storage",this.va)}}markCrossTabFeatureFlagChanges(e){Object.entries(e).forEach(([t,s])=>{const i=this.ea.get(t);if(!Ei(t)||i===!0)return;if(s===!0)return void this.ga(t,!0);const r=new Set(i||[]);s.forEach(n=>r.add(n)),r.size&&this.ga(t,r)})}onCrossTabFeatureFlagChange(e){return this.oa.add(e),()=>this.oa.delete(e)}destroy(){this.va&&b&&(b.removeEventListener("storage",this.va),this.va=void 0),this.oa.clear()}pa(e,t,s=!0){if(this.hi)return!1;let i,r;try{if(r=q.Ot(e),te(r)){const a=this.ma(t);return a.storageValue=null,t!==ae&&(a.persisted=!1),!1}i=bt(r)}catch{return!1}const n=t===ae?i:q.Lt(this.ua);if(n&&this.ya(n))return!1;const o=this.ba(i,t,s);return t===ae&&this.Xo&&!Ye(this._a().main,i)||this.wa(i,t,!0,r),o}ya(e){const t=this.props[Fe],s=e[Fe];return!x(t)&&!x(s)&&t!==s}wa(e,t,s,i){const r=this.ma(t);r.storageValue=i,t!==ae&&(r.persisted=s);try{r.fingerprint=this.ka(e,t)}catch{r.fingerprint=void 0}}ba(e,t,s){let i=!1;return We.forEach(r=>{var n;const o=(n=de(r))===null||n===void 0?void 0:n.storageGroup;if(t===ae&&this.Xo&&o||t!==ae&&o!==t)return;const a=r in e,l=this.Sa(r,a?e[r]:void 0),u=this.ea.has(r)?r in this.props:a;u===r in this.props&&Ye(l,this.props[r])||(u?this.xa(r,l,!1):this.$a(r,!1),i=!0)}),i&&s&&this.oa.forEach(r=>r()),i}Ca(){if(!this.Zo)return!1;try{this.sa=!1;const e=q.Ot(this.ua),t=this.ma(ae);let s,i=!1,r=!1;if(e!==t.storageValue)if(te(e))t.storageValue=null;else{if(s=bt(e),this.sa=!this.na&&this.ya(s),this.sa)return!1;r=this.ba(s,ae,!1),!this.Xo||Ye(this._a().main,s)?this.wa(s,ae,!0,e):t.storageValue=e,i=!0}return this.Xo&&Wt.forEach(n=>{const o=q.Ot(this.fa(n)),a=this.ma(n),l=s||{},u=i&&We.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(te(o))return a.storageValue=null,a.persisted=!1,void(u&&(r=this.ba(l,n,!1)||r));const c=bt(o);r=this.ba(c,n,!1)||r,this.wa(c,n,!0,o)}),r}catch{return!1}}ga(e,t){this.ea.set(e,t);const s=de(e);s?.volatile||(this.ma((this.Xo?s?.storageGroup:void 0)||ae).fingerprint=void 0,this.Ta(e))}Ia(){We.forEach(e=>this.ea.set(e,!0))}da(){if(this.Zo)try{const e=q.Ot(this.ua),t=bt(e);this.ma(ae).storageValue=e,We.forEach(s=>{var i;const r=this.Xo?(i=de(s))===null||i===void 0?void 0:i.storageGroup:void 0,n=r?q.Ot(this.fa(r)):null;if(r){const a=this.ma(r);a.storageValue=n,a.persisted=!te(n)}const o=r&&!te(n)?bt(n):t;s in this.props?this.Ma(s,o[s],this.props[s]):s in o&&this.ga(s,!0)})}catch{}}Sa(e,t){const s=this.ea.get(e);if(!s)return t;if(s===!0)return this.props[e];if(e==="$active_feature_flags"){const n=new Set(A(t)?t:[]),o=new Set(A(this.props[e])?this.props[e]:[]);return s.forEach(a=>o.has(a)?n.add(a):n.delete(a)),Array.from(n)}const i=N(t)?p({},t):{},r=N(this.props[e])?this.props[e]:{};return s.forEach(n=>{n in r?i[n]=r[n]:delete i[n]}),i}Ma(e,t,s){if(!Ei(e))return;const i=this.ea.get(e);if(i===!0)return;let r=t;if(this.Zo)try{var n;const a=this.Xo?(n=de(e))===null||n===void 0?void 0:n.storageGroup:void 0,l=a?this.fa(a):this.ua;r=bt(q.Ot(l))[e]}catch{}const o=new Set(i||[]);if(e==="$active_feature_flags"){if(!x(t)&&!A(t)||!x(r)&&!A(r)||!A(s))return void this.ga(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(!N(s))return void(Ye(r,s)?this.ea.delete(e):this.ga(e,!0));{if(!x(t)&&!N(t)||x(t)&&ke(s)&&x(r))return void this.ga(e,!0);const a=N(t)?t:{},l=N(r)?r:{};new Set([...Object.keys(a),...Object.keys(s)]).forEach(u=>{u in a==u in s&&Ye(a[u],s[u])||o.add(u)}),o.forEach(u=>{u in l==u in s&&Ye(l[u],s[u])&&o.delete(u)})}}o.size?this.ga(e,o):this.ea.delete(e)}Ea(){var e;const t=(e=this.Mr)===null||e===void 0?void 0:e.persistence_save_debounce_ms;return ne(t)&&t>0?t:0}Pa(e){if(this.Mr.cookieWinsOnConflict&&this.Mr.persistence.toLowerCase()==="localstorage+cookie")if(e)try{const t=wi(e,this.Mr.cookie_persisted_properties||[]),s=yn(t,this.Mr.cookie_persisted_properties||[]),i=JSON.stringify(t)+"|"+JSON.stringify(s),r=Q.Ot(this.ua)||void 0;r&&xi(this.ua,r)===i&&(this.Ra=i,this.Aa=r)}catch{}else try{const t=Q.Ot(this.ua)||void 0;this.Ra=t?xi(this.ua,t):void 0,this.Aa=t}catch{}}syncCookieProperties(){return this.Oa(this.Mr)}Oa(e,t=!1){if(this.hi&&!t||this.ta||!e.cookieWinsOnConflict||e.persistence.toLowerCase()!=="localstorage+cookie")return!1;let s;try{s=Q.Ot(this.ua)||void 0}catch{}if(!s||s===this.Aa)return!1;const i=xi(this.ua,s);let r;try{r=bi(JSON.parse(s))}catch{return!1}if((Q.Ot(this.ua)||void 0)!==s)return!1;this.Ra=i,this.Aa=s;const n=bn(this.ua,s),o=[...pt,...n.properties],a={};if(Object.keys(r).forEach(y=>{const g=r[y];(x(g)||te(g)||g===""||y==="$user_state"&&g!=="anonymous"&&g!=="identified")&&(a[y]=!0,delete r[y])}),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[be],h=Y({},u);[...pt,...e.cookie_persisted_properties||[]].forEach(y=>{if(o.indexOf(y)!==-1&&!(y in r)&&!a[y]&&(l||y!=="distinct_id"&&y!=="$user_state")){const g=h[y];(n.isValid||pt.indexOf(y)===-1||g!==!1&&g!==0)&&delete h[y]}}),this.props=Y(h,r),We.forEach(y=>{const g=y in this.props;y in u===g&&Ye(u[y],this.props[y])||(g?this.Ma(y,u[y],this.props[y]):this.ga(y,!0))}),!l||"$user_state"in r||"$user_state"in this.props||this.xa(be,ze);const v=this.props[Fe],f=this.props[be];return!l||v===c&&f===d||(this.na=!0,this.Yo=!0,X.$t(ks(this.ua),!0),this.$a(tt),this.$a(Ve),this.$a(Te),this.$a(vt),this.$a(et),this.$a(ft),this.$a(rt),this.$a(hs),this.$a(it),f!=="anonymous"||d!=="identified"&&r.$user_state!=="anonymous"&&(x(c)||v===c)||(Rn(this.props,r),this.$a(st)),f==="identified"?this.props.$user_id=v:delete this.props.$user_id,this.$a(Vs)),!0}consumeCookieIdentityChange(){const e=ks(this.ua),t=this.Yo||!!X.Ot(e);return this.Yo=!1,t&&X.Pt(e),t}Fa(e=!1){return!(this.ta||this.hi&&!e||!this.Mr.cookieWinsOnConflict||this.Mr.persistence.toLowerCase()!=="localstorage+cookie"||(this.ta=!0,0))}Da(){this.ta&&(x(this.La)||(clearTimeout(this.La),this.La=void 0),delete this.Jo[ae],this.Na(!0))}qa(e=!0){if(this.ta)try{e?this.Da():x(this.La)||(clearTimeout(this.La),this.La=void 0)}finally{this.ta=!1}}isDisabled(){return!!this.hi}ha(e){Gc.indexOf(e.persistence.toLowerCase())===-1&&(S.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");const t=((o=[],a=!1,l=()=>!1)=>{const u=[...pt,...o];return p(p({},q),{},{Lt(c){try{let h,v={};try{h=Q.Ot(c)||void 0,v=h?bi(JSON.parse(h)):{}}catch{}const f=JSON.parse(q.Ot(c)||"{}");let y;if(a){const g=bn(c,h),m=[...pt,...g.properties],_={};Object.keys(v).forEach($=>{const E=v[$];te(E)||E===""||$==="$user_state"&&E!=="anonymous"&&E!=="identified"||(_[$]=E)});const w="distinct_id"in _||_.$user_state==="anonymous"||_.$user_state==="identified";if(Object.keys(_).length>0){var d;const $=f[Fe],E=(d=f.$user_state)!==null&&d!==void 0?d:ze;u.forEach(P=>{if(m.indexOf(P)!==-1&&!(P in v)&&(w||P!=="distinct_id"&&P!=="$user_state")){const I=f[P];(g.isValid||pt.indexOf(P)===-1||I!==!1&&I!==0)&&delete f[P]}}),!w||"$user_state"in v||"$user_state"in f||(f[be]=ze),!w||("distinct_id"in _?_[Fe]:f[Fe])===$&&("$user_state"in _?_[be]:f[be])===E||(yi.forEach(P=>delete f[P]),_.$user_state==="identified"&&"distinct_id"in _?f.$user_id=_[Fe]:delete f.$user_id,_.$user_state!=="identified"&&(delete f[Sa],delete f[st]),delete f.__alias)}y=Y(f,_)}else y=Y(v,f);return l()||q.$t(c,y),y}catch{}return null},$t(c,d,h,v,f,y){const g=q.$t(c,d,void 0,void 0,y);try{const m=wi(d,o);if(Object.keys(m).length){if(a){const _=Gs(c),w=yn(m,o);if(Q.$t(_,w,h,v,f,y),Q.Ot(_)!==JSON.stringify(w)){Q.Pt(_,v);const $=wi(d);return Q.$t(c,$,h,v,f,y),g}}Q.$t(c,m,h,v,f,y)}}catch(m){q.Dt(m)}return g},Pt(c,d){try{b?.localStorage.removeItem(c),Q.Pt(c,d),Q.Pt(Gs(c),d)}catch(h){q.Dt(h)}}})})(e.cookie_persisted_properties||[],e.cookieWinsOnConflict,()=>!!this.hi);let s,i=!1,r=!1;const n=e.persistence.toLowerCase();return n==="localstorage"&&q.Et()?(s=q,r=!0):n==="localstorage+cookie"&&t.Et()?(s=t,r=!0,i=!0):n==="sessionstorage"&&X.Et()?s=X:n==="memory"?s=lr:n==="cookie"&&Q.Et()?(s=Q,i=!0):t.Et()?(s=t,r=!0,i=!0):Q.Et()?(s=Q,i=!0):s=lr,this.Zo=r,this.Ko=i,s}fa(e){return`${this.ua}__${e}`}ca(e){return this.Zo&&!!e.split_storage}properties(){const e={};return K(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.Mr.cookieWinsOnConflict&&this.Mr.persistence.toLowerCase()==="localstorage+cookie",s=t?q.Lt(this.ua):null;let i={};if(t)try{i=bi(Q.Lt(this.ua)),K(i,(a,l)=>{(x(a)||te(a)||a==="")&&delete i[l]})}catch{}const r=this.No.Lt(this.ua);if(r&&(this.props=Y({},r)),this.Xo&&this.ja(),t&&r){var n,o;const a=s?.[Fe],l=(n=s?.$user_state)!==null&&n!==void 0?n:ze,u=r[Fe],c=(o=r.$user_state)!==null&&o!==void 0?o:ze;if(u!==a||c!==l){this.Yo=!0,this.hi||X.$t(ks(this.ua),!0);const d=Y({},this.props);yi.forEach(v=>delete d[v]),c!=="anonymous"||l!=="identified"&&i.$user_state!=="anonymous"&&(x(a)||u===a)||(Rn(d,i),delete d[st]),this.props=d;const h=new Set;yi.forEach(v=>{var f;const y=(f=de(v))===null||f===void 0?void 0:f.storageGroup;y&&h.add(y)}),h.forEach(v=>{if(this.hi)return;const f={};K(this.props,(y,g)=>{var m;((m=de(g))===null||m===void 0?void 0:m.storageGroup)===v&&(f[g]=y)}),ke(f)?(q.Pt(this.fa(v)),this.Jo[v]={}):q.$t(this.fa(v),f)&&(this.Jo[v]={persisted:!0,fingerprint:this.ka(f,v)})})}}X.Ot(ks(this.ua))&&(this.Yo=!0)}ja(){for(const e of Wt){const t=q.Lt(this.fa(e));if(t&&!ke(t)){const s=this.ma(e);s.persisted=!0,this.Ba(e)||(s.fingerprint=this.ka(t,e)),this.Ha(e,t)||Y(this.props,t)}}}Ba(e){return Object.keys(this.props).some(t=>{var s;return((s=de(t))===null||s===void 0?void 0:s.storageGroup)===e})}Ha(e,t){const s=Uc[e];if(!s)return!1;const i=t[s],r=this.props[s];return ne(i)&&ne(r)&&r>i}refreshKey(e){var t;if(this.hi||this.ra.has(e))return;const s=this.Xo?(t=de(e))===null||t===void 0?void 0:t.storageGroup:void 0,i=s?q.Lt(this.fa(s)):this.No.Lt(this.ua);if(i&&e in i)this.xa(e,i[e],!1);else{if(s){const r=this.No.Lt(this.ua);if(r&&e in r)return void this.xa(e,r[e],!1)}this.$a(e,!1)}}save(){if(this.hi)return;const e=this.Ea();e>0?x(this.La)&&(this.La=setTimeout(()=>{this.La=void 0,this.Na()},e)):this.Na()}flush(){x(this.La)||(clearTimeout(this.La),this.La=void 0,this.Na())}Na(e=!1){if(this.hi||this.ta&&!e)return;e||(this.syncCookieProperties(),this.Mr.cookieWinsOnConflict&&this.Mr.persistence.toLowerCase()==="localstorage+cookie"||pl.forEach(r=>this.refreshKey(r)));const t=!e&&!this.ia;t||(this.sa=!1);const s=!!t&&this.Ca();if(this.sa)return void(this.Mr.debug&&S.warn("skipping persistence write because storage belongs to a different distinct ID"));if(this.Xo)return this.za(),void(s&&this.oa.forEach(r=>r()));const i=this.Ua(this.No,this.ua,this.props,ae);i==="written"&&this.Pa(this.props),i!=="failed"&&(this.ea.clear(),this.na=!1,this.ra.clear()),s&&this.oa.forEach(r=>r())}za(){const{main:e,groups:t}=this._a(),s=this.Ua(this.No,this.ua,e,ae);s==="written"&&this.Pa(e),s!=="failed"&&(this.na=!1,this.ra.clear(),We.forEach(r=>{var n;!((n=de(r))===null||n===void 0)&&n.storageGroup||this.ea.delete(r)}));for(const r of Wt){var i;const n=t[r];if(ke(n)&&!(!((i=this.Jo[r])===null||i===void 0)&&i.persisted)){We.forEach(a=>{var l;((l=de(a))===null||l===void 0?void 0:l.storageGroup)===r&&this.ea.delete(a)});continue}const o=this.Ua(q,this.fa(r),n,r);o!=="failed"&&We.forEach(a=>{const l=de(a);l?.storageGroup!==r||o!=="written"&&l.volatile||this.ea.delete(a)})}}_a(){const e={},t={flags:{},surveys:{}};return K(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}}ka(e,t){if(t===ae)return JSON.stringify(e)+"|"+this.Wa+"|"+this.Va+"|"+this.Ga;const s={};return K(e,(i,r)=>{var n;s[r]=!((n=de(r))===null||n===void 0)&&n.volatile?"__volatile__":i}),JSON.stringify(s)}Ua(e,t,s,i){const r=this.ma(i);if(i!==ae&&!r.dirty&&!x(r.fingerprint))return"skipped";let n;try{if(n=this.ka(s,i),n===r.fingerprint)return r.dirty=!1,"skipped"}catch{n=void 0}return e.$t(t,s,this.Wa,this.Va,this.Ga,this.Mr.debug)?(r.dirty=!1,i!==ae&&(r.persisted=!0),x(n)||(r.fingerprint=n),this.Zo&&(r.storageValue=q.Ot(t)),"written"):(this.Mr.debug&&S.warn(`failed to persist storage entry "${t}"; will retry on next save`),"failed")}remove({keepGroupEntries:e=!1}={}){if(this.Ia(),x(this.La)||(clearTimeout(this.La),this.La=void 0),this.No.Pt(this.ua,!1),this.No.Pt(this.ua,!0),!e&&this.aa)for(const t of Wt)q.Pt(this.fa(t));e?delete this.Jo[ae]:this.Jo={},this.Ra=void 0,this.Aa=void 0}clear(){this.remove(),this.props={}}register_once(e,t,s){if(N(e)){this.syncCookieProperties(),x(t)&&(t="None"),this.Wa=x(s)?this.Qa:s;let i=!1;if(K(e,(r,n)=>{this.props.hasOwnProperty(n)&&this.props[n]!==t||(this.xa(n,r),i=!0)}),i)return this.save(),!0}return!1}register(e,t){if(N(e)){this.syncCookieProperties(),this.Wa=x(t)?this.Qa:t;let s=!1;if(K(e,(i,r)=>{e.hasOwnProperty(r)&&(this.props[r]!==i||N(i)||A(i))&&(this.xa(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.$a(i),s=!0);s&&this.save()}update_campaign_params(){const e=k?.URL;if(e===this.la)return;const t=nl(this.Mr.custom_campaign_params,this.Mr.mask_personal_data_properties,this.Mr.custom_personal_data_properties),s=!ke(Cr(t));return s&&this.register(t),this.la=e,s?t:void 0}update_search_keyword(){this.register((function(){const e=k?.referrer;return e?al(e):{}})())}update_referrer_info(){var e;this.register_once({$referrer:ul(),$referring_domain:k?.referrer&&((e=Ge(k.referrer))===null||e===void 0?void 0:e.host)||Js},void 0)}set_initial_person_info(){if(this.props.$initial_campaign_params||this.props.$initial_referrer_info)return;const e=cl(this.Mr.mask_personal_data_properties,this.Mr.custom_personal_data_properties,this.Mr.disable_capture_url_hashes);this.register_once({[Pt]:this.Ko?{r:Es(e.r),u:e.u?Es(e.u):void 0}:e},void 0)}get_initial_props(){const e={};K([Fa,Ia],s=>{const i=this.props[s];i&&K(i,function(r,n){e["$initial_"+Vi(n)]=r})});const t=this.props[Pt];if(t){const s=(function(i,r=!1){const n=hl(i,r),o={};return K(n,function(a,l){o[`$initial_${Vi(l)}`]=a}),o})(t,this.Mr.disable_capture_url_hashes);Y(e,s)}return e}safe_merge(e){return K(this.props,function(t,s){s in e||(e[s]=t)}),e}update_config(e,t,s){const i=e.persistence!==t.persistence,r=!((v,f)=>{if(v.length!==f.length)return!1;const y=[...v].sort(),g=[...f].sort();return y.every((m,_)=>m===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.Oa(t,l),this.Mr=e,!a&&(i||r||o)&&(this.Ra=void 0,this.Aa=void 0,this.Oa(p(p({},e),{},{cookie_persisted_properties:t.cookie_persisted_properties}),l));const u=n||o?this.ha(e):this.No;this.Ja();const c=this.ca(e),d=n||c!==this.Xo,h=!a&&(d||e.cross_subdomain_cookie!==this.Va||e.secure_cookie!==this.Ga)&&this.Fa(l);this.ia=d;try{if(this.Qa=this.Wa=e.cookie_expiration,this.set_disabled(a),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),d){const v=this.props;this.clear(),this.No=u,this.Xo=c,this.props=v,this.save()}else o&&(this.No=u,a||(delete this.Jo[ae],this.Na()))}finally{this.ia=!1,h&&this.qa()}}Ja(){const e=this.props[Pt];if(!this.Ko||!N(e)||typeof e.r!="string")return;const t=Es(e.r),s=typeof e.u=="string"?Es(e.u):e.u;t===e.r&&s===e.u||this.xa(Pt,p(p({},e),{},{r:t,u:s}))}set_disabled(e){this.hi=e,this.hi?this.remove():this.save()}set_cross_subdomain(e){e!==this.Va&&(this.Va=e,this.remove({keepGroupEntries:!0}),this.save())}set_secure(e){e!==this.Ga&&(this.Ga=e,this.remove({keepGroupEntries:!0}),this.save())}set_event_timer(e,t){const s=this.props.__timers||{};s[e]=t,this.xa(Zi,s),this.save()}remove_event_timer(e){const t=this.props.__timers||{},s=t[e];return x(s)||(delete t[e],this.xa(Zi,t),this.save()),s}get_property(e){return this.props[e]}set_property(e,t){this.xa(e,t),this.save()}xa(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.na=!0),An(e)&&!Ye(r,t)&&this.ra.add(e),this.Ma(e,r,t),!((i=de(e))===null||i===void 0)&&i.volatile||this.Ta(e))}$a(e,t=!0){delete this.props[e],t&&(Ei(e)&&this.ga(e,!0),An(e)&&this.ra.add(e),this.Ta(e))}Ta(e){var t;const s=(t=de(e))===null||t===void 0?void 0:t.storageGroup;s&&(this.ma(s).dirty=!0)}ma(e){return this.Jo[e]||(this.Jo[e]={})}};const Se={GZipJS:"gzip-js",Base64:"base64"},Vt={Activation:"events",Cancellation:"cancelEvents"},Si={Popover:"popover",API:"api",Widget:"widget"},$e={SHOWN:"survey shown",DISMISSED:"survey dismissed",SENT:"survey sent"},Pi={SURVEY_ID:"$survey_id",SURVEY_ITERATION:"$survey_iteration",SURVEY_LAST_SEEN_DATE:"$survey_last_seen_date"},hr={Popover:"popover",Inline:"inline"};function $s(e){let t=!0;return{dispose(){if(t){t=!1;const s=e();s&&ue(s.then)&&s.then(void 0,()=>{})}}}}const Kc={SHOWN:"product tour shown"},Ln={TOUR_LAST_SEEN_DATE:"$product_tour_last_seen_date",TOUR_TYPE:"$product_tour_type"},Dn=ie("[RateLimiter]");var Jc=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=>{Dn.info(`${i||"events"} is quota limited.`),this.serverLimits[i]=new Date().getTime()+6e4})}catch(i){return void Dn.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+=(o-a.last)/1e3*n,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=(ne(a.dropped)?a.dropped:0)+1;a.dropped=u,!this.lastEventRateLimited&&this.Za(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}}Ka(e){const t=this.instance.config.property_denylist;return!A(t)||!t.includes(e)}Xa(){var e;if(this.Ka("$current_url")&&this.Ka("$pathname")&&ee?.pathname)return`${(e=ee.origin)!==null&&e!==void 0?e:""}${ee.pathname}`}Za(e){var t,s;const{captureEventsBurstLimit:i,captureEventsPerSecond:r}=this,n=this.Xa(),o=this.Ka("$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 Ze=ie("[RemoteConfig]");var vl=class{constructor(e){this._instance=e}get remoteConfig(){var e;return(e=F._POSTHOG_REMOTE_CONFIG)===null||e===void 0||(e=e[this._instance.config.token])===null||e===void 0?void 0:e.config}Ya(e){var t,s,i;!((t=F.__PosthogExtensions__)===null||t===void 0)&&t.loadExternalDependency?(s=F.__PosthogExtensions__)===null||s===void 0||(i=s.loadExternalDependency)===null||i===void 0||i.call(s,this._instance,"remote-config",()=>e(this.remoteConfig)):e()}tl(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 Ze.info("Using preloaded remote config",this.remoteConfig),void this.el(this.remoteConfig);if(this._instance.il())return void Ze.warn("Remote config is disabled. Falling back to local config.");this.Ya(e=>{if(!e)return Ze.info("No config found after loading remote JS config. Falling back to JSON."),void this.tl(t=>{this.el(t.json,t)});this.el(e)})}catch(e){Ze.error("Error loading remote config",e),this.el()}}el(e,t){!e&&t&&(t.statusCode===0?t.error||Ze.warn("Failed to fetch remote config from PostHog."):Ze.error("Failed to fetch remote config from PostHog."));try{this._instance.el(e?{ok:!0,config:e}:{ok:!1})}catch(i){Ze.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){Ze.error("Error loading feature flags",i)}}},Oe=Uint8Array,Ee=Uint16Array,Dt=Uint32Array,Nr=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]),jr=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]),Nn=new Oe([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),fl=function(e,t){for(var s=new Ee(31),i=0;31>i;++i)s[i]=t+=1<<e[i-1];var r=new Dt(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]},gl=fl(Nr,2),dr=gl[1];gl[0][28]=258,dr[258]=28;for(var jn=fl(jr,0)[1],_l=new Ee(32768),se=0;32768>se;++se){var wt=(43690&se)>>>1|(21845&se)<<1;_l[se]=((65280&(wt=(61680&(wt=(52428&wt)>>>2|(13107&wt)<<2))>>>4|(3855&wt)<<4))>>>8|(255&wt)<<8)>>>1}var ns=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]=_l[a[e[r]-1]++]>>>15-e[r];return o},gt=new Oe(288);for(se=0;144>se;++se)gt[se]=8;for(se=144;256>se;++se)gt[se]=9;for(se=256;280>se;++se)gt[se]=7;for(se=280;288>se;++se)gt[se]=8;var Xs=new Oe(32);for(se=0;32>se;++se)Xs[se]=5;var Xc=ns(gt,9),Yc=ns(Xs,5),ml=function(e){return(e/8|0)+(7&e&&1)},yl=function(e,t,s){(s==null||s>e.length)&&(s=e.length);var i=new(e instanceof Ee?Ee:e instanceof Dt?Dt:Oe)(s-t);return i.set(e.subarray(t,s)),i},Be=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},Mi=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(E,P){return E.f-P.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 v=new Ee(h+1),f=pr(s[c-1],v,0);if(f>t){i=0;var y=0,g=f-t,m=1<<g;for(n.sort(function(E,P){return v[P.s]-v[E.s]||E.f-P.f});r>i;++i){var _=n[i].s;if(t>=v[_])break;y+=m-(1<<f-v[_]),v[_]=t}for(y>>>=g;y>0;){var w=n[i].s;t>v[w]?y-=1<<t-v[w]++-1:++i}for(;i>=0&&y;--i){var $=n[i].s;v[$]==t&&(--v[$],++y)}f=t}return[new Oe(v),f]},pr=function(e,t,s){return e.s==-1?Math.max(pr(e.l,t,s+1),pr(e.r,t,s+1)):t[e.s]=s},Bn=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]},Ut=function(e,t){for(var s=0,i=0;t.length>i;++i)s+=e[i]*t[i];return s},vr=function(e,t,s){var i=s.length,r=ml(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)},qn=function(e,t,s,i,r,n,o,a,l,u,c){Be(t,c++,s),++r[256];for(var d=Mi(r,15),h=d[0],v=d[1],f=Mi(n,15),y=f[0],g=f[1],m=Bn(h),_=m[0],w=m[1],$=Bn(y),E=$[0],P=$[1],I=new Ee(19),M=0;_.length>M;++M)I[31&_[M]]++;for(M=0;E.length>M;++M)I[31&E[M]]++;for(var O=Mi(I,7),B=O[0],H=O[1],W=19;W>4&&!B[Nn[W-1]];--W);var J,T,j,D,U=u+5<<3,V=Ut(r,gt)+Ut(n,Xs)+o,re=Ut(r,h)+Ut(n,y)+o+14+3*W+Ut(I,B)+(2*I[16]+3*I[17]+7*I[18]);if(V>=U&&re>=U)return vr(t,c,e.subarray(l,l+u));if(Be(t,c,1+(V>re)),c+=2,V>re){J=ns(h,v),T=h,j=ns(y,g),D=y;var he=ns(B,H);for(Be(t,c,w-257),Be(t,c+5,P-1),Be(t,c+10,W-4),c+=14,M=0;W>M;++M)Be(t,c+3*M,B[Nn[M]]);c+=3*W;for(var oe=[_,E],Pe=0;2>Pe;++Pe){var ge=oe[Pe];for(M=0;ge.length>M;++M)Be(t,c,he[pe=31&ge[M]]),c+=B[pe],pe>15&&(Be(t,c,ge[M]>>>5&127),c+=ge[M]>>>12)}}else J=Xc,T=gt,j=Yc,D=Xs;for(M=0;a>M;++M)if(i[M]>255){var pe;zt(t,c,J[257+(pe=i[M]>>>18&31)]),c+=T[pe+257],pe>7&&(Be(t,c,i[M]>>>23&31),c+=Nr[pe]);var _e=31&i[M];zt(t,c,j[_e]),c+=D[_e],_e>3&&(zt(t,c,i[M]>>>5&8191),c+=jr[_e])}else zt(t,c,J[i[M]]),c+=T[i[M]];return zt(t,c,J[256]),c+T[256]},Zc=new Dt([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Qc=(function(){for(var e=new Dt(256),t=0;256>t;++t){for(var s=t,i=9;--i;)s=(1&s&&3988292384)^s>>>1;e[t]=s}return e})(),Oi=function(e,t,s){for(;s;++t)e[t]=s,s>>>=8};function eh(e,t){t===void 0&&(t={});var s=(function(){var d=4294967295;return{p(h){for(var v=d,f=0;h.length>f;++f)v=Qc[255&v^h[f]]^v>>>8;d=v},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,v,f,y,g){var m=d.length,_=new Oe(f+m+5*(1+Math.floor(m/7e3))+y),w=_.subarray(f,_.length-y),$=0;if(!h||8>m)for(var E=0;m>=E;E+=65535){var P=E+65535;m>P?$=vr(w,$,d.subarray(E,P)):(w[E]=g,$=vr(w,$,d.subarray(E,m)))}else{for(var I=Zc[h-1],M=I>>>13,O=8191&I,B=(1<<v)-1,H=new Ee(32768),W=new Ee(B+1),J=Math.ceil(v/3),T=2*J,j=function(oi){return(d[oi]^d[oi+1]<<J^d[oi+2]<<T)&B},D=new Dt(25e3),U=new Ee(288),V=new Ee(32),re=0,he=0,oe=(E=0,0),Pe=0,ge=0;m>E;++E){var pe=j(E),_e=32767&E,Ke=W[pe];if(H[_e]=Ke,W[pe]=_e,E>=Pe){var _t=m-E;if((re>7e3||oe>24576)&&_t>423){$=qn(d,w,0,D,U,V,he,oe,ge,E-ge,$),oe=re=he=0,ge=E;for(var xe=0;286>xe;++xe)U[xe]=0;for(xe=0;30>xe;++xe)V[xe]=0}var Ae=2,ot=0,Wl=O,Je=_e-Ke&32767;if(_t>2&&pe==j(E-Je))for(var Vl=Math.min(M,_t)-1,zl=Math.min(32767,E),Ul=Math.min(258,_t);zl>=Je&&--Wl&&_e!=Ke;){if(d[E+Ae]==d[E+Ae-Je]){for(var Xe=0;Ul>Xe&&d[E+Xe]==d[E+Xe-Je];++Xe);if(Xe>Ae){if(Ae=Xe,ot=Je,Xe>Vl)break;var Gl=Math.min(Je,Xe-2),qr=0;for(xe=0;Gl>xe;++xe){var ni=E-Je+xe+32768&32767,Hr=ni-H[ni]+32768&32767;Hr>qr&&(qr=Hr,Ke=ni)}}}Je+=(_e=Ke)-(Ke=H[_e])+32768&32767}if(ot){D[oe++]=268435456|dr[Ae]<<18|jn[ot];var Wr=31&dr[Ae],Vr=31&jn[ot];he+=Nr[Wr]+jr[Vr],++U[257+Wr],++V[Vr],Pe=E+Ae,++re}else D[oe++]=d[E],++U[d[E]]}}$=qn(d,w,g,D,U,V,he,oe,ge,E-ge,$)}return yl(_,0,f+ml($)+y)})(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 v=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&&Oi(d,4,Math.floor(new Date(h.mtime||Date.now())/1e3)),v){d[3]=8;for(var f=0;v.length>=f;++f)d[f+10]=v.charCodeAt(f)}})(u,t),Oi(u,c-8,s.d()),Oi(u,c-4,i),u}const th=!!yr||!!us,bl=new WeakMap,wl="text/plain";let Ii=0,As=!1;const xl=(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}`:""}`},ys=(e,t,s=!0)=>{var i;const[r,n]=e.split("?"),o=p({},t),a=(i=n?.split("&").map(u=>{var c;const[d,h]=u.split("="),v=s&&(c=o[d])!==null&&c!==void 0?c:h;return delete o[d],`${d}=${v}`}))!==null&&i!==void 0?i:[],l=(function(u,c="&"){let d,h;const v=[];return K(u,function(f,y){x(f)||x(y)||y==="undefined"||(d=encodeURIComponent((g=>g instanceof File)(f)?f.name:f.toString()),h=encodeURIComponent(y),v[v.length]=h+"="+d)}),v.join(c)})(o);return l&&a.push(l),a.length>0?`${r}?${a.join("&")}`:r},Fi=e=>{if(e.nl)return e.nl;const{data:t,compression:s}=e;if(!t)return;if(s===Se.GZipJS){const r=eh((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(v){a[l++]=v},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 yl(a,0,l)})(Ot(t)),{mtime:0});return{contentType:wl,body:r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength),estimatedSize:r.byteLength}}if(s===Se.Base64){const r=(function(o){return o&&btoa(encodeURIComponent(o).replace(/%([0-9A-F]{2})/g,(a,l)=>String.fromCharCode(parseInt(l,16))))})(Ot(t)),n=(o=>"data="+encodeURIComponent(typeof o=="string"?o:Ot(o)))(r);return{contentType:"application/x-www-form-urlencoded",body:n,estimatedSize:new Blob([n]).size}}const i=Ot(t);return{contentType:"application/json",body:i,estimatedSize:new Blob([i]).size}},kl=e=>{const t=()=>e.transport==="sendBeacon"?{url:ys(e.url,{compression:Se.Base64}),encodedBody:Fi(p(p({},e),{},{compression:Se.Base64,nl:void 0}))}:{url:xl(e.url,"compression"),encodedBody:Fi(p(p({},e),{},{compression:void 0,nl:void 0}))};let s;try{s=Fi(e)}catch(r){if(an(e.compression,Rt(e.url,"compression")))return S.error("Failed to gzip request body, sending uncompressed payload",r),t();throw r}return s&&an(e.compression,Rt(e.url,"compression"))&&!((i=s.body)instanceof ArrayBuffer?Xi(new Uint8Array(i)):ArrayBuffer.isView(i)&&Xi(new Uint8Array(i.buffer,i.byteOffset,i.byteLength)))?(As=!0,t()):{url:e.url,encodedBody:s};var i},El=e=>{try{return kl(e)}catch(s){var t;return S.error(s),void((t=e.callback)===null||t===void 0||t.call(e,{statusCode:0,error:s}))}},sh=(function(){var e=Z(function*(t){const s=yield(function(r){return Yi.apply(this,arguments)})(Ot(t.data),le.DEBUG,{rethrow:!0});if(!s)return t;const i=yield s.arrayBuffer();return p(p({},t),{},{nl:{contentType:wl,body:i,estimatedSize:i.byteLength}})});return function(t){return e.apply(this,arguments)}})(),ih=/Failed to fetch|NetworkError|Load failed/i,$l=e=>e?.name==="TypeError"&&ih.test(e?.message||""),Sl=e=>{try{const t=(function(s,i=Date.now()){if(typeof s!="string"||!s)return;const r=s.trim(),n=/^\d+\s*,/.test(r)?r.slice(0,r.indexOf(",")).trim():r;if(/^\d+$/.test(n)){const l=1e3*Math.min(Number(n),300);return l>0?l:void 0}if(!/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun)[a-z]*[ ,]/.test(n))return;const o=/^\w{3} \w{3} /.test(n)?n+" GMT":n,a=Date.parse(o)-i;return Number.isFinite(a)&&a>0?Math.min(a,Fs):void 0})(e());return x(t)?void 0:Math.min(t,3e4)}catch{return}},Pl=e=>{const t=El(e);if(!t)return;const s=new yr;bl.set(s,!0);const{url:i,encodedBody:r}=t;s.open(e.method||"GET",i,!0);const{contentType:n,body:o}=r??{};K(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,Sl(()=>s.getResponseHeader("Retry-After")))}},s.send(o)},Ml=e=>{const t=El(e);if(!t)return;const{url:s,encodedBody:i}=t,{contentType:r,body:n,estimatedSize:o}=i??{},a=new Headers;K(e.headers,function(f,y){a.append(y,f)}),r&&a.append("Content-Type",r);let l=null,u=!1;if(zr){const f=new zr;l={signal:f.signal,timeout:setTimeout(()=>{u=!0;try{f.abort(sa("AbortError","PostHog request timed out"+((y=e.timeout)?` after ${y}ms`:"")))}catch(g){d(g)}var y},e.timeout)}}let c=!1;const d=f=>{var y;c||(c=!0,u&&f?.name==="AbortError"||$l(f)?S.warn(f):S.error(f),(y=e.callback)===null||y===void 0||y.call(e,{statusCode:0,error:f}))};let h=0;const v=()=>{Ii-=h,h=0,l&&clearTimeout(l.timeout)};try{const f=p({method:e?.method||"GET",headers:a,referrerPolicy:"strict-origin",body:n,signal:l?.signal},e.fetchOptions),y=o??(x(n)?0:void 0);f.keepalive=f.method==="POST"&&!e.sl&&f.keepalive!==!1&&f.body===n&&!x(y)&&y>=0&&52428.8>Ii+y,f.keepalive&&(h=y,Ii+=h),us(s,f).then(g=>g.text().then(m=>{var _;if(c)return;const w={statusCode:g.status,text:m};if(g.status===200)try{w.json=JSON.parse(m)}catch($){S.error($)}c=!0,v(),(_=e.callback)===null||_===void 0||_.call(e,w,Sl(()=>g.headers.get("Retry-After")))})).catch(g=>{v(),d(g)}).finally(v)}catch(f){v(),d(f)}},fr=e=>{try{var t;const{url:s,encodedBody:i}=kl(e),{contentType:r,body:n,estimatedSize:o}=i??{};if(!n)return;const a=n instanceof Blob?n:new Blob([n],{type:r});if(ce.sendBeacon(s,a))return;const l=A(e.data)?e.data:(t=e.data)===null||t===void 0?void 0:t.batch;if(A(l)&&l.length>1&&(o??0)>16384){const u=Math.ceil(l.length/2),c=d=>A(e.data)?d:p(p({},e.data),{},{batch:d});return fr(p(p({},e),{},{data:c(l.slice(0,u))})),void fr(p(p({},e),{},{data:c(l.slice(u))}))}S.warn(`Beacon of ~${o??0} bytes was rejected by the browser, falling back to ${us?"fetch":"XHR"}`),us?Ml(p(p({},e),{},{sl:!0})):Pl(e)}catch(s){S.warn("Beacon send failed",s)}},Hn=(e,t,s,i)=>{const r=i==="query"?t==="POST"?"sent_at":"_":void 0;return ys(s===Se.GZipJS?xl(e,"compression"):e,p(p({},r?{[r]:Date.now().toString()}:{}),s===Se.GZipJS?{}:{compression:s}))},rh=(()=>{const e=[];return us&&e.push({transport:"fetch",method:Ml}),yr&&e.push({transport:"XHR",method:Pl}),ce?.sendBeacon&&e.push({transport:"sendBeacon",method:fr}),e})();let Ol=!th&&ye?.indexOf("MSIE")===-1&&ye?.indexOf("Mozilla")===-1;function Il(e,t,s){var i,r,n;s&&(t=p(p({},t),{},{callback:o=>s(o)})),e.__loaded?Ol?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=p(p({},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=p(p({},o),{},{callback:a??(g=>{var m;return(m=o.callback)===null||m===void 0?void 0:m.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=Se.Base64),d.method==="POST"&&d.data&&(d.timestampMode==="capture-body"?d.data=(g=>{var m,_;const w=(A(g)?g:[g]).map(E=>p(p({},E),E.timestamp instanceof Date&&!isNaN(E.timestamp.getTime())?{timestamp:E.timestamp.toISOString()}:{})),$=w[0];return{api_key:(m=$==null||(_=$.properties)===null||_===void 0?void 0:_.token)!==null&&m!==void 0?m:$?.token,batch:w,sent_at:new Date().toISOString()}})(d.data):d.timestampMode==="body"&&(d.data=((g,m=new Date().toISOString())=>A(g)?g.map(_=>p(p({},_),{},{sent_at:m})):p(p({},g),{},{sent_at:m}))(d.data))),d.url=Hn(d.url,d.method,d.compression,d.timestampMode);const v=rh.filter(g=>!d.disableTransport||!g.transport||!d.disableTransport.includes(g.transport)),f=(u=(c=(function(g,m){for(let _=0;g.length>_;_++)if(m(g[_]))return g[_]})(v,g=>g.transport===h))===null||c===void 0?void 0:c.method)!==null&&u!==void 0?u:v[0].method;if(!f)throw new Error("No available transport method");const y=g=>{try{f(g)}catch(_){var m;$l(_)?S.warn(_):S.error(_),(m=d.callback)===null||m===void 0||m.call(d,{statusCode:0,error:_})}};h!=="sendBeacon"&&!d.preferSyncCompression&&d.data&&d.compression===Se.GZipJS&&Kl&&typeof Promise<"u"&&!As?sh(d).then(g=>{y(g)}).catch(g=>{if(ln(g))return As=!0,void y(p(p({},d),{},{compression:void 0,url:Hn(o.url,o.method,void 0,o.timestampMode)}));(m=>{if(!m||typeof m!="object")return!1;const _="name"in m?String(m.name):"";return ln(m)||_===ua})(g)&&(As=!0),y(d)}):y(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 nh=class{constructor(e,t){this.rl=!0,this.ol=[],this.al=Ne(t?.flush_interval_ms||3e3,250,5e3,S.createLogger("flush interval"),3e3),this.ll=e}enqueue(e){this.ol.push(e),this.ul||this.hl()}unload(){this.cl();const e=this.ol.length>0?this.dl():{},t=Object.values(e);[...t.filter(s=>s.url.indexOf("/e")===0),...t.filter(s=>s.url.indexOf("/e")!==0)].map(s=>{this.vl(s,"sendBeacon")})}enable(){this.rl=!1,this.hl()}hl(){this.rl||(this.ul=setTimeout(()=>{if(this.cl(),this.ol.length>0){const e=this.dl();for(const t in e)this.vl(e[t])}},this.al))}vl(e,t){try{this.ll(e,t)}catch(s){S.error(s)}}cl(){clearTimeout(this.ul),this.ul=void 0}dl(){const e={};return K(this.ol,t=>{var s;const i=t,r=((i?i.batchKey:null)||i.url)+(i.batchGroup?`:${i.batchGroup}`:"");x(e[r])&&(e[r]=p(p({},i),{},{data:[]})),(s=e[r].data)===null||s===void 0||s.push(i.data)}),this.ol=[],e}};const oh=["retriesPerformedSoFar"];var ah=class{constructor(e){this._instance=e,this.fl=!1,this.pl=3e3,this.ol=[],this.ol=[],this.gl=!0,this.resume()}resume(){if(!x(b)&&"onLine"in b.navigator){if(this.gl=b.navigator.onLine,this.ml)return;this.ml=()=>{this.gl=!0,this.yl()},this.bl=()=>{this.gl=!1},z(b,"online",this.ml),z(b,"offline",this.bl)}}get length(){return this.ol.length}retriableRequest(e,t){let{retriesPerformedSoFar:s}=e,i=ca(e,oh);He(s)&&(i.url=ys(i.url,{retry_count:s})),Il(this._instance,t?p(p({},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(p({retriesPerformedSoFar:s},i),n);r.statusCode===0&&S.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.ol.push({retryAt:r,requestOptions:e});let n=`Enqueued failed request for retry in ${i}`;navigator.onLine||(n+=" (Browser is offline)"),S.warn(n),this.fl||(this.fl=!0,this._l())}_l(){if(this.wl&&clearTimeout(this.wl),this.ol.length===0)return this.fl=!1,void(this.wl=void 0);this.wl=setTimeout(()=>{this.gl&&this.ol.length>0&&this.yl(),this._l()},this.pl)}yl(){const e=Date.now(),t=[],s=this.ol.filter(i=>e>i.retryAt||(t.push(i),!1));if(this.ol=t,s.length>0)for(const{requestOptions:i}of s)this.retriableRequest(i)}unload(){this.wl&&(clearTimeout(this.wl),this.wl=void 0),this.fl=!1,x(b)||(this.ml&&(b.removeEventListener("online",this.ml),this.ml=void 0),this.bl&&(b.removeEventListener("offline",this.bl),this.bl=void 0));for(const{requestOptions:e}of this.ol)try{this._instance._send_request(p(p({},e),{},{transport:"sendBeacon"}))}catch(t){S.error(t)}this.ol=[]}},lh=class{constructor(e){this._instance=e,this.kl=()=>{var t,s,i,r;this.Sl||(this.Sl={});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.Sl.lastScrollY=Math.ceil(o),this.Sl.maxScrollY=Math.max(o,(t=this.Sl.maxScrollY)!==null&&t!==void 0?t:0),this.Sl.maxScrollHeight=Math.max(a,(s=this.Sl.maxScrollHeight)!==null&&s!==void 0?s:0),this.Sl.lastContentY=l,this.Sl.maxContentY=Math.max(l,(i=this.Sl.maxContentY)!==null&&i!==void 0?i:0),this.Sl.maxContentHeight=Math.max(u,(r=this.Sl.maxContentHeight)!==null&&r!==void 0?r:0)}}get xl(){return this._instance.config.scroll_root_selector}getContext(){return this.Sl}resetContext(){const e=this.Sl;return this.Sl=void 0,setTimeout(this.kl,0),e}startMeasuringScrollPosition(){z(b,"scroll",this.kl,{capture:!0}),z(b,"scrollend",this.kl,{capture:!0}),z(b,"resize",this.kl)}scrollElement(){if(this.xl){const s=A(this.xl)?this.xl:[this.xl];for(const i of s){var e;const r=b==null||(e=b.document)===null||e===void 0?void 0:e.querySelector(i);if(r)return r}return}var t;return b==null||(t=b.document)===null||t===void 0?void 0:t.documentElement}$l(e){var t,s;const i=e==="y"?"scrollTop":"scrollLeft";if(this.xl){const r=this.scrollElement();return r&&r[i]||0}return b?e==="y"?b.scrollY||b.pageYOffset||((t=b.document)===null||t===void 0||(t=t.documentElement)===null||t===void 0?void 0:t.scrollTop)||0:b.scrollX||b.pageXOffset||((s=b.document)===null||s===void 0||(s=s.documentElement)===null||s===void 0?void 0:s.scrollLeft)||0:0}scrollY(){return this.$l("y")}scrollX(){return this.$l("x")}};const uh=e=>cl(e?.config.mask_personal_data_properties,e?.config.custom_personal_data_properties,e?.config.disable_capture_url_hashes);var Wn=class{constructor(e,t,s,i){this.qe=r=>{const n=this.Cl();if(n&&n.sessionId===r)return;const o={sessionId:r,props:this.Tl(this._instance)};this.Il.register({[nr]:o})},this._instance=e,this.Ml=t,this.Il=s,this.Tl=i||uh,this.Ml.onSessionId(this.qe)}Cl(){return this.Il.props[nr]}getSetOnceProps(){var e;const t=(e=this.Cl())===null||e===void 0?void 0:e.props;return t?"r"in t?hl(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 K(Cr(this.getSetOnceProps()),(t,s)=>{s==="$current_url"&&(s="url"),e[`$session_entry_${Vi(s)}`]=t}),e}},Ys=class{on(e,t){return this.El[e]||(this.El[e]=[]),this.El[e].push(t),()=>{this.El[e]=this.El[e].filter(s=>s!==t)}}emit(e,t){for(const s of this.El[e]||[])s(t);for(const s of this.El["*"]||[])s(e,t)}constructor(){this.El={}}};const xt=ie("[SessionId]"),Vn=864e5;var zn=class{on(e,t){return this.Pl.on(e,t)}constructor(e,t,s){var i;if(this.Rl=null,this.Al=null,this.Ol=[],this.Fl=void 0,this.Dl=!1,this.Pl=new Ys,this.Ll=(n,o)=>!(!He(n)||!He(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.Mr=e.config,this.Il=e.persistence,this.je=void 0,this.Xt=void 0,this._sessionStartTimestamp=null,this.Nl=void 0,this._sessionActivityTimestamp=null,this.ql=t||Ce,this.jl=s||Ce;const r=this.Mr.persistence_name||this.Mr.token;if(this._sessionTimeoutMs=1e3*Ne(this.Mr.session_idle_timeout_seconds||1800,60,36e3,xt.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.Bl(),this.Hl="ph_"+r+"_window_id",this.zl="ph_"+r+"_primary_window_exists",this.Ul()){const n=X.Lt(this.Hl),o=X.Lt(this.zl);n&&!o?this.je=n:X.Pt(this.Hl),X.$t(this.zl,!0)}!((i=this.Mr.bootstrap)===null||i===void 0)&&i.sessionID&&this.setBootstrapSessionId(this.Mr.bootstrap.sessionID),this.Wl()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return x(this.Ol)&&(this.Ol=[]),this.Ol.push(e),this.Xt&&e(this.Xt,this.je),()=>{this.Ol=this.Ol.filter(t=>t!==e)}}Ul(){return this.Mr.persistence!=="memory"&&!this.Il.hi&&X.Et()}Vl(e){e!==this.je&&(this.je=e,this.Ul()&&X.$t(this.Hl,e))}Gl(){return this.je?this.je:this.Ul()?X.Lt(this.Hl):null}Ql(e){const t=this.Rl;return!te(t)&&!te(e)&&5e3>Math.abs(e-t)}Jl(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.Ql(t)||(this.Rl=t,this.Il.register({[St]:[t,e,s]}))}Zl(){var e;const t=(e=this.Mr)===null||e===void 0?void 0:e.persistence_save_debounce_ms;return He(t)&&t>0}Kl(){this.Zl()?this.Il.refreshKey(St):(this.Il.flush(),this.Il.load())}Xl(){var e;if(te(this._sessionActivityTimestamp)||this._sessionActivityTimestamp===this.Rl)return;this.Kl();const[,t,s]=this.Yl();t===this.Xt&&s===this._sessionStartTimestamp&&(this.Rl=this._sessionActivityTimestamp,this.Il.register({[St]:[this._sessionActivityTimestamp,(e=this.Xt)!==null&&e!==void 0?e:null,this._sessionStartTimestamp]}),this.Il.flush())}tu(){const[e]=this.Yl(),t=He(e)?e:0,s=He(this._sessionActivityTimestamp)?this._sessionActivityTimestamp:0;return Math.max(t,s)}eu(e){return this.Kl(),this.Ll(e,this.tu())}Yl(){const e=this.Il.props[St];return A(e)&&e.length===2&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this.Rl=null,this.Nl=void 0,clearTimeout(this.iu),this.iu=void 0,this.Jl(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 xt.error("Bootstrap sessionID cannot be in the future"):n}catch(n){return void xt.error("Invalid sessionID in bootstrap",n)}})(e);return!x(s)&&(t?this.Nl={sessionId:e,sessionStartTimestamp:s}:this.Jl(e,new Date().getTime(),s),!0)}destroy(){this.Dl=!0,this.Xl(),clearTimeout(this.iu),this.iu=void 0,this.Fl&&b&&(b.removeEventListener(Us,this.Fl,{capture:!1}),this.Fl=void 0),this.Ol=[]}Wl(){this.Fl=()=>{this.Xl(),this.Ul()&&X.Pt(this.zl)},z(b,Us,this.Fl,{capture:!1})}checkAndGetSessionAndWindowId(e=!1,t=null,s=!1){if(this.Mr.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.Al=i;else if(te(this.Al)||this.Al>i||i-this.Al>=1e3){var n,o;(n=(o=this.Il).syncCookieProperties)===null||n===void 0||n.call(o),this.Al=i}let[,a,l]=this.Yl();const u=!x(r)&&a!==r,c=this.tu();let d=this.Gl();const h=this.Nl,v=!!h&&(h.sessionStartTimestamp>i+6e4||i-h.sessionStartTimestamp>Vn),f=h?v:He(l)&&Math.abs(i-l)>Vn;let y=!1,g=u,m=!a||!!h;const _=a;let w=!m&&!e&&this.Ll(i,c);if(w&&(w=this.eu(i),w||xt.info("cross-tab refresh kept the session alive",{sessionId:a}),[,a,l]=this.Yl(),w||(m=!a||!!h)),m||w||f){g=!1;const I=h&&!v;a=I?h.sessionId:this.ql(),d=this.jl(),xt.info("new session ID assigned",{sessionId:a,windowId:d,bootstrapped:!!I,changeReason:{noSessionId:m,activityTimeout:w,sessionPastMaximumLength:f}}),l=I?h.sessionStartTimestamp:i,this.Nl=void 0,y=!0}else d||(d=this.jl(),y=!0),g=g||a!==_,g&&(xt.info("adopted cross-tab session id",{sessionId:a,windowId:d}),y=!0);const $=He(c)&&e&&!f?c:i,E=He(l)?l:new Date().getTime();this.Vl(d),this.Jl(a,$,E),e||this.Bl();const P={noSessionId:m,activityTimeout:w,sessionPastMaximumLength:f,crossTabAdoption:g};return y&&this.Ol.forEach(I=>I(a,d,P)),{sessionId:a,windowId:d,sessionStartTimestamp:E,changeReason:y?P:void 0,lastActivityTimestamp:c}}Bl(){this.Dl||(clearTimeout(this.iu),this.iu=setTimeout(()=>{if(!this.Dl)if(this.eu(new Date().getTime())){const e=this.Xt;this.resetSessionId(),this.Pl.emit("forcedIdleReset",{idleSessionId:e})}else this.Bl()},1.1*this.sessionTimeoutMs))}};const Fl=function(e,t){if(!e)return!1;const s=e.userAgent;if(s&&Gr(s,t))return!0;try{const i=e?.userAgentData;if(i?.brands&&i.brands.some(r=>Gr(r?.brand,t)))return!0}catch{}return!!e.webdriver};function Tl(){return(Tl=Z(function*(){const e=ce?.userAgentData;if(e?.getHighEntropyValues)try{const t=yield e.getHighEntropyValues(["model"]),s=t?.model;return L(s)&&s.length>0?s:void 0}catch(t){return void S.info("Unable to resolve $device_model from userAgentData.getHighEntropyValues",t)}})).apply(this,arguments)}function ch(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 Cl(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 Zs=(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}},Ss=e=>e.toLowerCase(),Al={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=>Zs(s,i))),not_regex:(e,t)=>t.every(s=>e.every(i=>!Zs(s,i))),icontains:(e,t)=>t.map(Ss).some(s=>e.map(Ss).some(i=>s.includes(i))),not_icontains:(e,t)=>t.map(Ss).every(s=>e.map(Ss).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 Rl(e,t){return!e||Object.entries(e).every(([s,i])=>{const r=t?.[s];if(r==null)return!1;const n=Al[i.operator];return!!n&&n(i.values.map(String),[String(r)])})}function Ti(e,t,s){return Ot({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:s})}const gr="custom",Un="i.posthog.com",hh=/^\/static\//,dh=["/s/","/e/","/i/"];var ph=class{constructor(e){this.nu={},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(`.${Un}`,".posthog.com")),t==="https://app.posthog.com"?"https://us.posthog.com":t}get region(){return this.nu[this.apiHost]||(this.nu[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":gr),this.nu[this.apiHost]}su(e){if(!hh.test(e))return;const t=this.instance.config.asset_host;return typeof t=="string"&&t.trim().replace(/\/$/,"")||void 0}ru(e){const t=Ge(e);return t?t.protocol+"//"+t.host+t.pathname:void 0}ou(e,t,s){if(e==="ui")return s;let i=s;const r=this.instance.config.rewriteRequestPath;if(r){var n;const o=((n=Ge(s))===null||n===void 0?void 0:n.href)||s;i=r(new URL(o)).toString()}if(r&&e==="api"&&dh.some(o=>t.indexOf(o)===0)){const o=this.ru(i);if(o){const a=this.apiHost;let l=this.au;l?.apiHost===a&&l.rewriteRequestPath===r||(l={apiHost:a,rewriteRequestPath:r,urls:new Set},this.au=l),l.urls.add(o)}}return i}isIngestionEndpoint(e){const t=this.au,s=this.ru(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.ou(e,t,this.uiHost+t);if(e==="flags")return this.ou(e,t,this.flagsApiHost+t);if(e==="assets"){const i=this.su(t);if(i)return this.ou(e,t,`${i}${t}`)}if(this.region===gr)return this.ou(e,t,this.apiHost+t);const s=Un+t;switch(e){case"assets":return this.ou(e,t,`https://${this.region}-assets.${s}`);case"api":return this.ou(e,t,`https://${this.region}.${s}`)}}};const G=ie("[Surveys]"),Ll=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)}},vh=[Si.Popover,Si.Widget,Si.API],fh={ignoreConditions:!1,ignoreDelay:!1,displayType:hr.Popover},gh=ie("[PostHog ExternalIntegrations]"),_h={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};var mh=class{constructor(e){this._instance=e}Ho(e,t){var s,i;(s=F.__PosthogExtensions__)===null||s===void 0||(i=s.loadExternalDependency)===null||i===void 0||i.call(s,this._instance,e,r=>{if(r)return gh.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=F.__PosthogExtensions__)===null||t===void 0||(t=t.integrations)===null||t===void 0)&&t[r])&&this.Ho(_h[r],()=>{var o;(o=F.__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=F.__PosthogExtensions__)===null||s===void 0||(s=s.integrations)===null||s===void 0)&&s[r])&&((i=F.__PosthogExtensions__)===null||i===void 0||(i=i.integrations)===null||i===void 0||(i=i[r])===null||i===void 0||i.stop())}}},yh=class{constructor(e,t){this.A=e,this.bo=t,this.lu=new Map,this.To=!1}add(e){var t=this;return Z(function*(){if(t.To)throw new Error("Cannot add an extension to a disposed ExtensionRuntime");if(t.lu.has(e.name))throw new Error(`Browser extension "${e.name}" is already registered`);t.lu.set(e.name,e);try{const s=e.setup(t.bo);s&&(yield s)}catch(s){const i=t.lu.get(e.name)===e;i&&t.lu.delete(e.name),t.A.error(`Failed to set up browser extension "${e.name}"`,s),i&&t.uu(e)}})()}getExtension(e){return this.lu.get(e)}dispose(){if(this.To)return;this.To=!0;const e=Array.from(this.lu.values()).reverse();this.lu.clear();for(const t of e)this.uu(t)}uu(e){try{var t;const s=(t=e.dispose)===null||t===void 0?void 0:t.call(e);s&&ue(s.then)&&s.then(void 0,i=>{this.A.error(`Failed to dispose browser extension "${e.name}"`,i)})}catch(s){this.A.error(`Failed to dispose browser extension "${e.name}"`,s)}}},bh=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)}};const Gn="extensionsRemoteConfig";var wh=class{constructor(e){this.instance=e,this.To=!1,this.A=S,this.hu=e.cu,this.kv=new bh(e),this.onEvent=t=>$s(this.instance.on("eventCaptured",s=>{try{t({event:s.event,properties:s.properties})}catch(i){this.A.error("Browser extension event listener failed",i)}})),this.onRemoteConfig=t=>{if(this.To)return $s(()=>{});const s=r=>{try{t(r)}catch(n){this.A.error("Browser extension remote config listener failed",n)}},i=this.instance.du.on(Gn,s);return this.hu&&s(this.hu),$s(i)},this.vu=new yh(S.createLogger("[BrowserExtensions]"),this)}get logger(){return this.A}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($r);return typeof e=="string"?e:void 0}get library(){return{name:le.LIB_NAME,version:le.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;const r=(e=this.instance.sessionManager)===null||e===void 0?void 0:e.checkAndGetSessionAndWindowId(!0);return{sessionId:(t=r?.sessionId)!==null&&t!==void 0?t:"",windowId:(s=r?.windowId)!==null&&s!==void 0?s:"",sessionStartTimestamp:(i=r?.sessionStartTimestamp)!==null&&i!==void 0?i:0}}catch{return{sessionId:"",windowId:"",sessionStartTimestamp:0}}}get canCapture(){return this.instance.is_capturing()}get projectToken(){return this.instance.config.token}add(e){return this.vu.add(e)}getExtension(e){return this.vu.getExtension(e)}capture(e,t,s){s?this.instance.capture(e,t,{timestamp:s.timestamp,uuid:s.uuid,$set:s.set,$set_once:s.setOnce}):this.instance.capture(e,t)}registerDynamicEventProperties(e){return $s(this.instance.fu(e))}handleRemoteConfig(e){this.To||(this.hu=e,this.instance.du.emit(Gn,e))}sendRequest(e){var t=this;return Z(function*(s,i={}){var r;const n=t.instance.requestRouter.endpointFor((r=i.target)!==null&&r!==void 0?r:"api",s),o={method:i.method,url:i.query?ys(n,i.query):n,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"?Wi.Base64:void 0,timestampMode:i.sentAt};return i.transport==="sendBeacon"?(t.instance._send_request(o),{statusCode:202}):new Promise(a=>{o.callback=a,t.instance._send_request(o)})}).apply(this,arguments)}dispose(){this.To||(this.To=!0,this.vu.dispose())}};const os={};let Ci=0;const as=()=>{},Kn='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',kt="Surveys module not available",Jn="sanitize_properties is deprecated. Use before_send instead",Dl="Invalid value for property_denylist config: ",xh=["$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"],kh=["$feature_flag_called","$$heatmap","$snapshot"],Xn=e=>e.charAt(0)==="$"&&!C(kh,e),Eh=/^[A-Za-z0-9_-]{1,400}$/,Yn=/^fb\.[0-9]+\.[0-9]+\.[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)?$/,Zn=/^fb\.[0-9]+\.[0-9]+\.[0-9]+$/,$h=["token","distinct_id",Ta],Xt="posthog",Sh=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},Ai=e=>{var t;return p({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,asset_host:null,token:"",autocapture:!0,cross_subdomain_cookie:kc(k?.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:as,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_external_dependency_versioned_paths:!1,__preview_cookie_wins_on_conflict:!1,debug:ee&&L(ee?.search)&&ee.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:(b==null||(t=b.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){S.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:Ha,before_send:void 0,get_current_url:void 0,request_queue_config:{flush_interval_ms:3e3},error_tracking:{},_onCapture:as},(s=>({rageclick:s&&s>="2026-05-30"?{content_ignorelist:Fc,ignore_text_selection:!0}:!s||"2025-11-30">s||{content_ignorelist:!0},capture_pageview:!s||"2025-05-24">s||"history_change",session_recording:Sh(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))},Ph=[["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"]],Qn=e=>{const t={};for(const[r,n]of Ph)x(e[r])||(t[n]=e[r]);const s=Y({},t,e),i=e.__preview_external_dependency_versioned_paths;return x(i)||(x(e.strict_script_versioning)&&(s.strict_script_versioning=!!i),L(i)&&x(e.asset_host)&&(s.asset_host=i)),A(e.property_blacklist)&&(x(e.property_denylist)?s.property_denylist=e.property_blacklist:A(e.property_denylist)?s.property_denylist=[...e.property_blacklist,...e.property_denylist]:S.error(Dl+e.property_denylist)),s};var Mh=class{constructor(){this.__forceAllowLocalhost=!1}get pu(){return this.__forceAllowLocalhost}set pu(e){S.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}},ls=class Qe{gu(t){if(!t)return;const s=this.lu.indexOf(t);s!==-1&&this.lu.splice(s,1)}mu(t,s){var i;return this.gu(t),this.lu.push(s),(i=s.initialize)===null||i===void 0||i.call(s),s}yu(){return this.config.cookieless_mode==="always"||this.config.cookieless_mode==="on_reject"&&this.consent.isRejected()}bu(){if(this._u||this.config.reuseAnonymousId||this.config.segment||this.yu())return;const t=this.config.persistence==="memory"||this.config.persistence==="sessionStorage";if(!t&&!this.config.disable_persistence||this.wu)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._u=!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}`)}ku(){const t=this.persistence;if(!t||this.Su)return;if(this.yu())return void(this.config.cookieless_mode==="on_reject"&&this.get_distinct_id()!=="$posthog_cookieless"&&(this.xu(),this.$u()));if(this.get_distinct_id()!=="$posthog_cookieless")return;this.Cu()||t.load(!0);const s=this.get_distinct_id();if(!s||s==="$posthog_cookieless"){const i=this.config.get_device_id(Ce());this.register({distinct_id:i,$device_id:i}),t.set_property(be,ze)}this.xu()}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.Tu=!1,this.Iu=!1,this.webPerformance=new Mh,this.Mu=!1,this.version=le.LIB_VERSION,this.Eu=new Set,this.Pu="",this.du=new Ys,this.lu=[],this.Ru=[],this.Au=!1,this.wu=!1,this._u=!1,this.Su=!1,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=Ai(),this.SentryIntegration=jc,this.sentryIntegration=i=>(function(r,n){const o=sl(r,n);return{name:tl,processEvent:a=>o(a)}})(this,i),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.Ou=!1,this.Fu=null,this.Du=null,this.Lu=null,this.scrollManager=new lh(this),this.pageViewManager=new Cn(this),this.rateLimiter=new Jc(this),this.requestRouter=new ph(this),this.consent=new Ic(this),this.externalIntegrations=new mh(this);const s=(t=Qe.__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=L(i)?{[i]:r}:i;this.setPersonProperties(o),n?.({})},set_once:(i,r,n)=>{const o=L(i)?{[i]:r}:i;this.setPersonProperties(void 0,o),n?.({})}},this.on("eventCaptured",i=>S.info(`send "${i?.event}"`,i))}init(t,s,i){if(i&&i!==Xt){var r;const n=(r=os[i])!==null&&r!==void 0?r:new Qe;return n._init(t,s,i),os[i]=n,os[Xt][i]=n,n}return this._init(t,s,i)}_init(t,s={},i){var r,n,o;const a=L(t)?t.trim():"";if(!a)return S.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=Ai(s.defaults),s.debug=this.Nu(s.debug),this.qu=s,this.ju=[],s.person_profiles?this.Du=s.person_profiles:s.process_person&&(this.Du=s.process_person);const u=Ai(s.defaults),c=Qn(s),d=Y({},u,c,{name:i,token:a});N(u.rageclick)&&N(c.rageclick)&&(d.rageclick=Y({},u.rageclick,c.rageclick)),N(u.session_recording)&&N(c.session_recording)&&(d.session_recording=Y({},u.session_recording,c.session_recording)),this.set_config(d),this.config.on_xhr_error&&S.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=s.disable_compression?void 0:Se.GZipJS;const h=this.Cu(),v=!this.yu();if(this.persistence=new $i(this.config,h,!0,v),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new $i(p(p({},this.config),{},{persistence:"sessionStorage"}),h,!1,v),this.Pu="ph_"+(this.config.persistence_name||this.config.token)+"_session_registered_properties",this.config.persistence!=="memory"&&!h&&X.Et()){const _=X.Lt(this.Pu);A(_)&&_.forEach(w=>{L(w)&&this.Eu.add(w)})}else X.Pt(this.Pu);const f=p({},this.persistence.props),y=p({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.Bu=new nh((_,w)=>this.Hu(_,w),this.config.request_queue_config),this.zu=new ah(this),this.__request_queue=[];const g=this.yu();g||(this.sessionManager=new zn(this),this.sessionPropsManager=new Wn(this,this.sessionManager,this.persistence),this.sessionManager.onSessionId((_,w,$)=>{($?.activityTimeout||$?.sessionPastMaximumLength||$?.crossTabAdoption)&&this.Uu()})),this.Wu(),this.config.__preview_deferred_init_extensions?(S.info("Deferring extension initialization to improve startup performance"),setTimeout(()=>{this.Vu(g)},0)):(S.info("Initializing extensions synchronously"),this.Vu(g)),le.DEBUG=le.DEBUG||this.config.debug,le.DEBUG&&S.info("Starting in debug mode",{this:this,config:s,thisC:p({},this.config),p:f,s:y}),this.config.identity_distinct_id&&!(!((r=s.bootstrap)===null||r===void 0)&&r.distinctID)&&(s.bootstrap=p(p({},s.bootstrap),{},{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0}));const m=(n=s.bootstrap)===null||n===void 0?void 0:n.distinctID;if(this.wu=!!m&&!Yt(m),(o=s.bootstrap)===null||o===void 0?void 0:o.distinctID){const _=s.bootstrap.distinctID,w=this.get_distinct_id(),$=this.persistence.get_property(be);if(s.bootstrap.isIdentifiedID&&w!=null&&w!==_&&$==="anonymous")this.identify(_);else if(s.bootstrap.isIdentifiedID&&w!=null&&w!==_&&$==="identified")S.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 E=this.config.get_device_id(Ce()),P=s.bootstrap.isIdentifiedID?E:_;this.persistence.set_property(be,s.bootstrap.isIdentifiedID?Ts:ze),this.register({distinct_id:_,$device_id:P})}}if(g)this.register_once({distinct_id:_i,$device_id:null},"");else if(!this.get_distinct_id()){const _=this.config.get_device_id(Ce());this.register_once({distinct_id:_,$device_id:_},""),this.persistence.set_property(be,ze)}return z(b,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),z(b,"pageshow",()=>{var _;this.Tu=!1,this.Iu||(_=this.zu)===null||_===void 0||_.resume()}),s.segment?Tn(this,()=>this.Gu()):this.Gu(),ue(this.config._onCapture)&&this.config._onCapture!==as&&(S.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",_=>this.config._onCapture(_.event,_))),this.config.ip&&S.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 Tl.apply(this,arguments)})().then(_=>{_&&this.register({[gi]:_})}).catch(as),this}Qu(t){const s=t;return L(s.name)&&ue(s.setup)}Ju(t,s){this.Qu(t)?s.push(()=>{this.Zu().add(t).catch(()=>{var i;return(i=t.dispose)===null||i===void 0?void 0:i.call(t)}).catch(i=>{S.error(`Failed to dispose browser extension "${t.name}"`,i)})}):this.lu.push(t)}Wu(){var t,s,i;const r=(t=(s=this.config.__extensionClasses)===null||s===void 0?void 0:s.featureFlags)!==null&&t!==void 0?t:(i=Qe.__defaultExtensionClasses)===null||i===void 0?void 0:i.featureFlags;var n,o,a;r&&(this.featureFlags&&this.featureFlags instanceof r||((n=this.Ku)===null||n===void 0||n.call(this),this.Ku=void 0,this.featureFlags=new r(this)),ue(this.featureFlags.onReloading)&&ue(this.featureFlags.setup)?this.Ku||(this.Ku=this.featureFlags.onReloading(()=>{this.du.emit("featureFlagsReloading",!0)}),this.Zu().add(this.featureFlags)):(o=(a=this.featureFlags).initialize)===null||o===void 0||o.call(a))}Vu(t){const s=performance.now(),i=p(p({},Qe.__defaultExtensionClasses),this.config.__extensionClasses),r=[];var n,o,a,l,u,c,d;i.exceptions&&this.lu.push(this.exceptions=(n=this.exceptions)!==null&&n!==void 0?n:new i.exceptions(this)),i.historyAutocapture&&this.lu.push(this.historyAutocapture=new i.historyAutocapture(this)),i.tracingHeaders&&this.lu.push(this.tracingHeaders=new i.tracingHeaders(this)),i.siteApps&&this.lu.push(this.siteApps=new i.siteApps(this)),i.sessionRecording&&!t&&this.lu.push(this.sessionRecording=new i.sessionRecording(this)),this.config.disable_scroll_properties||r.push(()=>{this.scrollManager.startMeasuringScrollPosition()}),i.autocapture&&this.Ju(this.autocapture=new i.autocapture(this),r),i.surveys&&this.Ju(this.surveys=(o=this.surveys)!==null&&o!==void 0?o:new i.surveys(this),r),i.logs&&this.Ju(this.logs=(a=this.logs)!==null&&a!==void 0?a:new i.logs(this),r),i.metrics&&this.lu.push(this.metrics=(l=this.metrics)!==null&&l!==void 0?l:new i.metrics(this)),i.conversations&&this.lu.push(this.conversations=(u=this.conversations)!==null&&u!==void 0?u:new i.conversations(this)),i.productTours&&this.lu.push(this.productTours=new i.productTours(this)),i.heatmaps&&this.lu.push(this.heatmaps=new i.heatmaps(this)),i.webVitalsAutocapture&&this.lu.push(this.webVitalsAutocapture=new i.webVitalsAutocapture(this)),i.exceptionObserver&&this.lu.push(this.exceptionObserver=new i.exceptionObserver(this)),i.deadClicksAutocapture&&this.lu.push(this.deadClicksAutocapture=new i.deadClicksAutocapture(this,Nc)),i.toolbar&&this.lu.push(this.toolbar=(c=this.toolbar)!==null&&c!==void 0?c:new i.toolbar(this)),i.experiments&&this.lu.push(this.experiments=(d=this.experiments)!==null&&d!==void 0?d:new i.experiments(this)),this.lu.forEach(h=>{h.initialize&&r.push(()=>{var v;(v=h.initialize)===null||v===void 0||v.call(h)})}),r.push(()=>{if(this.Xu){const h=this.Xu;this.Xu=void 0,this.lu.forEach(v=>{var f;return(f=v.onRemoteConfig)===null||f===void 0?void 0:f.call(v,h)})}}),this.Yu(r,s)}Yu(t,s){for(;t.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-s>=30&&t.length>0)return void setTimeout(()=>{this.Yu(t,s)},0);const r=t.shift();if(r)try{r()}catch(n){S.error("Error initializing extension:",n)}}const i=Math.round(performance.now()-s);this.register_for_session({[Ca]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[Aa]:i}),this.config.__preview_deferred_init_extensions&&S.info(`PostHog extensions initialized (${i}ms)`)}el(t){var s;if(!k||!k.body)return S.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout(()=>{this.el(t)},500);if(this.config.__preview_deferred_init_extensions&&(this.Xu=t),this.cu=t,this.compression=void 0,t.ok){var i;const r=t.config;r.supportedCompression&&!this.config.disable_compression&&(this.compression=C(r.supportedCompression,Se.GZipJS)?Se.GZipJS:C(r.supportedCompression,Se.Base64)?Se.Base64:void 0),!((i=r.analytics)===null||i===void 0)&&i.endpoint&&(this.analyticsDefaultEndpoint=r.analytics.endpoint)}this.set_config({person_profiles:this.Du?this.Du:Ha}),(s=this.th)===null||s===void 0||s.handleRemoteConfig(t),this.lu.forEach(r=>{var n;return(n=r.onRemoteConfig)===null||n===void 0?void 0:n.call(r,t)})}Gu(){try{this.config.loaded(this)}catch(t){S.critical("`loaded` function failed",t)}if(this.eh(),this.config.internal_or_test_user_hostname&&ee?.hostname){const t=ee.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.yu())&&this.ih()},1),this.nh=new vl(this),this.nh.load()}eh(){var t;this.is_capturing()&&this.config.request_batching&&((t=this.Bu)===null||t===void 0||t.enable())}_dom_loaded(){this.is_capturing()&&Mt(this.__request_queue,t=>this.Hu(t)),this.__request_queue=[],this.eh()}_handle_unload(){var t,s,i,r,n,o;this.Tu=!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.sh()&&this.capture(gn),(r=this.logs)===null||r===void 0||r.flushLogs("sendBeacon"),(n=this.Bu)===null||n===void 0||n.unload(),(o=this.zu)===null||o===void 0||o.unload()):this.sh()&&this.capture(gn,null,{transport:"sendBeacon"})}_send_request(t){Il(this,t)}Hu(t,s){this.zu?this.zu.retriableRequest(t,s):this._send_request(s?p(p({},t),{},{transport:s}):t)}_execute_array(t){Ci++;try{let s;const i=[],r=[],n=[];Mt(t,a=>{if(a)if(s=a[0],A(s))n.push(a);else if(ue(a))try{a.call(this)}catch(l){S.error("Error executing queued PostHog call",a,l)}else A(a)&&s==="alias"?i.push(a):A(a)&&s.indexOf("capture")!==-1&&ue(this[s])?n.push(a):r.push(a)});const o=function(a,l){Mt(a,function(u){try{if(A(u[0])){let c=l;K(u,function(d){c=c[d[0]].apply(c,d.slice(1))})}else l[u[0]].apply(l,u.slice(1))}catch(c){S.error("Error executing queued PostHog call",u,c)}})};o(i,this),o(r,this),o(n,this)}finally{Ci--}}push(t){if(Ci>0&&A(t)&&L(t[0])){const s=Qe.prototype[t[0]];return void(ue(s)&&s.apply(this,t.slice(1)))}this._execute_array([t])}get rh(){return{property:vn,persistenceKey:Ft,cookieName:"_fbc",pattern:Yn,register:(t,s)=>{var i;return(i=this.persistence)===null||i===void 0?void 0:i.register({[Ft]:{value:t,delivered:s}})},unregister:()=>{var t;return(t=this.persistence)===null||t===void 0?void 0:t.unregister(Ft)}}}get oh(){return{property:fn,persistenceKey:Qt,cookieName:"_fbp",pattern:Zn,register:(t,s)=>{var i;return(i=this.persistence)===null||i===void 0?void 0:i.register({[Qt]:{value:t,delivered:s}})},unregister:()=>{var t;return(t=this.persistence)===null||t===void 0?void 0:t.unregister(Qt)}}}ah(t){var s;const i=(s=this.persistence)===null||s===void 0?void 0:s.get_property(t.persistenceKey);return L(i)&&t.pattern.test(i)?{value:i,delivered:!1}:N(i)&&L(i.value)&&t.pattern.test(i.value)?{value:i.value,delivered:i.delivered===!0}:void 0}uh(t,s,i){return s===i?.value?{value:s,pending:!i.delivered}:(t.register(s,!1),{value:s,pending:!0})}hh(t){if(!this.config.save_campaign_params||this.yu())return;const s=ss(t.cookieName);return L(s)&&t.pattern.test(s)?s:void 0}dh(t,s,i,r){if(!this.persistence)return;const n=this.rh;this.persistence.refreshKey(n.persistenceKey);const o=this.ah(n);if(r)return void n.unregister();if(i)return L(s)&&Yn.test(s)?this.uh(n,s,o):void n.unregister();const a=L(t)&&Eh.test(t)?t:void 0,l=this.hh(n);return l&&((u,c,d)=>{const h=u.split(".");if(c)return h[3]===c;if(!d)return!0;const v=d.value.split(".");return h[3]===v[3]||Number(h[2])>Number(v[2])})(l,a,o)?this.uh(n,l,o):a?o?.value.split(".")[3]===a?{value:o.value,pending:!o.delivered}:this.uh(n,`fb.1.${Date.now()}.${a}`,o):o?{value:o.value,pending:!o.delivered}:void 0}fh(t,s,i){if(!this.persistence)return;const r=this.oh;this.persistence.refreshKey(r.persistenceKey);const n=this.ah(r);if(i)return void r.unregister();if(s)return L(t)&&Zn.test(t)?this.uh(r,t,n):void r.unregister();const o=this.hh(r);return o?this.uh(r,o,n):n?{value:n.value,pending:!n.delivered}:void 0}ph(t,s){if(!this.persistence)return;this.persistence.refreshKey(t.persistenceKey);const i=this.ah(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.Bu))return void S.uninitializedWarning("posthog.capture");if(!this.is_capturing())return;if(x(t)||!L(t))return void S.error("No event name provided to posthog.capture");if(this.ku(),t==="$snapshot"&&this.yu())return;const o=!this.config.opt_out_useragent_filter&&this._is_bot();if(o&&!this.config.__preview_capture_bot_pageviews)return;const a=i?.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(a?.isRateLimited)return void S.critical("This capture call is ignored due to client rate limiting.");let l;s?.$current_url&&!L(s?.$current_url)&&(S.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?.gh||S.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=Yr(i?.uuid,Ce);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 v=t==="$feature_flag_called"&&h.properties.$feature_flag_has_experiment===!1&&this.get_property("$minimal_flag_called_events")===!0;i?.$set&&!v&&(h.$set=i?.$set);const f=N(s?.$set)?s.$set:void 0,y=A(s?.$unset)?s.$unset:[],g=i?.$unset||[],m=T=>{var j;const D=!!i?.$set&&T in i.$set;return{hasProvided:D||!!f&&T in f,provided:D?i==null||(j=i.$set)===null||j===void 0?void 0:j[T]:f?.[T],unset:y.indexOf(T)!==-1||g.indexOf(T)!==-1}},_=m(vn),w=m(fn),$=[{channel:this.rh,hasProvided:_.hasProvided,update:this.dh(l?.fbclid,_.provided,_.hasProvided,_.unset)},{channel:this.oh,hasProvided:w.hasProvided,update:this.fh(w.provided,w.hasProvided,w.unset)}];for(const{channel:T,hasProvided:j,update:D}of $)D&&h.properties.$process_person_profile===!0&&D.pending&&!j&&!v&&(h.$set=p({[T.property]:D.value},h.$set));const E=i?.$unset;E&&(h.$unset=E);const P=v?void 0:this.mh(i?.$set_once,t!==_n,t===Wa);if(P&&(h.$set_once=P),i?._noTruncate||(I=this.config.properties_string_max_length,h=(function(T,j){const D=new Set;return(function U(V,re){if(V!==Object(V))return j?j(V):V;if(D.has(V))return;let he;if(D.add(V),A(V))he=[],Mt(V,oe=>{he.push(U(oe))});else{const oe={};K(Nt(V)?Va(V):V,(Pe,ge)=>{D.has(Pe)||(oe[ge]=U(Pe))}),he=oe}return he})(T)})(h,T=>L(T)?T.slice(0,I):T)),h.timestamp=c,x(i?.timestamp)||(h.properties.$event_time_override_provided=!0,h.properties.$event_time_override_system_time=u),v&&(h.properties=((T,j=[])=>{const D={},U=V=>{T[V]!==void 0&&(D[V]=T[V])};return Wu.forEach(U),j.forEach(U),D})(h.properties,$h)),t===$e.DISMISSED||t===$e.SENT){const T=s?.[Pi.SURVEY_ID],j=s?.[Pi.SURVEY_ITERATION];Ll({id:T,current_iteration:j}),h.$set=p(p({},h.$set),{},{[ch({id:T,current_iteration:j},t===$e.SENT?"responded":"dismissed")]:!0})}else t===$e.SHOWN&&(h.$set=p(p({},h.$set),{},{[Pi.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));var I;if(t===Kc.SHOWN){const T=s?.[Ln.TOUR_TYPE];T&&(h.$set=p(p({},h.$set),{},{[`${Ln.TOUR_LAST_SEEN_DATE}/${T}`]:new Date().toISOString()}))}const M=p(p({},h.properties.$set),h.$set);if(ke(M)||this.setPersonPropertiesForFlags(M),!R(this.config.before_send)){const T=this.Fs(h);if(!T)return;h=T,h.uuid=Yr(h.uuid,Ce)}this.sessionRecording&&!this.Au&&Xn(t)&&(this.Au=!0,setTimeout(()=>this.Au=!1,3e4));const O=$.filter(({channel:T,update:j})=>{var D,U,V;const re=(D=(U=h.$set)===null||U===void 0?void 0:U[T.property])!==null&&D!==void 0?D:N((V=h.properties)===null||V===void 0?void 0:V.$set)?h.properties.$set[T.property]:void 0;return j?.pending&&re===j.value});this.du.emit("eventCaptured",h);const B=(r=i?._url)!==null&&r!==void 0?r:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),H=i?._batchKey==="recordings"||/\/s\/(?:\?|$)/.test(B),W=p(p(p({method:"POST",url:B,data:h,compression:"best-available",preferSyncCompression:i?.send_instantly,timestampMode:H?"body":"capture-body",batchKey:i?._batchKey},H&&(!((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}:{}),O.length?{fireCallbackOnDrop:!0,callback:T=>{if(T.statusCode>=200&&300>T.statusCode)for(const{channel:j,update:D}of O)this.ph(j,D.value)}}:{});if(!this.config.request_batching||i&&!i?._batchKey||i?.send_instantly||O.length){var J;let T;!W.transport&&!W.callback&&ke((J=this.config.request_headers)!==null&&J!==void 0?J:{})&&this.Tu&&(T="sendBeacon"),this.Hu(W,T)}else this.Bu.enqueue(W);return h}_addCaptureHook(t){return this.on("eventCaptured",s=>t(s.event,s))}getExtension(t){var s;return(s=this.th)===null||s===void 0?void 0:s.getExtension(t)}Zu(){var t;return(t=this.th)!==null&&t!==void 0?t:this.th=new wh(this)}fu(t){this.Ru.push(t);let s=!0;return()=>{if(!s)return;s=!1;const i=this.Ru.indexOf(t);i!==-1&&this.Ru.splice(i,1)}}yh(t=!0){var s,i,r;return!!(!((s=this.persistence)===null||s===void 0)&&s.consumeCookieIdentityChange())&&(this.Lu=null,this.persistence.get_property("$user_state")==="anonymous"&&((r=this.sessionPersistence)===null||r===void 0||r.clear(),this.Eu.clear(),this.bh()),(i=this.featureFlags)===null||i===void 0||i.reset(),t&&this.reloadFeatureFlags(),!0)}calculateEventProperties(t,s,i,r,n){if(i=i||new Date,!this.persistence||!this.sessionPersistence)return s;this.ku(),this.persistence.syncCookieProperties(),this.yh();const o=n?void 0:this.persistence.remove_event_timer(t);let a=p({},s);if(a.token=this.config.token,a.$config_defaults=this.config.defaults,this.yu()&&(a[Ta]=!0),t==="$snapshot"){const _=p(p({},this.persistence.properties()),this.sessionPersistence.properties());return a.distinct_id=_.distinct_id,(!L(a.distinct_id)&&!ne(a.distinct_id)||Yt(a.distinct_id))&&S.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),a}const l=(function(_,w,$,E=!1){var P,I,M,O;if(!ye)return{};const B=_?[...Lt,...w||[]]:[],[H,W]=Zo(ye),[J,T]=(function(pe){for(let _e=0;Xr.length>_e;_e++){const[Ke,_t,xe]=Xr[_e],Ae=pe.match(Ke);if(Ae){const ot=xe&&pe.match(xe)||Ae;return[_t,ot?.[1]||""]}}return["",""]})(ye),j=(function(){const pe="u">typeof navigator?navigator:void 0;return pe?.brave?{brave:!0}:{}})(),D={};x($)||(D.detectGoogleSearchApp=$);const U={},V=(P=navigator)===null||P===void 0||(P=P.userAgentData)===null||P===void 0?void 0:P.platform,re=(I=navigator)===null||I===void 0?void 0:I.maxTouchPoints,he=b==null||(M=b.screen)===null||M===void 0?void 0:M.width,oe=b==null||(O=b.screen)===null||O===void 0?void 0:O.height,Pe=b?.devicePixelRatio;x(V)||(U.userAgentDataPlatform=V),x(re)||(U.maxTouchPoints=re),x(he)||(U.screenWidth=he),x(oe)||(U.screenHeight=oe),x(Pe)||(U.devicePixelRatio=Pe);const ge=Y(Cr({$os:H,$os_version:W,$browser:Yo(ye,navigator.vendor,j,D),$webview_app:J,$webview_app_version:T,$device:Qo(ye),$device_type:hu(ye,U),$timezone:dl(),$timezone_offset:zc()}),{$current_url:fs(E?nt(ee?.href):ee?.href,B,gs),$host:ee?.host,$pathname:ee?.pathname,$raw_user_agent:ye.length>1e3?ye.substring(0,997)+"...":ye,$browser_version:cu(ye,navigator.vendor,j,D),$browser_language:ll(),$browser_language_prefix:Vc(),$screen_height:b?.screen.height,$screen_width:b?.screen.width,$viewport_height:b?.innerHeight,$viewport_width:b?.innerWidth,$lib:Ue.LIB_NAME,$lib_version:Ue.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3});return Ue.SDK_DIST_CHANNEL&&(ge.$sdk_dist_channel=Ue.SDK_DIST_CHANNEL),ge})(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:w}=this.sessionManager.checkAndGetSessionAndWindowId(n,i.getTime(),!0);a.$session_id=_,a.$window_id=w}this.sessionPropsManager&&Y(a,this.sessionPropsManager.getSessionProps());try{var u;if(this.sessionRecording){const _=this.sessionRecording.sdkDebugProperties,w=!this.Au&&Xn(t);for(const $ in _)(w||C(xh,$))&&(a[$]=_[$])}a.$sdk_debug_retry_queue_size=(u=this.zu)===null||u===void 0?void 0:u.length}catch(_){a.$sdk_debug_error_capturing_properties=String(_)}let c;if(this.requestRouter.region===gr&&(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=Y(a,c),t==="$pageview"&&k&&(a.title=k.title),!x(o)){const _=i.getTime()-o;a.$duration=parseFloat((_/1e3).toFixed(3))}ye&&this.config.opt_out_useragent_filter&&(a.$browser_type=this._is_bot()?"bot":"browser");const d=this.persistence.properties(),h=this.sessionPersistence.properties(),v=a.$groups,f=d.$groups;N(v)&&!ke(v)&&(a.$groups=p(p({},N(f)?f:{}),v)),K(["$referrer","$referring_domain"],_=>{_ in d&&delete h[_]});const y={};if(this.Ru.length>0)for(const _ of this.Ru.slice())try{Y(y,_())}catch(w){S.error("Failed to produce browser extension event properties",w)}a=Y({},l,d,h,p(p({},y),a)),a.$is_identified=this._isIdentified(),A(this.config.property_denylist)?K(this.config.property_denylist,function(_){delete a[_]}):S.error(Dl+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);const g=this.config.sanitize_properties;g&&(S.error(Jn),a=g(a,t));const m=this._h();return a.$process_person_profile=m,m&&!n&&this.wh("_calculate_event_properties"),a}mh(t,s=!0,i=!1){var r;if(!this.persistence||!this._h()||this.Mu&&!i)return t;const n=this.persistence.get_initial_props(),o=(r=this.sessionPropsManager)===null||r===void 0?void 0:r.getSetOnceProps();let a=Y({},n,o||{},t||{});const l=this.config.sanitize_properties;return l&&(S.error(Jn),a=l(a,"$set_once")),s&&(this.Mu=!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.yh(),(i=this.sessionPersistence)===null||i===void 0||i.register(t),Object.keys(t).forEach(r=>this.Eu.add(r)),this.bh()}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.Eu.delete(t),this.bh()}kh(t,s){this.register({[t]:s})}Uu(){this.Eu.forEach(t=>{var s;(s=this.sessionPersistence)===null||s===void 0||s.unregister(t)}),this.Eu.clear(),this.bh()}bh(){var t;if(!this.Pu)return;if(this.config.persistence==="memory"||!((t=this.sessionPersistence)===null||t===void 0)&&t.hi||!X.Et())return void X.Pt(this.Pu);const s=[];this.Eu.forEach(i=>s.push(i)),s.length>0?X.$t(this.Pu,s):X.Pt(this.Pu)}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.du.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:kt}),()=>{})}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:kt})}getActiveMatchingSurveys(t,s=!1){this.surveys?this.surveys.getActiveMatchingSurveys(t,s):t([],{isLoaded:!1,error:kt})}onActiveMatchingSurveysChanged(t){return this.surveys?this.surveys.onActiveMatchingSurveysChanged(t):(t([],{isLoaded:!1,error:kt}),()=>{})}renderSurvey(t,s){var i;(i=this.surveys)===null||i===void 0||i.renderSurvey(t,s)}displaySurvey(t,s=fh){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:kt}}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:kt})}Sh(t){return!t||Yt(t)?(S.critical("Unique user id has not been set in posthog.identify"),!1):t==="$posthog_cookieless"?(S.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())||(S.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 S.uninitializedWarning("posthog.identify");if(ne(t)&&(t=t.toString(),S.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),!this.Sh(t)||!this.wh("posthog.identify"))return;this.ku();const r=this.get_distinct_id(),n=this.persistence.syncCookieProperties()&&this.get_distinct_id()!==r,o=this.yh(!1),a=this.persistence.Fa();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(Vs),this.register({distinct_id:t}));const d=(this.persistence.get_property("$user_state")||"anonymous")===ze,h=t!==c,v=!h&&d;if(h&&d){var u;const f=this.config.reuseAnonymousId?{distinct_id:t}:{distinct_id:t,$anon_distinct_id:c};this.persistence.set_property(be,Ts),this.setPersonPropertiesForFlags({$set:s||{},$set_once:i||{}},!1),this.config.cookieWinsOnConflict&&this.persistence.Da(),this.capture("$identify",f,{$set:s||{},$set_once:i||{}})&&(this.Lu=Ti(t,s,i)),(u=this.featureFlags)===null||u===void 0||u.setAnonymousDistinctId(this.config.reuseAnonymousId?void 0:c)}else if(v){this.persistence.set_property(be,Ts);const f=s||{},y=i||{};this.setPersonPropertiesForFlags({$set:f,$set_once:y},!1),this.config.cookieWinsOnConflict&&this.persistence.Da(),this.capture("$set",{$set:f,$set_once:y})&&(this.Lu=Ti(t,s,i))}else(s||i)&&this.setPersonProperties(s,i);h||n||o?(this.reloadFeatureFlags(),this.featureFlags?this.featureFlags.resetFlagCallReported():this.unregister(it)):v&&(s||i)&&this.reloadFeatureFlags(),l=!0}finally{a&&this.persistence.qa(l)}}setPersonProperties(t,s){if(!t&&!s||!this.wh("posthog.setPersonProperties"))return;const i=Ti(this.get_distinct_id(),t,s);this.Lu!==i?(this.setPersonPropertiesForFlags({$set:t||{},$set_once:s||{}},!0),this.capture("$set",{$set:t||{},$set_once:s||{}})&&(this.Lu=i)):S.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}unsetPersonProperties(t){var s;const i=(A(t)?t:[t]).filter(r=>L(r)&&r.length>0);i.length!==0&&this.wh("posthog.unsetPersonProperties")&&((s=this.featureFlags)===null||s===void 0||s.unsetPersonPropertiesForFlags(i,!0),this.capture("$set",{$unset:i}),this.Lu=null)}group(t,s,i){var r;if(!t||!s)return void S.error("posthog.group requires a group type and group key");(r=this.persistence)===null||r===void 0||r.syncCookieProperties(),this.yh();const n=this.getGroups(),o=n[t]!==s;if(o&&this.resetGroupPropertiesForFlags(t),this.register({$groups:p(p({},n),{},{[t]:s})}),(o||i)&&this._h()){const a={$group_type:t,$group_key:s};i&&(a.$group_set=i),this.capture(_n,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.wh("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.xh(s,!1,i)}xh(t,s=!1,i){var r,n,o,a,l,u;if(S.info("reset"),!this.__loaded)return S.uninitializedWarning("posthog.reset");const c=i?.sessionID;this.config.bootstrap=i||((r=this.qu)===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.il());const d=this.get_property($r),h=this.get_property(gi),v=this.get_property(es);(a=this.sessionRecording)===null||a===void 0||a.flushBeforeIdentityReset();const f=this.is_capturing();s||this.consent.reset(),s||!f||this.is_capturing()||console.warn("[PostHog.js]","reset() cleared the stored consent, and capturing is now off because of `opt_out_capturing_by_default`. Call opt_in_capturing() again, and prefer calling reset() before opting in rather than after.");const y=(l=this.persistence)===null||l===void 0||(u=l.Fa)===null||u===void 0?void 0:u.call(l),g=this.Su;this.Su=g||s;let m=!1;try{var _,w,$,E,P,I,M,O,B,H,W,J,T;if((_=this.persistence)===null||_===void 0||_.clear(),(w=this.sessionPersistence)===null||w===void 0||w.clear(),this.Eu.clear(),this.bh(),x(v)||(H=this.persistence)===null||H===void 0||H.register({$session_recording_remote_config:v}),($=this.surveys)===null||$===void 0||$.reset(),(E=this.featureFlags)===null||E===void 0||E.reset(),(P=this.conversations)===null||P===void 0||P.reset(),(I=this.logs)===null||I===void 0||I.reset(),(M=this.metrics)===null||M===void 0||M.reset(),(O=this.persistence)===null||O===void 0||O.set_property("$user_state","anonymous"),(B=this.sessionManager)===null||B===void 0||B.resetSessionId(),this.Lu=null,this.config.cookieless_mode==="always")this.register_once({distinct_id:_i,$device_id:null},"");else{const U=this.config.get_device_id(Ce());this.register_once({distinct_id:U,$device_id:t?U:d},""),t||x(h)||this.register({[gi]:h})}if(this.register({$last_posthog_reset:new Date().toISOString()},1),i&&(i.distinctID&&!this.yu()&&((T=this.persistence)===null||T===void 0||T.set_property("$user_state",i.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:i.distinctID})),(W=this.featureFlags)===null||W===void 0||W.initialize(),!R(c)&&!(!((J=this.sessionManager)===null||J===void 0)&&J.setBootstrapSessionId(c,!0)))){const U=p({},i);delete U.sessionID,this.config.bootstrap=U}delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,m=!0}finally{var j,D;this.Su=g,y&&((j=this.persistence)===null||j===void 0||(D=j.qa)===null||D===void 0||D.call(j,m))}this.reloadFeatureFlags()}shutdown(t){var s=this;return Z(function*(){var i,r,n,o,a,l,u,c;if(s.__loaded){s.Iu=!0,s.Zu().dispose(),(i=s.sessionRecording)===null||i===void 0||i.dispose(),(r=s.logs)===null||r===void 0||r.flushLogs("sendBeacon"),(n=s.metrics)===null||n===void 0||n.flush("sendBeacon"),(o=s.metrics)===null||o===void 0||o.dispose(),(a=s.Bu)===null||a===void 0||a.unload(),(l=s.zu)===null||l===void 0||l.unload();try{var d;(d=s.featureFlags)===null||d===void 0||d.destroy()}catch(h){S.error("Error while destroying feature flags",h)}(u=s.persistence)===null||u===void 0||u.destroy(),(c=s.sessionPersistence)===null||c===void 0||c.destroy()}else S.uninitializedWarning("posthog.shutdown")})()}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.$h()}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.Ch()}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")?(S.critical("Attempting to create alias for existing People user - aborting."),-2):this.wh("posthog.alias")?(x(s)&&(s=this.get_distinct_id()),t!==s?(this.kh(Vs,t),this.capture("$create_alias",{alias:t,distinct_id:s})):(S.warn("alias matches current distinct_id - skipping api call."),this.identify(t),-1)):void 0}set_config(t){const s=p({},this.config);if(N(t)){var i,r,n,o,a,l,u,c,d,h,v,f,y;Y(this.config,Qn(t));const $=this.Cu();if(this.persistence){const P=this.config.persistence==="sessionStorage"||this.config.persistence==="memory";var g,m;if(P&&this.sessionPersistence!==this.persistence&&((g=this.sessionPersistence)===null||g===void 0||g.remove(),(m=this.sessionPersistence)===null||m===void 0||m.destroy()),this.persistence.update_config(this.config,s,$),P)this.sessionPersistence=this.persistence;else if(this.sessionPersistence===this.persistence)this.sessionPersistence=new $i(p(p({},this.config),{},{persistence:"sessionStorage"}),$,!1);else{var _;(_=this.sessionPersistence)===null||_===void 0||_.update_config(p(p({},this.config),{},{persistence:"sessionStorage"}),p(p({},s),{},{persistence:"sessionStorage"}),$)}}const E=this.Nu(this.config.debug);var w;we(E)&&(this.config.debug=E),we(this.config.debug)&&(this.config.debug?(le.DEBUG=!0,q.Et()&&q.$t("ph_debug",!0),S.info("set_config",{config:t,oldConfig:s,newConfig:p({},this.config)})):(le.DEBUG=!1,q.Et()&&q.Pt("ph_debug"))),(i=this.featureFlags)===null||i===void 0||(r=i.updateConfig)===null||r===void 0||r.call(i,this.config,this.il()),(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.sessionRecording)===null||l===void 0||l.startIfEnabledOrStop(),(u=this.tracingHeaders)===null||u===void 0||u.startIfEnabledOrStop(),(c=this.autocapture)===null||c===void 0||c.startIfEnabled(),(d=this.heatmaps)===null||d===void 0||d.startIfEnabled(),("capture_pageview"in t||"disable_capture_url_hashes"in t)&&((w=this.historyAutocapture)===null||w===void 0||w.startIfEnabledOrStop()),(h=this.exceptionObserver)===null||h===void 0||h.startIfEnabledOrStop(),(v=this.deadClicksAutocapture)===null||v===void 0||v.startIfEnabledOrStop(),(f=this.surveys)===null||f===void 0||f.loadIfEnabled(),this.xu(),(y=this.externalIntegrations)===null||y===void 0||y.startIfEnabledOrStop(),!s.segment&&this.config.segment&&this.persistence&&Tn(this,as,!1)}}_overrideSDKInfo(t,s){le.LIB_NAME=t,le.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(p(p({},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:Qe.Th}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:Xt;return s!==Xt&&(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"}_h(){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))}sh(){return this.config.capture_pageleave===!0||this.config.capture_pageleave==="if_capture_pageview"&&!!this.config.capture_pageview}createPersonProfile(){this._h()||this.wh("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.wh("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}wh(t){return this.config.person_profiles==="never"?(S.error(t+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.bu(),this.kh(Mr,!0),!0)}Cu(){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")}xu(){var t,s;const i=this.Cu();var r,n,o;return this.is_capturing()||(r=this.logs)===null||r===void 0||r.Ih(),((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.bh(),i}opt_in_capturing(t){var s;if(this.config.cookieless_mode!=="always"){if(this.yu()){var i,r,n,o,a,l;(i=this.sessionRecording)===null||i===void 0||i.dispose({discardBufferedEvents:!0}),this.xh(!0,!0),(r=this.sessionManager)===null||r===void 0||r.destroy(),(n=this.pageViewManager)===null||n===void 0||n.destroy(),this.sessionManager=new zn(this),this.pageViewManager=new Cn(this),this.persistence&&(this.sessionPropsManager=new Wn(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=Qe.__defaultExtensionClasses)===null||l===void 0?void 0:l.sessionRecording;var u,c;v&&(this.sessionRecording=this.mu(this.sessionRecording,new v(this)),this.cu&&((u=this.sessionRecording)===null||u===void 0||(c=u.onRemoteConfig)===null||c===void 0||c.call(u,this.cu)))}var d,h;this.consent.optInOut(!0),this.xu(),this.eh(),(s=this.sessionRecording)===null||s===void 0||s.startIfEnabledOrStop(),this.config.cookieless_mode=="on_reject"&&((d=this.surveys)===null||d===void 0||d.loadIfEnabled()),(x(t?.captureEventName)||t?.captureEventName)&&this.capture((h=t?.captureEventName)!==null&&h!==void 0?h:"$opt_in",t?.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.ih()}else S.warn(Kn)}opt_out_capturing(){this.config.cookieless_mode!=="always"?(this.consent.optInOut(!1),this.xu(),this.config.cookieless_mode==="on_reject"&&this.$u()):S.warn(Kn)}$u(){var t,s;const i=this.sessionRecording;i?.dispose({discardBufferedEvents:!0}),this.get_distinct_id()!=="$posthog_cookieless"&&this.xh(!0,!0),this.register({distinct_id:_i,$device_id:null}),this.gu(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.ih(),this.eh()}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.Su&&(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.xu()}_is_bot(){return ce?Fl(ce,this.config.custom_blocked_useragents):void 0}ih(){k&&(k.visibilityState==="visible"?this.Ou||(this.Ou=!0,this.capture(Tr,{title:k.title},{send_instantly:!0}),this.Fu&&(k.removeEventListener(ds,this.Fu),this.Fu=null)):this.Fu||(this.Fu=this.ih.bind(this),z(k,ds,this.Fu)))}debug(t){t===!1?(b?.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(b?.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}))}il(){const t=this.qu||{};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?(S.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&&!R(s[i]),l=r in s&&!R(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,S)}Fs(t){var s;if(R(this.config.before_send))return t;const i=Object.keys((s=t.properties)!==null&&s!==void 0?s:{}).filter(Ql),r=A(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),R(n)){const a=`Event '${t.event}' was rejected in beforeSend function`;return Zl(t.event)?S.warn(`${a}. This can cause unexpected behavior.`):S.info(a),null}n.properties&&!ke(n.properties)||S.warn(`Event '${t.event}' has no properties after beforeSend function, this is likely an error.`)}catch(a){return S.error(`Error in beforeSend function for event '${t.event}':`,a),null}for(const o of i)if(n.properties&&R(n.properties[o]))return S.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.Wo)===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)})}Nu(t){const s=we(t)&&!t,i=q.Et()&&q.Ot("ph_debug")==="true";return!s&&(!!i||t)}};ls.__defaultExtensionClasses={},ls.Th=(()=>{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]]=wc(e.prototype[t[s]])})(ls,["identify"]);var Nl=class{constructor(e){this.disabled=e===!1;const t=N(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 Ri="$copy_autocapture",Li=ie("[AutoCapture]");function Di(e,t){return t.length>e?t.slice(0,e)+"...":t}function Oh(e){if(e.previousElementSibling)return e.previousElementSibling;let t=e;do t=t.previousSibling;while(t&&!je(t));return t}function Ih(e,{e:t,maskAllElementAttributes:s,maskAllText:i,elementAttributeIgnoreList:r,elementsChainAsString:n,disableCaptureUrlHashes:o}){var a,l;if(!je(e))return{props:{}};const u=[e],c=new Set([e]);let d=e;for(;d.parentNode&&!ve(d,"body")&&1e3>u.length;){if(Ar(d.parentNode)){const P=d.parentNode.host;if(c.has(P))break;c.add(P),u.push(P),d=P;continue}if(!je(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(P=>ve(P,"button")||ve(P,"a")):-1;h>0&&(i=i||u.slice(0,h+1).some(P=>!Tt(P)||vs(P)));const v=[],f={};let y,g=!1,m=!1;if(K(u,P=>{const I=Tt(P);if(ve(P,"a")&&!s&&!r?.includes("href")){const M=P.getAttribute("href");g=!!(I&&M&&rs(M))&&(o?nt(M):M)}C(At(P),"ph-no-capture")&&(m=!0),v.push((function(M,O,B,H,W=!1){const J=M.tagName.toLowerCase(),T={tag_name:J};Lr.indexOf(J)>-1&&!B&&(T.$el_text=J.toLowerCase()==="a"||J.toLowerCase()==="button"?Di(1024,On(M)):Di(1024,ps(M)));const j=At(M);O||H?.includes("class")||0>=j.length||(T.classes=j.filter(function(re){return re!==""})),K(M.attributes,function(re){var he;if((!vs(M)||["name","id","class","aria-label"].indexOf(re.name)!==-1)&&!H?.includes(re.name)&&!O&&rs(re.value)&&(!L(he=re.name)||he.substring(0,10)!=="_ngcontent"&&he.substring(0,7)!=="_nghost")){let oe=re.value;re.name==="class"&&(oe=Rr(oe).join(" ")),T["attr__"+re.name]=Di(1024,re.name==="href"&&W?nt(oe):oe)}});let D=1,U=1,V=M;for(;V=Oh(V);)D++,V.tagName===M.tagName&&U++;return T.nth_child=D,T.nth_of_type=U,T})(P,s,i,r,o)),K((function(M){if(!Tt(M))return{};const O={};return K(M.attributes,function(B){if(B.name&&B.name.indexOf("data-ph-capture-attribute")===0){const H=B.name.replace("data-ph-capture-attribute-",""),W=B.value;H&&W&&rs(W)&&(O[H]=W)}}),O})(P),(M,O)=>{({}).hasOwnProperty.call(f,O)||(f[O]=M)})}),m)return{props:{},explicitNoCapture:m};if(h>0&&(e=u[h],v.splice(0,h)),i||(v[0].$el_text=ve(e,"a")||ve(e,"button")?On(e):ps(e)),g){var _,w;v[0].attr__href=g;const P=(_=Ge(g))===null||_===void 0?void 0:_.host,I=b==null||(w=b.location)===null||w===void 0?void 0:w.host;P&&I&&P!==I&&(y=g)}return{props:Y((E=t.type,{$event_type:E,$ce_version:1}),n?{}:{$elements:v},{$elements_chain:($=v,A($)?(function(P){return P.map(I=>{var M,O;let B="";if(I.tag_name&&(B+=I.tag_name),I.attr_class){I.attr_class.sort();for(const J of I.attr_class)B+=`.${J.replace(/"/g,"")}`}const H=p(p(p(p({},I.text?{text:I.text}:{}),{},{"nth-child":(M=I.nth_child)!==null&&M!==void 0?M:0,"nth-of-type":(O=I.nth_of_type)!==null&&O!==void 0?O:0},I.href?{href:I.href}:{}),I.attr_id?{attr_id:I.attr_id}:{}),I.attributes),W={};return Cs(H).sort(([J],[T])=>(function(j,D){return D>j?-1:j>D?1:0})(J,T)).forEach(([J,T])=>W[In(J.toString())]=In(T.toString())),B+=":",B+=Cs(W).map(([J,T])=>`${J}="${T}"`).join(""),B}).join(";")})((function(P){return P.map(I=>{var M,O;const B={text:(M=I.$el_text)===null||M===void 0?void 0:M.slice(0,400),tag_name:I.tag_name,href:(O=I.attr__href)===null||O===void 0?void 0:O.slice(0,2048),attr_class:Lc(I),attr_id:I.attr__id,nth_child:I.nth_child,nth_of_type:I.nth_of_type,attributes:{}};return Cs(I).filter(([H])=>H.indexOf("attr__")===0).forEach(([H,W])=>B.attributes[H]=W),B})})($)):"")},!((a=v[0])===null||a===void 0)&&a.$el_text?{$el_text:(l=v[0])===null||l===void 0?void 0:l.$el_text}:{},y&&t.type==="click"?{$external_click_url:y}:{},f),target:e};var $,E}var Fh=class{do(){this.vo=void 0,clearTimeout(this.fo),this.fo=void 0}po(e){var t;if(!Tt(e))return!0;const s=(t=this.mo().css_selector_ignorelist)!==null&&t!==void 0?t:ki,i=new Set;let r=e;for(;r;){if(i.size>=1e3||i.has(r))return!0;i.add(r);const n=r,o=At(n);if(C(o,"ph-no-capture")||C(o,"ph-sensitive")||vs(n)||s.some(l=>ur(n,l)))return!0;const a=r.parentNode;r=Ar(a)?a.host:a&&je(a)?a:null}return!1}yo(e){if(!this.isEnabled||e.type==="pointercancel")return void this.do();if(e.type==="pointerdown"){this.do();const i=is(e);var t;return void(e.isPrimary&&e.button===0&&!e.ctrlKey&&i&&je(i)&&(this.vo={target:i,excluded:this.po(i),id:e.pointerId,x:e.clientX,y:e.clientY,released:!1,distinctId:(t=this.bo)===null||t===void 0?void 0:t.distinctId}))}const s=this.vo;s&&(e.pointerId!==s.id||Math.abs(e.clientX-s.x)>5||Math.abs(e.clientY-s.y)>5?this.do():e.type==="pointerup"&&(s.released=!0,this.fo=setTimeout(()=>this.do(),0)))}_o(e){var t;const s=this.vo;this.do();const i=is(e);if(s?.released&&s.target.isConnected&&s.distinctId===((t=this.bo)===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&&(ve(i,"html")||ve(i,"body"))){var r;if(s.excluded)return null;const n=(r=this.mo().css_selector_ignorelist)!==null&&r!==void 0?r:ki;return[i,k?.documentElement,k?.body].some(o=>{if(!o)return!1;const a=At(o);return C(a,"ph-no-capture")||C(a,"ph-sensitive")||!Tt(o)||vs(o)||n.some(l=>ur(o,l))})?null:s.target}}constructor(e){this.wo=e,this.name="autocapture",this.ko=!1,this.So=null,this.xo=!1,this.$o=new Map,this.Co=!1,this.Mr={enabled:!1,rageclick:!1,maskAllElementAttributes:!1,maskAllText:!1,disableCaptureUrlHashes:!1,remoteRequestsDisabled:!1},this.To=!1,this.wo.refresh(this.Mr),this.rageclicks=new Nl(this.Mr.rageclick),this.Io=null}setup(e){this.Mo(),this.bo=e;const t=e.onRemoteConfig(this.onRemoteConfig.bind(this));this.To?t.dispose():(this.Eo=t,this.startIfEnabled())}dispose(){var e;this.To||(this.To=!0,this.bo=void 0,(e=this.Eo)===null||e===void 0||e.dispose(),this.Eo=void 0,this.$o.clear(),this.Io=null,this.Po())}mo(){return this.wo.refresh(this.Mr),this.Mr}Mo(){var e,t;return this.mo(),this.Mr.url_allowlist=(e=this.Mr.url_allowlist)===null||e===void 0?void 0:e.map(s=>new RegExp(s)),this.Mr.url_ignorelist=(t=this.Mr.url_ignorelist)===null||t===void 0?void 0:t.map(s=>new RegExp(s)),this.Mr}Ro(){if(!this.isBrowserSupported())return void Li.info("Disabling Automatic Event Collection because this browser is not supported");if(!b||!k)return;const e=this.Ao=t=>{t=t||b?.event;try{if(t.type==="blur")return void this.do();if(t.type.indexOf("pointer")===0)return void this.yo(t);const s=t.type==="click"?this._o(t):void 0;if(te(s))return;this.Oo(t,"$autocapture",s)}catch(s){Li.error("Failed to capture event",s)}};if(z(b,"blur",e),z(k,"submit",e,{capture:!0}),z(k,"change",e,{capture:!0}),z(k,"click",e,{capture:!0}),K(["pointerdown","pointermove","pointerup","pointercancel"],t=>{z(k,t,e,{capture:!0})}),this.mo().capture_copied_text){const t=this.Fo=s=>{s=s||b?.event;try{this.Oo(s,Ri)}catch(i){Li.error("Failed to capture clipboard event",i)}};z(k,"copy",t,{capture:!0}),z(k,"cut",t,{capture:!0}),z(k,"paste",t,{capture:!0})}}Po(){this.do(),this.Ao&&(b?.removeEventListener("blur",this.Ao),K(["pointerdown","pointermove","pointerup","pointercancel"],e=>{k?.removeEventListener(e,this.Ao,!0)}),k?.removeEventListener("submit",this.Ao,!0),k?.removeEventListener("change",this.Ao,!0),k?.removeEventListener("click",this.Ao,!0),this.Ao=void 0),this.Fo&&(k?.removeEventListener("copy",this.Fo,!0),k?.removeEventListener("cut",this.Fo,!0),k?.removeEventListener("paste",this.Fo,!0),this.Fo=void 0),this.ko=!1}startIfEnabled(){this.isEnabled||this.do(),!this.To&&this.bo&&this.isEnabled&&!this.ko&&(this.Ro(),this.ko=!0)}onRemoteConfig(e){if(this.To)return;if(this.xo=!0,!e.ok)return void this.startIfEnabled();const t=e.config;t.elementsChainAsString&&(this.Co=t.elementsChainAsString);const s=t.autocapture_opt_out;var i;we(s)&&((i=this.bo)===null||i===void 0||i.kv.set("$autocapture_disabled_server_side",s),this.So=s),this.startIfEnabled()}setElementSelectors(e,t=this){if(this.To)return;e.size?this.$o.set(t,new Set(e)):this.$o.delete(t);const s=new Set;this.$o.forEach(i=>{i.forEach(r=>s.add(r))}),this.Io=s}getElementSelectors(e,t){var s;const i=[];return(s=this.Io)===null||s===void 0||s.forEach(r=>{const n=k?.querySelectorAll(r);n?.forEach(o=>{e!==o&&t!==o||C(i,r)||i.push(r)})}),i}get isEnabled(){var e,t;if(this.To)return!1;const s=(e=this.bo)===null||e===void 0?void 0:e.kv.get(wa),i=this.So,r=this.mo();if(!r.remoteRequestsDisabled&&!this.xo)return!1;const n=r.remoteRequestsDisabled&&!this.xo;if(te(i)&&!we(s)&&!n)return!1;const o=(t=this.So)!==null&&t!==void 0?t:!!s;return!!r.enabled&&!o}Oo(e,t="$autocapture",s){if(!this.isEnabled)return void this.do();let i=s||is(e);Ka(i)&&(i=i.parentNode||null);const r=this.Mo();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()))&&Za(i,r.rageclick)&&this.Oo(e,"$rageclick",s);const o=t===Ri,a=o?p(p({},r),{},{dom_event_allowlist:void 0}):r;if(i&&(function(d,h,v,f,y,g){var m;if(!b||Dr(d)||v?.url_allowlist&&!xn(v.url_allowlist,g)||v?.url_ignorelist&&xn(v.url_ignorelist,g))return!1;if(v?.dom_event_allowlist){const E=v.dom_event_allowlist;if(E&&!E.some(P=>h.type===P))return!1}const{parentIsUsefulElement:_,targetElementList:w}=Qa(d,f);if(!(function(E,P){const I=P?.element_allowlist;if(x(I))return!0;for(const M of E)if(I.some(O=>M.tagName.toLowerCase()===O))return!0;return!1})(w,v)||!cr(w,v?.css_selector_allowlist)||cr(w,(m=v?.css_selector_ignorelist)!==null&&m!==void 0?m:ki))return!1;try{const E=b.getComputedStyle(d);if(E&&E.getPropertyValue("cursor")==="pointer"&&h.type==="click")return!0}catch{}const $=d.tagName.toLowerCase();switch($){case"html":return!1;case"form":return(y||["submit"]).indexOf(h.type)>=0;case"input":case"select":case"textarea":return(y||["change","click"]).indexOf(h.type)>=0;default:return _?(y||["click"]).indexOf(h.type)>=0:(y||["click"]).indexOf(h.type)>=0&&(Lr.indexOf($)>-1||d.getAttribute("contenteditable")==="true")}})(i,e,a,o,o?["copy","cut","paste"]:void 0,{config:{get_current_url:r.getCurrentUrl}})){var l;const{props:d,explicitNoCapture:h,target:v}=Ih(i,{e,maskAllElementAttributes:r.maskAllElementAttributes,maskAllText:r.maskAllText,elementAttributeIgnoreList:r.element_attribute_ignorelist,elementsChainAsString:this.Co,disableCaptureUrlHashes:r.disableCaptureUrlHashes});if(h)return!1;const f=this.getElementSelectors(i,v);if(f&&f.length>0&&(d.$element_selectors=f),t===Ri){const y=e.type||"clipboard";if(y!=="paste"){var u,c;const g=b==null||(u=b.getSelection())===null||u===void 0?void 0:u.toString(),m=Ja(g);if(!m)return!1;d.$selected_content=m,d.$clipboard_text_length=(c=g?.length)!==null&&c!==void 0?c:0}d.$copy_type=y}return(l=this.bo)===null||l===void 0||l.capture(t,d),!0}}isBrowserSupported(){return ue(k?.querySelectorAll)}},Th=class{constructor(e){this._instance=e}refresh(e){const t=this._instance.config,s=N(t.autocapture)?t.autocapture:void 0;e.enabled=!!t.autocapture,e.rageclick=t.rageclick,e.maskAllElementAttributes=t.mask_all_element_attributes,e.maskAllText=t.mask_all_text,e.disableCaptureUrlHashes=t.disable_capture_url_hashes,e.getCurrentUrl=t.get_current_url,e.remoteRequestsDisabled=this._instance.il(),e.url_allowlist=s?.url_allowlist,e.url_ignorelist=s?.url_ignorelist,e.dom_event_allowlist=s?.dom_event_allowlist,e.element_allowlist=s?.element_allowlist,e.css_selector_allowlist=s?.css_selector_allowlist,e.css_selector_ignorelist=s?.css_selector_ignorelist,e.element_attribute_ignorelist=s?.element_attribute_ignorelist,e.capture_copied_text=s?.capture_copied_text}};const Gt=ie("[ExceptionAutocapture]"),eo=()=>{},to=e=>{var t;if(ue(e))return(t=e.__posthog_layer__)!==null&&t!==void 0?t:e.__rrweb_layer__};function _s(e,t,s){try{if(!(t in e))return eo;const i={next:e[t]},r=s(function(...n){return i.next.apply(this,n)});return ue(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=to(n);for(;o;){if(o.next===r)return void(o.next=i.next);n=o.next,o=to(n)}}}catch{return eo}}const Ch=ie("[TracingHeaders]"),lt=ie("[Web Vitals]"),so=9e5,io=["CLS","FCP","INP","LCP"],Ah=["INP","LCP"],Rh=["interactionTarget","interactionType","inputDelay","processingDuration","presentationDelay","loadState","target","url","timeToFirstByte","resourceLoadDelay","resourceLoadDuration","elementRenderDelay","largestShiftTarget","largestShiftTime","largestShiftValue","firstByteToFCP"],Ni="disabled",ro="lazy_loading",qe=ie("[SessionRecording]"),Lh=[Or,Ir,Ra,La,Da,Na,ja,Ba,qa],Dh=ie("[Heatmaps]");function ji(e){return N(e)&&"clientX"in e&&"clientY"in e&&ne(e.clientX)&&ne(e.clientY)}const Ps=ie("[Product Tours]"),Bi=e=>{var t;return!e.config.disable_product_tours&&!!(!((t=e.persistence)===null||t===void 0)&&t.get_property(Pr))},Nh=["$set_once","$set"],Re=ie("[SiteApps]"),no="Error while initializing PostHog app with config id ",jl=(e,t)=>e?.then?e.then(t):t(e),Et="SDK is not enabled or survey functionality is not yet loaded",oo="Disabled. Not loading surveys.";var jh=class{constructor(e,t){this.wo=e,this.Mh=t,this.name="surveys",this._surveyEventReceiver=null,this._surveyManager=null,this.Eh=!1,this.Ph=!1,this.Rh=[],this.Ah=[],this.Oh=null,this.Fh=null,this.To=!1,this.Dh=new Set,this.onRemoteConfig=s=>{if(this.To||this.Mr.disableSurveys)return;if(!s.ok)return this.Ph=!0,this.Lh({isLoaded:!1,error:"Remote config unavailable. Not loading surveys."}),G.warn("Remote config unavailable. Not loading surveys.");const i=s.config.surveys;if(R(i))return G.warn("Flags not loaded yet. Not loading surveys.");this.Nh=we(i)?i:i.length>0,G.info(`flags response received, isSurveysEnabled: ${this.Nh}`),this.loadIfEnabled()},this.Lh=s=>{this.Ah.slice().forEach(i=>this.qh(i,s))}}setup(e){if(!this.To)return this.jh=e,jl(e.kv.initialize(),()=>{if(this.jh!==e||this.To)return;this.jh=void 0,this.bo=e;const t=e.onRemoteConfig(this.onRemoteConfig);this.To?t.dispose():(this.Eo=t,this.loadIfEnabled())})}dispose(){var e,t,s,i,r;this.To||(this.To=!0,this.jh=void 0,this.bo=void 0,(e=this.Eo)===null||e===void 0||e.dispose(),this.Eo=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.Rh=[],this.Ah.forEach(n=>{n.active=!1}),this.Ah=[],(r=this.Bh)===null||r===void 0||r.call(this),this.Bh=void 0,this.Oh=null,this.Dh.forEach(n=>clearTimeout(n)),this.Dh.clear())}get Mr(){return this.wo.get()}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.Lh()}loadIfEnabled(){if(this.To||!this.bo)return;const e=this.Mr;if(this._surveyManager)return;if(this.Eh)return void G.info("Already initializing surveys, skipping...");if(e.disableSurveys)return void G.info(oo);if(e.cookielessMode&&this.wo.isOptedOut())return void G.info("Not loading surveys in cookieless mode without consent.");const t=this.wo.getExtensions();if(!t)return void this.Hh("PostHog Extensions not found.");if(x(this.Nh)&&!e.advancedEnableSurveys)return;const s=this.Nh||e.advancedEnableSurveys;this.Eh=!0,this.Ph=!1;try{const i=t.generateSurveys;if(i)return this.zh(i,s),void(this.Eh=!1);const r=t.loadExternalDependency;if(!r)return this.Hh(Fr),void(this.Eh=!1);r(n=>{try{if(this.To)return;const o=this.wo.getExtensions();n||!o?.generateSurveys?this.Hh("Could not load surveys script",n):this.zh(o.generateSurveys,s)}finally{this.Eh=!1}})}catch(i){throw this.Eh=!1,this.Hh("Error initializing surveys",i),i}}zh(e,t){var s,i;if(this.To)return;this._surveyManager=e(t),this._surveyEventReceiver=this.wo.createEventReceiver(this.Lh);const r=(s=(i=this.bo)!==null&&i!==void 0?i:this.Mh)===null||s===void 0?void 0:s.kv.get(Kt);r&&this.Uh(r),G.info("Surveys loaded successfully"),this.Wh(),this.Lh(),this.Vh({isLoaded:!0})}Hh(e,t){this.Ph=!0,G.error(e,t),this.Lh({isLoaded:!1,error:e}),this.Vh({isLoaded:!1,error:e})}onSurveysLoaded(e){return this.Rh.push(e),this._surveyManager&&this.Vh({isLoaded:!0}),()=>{this.Rh=this.Rh.filter(t=>t!==e)}}getSurveys(e,t=!1){var s;const i=(s=this.bo)!==null&&s!==void 0?s:this.Mh;if(!i||this.To)return;if(this.Mr.disableSurveys)return G.info(oo),e([]);const r=i.kv.get(Kt);if(r&&!t)return e(r,{isLoaded:!0}),void(this.Gh()&&this.getSurveys(()=>{},!0));if(this.Oh)return void this.Oh.then(({surveys:a,context:l})=>{this.To||e(a,l)}).catch(a=>G.error("Error in survey callback",a));const n=this.Qh("/api/surveys/",{method:"GET",query:{token:i.projectToken},sentAt:"query",timeoutMs:this.Mr.requestTimeoutMs}).then(a=>{try{return this.Jh(i,a)}catch(l){return G.error("Error processing surveys response",l),this.Jh(i,{statusCode:0,error:l})}},a=>this.Jh(i,{statusCode:0,error:a}));this.Oh=n;const o=()=>{this.Oh===n&&(this.Oh=null)};n.then(a=>{o(),this.To||(this.Lh(a.context),e(a.surveys,a.context))},o).catch(a=>G.error("Error in survey callback",a))}Qh(e,t){const s=this.bo;return s?s.sendRequest(e,t):new Promise(i=>i({statusCode:0,error:new Error(Et)}))}Jh(e,t){if(this.To)return{surveys:[],context:{isLoaded:!1,error:Et}};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.Fh=Date.now(),{surveys:[],context:{isLoaded:!1,error:r}}}this.Fh=null;const i=t.json.surveys||[];return e.kv.set({[Kt]:i,[zs]:Date.now()}),this.Uh(i),{surveys:i,context:{isLoaded:!0}}}Uh(e){var t;const s=e.filter(i=>(function(r){return!(!r.start_date||r.end_date)})(i)&&(Cl(i)||(function(r){var n;return!!(!((n=r.conditions)===null||n===void 0||(n=n.actions)===null||n===void 0||(n=n.values)===null||n===void 0)&&n.length)})(i)));(t=this._surveyEventReceiver)===null||t===void 0||t.replace(s)}Gh(){return this.Zh()&&!this.Oh&&!this.Kh()}Zh(){var e,t;const s=(e=(t=this.bo)!==null&&t!==void 0?t:this.Mh)===null||e===void 0?void 0:e.kv.get(zs);return ne(s)&&Date.now()-s>3e5}Kh(){return ne(this.Fh)&&3e5>Date.now()-this.Fh}markSurveyAsSeen(e,t){var s;const i={id:e,current_iteration:(s=t?.iteration)!==null&&s!==void 0?s:null};Ll(i);try{localStorage.setItem("lastSeenSurveyDate",new Date().toISOString())}catch{}this.Lh()}Vh(e){for(const t of this.Rh)try{if(!e.isLoaded)return t([],e);this.getSurveys(t)}catch(s){G.error("Error in survey callback",s)}}getActiveMatchingSurveys(e,t=!1){if(!R(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);G.warn("init was not called")}onActiveMatchingSurveysChanged(e){var t,s;if(this.To)return()=>{};const i={callback:e,active:!0,revision:0};this.Ah.push(i),this.Wh();const r=(t=(s=this.bo)!==null&&s!==void 0?s:this.Mh)===null||t===void 0?void 0:t.kv.get(Kt);return this.Mr.disableSurveys||!this._surveyManager&&this.Ph&&!this.Eh||!r&&!R(this.Fh)&&!this.Oh?this.qh(i,{isLoaded:!1}):this._surveyManager&&this.qh(i),()=>{var n;i.active=!1,this.Ah=this.Ah.filter(o=>o!==i),this.Ah.length===0&&((n=this.Bh)===null||n===void 0||n.call(this),this.Bh=void 0)}}Wh(){var e,t,s;this._surveyManager&&this.Ah.length>0&&((e=this.Bh)!==null&&e!==void 0||(this.Bh=(t=(s=this.wo).onMatchingConditionsChanged)===null||t===void 0?void 0:t.call(s,this.Lh)))}qh(e,t){if(this.To||!e.active)return;const s=++e.revision,i=r=>{if(!this.To&&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)}}Xh(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}Yh(e){if(R(this._surveyManager))return{eligible:!1,reason:Et};const t=typeof e=="string"?this.Xh(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:"Survey not found"}}tc(e){if(!this.wo.isCapturing())return{eligible:!1,reason:"PostHog is not capturing, so a survey response cannot be recorded"};if(R(this._surveyManager))return{eligible:!1,reason:Et};const t=typeof e=="string"?this.Xh(e):e;return t?this._surveyManager.checkSurveyRenderability(t):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(e){if(R(this._surveyManager))return G.warn("init was not called"),{visible:!1,disabledReason:Et};const t=this.tc(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return R(this._surveyManager)?(G.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:Et})):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.tc(n);s({visible:o.eligible,disabledReason:o.reason})}else s({visible:!1,disabledReason:"Survey not found"})},t)})}renderSurvey(e,t,s){var i;if(!this.wo.isCapturing())return;if(R(this._surveyManager))return void G.warn("init was not called");const r=typeof e=="string"?this.Xh(e):e;if(!r?.id)return void G.warn("Survey not found");if(!vh.includes(r.type))return void G.warn(`Surveys of type ${r.type} cannot be rendered in the app`);const n=k?.querySelector(t);if(n){if(!((i=r.appearance)===null||i===void 0)&&i.surveyPopupDelaySeconds){G.info(`Rendering survey ${r.id} with delay of ${r.appearance.surveyPopupDelaySeconds} seconds`);const o=setTimeout(()=>{var a,l;this.Dh.delete(o),!this.To&&this.wo.isCapturing()&&(G.info(`Rendering survey ${r.id} with delay of ${(a=r.appearance)===null||a===void 0?void 0:a.surveyPopupDelaySeconds} seconds`),(l=this._surveyManager)===null||l===void 0||l.renderSurvey(r,n,s),G.info(`Survey ${r.id} rendered`))},1e3*r.appearance.surveyPopupDelaySeconds);return void this.Dh.add(o)}this._surveyManager.renderSurvey(r,n,s)}else G.warn("Survey element not found")}displaySurvey(e,t){var s;if(!this.wo.isCapturing())return;if(R(this._surveyManager))return void G.warn("init was not called");const i=this.Xh(e);if(!i)return void G.warn("Survey not found");let r=i;if(!((s=i.appearance)===null||s===void 0)&&s.surveyPopupDelaySeconds&&t.ignoreDelay&&(r=p(p({},i),{},{appearance:p(p({},i.appearance),{},{surveyPopupDelaySeconds:0})})),t.displayType!==hr.Popover&&t.initialResponses&&G.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),t.ignoreConditions===!1){const n=this.Yh(i);if(!n.eligible)return void G.warn("Survey is not eligible to be displayed: ",n.reason)}t.displayType!==hr.Inline?this._surveyManager.handlePopoverSurvey(r,t):this.renderSurvey(r,t.selector,t.properties)}cancelPendingSurvey(e){R(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)}};function $t(e,t,s){if(R(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 Bh=class{constructor(e){this._instance=e,this.ec=new Set,this.nc=new Set,this.sc=new Ys,this.rc=(t,s)=>this.oc(t,s)&&this.ac(t,s)&&this.lc(t,s)&&this.uc(t,s),this.oc=(t,s)=>!s?.event||t?.event===s?.event}init(){var e,t;x((e=this._instance)===null||e===void 0?void 0:e._addCaptureHook)||(this.hc=(t=this._instance)===null||t===void 0?void 0:t._addCaptureHook((s,i)=>{this.on(s,i)}))}dispose(){var e,t;(e=this.hc)===null||e===void 0||e.call(this),this.hc=void 0,(t=this._instance)===null||t===void 0||(t=t.autocapture)===null||t===void 0||t.setElementSelectors(new Set,this),this.sc=new Ys}register(e){var t,s;if(!x((t=this._instance)===null||t===void 0?void 0:t._addCaptureHook)&&(e.forEach(i=>{var r;this.ec.add(i),(r=i.steps)===null||r===void 0||r.forEach(n=>{this.nc.add(n?.event||"")})}),(s=this._instance)===null||s===void 0?void 0:s.autocapture)){const i=new Set;this.ec.forEach(r=>{var n;(n=r.steps)===null||n===void 0||n.forEach(o=>{o?.selector&&i.add(o.selector)})}),this._instance.autocapture.setElementSelectors(i,this)}}replace(e){this.ec.clear(),this.nc.clear(),this.register(e)}on(e,t){t!=null&&e.length!=0&&(this.nc.has(e)||this.nc.has(t.event))&&this.ec.forEach(s=>{this.cc(t,s)&&this.sc.emit("actionCaptured",s.name)})}dc(e){this.onAction("actionCaptured",t=>e(t))}cc(e,t){if(t?.steps==null)return!1;for(const s of t.steps)if(this.rc(e,s))return!0;return!1}onAction(e,t){return this.sc.on(e,t)}ac(e,t){if(t?.url){var s;const i=e==null||(s=e.properties)===null||s===void 0?void 0:s.$current_url;if(!i||typeof i!="string"||!$t(i,t.url,t.url_matching||"contains"))return!1}return!0}lc(e,t){return!!this.vc(e,t)&&!!this.fc(e,t)&&!!this.gc(e,t)}vc(e,t){var s;if(!t?.href)return!0;const i=this.mc(e);if(i.length>0)return i.some(n=>$t(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&&$t((function(n){const o=n.match(/(?::|")href="(.*?)"/);return o?o[1]:""})(r),t.href,t.href_matching||"exact")}fc(e,t){var s;if(!t?.text)return!0;const i=this.mc(e);if(i.length>0)return i.some(l=>$t(l.text,t.text,t.text_matching||"exact")||$t(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(;!R(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=>$t(l,o,a)));var n,o,a}gc(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}return!1}mc(e){var t;return(e==null||(t=e.properties)===null||t===void 0?void 0:t.$elements)==null?[]:e?.properties.$elements}uc(e,t){return!t?.properties||t.properties.length===0||Rl(t.properties.reduce((s,i)=>{const r=A(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)}},qh=class{constructor(e,t){var s,i;this.yc=[],this._instance=e,this.bc=t,this._c=new Map,this.wc=new Map,this.kc=new Map,this.Sc=(s=this._instance)===null||s===void 0||(i=s.onSessionId)===null||i===void 0?void 0:i.call(s,r=>this.xc(r))}$c(e){return!1}Cc(){return null}Tc(e){}Ic(){}Mc(e,t){return!!e&&Rl(e.propertyFilters,t?.properties)}Ec(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}Pc(e,t,s){const i=(s===Vt.Activation?this._c:this.wc).get(e);let r=[];return this.Rc(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.Mc(a,t)})}register(e){this.Ac(e,!1)}replace(e){this.Ac(e,!0)}Ac(e,t){var s;x((s=this._instance)===null||s===void 0?void 0:s._addCaptureHook)||(this.Oc(e,t),this.Fc(e,t))}Fc(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.kc.clear(),s.length===0)return void(t&&((i=this.Dc)===null||i===void 0||i.replace([])));this.Dc||(this.Dc=new Bh(this._instance),this.Dc.init(),this.Dc.dc(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.kc.get(a.name))!==null&&l!==void 0?l:[];u.includes(n.id)||u.push(n.id),this.kc.set(a.name,u)}})}),t?this.Dc.replace(r):this.Dc.register(r)}Lc(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)})}Oc(e,t){var s,i;const r=e.filter(l=>{var u,c;return((u=l.conditions)===null||u===void 0?void 0:u.events)&&((c=l.conditions)===null||c===void 0||(c=c.events)===null||c===void 0||(c=c.values)===null||c===void 0?void 0:c.length)>0}),n=e.filter(l=>{var u,c;return((u=l.conditions)===null||u===void 0?void 0:u.cancelEvents)&&((c=l.conditions)===null||c===void 0||(c=c.cancelEvents)===null||c===void 0||(c=c.values)===null||c===void 0?void 0:c.length)>0}),o=this.Ec(e,Vt.Activation),a=this.Ec(e,Vt.Cancellation);t?(this._c=o,this.wc=a):(this.Lc(this._c,o),this.Lc(this.wc,a)),(r.length!==0||n.length!==0||e.some(l=>{var u;return(u=l.conditions)===null||u===void 0||(u=u.actions)===null||u===void 0||(u=u.values)===null||u===void 0?void 0:u.length}))&&((s=this.hc)!==null&&s!==void 0||(this.hc=(i=this._instance)===null||i===void 0?void 0:i._addCaptureHook((l,u)=>{this.onEvent(l,u)})))}onEvent(e,t){var s,i;const r=this.Nc(),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.qc(e,n,t);if(a==="consume")return r.info("event consumed activated item, removing it",{event:e,itemId:n}),void this.jc([n]);if(a==="persist")return r.info("shown item promoted to persisted activation",{event:e,itemId:n}),this.Bc(n),void this.Hc([n])}if(this.wc.has(e)){const a=this.Pc(e,t,Vt.Cancellation);a.length>0&&(r.info("cancel event matched, cancelling items",{event:e,itemsToCancel:a.map(l=>l.id)}),this.jc(a.map(l=>l.id)),a.forEach(l=>this.zc(l.id)))}if(!this._c.has(e))return;r.info("event name matched",{event:e,eventPayload:t,items:this._c.get(e)});const o=this.Pc(e,t,Vt.Activation);this.Uc(o.map(a=>a.id))}onAction(e){this.kc.has(e)&&this.Uc(this.kc.get(e)||[])}Uc(e){var t,s;if(e.length===0)return;const i=!!(!((t=this._instance)===null||t===void 0||(s=t.get_session_id)===null||s===void 0)&&s.call(t)),r=[];for(const n of e)i&&this.$c(n)?this.Bc(n)&&this.Wc(n):r.push(n);r.length>0&&(this.yc=[...new Set([...this.yc,...r])]),this.Nc().info("updating activated items",{activatedItems:this.getActivatedIds()}),this.Vc()}Bc(e){this.yc=this.yc.filter(s=>s!==e);const t=this.Gc();return!t.includes(e)&&(this.Qc([...t,e]),this.Jc(),!0)}jc(e){const t=new Set(e);this.yc=this.yc.filter(r=>!t.has(r));const s=this.Zc(),i=s.filter(r=>!t.has(r));i.length!==s.length&&(this.Qc(i),i.length===0&&this.Kc()),this.Hc(e),this.Vc()}Vc(){try{var e;(e=this.bc)===null||e===void 0||e.call(this)}catch(t){this.Nc().error("Error while handling activated items change",t)}}Xc(){var e;const t=this.Cc();if(!t)return{};const s=(e=this._instance)===null||e===void 0||(e=e.persistence)===null||e===void 0?void 0:e.props[t];return s&&typeof s=="object"?s:{}}Wc(e){if(!this.Cc())return;const t=this.Xc();this.Tc(p(p({},t),{},{[e]:Date.now()}))}Hc(e){if(!this.Cc())return;const t=this.Xc(),s={};let i=!1;for(const[r,n]of Object.entries(t))e.includes(r)?i=!0:s[r]=n;i&&(ke(s)?this.Ic():this.Tc(s))}Yc(){this.Cc()&&this.Ic()}getActivationTimestamp(e){if(!this.Gc().includes(e))return;const t=this.Xc()[e];return ne(t)?t:void 0}Zc(){var e;const t=this.td();return((e=this._instance)===null||e===void 0||(e=e.persistence)===null||e===void 0?void 0:e.props[t])||[]}Gc(){var e,t,s;const i=this.Zc();if(i.length===0)return[];const r=(e=this._instance)===null||e===void 0||(e=e.persistence)===null||e===void 0?void 0:e.props[this.ed()],n=(t=this._instance)===null||t===void 0||(s=t.get_session_id)===null||s===void 0?void 0:s.call(t);return n&&r===n?i:[]}Jc(){var e,t;const s=(e=this._instance)===null||e===void 0||(t=e.get_session_id)===null||t===void 0?void 0:t.call(e);s&&this.nd(s)}Kc(){this.sd()}xc(e){var t;const s=(t=this._instance)===null||t===void 0||(t=t.persistence)===null||t===void 0?void 0:t.props[this.ed()];if(s&&s!==e){const i=this.Zc(),r=this.Xc();i.length>0&&(this.Qc([]),i.filter(n=>ne(r[n])).forEach(n=>this.zc(n))),this.Kc(),this.Yc(),i.length>0&&this.Vc()}}getActivatedIds(){return[...new Set([...this.Gc(),...this.yc])].filter(e=>!this.rd(e))}dispose(){var e,t,s;(e=this.Sc)===null||e===void 0||e.call(this),this.Sc=void 0,(t=this.hc)===null||t===void 0||t.call(this),this.hc=void 0,(s=this.Dc)===null||s===void 0||s.dispose(),this.Dc=void 0}reset(){this.yc=[],this.Zc().length>0&&this.Qc([]),this.Kc(),this.Yc(),this.Vc()}getEventToItemsMap(){return this._c}od(){return this.Dc}},Hh=class extends qh{constructor(e,t){super(e,t)}td(){return Pa}ed(){return Ma}Cc(){return Oa}Tc(e){var t;(t=this._instance)===null||t===void 0||(t=t.persistence)===null||t===void 0||t.register({$surveys_activated_timestamps:e})}Ic(){var e;(e=this._instance)===null||e===void 0||(e=e.persistence)===null||e===void 0||e.unregister("$surveys_activated_timestamps")}$c(e){var t;let s;this.Rc(r=>{s=r.find(n=>n.id===e)});const i=s==null||(t=s.appearance)===null||t===void 0?void 0:t.surveyPopupDelaySeconds;return ne(i)&&i>0}ad(){return $e.SHOWN}Rc(e){var t;(t=this._instance)===null||t===void 0||t.getSurveys(e)}zc(e){var t;(t=this._instance)===null||t===void 0||t.cancelPendingSurvey(e)}Nc(){return G}Qc(e){var t;(t=this._instance)===null||t===void 0||(t=t.persistence)===null||t===void 0||t.register({$surveys_activated:e})}nd(e){var t;(t=this._instance)===null||t===void 0||(t=t.persistence)===null||t===void 0||t.register({$surveys_activated_session:e})}sd(){var e;(e=this._instance)===null||e===void 0||(e=e.persistence)===null||e===void 0||e.unregister("$surveys_activated_session")}rd(){return!1}qc(e,t,s){var i;if(e===$e.SENT&&(s==null||(i=s.properties)===null||i===void 0?void 0:i.$survey_completed)===!1)return"ignore";let r;return this.Rc(n=>{r=n.find(o=>o.id===t)}),!r||(function(n){var o;return Cl(n)&&!!(!((o=n.conditions)===null||o===void 0||(o=o.events)===null||o===void 0)&&o.repeatedActivation)||n.schedule==="always"})(r)?e===$e.SHOWN?"consume":"ignore":e===$e.SHOWN?"persist":e===$e.DISMISSED||e===$e.SENT?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},Wh=class{constructor(e){this._instance=e}initialize(){}get(e){if(typeof e=="string")return this._instance.get_property(e);const t={};for(const s of e){const i=this._instance.get_property(s);x(i)||(t[s]=i)}return t}set(e,t){this._instance.register(typeof e=="string"?{[e]:t}:e)}remove(e){typeof e!="string"?e.forEach(t=>this._instance.unregister(t)):this._instance.unregister(e)}},Vh=class{constructor(e){this._instance=e}get(){const e=this._instance.config;return{disableSurveys:e.disable_surveys,cookielessMode:!!e.cookieless_mode,advancedEnableSurveys:e.advanced_enable_surveys,requestTimeoutMs:e.surveys_request_timeout_ms}}isOptedOut(){return this._instance.consent.isOptedOut()}isCapturing(){return this._instance.is_capturing()}getExtensions(){const e=F?.__PosthogExtensions__;if(!e)return;const{generateSurveys:t,loadExternalDependency:s}=e;return{generateSurveys:t?i=>t(this._instance,i):void 0,loadExternalDependency:s?i=>s(this._instance,"surveys",i):void 0}}createEventReceiver(e){return new Hh(this._instance,e)}onMatchingConditionsChanged(e){const t=this._instance._addCaptureHook(n=>{n!=="$pageview"&&n!==$e.SHOWN&&n!==$e.DISMISSED&&n!==$e.SENT||e()}),s=()=>e();z(b,"PHSurveyShown",s);let i=!1;const r=this._instance.onFeatureFlags(()=>{i&&e()});return i=!0,()=>{i=!1,t(),r(),b?.removeEventListener("PHSurveyShown",s)}}};const zh=b?.location?Ks(b.location.hash,"__posthog")||Ks(location.hash,"state"):null,ao="_postHogToolbarParams",lo=ie("[Toolbar]"),uo=ie("[FeatureFlags]");var Uh=class{constructor(e,t=!1){this.ld=!1,this.update(e,t)}update(e,t){this.ud=((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:A(s.flag_keys)?s.flag_keys:void 0}})(e,t),!e.evaluation_environments||e.evaluation_contexts||this.ld||(uo.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.ld=!0),x(e.flag_keys)||A(e.flag_keys)||uo.error("Invalid flag_keys found:",e.flag_keys,"Expected array of non-empty strings")}get(){return this.ud}};const co=ie("[FeatureFlags]"),ut=ie("[FeatureFlags]",{debugEnabled:!0}),qi=`" failed. Feature flags didn't load in time.`,Gh=[502,504],ho=["click","keydown","wheel","touchstart","pointerdown"],po="connection_error",vo=e=>{const t={};for(let s=0;e.length>s;s++)t[e[s]]=!0;return t},fo=e=>{const t={};for(const[s,i]of Cs(e||{}))i&&(t[s]=i);return t},go=e=>Nt(e)&&(e.name==="RangeError"&&e.message.indexOf("Maximum call stack size exceeded")===0||e.name==="InternalError"&&e.message==="too much recursion"),Ie=ie("[Error tracking]"),_r="webkit-masked-url:",Kh=[{value:"isolatedAPI.contexts.topHostname",exact:!1},{value:"No response from target",exact:!0}],Jh=["chrome-extension://","moz-extension://","safari-extension:","safari-web-extension:",_r],Xh=["__firefox__","__gCrWeb"],_o="Refusing to render web experiment since the viewer is a likely bot",Yh={icontains:(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())>-1,not_icontains:(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())===-1,regex:(e,t)=>Zs(t,e),not_regex:(e,t)=>!Zs(t,e),exact:(e,t)=>t===e,is_not:(e,t)=>t!==e},Me=ie("[Conversations]"),ct="Conversations not available yet.";function mo(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),v=p(p({},(function(){let f="",y="";try{const g=ce?.userAgent;g&&([f,y]=Zo(g))}catch{}return(function(g,m){const _=(function(w){if(w)return{}.hasOwnProperty.call(cn,w)?cn[w]:w})(g);return p(p({},_?{"os.name":_}:{}),m?{"os.version":m}:{})})(f,y)})()),e?.resourceAttributes);return{serviceName:(n=(o=v?.["service.name"])!==null&&o!==void 0?o:e?.serviceName)!==null&&n!==void 0?n:t?.serviceNameDefault,serviceVersion:(a=v?.["service.version"])!==null&&a!==void 0?a:e?.serviceVersion,environment:(l=v?.["deployment.environment"])!==null&&l!==void 0?l:e?.environment,resourceAttributes:v,beforeSend:e?.beforeSend,flushIntervalMs:u,maxBufferSize:c,maxQueueSize:h,maxBatchRecordsPerPost:100,rateCapWindowMs:u,maxLogsPerInterval:d,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}}const Zh=["debug","log","warn","error","info"],Qh=e=>{for(;e?.__rrweb_original__;)e=e.__rrweb_original__;return e},yo="console",Bl="__posthogHandledLogsRequestError",Hi=(e,t)=>{const s=e instanceof Error?e:new Error(t);return s[Bl]=!0,s},bo=e=>!!e&&typeof e=="object"&&e[Bl]===!0,Qs=ie("[NetworkMetrics]"),Br=()=>{var e;return!(b==null||(e=b.performance)===null||e===void 0)&&e.now?b.performance.now():Date.now()},ed={"http:":80,"https:":443},td=new Set(["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"]),ql=(e,t)=>{var s;const i=String(t);return{method:String(e).toUpperCase(),url:((s=Ge(i))===null||s===void 0?void 0:s.href)||i}},mr=(e,t,s,i,r,n,o=!1)=>{try{var a,l;const u=r();if(!u)return;const c=s||void 0,d=Br()-i,h=Ge(t.url);if(h&&h.protocol!=="http:"&&h.protocol!=="https:")return;const v={url:h?.href||t.url,method:t.method},f=ue(u.name)?u.name(v):L(u.name)?u.name:"http.client.request.duration";if(!f)return;const y=o&&!c?void 0:((m,_)=>m?400>m?void 0:String(m):_?.name||"_OTHER")(c,n),g=p(p(p(p(p({},(m=>{const _=td.has(m)?m:"_OTHER";return p({"http.request.method":_},_==="_OTHER"&&m!==_?{"http.request.method_original":m}:{})})(v.method)),h?(m=>{return{"server.address":m.hostname.startsWith("[")&&m.hostname.endsWith("]")?m.hostname.slice(1,-1):m.hostname,"server.port":Number(m.port)||ed[m.protocol],"url.scheme":m.protocol.slice(0,-1),"url.template":(_=m.pathname,_.split("/").map(w=>($=>/^\d+$/.test($)||$.length>=8&&/^[0-9a-f-]*\d[0-9a-f-]*$/i.test($))(w)?":id":w).join("/"))};var _})(h):{}),c?{"http.response.status_code":c}:{}),y?{"error.type":y}:{}),(a=u.attributes)===null||a===void 0?void 0:a.call(u,v,{status:c,durationMs:d}));(l=e.metrics)===null||l===void 0||l.histogram(f,d,{unit:"ms",attributes:g})}catch(u){Qs.error("Failed to record network metric",u)}},Hl=()=>{},sd=(e,t)=>ue(b?.fetch)?_s(b,"fetch",s=>function(...i){const r=Br(),n=s.apply(this,i);if(!t())return n;try{var o,a,l;const[u,c]=i,d=ql((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=>(mr(e,d,h?.status,r,t,void 0,!0),h),h=>{throw mr(e,d,void 0,r,t,h),h})}catch(u){return Qs.error("Failed to observe fetch",u),n}}):Hl,id=(e,t)=>{var s;const i=b==null||(s=b.XMLHttpRequest)===null||s===void 0?void 0:s.prototype;if(!i)return Hl;const r=new WeakMap,n=_s(i,"open",a=>function(...l){try{bl.has(this)||r.set(this,ql(l[0],l[1]))}catch(u){Qs.error("Failed to observe XHR open",u)}return a.apply(this,l)}),o=_s(i,"send",a=>function(...l){let u;try{const c=r.get(this);if(c&&t()){const d=Br();u=()=>{this.removeEventListener("loadend",u),mr(e,c,this.status,d,t)},z(this,"loadend",u)}}catch(c){Qs.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()}},ri={featureFlags:class{constructor(e){this.name="featureFlags",this.hd=!1,this.featureFlagEventHandlers=[],this.A=co,this.dd={},this.vd={},this.fd=[],this.pd=!1,this.gd=!1,this.md=0,this.yd=!1,this.bd=!1,this._d=!1,this.wd=!1,this.kd=0,this.Sd=!1,this.rn=()=>{const t=this.xd();this.kd=0,t&&this.reloadFeatureFlags()},this.$d=()=>{var t,s;const i=this.Cd,r=(t=this.Td)!==null&&t!==void 0?t:i;x(i)||x(r)||this.Mr.remoteRequestsDisabled||!k||k.visibilityState==="hidden"||Date.now()-((s=this.Id)!==null&&s!==void 0?s:0)<r||(this.Td=this.Sd||!this.Mr.idleRefreshBackoff?i:Math.min(2*r,36e5),this.Sd=!1,this.reloadFeatureFlags(),this.Md())},this.Ed=()=>{this.Sd&&this.Td===this.Cd||this.Pd()},this.sn=()=>{k?.visibilityState==="visible"&&this.Pd()},"get"in e?this.wo=e:(this._instance=e,this.Rd=new Uh(e.config,e.il()),this.wo=this.Rd)}updateConfig(e,t){var s;(s=this.Rd)===null||s===void 0||s.update(e,t),this.bo&&this.Ad()}setup(e){return this.jh=e,this.A=e.logger.createLogger("[FeatureFlags]"),jl(e.kv.initialize(),()=>{this.jh===e&&(this.jh=void 0,this.bo=e,this.Od(e))})}Od(e){var t;if(this.bo===e)return b&&z(b,"online",this.rn),this.Ad(),this.Fd=e.registerDynamicEventProperties(()=>this.Dd()?this.dd:this.vd),this.Ld=(t=this._instance)===null||t===void 0||(t=t.persistence)===null||t===void 0?void 0:t.onCrossTabFeatureFlagChange(()=>{this.Nd(),this.qd(),this.jd()}),this.qd(),this.initialize()}Pd(){this.Sd=!0,this.Td=this.Cd,this.$d()}Ad(){const e=this.Mr.refreshIntervalMs,t=!this.Mr.remoteRequestsDisabled&&k&&!x(e)&&e>0?e:void 0;this.Mr.idleRefreshBackoff||(this.Td=t),t!==this.Cd&&(this.Bd(),x(t)||(this.Cd=t,this.Td=t,this.Md(),k?.addEventListener&&(z(k,ds,this.sn),Mt(ho,s=>{z(k,s,this.Ed,{capture:!0})}))))}Md(){x(this.Cd)||(x(this.Hd)||clearInterval(this.Hd),this.Id=Date.now(),this.Hd=setInterval(this.$d,this.Cd))}Bd(){var e;x(this.Hd)||(clearInterval(this.Hd),this.Hd=void 0,k==null||(e=k.removeEventListener)===null||e===void 0||e.call(k,"visibilitychange",this.sn),Mt(ho,t=>{var s;k==null||(s=k.removeEventListener)===null||s===void 0||s.call(k,t,this.Ed,{capture:!0})})),this.Cd=void 0,this.Td=void 0,this.Sd=!1,this.Id=void 0}destroy(){this.zd()}dispose(){this.zd()}zd(){var e,t;this.Bd(),this.md++,this.bd=!1,this.jh=void 0,this.bo&&(this.Ud(),(e=this.Fd)===null||e===void 0||e.dispose(),this.Fd=void 0,(t=this.Ld)===null||t===void 0||t.call(this),this.Ld=void 0,this.fd=[],b?.removeEventListener("online",this.rn),this.bo=void 0)}get Mr(){return this.wo.get()}Wd(e){var t;return this.Vd&&e in this.Vd?this.Vd[e]:(t=this.bo)===null||t===void 0?void 0:t.kv.get(e)}Nd(){return!!this.Vd&&(this.Vd=void 0,!0)}Gd(){var e;return!x((e=this.bo)===null||e===void 0?void 0:e.kv.get("$enabled_feature_flags"))&&this.Nd()}$t(e){this.Qd(()=>{var t;return(t=this.bo)===null||t===void 0?void 0:t.kv.set(e)})}Jd(e,t,s){var i;if(!(!((i=this._instance)===null||i===void 0)&&i.persistence)||!e.$enabled_feature_flags)return;const r=this.Wd("$enabled_feature_flags")||{},n=e.$enabled_feature_flags||{},o=t.flags||t.featureFlags,a=t.flags?Object.entries(t.flags).filter(([,m])=>!m?.failed).map(([m])=>m):[],l=!!t.errorsWhileComputingFlags&&!!t.flags,u=l?a:s&&!A(o)?Object.keys(o||{}):Array.from(new Set([...Object.keys(r),...Object.keys(n)])),c=this.Wd("$feature_flag_payloads")||{},d=e.$feature_flag_payloads||{},h=l||s?u:Array.from(new Set([...Object.keys(c),...Object.keys(d)])),v=!l&&!s,f=!!v||u,y=!!v||h,g={[Ve]:f,[Te]:f,[et]:y};e.$feature_flag_details&&(g[vt]=f);for(const m of[ft,rt,ts])x(e[m])||(g[m]=!0);this._instance.persistence.markCrossTabFeatureFlagChanges(g)}Pt(e){this.Qd(()=>{var t;return(t=this.bo)===null||t===void 0?void 0:t.kv.remove(e)})}Qd(e){try{e()}catch(t){this.A.error("Failed to update feature flag persistence",t)}}qd(){const e={};for(const i of[Ve,et,ft,Le]){const r=this.Wd(i);x(r)||(e[i]=r)}this.dd=e;const t=p({},e),s=this.Wd(Te);if(s)for(const[i,r]of Object.entries(s))t[`$feature/${i}`]=r;this.vd=t}Dd(){const e=this.Mr.cacheTtlMs;if(!e||0>=e)return!1;const t=this.Wd(rt);return typeof t!="number"||Date.now()-t>e}Zd(){return!!this.Dd()&&(this.wd||this.gd||(this.wd=!0,this.A.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}Kd(){const e=this.Mr.evaluationContexts;return e?.length?e.filter(t=>{const s=t&&typeof t=="string"&&t.trim().length>0;return s||this.A.error("Invalid evaluation context found:",t,"Expected non-empty string"),s}):[]}Xd(){const e=this.Mr.flagKeys;if(!x(e))return e.filter(t=>{const s=t&&typeof t=="string"&&t.trim().length>0;return s||this.A.error("Invalid flag key found:",t,"Expected non-empty string"),s})}initialize(){var e,t;const s=this.Mr,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.Yd({featureFlags:a,featureFlagPayloads:l},void 0,{persist:!1})}}updateFlags(e,t,s){var i,r;const n=s?.merge&&(i=this.Wd("$enabled_feature_flags"))!==null&&i!==void 0?i:{},o=s?.merge&&(r=this.Wd("$feature_flag_payloads"))!==null&&r!==void 0?r:{},a=p(p({},n),e),l=p(p({},o),t),u={};for(const[c,d]of Object.entries(a))u[c]={key:c,enabled:nn(d),variant:on(d),reason:void 0,metadata:x(l?.[c])?void 0:{id:0,version:void 0,description:void 0,payload:l[c]}};this.Yd({flags:u})}get hasLoadedFlags(){return this.pd}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){const e=this.Wd(vt),t=this.Wd(Le),s=this.Wd(dt);if(!s&&!t)return e||{};const i=Y({},e||{}),r=[...new Set([...Object.keys(s||{}),...Object.keys(t||{})])];for(const a of r){var n;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],v=p(p({},l),{},{enabled:c,variant:c?d??l?.variant:void 0});var o;c!==l?.enabled&&(v.original_enabled=l?.enabled),d!==l?.variant&&(v.original_variant=l?.variant),h&&(v.metadata=p(p({},l?.metadata),{},{payload:h,original_payload:l==null||(o=l.metadata)===null||o===void 0?void 0:o.payload})),i[a]=v}return this.hd||(this.A.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:s,finalDetails:i}),this.hd=!0),i}getAllFeatureFlags(){const e=this.getFlagVariants(),t=this.getFlagPayloads();return Object.keys(e).map(s=>{const i=e[s];return{key:s,enabled:nn(i),variant:on(i),payload:rn(t[s])}})}getFlagVariants(){const e=this.Wd(Te),t=this.Wd(Le);if(!t)return e||{};const s=Y({},e||{}),i=Object.keys(t);for(let r=0;i.length>r;r++)s[i[r]]=t[i[r]];return this.hd||(this.A.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:s}),this.hd=!0),s}getFlagPayloads(){const e=this.Wd(et),t=this.Wd(dt);if(!t)return e||{};const s=Y({},e||{}),i=Object.keys(t);for(let r=0;i.length>r;r++)s[i[r]]=t[i[r]];return this.hd||(this.A.warn(" Overriding feature flag payloads!",{flagPayloads:e,overriddenPayloads:t,finalPayloads:s}),this.hd=!0),s}reloadFeatureFlags(){this.yd||this.Mr.featureFlagsDisabled||this.xd()||(this.gd&&(this.bd=!0),this.tv||(this.fd.slice().forEach(e=>{try{e()}catch(t){this.A.error("Error while running feature flags reloading callback",t)}}),this.tv=setTimeout(()=>{this.ev()},5)))}Ud(){clearTimeout(this.tv),this.tv=void 0}onReloading(e){return this.fd.push(e),()=>{this.fd=this.fd.filter(t=>t!==e)}}ensureFlagsLoaded(){this.pd||this.gd||this.tv||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this.yd=e}resetFlagCallReported(){this.Pt(it)}ev(e){this.Ud();const t=this.bo;if(!t||this.Mr.remoteRequestsDisabled||this.xd())return;if(this.gd)return void(this.bd=!0);const s={token:t.projectToken,distinct_id:t.distinctId,groups:t.groups,$anon_distinct_id:this.$anon_distinct_id,person_properties:p(p(p({},t.initialPersonProperties),this.Wd("$stored_person_properties")||{}),{},{$lib:t.library.name,$lib_version:t.library.version}),group_properties:this.Wd(st),timezone:dl()};x(t.deviceId)||(s.$device_id=t.deviceId),(e?.disableFlags||this.Mr.featureFlagsDisabled)&&(s.disable_flags=!0);const i=this.Kd();i.length&&(s.evaluation_contexts=i);const r=this.Xd();x(r)||(s.flag_keys=r);const n=this.Mr.onlyEvaluateSurveyFeatureFlags,o="/flags/?v=2"+(n?"&only_evaluate_survey_feature_flags=true":""),a=this.md;this.gd=!0;const l=()=>{this.bd&&(this.bd=!1,this.ev())},u=f=>{var y,g;const m=(y=f.json)!==null&&y!==void 0?y:{},_=f.statusCode!==200;if(this.gd=!1,a!==this.md)return void l();if(this.iv(f.statusCode),_||this.bd||(this.$anon_distinct_id=void 0),s.disable_flags&&!this.bd)return;this._d=!_;const w=[];f.error?w.push(f.error instanceof Error&&f.error.name==="AbortError"?"timeout":f.error instanceof Error?po:"unknown_error"):f.statusCode!==200&&w.push(`api_error_${f.statusCode}`),m.errorsWhileComputingFlags&&w.push("errors_while_computing_flags");const $=!!(!((g=m.quotaLimited)===null||g===void 0)&&g.includes("feature_flags"));$&&w.push("quota_limited"),this.$t({[hs]:w}),$?this.A.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."):s.disable_flags||this.Yd(m,_,{partialResponse:n}),l()},c=f=>{this.gd=!1,a===this.md&&(this.$t({[hs]:[po]}),this.A.error("Feature flag request failed",f),this.Gd()&&this.jd(!0)),l()};let d=this.Mr.requestMaxRetries;const h=()=>d>0&&a===this.md,v=()=>{if(a!==this.md||!this.bo||this.Mr.remoteRequestsDisabled)return this.gd=!1,void l();try{t.sendRequest(o,{target:"flags",method:"POST",body:s,compression:this.Mr.compression,sentAt:"body",timeoutMs:this.Mr.requestTimeoutMs}).then(f=>{if((y=>Gh.includes(y.statusCode)||(g=>g.statusCode===0&&g.error instanceof Error&&g.error.name==="AbortError")(y))(f)&&h())return d--,void setTimeout(v,500);u(f)}).catch(c)}catch(f){c(f)}};v()}xd(){return il(this.kd,3)}iv(e){this.kd=rl(e,this.kd,3,()=>this.A.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._d)return;if(!(this.pd||this.getFlags()&&this.getFlags().length>0))return void this.A.warn('getFeatureFlag for key "'+e+qi);if(this.Zd())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._d)return;if(!(this.pd||this.getFlags()&&this.getFlags().length>0))return void this.A.warn('getFeatureFlagResult for key "'+e+qi);if(this.Zd())return;const s=this.getFlagVariants(),i=e in s,r=s[e],n=this.getFlagPayloads()[e],o=String(r),a=this.Wd("$feature_flag_request_id")||void 0,l=this.Wd("$feature_flag_evaluated_at")||void 0;let u,c=this.Wd("$flag_call_reported")||{};if(this.Mr.deduplicateCallsPerSession){var d;const O=(d=this.bo)===null||d===void 0?void 0:d.session.sessionId,B=this.Wd(Jt);O&&O!==B&&(c={},u=O)}if(t.send_event||!("send_event"in t))if(e in c&&c[e].includes(o))u&&this.$t({[it]:c,[Jt]:u});else{var h,v,f,y,g,m,_,w,$,E,P,I;A(c[e])?c[e].push(o):c[e]=[o],this.$t(p({[it]:c},u?{[Jt]:u}:{}));const O=this.getFeatureFlagDetails(e),B=[...(h=this.Wd("$feature_flag_errors"))!==null&&h!==void 0?h:[]];x(r)&&B.push("flag_missing");const H={$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:(v=(f=this.Mr.bootstrap)===null||f===void 0||(f=f.featureFlags)===null||f===void 0?void 0:f[e])!==null&&v!==void 0?v:null,$feature_flag_bootstrapped_payload:(y=(g=this.Mr.bootstrap)===null||g===void 0||(g=g.featureFlagPayloads)===null||g===void 0?void 0:g[e])!==null&&y!==void 0?y:null,$used_bootstrap_value:!this._d};x(O==null||(m=O.metadata)===null||m===void 0?void 0:m.has_experiment)||(H.$feature_flag_has_experiment=O.metadata.has_experiment),x(O==null||(_=O.metadata)===null||_===void 0?void 0:_.version)||(H.$feature_flag_version=O.metadata.version);const W=(w=O==null||($=O.reason)===null||$===void 0?void 0:$.description)!==null&&w!==void 0?w:O==null||(E=O.reason)===null||E===void 0?void 0:E.code;var M;W&&(H.$feature_flag_reason=W),!(O==null||(P=O.metadata)===null||P===void 0)&&P.id&&(H.$feature_flag_id=O.metadata.id),x(O?.original_variant)&&x(O?.original_enabled)||(H.$feature_flag_original_response=x(O.original_variant)?O.original_enabled:O.original_variant),!(O==null||(I=O.metadata)===null||I===void 0)&&I.original_payload&&(H.$feature_flag_original_payload=O==null||(M=O.metadata)===null||M===void 0?void 0:M.original_payload),B.length&&(H.$feature_flag_error=B.join(",")),this.nv(H)}else u&&this.$t({[it]:c,[Jt]:u});return i?{key:e,enabled:!!r,variant:typeof r=="string"?r:void 0,payload:rn(n)}:void 0}nv(e){try{var t;(t=this.bo)===null||t===void 0||t.capture("$feature_flag_called",e)}catch(s){this.A.error("Failed to capture feature flag call",s)}}getRemoteConfigPayload(e,t){this.sv(e,t)}sv(e,t){var s=this;return Z(function*(){const i=s.bo;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.Kd();n.length&&(r.evaluation_contexts=n);const o=s.Xd();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.Mr.compression,sentAt:"body",timeoutMs:s.Mr.requestTimeoutMs})).json)===null||l===void 0?void 0:l.featureFlagPayloads;a=u?.[e]||void 0}catch(u){return void s.A.error("Remote config feature flag request failed",u)}try{t(a)}catch(u){s.A.error("Remote config feature flag callback failed",u)}})()}isFeatureEnabled(e,t={}){if(t.fresh&&!this._d)return t.defaultValue;if(!(this.pd||this.getFlags()&&this.getFlags().length>0))return this.A.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.Yd(e,t,s)}Yd(e,t,s){if(!this.bo)return;this.pd=!0;const i=((r,n={},o={},a={},l,u=co)=>{const c=((w,$)=>{const E=w.flags;if(E){const P=Object.fromEntries(Object.keys(E).map(M=>{var O;return[M,(O=E[M].variant)!==null&&O!==void 0?O:E[M].enabled]})),I=Object.fromEntries(Object.keys(E).filter(M=>E[M].enabled).filter(M=>{var O;return!x((O=E[M].metadata)===null||O===void 0?void 0:O.payload)}).map(M=>{var O;return[M,(O=E[M].metadata)===null||O===void 0?void 0:O.payload]}));return p(p({},w),{},{featureFlags:P,featureFlagPayloads:I})}return w.featureFlags&&$.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),w})(r,u),d=c.flags,h=c.featureFlags,v=c.featureFlagPayloads;if(!h)return;const f=r.requestId,y=r.evaluatedAt;if(A(h)){u.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");const w={};if(h)for(let $=0;h.length>$;$++)w[h[$]]=!0;return{[Ve]:h,[Te]:w,[ts]:!1}}let g=h,m=v,_=d;if(l?.partialResponse){const w=Object.keys(g),$=m||{};g=p(p({},n),g),m=p(p({},o),$),w.forEach(E=>{E in $||m==null||delete m[E]}),_=p(p({},a),_)}else if(r.errorsWhileComputingFlags)if(d){const w=new Set(Object.keys(d).filter(E=>{var P;return!(!((P=d[E])===null||P===void 0)&&P.failed)}));g=p(p({},n),Object.fromEntries(Object.entries(g).filter(([E])=>w.has(E))));const $=Object.fromEntries(Object.entries(m||{}).filter(([E])=>w.has(E)));m=p(p({},o),$),w.forEach(E=>{E in $||m==null||delete m[E]}),_=p(p({},a),Object.fromEntries(Object.entries(_||{}).filter(([E])=>w.has(E))))}else g=p(p({},n),g),m=p(p({},o),m),_=p(p({},a),_);return p(p({[Ve]:Object.keys(fo(g)),[Te]:g||{},[et]:m||{},[vt]:_||{},[ts]:r.minimalFlagCalledEvents===!0},f?{[ft]:f}:{}),y?{[rt]:y}:{})})(e,this.getFlagVariants(),this.getFlagPayloads(),this.getFlagsWithDetails(),s,this.A);if(i)if(s?.persist===!1){const r=!x(this.bo.kv.get(Te));this.Vd=i,r||this.$t(i)}else this.Nd(),this.Jd(i,e,!!s?.partialResponse),this.$t(i);else t&&this.Gd();t||(this.wd=!1),this.jd(t)}override(e,t=!1){this.A.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){this.rv(e)}rv(e){if(this.bo){if(e===!1)return this.Pt([Le,dt]),this.jd(),void ut.info("All overrides cleared");if(A(e))return this.$t({[Le]:vo(e)}),this.jd(),void ut.info("Flag overrides set",{flags:e});if(e&&typeof e=="object"&&("flags"in e||"payloads"in e)){var t;const s=e;this.hd=!!((t=s.suppressWarning)!==null&&t!==void 0&&t);const i={},r=s.flags,n=s.payloads;return r&&(i[Le]=A(r)?vo(r):r),n&&(i[dt]=n),Object.keys(i).length&&this.$t(i),r===!1&&n===!1?this.Pt([Le,dt]):r===!1?this.Pt(Le):n===!1&&this.Pt(dt),this.jd(),r===!1?ut.info("Flag overrides cleared"):r&&ut.info("Flag overrides set",{flags:r}),void(n===!1?ut.info("Payload overrides cleared"):n&&ut.info("Payload overrides set",{payloads:n}))}if(e&&typeof e=="object")return this.$t({[Le]:e}),this.jd(),void ut.info("Flag overrides set",{flags:e});this.A.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:e})}else this.A.warn("posthog.featureFlags.overrideFeatureFlags called before feature flags were ready")}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this.pd){const{flags:t,flagVariants:s}=this.ov();try{e(t,s)}catch(i){this.A.error("Error while running feature flags callback",i)}}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t,s){var i;const r=(this.Wd("$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=p(p({},this.getFlagVariants()),{},{[e]:t});(i=this._instance)===null||i===void 0||(i=i.persistence)===null||i===void 0||i.markCrossTabFeatureFlagChanges({$active_feature_flags:[e],$enabled_feature_flags:[e],$stored_person_properties:Object.keys(n)}),this.$t({[Ve]:Object.keys(fo(a)),[Te]:a,[tt]:p(p({},this.Wd("$stored_person_properties")||{}),n)}),this.jd();try{var l;(l=this.bo)===null||l===void 0||l.capture("$feature_enrollment_update",o)}catch(u){this.A.error("Failed to capture early access feature enrollment",u)}}getEarlyAccessFeatures(e,t=!1,s){const i=this.Wd(ir);!i||t?this.av(e,s):e(i)}av(e,t){var s=this;return Z(function*(){const i=s.bo;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.$t({[ir]:n})}catch(o){return void s.A.error("Early access feature request failed",o)}try{e(n)}catch(o){s.A.error("Early access feature callback failed",o)}})()}ov(){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),{})}}jd(e){this.qd();const{flags:t,flagVariants:s}=this.ov();this.featureFlagEventHandlers.forEach(i=>{try{i(t,s,{errorsLoading:e})}catch(r){this.A.error("Error while running feature flags callback",r)}})}setPersonPropertiesForFlags(e,t=!0){this.lv(e,t)}lv(e,t=!0){const s=this.Wd("$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.$t({[tt]:p(p(p({},s),n),i)}),t&&this.reloadFeatureFlags()}unsetPersonPropertiesForFlags(e,t=!0){const s=p({},this.Wd("$stored_person_properties")||{});e.forEach(i=>{delete s[i]}),this.$t({[tt]:s}),t&&this.reloadFeatureFlags()}resetPersonPropertiesForFlags(e=!0){this.Pt(tt),e&&this.reloadFeatureFlags()}setGroupPropertiesForFlags(e,t=!0){const s=this.Wd("$stored_group_properties")||{},i=p({},s);for(const r of Object.keys(e))i[r]=p(p({},s[r]),e[r]);this.$t({[st]:i}),t&&this.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){const t=this.Wd("$stored_group_properties")||{};this.$t({[st]:p(p({},t),{},{[e]:{}})})}else this.Pt(st)}reset(){this.md++,this.bd=!1,this.dd={},this.vd={},this.Vd=void 0,this.pd=!1,this.yd=!1,this._d=!1,this.$anon_distinct_id=void 0,this.Ud(),this.hd=!1,this.kd=0}}},rd={sessionRecording:class{get Mr(){return this._instance.config}get Il(){return this._instance.persistence}get started(){var e;return!!(!((e=this.uv)===null||e===void 0)&&e.isStarted)}get status(){var e,t;return this.hv==="awaiting_config"||this.hv==="missing_config"?this.hv:(e=(t=this.uv)===null||t===void 0?void 0:t.status)!==null&&e!==void 0?e:this.hv}constructor(e){if(this._instance=e,this._forceAllowLocalhostNetworkCapture=!1,this.hv=Ni,this.dv=void 0,this.vv=!1,this.Je=(()=>{var t,s;if(!k?.visibilityState||k.visibilityState==="visible")return!0;const i=b==null||(t=b.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;k?.visibilityState==="visible"&&(this.Je=!0,(t=this.uv)===null||t===void 0||(s=t.setDocumentWasEverVisible)===null||s===void 0||s.call(t,!0))},!this._instance.sessionManager)throw qe.error("started without valid sessionManager"),new Error("[SessionRecording] started without valid sessionManager. This is a bug.");if(this.Mr.cookieless_mode==="always")throw new Error('[SessionRecording] cannot be used with cookieless_mode="always"');k?.addEventListener&&z(k,"visibilitychange",this.sn)}initialize(){this.startIfEnabledOrStop()}dispose({discardBufferedEvents:e=!1}={}){var t;this.vv=!0,k==null||(t=k.removeEventListener)===null||t===void 0||t.call(k,"visibilitychange",this.sn),e?this.fv(!0):this.stopRecording()}get pv(){var e;const t=!!(!((e=this._instance.get_property("$session_recording_remote_config"))===null||e===void 0)&&e.enabled),s=!this.Mr.disable_session_recording,i=this.Mr.disable_session_recording||this._instance.consent.isOptedOut();return b&&t&&s&&!i}startIfEnabledOrStop(e){var t;if(this.vv||this.pv&&(!((t=this.uv)===null||t===void 0)&&t.isStarted))return;const s=!x(Object.assign)&&!x(Array.from);this.pv&&s?(this.gv(e),qe.info("starting")):(this.hv=Ni,this.stopRecording())}gv(e){var t,s;if(this.pv)if(this.hv!=="awaiting_config"&&this.hv!=="missing_config"&&(this.hv=ro),(F==null||(t=F.__PosthogExtensions__)===null||t===void 0||(t=t.rrweb)===null||t===void 0?void 0:t.record)&&((s=F.__PosthogExtensions__)===null||s===void 0?void 0:s.initSessionRecording))this.mv(e);else{var i,r;const n=this._instance.sessionManager;(i=F.__PosthogExtensions__)===null||i===void 0||(r=i.loadExternalDependency)===null||r===void 0||r.call(i,this._instance,this.yv,o=>{if(!this.vv&&this.pv&&this._instance.sessionManager===n)return o?(this._instance.register_for_session({$sdk_debug_recording_script_not_loaded:!0}),qe.error("could not load recorder",o)):void this.mv(e);this.hv="disabled"})}}stopRecording(){var e,t;(e=this.dv)===null||e===void 0||e.call(this),this.dv=void 0,(t=this.uv)===null||t===void 0||t.stop()}fv(e=!1){var t,s;(t=this.dv)===null||t===void 0||t.call(this),this.dv=void 0,(s=this.uv)===null||s===void 0||s.discard({discardProducerEvents:e})}bv(){var e,t;(e=this.Il)===null||e===void 0||e.unregister("$session_is_sampled"),(t=this.Il)===null||t===void 0||t.unregister("$replay_sample_rate")}_v(e,t){if(R(e))return null;const s=ne(e)?e:parseFloat(e);return typeof(i=s)!="number"||!Number.isFinite(i)||0>i||i>1?(qe.warn(`${t} must be between 0 and 1. Ignoring invalid value:`,e),null):s;var i}wv(e){if(this.Il){var t,s;const i=this.Il,r=()=>{var n;const o=e.sessionRecording===!1?void 0:e.sessionRecording,a=this._v((n=this.Mr.session_recording)===null||n===void 0?void 0:n.sampleRate,"session_recording.sampleRate"),l=this._v(o?.sampleRate,"remote config sampleRate"),u=a??l;R(u)&&this.bv();const c=o?.minimumDurationMilliseconds;i.register({[es]:p(p({cache_timestamp:Date.now(),enabled:!!o},o),{},{networkPayloadCapture:p({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.dv)===null||t===void 0||t.call(this),this.dv=(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.wv(t),void this.fv()):(this.wv(t),void this.startIfEnabledOrStop()):(this.hv==="awaiting_config"&&(this.hv="missing_config",this._instance.register_for_session({[Ir]:!0}),qe.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(e,t="log"){var s;!((s=this.uv)===null||s===void 0)&&s.log?this.uv.log(e,t):qe.warn("log called before recorder was ready")}get yv(){var e,t;const s=(e=this._instance)===null||e===void 0||(e=e.persistence)===null||e===void 0?void 0:e.get_property(es);return(s==null||(t=s.scriptConfig)===null||t===void 0?void 0:t.script)||"lazy-recorder"}Sv(){const e=this._instance.get_property(es);if(!e)return!1;let t;try{t=typeof e=="object"?e:JSON.parse(e)}catch(s){return qe.warn("persisted remote config for session recording is invalid and will be ignored",s),!1}return!R(t.cache_timestamp)&&36e5>=Date.now()-t.cache_timestamp}mv(e){var t,s,i;if(!this.vv&&this.pv&&this._instance.sessionManager){if(!(!((t=F.__PosthogExtensions__)===null||t===void 0)&&t.initSessionRecording))return qe.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[Or]:!0});var r;if(this.uv||(this.uv=(r=F.__PosthogExtensions__)===null||r===void 0?void 0:r.initSessionRecording(this._instance,this.Je),this.uv._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.Sv())return this.hv==="missing_config"||this.hv==="awaiting_config"?void 0:(this.hv="awaiting_config",qe.info("persisted remote config is stale, requesting fresh config before starting"),void new vl(this._instance).load());this.hv=ro,(s=(i=this.uv).setDocumentWasEverVisible)===null||s===void 0||s.call(i,this.Je),this.uv.start(e)}else this.hv=Ni}onRRwebEmit(e){var t,s;(t=this.uv)===null||t===void 0||(s=t.onRRwebEmit)===null||s===void 0||s.call(t,e)}overrideLinkedFlag(){var e,t;this.uv||(t=this.Il)===null||t===void 0||t.register({$replay_override_linked_flag:!0}),(e=this.uv)===null||e===void 0||e.overrideLinkedFlag()}overrideSampling(){var e,t;this.uv||(t=this.Il)===null||t===void 0||t.register({$replay_override_sampling:!0}),(e=this.uv)===null||e===void 0||e.overrideSampling()}overrideTrigger(e){var t,s;this.uv||(s=this.Il)===null||s===void 0||s.register({[e==="url"?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),(t=this.uv)===null||t===void 0||t.overrideTrigger(e)}get sdkDebugProperties(){var e;const t={};for(const i of Lh){var s;const r=(s=this._instance.sessionPersistence)===null||s===void 0?void 0:s.get_property(i);x(r)||(t[i]=r)}return p(p({},t),((e=this.uv)===null||e===void 0?void 0:e.sdkDebugProperties)||{$recording_status:this.status})}tryAddCustomEvent(e,t){var s;return!!(!((s=this.uv)===null||s===void 0)&&s.tryAddCustomEvent(e,t))}flushBeforeIdentityReset(){var e,t;(e=this.uv)===null||e===void 0||(t=e.flushBeforeIdentityReset)===null||t===void 0||t.call(e)}}},nd={autocapture:class extends Fh{constructor(e){super(new Th(e)),this.instance=e}},historyAutocapture:class{constructor(e){this.xv=!1,this._instance=e,this.$v=this.Cv()}initialize(){this.startIfEnabled()}get isEnabled(){const e=this.Tv();return!!(e.path||e.search||this.Iv(e))}startIfEnabled(){this.isEnabled&&(S.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}startIfEnabledOrStop(){this.stop(),this.$v=this.Cv(),this.startIfEnabled()}stop(){this.Mv&&this.Mv(),this.Mv=void 0,this.Ev&&this.Ev(),this.Ev=void 0,S.info("History API monitoring stopped")}monitorHistoryChanges(){b&&b.history&&(this.Pv("pushState"),this.Pv("replaceState"),this.Rv(),this.Iv()&&this.Av())}Pv(e){var t;if(!b||!((t=b.history[e])===null||t===void 0)&&t.__posthog_wrapped__)return;const s=this;_s(b.history,e,i=>function(r,n,o){var a;s.Ov(o)&&s.Fv(),i.call(this,r,n,o),s.Dv(e,!s.xv&&(b==null||(a=b.event)===null||a===void 0?void 0:a.type)!=="popstate")})}Cv(){const e=b?.location;if(e?.pathname)return{pathname:e.pathname,search:e.search,hash:e.hash}}Tv(){const e=this._instance.config.capture_pageview;return e==="history_change"?{path:!0}:N(e)?e:{}}Iv(e=this.Tv()){return!!e.hash&&!this._instance.config.disable_capture_url_hashes}Lv(e){const t=this.Tv(),s=this.$v;return!(!s||!(t.path&&e.pathname!==s.pathname||t.search&&e.search!==s.search||this.Iv(t)&&e.hash!==s.hash))}Dv(e,t=!1){try{t||this.Fv();const s=this.Cv();if(!s)return;if(this.Lv(s)){const i=()=>this._instance.capture(Tr,{navigation_type:e});t?(this.Nv=i,Promise.resolve().then(()=>this.Fv())):i()}this.$v=s}catch(s){S.error(`Error capturing ${e} pageview`,s)}}Ov(e){var t,s;return!(R(e)||!b)&&((t=Ge(String(e)))===null||t===void 0?void 0:t.href)!==((s=b.location)===null||s===void 0?void 0:s.href)}Fv(){const e=this.Nv;if(e){this.Nv=void 0,this.xv=!0;try{e()}catch(t){S.error("Error capturing deferred pageview",t)}finally{this.xv=!1}this.$v=this.Cv()}}Rv(){if(this.Mv)return;const e=()=>{this.Dv("popstate")};z(b,"popstate",e),this.Mv=()=>{b&&b.removeEventListener("popstate",e)}}Av(){if(this.Ev)return;const e=()=>{this.Dv("hashchange")};z(b,"hashchange",e),this.Ev=()=>{b&&b.removeEventListener("hashchange",e)}}},heatmaps:class{get Mr(){return this.instance.config}constructor(e){var t;this.qv=!1,this.ko=!1,this.jv=null,this.instance=e,this.qv=!!(!((t=this.instance.persistence)===null||t===void 0)&&t.props[Qi]),this.rageclicks=new Nl(e.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){let e=5e3;return N(this.Mr.capture_heatmaps)&&this.Mr.capture_heatmaps.flush_interval_milliseconds&&(e=this.Mr.capture_heatmaps.flush_interval_milliseconds),e}get isEnabled(){return R(this.Mr.capture_heatmaps)?R(this.Mr.enable_heatmaps)?this.qv:this.Mr.enable_heatmaps:this.Mr.capture_heatmaps!==!1}startIfEnabled(){if(this.isEnabled){if(this.ko)return;Dh.info("starting..."),this.Bv(),this.sn()}else{var e;clearInterval((e=this.jv)!==null&&e!==void 0?e:void 0),this.Hv(),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({[Qi]:s}),this.qv=s,this.startIfEnabled()}getAndClearBuffer(){const e=this.Rt;return this.Rt=void 0,e}zv(e){ji(e.originalEvent)&&this.Ir(e.originalEvent,"deadclick")}sn(){this.jv&&clearInterval(this.jv),this.jv=k?.visibilityState==="visible"?setInterval(this.yl.bind(this),this.flushIntervalMilliseconds):null}Bv(){b&&k&&(this.Uv=this.yl.bind(this),z(b,Us,this.Uv),this.Wv=e=>this.Ir(e||b?.event),z(k,"click",this.Wv,{capture:!0}),this.Vv=e=>this.Gv(e||b?.event),z(k,"mousemove",this.Vv,{capture:!0}),this.Qv=new Fn(this.instance,Dc,this.zv.bind(this)),this.Qv.startIfEnabledOrStop(),this.Jv=this.sn.bind(this),z(k,ds,this.Jv),this.ko=!0)}Hv(){var e;b&&k&&(this.Uv&&b.removeEventListener(Us,this.Uv),this.Wv&&k.removeEventListener("click",this.Wv,{capture:!0}),this.Vv&&k.removeEventListener("mousemove",this.Vv,{capture:!0}),this.Jv&&k.removeEventListener(ds,this.Jv),clearTimeout(this.Zv),(e=this.Qv)===null||e===void 0||e.stop(),this.ko=!1)}Kv(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&&je(u)&&!ve(u,"body");){if(u===l)return!1;let v;try{var c,d,h;v=(c=(d=(h=u.ownerDocument)===null||h===void 0?void 0:h.defaultView)!==null&&d!==void 0?d:b)===null||c===void 0?void 0:c.getComputedStyle(u).position}catch{return!1}if(C(a,v))return!0;u=Xa(u)}return!1})(is(e),["fixed","sticky"],r);return{x:e.clientX+(n?0:i),y:e.clientY+(n?0:s),target_fixed:n,type:t}}Ir(e,t="click"){var s;if(wn(e.target)||!ji(e))return;const i=this.Kv(e,t);!((s=this.rageclicks)===null||s===void 0)&&s.isRageClick(e.clientX,e.clientY,new Date().getTime())&&Za(is(e),this.instance.config.rageclick)&&this.Qs(p(p({},i),{},{type:"rageclick"})),this.Qs(i)}Gv(e){!wn(e.target)&&ji(e)&&(clearTimeout(this.Zv),this.Zv=setTimeout(()=>{this.Qs(this.Kv(e,"mousemove"))},500))}Qs(e){if(!b)return;const t=this.Mr.disable_capture_url_hashes?nt(b.location.href):b.location.href,s=this.Mr.custom_personal_data_properties,i=this.Mr.mask_personal_data_properties?[...Lt,...s||[]]:[],r=fs(t,i,gs);this.Rt=this.Rt||{},this.Rt[r]||(this.Rt[r]=[]),this.Rt[r].push(e)}yl(){this.Rt&&!ke(this.Rt)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:Fn,webVitalsAutocapture:class{constructor(e){var t;this._instance=e,this.qv=!1,this.ko=!1,this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this.Xv=()=>{clearTimeout(this.Yv),this.Yv=void 0,this.Rt.metrics.length!==0&&(this._instance.capture("$web_vitals",p({$current_url:this.Rt.url},this.Rt.metrics.reduce((s,i)=>p(p({},s),{},{[`$web_vitals_${i.name}_event`]:p({},i),[`$web_vitals_${i.name}_value`]:i.value}),{}))),this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.tf=s=>{var i;if(this.Rt=this.Rt||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},R(s?.name)||R(s?.value))return void lt.error("Invalid metric received",s);const r=typeof s.navigationURL=="string"?s.navigationURL:void 0,n=this.ef(r);if(x(n))return;const o=ne(s.navigationId)||typeof s.navigationId=="string"?`navigation:${s.navigationId}`:`url:${n}`;if(this.if&&s.value>=this.if)return void lt.error("Ignoring metric with value >= "+this.if,s);this.Rt.navigationKey!==o&&(this.Xv(),this.Yv=setTimeout(this.Xv,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=p(p(p({},s),r?{navigationURL:n}:{}),{},{$current_url:n,timestamp:Date.now()});if(delete l.entries,N(s.attribution)&&this.attributionMetrics.indexOf(s.name)>-1){const u={};for(const c of Rh){const d=c==="url"&&typeof s.attribution[c]=="string"?this.ef(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.Xv()},this.nf=()=>{if(this.ko)return;let s,i,r,n,o=!1;const a=F.__PosthogExtensions__,l=a?.postHogWebVitalsCallbacksByFlavor,u=l?.[this.sf]||(this.sf==="web-vitals"&&x(l)?a?.postHogWebVitalsCallbacks:void 0);if(!x(u)){const h=u.withoutAttribution,v=this.attributionMetrics;o=!x(h),s=v.indexOf("LCP")>-1?u.onLCP:h?.onLCP||u.onLCP,i=v.indexOf("CLS")>-1?u.onCLS:h?.onCLS||u.onCLS,r=v.indexOf("FCP")>-1?u.onFCP:h?.onFCP||u.onFCP,n=v.indexOf("INP")>-1?u.onINP:h?.onINP||u.onINP}if(!(s&&i&&r&&n))return void lt.error("web vitals callbacks not loaded - not starting");const c={reportSoftNavs:this.useSoftNavs},d=o&&this.attributionMetrics.indexOf("INP")>-1?p(p({},c),{},{includeProcessedEventEntries:!1}):c;this.allowedMetrics.indexOf("LCP")>-1&&s(this.tf.bind(this),c),this.allowedMetrics.indexOf("CLS")>-1&&i(this.tf.bind(this),c),this.allowedMetrics.indexOf("FCP")>-1&&r(this.tf.bind(this),c),this.allowedMetrics.indexOf("INP")>-1&&n(this.tf.bind(this),d),this.ko=!0},this.qv=!!(!((t=this._instance.persistence)===null||t===void 0)&&t.props[sr]),this.startIfEnabled()}get rf(){return this._instance.config.capture_performance}get allowedMetrics(){var e,t;const s=N(this.rf)?(e=this.rf)===null||e===void 0?void 0:e.web_vitals_allowed_metrics:void 0;return R(s)?((t=this._instance.persistence)===null||t===void 0?void 0:t.props.$web_vitals_allowed_metrics)||io:s}get flushToCaptureTimeoutMs(){return(N(this.rf)?this.rf.web_vitals_delayed_flush_ms:void 0)||5e3}get attributionMetrics(){const e=N(this.rf)?this.rf.web_vitals_attribution:void 0;return we(e)?e?io:[]:A(e)?e:Ah}get useAttribution(){return this.attributionMetrics.length>0}get useSoftNavs(){const e=N(this.rf)?this.rf.__preview_web_vitals_soft_navs:void 0;return e!=null&&e}get if(){const e=N(this.rf)&&ne(this.rf.__web_vitals_max_value)?this.rf.__web_vitals_max_value:so;return e>0&&6e4>=e?so:e}get isEnabled(){const e=ee?.protocol;if(e!=="http:"&&e!=="https:")return lt.info("Web Vitals are disabled on non-http/https protocols"),!1;const t=N(this.rf)?this.rf.web_vitals:we(this.rf)?this.rf:void 0;return we(t)?t:this.qv}startIfEnabled(){this.isEnabled&&!this.ko&&(lt.info("enabled, starting..."),this.Ho(this.nf))}onRemoteConfig(e){if(!e.ok)return;const t=e.config;if(!("capturePerformance"in t))return;const s=N(t.capturePerformance)&&!!t.capturePerformance.web_vitals,i=N(t.capturePerformance)?t.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[sr]:s}),this._instance.persistence.register({[Ea]:i})),this.qv=s,this.startIfEnabled()}get sf(){return this.useSoftNavs?this.useAttribution?"web-vitals-with-attribution-soft-navs":"web-vitals-soft-navs":this.useAttribution?"web-vitals-with-attribution":"web-vitals"}Ho(e){var t;const s=F.__PosthogExtensions__,i=this.sf,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?lt.error("failed to load script",n):e()})}ef(e){const t=e||b?.location.href;if(!t)return void lt.error("Could not determine current URL");const s=this._instance.config.disable_capture_url_hashes?nt(t):t,i=this._instance.config.custom_personal_data_properties,r=this._instance.config.mask_personal_data_properties?[...Lt,...i||[]]:[];return fs(s,r,gs)}}},od={exceptionObserver:class{constructor(e){var t;this.nf=()=>{var s;if(!b||!this.isEnabled||!(!((s=F.__PosthogExtensions__)===null||s===void 0)&&s.errorWrappingFunctions))return;const i=F.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,r=F.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,n=F.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.af&&this.Mr.capture_unhandled_errors&&(this.af=i(this.captureException.bind(this))),!this.lf&&this.Mr.capture_unhandled_rejections&&(this.lf=r(this.captureException.bind(this))),!this.uf&&this.Mr.capture_console_errors&&(this.uf=n(this.captureException.bind(this)))}catch(o){Gt.error("failed to start",o),this.hf()}},this._instance=e,this.cf=!!(!((t=this._instance.persistence)===null||t===void 0)&&t.props[er]),this.wt=new iu(p(p({},(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,A:Gt})),this.Mr=this.df(),this.startIfEnabledOrStop()}df(){const e=this._instance.config.capture_exceptions;let t={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return N(e)?t=p(p({},t),e):(x(e)?this.cf:e)&&(t=p(p({},t),{},{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),t}get isEnabled(){return this.Mr.capture_console_errors||this.Mr.capture_unhandled_errors||this.Mr.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(Gt.info("enabled"),this.hf(),this.Ho(this.nf)):this.hf()}Ho(e){var t,s,i;!((t=F.__PosthogExtensions__)===null||t===void 0)&&t.errorWrappingFunctions?e():(s=F.__PosthogExtensions__)===null||s===void 0||(i=s.loadExternalDependency)===null||i===void 0||i.call(s,this._instance,"exception-autocapture",r=>{if(r)return Gt.error("failed to load script",r);e()})}hf(){var e,t,s;(e=this.af)===null||e===void 0||e.call(this),this.af=void 0,(t=this.lf)===null||t===void 0||t.call(this),this.lf=void 0,(s=this.uf)===null||s===void 0||s.call(this),this.uf=void 0}onRemoteConfig(e){if(!e.ok)return;const t=e.config;"autocaptureExceptions"in t&&(this.cf=!!t.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[er]:this.cf}),this.Mr=this.df(),this.startIfEnabledOrStop())}onConfigChange(){this.Mr=this.df()}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 Gt.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.vf=[],this.ff=new fu([new Iu,new ju,new Tu,new Fu,new Du,new Lu,new Au,new Nu],(function(i,...r){return(n,o=0)=>{const a=[],l=n.split(`
3
- `),u=Math.min(l.length,o+1e3),c=[];for(let v=o;u>v;v++){const f=l[v];if(f.length>1024)continue;const y=sn.test(f)?f.replace(sn,"$1"):f;if(!y.match(/\S*Error: /)){for(const g of r){const m=g(y,i);if(m){a.push(m);const _=Su(a);if(_){for(let w=c.length-1;w>=0;w--){const $=c[w];if(_.start>=$.start+$.length)break;c.pop()}c.push(_)}break}}if(Mu(a,c)>=50)break}}const d=[...c].sort((v,f)=>f.start-v.start),h=d[d.length-1];if(h){const v=oa(a,h);a.splice(h.start-v,v);for(const f of d)f.start-=v}for(const v of d)Pu(a,v);return c.some(v=>v.start===0&&a.length===v.length)&&(function(v){const f=v.map(g=>`${g.function}|${g.filename}|${g.lineno}|${g.colno}|${g.module}`);let y=0;for(let g=1;f.length>g;g++)Ou(f,g,y)&&(y=g);v.push(...v.splice(0,y))})(a),(function(v){if(!v.length)return[];const f=Array.from(v);return f.reverse(),f.slice(0,50).map(y=>{return p(p({},y),{},{filename:y.filename||(g=f,g[g.length-1]||{}).filename,function:y.function||"?"});var g})})(a)}})("web:javascript",xu,$u)),this._instance=e,this.vf=(t=(s=this._instance.persistence)===null||s===void 0?void 0:s.get_property("$error_tracking_suppression_rules"))!==null&&t!==void 0?t:[],this.pf=qs(this.gf()),this.mf=new qu(this.pf)}onConfigChange(){this.pf=qs(this.gf()),this.mf.setConfig(this.pf)}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.vf=n,this._instance.persistence&&this._instance.persistence.register({[xa]:this.vf,[tr]:o})}get yf(){var e;const t=!!this._instance.get_property(tr),s=this._instance.config.error_tracking.captureExtensionExceptions;return(e=s??t)!==null&&e!==void 0&&e}buildProperties(e,t){return this.ff.buildFromUnknown(e,{syntheticException:t?.syntheticException,mechanism:{handled:t?.handled}})}addExceptionStep(e,t){if(this.pf.enabled)try{if(!L(e)||e.trim().length===0)return void Ie.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)=>Bu.has(a)?(n.push(a),o):(o[a]=r[a],o),{}),droppedKeys:n}})(this.bf(t));i.length>0&&Ie.warn("Ignoring reserved exception step fields",{droppedKeys:i}),this.mf.add(p({[js]:e,[Bs]:new Date().toISOString()},s))}catch(s){Ie.error("Failed to add exception step. Ignoring breadcrumb.",s)}}sendExceptionEvent(e){try{const t=e.$exception_list;if(this._f(t)){if(this.wf(t))return this.kf("Exception dropped: matched a suppression rule"),void Ie.info("Skipping exception capture because a suppression rule matched");if(!this.yf&&this.Sf(t))return this.kf("Exception dropped: thrown by a browser extension"),void Ie.info("Skipping exception capture because it was thrown by an extension");if(!this.yf&&this.xf(t))return this.kf("Exception dropped: thrown by an injected browser script"),void Ie.info("Skipping exception capture because it was thrown by an injected browser script");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.$f(t))return this.kf("Exception dropped: thrown by the PostHog SDK"),void Ie.info("Skipping exception capture because it was thrown by the PostHog SDK")}const s=this.pf.enabled&&R(e.$exception_steps)?this.Cf(e):e,i=(function(){const r=globalThis._posthogReleaseId;return typeof r=="string"&&r.length>0?r:void 0})();i&&(s.$release_id=i);try{const r=this._instance.capture("$exception",s,{_noTruncate:!0,_batchKey:"exceptionEvent",gh:!0});return r&&this.mf.clear(),r}catch(r){return go(r)||Ie.error("Failed to capture exception event. Dropping this exception.",r),void this.mf.clear()}}catch(t){return void(go(t)||Ie.error("Failed to process exception event. Ignoring this exception.",t))}}Cf(e){try{const t=this.mf.getAttachable();return t.length===0?e:p(p({},e),{},{$exception_steps:t})}catch(t){return Ie.error("Failed to read buffered exception steps. Capturing exception without steps.",t),e}}kf(e){this.pf.enabled&&this.mf.add({[js]:e,[Bs]:new Date().toISOString()})}bf(e){return N(e)?p({},e):{}}gf(){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:{}}wf(e){if(e.length===0)return!1;try{const t=e.reduce((s,{type:i,value:r})=>(L(i)&&i.length>0&&s.$exception_types.push(i),L(r)&&r.length>0&&s.$exception_values.push(r),s),{$exception_types:[],$exception_values:[]});return this.vf.some(s=>{const i=s.values.map(r=>{const n=Al[r.operator],o=t[r.key];if(!n||!o)return!1;const a=A(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 Ie.warn("Failed to evaluate suppression rules. Capturing the exception.",t),!1}}Sf(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&&Jh.some(r=>i.startsWith(r)));return s.length!==0&&(!s.every(({filename:i})=>!!i&&i.startsWith(_r))||e.some(({type:i,value:r})=>i==="NoResponse"||L(r)&&Kh.some(({value:n,exact:o})=>o?r===n:r.includes(n)))&&!t.some(({in_app:i,filename:r})=>i&&!r?.startsWith(_r)))}xf(e){return e.some(({value:t})=>L(t)&&Xh.some(s=>t.includes(s)))}$f(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}_f(e){return!R(e)&&A(e)}}},ad=p({productTours:class{get Il(){return this._instance.persistence}constructor(e){this.Tf=null,this.If=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.Il&&this.Il.register({[Pr]:!!t.productTours}),!Bi(this._instance))return!this.Tf&&R((s=this.Il)===null||s===void 0?void 0:s.props.ph_product_tours)||Ps.info("product tours disabled; stopping and clearing cached tours"),(i=this.Tf)===null||i===void 0||i.stop(),this.Tf=null,void this.clearCache();this.loadIfEnabled()}}loadIfEnabled(){!this.Tf&&Bi(this._instance)&&this.Ho(()=>this.Mf())}Ho(e){var t,s,i;!((t=F.__PosthogExtensions__)===null||t===void 0)&&t.generateProductTours?e():(s=F.__PosthogExtensions__)===null||s===void 0||(i=s.loadExternalDependency)===null||i===void 0||i.call(s,this._instance,"product-tours",r=>{r?Ps.error("Could not load product tours script",r):e()})}Mf(){var e;!this.Tf&&(!((e=F.__PosthogExtensions__)===null||e===void 0)&&e.generateProductTours)&&(this.Tf=F.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,t=!1){if(A(this.If)&&!t)return void e(this.If,{isLoaded:!0});const s=this.Il;if(s){const i=s.props[rr];if(A(i)&&!t)return this.If=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(!Bi(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||Ps.warn(o):Ps.error(o),void e([],{isLoaded:!1,error:o})}const n=A(i.json.product_tours)?i.json.product_tours:[];this.If=n,s&&s.register({[rr]:n}),e(n,{isLoaded:!0})}})}getActiveProductTours(e){R(this.Tf)?e([],{isLoaded:!1,error:"Product tours not loaded"}):this.Tf.getActiveProductTours(e)}showProductTour(e){var t;(t=this.Tf)===null||t===void 0||t.showTourById(e)}previewTour(e){this.Tf?this.Tf.previewTour(e):this.Ho(()=>{var t;this.Mf(),(t=this.Tf)===null||t===void 0||t.previewTour(e)})}dismissProductTour(){var e;(e=this.Tf)===null||e===void 0||e.dismissTour("user_clicked_skip")}nextStep(){var e;(e=this.Tf)===null||e===void 0||e.nextStep()}previousStep(){var e;(e=this.Tf)===null||e===void 0||e.previousStep()}clearCache(){var e;this.If=null,(e=this.Il)===null||e===void 0||e.unregister("ph_product_tours")}resetTour(e){var t;(t=this.Tf)===null||t===void 0||t.resetTour(e)}resetAllTours(){var e;(e=this.Tf)===null||e===void 0||e.resetAllTours()}cancelPendingTour(e){var t;(t=this.Tf)===null||t===void 0||t.cancelPendingTour(e)}}},ri),ld={siteApps:class{constructor(e){this._instance=e,this.Ef=0,this.Pf=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}Rf(e,t){if(!t)return;const s=this.globalsForEvent(t);this.Pf.push(s),this.Pf.length>1e3&&(this.Pf=this.Pf.slice(10))}get siteAppLoaders(){var e;return(e=F._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.Rf.bind(this));this.Af=()=>{e(),this.Pf=[],this.Af=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[v,f]of Object.entries(c))l[v]={id:u[v],type:v,properties:f};const{$set_once:d,$set:h}=e;return{event:p(p({},ca(e,Nh)),{},{properties:p(p(p({},e.properties),h?{$set:p(p({},(t=(s=e.properties)===null||s===void 0?void 0:s.$set)!==null&&t!==void 0?t:{}),h)}:{}),d?{$set_once:p(p({},(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}}Of(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)||(Re.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)||(Re.error("prepare_external_dependency_script returned null"),null):e}Ff(){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=k?.defaultView,u=l==null||(e=l.Node)===null||e===void 0?void 0:e.prototype;if(!l||!u)return()=>{};if(this.Ef++,this.Df)return this.Lf();const c=[],d=this,h=new WeakSet,v=(g,m,_)=>{if(!g?.[m])return;const w=g[m];g[m]=_(w),c.push(()=>{g[m]=w})},f=g=>{if(h.has(g))return g;const m=d.Of(g);return m&&h.add(m),m},y=g=>g.map(m=>typeof m=="string"?m:f(m)).filter(m=>!te(m));return v(u,"appendChild",g=>function(m){const _=f(m);return _?g.call(this,_):m}),v(u,"insertBefore",g=>function(m,_){const w=f(m);return w?g.call(this,w,_):m}),v(u,"replaceChild",g=>function(m,_){const w=f(m);return w?g.call(this,w,_):_}),[(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=>{v(g,"append",m=>function(..._){return m.apply(this,y(_))}),v(g,"prepend",m=>function(..._){return m.apply(this,y(_))})}),[(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=>{v(g,"before",m=>function(..._){return m.apply(this,y(_))}),v(g,"after",m=>function(..._){return m.apply(this,y(_))}),v(g,"replaceWith",m=>function(..._){const w=y(_);return _.length&&!w.length?void 0:m.apply(this,w)})}),v((a=l.Element)===null||a===void 0?void 0:a.prototype,"insertAdjacentElement",g=>function(m,_){const w=f(_);return w?g.call(this,m,w):null}),this.Df=()=>{c.forEach(g=>g()),this.Df=void 0},this.Lf()}Lf(){let e=!1;return()=>{var t;e||(e=!0,this.Ef--,this.Ef===0&&((t=this.Df)===null||t===void 0||t.call(this)))}}Nf(e,t=!0){const s=this.Ff();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.Pf.length&&(Re.info(`Processing ${this.Pf.length} events for site app with id ${e.id}`),this.Pf.forEach(o=>this.Nf(()=>{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.Af)===null||n===void 0||n.call(this))};let i=!1;const r=n=>{t.errored=!n,t.loaded=!0,Re.info(`Site app with id ${e.id} ${n?"loaded":"errored"}`),i&&s()};try{const{processEvent:n}=this.Nf(o=>e.init({posthog:this._instance,callback(a){o(),r(a)}}),!1);n&&(t.processEvent=n),i=!0}catch(n){Re.error(no+e.id,n),r(!1)}if(i&&t.loaded)try{s()}catch(n){Re.error(`Error while processing buffered events PostHog app with config id ${e.id}`,n),t.errored=!0}}qf(){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)}jf(e){if(Object.keys(this.apps).length===0)return;const t=this.globalsForEvent(e);for(const s of Object.values(this.apps))try{this.Nf(()=>{var i;return(i=s.processEvent)===null||i===void 0?void 0:i.call(s,t)})}catch(i){Re.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.qf(),void this._instance.on("eventCaptured",a=>this.jf(a))):void Re.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if((s=this.Af)===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;F[`__$$ph_site_app_${a}`]=this._instance,(n=F.__PosthogExtensions__)===null||n===void 0||(o=n.loadSiteApp)===null||o===void 0||o.call(n,this._instance,l,u=>{if(u)return Re.error(no+a,u)})}else Re.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}},ud={tracingHeaders:class{constructor(e){this._instance=e,this.Bf=void 0,this.Hf=void 0,this.zf=void 0,this.nf=()=>{const t=this.Uf();var s,i;t?(x(this.Bf)&&(this.Bf=(s=F.__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.Hf)&&(this.Hf=(i=F.__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.hf()}}initialize(){this.startIfEnabledOrStop()}Ho(e){var t,s,i;!((t=F.__PosthogExtensions__)===null||t===void 0)&&t.tracingHeadersPatchFns?e():(s=F.__PosthogExtensions__)===null||s===void 0||(i=s.loadExternalDependency)===null||i===void 0||i.call(s,this._instance,"tracing-headers",r=>{if(r)return Ch.error("failed to load script",r);e()})}Wf(){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}Uf(){const e=this.Wf();return A(e)?(A(this.zf)?this.zf.splice(0,this.zf.length,...e):this.zf=[...e],e.length>0?this.zf:void 0):(A(this.zf)&&this.zf.splice(0),this.zf=e||void 0,this.zf)}hf(){var e,t;(e=this.Bf)===null||e===void 0||e.call(this),(t=this.Hf)===null||t===void 0||t.call(this),this.Bf=void 0,this.Hf=void 0}startIfEnabledOrStop(){this.Uf()?this.Ho(this.nf):this.hf()}}},cd=p({surveys:class extends jh{constructor(e){var t;super(new Vh(e),(t=e,{get projectToken(){return t.config.token},kv:new Wh(t)})),this._instance=e}Qh(e,t){const s=t.query?ys(e,t.query):e;return new Promise(i=>{var r;this._instance._send_request({method:t.method,url:this._instance.requestRouter.endpointFor((r=t.target)!==null&&r!==void 0?r:"api",s),data:t.body,headers:t.headers,timeout:t.timeoutMs,fireCallbackOnDrop:!0,transport:t.transport,compression:t.compression,timestampMode:t.sentAt,callback:i})})}}},ri),hd={toolbar:class{constructor(e){this.instance=e}Vf(e){F.ph_toolbar_state=e}Gf(){var e;return(e=F.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(or(this.instance.config)||!b||!k)return!1;e=(i=e)!==null&&i!==void 0?i:b.location,s=(r=s)!==null&&r!==void 0?r:b.history;try{if(!t){try{b.localStorage.setItem("test","test"),b.localStorage.removeItem("test")}catch{return!1}t=b?.localStorage}const n=zh||Ks(e.hash,"__posthog")||Ks(e.hash,"state");let o;const a=n?Zr(()=>JSON.parse(atob(decodeURIComponent(n))))||Zr(()=>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(ao)||"{}"),o.source="localstorage",delete o.userIntent),!(!o.token||this.instance.config.token!==o.token||(this.loadToolbar(o),0))}catch{return!1}}Qf(e){const t=F.ph_load_toolbar||F.ph_load_editor;!R(t)&&ue(t)?t(e,this.instance):lo.warn("No toolbar load function found")}loadToolbar(e){const t=!!k?.getElementById("__POSTHOG_TOOLBAR__");if(!b||t)return!1;const s=this.instance.requestRouter.region==="custom"&&this.instance.config.advanced_disable_toolbar_metrics,i=p(p({token:this.instance.config.token},e),{},{apiURL:this.instance.requestRouter.endpointFor("ui")},s?{instrument:!1}:{});if(b.localStorage.setItem(ao,JSON.stringify(p(p({},i),{},{source:void 0}))),this.Gf()===2)this.Qf(i);else if(this.Gf()===0){var r,n;this.Vf(1),(r=F.__PosthogExtensions__)===null||r===void 0||(n=r.loadExternalDependency)===null||n===void 0||n.call(r,this.instance,"toolbar",o=>{if(o)return lo.error("[Toolbar] Failed to load",o),void this.Vf(0);this.Vf(2),this.Qf(i)}),z(b,"turbolinks:load",()=>{this.Vf(0),this.loadToolbar(i)})}return!0}Jf(e){return this.loadToolbar(e)}maybeLoadEditor(e=void 0,t=void 0,s=void 0){return this.maybeLoadToolbar(e,t,s)}}},dd=p({experiments:class me{get Mr(){return this._instance.config}constructor(t){this._instance=t,this.getWebExperimentsAndEvaluateDisplayLogic=(s=!1)=>{this.getWebExperiments(i=>{me.Zf("retrieved web experiments from the server"),this.Kf=new Map,i.forEach(r=>{if(r.feature_flag_key){var n;this.Kf&&(me.Zf("setting flag key ",r.feature_flag_key," to web experiment ",r),(n=this.Kf)===null||n===void 0||n.set(r.feature_flag_key,r));const o=this._instance.getFeatureFlag(r.feature_flag_key);L(o)&&r.variants[o]&&this.Xf(r.name,o,r.variants[o].transforms)}else if(r.variants)for(const o in r.variants){const a=r.variants[o];me.Yf(a,this._instance)&&this.Xf(r.name,o,a.transforms)}})},s)},this._instance.onFeatureFlags(s=>{this.onFeatureFlags(s)})}initialize(){}onFeatureFlags(t){if(this._is_bot())me.Zf(_o);else if(!this.Mr.disable_web_experiments){if(R(this.Kf))return this.Kf=new Map,this.loadIfEnabled(),void this.previewWebExperiment();me.Zf("applying feature flags",t),t.forEach(s=>{var i;if(this.Kf&&(!((i=this.Kf)===null||i===void 0)&&i.has(s))){var r;const n=this._instance.getFeatureFlag(s),o=(r=this.Kf)===null||r===void 0?void 0:r.get(s);n&&o?.variants[n]&&this.Xf(o.name,n,o.variants[n].transforms)}})}}previewWebExperiment(){const t=me.getWindowLocation();if(t?.search){const s=Rt(t?.search,"__experiment_id"),i=Rt(t?.search,"__experiment_variant");s&&i&&(me.Zf(`previewing web experiments ${s} && ${i}`),this.getWebExperiments(r=>{this.tp(parseInt(s),i,r)},!1,!0))}}loadIfEnabled(){this.Mr.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(t,s,i){if(this.Mr.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.Mr.token}`),method:"GET",timestampMode:"query",callback:n=>t(n.statusCode===200&&n.json&&n.json.experiments||[])})}tp(t,s,i){const r=i.filter(n=>n.id===t);r&&r.length>0&&(me.Zf(`Previewing web experiment [${r[0].name}] with variant [${s}]`),this.Xf(r[0].name,s,r[0].variants[s].transforms))}static Yf(t,s){return!R(t.conditions)&&me.ep(t,s)&&me.np(t)}static ep(t,s){var i;if(R(t.conditions)||R((i=t.conditions)===null||i===void 0?void 0:i.url))return!0;const r=me.getWindowLocation();if(r){var n,o,a;const l=Ga(s,r.href);return!(!((n=t.conditions)===null||n===void 0)&&n.url)||Yh[(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 b?.location}static np(t){var s;if(R(t.conditions)||R((s=t.conditions)===null||s===void 0?void 0:s.utm))return!0;const i=nl();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,v=!(!((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,f=!(!((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,y=!(!((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&&f&&y&&v}return!1}static Zf(t,...s){S.info(`[WebExperiments] ${t}`,s)}Xf(t,s,i){this._is_bot()?me.Zf(_o):s!=="control"?i.forEach(r=>{if(r.selector){var n;me.Zf(`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)})}}):me.Zf("Control variants leave the page unmodified.")}_is_bot(){return ce&&this._instance?Fl(ce,this.Mr.custom_blocked_useragents):void 0}}},ri),pd={conversations:class{constructor(e){this._instance=e,this.sp=void 0,this._conversationsManager=null,this.rp=!1,this.ne=null,this.op=!1}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(this._instance.config.disable_conversations||(this.ap=e.ok,!e.ok))return;const t=e.config.conversations;R(t)||(we(t)?this.sp=t:(this.sp=t.enabled,this.ne=t),this.loadIfEnabled())}reset(){var e;(e=this._conversationsManager)===null||e===void 0||e.reset(),this._conversationsManager=null,this.sp=void 0,this.ne=null,this.ap=void 0,this.op=!1}loadIfEnabled(){if(this._conversationsManager||this.rp||this._instance.config.disable_conversations||or(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())return;const e=F?.__PosthogExtensions__;if(e&&!x(this.sp)&&this.sp)if(this.ne&&this.ne.token){this.rp=!0;try{const t=e.initConversations;if(t)return this.lp(t),void(this.rp=!1);const s=e.loadExternalDependency;if(!s)return void this.up(Fr);s(this._instance,"conversations",i=>{i||!e.initConversations?this.up("Could not load conversations script",i):this.lp(e.initConversations),this.rp=!1})}catch(t){this.up("Error initializing conversations",t),this.rp=!1}}else Me.error("Conversations enabled but missing token in remote config.")}lp(e){if(this.ne)try{this._conversationsManager=e(this.ne,this._instance),this.op=!1,Me.info("Conversations loaded successfully")}catch(t){this.up("Error completing conversations initialization",t)}else Me.error("Cannot complete initialization: remote config is null")}up(e,t){Me.error(e,t),this._conversationsManager=null,this.rp=!1,this.op=!0}show(){this._conversationsManager?this._conversationsManager.show():Me.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return this.sp===!0&&!te(this._conversationsManager)}getUnavailableReason(){return this.isAvailable()?null:this._instance.config.disable_conversations?"disabled_by_config":or(this._instance.config)?"disabled_for_toolbar":this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut()?"consent_opted_out":this.ap===!1?"remote_config_failed":x(this.sp)?this.ap?"disabled_in_project":"remote_config_pending":this.sp?R(this.ne)||!this.ne.token?"missing_token":F?.__PosthogExtensions__?this.rp?"initializing":this.op?"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 Z(function*(){return i._conversationsManager?i._conversationsManager.sendMessage(e,t,s):(Me.warn(ct),null)})()}getMessages(e,t){var s=this;return Z(function*(){return s._conversationsManager?s._conversationsManager.getMessages(e,t):(Me.warn(ct),null)})()}markAsRead(e){var t=this;return Z(function*(){return t._conversationsManager?t._conversationsManager.markAsRead(e):(Me.warn(ct),null)})()}getTickets(e){var t=this;return Z(function*(){return t._conversationsManager?t._conversationsManager.getTickets(e):(Me.warn(ct),null)})()}requestRestoreLink(e){var t=this;return Z(function*(){return t._conversationsManager?t._conversationsManager.requestRestoreLink(e):(Me.warn(ct),null)})()}restoreFromToken(e){var t=this;return Z(function*(){return t._conversationsManager?t._conversationsManager.restoreFromToken(e):(Me.warn(ct),null)})()}restoreFromUrlToken(){var e=this;return Z(function*(){return e._conversationsManager?e._conversationsManager.restoreFromUrlToken():(Me.warn(ct),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}$h(){var e;(e=this._conversationsManager)===null||e===void 0||e.setIdentity()}Ch(){var e;(e=this._conversationsManager)===null||e===void 0||e.clearIdentity()}}},vd={logs:class{constructor(e){var t;this._instance=e,this.name="logs",this.hp=!1,this.cp=!1,this.dp=!1,this.A=ie("[logs]"),this.vp=p(p({},this.A),{},{error:(...s)=>{s.some(bo)||this.A.error(...s)}}),this.ol=[],this.fp=[],this.kd=0,this.To=!1,this.pp=[],this.gp=[],this.mp=!1,this.yp=!1,this.bp=()=>{var s,i;this.To||(this.kd=0,(s=this._p)===null||s===void 0||s.onReconnect(),(i=this.wp)===null||i===void 0||i.onReconnect())},this._instance&&(!((t=this._instance.config.logs)===null||t===void 0)&&t.captureConsoleLogs)&&(this.hp=!0),b&&z(b,"online",this.bp)}kp(e,t,s,i){var r;const n=mo((r=this._instance)===null||r===void 0||(r=r.config)===null||r===void 0?void 0:r.logs,s);return[new Yu(this.Sp(e,t),n,this.vp,()=>this.xp(),o=>o(),void 0,i),n]}$p(){var e;const t=(e=this._instance)===null||e===void 0||(e=e.config)===null||e===void 0?void 0:e.logs;var s;return this._p&&this.Cp===t||((s=this._p)===null||s===void 0||s.reset(),this.Cp=t,[this._p,this.Tp]=this.kp(()=>this.ol,i=>{this.ol=i})),this._p}Ip(){var e;const t=(e=this._instance)===null||e===void 0||(e=e.config)===null||e===void 0?void 0:e.logs;var s;return this.wp&&this.Mp===t||((s=this.wp)===null||s===void 0||s.reset(),this.Mp=t,[this.wp,this.Ep]=this.kp(()=>this.fp,i=>{this.fp=i},{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},yo)),this.wp}setup(e){var t;if(this.To)return;this.bo=e,!((t=this._instance)===null||t===void 0||(t=t.config)===null||t===void 0||(t=t.logs)===null||t===void 0)&&t.captureConsoleLogs&&(this.hp=!0),(this.hp||this.Pp()&&this.Rp())&&this.Ap();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.To?i.dispose():(this.Eo=i,s||this.loadIfEnabled())}dispose(){var e,t,s,i;this.To||(this.To=!0,this.Op(),(e=this.Eo)===null||e===void 0||e.dispose(),this.Eo=void 0,this.bo=void 0,this.dp=!1,b?.removeEventListener("online",this.bp),(t=this.Fp)===null||t===void 0||t.call(this),this.Fp=void 0,(s=this._p)===null||s===void 0||s.reset(),(i=this.wp)===null||i===void 0||i.reset())}onRemoteConfig(e){var t,s;if(this.To)return;const i=e.ok?(t=e.config.logs)===null||t===void 0?void 0:t.captureConsoleLogs:void 0;R(i)?this.Dp():((s=this._instance)===null||s===void 0||(s=s.persistence)===null||s===void 0||s.register({$logs_capture_enabled_server_side:!!i}),i?(this.hp=!0,this.cp||this.Ap(),this.loadIfEnabled()):this.Dp())}reset(){var e,t,s,i;this.Op(),(e=this._p)===null||e===void 0||e.clearQueue(),this.ol=[],(t=this._p)===null||t===void 0||t.reset(),(s=this.wp)===null||s===void 0||s.clearQueue(),this.fp=[],(i=this.wp)===null||i===void 0||i.reset(),this.kd=0}captureLog(e){this.To||this.$p().captureLog(e)}captureConsoleLog(e){this.To||this.Ip().captureLog(e)}captureBufferedConsoleLog(e,t,s){this.To||this.Ip().captureLog(e,{context:t,occurredAtMs:s})}Rp(){var e;return!!(!((e=this._instance)===null||e===void 0||(e=e.persistence)===null||e===void 0||(e=e.props)===null||e===void 0)&&e[ka])}Pp(){var e,t,s;return!(!((e=this._instance)===null||e===void 0||(t=e.il)===null||t===void 0)&&t.call(e))||!!(!((s=F._POSTHOG_REMOTE_CONFIG)===null||s===void 0||(s=s[this._instance.config.token])===null||s===void 0)&&s.config)}Ih(){var e;this.Op(),(e=this.wp)===null||e===void 0||e.clearQueue(),this.fp=[]}Dp(){this.hp||this.Op()}Ap(){var e;if(this.mp||!F?.console)return;const t=mo((e=this._instance)===null||e===void 0||(e=e.config)===null||e===void 0?void 0:e.logs).maxBufferSize;let s=!0;this.gp.push(()=>{s=!1});for(const i of Zh){let r;try{r=Qh(F.console[i])}catch{continue}r&&this.gp.push(_s(F.console,i,n=>{const o=(...a)=>{try{s&&this.Lp(i,a,t)}catch{}return n.apply(F.console,a)};return o.__rrweb_original__=r,o}))}this.mp=!0,this.Np=setTimeout(()=>{this.Op()},3e4)}Lp(e,t,s){var i;if(this.mp&&!this.yp&&t.length!==0)if(!((i=this._instance)===null||i===void 0)&&i.is_capturing()){if(s>this.pp.length){this.yp=!0;try{this.pp.push({level:e,args:t,occurredAtMs:Date.now(),context:this.xp()})}finally{this.yp=!1}}}else this.Op()}Op(){if(this.pp=[],this.mp){this.mp=!1,this.Np&&(clearTimeout(this.Np),this.Np=void 0);for(const e of this.gp)e();this.gp=[]}}qp(){const e=this.pp;return this.Op(),e}get logger(){return this.jp||(this.jp={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.jp}flushLogs(e){e?this.Bp(e):(this._p&&this._p.flush().catch(t=>this.Hp(t)),this.wp&&this.wp.flush().catch(t=>this.Hp(t)))}Hp(e){bo(e)||this.A.error("PostHog logs flush failed:",e)}loadIfEnabled(){if(this.To||!this.hp||this.cp||this.dp)return;const e=F?.__PosthogExtensions__;if(!e)return this.A.error("PostHog Extensions not found."),void this.Op();const t=e.loadExternalDependency;if(!t)return this.A.error(Fr),void this.Op();this.dp=!0;try{t(this._instance,"logs",s=>{if(this.dp=!1,this.To||!this.hp)return;const i=e.logs;if(s||!i?.initializeLogs)this.A.error("Could not load logs script",s),this.Op();else{var r;const a=this.qp();var n,o;this.Fp=i.initializeLogs((r=this.bo)!==null&&r!==void 0?r:this._instance),this.cp=!0,a.length>0&&((n=i.replayConsoleBuffer)===null||n===void 0||n.call(i,(o=this.bo)!==null&&o!==void 0?o:this._instance,a))}})}catch(s){throw this.dp=!1,s}}Sp(e,t){const s=this._instance;return{get isDisabled(){return!1},get optedOut(){return!s.is_capturing()},getPersistedProperty:i=>i===De.LogsQueue?e():void 0,setPersistedProperty(i,r){var n;i===De.LogsQueue&&t((n=r)!==null&&n!==void 0?n:[])},js:i=>this.js(i),getLibraryId:()=>le.LIB_NAME,getLibraryVersion:()=>le.LIB_VERSION}}js(e){return new Promise(t=>{if(il(this.kd,3))return void t({kind:"fatal",error:Hi(void 0,"logs endpoint is unreachable, dropping batch")});let s=!1;const i=n=>{s||(s=!0,clearTimeout(r),t(n))},r=setTimeout(()=>{this.A.warn("Logs request timed out before receiving a response"),i({kind:"retry-later",error:Hi(void 0,"logs request timed out")})},9e4);this._instance._send_request({method:"POST",url:this.zp(),data:e,compression:"best-available",batchKey:"logs",fireCallbackOnDrop:!0,callback:n=>{const o=n.statusCode;if(this.Up(o),o>=200&&300>o)i({kind:"ok"});else if(o===413)i({kind:"too-large"});else if(o!==0&&o!==408&&o!==429&&500>o)i({kind:"fatal",error:new Error(`logs request failed with status ${o}`)});else{var a;o===0?(n.error||this.A.warn("Logs request failed before receiving an HTTP response"),i({kind:"retry-later",error:Hi(n.error,"logs request failed before receiving an HTTP response")})):i({kind:"retry-later",error:(a=n.error)!==null&&a!==void 0?a:new Error(`logs request failed with status ${o}`)})}}})})}Up(e){(e!==0||this._instance.__loaded)&&(this.kd=rl(e,this.kd,3,()=>this.A.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.")))}Bp(e){this.ol.length>0&&this.Wp(e,this.ol,this.Tp,le.LIB_NAME,t=>{this.ol=t}),this.fp.length>0&&this.Wp(e,this.fp,this.Ep,yo,t=>{this.fp=t})}Wp(e,t,s,i,r){if(t.length===0)return;const n=t.map(a=>a.record);r([]);const o=ga(n,fa(s,le.LIB_NAME,le.LIB_VERSION),i,le.LIB_VERSION);this._instance._send_request({method:"POST",url:this.zp(),data:o,compression:"best-available",batchKey:"logs",transport:e})}zp(){return this._instance.requestRouter.endpointFor("api","/i/v1/logs")+"?token="+encodeURIComponent(this._instance.config.token)}xp(){var e;const t={};if(t.distinctId=this._instance.get_distinct_id(),this._instance.sessionManager){const{sessionId:s,windowId:i,sessionStartTimestamp:r,lastActivityTimestamp:n}=this._instance.sessionManager.checkAndGetSessionAndWindowId(!0);t.sessionId=s,t.windowId=i,R(r)||(t.sessionStartTimestamp=r),R(n)||(t.lastActivityTimestamp=n)}if(!(F==null||(e=F.location)===null||e===void 0)&&e.href&&(t.currentUrl=this._instance.config.disable_capture_url_hashes?nt(F.location.href):F.location.href),this._instance.featureFlags){const s=this._instance.featureFlags.getFlags();s&&s.length>0&&(t.activeFeatureFlags=s)}return t}}},fd={metrics:class{constructor(e){this._instance=e,this.A=ie("[metrics]"),this.To=!1}initialize(){this.onConfigChange()}onConfigChange(){var e;if(this.To)return;const t=!!(!((e=this._instance.config.metrics)===null||e===void 0)&&e.network);t&&!this.Vp?this.Vp=(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=sd(s,r),o=id(s,r);return()=>{i=!1,n(),o()}})(this._instance):!t&&this.Vp&&(this.Vp(),this.Vp=void 0)}$p(){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._p&&this.Cp===t||((s=this._p)===null||s===void 0||s.reset(),this.Cp=t,this._p=new Zu(this.Sp(),(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.A)),this._p}count(e,t=1,s){this.$p().count(e,t,s)}gauge(e,t,s){this.$p().gauge(e,t,s)}histogram(e,t,s){this.$p().histogram(e,t,s)}flush(e){if(!this._p)return Promise.resolve();if(e){const t=this._p.drainWindow();return t&&this.Ys(t,e),Promise.resolve()}return this._p.flush().catch(t=>this.A.error("PostHog metrics flush failed:",t))}reset(){var e;(e=this._p)===null||e===void 0||e.reset()}dispose(){var e,t;this.To=!0,(e=this.Vp)===null||e===void 0||e.call(this),this.Vp=void 0,(t=this._p)===null||t===void 0||t.reset()}Sp(){const e=this._instance,t=this;return{get isDisabled(){return!1},get optedOut(){return!e.is_capturing()},Ys:s=>t.Ys(s),getLibraryId:()=>le.LIB_NAME,getLibraryVersion:()=>le.LIB_VERSION}}Ys(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(p(p({method:"POST",url:this.Gp(),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}`)})}}}))})}Gp(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}}};ls.__defaultExtensionClasses=p({},p(p(p(p(p(p(p(p(p(p(p(p(p({},ri),rd),nd),od),ad),ld),cd),ud),hd),dd),pd),vd),fd));const gd=(function(){le.SDK_DIST_CHANNEL="npm";const e=os[Xt]=new ls;return(function(){function t(){t.done||(t.done=!0,Ol=!1,K(os,function(s){s._dom_loaded()}))}k?.addEventListener?k.readyState==="complete"?t():z(k,"DOMContentLoaded",t,{capture:!1}):b&&S.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")})(),e})();var _d=gd;export{Se as Compression,hr as DisplaySurveyType,ls as PostHog,Kc as ProductTourEventName,Ln as ProductTourEventProperties,$e as SurveyEventName,Pi as SurveyEventProperties,Vt as SurveyEventType,Si as SurveyType,_d as default,gd as posthog};