tokentracker-cli 0.94.0 → 0.95.0

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 (130) hide show
  1. package/README.de.md +9 -7
  2. package/README.ja.md +8 -6
  3. package/README.ko.md +8 -6
  4. package/README.md +23 -10
  5. package/README.zh-CN.md +8 -6
  6. package/dashboard/dist/assets/{AchievementBadge-DPqwk2zI.js → AchievementBadge-Pi3Gvbm8.js} +1 -1
  7. package/dashboard/dist/assets/{AchievementsPage-CELHoMQt.js → AchievementsPage-C4WLT8Rl.js} +2 -2
  8. package/dashboard/dist/assets/{AchievementsSection-DdAC0VCb.js → AchievementsSection-ilvR2ssr.js} +1 -1
  9. package/dashboard/dist/assets/{BadgeDetailModal-Dd4I1SpM.js → BadgeDetailModal-CjEeToxa.js} +1 -1
  10. package/dashboard/dist/assets/{BotAnimated-DL2-4mnm.js → BotAnimated-DDf9pBuK.js} +1 -1
  11. package/dashboard/dist/assets/{Card-B_MpSRse.js → Card-DNous84-.js} +1 -1
  12. package/dashboard/dist/assets/{ClawdAnimated-BLZZ4rG6.js → ClawdAnimated-BLMIRntb.js} +2 -2
  13. package/dashboard/dist/assets/{CommandPalette-B-vfdIbH.js → CommandPalette-vVekhoFO.js} +1 -1
  14. package/dashboard/dist/assets/CommunityStatsModal-C0Kp_J8B.js +1 -0
  15. package/dashboard/dist/assets/{ConfirmModal-DLnRwUXC.js → ConfirmModal-DFdpcx12.js} +1 -1
  16. package/dashboard/dist/assets/{Controls-FZ8wEN5w.js → Controls-RNhqybmE.js} +1 -1
  17. package/dashboard/dist/assets/DashboardPage-BQjQh1IQ.js +1 -0
  18. package/dashboard/dist/assets/{DevicePage-D2IzPc5o.js → DevicePage-DIhh-YAk.js} +1 -1
  19. package/dashboard/dist/assets/{DialogClose-BaqQaUUk.js → DialogClose-ZqxYVIzl.js} +1 -1
  20. package/dashboard/dist/assets/DialogDescription-DDM4aanX.js +1 -0
  21. package/dashboard/dist/assets/{DialogTitle-DrbKjtuS.js → DialogTitle-BiRcejlu.js} +1 -1
  22. package/dashboard/dist/assets/{FadeIn-GddKDE8i.js → FadeIn-BDBQpeGe.js} +1 -1
  23. package/dashboard/dist/assets/{HeaderGithubStar-DUu-Z5mE.js → HeaderGithubStar-CztIwtKT.js} +1 -1
  24. package/dashboard/dist/assets/{HoverTooltip-BmDkY35A.js → HoverTooltip-Cfso7LTC.js} +1 -1
  25. package/dashboard/dist/assets/{IpCheckPage-CGJyqWk2.js → IpCheckPage-CNE7dLs3.js} +1 -1
  26. package/dashboard/dist/assets/{LandingPage-Bd91ALUj.js → LandingPage-B2a3cweM.js} +2 -2
  27. package/dashboard/dist/assets/{LeaderboardAvatar-BGGUwXFd.js → LeaderboardAvatar-CwmZnIji.js} +1 -1
  28. package/dashboard/dist/assets/{LeaderboardPage-BMEqHwif.js → LeaderboardPage-DkTHj3fB.js} +2 -2
  29. package/dashboard/dist/assets/{LeaderboardProfileModal-BSweJqm2.js → LeaderboardProfileModal-CefTO3Zh.js} +3 -3
  30. package/dashboard/dist/assets/{LeaderboardProfilePage-CRrI3RFz.js → LeaderboardProfilePage-CnOXlQ3L.js} +1 -1
  31. package/dashboard/dist/assets/{LimitsPage-XIRDv46K.js → LimitsPage-BIZ1-6BB.js} +2 -2
  32. package/dashboard/dist/assets/{LocalOnlyNotice-CCD-lGWG.js → LocalOnlyNotice-CdHQiPhy.js} +1 -1
  33. package/dashboard/dist/assets/{LoginCard-lDuqSv4f.js → LoginCard-yXLA9geu.js} +1 -1
  34. package/dashboard/dist/assets/{LoginModal-DStt5VXN.js → LoginModal-BF2Pfkqa.js} +1 -1
  35. package/dashboard/dist/assets/{LoginPage-dmVPSL72.js → LoginPage-DuOypZap.js} +1 -1
  36. package/dashboard/dist/assets/{PetPage-ybcZRctF.js → PetPage-BH3xDVV9.js} +1 -1
  37. package/dashboard/dist/assets/{PopoverPopup-Dar_UjxF.js → PopoverPopup-CewF_cGz.js} +1 -1
  38. package/dashboard/dist/assets/{ProviderIcon-Ct9tILpz.js → ProviderIcon-Dg0K0RPn.js} +1 -1
  39. package/dashboard/dist/assets/{ResetPasswordPage-B4yLh5zx.js → ResetPasswordPage-CYwt85O3.js} +1 -1
  40. package/dashboard/dist/assets/{SegmentedControl-BOE1CEzq.js → SegmentedControl-BJkXXomQ.js} +1 -1
  41. package/dashboard/dist/assets/{Select-D-bSh7Zz.js → Select-B3_WH0Qe.js} +1 -1
  42. package/dashboard/dist/assets/{SelectItemText-DMYjXXq4.js → SelectItemText-BUby_DUu.js} +1 -1
  43. package/dashboard/dist/assets/{ServiceStatusPage-CaleS-6_.js → ServiceStatusPage-BDlVZk4i.js} +1 -1
  44. package/dashboard/dist/assets/SessionsPage-TaC9nahK.js +2 -0
  45. package/dashboard/dist/assets/{SettingsPage-iJH0Yyah.js → SettingsPage-CudcQh6m.js} +2 -2
  46. package/dashboard/dist/assets/SkillsPage-iDLQ8lpZ.js +1 -0
  47. package/dashboard/dist/assets/{TokenGalaxy-CuXKoMPg.js → TokenGalaxy-DtYzUsXU.js} +1 -1
  48. package/dashboard/dist/assets/{ToolbarRootContext-Dx5GB7F5.js → ToolbarRootContext-PC8Tg1Jz.js} +1 -1
  49. package/dashboard/dist/assets/TrendMonitor-r8n8YO_9.js +19 -0
  50. package/dashboard/dist/assets/{WidgetsPage-DUaIyGtu.js → WidgetsPage-vzfGccWb.js} +1 -1
  51. package/dashboard/dist/assets/{WrappedPage-BzqlcAUC.js → WrappedPage-DaKuIkYE.js} +1 -1
  52. package/dashboard/dist/assets/{__vite-browser-external-BHz2N7Ih.css → __vite-browser-external-CCMdjCX2.css} +1 -1
  53. package/dashboard/dist/assets/__vite-browser-external-Dnxl50k1.js +45 -0
  54. package/dashboard/dist/assets/{agent-logos-BdWWxza6.js → agent-logos-B7nzn3n2.js} +1 -1
  55. package/dashboard/dist/assets/{arrow-up-right-CANSzmm-.js → arrow-up-right-CsxyvCER.js} +1 -1
  56. package/dashboard/dist/assets/{check-BnJpzXRZ.js → check-hYcC7MdH.js} +1 -1
  57. package/dashboard/dist/assets/{composite-Ccj6KQmh.js → composite-C79LNbex.js} +1 -1
  58. package/dashboard/dist/assets/{copy-C2Yc8Evu.js → copy-Cz4qzE62.js} +1 -1
  59. package/dashboard/dist/assets/{download-B52JTk6Y.js → download-CUaSNE2E.js} +1 -1
  60. package/dashboard/dist/assets/{external-link-DayTwZx-.js → external-link-vq7kIyKK.js} +1 -1
  61. package/dashboard/dist/assets/{flame-B8GEX2yT.js → flame-CB6K4eR6.js} +1 -1
  62. package/dashboard/dist/assets/{format-tokens-mhkbohkb.js → format-tokens-KI-e_JQ-.js} +1 -1
  63. package/dashboard/dist/assets/{icons-o8bPXqRP.js → icons-3maItkrp.js} +1 -1
  64. package/dashboard/dist/assets/{index-MBVWUKpA.js → index-BRXoZ7Jj.js} +1 -1
  65. package/dashboard/dist/assets/{index-CK_CduLm.js → index-C5WrfmLB.js} +1 -1
  66. package/dashboard/dist/assets/{index-Bp0ZHDtz.js → index-CUbC50Zp.js} +1 -1
  67. package/dashboard/dist/assets/{info-D94QM_vX.js → info-r0yGihUe.js} +1 -1
  68. package/dashboard/dist/assets/{limits-providers-BLzMyCiy.js → limits-providers-BN_94oe9.js} +1 -1
  69. package/dashboard/dist/assets/{link-2-CqBmFaDI.js → link-2-J9t0VXWM.js} +1 -1
  70. package/dashboard/dist/assets/{loader-circle-SaxUpDR6.js → loader-circle-DCvOsPze.js} +1 -1
  71. package/dashboard/dist/assets/{maximize-2-BoXqARks.js → maximize-2-CZ9JhGjf.js} +1 -1
  72. package/dashboard/dist/assets/{modifiers.esm-Conh_-BD.js → modifiers.esm-DJ0_WKg0.js} +1 -1
  73. package/dashboard/dist/assets/module-xpSFyNBK.js +3 -0
  74. package/dashboard/dist/assets/{monitor-smartphone-D6qLR9qd.js → monitor-smartphone-nqbWjJx_.js} +1 -1
  75. package/dashboard/dist/assets/{plus-D51mjIc2.js → plus-Cg7wd2jK.js} +1 -1
  76. package/dashboard/dist/assets/{provider-display-DpHPjd_s.js → provider-display-B9L1nRY9.js} +2 -2
  77. package/dashboard/dist/assets/{react-D_AcI466.js → react-D2AD6Pk2.js} +1 -1
  78. package/dashboard/dist/assets/{search-CwLcNdvZ.js → search-uNiWba1h.js} +1 -1
  79. package/dashboard/dist/assets/{skills-api-Dqi7Mjgo.js → skills-api-BBYuAhiL.js} +1 -1
  80. package/dashboard/dist/assets/{sortable.esm-BPDlUxPb.js → sortable.esm-CzPxc949.js} +1 -1
  81. package/dashboard/dist/assets/{store-ikeRIRGd.js → store-D4A7EUwE.js} +1 -1
  82. package/dashboard/dist/assets/{terminal-BfeX3L5T.js → terminal-Crmm_yKF.js} +1 -1
  83. package/dashboard/dist/assets/{trash-2-5_Qlp1k7.js → trash-2-ia9VjRnU.js} +1 -1
  84. package/dashboard/dist/assets/{use-community-stats-D90Fy2_j.js → use-community-stats-KaGCAxaF.js} +1 -1
  85. package/dashboard/dist/assets/use-latest-request-guard-Dy8gSDkk.js +1 -0
  86. package/dashboard/dist/assets/{use-limits-display-prefs-D4BYFaa-.js → use-limits-display-prefs-JSTYlbTD.js} +1 -1
  87. package/dashboard/dist/assets/{use-ordered-list-DJxLNdXY.js → use-ordered-list-C4JnHdE0.js} +1 -1
  88. package/dashboard/dist/assets/use-reduced-motion-AQE0ummK.js +1 -0
  89. package/dashboard/dist/assets/{use-session-efficiency-pref-CAX_GqXc.js → use-session-efficiency-pref-CgyUz5Gc.js} +1 -1
  90. package/dashboard/dist/assets/{use-transform-CeW6Z5R0.js → use-transform-C7-jSJ9k.js} +1 -1
  91. package/dashboard/dist/assets/use-usage-limits-B3YYqn-v.js +1 -0
  92. package/dashboard/dist/assets/{useCurrency-BarGeFyK.js → useCurrency-CK_gcb3J.js} +1 -1
  93. package/dashboard/dist/assets/{useTokenFormat-DUJ9iT9H.js → useTokenFormat-C_a-UkCA.js} +1 -1
  94. package/dashboard/dist/assets/{zap--m0IWoI3.js → zap-BIJNn-Ic.js} +1 -1
  95. package/dashboard/dist/brand-logos/lmstudio.svg +12 -0
  96. package/dashboard/dist/brand-logos/unsloth.svg +1 -0
  97. package/dashboard/dist/index.html +16 -12
  98. package/dashboard/dist/ip-check.html +2 -2
  99. package/dashboard/dist/leaderboard.html +2 -2
  100. package/dashboard/dist/llms.txt +4 -2
  101. package/dashboard/dist/share.html +2 -2
  102. package/package.json +2 -2
  103. package/src/commands/device-login.js +5 -10
  104. package/src/commands/init.js +28 -1
  105. package/src/commands/serve.js +6 -0
  106. package/src/commands/status.js +24 -0
  107. package/src/commands/sync.js +114 -18
  108. package/src/lib/cloud-account.js +102 -29
  109. package/src/lib/fs.js +30 -0
  110. package/src/lib/grok-context-breakdown.js +24 -33
  111. package/src/lib/grok-usage.js +95 -0
  112. package/src/lib/local-api.js +101 -13
  113. package/src/lib/pricing/index.js +15 -0
  114. package/src/lib/pricing/matcher.js +15 -0
  115. package/src/lib/pricing/seed-snapshot.json +1 -1
  116. package/src/lib/rollout.js +1094 -72
  117. package/src/lib/session-analytics.js +100 -40
  118. package/src/lib/usage-limits.js +507 -55
  119. package/src/lib/zcode-limits.js +65 -8
  120. package/dashboard/dist/assets/CommunityStatsModal-aAico565.js +0 -1
  121. package/dashboard/dist/assets/DashboardPage-BByRBsbt.js +0 -1
  122. package/dashboard/dist/assets/DialogDescription-BUrh0Jod.js +0 -1
  123. package/dashboard/dist/assets/SessionsPage-DOaY6_E9.js +0 -2
  124. package/dashboard/dist/assets/SkillsPage-BkzJOBLk.js +0 -1
  125. package/dashboard/dist/assets/TrendMonitor-BuKmsznP.js +0 -19
  126. package/dashboard/dist/assets/__vite-browser-external-CVIGknXl.js +0 -45
  127. package/dashboard/dist/assets/chevron-right-DJm0mbG0.js +0 -1
  128. package/dashboard/dist/assets/module-D2D5r9gC.js +0 -3
  129. package/dashboard/dist/assets/use-reduced-motion-yE3T3cat.js +0 -1
  130. package/dashboard/dist/assets/use-usage-limits-5HP8k9a3.js +0 -1
@@ -1,3 +0,0 @@
1
- var _=typeof window<"u"?window:void 0,ge=typeof globalThis<"u"?globalThis:_,be=ge?.navigator,S=ge?.document,X=ge?.location,Cr=ge?.fetch,Js=ge!=null&&ge.XMLHttpRequest&&"withCredentials"in new ge.XMLHttpRequest?ge.XMLHttpRequest:void 0,Zr=ge?.AbortController,rl=ge?.CompressionStream,Ee=be?.userAgent;function ga(){return!(!_||_.navigator.onLine===!1)}var Gt=typeof globalThis<"u"?globalThis:_;Gt&&typeof self>"u"&&(Gt.self=Gt),Gt&&typeof File>"u"&&(Gt.File=function(){});var $=_??{},Y={DEBUG:!1,LIB_VERSION:"0.5.0",LIB_NAME:"browser-common"};function Kr(i,e,t,s,r,n,a){try{var o=i[n](a),l=o.value}catch(h){return void t(h)}o.done?e(l):Promise.resolve(l).then(s,r)}function Q(i){return function(){var e=this,t=arguments;return new Promise((function(s,r){var n=i.apply(e,t);function a(l){Kr(n,s,r,a,o,"next",l)}function o(l){Kr(n,s,r,a,o,"throw",l)}a(void 0)}))}}function y(){return y=Object.assign?Object.assign.bind():function(i){for(var e=1;arguments.length>e;e++){var t=arguments[e];for(var s in t)({}).hasOwnProperty.call(t,s)&&(i[s]=t[s])}return i},y.apply(null,arguments)}function _a(i,e){if(i==null)return{};var t={};for(var s in i)if({}.hasOwnProperty.call(i,s)){if(e.indexOf(s)!==-1)continue;t[s]=i[s]}return t}var Xr=i=>{if(typeof i!="string")return i;try{return JSON.parse(i)}catch{return i}};function en(i){return typeof i=="string"||i}function tn(i){return typeof i=="string"?i:void 0}var Wt,nl=["$feature_flag","$feature_flag_response","$feature_flag_has_experiment","$feature_flag_id","$feature_flag_version","$feature_flag_reason","$feature_flag_request_id","$feature_flag_evaluated_at","$feature_flag_error","locally_evaluated","$groups","$process_person_profile","$geoip_disable","$current_url","$pathname","$referring_domain","utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid","gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx","$session_id","$window_id","$lib","$lib_version","$device_id","$is_server"],Ye=(function(i){return i.AnonymousId="anonymous_id",i.DistinctId="distinct_id",i.Props="props",i.EnablePersonProcessing="enable_person_processing",i.PersonMode="person_mode",i.FeatureFlagDetails="feature_flag_details",i.FeatureFlags="feature_flags",i.FeatureFlagPayloads="feature_flag_payloads",i.BootstrapFeatureFlagDetails="bootstrap_feature_flag_details",i.BootstrapFeatureFlags="bootstrap_feature_flags",i.BootstrapFeatureFlagPayloads="bootstrap_feature_flag_payloads",i.OverrideFeatureFlags="override_feature_flags",i.Queue="queue",i.AiQueue="ai_queue",i.AiCaptureQueue="ai_capture_queue",i.LogsQueue="logs_queue",i.OptedOut="opted_out",i.SessionId="session_id",i.SessionStartTimestamp="session_start_timestamp",i.SessionLastTimestamp="session_timestamp",i.PersonProperties="person_properties",i.GroupProperties="group_properties",i.InstalledAppBuild="installed_app_build",i.InstalledAppVersion="installed_app_version",i.SessionReplay="session_replay",i.PushRegistered="push_registered",i.SessionReplayEventTriggerActivatedSession="session_replay_event_trigger_activated_session",i.SurveyLastSeenDate="survey_last_seen_date",i.SurveysSeen="surveys_seen",i.Surveys="surveys",i.RemoteConfig="remote_config",i.FlagsEndpointWasHit="flags_endpoint_was_hit",i.DeviceId="device_id",i})({}),sn=(function(i){return i.GZipJS="gzip-js",i.Base64="base64",i})({}),al=["$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"],ol=["token"],ma="NativeGzipValidationError",Ys=i=>i.length>=2&&i[0]===31&&i[1]===139,rn=(i,e)=>i===sn.GZipJS||e===sn.GZipJS||e==="gzip",nn=i=>!(!i||typeof i!="object")&&("name"in i?String(i.name):"")==="NotReadableError",bi=i=>{var e=new Error("Native gzip produced invalid output: "+i);throw e.name=ma,e},ll=(function(){var i=Q((function*(e,t){18>e.size&&bi("too-short");var s=new Uint8Array(yield e.slice(0,10).arrayBuffer());Ys(s)&&s[2]===8||bi("invalid-header");var r=new DataView(yield e.slice(e.size-8).arrayBuffer());r.getUint32(0,!0)!==(a=>{for(var o=(()=>{if(Wt)return Wt;Wt=[];for(var u=0;256>u;u++){for(var c=u,d=0;8>d;d++)c=1&c?3988292384^c>>>1:c>>>1;Wt[u]=c>>>0}return Wt})(),l=4294967295,h=0;a.length>h;h++)l=o[255&(l^a[h])]^l>>>8;return(4294967295^l)>>>0})(t)&&bi("invalid-crc");var n=t.length>>>0;r.getUint32(4,!0)!==n&&bi("invalid-size")}));return function(e,t){return i.apply(this,arguments)}})();function Qs(){return Qs=Q((function*(i,e,t){e===void 0&&(e=!0);try{var s=new TextEncoder().encode(i),r=new globalThis.CompressionStream("gzip"),n=r.writable.getWriter(),a=n.write(s).then((()=>n.close())).catch((function(){var h=Q((function*(u){try{yield n.abort(u)}catch{}throw u}));return function(u){return h.apply(this,arguments)}})()),o=new Response(r.readable).blob(),l=(yield Promise.all([o,a]))[0];return yield ll(l,s),l}catch(h){if(t!=null&&t.rethrow)throw h;return e&&console.error("Failed to gzip compress data",h),null}})),Qs.apply(this,arguments)}var ul=20,ya=1e3,hl=1e4,cl="[Circular]",Zs="[Truncated]",us="[Unserializable]",dl="[Function]";function $t(i){for(var e="",t=0;i.length>t;t++){var s=i.charCodeAt(t);if(55296>s||s>56319)e+=56320>s||s>57343?i[t]:"�";else{var r=i.charCodeAt(t+1);56320>r||r>57343?e+="�":(e+=i[t]+i[t+1],t++)}}return e}var vl=["amazonbot","amazonproductbot","app.hypefactors.com","applebot","archive.org_bot","awariobot","backlinksextendedbot","baiduspider","bingbot","bingpreview","chrome-lighthouse","dataforseobot","deepscan","duckduckbot","facebookexternal","facebookcatalog","http://yandex.com/bots","hubspot","ia_archiver","leikibot","linkedinbot","meta-externalagent","mj12bot","msnbot","nessus","petalbot","pinterest","prerender","rogerbot","screaming frog","sebot-wa","sitebulb","slackbot","slurp","trendictionbot","turnitin","twitterbot","vercel-screenshot","vercelbot","yahoo! slurp","yandexbot","zoombot","bot.htm","bot.php","(bot;","bot/","crawler","ahrefsbot","ahrefssiteaudit","semrushbot","siteauditbot","splitsignalbot","gptbot","oai-searchbot","chatgpt-user","perplexitybot","better uptime bot","sentryuptimebot","uptimerobot","headlesschrome","cypress","google-hoteladsverifier","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleother","google-cloudvertexbot","googleweblight","mediapartners-google","storebot-google","google-inspectiontool","bytespider"],an=function(i,e){if(e===void 0&&(e=[]),!i)return!1;var t=i.toLowerCase();return vl.concat(e).some((s=>{var r=s.toLowerCase();return t.indexOf(r)!==-1}))};function L(i,e){return i.indexOf(e)!==-1}var hs=function(i){return i.trim()},Ks=function(i){return i.replace(/^\$/,"")};function ba(i){var e,t=[];return(e=JSON.stringify(i,(function(s,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(;t.length>0&&t[t.length-1]!==this;)t.pop();if(t.includes(r))return"[Circular]";t.push(r)}return r}})))!==null&&e!==void 0?e:"null"}var wa=Object.prototype,xa=wa.hasOwnProperty,cs=wa.toString,A=Array.isArray||function(i){return cs.call(i)==="[object Array]"},me=i=>typeof i=="function",Z=i=>i===Object(i)&&!A(i),De=i=>{if(Z(i)){for(var e in i)if(xa.call(i,e))return!1;return!0}return!1},w=i=>i===void 0,q=i=>cs.call(i)=="[object String]",Ni=i=>q(i)&&i.trim().length===0,de=i=>i===null,D=i=>w(i)||de(i),oe=i=>cs.call(i)=="[object Number]"&&i==i,Je=i=>oe(i)&&i>0,Oe=i=>cs.call(i)==="[object Boolean]",pl=i=>i instanceof FormData,fl=i=>L(al,i),gl=i=>L(ol,i);function ka(i){return i===null||typeof i!="object"}function ji(i,e){return{}.toString.call(i)==="[object "+e+"]"}function Ea(i){switch({}.toString.call(i)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object DOMError]":case"[object WebAssembly.Exception]":return!0;default:return Sa(i,Error)}}function Tr(i){return typeof Event<"u"&&Sa(i,Event)}function Sa(i,e){try{return i instanceof e}catch{return!1}}var _l=[!0,"true",1,"1","yes"],fs=i=>L(_l,i),ml=[!1,"false",0,"0","no"];function ze(i,e,t,s,r){return e>t&&(s.warn("min cannot be greater than max."),e=t),oe(i)?i>t?(s.warn(" cannot be greater than max: "+t+". Using max value instead."),t):e>i?(s.warn(" cannot be less than min: "+e+". Using min value instead."),e):i:(s.warn(" must be a number. using max or fallback. max: "+t+", fallback: "+r),ze(r||t,e,t,s))}class yl{constructor(e){this.k={},this.S=e.S,this.C=ze(e.bucketSize,0,100,e.I),this.R=ze(e.refillRate,0,this.C,e.I),this.A=ze(e.refillInterval,0,864e5,e.I)}O(e,t){var s=Math.floor((t-e.lastAccess)/this.A);s>0&&(e.tokens=Math.min(e.tokens+s*this.R,this.C),e.lastAccess=e.lastAccess+s*this.A)}consumeRateLimit(e){var t,s=Date.now(),r=String(e),n=this.k[r];return n?this.O(n,s):this.k[r]=n={tokens:this.C,lastAccess:s},n.tokens===0||(n.tokens--,n.tokens===0&&((t=this.S)==null||t.call(this,e)),n.tokens===0)}stop(){this.k={}}}var Ce="Mobile",Hi="iOS",et="Android",Dt="Tablet",Pa=et+" "+Dt,Ia="iPad",Oa="Apple",Fa=Oa+" Watch",ni="Safari",Nt="BlackBerry",Ca="Samsung",Ta=Ca+"Browser",$a=Ca+" Internet",mt="Chrome",bl=mt+" OS",Ma=mt+" "+Hi,$r="Internet Explorer",Ra=$r+" "+Ce,Mr="Opera",wl=Mr+" Mini",Rr="Edge",Aa="Microsoft "+Rr,Mt="Firefox",La=Mt+" "+Hi,hi="Nintendo",ci="PlayStation",Rt="Xbox",Da=et+" "+Ce,Na=Ce+" "+ni,ti="Windows",Xs=ti+" Phone",on="Nokia",er="Ouya",ja="Generic",xl=ja+" "+Ce.toLowerCase(),Ha=ja+" "+Dt.toLowerCase(),tr="Konqueror",qa="Oculus Browser",qi="Vivaldi",Ba="Yandex",Bi="Whale",ir="DuckDuckGo",Va="Pale Moon",Vi="Waterfox",ai="Brave",Ua="Google Search App",re="(\\d+(\\.\\d+)?)",gs=new RegExp("Version/"+re),kl=new RegExp(Rt,"i"),El=new RegExp(ci+" \\w+","i"),Sl=new RegExp(hi+" \\w+","i"),Ar=new RegExp(Nt+"|PlayBook|BB10","i"),Pl={"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"},za=function(i,e,t,s){e=e||"";var r=(function(n){return n!=null&&n.brave?ai:null})(t);return r||(s!=null&&s.detectGoogleSearchApp&&L(i,"GSA/")?Ua:L(i," OPR/")&&L(i,"Mini")?wl:L(i," OPR/")?Mr:Ar.test(i)?Nt:L(i,"IE"+Ce)||L(i,"WPDesktop")?Ra:L(i,"OculusBrowser")?qa:L(i,Ta)?$a:L(i,Rr)||L(i,"Edg/")?Aa:L(i,qi+"/")?qi:L(i,"YaBrowser/")?Ba:L(i,Bi+"/")?Bi:L(i,ir+"/")||L(i,"Ddg/")?ir:L(i,"FBIOS")?"Facebook "+Ce:L(i,"UCWEB")||L(i,"UCBrowser")?"UC Browser":L(i,"CriOS")?Ma:L(i,"CrMo")||L(i,mt)?mt:L(i,et)&&L(i,ni)?Da:L(i,"FxiOS")?La:L(i.toLowerCase(),tr.toLowerCase())?tr:L(i,ai+"/")?ai:((n,a)=>a&&L(a,Oa)||(function(o){return L(o,ni)&&!L(o,mt)&&!L(o,et)})(n))(i,e)?L(i,Ce)?Na:ni:L(i,"PaleMoon/")?Va:L(i,Vi+"/")?Vi:L(i,Mt)?Mt:L(i,"MSIE")||L(i,"Trident/")?$r:L(i,"Gecko")?Mt:"")},Il={[Ra]:[new RegExp("rv:"+re)],[Aa]:[new RegExp(Rr+"?\\/"+re)],[mt]:[new RegExp("("+mt+"|CrMo)\\/"+re)],[Ma]:[new RegExp("CriOS\\/"+re)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+re)],[ni]:[gs],[Na]:[gs],[Mr]:[new RegExp("(Opera|OPR)\\/"+re)],[Mt]:[new RegExp(Mt+"\\/"+re)],[La]:[new RegExp("FxiOS\\/"+re)],[tr]:[new RegExp("Konqueror[:/]?"+re,"i")],[Nt]:[new RegExp(Nt+" "+re),gs],[Da]:[new RegExp("android\\s"+re,"i")],[$a]:[new RegExp(Ta+"\\/"+re)],[qa]:[new RegExp("OculusBrowser\\/"+re)],[qi]:[new RegExp(qi+"\\/"+re)],[Ba]:[new RegExp("YaBrowser\\/"+re)],[Bi]:[new RegExp(Bi+"\\/"+re)],[ai]:[new RegExp(ai+"\\/"+re)],[ir]:[new RegExp("(DuckDuckGo|Ddg)\\/"+re)],[Va]:[new RegExp("PaleMoon\\/"+re)],[Vi]:[new RegExp(Vi+"\\/"+re)],[Ua]:[new RegExp("GSA\\/"+re)],[$r]:[new RegExp("(rv:|MSIE )"+re)],Mozilla:[new RegExp("rv:"+re)]},Ol=function(i,e,t,s){var r=za(i,e,t,s),n=Il[r];if(w(n))return null;for(var a=0;n.length>a;a++){var o=i.match(n[a]);if(o)return parseFloat(o[o.length-2])}return null},ln=[[new RegExp(Rt+"; "+Rt+" (.*?)[);]","i"),i=>[Rt,i&&i[1]||""]],[new RegExp(hi,"i"),[hi,""]],[new RegExp(ci,"i"),[ci,""]],[Ar,[Nt,""]],[new RegExp(ti,"i"),(i,e)=>{if(/Phone/.test(e)||/WPDesktop/.test(e))return[Xs,""];if(new RegExp(Ce).test(e)&&!/IEMobile\b/.test(e))return[ti+" "+Ce,""];var t=/Windows NT ([0-9.]+)/i.exec(e);if(t&&t[1]){var s=Pl[t[1]]||"";return/arm/i.test(e)&&(s="RT"),[ti,s]}return[ti,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,i=>i&&i[3]?[Hi,[i[3],i[4],i[5]||"0"].join(".")]:[Hi,""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,i=>{var e="";return i&&i.length>=3&&(e=w(i[2])?i[3]:i[2]),["watchOS",e]}],[new RegExp("("+et+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+et+")","i"),i=>i&&i[2]?[et,[i[2],i[3],i[4]||"0"].join(".")]:[et,""]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,i=>{var e=["Mac OS X",""];return i&&i[1]&&(e[1]=[i[1],i[2],i[3]||"0"].join(".")),e}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[bl,""]],[/Linux|debian/i,["Linux",""]]],un=function(i){return Sl.test(i)?hi:El.test(i)?ci:kl.test(i)?Rt:new RegExp(er,"i").test(i)?er:new RegExp("("+Xs+"|WPDesktop)","i").test(i)?Xs:/iPad/.test(i)?Ia:/iPod/.test(i)?"iPod Touch":/iPhone/.test(i)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(i)?Fa:Ar.test(i)?Nt:/(kobo)\s(ereader|touch)/i.test(i)?"Kobo":new RegExp(on,"i").test(i)?on:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(i)||/(kf[a-z]+)( bui|\)).+silk\//i.test(i)?"Kindle Fire":/(Android|ZTE)/i.test(i)?new RegExp(Ce).test(i)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(i)||/pixel[\daxl ]{1,6}/i.test(i)&&!/pixel c/i.test(i)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(i)||/lmy47v/i.test(i)&&!/QTAQZ3/i.test(i)?et:Pa:new RegExp("(pda|"+Ce+")","i").test(i)?xl:new RegExp(Dt,"i").test(i)&&!new RegExp(Dt+" pc","i").test(i)?Ha:""},Fl=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function hn(i,e){return typeof(t=i)=="string"&&Fl.test(t)?i:e();var t}function rt(i){return i&&i.split("#")[0]}function Lr(i,e){var t=setTimeout(i,e);return t?.unref&&t?.unref(),t}function cn(i,e,t){return Ga.apply(this,arguments)}function Ga(){return(Ga=Q((function*(i,e,t){var s;try{return yield Promise.race([i,new Promise(((r,n)=>{s=Lr((()=>{try{t?.(),r()}catch(a){n(a)}}),e)}))])}finally{clearTimeout(s)}}))).apply(this,arguments)}var Wa={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}},Cl=Wa.info,dn=9223372036854776e3,Tl={}.propertyIsEnumerable;function Ui(i,e){try{return Ja(i,e,{ancestors:new WeakSet,remainingNodes:hl},0)}catch{return[]}}function Dr(i,e,t,s){if(0>=t.remainingNodes)return{stringValue:Zs};if(t.remainingNodes--,Oe(i))return{boolValue:i};if(typeof i=="number"){if(!Number.isFinite(i))return{stringValue:String(i)};if(Number.isInteger(i)){if(Number.isSafeInteger(i))return{intValue:String(i)};if(typeof BigInt>"u")return{stringValue:String(i)};var r=BigInt(i).toString();return i>=dn||-dn>i?(e?.debug("Attribute "+r+" is outside the int64 range; encoding it as a string"),{stringValue:r}):{intValue:r}}return{doubleValue:i}}if(typeof i=="string")return{stringValue:$t(i)};if(typeof i=="function")return{stringValue:dl};if(typeof i=="symbol")return{stringValue:String(i)};if(typeof i=="object"&&i!==null){if(t.ancestors.has(i))return{stringValue:cl};if(s>=ul)return{stringValue:Zs};if(i instanceof Date){var n=i.getTime(),a=Number.isFinite(n)?i.toISOString():String(i);return{stringValue:typeof a=="string"?$t(a):String(a)}}t.ancestors.add(i);try{try{var o=i.toJSON;if(typeof o=="function")return Dr(o.call(i),e,t,s+1)}catch{}return A(i)?{arrayValue:{values:$l(i,e,t,s+1)}}:{kvlistValue:{values:Ja(i,e,t,s+1)}}}finally{t.ancestors.delete(i)}}return{stringValue:$t(String(i))}}function $l(i,e,t,s){for(var r=[],n=Math.min(i.length,ya),a=0;n>a&&t.remainingNodes>0;a++)try{var o=a in i?i[a]:void 0;if(D(o))continue;r.push(Dr(o,e,t,s))}catch{r.push({stringValue:us})}return i.length>a&&r.push({stringValue:Zs}),r}function Ja(i,e,t,s){var r=[];for(var n in i)if(Tl.call(i,n)){if(r.length>=ya||0>=t.remainingNodes){e?.debug("Attributes truncated: the value exceeds the OTLP encoder budget");break}try{var a=i[n];if(de(a)||w(a))continue;r.push({key:$t(n),value:Dr(a,e,t,s)})}catch{r.push({key:$t(n),value:{stringValue:us}})}}return r}function Ml(i){try{return $t(String(i))}catch{return us}}function Rl(i,e,t){var s=Wa[i.level||"info"]||Cl,r=s.text,n=s.number,a=String(Date.now())+"000000",o={};e.distinctId&&(o.posthogDistinctId=e.distinctId),e.sessionId&&(o.sessionId=e.sessionId),e.windowId&&(o["window.id"]=e.windowId),D(e.sessionStartTimestamp)||(o.sessionStartTimestamp=String(e.sessionStartTimestamp)),D(e.lastActivityTimestamp)||(o.lastActivityTimestamp=String(e.lastActivityTimestamp)),e.currentUrl&&(o["url.full"]=e.currentUrl),e.screenName&&(o["screen.name"]=e.screenName),e.appState&&(o["app.state"]=e.appState),e.activeFeatureFlags&&e.activeFeatureFlags.length>0&&(o.feature_flags=e.activeFeatureFlags);var l=y({},o),h=i.attributes;if(h){var u=[];try{u=Object.keys(h)}catch{u=[]}for(var c of u){var d=void 0;try{d=h[c]}catch{d=us}Object.defineProperty(l,c,{value:d,enumerable:!0,writable:!0,configurable:!0})}}var p={timeUnixNano:a,observedTimeUnixNano:a,severityNumber:n,severityText:r,body:{stringValue:Ml(i.body)},attributes:Ui(l,t)};return i.trace_id&&(p.traceId=i.trace_id),i.span_id&&(p.spanId=i.span_id),w(i.trace_flags)||(p.flags=i.trace_flags),p}function Ya(i,e,t){return y({},i.resourceAttributes,{"service.name":i.serviceName||"unknown_service"},i.environment&&{"deployment.environment":i.environment},i.serviceVersion&&{"service.version":i.serviceVersion},{"telemetry.sdk.name":e,"telemetry.sdk.version":t})}function Qa(i,e,t,s){return{resourceLogs:[{resource:{attributes:Ui(e)},scopeLogs:[{scope:{name:t,version:s},logRecords:i}]}]}}let Al=class{constructor(i,e,t,s,r,n,a){var o;n===void 0&&(n=()=>Promise.resolve()),this._instance=i,this.Oi=e,this.I=t,this.Ji=s,this.Ki=r,this.Xi=n,this.tn=a,this.en=null,this.rn=0,this.nn=0,this.sn=0,this.an=0,this.ln=!1,this.un=e.maxBufferSize,this.hn=Math.max((o=e.maxQueueSize)!==null&&o!==void 0?o:e.maxBufferSize,e.maxBufferSize),this.dn=e.flushIntervalMs,this.vn=e.maxBatchRecordsPerPost,this.cn=e.rateCapWindowMs,this.fn=e.maxLogsPerInterval}reset(){this.pn(),this.en=null,this.sn=0,this.an=0,this.ln=!1,this.rn=0,this.nn=0,this.vn=this.Oi.maxBatchRecordsPerPost}onReconnect(){this.nn=0,this.gn()}captureLog(i){if(!this._instance.isDisabled&&!this._instance.optedOut&&i!=null&&i.body){var e=this.mn(i);if(e!==null)if(e.body){if(this.yn()){var t={record:Rl(e,this.Ji(),this.I)};this.Ki((()=>this.bn(t)))}}else this.I.info("Log was rejected in beforeSend function")}}mn(i){var e=this.Oi.beforeSend;if(!e)return i;var t=A(e)?e:[e],s=i;for(var r of t)try{var n=r(s);if(!n)return this.I.info("Log was rejected in beforeSend function"),null;s=n}catch(a){return this.I.error("Error in beforeSend function for log:",a),null}return s}yn(){if(this.fn===void 0)return!0;var i=Date.now(),e=i-this.sn;return this.cn>e&&e>=0||(this.sn=i,this.an=0,this.ln=!1),this.fn>this.an?(this.an++,!0):(this.ln||(this.I.warn("captureLog dropping logs: exceeded "+this.fn+" logs per "+this.cn+"ms"),this.ln=!0),!1)}flush(){var i=this;return Q((function*(){if(!i._instance.isDisabled)return i.en||(i.en=i._n().finally((()=>{i.en=null}))),i.en}))()}_n(){var i=this;return Q((function*(){var e;i.pn();var t=(e=i._instance.getPersistedProperty(Ye.LogsQueue))!==null&&e!==void 0?e:[];if(t.length!==0)for(var s=t.length,r=0;t.length>0&&s>r;){var n,a;i.rn=0;var o=Math.min(t.length,i.vn),l=t.slice(0,o),h=Qa(l.map((c=>c.record)),i.wn(),(n=i.tn)!==null&&n!==void 0?n:i._instance.getLibraryId(),i._instance.getLibraryVersion()),u=yield i._instance.kn(h);if(u.kind==="too-large"&&l.length>1)i.vn=Math.max(1,Math.floor(l.length/2)),i.I.warn("Received 413 when sending logs batch of size "+l.length+", reducing batch size to "+i.vn);else if(u.kind==="retry-later"||(u.kind==="too-large"?i.I.warn("Dropping a single log record after 413 with batch size 1 — the record is larger than the server cap and cannot be split further."):u.kind==="ok"&&i.Oi.maxBatchRecordsPerPost>i.vn&&(i.vn=Math.min(i.Oi.maxBatchRecordsPerPost,i.vn+1)),yield i.Sn(l.length),t=(a=i._instance.getPersistedProperty(Ye.LogsQueue))!==null&&a!==void 0?a:[],r+=l.length,u.kind==="fatal"))throw u.error}}))()}Sn(i){var e=this;return Q((function*(){var t,s=Math.max(0,i-e.rn),r=(t=e._instance.getPersistedProperty(Ye.LogsQueue))!==null&&t!==void 0?t:[];e._instance.setPersistedProperty(Ye.LogsQueue,r.slice(s)),yield e.Xi()}))()}wn(){return Ya(this.Oi,this._instance.getLibraryId(),this._instance.getLibraryVersion())}bn(i){var e;if(!this._instance.optedOut){var t=(e=this._instance.getPersistedProperty(Ye.LogsQueue))!==null&&e!==void 0?e:[];this.hn>t.length||(t.shift(),this.rn++,this.I.info("Logs queue is full, dropping oldest record.")),t.push(i),this._instance.setPersistedProperty(Ye.LogsQueue,t),this.un>t.length?this.xn():this.gn()}}xn(i){i===void 0&&(i=this.dn),this.Cn||(this.Cn=Lr((()=>{this.Cn=void 0,this.gn()}),i))}Tn(){var i=Math.min(Math.max(0,this.nn-1),6);return this.dn*Math.pow(2,i)}Mn(){var i=this._instance.getPersistedProperty(Ye.LogsQueue);return!!i&&i.length>0}shutdown(i){var e=this;return Q((function*(){e.pn();var t=e.flush().catch((()=>{}));i!==void 0?yield cn(t,i):yield t}))()}flushWithTimeout(i){var e=this;return Q((function*(){var t=e.flush();yield cn(t,i,(()=>{t.catch((()=>{}))}))}))()}gn(){this.flush().then((()=>{this.nn=0}),(i=>{this.nn++,this.I.error("PostHog logs flush failed:",i)})).finally((()=>{!this._instance.isDisabled&&this.Mn()&&this.xn(this.Tn())}))}pn(){this.Cn&&(clearTimeout(this.Cn),this.Cn=void 0)}};var _s=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function vn(i){return String(i)+"000000"}function pn(i,e,t,s){var r="";return s&&(r=Object.keys(s).sort().map((n=>JSON.stringify(n)+":"+JSON.stringify(s[n]))).join(",")),i+"\0"+e+"\0"+(t??"")+"\0"+r}let Ll=class{constructor(i,e,t){this._instance=i,this.Oi=e,this.I=t,this.En=new Map,this.en=null,this.In=!1,this.Rn=new Map,this.Pn=new Set,this.An=0}count(i,e,t){e===void 0&&(e=1),this.Fn({name:i,type:"count",value:e,unit:t?.unit,attributes:t?.attributes})}gauge(i,e,t){this.Fn({name:i,type:"gauge",value:e,unit:t?.unit,attributes:t?.attributes})}histogram(i,e,t){this.Fn({name:i,type:"histogram",value:e,unit:t?.unit,attributes:t?.attributes})}flush(){var i=this,e=this.en,t=(function(){var r=Q((function*(){e&&(yield e.catch((()=>{}))),yield i.On()}));return function(){return r.apply(this,arguments)}})(),s=t().finally((()=>{this.en===s&&(this.en=null)}));return this.en=s,s}drainWindow(){if(this.En.size===0)return null;var i=this.En;return this.En=new Map,this.In=!1,this.Rn=new Map,this.Pn=new Set,this.Ln(i)}reset(){this.An++,this.pn(),this.En=new Map,this.en=null,this.In=!1,this.Rn=new Map,this.Pn=new Set}Fn(i){if(!this._instance.isDisabled&&!this._instance.optedOut){var e=this.mn(i);if(e!==null)if(e.name&&typeof e.name=="string")if(typeof e.value=="number"&&Number.isFinite(e.value))if(e.type==="count"&&0>e.value)this.I.warn("Dropping count '"+e.name+"': counters are monotonic, value must be >= 0");else{var t,s;try{t=e.attributes?y({},e.attributes):void 0,s=pn(e.type,e.name,e.unit,t)}catch(a){return void this.I.warn("Dropping metric '"+e.name+"': attributes could not be serialized",a)}var r=this.En.get(s);if(!r){if(!this.$n())return;r={name:e.name,type:e.type,unit:e.unit,attributes:t,windowStartMs:Date.now()},this.En.set(s,r)}var n=this.Rn.get(e.name);n===void 0?this.Rn.set(e.name,e.type):n===e.type||this.Pn.has(e.name)||(this.Pn.add(e.name),this.I.warn("Metric name '"+e.name+"' is already used as a "+n+"; recording it as a "+e.type+" too will blend both series in charts. Use a distinct name.")),this.Dn(r,e.value),this.xn()}else this.I.warn("Dropping metric '"+e.name+"': value must be a finite number");else this.I.warn("Dropping metric with empty name")}}$n(){return this.Oi.maxSeriesPerFlush>this.En.size||(this.In||(this.In=!0,this.I.warn("Metric series cap reached ("+this.Oi.maxSeriesPerFlush+" per flush window); dropping new series until the next flush. Reduce attribute cardinality.")),!1)}Dn(i,e){var t;switch(i.type){case"count":i.total=((t=i.total)!==null&&t!==void 0?t:0)+e;break;case"gauge":i.last=e;break;case"histogram":i.hist||(i.hist={count:0,sum:0,min:e,max:e,bucketCounts:new Array(_s.length+1).fill(0)});var s=i.hist;s.count+=1,s.sum+=e,s.min=Math.min(s.min,e),s.max=Math.max(s.max,e),s.bucketCounts[(function(r,n){for(var a=0;n.length>a;a++)if(n[a]>=r)return a;return n.length})(e,_s)]+=1}}mn(i){var e=this.Oi.beforeSend;if(!e)return i;var t=A(e)?e:[e],s=i;for(var r of t)try{var n=r(s);if(!n)return this.I.info("Metric was rejected in beforeSend function"),null;s=n}catch(a){return this.I.error("Error in beforeSend function for metric:",a),null}return s}xn(){this.Cn||(this.Cn=Lr((()=>{this.Cn=void 0,this.flush().catch((i=>{this.I.error("Metrics flush failed:",i)}))}),this.Oi.flushIntervalMs))}pn(){this.Cn&&(clearTimeout(this.Cn),this.Cn=void 0)}On(){var i=this;return Q((function*(){if(i.En.size!==0){var e=i.En;i.En=new Map,i.In=!1,i.Rn=new Map,i.Pn=new Set;var t=i.An,s=yield i._instance.Nn(i.Ln(e));if(t===i.An)switch(s.kind){case"ok":return;case"retry-later":return i.qn(e),void i.xn();case"too-large":return void i.I.warn("Metrics batch exceeded the server size limit and was dropped");case"fatal":return void i.I.error("Failed to send metrics batch:",s.error)}}}))()}Ln(i){return e=this.jn(i),t=(function(n,a,o){return y({},n.resourceAttributes,{"service.name":n.serviceName||"unknown_service"},n.environment&&{"deployment.environment":n.environment},n.serviceVersion&&{"service.version":n.serviceVersion},{"telemetry.sdk.name":a,"telemetry.sdk.version":o})})(this.Oi,this._instance.getLibraryId(),this._instance.getLibraryVersion()),s=this._instance.getLibraryId(),r=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:Ui(t)},scopeMetrics:[{scope:{name:s,version:r},metrics:e}]}]};var e,t,s,r}jn(i){var e=vn(Date.now()),t=new Map;for(var s of i.values()){var r,n=pn(s.type,s.name,s.unit,void 0),a=t.get(n);a||(a=y({name:s.name},s.unit&&{unit:s.unit}),s.type==="count"?a.sum={aggregationTemporality:1,isMonotonic:!0,dataPoints:[]}:s.type==="gauge"?a.gauge={dataPoints:[]}:a.histogram={aggregationTemporality:1,dataPoints:[]},t.set(n,a));var o=Ui((r=s.attributes)!==null&&r!==void 0?r:{},this.I),l=vn(s.windowStartMs);if(s.type==="count"){var h,u={attributes:o,startTimeUnixNano:l,timeUnixNano:e,asDouble:(h=s.total)!==null&&h!==void 0?h:0};a.sum.dataPoints.push(u)}else if(s.type==="gauge"){var c,d={attributes:o,timeUnixNano:e,asDouble:(c=s.last)!==null&&c!==void 0?c:0};a.gauge.dataPoints.push(d)}else s.hist&&a.histogram.dataPoints.push({attributes:o,startTimeUnixNano:l,timeUnixNano:e,count:s.hist.count,sum:s.hist.sum,min:s.hist.min,max:s.hist.max,bucketCounts:s.hist.bucketCounts,explicitBounds:_s})}return Array.from(t.values())}qn(i){var e,t;for(var s of i){var r=s[0],n=s[1],a=this.En.get(r);if(a)switch(a.windowStartMs=Math.min(a.windowStartMs,n.windowStartMs),a.type){case"count":a.total=((e=a.total)!==null&&e!==void 0?e:0)+((t=n.total)!==null&&t!==void 0?t:0);break;case"gauge":break;case"histogram":if(n.hist)if(a.hist){a.hist.count+=n.hist.count,a.hist.sum+=n.hist.sum,a.hist.min=Math.min(a.hist.min,n.hist.min),a.hist.max=Math.max(a.hist.max,n.hist.max);for(var o=0;a.hist.bucketCounts.length>o;o++)a.hist.bucketCounts[o]+=n.hist.bucketCounts[o]}else a.hist=n.hist}else this.$n()&&this.En.set(r,n)}}};var wi,fn,ms;function Dl(i){var e=globalThis._posthogChunkIds;if(e){var t=Object.keys(e);return ms&&t.length===fn||(fn=t.length,ms=t.reduce(((s,r)=>{wi||(wi={});var n=wi[r];if(n)s[n[0]]=n[1];else for(var a=i(r),o=a.length-1;o>=0;o--){var l=a[o],h=l?.filename,u=e[r];if(h&&u){s[h]=u,wi[r]=[h,u];break}}return s}),{})),ms}}class Nl{constructor(e,t,s){s===void 0&&(s=[]),this.coercers=e,this.stackParser=t,this.modifiers=s}buildFromUnknown(e,t){t===void 0&&(t={});var s=t&&t.mechanism||{handled:!0,type:"generic"},r=this.buildCoercingContext(s,t,0).apply(e),n=this.buildParsingContext(t),a=this.parseStacktrace(r,n);return{$exception_list:this.convertToExceptionList(a,s),$exception_level:"error"}}modifyFrames(e){var t=this;return Q((function*(){for(var 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?void 0:t.stack,synthetic:!0}}parseStacktrace(e,t){var s,r;return e.cause!=null&&(s=this.parseStacktrace(e.cause,t)),e.stack!=""&&e.stack!=null&&(r=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?t.skipFirstLines:0),t.chunkIdMap)),y({},e,{cause:s,stack:r})}applyChunkIds(e,t){return e.map((s=>(s.filename&&t&&(s.chunk_id=t[s.filename]),s)))}applyCoercers(e,t){for(var s of this.coercers)if(s.match(e))return s.coerce(e,t);return this.coerceFallback(t)}applyModifiers(e){var t=this;return Q((function*(){var s=e;for(var r of t.modifiers)s=yield r(s);return s}))()}convertToExceptionList(e,t){var s,r,n,a={type:e.type,value:e.value,mechanism:{type:(s=t.type)!==null&&s!==void 0?s:"generic",handled:(r=t.handled)===null||r===void 0||r,synthetic:(n=e.synthetic)!==null&&n!==void 0&&n}};e.stack&&(a.stacktrace={type:"raw",frames:e.stack});var o=[a];return e.cause!=null&&o.push(...this.convertToExceptionList(e.cause,y({},t,{handled:!0}))),o}buildParsingContext(e){var t;return{chunkIdMap:Dl(this.stackParser),skipFirstLines:(t=e.skipFirstLines)!==null&&t!==void 0?t:1}}buildCoercingContext(e,t,s){s===void 0&&(s=0);var r=(n,a)=>{if(4>=a){var o=this.buildCoercingContext(e,t,a);return this.applyCoercers(n,o)}};return y({},t,{syntheticException:s==0?t.syntheticException:void 0,mechanism:e,apply:n=>r(n,s),next:n=>r(n,s+1)})}}var jt="?";function sr(i,e,t,s,r){var n={platform:i,filename:e,function:t==="<anonymous>"?jt:t,in_app:!(e!=null&&e.startsWith("webkit-masked-url://"))&&e!=="<anonymous>"};return w(s)||(n.lineno=s),w(r)||(n.colno=r),n}var Za=(i,e)=>{var t=i.indexOf("safari-extension")!==-1,s=i.indexOf("safari-web-extension")!==-1;return t||s?[i.indexOf("@")!==-1?i.split("@")[0]:jt,t?"safari-extension:"+e:"safari-web-extension:"+e]:[i,e]},jl=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,Hl=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,ql=/\((\S*)(?::(\d+))(?::(\d+))\)/,Bl=(i,e)=>{var t=jl.exec(i);if(t)return sr(e,t[1],jt,+t[2],+t[3]);var s=Hl.exec(i);if(s){if(s[2]&&s[2].indexOf("eval")===0){var r=ql.exec(s[2]);r&&(s[2]=r[1],s[3]=r[2],s[4]=r[3])}var n=Za(s[1]||jt,s[2]);return sr(e,n[1],n[0],s[3]?+s[3]:void 0,s[4]?+s[4]:void 0)}},Vl=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,Ul=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,zl=(i,e)=>{var t=Vl.exec(i);if(t){if(t[3]&&t[3].indexOf(" > eval")>-1){var s=Ul.exec(t[3]);s&&(t[1]=t[1]||"eval",t[3]=s[1],t[4]=s[2],t[5]="")}var r=t[3],n=t[1]||jt,a=Za(n,r);return sr(e,r=a[1],n=a[0],t[4]?+t[4]:void 0,t[5]?+t[5]:void 0)}},gn=/\(error: (.*)\)/;class Gl{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){var s=q(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){var t=e.name||(this.isDOMError(e)?"DOMError":"DOMException");return e.message?t+": "+e.message:t}isDOMException(e){return ji(e,"DOMException")}isDOMError(e){return ji(e,"DOMError")}}class Wl{match(e){return Ea(e)}coerce(e,t){var s,r=this.getStack(e),n=r===void 0;return{type:this.getType(e),value:this.getMessage(e,t),stack:r??((s=t.syntheticException)==null?void 0:s.stack),cause:e.cause?t.next(e.cause):void 0,synthetic:n}}getType(e){return e.name||e.constructor.name}getMessage(e,t){var s=e.message;return String(s.error&&typeof s.error.message=="string"?s.error.message:s)}getStack(e){return e.stacktrace||e.stack||void 0}}class Jl{constructor(){}match(e){return!!ji(e,"ErrorEvent")&&(e.error!=null||this.li(e))}coerce(e,t){var s;if(e.error!=null)return t.apply(e.error);var r=t.apply(e.message);return y({},r,{stack:(s=this.hi(e))!==null&&s!==void 0?s:r.stack,synthetic:!0})}li(e){return q(e.message)&&e.message.length>0}hi(e){var t,s,r=e,n=(t=r.lineno)!==null&&t!==void 0?t:0,a=(s=r.colno)!==null&&s!==void 0?s:0;if(q(r.filename)&&r.filename.length!==0&&n!==0)return`Error
2
- at `+r.filename+":"+n+":"+a}}var Yl=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;class Ql{match(e){return typeof e=="string"}coerce(e,t){var s,r=this.getInfos(e),n=r[0],a=r[1];return{type:n??"Error",value:a??e,stack:(s=t.syntheticException)==null?void 0:s.stack,synthetic:!0}}getInfos(e){var t="Error",s=e,r=e.match(Yl);return r&&(t=r[1],s=r[2]),[t,s]}}var Zl=["fatal","error","warning","log","info","debug"];function Ka(i,e){e===void 0&&(e=40);var t=Object.keys(i);if(t.sort(),!t.length)return"[object has no keys]";for(var s=t.length;s>0;s--){var r=t.slice(0,s).join(", ");if(e>=r.length)return s===t.length?r:r.length>e?r.slice(0,e)+"...":r}return""}class Kl{match(e){return typeof e=="object"&&e!==null}coerce(e,t){var s,r,n=this.getErrorPropertyFromObject(e);return n?t.apply(n):{type:this.getType(e),value:this.getValue(e),stack:(s=this.getStack(e))!==null&&s!==void 0?s:(r=t.syntheticException)==null?void 0:r.stack,level:this.isSeverityLevel(e.level)?e.level:"error",synthetic:!0}}getType(e){if(Tr(e))return e.constructor.name;var t="name"in e?e.name:void 0;return q(t)&&!Ni(t)?t:"Error"}getValue(e){if("name"in e&&typeof e.name=="string"){var t="'"+e.name+"' captured as exception";return"message"in e&&typeof e.message=="string"&&(t+=" with message: '"+e.message+"'"),t}if("message"in e&&typeof e.message=="string")return e.message;var s=this.getObjectClassName(e);return(s&&s!=="Object"?"'"+s+"'":"Object")+" captured as exception with keys: "+Ka(e)}isSeverityLevel(e){return q(e)&&!Ni(e)&&Zl.indexOf(e)>=0}getStack(e){try{return q(e.stacktrace)&&e.stacktrace.length>0?e.stacktrace:q(e.stack)&&e.stack.length>0?e.stack:void 0}catch{return}}getErrorPropertyFromObject(e){for(var t in e)if({}.hasOwnProperty.call(e,t)){var s=e[t];if(Ea(s))return s}}getObjectClassName(e){try{var t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{return}}}class Xl{match(e){return Tr(e)}coerce(e,t){var s,r=e.constructor.name;return{type:r,value:r+" captured as exception with keys: "+Ka(e),stack:(s=t.syntheticException)==null?void 0:s.stack,synthetic:!0}}}class eu{match(e){return ka(e)}coerce(e,t){var s;return{type:"Error",value:"Primitive value captured as exception: "+String(e),stack:(s=t.syntheticException)==null?void 0:s.stack,synthetic:!0}}}class tu{match(e){return ji(e,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(e)}isCustomEventWrappingRejection(e){if(!Tr(e))return!1;try{var t=e.detail;return t!=null&&typeof t=="object"&&"reason"in t}catch{return!1}}coerce(e,t){var s,r=this.getUnhandledRejectionReason(e);return ka(r)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(r),stack:(s=t.syntheticException)==null?void 0:s.stack,synthetic:!0}:t.apply(r)}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}}var zi="$message",Gi="$timestamp",iu=new Set([zi,Gi]),ys={enabled:!0,max_bytes:32768};function Wi(i){var e;return i?{enabled:(e=i.enabled)!==null&&e!==void 0?e:ys.enabled,max_bytes:ru(i.max_bytes,ys.max_bytes)}:y({},ys)}class su{constructor(e){this.Bn=[],this.Hn=0,this.Oi=Wi(e)}setConfig(e){this.Oi=Wi(e),this.zn()}add(e){var t=(function(r){var n;try{n=ba(r)}catch{return}try{var a=JSON.parse(n);if(!Z(a))return;var o=a,l=o[zi],h=o[Gi];return!q(l)||l.trim().length===0||!q(h)&&!oe(h)?void 0:{step:o,json:n}}catch{return}})(e);if(t){var s=(function(r){if(typeof TextEncoder<"u")return new TextEncoder().encode(r).length;for(var n=encodeURIComponent(r),a=0,o=0;n.length>o;o++)n[o]==="%"?(a+=1,o+=2):a+=1;return a})(t.json);s>this.Oi.max_bytes||(this.Bn.push({step:t.step,bytes:s}),this.Hn+=s,this.zn())}}getAttachable(){return this.Bn.map((e=>e.step))}clear(){this.Bn=[],this.Hn=0}size(){return this.Bn.length}zn(){for(;this.Hn>this.Oi.max_bytes&&this.Bn.length>0;){var e=this.Bn.shift();e&&(this.Hn-=e.bytes)}}}function ru(i,e){if(!oe(i)||i===1/0||i===-1/0)return e;var t=Math.floor(i);return 0>t?e:t}var Xa=function(i,e){var t=(e===void 0?{}:e).debugEnabled,s={F(r){if(_&&(Y.DEBUG||_.POSTHOG_DEBUG||t)&&!w(_.console)&&_.console){for(var n=("__rrweb_original__"in _.console[r])?_.console[r].__rrweb_original__:_.console[r],a=arguments.length,o=new Array(a>1?a-1:0),l=1;a>l;l++)o[l-1]=arguments[l];n(i,...o)}},debug(){for(var r=arguments.length,n=new Array(r),a=0;r>a;a++)n[a]=arguments[a];s.F("debug",...n)},info(){for(var r=arguments.length,n=new Array(r),a=0;r>a;a++)n[a]=arguments[a];s.F("log",...n)},warn(){for(var r=arguments.length,n=new Array(r),a=0;r>a;a++)n[a]=arguments[a];s.F("warn",...n)},error(){for(var r=arguments.length,n=new Array(r),a=0;r>a;a++)n[a]=arguments[a];s.F("error",...n)},critical(){for(var r=arguments.length,n=new Array(r),a=0;r>a;a++)n[a]=arguments[a];console.error(i,...n)},uninitializedWarning(r){s.error("You must initialize PostHog before calling "+r)},createLogger:(r,n)=>Xa(i+" "+r,n)};return s},E=Xa("[PostHog.js]"),K=E.createLogger,nu=K("[ExternalScriptsLoader]"),Ji=i=>{var e=S?.querySelectorAll("script");if(e){for(var t=0;e.length>t;t++)if(e[t].src===i)return e[t]}},ct=(i,e,t)=>{if(i.config.disable_external_dependency_loading)return nu.warn(e+" was requested but loading of external scripts is disabled."),t("Loading of external scripts is disabled");var s=Ji(e);if(s){if(s.__posthog_loading_callback_fired)return t();var r=s.__posthog_loading_error;return r?t(r):(s.addEventListener("load",(a=>{s.__posthog_loading_callback_fired=!0,t(void 0,a)})),void s.addEventListener("error",(a=>{s.__posthog_loading_error=a,t(a)})))}var n=()=>{if(!S)return t("document not found");if(Ji(e))return ct(i,e,t);var a=S.createElement("script");if(a.type="text/javascript",a.crossOrigin="anonymous",a.src=e,a.onload=h=>{a.__posthog_loading_callback_fired=!0,t(void 0,h)},a.onerror=h=>{a.__posthog_loading_error=h,t(h)},i.config.prepare_external_dependency_script&&(a=i.config.prepare_external_dependency_script(a)),!a)return t("prepare_external_dependency_script returned null");if(i.config.external_scripts_inject_target==="head")S.head.appendChild(a);else{var o,l=S.querySelectorAll("body > script");l.length>0?(o=l[0].parentNode)==null||o.insertBefore(a,l[0]):S.body.appendChild(a)}};S!=null&&S.body?n():S?.addEventListener("DOMContentLoaded",n)},bs={},_n=(i,e)=>{var t="/static/"+e+".js?v="+i.version;if(e==="toolbar"){var s=3e5;t=t+"&t="+Math.floor(Date.now()/s)*s}return i.requestRouter.endpointFor("assets",t)};$.__PosthogExtensions__=$.__PosthogExtensions__||{},$.__PosthogExtensions__.loadExternalDependency=(i,e,t)=>{if(e!=="remote-config"){var s=i.config.strict_script_versioning;if(s){var r=i.requestRouter.endpointFor("assets","/static/"+i.version+"/"+e+".js"),n=bs[r];if(s==="fallback"&&n){if(Ji(n))return void ct(i,n,t);delete bs[r]}ct(i,r,s==="fallback"?(o,l)=>{if(o)if(typeof o=="string")t(o);else{var h,u=_n(i,e);bs[r]=u;var c=Ji(r);c==null||(h=c.parentNode)==null||h.removeChild(c),ct(i,u,t)}else t(void 0,l)}:t)}else ct(i,_n(i,e),t)}else{var a=i.requestRouter.endpointFor("assets","/array/"+i.config.token+"/config.js");ct(i,a,t)}},$.__PosthogExtensions__.loadSiteApp=(i,e,t)=>{var s=i.requestRouter.endpointFor("api",e);ct(i,s,t)};Y.DEBUG=!1,Y.LIB_VERSION="1.418.10",Y.LIB_NAME="web";var eo="$people_distinct_id",_e="distinct_id",di="$device_id",ws="$device_model",Ft="__alias",ii="__timers",rr="$autocapture_disabled_server_side",nr="$heatmaps_enabled_server_side",ar="$exception_capture_enabled_server_side",or="$error_tracking_suppression_rules",lr="$error_tracking_capture_extension_exceptions",ur="$web_vitals_enabled_server_side",Nr="$dead_clicks_enabled_server_side",jr="$product_tours_enabled_server_side",hr="$web_vitals_allowed_metrics",ft="$session_recording_remote_config",to="$replay_sample_rate",io="$replay_override_sampling",so="$replay_override_linked_flag",ro="$replay_override_url_trigger",no="$replay_override_event_trigger",Ct="$sesid",Hr="$session_is_sampled",Qe="$enabled_feature_flags",gt="$active_feature_flags",$i="$early_access_features",vi="$feature_flag_details",_t="$feature_flag_payloads",At="$feature_flag_request_id",Yi="$minimal_flag_called_events",qe="$override_feature_flags",dt="$override_feature_flag_payloads",Le="$stored_person_properties",Ue="$stored_group_properties",ao="$groups",cr="$surveys",Qi="$surveys_loaded_at",dr="$surveys_activated",Mi="$surveys_activated_session",Ri="$surveys_activated_timestamps",si="ph_product_tours",Ze="$flag_call_reported",ri="$flag_call_reported_session_id",Lt="$feature_flag_errors",yt="$feature_flag_evaluated_at",j="$user_state",vr="$client_session_props",pr="$capture_rate_limit",fr="$initial_campaign_params",gr="$initial_referrer_info",Zi="$initial_person_info",Ki="$epp",kt="$posthog_cookieless",oo="$cookieless_mode",lo="$sdk_debug_extensions_init_method",uo="$sdk_debug_extensions_init_time_ms",_r="$sdk_debug_recording_script_not_loaded",qr="PostHog loadExternalDependency extension not found.",vt="on_reject",Ke="always",ae="anonymous",ve="identified",mr="identified_only",Xi="visibilitychange",es="beforeunload",It="$pageview",xs="$pageleave",ks="$identify",mn="$groupidentify";function xi(i,e){A(i)&&i.forEach(e)}function U(i,e){if(!D(i))if(A(i))i.forEach(e);else if(pl(i))i.forEach(((s,r)=>e(s,r)));else for(var t in i)xa.call(i,t)&&e(i[t],t)}var W=function(i){for(var e=arguments.length,t=new Array(e>1?e-1:0),s=1;e>s;s++)t[s-1]=arguments[s];for(var r of t)for(var n in r)r[n]!==void 0&&(i[n]=r[n]);return i};function Ai(i){for(var e=Object.keys(i),t=e.length,s=new Array(t);t--;)s[t]=[e[t],i[e[t]]];return s}var yn=function(i){try{return i()}catch{return}},au=function(i){return function(){try{for(var e=arguments.length,t=new Array(e),s=0;e>s;s++)t[s]=arguments[s];return i.apply(this,t)}catch(r){E.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),E.critical(r)}}},Br=function(i){var e={};return U(i,(function(t,s){(q(t)&&t.length>0||oe(t))&&(e[s]=t)})),e},ou=["herokuapp.com","vercel.app","netlify.app"];function lu(i){var e=i?.hostname;if(!q(e))return!1;var t=e.split(".").slice(-2).join(".");for(var s of ou)if(t===s)return!1;return!0}function ee(i,e,t,s){var r=s??{},n=r.capture,a=r.passive;i?.addEventListener(e,t,{capture:n!==void 0&&n,passive:a===void 0||a})}function yr(i){return i.name==="ph_toolbar_internal"}var ho=i=>{if(S){try{for(var e=i+"=",t=S.cookie.split(";").filter((n=>n.length)),s=0;t.length>s;s++){for(var r=t[s];r.charAt(0)==" ";)r=r.substring(1,r.length);if(r.indexOf(e)===0)return decodeURIComponent(r.substring(e.length,r.length))}}catch{}return null}};Math.trunc||(Math.trunc=function(i){return 0>i?Math.ceil(i):Math.floor(i)}),Number.isInteger||(Number.isInteger=function(i){return oe(i)&&isFinite(i)&&Math.floor(i)===i});class ts{constructor(e){if(this.bytes=e,e.length!==16)throw new TypeError("not 128-bit length")}static fromFieldsV7(e,t,s,r){if(!Number.isInteger(e)||!Number.isInteger(t)||!Number.isInteger(s)||!Number.isInteger(r)||0>e||0>t||0>s||0>r||e>0xffffffffffff||t>4095||s>1073741823||r>4294967295)throw new RangeError("invalid field value");var n=new Uint8Array(16);return n[0]=e/Math.pow(2,40),n[1]=e/Math.pow(2,32),n[2]=e/Math.pow(2,24),n[3]=e/Math.pow(2,16),n[4]=e/256,n[5]=e,n[6]=112|t>>>8,n[7]=t,n[8]=128|s>>>24,n[9]=s>>>16,n[10]=s>>>8,n[11]=s,n[12]=r>>>24,n[13]=r>>>16,n[14]=r>>>8,n[15]=r,new ts(n)}toString(){for(var e="",t=0;this.bytes.length>t;t++)e=e+(this.bytes[t]>>>4).toString(16)+(15&this.bytes[t]).toString(16),t!==3&&t!==5&&t!==7&&t!==9||(e+="-");if(e.length!==36)throw new Error("Invalid UUIDv7 was generated");return e}clone(){return new ts(this.bytes.slice(0))}equals(e){return this.compareTo(e)===0}compareTo(e){for(var t=0;16>t;t++){var s=this.bytes[t]-e.bytes[t];if(s!==0)return Math.sign(s)}return 0}}class uu{generate(){var e=this.generateOrAbort();if(!w(e))return e;this.Tr=0;var t=this.generateOrAbort();if(w(t))throw new Error("Could not generate UUID after timestamp reset");return t}generateOrAbort(){var e=Date.now();if(e>this.Tr)this.Tr=e,this.Ir();else{if(this.Tr>=e+1e4)return;this.Er++,this.Er>4398046511103&&(this.Tr++,this.Ir())}return ts.fromFieldsV7(this.Tr,Math.trunc(this.Er/Math.pow(2,30)),this.Er&Math.pow(2,30)-1,this.Rr.nextUint32())}Ir(){this.Er=1024*this.Rr.nextUint32()+(1023&this.Rr.nextUint32())}constructor(){this.Tr=0,this.Er=0,this.Rr=new hu}}var bn,co=i=>{if(typeof UUIDV7_DENY_WEAK_RNG<"u"&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var e=0;i.length>e;e++)i[e]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return i};_&&!w(_.crypto)&&crypto.getRandomValues&&(co=i=>crypto.getRandomValues(i));class hu{nextUint32(){return this.ft.length>this.Ar||(co(this.ft),this.Ar=0),this.ft[this.Ar++]}constructor(){this.ft=new Uint32Array(8),this.Ar=1/0}}var Ve=()=>cu().toString(),cu=()=>(bn||(bn=new uu)).generate(),Jt="",du=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i,le={Lr:()=>!!S,Nr(i){E.error("cookieStore error: "+i)},Fr:ho,Pr(i){var e;try{e=JSON.parse(le.Fr(i))||{}}catch{}return e},Or(i,e,t,s,r){if(!S)return!1;try{var n="",a="",o=(function(u,c){if(c){var d=(function(v,f){if(f===void 0&&(f=S),Jt)return Jt;if(!f||["localhost","127.0.0.1"].includes(v))return"";for(var g=v.split("."),m=Math.min(g.length,8),b="dmn_chk_"+Ve();!Jt&&m--;){var k=g.slice(m).join("."),P=b+"=1;domain=."+k+";path=/";f.cookie=P+";max-age=3",f.cookie.includes(b)&&(f.cookie=P+";max-age=0",Jt=k)}return Jt})(u);if(!d){var p=(v=>{var f=v.match(du);return f?f[0]:""})(u);p!==d&&E.info("Warning: cookie subdomain discovery mismatch",p,d),d=p}return d?"; domain=."+d:""}return""})(S.location.hostname,s);if(t){var l=new Date;l.setTime(l.getTime()+864e5*t),n="; expires="+l.toUTCString()}r&&(a="; secure");var h=i+"="+encodeURIComponent(JSON.stringify(e))+n+"; SameSite=Lax; path=/"+o+a;return h.length>3686.4&&E.warn("cookieStore warning: large cookie, len="+h.length),S.cookie=h,!0}catch{return!1}},Dr(i,e){if(S!=null&&S.cookie)try{le.Or(i,"",-1,e)}catch{return}}},Es=null,G={Lr(){if(!de(Es))return Es;var i=!0;if(w(_))i=!1;else try{var e="__mplssupport__";G.Or(e,"xyz"),G.Fr(e)!=='"xyz"'&&(i=!1),G.Dr(e)}catch{i=!1}return i||E.error("localStorage unsupported; falling back to cookie store"),Es=i,i},Nr(i){E.error("localStorage error: "+i)},Fr(i){try{return _?.localStorage.getItem(i)}catch(e){G.Nr(e)}return null},Pr(i){try{return JSON.parse(G.Fr(i))||{}}catch{}return null},Or(i,e){try{return _?.localStorage.setItem(i,JSON.stringify(e)),!0}catch(t){G.Nr(t)}return!1},Dr(i){try{_?.localStorage.removeItem(i)}catch(e){G.Nr(e)}}},Ss=[Le,gt,Qe,vi,_t,At,yt,Lt,Ze],pt=[di,_e,Ct,Hr,Ki,Zi,j],is=i=>i+"_cpm",vu=["__proto__","constructor","prototype"],Ps=i=>{if(!Z(i))return{};var e={};return Object.keys(i).forEach((t=>{vu.indexOf(t)===-1&&(e[t]=i[t])})),e},Is=function(i,e){e===void 0&&(e=[]);var t={};return[...pt,...e].forEach((s=>{var r=i[s];w(r)||de(r)||r===""||(t[s]=r)})),t},vo=i=>{for(var e=5381,t=2166136261,s=0;i.length>s;s++){var r=i.charCodeAt(s);e=33*e^r,t=Math.imul(t^r,16777619)}return i.length.toString(36)+"."+(e>>>0).toString(36)+"."+(t>>>0).toString(36)},wn=(i,e)=>({p:e,f:vo(JSON.stringify(i))}),xn=(i,e)=>{if(!e)return{properties:[],isValid:!1};try{var t=le.Pr(is(i)),s=t?.f===vo(e)&&A(t.p);return{properties:s?t.p:[],isValid:s}}catch{return{properties:[],isValid:!1}}},Os=(i,e)=>e+"|"+(le.Fr(is(i))||""),ki={},pu={Lr:()=>!0,Nr(i){E.error("memoryStorage error: "+i)},Fr:i=>ki[i]||null,Pr:i=>ki[i]||null,Or:(i,e)=>(ki[i]=e,!0),Dr(i){delete ki[i]}},ot=null,J={Lr(){if(!de(ot))return ot;if(ot=!0,w(_))ot=!1;else try{var i="__support__";J.Or(i,"xyz"),J.Fr(i)!=='"xyz"'&&(ot=!1),J.Dr(i)}catch{ot=!1}return ot},Nr(i){E.error("sessionStorage error: ",i)},Fr(i){try{return _?.sessionStorage.getItem(i)}catch(e){J.Nr(e)}return null},Pr(i){try{return JSON.parse(J.Fr(i))||null}catch{}return null},Or(i,e){try{return _?.sessionStorage.setItem(i,JSON.stringify(e)),!0}catch(t){J.Nr(t)}return!1},Dr(i){try{_?.sessionStorage.removeItem(i)}catch(e){J.Nr(e)}}};class fu{constructor(e){this._instance=e}get Oi(){return this._instance.config}get consent(){return this.Un()?0:this.Wn}isOptedOut(){return this.Oi.cookieless_mode===Ke||this.isRejected()||this.consent===-1&&this.Oi.cookieless_mode===vt}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===0}isRejected(){return this.consent===0||this.consent===-1&&this.Oi.opt_out_capturing_by_default}optInOut(e){this.Vn.Or(this.Gn,e?1:0,this.Oi.cookie_expiration,this.Oi.cross_subdomain_cookie,this.Oi.secure_cookie)}reset(){this.Vn.Dr(this.Gn,this.Oi.cross_subdomain_cookie)}get Gn(){var e=this._instance.config,t=e.token,s=e.opt_out_capturing_cookie_prefix;return e.consent_persistence_name||(s?s+t:"__ph_opt_in_out_"+t)}get Wn(){var e=this.Vn.Fr(this.Gn);return fs(e)?1:L(ml,e)?0:-1}get Vn(){var e=this.Oi.opt_out_capturing_persistence_type,t=e==="localStorage"?G:le;if(!this.Zn||this.Zn!==t){this.Zn=t;var s=e==="localStorage"?le:G;s.Fr(this.Gn)&&(this.Zn.Fr(this.Gn)||this.optInOut(fs(s.Fr(this.Gn))),s.Dr(this.Gn,this.Oi.cross_subdomain_cookie))}return this.Zn}Un(){return!!this.Oi.respect_dnt&&[be?.doNotTrack,be?.msDoNotTrack,$.doNotTrack].some((e=>fs(e)))}}function po(i,e){var t,s=i==null||(t=i.config)==null?void 0:t.get_current_url;if(!me(s))return e;try{var r=s(e);return q(r)&&r?r:e}catch(n){return E.error("Error in get_current_url, falling back to window.location.href",n),e}}var fo="__POSTHOG_TOOLBAR__",gu=1,_u=3,mu=11;function kn(i){return i instanceof Element&&(i.id===fo||!(i.closest==null||!i.closest(".toolbar-global-fade-container")))}function nt(i){return!!i&&i.nodeType===gu}function Fe(i,e){return!!i&&!!i.tagName&&i.tagName.toLowerCase()===e.toLowerCase()}function go(i){return!!i&&i.nodeType===_u}function _o(i){return!!i&&i.nodeType===mu&&nt(i.host)}var mo=1e3;function Vr(i){return i?hs(i).split(/\s+/):[]}function En(i,e){var t=(function(s){var r,n=_==null||(r=_.location)==null?void 0:r.href;return w(n)?void 0:po(s,n)})(e);return!!(t&&i&&i.some((s=>t.match(s))))}function ss(i){var e="";switch(typeof i.className){case"string":e=i.className;break;case"object":e=(i.className&&"baseVal"in i.className?i.className.baseVal:null)||i.getAttribute("class")||"";break;default:e=""}return Vr(e)}function yo(i){return D(i)?null:hs(i).split(/(\s+)/).filter((e=>oi(e))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function pi(i){var e="";return wr(i)&&!ko(i)&&i.childNodes&&i.childNodes.length&&U(i.childNodes,(function(t){var s;go(t)&&t.textContent&&(e+=(s=yo(t.textContent))!==null&&s!==void 0?s:"")})),hs(e)}function Fs(i){var e;return w(i.target)?i.srcElement||null:(e=i.target)!=null&&e.shadowRoot?i.composedPath()[0]||null:i.target||null}var Ur=["a","button","form","input","select","textarea","label"];function br(i,e){if(w(e))return!0;var t,s=function(n){if(e.some((a=>(function(o,l){var h=o.matches||o.matchesSelector||o.msMatchesSelector||o.mozMatchesSelector||o.webkitMatchesSelector||o.oMatchesSelector;try{return!!h&&h.call(o,l)}catch{return!1}})(n,a))))return{v:!0}};for(var r of i)if(t=s(r))return t.v;return!1}function bo(i){var e=i.parentNode;return!(!e||!nt(e))&&e}var yu=[".ph-no-autocapture","[data-ph-no-autocapture]"],wo=["next","previous","prev",">","<"],bu=[...wo,"+","-","−","–"],Sn=(i,e)=>/[a-z0-9]/i.test(e)?i.includes(e):i===e,Pn=[".ph-no-rageclick",".ph-no-capture"],wu=["","text","search","email","password","url","tel","number"];function In(i,e){if(!_||zr(i))return!1;var t,s,r,n,a;if(Oe(e)?(t=!!e&&Pn,s=void 0,r=!1):(t=(n=e?.css_selector_ignorelist)!==null&&n!==void 0?n:Pn,s=e?.content_ignorelist,r=(a=e?.ignore_text_selection)!==null&&a!==void 0&&a),t===!1||r&&(function(l){return!(!l||!nt(l))&&(!!Fe(l,"textarea")||(Fe(l,"input")?L(wu,(l.getAttribute("type")||"").toLowerCase()):(function(h){if(h.isContentEditable)return!0;var u=h.getAttribute==null?void 0:h.getAttribute("contenteditable");return u==="true"||u===""})(l)))})(i))return!1;var o=xo(i,!1).targetElementList;return!(function(l,h){if(l===!1||w(l))return!1;var u;if(l===!0)u=wo;else{if(!A(l))return!1;if(l.length>10)return E.error("[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching."),!1;u=l.map((c=>c.toLowerCase()))}return h.some((c=>{var d=c.safeText,p=c.ariaLabel;return u.some((v=>Sn(d,v)||Sn(p,v)))}))})(s,o.map((l=>{var h;return{safeText:pi(l).toLowerCase(),ariaLabel:((h=l.getAttribute("aria-label"))==null?void 0:h.toLowerCase().trim())||""}})))&&!br(o,t)}var zr=i=>!i||Fe(i,"html")||!nt(i),xo=(i,e)=>{if(!_||zr(i))return{parentIsUsefulElement:!1,targetElementList:[]};for(var t=!1,s=[i],r=i;r.parentNode&&!Fe(r,"body");)if(_o(r.parentNode))s.push(r.parentNode.host),r=r.parentNode.host;else{var n=bo(r);if(!n)break;if(e||Ur.indexOf(n.tagName.toLowerCase())>-1)t=!0;else try{var a=_.getComputedStyle(n);a&&a.getPropertyValue("cursor")==="pointer"&&(t=!0)}catch{}s.push(n),r=n}return{parentIsUsefulElement:t,targetElementList:s}};function wr(i){for(var e=new Set,t=0,s=i;s.parentNode&&!Fe(s,"body");s=s.parentNode){if(t++>=mo||e.has(s))return!1;e.add(s);var r=ss(s);if(L(r,"ph-sensitive")||L(r,"ph-no-capture"))return!1}if(L(ss(i),"ph-include"))return!0;var n=i.type||"";if(q(n))switch(n.toLowerCase()){case"hidden":case"password":return!1}var a=i.name||i.id||"";return!q(a)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(a.replace(/[^a-zA-Z0-9]/g,""))}function ko(i){return!!(Fe(i,"input")&&!["button","checkbox","submit","reset"].includes(i.type)||Fe(i,"select")||Fe(i,"textarea")||i.getAttribute("contenteditable")==="true")}var On=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}))$"),Fn=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,xu=[16,15,14,13],ku=new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),Cn=new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),Tn=/[0-9A-Za-z_]/;function Eu(i){for(var e=0,t=!1,s=i.length-1;s>=0;s--){var r=i.charCodeAt(s)-48;t&&(r*=2)>9&&(r-=9),e+=r,t=!t}return e%10==0}function oi(i,e){if(e===void 0&&(e=!0),D(i))return!1;if(q(i)){i=hs(i);var t=e?On.test((i||"").replace(/[- ]/g,"")):(function(r){var n;for(Fn.lastIndex=0;n=Fn.exec(r);){var a=n[2];if(a)for(var o=a.replace(/[- ]/g,""),l=0;o.length>l;l++)for(var h of xu){var u=l+h;if(o.length>=u){var c=o.slice(l,u);if(On.test(c)&&Eu(c))return!0}}}return!1})(i);if(t)return!1;var s=e?ku.test(i):(function(r){var n;for(Cn.lastIndex=0;n=Cn.exec(r);){var a=n[1],o=n[3];if(!(a&&o&&Tn.test(a)&&Tn.test(o)))return!0}return!1})(i);if(s)return!1}return!0}function $n(i){var e=pi(i);return oi(e=(e+" "+Eo(i)).trim())?e:""}function Eo(i){var e="";return i&&i.childNodes&&i.childNodes.length&&U(i.childNodes,(function(t){var s;if(t&&((s=t.tagName)==null?void 0:s.toLowerCase())==="span")try{var r=pi(t);e=(e+" "+r).trim(),t.childNodes&&t.childNodes.length&&(e=(e+" "+Eo(t)).trim())}catch(n){E.error("[AutoCapture]",n)}})),e}function Mn(i){return i.replace(/"|\\"/g,'\\"')}function Su(i){var e=i.attr__class;if(e)return A(e)?e:Vr(e)}var Ei=K("[Dead Clicks]"),Pu=()=>!0,Iu=i=>{var e,t=!((e=i.instance.persistence)==null||!e.get_property(Nr)),s=i.instance.config.capture_dead_clicks;return Oe(s)?s:!!Z(s)||t};class Rn{get lazyLoadedDeadClicksAutocapture(){return this.Qn}constructor(e,t,s){this.instance=e,this.isEnabled=t,this.onCapture=s,this.startIfEnabledOrStop()}onRemoteConfig(e){if(e.ok){var t=e.config;"captureDeadClicks"in t&&(this.instance.persistence&&this.instance.persistence.register({[Nr]:t.captureDeadClicks}),this.startIfEnabledOrStop())}}startIfEnabledOrStop(){this.isEnabled(this)?this.Jn((()=>{this.Kn()})):this.stop()}Jn(e){var t,s;(t=$.__PosthogExtensions__)!=null&&t.initDeadClicksAutocapture?e():(s=$.__PosthogExtensions__)==null||s.loadExternalDependency==null||s.loadExternalDependency(this.instance,"dead-clicks-autocapture",(r=>{r?Ei.error("failed to load script",r):e()}))}Kn(){var e;if(S){if(!this.Qn&&(e=$.__PosthogExtensions__)!=null&&e.initDeadClicksAutocapture){var t=Z(this.instance.config.capture_dead_clicks)?y({},this.instance.config.capture_dead_clicks):{};t.__onCapture=this.onCapture,this.onCapture&&(t.capture_dead_swipes=!1),this.Qn=$.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this.Qn.start(S),Ei.info("starting...")}}else Ei.error("`document` not found. Cannot start.")}stop(){this.Qn&&(this.Qn.stop(),this.Qn=void 0,Ei.info("stopping..."))}}var Cs=K("[SegmentIntegration]"),So="posthog-js";function Po(i,e){var t=e===void 0?{}:e,s=t.organization,r=t.projectId,n=t.prefix,a=t.severityAllowList,o=a===void 0?["error"]:a,l=t.sendExceptionsToPostHog,h=l===void 0||l;return u=>{var c,d,p,v,f;if(o!=="*"&&!o.includes(u.level)||!i.__loaded)return u;u.tags||(u.tags={});var g=i.requestRouter.endpointFor("ui","/project/"+i.config.token+"/person/"+i.get_distinct_id());u.tags["PostHog Person URL"]=g,i.sessionRecordingStarted()&&(u.tags["PostHog Recording URL"]=i.get_session_replay_url({withTimestamp:!0}));var m,b=((c=u.exception)==null?void 0:c.values)||[],k=b.map((x=>y({},x,{stacktrace:x.stacktrace?y({},x.stacktrace,{type:"raw",frames:(x.stacktrace.frames||[]).map((C=>y({},C,{platform:"web:javascript"})))}):void 0}))),P={$exception_message:((d=b[0])==null?void 0:d.value)||u.message,$exception_type:(p=b[0])==null?void 0:p.type,$exception_level:u.level,$exception_list:k,$sentry_event_id:u.event_id,$sentry_exception:u.exception,$sentry_exception_message:((v=b[0])==null?void 0:v.value)||u.message,$sentry_exception_type:(f=b[0])==null?void 0:f.type,$sentry_tags:u.tags};return s&&r&&(P.$sentry_url=(n||"https://sentry.io/organizations/")+s+"/issues/?project="+r+"&query="+u.event_id),h&&((m=i.exceptions)==null||m.sendExceptionEvent(P)),u}}class Ou{constructor(e,t,s,r,n,a){this.name=So,this.setupOnce=function(o){o(Po(e,{organization:t,projectId:s,prefix:r,severityAllowList:n,sendExceptionsToPostHog:a==null||a}))}}}class An{constructor(e){this.Yn=(t,s,r)=>{r&&(r.noSessionId||r.activityTimeout||r.sessionPastMaximumLength||r.crossTabAdoption)&&(E.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:t,changeReason:r}),this.Xn=void 0,this._instance.scrollManager.resetContext())},this._instance=e,this.ts()}ts(){var e;this.es=(e=this._instance.sessionManager)==null?void 0:e.onSessionId(this.Yn)}destroy(){var e;(e=this.es)==null||e.call(this),this.es=void 0}doPageView(e,t){var s,r=this.rs(e,t);return this.Xn={pathname:(s=_?.location.pathname)!==null&&s!==void 0?s:"",pageViewId:t,timestamp:e},this._instance.scrollManager.resetContext(),r}doPageLeave(e){var t;return this.rs(e,(t=this.Xn)==null?void 0:t.pageViewId)}doEvent(){var e;return{$pageview_id:(e=this.Xn)==null?void 0:e.pageViewId}}rs(e,t){var s=this.Xn;if(!s)return{$pageview_id:t};var r={$pageview_id:t,$prev_pageview_id:s.pageViewId},n=this._instance.scrollManager.getContext();if(n&&!this._instance.config.disable_scroll_properties){var a=n.maxScrollHeight,o=n.lastScrollY,l=n.maxScrollY,h=n.maxContentHeight,u=n.lastContentY,c=n.maxContentY;if(!(w(a)||w(o)||w(l)||w(h)||w(u)||w(c))){a=Math.ceil(a),o=Math.ceil(o),l=Math.ceil(l),h=Math.ceil(h),u=Math.ceil(u),c=Math.ceil(c);var d=a>1?ze(o/a,0,1,E):1,p=a>1?ze(l/a,0,1,E):1,v=h>1?ze(u/h,0,1,E):1,f=h>1?ze(c/h,0,1,E):1;r=W(r,{$prev_pageview_last_scroll:o,$prev_pageview_last_scroll_percentage:d,$prev_pageview_max_scroll:l,$prev_pageview_max_scroll_percentage:p,$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&&(r.$prev_pageview_pathname=s.pathname),s.timestamp&&(r.$prev_pageview_duration=(e.getTime()-s.timestamp.getTime())/1e3),r}}var Ts=["flags","surveys"],Fu={[eo]:{exposure:"hidden"},[Ft]:{exposure:"hidden"},__cmpns:{exposure:"hidden"},[ii]:{exposure:"hidden"},[rr]:{exposure:"event"},[nr]:{exposure:"hidden"},[ar]:{exposure:"event"},[or]:{exposure:"hidden"},[lr]:{exposure:"event"},[ur]:{exposure:"event"},[Nr]:{exposure:"event"},[jr]:{exposure:"hidden"},[hr]:{exposure:"event"},[ft]:{exposure:"hidden"},$session_recording_enabled_server_side:{exposure:"hidden"},[Ct]:{exposure:"hidden"},[Hr]:{exposure:"event"},[to]:{exposure:"event",shouldSkipFromEventProperties:i=>de(i)},$session_past_minimum_duration:{exposure:"event"},$session_recording_url_trigger_activated_session:{exposure:"event"},$session_recording_event_trigger_activated_session:{exposure:"event"},$debug_first_full_snapshot_timestamp:{exposure:"event"},$sess_rec_flush_size:{exposure:"hidden"},[Qe]:{exposure:"hidden",storageGroup:"flags"},[gt]:{exposure:"hidden",storageGroup:"flags"},[$i]:{exposure:"hidden"},[vi]:{exposure:"hidden",storageGroup:"flags"},[_t]:{exposure:"hidden",storageGroup:"flags"},[At]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[Yi]:{exposure:"hidden",storageGroup:"flags"},[qe]:{exposure:"hidden"},[dt]:{exposure:"hidden"},[Le]:{exposure:"hidden"},[Ue]:{exposure:"hidden"},[cr]:{exposure:"hidden",storageGroup:"surveys"},[Qi]:{exposure:"hidden",storageGroup:"surveys",volatile:!0},[dr]:{exposure:"event"},[Mi]:{exposure:"hidden"},[Ri]:{exposure:"hidden"},[si]:{exposure:"hidden"},$product_tours_activated:{exposure:"hidden"},$product_tours_activated_session:{exposure:"hidden"},$conversations_widget_session_id:{exposure:"event"},$conversations_ticket_id:{exposure:"event"},$conversations_widget_state:{exposure:"event"},$conversations_user_traits:{exposure:"event"},[Ze]:{exposure:"hidden"},[ri]:{exposure:"hidden"},[ao]:{exposure:"event"},[Lt]:{exposure:"hidden"},[yt]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[j]:{exposure:"hidden"},[vr]:{exposure:"hidden"},[pr]:{exposure:"hidden"},[fr]:{exposure:"hidden"},[gr]:{exposure:"hidden"},[Zi]:{exposure:"hidden"},[Ki]:{exposure:"hidden"},[io]:{exposure:"event"},[so]:{exposure:"event"},[ro]:{exposure:"event"},[no]:{exposure:"event"},[lo]:{exposure:"event"},[uo]:{exposure:"event"},[_r]:{exposure:"event"},$sdk_debug_replay_event_trigger_status:{exposure:"event"},$sdk_debug_replay_linked_flag_trigger_status:{exposure:"event"},$sdk_debug_replay_matched_recording_trigger_groups:{exposure:"event"},$sdk_debug_replay_remote_trigger_matching_config:{exposure:"event"},$sdk_debug_replay_trigger_groups_count:{exposure:"event"},$sdk_debug_replay_url_trigger_status:{exposure:"event"},$session_recording_start_reason:{exposure:"event"}},Cu=[["$posthog_sr_group_event_trigger_",{exposure:"hidden"}],["$posthog_sr_group_url_trigger_",{exposure:"hidden"}],["$posthog_sr_group_sampling_",{exposure:"hidden"}]],Be=i=>{var e=Fu[i];if(e)return e;for(var t of Cu){var s=t[1];if(i.indexOf(t[0])===0)return s}},Tt=(i,e)=>{try{return JSON.stringify(i,((t,s)=>typeof s=="bigint"?s.toString():s),e)}catch{return ba(i)}},Ht=i=>{var e=S?.createElement("a");return w(e)?null:(e.href=i,e)},qt=function(i,e){for(var t,s=((i.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),r=0;s.length>r;r++){var n=s[r].split("=");if(n[0]===e){t=n;break}}if(!A(t)||2>t.length)return"";var a=t[1];try{a=decodeURIComponent(a)}catch{E.error("Skipping decoding for malformed query param: "+a)}return a.replace(/\+/g," ")},fi=function(i,e,t){if(!i||!e||!e.length)return i;for(var s=i.split("#"),r=s[1],n=(s[0]||"").split("?"),a=n[1],o=n[0],l=(a||"").split("&"),h=[],u=0;l.length>u;u++){var c=l[u].split("=");A(c)&&(e.includes(c[0])?h.push(c[0]+"="+t):h.push(l[u]))}var d=o;return a!=null&&(d+="?"+h.join("&")),r!=null&&(d+="#"+r),d},rs=function(i,e){var t=i.match(new RegExp(e+"=([^&]*)"));return t?t[1]:null},Io=(i,e)=>i>=e&&ga(),Oo=(i,e,t,s)=>{if(i===0){if(ga()){var r=e+1;return r===t&&s(),r}return e}return 0},Si="https?://(.*)",Bt=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],Tu=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...Bt],gi="<masked>",$u=["li_fat_id"];function Fo(i,e,t){if(!S)return{};var s,r=e?[...Bt,...t||[]]:[],n=Co(fi(S.URL,r,gi),i),a=(s={},U($u,(function(o){var l=ho(o);s[o]=l||null})),s);return W(a,n)}function Co(i,e){var t=Tu.concat(e||[]),s={};return U(t,(function(r){var n=qt(i,r);s[r]=n||null})),s}function To(i){var e=(function(n){return n?n.search(Si+"google.([^/?]*)")===0?"google":n.search(Si+"bing.com")===0?"bing":n.search(Si+"yahoo.com")===0?"yahoo":n.search(Si+"duckduckgo.com")===0?"duckduckgo":null:null})(i),t=e!="yahoo"?"q":"p",s={};if(!de(e)){s.$search_engine=e;var r=S?qt(S.referrer,t):"";r.length&&(s.ph_keyword=r)}return s}function Ln(){return navigator.language||navigator.userLanguage}var ns="$direct";function $o(){return S?.referrer||ns}function Mo(i,e,t){t===void 0&&(t=!1);var s=i?[...Bt,...e||[]]:[],r=t?rt(X?.href):X?.href,n=r?.substring(0,1e3);return{r:$o().substring(0,1e3),u:n?fi(n,s,gi):void 0}}function Ro(i,e){var t;e===void 0&&(e=!1);var s=i.r,r=i.u,n=e?rt(r):r,a={$referrer:s,$referring_domain:s==null?void 0:s==ns?ns:(t=Ht(s))==null?void 0:t.host};if(n){a.$current_url=n;var o=Ht(n);a.$host=o?.host,a.$pathname=o?.pathname;var l=Co(n);W(a,l)}if(s){var h=To(s);W(a,h)}return a}function Ao(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function Mu(){try{return new Date().getTimezoneOffset()}catch{return}}var Ru={flags:yt,surveys:Qi},Au=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],Pi=i=>i+"_cookie_identity_change_pending",it="main",Dn=(i,e)=>{U(i,((t,s)=>{var r=Be(s);r&&r.exposure!=="event"||{}.hasOwnProperty.call(e,s)||delete i[s]}))};class $s{constructor(e,t,s){if(s===void 0&&(s=!0),this.ns={},this.ss=!1,this.os=!1,this.ls=!1,this.us=!1,this.Oi=e,this.hs=s,this.props={},this.ds=void 0,this.vs=(n=>{var a="";return n.token&&(a=n.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),n.persistence_name?"ph_"+n.persistence_name:"ph_"+a+"_posthog"})(e),this.Vn=this.cs(e),this.os=this.fs(e),this.load(),e.debug&&E.info("Persistence loaded",e.persistence,y({},this.props)),this.update_config(e,e,t),this.save(),_){var r=()=>this.flush();ee(_,"beforeunload",r,{capture:!1}),ee(_,"pagehide",r,{capture:!1})}}ps(){var e,t=(e=this.Oi)==null?void 0:e.persistence_save_debounce_ms;return oe(t)&&t>0?t:0}gs(e){if(this.Oi.cookieWinsOnConflict&&this.Oi.persistence.toLowerCase()==="localstorage+cookie")if(e)try{var t=Is(e,this.Oi.cookie_persisted_properties||[]),s=wn(t,this.Oi.cookie_persisted_properties||[]),r=JSON.stringify(t)+"|"+JSON.stringify(s),n=le.Fr(this.vs)||void 0;n&&Os(this.vs,n)===r&&(this.ys=r,this.bs=n)}catch{}else try{var a=le.Fr(this.vs)||void 0;this.ys=a?Os(this.vs,a):void 0,this.bs=a}catch{}}syncCookieProperties(){return this._s(this.Oi)}_s(e,t){if(t===void 0&&(t=!1),this.ws&&!t||this.us||!e.cookieWinsOnConflict||e.persistence.toLowerCase()!=="localstorage+cookie")return!1;var s;try{s=le.Fr(this.vs)||void 0}catch{}if(!s||s===this.bs)return!1;var r,n=Os(this.vs,s);try{r=Ps(JSON.parse(s))}catch{return!1}if((le.Fr(this.vs)||void 0)!==s)return!1;this.ys=n,this.bs=s;var a=xn(this.vs,s),o=[...pt,...a.properties],l={};if(Object.keys(r).forEach((f=>{var g=r[f];(w(g)||de(g)||g===""||f===j&&g!==ae&&g!==ve)&&(l[f]=!0,delete r[f])})),De(r))return!1;var h=_e in r||r[j]===ae||r[j]===ve,u=this.props[_e],c=this.props[j],d=W({},this.props);[...pt,...e.cookie_persisted_properties||[]].forEach((f=>{if(o.indexOf(f)!==-1&&!(f in r)&&!l[f]&&(h||f!==_e&&f!==j)){var g=d[f];!a.isValid&&pt.indexOf(f)!==-1&&(g===!1||g===0)||delete d[f]}})),this.props=W(d,r),!h||j in r||j in this.props||this.ks(j,ae);var p=this.props[_e],v=this.props[j];return!h||p===u&&v===c||(this.ls=!0,J.Or(Pi(this.vs),!0),this.Ss(Le),this.Ss(gt),this.Ss(Qe),this.Ss(vi),this.Ss(_t),this.Ss(At),this.Ss(yt),this.Ss(Lt),this.Ss(Ze),v===ae&&(c===ve||r[j]===ae||!w(u)&&p!==u)&&(Dn(this.props,r),this.Ss(Ue)),v===ve?this.props.$user_id=p:delete this.props.$user_id,this.Ss(Ft)),!0}consumeCookieIdentityChange(){var e=Pi(this.vs),t=this.ls||!!J.Fr(e);return this.ls=!1,t&&J.Dr(e),t}xs(e){return e===void 0&&(e=!1),!(this.us||this.ws&&!e||!this.Oi.cookieWinsOnConflict||this.Oi.persistence.toLowerCase()!=="localstorage+cookie"||(this.us=!0,0))}Cs(){this.us&&(w(this.Ts)||(clearTimeout(this.Ts),this.Ts=void 0),delete this.ns[it],this.Ms(!0))}Es(e){if(e===void 0&&(e=!0),this.us)try{e?this.Cs():w(this.Ts)||(clearTimeout(this.Ts),this.Ts=void 0)}finally{this.us=!1}}isDisabled(){return!!this.ws}cs(e){Au.indexOf(e.persistence.toLowerCase())===-1&&(E.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var t,s=(function(a,o){a===void 0&&(a=[]),o===void 0&&(o=!1);var l=[...pt,...a];return y({},G,{Pr(h){try{var u,c={};try{u=le.Fr(h)||void 0,c=u?Ps(JSON.parse(u)):{}}catch{}var d,p=JSON.parse(G.Fr(h)||"{}");if(o){var v=xn(h,u),f=[...pt,...v.properties],g={};Object.keys(c).forEach((x=>{var C=c[x];de(C)||C===""||x===j&&C!==ae&&C!==ve||(g[x]=C)}));var m=_e in g||g[j]===ae||g[j]===ve;if(Object.keys(g).length>0){var b,k=p[_e],P=(b=p[j])!==null&&b!==void 0?b:ae;l.forEach((x=>{if(f.indexOf(x)!==-1&&!(x in c)&&(m||x!==_e&&x!==j)){var C=p[x];!v.isValid&&pt.indexOf(x)!==-1&&(C===!1||C===0)||delete p[x]}})),!m||j in c||j in p||(p[j]=ae),!m||(_e in g?g[_e]:p[_e])===k&&(j in g?g[j]:p[j])===P||(Ss.forEach((x=>delete p[x])),g[j]===ve&&_e in g?p.$user_id=g[_e]:delete p.$user_id,g[j]!==ve&&(delete p[ao],delete p[Ue]),delete p.__alias)}d=W(p,g)}else d=W(c,p);return G.Or(h,d),d}catch{}return null},Or(h,u,c,d,p,v){var f=G.Or(h,u,void 0,void 0,v);try{var g=Is(u,a);if(Object.keys(g).length){if(o){var m=is(h),b=wn(g,a);if(le.Or(m,b,c,d,p,v),le.Fr(m)!==JSON.stringify(b)){le.Dr(m,d);var k=Is(u);return le.Or(h,k,c,d,p,v),f}}le.Or(h,g,c,d,p,v)}}catch(P){G.Nr(P)}return f},Dr(h,u){try{_?.localStorage.removeItem(h),le.Dr(h,u),le.Dr(is(h),u)}catch(c){G.Nr(c)}}})})(e.cookie_persisted_properties||[],e.cookieWinsOnConflict),r=!1,n=e.persistence.toLowerCase();return n==="localstorage"&&G.Lr()?(t=G,r=!0):n==="localstorage+cookie"&&s.Lr()?(t=s,r=!0):n==="sessionstorage"&&J.Lr()?t=J:n==="memory"?t=pu:n==="cookie"?t=le:s.Lr()?(t=s,r=!0):t=le,this.ss=r,t}Is(e){return this.vs+"__"+e}fs(e){return this.ss&&!!e.split_storage}properties(){var e={};return U(this.props,((t,s)=>{var r=Be(s);if(!r||r.exposure==="event"){if(r!=null&&r.shouldSkipFromEventProperties!=null&&r.shouldSkipFromEventProperties(t))return;e[s]=t}})),e}load(e){if(e===void 0&&(e=!1),!this.ws||e){var t=this.Oi.cookieWinsOnConflict&&this.Oi.persistence.toLowerCase()==="localstorage+cookie",s=t?G.Pr(this.vs):null,r={};if(t)try{U(r=Ps(le.Pr(this.vs)),((v,f)=>{(w(v)||de(v)||v==="")&&delete r[f]}))}catch{}var n=this.Vn.Pr(this.vs);if(n&&(this.props=W({},n)),this.os&&this.Rs(),t&&n){var a,o,l=s?.[_e],h=(a=s?.[j])!==null&&a!==void 0?a:ae,u=n[_e],c=(o=n[j])!==null&&o!==void 0?o:ae;if(u!==l||c!==h){this.ls=!0,J.Or(Pi(this.vs),!0);var d=W({},this.props);Ss.forEach((v=>delete d[v])),c===ae&&(h===ve||r[j]===ae||!w(l)&&u!==l)&&(Dn(d,r),delete d[Ue]),this.props=d;var p=new Set;Ss.forEach((v=>{var f,g=(f=Be(v))==null?void 0:f.storageGroup;g&&p.add(g)})),p.forEach((v=>{var f={};U(this.props,((g,m)=>{var b;((b=Be(m))==null?void 0:b.storageGroup)===v&&(f[m]=g)})),De(f)?(G.Dr(this.Is(v)),this.ns[v]={}):G.Or(this.Is(v),f)&&(this.ns[v]={persisted:!0,fingerprint:this.Ps(f,v)})}))}}J.Fr(Pi(this.vs))&&(this.ls=!0)}}Rs(){for(var e of Ts){var t=G.Pr(this.Is(e));if(t&&!De(t)){var s=this.As(e);s.persisted=!0,this.Fs(e)||(s.fingerprint=this.Ps(t,e)),this.Os(e,t)||W(this.props,t)}}}Fs(e){return Object.keys(this.props).some((t=>{var s;return((s=Be(t))==null?void 0:s.storageGroup)===e}))}Os(e,t){var s=Ru[e];if(!s)return!1;var r=t[s],n=this.props[s];return oe(r)&&oe(n)&&n>r}refreshKey(e){var t;if(!this.ws){var s=this.os?(t=Be(e))==null?void 0:t.storageGroup:void 0,r=s?G.Pr(this.Is(s)):this.Vn.Pr(this.vs);if(r&&e in r)this.ks(e,r[e]);else{if(s){var n=this.Vn.Pr(this.vs);if(n&&e in n)return void this.ks(e,n[e])}this.Ss(e)}}}save(){if(!this.ws){var e=this.ps();e>0?w(this.Ts)&&(this.Ts=setTimeout((()=>{this.Ts=void 0,this.Ms()}),e)):this.Ms()}}flush(){w(this.Ts)||(clearTimeout(this.Ts),this.Ts=void 0,this.Ms())}Ms(e){e===void 0&&(e=!1),this.ws||this.us&&!e||(e||this.syncCookieProperties(),this.os?this.Ls():this.$s(this.Vn,this.vs,this.props,it)&&this.gs(this.props))}Ls(){var e=this.Ds(),t=e.main,s=e.groups;for(var r of(this.$s(this.Vn,this.vs,t,it)&&this.gs(t),Ts)){var n,a=s[r];(!De(a)||(n=this.ns[r])!=null&&n.persisted)&&this.$s(G,this.Is(r),a,r)}}Ds(){var e={},t={flags:{},surveys:{}};return U(this.props,((s,r)=>{var n,a=(n=Be(r))==null?void 0:n.storageGroup;a?t[a][r]=s:e[r]=s})),{main:e,groups:t}}Ps(e,t){if(t===it)return JSON.stringify(e)+"|"+this.Ns+"|"+this.qs+"|"+this.js;var s={};return U(e,((r,n)=>{var a;s[n]=(a=Be(n))!=null&&a.volatile?"__volatile__":r})),JSON.stringify(s)}$s(e,t,s,r){var n,a=this.As(r);if(r!==it&&!a.dirty&&!w(a.fingerprint))return!1;try{if((n=this.Ps(s,r))===a.fingerprint)return a.dirty=!1,!1}catch{n=void 0}return e.Or(t,s,this.Ns,this.qs,this.js,this.Oi.debug)?(a.dirty=!1,r!==it&&(a.persisted=!0),w(n)||(a.fingerprint=n),!0):(this.Oi.debug&&E.warn('failed to persist storage entry "'+t+'"; will retry on next save'),!1)}remove(e){var t=(e===void 0?{}:e).keepGroupEntries,s=t!==void 0&&t;if(w(this.Ts)||(clearTimeout(this.Ts),this.Ts=void 0),this.Vn.Dr(this.vs,!1),this.Vn.Dr(this.vs,!0),!s&&this.hs)for(var r of Ts)G.Dr(this.Is(r));s?delete this.ns[it]:this.ns={},this.ys=void 0,this.bs=void 0}clear(){this.remove(),this.props={}}register_once(e,t,s){if(Z(e)){this.syncCookieProperties(),w(t)&&(t="None"),this.Ns=w(s)?this.Bs:s;var r=!1;if(U(e,((n,a)=>{this.props.hasOwnProperty(a)&&this.props[a]!==t||(this.ks(a,n),r=!0)})),r)return this.save(),!0}return!1}register(e,t){if(Z(e)){this.syncCookieProperties(),this.Ns=w(t)?this.Bs:t;var s=!1;if(U(e,((r,n)=>{e.hasOwnProperty(n)&&(this.props[n]!==r||Z(r)||A(r))&&(this.ks(n,r),s=!0)})),s)return this.save(),!0}return!1}unregister(e){this.syncCookieProperties();var t=typeof e=="string"?[e]:e,s=!1;for(var r of t)r in this.props&&(this.Ss(r),s=!0);s&&this.save()}update_campaign_params(){var e=S?.URL;if(e!==this.ds){var t=Fo(this.Oi.custom_campaign_params,this.Oi.mask_personal_data_properties,this.Oi.custom_personal_data_properties);De(Br(t))||this.register(t),this.ds=e}}update_search_keyword(){var e;this.register((e=S?.referrer)?To(e):{})}update_referrer_info(){var e;this.register_once({$referrer:$o(),$referring_domain:S!=null&&S.referrer&&((e=Ht(S.referrer))==null?void 0:e.host)||ns},void 0)}set_initial_person_info(){this.props[fr]||this.props[gr]||this.register_once({[Zi]:Mo(this.Oi.mask_personal_data_properties,this.Oi.custom_personal_data_properties,this.Oi.disable_capture_url_hashes)},void 0)}get_initial_props(){var e={};U([gr,fr],(r=>{var n=this.props[r];n&&U(n,(function(a,o){e["$initial_"+Ks(o)]=a}))}));var t=this.props[Zi];if(t){var s=(function(r,n){n===void 0&&(n=!1);var a=Ro(r,n),o={};return U(a,(function(l,h){o["$initial_"+Ks(h)]=l})),o})(t,this.Oi.disable_capture_url_hashes);W(e,s)}return e}safe_merge(e){return U(this.props,(function(t,s){s in e||(e[s]=t)})),e}update_config(e,t,s){var r=e.persistence!==t.persistence,n=!((f,g)=>{if(f.length!==g.length)return!1;var m=[...f].sort(),b=[...g].sort();return m.every(((k,P)=>k===b[P]))})(e.cookie_persisted_properties||[],t.cookie_persisted_properties||[]),a=r||n,o=e.cookieWinsOnConflict!==t.cookieWinsOnConflict,l=e.disable_persistence||!!s,h=!!this.ws&&!l;l||this._s(t,h),this.Oi=e,!l&&(r||n||o)&&(this.ys=void 0,this.bs=void 0,this._s(y({},e,{cookie_persisted_properties:t.cookie_persisted_properties}),h));var u=a||o?this.cs(e):this.Vn,c=this.fs(e),d=a||c!==this.os,p=!l&&(d||e.cross_subdomain_cookie!==this.qs||e.secure_cookie!==this.js)&&this.xs(h);try{if(this.Bs=this.Ns=e.cookie_expiration,this.set_disabled(l),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),d){var v=this.props;this.clear(),this.Vn=u,this.os=c,this.props=v,this.save()}else o&&(this.Vn=u,l||(delete this.ns[it],this.Ms()))}finally{p&&this.Es()}}set_disabled(e){this.ws=e,this.ws?this.remove():this.save()}set_cross_subdomain(e){e!==this.qs&&(this.qs=e,this.remove({keepGroupEntries:!0}),this.save())}set_secure(e){e!==this.js&&(this.js=e,this.remove({keepGroupEntries:!0}),this.save())}set_event_timer(e,t){var s=this.props[ii]||{};s[e]=t,this.ks(ii,s),this.save()}remove_event_timer(e){var t=this.props[ii]||{},s=t[e];return w(s)||(delete t[e],this.ks(ii,t),this.save()),s}get_property(e){return this.props[e]}set_property(e,t){this.ks(e,t),this.save()}ks(e,t){var s;this.props[e]=t,(s=Be(e))!=null&&s.volatile||this.Hs(e)}Ss(e){delete this.props[e],this.Hs(e)}Hs(e){var t,s=(t=Be(e))==null?void 0:t.storageGroup;s&&(this.As(s).dirty=!0)}As(e){return this.ns[e]||(this.ns[e]={})}}function Ii(i){var e=!0;return{dispose(){if(e){e=!1;var t=i();t&&me(t.then)&&t.then(void 0,(()=>{}))}}}}var ye={GZipJS:"gzip-js",Base64:"base64"},Yt={Activation:"events",Cancellation:"cancelEvents"},Ms={Popover:"popover",API:"api",Widget:"widget"},Xe={SHOWN:"survey shown",DISMISSED:"survey dismissed",SENT:"survey sent"},Rs={SURVEY_ID:"$survey_id",SURVEY_ITERATION:"$survey_iteration",SURVEY_LAST_SEEN_DATE:"$survey_last_seen_date"},xr={Popover:"popover",Inline:"inline"},Lu={SHOWN:"product tour shown"},Nn={TOUR_LAST_SEEN_DATE:"$product_tour_last_seen_date",TOUR_TYPE:"$product_tour_type"},jn=K("[RateLimiter]");class Du{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=t=>{var s=t.text;if(s&&s.length)try{(JSON.parse(s).quota_limited||[]).forEach((r=>{jn.info((r||"events")+" is quota limited."),this.serverLimits[r]=new Date().getTime()+6e4}))}catch(r){return void jn.warn('could not rate limit - continuing. Error: "'+r?.message+'"',{text:s})}},this.instance=e,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var e;return((e=this.instance.config.rate_limiting)==null?void 0:e.events_per_second)||10}get captureEventsBurstLimit(){var e;return Math.max(((e=this.instance.config.rate_limiting)==null?void 0:e.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(e){var t,s,r;e===void 0&&(e=!1);var n=this.captureEventsBurstLimit,a=this.captureEventsPerSecond,o=new Date().getTime(),l=(t=(s=this.instance.persistence)==null?void 0:s.get_property(pr))!==null&&t!==void 0?t:{tokens:n,last:o};l.tokens+=(o-l.last)/1e3*a,l.last=o,l.tokens>n&&(l.tokens=n);var h=1>l.tokens;if(h||e||(l.tokens=Math.max(0,l.tokens-1)),h&&!e){var u=(oe(l.dropped)?l.dropped:0)+1;l.dropped=u,!this.lastEventRateLimited&&this.zs(u)&&(l.dropped=0)}return this.lastEventRateLimited=h,(r=this.instance.persistence)==null||r.set_property(pr,l),{isRateLimited:h,remainingTokens:l.tokens}}Us(e){var t=this.instance.config.property_denylist;return!A(t)||!t.includes(e)}Ws(){var e;if(this.Us("$current_url")&&this.Us("$pathname")&&X!=null&&X.pathname)return""+((e=X.origin)!==null&&e!==void 0?e:"")+X.pathname}zs(e){var t,s,r=this.captureEventsBurstLimit,n=this.captureEventsPerSecond,a=this.Ws(),o=this.Us("$session_id")?(t=(s=this.instance).get_session_id)==null?void 0:t.call(s):void 0,l=[e+" event(s) dropped since the last warning",a?"triggered on "+a:void 0,o?"session "+o:void 0].filter(Boolean).join(", ");return!!this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited: "+l+". Config is set to "+n+" events per second and "+r+" events burst limit."},{skip_client_rate_limiting:!0})}isServerRateLimited(e){var t=this.serverLimits[e||"events"]||!1;return t!==!1&&new Date().getTime()<t}}var st=K("[RemoteConfig]");class Lo{constructor(e){this._instance=e}get remoteConfig(){var e;return(e=$._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.config}Vs(e){var t,s;(t=$.__PosthogExtensions__)!=null&&t.loadExternalDependency?(s=$.__PosthogExtensions__)==null||s.loadExternalDependency==null||s.loadExternalDependency(this._instance,"remote-config",(()=>e(this.remoteConfig))):e()}Gs(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 st.info("Using preloaded remote config",this.remoteConfig),this.Zs(this.remoteConfig),void this.Qs();if(this._instance.Js())return void st.warn("Remote config is disabled. Falling back to local config.");this.Vs((e=>{if(!e)return st.info("No config found after loading remote JS config. Falling back to JSON."),void this.Gs((t=>{this.Zs(t.json,t),this.Qs()}));this.Zs(e),this.Qs()}))}catch(e){st.error("Error loading remote config",e),this.Zs()}}stop(){this.Ks&&(clearInterval(this.Ks),this.Ks=void 0)}refresh(){!this._instance.Js()&&S&&S.visibilityState!=="hidden"&&this._instance.reloadFeatureFlags()}Qs(){var e;if(!this.Ks){var t=(e=this._instance.config.remote_config_refresh_interval_ms)!==null&&e!==void 0?e:3e5;t!==0&&(this.Ks=setInterval((()=>{this.refresh()}),t))}}Zs(e,t){!e&&t&&(t.statusCode===0?t.error||st.warn("Failed to fetch remote config from PostHog."):st.error("Failed to fetch remote config from PostHog."));try{this._instance.Zs(e?{ok:!0,config:e}:{ok:!1})}catch(r){st.error("Error applying remote config",r)}if(e?.hasFeatureFlags!==!1&&!this._instance.config.advanced_disable_feature_flags_on_first_load)try{var s;(s=this._instance.featureFlags)==null||s.ensureFlagsLoaded()}catch(r){st.error("Error loading feature flags",r)}}}var Re=Uint8Array,Se=Uint16Array,Vt=Uint32Array,Gr=new Re([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]),Wr=new Re([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]),Hn=new Re([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Do=function(i,e){for(var t=new Se(31),s=0;31>s;++s)t[s]=e+=1<<i[s-1];var r=new Vt(t[30]);for(s=1;30>s;++s)for(var n=t[s];t[s+1]>n;++n)r[n]=n-t[s]<<5|s;return[t,r]},No=Do(Gr,2),kr=No[1];No[0][28]=258,kr[258]=28;for(var qn=Do(Wr,0)[1],jo=new Se(32768),te=0;32768>te;++te){var Et=(43690&te)>>>1|(21845&te)<<1;jo[te]=((65280&(Et=(61680&(Et=(52428&Et)>>>2|(13107&Et)<<2))>>>4|(3855&Et)<<4))>>>8|(255&Et)<<8)>>>1}var li=function(i,e,t){for(var s=i.length,r=0,n=new Se(e);s>r;++r)++n[i[r]-1];var a,o=new Se(e);for(r=0;e>r;++r)o[r]=o[r-1]+n[r-1]<<1;for(a=new Se(s),r=0;s>r;++r)a[r]=jo[o[i[r]-1]++]>>>15-i[r];return a},bt=new Re(288);for(te=0;144>te;++te)bt[te]=8;for(te=144;256>te;++te)bt[te]=9;for(te=256;280>te;++te)bt[te]=7;for(te=280;288>te;++te)bt[te]=8;var as=new Re(32);for(te=0;32>te;++te)as[te]=5;var Nu=li(bt,9),ju=li(as,5),Ho=function(i){return(i/8>>0)+(7&i&&1)},qo=function(i,e,t){(t==null||t>i.length)&&(t=i.length);var s=new(i instanceof Se?Se:i instanceof Vt?Vt:Re)(t-e);return s.set(i.subarray(e,t)),s},Ge=function(i,e,t){var s=e/8>>0;i[s]|=t<<=7&e,i[s+1]|=t>>>8},Qt=function(i,e,t){var s=e/8>>0;i[s]|=t<<=7&e,i[s+1]|=t>>>8,i[s+2]|=t>>>16},As=function(i,e){for(var t=[],s=0;i.length>s;++s)i[s]&&t.push({s,f:i[s]});var r=t.length,n=t.slice();if(!r)return[new Re(0),0];if(r==1){var a=new Re(t[0].s+1);return a[t[0].s]=1,[a,1]}t.sort((function(x,C){return x.f-C.f})),t.push({s:-1,f:25001});var o=t[0],l=t[1],h=0,u=1,c=2;for(t[0]={s:-1,f:o.f+l.f,l:o,r:l};u!=r-1;)o=t[t[c].f>t[h].f?h++:c++],l=t[h!=u&&t[c].f>t[h].f?h++:c++],t[u++]={s:-1,f:o.f+l.f,l:o,r:l};var d=n[0].s;for(s=1;r>s;++s)n[s].s>d&&(d=n[s].s);var p=new Se(d+1),v=Er(t[u-1],p,0);if(v>e){s=0;var f=0,g=v-e,m=1<<g;for(n.sort((function(x,C){return p[C.s]-p[x.s]||x.f-C.f}));r>s;++s){var b=n[s].s;if(e>=p[b])break;f+=m-(1<<v-p[b]),p[b]=e}for(f>>>=g;f>0;){var k=n[s].s;e>p[k]?f-=1<<e-p[k]++-1:++s}for(;s>=0&&f;--s){var P=n[s].s;p[P]==e&&(--p[P],++f)}v=e}return[new Re(p),v]},Er=function(i,e,t){return i.s==-1?Math.max(Er(i.l,e,t+1),Er(i.r,e,t+1)):e[i.s]=t},Bn=function(i){for(var e=i.length;e&&!i[--e];);for(var t=new Se(++e),s=0,r=i[0],n=1,a=function(l){t[s++]=l},o=1;e>=o;++o)if(i[o]==r&&o!=e)++n;else{if(!r&&n>2){for(;n>138;n-=138)a(32754);n>2&&(a(n>10?n-11<<5|28690:n-3<<5|12305),n=0)}else if(n>3){for(a(r),--n;n>6;n-=6)a(8304);n>2&&(a(n-3<<5|8208),n=0)}for(;n--;)a(r);n=1,r=i[o]}return[t.subarray(0,s),e]},Zt=function(i,e){for(var t=0,s=0;e.length>s;++s)t+=i[s]*e[s];return t},Sr=function(i,e,t){var s=t.length,r=Ho(e+2);i[r]=255&s,i[r+1]=s>>>8,i[r+2]=255^i[r],i[r+3]=255^i[r+1];for(var n=0;s>n;++n)i[r+n+4]=t[n];return 8*(r+4+s)},Vn=function(i,e,t,s,r,n,a,o,l,h,u){Ge(e,u++,t),++r[256];for(var c=As(r,15),d=c[0],p=c[1],v=As(n,15),f=v[0],g=v[1],m=Bn(d),b=m[0],k=m[1],P=Bn(f),x=P[0],C=P[1],N=new Se(19),I=0;b.length>I;++I)N[31&b[I]]++;for(I=0;x.length>I;++I)N[31&x[I]]++;for(var F=As(N,7),O=F[0],M=F[1],T=19;T>4&&!O[Hn[T-1]];--T);var R,H,V,B,ie=h+5<<3,ue=Zt(r,bt)+Zt(n,as)+a,we=Zt(r,d)+Zt(n,f)+a+14+3*T+Zt(N,O)+(2*N[16]+3*N[17]+7*N[18]);if(ue>=ie&&we>=ie)return Sr(e,u,i.subarray(l,l+h));if(Ge(e,u,1+(ue>we)),u+=2,ue>we){R=li(d,p),H=d,V=li(f,g),B=f;var pe=li(O,M);for(Ge(e,u,k-257),Ge(e,u+5,C-1),Ge(e,u+10,T-4),u+=14,I=0;T>I;++I)Ge(e,u+3*I,O[Hn[I]]);u+=3*T;for(var xe=[b,x],Pe=0;2>Pe;++Pe){var se=xe[Pe];for(I=0;se.length>I;++I)Ge(e,u,pe[ce=31&se[I]]),u+=O[ce],ce>15&&(Ge(e,u,se[I]>>>5&127),u+=se[I]>>>12)}}else R=Nu,H=bt,V=ju,B=as;for(I=0;o>I;++I)if(s[I]>255){var ce;Qt(e,u,R[257+(ce=s[I]>>>18&31)]),u+=H[ce+257],ce>7&&(Ge(e,u,s[I]>>>23&31),u+=Gr[ce]);var he=31&s[I];Qt(e,u,V[he]),u+=B[he],he>3&&(Qt(e,u,s[I]>>>5&8191),u+=Wr[he])}else Qt(e,u,R[s[I]]),u+=H[s[I]];return Qt(e,u,R[256]),u+H[256]},Hu=new Vt([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),qu=(function(){for(var i=new Vt(256),e=0;256>e;++e){for(var t=e,s=9;--s;)t=(1&t&&3988292384)^t>>>1;i[e]=t}return i})(),Ls=function(i,e,t){for(;t;++e)i[e]=t,t>>>=8};function Bu(i,e){e===void 0&&(e={});var t=(function(){var c=4294967295;return{p(d){for(var p=c,v=0;d.length>v;++v)p=qu[255&p^d[v]]^p>>>8;c=p},d(){return 4294967295^c}}})(),s=i.length;t.p(i);var r,n,a,o,l,h=(o=10+((r=e).filename&&r.filename.length+1||0),l=8,(function(c,d,p,v,f,g){var m=c.length,b=new Re(v+m+5*(1+Math.floor(m/7e3))+f),k=b.subarray(v,b.length-f),P=0;if(!d||8>m)for(var x=0;m>=x;x+=65535){var C=x+65535;m>C?P=Sr(k,P,c.subarray(x,C)):(k[x]=!0,P=Sr(k,P,c.subarray(x,m)))}else{for(var N=Hu[d-1],I=N>>>13,F=8191&N,O=(1<<p)-1,M=new Se(32768),T=new Se(O+1),R=Math.ceil(p/3),H=2*R,V=function(ps){return(c[ps]^c[ps+1]<<R^c[ps+2]<<H)&O},B=new Vt(25e3),ie=new Se(288),ue=new Se(32),we=0,pe=0,xe=(x=0,0),Pe=0,se=0;m>x;++x){var ce=V(x),he=32767&x,Ne=T[ce];if(M[he]=Ne,T[ce]=he,x>=Pe){var at=m-x;if((we>7e3||xe>24576)&&at>423){P=Vn(c,k,0,B,ie,ue,pe,xe,se,x-se,P),xe=we=pe=0,se=x;for(var ne=0;286>ne;++ne)ie[ne]=0;for(ne=0;30>ne;++ne)ue[ne]=0}var Ae=2,tt=0,Ut=F,Te=he-Ne&32767;if(at>2&&ce==V(x-Te))for(var ke=Math.min(I,at)-1,_i=Math.min(32767,x),mi=Math.min(258,at);_i>=Te&&--Ut&&he!=Ne;){if(c[x+Ae]==c[x+Ae-Te]){for(var $e=0;mi>$e&&c[x+$e]==c[x+$e-Te];++$e);if($e>Ae){if(Ae=$e,tt=Te,$e>ke)break;var yi=Math.min(Te,$e-2),wt=0;for(ne=0;yi>ne;++ne){var xt=x-Te+ne+32768&32767,zt=xt-M[xt]+32768&32767;zt>wt&&(wt=zt,Ne=xt)}}}Te+=(he=Ne)-(Ne=M[he])+32768&32767}if(tt){B[xe++]=268435456|kr[Ae]<<18|qn[tt];var Yr=31&kr[Ae],Qr=31&qn[tt];pe+=Gr[Yr]+Wr[Qr],++ie[257+Yr],++ue[Qr],Pe=x+Ae,++we}else B[xe++]=c[x],++ie[c[x]]}}P=Vn(c,k,!0,B,ie,ue,pe,xe,se,x-se,P)}return qo(b,0,v+Ho(P)+f)})(n=i,(a=e).level==null?6:a.level,a.mem==null?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(n.length)))):12+a.mem,o,l)),u=h.length;return(function(c,d){var p=d.filename;if(c[0]=31,c[1]=139,c[2]=8,c[8]=2>d.level?4:d.level==9?2:0,c[9]=3,d.mtime!=0&&Ls(c,4,Math.floor(new Date(d.mtime||Date.now())/1e3)),p){c[3]=8;for(var v=0;p.length>=v;++v)c[v+10]=p.charCodeAt(v)}})(h,e),Ls(h,u-8,t.d()),Ls(h,u-4,s),h}var Vu=!!Js||!!Cr,Bo="text/plain",Li=!1,Vo=(i,e)=>{var t=i.split("#"),s=t[1],r=t[0].split("?"),n=r[0],a=r[1];if(!a)return i;var o=a.split("&").filter((l=>l.split("=")[0]!==e)).join("&");return n+(o?"?"+o:"")+(s?"#"+s:"")},ds=function(i,e,t){var s;t===void 0&&(t=!0);var r=i.split("?"),n=r[0],a=r[1],o=y({},e),l=(s=a?.split("&").map((u=>{var c,d=u.split("="),p=d[0],v=t&&(c=o[p])!==null&&c!==void 0?c:d[1];return delete o[p],p+"="+v})))!==null&&s!==void 0?s:[],h=(function(u,c){var d,p;c===void 0&&(c="&");var v=[];return U(u,(function(f,g){w(f)||w(g)||g==="undefined"||(d=encodeURIComponent((m=>m instanceof File)(f)?f.name:f.toString()),p=encodeURIComponent(g),v[v.length]=p+"="+d)})),v.join(c)})(o);return h&&l.push(h),l.length>0?n+"?"+l.join("&"):n},Ds=i=>{if(i.Ys)return i.Ys;var e=i.data,t=i.compression;if(e){if(t===ye.GZipJS){var s=Bu((function(o,l){var h=o.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(o);for(var u=new Re(o.length+(o.length>>>1)),c=0,d=function(g){u[c++]=g},p=0;h>p;++p){if(c+5>u.length){var v=new Re(c+8+(h-p<<1));v.set(u),u=v}var f=o.charCodeAt(p);128>f?d(f):2048>f?(d(192|f>>>6),d(128|63&f)):f>55295&&57344>f?(d(240|(f=65536+(1047552&f)|1023&o.charCodeAt(++p))>>>18),d(128|f>>>12&63),d(128|f>>>6&63),d(128|63&f)):(d(224|f>>>12),d(128|f>>>6&63),d(128|63&f))}return qo(u,0,c)})(Tt(e)),{mtime:0});return{contentType:Bo,body:s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength),estimatedSize:s.byteLength}}if(t===ye.Base64){var r=(function(o){return o&&btoa(encodeURIComponent(o).replace(/%([0-9A-F]{2})/g,((l,h)=>String.fromCharCode(parseInt(h,16)))))})(Tt(e)),n=(o=>"data="+encodeURIComponent(typeof o=="string"?o:Tt(o)))(r);return{contentType:"application/x-www-form-urlencoded",body:n,estimatedSize:new Blob([n]).size}}var a=Tt(e);return{contentType:"application/json",body:a,estimatedSize:new Blob([a]).size}}},Uo=i=>{var e,t,s=()=>i.transport==="sendBeacon"?{url:ds(i.url,{compression:ye.Base64}),encodedBody:Ds(y({},i,{compression:ye.Base64,Ys:void 0}))}:{url:Vo(i.url,"compression"),encodedBody:Ds(y({},i,{compression:void 0,Ys:void 0}))};try{e=Ds(i)}catch(r){if(rn(i.compression,qt(i.url,"compression")))return E.error("Failed to gzip request body, sending uncompressed payload",r),s();throw r}return e&&rn(i.compression,qt(i.url,"compression"))&&!((t=e.body)instanceof ArrayBuffer?Ys(new Uint8Array(t)):ArrayBuffer.isView(t)&&Ys(new Uint8Array(t.buffer,t.byteOffset,t.byteLength)))?(Li=!0,s()):{url:i.url,encodedBody:e}},zo=i=>{try{return Uo(i)}catch(e){return E.error(e),void(i.callback==null||i.callback({statusCode:0,error:e}))}},Uu=(function(){var i=Q((function*(e){var t=Tt(e.data),s=yield(function(n,a,o){return Qs.apply(this,arguments)})(t,Y.DEBUG,{rethrow:!0});if(!s)return e;var r=yield s.arrayBuffer();return y({},e,{Ys:{contentType:Bo,body:r,estimatedSize:r.byteLength}})}));return function(e){return i.apply(this,arguments)}})(),zu=/Failed to fetch|NetworkError|Load failed/i,Go=i=>i?.name==="TypeError"&&zu.test(i?.message||""),Wo=i=>{var e=zo(i);if(e){var t=e.url,s=e.encodedBody,r=s??{},n=r.contentType,a=r.body,o=r.estimatedSize,l=new Headers;U(i.headers,(function(v,f){l.append(f,v)})),n&&l.append("Content-Type",n);var h=null,u=!1;if(Zr){var c=new Zr;h={signal:c.signal,timeout:setTimeout((()=>{var v,f;u=!0,c.abort((v=i.timeout,(f=new Error("PostHog request timed out"+(v?" after "+v+"ms":""))).name="AbortError",f))}),i.timeout)}}var d=v=>{u&&v?.name==="AbortError"||Go(v)?E.warn(v):E.error(v),i.callback==null||i.callback({statusCode:0,error:v})};try{var p;Cr(t,y({method:i?.method||"GET",headers:l,keepalive:i.method==="POST"&&!i.Xs&&52428.8>(o||0),body:a,signal:(p=h)==null?void 0:p.signal},i.fetchOptions)).then((v=>v.text().then((f=>{var g={statusCode:v.status,text:f};if(v.status===200)try{g.json=JSON.parse(f)}catch(m){E.error(m)}i.callback==null||i.callback(g)})))).catch(d).finally((()=>h?clearTimeout(h.timeout):null))}catch(v){h&&clearTimeout(h.timeout),d(v)}}},Pr=i=>{try{var e,t=Uo(i),s=t.url,r=t.encodedBody,n=r??{},a=n.body,o=n.estimatedSize;if(!a)return;var l=a instanceof Blob?a:new Blob([a],{type:n.contentType});if(be.sendBeacon(s,l))return;var h=A(i.data)?i.data:(e=i.data)==null?void 0:e.batch;if(A(h)&&h.length>1&&(o??0)>16384){var u=Math.ceil(h.length/2),c=d=>A(i.data)?d:y({},i.data,{batch:d});return Pr(y({},i,{data:c(h.slice(0,u))})),void Pr(y({},i,{data:c(h.slice(u))}))}E.warn("Beacon of ~"+(o??0)+" bytes was rejected by the browser, falling back to fetch"),Wo(y({},i,{Xs:!0}))}catch(d){E.warn("Beacon send failed",d)}},Un=(i,e,t,s)=>{var r=s==="query"?e==="POST"?"sent_at":"_":void 0;return ds(t===ye.GZipJS?Vo(i,"compression"):i,y({},r?{[r]:Date.now().toString()}:{},t===ye.GZipJS?{}:{compression:t}))},Di=[];Cr&&Di.push({transport:"fetch",method:Wo}),Js&&Di.push({transport:"XHR",method(i){var e=zo(i);if(e){var t=new Js,s=e.encodedBody;t.open(i.method||"GET",e.url,!0);var r=s??{},n=r.contentType,a=r.body;U(i.headers,(function(o,l){t.setRequestHeader(l,o)})),n&&t.setRequestHeader("Content-Type",n),i.timeout&&(t.timeout=i.timeout),t.onreadystatechange=()=>{if(t.readyState===4){var o={statusCode:t.status,text:t.responseText};if(t.status===200)try{o.json=JSON.parse(t.responseText)}catch{}i.callback==null||i.callback(o)}},t.send(a)}}}),be!=null&&be.sendBeacon&&Di.push({transport:"sendBeacon",method:Pr});var Ir=3e3;class Gu{constructor(e,t){this.ta=!0,this.ea=[],this.ia=ze(t?.flush_interval_ms||Ir,250,5e3,E.createLogger("flush interval"),Ir),this.ra=e}enqueue(e){this.ea.push(e),this.na||this.sa()}unload(){this.aa();var e=this.ea.length>0?this.oa():{},t=Object.values(e);[...t.filter((s=>s.url.indexOf("/e")===0)),...t.filter((s=>s.url.indexOf("/e")!==0))].map((s=>{this.la(y({},s,{transport:"sendBeacon"}))}))}enable(){this.ta=!1,this.sa()}sa(){var e=this;this.ta||(this.na=setTimeout((()=>{if(this.aa(),this.ea.length>0){var t=this.oa(),s=function(){var n=t[r],a=new Date().getTime();n.data&&A(n.data)&&U(n.data,(o=>{o.offset=Math.abs(o.timestamp-a),delete o.timestamp})),e.la(n)};for(var r in t)s()}}),this.ia))}la(e){try{this.ra(e)}catch(t){E.error(t)}}aa(){clearTimeout(this.na),this.na=void 0}oa(){var e={};return U(this.ea,(t=>{var s,r=t,n=(r?r.batchKey:null)||r.url;w(e[n])&&(e[n]=y({},r,{data:[]})),(s=e[n].data)==null||s.push(r.data)})),this.ea=[],e}}var Wu=["retriesPerformedSoFar"];class Ju{constructor(e){this.ua=!1,this.ha=3e3,this.ea=[],this._instance=e,this.ea=[],this.da=!0,!w(_)&&"onLine"in _.navigator&&(this.da=_.navigator.onLine,this.va=()=>{this.da=!0,this.ca()},this.fa=()=>{this.da=!1},ee(_,"online",this.va),ee(_,"offline",this.fa))}get length(){return this.ea.length}retriableRequest(e){var t=e.retriesPerformedSoFar,s=_a(e,Wu);Je(t)&&(s.url=ds(s.url,{retry_count:t})),this._instance._send_request(y({},s,{callback:r=>{if(r.statusCode!==200&&(400>r.statusCode||r.statusCode>=500)){if((r.statusCode===0?3:10)>(t??0))return void this.bn(y({retriesPerformedSoFar:t},s));r.statusCode===0&&E.warn("Request failed before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped retrying after "+(t??0)+" retries.")}s.callback==null||s.callback(r)}}))}bn(e){var t=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=t+1;var s=(function(a){var o=3e3*Math.pow(2,a),l=o/2,h=Math.min(18e5,o),u=Math.random()-.5;return Math.ceil(h+u*(h-l))})(t),r=Date.now()+s;this.ea.push({retryAt:r,requestOptions:e});var n="Enqueued failed request for retry in "+s;navigator.onLine||(n+=" (Browser is offline)"),E.warn(n),this.ua||(this.ua=!0,this.pa())}pa(){if(this.ga&&clearTimeout(this.ga),this.ea.length===0)return this.ua=!1,void(this.ga=void 0);this.ga=setTimeout((()=>{this.da&&this.ea.length>0&&this.ca(),this.pa()}),this.ha)}ca(){var e=Date.now(),t=[],s=this.ea.filter((n=>e>n.retryAt||(t.push(n),!1)));if(this.ea=t,s.length>0)for(var r of s)this.retriableRequest(r.requestOptions)}unload(){for(var e of(this.ga&&(clearTimeout(this.ga),this.ga=void 0),this.ua=!1,w(_)||(this.va&&(_.removeEventListener("online",this.va),this.va=void 0),this.fa&&(_.removeEventListener("offline",this.fa),this.fa=void 0)),this.ea)){var t=e.requestOptions;try{this._instance._send_request(y({},t,{transport:"sendBeacon"}))}catch(s){E.error(s)}}this.ea=[]}}class Yu{constructor(e){this.ma=()=>{var t,s,r,n;this.ya||(this.ya={});var a=this.scrollElement(),o=this.scrollY(),l=a?Math.max(0,a.scrollHeight-a.clientHeight):0,h=o+(a?.clientHeight||0),u=a?.scrollHeight||0;this.ya.lastScrollY=Math.ceil(o),this.ya.maxScrollY=Math.max(o,(t=this.ya.maxScrollY)!==null&&t!==void 0?t:0),this.ya.maxScrollHeight=Math.max(l,(s=this.ya.maxScrollHeight)!==null&&s!==void 0?s:0),this.ya.lastContentY=h,this.ya.maxContentY=Math.max(h,(r=this.ya.maxContentY)!==null&&r!==void 0?r:0),this.ya.maxContentHeight=Math.max(u,(n=this.ya.maxContentHeight)!==null&&n!==void 0?n:0)},this._instance=e}get ba(){return this._instance.config.scroll_root_selector}getContext(){return this.ya}resetContext(){var e=this.ya;return setTimeout(this.ma,0),e}startMeasuringScrollPosition(){ee(_,"scroll",this.ma,{capture:!0}),ee(_,"scrollend",this.ma,{capture:!0}),ee(_,"resize",this.ma)}scrollElement(){if(!this.ba)return _?.document.documentElement;var e=A(this.ba)?this.ba:[this.ba];for(var t of e){var s=_?.document.querySelector(t);if(s)return s}}_a(e){var t=e==="y"?"scrollTop":"scrollLeft";if(this.ba){var s=this.scrollElement();return s&&s[t]||0}return _?e==="y"?_.scrollY||_.pageYOffset||_.document.documentElement.scrollTop||0:_.scrollX||_.pageXOffset||_.document.documentElement.scrollLeft||0:0}scrollY(){return this._a("y")}scrollX(){return this._a("x")}}var Qu=i=>Mo(i?.config.mask_personal_data_properties,i?.config.custom_personal_data_properties,i?.config.disable_capture_url_hashes);class zn{constructor(e,t,s,r){this.ot=n=>{var a=this.wa();if(!a||a.sessionId!==n){var o={sessionId:n,props:this.ka(this._instance)};this.Sa.register({[vr]:o})}},this._instance=e,this.xa=t,this.Sa=s,this.ka=r||Qu,this.xa.onSessionId(this.ot)}wa(){return this.Sa.props[vr]}getSetOnceProps(){var e,t=(e=this.wa())==null?void 0:e.props;return t?"r"in t?Ro(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(){var e={};return U(Br(this.getSetOnceProps()),((t,s)=>{s==="$current_url"&&(s="url"),e["$session_entry_"+Ks(s)]=t})),e}}class Jr{on(e,t){return this.Ca[e]||(this.Ca[e]=[]),this.Ca[e].push(t),()=>{this.Ca[e]=this.Ca[e].filter((s=>s!==t))}}emit(e,t){for(var s of this.Ca[e]||[])s(t);for(var r of this.Ca["*"]||[])r(e,t)}constructor(){this.Ca={}}}var St=K("[SessionId]"),Gn=864e5;class Wn{on(e,t){return this.Ta.on(e,t)}constructor(e,t,s){var r;if(this.Ma=null,this.Ea=null,this.Ia=[],this.Ra=void 0,this.Pa=!1,this.Ta=new Jr,this.Aa=(l,h)=>!(!Je(l)||!Je(h))&&Math.abs(l-h)>this.sessionTimeoutMs,!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(e.config.cookieless_mode===Ke)throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this.Oi=e.config,this.Sa=e.persistence,this.st=void 0,this._e=void 0,this._sessionStartTimestamp=null,this.Fa=void 0,this._sessionActivityTimestamp=null,this.Oa=t||Ve,this.La=s||Ve;var n=this.Oi.persistence_name||this.Oi.token;if(this._sessionTimeoutMs=1e3*ze(this.Oi.session_idle_timeout_seconds||1800,60,36e3,St.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.$a(),this.Da="ph_"+n+"_window_id",this.Na="ph_"+n+"_primary_window_exists",this.qa()){var a=J.Pr(this.Da),o=J.Pr(this.Na);a&&!o?this.st=a:J.Dr(this.Da),J.Or(this.Na,!0)}(r=this.Oi.bootstrap)!=null&&r.sessionID&&this.setBootstrapSessionId(this.Oi.bootstrap.sessionID),this.ja()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return w(this.Ia)&&(this.Ia=[]),this.Ia.push(e),this._e&&e(this._e,this.st),()=>{this.Ia=this.Ia.filter((t=>t!==e))}}qa(){return this.Oi.persistence!=="memory"&&!this.Sa.ws&&J.Lr()}Ba(e){e!==this.st&&(this.st=e,this.qa()&&J.Or(this.Da,e))}Ha(){return this.st?this.st:this.qa()?J.Pr(this.Da):null}za(e){var t=this.Ma;return!de(t)&&!de(e)&&5e3>Math.abs(e-t)}Ua(e,t,s){var r=t!==this._sessionActivityTimestamp,n=!(e!==this._e||s!==this._sessionStartTimestamp);this._sessionStartTimestamp=s,this._sessionActivityTimestamp=t,this._e=e,n&&!r||n&&this.za(t)||(this.Ma=t,this.Sa.register({[Ct]:[t,e,s]}))}Wa(){var e,t=(e=this.Oi)==null?void 0:e.persistence_save_debounce_ms;return Je(t)&&t>0}Va(){this.Wa()?this.Sa.refreshKey(Ct):(this.Sa.flush(),this.Sa.load())}Ga(){var e;if(!de(this._sessionActivityTimestamp)&&this._sessionActivityTimestamp!==this.Ma){this.Va();var t=this.Za();t[1]===this._e&&t[2]===this._sessionStartTimestamp&&(this.Ma=this._sessionActivityTimestamp,this.Sa.register({[Ct]:[this._sessionActivityTimestamp,(e=this._e)!==null&&e!==void 0?e:null,this._sessionStartTimestamp]}),this.Sa.flush())}}Qa(){var e=this.Za()[0],t=Je(e)?e:0,s=Je(this._sessionActivityTimestamp)?this._sessionActivityTimestamp:0;return Math.max(t,s)}Ja(e){return this.Va(),this.Aa(e,this.Qa())}Za(){var e=this.Sa.props[Ct];return A(e)&&e.length===2&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this.Ma=null,this.Fa=void 0,clearTimeout(this.Ka),this.Ka=void 0,this.Ua(null,null,null)}setBootstrapSessionId(e,t){t===void 0&&(t=!1);var s=(function(r,n){n===void 0&&(n=new Date().getTime());try{var a=(o=>{var l=o.replace(/-/g,"");if(l.length!==32)throw new Error("Not a valid UUID");if(l[12]!=="7")throw new Error("Not a UUIDv7");return parseInt(l.substring(0,12),16)})(r);return a>n+6e4?void St.error("Bootstrap sessionID cannot be in the future"):a}catch(o){return void St.error("Invalid sessionID in bootstrap",o)}})(e);return!w(s)&&(t?this.Fa={sessionId:e,sessionStartTimestamp:s}:this.Ua(e,new Date().getTime(),s),!0)}destroy(){this.Pa=!0,this.Ga(),clearTimeout(this.Ka),this.Ka=void 0,this.Ra&&_&&(_.removeEventListener(es,this.Ra,{capture:!1}),this.Ra=void 0),this.Ia=[]}ja(){this.Ra=()=>{this.Ga(),this.qa()&&J.Dr(this.Na)},ee(_,es,this.Ra,{capture:!1})}checkAndGetSessionAndWindowId(e,t,s){if(e===void 0&&(e=!1),t===void 0&&(t=null),s===void 0&&(s=!1),this.Oi.cookieless_mode===Ke)throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var r=t||new Date().getTime(),n=this._e;if(s)this.Ea=r;else if(de(this.Ea)||this.Ea>r||r-this.Ea>=1e3){var a,o;(a=(o=this.Sa).syncCookieProperties)==null||a.call(o),this.Ea=r}var l=this.Za(),h=l[1],u=l[2],c=!w(n)&&h!==n,d=this.Qa(),p=this.Ha(),v=this.Fa,f=!!v&&(v.sessionStartTimestamp>r+6e4||r-v.sessionStartTimestamp>Gn),g=v?f:Je(u)&&Math.abs(r-u)>Gn,m=!1,b=c,k=!h||!!v,P=h,x=!k&&!e&&this.Aa(r,d);if(x){(x=this.Ja(r))||St.info("cross-tab refresh kept the session alive",{sessionId:h});var C=this.Za();h=C[1],u=C[2]}if(k||x||g){b=!1;var N=v&&!f;h=N?v.sessionId:this.Oa(),p=this.La(),St.info("new session ID assigned",{sessionId:h,windowId:p,bootstrapped:!!N,changeReason:{noSessionId:k,activityTimeout:x,sessionPastMaximumLength:g}}),u=N?v.sessionStartTimestamp:r,this.Fa=void 0,m=!0}else p||(p=this.La(),m=!0),(b=b||h!==P)&&(St.info("adopted cross-tab session id",{sessionId:h,windowId:p}),m=!0);var I=Je(d)&&e&&!g?d:r,F=Je(u)?u:new Date().getTime();this.Ba(p),this.Ua(h,I,F),e||this.$a();var O={noSessionId:k,activityTimeout:x,sessionPastMaximumLength:g,crossTabAdoption:b};return m&&this.Ia.forEach((M=>M(h,p,O))),{sessionId:h,windowId:p,sessionStartTimestamp:F,changeReason:m?O:void 0,lastActivityTimestamp:d}}$a(){this.Pa||(clearTimeout(this.Ka),this.Ka=setTimeout((()=>{if(!this.Pa)if(this.Ja(new Date().getTime())){var e=this._e;this.resetSessionId(),this.Ta.emit("forcedIdleReset",{idleSessionId:e})}else this.$a()}),1.1*this.sessionTimeoutMs))}}var Jo=function(i,e){if(!i)return!1;var t=i.userAgent;if(t&&an(t,e))return!0;try{var s=i?.userAgentData;if(s!=null&&s.brands&&s.brands.some((r=>an(r?.brand,e))))return!0}catch{}return!!i.webdriver};function Yo(){return(Yo=Q((function*(){var i=be?.userAgentData;if(i!=null&&i.getHighEntropyValues)try{var e=yield i.getHighEntropyValues(["model"]),t=e?.model;return q(t)&&t.length>0?t:void 0}catch(s){return void E.info("Unable to resolve $device_model from userAgentData.getHighEntropyValues",s)}}))).apply(this,arguments)}var os=function(i,e){if(!(function(t){try{new RegExp(t)}catch{return!1}return!0})(e))return!1;try{return new RegExp(e).test(i)}catch{return!1}};function Ns(i,e,t){return Tt({distinct_id:i,userPropertiesToSet:e,userPropertiesToSetOnce:t})}var Qo={exact:(i,e)=>e.some((t=>i.some((s=>t===s)))),is_not:(i,e)=>e.every((t=>i.every((s=>t!==s)))),regex:(i,e)=>e.some((t=>i.some((s=>os(t,s))))),not_regex:(i,e)=>e.every((t=>i.every((s=>!os(t,s))))),icontains:(i,e)=>e.map(Oi).some((t=>i.map(Oi).some((s=>t.includes(s))))),not_icontains:(i,e)=>e.map(Oi).every((t=>i.map(Oi).every((s=>!t.includes(s))))),gt:(i,e)=>e.some((t=>{var s=parseFloat(t);return!isNaN(s)&&i.some((r=>s>parseFloat(r)))})),lt:(i,e)=>e.some((t=>{var s=parseFloat(t);return!isNaN(s)&&i.some((r=>s<parseFloat(r)))}))},Oi=i=>i.toLowerCase();function Zo(i,e){return!i||Object.entries(i).every((t=>{var s=t[1],r=e?.[t[0]];if(w(r)||de(r))return!1;var n=[String(r)],a=Qo[s.operator];return!!a&&a(s.values,n)}))}var Or="custom",Jn="i.posthog.com",Zu=/^\/static\//,Ku=["/s/","/e/","/i/"];class Xu{constructor(e){this.Ya={},this.instance=e}get apiHost(){var e=this.instance.config.api_host.trim().replace(/\/$/,"");return e==="https://app.posthog.com"?"https://us.i.posthog.com":e}get flagsApiHost(){var e=this.instance.config.flags_api_host;return e?e.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var e,t=(e=this.instance.config.ui_host)==null?void 0:e.replace(/\/$/,"");return t||(t=this.apiHost.replace("."+Jn,".posthog.com")),t==="https://app.posthog.com"?"https://us.posthog.com":t}get region(){return this.Ya[this.apiHost]||(this.Ya[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":Or),this.Ya[this.apiHost]}Xa(e){if(Zu.test(e)){var t=this.instance.config.asset_host;if(typeof t=="string")return t.trim().replace(/\/$/,"")||void 0}}eo(e){var t=Ht(e);return t?t.protocol+"//"+t.host+t.pathname:void 0}io(e,t,s){if(e==="ui")return s;var r=s,n=this.instance.config.rewriteRequestPath;if(n){var a,o=((a=Ht(s))==null?void 0:a.href)||s;r=n(new URL(o)).toString()}if(n&&e==="api"&&Ku.some((d=>t.indexOf(d)===0))){var l=this.eo(r);if(l){var h,u=this.apiHost,c=this.ro;((h=c)==null?void 0:h.apiHost)===u&&c.rewriteRequestPath===n||(c={apiHost:u,rewriteRequestPath:n,urls:new Set},this.ro=c),c.urls.add(l)}}return r}isIngestionEndpoint(e){var t=this.ro,s=this.eo(e);return t?.apiHost===this.apiHost&&t.rewriteRequestPath===this.instance.config.rewriteRequestPath&&!!s&&t.urls.has(s)}endpointFor(e,t){if(t===void 0&&(t=""),t&&(t=t[0]==="/"?t:"/"+t),e==="ui")return this.io(e,t,this.uiHost+t);if(e==="flags")return this.io(e,t,this.flagsApiHost+t);if(e==="assets"){var s=this.Xa(t);if(s)return this.io(e,t,""+s+t)}if(this.region===Or)return this.io(e,t,this.apiHost+t);var r=Jn+t;switch(e){case"assets":return this.io(e,t,"https://"+this.region+"-assets."+r);case"api":return this.io(e,t,"https://"+this.region+"."+r)}}}function Ko(i){var e;return!((e=i.conditions)==null||(e=e.events)==null||(e=e.values)==null||!e.length)}var z=K("[Surveys]"),Xo="seenSurvey_",el=i=>{try{var e=(t=>((s,r)=>""+Xo+(function(n){return n.current_iteration&&n.current_iteration>0?n.id+"_"+n.current_iteration:n.id})(r))(0,t))(i);if(localStorage.getItem(e))return;localStorage.setItem(e,"true")}catch(t){z.error("Failed to persist survey seen state",t)}},eh=[Ms.Popover,Ms.Widget,Ms.API],th={ignoreConditions:!1,ignoreDelay:!1,displayType:xr.Popover},ih=K("[PostHog ExternalIntegrations]"),sh={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};class rh{constructor(e){this._instance=e}Jn(e,t){var s;(s=$.__PosthogExtensions__)==null||s.loadExternalDependency==null||s.loadExternalDependency(this._instance,e,(r=>{if(r)return ih.error("failed to load script",r);t()}))}startIfEnabledOrStop(){var e=this,t=function(){var n,a,o,l=s[0],h=s[1];!h||(n=$.__PosthogExtensions__)!=null&&(n=n.integrations)!=null&&n[l]||e.Jn(sh[l],(()=>{var u;(u=$.__PosthogExtensions__)==null||(u=u.integrations)==null||(u=u[l])==null||u.start(e._instance)})),!h&&(a=$.__PosthogExtensions__)!=null&&(a=a.integrations)!=null&&a[l]&&((o=$.__PosthogExtensions__)==null||(o=o.integrations)==null||(o=o[l])==null||o.stop())};for(var s of Object.entries((r=this._instance.config.integrations)!==null&&r!==void 0?r:{})){var r;t()}}}class nh{constructor(e,t){this.I=e,this.no=t,this.so=new Map,this.ao=!1}add(e){var t=this;return Q((function*(){if(t.ao)throw new Error("Cannot add an extension to a disposed ExtensionRuntime");if(t.so.has(e.name))throw new Error('Browser extension "'+e.name+'" is already registered');t.so.set(e.name,e);try{var s=e.setup(t.no);s&&(yield s)}catch(n){var r=t.so.get(e.name)===e;r&&t.so.delete(e.name),t.I.error('Failed to set up browser extension "'+e.name+'"',n),r&&t.oo(e)}}))()}dispose(){if(!this.ao){this.ao=!0;var e=Array.from(this.so.values()).reverse();for(var t of(this.so.clear(),e))this.oo(t)}}oo(e){try{var t=e.dispose==null?void 0:e.dispose();t&&me(t.then)&&t.then(void 0,(s=>{this.I.error('Failed to dispose browser extension "'+e.name+'"',s)}))}catch(s){this.I.error('Failed to dispose browser extension "'+e.name+'"',s)}}}class ah{constructor(e){this._instance=e}initialize(){}get(e){var t=this._instance.persistence;if(typeof e=="string")return t?.get_property(e);var s={};for(var r of e){var n=t?.get_property(r);w(n)||(s[r]=n)}return s}set(e,t){var s;(s=this._instance.persistence)==null||s.register(typeof e=="string"?{[e]:t}:e)}remove(e){var t;(t=this._instance.persistence)==null||t.unregister(e)}}var Yn="extensionsRemoteConfig";class oh{constructor(e){this.ao=!1,this.instance=e,this.I=E,this.lo=e.uo,this.kv=new ah(e),this.onEvent=t=>Ii(this.instance.on("eventCaptured",(s=>{try{t({event:s.event,properties:s.properties})}catch(r){this.I.error("Browser extension event listener failed",r)}}))),this.onRemoteConfig=t=>{if(this.ao)return Ii((()=>{}));var s=n=>{try{t(n)}catch(a){this.I.error("Browser extension remote config listener failed",a)}},r=this.instance.ho.on(Yn,s);return this.lo&&s(this.lo),Ii(r)},this.do=new nh(E.createLogger("[BrowserExtensions]"),this)}get logger(){return this.I}get distinctId(){return this.instance.get_distinct_id()}get anonymousId(){var e;return(e=this.instance.get_property(di))!==null&&e!==void 0?e:this.distinctId}get deviceId(){var e=this.instance.get_property(di);return typeof e=="string"?e:void 0}get library(){return{name:Y.LIB_NAME,version:Y.LIB_VERSION}}get initialPersonProperties(){var e,t;return(e=(t=this.instance.persistence)==null?void 0:t.get_initial_props())!==null&&e!==void 0?e:{}}get groups(){return this.instance.getGroups()}get session(){try{var e,t,s,r,n=(e=this.instance.sessionManager)==null?void 0:e.checkAndGetSessionAndWindowId(!0);return{sessionId:(t=n?.sessionId)!==null&&t!==void 0?t:"",windowId:(s=n?.windowId)!==null&&s!==void 0?s:"",sessionStartTimestamp:(r=n?.sessionStartTimestamp)!==null&&r!==void 0?r:0}}catch{return{sessionId:"",windowId:"",sessionStartTimestamp:0}}}get projectToken(){return this.instance.config.token}add(e){return this.do.add(e)}capture(e,t,s){var r=this;return Q((function*(){s?r.instance.capture(e,t,{timestamp:s.timestamp,uuid:s.uuid,$set:s.set,$set_once:s.setOnce}):r.instance.capture(e,t)}))()}registerDynamicEventProperties(e){return Ii(this.instance.vo(e))}handleRemoteConfig(e){this.ao||(this.lo=e,this.instance.ho.emit(Yn,e))}sendRequest(e,t){var s=this;return Q((function*(){var r;t===void 0&&(t={});var n=s.instance.requestRouter.endpointFor((r=t.target)!==null&&r!==void 0?r:"api",e),a={method:t.method,url:t.query?ds(n,t.query):n,data:t.body,headers:t.headers,timeout:t.timeoutMs,fireCallbackOnDrop:!0,transport:t.transport,compression:t.compression,timestampMode:t.sentAt};return t.transport==="sendBeacon"?(s.instance._send_request(a),{statusCode:202}):new Promise((o=>{a.callback=o,s.instance._send_request(a)}))}))()}dispose(){this.ao||(this.ao=!0,this.do.dispose())}}var ui={},js=0,ls=()=>{},Qn='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',Kt="Surveys module not available",Zn="sanitize_properties is deprecated. Use before_send instead",tl="Invalid value for property_denylist config: ",lh=["token","distinct_id",oo],Ot="posthog",il=!Vu&&Ee?.indexOf("MSIE")===-1&&Ee?.indexOf("Mozilla")===-1,Hs=i=>{var e;return y({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,asset_host:null,token:"",autocapture:!0,cross_subdomain_cookie:lu(S?.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:ls,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:i??"unset",__preview_deferred_init_extensions:!1,__preview_external_dependency_versioned_paths:!1,__preview_cookie_wins_on_conflict:!1,debug:X&&q(X?.search)&&X.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,disable_external_dependency_loading:!1,strict_script_versioning:"fallback",enable_recording_console_log:void 0,secure_cookie:(_==null||(e=_.location)==null?void 0:e.protocol)==="https:",ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_flags:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_only_evaluate_survey_feature_flags:!1,advanced_feature_flags_dedup_per_session:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,surveys_request_timeout_ms:1e4,on_request_error(t){E.error("Bad HTTP status: "+t.statusCode+" "+t.text)},get_device_id:t=>t,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:mr,before_send:void 0,get_current_url:void 0,request_queue_config:{flush_interval_ms:Ir},error_tracking:{},_onCapture:ls},(t=>({rageclick:t&&t>="2026-05-30"?{content_ignorelist:bu,ignore_text_selection:!0}:!t||"2025-11-30">t||{content_ignorelist:!0},capture_pageview:!t||"2025-05-24">t||"history_change",session_recording:t&&t>="2026-06-25"?{strictMinimumDuration:!0,canvasCapture:{resolutionScale:.6},streamNetworkBody:!0}:t&&t>="2026-05-30"?{strictMinimumDuration:!0,canvasCapture:{resolutionScale:.6}}:t&&t>="2025-11-30"?{strictMinimumDuration:!0}:{},external_scripts_inject_target:t&&t>="2026-01-30"?"head":"body",internal_or_test_user_hostname:t&&t>="2026-01-30"?/^(localhost|127\.0\.0\.1)$/:void 0,persistence_save_debounce_ms:t&&t>="2026-05-30"?250:0,split_storage:!(!t||"2026-05-30">t),detect_google_search_app:!(!t||"2026-05-30">t),disable_capture_url_hashes:!(!t||"2026-06-25">t),cookieWinsOnConflict:!(!t||t==="unset"||"2026-08-29">t)}))(i))},uh=[["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"]],Kn=i=>{var e={};for(var t of uh){var s=t[0],r=t[1];w(i[s])||(e[r]=i[s])}var n=W({},e,i),a=i.__preview_external_dependency_versioned_paths;return w(a)||(w(i.strict_script_versioning)&&(n.strict_script_versioning=!!a),q(a)&&w(i.asset_host)&&(n.asset_host=a)),A(i.property_blacklist)&&(w(i.property_denylist)?n.property_denylist=i.property_blacklist:A(i.property_denylist)?n.property_denylist=[...i.property_blacklist,...i.property_denylist]:E.error(tl+i.property_denylist)),n};class hh{constructor(){this.__forceAllowLocalhost=!1}get co(){return this.__forceAllowLocalhost}set co(e){E.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}}class Ie{fo(e,t){if(e){var s=this.so.indexOf(e);s!==-1&&this.so.splice(s,1)}return this.so.push(t),t.initialize==null||t.initialize(),t}po(){return this.config.cookieless_mode===Ke||this.config.cookieless_mode===vt&&this.consent.isRejected()}mo(){if(!this.po()&&this.get_distinct_id()===kt){var e=this.persistence;if(e){this.yo()||e.load(!0);var t=this.get_distinct_id();if(!t||t===kt){var s=this.config.get_device_id(Ve());this.register({distinct_id:s,$device_id:s}),e.set_property(j,ae)}this.bo()}}}get decideEndpointWasHit(){var e,t;return(e=(t=this.featureFlags)==null?void 0:t.hasLoadedFlags)!==null&&e!==void 0&&e}get flagsEndpointWasHit(){var e,t;return(e=(t=this.featureFlags)==null?void 0:t.hasLoadedFlags)!==null&&e!==void 0&&e}constructor(){var e;this.webPerformance=new hh,this._o=!1,this.version=Y.LIB_VERSION,this.wo=new Set,this.ko="",this.ho=new Jr,this.so=[],this.So=[],this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=Hs(),this.SentryIntegration=Ou,this.sentryIntegration=s=>(function(r,n){var a=Po(r,n);return{name:So,processEvent:o=>a(o)}})(this,s),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.xo=!1,this.Co=null,this.To=null,this.Mo=null,this.scrollManager=new Yu(this),this.pageViewManager=new An(this),this.rateLimiter=new Du(this),this.requestRouter=new Xu(this),this.consent=new fu(this),this.externalIntegrations=new rh(this);var t=(e=Ie.__defaultExtensionClasses)!==null&&e!==void 0?e:{};this.featureFlags=t.featureFlags&&new t.featureFlags(this),this.toolbar=t.toolbar&&new t.toolbar(this),this.surveys=t.surveys&&new t.surveys(this),this.conversations=t.conversations&&new t.conversations(this),this.logs=t.logs&&new t.logs(this),this.metrics=t.metrics&&new t.metrics(this),this.experiments=t.experiments&&new t.experiments(this),this.exceptions=t.exceptions&&new t.exceptions(this),this.people={set:(s,r,n)=>{var a=q(s)?{[s]:r}:s;this.setPersonProperties(a),n?.({})},set_once:(s,r,n)=>{var a=q(s)?{[s]:r}:s;this.setPersonProperties(void 0,a),n?.({})}},this.on("eventCaptured",(s=>E.info('send "'+s?.event+'"',s)))}init(e,t,s){if(s&&s!==Ot){var r,n=(r=ui[s])!==null&&r!==void 0?r:new Ie;return n._init(e,t,s),ui[s]=n,ui[Ot][s]=n,n}return this._init(e,t,s)}_init(e,t,s){var r,n;t===void 0&&(t={});var a,o=q(e)?e.trim():"";if(!o)return E.critical("PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()"),this;if(this.__loaded)return o!==((a=this.config)==null?void 0:a.token)?console.warn("[PostHog.js]","You have already initialized PostHog with a different project token! Re-initializing is a no-op, so events will keep going to the project this instance was initialized with. To capture into a second project, load PostHog once, then initialize a named instance after the SDK has loaded, e.g. posthog.init('"+o+"', { ... }, 'project2')"):console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config=Hs(t.defaults),t.debug=this.Eo(t.debug),this.Io=t,this.Ro=[],t.person_profiles?this.To=t.person_profiles:t.process_person&&(this.To=t.process_person);var l=Hs(t.defaults),h=Kn(t),u=W({},l,h,{name:s,token:o});Z(l.rageclick)&&Z(h.rageclick)&&(u.rageclick=W({},l.rageclick,h.rageclick)),Z(l.session_recording)&&Z(h.session_recording)&&(u.session_recording=W({},l.session_recording,h.session_recording)),this.set_config(u),this.config.on_xhr_error&&E.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=t.disable_compression?void 0:ye.GZipJS;var c=this.yo();if(this.persistence=new $s(this.config,c),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new $s(y({},this.config,{persistence:"sessionStorage"}),c,!1),this.ko="ph_"+(this.config.persistence_name||this.config.token)+"_session_registered_properties",this.config.persistence!=="memory"&&!c&&J.Lr()){var d=J.Pr(this.ko);A(d)&&d.forEach((C=>{q(C)&&this.wo.add(C)}))}else J.Dr(this.ko);var p=y({},this.persistence.props),v=y({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.Po=new Gu((C=>this.Ao(C)),this.config.request_queue_config),this.Fo=new Ju(this),this.__request_queue=[];var f=this.po();if(f||(this.sessionManager=new Wn(this),this.sessionPropsManager=new zn(this,this.sessionManager,this.persistence),this.sessionManager.onSessionId(((C,N,I)=>{(I!=null&&I.activityTimeout||I!=null&&I.sessionPastMaximumLength||I!=null&&I.crossTabAdoption)&&this.Oo()}))),this.Lo(),this.config.__preview_deferred_init_extensions?(E.info("Deferring extension initialization to improve startup performance"),setTimeout((()=>{this.$o(f)}),0)):(E.info("Initializing extensions synchronously"),this.$o(f)),Y.DEBUG=Y.DEBUG||this.config.debug,Y.DEBUG&&E.info("Starting in debug mode",{this:this,config:t,thisC:y({},this.config),p,s:v}),!this.config.identity_distinct_id||(r=t.bootstrap)!=null&&r.distinctID||(t.bootstrap=y({},t.bootstrap,{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0})),((n=t.bootstrap)==null?void 0:n.distinctID)!==void 0){var g=t.bootstrap.distinctID,m=this.get_distinct_id(),b=this.persistence.get_property(j);if(t.bootstrap.isIdentifiedID&&m!=null&&m!==g&&b===ae)this.identify(g);else if(t.bootstrap.isIdentifiedID&&m!=null&&m!==g&&b===ve)E.warn("Bootstrap distinctID differs from an already-identified user. The existing identity is preserved. Call reset() before reinitializing if you intend to switch users.");else{var k=this.config.get_device_id(Ve()),P=t.bootstrap.isIdentifiedID?k:g;this.persistence.set_property(j,t.bootstrap.isIdentifiedID?ve:ae),this.register({distinct_id:g,$device_id:P})}}if(f)this.register_once({distinct_id:kt,$device_id:null},"");else if(!this.get_distinct_id()){var x=this.config.get_device_id(Ve());this.register_once({distinct_id:x,$device_id:x},""),this.persistence.set_property(j,ae)}return ee(_,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),t.segment?(function(C,N){var I=C.config.segment;if(!I)return N();(function(F,O){var M=F.config.segment;if(!M)return O();var T=H=>{var V=()=>H.anonymousId()||Ve();F.config.get_device_id=V,H.id()&&(F.register({distinct_id:H.id(),$device_id:V()}),F.persistence.set_property(j,ve)),O()},R=M.user();"then"in R&&me(R.then)?R.then(T):T(R)})(C,(()=>{I.register((F=>{typeof Promise<"u"&&Promise.resolve||Cs.warn("This browser does not have Promise support, and can not use the segment integration");var O=(M,T)=>{if(!T)return M;M.event.userId||M.event.anonymousId===F.get_distinct_id()||(Cs.info("No userId set, resetting PostHog"),F.reset()),M.event.userId&&M.event.userId!==F.get_distinct_id()&&(Cs.info("UserId set, identifying with PostHog"),F.identify(M.event.userId));var R=F.calculateEventProperties(T,M.event.properties);return M.event.properties=Object.assign({},R,M.event.properties),M};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:()=>!0,load:()=>Promise.resolve(),track:M=>O(M,M.event.event),page:M=>O(M,It),identify:M=>O(M,ks),screen:M=>O(M,"$screen")}})(C)).then((()=>{N()}))}))})(this,(()=>this.Do())):this.Do(),me(this.config._onCapture)&&this.config._onCapture!==ls&&(E.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",(C=>this.config._onCapture(C.event,C)))),this.config.ip&&E.warn('The `ip` config option has NO EFFECT AT ALL and has been deprecated. Use a custom transformation or "Discard IP data" project setting instead. See https://posthog.com/tutorials/web-redact-properties#hiding-customer-ip-address for more information.'),this.config.disableDeviceModel||(function(){return Yo.apply(this,arguments)})().then((C=>{C&&this.register({[ws]:C})})).catch(ls),this}Lo(){var e,t,s,r,n,a,o=(e=(t=this.config.__extensionClasses)==null?void 0:t.featureFlags)!==null&&e!==void 0?e:(s=Ie.__defaultExtensionClasses)==null?void 0:s.featureFlags;o&&(this.featureFlags&&this.featureFlags instanceof o||((r=this.No)==null||r.call(this),this.No=void 0,this.featureFlags=new o(this)),me(this.featureFlags.onReloading)&&me(this.featureFlags.setup)?this.No||(this.No=this.featureFlags.onReloading((()=>{this.ho.emit("featureFlagsReloading",!0)})),this.qo().add(this.featureFlags)):(n=(a=this.featureFlags).initialize)==null||n.call(a))}$o(e){var t,s,r,n,a,o,l,h=performance.now(),u=y({},Ie.__defaultExtensionClasses,this.config.__extensionClasses),c=[];u.exceptions&&this.so.push(this.exceptions=(t=this.exceptions)!==null&&t!==void 0?t:new u.exceptions(this)),u.historyAutocapture&&this.so.push(this.historyAutocapture=new u.historyAutocapture(this)),u.tracingHeaders&&this.so.push(this.tracingHeaders=new u.tracingHeaders(this)),u.siteApps&&this.so.push(this.siteApps=new u.siteApps(this)),u.sessionRecording&&!e&&this.so.push(this.sessionRecording=new u.sessionRecording(this)),this.config.disable_scroll_properties||c.push((()=>{this.scrollManager.startMeasuringScrollPosition()})),u.autocapture&&this.so.push(this.autocapture=new u.autocapture(this)),u.surveys&&this.so.push(this.surveys=(s=this.surveys)!==null&&s!==void 0?s:new u.surveys(this)),u.logs&&this.so.push(this.logs=(r=this.logs)!==null&&r!==void 0?r:new u.logs(this)),u.metrics&&this.so.push(this.metrics=(n=this.metrics)!==null&&n!==void 0?n:new u.metrics(this)),u.conversations&&this.so.push(this.conversations=(a=this.conversations)!==null&&a!==void 0?a:new u.conversations(this)),u.productTours&&this.so.push(this.productTours=new u.productTours(this)),u.heatmaps&&this.so.push(this.heatmaps=new u.heatmaps(this)),u.webVitalsAutocapture&&this.so.push(this.webVitalsAutocapture=new u.webVitalsAutocapture(this)),u.exceptionObserver&&this.so.push(this.exceptionObserver=new u.exceptionObserver(this)),u.deadClicksAutocapture&&this.so.push(this.deadClicksAutocapture=new u.deadClicksAutocapture(this,Iu)),u.toolbar&&this.so.push(this.toolbar=(o=this.toolbar)!==null&&o!==void 0?o:new u.toolbar(this)),u.experiments&&this.so.push(this.experiments=(l=this.experiments)!==null&&l!==void 0?l:new u.experiments(this)),this.so.forEach((d=>{d.initialize&&c.push((()=>{d.initialize==null||d.initialize()}))})),c.push((()=>{if(this.jo){var d=this.jo;this.jo=void 0,this.so.forEach((p=>p.onRemoteConfig==null?void 0:p.onRemoteConfig(d)))}})),this.Bo(c,h)}Bo(e,t){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-t>=30&&e.length>0)return void setTimeout((()=>{this.Bo(e,t)}),0);var s=e.shift();if(s)try{s()}catch(n){E.error("Error initializing extension:",n)}}var r=Math.round(performance.now()-t);this.register_for_session({[lo]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[uo]:r}),this.config.__preview_deferred_init_extensions&&E.info("PostHog extensions initialized ("+r+"ms)")}Zs(e){var t;if(!S||!S.body)return E.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout((()=>{this.Zs(e)}),500);if(this.config.__preview_deferred_init_extensions&&(this.jo=e),this.uo=e,this.compression=void 0,e.ok){var s,r=e.config;r.supportedCompression&&!this.config.disable_compression&&(this.compression=L(r.supportedCompression,ye.GZipJS)?ye.GZipJS:L(r.supportedCompression,ye.Base64)?ye.Base64:void 0),(s=r.analytics)!=null&&s.endpoint&&(this.analyticsDefaultEndpoint=r.analytics.endpoint)}this.set_config({person_profiles:this.To?this.To:mr}),(t=this.Ho)==null||t.handleRemoteConfig(e),this.so.forEach((n=>n.onRemoteConfig==null?void 0:n.onRemoteConfig(e)))}Do(){try{this.config.loaded(this)}catch(s){E.critical("`loaded` function failed",s)}if(this.zo(),this.config.internal_or_test_user_hostname&&X!=null&&X.hostname){var e=X.hostname,t=this.config.internal_or_test_user_hostname;(typeof t=="string"?e===t:t.test(e))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout((()=>{(this.consent.isOptedIn()||this.po())&&this.Uo()}),1),this.Wo=new Lo(this),this.Wo.load()}zo(){var e;this.is_capturing()&&this.config.request_batching&&((e=this.Po)==null||e.enable())}_dom_loaded(){this.is_capturing()&&xi(this.__request_queue,(e=>this.Ao(e))),this.__request_queue=[],this.zo()}_handle_unload(){var e,t,s,r,n;(e=this.surveys)==null||e.handlePageUnload==null||e.handlePageUnload(),(t=this.metrics)==null||t.flush("sendBeacon"),this.config.request_batching?(this.Vo()&&this.capture(xs),(s=this.logs)==null||s.flushLogs("sendBeacon"),(r=this.Po)==null||r.unload(),(n=this.Fo)==null||n.unload()):this.Vo()&&this.capture(xs,null,{transport:"sendBeacon"})}_send_request(e){this.__loaded?il?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)?e.fireCallbackOnDrop&&(e.callback==null||e.callback({statusCode:429})):(e.transport=e.transport||this.config.api_transport,e.headers=y({},this.config.request_headers,e.headers),e.compression=e.compression==="best-available"?this.compression:e.compression,(w(this.config.disable_beacon)?this.config.__preview_disable_beacon:this.config.disable_beacon)&&(e.disableTransport=["sendBeacon"]),e.fetchOptions=e.fetchOptions||this.config.fetch_options,(t=>{var s,r,n,a=y({},t);a.timeout=a.timeout||6e4;var o,l,h,u,c,d=(s=a.transport)!==null&&s!==void 0?s:"fetch";d==="sendBeacon"&&w(a.compression)&&a.data&&(a.compression=ye.Base64),a.method==="POST"&&a.data&&(a.timestampMode==="capture-body"?a.data={api_key:(l=(c=(u=(A(o=a.data)?o:[o]).map((g=>y({},g,g.timestamp instanceof Date&&!isNaN(g.timestamp.getTime())?{timestamp:g.timestamp.toISOString()}:{}))))[0])==null||(h=c.properties)==null?void 0:h.token)!==null&&l!==void 0?l:c?.token,batch:u,sent_at:new Date().toISOString()}:a.timestampMode==="body"&&(a.data=(function(g,m){return m===void 0&&(m=new Date().toISOString()),A(g)?g.map((b=>y({},b,{sent_at:m}))):y({},g,{sent_at:m})})(a.data))),a.url=Un(a.url,a.method,a.compression,a.timestampMode);var p=Di.filter((g=>!a.disableTransport||!g.transport||!a.disableTransport.includes(g.transport))),v=(r=(n=(function(g,m){for(var b=0;g.length>b;b++)if(g[b].transport===d)return g[b]})(p))==null?void 0:n.method)!==null&&r!==void 0?r:p[0].method;if(!v)throw new Error("No available transport method");var f=g=>{try{v(g)}catch(m){Go(m)?E.warn(m):E.error(m),a.callback==null||a.callback({statusCode:0,error:m})}};d!=="sendBeacon"&&a.data&&a.compression===ye.GZipJS&&rl&&typeof Promise<"u"&&!Li?Uu(a).then((g=>{f(g)})).catch((g=>{if(nn(g))return Li=!0,void f(y({},a,{compression:void 0,url:Un(t.url,t.method,void 0,t.timestampMode)}));(m=>{if(!m||typeof m!="object")return!1;var b="name"in m?String(m.name):"";return nn(m)||b===ma})(g)&&(Li=!0),f(a)})):v(a)})(y({},e,{callback:t=>{var s,r;this.rateLimiter.checkForLimiting(t),400>t.statusCode||(s=(r=this.config).on_request_error)==null||s.call(r,t),e.callback==null||e.callback(t)}}))):e.fireCallbackOnDrop&&(e.callback==null||e.callback({statusCode:0}))}Ao(e){this.Fo?this.Fo.retriableRequest(e):this._send_request(e)}_execute_array(e){js++;try{var t,s=[],r=[],n=[];xi(e,(o=>{if(o)if(A(t=o[0]))n.push(o);else if(me(o))try{o.call(this)}catch(l){E.error("Error executing queued PostHog call",o,l)}else A(o)&&t==="alias"?s.push(o):A(o)&&t.indexOf("capture")!==-1&&me(this[t])?n.push(o):r.push(o)}));var a=function(o,l){xi(o,(function(h){try{if(A(h[0])){var u=l;U(h,(function(c){u=u[c[0]].apply(u,c.slice(1))}))}else l[h[0]].apply(l,h.slice(1))}catch(c){E.error("Error executing queued PostHog call",h,c)}}))};a(s,this),a(r,this),a(n,this)}finally{js--}}push(e){if(js>0&&A(e)&&q(e[0])){var t=Ie.prototype[e[0]];me(t)&&t.apply(this,e.slice(1))}else this._execute_array([e])}capture(e,t,s){var r,n,a,o,l;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.Po){if(this.is_capturing())if(!w(e)&&q(e)){this.mo();var h=!this.config.opt_out_useragent_filter&&this._is_bot();if(!h||this.config.__preview_capture_bot_pageviews){var u=s!=null&&s.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(u==null||!u.isRateLimited){t!=null&&t.$current_url&&!q(t?.$current_url)&&(E.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),t==null||delete t.$current_url),e!=="$exception"||s!=null&&s.Go||E.warn("Using `posthog.capture('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureException(error)` instead, which attaches required metadata automatically."),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&this.sessionPersistence.update_campaign_params(),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();var c=new Date,d=s?.timestamp||c,p=hn(s?.uuid,Ve),v={uuid:p,event:e,properties:this.calculateEventProperties(e,t||{},d,p)};e===It&&this.config.__preview_capture_bot_pageviews&&h&&(v.event="$bot_pageview",v.properties.$browser_type="bot"),u&&(v.properties.$lib_rate_limit_remaining_tokens=u.remainingTokens);var f=e==="$feature_flag_called"&&v.properties.$feature_flag_has_experiment===!1&&this.get_property(Yi)===!0;s?.$set&&!f&&(v.$set=s?.$set);var g=s?.$unset;g&&(v.$unset=g);var m,b,k,P=f?void 0:this.Zo(s?.$set_once,e!==mn,e===ks);if(P&&(v.$set_once=P),s!=null&&s._noTruncate||(n=this.config.properties_string_max_length,a=v,o=T=>q(T)?T.slice(0,n):T,l=new Set,v=(function T(R,H){if(R!==Object(R))return o?o(R):R;if(!l.has(R)){var V;if(l.add(R),A(R))V=[],xi(R,(ie=>{V.push(T(ie))}));else{var B={};U(R,((ie,ue)=>{l.has(ie)||(B[ue]=T(ie))})),V=B}return V}})(a)),v.timestamp=d,w(s?.timestamp)||(v.properties.$event_time_override_provided=!0,v.properties.$event_time_override_system_time=c),f&&(v.properties=(function(T,R){R===void 0&&(R=[]);var H={},V=B=>{T[B]!==void 0&&(H[B]=T[B])};return nl.forEach(V),R.forEach(V),H})(v.properties,lh)),e===Xe.DISMISSED||e===Xe.SENT){var x=t?.[Rs.SURVEY_ID],C=t?.[Rs.SURVEY_ITERATION];el({id:x,current_iteration:C}),v.$set=y({},v.$set,{[(m={id:x,current_iteration:C},b=e===Xe.SENT?"responded":"dismissed",k="$survey_"+b+"/"+m.id,m.current_iteration&&m.current_iteration>0&&(k="$survey_"+b+"/"+m.id+"/"+m.current_iteration),k)]:!0})}else e===Xe.SHOWN&&(v.$set=y({},v.$set,{[Rs.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));if(e===Lu.SHOWN){var N=t?.[Nn.TOUR_TYPE];N&&(v.$set=y({},v.$set,{[Nn.TOUR_LAST_SEEN_DATE+"/"+N]:new Date().toISOString()}))}var I=y({},v.properties.$set,v.$set);if(De(I)||this.setPersonPropertiesForFlags(I),!D(this.config.before_send)){var F=this.mn(v);if(!F)return;(v=F).uuid=hn(v.uuid,Ve)}this.ho.emit("eventCaptured",v);var O=(r=s?._url)!==null&&r!==void 0?r:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),M={method:"POST",url:O,data:v,compression:"best-available",timestampMode:s?._batchKey==="recordings"||/\/s\/(?:\?|$)/.test(O)?"body":"capture-body",batchKey:s?._batchKey,transport:s?.transport};return!this.config.request_batching||s&&(s==null||!s._batchKey)||s!=null&&s.send_instantly?this.Ao(M):this.Po.enqueue(M),v}E.critical("This capture call is ignored due to client rate limiting.")}}else E.error("No event name provided to posthog.capture")}else E.uninitializedWarning("posthog.capture")}_addCaptureHook(e){return this.on("eventCaptured",(t=>e(t.event,t)))}qo(){var e;return(e=this.Ho)!==null&&e!==void 0?e:this.Ho=new oh(this)}vo(e){this.So.push(e);var t=!0;return()=>{if(t){t=!1;var s=this.So.indexOf(e);s!==-1&&this.So.splice(s,1)}}}Qo(e){var t,s,r;return e===void 0&&(e=!0),!((t=this.persistence)==null||!t.consumeCookieIdentityChange())&&(this.Mo=null,this.persistence.get_property(j)===ae&&((r=this.sessionPersistence)==null||r.clear(),this.wo.clear(),this.Jo()),(s=this.featureFlags)==null||s.reset(),e&&this.reloadFeatureFlags(),!0)}calculateEventProperties(e,t,s,r,n){if(s=s||new Date,!this.persistence||!this.sessionPersistence)return t;this.persistence.syncCookieProperties(),this.Qo();var a=n?void 0:this.persistence.remove_event_timer(e),o=y({},t);if(o.token=this.config.token,o.$config_defaults=this.config.defaults,this.po()&&(o[oo]=!0),e==="$snapshot"){var l=y({},this.persistence.properties(),this.sessionPersistence.properties());return o.distinct_id=l.distinct_id,(!q(o.distinct_id)&&!oe(o.distinct_id)||Ni(o.distinct_id))&&E.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),o}var h,u=(function(x,C,N,I){var F,O,M,T;if(I===void 0&&(I=!1),!Ee)return{};var R,H=x?[...Bt,...C||[]]:[],V=(function(mi){for(var $e=0;ln.length>$e;$e++){var yi=ln[$e],wt=yi[1],xt=yi[0].exec(mi),zt=xt&&(me(wt)?wt(xt,mi):wt);if(zt)return zt}return["",""]})(Ee),B=V[0],ie=V[1],ue=(R=typeof navigator<"u"?navigator:void 0)!=null&&R.brave?{brave:!0}:{},we={};w(N)||(we.detectGoogleSearchApp=N);var pe={},xe=(F=navigator)==null||(F=F.userAgentData)==null?void 0:F.platform,Pe=(O=navigator)==null?void 0:O.maxTouchPoints,se=_==null||(M=_.screen)==null?void 0:M.width,ce=_==null||(T=_.screen)==null?void 0:T.height,he=_?.devicePixelRatio;w(xe)||(pe.userAgentDataPlatform=xe),w(Pe)||(pe.maxTouchPoints=Pe),w(se)||(pe.screenWidth=se),w(ce)||(pe.screenHeight=ce),w(he)||(pe.devicePixelRatio=he);var Ne,at,ne,Ae,tt,Ut,Te,ke,_i=W(Br({$os:B,$os_version:ie,$browser:za(Ee,navigator.vendor,ue,we),$device:un(Ee),$device_type:(at=Ee,ne=pe,ke=un(at),ke===Ia||ke===Pa||ke==="Kobo"||ke==="Kindle Fire"||ke===Ha?Dt:ke===hi||ke===Rt||ke===ci||ke===er?"Console":ke===Fa?"Wearable":ke?Ce:ne?.userAgentDataPlatform==="Android"&&((Ae=ne?.maxTouchPoints)!==null&&Ae!==void 0?Ae:0)>0?600>Math.min((tt=ne?.screenWidth)!==null&&tt!==void 0?tt:0,(Ut=ne?.screenHeight)!==null&&Ut!==void 0?Ut:0)/((Te=ne?.devicePixelRatio)!==null&&Te!==void 0?Te:1)?Ce:Dt:"Desktop"),$timezone:Ao(),$timezone_offset:Mu()}),{$current_url:fi(I?rt(X?.href):X?.href,H,gi),$host:X?.host,$pathname:X?.pathname,$raw_user_agent:Ee.length>1e3?Ee.substring(0,997)+"...":Ee,$browser_version:Ol(Ee,navigator.vendor,ue,we),$browser_language:Ln(),$browser_language_prefix:(Ne=Ln(),typeof Ne=="string"?Ne.split("-")[0]:void 0),$screen_height:_?.screen.height,$screen_width:_?.screen.width,$viewport_height:_?.innerHeight,$viewport_width:_?.innerWidth,$lib:Y.LIB_NAME,$lib_version:Y.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3});return Y.SDK_DIST_CHANNEL&&(_i.$sdk_dist_channel=Y.SDK_DIST_CHANNEL),_i})(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){var c=this.sessionManager.checkAndGetSessionAndWindowId(n,s.getTime(),!0),d=c.windowId;o.$session_id=c.sessionId,o.$window_id=d}this.sessionPropsManager&&W(o,this.sessionPropsManager.getSessionProps());try{var p;this.sessionRecording&&W(o,this.sessionRecording.sdkDebugProperties),o.$sdk_debug_retry_queue_size=(p=this.Fo)==null?void 0:p.length}catch(x){o.$sdk_debug_error_capturing_properties=String(x)}if(this.requestRouter.region===Or&&(o.$lib_custom_api_host=this.config.api_host),h=e!==It||n?e!==xs||n?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(s):this.pageViewManager.doPageView(s,r),o=W(o,h),e===It&&S&&(o.title=S.title),!w(a)){var v=s.getTime()-a;o.$duration=parseFloat((v/1e3).toFixed(3))}Ee&&this.config.opt_out_useragent_filter&&(o.$browser_type=this._is_bot()?"bot":"browser");var f=this.persistence.properties(),g=this.sessionPersistence.properties();U(["$referrer","$referring_domain"],(x=>{x in f&&delete g[x]}));var m={};if(this.So.length>0)for(var b of this.So.slice())try{W(m,b())}catch(x){E.error("Failed to produce browser extension event properties",x)}(o=W({},u,f,g,y({},m,o))).$is_identified=this._isIdentified(),A(this.config.property_denylist)?U(this.config.property_denylist,(function(x){delete o[x]})):E.error(tl+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var k=this.config.sanitize_properties;k&&(E.error(Zn),o=k(o,e));var P=this.Ko();return o.$process_person_profile=P,P&&!n&&this.Yo("_calculate_event_properties"),o}Zo(e,t,s){var r;if(t===void 0&&(t=!0),s===void 0&&(s=!1),!this.persistence||!this.Ko()||this._o&&!s)return e;var n=this.persistence.get_initial_props(),a=(r=this.sessionPropsManager)==null?void 0:r.getSetOnceProps(),o=W({},n,a||{},e||{}),l=this.config.sanitize_properties;return l&&(E.error(Zn),o=l(o,"$set_once")),t&&(this._o=!0),De(o)?void 0:o}register(e,t){var s;(s=this.persistence)==null||s.register(e,t)}register_once(e,t,s){var r;(r=this.persistence)==null||r.register_once(e,t,s)}register_for_session(e){var t,s;(t=this.persistence)==null||t.syncCookieProperties(),this.Qo(),(s=this.sessionPersistence)==null||s.register(e),Object.keys(e).forEach((r=>this.wo.add(r))),this.Jo()}unregister(e){var t;(t=this.persistence)==null||t.unregister(e)}unregister_for_session(e){var t;(t=this.sessionPersistence)==null||t.unregister(e),this.wo.delete(e),this.Jo()}Xo(e,t){this.register({[e]:t})}Oo(){this.wo.forEach((e=>{var t;(t=this.sessionPersistence)==null||t.unregister(e)})),this.wo.clear(),this.Jo()}Jo(){var e;if(this.ko)if(this.config.persistence==="memory"||(e=this.sessionPersistence)!=null&&e.ws||!J.Lr())J.Dr(this.ko);else{var t=[];this.wo.forEach((s=>t.push(s))),t.length>0?J.Or(this.ko,t):J.Dr(this.ko)}}getFeatureFlag(e,t){var s;return(s=this.featureFlags)==null?void 0:s.getFeatureFlag(e,t)}getFeatureFlagPayload(e){var t;return(t=this.featureFlags)==null?void 0:t.getFeatureFlagPayload(e)}getFeatureFlagResult(e,t){var s;return(s=this.featureFlags)==null?void 0:s.getFeatureFlagResult(e,t)}getAllFeatureFlags(){var e,t;return(e=(t=this.featureFlags)==null?void 0:t.getAllFeatureFlags())!==null&&e!==void 0?e:[]}isFeatureEnabled(e,t){var s,r;return(s=(r=this.featureFlags)==null?void 0:r.isFeatureEnabled(e,t))!==null&&s!==void 0?s:t?.defaultValue}reloadFeatureFlags(){var e;(e=this.featureFlags)==null||e.reloadFeatureFlags()}updateFlags(e,t,s){var r;(r=this.featureFlags)==null||r.updateFlags(e,t,s)}updateEarlyAccessFeatureEnrollment(e,t,s){var r;(r=this.featureFlags)==null||r.updateEarlyAccessFeatureEnrollment(e,t,s)}getEarlyAccessFeatures(e,t,s){var r;return t===void 0&&(t=!1),(r=this.featureFlags)==null?void 0:r.getEarlyAccessFeatures(e,t,s)}on(e,t){return this.ho.on(e,t)}onFeatureFlags(e){return this.featureFlags?this.featureFlags.onFeatureFlags(e):(e([],{},{errorsLoading:!0}),()=>{})}onSurveysLoaded(e){return this.surveys?this.surveys.onSurveysLoaded(e):(e([],{isLoaded:!1,error:Kt}),()=>{})}onSessionId(e){var t,s;return(t=(s=this.sessionManager)==null?void 0:s.onSessionId(e))!==null&&t!==void 0?t:()=>{}}getSurveys(e,t){t===void 0&&(t=!1),this.surveys?this.surveys.getSurveys(e,t):e([],{isLoaded:!1,error:Kt})}getActiveMatchingSurveys(e,t){t===void 0&&(t=!1),this.surveys?this.surveys.getActiveMatchingSurveys(e,t):e([],{isLoaded:!1,error:Kt})}renderSurvey(e,t){var s;(s=this.surveys)==null||s.renderSurvey(e,t)}displaySurvey(e,t){var s;t===void 0&&(t=th),(s=this.surveys)==null||s.displaySurvey(e,t)}cancelPendingSurvey(e){var t;(t=this.surveys)==null||t.cancelPendingSurvey(e)}canRenderSurvey(e){var t,s;return(t=(s=this.surveys)==null?void 0:s.canRenderSurvey(e))!==null&&t!==void 0?t:{visible:!1,disabledReason:Kt}}canRenderSurveyAsync(e,t){var s,r;return t===void 0&&(t=!1),(s=(r=this.surveys)==null?void 0:r.canRenderSurveyAsync(e,t))!==null&&s!==void 0?s:Promise.resolve({visible:!1,disabledReason:Kt})}tl(e){return!e||Ni(e)?(E.critical("Unique user id has not been set in posthog.identify"),!1):e===kt?(E.critical('The string "'+e+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.'),!1):!["distinct_id","distinctid"].includes(e.toLowerCase())&&!["undefined","null"].includes(e.toLowerCase())||(E.critical('The string "'+e+'" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.'),!1)}identify(e,t,s){if(!this.__loaded||!this.persistence)return E.uninitializedWarning("posthog.identify");if(oe(e)&&(e=e.toString(),E.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),this.tl(e)&&this.Yo("posthog.identify")){this.mo();var r=this.get_distinct_id(),n=this.persistence.syncCookieProperties()&&this.get_distinct_id()!==r,a=this.Qo(!1),o=this.persistence.xs(),l=!1;try{var h=this.get_distinct_id();this.register({$user_id:e}),this.get_property(di)||this.register_once({$had_persisted_distinct_id:!0,$device_id:h},""),e!==h&&e!==this.get_property(Ft)&&(this.unregister(Ft),this.register({distinct_id:e}));var u,c=(this.persistence.get_property(j)||ae)===ae,d=e!==h,p=!d&&c;if(d&&c)this.persistence.set_property(j,ve),this.setPersonPropertiesForFlags({$set:t||{},$set_once:s||{}},!1),this.config.cookieWinsOnConflict&&this.persistence.Cs(),this.capture(ks,{distinct_id:e,$anon_distinct_id:h},{$set:t||{},$set_once:s||{}}),this.Mo=Ns(e,t,s),(u=this.featureFlags)==null||u.setAnonymousDistinctId(h);else if(p){this.persistence.set_property(j,ve);var v=t||{},f=s||{};this.setPersonPropertiesForFlags({$set:v,$set_once:f},!1),this.config.cookieWinsOnConflict&&this.persistence.Cs(),this.capture("$set",{$set:v,$set_once:f}),this.Mo=Ns(e,t,s)}else(t||s)&&this.setPersonProperties(t,s);d||n||a?(this.reloadFeatureFlags(),this.featureFlags?this.featureFlags.resetFlagCallReported():this.unregister(Ze)):p&&(t||s)&&this.reloadFeatureFlags(),l=!0}finally{o&&this.persistence.Es(l)}}}setPersonProperties(e,t){if((e||t)&&this.Yo("posthog.setPersonProperties")){var s=Ns(this.get_distinct_id(),e,t);this.Mo!==s?(this.setPersonPropertiesForFlags({$set:e||{},$set_once:t||{}},!0),this.capture("$set",{$set:e||{},$set_once:t||{}}),this.Mo=s):E.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}unsetPersonProperties(e){var t,s=(A(e)?e:[e]).filter((r=>q(r)&&r.length>0));s.length!==0&&this.Yo("posthog.unsetPersonProperties")&&((t=this.featureFlags)==null||t.unsetPersonPropertiesForFlags(s,!0),this.capture("$set",{$unset:s}),this.Mo=null)}group(e,t,s){var r;if(e&&t){(r=this.persistence)==null||r.syncCookieProperties(),this.Qo();var n=this.getGroups(),a=n[e]!==t;if(a&&this.resetGroupPropertiesForFlags(e),this.register({$groups:y({},n,{[e]:t})}),a||s){var o={$group_type:e,$group_key:t};s&&(o.$group_set=s),this.capture(mn,o)}s&&this.setGroupPropertiesForFlags({[e]:s}),a&&!s&&this.reloadFeatureFlags()}else E.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,t){var s;t===void 0&&(t=!0),(s=this.featureFlags)==null||s.setPersonPropertiesForFlags(e,t)}resetPersonPropertiesForFlags(e){var t;e===void 0&&(e=!0),(t=this.featureFlags)==null||t.resetPersonPropertiesForFlags(e)}setGroupPropertiesForFlags(e,t){var s;t===void 0&&(t=!0),this.Yo("posthog.setGroupPropertiesForFlags")&&((s=this.featureFlags)==null||s.setGroupPropertiesForFlags(e,t))}resetGroupPropertiesForFlags(e){var t;(t=this.featureFlags)==null||t.resetGroupPropertiesForFlags(e)}reset(e){var t=Oe(e)?e:e?.resetDeviceID,s=Oe(e)||e==null?void 0:e.bootstrap;this.el(t,!1,s)}el(e,t,s){var r,n,a;if(t===void 0&&(t=!1),E.info("reset"),!this.__loaded)return E.uninitializedWarning("posthog.reset");var o=s?.sessionID;this.config.bootstrap=s||((r=this.Io)==null?void 0:r.bootstrap)||{},(n=this.featureFlags)==null||n.updateConfig==null||n.updateConfig(this.config,this.Js());var l=this.get_property(di),h=this.get_property(ws),u=this.get_property(ft),c=this.is_capturing();this.consent.reset(),t||!c||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.");var d=(a=this.persistence)==null||a.xs==null?void 0:a.xs(),p=!1;try{var v,f,g,m,b,k,P,x,C,N,I,F,O,M;if((v=this.persistence)==null||v.clear(),(f=this.sessionPersistence)==null||f.clear(),this.wo.clear(),this.Jo(),w(u)||(I=this.persistence)==null||I.register({[ft]:u}),(g=this.surveys)==null||g.reset(),(m=this.Wo)==null||m.stop(),(b=this.featureFlags)==null||b.reset(),(k=this.conversations)==null||k.reset(),(P=this.logs)==null||P.reset(),(x=this.metrics)==null||x.reset(),(C=this.persistence)==null||C.set_property(j,ae),(N=this.sessionManager)==null||N.resetSessionId(),this.Mo=null,this.config.cookieless_mode===Ke)this.register_once({distinct_id:kt,$device_id:null},"");else{var T=this.config.get_device_id(Ve());this.register_once({distinct_id:T,$device_id:e?T:l},""),e||w(h)||this.register({[ws]:h})}if(this.register({$last_posthog_reset:new Date().toISOString()},1),s&&(s.distinctID===void 0||this.po()||((M=this.persistence)==null||M.set_property(j,s.isIdentifiedID?ve:ae),this.register({distinct_id:s.distinctID})),(F=this.featureFlags)==null||F.initialize(),!(w(o)||(O=this.sessionManager)!=null&&O.setBootstrapSessionId(o,!0)))){var R=y({},s);delete R.sessionID,this.config.bootstrap=R}delete this.config.identity_distinct_id,delete this.config.identity_hash,p=!0}finally{var H;d&&((H=this.persistence)==null||H.Es==null||H.Es(p))}this.reloadFeatureFlags()}shutdown(e){var t=this;return Q((function*(){var s,r,n,a,o,l,h;if(t.__loaded){(s=t.Wo)==null||s.stop(),(r=t.Ho)==null||r.dispose(),(n=t.sessionRecording)==null||n.dispose(),(a=t.logs)==null||a.flushLogs("sendBeacon"),(o=t.metrics)==null||o.flush("sendBeacon"),(l=t.Po)==null||l.unload(),(h=t.Fo)==null||h.unload();try{var u;(u=t.featureFlags)==null||u.destroy()}catch(c){E.error("Error while destroying feature flags",c)}}else E.uninitializedWarning("posthog.shutdown")}))()}setIdentity(e,t){var s;this.config.identity_distinct_id=e,this.config.identity_hash=t,this.alias(e),(s=this.conversations)==null||s.il()}clearIdentity(){var e;delete this.config.identity_distinct_id,delete this.config.identity_hash,(e=this.conversations)==null||e.rl()}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var e,t;return(e=(t=this.sessionManager)==null?void 0:t.checkAndGetSessionAndWindowId(!0).sessionId)!==null&&e!==void 0?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";var t=this.sessionManager.checkAndGetSessionAndWindowId(!0),s=t.sessionStartTimestamp,r=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+t.sessionId);if(e!=null&&e.withTimestamp&&s){var n,a=(n=e.timestampLookBack)!==null&&n!==void 0?n:10;if(!s)return r;r+="?t="+Math.max(Math.floor((new Date().getTime()-s)/1e3)-a,0)}return r}alias(e,t){return e===this.get_property(eo)?(E.critical("Attempting to create alias for existing People user - aborting."),-2):this.Yo("posthog.alias")?(w(t)&&(t=this.get_distinct_id()),e!==t?(this.Xo(Ft,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(E.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var t=y({},this.config);if(Z(e)){var s,r,n,a,o,l,h,u,c,d,p,v;W(this.config,Kn(e));var f=this.yo();(s=this.persistence)==null||s.update_config(this.config,t,f),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new $s(y({},this.config,{persistence:"sessionStorage"}),f,!1);var g=this.Eo(this.config.debug);Oe(g)&&(this.config.debug=g),Oe(this.config.debug)&&(this.config.debug?(Y.DEBUG=!0,G.Lr()&&G.Or("ph_debug",!0),E.info("set_config",{config:e,oldConfig:t,newConfig:y({},this.config)})):(Y.DEBUG=!1,G.Lr()&&G.Dr("ph_debug"))),(r=this.featureFlags)==null||r.updateConfig==null||r.updateConfig(this.config,this.Js()),(n=this.exceptionObserver)==null||n.onConfigChange(),(a=this.exceptions)==null||a.onConfigChange(),(o=this.sessionRecording)==null||o.startIfEnabledOrStop(),(l=this.tracingHeaders)==null||l.startIfEnabledOrStop(),(h=this.autocapture)==null||h.startIfEnabled(),(u=this.heatmaps)==null||u.startIfEnabled(),(c=this.exceptionObserver)==null||c.startIfEnabledOrStop(),(d=this.deadClicksAutocapture)==null||d.startIfEnabledOrStop(),(p=this.surveys)==null||p.loadIfEnabled(),this.bo(),(v=this.externalIntegrations)==null||v.startIfEnabledOrStop()}}_overrideSDKInfo(e,t){Y.LIB_NAME=e,Y.LIB_VERSION=t}startSessionRecording(e){var t,s,r,n,a,o=e===!0,l={sampling:o||!(e==null||!e.sampling),linked_flag:o||!(e==null||!e.linked_flag),url_trigger:o||!(e==null||!e.url_trigger),event_trigger:o||!(e==null||!e.event_trigger)};Object.values(l).some(Boolean)&&((t=this.sessionManager)==null||t.checkAndGetSessionAndWindowId(),l.sampling&&((s=this.sessionRecording)==null||s.overrideSampling()),l.linked_flag&&((r=this.sessionRecording)==null||r.overrideLinkedFlag()),l.url_trigger&&((n=this.sessionRecording)==null||n.overrideTrigger("url")),l.event_trigger&&((a=this.sessionRecording)==null||a.overrideTrigger("event"))),this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var e;return!((e=this.sessionRecording)==null||!e.started)}captureException(e,t){if(this.exceptions){var s=new Error("PostHog syntheticException"),r=this.exceptions.buildProperties(e,{handled:!0,syntheticException:s});return this.exceptions.sendExceptionEvent(y({},r,t))}}addExceptionStep(e,t){var s;(s=this.exceptions)==null||s.addExceptionStep(e,t)}captureLog(e){var t;(t=this.logs)==null||t.captureLog(e)}get logger(){var e,t;return(e=(t=this.logs)==null?void 0:t.logger)!==null&&e!==void 0?e:Ie.nl}startExceptionAutocapture(e){this.set_config({capture_exceptions:e==null||e})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(e){var t,s;return(t=(s=this.toolbar)==null?void 0:s.loadToolbar(e))!==null&&t!==void 0&&t}get_property(e){var t;return(t=this.persistence)==null?void 0:t.props[e]}getSessionProperty(e){var t;return(t=this.sessionPersistence)==null?void 0:t.props[e]}toString(){var e,t=(e=this.config.name)!==null&&e!==void 0?e:Ot;return t!==Ot&&(t=Ot+"."+t),t}_isIdentified(){var e,t;return((e=this.persistence)==null?void 0:e.get_property(j))===ve||((t=this.sessionPersistence)==null?void 0:t.get_property(j))===ve}Ko(){var e,t;return!(this.config.person_profiles==="never"||this.config.person_profiles===mr&&!this._isIdentified()&&De(this.getGroups())&&((e=this.persistence)==null||(e=e.props)==null||!e[Ft])&&((t=this.persistence)==null||(t=t.props)==null||!t[Ki]))}Vo(){return this.config.capture_pageleave===!0||this.config.capture_pageleave==="if_capture_pageview"&&(this.config.capture_pageview===!0||this.config.capture_pageview==="history_change")}createPersonProfile(){this.Ko()||this.Yo("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.Yo("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}Yo(e){return this.config.person_profiles==="never"?(E.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.Xo(Ki,!0),!0)}yo(){if(this.config.cookieless_mode==="always")return!0;var e=this.consent.isOptedOut();return this.config.disable_persistence||e&&!(!this.config.opt_out_persistence_by_default&&this.config.cookieless_mode!==vt)}bo(){var e,t,s,r,n=this.yo();return((e=this.persistence)==null?void 0:e.ws)!==n&&((s=this.persistence)==null||s.set_disabled(n)),((t=this.sessionPersistence)==null?void 0:t.ws)!==n&&((r=this.sessionPersistence)==null||r.set_disabled(n)),n&&(this.wo.clear(),this.Jo()),n}opt_in_capturing(e){var t;if(this.config.cookieless_mode!==Ke){if(this.po()){var s,r,n,a,o;this.el(!0,!0),(s=this.sessionManager)==null||s.destroy(),(r=this.pageViewManager)==null||r.destroy(),this.sessionManager=new Wn(this),this.pageViewManager=new An(this),this.persistence&&(this.sessionPropsManager=new zn(this,this.sessionManager,this.persistence));var l,h=(n=(a=this.config.__extensionClasses)==null?void 0:a.sessionRecording)!==null&&n!==void 0?n:(o=Ie.__defaultExtensionClasses)==null?void 0:o.sessionRecording;h&&(this.sessionRecording=this.fo(this.sessionRecording,new h(this)),this.uo&&((l=this.sessionRecording)==null||l.onRemoteConfig==null||l.onRemoteConfig(this.uo)))}var u,c;this.consent.optInOut(!0),this.bo(),this.zo(),(t=this.sessionRecording)==null||t.startIfEnabledOrStop(),this.config.cookieless_mode==vt&&((u=this.surveys)==null||u.loadIfEnabled()),(w(e?.captureEventName)||e!=null&&e.captureEventName)&&this.capture((c=e?.captureEventName)!==null&&c!==void 0?c:"$opt_in",e?.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.Uo()}else E.warn(Qn)}opt_out_capturing(){var e,t,s;this.config.cookieless_mode!==Ke?(this.config.cookieless_mode===vt&&this.consent.isOptedIn()&&this.el(!0,!0),this.consent.optInOut(!1),this.bo(),this.config.cookieless_mode===vt&&(this.register({distinct_id:kt,$device_id:null}),(e=this.sessionRecording)==null||e.stopRecording(),this.sessionRecording=void 0,(t=this.sessionManager)==null||t.destroy(),(s=this.pageViewManager)==null||s.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,this.config.capture_pageview&&this.Uo(),this.zo())):E.warn(Qn)}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){var e=this.consent.consent;return e===1?"granted":e===0?"denied":"pending"}is_capturing(){return this.config.cookieless_mode===Ke||(this.config.cookieless_mode===vt?this.consent.isRejected()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this.bo()}_is_bot(){return be?Jo(be,this.config.custom_blocked_useragents):void 0}Uo(){S&&(S.visibilityState==="visible"?this.xo||(this.xo=!0,this.capture(It,{title:S.title},{send_instantly:!0}),this.Co&&(S.removeEventListener(Xi,this.Co),this.Co=null)):this.Co||(this.Co=this.Uo.bind(this),ee(S,Xi,this.Co)))}debug(e){e===!1?(_?.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(_?.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}))}Js(){var e=this.Io||{};return"advanced_disable_flags"in e?!!e.advanced_disable_flags:this.config.advanced_disable_flags!==!1?!!this.config.advanced_disable_flags:this.config.advanced_disable_decide===!0?(E.warn("Config field 'advanced_disable_decide' is deprecated. Please use 'advanced_disable_flags' instead. The old field will be removed in a future major version."),!0):(function(t,s,r,n,a){var o=s in t&&!D(t[s]),l=r in t&&!D(t[r]);return o?t[s]:!!l&&(a&&a.warn("Config field '"+r+"' is deprecated. Please use '"+s+"' instead. The old field will be removed in a future major version."),t[r])})(e,"advanced_disable_flags","advanced_disable_decide",0,E)}mn(e){var t;if(D(this.config.before_send))return e;var s=Object.keys((t=e.properties)!==null&&t!==void 0?t:{}).filter(gl),r=A(this.config.before_send)?this.config.before_send:[this.config.before_send],n=e;for(var a of r)try{if(n=a(n),D(n)){var o="Event '"+e.event+"' was rejected in beforeSend function";return fl(e.event)?E.warn(o+". This can cause unexpected behavior."):E.info(o),null}n.properties&&!De(n.properties)||E.warn("Event '"+e.event+"' has no properties after beforeSend function, this is likely an error.")}catch(h){return E.error("Error in beforeSend function for event '"+e.event+"':",h),null}for(var l of s)if(n.properties&&D(n.properties[l]))return E.warn("Event '"+e.event+"' had its '"+l+"' property removed in a beforeSend function. This property is required for ingestion, so the event will be dropped."),null;return n}getPageViewId(){var e;return(e=this.pageViewManager.Xn)==null?void 0:e.pageViewId}captureTraceFeedback(e,t){this.capture("$ai_feedback",{$ai_trace_id:String(e),$ai_feedback_text:t})}captureTraceMetric(e,t,s){this.capture("$ai_metric",{$ai_trace_id:String(e),$ai_metric_name:t,$ai_metric_value:String(s)})}Eo(e){var t=Oe(e)&&!e,s=G.Lr()&&G.Fr("ph_debug")==="true";return!t&&(!!s||e)}}Ie.__defaultExtensionClasses={},Ie.nl=(()=>{var i=()=>{};return{trace:i,debug:i,info:i,warn:i,error:i,fatal:i}})(),(function(i,e){for(var t=0;e.length>t;t++)i.prototype[e[t]]=au(i.prototype[e[t]])})(Ie,["identify"]);class Xn{constructor(e){this.disabled=e===!1;var t=Z(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;var r=this.clicks[this.clicks.length-1];if(r&&Math.abs(e-r.x)+Math.abs(t-r.y)<this.thresholdPx&&this.timeoutMs>s-r.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}}var qs="$copy_autocapture",Bs=K("[AutoCapture]");function Vs(i,e){return e.length>i?e.slice(0,i)+"...":e}function ch(i){if(i.previousElementSibling)return i.previousElementSibling;var e=i;do e=e.previousSibling;while(e&&!nt(e));return e}function dh(i,e){var t,s,r=e.e,n=e.maskAllElementAttributes,a=e.maskAllText,o=e.elementAttributeIgnoreList,l=e.elementsChainAsString,h=e.disableCaptureUrlHashes;if(!nt(i))return{props:{}};for(var u=[i],c=new Set([i]),d=i;d.parentNode&&!Fe(d,"body")&&mo>u.length;)if(_o(d.parentNode)){var p=d.parentNode.host;if(c.has(p))break;c.add(p),u.push(p),d=p}else{if(!nt(d.parentNode)||c.has(d.parentNode))break;c.add(d.parentNode),u.push(d.parentNode),d=d.parentNode}var v,f,g=[],m={},b=!1,k=!1;if(U(u,(I=>{var F=wr(I);if(Fe(I,"a")){var O=I.getAttribute("href");b=!!(F&&O&&oi(O))&&(h?rt(O):O)}L(ss(I),"ph-no-capture")&&(k=!0),g.push((function(T,R,H,V,B){B===void 0&&(B=!1);var ie=T.tagName.toLowerCase(),ue={tag_name:ie};Ur.indexOf(ie)>-1&&!H&&(ue.$el_text=ie.toLowerCase()==="a"||ie.toLowerCase()==="button"?Vs(1024,$n(T)):Vs(1024,pi(T)));var we=ss(T);we.length>0&&(ue.classes=we.filter((function(se){return se!==""}))),U(T.attributes,(function(se){var ce;if((!ko(T)||["name","id","class","aria-label"].indexOf(se.name)!==-1)&&(V==null||!V.includes(se.name))&&!R&&oi(se.value)&&(!q(ce=se.name)||ce.substring(0,10)!=="_ngcontent"&&ce.substring(0,7)!=="_nghost")){var he=se.value;se.name==="class"&&(he=Vr(he).join(" ")),ue["attr__"+se.name]=Vs(1024,se.name==="href"&&B?rt(he):he)}}));for(var pe=1,xe=1,Pe=T;Pe=ch(Pe);)pe++,Pe.tagName===T.tagName&&xe++;return ue.nth_child=pe,ue.nth_of_type=xe,ue})(I,n,a,o,h));var M=(function(T){if(!wr(T))return{};var R={};return U(T.attributes,(function(H){if(H.name&&H.name.indexOf("data-ph-capture-attribute")===0){var V=H.name.replace("data-ph-capture-attribute-",""),B=H.value;V&&B&&oi(B)&&(R[V]=B)}})),R})(I);W(m,M)})),k)return{props:{},explicitNoCapture:k};if(a||(g[0].$el_text=Fe(i,"a")||Fe(i,"button")?$n(i):pi(i)),b){var P,x;g[0].attr__href=b;var C=(P=Ht(b))==null?void 0:P.host,N=_==null||(x=_.location)==null?void 0:x.host;C&&N&&C!==N&&(v=b)}return{props:W({$event_type:r.type,$ce_version:1},l?{}:{$elements:g},{$elements_chain:(f=g,(function(I){return I.map((F=>{var O,M,T="";if(F.tag_name&&(T+=F.tag_name),F.attr_class)for(var R of(F.attr_class.sort(),F.attr_class))T+="."+R.replace(/"/g,"");var H=y({},F.text?{text:F.text}:{},{"nth-child":(O=F.nth_child)!==null&&O!==void 0?O:0,"nth-of-type":(M=F.nth_of_type)!==null&&M!==void 0?M:0},F.href?{href:F.href}:{},F.attr_id?{attr_id:F.attr_id}:{},F.attributes),V={};return Ai(H).sort(((B,ie)=>B[0].localeCompare(ie[0]))).forEach((B=>{var ie=B[1];return V[Mn(B[0].toString())]=Mn(ie.toString())})),(T+=":")+Ai(V).map((B=>B[0]+'="'+B[1]+'"')).join("")})).join(";")})((function(I){return I.map((F=>{var O,M,T={text:(O=F.$el_text)==null?void 0:O.slice(0,400),tag_name:F.tag_name,href:(M=F.attr__href)==null?void 0:M.slice(0,2048),attr_class:Su(F),attr_id:F.attr__id,nth_child:F.nth_child,nth_of_type:F.nth_of_type,attributes:{}};return Ai(F).filter((R=>R[0].indexOf("attr__")===0)).forEach((R=>T.attributes[R[0]]=R[1])),T}))})(f)))},(t=g[0])!=null&&t.$el_text?{$el_text:(s=g[0])==null?void 0:s.$el_text}:{},v&&r.type==="click"?{$external_click_url:v}:{},m)}}var Xt=K("[ExceptionAutocapture]"),ea=()=>{},vh=K("[TracingHeaders]"),lt=K("[Web Vitals]"),ta=9e5,ia="disabled",sa="lazy_loading",ei="awaiting_config",Fi="missing_config";K("[SessionRecording]"),K("[SessionRecording]");var Fr="[SessionRecording]",We=K(Fr),ph=K("[Heatmaps]");function Us(i){return Z(i)&&"clientX"in i&&"clientY"in i&&oe(i.clientX)&&oe(i.clientY)}var Ci=K("[Product Tours]"),zs=i=>{var e;return!i.config.disable_product_tours&&!((e=i.persistence)==null||!e.get_property(jr))},fh=["$set_once","$set"],je=K("[SiteApps]"),ra="Error while initializing PostHog app with config id ";function Pt(i,e,t){if(D(i))return!1;switch(t){case"exact":return i===e;case"contains":var s=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(s,"i").test(i);case"regex":try{return new RegExp(e).test(i)}catch{return!1}default:return!1}}class gh{constructor(e){this.sl=new Jr,this.al=(t,s)=>this.ol(t,s)&&this.ll(t,s)&&this.ul(t,s)&&this.hl(t,s),this.ol=(t,s)=>s==null||!s.event||t?.event===s?.event,this._instance=e,this.dl=new Set,this.vl=new Set}init(){var e,t;w((e=this._instance)==null?void 0:e._addCaptureHook)||(t=this._instance)==null||t._addCaptureHook(((s,r)=>{this.on(s,r)}))}register(e){var t,s;if(!w((t=this._instance)==null?void 0:t._addCaptureHook)&&(e.forEach((a=>{var o,l;(o=this.vl)==null||o.add(a),(l=a.steps)==null||l.forEach((h=>{var u;(u=this.dl)==null||u.add(h?.event||"")}))})),(s=this._instance)!=null&&s.autocapture)){var r,n=new Set;e.forEach((a=>{var o;(o=a.steps)==null||o.forEach((l=>{l!=null&&l.selector&&n.add(l?.selector)}))})),(r=this._instance)==null||r.autocapture.setElementSelectors(n)}}on(e,t){var s;t!=null&&e.length!=0&&(this.dl.has(e)||this.dl.has(t.event))&&this.vl&&((s=this.vl)==null?void 0:s.size)>0&&this.vl.forEach((r=>{this.cl(t,r)&&this.sl.emit("actionCaptured",r.name)}))}fl(e){this.onAction("actionCaptured",(t=>e(t)))}cl(e,t){if(t?.steps==null)return!1;for(var s of t.steps)if(this.al(e,s))return!0;return!1}onAction(e,t){return this.sl.on(e,t)}ll(e,t){if(t!=null&&t.url){var s,r=e==null||(s=e.properties)==null?void 0:s.$current_url;if(!r||typeof r!="string"||!Pt(r,t.url,t.url_matching||"contains"))return!1}return!0}ul(e,t){return!!this.pl(e,t)&&!!this.gl(e,t)&&!!this.ml(e,t)}pl(e,t){var s;if(t==null||!t.href)return!0;var r=this.yl(e);if(r.length>0)return r.some((o=>Pt(o.href,t.href,t.href_matching||"exact")));var n,a=(e==null||(s=e.properties)==null?void 0:s.$elements_chain)||"";return!!a&&Pt((n=a.match(/(?::|")href="(.*?)"/))?n[1]:"",t.href,t.href_matching||"exact")}gl(e,t){var s;if(t==null||!t.text)return!0;var r=this.yl(e);if(r.length>0)return r.some((h=>Pt(h.text,t.text,t.text_matching||"exact")||Pt(h.$el_text,t.text,t.text_matching||"exact")));var n,a,o,l=(e==null||(s=e.properties)==null?void 0:s.$elements_chain)||"";return!!l&&(n=(function(h){for(var u,c=[],d=/(?::|")text="(.*?)"/g;!D(u=d.exec(h));)c.includes(u[1])||c.push(u[1]);return c})(l),a=t.text,o=t.text_matching||"exact",n.some((h=>Pt(h,a,o))))}ml(e,t){var s,r;if(t==null||!t.selector)return!0;var n=e==null||(s=e.properties)==null?void 0:s.$element_selectors;if(n!=null&&n.includes(t.selector))return!0;var a=(e==null||(r=e.properties)==null?void 0:r.$elements_chain)||"";if(t.selector_regex&&a)try{return new RegExp(t.selector_regex).test(a)}catch{return!1}return!1}yl(e){var t;return(e==null||(t=e.properties)==null?void 0:t.$elements)==null?[]:e?.properties.$elements}hl(e,t){return t==null||!t.properties||t.properties.length===0||Zo(t.properties.reduce(((s,r)=>{var n=A(r.value)?r.value.map(String):r.value!=null?[String(r.value)]:[];return s[r.key]={values:n,operator:r.operator||"exact"},s}),{}),e?.properties)}}class _h{constructor(e){var t;this.bl=[],this._instance=e,this._l=new Map,this.wl=new Map,this.kl=new Map,(t=this._instance)==null||t.onSessionId==null||t.onSessionId((s=>this.Sl(s)))}xl(e){return!1}Cl(){return null}Tl(e){}Ml(){}El(e,t){return!!e&&Zo(e.propertyFilters,t?.properties)}Il(e,t){var s=new Map;return e.forEach((r=>{var n;(n=r.conditions)==null||(n=n[t])==null||(n=n.values)==null||n.forEach((a=>{if(a!=null&&a.name){var o=s.get(a.name)||[];o.push(r.id),s.set(a.name,o)}}))})),s}Rl(e,t,s){var r=(s===Yt.Activation?this._l:this.wl).get(e),n=[];return this.Pl((a=>{n=a.filter((o=>r?.includes(o.id)))})),n.filter((a=>{var o,l=(o=a.conditions)==null||(o=o[s])==null||(o=o.values)==null?void 0:o.find((h=>h.name===e));return this.El(l,t)}))}register(e){var t;w((t=this._instance)==null?void 0:t._addCaptureHook)||(this.Al(e),this.Fl(e))}Fl(e){var t=e.filter((s=>{var r,n;return((r=s.conditions)==null?void 0:r.actions)&&((n=s.conditions)==null||(n=n.actions)==null||(n=n.values)==null?void 0:n.length)>0}));t.length!==0&&(this.Ol==null&&(this.Ol=new gh(this._instance),this.Ol.init(),this.Ol.fl((s=>{this.onAction(s)}))),t.forEach((s=>{var r,n,a,o,l;s.conditions&&(r=s.conditions)!=null&&r.actions&&(n=s.conditions)!=null&&(n=n.actions)!=null&&n.values&&((a=s.conditions)==null||(a=a.actions)==null||(a=a.values)==null?void 0:a.length)>0&&((o=this.Ol)==null||o.register(s.conditions.actions.values),(l=s.conditions)==null||(l=l.actions)==null||(l=l.values)==null||l.forEach((h=>{if(h&&h.name){var u=this.kl.get(h.name);u&&u.push(s.id),this.kl.set(h.name,u||[s.id])}})))})))}Al(e){var t,s=e.filter((n=>{var a,o;return((a=n.conditions)==null?void 0:a.events)&&((o=n.conditions)==null||(o=o.events)==null||(o=o.values)==null?void 0:o.length)>0})),r=e.filter((n=>{var a,o;return((a=n.conditions)==null?void 0:a.cancelEvents)&&((o=n.conditions)==null||(o=o.cancelEvents)==null||(o=o.values)==null?void 0:o.length)>0}));s.length===0&&r.length===0||((t=this._instance)==null||t._addCaptureHook(((n,a)=>{this.onEvent(n,a)})),this._l=this.Il(e,Yt.Activation),this.wl=this.Il(e,Yt.Cancellation))}onEvent(e,t){var s,r,n=this.Ll(),a=(t==null||(s=t.properties)==null?void 0:s.$survey_id)||(t==null||(r=t.properties)==null?void 0:r.$product_tour_id);if(a&&this.getActivatedIds().includes(a)){var o=this.$l(e,a);if(o==="consume")return n.info("event consumed activated item, removing it",{event:e,itemId:a}),void this.Dl([a]);if(o==="persist")return n.info("shown item promoted to persisted activation",{event:e,itemId:a}),this.Nl(a),void this.ql([a])}if(this.wl.has(e)){var l=this.Rl(e,t,Yt.Cancellation);l.length>0&&(n.info("cancel event matched, cancelling items",{event:e,itemsToCancel:l.map((u=>u.id))}),this.Dl(l.map((u=>u.id))),l.forEach((u=>this.jl(u.id))))}if(this._l.has(e)){n.info("event name matched",{event:e,eventPayload:t,items:this._l.get(e)});var h=this.Rl(e,t,Yt.Activation);this.Bl(h.map((u=>u.id)))}}onAction(e){this.kl.has(e)&&this.Bl(this.kl.get(e)||[])}Bl(e){var t;if(e.length!==0){var s=!((t=this._instance)==null||t.get_session_id==null||!t.get_session_id()),r=[];for(var n of e)s&&this.xl(n)?this.Nl(n)&&this.Hl(n):r.push(n);r.length>0&&(this.bl=[...new Set([...this.bl,...r])]),this.Ll().info("updating activated items",{activatedItems:this.getActivatedIds()})}}Nl(e){this.bl=this.bl.filter((s=>s!==e));var t=this.zl();return!t.includes(e)&&(this.Ul([...t,e]),this.Wl(),!0)}Dl(e){var t=new Set(e);this.bl=this.bl.filter((n=>!t.has(n)));var s=this.Vl(),r=s.filter((n=>!t.has(n)));r.length!==s.length&&(this.Ul(r),r.length===0&&this.Gl()),this.ql(e)}Zl(){var e,t=this.Cl();if(!t)return{};var s=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[t];return s&&typeof s=="object"?s:{}}Hl(e){if(this.Cl()){var t=this.Zl();this.Tl(y({},t,{[e]:Date.now()}))}}ql(e){if(this.Cl()){var t=this.Zl(),s={},r=!1;for(var n of Object.entries(t)){var a=n[0],o=n[1];e.includes(a)?r=!0:s[a]=o}r&&(De(s)?this.Ml():this.Tl(s))}}Ql(){this.Cl()&&this.Ml()}getActivationTimestamp(e){if(this.zl().includes(e)){var t=this.Zl()[e];return oe(t)?t:void 0}}Vl(){var e,t=this.Jl();return((e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[t])||[]}zl(){var e,t,s=this.Vl();if(s.length===0)return[];var r=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[this.Kl()],n=(t=this._instance)==null||t.get_session_id==null?void 0:t.get_session_id();return n&&r===n?s:[]}Wl(){var e,t=(e=this._instance)==null||e.get_session_id==null?void 0:e.get_session_id();t&&this.Yl(t)}Gl(){this.Xl()}Sl(e){var t,s=(t=this._instance)==null||(t=t.persistence)==null?void 0:t.props[this.Kl()];if(s&&s!==e){var r=this.Vl(),n=this.Zl();r.length>0&&(this.Ul([]),r.filter((a=>oe(n[a]))).forEach((a=>this.jl(a)))),this.Gl(),this.Ql()}}getActivatedIds(){return[...new Set([...this.zl(),...this.bl])].filter((e=>!this.tu(e)))}reset(){this.bl=[],this.Vl().length>0&&this.Ul([]),this.Gl(),this.Ql()}getEventToItemsMap(){return this._l}eu(){return this.Ol}}class mh extends _h{constructor(e){super(e)}Jl(){return dr}Kl(){return Mi}Cl(){return Ri}Tl(e){var t;(t=this._instance)==null||(t=t.persistence)==null||t.register({[Ri]:e})}Ml(){var e;(e=this._instance)==null||(e=e.persistence)==null||e.unregister(Ri)}xl(e){var t,s;this.Pl((n=>{s=n.find((a=>a.id===e))}));var r=(t=s)==null||(t=t.appearance)==null?void 0:t.surveyPopupDelaySeconds;return oe(r)&&r>0}iu(){return Xe.SHOWN}Pl(e){var t;(t=this._instance)==null||t.getSurveys(e)}jl(e){var t;(t=this._instance)==null||t.cancelPendingSurvey(e)}Ll(){return z}Ul(e){var t;(t=this._instance)==null||(t=t.persistence)==null||t.register({[dr]:e})}Yl(e){var t;(t=this._instance)==null||(t=t.persistence)==null||t.register({[Mi]:e})}Xl(){var e;(e=this._instance)==null||(e=e.persistence)==null||e.unregister(Mi)}tu(){return!1}$l(e,t){var s;this.Pl((n=>{s=n.find((a=>a.id===t))}));var r=!s||(function(n){var a;return Ko(n)&&!((a=n.conditions)==null||(a=a.events)==null||!a.repeatedActivation)||n.schedule==="always"})(s);return r?e===Xe.SHOWN?"consume":"ignore":e===Xe.SHOWN?"persist":e===Xe.DISMISSED||e===Xe.SENT?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}}var Ti="SDK is not enabled or survey functionality is not yet loaded",na="Disabled. Not loading surveys.",yh=_!=null&&_.location?rs(_.location.hash,"__posthog")||rs(location.hash,"state"):null,aa="_postHogToolbarParams",oa=K("[Toolbar]"),la=K("[FeatureFlags]");class bh{constructor(e,t){t===void 0&&(t=!1),this.ru=!1,this.update(e,t)}update(e,t){this.nu=((s,r)=>{var n,a,o,l;return{bootstrap:{featureFlags:(n=s.bootstrap)==null?void 0:n.featureFlags,featureFlagPayloads:(a=s.bootstrap)==null?void 0:a.featureFlagPayloads},remoteRequestsDisabled:r,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,requestTimeoutMs:s.feature_flag_request_timeout_ms,compression:s.disable_compression?"none":"base64",evaluationContexts:(o=(l=s.evaluation_contexts)!==null&&l!==void 0?l:s.evaluation_environments)!==null&&o!==void 0?o:[],flagKeys:A(s.flag_keys)?s.flag_keys:void 0}})(e,t),!e.evaluation_environments||e.evaluation_contexts||this.ru||(la.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.ru=!0),w(e.flag_keys)||A(e.flag_keys)||la.error("Invalid flag_keys found:",e.flag_keys,"Expected array of non-empty strings")}get(){return this.nu}}var ua=K("[FeatureFlags]"),ut=K("[FeatureFlags]",{debugEnabled:!0}),Gs=`" failed. Feature flags didn't load in time.`,ha="connection_error",ca=i=>{for(var e={},t=0;i.length>t;t++)e[i[t]]=!0;return e},da=i=>{var e={};for(var t of Ai(i||{})){var s=t[1];s&&(e[t[0]]=s)}return e},He=K("[Error tracking]"),wh=["chrome-extension://","moz-extension://","safari-extension:","safari-web-extension:"],va="Refusing to render web experiment since the viewer is a likely bot",xh={icontains:(i,e)=>e.toLowerCase().indexOf(i.toLowerCase())>-1,not_icontains:(i,e)=>e.toLowerCase().indexOf(i.toLowerCase())===-1,regex:(i,e)=>os(e,i),not_regex:(i,e)=>!os(e,i),exact:(i,e)=>e===i,is_not:(i,e)=>e!==i};class fe{get Oi(){return this._instance.config}constructor(e){var t=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(s){s===void 0&&(s=!1),t.getWebExperiments((r=>{fe.su("retrieved web experiments from the server"),t.au=new Map,r.forEach((n=>{if(n.feature_flag_key){var a;t.au&&(fe.su("setting flag key ",n.feature_flag_key," to web experiment ",n),(a=t.au)==null||a.set(n.feature_flag_key,n));var o=t._instance.getFeatureFlag(n.feature_flag_key);q(o)&&n.variants[o]&&t.ou(n.name,o,n.variants[o].transforms)}else if(n.variants)for(var l in n.variants){var h=n.variants[l];fe.lu(h,t._instance)&&t.ou(n.name,l,h.transforms)}}))}),s)},this._instance=e,this._instance.onFeatureFlags((s=>{this.onFeatureFlags(s)}))}initialize(){}onFeatureFlags(e){if(this._is_bot())fe.su(va);else if(!this.Oi.disable_web_experiments){if(D(this.au))return this.au=new Map,this.loadIfEnabled(),void this.previewWebExperiment();fe.su("applying feature flags",e),e.forEach((t=>{var s;if(this.au&&(s=this.au)!=null&&s.has(t)){var r,n=this._instance.getFeatureFlag(t),a=(r=this.au)==null?void 0:r.get(t);n&&a!=null&&a.variants[n]&&this.ou(a.name,n,a.variants[n].transforms)}}))}}previewWebExperiment(){var e=fe.getWindowLocation();if(e!=null&&e.search){var t=qt(e?.search,"__experiment_id"),s=qt(e?.search,"__experiment_variant");t&&s&&(fe.su("previewing web experiments "+t+" && "+s),this.getWebExperiments((r=>{this.uu(parseInt(t),s,r)}),!1,!0))}}loadIfEnabled(){this.Oi.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,t,s){if(this.Oi.disable_web_experiments&&!s)return e([]);var r=this._instance.get_property("$web_experiments");if(r&&!t)return e(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this.Oi.token),method:"GET",timestampMode:"query",callback:n=>e(n.statusCode===200&&n.json&&n.json.experiments||[])})}uu(e,t,s){var r=s.filter((n=>n.id===e));r&&r.length>0&&(fe.su("Previewing web experiment ["+r[0].name+"] with variant ["+t+"]"),this.ou(r[0].name,t,r[0].variants[t].transforms))}static lu(e,t){return!D(e.conditions)&&fe.hu(e,t)&&fe.du(e)}static hu(e,t){var s;if(D(e.conditions)||D((s=e.conditions)==null?void 0:s.url))return!0;var r=fe.getWindowLocation();if(r){var n,a,o,l=po(t,r.href);return(n=e.conditions)==null||!n.url||xh[(a=(o=e.conditions)==null?void 0:o.urlMatchType)!==null&&a!==void 0?a:"icontains"](e.conditions.url,l)}return!1}static getWindowLocation(){return _?.location}static du(e){var t;if(D(e.conditions)||D((t=e.conditions)==null?void 0:t.utm))return!0;var s=Fo();if(s.utm_source){var r,n,a,o,l,h,u,c,d=(r=e.conditions)==null||(r=r.utm)==null||!r.utm_campaign||((n=e.conditions)==null||(n=n.utm)==null?void 0:n.utm_campaign)==s.utm_campaign,p=(a=e.conditions)==null||(a=a.utm)==null||!a.utm_source||((o=e.conditions)==null||(o=o.utm)==null?void 0:o.utm_source)==s.utm_source,v=(l=e.conditions)==null||(l=l.utm)==null||!l.utm_medium||((h=e.conditions)==null||(h=h.utm)==null?void 0:h.utm_medium)==s.utm_medium,f=(u=e.conditions)==null||(u=u.utm)==null||!u.utm_term||((c=e.conditions)==null||(c=c.utm)==null?void 0:c.utm_term)==s.utm_term;return d&&v&&f&&p}return!1}static su(e){for(var t=arguments.length,s=new Array(t>1?t-1:0),r=1;t>r;r++)s[r-1]=arguments[r];E.info("[WebExperiments] "+e,s)}ou(e,t,s){this._is_bot()?fe.su(va):t!=="control"?s.forEach((r=>{if(r.selector){var n;fe.su("applying transform of variant "+t+" for experiment "+e+" ",r);var a=(n=document)==null?void 0:n.querySelectorAll(r.selector);a?.forEach((o=>{var l=o;r.html&&(l.innerHTML=r.html),r.css&&l.setAttribute("style",r.css)}))}})):fe.su("Control variants leave the page unmodified.")}_is_bot(){return be&&this._instance?Jo(be,this.Oi.custom_blocked_useragents):void 0}}var Me=K("[Conversations]"),ht="Conversations not available yet.",pa="console",sl="__posthogHandledLogsRequestError",Ws=(i,e)=>{var t=i instanceof Error?i:new Error(e);return t[sl]=!0,t},fa=i=>!!i&&typeof i=="object"&&i[sl]===!0,vs={featureFlags:class{constructor(i){this.name="featureFlags",this.vu=!1,this.featureFlagEventHandlers=[],this.I=ua,this.cu={},this.fu={},this.pu=[],this.gu=!1,this.mu=!1,this.yu=0,this.bu=!1,this._u=!1,this.wu=!1,this.ku=!1,this.Su=0,this.Tt=()=>{var e=this.xu();this.Su=0,e&&this.reloadFeatureFlags()},"get"in i?this.Cu=i:(this.Tu=new bh(i.config,i.Js()),this.Cu=this.Tu)}updateConfig(i,e){var t;(t=this.Tu)==null||t.update(i,e)}setup(i){return this.Mu=i,this.I=i.logger.createLogger("[FeatureFlags]"),t=()=>{this.Mu===i&&(this.Mu=void 0,this.no=i,this.Eu(i))},(e=i.kv.initialize())!=null&&e.then?e.then(t):t();var e,t}Eu(i){if(this.no===i)return _&&ee(_,"online",this.Tt),this.Iu=i.registerDynamicEventProperties((()=>this.Ru()?this.cu:this.fu)),this.Pu(),this.initialize()}destroy(){_?.removeEventListener("online",this.Tt)}dispose(){var i;this.yu++,this._u=!1,this.Mu=void 0,this.no&&(this.Au(),(i=this.Iu)==null||i.dispose(),this.Iu=void 0,this.pu=[],_?.removeEventListener("online",this.Tt),this.no=void 0)}get Oi(){return this.Cu.get()}Fu(i){var e;return(e=this.no)==null?void 0:e.kv.get(i)}Or(i){this.Ou((()=>{var e;return(e=this.no)==null?void 0:e.kv.set(i)}))}Dr(i){this.Ou((()=>{var e;return(e=this.no)==null?void 0:e.kv.remove(i)}))}Ou(i){try{i()}catch(e){this.I.error("Failed to update feature flag persistence",e)}}Pu(){var i={};for(var e of[gt,_t,At,qe]){var t=this.Fu(e);w(t)||(i[e]=t)}this.cu=i;var s=y({},i),r=this.Fu(Qe);if(r)for(var n of Object.entries(r))s["$feature/"+n[0]]=n[1];this.fu=s}Ru(){var i=this.Oi.cacheTtlMs;if(!i||0>=i)return!1;var e=this.Fu(yt);return typeof e!="number"||Date.now()-e>i}Lu(){return!!this.Ru()&&(this.ku||this.mu||(this.ku=!0,this.I.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}$u(){var i=this.Oi.evaluationContexts;return i!=null&&i.length?i.filter((e=>{var t=e&&typeof e=="string"&&e.trim().length>0;return t||this.I.error("Invalid evaluation context found:",e,"Expected non-empty string"),t})):[]}Du(){var i=this.Oi.flagKeys;if(!w(i))return i.filter((e=>{var t=e&&typeof e=="string"&&e.trim().length>0;return t||this.I.error("Invalid flag key found:",e,"Expected non-empty string"),t}))}initialize(){var i,e,t=this.Oi,s=(i=(e=t.bootstrap)==null?void 0:e.featureFlags)!==null&&i!==void 0?i:{};if(Object.keys(s).length){var r,n,a=(r=(n=t.bootstrap)==null?void 0:n.featureFlagPayloads)!==null&&r!==void 0?r:{},o=Object.keys(s).filter((h=>!!s[h])).reduce(((h,u)=>(h[u]=s[u]||!1,h)),{}),l=Object.keys(a).filter((h=>o[h])).reduce(((h,u)=>(h[u]=a[u],h)),{});return this.Nu({featureFlags:o,featureFlagPayloads:l})}}updateFlags(i,e,t){var s,r,n=t!=null&&t.merge&&(s=this.Fu(Qe))!==null&&s!==void 0?s:{},a=t!=null&&t.merge&&(r=this.Fu(_t))!==null&&r!==void 0?r:{},o=y({},n,i),l=y({},a,e),h={};for(var u of Object.entries(o)){var c=u[0],d=u[1];h[c]={key:c,enabled:en(d),variant:tn(d),reason:void 0,metadata:w(l?.[c])?void 0:{id:0,version:void 0,description:void 0,payload:l[c]}}}this.Nu({flags:h})}get hasLoadedFlags(){return this.gu}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var i=this.Fu(vi),e=this.Fu(qe),t=this.Fu(dt);if(!t&&!e)return i||{};var s=W({},i||{}),r=[...new Set([...Object.keys(t||{}),...Object.keys(e||{})])];for(var n of r){var a,o,l=s[n],h=e?.[n],u=w(h)?(a=l?.enabled)!==null&&a!==void 0&&a:!!h,c=w(h)?l?.variant:typeof h=="string"?h:void 0,d=t?.[n],p=y({},l,{enabled:u,variant:u?c??l?.variant:void 0});u!==l?.enabled&&(p.original_enabled=l?.enabled),c!==l?.variant&&(p.original_variant=l?.variant),d&&(p.metadata=y({},l?.metadata,{payload:d,original_payload:l==null||(o=l.metadata)==null?void 0:o.payload})),s[n]=p}return this.vu||(this.I.warn(" Overriding feature flag details!",{flagDetails:i,overriddenPayloads:t,finalDetails:s}),this.vu=!0),s}getAllFeatureFlags(){var i=this.getFlagVariants(),e=this.getFlagPayloads();return Object.keys(i).map((t=>{var s=i[t];return{key:t,enabled:en(s),variant:tn(s),payload:Xr(e[t])}}))}getFlagVariants(){var i=this.Fu(Qe),e=this.Fu(qe);if(!e)return i||{};for(var t=W({},i||{}),s=Object.keys(e),r=0;s.length>r;r++)t[s[r]]=e[s[r]];return this.vu||(this.I.warn(" Overriding feature flags!",{enabledFlags:i,overriddenFlags:e,finalFlags:t}),this.vu=!0),t}getFlagPayloads(){var i=this.Fu(_t),e=this.Fu(dt);if(!e)return i||{};for(var t=W({},i||{}),s=Object.keys(e),r=0;s.length>r;r++)t[s[r]]=e[s[r]];return this.vu||(this.I.warn(" Overriding feature flag payloads!",{flagPayloads:i,overriddenPayloads:e,finalPayloads:t}),this.vu=!0),t}reloadFeatureFlags(){this.bu||this.Oi.featureFlagsDisabled||this.xu()||this.qu||(this.pu.slice().forEach((i=>{try{i()}catch(e){this.I.error("Error while running feature flags reloading callback",e)}})),this.qu=setTimeout((()=>{this.ju()}),5))}Au(){clearTimeout(this.qu),this.qu=void 0}onReloading(i){return this.pu.push(i),()=>{this.pu=this.pu.filter((e=>e!==i))}}ensureFlagsLoaded(){this.gu||this.mu||this.qu||this.reloadFeatureFlags()}setAnonymousDistinctId(i){this.$anon_distinct_id=i}setReloadingPaused(i){this.bu=i}resetFlagCallReported(){this.Dr(Ze)}ju(i){this.Au();var e=this.no;if(e&&!this.Oi.remoteRequestsDisabled&&!this.xu())if(this.mu)this._u=!0;else{var t={token:e.projectToken,distinct_id:e.distinctId,groups:e.groups,$anon_distinct_id:this.$anon_distinct_id,person_properties:y({},e.initialPersonProperties,this.Fu(Le)||{},{$lib:e.library.name,$lib_version:e.library.version}),group_properties:this.Fu(Ue),timezone:Ao()};w(e.deviceId)||(t.$device_id=e.deviceId),(i!=null&&i.disableFlags||this.Oi.featureFlagsDisabled)&&(t.disable_flags=!0);var s=this.$u();s.length&&(t.evaluation_contexts=s);var r=this.Du();w(r)||(t.flag_keys=r);var n=this.Oi.onlyEvaluateSurveyFeatureFlags,a="/flags/?v=2"+(n?"&only_evaluate_survey_feature_flags=true":""),o=this.yu;this.mu=!0;var l=()=>{this._u&&(this._u=!1,this.ju())},h=u=>{this.mu=!1,o===this.yu&&(this.Or({[Lt]:[ha]}),this.I.error("Feature flag request failed",u)),l()};try{e.sendRequest(a,{target:"flags",method:"POST",body:t,compression:this.Oi.compression==="base64"?ye.Base64:void 0,sentAt:"body",timeoutMs:this.Oi.requestTimeoutMs}).then((u=>{var c,d,p=(c=u.json)!==null&&c!==void 0?c:{},v=u.statusCode!==200;if(this.mu=!1,o===this.yu){if(this.Bu(u.statusCode),v||this._u||(this.$anon_distinct_id=void 0),!t.disable_flags||this._u){this.wu=!v;var f=[];u.error?f.push(u.error instanceof Error&&u.error.name==="AbortError"?"timeout":u.error instanceof Error?ha:"unknown_error"):u.statusCode!==200&&f.push("api_error_"+u.statusCode),p.errorsWhileComputingFlags&&f.push("errors_while_computing_flags");var g=!((d=p.quotaLimited)==null||!d.includes("feature_flags"));g&&f.push("quota_limited"),this.Or({[Lt]:f}),g?this.I.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."):t.disable_flags||this.Nu(p,v,{partialResponse:n}),l()}}else l()})).catch(h)}catch(u){h(u)}}}xu(){return Io(this.Su,3)}Bu(i){this.Su=Oo(i,this.Su,3,(()=>this.I.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(i,e){var t;if(e===void 0&&(e={}),!e.fresh||this.wu)if(this.gu||this.getFlags()&&this.getFlags().length>0){if(!this.Lu()){var s=this.getFeatureFlagResult(i,e);return(t=s?.variant)!==null&&t!==void 0?t:s?.enabled}}else this.I.warn('getFeatureFlag for key "'+i+Gs)}getFeatureFlagDetails(i){return this.getFlagsWithDetails()[i]}getFeatureFlagPayload(i){var e=this.getFeatureFlagResult(i,{send_event:!1});return e?.payload}getFeatureFlagResult(i,e){if(e===void 0&&(e={}),!e.fresh||this.wu)if(this.gu||this.getFlags()&&this.getFlags().length>0){if(!this.Lu()){var t,s=this.getFlagVariants(),r=i in s,n=s[i],a=this.getFlagPayloads()[i],o=String(n),l=this.Fu(At)||void 0,h=this.Fu(yt)||void 0,u=this.Fu(Ze)||{};if(this.Oi.deduplicateCallsPerSession){var c,d=(c=this.no)==null?void 0:c.session.sessionId,p=this.Fu(ri);d&&d!==p&&(u={},t=d)}if(e.send_event||!("send_event"in e))if(i in u&&u[i].includes(o))t&&this.Or({[Ze]:u,[ri]:t});else{var v,f,g,m,b,k,P,x,C,N,I,F;A(u[i])?u[i].push(o):u[i]=[o],this.Or(y({[Ze]:u},t?{[ri]:t}:{}));var O=this.getFeatureFlagDetails(i),M=[...(v=this.Fu(Lt))!==null&&v!==void 0?v:[]];w(n)&&M.push("flag_missing");var T={$feature_flag:i,$feature_flag_response:n,$feature_flag_payload:a??null,$feature_flag_request_id:l,$feature_flag_evaluated_at:h,$feature_flag_bootstrapped_response:(f=(g=this.Oi.bootstrap)==null||(g=g.featureFlags)==null?void 0:g[i])!==null&&f!==void 0?f:null,$feature_flag_bootstrapped_payload:(m=(b=this.Oi.bootstrap)==null||(b=b.featureFlagPayloads)==null?void 0:b[i])!==null&&m!==void 0?m:null,$used_bootstrap_value:!this.wu};w(O==null||(k=O.metadata)==null?void 0:k.has_experiment)||(T.$feature_flag_has_experiment=O.metadata.has_experiment),w(O==null||(P=O.metadata)==null?void 0:P.version)||(T.$feature_flag_version=O.metadata.version);var R,H=(x=O==null||(C=O.reason)==null?void 0:C.description)!==null&&x!==void 0?x:O==null||(N=O.reason)==null?void 0:N.code;H&&(T.$feature_flag_reason=H),O!=null&&(I=O.metadata)!=null&&I.id&&(T.$feature_flag_id=O.metadata.id),w(O?.original_variant)&&w(O?.original_enabled)||(T.$feature_flag_original_response=w(O.original_variant)?O.original_enabled:O.original_variant),O!=null&&(F=O.metadata)!=null&&F.original_payload&&(T.$feature_flag_original_payload=O==null||(R=O.metadata)==null?void 0:R.original_payload),M.length&&(T.$feature_flag_error=M.join(",")),this.Hu(T)}else t&&this.Or({[Ze]:u,[ri]:t});if(r)return{key:i,enabled:!!n,variant:typeof n=="string"?n:void 0,payload:Xr(a)}}}else this.I.warn('getFeatureFlagResult for key "'+i+Gs)}Hu(i){try{var e;(e=this.no)==null||e.capture("$feature_flag_called",i).catch((t=>{this.I.error("Failed to capture feature flag call",t)}))}catch(t){this.I.error("Failed to capture feature flag call",t)}}getRemoteConfigPayload(i,e){this.zu(i,e)}zu(i,e){var t=this;return Q((function*(){var s=t.no;if(s){var r={distinct_id:s.distinctId,token:s.projectToken,person_properties:{$lib:s.library.name,$lib_version:s.library.version}},n=t.$u();n.length&&(r.evaluation_contexts=n);var a,o=t.Du();w(o)||(r.flag_keys=o);try{var l,h=(l=(yield s.sendRequest("/flags/?v=2",{target:"flags",method:"POST",body:r,compression:t.Oi.compression==="base64"?ye.Base64:void 0,sentAt:"body",timeoutMs:t.Oi.requestTimeoutMs})).json)==null?void 0:l.featureFlagPayloads;a=h?.[i]||void 0}catch(u){return void t.I.error("Remote config feature flag request failed",u)}try{e(a)}catch(u){t.I.error("Remote config feature flag callback failed",u)}}}))()}isFeatureEnabled(i,e){if(e===void 0&&(e={}),e.fresh&&!this.wu)return e.defaultValue;if(!(this.gu||this.getFlags()&&this.getFlags().length>0))return this.I.warn('isFeatureEnabled for key "'+i+Gs),e.defaultValue;var t=this.getFeatureFlag(i,e);return w(t)?e.defaultValue:!!t}addFeatureFlagsHandler(i){this.featureFlagEventHandlers.push(i)}removeFeatureFlagsHandler(i){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((e=>e!==i))}receivedFeatureFlags(i,e,t){this.Nu(i,e,t)}Nu(i,e,t){if(this.no){this.gu=!0;var s=(function(r,n,a,o,l,h){n===void 0&&(n={}),a===void 0&&(a={}),o===void 0&&(o={}),h===void 0&&(h=ua);var u=((C,N)=>{var I=C.flags;return I?y({},C,{featureFlags:Object.fromEntries(Object.keys(I).map((F=>{var O;return[F,(O=I[F].variant)!==null&&O!==void 0?O:I[F].enabled]}))),featureFlagPayloads:Object.fromEntries(Object.keys(I).filter((F=>I[F].enabled)).filter((F=>{var O;return(O=I[F].metadata)==null?void 0:O.payload})).map((F=>{var O;return[F,(O=I[F].metadata)==null?void 0:O.payload]})))}):(C.featureFlags&&N.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),C)})(r,h),c=u.flags,d=u.featureFlags,p=u.featureFlagPayloads;if(d){var v=r.requestId,f=r.evaluatedAt;if(A(d)){h.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var g={};if(d)for(var m=0;d.length>m;m++)g[d[m]]=!0;return{[gt]:d,[Qe]:g,[Yi]:!1}}var b=d,k=p,P=c;if(l!=null&&l.partialResponse)b=y({},n,b),k=y({},a,k),P=y({},o,P);else if(r.errorsWhileComputingFlags)if(c){var x=new Set(Object.keys(c).filter((C=>{var N;return!((N=c[C])!=null&&N.failed)})));b=y({},n,Object.fromEntries(Object.entries(b).filter((C=>x.has(C[0]))))),k=y({},a,Object.fromEntries(Object.entries(k||{}).filter((C=>x.has(C[0]))))),P=y({},o,Object.fromEntries(Object.entries(P||{}).filter((C=>x.has(C[0])))))}else b=y({},n,b),k=y({},a,k),P=y({},o,P);return y({[gt]:Object.keys(da(b)),[Qe]:b||{},[_t]:k||{},[vi]:P||{},[Yi]:r.minimalFlagCalledEvents===!0},v?{[At]:v}:{},f?{[yt]:f}:{})}})(i,this.getFlagVariants(),this.getFlagPayloads(),this.getFlagsWithDetails(),t,this.I);s&&this.Or(s),e||(this.ku=!1),this.Uu(e)}}override(i,e){e===void 0&&(e=!1),this.I.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:i,suppressWarning:e})}overrideFeatureFlags(i){this.Wu(i)}Wu(i){if(this.no){if(i===!1)return this.Dr([qe,dt]),this.Uu(),void ut.info("All overrides cleared");if(A(i))return this.Or({[qe]:ca(i)}),this.Uu(),void ut.info("Flag overrides set",{flags:i});if(i&&typeof i=="object"&&("flags"in i||"payloads"in i)){var e,t=i;this.vu=!!((e=t.suppressWarning)!==null&&e!==void 0&&e);var s={},r=t.flags,n=t.payloads;return r&&(s[qe]=A(r)?ca(r):r),n&&(s[dt]=n),Object.keys(s).length&&this.Or(s),r===!1&&n===!1?this.Dr([qe,dt]):r===!1?this.Dr(qe):n===!1&&this.Dr(dt),this.Uu(),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(i&&typeof i=="object")return this.Or({[qe]:i}),this.Uu(),void ut.info("Flag overrides set",{flags:i});this.I.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:i})}else this.I.warn("posthog.featureFlags.overrideFeatureFlags called before feature flags were ready")}onFeatureFlags(i){if(this.addFeatureFlagsHandler(i),this.gu){var e=this.Vu(),t=e.flags,s=e.flagVariants;try{i(t,s)}catch(r){this.I.error("Error while running feature flags callback",r)}}return()=>this.removeFeatureFlagsHandler(i)}updateEarlyAccessFeatureEnrollment(i,e,t){var s=(this.Fu($i)||[]).find((l=>l.flagKey===i)),r={["$feature_enrollment/"+i]:e},n={$feature_flag:i,$feature_enrollment:e,$set:r};s&&(n.$early_access_feature_name=s.name),t&&(n.$feature_enrollment_stage=t);var a=y({},this.getFlagVariants(),{[i]:e});this.Or({[gt]:Object.keys(da(a)),[Qe]:a,[Le]:y({},this.Fu(Le)||{},r)}),this.Uu();try{var o;(o=this.no)==null||o.capture("$feature_enrollment_update",n).catch((l=>{this.I.error("Failed to capture early access feature enrollment",l)}))}catch(l){this.I.error("Failed to capture early access feature enrollment",l)}}getEarlyAccessFeatures(i,e,t){e===void 0&&(e=!1);var s=this.Fu($i);!s||e?this.Gu(i,t):i(s)}Gu(i,e){var t=this;return Q((function*(){var s=t.no;if(s){var r,n=e?"&"+e.map((o=>"stage="+o)).join("&"):"";try{var a=yield s.sendRequest("/api/early_access_features/?token="+s.projectToken+n,{target:"api",method:"GET",sentAt:"query"});if(!a.json)return;t.Or({[$i]:r=a.json.earlyAccessFeatures})}catch(o){return void t.I.error("Early access feature request failed",o)}try{i(r)}catch(o){t.I.error("Early access feature callback failed",o)}}}))()}Vu(){var i=this.getFlags(),e=this.getFlagVariants();return{flags:i.filter((t=>e[t])),flagVariants:Object.keys(e).filter((t=>e[t])).reduce(((t,s)=>(t[s]=e[s],t)),{})}}Uu(i){this.Pu();var e=this.Vu(),t=e.flags,s=e.flagVariants;this.featureFlagEventHandlers.forEach((r=>{try{r(t,s,{errorsLoading:i})}catch(n){this.I.error("Error while running feature flags callback",n)}}))}setPersonPropertiesForFlags(i,e){e===void 0&&(e=!0),this.Zu(i,e)}Zu(i,e){e===void 0&&(e=!0);var t=this.Fu(Le)||{},s=i?.$set||(i!=null&&i.$set_once?{}:i),r=i?.$set_once,n={};if(r)for(var a in r)({}).hasOwnProperty.call(r,a)&&(a in t||(n[a]=r[a]));this.Or({[Le]:y({},t,n,s)}),e&&this.reloadFeatureFlags()}unsetPersonPropertiesForFlags(i,e){e===void 0&&(e=!0);var t=y({},this.Fu(Le)||{});i.forEach((s=>{delete t[s]})),this.Or({[Le]:t}),e&&this.reloadFeatureFlags()}resetPersonPropertiesForFlags(i){i===void 0&&(i=!0),this.Dr(Le),i&&this.reloadFeatureFlags()}setGroupPropertiesForFlags(i,e){e===void 0&&(e=!0);var t=this.Fu(Ue)||{},s=y({},t);for(var r of Object.keys(i))s[r]=y({},t[r],i[r]);this.Or({[Ue]:s}),e&&this.reloadFeatureFlags()}resetGroupPropertiesForFlags(i){if(i){var e=this.Fu(Ue)||{};this.Or({[Ue]:y({},e,{[i]:{}})})}else this.Dr(Ue)}reset(){this.yu++,this._u=!1,this.cu={},this.fu={},this.gu=!1,this.bu=!1,this.wu=!1,this.$anon_distinct_id=void 0,this.Au(),this.vu=!1,this.Su=0}}},kh={sessionRecording:class{get Oi(){return this._instance.config}get Sa(){return this._instance.persistence}get started(){var i;return!((i=this.Qu)==null||!i.isStarted)}get status(){var i,e;return this.Ju===ei||this.Ju===Fi?this.Ju:(i=(e=this.Qu)==null?void 0:e.status)!==null&&i!==void 0?i:this.Ju}constructor(i){if(this._forceAllowLocalhostNetworkCapture=!1,this.Ju=ia,this.Ku=void 0,this.Yu=!1,this.kt=(()=>{var e;if(S==null||!S.visibilityState||S.visibilityState==="visible")return!0;var t=_==null||(e=_.performance)==null||e.getEntriesByType==null?void 0:e.getEntriesByType("visibility-state");return!(t!=null&&t.length)||t.some((s=>s.name==="visible"))})(),this.It=()=>{var e;S?.visibilityState==="visible"&&(this.kt=!0,(e=this.Qu)==null||e.setDocumentWasEverVisible==null||e.setDocumentWasEverVisible(!0))},this._instance=i,!this._instance.sessionManager)throw We.error("started without valid sessionManager"),new Error(Fr+" started without valid sessionManager. This is a bug.");if(this.Oi.cookieless_mode===Ke)throw new Error(Fr+' cannot be used with cookieless_mode="always"');S!=null&&S.addEventListener&&ee(S,"visibilitychange",this.It)}initialize(){this.startIfEnabledOrStop()}dispose(){this.Yu=!0,S==null||S.removeEventListener==null||S.removeEventListener("visibilitychange",this.It),this.stopRecording()}get Xu(){var i,e=!((i=this._instance.get_property(ft))==null||!i.enabled),t=!this.Oi.disable_session_recording,s=this.Oi.disable_session_recording||this._instance.consent.isOptedOut();return _&&e&&t&&!s}startIfEnabledOrStop(i){var e;if(!(this.Yu||this.Xu&&(e=this.Qu)!=null&&e.isStarted)){var t=!w(Object.assign)&&!w(Array.from);this.Xu&&t?(this.th(i),We.info("starting")):(this.Ju=ia,this.stopRecording())}}th(i){var e,t,s;this.Xu&&(this.Ju!==ei&&this.Ju!==Fi&&(this.Ju=sa),$!=null&&(e=$.__PosthogExtensions__)!=null&&(e=e.rrweb)!=null&&e.record&&(t=$.__PosthogExtensions__)!=null&&t.initSessionRecording?this.eh(i):(s=$.__PosthogExtensions__)==null||s.loadExternalDependency==null||s.loadExternalDependency(this._instance,this.ih,(r=>{if(r)return this._instance.register_for_session({[_r]:!0}),We.error("could not load recorder",r);this.eh(i)})))}stopRecording(){var i,e;(i=this.Ku)==null||i.call(this),this.Ku=void 0,(e=this.Qu)==null||e.stop()}rh(){var i,e;(i=this.Ku)==null||i.call(this),this.Ku=void 0,(e=this.Qu)==null||e.discard()}nh(){var i,e;(i=this.Sa)==null||i.unregister(Hr),(e=this.Sa)==null||e.unregister(to)}sh(i,e){if(D(i))return null;var t,s=oe(i)?i:parseFloat(i);return typeof(t=s)!="number"||!Number.isFinite(t)||0>t||t>1?(We.warn(e+" must be between 0 and 1. Ignoring invalid value:",i),null):s}ah(i){if(this.Sa){var e,t,s=this.Sa,r=()=>{var n,a=i.sessionRecording===!1?void 0:i.sessionRecording,o=this.sh((n=this.Oi.session_recording)==null?void 0:n.sampleRate,"session_recording.sampleRate"),l=this.sh(a?.sampleRate,"remote config sampleRate"),h=o??l;D(h)&&this.nh();var u=a?.minimumDurationMilliseconds;s.register({[ft]:y({cache_timestamp:Date.now(),enabled:!!a},a,{networkPayloadCapture:y({capturePerformance:i.capturePerformance},a?.networkPayloadCapture),canvasRecording:{enabled:a?.recordCanvas,fps:a?.canvasFps,quality:a?.canvasQuality},sampleRate:h,minimumDurationMilliseconds:w(u)?null:u,endpoint:a?.endpoint,triggerMatchType:a?.triggerMatchType,masking:a?.masking,urlTriggers:a?.urlTriggers,version:a?.version,triggerGroups:a?.triggerGroups})})};r(),(e=this.Ku)==null||e.call(this),this.Ku=(t=this._instance.sessionManager)==null?void 0:t.onSessionId(r)}}onRemoteConfig(i){var e=i.ok?i.config:void 0;return e&&"sessionRecording"in e?e.sessionRecording===!1?(this.ah(e),void this.rh()):(this.ah(e),void this.startIfEnabledOrStop()):(this.Ju===ei&&(this.Ju=Fi,We.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(i,e){var t;e===void 0&&(e="log"),(t=this.Qu)!=null&&t.log?this.Qu.log(i,e):We.warn("log called before recorder was ready")}get ih(){var i,e,t=(i=this._instance)==null||(i=i.persistence)==null?void 0:i.get_property(ft);return(t==null||(e=t.scriptConfig)==null?void 0:e.script)||"lazy-recorder"}oh(){var i,e=this._instance.get_property(ft);if(!e)return!1;try{i=typeof e=="object"?e:JSON.parse(e)}catch(t){return We.warn("persisted remote config for session recording is invalid and will be ignored",t),!1}return!D(i.cache_timestamp)&&36e5>=Date.now()-i.cache_timestamp}eh(i){var e,t,s;if(!this.Yu){if((e=$.__PosthogExtensions__)==null||!e.initSessionRecording)return We.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[_r]:!0});var r;if(this.Qu||(this.Qu=(r=$.__PosthogExtensions__)==null?void 0:r.initSessionRecording(this._instance,this.kt),this.Qu._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.oh())return this.Ju===Fi||this.Ju===ei?void 0:(this.Ju=ei,We.info("persisted remote config is stale, requesting fresh config before starting"),void new Lo(this._instance).load());this.Ju=sa,(t=(s=this.Qu).setDocumentWasEverVisible)==null||t.call(s,this.kt),this.Qu.start(i)}}onRRwebEmit(i){var e;(e=this.Qu)==null||e.onRRwebEmit==null||e.onRRwebEmit(i)}overrideLinkedFlag(){var i,e;this.Qu||(e=this.Sa)==null||e.register({[so]:!0}),(i=this.Qu)==null||i.overrideLinkedFlag()}overrideSampling(){var i,e;this.Qu||(e=this.Sa)==null||e.register({[io]:!0}),(i=this.Qu)==null||i.overrideSampling()}overrideTrigger(i){var e,t;this.Qu||(t=this.Sa)==null||t.register({[i==="url"?ro:no]:!0}),(e=this.Qu)==null||e.overrideTrigger(i)}get sdkDebugProperties(){var i;return((i=this.Qu)==null?void 0:i.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(i,e){var t;return!((t=this.Qu)==null||!t.tryAddCustomEvent(i,e))}}},Eh={autocapture:class{constructor(i){this.lh=!1,this.uh=null,this.hh=!1,this.dh=!1,this.instance=i,this.rageclicks=new Xn(i.config.rageclick),this.fh=null}initialize(){this.startIfEnabled()}get Oi(){var i,e,t=Z(this.instance.config.autocapture)?this.instance.config.autocapture:{};return t.url_allowlist=(i=t.url_allowlist)==null?void 0:i.map((s=>new RegExp(s))),t.url_ignorelist=(e=t.url_ignorelist)==null?void 0:e.map((s=>new RegExp(s))),t}ph(){if(this.isBrowserSupported()){if(_&&S){var i=t=>{t=t||_?.event;try{this.gh(t)}catch(s){Bs.error("Failed to capture event",s)}};if(ee(S,"submit",i,{capture:!0}),ee(S,"change",i,{capture:!0}),ee(S,"click",i,{capture:!0}),this.Oi.capture_copied_text){var e=t=>{t=t||_?.event;try{this.gh(t,qs)}catch(s){Bs.error("Failed to capture copy/cut event",s)}};ee(S,"copy",e,{capture:!0}),ee(S,"cut",e,{capture:!0})}}}else Bs.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this.lh&&(this.ph(),this.lh=!0)}onRemoteConfig(i){if(this.hh=!0,i.ok){var e=i.config;e.elementsChainAsString&&(this.dh=e.elementsChainAsString);var t=e.autocapture_opt_out;Oe(t)&&(this.instance.persistence&&this.instance.persistence.register({[rr]:t}),this.uh=t),this.startIfEnabled()}else this.startIfEnabled()}setElementSelectors(i){this.fh=i}getElementSelectors(i){var e,t=[];return(e=this.fh)==null||e.forEach((s=>{var r=S?.querySelectorAll(s);r?.forEach((n=>{i===n&&t.push(s)}))})),t}get isEnabled(){var i,e,t=(i=this.instance.persistence)==null?void 0:i.props[rr],s=this.uh,r=this.instance.Js()&&!this.hh;if(de(s)&&!Oe(t)&&!r)return!1;var n=(e=this.uh)!==null&&e!==void 0?e:!!t;return!!this.instance.config.autocapture&&!n}gh(i,e){if(e===void 0&&(e="$autocapture"),this.isEnabled){var t,s=Fs(i);go(s)&&(s=s.parentNode||null),e==="$autocapture"&&i.type==="click"&&i instanceof MouseEvent&&this.instance.config.rageclick&&(t=this.rageclicks)!=null&&t.isRageClick(i.clientX,i.clientY,i.timeStamp||new Date().getTime())&&In(s,this.instance.config.rageclick)&&this.gh(i,"$rageclick");var r=e===qs;if(s&&(function(c,d,p,v,f,g){var m;if(!_||zr(c)||p!=null&&p.url_allowlist&&!En(p.url_allowlist,g)||p!=null&&p.url_ignorelist&&En(p.url_ignorelist,g))return!1;if(p!=null&&p.dom_event_allowlist){var b=p.dom_event_allowlist;if(b&&!b.some((I=>d.type===I)))return!1}var k=xo(c,v),P=k.parentIsUsefulElement,x=k.targetElementList;if(!(function(I,F){var O=F?.element_allowlist;if(w(O))return!0;var M,T=function(H){if(O.some((V=>H.tagName.toLowerCase()===V)))return{v:!0}};for(var R of I)if(M=T(R))return M.v;return!1})(x,p)||!br(x,p?.css_selector_allowlist)||br(x,(m=p?.css_selector_ignorelist)!==null&&m!==void 0?m:yu))return!1;try{var C=_.getComputedStyle(c);if(C&&C.getPropertyValue("cursor")==="pointer"&&d.type==="click")return!0}catch{}var N=c.tagName.toLowerCase();switch(N){case"html":return!1;case"form":return(f||["submit"]).indexOf(d.type)>=0;case"input":case"select":case"textarea":return(f||["change","click"]).indexOf(d.type)>=0;default:return P?(f||["click"]).indexOf(d.type)>=0:(f||["click"]).indexOf(d.type)>=0&&(Ur.indexOf(N)>-1||c.getAttribute("contenteditable")==="true")}})(s,i,this.Oi,r,r?["copy","cut"]:void 0,this.instance)){var n=dh(s,{e:i,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.Oi.element_attribute_ignorelist,elementsChainAsString:this.dh,disableCaptureUrlHashes:this.instance.config.disable_capture_url_hashes}),a=n.props;if(n.explicitNoCapture)return!1;var o=this.getElementSelectors(s);if(o&&o.length>0&&(a.$element_selectors=o),e===qs){var l,h=yo(_==null||(l=_.getSelection())==null?void 0:l.toString()),u=i.type||"clipboard";if(!h)return!1;a.$selected_content=h,a.$copy_type=u}return this.instance.capture(e,a),!0}}}isBrowserSupported(){return me(S?.querySelectorAll)}},historyAutocapture:class{constructor(i){var e;this._instance=i,this.mh=(_==null||(e=_.location)==null?void 0:e.pathname)||""}initialize(){this.startIfEnabled()}get isEnabled(){return this._instance.config.capture_pageview==="history_change"}startIfEnabled(){this.isEnabled&&(E.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this.yh&&this.yh(),this.yh=void 0,E.info("History API monitoring stopped")}monitorHistoryChanges(){_&&_.history&&(this.bh("pushState"),this.bh("replaceState"),this._h())}bh(i){var e;if(_&&((e=_.history[i])==null||!e.__posthog_wrapped__)){var t=this;(function(s,r,n){try{if(!(r in s))return ea;var a={next:s[r]},o=n((function(){for(var l=arguments.length,h=new Array(l),u=0;l>u;u++)h[u]=arguments[u];return a.next.apply(this,h)}));return me(o)&&(o.prototype=o.prototype||{},Object.defineProperties(o,{__posthog_wrapped__:{enumerable:!1,value:!0},__posthog_layer__:{enumerable:!1,value:a}})),s[r]=o,()=>{if(s[r]!==o)for(var l=s[r];me(l)&&l.__posthog_layer__;){var h=l.__posthog_layer__;if(h.next===o)return void(h.next=a.next);l=h.next}else s[r]=a.next}}catch{return ea}})(_.history,i,(s=>function(r,n,a){s.call(this,r,n,a),t.wh(i)}))}}wh(i){try{var e,t=_==null||(e=_.location)==null?void 0:e.pathname;if(!t)return;t!==this.mh&&this.isEnabled&&this._instance.capture(It,{navigation_type:i}),this.mh=t}catch(s){E.error("Error capturing "+i+" pageview",s)}}_h(){if(!this.yh){var i=()=>{this.wh("popstate")};ee(_,"popstate",i),this.yh=()=>{_&&_.removeEventListener("popstate",i)}}}},heatmaps:class{get Oi(){return this.instance.config}constructor(i){var e;this.kh=!1,this.lh=!1,this.Sh=null,this.instance=i,this.kh=!((e=this.instance.persistence)==null||!e.props[nr]),this.rageclicks=new Xn(i.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var i=5e3;return Z(this.Oi.capture_heatmaps)&&this.Oi.capture_heatmaps.flush_interval_milliseconds&&(i=this.Oi.capture_heatmaps.flush_interval_milliseconds),i}get isEnabled(){return D(this.Oi.capture_heatmaps)?D(this.Oi.enable_heatmaps)?this.kh:this.Oi.enable_heatmaps:this.Oi.capture_heatmaps!==!1}startIfEnabled(){if(this.isEnabled){if(this.lh)return;ph.info("starting..."),this.xh(),this.It()}else{var i;clearInterval((i=this.Sh)!==null&&i!==void 0?i:void 0),this.Ch(),this.getAndClearBuffer()}}onRemoteConfig(i){if(i.ok){var e=i.config;if("heatmaps"in e){var t=!!e.heatmaps;this.instance.persistence&&this.instance.persistence.register({[nr]:t}),this.kh=t,this.startIfEnabled()}}}getAndClearBuffer(){var i=this.ft;return this.ft=void 0,i}Th(i){Us(i.originalEvent)&&this.mi(i.originalEvent,"deadclick")}It(){this.Sh&&clearInterval(this.Sh),this.Sh=S?.visibilityState==="visible"?setInterval(this.ca.bind(this),this.flushIntervalMilliseconds):null}xh(){_&&S&&(this.Mh=this.ca.bind(this),ee(_,es,this.Mh),this.Eh=i=>this.mi(i||_?.event),ee(S,"click",this.Eh,{capture:!0}),this.Ih=i=>this.Rh(i||_?.event),ee(S,"mousemove",this.Ih,{capture:!0}),this.Ph=new Rn(this.instance,Pu,this.Th.bind(this)),this.Ph.startIfEnabledOrStop(),this.Ah=this.It.bind(this),ee(S,Xi,this.Ah),this.lh=!0)}Ch(){var i;_&&S&&(this.Mh&&_.removeEventListener(es,this.Mh),this.Eh&&S.removeEventListener("click",this.Eh,{capture:!0}),this.Ih&&S.removeEventListener("mousemove",this.Ih,{capture:!0}),this.Ah&&S.removeEventListener(Xi,this.Ah),clearTimeout(this.Fh),(i=this.Ph)==null||i.stop(),this.lh=!1)}Oh(i,e){var t=this.instance.scrollManager.scrollY(),s=this.instance.scrollManager.scrollX(),r=this.instance.scrollManager.scrollElement(),n=(function(a,o,l){for(var h=a;h&&nt(h)&&!Fe(h,"body");){if(h===l)return!1;var u=void 0;try{var c,d,p;u=(c=(d=(p=h.ownerDocument)==null?void 0:p.defaultView)!==null&&d!==void 0?d:_)==null?void 0:c.getComputedStyle(h).position}catch{return!1}if(L(o,u))return!0;h=bo(h)}return!1})(Fs(i),["fixed","sticky"],r);return{x:i.clientX+(n?0:s),y:i.clientY+(n?0:t),target_fixed:n,type:e}}mi(i,e){var t;if(e===void 0&&(e="click"),!kn(i.target)&&Us(i)){var s=this.Oh(i,e);(t=this.rageclicks)!=null&&t.isRageClick(i.clientX,i.clientY,new Date().getTime())&&In(Fs(i),this.instance.config.rageclick)&&this.Fn(y({},s,{type:"rageclick"})),this.Fn(s)}}Rh(i){!kn(i.target)&&Us(i)&&(clearTimeout(this.Fh),this.Fh=setTimeout((()=>{this.Fn(this.Oh(i,"mousemove"))}),500))}Fn(i){if(_){var e=this.Oi.disable_capture_url_hashes?rt(_.location.href):_.location.href,t=this.Oi.custom_personal_data_properties,s=this.Oi.mask_personal_data_properties?[...Bt,...t||[]]:[],r=fi(e,s,gi);this.ft=this.ft||{},this.ft[r]||(this.ft[r]=[]),this.ft[r].push(i)}}ca(){this.ft&&!De(this.ft)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:Rn,webVitalsAutocapture:class{constructor(i){var e;this.kh=!1,this.lh=!1,this.ft={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this.Lh=()=>{clearTimeout(this.$h),this.$h=void 0,this.ft.metrics.length!==0&&(this._instance.capture("$web_vitals",y({$current_url:this.ft.url},this.ft.metrics.reduce(((t,s)=>y({},t,{["$web_vitals_"+s.name+"_event"]:y({},s),["$web_vitals_"+s.name+"_value"]:s.value})),{}))),this.ft={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.Dh=t=>{var s;if(this.ft=this.ft||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},D(t?.name)||D(t?.value))lt.error("Invalid metric received",t);else{var r=typeof t.navigationURL=="string"?t.navigationURL:void 0,n=this.Nh(r);if(!w(n)){var a=oe(t.navigationId)||typeof t.navigationId=="string"?"navigation:"+t.navigationId:"url:"+n;if(!this.qh||this.qh>t.value){this.ft.navigationKey!==a&&(this.Lh(),this.$h=setTimeout(this.Lh,this.flushToCaptureTimeoutMs)),w(this.ft.navigationKey)&&(this.ft.navigationKey=a,this.ft.url=n),this.ft.firstMetricTimestamp=w(this.ft.firstMetricTimestamp)?Date.now():this.ft.firstMetricTimestamp,t.attribution&&t.attribution.interactionTargetElement&&(t.attribution.interactionTargetElement=void 0);var o=(s=this._instance.sessionManager)==null?void 0:s.checkAndGetSessionAndWindowId(!0),l=y({},t,r?{navigationURL:n}:{},{$current_url:n,timestamp:Date.now()});w(o)||(l.$session_id=o.sessionId,l.$window_id=o.windowId),this.ft.metrics.push(l),this.ft.metrics.length===this.allowedMetrics.length&&this.Lh()}else lt.error("Ignoring metric with value >= "+this.qh,t)}}},this.jh=()=>{if(!this.lh){var t,s,r,n,a=$.__PosthogExtensions__,o=a?.postHogWebVitalsCallbacksByFlavor,l=o?.[this.Bh]||(this.Bh==="web-vitals"&&w(o)?a?.postHogWebVitalsCallbacks:void 0);if(w(l)||(t=l.onLCP,s=l.onCLS,r=l.onFCP,n=l.onINP),t&&s&&r&&n){var h={reportSoftNavs:this.useSoftNavs};this.allowedMetrics.indexOf("LCP")>-1&&t(this.Dh.bind(this),h),this.allowedMetrics.indexOf("CLS")>-1&&s(this.Dh.bind(this),h),this.allowedMetrics.indexOf("FCP")>-1&&r(this.Dh.bind(this),h),this.allowedMetrics.indexOf("INP")>-1&&n(this.Dh.bind(this),h),this.lh=!0}else lt.error("web vitals callbacks not loaded - not starting")}},this._instance=i,this.kh=!((e=this._instance.persistence)==null||!e.props[ur]),this.startIfEnabled()}get Hh(){return this._instance.config.capture_performance}get allowedMetrics(){var i,e,t=Z(this.Hh)?(i=this.Hh)==null?void 0:i.web_vitals_allowed_metrics:void 0;return D(t)?((e=this._instance.persistence)==null?void 0:e.props[hr])||["CLS","FCP","INP","LCP"]:t}get flushToCaptureTimeoutMs(){return(Z(this.Hh)?this.Hh.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var i=Z(this.Hh)?this.Hh.web_vitals_attribution:void 0;return i!=null&&i}get useSoftNavs(){var i=Z(this.Hh)?this.Hh.__preview_web_vitals_soft_navs:void 0;return i!=null&&i}get qh(){var i=Z(this.Hh)&&oe(this.Hh.__web_vitals_max_value)?this.Hh.__web_vitals_max_value:ta;return i>0&&6e4>=i?ta:i}get isEnabled(){var i=X?.protocol;if(i!=="http:"&&i!=="https:")return lt.info("Web Vitals are disabled on non-http/https protocols"),!1;var e=Z(this.Hh)?this.Hh.web_vitals:Oe(this.Hh)?this.Hh:void 0;return Oe(e)?e:this.kh}startIfEnabled(){this.isEnabled&&!this.lh&&(lt.info("enabled, starting..."),this.Jn(this.jh))}onRemoteConfig(i){if(i.ok){var e=i.config;if("capturePerformance"in e){var t=Z(e.capturePerformance)&&!!e.capturePerformance.web_vitals,s=Z(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[ur]:t}),this._instance.persistence.register({[hr]:s})),this.kh=t,this.startIfEnabled()}}}get Bh(){return this.useSoftNavs?this.useAttribution?"web-vitals-with-attribution-soft-navs":"web-vitals-soft-navs":this.useAttribution?"web-vitals-with-attribution":"web-vitals"}Jn(i){var e=$.__PosthogExtensions__,t=this.Bh,s=e?.postHogWebVitalsCallbacksByFlavor;s!=null&&s[t]||t==="web-vitals"&&w(s)&&e!=null&&e.postHogWebVitalsCallbacks?i():e==null||e.loadExternalDependency==null||e.loadExternalDependency(this._instance,t,(r=>{r?lt.error("failed to load script",r):i()}))}Nh(i){var e=i||_?.location.href;if(e){var t=this._instance.config.disable_capture_url_hashes?rt(e):e,s=this._instance.config.custom_personal_data_properties,r=this._instance.config.mask_personal_data_properties?[...Bt,...s||[]]:[];return fi(t,r,gi)}lt.error("Could not determine current URL")}}},Sh={exceptionObserver:class{constructor(i){var e;this.jh=()=>{var t;if(_&&this.isEnabled&&(t=$.__PosthogExtensions__)!=null&&t.errorWrappingFunctions){var s=$.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,r=$.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,n=$.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.zh&&this.Oi.capture_unhandled_errors&&(this.zh=s(this.captureException.bind(this))),!this.Uh&&this.Oi.capture_unhandled_rejections&&(this.Uh=r(this.captureException.bind(this))),!this.Wh&&this.Oi.capture_console_errors&&(this.Wh=n(this.captureException.bind(this)))}catch(a){Xt.error("failed to start",a),this.Vh()}}},this._instance=i,this.Gh=!((e=this._instance.persistence)==null||!e.props[ar]),this.oe=new yl(y({},(function(t){var s,r,n,a;return t===void 0&&(t={}),{refillRate:(s=(r=t.exceptionRateLimiterRefillRate)!==null&&r!==void 0?r:t.__exceptionRateLimiterRefillRate)!==null&&s!==void 0?s:1,bucketSize:(n=(a=t.exceptionRateLimiterBucketSize)!==null&&a!==void 0?a:t.__exceptionRateLimiterBucketSize)!==null&&n!==void 0?n:10}})(this._instance.config.error_tracking),{refillInterval:1e4,I:Xt})),this.Oi=this.Zh(),this.startIfEnabledOrStop()}Zh(){var i=this._instance.config.capture_exceptions,e={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return Z(i)?e=y({},e,i):(w(i)?this.Gh:i)&&(e=y({},e,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),e}get isEnabled(){return this.Oi.capture_console_errors||this.Oi.capture_unhandled_errors||this.Oi.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(Xt.info("enabled"),this.Vh(),this.Jn(this.jh)):this.Vh()}Jn(i){var e,t;(e=$.__PosthogExtensions__)!=null&&e.errorWrappingFunctions?i():(t=$.__PosthogExtensions__)==null||t.loadExternalDependency==null||t.loadExternalDependency(this._instance,"exception-autocapture",(s=>{if(s)return Xt.error("failed to load script",s);i()}))}Vh(){var i,e,t;(i=this.zh)==null||i.call(this),this.zh=void 0,(e=this.Uh)==null||e.call(this),this.Uh=void 0,(t=this.Wh)==null||t.call(this),this.Wh=void 0}onRemoteConfig(i){if(i.ok){var e=i.config;"autocaptureExceptions"in e&&(this.Gh=!!e.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[ar]:this.Gh}),this.Oi=this.Zh(),this.startIfEnabledOrStop())}}onConfigChange(){this.Oi=this.Zh()}captureException(i){var e,t,s,r=(e=i==null||(t=i.$exception_list)==null||(t=t[0])==null?void 0:t.type)!==null&&e!==void 0?e:"Exception";this.oe.consumeRateLimit(r)?Xt.info("Skipping exception capture because of client rate limiting.",{exception:r}):(s=this._instance.exceptions)==null||s.sendExceptionEvent(i)}},exceptions:class{constructor(i){var e,t;this.Qh=[],this.Jh=new Nl([new Gl,new tu,new Jl,new Wl,new Xl,new Kl,new Ql,new eu],(function(s){for(var r=arguments.length,n=new Array(r>1?r-1:0),a=1;r>a;a++)n[a-1]=arguments[a];return function(o,l){l===void 0&&(l=0);for(var h=[],u=o.split(`
3
- `),c=l;u.length>c;c++){var d=u[c];if(1024>=d.length){var p=gn.test(d)?d.replace(gn,"$1"):d;if(!p.match(/\S*Error: /)){for(var v of n){var f=v(p,s);if(f){h.push(f);break}}if(h.length>=50)break}}}return(function(g){if(!g.length)return[];var m=Array.from(g);return m.reverse(),m.slice(0,50).map((b=>{return y({},b,{filename:b.filename||(k=m,k[k.length-1]||{}).filename,function:b.function||jt});var k}))})(h)}})("web:javascript",Bl,zl)),this._instance=i,this.Qh=(e=(t=this._instance.persistence)==null?void 0:t.get_property(or))!==null&&e!==void 0?e:[],this.Kh=Wi(this.Yh()),this.Xh=new su(this.Kh)}onConfigChange(){this.Kh=Wi(this.Yh()),this.Xh.setConfig(this.Kh)}onRemoteConfig(i){var e,t,s;if(i.ok){var r=i.config;if("errorTracking"in r){var n=(e=(t=r.errorTracking)==null?void 0:t.suppressionRules)!==null&&e!==void 0?e:[],a=(s=r.errorTracking)==null?void 0:s.captureExtensionExceptions;this.Qh=n,this._instance.persistence&&this._instance.persistence.register({[or]:this.Qh,[lr]:a})}}}get td(){var i,e=!!this._instance.get_property(lr),t=this._instance.config.error_tracking.captureExtensionExceptions;return(i=t??e)!==null&&i!==void 0&&i}buildProperties(i,e){return this.Jh.buildFromUnknown(i,{syntheticException:e?.syntheticException,mechanism:{handled:e?.handled}})}addExceptionStep(i,e){if(this.Kh.enabled)try{if(!q(i)||i.trim().length===0)return void He.warn("Ignoring exception step because message must be a non-empty string");var t=(function(n){if(!n)return{sanitizedProperties:{},droppedKeys:[]};var a=[];return{sanitizedProperties:Object.keys(n).reduce(((o,l)=>iu.has(l)?(a.push(l),o):(o[l]=n[l],o)),{}),droppedKeys:a}})(this.ed(e)),s=t.sanitizedProperties,r=t.droppedKeys;r.length>0&&He.warn("Ignoring reserved exception step fields",{droppedKeys:r}),this.Xh.add(y({[zi]:i,[Gi]:new Date().toISOString()},s))}catch(n){He.error("Failed to add exception step. Ignoring breadcrumb.",n)}}sendExceptionEvent(i){try{var e=i.$exception_list;if(this.rd(e)){if(this.nd(e))return this.sd("Exception dropped: matched a suppression rule"),void He.info("Skipping exception capture because a suppression rule matched");if(!this.td&&this.ad(e))return this.sd("Exception dropped: thrown by a browser extension"),void He.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.od(e))return this.sd("Exception dropped: thrown by the PostHog SDK"),void He.info("Skipping exception capture because it was thrown by the PostHog SDK")}var t=this.Kh.enabled&&D(i.$exception_steps)?this.ld(i):i,s=typeof(n=globalThis._posthogReleaseId)=="string"&&n.length>0?n:void 0;s&&(t.$release_id=s);try{var r=this._instance.capture("$exception",t,{_noTruncate:!0,_batchKey:"exceptionEvent",Go:!0});return r&&this.Xh.clear(),r}catch(a){return He.error("Failed to capture exception event. Dropping this exception.",a),void this.Xh.clear()}}catch(a){return void He.error("Failed to process exception event. Ignoring this exception.",a)}var n}ld(i){try{var e=this.Xh.getAttachable();return e.length===0?i:y({},i,{$exception_steps:e})}catch(t){return He.error("Failed to read buffered exception steps. Capturing exception without steps.",t),i}}sd(i){this.Kh.enabled&&this.Xh.add({[zi]:i,[Gi]:new Date().toISOString()})}ed(i){return Z(i)?y({},i):{}}Yh(){var i,e;return(i=(e=this._instance.config.error_tracking)==null?void 0:e.exception_steps)!==null&&i!==void 0?i:{}}nd(i){if(i.length===0)return!1;try{var e=i.reduce(((t,s)=>{var r=s.type,n=s.value;return q(r)&&r.length>0&&t.$exception_types.push(r),q(n)&&n.length>0&&t.$exception_values.push(n),t}),{$exception_types:[],$exception_values:[]});return this.Qh.some((t=>{var s=t.values.map((r=>{var n=Qo[r.operator],a=e[r.key];if(!n||!a)return!1;var o=A(r.value)?r.value:[r.value];return o.length>0&&n(o,a)}));return t.type==="OR"?s.some(Boolean):s.every(Boolean)}))}catch(t){return He.warn("Failed to evaluate suppression rules. Capturing the exception.",t),!1}}ad(i){return i.flatMap((e=>{var t,s;return(t=(s=e.stacktrace)==null?void 0:s.frames)!==null&&t!==void 0?t:[]})).some((e=>{var t=e.filename;return!!t&&wh.some((s=>t.startsWith(s)))}))}od(i){if(i.length>0){var e,t,s,r,n=(e=(t=i[0].stacktrace)==null?void 0:t.frames)!==null&&e!==void 0?e:[],a=n[n.length-1];return(s=a==null||(r=a.filename)==null?void 0:r.includes("posthog.com/static"))!==null&&s!==void 0&&s}return!1}rd(i){return!D(i)&&A(i)}}},Ph=y({productTours:class{get Sa(){return this._instance.persistence}constructor(i){this.ud=null,this.hd=null,this._instance=i}initialize(){this.loadIfEnabled()}onRemoteConfig(i){if(i.ok){var e=i.config;if("productTours"in e){var t,s;if(this.Sa&&this.Sa.register({[jr]:!!e.productTours}),!zs(this._instance))return!this.ud&&D((t=this.Sa)==null?void 0:t.props[si])||Ci.info("product tours disabled; stopping and clearing cached tours"),(s=this.ud)==null||s.stop(),this.ud=null,void this.clearCache();this.loadIfEnabled()}}}loadIfEnabled(){!this.ud&&zs(this._instance)&&this.Jn((()=>this.dd()))}Jn(i){var e,t;(e=$.__PosthogExtensions__)!=null&&e.generateProductTours?i():(t=$.__PosthogExtensions__)==null||t.loadExternalDependency==null||t.loadExternalDependency(this._instance,"product-tours",(s=>{s?Ci.error("Could not load product tours script",s):i()}))}dd(){var i;!this.ud&&(i=$.__PosthogExtensions__)!=null&&i.generateProductTours&&(this.ud=$.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(i,e){if(e===void 0&&(e=!1),!A(this.hd)||e){var t=this.Sa;if(t){var s=t.props[si];if(A(s)&&!e)return this.hd=s,void i(s,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/product_tours/?token="+this._instance.config.token),method:"GET",timestampMode:"query",callback:r=>{if(zs(this._instance)){var n=r.statusCode;if(n!==200||!r.json){var a="Product Tours API could not be loaded, status: "+n;return n===0?r.error||Ci.warn(a):Ci.error(a),void i([],{isLoaded:!1,error:a})}var o=A(r.json.product_tours)?r.json.product_tours:[];this.hd=o,t&&t.register({[si]:o}),i(o,{isLoaded:!0})}else i([],{isLoaded:!0})}})}else i(this.hd,{isLoaded:!0})}getActiveProductTours(i){D(this.ud)?i([],{isLoaded:!1,error:"Product tours not loaded"}):this.ud.getActiveProductTours(i)}showProductTour(i){var e;(e=this.ud)==null||e.showTourById(i)}previewTour(i){this.ud?this.ud.previewTour(i):this.Jn((()=>{var e;this.dd(),(e=this.ud)==null||e.previewTour(i)}))}dismissProductTour(){var i;(i=this.ud)==null||i.dismissTour("user_clicked_skip")}nextStep(){var i;(i=this.ud)==null||i.nextStep()}previousStep(){var i;(i=this.ud)==null||i.previousStep()}clearCache(){var i;this.hd=null,(i=this.Sa)==null||i.unregister(si)}resetTour(i){var e;(e=this.ud)==null||e.resetTour(i)}resetAllTours(){var i;(i=this.ud)==null||i.resetAllTours()}cancelPendingTour(i){var e;(e=this.ud)==null||e.cancelPendingTour(i)}}},vs),Ih={siteApps:class{constructor(i){this.vd=0,this._instance=i,this.fd=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}pd(i,e){if(e){var t=this.globalsForEvent(e);this.fd.push(t),this.fd.length>1e3&&(this.fd=this.fd.slice(10))}}get siteAppLoaders(){var i;return(i=$._POSTHOG_REMOTE_CONFIG)==null||(i=i[this._instance.config.token])==null?void 0:i.siteApps}initialize(){if(this.isEnabled){var i=this._instance._addCaptureHook(this.pd.bind(this));this.gd=()=>{i(),this.fd=[],this.gd=void 0}}}globalsForEvent(i){var e,t,s,r,n,a,o;if(!i)throw new Error("Event payload is required");var l={},h=this._instance.get_property("$groups")||[],u=this._instance.get_property("$stored_group_properties")||{};for(var c of Object.entries(u)){var d=c[0];l[d]={id:h[d],type:d,properties:c[1]}}var p=i.$set_once,v=i.$set;return{event:y({},_a(i,fh),{properties:y({},i.properties,v?{$set:y({},(e=(t=i.properties)==null?void 0:t.$set)!==null&&e!==void 0?e:{},v)}:{},p?{$set_once:y({},(s=(r=i.properties)==null?void 0:r.$set_once)!==null&&s!==void 0?s:{},p)}:{}),elements_chain:(n=(a=i.properties)==null?void 0:a.$elements_chain)!==null&&n!==void 0?n:"",distinct_id:(o=i.properties)==null?void 0:o.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:l}}md(i){var e,t=(e=i.tagName)==null?void 0:e.toLowerCase();return t==="style"&&this._instance.config.prepare_external_dependency_stylesheet?this._instance.config.prepare_external_dependency_stylesheet(i)||(je.error("prepare_external_dependency_stylesheet returned null"),null):t==="script"&&this._instance.config.prepare_external_dependency_script?this._instance.config.prepare_external_dependency_script(i)||(je.error("prepare_external_dependency_script returned null"),null):i}yd(){var i,e,t,s,r,n,a,o;if(!this._instance.config.prepare_external_dependency_stylesheet&&!this._instance.config.prepare_external_dependency_script)return()=>{};var l=S?.defaultView,h=l==null||(i=l.Node)==null?void 0:i.prototype;if(!l||!h)return()=>{};if(this.vd++,this.bd)return this._d();var u=[],c=this,d=new WeakSet,p=(g,m,b)=>{if(g!=null&&g[m]){var k=g[m];g[m]=b(k),u.push((()=>{g[m]=k}))}},v=g=>{if(d.has(g))return g;var m=c.md(g);return m&&d.add(m),m},f=g=>g.map((m=>typeof m=="string"?m:v(m))).filter((m=>!de(m)));return p(h,"appendChild",(g=>function(m){var b=v(m);return b?g.call(this,b):m})),p(h,"insertBefore",(g=>function(m,b){var k=v(m);return k?g.call(this,k,b):m})),p(h,"replaceChild",(g=>function(m,b){var k=v(m);return k?g.call(this,k,b):b})),[(e=l.Element)==null?void 0:e.prototype,(t=l.Document)==null?void 0:t.prototype,(s=l.DocumentFragment)==null?void 0:s.prototype].forEach((g=>{p(g,"append",(m=>function(){for(var b=arguments.length,k=new Array(b),P=0;b>P;P++)k[P]=arguments[P];return m.apply(this,f(k))})),p(g,"prepend",(m=>function(){for(var b=arguments.length,k=new Array(b),P=0;b>P;P++)k[P]=arguments[P];return m.apply(this,f(k))}))})),[(r=l.Element)==null?void 0:r.prototype,(n=l.CharacterData)==null?void 0:n.prototype,(a=l.DocumentType)==null?void 0:a.prototype].forEach((g=>{p(g,"before",(m=>function(){for(var b=arguments.length,k=new Array(b),P=0;b>P;P++)k[P]=arguments[P];return m.apply(this,f(k))})),p(g,"after",(m=>function(){for(var b=arguments.length,k=new Array(b),P=0;b>P;P++)k[P]=arguments[P];return m.apply(this,f(k))})),p(g,"replaceWith",(m=>function(){for(var b=arguments.length,k=new Array(b),P=0;b>P;P++)k[P]=arguments[P];var x=f(k);return k.length&&!x.length?void 0:m.apply(this,x)}))})),p((o=l.Element)==null?void 0:o.prototype,"insertAdjacentElement",(g=>function(m,b){var k=v(b);return k?g.call(this,m,k):null})),this.bd=()=>{u.forEach((g=>g())),this.bd=void 0},this._d()}_d(){var i=!1;return()=>{var e;i||(i=!0,this.vd--,this.vd===0&&((e=this.bd)==null||e.call(this)))}}wd(i,e){e===void 0&&(e=!0);var t=this.yd();try{var s=i(t);return e&&t(),s}catch(r){throw t(),r}}setupSiteApp(i){var e=this.apps[i.id],t=()=>{var a;!e.errored&&this.fd.length&&(je.info("Processing "+this.fd.length+" events for site app with id "+i.id),this.fd.forEach((o=>this.wd((()=>e.processEvent==null?void 0:e.processEvent(o))))),e.processedBuffer=!0),Object.values(this.apps).every((o=>o.processedBuffer||o.errored))&&((a=this.gd)==null||a.call(this))},s=!1,r=a=>{e.errored=!a,e.loaded=!0,je.info("Site app with id "+i.id+" "+(a?"loaded":"errored")),s&&t()};try{var n=this.wd((a=>i.init({posthog:this._instance,callback(o){a(),r(o)}})),!1).processEvent;n&&(e.processEvent=n),s=!0}catch(a){je.error(ra+i.id,a),r(!1)}if(s&&e.loaded)try{t()}catch(a){je.error("Error while processing buffered events PostHog app with config id "+i.id,a),e.errored=!0}}kd(){var i=this.siteAppLoaders||[];for(var e of i)this.apps[e.id]={id:e.id,loaded:!1,errored:!1,processedBuffer:!1};for(var t of i)this.setupSiteApp(t)}Sd(i){var e=this;if(Object.keys(this.apps).length!==0){var t=this.globalsForEvent(i),s=function(n){try{e.wd((()=>n.processEvent==null?void 0:n.processEvent(t)))}catch(a){je.error("Error while processing event "+i.event+" for site app "+n.id,a)}};for(var r of Object.values(this.apps))s(r)}}onRemoteConfig(i){var e,t,s,r=this;if((e=this.siteAppLoaders)!=null&&e.length)return this.isEnabled?(this.kd(),void this._instance.on("eventCaptured",(l=>this.Sd(l)))):void je.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if((t=this.gd)==null||t.call(this),i.ok){var n=i.config;if((s=n.siteApps)!=null&&s.length)if(this.isEnabled){var a=function(){var l,h=o.id,u=o.url;$["__$$ph_site_app_"+h]=r._instance,(l=$.__PosthogExtensions__)==null||l.loadSiteApp==null||l.loadSiteApp(r._instance,u,(c=>{if(c)return je.error(ra+h,c)}))};for(var o of n.siteApps)a()}else je.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}}},Oh={tracingHeaders:class{constructor(i){this.xd=void 0,this.Cd=void 0,this.Td=void 0,this.jh=()=>{var e,t,s=this.Md();s?(w(this.xd)&&(this.xd=(e=$.__PosthogExtensions__)==null||(e=e.tracingHeadersPatchFns)==null?void 0:e._patchXHR(s,(()=>this._instance.get_distinct_id()),this._instance.sessionManager)),w(this.Cd)&&(this.Cd=(t=$.__PosthogExtensions__)==null||(t=t.tracingHeadersPatchFns)==null?void 0:t._patchFetch(s,(()=>this._instance.get_distinct_id()),this._instance.sessionManager))):this.Vh()},this._instance=i}initialize(){this.startIfEnabledOrStop()}Jn(i){var e,t;(e=$.__PosthogExtensions__)!=null&&e.tracingHeadersPatchFns?i():(t=$.__PosthogExtensions__)==null||t.loadExternalDependency==null||t.loadExternalDependency(this._instance,"tracing-headers",(s=>{if(s)return vh.error("failed to load script",s);i()}))}Ed(){var i,e;return(i=(e=this._instance.config.tracing_headers)!==null&&e!==void 0?e:this._instance.config.addTracingHeaders)!==null&&i!==void 0?i:this._instance.config.__add_tracing_headers}Md(){var i=this.Ed();return A(i)?(A(this.Td)?this.Td.splice(0,this.Td.length,...i):this.Td=[...i],i.length>0?this.Td:void 0):(A(this.Td)&&this.Td.splice(0),this.Td=i||void 0,this.Td)}Vh(){var i,e;(i=this.xd)==null||i.call(this),(e=this.Cd)==null||e.call(this),this.xd=void 0,this.Cd=void 0}startIfEnabledOrStop(){this.Md()?this.Jn(this.jh):this.Vh()}}},Fh=y({surveys:class{get Oi(){return this._instance.config}constructor(i){this.Id=void 0,this._surveyManager=null,this.Rd=!1,this.Pd=[],this.Ad=null,this.Fd=null,this._instance=i,this._surveyEventReceiver=null}initialize(){this.loadIfEnabled()}onRemoteConfig(i){if(!this.Oi.disable_surveys){if(!i.ok)return z.warn("Remote config unavailable. Not loading surveys.");var e=i.config.surveys;if(D(e))return z.warn("Flags not loaded yet. Not loading surveys.");var t=A(e);this.Id=t?e.length>0:e,z.info("flags response received, isSurveysEnabled: "+this.Id),this.loadIfEnabled()}}reset(){try{var i;(i=this._surveyEventReceiver)==null||i.reset(),localStorage.removeItem("lastSeenSurveyDate");for(var e=[],t=0;t<localStorage.length;t++){var s=localStorage.key(t);(s!=null&&s.startsWith(Xo)||s!=null&&s.startsWith("inProgressSurvey_"))&&e.push(s)}e.forEach((r=>localStorage.removeItem(r)))}catch{}}loadIfEnabled(){if(!this._surveyManager)if(this.Rd)z.info("Already initializing surveys, skipping...");else if(this.Oi.disable_surveys)z.info(na);else if(this.Oi.cookieless_mode&&this._instance.consent.isOptedOut())z.info("Not loading surveys in cookieless mode without consent.");else{var i=$?.__PosthogExtensions__;if(i){if(!w(this.Id)||this.Oi.advanced_enable_surveys){var e=this.Id||this.Oi.advanced_enable_surveys;this.Rd=!0;try{var t=i.generateSurveys;if(t)return void this.Od(t,e);var s=i.loadExternalDependency;if(!s)return void this.Ld(qr);s(this._instance,"surveys",(r=>{r||!i.generateSurveys?this.Ld("Could not load surveys script",r):this.Od(i.generateSurveys,e)}))}catch(r){throw this.Ld("Error initializing surveys",r),r}finally{this.Rd=!1}}}else z.error("PostHog Extensions not found.")}}Od(i,e){this._surveyManager=i(this._instance,e),this._surveyEventReceiver=new mh(this._instance),z.info("Surveys loaded successfully"),this.$d({isLoaded:!0})}Ld(i,e){z.error(i,e),this.$d({isLoaded:!1,error:i})}onSurveysLoaded(i){return this.Pd.push(i),this._surveyManager&&this.$d({isLoaded:!0}),()=>{this.Pd=this.Pd.filter((e=>e!==i))}}getSurveys(i,e){if(e===void 0&&(e=!1),this.Oi.disable_surveys)return z.info(na),i([]);var t,s=this._instance.get_property(cr);if(s&&!e)return i(s,{isLoaded:!0}),void(this.Dd()&&this.getSurveys((()=>{}),!0));typeof Promise<"u"&&this.Ad?this.Ad.then((r=>i(r.surveys,r.context))):(typeof Promise<"u"&&(this.Ad=new Promise((r=>{t=r}))),this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/surveys/?token="+this.Oi.token),method:"GET",timestampMode:"query",timeout:this.Oi.surveys_request_timeout_ms,callback:r=>{var n;this.Ad=null;var a=r.statusCode;if(a!==200||!r.json){var o="Surveys API could not be loaded, status: "+a;a!==0?z.error(o):r.error||z.warn(o),this.Fd=Date.now();var l={isLoaded:!1,error:o};return i([],l),void(t==null||t({surveys:[],context:l}))}this.Fd=null;var h,u=r.json.surveys||[],c=u.filter((p=>(function(v){return!(!v.start_date||v.end_date)})(p)&&(Ko(p)||(function(v){var f;return!((f=v.conditions)==null||(f=f.actions)==null||(f=f.values)==null||!f.length)})(p))));c.length>0&&((h=this._surveyEventReceiver)==null||h.register(c)),(n=this._instance.persistence)==null||n.register({[cr]:u,[Qi]:Date.now()});var d={isLoaded:!0};i(u,d),t?.({surveys:u,context:d})}}))}Dd(){return this.Nd()&&!this.Ad&&!this.qd()}Nd(){var i=this._instance.get_property(Qi);return oe(i)&&Date.now()-i>3e5}qd(){return oe(this.Fd)&&3e5>Date.now()-this.Fd}markSurveyAsSeen(i,e){var t,s={id:i,current_iteration:(t=e?.iteration)!==null&&t!==void 0?t:null};el(s);try{localStorage.setItem("lastSeenSurveyDate",new Date().toISOString())}catch{}}$d(i){for(var e of this.Pd)try{if(!i.isLoaded)return e([],i);this.getSurveys(e)}catch(t){z.error("Error in survey callback",t)}}getActiveMatchingSurveys(i,e){if(e===void 0&&(e=!1),!D(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(i,e);z.warn("init was not called")}jd(i){var e=null;return this.getSurveys((t=>{var s;e=(s=t.find((r=>r.id===i)))!==null&&s!==void 0?s:null})),e}Bd(i){if(D(this._surveyManager))return{eligible:!1,reason:Ti};var e=typeof i=="string"?this.jd(i):i;return e?this._surveyManager.checkSurveyEligibility(e):{eligible:!1,reason:"Survey not found"}}Hd(i){if(D(this._surveyManager))return{eligible:!1,reason:Ti};var e=typeof i=="string"?this.jd(i):i;return e?this._surveyManager.checkSurveyRenderability(e):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(i){if(D(this._surveyManager))return z.warn("init was not called"),{visible:!1,disabledReason:Ti};var e=this.Hd(i);return{visible:e.eligible,disabledReason:e.reason}}canRenderSurveyAsync(i,e){return D(this._surveyManager)?(z.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:Ti})):new Promise((t=>{this.getSurveys((s=>{var r,n=(r=s.find((o=>o.id===i)))!==null&&r!==void 0?r:null;if(n){var a=this.Hd(n);t({visible:a.eligible,disabledReason:a.reason})}else t({visible:!1,disabledReason:"Survey not found"})}),e)}))}renderSurvey(i,e,t){var s;if(D(this._surveyManager))z.warn("init was not called");else{var r=typeof i=="string"?this.jd(i):i;if(r!=null&&r.id)if(eh.includes(r.type)){var n=S?.querySelector(e);if(n)return(s=r.appearance)!=null&&s.surveyPopupDelaySeconds?(z.info("Rendering survey "+r.id+" with delay of "+r.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var a,o;z.info("Rendering survey "+r.id+" with delay of "+((a=r.appearance)==null?void 0:a.surveyPopupDelaySeconds)+" seconds"),(o=this._surveyManager)==null||o.renderSurvey(r,n,t),z.info("Survey "+r.id+" rendered")}),1e3*r.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(r,n,t);z.warn("Survey element not found")}else z.warn("Surveys of type "+r.type+" cannot be rendered in the app");else z.warn("Survey not found")}}displaySurvey(i,e){var t;if(D(this._surveyManager))z.warn("init was not called");else{var s=this.jd(i);if(s){var r=s;if((t=s.appearance)!=null&&t.surveyPopupDelaySeconds&&e.ignoreDelay&&(r=y({},s,{appearance:y({},s.appearance,{surveyPopupDelaySeconds:0})})),e.displayType!==xr.Popover&&e.initialResponses&&z.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),e.ignoreConditions===!1){var n=this.Bd(s);if(!n.eligible)return void z.warn("Survey is not eligible to be displayed: ",n.reason)}e.displayType!==xr.Inline?this._surveyManager.handlePopoverSurvey(r,e):this.renderSurvey(r,e.selector,e.properties)}else z.warn("Survey not found")}}cancelPendingSurvey(i){D(this._surveyManager)?z.warn("init was not called"):this._surveyManager.cancelSurvey(i)}handlePageUnload(){var i;(i=this._surveyManager)==null||i.handlePageUnload==null||i.handlePageUnload()}}},vs),Ch={toolbar:class{constructor(i){this.instance=i}zd(i){$.ph_toolbar_state=i}Ud(){var i;return(i=$.ph_toolbar_state)!==null&&i!==void 0?i:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(i,e,t){if(i===void 0&&(i=void 0),e===void 0&&(e=void 0),t===void 0&&(t=void 0),yr(this.instance.config)||!_||!S)return!1;i=i??_.location,t=t??_.history;try{if(!e){try{_.localStorage.setItem("test","test"),_.localStorage.removeItem("test")}catch{return!1}e=_?.localStorage}var s,r=yh||rs(i.hash,"__posthog")||rs(i.hash,"state"),n=r?yn((()=>JSON.parse(atob(decodeURIComponent(r)))))||yn((()=>JSON.parse(decodeURIComponent(r)))):null;return n&&n.action==="ph_authorize"?((s=n).source="url",s&&Object.keys(s).length>0&&(n.desiredHash?i.hash=n.desiredHash:t?t.replaceState(t.state,"",i.pathname+i.search):i.hash="")):((s=JSON.parse(e.getItem(aa)||"{}")).source="localstorage",delete s.userIntent),!(!s.token||this.instance.config.token!==s.token||(this.loadToolbar(s),0))}catch{return!1}}Wd(i){var e=$.ph_load_toolbar||$.ph_load_editor;!D(e)&&me(e)?e(i,this.instance):oa.warn("No toolbar load function found")}loadToolbar(i){var e=!(S==null||!S.getElementById(fo));if(!_||e)return!1;var t=this.instance.requestRouter.region==="custom"&&this.instance.config.advanced_disable_toolbar_metrics,s=y({token:this.instance.config.token},i,{apiURL:this.instance.requestRouter.endpointFor("ui")},t?{instrument:!1}:{});if(_.localStorage.setItem(aa,JSON.stringify(y({},s,{source:void 0}))),this.Ud()===2)this.Wd(s);else if(this.Ud()===0){var r;this.zd(1),(r=$.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this.instance,"toolbar",(n=>{if(n)return oa.error("[Toolbar] Failed to load",n),void this.zd(0);this.zd(2),this.Wd(s)})),ee(_,"turbolinks:load",(()=>{this.zd(0),this.loadToolbar(s)}))}return!0}Vd(i){return this.loadToolbar(i)}maybeLoadEditor(i,e,t){return i===void 0&&(i=void 0),e===void 0&&(e=void 0),t===void 0&&(t=void 0),this.maybeLoadToolbar(i,e,t)}}},Th=y({experiments:fe},vs),$h={conversations:class{constructor(i){this.Gd=void 0,this._conversationsManager=null,this.Zd=!1,this.Me=null,this.Qd=!1,this._instance=i}initialize(){this.loadIfEnabled()}onRemoteConfig(i){if(!this._instance.config.disable_conversations&&(this.Jd=i.ok,i.ok)){var e=i.config.conversations;D(e)||(Oe(e)?this.Gd=e:(this.Gd=e.enabled,this.Me=e),this.loadIfEnabled())}}reset(){var i;(i=this._conversationsManager)==null||i.reset(),this._conversationsManager=null,this.Gd=void 0,this.Me=null,this.Jd=void 0,this.Qd=!1}loadIfEnabled(){if(!(this._conversationsManager||this.Zd||this._instance.config.disable_conversations||yr(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var i=$?.__PosthogExtensions__;if(i&&!w(this.Gd)&&this.Gd)if(this.Me&&this.Me.token){this.Zd=!0;try{var e=i.initConversations;if(e)return this.Kd(e),void(this.Zd=!1);var t=i.loadExternalDependency;if(!t)return void this.Yd(qr);t(this._instance,"conversations",(s=>{s||!i.initConversations?this.Yd("Could not load conversations script",s):this.Kd(i.initConversations),this.Zd=!1}))}catch(s){this.Yd("Error initializing conversations",s),this.Zd=!1}}else Me.error("Conversations enabled but missing token in remote config.")}}Kd(i){if(this.Me)try{this._conversationsManager=i(this.Me,this._instance),this.Qd=!1,Me.info("Conversations loaded successfully")}catch(e){this.Yd("Error completing conversations initialization",e)}else Me.error("Cannot complete initialization: remote config is null")}Yd(i,e){Me.error(i,e),this._conversationsManager=null,this.Zd=!1,this.Qd=!0}show(){this._conversationsManager?this._conversationsManager.show():Me.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return this.Gd===!0&&!de(this._conversationsManager)}getUnavailableReason(){return this.isAvailable()?null:this._instance.config.disable_conversations?"disabled_by_config":yr(this._instance.config)?"disabled_for_toolbar":this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut()?"consent_opted_out":this.Jd===!1?"remote_config_failed":w(this.Gd)?this.Jd?"disabled_in_project":"remote_config_pending":this.Gd?D(this.Me)||!this.Me.token?"missing_token":$!=null&&$.__PosthogExtensions__?this.Zd?"initializing":this.Qd?"load_failed":"not_loaded":"extensions_unavailable":"disabled_in_project"}isVisible(){var i,e;return(i=(e=this._conversationsManager)==null?void 0:e.isVisible())!==null&&i!==void 0&&i}sendMessage(i,e,t){var s=this;return Q((function*(){return s._conversationsManager?s._conversationsManager.sendMessage(i,e,t):(Me.warn(ht),null)}))()}getMessages(i,e){var t=this;return Q((function*(){return t._conversationsManager?t._conversationsManager.getMessages(i,e):(Me.warn(ht),null)}))()}markAsRead(i){var e=this;return Q((function*(){return e._conversationsManager?e._conversationsManager.markAsRead(i):(Me.warn(ht),null)}))()}getTickets(i){var e=this;return Q((function*(){return e._conversationsManager?e._conversationsManager.getTickets(i):(Me.warn(ht),null)}))()}requestRestoreLink(i){var e=this;return Q((function*(){return e._conversationsManager?e._conversationsManager.requestRestoreLink(i):(Me.warn(ht),null)}))()}restoreFromToken(i){var e=this;return Q((function*(){return e._conversationsManager?e._conversationsManager.restoreFromToken(i):(Me.warn(ht),null)}))()}restoreFromUrlToken(){var i=this;return Q((function*(){return i._conversationsManager?i._conversationsManager.restoreFromUrlToken():(Me.warn(ht),null)}))()}getCurrentTicketId(){var i,e;return(i=(e=this._conversationsManager)==null?void 0:e.getCurrentTicketId())!==null&&i!==void 0?i:null}getWidgetSessionId(){var i,e;return(i=(e=this._conversationsManager)==null?void 0:e.getWidgetSessionId())!==null&&i!==void 0?i:null}il(){var i;(i=this._conversationsManager)==null||i.setIdentity()}rl(){var i;(i=this._conversationsManager)==null||i.clearIdentity()}}},Mh={logs:class{constructor(i){var e,t=this;this.Xd=!1,this.tv=!1,this.I=K("[logs]"),this.ev=y({},this.I,{error(){for(var s=arguments.length,r=new Array(s),n=0;s>n;n++)r[n]=arguments[n];r.some(fa)||t.I.error(...r)}}),this.ea=[],this.iv=[],this.Su=0,this.rv=()=>{var s,r;this.Su=0,(s=this.nv)==null||s.onReconnect(),(r=this.sv)==null||r.onReconnect()},this._instance=i,this._instance&&(e=this._instance.config.logs)!=null&&e.captureConsoleLogs&&(this.Xd=!0),_&&ee(_,"online",this.rv)}av(i,e,t,s){var r,n=(function(a,o){var l,h,u,c,d,p,v,f=(l=a?.flushIntervalMs)!==null&&l!==void 0?l:3e3,g=(h=a?.maxBufferSize)!==null&&h!==void 0?h:100,m=o!=null&&o.consoleCapture?void 0:(u=a?.maxLogsPerInterval)!==null&&u!==void 0?u:1e3,b=w(m)?Math.max(g,2048):Math.max(g,m),k=a?.resourceAttributes;return{serviceName:(c=(d=k?.["service.name"])!==null&&d!==void 0?d:a?.serviceName)!==null&&c!==void 0?c:o?.serviceNameDefault,serviceVersion:(p=k?.["service.version"])!==null&&p!==void 0?p:a?.serviceVersion,environment:(v=k?.["deployment.environment"])!==null&&v!==void 0?v:a?.environment,resourceAttributes:k,beforeSend:a?.beforeSend,flushIntervalMs:f,maxBufferSize:g,maxQueueSize:b,maxBatchRecordsPerPost:100,rateCapWindowMs:f,maxLogsPerInterval:m,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}})((r=this._instance)==null||(r=r.config)==null?void 0:r.logs,t);return[new Al(this.ov(i,e),n,this.ev,(()=>this.lv()),(a=>a()),void 0,s),n]}uv(){var i,e=(i=this._instance)==null||(i=i.config)==null?void 0:i.logs;if(!this.nv||this.hv!==e){var t;(t=this.nv)==null||t.reset(),this.hv=e;var s=this.av((()=>this.ea),(r=>{this.ea=r}));this.nv=s[0],this.dv=s[1]}return this.nv}vv(){var i,e=(i=this._instance)==null||(i=i.config)==null?void 0:i.logs;if(!this.sv||this.fv!==e){var t;(t=this.sv)==null||t.reset(),this.fv=e;var s=this.av((()=>this.iv),(r=>{this.iv=r}),{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},pa);this.sv=s[0],this.pv=s[1]}return this.sv}initialize(){this.loadIfEnabled()}onRemoteConfig(i){var e;if(i.ok){var t=(e=i.config.logs)==null?void 0:e.captureConsoleLogs;!D(t)&&t&&(this.Xd=!0,this.loadIfEnabled())}}reset(){var i,e;this.ea=[],(i=this.nv)==null||i.reset(),this.iv=[],(e=this.sv)==null||e.reset(),this.Su=0}captureLog(i){this.uv().captureLog(i)}ui(i){this.vv().captureLog(i)}get logger(){return this.gv||(this.gv={trace:(i,e)=>this.captureLog({body:i,level:"trace",attributes:e}),debug:(i,e)=>this.captureLog({body:i,level:"debug",attributes:e}),info:(i,e)=>this.captureLog({body:i,level:"info",attributes:e}),warn:(i,e)=>this.captureLog({body:i,level:"warn",attributes:e}),error:(i,e)=>this.captureLog({body:i,level:"error",attributes:e}),fatal:(i,e)=>this.captureLog({body:i,level:"fatal",attributes:e})}),this.gv}flushLogs(i){i?this.mv(i):(this.nv&&this.nv.flush().catch((e=>this.yv(e))),this.sv&&this.sv.flush().catch((e=>this.yv(e))))}yv(i){fa(i)||this.I.error("PostHog logs flush failed:",i)}loadIfEnabled(){if(this.Xd&&!this.tv){var i=$?.__PosthogExtensions__;if(i){var e=i.loadExternalDependency;e?e(this._instance,"logs",(t=>{var s;t||(s=i.logs)==null||!s.initializeLogs?this.I.error("Could not load logs script",t):(i.logs.initializeLogs(this._instance),this.tv=!0)})):this.I.error(qr)}else this.I.error("PostHog Extensions not found.")}}ov(i,e){var t=this._instance;return{get isDisabled(){return!1},get optedOut(){return!t.is_capturing()},getPersistedProperty:s=>s===Ye.LogsQueue?i():void 0,setPersistedProperty(s,r){var n;s===Ye.LogsQueue&&e((n=r)!==null&&n!==void 0?n:[])},kn:s=>this.kn(s),getLibraryId:()=>Y.LIB_NAME,getLibraryVersion:()=>Y.LIB_VERSION}}kn(i){return new Promise((e=>{if(Io(this.Su,3))e({kind:"fatal",error:Ws(void 0,"logs endpoint is unreachable, dropping batch")});else{var t=!1,s=n=>{t||(t=!0,clearTimeout(r),e(n))},r=setTimeout((()=>{this.I.warn("Logs request timed out before receiving a response"),s({kind:"retry-later",error:Ws(void 0,"logs request timed out")})}),9e4);this._instance._send_request({method:"POST",url:this.bv(),data:i,compression:"best-available",batchKey:"logs",fireCallbackOnDrop:!0,callback:n=>{var a=n.statusCode;if(this._v(a),a>=200&&300>a)s({kind:"ok"});else if(a===413)s({kind:"too-large"});else if(a!==0&&a!==429&&500>a)s({kind:"fatal",error:new Error("logs request failed with status "+a)});else{var o;a===0?(n.error||this.I.warn("Logs request failed before receiving an HTTP response"),s({kind:"retry-later",error:Ws(n.error,"logs request failed before receiving an HTTP response")})):s({kind:"retry-later",error:(o=n.error)!==null&&o!==void 0?o:new Error("logs request failed with status "+a)})}}})}}))}_v(i){(i!==0||this._instance.__loaded)&&(this.Su=Oo(i,this.Su,3,(()=>this.I.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."))))}mv(i){this.ea.length>0&&this.wv(i,this.ea,this.dv,Y.LIB_NAME,(e=>{this.ea=e})),this.iv.length>0&&this.wv(i,this.iv,this.pv,pa,(e=>{this.iv=e}))}wv(i,e,t,s,r){if(e.length!==0){var n=e.map((o=>o.record));r([]);var a=Qa(n,Ya(t,Y.LIB_NAME,Y.LIB_VERSION),s,Y.LIB_VERSION);this._instance._send_request({method:"POST",url:this.bv(),data:a,compression:"best-available",batchKey:"logs",transport:i})}}bv(){return this._instance.requestRouter.endpointFor("api","/i/v1/logs")+"?token="+encodeURIComponent(this._instance.config.token)}lv(){var i,e={};if(e.distinctId=this._instance.get_distinct_id(),this._instance.sessionManager){var t=this._instance.sessionManager.checkAndGetSessionAndWindowId(!0),s=t.windowId,r=t.sessionStartTimestamp,n=t.lastActivityTimestamp;e.sessionId=t.sessionId,e.windowId=s,D(r)||(e.sessionStartTimestamp=r),D(n)||(e.lastActivityTimestamp=n)}if($!=null&&(i=$.location)!=null&&i.href&&(e.currentUrl=this._instance.config.disable_capture_url_hashes?rt($.location.href):$.location.href),this._instance.featureFlags){var a=this._instance.featureFlags.getFlags();a&&a.length>0&&(e.activeFeatureFlags=a)}return e}}},Rh={metrics:class{constructor(i){this.I=K("[metrics]"),this._instance=i}initialize(){}uv(){var i,e,t=(i=this._instance)==null||(i=i.config)==null?void 0:i.metrics;return this.nv&&this.hv===t||((e=this.nv)==null||e.reset(),this.hv=t,this.nv=new Ll(this.ov(),(function(s){var r,n,a,o,l,h=s?.resourceAttributes;return{serviceName:(r=h?.["service.name"])!==null&&r!==void 0?r:s?.serviceName,serviceVersion:(n=h?.["service.version"])!==null&&n!==void 0?n:s?.serviceVersion,environment:(a=h?.["deployment.environment"])!==null&&a!==void 0?a:s?.environment,resourceAttributes:h,beforeSend:s?.beforeSend,flushIntervalMs:(o=s?.flushIntervalMs)!==null&&o!==void 0?o:1e4,maxSeriesPerFlush:(l=s?.maxSeriesPerFlush)!==null&&l!==void 0?l:1e3}})(t),this.I)),this.nv}count(i,e,t){e===void 0&&(e=1),this.uv().count(i,e,t)}gauge(i,e,t){this.uv().gauge(i,e,t)}histogram(i,e,t){this.uv().histogram(i,e,t)}flush(i){if(!this.nv)return Promise.resolve();if(i){var e=this.nv.drainWindow();return e&&this.Nn(e,i),Promise.resolve()}return this.nv.flush().catch((t=>this.I.error("PostHog metrics flush failed:",t)))}reset(){var i;(i=this.nv)==null||i.reset()}ov(){var i=this._instance,e=this;return{get isDisabled(){return!1},get optedOut(){return!i.is_capturing()},Nn:t=>e.Nn(t),getLibraryId:()=>Y.LIB_NAME,getLibraryVersion:()=>Y.LIB_VERSION}}Nn(i,e){return new Promise((t=>{var s=!1,r=a=>{s||(s=!0,clearTimeout(n),t(a))},n=setTimeout((()=>r({kind:"retry-later",error:new Error("metrics request timed out")})),9e4);this._instance._send_request(y({method:"POST",url:this.Sv(),data:i,compression:"best-available",batchKey:"metrics"},e&&{transport:e},{fireCallbackOnDrop:!0,callback(a){var o=a.statusCode;if(o>=200&&300>o)r({kind:"ok"});else if(o===413)r({kind:"too-large"});else if(o!==0&&o!==429&&500>o)r({kind:"fatal",error:new Error("metrics request failed with status "+o)});else{var l;r({kind:"retry-later",error:(l=a.error)!==null&&l!==void 0?l:new Error("metrics request failed with status "+o)})}}}))}))}Sv(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}}},Ah=y({},vs,kh,Eh,Sh,Ph,Ih,Fh,Oh,Ch,Th,$h,Mh,Rh);Ie.__defaultExtensionClasses=y({},Ah);var Lh=(function(){Y.SDK_DIST_CHANNEL="npm";var i=ui[Ot]=new Ie;return(function(){function e(){e.done||(e.done=!0,il=!1,U(ui,(function(t){t._dom_loaded()})))}S!=null&&S.addEventListener?S.readyState==="complete"?e():ee(S,"DOMContentLoaded",e,{capture:!1}):_&&E.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")})(),i})();export{ye as Compression,xr as DisplaySurveyType,Ie as PostHog,Lu as ProductTourEventName,Nn as ProductTourEventProperties,Xe as SurveyEventName,Rs as SurveyEventProperties,Yt as SurveyEventType,Ms as SurveyType,Lh as default,Lh as posthog};