posthog-js 1.433.2 → 1.433.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/dist/all-external-dependencies.js +1 -1
  2. package/dist/array.full.es5.js +1 -1
  3. package/dist/array.full.es5.js.map +1 -1
  4. package/dist/array.full.js +1 -1
  5. package/dist/array.full.js.map +1 -1
  6. package/dist/array.full.no-external.js +1 -1
  7. package/dist/array.full.no-external.js.map +1 -1
  8. package/dist/array.js +1 -1
  9. package/dist/array.js.map +1 -1
  10. package/dist/array.no-external.js +1 -1
  11. package/dist/array.no-external.js.map +1 -1
  12. package/dist/customizations.full.js +1 -1
  13. package/dist/customizations.js +1 -1
  14. package/dist/default-extensions.js +1 -1
  15. package/dist/default-extensions.js.map +1 -1
  16. package/dist/extension-bundles.js +1 -1
  17. package/dist/lazy-recorder.js +1 -1
  18. package/dist/main.js +1 -1
  19. package/dist/main.js.map +1 -1
  20. package/dist/module.full.cjs +1 -1
  21. package/dist/module.full.js +1 -1
  22. package/dist/module.full.js.map +1 -1
  23. package/dist/module.full.no-external.cjs +1 -1
  24. package/dist/module.full.no-external.js +1 -1
  25. package/dist/module.full.no-external.js.map +1 -1
  26. package/dist/module.js +1 -1
  27. package/dist/module.js.map +1 -1
  28. package/dist/module.mjs +1 -1
  29. package/dist/module.mjs.map +1 -1
  30. package/dist/module.no-external.cjs +1 -1
  31. package/dist/module.no-external.js +1 -1
  32. package/dist/module.no-external.js.map +1 -1
  33. package/dist/module.slim.js +1 -1
  34. package/dist/module.slim.js.map +1 -1
  35. package/dist/module.slim.no-external.js +1 -1
  36. package/dist/module.slim.no-external.js.map +1 -1
  37. package/dist/posthog-recorder.js +1 -1
  38. package/lib/package.json +1 -1
  39. package/lib/src/request.js +3 -1
  40. package/lib/src/request.js.map +1 -1
  41. package/package.json +6 -6
@@ -1,2 +1,2 @@
1
- var e,t=["retriesPerformedSoFar"];function i(){return i=Object.assign?Object.assign.bind():function(e){for(var t=1;arguments.length>t;t++){var i=arguments[t];for(var s in i)({}).hasOwnProperty.call(i,s)&&(e[s]=i[s])}return e},i.apply(null,arguments)}function s(e,t,i,s,r,n,o){try{var a=e[n](o),l=a.value}catch(e){return void i(e)}a.done?t(l):Promise.resolve(l).then(s,r)}function r(e){return function(){var t=this,i=arguments;return new Promise(function(r,n){var o=e.apply(t,i);function a(e){s(o,r,n,a,l,"next",e)}function l(e){s(o,r,n,a,l,"throw",e)}a(void 0)})}}var n="0.8.3",o={DEBUG:(!1,!1),LIB_VERSION:(n,"1.433.2"),LIB_NAME:("browser-common","web"),JS_SDK_VERSION:n},a=o,l="$people_distinct_id",d="distinct_id",u="$device_id",_="$device_model",c="__alias",h="__cmpns",p="$fbc",g="$fbc_persistence",v="$fbp",f="$fbp_persistence",m="__timers",y="$autocapture_disabled_server_side",b="$heatmaps_enabled_server_side",w="$exception_capture_enabled_server_side",S="$error_tracking_suppression_rules",P="$error_tracking_capture_extension_exceptions",x="$web_vitals_enabled_server_side",E="$dead_clicks_enabled_server_side",C="$product_tours_enabled_server_side",k="$logs_capture_enabled_server_side",I="$web_vitals_allowed_metrics",T="$session_recording_remote_config",F="$session_recording_enabled_server_side",R="$replay_sample_rate",O="$replay_override_sampling",A="$replay_override_linked_flag",M="$replay_override_url_trigger",D="$replay_override_event_trigger",L="$sesid",N="$session_is_sampled",B="$session_past_minimum_duration",U="$session_recording_url_trigger_activated_session",q="$session_recording_event_trigger_activated_session",H="$debug_first_full_snapshot_timestamp",G="$sess_rec_flush_size",W="$enabled_feature_flags",V="$active_feature_flags",j="$early_access_features",z="$feature_flag_details",K="$feature_flag_payloads",J="$feature_flag_request_id",Y="$minimal_flag_called_events",Q="$override_feature_flags",X="$override_feature_flag_payloads",Z="$stored_person_properties",ee="$stored_group_properties",te="$groups",ie="$surveys",se="$surveys_loaded_at",re="$surveys_activated",ne="$surveys_activated_session",oe="$surveys_activated_timestamps",ae="ph_product_tours",le="$product_tours_activated",de="$product_tours_activated_session",ue="$conversations_widget_session_id",_e="$conversations_ticket_id",ce="$conversations_widget_state",he="$conversations_user_traits",pe="$flag_call_reported",ge="$flag_call_reported_session_id",ve="$feature_flag_errors",fe="$feature_flag_evaluated_at",me="$user_state",ye="$client_session_props",be="$capture_rate_limit",we="$initial_campaign_params",Se="$initial_referrer_info",Pe="$initial_person_info",xe="$epp",Ee="$posthog_cookieless",Ce="$cookieless_mode",ke="$sdk_debug_extensions_init_method",Ie="$sdk_debug_extensions_init_time_ms",Te="$sdk_debug_recording_script_not_loaded",$e="$sdk_debug_replay_event_trigger_status",Fe="$sdk_debug_replay_linked_flag_trigger_status",Re="$sdk_debug_replay_matched_recording_trigger_groups",Oe="$sdk_debug_replay_pending_trigger_conditions",Ae="$sdk_debug_replay_remote_trigger_matching_config",Me="$sdk_debug_replay_trigger_groups_count",De="$sdk_debug_replay_url_trigger_status",Le="$session_recording_start_reason",Ne="anonymous",Be="identified",Ue="identified_only",qe="visibilitychange",He="beforeunload",Ge="$pageview",We="$pageleave",Ve="$identify",je="$groupidentify",ze="u">typeof window?window:void 0,Ke="u">typeof globalThis?globalThis:ze,Je=null==Ke?void 0:Ke.navigator,Ye=null==Ke?void 0:Ke.document,Qe=null==Ke?void 0:Ke.location,Xe=null==Ke?void 0:Ke.fetch,Ze=null!=Ke&&Ke.XMLHttpRequest&&"withCredentials"in new Ke.XMLHttpRequest?Ke.XMLHttpRequest:void 0,et=null==Ke?void 0:Ke.AbortController,tt=null==Ke?void 0:Ke.CompressionStream,it=null==Je?void 0:Je.userAgent,st="undefined"!=typeof globalThis?globalThis:ze;st&&"undefined"==typeof self&&(st.self=st),st&&"undefined"==typeof File&&(st.File=function(){});var rt=null!=ze?ze:{},nt=function(e){return e.GZipJS="gzip-js",e.Base64="base64",e}({}),ot=["$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"],at=["token"];function lt(e,t){return-1!==e.indexOf(t)}var dt=function(e){return e.replace(/^\$/,"")},ut=Object.prototype,_t=ut.hasOwnProperty,ct=ut.toString,ht=Array.isArray||function(e){return"[object Array]"===ct.call(e)},pt=e=>"function"==typeof e,gt=e=>e===Object(e)&&!ht(e),vt=e=>{if(gt(e)){for(var t in e)if(_t.call(e,t))return!1;return!0}return!1},ft=e=>void 0===e,mt=e=>"[object String]"==ct.call(e),yt=e=>mt(e)&&0===e.trim().length,bt=e=>null===e,wt=e=>ft(e)||bt(e),St=e=>"[object Number]"==ct.call(e)&&e==e,Pt=e=>St(e)&&e>0,xt=e=>"[object Boolean]"===ct.call(e),Et=e=>lt(ot,e),Ct=e=>lt(at,e);function kt(e){switch({}.toString.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object DOMError]":case"[object WebAssembly.Exception]":return!0;default:return function(e,t){try{return e instanceof t}catch(e){return!1}}(e,Error)}}var It=[!0,"true",1,"1","yes"],Tt=e=>lt(It,e),$t=[!1,"false",0,"0","no"],Ft=["amazonbot","amazonproductbot","app.hypefactors.com","applebot","archive.org_bot","awariobot","backlinksextendedbot","baiduspider","bingbot","bingpreview","chrome-lighthouse","dataforseobot","deepscan","duckduckbot","facebookexternal","facebookcatalog","http://yandex.com/bots","hubspot","ia_archiver","leikibot","linkedinbot","meta-externalagent","mj12bot","msnbot","nessus","petalbot","pinterestbot","prerender","rogerbot","screaming frog","sebot-wa","sitebulb","slackbot","slurp","trendictionbot","turnitin","twitterbot","vercel-screenshot","vercelbot","yahoo! slurp","yandexbot","zoombot","bot.htm","bot.php","(bot;","bot/","crawler","ahrefsbot","ahrefssiteaudit","semrushbot","siteauditbot","splitsignalbot","gptbot","oai-searchbot","chatgpt-user","perplexitybot","better uptime bot","sentryuptimebot","uptimerobot","headlesschrome","cypress","google-hoteladsverifier","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleother","google-cloudvertexbot","googleweblight","mediapartners-google","storebot-google","google-inspectiontool","bytespider"],Rt=function(e,t){if(void 0===t&&(t=[]),!e)return!1;var i=e.toLowerCase();return Ft.concat(t).some(e=>{var t=e.toLowerCase();return-1!==i.indexOf(t)})};function Ot(e,t,i,s,r){return t>i&&(s.warn("min cannot be greater than max."),t=i),St(e)?e>i?(s.warn(" cannot be greater than max: "+i+". Using max value instead."),i):t>e?(s.warn(" cannot be less than min: "+t+". Using min value instead."),t):e:(s.warn(" must be a number. using max or fallback. max: "+i+", fallback: "+r),Ot(null!=r?r:i,t,i,s))}var At="Mobile",Mt="Android",Dt="Tablet",Lt="Android Tablet",Nt="iPad",Bt="Apple Watch",Ut="Safari",qt="BlackBerry",Ht="Samsung Internet",Gt="Chrome",Wt="Chrome iOS",Vt="Internet Explorer",jt="Internet Explorer Mobile",zt="Opera",Kt="Microsoft Edge",Jt="Firefox",Yt="Firefox iOS",Qt="Nintendo",Xt="PlayStation",Zt="Xbox",ei="Android Mobile",ti="Mobile Safari",ii="Windows",si="Windows Phone",ri="Nokia",ni="Ouya",oi="Generic "+At.toLowerCase(),ai="Generic "+Dt.toLowerCase(),li="Konqueror",di="Oculus Browser",ui="Vivaldi",_i="Yandex",ci="Whale",hi="DuckDuckGo",pi="Pale Moon",gi="Waterfox",vi="Brave",fi="Claude",mi="Codex",yi="ChatGPT",bi="Google Search App",wi=new RegExp("Version/(\\d+(\\.\\d+)?)"),Si=new RegExp("(Claude|Codex|ChatGPT)\\/(\\d+(\\.\\d+)?)"),Pi=new RegExp(Zt,"i"),xi=new RegExp("PlayStation \\w+","i"),Ei=new RegExp("Nintendo \\w+","i"),Ci=new RegExp("BlackBerry|PlayBook|BB10","i"),ki={"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"},Ii=function(e,t,i,s){t=t||"";var r=function(e){return null!=e&&e.brave?vi:null}(i);return r||(null!=s&&s.detectGoogleSearchApp&&lt(e,"GSA/")?bi:lt(e," OPR/")&&lt(e,"Mini")?"Opera Mini":lt(e," OPR/")?zt:Ci.test(e)?qt:lt(e,"IEMobile")||lt(e,"WPDesktop")?jt:lt(e,"OculusBrowser")?di:lt(e,"SamsungBrowser")?Ht:lt(e,"Edge")||lt(e,"Edg/")?Kt:lt(e,"Vivaldi/")?ui:lt(e,"YaBrowser/")?_i:lt(e,"Whale/")?ci:lt(e,"DuckDuckGo/")||lt(e,"Ddg/")?hi:lt(e,"Claude/")?fi:lt(e,"Codex/")?mi:lt(e,"ChatGPT/")?yi:lt(e,"FBIOS")?"Facebook Mobile":lt(e,"UCWEB")||lt(e,"UCBrowser")?"UC Browser":lt(e,"CriOS")?Wt:lt(e,"CrMo")||lt(e,Gt)?Gt:lt(e,Mt)&&lt(e,Ut)?ei:lt(e,"FxiOS")?Yt:lt(e.toLowerCase(),li.toLowerCase())?li:lt(e,"Brave/")?vi:((e,t)=>t&&lt(t,"Apple")||function(e){return lt(e,Ut)&&!lt(e,Gt)&&!lt(e,Mt)}(e))(e,t)?lt(e,At)?ti:Ut:lt(e,"PaleMoon/")?pi:lt(e,"Waterfox/")?gi:lt(e,Jt)?Jt:lt(e,"MSIE")||lt(e,"Trident/")?Vt:lt(e,"Gecko")?Jt:"")},Ti={[jt]:[new RegExp("rv:(\\d+(\\.\\d+)?)")],[Kt]:[new RegExp("Edge?\\/(\\d+(\\.\\d+)?)")],[Gt]:[new RegExp("(Chrome|CrMo)\\/(\\d+(\\.\\d+)?)")],[Wt]:[new RegExp("CriOS\\/(\\d+(\\.\\d+)?)")],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/(\\d+(\\.\\d+)?)")],[Ut]:[wi],[ti]:[wi],[zt]:[new RegExp("(Opera|OPR)\\/(\\d+(\\.\\d+)?)")],[Jt]:[new RegExp("Firefox\\/(\\d+(\\.\\d+)?)")],[Yt]:[new RegExp("FxiOS\\/(\\d+(\\.\\d+)?)")],[li]:[new RegExp("Konqueror[:/]?(\\d+(\\.\\d+)?)","i")],[qt]:[new RegExp("BlackBerry (\\d+(\\.\\d+)?)"),wi],[ei]:[new RegExp("android\\s(\\d+(\\.\\d+)?)","i")],[Ht]:[new RegExp("SamsungBrowser\\/(\\d+(\\.\\d+)?)")],[di]:[new RegExp("OculusBrowser\\/(\\d+(\\.\\d+)?)")],[ui]:[new RegExp("Vivaldi\\/(\\d+(\\.\\d+)?)")],[_i]:[new RegExp("YaBrowser\\/(\\d+(\\.\\d+)?)")],[ci]:[new RegExp("Whale\\/(\\d+(\\.\\d+)?)")],[vi]:[new RegExp("Brave\\/(\\d+(\\.\\d+)?)")],[fi]:[Si],[mi]:[Si],[yi]:[Si],[hi]:[new RegExp("(DuckDuckGo|Ddg)\\/(\\d+(\\.\\d+)?)")],[pi]:[new RegExp("PaleMoon\\/(\\d+(\\.\\d+)?)")],[gi]:[new RegExp("Waterfox\\/(\\d+(\\.\\d+)?)")],[bi]:[new RegExp("GSA\\/(\\d+(\\.\\d+)?)")],[Vt]:[new RegExp("(rv:|MSIE )(\\d+(\\.\\d+)?)")],Mozilla:[new RegExp("rv:(\\d+(\\.\\d+)?)")]},$i=function(e,t,i,s){var r=Ti[Ii(e,t,i,s)];if(ft(r))return null;for(var n=0;r.length>n;n++){var o=e.match(r[n]);if(o)return parseFloat(o[o.length-2])}return null},Fi=[[new RegExp("Xbox; Xbox (.*?)[);]","i"),e=>[Zt,e&&e[1]||""]],[new RegExp(Qt,"i"),[Qt,""]],[new RegExp(Xt,"i"),[Xt,""]],[Ci,[qt,""]],[new RegExp(ii,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[si,""];if(new RegExp(At).test(t)&&!/IEMobile\b/.test(t))return["Windows Mobile",""];var i=/Windows NT ([0-9.]+)/i.exec(t);if(i&&i[1]){var s=ki[i[1]]||"";return/arm/i.test(t)&&(s="RT"),[ii,s]}return[ii,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>e&&e[3]?["iOS",[e[3],e[4],e[5]||"0"].join(".")]:["iOS",""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var t="";return e&&e.length>=3&&(t=ft(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("(Android (\\d+)\\.(\\d+)\\.?(\\d+)?|Android)","i"),e=>e&&e[2]?[Mt,[e[2],e[3],e[4]||"0"].join(".")]:[Mt,""]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{var t=["Mac OS X",""];return e&&e[1]&&(t[1]=[e[1],e[2],e[3]||"0"].join(".")),t}],[/Mac/i,["Mac OS X",""]],[/CrOS/,["Chrome OS",""]],[/Linux|debian/i,["Linux",""]]],Ri=function(e){return Ei.test(e)?Qt:xi.test(e)?Xt:Pi.test(e)?Zt:new RegExp(ni,"i").test(e)?ni:new RegExp("(Windows Phone|WPDesktop)","i").test(e)?si:/iPad/.test(e)?Nt:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?Bt:Ci.test(e)?qt:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(ri,"i").test(e)?ri:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(e)||/(kf[a-z]+)( bui|\)).+silk\//i.test(e)?"Kindle Fire":/(Android|ZTE)/i.test(e)?new RegExp(At).test(e)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(e)||/pixel[\daxl ]{1,6}/i.test(e)&&!/pixel c/i.test(e)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(e)||/lmy47v/i.test(e)&&!/QTAQZ3/i.test(e)?Mt:Lt:new RegExp("(pda|Mobile)","i").test(e)?oi:new RegExp(Dt,"i").test(e)&&!new RegExp("Tablet pc","i").test(e)?ai:""},Oi=/\bFBAV\/(\d+(?:\.\d+)*)/i,Ai=[[/\bInstagram(?:[ /](\d+(?:\.\d+)*))?\b/i,"Instagram"],[/\bBarcelona[ /](\d+(?:\.\d+)*)?/i,"Threads"],[/\b(?:MessengerForiOS|(?:FBAN|FB_IAB)\/Orca-Android)\b/i,"Messenger",Oi],[/\bFBAN\/EMA\b/i,"Facebook Lite",Oi],[/\b(?:FBIOS|(?:FBAN|FB_IAB)\/(?:FB4A|FBIOS))\b/i,"Facebook",Oi],[/\bLinkedInApp(?:\]?\/(\d+(?:\.\d+)*))?\b/i,"LinkedIn"],[/\bTwitter(?:Android| for (?:iPhone|iPad|Android))(?:\/(\d+(?:\.\d+)*))?\b/i,"Twitter"],[/\b(?:musical_ly|trill)(?:[_/](\d+\.\d+(?:\.\d+)*))?(?=\b|_)/i,"TikTok",/\bapp_version\/(\d+(?:\.\d+)*)/i],[/\b(?:MicroMessenger|WeChat)\/(\d+(?:\.\d+)*)?/i,"WeChat"],[/\bLine\/(\d+(?:\.\d+)*)?/i,"Line"],[/\bGSA\/(\d+(?:\.\d+)*)?/i,"Google"],[/\[Pinterest\/(?:iOS|Android)\b|\bPinterest(?: for (?:Android(?: Tablet)?|iOS))?\/(\d+(?:\.\d+)*)/i,"Pinterest"],[/\b(?:WA4A|WAiOS)\/(\d+(?:\.\d+)*)?/i,"WhatsApp"],[/\bSnapchat[ /](\d+(?:\.\d+)*)?/i,"Snapchat"],[/\bBing(?:Web|Sapphire)\/(\d+(?:\.\d+)*)?/i,"Bing"],[/\bNAVER\(inapp; search;/i,"Naver",/\bNAVER\(inapp; search;[^;)]*; (\d+(?:\.\d+)*)/i],[/\bKAKAOTALK[ /](\d+\.\d+(?:\.\d+)*)?/i,"KakaoTalk"]],Mi=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function Di(e,t){return"string"==typeof(i=e)&&Mi.test(i)?e:t();var i}function Li(e,t){var i=new Error(t);try{Object.defineProperty(i,"name",{value:e,writable:!0,enumerable:!0,configurable:!0})}catch(e){}return i}function Ni(e){return e?e.split("#")[0]:e}var Bi,Ui=["$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"],qi="NativeGzipValidationError",Hi=e=>e.length>=2&&31===e[0]&&139===e[1],Gi=(e,t)=>e===nt.GZipJS||t===nt.GZipJS||"gzip"===t,Wi=e=>!(!e||"object"!=typeof e)&&"NotReadableError"===("name"in e?String(e.name):""),Vi=e=>{throw Li(qi,"Native gzip produced invalid output: "+e)},ji=function(){var e=r(function*(e,t){18>e.size&&Vi("too-short");var i=new Uint8Array(yield e.slice(0,10).arrayBuffer());Hi(i)&&8===i[2]||Vi("invalid-header");var s=new DataView(yield e.slice(e.size-8).arrayBuffer());s.getUint32(0,!0)!==(e=>{for(var t=(()=>{if(Bi)return Bi;Bi=[];for(var e=0;256>e;e++){for(var t=e,i=0;8>i;i++)t=1&t?3988292384^t>>>1:t>>>1;Bi[e]=t>>>0}return Bi})(),i=4294967295,s=0;e.length>s;s++)i=t[255&(i^e[s])]^i>>>8;return(4294967295^i)>>>0})(t)&&Vi("invalid-crc");var r=t.length>>>0;s.getUint32(4,!0)!==r&&Vi("invalid-size")});return function(t,i){return e.apply(this,arguments)}}();function zi(){return zi=r(function*(e,t,i){void 0===t&&(t=!0);try{var s=(new TextEncoder).encode(e),n=new globalThis.CompressionStream("gzip"),o=n.writable.getWriter(),a=o.write(s).then(()=>o.close()).catch(function(){var e=r(function*(e){try{yield o.abort(e)}catch(e){}throw e});return function(t){return e.apply(this,arguments)}}()),l=new Response(n.readable).blob(),d=(yield Promise.all([l,a]))[0];return yield ji(d,s),d}catch(e){if(null!=i&&i.rethrow)throw e;return t&&console.error("Failed to gzip compress data",e),null}}),zi.apply(this,arguments)}var Ki=function(e,t){var i=(void 0===t?{}:t).debugEnabled,s={_log(t){for(var s=arguments.length,r=new Array(s>1?s-1:0),n=1;s>n;n++)r[n-1]=arguments[n];ze&&(o.DEBUG||ze.POSTHOG_DEBUG||i)&&!ft(ze.console)&&ze.console&&("__rrweb_original__"in ze.console[t]?ze.console[t].__rrweb_original__:ze.console[t])(e,...r)},debug(){for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];s._log("debug",...t)},info(){for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];s._log("log",...t)},warn(){for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];s._log("warn",...t)},error(){for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];s._log("error",...t)},critical(){for(var t=arguments.length,i=new Array(t),s=0;t>s;s++)i[s]=arguments[s];console.error(e,...i)},uninitializedWarning(e){s.error("You must initialize PostHog before calling "+e)},createLogger:(t,i)=>Ki(e+" "+t,i)};return s},Ji=Ki("[PostHog.js]"),Yi=Ji.createLogger;function Qi(e,t){ht(e)&&e.forEach(t)}function Xi(e,t){if(!wt(e))if(ht(e))e.forEach(t);else if((e=>e instanceof FormData)(e))e.forEach((e,i)=>t(e,i));else for(var i in e)_t.call(e,i)&&t(e[i],i)}var Zi=function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),s=1;t>s;s++)i[s-1]=arguments[s];for(var r of i)for(var n in r)void 0!==r[n]&&(e[n]=r[n]);return e},es=function(e){return function(){try{for(var t=arguments.length,i=new Array(t),s=0;t>s;s++)i[s]=arguments[s];return e.apply(this,i)}catch(e){Ji.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),Ji.critical(e)}}},ts=function(e){var t={};return Xi(e,function(e,i){(mt(e)&&e.length>0||St(e))&&(t[i]=e)}),t};function is(e){var t=i({},e);for(var s of["name","message","stack","cause","errors"])try{s in e&&(t[s]=e[s])}catch(e){}return t}var ss=["herokuapp.com","vercel.app","netlify.app"];function rs(e){var t=null==e?void 0:e.hostname;if(!mt(t))return!1;var i=t.split(".").slice(-2).join(".");for(var s of ss)if(i===s)return!1;return!0}function ns(e,t,i,s){var r=null!=s?s:{},n=r.capture,o=r.passive;null==e||e.addEventListener(t,i,{capture:void 0!==n&&n,passive:void 0===o||o})}var os=e=>{if(Ye){try{for(var t=e+"=",i=Ye.cookie.split(";").filter(e=>e.length),s=0;i.length>s;s++){for(var r=i[s];" "==r.charAt(0);)r=r.substring(1,r.length);if(0===r.indexOf(t))return decodeURIComponent(r.substring(t.length,r.length))}}catch(e){}return null}};Math.trunc||(Math.trunc=function(e){return 0>e?Math.ceil(e):Math.floor(e)}),Number.isInteger||(Number.isInteger=function(e){return St(e)&&isFinite(e)&&Math.floor(e)===e});var as=class e{constructor(e){if(this.bytes=e,16!==e.length)throw new TypeError("not 128-bit length")}static fromFieldsV7(t,i,s,r){if(!Number.isInteger(t)||!Number.isInteger(i)||!Number.isInteger(s)||!Number.isInteger(r)||0>t||0>i||0>s||0>r||t>0xffffffffffff||i>4095||s>1073741823||r>4294967295)throw new RangeError("invalid field value");var n=new Uint8Array(16);return n[0]=t/Math.pow(2,40),n[1]=t/Math.pow(2,32),n[2]=t/Math.pow(2,24),n[3]=t/Math.pow(2,16),n[4]=t/256,n[5]=t,n[6]=112|i>>>8,n[7]=i,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 e(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),3!==t&&5!==t&&7!==t&&9!==t||(e+="-");if(36!==e.length)throw new Error("Invalid UUIDv7 was generated");return e}clone(){return new e(this.bytes.slice(0))}equals(e){return 0===this.compareTo(e)}compareTo(e){for(var t=0;16>t;t++){var i=this.bytes[t]-e.bytes[t];if(0!==i)return Math.sign(i)}return 0}},ls=class{generate(){var e=this.generateOrAbort();if(!ft(e))return e;this._timestamp=0;var t=this.generateOrAbort();if(ft(t))throw new Error("Could not generate UUID after timestamp reset");return t}generateOrAbort(){var e,t=(e=Date.now(),St(e)&&isFinite(e)?Math.min(Math.max(Math.floor(e),0),0xffffffffffff):0);if(t>this._timestamp)this._timestamp=t,this._resetCounter();else{if(this._timestamp>=t+1e4)return;this._counter++,this._counter>4398046511103&&(this._timestamp++,this._resetCounter())}return as.fromFieldsV7(this._timestamp,Math.trunc(this._counter/Math.pow(2,30)),this._counter&Math.pow(2,30)-1,this._random.nextUint32())}_resetCounter(){this._counter=1024*this._random.nextUint32()+(1023&this._random.nextUint32())}constructor(){this._timestamp=0,this._counter=0,this._random=new _s}},ds=e=>{if("u">typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var t=0;e.length>t;t++)e[t]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return e};ze&&!ft(ze.crypto)&&crypto.getRandomValues&&(ds=e=>crypto.getRandomValues(e));var us,_s=class{nextUint32(){return this._buffer.length>this._cursor||(ds(this._buffer),this._cursor=0),this._buffer[this._cursor++]}constructor(){this._buffer=new Uint32Array(8),this._cursor=1/0}},cs=()=>hs().toString(),hs=()=>(us||(us=new ls)).generate(),ps="",gs=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;var vs=null,fs={_is_supported(){if(!bt(vs))return vs;if(vs=!1,Ye)try{var e="__ph_cookie_support_"+cs();fs._set(e,"xyz"),vs='"xyz"'===os(e),fs._remove(e)}catch(e){vs=!1}return vs},_error(e){Ji.error("cookieStore error: "+e)},_get:os,_parse(e){var t;try{t=JSON.parse(fs._get(e))||{}}catch(e){}return t},_set(e,t,i,s,r){if(!Ye)return!1;try{var n="",o="",a=function(e,t){if(t){var i=function(e,t){if(void 0===t&&(t=Ye),ps)return ps;if(!t)return"";if(["localhost","127.0.0.1"].includes(e))return"";for(var i=e.split("."),s=Math.min(i.length,8),r="dmn_chk_"+cs();!ps&&s--;){var n=i.slice(s).join("."),o=r+"=1;domain=."+n+";path=/";t.cookie=o+";max-age=3",t.cookie.includes(r)&&(t.cookie=o+";max-age=0",ps=n)}return ps}(e);if(!i){var s=(e=>{var t=e.match(gs);return t?t[0]:""})(e);s!==i&&Ji.info("Warning: cookie subdomain discovery mismatch",s,i),i=s}return i?"; domain=."+i:""}return""}(Ye.location.hostname,s);if(i){var l=new Date;l.setTime(l.getTime()+864e5*i),n="; expires="+l.toUTCString()}r&&(o="; secure");var d=e+"="+encodeURIComponent(JSON.stringify(t))+n+"; SameSite=Lax; path=/"+a+o;return d.length>3686.4&&Ji.warn("cookieStore warning: large cookie, len="+d.length),Ye.cookie=d,!0}catch(e){return!1}},_remove(e,t){if(null!=Ye&&Ye.cookie)try{fs._set(e,"",-1,t)}catch(e){return}}},ms=null,ys={_is_supported(){if(!bt(ms))return ms;var e=!0;if(ft(ze))e=!1;else try{var t="__mplssupport__";ys._set(t,"xyz"),'"xyz"'!==ys._get(t)&&(e=!1),ys._remove(t)}catch(t){e=!1}return e||Ji.error("localStorage unsupported; falling back to cookie store"),ms=e,e},_error(e){Ji.error("localStorage error: "+e)},_get(e){try{return null==ze?void 0:ze.localStorage.getItem(e)}catch(e){ys._error(e)}return null},_parse(e){try{return JSON.parse(ys._get(e))||{}}catch(e){}return null},_set(e,t){try{return null==ze||ze.localStorage.setItem(e,JSON.stringify(t)),!0}catch(e){ys._error(e)}return!1},_remove(e){try{null==ze||ze.localStorage.removeItem(e)}catch(e){ys._error(e)}}},bs=[Z,V,W,z,K,J,fe,ve,pe],ws=[u,d,L,N,xe,Pe,g,me],Ss=e=>e+"_cpm",Ps=["__proto__","constructor","prototype"],xs=e=>{if(!gt(e))return{};var t={};return Object.keys(e).forEach(i=>{-1===Ps.indexOf(i)&&(t[i]=e[i])}),t},Es=function(e,t){void 0===t&&(t=[]);var i={};return[...ws,...t].forEach(t=>{var s=e[t];ft(s)||bt(s)||""===s||(i[t]=s)}),i},Cs=e=>{for(var t=5381,i=2166136261,s=0;e.length>s;s++){var r=e.charCodeAt(s);t=33*t^r,i=Math.imul(i^r,16777619)}return e.length.toString(36)+"."+(t>>>0).toString(36)+"."+(i>>>0).toString(36)},ks=(e,t)=>({p:t,f:Cs(JSON.stringify(e))}),Is=(e,t)=>{if(!t)return{properties:[],isValid:!1};try{var i=fs._parse(Ss(e)),s=(null==i?void 0:i.f)===Cs(t)&&ht(i.p);return{properties:s?i.p:[],isValid:s}}catch(e){return{properties:[],isValid:!1}}},Ts=(e,t)=>t+"|"+(fs._get(Ss(e))||""),$s={},Fs={_is_supported:()=>!0,_error(e){Ji.error("memoryStorage error: "+e)},_get:e=>e in $s?$s[e]:null,_parse:e=>e in $s?$s[e]:null,_set:(e,t)=>($s[e]=t,!0),_remove(e){delete $s[e]}},Rs=null,Os={_is_supported(){if(!bt(Rs))return Rs;if(Rs=!0,ft(ze))Rs=!1;else try{var e="__support__";Os._set(e,"xyz"),'"xyz"'!==Os._get(e)&&(Rs=!1),Os._remove(e)}catch(e){Rs=!1}return Rs},_error(e){Ji.error("sessionStorage error: ",e)},_get(e){try{return null==ze?void 0:ze.sessionStorage.getItem(e)}catch(e){Os._error(e)}return null},_parse(e){try{return JSON.parse(Os._get(e))||null}catch(e){}return null},_set(e,t){try{return null==ze||ze.sessionStorage.setItem(e,JSON.stringify(t)),!0}catch(e){Os._error(e)}return!1},_remove(e){try{null==ze||ze.sessionStorage.removeItem(e)}catch(e){Os._error(e)}}},As=class{constructor(e){this._instance=e}get _config(){return this._instance.config}get consent(){return this._getDnt()?0:this._storedConsent}isOptedOut(){return"always"===this._config.cookieless_mode||this.isRejected()||-1===this.consent&&"on_reject"===this._config.cookieless_mode}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return 0===this.consent}isRejected(){return 0===this.consent||-1===this.consent&&this._config.opt_out_capturing_by_default}optInOut(e){this._storage._set(this._storageKey,e?1:0,this._config.cookie_expiration,this._config.cross_subdomain_cookie,this._config.secure_cookie)}reset(){this._storage._remove(this._storageKey,this._config.cross_subdomain_cookie)}get _storageKey(){var e=this._instance.config,t=e.token,i=e.opt_out_capturing_cookie_prefix;return e.consent_persistence_name||(i?i+t:"__ph_opt_in_out_"+t)}get _storedConsent(){var e=this._storage._get(this._storageKey);return Tt(e)?1:lt($t,e)?0:-1}get _storage(){var e=this._config.opt_out_capturing_persistence_type,t="localStorage"===e?ys:fs,i=t._is_supported()?t:Fs;if(!this._persistentStore||this._persistentStore!==i){this._persistentStore=i;var s="localStorage"===e?fs:ys;s._get(this._storageKey)&&(this._persistentStore._get(this._storageKey)||this.optInOut(Tt(s._get(this._storageKey))),s._remove(this._storageKey,this._config.cross_subdomain_cookie))}return this._persistentStore}_getDnt(){return!!this._config.respect_dnt&&[null==Je?void 0:Je.doNotTrack,null==Je?void 0:Je.msDoNotTrack,rt.doNotTrack,null==Je?void 0:Je.globalPrivacyControl].some(e=>Tt(e))}},Ms=["next","previous","prev",">","<","+","-","−","–"];Yi("[Dead Clicks]");var Ds=e=>{var t,i=!(null==(t=e.instance.persistence)||!t.get_property(E)),s=e.instance.config.capture_dead_clicks;return xt(s)?s:!!gt(s)||i},Ls=Yi("[SegmentIntegration]");function Ns(e,t,s){void 0===s&&(s=!0);var r=e.config.segment;if(!r)return t();var n,o=(e=>pt(e.register))(n=r)?{analytics:n}:n,a=o.analytics,l=o.filterProperties;!function(e,t,i,s){var r=t=>{var r=()=>t.anonymousId()||cs();e.config.get_device_id=r,s&&t.id()&&(e.register({distinct_id:t.id(),$device_id:r()}),e.persistence.set_property(me,Be)),i(s?void 0:t.anonymousId()||void 0)},n=t.user();"then"in n&&pt(n.then)?n.then(r):r(n)}(e,a,s=>{a.register(function(e,t,s){var r=(void 0===s?{}:s).filterProperties;"undefined"!=typeof Promise&&Promise.resolve||Ls.warn("This browser does not have Promise support, and can not use the segment integration");var n=(s,n)=>{if(!n)return s;var o=!!t&&s.event.anonymousId===t&&!s.event.userId;o||s.event.userId||s.event.anonymousId===e.get_distinct_id()||(Ls.info("No userId set, resetting PostHog"),e.reset()),o||(t=void 0),s.event.userId&&s.event.userId!==e.get_distinct_id()&&(Ls.info("UserId set, identifying with PostHog"),e.identify(s.event.userId));var a=e.calculateEventProperties(n,s.event.properties);if(!wt(r)){var l=s.event.properties||{},d={};for(var u of Object.keys(a))_t.call(l,u)||(d[u]=a[u]);var _=((e,t)=>{var s=ht(e)?e:[e],r=i({},t);for(var n of s)try{if(r=n(r),wt(r))return null}catch(e){return Ls.error("Error in Segment filterProperties:",e),null}return r})(r,d);if(wt(_))return s;a=_}return s.event.properties=Object.assign({},a,s.event.properties),s};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded(){return!0},load(){return Promise.resolve()},track(e){return n(e,e.event.event)},page(e){return n(e,Ge)},identify(e){return n(e,Ve)},screen(e){return n(e,"$screen")}}}(e,s,{filterProperties:l})).then(()=>{t()},e=>{Ls.error("Failed to register the Segment integration",e),t()})},s)}var Bs="posthog-js";function Us(e,t){var s=void 0===t?{}:t,r=s.organization,n=s.projectId,o=s.prefix,a=s.severityAllowList,l=void 0===a?["error"]:a,d=s.sendExceptionsToPostHog,u=void 0===d||d;return t=>{var s,a,d,_,c,h;if("*"!==l&&!l.includes(t.level)||!e.__loaded)return t;t.tags||(t.tags={});var p=e.requestRouter.endpointFor("ui","/project/"+e.config.token+"/person/"+e.get_distinct_id());t.tags["PostHog Person URL"]=p,e.sessionRecordingStarted()&&(t.tags["PostHog Recording URL"]=e.get_session_replay_url({withTimestamp:!0}));var g=(null==(s=t.exception)?void 0:s.values)||[],v=g.map(e=>i({},e,{stacktrace:e.stacktrace?i({},e.stacktrace,{type:"raw",frames:(e.stacktrace.frames||[]).map(e=>i({},e,{platform:"web:javascript"}))}):void 0})),f={$exception_message:(null==(a=g[0])?void 0:a.value)||t.message,$exception_type:null==(d=g[0])?void 0:d.type,$exception_level:t.level,$exception_list:v,$sentry_event_id:t.event_id,$sentry_exception:t.exception,$sentry_exception_message:(null==(_=g[0])?void 0:_.value)||t.message,$sentry_exception_type:null==(c=g[0])?void 0:c.type,$sentry_tags:t.tags};return r&&n&&(f.$sentry_url=(o||"https://sentry.io/organizations/")+r+"/issues/?project="+n+"&query="+t.event_id),u&&(null==(h=e.exceptions)||h.sendExceptionEvent(f)),t}}var qs=class{constructor(e,t,i,s,r,n){this.name=Bs,this.setupOnce=function(o){o(Us(e,{organization:t,projectId:i,prefix:s,severityAllowList:r,sendExceptionsToPostHog:null==n||n}))}}},Hs=class{constructor(e){this._onSessionIdChange=(e,t,i)=>{i&&(i.noSessionId||i.activityTimeout||i.sessionPastMaximumLength||i.crossTabAdoption)&&(Ji.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:e,changeReason:i}),this._currentPageview=void 0,this._instance.scrollManager.resetContext())},this._instance=e,this._setupSessionRotationHandler()}_setupSessionRotationHandler(){var e;this._unsubscribeSessionId=null==(e=this._instance.sessionManager)?void 0:e.onSessionId(this._onSessionIdChange)}destroy(){var e;null==(e=this._unsubscribeSessionId)||e.call(this),this._unsubscribeSessionId=void 0}doPageView(e,t){var i,s=this._previousPageViewProperties(e,t);return this._currentPageview={pathname:null!==(i=null==ze?void 0:ze.location.pathname)&&void 0!==i?i:"",pageViewId:t,timestamp:e},this._instance.scrollManager.resetContext(),s}doPageLeave(e){var t;return this._previousPageViewProperties(e,null==(t=this._currentPageview)?void 0:t.pageViewId)}doEvent(){var e;return{$pageview_id:null==(e=this._currentPageview)?void 0:e.pageViewId}}_previousPageViewProperties(e,t){var i=this._currentPageview;if(!i)return{$pageview_id:t};var s={$pageview_id:t,$prev_pageview_id:i.pageViewId},r=this._instance.scrollManager.getContext();if(r&&!this._instance.config.disable_scroll_properties){var n=r.maxScrollHeight,o=r.lastScrollY,a=r.maxScrollY,l=r.maxContentHeight,d=r.lastContentY,u=r.maxContentY;if(!(ft(n)||ft(o)||ft(a)||ft(l)||ft(d)||ft(u))){n=Math.ceil(n),o=Math.ceil(o),a=Math.ceil(a),l=Math.ceil(l),d=Math.ceil(d),u=Math.ceil(u);var _=n>1?Ot(o/n,0,1,Ji):1,c=n>1?Ot(a/n,0,1,Ji):1,h=l>1?Ot(d/l,0,1,Ji):1,p=l>1?Ot(u/l,0,1,Ji):1;s=Zi(s,{$prev_pageview_last_scroll:o,$prev_pageview_last_scroll_percentage:_,$prev_pageview_max_scroll:a,$prev_pageview_max_scroll_percentage:c,$prev_pageview_last_content:d,$prev_pageview_last_content_percentage:h,$prev_pageview_max_content:u,$prev_pageview_max_content_percentage:p})}}return i.pathname&&(s.$prev_pageview_pathname=i.pathname),i.timestamp&&(s.$prev_pageview_duration=(e.getTime()-i.timestamp.getTime())/1e3),s}},Gs=["flags","surveys"],Ws={[l]:{exposure:"hidden"},[c]:{exposure:"hidden"},[h]:{exposure:"hidden"},[m]:{exposure:"hidden"},[g]:{exposure:"hidden"},[f]:{exposure:"hidden"},[y]:{exposure:"event"},[b]:{exposure:"hidden"},[k]:{exposure:"hidden"},[w]:{exposure:"event"},[S]:{exposure:"hidden"},[P]:{exposure:"event"},[x]:{exposure:"event"},[E]:{exposure:"event"},[C]:{exposure:"hidden"},[I]:{exposure:"event"},[T]:{exposure:"hidden"},[F]:{exposure:"hidden"},[L]:{exposure:"hidden"},[N]:{exposure:"event"},[R]:{exposure:"event",shouldSkipFromEventProperties:e=>bt(e)},[B]:{exposure:"event"},[U]:{exposure:"event"},[q]:{exposure:"event"},[H]:{exposure:"event"},[G]:{exposure:"hidden"},[W]:{exposure:"hidden",storageGroup:"flags"},[V]:{exposure:"hidden",storageGroup:"flags"},[j]:{exposure:"hidden"},[z]:{exposure:"hidden",storageGroup:"flags"},[K]:{exposure:"hidden",storageGroup:"flags"},[J]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[Y]:{exposure:"hidden",storageGroup:"flags"},[Q]:{exposure:"hidden"},[X]:{exposure:"hidden"},[Z]:{exposure:"hidden"},[ee]:{exposure:"hidden"},[ie]:{exposure:"hidden",storageGroup:"surveys"},[se]:{exposure:"hidden",storageGroup:"surveys",volatile:!0},[re]:{exposure:"event"},[ne]:{exposure:"hidden"},[oe]:{exposure:"hidden"},[ae]:{exposure:"hidden"},[le]:{exposure:"hidden"},[de]:{exposure:"hidden"},[ue]:{exposure:"event"},[_e]:{exposure:"event"},[ce]:{exposure:"event"},[he]:{exposure:"event"},[pe]:{exposure:"hidden"},[ge]:{exposure:"hidden"},[te]:{exposure:"event"},[ve]:{exposure:"hidden"},[fe]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[me]:{exposure:"hidden"},[ye]:{exposure:"hidden"},[be]:{exposure:"hidden"},[we]:{exposure:"hidden"},[Se]:{exposure:"hidden"},[Pe]:{exposure:"hidden"},[xe]:{exposure:"hidden"},[O]:{exposure:"event"},[A]:{exposure:"event"},[M]:{exposure:"event"},[D]:{exposure:"event"},[ke]:{exposure:"event"},[Ie]:{exposure:"event"},[Te]:{exposure:"event"},[$e]:{exposure:"event"},[Fe]:{exposure:"event"},[Re]:{exposure:"event"},[Oe]:{exposure:"event"},[Ae]:{exposure:"event"},[Me]:{exposure:"event"},[De]:{exposure:"event"},[Le]:{exposure:"event"}},Vs=[["$posthog_sr_group_event_trigger_",{exposure:"hidden"}],["$posthog_sr_group_url_trigger_",{exposure:"hidden"}],["$posthog_sr_group_sampling_",{exposure:"hidden"}]],js=e=>{var t=Ws[e];if(t)return t;for(var i of Vs){var s=i[1];if(0===e.indexOf(i[0]))return s}},zs=(e,t)=>{try{var i;return JSON.stringify(e,(e,t)=>kt(t)?(null!=i||(i=new WeakMap),i.has(t)||i.set(t,is(t)),i.get(t)):"bigint"==typeof t?t.toString():t,t)}catch(t){return r=[],null!==(s=JSON.stringify(e,function(e,t){if("bigint"==typeof t)return t.toString();if("function"!=typeof t&&"symbol"!=typeof t){if(t instanceof Error)return{name:t.name,message:t.message,stack:t.stack};if(t&&"object"==typeof t){for(;r.length>0&&r[r.length-1]!==this;)r.pop();if(r.includes(t))return"[Circular]";r.push(t)}return t}}))&&void 0!==s?s:"null"}var s,r},Ks=e=>{var t=null==Ye?void 0:Ye.createElement("a");return ft(t)?null:(t.href=e,t)},Js=function(e,t){for(var i,s=((e.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),r=0;s.length>r;r++){var n=s[r].split("=");if(n[0]===t){i=n;break}}if(!ht(i)||2>i.length)return"";var o=i[1];try{o=decodeURIComponent(o)}catch(e){Ji.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},Ys=function(e,t,i){if(!e||!t||!t.length)return e;for(var s=e.split("#"),r=s[1],n=(s[0]||"").split("?"),o=n[1],a=n[0],l=(o||"").split("&"),d=[],u=0;l.length>u;u++){var _=l[u].split("=");ht(_)&&(t.includes(_[0])?d.push(_[0]+"="+i):d.push(l[u]))}var c=a;return null!=o&&(c+="?"+d.join("&")),null!=r&&(c+="#"+r),c},Qs=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],Xs=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...Qs],Zs="<masked>",er=["li_fat_id"];function tr(e,t){var i=Xs.concat(t||[]),s={};return Xi(i,function(t){var i=Js(e,t);s[t]=i||null}),s}function ir(e){var t=function(e){return e?0===e.search("https?://(.*)google.([^/?]*)")?"google":0===e.search("https?://(.*)bing.com")?"bing":0===e.search("https?://(.*)yahoo.com")?"yahoo":0===e.search("https?://(.*)duckduckgo.com")?"duckduckgo":null:null}(e),i="yahoo"!=t?"q":"p",s={};if(!bt(t)){s.$search_engine=t;var r=Ye?Js(Ye.referrer,i):"";r.length&&(s.ph_keyword=r)}return s}function sr(){return navigator.language||navigator.userLanguage}var rr="$direct";function nr(){return(null==Ye?void 0:Ye.referrer)||rr}function or(e,t,i){var s;void 0===i&&(i=!1);var r=e?[...Qs,...t||[]]:[],n=null==(s=i?Ni(null==Qe?void 0:Qe.href):null==Qe?void 0:Qe.href)?void 0:s.substring(0,1e3);return{r:nr().substring(0,1e3),u:n?Ys(n,r,Zs):void 0}}function ar(e,t){var i;void 0===t&&(t=!1);var s=e.r,r=e.u,n=t?Ni(r):r,o={$referrer:s,$referring_domain:null==s?void 0:s==rr?rr:null==(i=Ks(s))?void 0:i.host};if(n){o.$current_url=n;var a=Ks(n);o.$host=null==a?void 0:a.host,o.$pathname=null==a?void 0:a.pathname,Zi(o,tr(n))}return s&&Zi(o,ir(s)),o}function lr(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(e){return}}function dr(){try{return(new Date).getTimezoneOffset()}catch(e){return}}var ur={flags:fe,surveys:se},_r=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],cr=e=>e+"_cookie_identity_change_pending",hr=e=>{var t="",i=0;for(var s of e){var r=encodeURIComponent(JSON.stringify(s).slice(1,-1)).length;if(i+r>1e3)break;t+=s,i+=r}return t},pr="main",gr=[W,V,z,K,J,fe,Y,Z],vr=e=>-1!==gr.indexOf(e),fr=[g,f],mr=e=>-1!==fr.indexOf(e),yr=(e,t)=>{try{return JSON.stringify(e)===JSON.stringify(t)}catch(i){return e===t}},br=e=>{if(!e)return{};var t=JSON.parse(e);return gt(t)?t:{}},wr=(e,t)=>{Xi(e,(i,s)=>{var r=js(s);r&&"event"!==r.exposure||{}.hasOwnProperty.call(t,s)||delete e[s]})},Sr=class{constructor(e,t,s){if(void 0===s&&(s=!0),this._slotState={},this._splitStorageEligible=!1,this._storesIdentityInCookie=!1,this._splitStorage=!1,this._cookieIdentityChangePending=!1,this._cookieSyncSuppressed=!1,this._pendingCrossTabFeatureFlagChanges=new Map,this._storageMigrationInProgress=!1,this._localIdentityChangePending=!1,this._crossTabFeatureFlagIdentityMismatch=!1,this._metaIdentifierChangePending=new Set,this._crossTabFeatureFlagHandlers=new Set,this._config=e,this._ownsSplitStorage=s,this.props={},this._campaign_params_url=void 0,this._name=(e=>{var t="";return e.token&&(t=e.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),e.persistence_name?"ph_"+e.persistence_name:"ph_"+t+"_posthog"})(e),this._storage=this._buildStorage(e),this._splitStorage=this._resolveSplitStorage(e),this.load(),this._markLoadedCrossTabFeatureFlagChangesPending(),e.debug&&Ji.info("Persistence loaded",e.persistence,i({},this.props)),this.update_config(e,e,t),this.save(),ze){var r=()=>this.flush();ns(ze,"beforeunload",r,{capture:!1}),ns(ze,"pagehide",r,{capture:!1}),this._onStorage=e=>{if(this._splitStorageEligible&&(!e.storageArea||e.storageArea===(null==ze?void 0:ze.localStorage))&&e.key)if(e.key!==this._name){if(this._splitStorage){var t=Gs.find(t=>e.key===this._groupEntryName(t));t&&this._syncCrossTabFeatureFlagProperties(e.key,t)}}else this._syncCrossTabFeatureFlagProperties(e.key,pr)},ns(ze,"storage",this._onStorage)}}markCrossTabFeatureFlagChanges(e){Object.entries(e).forEach(e=>{var t=e[0],i=e[1],s=this._pendingCrossTabFeatureFlagChanges.get(t);if(vr(t)&&!0!==s)if(!0!==i){var r=new Set(s||[]);i.forEach(e=>r.add(e)),r.size&&this._setCrossTabFeatureFlagChangesPending(t,r)}else this._setCrossTabFeatureFlagChangesPending(t,!0)})}onCrossTabFeatureFlagChange(e){return this._crossTabFeatureFlagHandlers.add(e),()=>this._crossTabFeatureFlagHandlers.delete(e)}destroy(){this._onStorage&&ze&&(ze.removeEventListener("storage",this._onStorage),this._onStorage=void 0),this._crossTabFeatureFlagHandlers.clear()}_syncCrossTabFeatureFlagProperties(e,t,i){if(void 0===i&&(i=!0),this._disabled)return!1;var s,r;try{if(r=ys._get(e),bt(r)){var n=this._slotWriteState(t);return n.storageValue=null,t!==pr&&(n.persisted=!1),!1}s=br(r)}catch(e){return!1}var o=t===pr?s:ys._parse(this._name);if(o&&this._hasCrossTabFeatureFlagIdentityMismatch(o))return!1;var a=this._mergeCrossTabFeatureFlagProperties(s,t,i);return t===pr&&this._splitStorage&&!yr(this._partitionProps().main,s)||this._rememberCrossTabStorageFingerprint(s,t,!0,r),a}_hasCrossTabFeatureFlagIdentityMismatch(e){var t=this.props[d],i=e[d];return!ft(t)&&!ft(i)&&t!==i}_rememberCrossTabStorageFingerprint(e,t,i,s){var r=this._slotWriteState(t);r.storageValue=s,t!==pr&&(r.persisted=i);try{r.fingerprint=this._entryFingerprint(e,t)}catch(e){r.fingerprint=void 0}}_mergeCrossTabFeatureFlagProperties(e,t,i){var s=!1;return gr.forEach(i=>{var r,n=null==(r=js(i))?void 0:r.storageGroup;if(!(t===pr&&this._splitStorage&&n||t!==pr&&n!==t)){var o=i in e,a=this._mergePendingCrossTabFeatureFlagChanges(i,o?e[i]:void 0),l=this._pendingCrossTabFeatureFlagChanges.has(i)?i in this.props:o;l===i in this.props&&yr(a,this.props[i])||(l?this._setProp(i,a,!1):this._deleteProp(i,!1),s=!0)}}),s&&i&&this._crossTabFeatureFlagHandlers.forEach(e=>e()),s}_reconcileCrossTabFeatureFlagPropertiesBeforeWrite(){if(!this._splitStorageEligible)return!1;try{this._crossTabFeatureFlagIdentityMismatch=!1;var e,t=ys._get(this._name),i=this._slotWriteState(pr),s=!1,r=!1;if(t!==i.storageValue)if(bt(t))i.storageValue=null;else{if(e=br(t),this._crossTabFeatureFlagIdentityMismatch=!this._localIdentityChangePending&&this._hasCrossTabFeatureFlagIdentityMismatch(e),this._crossTabFeatureFlagIdentityMismatch)return!1;r=this._mergeCrossTabFeatureFlagProperties(e,pr,!1),!this._splitStorage||yr(this._partitionProps().main,e)?this._rememberCrossTabStorageFingerprint(e,pr,!0,t):i.storageValue=t,s=!0}return this._splitStorage&&Gs.forEach(t=>{var i=ys._get(this._groupEntryName(t)),n=this._slotWriteState(t),o=e||{},a=s&&gr.some(e=>{var i;return(null==(i=js(e))?void 0:i.storageGroup)===t&&e in o});if(i!==n.storageValue||a){if(bt(i))return n.storageValue=null,n.persisted=!1,void(a&&(r=this._mergeCrossTabFeatureFlagProperties(o,t,!1)||r));var l=br(i);r=this._mergeCrossTabFeatureFlagProperties(l,t,!1)||r,this._rememberCrossTabStorageFingerprint(l,t,!0,i)}}),r}catch(e){return!1}}_setCrossTabFeatureFlagChangesPending(e,t){this._pendingCrossTabFeatureFlagChanges.set(e,t);var i=js(e);null!=i&&i.volatile||(this._slotWriteState((this._splitStorage?null==i?void 0:i.storageGroup:void 0)||pr).fingerprint=void 0,this._markGroupDirty(e))}_markAllCrossTabFeatureFlagChangesPending(){gr.forEach(e=>this._pendingCrossTabFeatureFlagChanges.set(e,!0))}_markLoadedCrossTabFeatureFlagChangesPending(){if(this._splitStorageEligible)try{var e=ys._get(this._name),t=br(e);this._slotWriteState(pr).storageValue=e,gr.forEach(e=>{var i,s=this._splitStorage?null==(i=js(e))?void 0:i.storageGroup:void 0,r=s?ys._get(this._groupEntryName(s)):null;if(s){var n=this._slotWriteState(s);n.storageValue=r,n.persisted=!bt(r)}var o=s&&!bt(r)?br(r):t;e in this.props?this._markPendingCrossTabFeatureFlagChanges(e,o[e],this.props[e]):e in o&&this._setCrossTabFeatureFlagChangesPending(e,!0)})}catch(e){}}_mergePendingCrossTabFeatureFlagChanges(e,t){var s=this._pendingCrossTabFeatureFlagChanges.get(e);if(!s)return t;if(!0===s)return this.props[e];if("$active_feature_flags"===e){var r=new Set(ht(t)?t:[]),n=new Set(ht(this.props[e])?this.props[e]:[]);return s.forEach(e=>n.has(e)?r.add(e):r.delete(e)),Array.from(r)}var o=gt(t)?i({},t):{},a=gt(this.props[e])?this.props[e]:{};return s.forEach(e=>{e in a?o[e]=a[e]:delete o[e]}),o}_markPendingCrossTabFeatureFlagChanges(e,t,i){if(vr(e)){var s=this._pendingCrossTabFeatureFlagChanges.get(e);if(!0!==s){var r=t;if(this._splitStorageEligible)try{var n,o=this._splitStorage?null==(n=js(e))?void 0:n.storageGroup:void 0,a=o?this._groupEntryName(o):this._name;r=br(ys._get(a))[e]}catch(e){}var l=new Set(s||[]);if("$active_feature_flags"===e){if(!ft(t)&&!ht(t)||!ft(r)&&!ht(r)||!ht(i))return void this._setCrossTabFeatureFlagChangesPending(e,!0);var d=new Set(t||[]),u=new Set(r||[]),_=new Set(i);new Set([...d,..._]).forEach(e=>{d.has(e)!==_.has(e)&&l.add(e)}),l.forEach(e=>{u.has(e)===_.has(e)&&l.delete(e)})}else{if(!gt(i))return void(yr(r,i)?this._pendingCrossTabFeatureFlagChanges.delete(e):this._setCrossTabFeatureFlagChangesPending(e,!0));if(!ft(t)&&!gt(t)||ft(t)&&vt(i)&&ft(r))return void this._setCrossTabFeatureFlagChangesPending(e,!0);var c=gt(t)?t:{},h=gt(r)?r:{};new Set([...Object.keys(c),...Object.keys(i)]).forEach(e=>{e in c==e in i&&yr(c[e],i[e])||l.add(e)}),l.forEach(e=>{e in h==e in i&&yr(h[e],i[e])&&l.delete(e)})}l.size?this._setCrossTabFeatureFlagChangesPending(e,l):this._pendingCrossTabFeatureFlagChanges.delete(e)}}}_saveDebounceMs(){var e,t=null==(e=this._config)?void 0:e.persistence_save_debounce_ms;return St(t)&&t>0?t:0}_rememberCurrentCookieProperties(e){if(this._config.cookieWinsOnConflict&&"localstorage+cookie"===this._config.persistence.toLowerCase())if(e)try{var t=Es(e,this._config.cookie_persisted_properties||[]),i=ks(t,this._config.cookie_persisted_properties||[]),s=JSON.stringify(t)+"|"+JSON.stringify(i),r=fs._get(this._name)||void 0;r&&Ts(this._name,r)===s&&(this._lastSeenCookiePropertiesFingerprint=s,this._lastSeenMainCookieValue=r)}catch(e){}else try{var n=fs._get(this._name)||void 0;this._lastSeenCookiePropertiesFingerprint=n?Ts(this._name,n):void 0,this._lastSeenMainCookieValue=n}catch(e){}}syncCookieProperties(){return this._syncCookieProperties(this._config)}_syncCookieProperties(e,t){if(void 0===t&&(t=!1),this._disabled&&!t||this._cookieSyncSuppressed||!e.cookieWinsOnConflict||"localstorage+cookie"!==e.persistence.toLowerCase())return!1;var i;try{i=fs._get(this._name)||void 0}catch(e){}if(!i||i===this._lastSeenMainCookieValue)return!1;var s,r=Ts(this._name,i);try{s=xs(JSON.parse(i))}catch(e){return!1}if((fs._get(this._name)||void 0)!==i)return!1;this._lastSeenCookiePropertiesFingerprint=r,this._lastSeenMainCookieValue=i;var n=Is(this._name,i),o=[...ws,...n.properties],a={};if(Object.keys(s).forEach(e=>{var t=s[e];(ft(t)||bt(t)||""===t||"$user_state"===e&&"anonymous"!==t&&"identified"!==t)&&(a[e]=!0,delete s[e])}),vt(s))return!1;var l="distinct_id"in s||"anonymous"===s.$user_state||"identified"===s.$user_state,u=this.props,_=u[d],h=u[me],p=Zi({},u);[...ws,...e.cookie_persisted_properties||[]].forEach(e=>{if(-1!==o.indexOf(e)&&!(e in s)&&!a[e]&&(l||"distinct_id"!==e&&"$user_state"!==e)){var t=p[e];(n.isValid||-1===ws.indexOf(e)||!1!==t&&0!==t)&&delete p[e]}}),this.props=Zi(p,s),gr.forEach(e=>{var t=e in this.props;e in u===t&&yr(u[e],this.props[e])||(t?this._markPendingCrossTabFeatureFlagChanges(e,u[e],this.props[e]):this._setCrossTabFeatureFlagChangesPending(e,!0))}),!l||"$user_state"in s||"$user_state"in this.props||this._setProp(me,Ne);var g=this.props[d],v=this.props[me];return!l||g===_&&v===h||(this._localIdentityChangePending=!0,this._cookieIdentityChangePending=!0,Os._set(cr(this._name),!0),this._deleteProp(Z),this._deleteProp(V),this._deleteProp(W),this._deleteProp(z),this._deleteProp(K),this._deleteProp(J),this._deleteProp(fe),this._deleteProp(ve),this._deleteProp(pe),"anonymous"!==v||"identified"!==h&&"anonymous"!==s.$user_state&&(ft(_)||g===_)||(wr(this.props,s),this._deleteProp(ee)),"identified"===v?this.props.$user_id=g:delete this.props.$user_id,this._deleteProp(c)),!0}consumeCookieIdentityChange(){var e=cr(this._name),t=this._cookieIdentityChangePending||!!Os._get(e);return this._cookieIdentityChangePending=!1,t&&Os._remove(e),t}_beginCookieSyncSuppression(e){return void 0===e&&(e=!1),!(this._cookieSyncSuppressed||this._disabled&&!e||!this._config.cookieWinsOnConflict||"localstorage+cookie"!==this._config.persistence.toLowerCase()||(this._cookieSyncSuppressed=!0,0))}_publishSuppressedCookieSnapshot(){this._cookieSyncSuppressed&&(ft(this._pendingSaveTimer)||(clearTimeout(this._pendingSaveTimer),this._pendingSaveTimer=void 0),delete this._slotState[pr],this._writeNow(!0))}_endCookieSyncSuppression(e){if(void 0===e&&(e=!0),this._cookieSyncSuppressed)try{e?this._publishSuppressedCookieSnapshot():ft(this._pendingSaveTimer)||(clearTimeout(this._pendingSaveTimer),this._pendingSaveTimer=void 0)}finally{this._cookieSyncSuppressed=!1}}isDisabled(){return!!this._disabled}_buildStorage(e){-1===_r.indexOf(e.persistence.toLowerCase())&&(Ji.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var t,s=function(e,t){void 0===e&&(e=[]),void 0===t&&(t=!1);var s=[...ws,...e];return i({},ys,{_parse(e){try{var i,r={};try{i=fs._get(e)||void 0,r=i?xs(JSON.parse(i)):{}}catch(e){}var n,o=JSON.parse(ys._get(e)||"{}");if(t){var a=Is(e,i),l=[...ws,...a.properties],u={};Object.keys(r).forEach(e=>{var t=r[e];bt(t)||""===t||"$user_state"===e&&"anonymous"!==t&&"identified"!==t||(u[e]=t)});var _="distinct_id"in u||"anonymous"===u.$user_state||"identified"===u.$user_state;if(Object.keys(u).length>0){var c,h=o[d],p=null!==(c=o.$user_state)&&void 0!==c?c:"anonymous";s.forEach(e=>{if(-1!==l.indexOf(e)&&!(e in r)&&(_||"distinct_id"!==e&&"$user_state"!==e)){var t=o[e];(a.isValid||-1===ws.indexOf(e)||!1!==t&&0!==t)&&delete o[e]}}),!_||"$user_state"in r||"$user_state"in o||(o[me]=Ne),!_||("distinct_id"in u?u[d]:o[d])===h&&("$user_state"in u?u[me]:o[me])===p||(bs.forEach(e=>delete o[e]),"identified"===u.$user_state&&"distinct_id"in u?o.$user_id=u[d]:delete o.$user_id,"identified"!==u.$user_state&&(delete o[te],delete o[ee]),delete o.__alias)}n=Zi(o,u)}else n=Zi(r,o);return ys._set(e,n),n}catch(e){}return null},_set(i,s,r,n,o,a){var l=ys._set(i,s,void 0,void 0,a);try{var d=Es(s,e);if(Object.keys(d).length){if(t){var u=Ss(i),_=ks(d,e);if(fs._set(u,_,r,n,o,a),fs._get(u)!==JSON.stringify(_)){fs._remove(u,n);var c=Es(s);return fs._set(i,c,r,n,o,a),l}}fs._set(i,d,r,n,o,a)}}catch(e){ys._error(e)}return l},_remove(e,t){try{null==ze||ze.localStorage.removeItem(e),fs._remove(e,t),fs._remove(Ss(e),t)}catch(e){ys._error(e)}}})}(e.cookie_persisted_properties||[],e.cookieWinsOnConflict),r=!1,n=!1,o=e.persistence.toLowerCase();return"localstorage"===o&&ys._is_supported()?(t=ys,n=!0):"localstorage+cookie"===o&&s._is_supported()?(t=s,n=!0,r=!0):"sessionstorage"===o&&Os._is_supported()?t=Os:"memory"===o?t=Fs:"cookie"===o&&fs._is_supported()?(t=fs,r=!0):s._is_supported()?(t=s,n=!0,r=!0):fs._is_supported()?(t=fs,r=!0):t=Fs,this._splitStorageEligible=n,this._storesIdentityInCookie=r,t}_groupEntryName(e){return this._name+"__"+e}_resolveSplitStorage(e){return this._splitStorageEligible&&!!e.split_storage}properties(){var e={};return Xi(this.props,(t,i)=>{var s=js(i);if(!s||"event"===s.exposure){if(null!=s&&null!=s.shouldSkipFromEventProperties&&s.shouldSkipFromEventProperties(t))return;e[i]=t}}),e}load(e){if(void 0===e&&(e=!1),!this._disabled||e){var t=this._config.cookieWinsOnConflict&&"localstorage+cookie"===this._config.persistence.toLowerCase(),i=t?ys._parse(this._name):null,s={};if(t)try{Xi(s=xs(fs._parse(this._name)),(e,t)=>{(ft(e)||bt(e)||""===e)&&delete s[t]})}catch(e){}var r=this._storage._parse(this._name);if(r&&(this.props=Zi({},r)),this._splitStorage&&this._loadGroupEntries(),t&&r){var n,o,a=null==i?void 0:i[d],l=null!==(n=null==i?void 0:i.$user_state)&&void 0!==n?n:"anonymous",u=r[d],_=null!==(o=r.$user_state)&&void 0!==o?o:"anonymous";if(u!==a||_!==l){this._cookieIdentityChangePending=!0,Os._set(cr(this._name),!0);var c=Zi({},this.props);bs.forEach(e=>delete c[e]),"anonymous"!==_||"identified"!==l&&"anonymous"!==s.$user_state&&(ft(a)||u===a)||(wr(c,s),delete c[ee]),this.props=c;var h=new Set;bs.forEach(e=>{var t,i=null==(t=js(e))?void 0:t.storageGroup;i&&h.add(i)}),h.forEach(e=>{var t={};Xi(this.props,(i,s)=>{var r;(null==(r=js(s))?void 0:r.storageGroup)===e&&(t[s]=i)}),vt(t)?(ys._remove(this._groupEntryName(e)),this._slotState[e]={}):ys._set(this._groupEntryName(e),t)&&(this._slotState[e]={persisted:!0,fingerprint:this._entryFingerprint(t,e)})})}}Os._get(cr(this._name))&&(this._cookieIdentityChangePending=!0)}}_loadGroupEntries(){for(var e of Gs){var t=ys._parse(this._groupEntryName(e));if(t&&!vt(t)){var i=this._slotWriteState(e);i.persisted=!0,this._mainCarriesGroupKey(e)||(i.fingerprint=this._entryFingerprint(t,e)),this._groupEntryIsStale(e,t)||Zi(this.props,t)}}}_mainCarriesGroupKey(e){return Object.keys(this.props).some(t=>{var i;return(null==(i=js(t))?void 0:i.storageGroup)===e})}_groupEntryIsStale(e,t){var i=ur[e];if(!i)return!1;var s=t[i],r=this.props[i];return St(s)&&St(r)&&r>s}refreshKey(e){var t;if(!this._disabled&&!this._metaIdentifierChangePending.has(e)){var i=this._splitStorage?null==(t=js(e))?void 0:t.storageGroup:void 0,s=i?ys._parse(this._groupEntryName(i)):this._storage._parse(this._name);if(s&&e in s)this._setProp(e,s[e],!1);else{if(i){var r=this._storage._parse(this._name);if(r&&e in r)return void this._setProp(e,r[e],!1)}this._deleteProp(e,!1)}}}save(){if(!this._disabled){var e=this._saveDebounceMs();e>0?ft(this._pendingSaveTimer)&&(this._pendingSaveTimer=setTimeout(()=>{this._pendingSaveTimer=void 0,this._writeNow()},e)):this._writeNow()}}flush(){ft(this._pendingSaveTimer)||(clearTimeout(this._pendingSaveTimer),this._pendingSaveTimer=void 0,this._writeNow())}_writeNow(e){if(void 0===e&&(e=!1),!(this._disabled||this._cookieSyncSuppressed&&!e)){e||(this.syncCookieProperties(),this._config.cookieWinsOnConflict&&"localstorage+cookie"===this._config.persistence.toLowerCase()||fr.forEach(e=>this.refreshKey(e)));var t=!e&&!this._storageMigrationInProgress;t||(this._crossTabFeatureFlagIdentityMismatch=!1);var i=!!t&&this._reconcileCrossTabFeatureFlagPropertiesBeforeWrite();if(this._crossTabFeatureFlagIdentityMismatch)this._config.debug&&Ji.warn("skipping persistence write because storage belongs to a different distinct ID");else{if(this._splitStorage)return this._writeNowSplit(),void(i&&this._crossTabFeatureFlagHandlers.forEach(e=>e()));var s=this._writeEntry(this._storage,this._name,this.props,pr);"written"===s&&this._rememberCurrentCookieProperties(this.props),"failed"!==s&&(this._pendingCrossTabFeatureFlagChanges.clear(),this._localIdentityChangePending=!1,this._metaIdentifierChangePending.clear()),i&&this._crossTabFeatureFlagHandlers.forEach(e=>e())}}}_writeNowSplit(){var e=this,t=this._partitionProps(),i=t.main,s=t.groups,r=this._writeEntry(this._storage,this._name,i,pr);"written"===r&&this._rememberCurrentCookieProperties(i),"failed"!==r&&(this._localIdentityChangePending=!1,this._metaIdentifierChangePending.clear(),gr.forEach(e=>{var t;null!=(t=js(e))&&t.storageGroup||this._pendingCrossTabFeatureFlagChanges.delete(e)}));var n=function(t){var i,r=s[t];if(vt(r)&&(null==(i=e._slotState[t])||!i.persisted))return gr.forEach(i=>{var s;(null==(s=js(i))?void 0:s.storageGroup)===t&&e._pendingCrossTabFeatureFlagChanges.delete(i)}),1;var n=e._writeEntry(ys,e._groupEntryName(t),r,t);"failed"!==n&&gr.forEach(i=>{var s=js(i);(null==s?void 0:s.storageGroup)!==t||"written"!==n&&s.volatile||e._pendingCrossTabFeatureFlagChanges.delete(i)})};for(var o of Gs)if(n(o))continue}_partitionProps(){var e={},t={flags:{},surveys:{}};return Xi(this.props,(i,s)=>{var r,n=null==(r=js(s))?void 0:r.storageGroup;n?t[n][s]=i:e[s]=i}),{main:e,groups:t}}_entryFingerprint(e,t){if(t===pr)return JSON.stringify(e)+"|"+this._expire_days+"|"+this._cross_subdomain+"|"+this._secure;var i={};return Xi(e,(e,t)=>{var s;i[t]=null!=(s=js(t))&&s.volatile?"__volatile__":e}),JSON.stringify(i)}_writeEntry(e,t,i,s){var r,n=this._slotWriteState(s);if(s!==pr&&!n.dirty&&!ft(n.fingerprint))return"skipped";try{if((r=this._entryFingerprint(i,s))===n.fingerprint)return n.dirty=!1,"skipped"}catch(e){r=void 0}return e._set(t,i,this._expire_days,this._cross_subdomain,this._secure,this._config.debug)?(n.dirty=!1,s!==pr&&(n.persisted=!0),ft(r)||(n.fingerprint=r),this._splitStorageEligible&&(n.storageValue=ys._get(t)),"written"):(this._config.debug&&Ji.warn('failed to persist storage entry "'+t+'"; will retry on next save'),"failed")}remove(e){var t=(void 0===e?{}:e).keepGroupEntries,i=void 0!==t&&t;if(this._markAllCrossTabFeatureFlagChangesPending(),ft(this._pendingSaveTimer)||(clearTimeout(this._pendingSaveTimer),this._pendingSaveTimer=void 0),this._storage._remove(this._name,!1),this._storage._remove(this._name,!0),!i&&this._ownsSplitStorage)for(var s of Gs)ys._remove(this._groupEntryName(s));i?delete this._slotState[pr]:this._slotState={},this._lastSeenCookiePropertiesFingerprint=void 0,this._lastSeenMainCookieValue=void 0}clear(){this.remove(),this.props={}}register_once(e,t,i){if(gt(e)){this.syncCookieProperties(),ft(t)&&(t="None"),this._expire_days=ft(i)?this._default_expiry:i;var s=!1;if(Xi(e,(e,i)=>{this.props.hasOwnProperty(i)&&this.props[i]!==t||(this._setProp(i,e),s=!0)}),s)return this.save(),!0}return!1}register(e,t){if(gt(e)){this.syncCookieProperties(),this._expire_days=ft(t)?this._default_expiry:t;var i=!1;if(Xi(e,(t,s)=>{e.hasOwnProperty(s)&&(this.props[s]!==t||gt(t)||ht(t))&&(this._setProp(s,t),i=!0)}),i)return this.save(),!0}return!1}unregister(e){this.syncCookieProperties();var t="string"==typeof e?[e]:e,i=!1;for(var s of t)s in this.props&&(this._deleteProp(s),i=!0);i&&this.save()}update_campaign_params(){var e=null==Ye?void 0:Ye.URL;if(e!==this._campaign_params_url){var t=function(e,t,i){if(!Ye)return{};var s,r=t?[...Qs,...i||[]]:[],n=tr(Ys(Ye.URL,r,Zs),e);return Zi((s={},Xi(er,function(e){var t=os(e);s[e]=t||null}),s),n)}(this._config.custom_campaign_params,this._config.mask_personal_data_properties,this._config.custom_personal_data_properties),i=!vt(ts(t));return i&&this.register(t),this._campaign_params_url=e,i?t:void 0}}update_search_keyword(){var e;this.register((e=null==Ye?void 0:Ye.referrer)?ir(e):{})}update_referrer_info(){var e;this.register_once({$referrer:nr(),$referring_domain:null!=Ye&&Ye.referrer&&(null==(e=Ks(Ye.referrer))?void 0:e.host)||rr},void 0)}set_initial_person_info(){if(!this.props.$initial_campaign_params&&!this.props.$initial_referrer_info){var e=or(this._config.mask_personal_data_properties,this._config.custom_personal_data_properties,this._config.disable_capture_url_hashes);this.register_once({[Pe]:this._storesIdentityInCookie?{r:hr(e.r),u:e.u?hr(e.u):void 0}:e},void 0)}}get_initial_props(){var e={};Xi([Se,we],t=>{var i=this.props[t];i&&Xi(i,function(t,i){e["$initial_"+dt(i)]=t})});var t=this.props[Pe];return t&&Zi(e,function(e,t){void 0===t&&(t=!1);var i=ar(e,t),s={};return Xi(i,function(e,t){s["$initial_"+dt(t)]=e}),s}(t,this._config.disable_capture_url_hashes)),e}safe_merge(e){return Xi(this.props,function(t,i){i in e||(e[i]=t)}),e}update_config(e,t,s){var r=e.persistence!==t.persistence,n=!((e,t)=>{if(e.length!==t.length)return!1;var i=[...e].sort(),s=[...t].sort();return i.every((e,t)=>e===s[t])})(e.cookie_persisted_properties||[],t.cookie_persisted_properties||[]),o=r||n,a=e.cookieWinsOnConflict!==t.cookieWinsOnConflict,l=e.disable_persistence||!!s,d=!!this._disabled&&!l;l||this._syncCookieProperties(t,d),this._config=e,!l&&(r||n||a)&&(this._lastSeenCookiePropertiesFingerprint=void 0,this._lastSeenMainCookieValue=void 0,this._syncCookieProperties(i({},e,{cookie_persisted_properties:t.cookie_persisted_properties}),d));var u=o||a?this._buildStorage(e):this._storage;this._truncateExistingPersonInfoForCookie();var _=this._resolveSplitStorage(e),c=o||_!==this._splitStorage,h=!l&&(c||e.cross_subdomain_cookie!==this._cross_subdomain||e.secure_cookie!==this._secure)&&this._beginCookieSyncSuppression(d);this._storageMigrationInProgress=c;try{if(this._default_expiry=this._expire_days=e.cookie_expiration,this.set_disabled(l),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),c){var p=this.props;this.clear(),this._storage=u,this._splitStorage=_,this.props=p,this.save()}else a&&(this._storage=u,l||(delete this._slotState[pr],this._writeNow()))}finally{this._storageMigrationInProgress=!1,h&&this._endCookieSyncSuppression()}}_truncateExistingPersonInfoForCookie(){var e=this.props[Pe];if(this._storesIdentityInCookie&&gt(e)&&"string"==typeof e.r){var t=hr(e.r),s="string"==typeof e.u?hr(e.u):e.u;t===e.r&&s===e.u||this._setProp(Pe,i({},e,{r:t,u:s}))}}set_disabled(e){this._disabled=e,this._disabled?this.remove():this.save()}set_cross_subdomain(e){e!==this._cross_subdomain&&(this._cross_subdomain=e,this.remove({keepGroupEntries:!0}),this.save())}set_secure(e){e!==this._secure&&(this._secure=e,this.remove({keepGroupEntries:!0}),this.save())}set_event_timer(e,t){var i=this.props.__timers||{};i[e]=t,this._setProp(m,i),this.save()}remove_event_timer(e){var t=this.props.__timers||{},i=t[e];return ft(i)||(delete t[e],this._setProp(m,t),this.save()),i}get_property(e){return this.props[e]}set_property(e,t){this._setProp(e,t),this.save()}_setProp(e,t,i){var s;void 0===i&&(i=!0);var r=this.props[e];this.props[e]=t,i&&("distinct_id"!==e&&"$user_state"!==e||r===t||(this._localIdentityChangePending=!0),mr(e)&&!yr(r,t)&&this._metaIdentifierChangePending.add(e),this._markPendingCrossTabFeatureFlagChanges(e,r,t),null!=(s=js(e))&&s.volatile||this._markGroupDirty(e))}_deleteProp(e,t){void 0===t&&(t=!0),delete this.props[e],t&&(vr(e)&&this._setCrossTabFeatureFlagChangesPending(e,!0),mr(e)&&this._metaIdentifierChangePending.add(e),this._markGroupDirty(e))}_markGroupDirty(e){var t,i=null==(t=js(e))?void 0:t.storageGroup;i&&(this._slotWriteState(i).dirty=!0)}_slotWriteState(e){return this._slotState[e]||(this._slotState[e]={})}},Pr={GZipJS:"gzip-js",Base64:"base64"},xr={Activation:"events",Cancellation:"cancelEvents"},Er={Button:"button",Tab:"tab",Selector:"selector"},Cr={TopLeft:"top_left",TopRight:"top_right",TopCenter:"top_center",MiddleLeft:"middle_left",MiddleRight:"middle_right",MiddleCenter:"middle_center",Left:"left",Center:"center",Right:"right",NextToTrigger:"next_to_trigger"},kr={Top:"top",Left:"left",Right:"right",Bottom:"bottom"},Ir={Popover:"popover",API:"api",Widget:"widget",ExternalSurvey:"external_survey"},Tr={Open:"open",MultipleChoice:"multiple_choice",SingleChoice:"single_choice",Rating:"rating",Link:"link"},$r={NextQuestion:"next_question",End:"end",ResponseBased:"response_based",SpecificQuestion:"specific_question"},Fr={Once:"once",Recurring:"recurring",Always:"always"},Rr={SHOWN:"survey shown",DISMISSED:"survey dismissed",SENT:"survey sent",ABANDONED:"survey abandoned"},Or={SURVEY_ID:"$survey_id",SURVEY_NAME:"$survey_name",SURVEY_RESPONSE:"$survey_response",SURVEY_ITERATION:"$survey_iteration",SURVEY_ITERATION_START_DATE:"$survey_iteration_start_date",SURVEY_PARTIALLY_COMPLETED:"$survey_partially_completed",SURVEY_SUBMISSION_ID:"$survey_submission_id",SURVEY_QUESTIONS:"$survey_questions",SURVEY_COMPLETED:"$survey_completed",PRODUCT_TOUR_ID:"$product_tour_id",SURVEY_LAST_SEEN_DATE:"$survey_last_seen_date",SURVEY_LANGUAGE:"$survey_language"},Ar={Popover:"popover",Inline:"inline"};function Mr(e){var t=!0;return{dispose(){if(t){t=!1;var i=e();i&&pt(i.then)&&i.then(void 0,()=>{})}}}}var Dr={backgroundColor:"#ffffff",textColor:"#1d1f27",buttonColor:"#1d1f27",borderRadius:8,buttonBorderRadius:6,borderColor:"#e5e7eb",fontFamily:"system-ui",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",showOverlay:!0,whiteLabel:!1,dismissOnClickOutside:!0,zIndex:2147483646},Lr={SHOWN:"product tour shown",DISMISSED:"product tour dismissed",COMPLETED:"product tour completed",STEP_SHOWN:"product tour step shown",STEP_COMPLETED:"product tour step completed",BUTTON_CLICKED:"product tour button clicked",STEP_SELECTOR_FAILED:"product tour step selector failed",BANNER_CONTAINER_SELECTOR_FAILED:"product tour banner container selector failed",BANNER_ACTION_CLICKED:"product tour banner action clicked"},Nr={TOUR_ID:"$product_tour_id",TOUR_NAME:"$product_tour_name",TOUR_ITERATION:"$product_tour_iteration",TOUR_RENDER_REASON:"$product_tour_render_reason",TOUR_STEP_ID:"$product_tour_step_id",TOUR_STEP_ORDER:"$product_tour_step_order",TOUR_STEP_TYPE:"$product_tour_step_type",TOUR_DISMISS_REASON:"$product_tour_dismiss_reason",TOUR_BUTTON_TEXT:"$product_tour_button_text",TOUR_BUTTON_ACTION:"$product_tour_button_action",TOUR_BUTTON_LINK:"$product_tour_button_link",TOUR_BUTTON_TOUR_ID:"$product_tour_button_tour_id",TOUR_STEPS_COUNT:"$product_tour_steps_count",TOUR_STEP_SELECTOR:"$product_tour_step_selector",TOUR_STEP_SELECTOR_FOUND:"$product_tour_step_selector_found",TOUR_STEP_ELEMENT_TAG:"$product_tour_step_element_tag",TOUR_STEP_ELEMENT_ID:"$product_tour_step_element_id",TOUR_STEP_ELEMENT_CLASSES:"$product_tour_step_element_classes",TOUR_STEP_ELEMENT_TEXT:"$product_tour_step_element_text",TOUR_ERROR:"$product_tour_error",TOUR_MATCHES_COUNT:"$product_tour_matches_count",TOUR_FAILURE_PHASE:"$product_tour_failure_phase",TOUR_WAITED_FOR_ELEMENT:"$product_tour_waited_for_element",TOUR_WAIT_DURATION_MS:"$product_tour_wait_duration_ms",TOUR_BANNER_SELECTOR:"$product_tour_banner_selector",TOUR_LINKED_SURVEY_ID:"$product_tour_linked_survey_id",USE_MANUAL_SELECTOR:"$use_manual_selector",INFERENCE_DATA_PRESENT:"$inference_data_present",TOUR_LAST_SEEN_DATE:"$product_tour_last_seen_date",TOUR_TYPE:"$product_tour_type"},Br=Yi("[RateLimiter]"),Ur=class{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=e=>{var t=e.text;if(t&&t.length)try{(JSON.parse(t).quota_limited||[]).forEach(e=>{Br.info((e||"events")+" is quota limited."),this.serverLimits[e]=(new Date).getTime()+6e4})}catch(e){return void Br.warn('could not rate limit - continuing. Error: "'+(null==e?void 0:e.message)+'"',{text:t})}},this.instance=e,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var e;return(null==(e=this.instance.config.rate_limiting)?void 0:e.events_per_second)||10}get captureEventsBurstLimit(){var e;return Math.max((null==(e=this.instance.config.rate_limiting)?void 0:e.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(e){var t,i,s;void 0===e&&(e=!1);var r=this.captureEventsBurstLimit,n=this.captureEventsPerSecond,o=(new Date).getTime(),a=null!==(t=null==(i=this.instance.persistence)?void 0:i.get_property("$capture_rate_limit"))&&void 0!==t?t:{tokens:r,last:o};a.tokens+=(o-a.last)/1e3*n,a.last=o,a.tokens>r&&(a.tokens=r);var l=1>a.tokens;if(l||e||(a.tokens=Math.max(0,a.tokens-1)),l&&!e){var d=(St(a.dropped)?a.dropped:0)+1;a.dropped=d,!this.lastEventRateLimited&&this._captureWarning(d)&&(a.dropped=0)}return this.lastEventRateLimited=l,null==(s=this.instance.persistence)||s.set_property(be,a),{isRateLimited:l,remainingTokens:a.tokens}}_isPropertyAllowed(e){var t=this.instance.config.property_denylist;return!ht(t)||!t.includes(e)}_triggeringPage(){var e;if(this._isPropertyAllowed("$current_url")&&this._isPropertyAllowed("$pathname")&&null!=Qe&&Qe.pathname)return""+(null!==(e=Qe.origin)&&void 0!==e?e:"")+Qe.pathname}_captureWarning(e){var t,i,s=this.captureEventsBurstLimit,r=this.captureEventsPerSecond,n=this._triggeringPage(),o=this._isPropertyAllowed("$session_id")?null==(t=(i=this.instance).get_session_id)?void 0:t.call(i):void 0,a=[e+" event(s) dropped since the last warning",n?"triggered on "+n:void 0,o?"session "+o:void 0].filter(Boolean).join(", ");return!!this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited: "+a+". Config is set to "+r+" events per second and "+s+" events burst limit."},{skip_client_rate_limiting:!0})}isServerRateLimited(e){var t=this.serverLimits[e||"events"]||!1;return!1!==t&&(new Date).getTime()<t}},qr=Yi("[RemoteConfig]"),Hr=class{constructor(e){this._instance=e}get remoteConfig(){var e;return null==(e=rt._POSTHOG_REMOTE_CONFIG)||null==(e=e[this._instance.config.token])?void 0:e.config}_loadRemoteConfigJs(e){var t,i;null!=(t=rt.__PosthogExtensions__)&&t.loadExternalDependency?null==(i=rt.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"remote-config",()=>e(this.remoteConfig)):e()}_loadRemoteConfigJSON(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 qr.info("Using preloaded remote config",this.remoteConfig),void this._onRemoteConfig(this.remoteConfig);if(this._instance._shouldDisableFlags())return void qr.warn("Remote config is disabled. Falling back to local config.");this._loadRemoteConfigJs(e=>{if(!e)return qr.info("No config found after loading remote JS config. Falling back to JSON."),void this._loadRemoteConfigJSON(e=>{this._onRemoteConfig(e.json,e)});this._onRemoteConfig(e)})}catch(e){qr.error("Error loading remote config",e),this._onRemoteConfig()}}_onRemoteConfig(e,t){!e&&t&&(0===t.statusCode?t.error||qr.warn("Failed to fetch remote config from PostHog."):qr.error("Failed to fetch remote config from PostHog."));try{this._instance._onRemoteConfig(e?{ok:!0,config:e}:{ok:!1})}catch(e){qr.error("Error applying remote config",e)}if(!1!==(null==e?void 0:e.hasFeatureFlags)&&!this._instance.config.advanced_disable_feature_flags_on_first_load)try{var i;null==(i=this._instance.featureFlags)||i.ensureFlagsLoaded()}catch(e){qr.error("Error loading feature flags",e)}}},Gr=["fatal","error","warning","log","info","debug"],Wr=Uint8Array,Vr=Uint16Array,jr=Uint32Array,zr=new Wr([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]),Kr=new Wr([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]),Jr=new Wr([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Yr=function(e,t){for(var i=new Vr(31),s=0;31>s;++s)i[s]=t+=1<<e[s-1];var r=new jr(i[30]);for(s=1;30>s;++s)for(var n=i[s];i[s+1]>n;++n)r[n]=n-i[s]<<5|s;return[i,r]},Qr=Yr(zr,2),Xr=Qr[1];Qr[0][28]=258,Xr[258]=28;for(var Zr=Yr(Kr,0)[1],en=new Vr(32768),tn=0;32768>tn;++tn){var sn=(43690&tn)>>>1|(21845&tn)<<1;en[tn]=((65280&(sn=(61680&(sn=(52428&sn)>>>2|(13107&sn)<<2))>>>4|(3855&sn)<<4))>>>8|(255&sn)<<8)>>>1}var rn=function(e,t,i){for(var s=e.length,r=0,n=new Vr(t);s>r;++r)++n[e[r]-1];var o,a=new Vr(t);for(r=0;t>r;++r)a[r]=a[r-1]+n[r-1]<<1;if(i){o=new Vr(1<<t);var l=15-t;for(r=0;s>r;++r)if(e[r])for(var d=r<<4|e[r],u=t-e[r],_=a[e[r]-1]++<<u,c=_|(1<<u)-1;c>=_;++_)o[en[_]>>>l]=d}else for(o=new Vr(s),r=0;s>r;++r)o[r]=en[a[e[r]-1]++]>>>15-e[r];return o},nn=new Wr(288);for(tn=0;144>tn;++tn)nn[tn]=8;for(tn=144;256>tn;++tn)nn[tn]=9;for(tn=256;280>tn;++tn)nn[tn]=7;for(tn=280;288>tn;++tn)nn[tn]=8;var on=new Wr(32);for(tn=0;32>tn;++tn)on[tn]=5;var an=rn(nn,9,0),ln=rn(on,5,0),dn=function(e){return(e/8|0)+(7&e&&1)},un=function(e,t,i){(null==t||0>t)&&(t=0),(null==i||i>e.length)&&(i=e.length);var s=new(e instanceof Vr?Vr:e instanceof jr?jr:Wr)(i-t);return s.set(e.subarray(t,i)),s},_n=function(e,t,i){var s=t/8|0;e[s]|=i<<=7&t,e[s+1]|=i>>>8},cn=function(e,t,i){var s=t/8|0;e[s]|=i<<=7&t,e[s+1]|=i>>>8,e[s+2]|=i>>>16},hn=function(e,t){for(var i=[],s=0;e.length>s;++s)e[s]&&i.push({s:s,f:e[s]});var r=i.length,n=i.slice();if(!r)return[new Wr(0),0];if(1==r){var o=new Wr(i[0].s+1);return o[i[0].s]=1,[o,1]}i.sort(function(e,t){return e.f-t.f}),i.push({s:-1,f:25001});var a=i[0],l=i[1],d=0,u=1,_=2;for(i[0]={s:-1,f:a.f+l.f,l:a,r:l};u!=r-1;)a=i[i[_].f>i[d].f?d++:_++],l=i[d!=u&&i[_].f>i[d].f?d++:_++],i[u++]={s:-1,f:a.f+l.f,l:a,r:l};var c=n[0].s;for(s=1;r>s;++s)n[s].s>c&&(c=n[s].s);var h=new Vr(c+1),p=pn(i[u-1],h,0);if(p>t){s=0;var g=0,v=p-t,f=1<<v;for(n.sort(function(e,t){return h[t.s]-h[e.s]||e.f-t.f});r>s;++s){var m=n[s].s;if(t>=h[m])break;g+=f-(1<<p-h[m]),h[m]=t}for(g>>>=v;g>0;){var y=n[s].s;t>h[y]?g-=1<<t-h[y]++-1:++s}for(;s>=0&&g;--s){var b=n[s].s;h[b]==t&&(--h[b],++g)}p=t}return[new Wr(h),p]},pn=function(e,t,i){return-1==e.s?Math.max(pn(e.l,t,i+1),pn(e.r,t,i+1)):t[e.s]=i},gn=function(e){for(var t=e.length;t&&!e[--t];);for(var i=new Vr(++t),s=0,r=e[0],n=1,o=function(e){i[s++]=e},a=1;t>=a;++a)if(e[a]==r&&a!=t)++n;else{if(!r&&n>2){for(;n>138;n-=138)o(32754);n>2&&(o(n>10?n-11<<5|28690:n-3<<5|12305),n=0)}else if(n>3){for(o(r),--n;n>6;n-=6)o(8304);n>2&&(o(n-3<<5|8208),n=0)}for(;n--;)o(r);n=1,r=e[a]}return[i.subarray(0,s),t]},vn=function(e,t){for(var i=0,s=0;t.length>s;++s)i+=e[s]*t[s];return i},fn=function(e,t,i){var s=i.length,r=dn(t+2);e[r]=255&s,e[r+1]=s>>>8,e[r+2]=255^e[r],e[r+3]=255^e[r+1];for(var n=0;s>n;++n)e[r+n+4]=i[n];return 8*(r+4+s)},mn=function(e,t,i,s,r,n,o,a,l,d,u){_n(t,u++,i),++r[256];for(var _=hn(r,15),c=_[0],h=_[1],p=hn(n,15),g=p[0],v=p[1],f=gn(c),m=f[0],y=f[1],b=gn(g),w=b[0],S=b[1],P=new Vr(19),x=0;m.length>x;++x)P[31&m[x]]++;for(x=0;w.length>x;++x)P[31&w[x]]++;for(var E=hn(P,7),C=E[0],k=E[1],I=19;I>4&&!C[Jr[I-1]];--I);var T,F,R,O,A=d+5<<3,M=vn(r,nn)+vn(n,on)+o,D=vn(r,c)+vn(n,g)+o+14+3*I+vn(P,C)+(2*P[16]+3*P[17]+7*P[18]);if(M>=A&&D>=A)return fn(t,u,e.subarray(l,l+d));if(_n(t,u,1+(M>D)),u+=2,M>D){T=rn(c,h,0),F=c,R=rn(g,v,0),O=g;var L=rn(C,k,0);for(_n(t,u,y-257),_n(t,u+5,S-1),_n(t,u+10,I-4),u+=14,x=0;I>x;++x)_n(t,u+3*x,C[Jr[x]]);u+=3*I;for(var N=[m,w],B=0;2>B;++B){var U=N[B];for(x=0;U.length>x;++x)_n(t,u,L[q=31&U[x]]),u+=C[q],q>15&&(_n(t,u,U[x]>>>5&127),u+=U[x]>>>12)}}else T=an,F=nn,R=ln,O=on;for(x=0;a>x;++x)if(s[x]>255){var q;cn(t,u,T[257+(q=s[x]>>>18&31)]),u+=F[q+257],q>7&&(_n(t,u,s[x]>>>23&31),u+=zr[q]);var H=31&s[x];cn(t,u,R[H]),u+=O[H],H>3&&(cn(t,u,s[x]>>>5&8191),u+=Kr[H])}else cn(t,u,T[s[x]]),u+=F[s[x]];return cn(t,u,T[256]),u+F[256]},yn=new jr([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),bn=new Wr(0),wn=function(){for(var e=new jr(256),t=0;256>t;++t){for(var i=t,s=9;--s;)i=(1&i&&3988292384)^i>>>1;e[t]=i}return e}(),Sn=function(e,t,i){for(;i;++t)e[t]=i,i>>>=8};function Pn(e,t){void 0===t&&(t={});var i=function(){var e=4294967295;return{p(t){for(var i=e,s=0;t.length>s;++s)i=wn[255&i^t[s]]^i>>>8;e=i},d(){return 4294967295^e}}}(),s=e.length;i.p(e);var r,n,o,a,l,d,u=(a=10+((r=t).filename&&r.filename.length+1||0),l=8,function(e,t,i,s,r,n){var o=e.length,a=new Wr(s+o+5*(1+Math.floor(o/7e3))+r),l=a.subarray(s,a.length-r),d=0;if(!t||8>o)for(var u=0;o>=u;u+=65535){var _=u+65535;o>_?d=fn(l,d,e.subarray(u,_)):(l[u]=n,d=fn(l,d,e.subarray(u,o)))}else{for(var c=yn[t-1],h=c>>>13,p=8191&c,g=(1<<i)-1,v=new Vr(32768),f=new Vr(g+1),m=Math.ceil(i/3),y=2*m,b=function(t){return(e[t]^e[t+1]<<m^e[t+2]<<y)&g},w=new jr(25e3),S=new Vr(288),P=new Vr(32),x=0,E=0,C=(u=0,0),k=0,I=0;o>u;++u){var T=b(u),F=32767&u,R=f[T];if(v[F]=R,f[T]=F,u>=k){var O=o-u;if((x>7e3||C>24576)&&O>423){d=mn(e,l,0,w,S,P,E,C,I,u-I,d),C=x=E=0,I=u;for(var A=0;286>A;++A)S[A]=0;for(A=0;30>A;++A)P[A]=0}var M=2,D=0,L=p,N=F-R&32767;if(O>2&&T==b(u-N))for(var B=Math.min(h,O)-1,U=Math.min(32767,u),q=Math.min(258,O);U>=N&&--L&&F!=R;){if(e[u+M]==e[u+M-N]){for(var H=0;q>H&&e[u+H]==e[u+H-N];++H);if(H>M){if(M=H,D=N,H>B)break;var G=Math.min(N,H-2),W=0;for(A=0;G>A;++A){var V=u-N+A+32768&32767,j=V-v[V]+32768&32767;j>W&&(W=j,R=V)}}}N+=(F=R)-(R=v[F])+32768&32767}if(D){w[C++]=268435456|Xr[M]<<18|Zr[D];var z=31&Xr[M],K=31&Zr[D];E+=zr[z]+Kr[K],++S[257+z],++P[K],k=u+M,++x}else w[C++]=e[u],++S[e[u]]}}d=mn(e,l,n,w,S,P,E,C,I,u-I,d),n||(d=fn(l,d,bn))}return un(a,0,s+dn(d)+r)}(n=e,null==(o=t).level?6:o.level,null==o.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(n.length)))):12+o.mem,a,l,!d)),_=u.length;return function(e,t){var i=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=2>t.level?4:9==t.level?2:0,e[9]=3,0!=t.mtime&&Sn(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),i){e[3]=8;for(var s=0;i.length>=s;++s)e[s+10]=i.charCodeAt(s)}}(u,t),Sn(u,_-8,i.d()),Sn(u,_-4,s),u}var xn=!!Ze||!!Xe,En=new WeakMap,Cn="text/plain",kn=0,In=!1,Tn=(e,t)=>{var i=e.split("#"),s=i[1],r=i[0].split("?"),n=r[0],o=r[1];if(!o)return e;var a=o.split("&").filter(e=>e.split("=")[0]!==t).join("&");return n+(a?"?"+a:"")+(s?"#"+s:"")},$n=function(e,t,s){var r;void 0===s&&(s=!0);var n=e.split("?"),o=n[0],a=n[1],l=i({},t),d=null!==(r=null==a?void 0:a.split("&").map(e=>{var t,i=e.split("="),r=i[0],n=s&&null!==(t=l[r])&&void 0!==t?t:i[1];return delete l[r],r+"="+n}))&&void 0!==r?r:[],u=function(e,t){var i,s;void 0===t&&(t="&");var r=[];return Xi(e,function(e,t){ft(e)||ft(t)||"undefined"===t||(i=encodeURIComponent((e=>e instanceof File)(e)?e.name:e.toString()),s=encodeURIComponent(t),r[r.length]=s+"="+i)}),r.join(t)}(l);return u&&d.push(u),d.length>0?o+"?"+d.join("&"):o},Fn=e=>{if(e._encodedBody)return e._encodedBody;var t=e.data,i=e.compression;if(t){if(i===Pr.GZipJS){var s=Pn(function(e){var t=e.length;if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var i=new Wr(e.length+(e.length>>>1)),s=0,r=function(e){i[s++]=e},n=0;t>n;++n){if(s+5>i.length){var o=new Wr(s+8+(t-n<<1));o.set(i),i=o}var a=e.charCodeAt(n);128>a?r(a):2048>a?(r(192|a>>>6),r(128|63&a)):a>55295&&57344>a?(r(240|(a=65536+(1047552&a)|1023&e.charCodeAt(++n))>>>18),r(128|a>>>12&63),r(128|a>>>6&63),r(128|63&a)):(r(224|a>>>12),r(128|a>>>6&63),r(128|63&a))}return un(i,0,s)}(zs(t)),{mtime:0});return{contentType:Cn,body:s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength),estimatedSize:s.byteLength}}if(i===Pr.Base64){var r=(e=>"data="+encodeURIComponent("string"==typeof e?e:zs(e)))(function(e){return e?btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,(e,t)=>String.fromCharCode(parseInt(t,16)))):e}(zs(t)));return{contentType:"application/x-www-form-urlencoded",body:r,estimatedSize:new Blob([r]).size}}var n=zs(t);return{contentType:"application/json",body:n,estimatedSize:new Blob([n]).size}}},Rn=e=>{var t,s,r=()=>"sendBeacon"===e.transport?{url:$n(e.url,{compression:Pr.Base64}),encodedBody:Fn(i({},e,{compression:Pr.Base64,_encodedBody:void 0}))}:{url:Tn(e.url,"compression"),encodedBody:Fn(i({},e,{compression:void 0,_encodedBody:void 0}))};try{t=Fn(e)}catch(t){if(Gi(e.compression,Js(e.url,"compression")))return Ji.error("Failed to gzip request body, sending uncompressed payload",t),r();throw t}return t&&Gi(e.compression,Js(e.url,"compression"))&&!((s=t.body)instanceof ArrayBuffer?Hi(new Uint8Array(s)):ArrayBuffer.isView(s)&&Hi(new Uint8Array(s.buffer,s.byteOffset,s.byteLength)))?(In=!0,r()):{url:e.url,encodedBody:t}},On=e=>{try{return Rn(e)}catch(t){return Ji.error(t),void(null==e.callback||e.callback({statusCode:0,error:t}))}},An=function(){var e=r(function*(e){var t=yield function(e,t,i){return zi.apply(this,arguments)}(zs(e.data),a.DEBUG,{rethrow:!0});if(!t)return e;var s=yield t.arrayBuffer();return i({},e,{_encodedBody:{contentType:Cn,body:s,estimatedSize:s.byteLength}})});return function(t){return e.apply(this,arguments)}}(),Mn=/Failed to fetch|NetworkError|Load failed/i,Dn=e=>"TypeError"===(null==e?void 0:e.name)&&Mn.test((null==e?void 0:e.message)||""),Ln=e=>{try{var t=function(e,t){if(void 0===t&&(t=Date.now()),"string"==typeof e&&e){var i=e.trim(),s=/^\d+\s*,/.test(i)?i.slice(0,i.indexOf(",")).trim():i;if(/^\d+$/.test(s)){var r=1e3*Math.min(Number(s),300);return r>0?r:void 0}if(/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun)[a-z]*[ ,]/.test(s)){var n=/^\w{3} \w{3} /.test(s)?s+" GMT":s,o=Date.parse(n)-t;if(Number.isFinite(o)&&o>0)return Math.min(o,3e5)}}}(e());return ft(t)?void 0:Math.min(t,3e4)}catch(e){return}},Nn=e=>{var t=On(e);if(t){var i=new Ze;En.set(i,!0);var s=t.encodedBody;i.open(e.method||"GET",t.url,!0);var r=null!=s?s:{},n=r.contentType,o=r.body;Xi(e.headers,function(e,t){i.setRequestHeader(t,e)}),n&&i.setRequestHeader("Content-Type",n),e.timeout&&(i.timeout=e.timeout),i.onreadystatechange=()=>{if(4===i.readyState){var t={statusCode:i.status,text:i.responseText};if(200===i.status)try{t.json=JSON.parse(i.responseText)}catch(e){}null==e.callback||e.callback(t,Ln(()=>i.getResponseHeader("Retry-After")))}},i.send(o)}},Bn=e=>{var t=On(e);if(t){var s=t.url,r=t.encodedBody,n=null!=r?r:{},o=n.contentType,a=n.body,l=n.estimatedSize,d=new Headers;Xi(e.headers,function(e,t){d.append(t,e)}),o&&d.append("Content-Type",o);var u=null,_=!1;if(et){var c=new et;u={signal:c.signal,timeout:setTimeout(()=>{var t;_=!0,c.abort(Li("AbortError","PostHog request timed out"+((t=e.timeout)?" after "+t+"ms":"")))},e.timeout)}}var h=t=>{_&&"AbortError"===(null==t?void 0:t.name)||Dn(t)?Ji.warn(t):Ji.error(t),null==e.callback||e.callback({statusCode:0,error:t})},p=0,g=()=>{kn-=p,p=0,u&&clearTimeout(u.timeout)};try{var v,f=i({method:(null==e?void 0:e.method)||"GET",headers:d,body:a,signal:null==(v=u)?void 0:v.signal},e.fetchOptions),m=null!=l?l:ft(a)?0:void 0;f.keepalive="POST"===f.method&&!e._keepaliveDisabled&&!1!==f.keepalive&&f.body===a&&!ft(m)&&m>=0&&52428.8>kn+m,f.keepalive&&(kn+=p=m),Xe(s,f).then(t=>t.text().then(i=>{var s={statusCode:t.status,text:i};if(200===t.status)try{s.json=JSON.parse(i)}catch(e){Ji.error(e)}g(),null==e.callback||e.callback(s,Ln(()=>t.headers.get("Retry-After")))})).catch(e=>{g(),h(e)}).finally(g)}catch(e){g(),h(e)}}},Un=e=>{try{var t,s=Rn(e),r=s.url,n=s.encodedBody,o=null!=n?n:{},a=o.body,l=o.estimatedSize;if(!a)return;var d=a instanceof Blob?a:new Blob([a],{type:o.contentType});if(Je.sendBeacon(r,d))return;var u=ht(e.data)?e.data:null==(t=e.data)?void 0:t.batch;if(ht(u)&&u.length>1&&(null!=l?l:0)>16384){var _=Math.ceil(u.length/2),c=t=>ht(e.data)?t:i({},e.data,{batch:t});return Un(i({},e,{data:c(u.slice(0,_))})),void Un(i({},e,{data:c(u.slice(_))}))}Ji.warn("Beacon of ~"+(null!=l?l:0)+" bytes was rejected by the browser, falling back to "+(Xe?"fetch":"XHR")),Xe?Bn(i({},e,{_keepaliveDisabled:!0})):Nn(e)}catch(e){Ji.warn("Beacon send failed",e)}},qn=(e,t,s,r)=>{var n="query"===r?"POST"===t?"sent_at":"_":void 0;return $n(s===Pr.GZipJS?Tn(e,"compression"):e,i({},n?{[n]:Date.now().toString()}:{},s===Pr.GZipJS?{}:{compression:s}))},Hn=(()=>{var e=[];return Xe&&e.push({transport:"fetch",method:Bn}),Ze&&e.push({transport:"XHR",method:Nn}),null!=Je&&Je.sendBeacon&&e.push({transport:"sendBeacon",method:Un}),e})(),Gn=!xn&&-1===(null==it?void 0:it.indexOf("MSIE"))&&-1===(null==it?void 0:it.indexOf("Mozilla"));function Wn(e,t,s){var r;s&&(t=i({},t,{callback:e=>s(e)})),e.__loaded?Gn?e.__request_queue.push(t):e.rateLimiter.isServerRateLimited(t.batchKey)?t.fireCallbackOnDrop&&(null==t.callback||t.callback({statusCode:429})):(t.transport=t.transport||e.config.api_transport,t.headers=i({},e.config.request_headers,t.headers),t.compression="best-available"===t.compression?null!==(r=e.compression)&&void 0!==r?r:t.compressionFallback:t.compression,(ft(e.config.disable_beacon)?e.config.__preview_disable_beacon:e.config.disable_beacon)&&(t.disableTransport=["sendBeacon"]),t.fetchOptions=t.fetchOptions||e.config.fetch_options,((e,t)=>{var s,r,n,o=i({},e,{callback:null!=t?t:t=>null==e.callback?void 0:e.callback(t)});o.timeout=o.timeout||6e4;var a,l,d,u,_,c=null!==(s=o.transport)&&void 0!==s?s:"fetch";"sendBeacon"===c&&ft(o.compression)&&o.data&&(o.compression=Pr.Base64),"POST"===o.method&&o.data&&("capture-body"===o.timestampMode?o.data={api_key:null!==(l=null==(_=(u=(ht(a=o.data)?a:[a]).map(e=>i({},e,e.timestamp instanceof Date&&!isNaN(e.timestamp.getTime())?{timestamp:e.timestamp.toISOString()}:{})))[0])||null==(d=_.properties)?void 0:d.token)&&void 0!==l?l:null==_?void 0:_.token,batch:u,sent_at:(new Date).toISOString()}:"body"===o.timestampMode&&(o.data=function(e,t){return void 0===t&&(t=(new Date).toISOString()),ht(e)?e.map(e=>i({},e,{sent_at:t})):i({},e,{sent_at:t})}(o.data))),o.url=qn(o.url,o.method,o.compression,o.timestampMode);var h=Hn.filter(e=>!o.disableTransport||!e.transport||!o.disableTransport.includes(e.transport)),p=null!==(r=null==(n=function(e,t){for(var i=0;e.length>i;i++)if(t(e[i]))return e[i]}(h,e=>e.transport===c))?void 0:n.method)&&void 0!==r?r:h[0].method;if(!p)throw new Error("No available transport method");var g=e=>{try{p(e)}catch(e){Dn(e)?Ji.warn(e):Ji.error(e),null==o.callback||o.callback({statusCode:0,error:e})}};"sendBeacon"!==c&&o.data&&o.compression===Pr.GZipJS&&tt&&"undefined"!=typeof Promise&&!In?An(o).then(e=>{g(e)}).catch(t=>{if(Wi(t))return In=!0,void g(i({},o,{compression:void 0,url:qn(e.url,e.method,void 0,e.timestampMode)}));(e=>{if(!e||"object"!=typeof e)return!1;var t="name"in e?String(e.name):"";return Wi(e)||t===qi})(t)&&(In=!0),g(o)}):p(o)})(t,(i,r)=>{e.rateLimiter.checkForLimiting(i),400>i.statusCode||null==e.config.on_request_error||e.config.on_request_error(i),s?s(i,r):null==t.callback||t.callback(i)})):t.fireCallbackOnDrop&&(null==t.callback||t.callback({statusCode:0}))}var Vn=class{constructor(e,t){this._isPaused=!0,this._queue=[],this._flushTimeoutMs=Ot((null==t?void 0:t.flush_interval_ms)||3e3,250,5e3,Ji.createLogger("flush interval"),3e3),this._sendRequest=e}enqueue(e){this._queue.push(e),this._flushTimeout||this._setFlushTimeout()}unload(){this._clearFlushTimeout();var e=this._queue.length>0?this._formatQueue():{},t=Object.values(e);[...t.filter(e=>0===e.url.indexOf("/e")),...t.filter(e=>0!==e.url.indexOf("/e"))].map(e=>{this._sendRequestSafely(e,"sendBeacon")})}enable(){this._isPaused=!1,this._setFlushTimeout()}_setFlushTimeout(){this._isPaused||(this._flushTimeout=setTimeout(()=>{if(this._clearFlushTimeout(),this._queue.length>0){var e=this._formatQueue();for(var t in e)this._sendRequestSafely(e[t])}},this._flushTimeoutMs))}_sendRequestSafely(e,t){try{this._sendRequest(e,t)}catch(e){Ji.error(e)}}_clearFlushTimeout(){clearTimeout(this._flushTimeout),this._flushTimeout=void 0}_formatQueue(){var e={};return Xi(this._queue,t=>{var s,r=t,n=((r?r.batchKey:null)||r.url)+(r.batchGroup?":"+r.batchGroup:"");ft(e[n])&&(e[n]=i({},r,{data:[]})),null==(s=e[n].data)||s.push(r.data)}),this._queue=[],e}},jn=class{constructor(e){this._instance=e,this._isPolling=!1,this._pollIntervalMs=3e3,this._queue=[],this._queue=[],this._areWeOnline=!0,this.resume()}resume(){if(!ft(ze)&&"onLine"in ze.navigator){if(this._areWeOnline=ze.navigator.onLine,this._onlineListener)return;this._onlineListener=()=>{this._areWeOnline=!0,this._flush()},this._offlineListener=()=>{this._areWeOnline=!1},ns(ze,"online",this._onlineListener),ns(ze,"offline",this._offlineListener)}}get length(){return this._queue.length}retriableRequest(e,s){var r=e.retriesPerformedSoFar,n=function(e,t){if(null==e)return{};var i={};for(var s in e)if({}.hasOwnProperty.call(e,s)){if(-1!==t.indexOf(s))continue;i[s]=e[s]}return i}(e,t);Pt(r)&&(n.url=$n(n.url,{retry_count:r})),Wn(this._instance,s?i({},n,{transport:s}):n,(e,t)=>{if(200!==e.statusCode&&(400>e.statusCode||e.statusCode>=500)){if((0===e.statusCode?3:10)>(null!=r?r:0))return void this._enqueue(i({retriesPerformedSoFar:r},n),t);0===e.statusCode&&Ji.warn("Request failed before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped retrying after "+(null!=r?r:0)+" retries.")}null==n.callback||n.callback(e)})}_enqueue(e,t){var i=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=i+1;var s=Math.max(function(e){var t=3e3*Math.pow(2,e),i=t/2,s=Math.min(18e5,t),r=(Math.random()-.5)*(s-i);return Math.ceil(s+r)}(i),null!=t?t:0),r=Date.now()+s;this._queue.push({retryAt:r,requestOptions:e});var n="Enqueued failed request for retry in "+s;navigator.onLine||(n+=" (Browser is offline)"),Ji.warn(n),this._isPolling||(this._isPolling=!0,this._poll())}_poll(){if(this._poller&&clearTimeout(this._poller),0===this._queue.length)return this._isPolling=!1,void(this._poller=void 0);this._poller=setTimeout(()=>{this._areWeOnline&&this._queue.length>0&&this._flush(),this._poll()},this._pollIntervalMs)}_flush(){var e=Date.now(),t=[],i=this._queue.filter(i=>e>i.retryAt||(t.push(i),!1));if(this._queue=t,i.length>0)for(var s of i)this.retriableRequest(s.requestOptions)}unload(){for(var e of(this._poller&&(clearTimeout(this._poller),this._poller=void 0),this._isPolling=!1,ft(ze)||(this._onlineListener&&(ze.removeEventListener("online",this._onlineListener),this._onlineListener=void 0),this._offlineListener&&(ze.removeEventListener("offline",this._offlineListener),this._offlineListener=void 0)),this._queue)){var t=e.requestOptions;try{this._instance._send_request(i({},t,{transport:"sendBeacon"}))}catch(e){Ji.error(e)}}this._queue=[]}},zn=class{constructor(e){this._instance=e,this._updateScrollData=()=>{var e,t,i,s;this._context||(this._context={});var r=this.scrollElement(),n=this.scrollY(),o=r?Math.max(0,r.scrollHeight-r.clientHeight):0,a=n+((null==r?void 0:r.clientHeight)||0),l=(null==r?void 0:r.scrollHeight)||0;this._context.lastScrollY=Math.ceil(n),this._context.maxScrollY=Math.max(n,null!==(e=this._context.maxScrollY)&&void 0!==e?e:0),this._context.maxScrollHeight=Math.max(o,null!==(t=this._context.maxScrollHeight)&&void 0!==t?t:0),this._context.lastContentY=a,this._context.maxContentY=Math.max(a,null!==(i=this._context.maxContentY)&&void 0!==i?i:0),this._context.maxContentHeight=Math.max(l,null!==(s=this._context.maxContentHeight)&&void 0!==s?s:0)}}get _scrollRoot(){return this._instance.config.scroll_root_selector}getContext(){return this._context}resetContext(){var e=this._context;return this._context=void 0,setTimeout(this._updateScrollData,0),e}startMeasuringScrollPosition(){ns(ze,"scroll",this._updateScrollData,{capture:!0}),ns(ze,"scrollend",this._updateScrollData,{capture:!0}),ns(ze,"resize",this._updateScrollData)}scrollElement(){var e;if(!this._scrollRoot)return null==ze||null==(e=ze.document)?void 0:e.documentElement;for(var t of ht(this._scrollRoot)?this._scrollRoot:[this._scrollRoot]){var i,s=null==ze||null==(i=ze.document)?void 0:i.querySelector(t);if(s)return s}}_scrollPosition(e){var t,i,s="y"===e?"scrollTop":"scrollLeft";if(this._scrollRoot){var r=this.scrollElement();return r&&r[s]||0}return ze?"y"===e?ze.scrollY||ze.pageYOffset||(null==(t=ze.document)||null==(t=t.documentElement)?void 0:t.scrollTop)||0:ze.scrollX||ze.pageXOffset||(null==(i=ze.document)||null==(i=i.documentElement)?void 0:i.scrollLeft)||0:0}scrollY(){return this._scrollPosition("y")}scrollX(){return this._scrollPosition("x")}},Kn=e=>or(null==e?void 0:e.config.mask_personal_data_properties,null==e?void 0:e.config.custom_personal_data_properties,null==e?void 0:e.config.disable_capture_url_hashes),Jn=class{constructor(e,t,i,s){this._onSessionIdCallback=e=>{var t=this._getStored();if(!t||t.sessionId!==e){var i={sessionId:e,props:this._sessionSourceParamGenerator(this._instance)};this._persistence.register({[ye]:i})}},this._instance=e,this._sessionIdManager=t,this._persistence=i,this._sessionSourceParamGenerator=s||Kn,this._sessionIdManager.onSessionId(this._onSessionIdCallback)}_getStored(){return this._persistence.props[ye]}getSetOnceProps(){var e,t=null==(e=this._getStored())?void 0:e.props;return t?"r"in t?ar(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 Xi(ts(this.getSetOnceProps()),(t,i)=>{"$current_url"===i&&(i="url"),e["$session_entry_"+dt(i)]=t}),e}},Yn=class{on(e,t){return this._events[e]||(this._events[e]=[]),this._events[e].push(t),()=>{this._events[e]=this._events[e].filter(e=>e!==t)}}emit(e,t){for(var i of this._events[e]||[])i(t);for(var s of this._events["*"]||[])s(e,t)}constructor(){this._events={}}},Qn=Yi("[SessionId]"),Xn=864e5,Zn=class{on(e,t){return this._eventEmitter.on(e,t)}constructor(e,t,i){var s;if(this._lastPersistedActivityTimestamp=null,this._lastCookieSyncTimestamp=null,this._sessionIdChangedHandlers=[],this._beforeUnloadListener=void 0,this._destroyed=!1,this._eventEmitter=new Yn,this._sessionHasBeenIdleTooLong=(e,t)=>!(!Pt(e)||!Pt(t))&&Math.abs(e-t)>this.sessionTimeoutMs,!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if("always"===e.config.cookieless_mode)throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this._config=e.config,this._persistence=e.persistence,this._windowId=void 0,this._sessionId=void 0,this._sessionStartTimestamp=null,this._pendingBootstrapSession=void 0,this._sessionActivityTimestamp=null,this._sessionIdGenerator=t||cs,this._windowIdGenerator=i||cs;var r=this._config.persistence_name||this._config.token;if(this._sessionTimeoutMs=1e3*Ot(this._config.session_idle_timeout_seconds||1800,60,36e3,Qn.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this._resetIdleTimer(),this._window_id_storage_key="ph_"+r+"_window_id",this._primary_window_exists_storage_key="ph_"+r+"_primary_window_exists",this._canUseSessionStorage()){var n=Os._parse(this._window_id_storage_key),o=Os._parse(this._primary_window_exists_storage_key);n&&!o?this._windowId=n:Os._remove(this._window_id_storage_key),Os._set(this._primary_window_exists_storage_key,!0)}null!=(s=this._config.bootstrap)&&s.sessionID&&this.setBootstrapSessionId(this._config.bootstrap.sessionID),this._listenToReloadWindow()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return ft(this._sessionIdChangedHandlers)&&(this._sessionIdChangedHandlers=[]),this._sessionIdChangedHandlers.push(e),this._sessionId&&e(this._sessionId,this._windowId),()=>{this._sessionIdChangedHandlers=this._sessionIdChangedHandlers.filter(t=>t!==e)}}_canUseSessionStorage(){return"memory"!==this._config.persistence&&!this._persistence._disabled&&Os._is_supported()}_setWindowId(e){e!==this._windowId&&(this._windowId=e,this._canUseSessionStorage()&&Os._set(this._window_id_storage_key,e))}_getWindowId(){return this._windowId?this._windowId:this._canUseSessionStorage()?Os._parse(this._window_id_storage_key):null}_isActivityChangeBelowGranularity(e){var t=this._lastPersistedActivityTimestamp;return!bt(t)&&!bt(e)&&5e3>Math.abs(e-t)}_setSessionId(e,t,i){var s=t!==this._sessionActivityTimestamp,r=!(e!==this._sessionId||i!==this._sessionStartTimestamp);this._sessionStartTimestamp=i,this._sessionActivityTimestamp=t,this._sessionId=e,r&&!s||r&&this._isActivityChangeBelowGranularity(t)||(this._lastPersistedActivityTimestamp=t,this._persistence.register({[L]:[t,e,i]}))}_useCrossTabRefreshHardening(){var e,t=null==(e=this._config)?void 0:e.persistence_save_debounce_ms;return Pt(t)&&t>0}_refreshSessionIdFromStorage(){this._useCrossTabRefreshHardening()?this._persistence.refreshKey(L):(this._persistence.flush(),this._persistence.load())}_flushPendingActivityTimestamp(){var e;if(!bt(this._sessionActivityTimestamp)&&this._sessionActivityTimestamp!==this._lastPersistedActivityTimestamp){this._refreshSessionIdFromStorage();var t=this._getSessionId();t[1]===this._sessionId&&t[2]===this._sessionStartTimestamp&&(this._lastPersistedActivityTimestamp=this._sessionActivityTimestamp,this._persistence.register({[L]:[this._sessionActivityTimestamp,null!==(e=this._sessionId)&&void 0!==e?e:null,this._sessionStartTimestamp]}),this._persistence.flush())}}_freshestActivityTimestamp(){var e=this._getSessionId()[0],t=Pt(e)?e:0,i=Pt(this._sessionActivityTimestamp)?this._sessionActivityTimestamp:0;return Math.max(t,i)}_isSessionIdleAfterCrossTabRefresh(e){return this._refreshSessionIdFromStorage(),this._sessionHasBeenIdleTooLong(e,this._freshestActivityTimestamp())}_getSessionId(){var e=this._persistence.props[L];return ht(e)&&2===e.length&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this._lastPersistedActivityTimestamp=null,this._pendingBootstrapSession=void 0,clearTimeout(this._enforceIdleTimeout),this._enforceIdleTimeout=void 0,this._setSessionId(null,null,null)}setBootstrapSessionId(e,t){void 0===t&&(t=!1);var i=function(e,t){void 0===t&&(t=(new Date).getTime());try{var i=(e=>{var t=e.replace(/-/g,"");if(32!==t.length)throw new Error("Not a valid UUID");if("7"!==t[12])throw new Error("Not a UUIDv7");return parseInt(t.substring(0,12),16)})(e);return i>t+6e4?void Qn.error("Bootstrap sessionID cannot be in the future"):i}catch(e){return void Qn.error("Invalid sessionID in bootstrap",e)}}(e);return!ft(i)&&(t?this._pendingBootstrapSession={sessionId:e,sessionStartTimestamp:i}:this._setSessionId(e,(new Date).getTime(),i),!0)}destroy(){this._destroyed=!0,this._flushPendingActivityTimestamp(),clearTimeout(this._enforceIdleTimeout),this._enforceIdleTimeout=void 0,this._beforeUnloadListener&&ze&&(ze.removeEventListener(He,this._beforeUnloadListener,{capture:!1}),this._beforeUnloadListener=void 0),this._sessionIdChangedHandlers=[]}_listenToReloadWindow(){this._beforeUnloadListener=()=>{this._flushPendingActivityTimestamp(),this._canUseSessionStorage()&&Os._remove(this._primary_window_exists_storage_key)},ns(ze,He,this._beforeUnloadListener,{capture:!1})}checkAndGetSessionAndWindowId(e,t,i){if(void 0===e&&(e=!1),void 0===t&&(t=null),void 0===i&&(i=!1),"always"===this._config.cookieless_mode)throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var s=t||(new Date).getTime(),r=this._sessionId;if(i)this._lastCookieSyncTimestamp=s;else if(bt(this._lastCookieSyncTimestamp)||this._lastCookieSyncTimestamp>s||s-this._lastCookieSyncTimestamp>=1e3){var n,o;null==(n=(o=this._persistence).syncCookieProperties)||n.call(o),this._lastCookieSyncTimestamp=s}var a=this._getSessionId(),l=a[1],d=a[2],u=!ft(r)&&l!==r,_=this._freshestActivityTimestamp(),c=this._getWindowId(),h=this._pendingBootstrapSession,p=!!h&&(h.sessionStartTimestamp>s+6e4||s-h.sessionStartTimestamp>Xn),g=h?p:Pt(d)&&Math.abs(s-d)>Xn,v=!1,f=u,m=!l||!!h,y=l,b=!m&&!e&&this._sessionHasBeenIdleTooLong(s,_);if(b){(b=this._isSessionIdleAfterCrossTabRefresh(s))||Qn.info("cross-tab refresh kept the session alive",{sessionId:l});var w=this._getSessionId();l=w[1],d=w[2]}if(m||b||g){f=!1;var S=h&&!p;l=S?h.sessionId:this._sessionIdGenerator(),c=this._windowIdGenerator(),Qn.info("new session ID assigned",{sessionId:l,windowId:c,bootstrapped:!!S,changeReason:{noSessionId:m,activityTimeout:b,sessionPastMaximumLength:g}}),d=S?h.sessionStartTimestamp:s,this._pendingBootstrapSession=void 0,v=!0}else c||(c=this._windowIdGenerator(),v=!0),(f=f||l!==y)&&(Qn.info("adopted cross-tab session id",{sessionId:l,windowId:c}),v=!0);var P=Pt(_)&&e&&!g?_:s,x=Pt(d)?d:(new Date).getTime();this._setWindowId(c),this._setSessionId(l,P,x),e||this._resetIdleTimer();var E={noSessionId:m,activityTimeout:b,sessionPastMaximumLength:g,crossTabAdoption:f};return v&&this._sessionIdChangedHandlers.forEach(e=>e(l,c,E)),{sessionId:l,windowId:c,sessionStartTimestamp:x,changeReason:v?E:void 0,lastActivityTimestamp:_}}_resetIdleTimer(){this._destroyed||(clearTimeout(this._enforceIdleTimeout),this._enforceIdleTimeout=setTimeout(()=>{if(!this._destroyed)if(this._isSessionIdleAfterCrossTabRefresh((new Date).getTime())){var e=this._sessionId;this.resetSessionId(),this._eventEmitter.emit("forcedIdleReset",{idleSessionId:e})}else this._resetIdleTimer()},1.1*this.sessionTimeoutMs))}};function eo(){return(eo=r(function*(){var e=null==Je?void 0:Je.userAgentData;if(null!=e&&e.getHighEntropyValues)try{var t,i=null==(t=yield e.getHighEntropyValues(["model"]))?void 0:t.model;return mt(i)&&i.length>0?i:void 0}catch(e){return void Ji.info("Unable to resolve $device_model from userAgentData.getHighEntropyValues",e)}})).apply(this,arguments)}function to(e,t){var i="$survey_"+t+"/"+e.id;return e.current_iteration&&e.current_iteration>0&&(i="$survey_"+t+"/"+e.id+"/"+e.current_iteration),i}function io(e,t,i){return zs({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:i})}var so,ro="custom",no="i.posthog.com",oo=/^\/static\//,ao=["/s/","/e/","/i/"],lo=class{constructor(e){this._regionCache={},this.instance=e}get apiHost(){var e=this.instance.config.api_host.trim().replace(/\/$/,"");return"https://app.posthog.com"===e?"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=null==(e=this.instance.config.ui_host)?void 0:e.replace(/\/$/,"");return t||(t=this.apiHost.replace("."+no,".posthog.com")),"https://app.posthog.com"===t?"https://us.posthog.com":t}get region(){return this._regionCache[this.apiHost]||(this._regionCache[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":ro),this._regionCache[this.apiHost]}_staticAssetHostOverride(e){if(oo.test(e)){var t=this.instance.config.asset_host;if("string"==typeof t)return t.trim().replace(/\/$/,"")||void 0}}_urlKey(e){var t=Ks(e);return t?t.protocol+"//"+t.host+t.pathname:void 0}_prepareEndpoint(e,t,i){if("ui"===e)return i;var s=i,r=this.instance.config.rewriteRequestPath;if(r){var n,o=(null==(n=Ks(i))?void 0:n.href)||i;s=r(new URL(o)).toString()}if(r&&"api"===e&&ao.some(e=>0===t.indexOf(e))){var a=this._urlKey(s);if(a){var l,d=this.apiHost,u=this._ingestionEndpoints;(null==(l=u)?void 0:l.apiHost)===d&&u.rewriteRequestPath===r||(this._ingestionEndpoints=u={apiHost:d,rewriteRequestPath:r,urls:new Set}),u.urls.add(a)}}return s}isIngestionEndpoint(e){var t=this._ingestionEndpoints,i=this._urlKey(e);return(null==t?void 0:t.apiHost)===this.apiHost&&t.rewriteRequestPath===this.instance.config.rewriteRequestPath&&!!i&&t.urls.has(i)}endpointFor(e,t){if(void 0===t&&(t=""),t&&(t="/"===t[0]?t:"/"+t),"ui"===e)return this._prepareEndpoint(e,t,this.uiHost+t);if("flags"===e)return this._prepareEndpoint(e,t,this.flagsApiHost+t);if("assets"===e){var i=this._staticAssetHostOverride(t);if(i)return this._prepareEndpoint(e,t,""+i+t)}if(this.region===ro)return this._prepareEndpoint(e,t,this.apiHost+t);var s=no+t;switch(e){case"assets":return this._prepareEndpoint(e,t,"https://"+this.region+"-assets."+s);case"api":return this._prepareEndpoint(e,t,"https://"+this.region+"."+s)}}},uo=Yi("[Surveys]"),_o={ignoreConditions:!1,ignoreDelay:!1,displayType:Ar.Popover},co=Yi("[PostHog ExternalIntegrations]"),ho={intercom:"intercom-integration",crispChat:"crisp-chat-integration"},po=class{constructor(e){this._instance=e}_loadScript(e,t){var i;null==(i=rt.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,e,e=>{if(e)return co.error("failed to load script",e);t()})}startIfEnabledOrStop(){var e=this,t=function(){var t,s,r,n=i[0],o=i[1];!o||null!=(t=rt.__PosthogExtensions__)&&null!=(t=t.integrations)&&t[n]||e._loadScript(ho[n],()=>{var t;null==(t=rt.__PosthogExtensions__)||null==(t=t.integrations)||null==(t=t[n])||t.start(e._instance)}),!o&&null!=(s=rt.__PosthogExtensions__)&&null!=(s=s.integrations)&&s[n]&&(null==(r=rt.__PosthogExtensions__)||null==(r=r.integrations)||null==(r=r[n])||r.stop())};for(var i of Object.entries(null!==(s=this._instance.config.integrations)&&void 0!==s?s:{})){var s;t()}}},go=class{constructor(e,t){this._logger=e,this._client=t,this._extensions=new Map,this._disposed=!1}add(e){var t=this;return r(function*(){if(t._disposed)throw new Error("Cannot add an extension to a disposed ExtensionRuntime");if(t._extensions.has(e.name))throw new Error('Browser extension "'+e.name+'" is already registered');t._extensions.set(e.name,e);try{var i=e.setup(t._client);i&&(yield i)}catch(i){var s=t._extensions.get(e.name)===e;s&&t._extensions.delete(e.name),t._logger.error('Failed to set up browser extension "'+e.name+'"',i),s&&t._disposeExtension(e)}})()}getExtension(e){return this._extensions.get(e)}dispose(){if(!this._disposed){this._disposed=!0;var e=Array.from(this._extensions.values()).reverse();for(var t of(this._extensions.clear(),e))this._disposeExtension(t)}}_disposeExtension(e){try{var t=null==e.dispose?void 0:e.dispose();t&&pt(t.then)&&t.then(void 0,t=>{this._logger.error('Failed to dispose browser extension "'+e.name+'"',t)})}catch(t){this._logger.error('Failed to dispose browser extension "'+e.name+'"',t)}}},vo=class{constructor(e){this._instance=e}initialize(){}get(e){var t=this._instance.persistence;if("string"==typeof e)return null==t?void 0:t.get_property(e);var i={};for(var s of e){var r=null==t?void 0:t.get_property(s);ft(r)||(i[s]=r)}return i}set(e,t){var i;null==(i=this._instance.persistence)||i.register("string"==typeof e?{[e]:t}:e)}remove(e){var t;null==(t=this._instance.persistence)||t.unregister(e)}},fo="extensionsRemoteConfig",mo=class{constructor(e){this.instance=e,this._disposed=!1,this._logger=Ji,this._latestRemoteConfigResult=e._lastRemoteConfig,this.kv=new vo(e),this.onEvent=e=>Mr(this.instance.on("eventCaptured",t=>{try{e({event:t.event,properties:t.properties})}catch(e){this._logger.error("Browser extension event listener failed",e)}})),this.onRemoteConfig=e=>{if(this._disposed)return Mr(()=>{});var t=t=>{try{e(t)}catch(e){this._logger.error("Browser extension remote config listener failed",e)}},i=this.instance._internalEventEmitter.on(fo,t);return this._latestRemoteConfigResult&&t(this._latestRemoteConfigResult),Mr(i)},this._runtime=new go(Ji.createLogger("[BrowserExtensions]"),this)}get logger(){return this._logger}get distinctId(){return this.instance.get_distinct_id()}get anonymousId(){var e;return null!==(e=this.instance.get_property("$device_id"))&&void 0!==e?e:this.distinctId}get deviceId(){var e=this.instance.get_property(u);return"string"==typeof e?e:void 0}get library(){return{name:a.LIB_NAME,version:a.LIB_VERSION}}get initialPersonProperties(){var e,t;return null!==(e=null==(t=this.instance.persistence)?void 0:t.get_initial_props())&&void 0!==e?e:{}}get groups(){return this.instance.getGroups()}get session(){try{var e,t,i,s,r=null==(e=this.instance.sessionManager)?void 0:e.checkAndGetSessionAndWindowId(!0);return{sessionId:null!==(t=null==r?void 0:r.sessionId)&&void 0!==t?t:"",windowId:null!==(i=null==r?void 0:r.windowId)&&void 0!==i?i:"",sessionStartTimestamp:null!==(s=null==r?void 0:r.sessionStartTimestamp)&&void 0!==s?s:0}}catch(e){return{sessionId:"",windowId:"",sessionStartTimestamp:0}}}get canCapture(){return this.instance.is_capturing()}get projectToken(){return this.instance.config.token}add(e){return this._runtime.add(e)}getExtension(e){return this._runtime.getExtension(e)}capture(e,t,i){var s=this;return r(function*(){i?s.instance.capture(e,t,{timestamp:i.timestamp,uuid:i.uuid,$set:i.set,$set_once:i.setOnce}):s.instance.capture(e,t)})()}registerDynamicEventProperties(e){return Mr(this.instance._registerExtensionEventProperties(e))}handleRemoteConfig(e){this._disposed||(this._latestRemoteConfigResult=e,this.instance._internalEventEmitter.emit(fo,e))}sendRequest(e,t){var i=this;return r(function*(){var s;void 0===t&&(t={});var r=i.instance.requestRouter.endpointFor(null!==(s=t.target)&&void 0!==s?s:"api",e),n={method:t.method,url:t.query?$n(r,t.query):r,data:t.body,headers:t.headers,timeout:t.timeoutMs,fireCallbackOnDrop:!0,transport:t.transport,compression:t.compression,compressionFallback:"flags"===t.target&&"best-available"===t.compression?nt.Base64:void 0,timestampMode:t.sentAt};return"sendBeacon"===t.transport?(i.instance._send_request(n),{statusCode:202}):new Promise(e=>{n.callback=e,i.instance._send_request(n)})})()}dispose(){this._disposed||(this._disposed=!0,this._runtime.dispose())}},yo={},bo=0,wo=()=>{},So='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',Po="Surveys module not available",xo="sanitize_properties is deprecated. Use before_send instead",Eo="Invalid value for property_denylist config: ",Co=/^[A-Za-z0-9_-]{1,400}$/,ko=/^fb\.[0-9]+\.[0-9]+\.[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)?$/,Io=/^fb\.[0-9]+\.[0-9]+\.[0-9]+$/,To=["token","distinct_id",Ce],$o="posthog",Fo=e=>{var t={};return e&&"unset"!==e?("2025-11-30">e||(t.strictMinimumDuration=!0),"2026-05-30">e||(t.canvasCapture={resolutionScale:.6}),"2026-06-25">e||(t.streamNetworkBody=!0),"2026-08-30">e||(t.captureJsonLd=!0),t):t},Ro=e=>{var t;return i({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,asset_host:null,token:"",autocapture:!0,cross_subdomain_cookie:rs(null==Ye?void 0:Ye.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:wo,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:null!=e?e:"unset",__preview_deferred_init_extensions:!1,__preview_external_dependency_versioned_paths:!1,__preview_cookie_wins_on_conflict:!1,debug:Qe&&mt(null==Qe?void 0:Qe.search)&&-1!==Qe.search.indexOf("__posthog_debug=true")||!1,cookie_expiration:365,upgrade:!1,disable_session_recording:!1,disable_persistence:!1,disable_web_experiments:!0,disable_surveys:!1,disable_surveys_automatic_display:!1,disable_conversations:!1,disable_product_tours:!1,disableDeviceModel:!1,reuseAnonymousId:!1,disable_external_dependency_loading:!1,strict_script_versioning:"fallback",enable_recording_console_log:void 0,secure_cookie:"https:"===(null==ze||null==(t=ze.location)?void 0:t.protocol),ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_flags:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_only_evaluate_survey_feature_flags:!1,advanced_feature_flags_dedup_per_session:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,surveys_request_timeout_ms:1e4,on_request_error(e){Ji.error("Bad HTTP status: "+e.statusCode+" "+e.text)},get_device_id:e=>e,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:Ue,before_send:void 0,get_current_url:void 0,request_queue_config:{flush_interval_ms:3e3},error_tracking:{},_onCapture:wo},(e=>({rageclick:e&&e>="2026-05-30"?{content_ignorelist:Ms,ignore_text_selection:!0}:!e||"2025-11-30">e||{content_ignorelist:!0},capture_pageview:!e||"2025-05-24">e||"history_change",session_recording:Fo(e),external_scripts_inject_target:e&&e>="2026-01-30"?"head":"body",internal_or_test_user_hostname:e&&e>="2026-01-30"?/^(localhost|127\.0\.0\.1)$/:void 0,persistence_save_debounce_ms:e&&e>="2026-05-30"?250:0,split_storage:!(!e||"2026-05-30">e),detect_google_search_app:!(!e||"2026-05-30">e),disable_capture_url_hashes:!(!e||"2026-06-25">e),cookieWinsOnConflict:!(!e||"unset"===e||"2026-08-29">e)}))(e))},Oo=[["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"]],Ao=e=>{var t={};for(var i of Oo){var s=i[0],r=i[1];ft(e[s])||(t[r]=e[s])}var n=Zi({},t,e),o=e.__preview_external_dependency_versioned_paths;return ft(o)||(ft(e.strict_script_versioning)&&(n.strict_script_versioning=!!o),mt(o)&&ft(e.asset_host)&&(n.asset_host=o)),ht(e.property_blacklist)&&(ft(e.property_denylist)?n.property_denylist=e.property_blacklist:ht(e.property_denylist)?n.property_denylist=[...e.property_blacklist,...e.property_denylist]:Ji.error(Eo+e.property_denylist)),n},Mo=class{constructor(){this.__forceAllowLocalhost=!1}get _forceAllowLocalhost(){return this.__forceAllowLocalhost}set _forceAllowLocalhost(e){Ji.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}},Do=(e=class e{_removeExtension(e){if(e){var t=this._extensions.indexOf(e);-1!==t&&this._extensions.splice(t,1)}}_replaceExtension(e,t){return this._removeExtension(e),this._extensions.push(t),null==t.initialize||t.initialize(),t}_inCookielessMode(){return"always"===this.config.cookieless_mode||"on_reject"===this.config.cookieless_mode&&this.consent.isRejected()}_warnIfVolatileIdentityWithoutStableId(){if(!(this._hasWarnedAboutVolatileIdentity||this.config.reuseAnonymousId||this.config.segment||this._inCookielessMode())){var e,t,i,s="memory"===this.config.persistence||"sessionStorage"===this.config.persistence;(s||this.config.disable_persistence)&&(this._hasStableInitialDistinctId||(s?(e="persistence is set to '"+this.config.persistence+"'",t="memory"===this.config.persistence?"on every page load":"for every new browser tab or window",i="Either set persistence to 'localStorage+cookie', keep this persistence and pass a stable ID through bootstrap.distinctID, or enable reuseAnonymousId."):(e="persistence is disabled (disable_persistence is true)",t="on every page load",i="Either set disable_persistence to false, keep persistence disabled and pass a stable ID through bootstrap.distinctID, or enable reuseAnonymousId."),this._hasWarnedAboutVolatileIdentity=!0,console.warn("[PostHog.js]",e+" but no bootstrap.distinctID was provided. PostHog will mint a new distinct ID "+t+", so calling identify() merges a new ID onto the person each time. A person can then pass the distinct-ID limit and its events stop appearing on person pages and the session tab. "+i)))}}_healCookielessSentinelDistinctId(){if(!this._inCookielessMode()&&"$posthog_cookieless"===this.get_distinct_id()){var e=this.persistence;if(e){this._is_persistence_disabled()||e.load(!0);var t=this.get_distinct_id();if(!t||"$posthog_cookieless"===t){var i=this.config.get_device_id(cs());this.register({distinct_id:i,$device_id:i}),e.set_property(me,Ne)}this._sync_opt_out_with_persistence()}}}get decideEndpointWasHit(){var e,t;return null!==(e=null==(t=this.featureFlags)?void 0:t.hasLoadedFlags)&&void 0!==e&&e}get flagsEndpointWasHit(){var e,t;return null!==(e=null==(t=this.featureFlags)?void 0:t.hasLoadedFlags)&&void 0!==e&&e}constructor(){var t;this._isPageUnloading=!1,this._isShutdown=!1,this.webPerformance=new Mo,this._personProcessingSetOncePropertiesSent=!1,this.version=a.LIB_VERSION,this._sessionRegisteredPropKeys=new Set,this._sessionRegisteredPropertiesStorageKey="",this._internalEventEmitter=new Yn,this._extensions=[],this._extensionEventPropertyProducers=[],this._hasStableInitialDistinctId=!1,this._hasWarnedAboutVolatileIdentity=!1,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=Ro(),this.SentryIntegration=qs,this.sentryIntegration=e=>function(e,t){var i=Us(e,t);return{name:Bs,processEvent:e=>i(e)}}(this,e),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this._initialPageviewCaptured=!1,this._visibilityStateListener=null,this._initialPersonProfilesConfig=null,this._cachedPersonProperties=null,this.scrollManager=new zn(this),this.pageViewManager=new Hs(this),this.rateLimiter=new Ur(this),this.requestRouter=new lo(this),this.consent=new As(this),this.externalIntegrations=new po(this);var i=null!==(t=e.__defaultExtensionClasses)&&void 0!==t?t:{};this.featureFlags=i.featureFlags&&new i.featureFlags(this),this.toolbar=i.toolbar&&new i.toolbar(this),this.surveys=i.surveys&&new i.surveys(this),this.conversations=i.conversations&&new i.conversations(this),this.logs=i.logs&&new i.logs(this),this.metrics=i.metrics&&new i.metrics(this),this.experiments=i.experiments&&new i.experiments(this),this.exceptions=i.exceptions&&new i.exceptions(this),this.people={set:(e,t,i)=>{var s=mt(e)?{[e]:t}:e;this.setPersonProperties(s),null==i||i({})},set_once:(e,t,i)=>{var s=mt(e)?{[e]:t}:e;this.setPersonProperties(void 0,s),null==i||i({})}},this.on("eventCaptured",e=>Ji.info('send "'+(null==e?void 0:e.event)+'"',e))}init(t,i,s){if(s&&s!==$o){var r,n=null!==(r=yo[s])&&void 0!==r?r:new e;return n._init(t,i,s),yo[s]=n,yo[$o][s]=n,n}return this._init(t,i,s)}_init(e,t,s){var r,n,o;void 0===t&&(t={});var l,d=mt(e)?e.trim():"";if(!d)return Ji.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 d!==(null==(l=this.config)?void 0:l.token)?console.warn("[PostHog.js]","You have already initialized PostHog with a different project token! Re-initializing is a no-op, so events will keep going to the project this instance was initialized with. To capture into a second project, load PostHog once, then initialize a named instance after the SDK has loaded, e.g. posthog.init('"+d+"', { ... }, 'project2')"):console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config=Ro(t.defaults),t.debug=this._checkLocalStorageForDebug(t.debug),this._originalUserConfig=t,this._triggered_notifs=[],t.person_profiles?this._initialPersonProfilesConfig=t.person_profiles:t.process_person&&(this._initialPersonProfilesConfig=t.process_person);var u=Ro(t.defaults),c=Ao(t),h=Zi({},u,c,{name:s,token:d});gt(u.rageclick)&&gt(c.rageclick)&&(h.rageclick=Zi({},u.rageclick,c.rageclick)),gt(u.session_recording)&&gt(c.session_recording)&&(h.session_recording=Zi({},u.session_recording,c.session_recording)),this.set_config(h),this.config.on_xhr_error&&Ji.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=t.disable_compression?void 0:Pr.GZipJS;var p=this._is_persistence_disabled();if(this.persistence=new Sr(this.config,p),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new Sr(i({},this.config,{persistence:"sessionStorage"}),p,!1),this._sessionRegisteredPropertiesStorageKey="ph_"+(this.config.persistence_name||this.config.token)+"_session_registered_properties","memory"!==this.config.persistence&&!p&&Os._is_supported()){var g=Os._parse(this._sessionRegisteredPropertiesStorageKey);ht(g)&&g.forEach(e=>{mt(e)&&this._sessionRegisteredPropKeys.add(e)})}else Os._remove(this._sessionRegisteredPropertiesStorageKey);var v=i({},this.persistence.props),f=i({},this.sessionPersistence.props);this.register({$initialization_time:(new Date).toISOString()}),this._requestQueue=new Vn((e,t)=>this._send_retriable_request(e,t),this.config.request_queue_config),this._retryQueue=new jn(this),this.__request_queue=[];var m=this._inCookielessMode();m||(this.sessionManager=new Zn(this),this.sessionPropsManager=new Jn(this,this.sessionManager,this.persistence),this.sessionManager.onSessionId((e,t,i)=>{(null!=i&&i.activityTimeout||null!=i&&i.sessionPastMaximumLength||null!=i&&i.crossTabAdoption)&&this._clearSessionRegisteredProps()})),this._enrollFeatureFlags(),this.config.__preview_deferred_init_extensions?(Ji.info("Deferring extension initialization to improve startup performance"),setTimeout(()=>{this._initExtensions(m)},0)):(Ji.info("Initializing extensions synchronously"),this._initExtensions(m)),a.DEBUG=a.DEBUG||this.config.debug,a.DEBUG&&Ji.info("Starting in debug mode",{this:this,config:t,thisC:i({},this.config),p:v,s:f}),!this.config.identity_distinct_id||null!=(r=t.bootstrap)&&r.distinctID||(t.bootstrap=i({},t.bootstrap,{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0}));var y=null==(n=t.bootstrap)?void 0:n.distinctID;if(this._hasStableInitialDistinctId=!!y&&!yt(y),null!=(o=t.bootstrap)&&o.distinctID){var b=t.bootstrap.distinctID,w=this.get_distinct_id(),S=this.persistence.get_property(me);if(t.bootstrap.isIdentifiedID&&null!=w&&w!==b&&"anonymous"===S)this.identify(b);else if(t.bootstrap.isIdentifiedID&&null!=w&&w!==b&&"identified"===S)Ji.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 P=this.config.get_device_id(cs()),x=t.bootstrap.isIdentifiedID?P:b;this.persistence.set_property(me,t.bootstrap.isIdentifiedID?Be:Ne),this.register({distinct_id:b,$device_id:x})}}if(m)this.register_once({distinct_id:Ee,$device_id:null},"");else if(!this.get_distinct_id()){var E=this.config.get_device_id(cs());this.register_once({distinct_id:E,$device_id:E},""),this.persistence.set_property(me,Ne)}return ns(ze,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),ns(ze,"pageshow",()=>{var e;this._isPageUnloading=!1,this._isShutdown||null==(e=this._retryQueue)||e.resume()}),t.segment?Ns(this,()=>this._loaded()):this._loaded(),pt(this.config._onCapture)&&this.config._onCapture!==wo&&(Ji.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",e=>this.config._onCapture(e.event,e))),this.config.ip&&Ji.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 eo.apply(this,arguments)}().then(e=>{e&&this.register({[_]:e})}).catch(wo),this}_isSharedExtension(e){var t=e;return mt(t.name)&&pt(t.setup)}_enrollExtension(e,t){this._isSharedExtension(e)?t.push(()=>{this._getBrowserClientAdapter().add(e).catch(()=>null==e.dispose?void 0:e.dispose()).catch(t=>{Ji.error('Failed to dispose browser extension "'+e.name+'"',t)})}):this._extensions.push(e)}_enrollFeatureFlags(){var t,i,s,r,n,o,a=null!==(t=null==(i=this.config.__extensionClasses)?void 0:i.featureFlags)&&void 0!==t?t:null==(s=e.__defaultExtensionClasses)?void 0:s.featureFlags;a&&(this.featureFlags&&this.featureFlags instanceof a||(null==(o=this._featureFlagsReloadingUnsubscribe)||o.call(this),this._featureFlagsReloadingUnsubscribe=void 0,this.featureFlags=new a(this)),pt(this.featureFlags.onReloading)&&pt(this.featureFlags.setup)?this._featureFlagsReloadingUnsubscribe||(this._featureFlagsReloadingUnsubscribe=this.featureFlags.onReloading(()=>{this._internalEventEmitter.emit("featureFlagsReloading",!0)}),this._getBrowserClientAdapter().add(this.featureFlags)):null==(r=(n=this.featureFlags).initialize)||r.call(n))}_initExtensions(t){var s,r,n,o,a,l,d,u=performance.now(),_=i({},e.__defaultExtensionClasses,this.config.__extensionClasses),c=[];_.exceptions&&this._extensions.push(this.exceptions=null!==(s=this.exceptions)&&void 0!==s?s:new _.exceptions(this)),_.historyAutocapture&&this._extensions.push(this.historyAutocapture=new _.historyAutocapture(this)),_.tracingHeaders&&this._extensions.push(this.tracingHeaders=new _.tracingHeaders(this)),_.siteApps&&this._extensions.push(this.siteApps=new _.siteApps(this)),_.sessionRecording&&!t&&this._extensions.push(this.sessionRecording=new _.sessionRecording(this)),this.config.disable_scroll_properties||c.push(()=>{this.scrollManager.startMeasuringScrollPosition()}),_.autocapture&&this._enrollExtension(this.autocapture=new _.autocapture(this),c),_.surveys&&this._enrollExtension(this.surveys=null!==(r=this.surveys)&&void 0!==r?r:new _.surveys(this),c),_.logs&&this._enrollExtension(this.logs=null!==(n=this.logs)&&void 0!==n?n:new _.logs(this),c),_.metrics&&this._extensions.push(this.metrics=null!==(o=this.metrics)&&void 0!==o?o:new _.metrics(this)),_.conversations&&this._extensions.push(this.conversations=null!==(a=this.conversations)&&void 0!==a?a:new _.conversations(this)),_.productTours&&this._extensions.push(this.productTours=new _.productTours(this)),_.heatmaps&&this._extensions.push(this.heatmaps=new _.heatmaps(this)),_.webVitalsAutocapture&&this._extensions.push(this.webVitalsAutocapture=new _.webVitalsAutocapture(this)),_.exceptionObserver&&this._extensions.push(this.exceptionObserver=new _.exceptionObserver(this)),_.deadClicksAutocapture&&this._extensions.push(this.deadClicksAutocapture=new _.deadClicksAutocapture(this,Ds)),_.toolbar&&this._extensions.push(this.toolbar=null!==(l=this.toolbar)&&void 0!==l?l:new _.toolbar(this)),_.experiments&&this._extensions.push(this.experiments=null!==(d=this.experiments)&&void 0!==d?d:new _.experiments(this)),this._extensions.forEach(e=>{e.initialize&&c.push(()=>{null==e.initialize||e.initialize()})}),c.push(()=>{if(this._pendingRemoteConfig){var e=this._pendingRemoteConfig;this._pendingRemoteConfig=void 0,this._extensions.forEach(t=>null==t.onRemoteConfig?void 0:t.onRemoteConfig(e))}}),this._processInitTaskQueue(c,u)}_processInitTaskQueue(e,t){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-t>=30&&e.length>0)return void setTimeout(()=>{this._processInitTaskQueue(e,t)},0);var i=e.shift();if(i)try{i()}catch(e){Ji.error("Error initializing extension:",e)}}var s=Math.round(performance.now()-t);this.register_for_session({[ke]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[Ie]:s}),this.config.__preview_deferred_init_extensions&&Ji.info("PostHog extensions initialized ("+s+"ms)")}_onRemoteConfig(e){var t;if(!Ye||!Ye.body)return Ji.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout(()=>{this._onRemoteConfig(e)},500);if(this.config.__preview_deferred_init_extensions&&(this._pendingRemoteConfig=e),this._lastRemoteConfig=e,this.compression=void 0,e.ok){var i,s=e.config;s.supportedCompression&&!this.config.disable_compression&&(this.compression=lt(s.supportedCompression,Pr.GZipJS)?Pr.GZipJS:lt(s.supportedCompression,Pr.Base64)?Pr.Base64:void 0),null!=(i=s.analytics)&&i.endpoint&&(this.analyticsDefaultEndpoint=s.analytics.endpoint)}this.set_config({person_profiles:this._initialPersonProfilesConfig?this._initialPersonProfilesConfig:Ue}),null==(t=this._browserClientAdapter)||t.handleRemoteConfig(e),this._extensions.forEach(t=>null==t.onRemoteConfig?void 0:t.onRemoteConfig(e))}_loaded(){try{this.config.loaded(this)}catch(e){Ji.critical("`loaded` function failed",e)}if(this._start_queue_if_opted_in(),this.config.internal_or_test_user_hostname&&null!=Qe&&Qe.hostname){var e=Qe.hostname,t=this.config.internal_or_test_user_hostname;("string"==typeof t?e===t:t.test(e))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout(()=>{(this.consent.isOptedIn()||this._inCookielessMode())&&this._captureInitialPageview()},1),this._remoteConfigLoader=new Hr(this),this._remoteConfigLoader.load()}_start_queue_if_opted_in(){var e;this.is_capturing()&&this.config.request_batching&&(null==(e=this._requestQueue)||e.enable())}_dom_loaded(){this.is_capturing()&&Qi(this.__request_queue,e=>this._send_retriable_request(e)),this.__request_queue=[],this._start_queue_if_opted_in()}_handle_unload(){var e,t,i,s,r;this._isPageUnloading=!0,null==(e=this.surveys)||null==e.handlePageUnload||e.handlePageUnload(),null==(t=this.metrics)||t.flush("sendBeacon"),this.config.request_batching?(this._shouldCapturePageleave()&&this.capture(We),null==(i=this.logs)||i.flushLogs("sendBeacon"),null==(s=this._requestQueue)||s.unload(),null==(r=this._retryQueue)||r.unload()):this._shouldCapturePageleave()&&this.capture(We,null,{transport:"sendBeacon"})}_send_request(e){Wn(this,e)}_send_retriable_request(e,t){this._retryQueue?this._retryQueue.retriableRequest(e,t):this._send_request(t?i({},e,{transport:t}):e)}_execute_array(e){bo++;try{var t,i=[],s=[],r=[];Qi(e,e=>{if(e)if(ht(t=e[0]))r.push(e);else if(pt(e))try{e.call(this)}catch(t){Ji.error("Error executing queued PostHog call",e,t)}else ht(e)&&"alias"===t?i.push(e):ht(e)&&-1!==t.indexOf("capture")&&pt(this[t])?r.push(e):s.push(e)});var n=function(e,t){Qi(e,function(e){try{if(ht(e[0])){var i=t;Xi(e,function(e){i=i[e[0]].apply(i,e.slice(1))})}else t[e[0]].apply(t,e.slice(1))}catch(t){Ji.error("Error executing queued PostHog call",e,t)}})};n(i,this),n(s,this),n(r,this)}finally{bo--}}push(t){if(bo>0&&ht(t)&&mt(t[0])){var i=e.prototype[t[0]];pt(i)&&i.apply(this,t.slice(1))}else this._execute_array([t])}get _facebookClickIdChannel(){return{property:p,persistenceKey:g,cookieName:"_fbc",pattern:ko,register:(e,t)=>{var i;return null==(i=this.persistence)?void 0:i.register({[g]:{value:e,delivered:t}})},unregister:()=>{var e;return null==(e=this.persistence)?void 0:e.unregister(g)}}}get _facebookBrowserIdChannel(){return{property:v,persistenceKey:f,cookieName:"_fbp",pattern:Io,register:(e,t)=>{var i;return null==(i=this.persistence)?void 0:i.register({[f]:{value:e,delivered:t}})},unregister:()=>{var e;return null==(e=this.persistence)?void 0:e.unregister(f)}}}_getPersistedMetaIdentifier(e){var t,i=null==(t=this.persistence)?void 0:t.get_property(e.persistenceKey);return mt(i)&&e.pattern.test(i)?{value:i,delivered:!1}:gt(i)&&mt(i.value)&&e.pattern.test(i.value)?{value:i.value,delivered:!0===i.delivered}:void 0}_storeMetaIdentifier(e,t,i){return t===(null==i?void 0:i.value)?{value:t,pending:!i.delivered}:(e.register(t,!1),{value:t,pending:!0})}_readMetaCookie(e){if(this.config.save_campaign_params&&!this._inCookielessMode()){var t=os(e.cookieName);return mt(t)&&e.pattern.test(t)?t:void 0}}_updateFacebookClickId(e,t,i,s){if(this.persistence){var r=this._facebookClickIdChannel;this.persistence.refreshKey(r.persistenceKey);var n=this._getPersistedMetaIdentifier(r);if(!s){if(i)return mt(t)&&ko.test(t)?this._storeMetaIdentifier(r,t,n):void r.unregister();var o=mt(e)&&Co.test(e)?e:void 0,a=this._readMetaCookie(r);return a&&((e,t,i)=>{var s=e.split(".");if(t)return s[3]===t;if(!i)return!0;var r=i.value.split(".");return s[3]===r[3]||Number(s[2])>Number(r[2])})(a,o,n)?this._storeMetaIdentifier(r,a,n):o?(null==n?void 0:n.value.split(".")[3])===o?{value:n.value,pending:!n.delivered}:this._storeMetaIdentifier(r,"fb.1."+Date.now()+"."+o,n):n?{value:n.value,pending:!n.delivered}:void 0}r.unregister()}}_updateFacebookBrowserId(e,t,i){if(this.persistence){var s=this._facebookBrowserIdChannel;this.persistence.refreshKey(s.persistenceKey);var r=this._getPersistedMetaIdentifier(s);if(!i){if(t)return mt(e)&&Io.test(e)?this._storeMetaIdentifier(s,e,r):void s.unregister();var n=this._readMetaCookie(s);return n?this._storeMetaIdentifier(s,n,r):r?{value:r.value,pending:!r.delivered}:void 0}s.unregister()}}_markMetaIdentifierDelivered(e,t){if(this.persistence){this.persistence.refreshKey(e.persistenceKey);var i=this._getPersistedMetaIdentifier(e);(null==i?void 0:i.value)!==t||i.delivered||e.register(t,!0)}}capture(e,t,s){var r,n,o,a,l,d,u;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this._requestQueue){if(this.is_capturing())if(!ft(e)&&mt(e)){this._healCookielessSentinelDistinctId();var _=!this.config.opt_out_useragent_filter&&this._is_bot();if(!_||this.config.__preview_capture_bot_pageviews){var c=null!=s&&s.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(null==c||!c.isRateLimited){var h;null!=t&&t.$current_url&&!mt(null==t?void 0:t.$current_url)&&(Ji.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),null==t||delete t.$current_url),"$exception"!==e||null!=s&&s._originatedFromCaptureException||Ji.warn("Using `posthog.capture('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureException(error)` instead, which attaches required metadata automatically."),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&(h=this.sessionPersistence.update_campaign_params()),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();var g=new Date,f=(null==s?void 0:s.timestamp)||g,m=Di(null==s?void 0:s.uuid,cs),y={uuid:m,event:e,properties:this.calculateEventProperties(e,t||{},f,m)};"$pageview"===e&&this.config.__preview_capture_bot_pageviews&&_&&(y.event="$bot_pageview",y.properties.$browser_type="bot"),c&&(y.properties.$lib_rate_limit_remaining_tokens=c.remainingTokens);var b="$feature_flag_called"===e&&!1===y.properties.$feature_flag_has_experiment&&!0===this.get_property("$minimal_flag_called_events");null!=s&&s.$set&&!b&&(y.$set=null==s?void 0:s.$set);var w=gt(null==t?void 0:t.$set)?t.$set:void 0,S=ht(null==t?void 0:t.$unset)?t.$unset:[],P=(null==s?void 0:s.$unset)||[],x=e=>{var t,i=!(null==s||!s.$set)&&e in s.$set;return{hasProvided:i||!!w&&e in w,provided:i?null==s||null==(t=s.$set)?void 0:t[e]:null==w?void 0:w[e],unset:-1!==S.indexOf(e)||-1!==P.indexOf(e)}},E=x(p),C=x(v),k=[{channel:this._facebookClickIdChannel,hasProvided:E.hasProvided,update:this._updateFacebookClickId(null==(r=h)?void 0:r.fbclid,E.provided,E.hasProvided,E.unset)},{channel:this._facebookBrowserIdChannel,hasProvided:C.hasProvided,update:this._updateFacebookBrowserId(C.provided,C.hasProvided,C.unset)}];for(var I of k){var T=I.channel,F=I.update;F&&!0===y.properties.$process_person_profile&&F.pending&&!I.hasProvided&&!b&&(y.$set=i({[T.property]:F.value},y.$set))}var R=null==s?void 0:s.$unset;R&&(y.$unset=R);var O=b?void 0:this._calculate_set_once_properties(null==s?void 0:s.$set_once,e!==je,e===Ve);if(O&&(y.$set_once=O),null!=s&&s._noTruncate||(a=this.config.properties_string_max_length,l=y,d=e=>mt(e)?e.slice(0,a):e,u=new Set,y=function e(t,i){if(t!==Object(t))return d?d(t):t;if(!u.has(t)){var s;if(u.add(t),ht(t))s=[],Qi(t,t=>{s.push(e(t))});else{var r={};Xi(kt(t)?is(t):t,(t,i)=>{u.has(t)||(r[i]=e(t,i))}),s=r}return s}}(l)),y.timestamp=f,ft(null==s?void 0:s.timestamp)||(y.properties.$event_time_override_provided=!0,y.properties.$event_time_override_system_time=g),b&&(y.properties=function(e,t){void 0===t&&(t=[]);var i={},s=t=>{void 0!==e[t]&&(i[t]=e[t])};return Ui.forEach(s),t.forEach(s),i}(y.properties,To)),e===Rr.DISMISSED||e===Rr.SENT){var A=null==t?void 0:t[Or.SURVEY_ID],M=null==t?void 0:t[Or.SURVEY_ITERATION];(e=>{try{var t=(e=>((e,t)=>"seenSurvey_"+function(e){return e.current_iteration&&e.current_iteration>0?e.id+"_"+e.current_iteration:e.id}(t))(0,e))(e);if(localStorage.getItem(t))return;localStorage.setItem(t,"true")}catch(e){uo.error("Failed to persist survey seen state",e)}})({id:A,current_iteration:M}),y.$set=i({},y.$set,{[to({id:A,current_iteration:M},e===Rr.SENT?"responded":"dismissed")]:!0})}else e===Rr.SHOWN&&(y.$set=i({},y.$set,{[Or.SURVEY_LAST_SEEN_DATE]:(new Date).toISOString()}));if(e===Lr.SHOWN){var D=null==t?void 0:t[Nr.TOUR_TYPE];D&&(y.$set=i({},y.$set,{[Nr.TOUR_LAST_SEEN_DATE+"/"+D]:(new Date).toISOString()}))}var L=i({},y.properties.$set,y.$set);if(vt(L)||this.setPersonPropertiesForFlags(L),!wt(this.config.before_send)){var N=this._runBeforeSend(y);if(!N)return;(y=N).uuid=Di(y.uuid,cs)}var B=k.filter(e=>{var t,i,s,r=e.channel,n=e.update,o=null!==(t=null==(i=y.$set)?void 0:i[r.property])&&void 0!==t?t:gt(null==(s=y.properties)?void 0:s.$set)?y.properties.$set[r.property]:void 0;return(null==n?void 0:n.pending)&&o===n.value});this._internalEventEmitter.emit("eventCaptured",y);var U,q,H=null!==(n=null==s?void 0:s._url)&&void 0!==n?n:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),G="recordings"===(null==s?void 0:s._batchKey)||/\/s\/(?:\?|$)/.test(H),W=i({method:"POST",url:H,data:y,compression:"best-available",timestampMode:G?"body":"capture-body",batchKey:null==s?void 0:s._batchKey},G&&null!=(o=y.properties)&&o.$session_id?{batchGroup:y.properties.$session_id+(y.properties.$window_id?"-"+y.properties.$window_id:"")}:{},null!=s&&s.transport?{transport:s.transport}:{},B.length?{fireCallbackOnDrop:!0,callback:e=>{if(e.statusCode>=200&&300>e.statusCode)for(var t of B)this._markMetaIdentifierDelivered(t.channel,t.update.value)}}:{});return!this.config.request_batching||s&&(null==s||!s._batchKey)||null!=s&&s.send_instantly||B.length?(!W.transport&&!W.callback&&vt(null!==(U=this.config.request_headers)&&void 0!==U?U:{})&&this._isPageUnloading&&(q="sendBeacon"),this._send_retriable_request(W,q)):this._requestQueue.enqueue(W),y}Ji.critical("This capture call is ignored due to client rate limiting.")}}else Ji.error("No event name provided to posthog.capture")}else Ji.uninitializedWarning("posthog.capture")}_addCaptureHook(e){return this.on("eventCaptured",t=>e(t.event,t))}getExtension(e){var t;return null==(t=this._browserClientAdapter)?void 0:t.getExtension(e)}_getBrowserClientAdapter(){var e;return null!==(e=this._browserClientAdapter)&&void 0!==e?e:this._browserClientAdapter=new mo(this)}_registerExtensionEventProperties(e){this._extensionEventPropertyProducers.push(e);var t=!0;return()=>{if(t){t=!1;var i=this._extensionEventPropertyProducers.indexOf(e);-1!==i&&this._extensionEventPropertyProducers.splice(i,1)}}}_processCookieIdentityChange(e){var t,i,s;return void 0===e&&(e=!0),!(null==(t=this.persistence)||!t.consumeCookieIdentityChange())&&(this._cachedPersonProperties=null,"anonymous"===this.persistence.get_property("$user_state")&&(null==(s=this.sessionPersistence)||s.clear(),this._sessionRegisteredPropKeys.clear(),this._persistSessionRegisteredPropKeys()),null==(i=this.featureFlags)||i.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._processCookieIdentityChange();var a=n?void 0:this.persistence.remove_event_timer(e),l=i({},t);if(l.token=this.config.token,l.$config_defaults=this.config.defaults,this._inCookielessMode()&&(l[Ce]=!0),"$snapshot"===e){var d=i({},this.persistence.properties(),this.sessionPersistence.properties());return l.distinct_id=d.distinct_id,(!mt(l.distinct_id)&&!St(l.distinct_id)||yt(l.distinct_id))&&Ji.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),l}var u,_=function(e,t,i,s){var r,n,a,l;if(void 0===s&&(s=!1),!it)return{};var d,u=e?[...Qs,...t||[]]:[],_=function(e){for(var t=0;Fi.length>t;t++){var i=Fi[t],s=i[1],r=i[0].exec(e),n=r&&(pt(s)?s(r,e):s);if(n)return n}return["",""]}(it),c=_[0],h=_[1],p=function(e){for(var t=0;Ai.length>t;t++){var i,s=Ai[t],r=s[1],n=s[2],o=e.match(s[0]);if(o)return[r,(null==(i=n&&e.match(n)||o)?void 0:i[1])||""]}return["",""]}(it),g=p[0],v=p[1],f=null!=(d="u">typeof navigator?navigator:void 0)&&d.brave?{brave:!0}:{},m={};ft(i)||(m.detectGoogleSearchApp=i);var y={},b=null==(r=navigator)||null==(r=r.userAgentData)?void 0:r.platform,w=null==(n=navigator)?void 0:n.maxTouchPoints,S=null==ze||null==(a=ze.screen)?void 0:a.width,P=null==ze||null==(l=ze.screen)?void 0:l.height,x=null==ze?void 0:ze.devicePixelRatio;ft(b)||(y.userAgentDataPlatform=b),ft(w)||(y.maxTouchPoints=w),ft(S)||(y.screenWidth=S),ft(P)||(y.screenHeight=P),ft(x)||(y.devicePixelRatio=x);var E,C,k,I,T,F,R,O,A=Zi(ts({$os:c,$os_version:h,$browser:Ii(it,navigator.vendor,f,m),$webview_app:g,$webview_app_version:v,$device:Ri(it),$device_type:(C=it,k=y,O=Ri(C),O===Nt||O===Lt||"Kobo"===O||"Kindle Fire"===O||O===ai?Dt:O===Qt||O===Zt||O===Xt||O===ni?"Console":O===Bt?"Wearable":O?At:"Android"===(null==k?void 0:k.userAgentDataPlatform)&&(null!==(I=null==k?void 0:k.maxTouchPoints)&&void 0!==I?I:0)>0?600>Math.min(null!==(T=null==k?void 0:k.screenWidth)&&void 0!==T?T:0,null!==(F=null==k?void 0:k.screenHeight)&&void 0!==F?F:0)/(null!==(R=null==k?void 0:k.devicePixelRatio)&&void 0!==R?R:1)?At:Dt:"Desktop"),$timezone:lr(),$timezone_offset:dr()}),{$current_url:Ys(s?Ni(null==Qe?void 0:Qe.href):null==Qe?void 0:Qe.href,u,Zs),$host:null==Qe?void 0:Qe.host,$pathname:null==Qe?void 0:Qe.pathname,$raw_user_agent:it.length>1e3?it.substring(0,997)+"...":it,$browser_version:$i(it,navigator.vendor,f,m),$browser_language:sr(),$browser_language_prefix:(E=sr(),"string"==typeof E?E.split("-")[0]:void 0),$screen_height:null==ze?void 0:ze.screen.height,$screen_width:null==ze?void 0:ze.screen.width,$viewport_height:null==ze?void 0:ze.innerHeight,$viewport_width:null==ze?void 0:ze.innerWidth,$lib:o.LIB_NAME,$lib_version:o.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3});return o.SDK_DIST_CHANNEL&&(A.$sdk_dist_channel=o.SDK_DIST_CHANNEL),A}(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),h=c.windowId;l.$session_id=c.sessionId,l.$window_id=h}this.sessionPropsManager&&Zi(l,this.sessionPropsManager.getSessionProps());try{var p;this.sessionRecording&&Zi(l,this.sessionRecording.sdkDebugProperties),l.$sdk_debug_retry_queue_size=null==(p=this._retryQueue)?void 0:p.length}catch(e){l.$sdk_debug_error_capturing_properties=String(e)}if(this.requestRouter.region===ro&&(l.$lib_custom_api_host=this.config.api_host),u="$pageview"!==e||n?"$pageleave"!==e||n?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(s):this.pageViewManager.doPageView(s,r),l=Zi(l,u),"$pageview"===e&&Ye&&(l.title=Ye.title),!ft(a)){var g=s.getTime()-a;l.$duration=parseFloat((g/1e3).toFixed(3))}it&&this.config.opt_out_useragent_filter&&(l.$browser_type=this._is_bot()?"bot":"browser");var v=this.persistence.properties(),f=this.sessionPersistence.properties(),m=l.$groups,y=v.$groups;gt(m)&&!vt(m)&&(l.$groups=i({},gt(y)?y:{},m)),Xi(["$referrer","$referring_domain"],e=>{e in v&&delete f[e]});var b={};if(this._extensionEventPropertyProducers.length>0)for(var w of this._extensionEventPropertyProducers.slice())try{Zi(b,w())}catch(e){Ji.error("Failed to produce browser extension event properties",e)}(l=Zi({},_,v,f,i({},b,l))).$is_identified=this._isIdentified(),ht(this.config.property_denylist)?Xi(this.config.property_denylist,function(e){delete l[e]}):Ji.error(Eo+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var S=this.config.sanitize_properties;S&&(Ji.error(xo),l=S(l,e));var P=this._hasPersonProcessing();return l.$process_person_profile=P,P&&!n&&this._requirePersonProcessing("_calculate_event_properties"),l}_calculate_set_once_properties(e,t,i){var s;if(void 0===t&&(t=!0),void 0===i&&(i=!1),!this.persistence||!this._hasPersonProcessing())return e;if(this._personProcessingSetOncePropertiesSent&&!i)return e;var r=Zi({},this.persistence.get_initial_props(),(null==(s=this.sessionPropsManager)?void 0:s.getSetOnceProps())||{},e||{}),n=this.config.sanitize_properties;return n&&(Ji.error(xo),r=n(r,"$set_once")),t&&(this._personProcessingSetOncePropertiesSent=!0),vt(r)?void 0:r}register(e,t){var i;null==(i=this.persistence)||i.register(e,t)}register_once(e,t,i){var s;null==(s=this.persistence)||s.register_once(e,t,i)}register_for_session(e){var t,i;null==(t=this.persistence)||t.syncCookieProperties(),this._processCookieIdentityChange(),null==(i=this.sessionPersistence)||i.register(e),Object.keys(e).forEach(e=>this._sessionRegisteredPropKeys.add(e)),this._persistSessionRegisteredPropKeys()}unregister(e){var t;null==(t=this.persistence)||t.unregister(e)}unregister_for_session(e){var t;null==(t=this.sessionPersistence)||t.unregister(e),this._sessionRegisteredPropKeys.delete(e),this._persistSessionRegisteredPropKeys()}_register_single(e,t){this.register({[e]:t})}_clearSessionRegisteredProps(){this._sessionRegisteredPropKeys.forEach(e=>{var t;null==(t=this.sessionPersistence)||t.unregister(e)}),this._sessionRegisteredPropKeys.clear(),this._persistSessionRegisteredPropKeys()}_persistSessionRegisteredPropKeys(){var e;if(this._sessionRegisteredPropertiesStorageKey)if("memory"===this.config.persistence||null!=(e=this.sessionPersistence)&&e._disabled||!Os._is_supported())Os._remove(this._sessionRegisteredPropertiesStorageKey);else{var t=[];this._sessionRegisteredPropKeys.forEach(e=>t.push(e)),t.length>0?Os._set(this._sessionRegisteredPropertiesStorageKey,t):Os._remove(this._sessionRegisteredPropertiesStorageKey)}}getFeatureFlag(e,t){var i;return null==(i=this.featureFlags)?void 0:i.getFeatureFlag(e,t)}getFeatureFlagPayload(e){var t;return null==(t=this.featureFlags)?void 0:t.getFeatureFlagPayload(e)}getFeatureFlagResult(e,t){var i;return null==(i=this.featureFlags)?void 0:i.getFeatureFlagResult(e,t)}getAllFeatureFlags(){var e,t;return null!==(e=null==(t=this.featureFlags)?void 0:t.getAllFeatureFlags())&&void 0!==e?e:[]}isFeatureEnabled(e,t){var i,s;return null!==(i=null==(s=this.featureFlags)?void 0:s.isFeatureEnabled(e,t))&&void 0!==i?i:null==t?void 0:t.defaultValue}reloadFeatureFlags(){var e;null==(e=this.featureFlags)||e.reloadFeatureFlags()}updateFlags(e,t,i){var s;null==(s=this.featureFlags)||s.updateFlags(e,t,i)}updateEarlyAccessFeatureEnrollment(e,t,i){var s;null==(s=this.featureFlags)||s.updateEarlyAccessFeatureEnrollment(e,t,i)}getEarlyAccessFeatures(e,t,i){var s;return void 0===t&&(t=!1),null==(s=this.featureFlags)?void 0:s.getEarlyAccessFeatures(e,t,i)}on(e,t){return this._internalEventEmitter.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:Po}),()=>{})}onSessionId(e){var t,i;return null!==(t=null==(i=this.sessionManager)?void 0:i.onSessionId(e))&&void 0!==t?t:()=>{}}getSurveys(e,t){void 0===t&&(t=!1),this.surveys?this.surveys.getSurveys(e,t):e([],{isLoaded:!1,error:Po})}getActiveMatchingSurveys(e,t){void 0===t&&(t=!1),this.surveys?this.surveys.getActiveMatchingSurveys(e,t):e([],{isLoaded:!1,error:Po})}renderSurvey(e,t){var i;null==(i=this.surveys)||i.renderSurvey(e,t)}displaySurvey(e,t){var i;void 0===t&&(t=_o),null==(i=this.surveys)||i.displaySurvey(e,t)}cancelPendingSurvey(e){var t;null==(t=this.surveys)||t.cancelPendingSurvey(e)}canRenderSurvey(e){var t,i;return null!==(t=null==(i=this.surveys)?void 0:i.canRenderSurvey(e))&&void 0!==t?t:{visible:!1,disabledReason:Po}}canRenderSurveyAsync(e,t){var i,s;return void 0===t&&(t=!1),null!==(i=null==(s=this.surveys)?void 0:s.canRenderSurveyAsync(e,t))&&void 0!==i?i:Promise.resolve({visible:!1,disabledReason:Po})}_validateIdentifyId(e){return!e||yt(e)?(Ji.critical("Unique user id has not been set in posthog.identify"),!1):"$posthog_cookieless"===e?(Ji.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())||(Ji.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,i){if(!this.__loaded||!this.persistence)return Ji.uninitializedWarning("posthog.identify");if(St(e)&&(e=e.toString(),Ji.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),this._validateIdentifyId(e)&&this._requirePersonProcessing("posthog.identify")){this._healCookielessSentinelDistinctId();var s=this.get_distinct_id(),r=this.persistence.syncCookieProperties()&&this.get_distinct_id()!==s,n=this._processCookieIdentityChange(!1),o=this.persistence._beginCookieSyncSuppression(),a=!1;try{var l=this.get_distinct_id();this.register({$user_id:e}),this.get_property("$device_id")||this.register_once({$had_persisted_distinct_id:!0,$device_id:l},""),e!==l&&e!==this.get_property("__alias")&&(this.unregister(c),this.register({distinct_id:e}));var d=(this.persistence.get_property("$user_state")||"anonymous")===Ne,u=e!==l,_=!u&&d;if(u&&d){var h,p=this.config.reuseAnonymousId?{distinct_id:e}:{distinct_id:e,$anon_distinct_id:l};this.persistence.set_property(me,Be),this.setPersonPropertiesForFlags({$set:t||{},$set_once:i||{}},!1),this.config.cookieWinsOnConflict&&this.persistence._publishSuppressedCookieSnapshot(),this.capture("$identify",p,{$set:t||{},$set_once:i||{}})&&(this._cachedPersonProperties=io(e,t,i)),null==(h=this.featureFlags)||h.setAnonymousDistinctId(this.config.reuseAnonymousId?void 0:l)}else if(_){this.persistence.set_property(me,Be);var g=t||{},v=i||{};this.setPersonPropertiesForFlags({$set:g,$set_once:v},!1),this.config.cookieWinsOnConflict&&this.persistence._publishSuppressedCookieSnapshot(),this.capture("$set",{$set:g,$set_once:v})&&(this._cachedPersonProperties=io(e,t,i))}else(t||i)&&this.setPersonProperties(t,i);u||r||n?(this.reloadFeatureFlags(),this.featureFlags?this.featureFlags.resetFlagCallReported():this.unregister(pe)):_&&(t||i)&&this.reloadFeatureFlags(),a=!0}finally{o&&this.persistence._endCookieSyncSuppression(a)}}}setPersonProperties(e,t){if((e||t)&&this._requirePersonProcessing("posthog.setPersonProperties")){var i=io(this.get_distinct_id(),e,t);this._cachedPersonProperties!==i?(this.setPersonPropertiesForFlags({$set:e||{},$set_once:t||{}},!0),this.capture("$set",{$set:e||{},$set_once:t||{}})&&(this._cachedPersonProperties=i)):Ji.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}unsetPersonProperties(e){var t,i=(ht(e)?e:[e]).filter(e=>mt(e)&&e.length>0);0!==i.length&&this._requirePersonProcessing("posthog.unsetPersonProperties")&&(null==(t=this.featureFlags)||t.unsetPersonPropertiesForFlags(i,!0),this.capture("$set",{$unset:i}),this._cachedPersonProperties=null)}group(e,t,s){var r;if(e&&t){null==(r=this.persistence)||r.syncCookieProperties(),this._processCookieIdentityChange();var n=this.getGroups(),o=n[e]!==t;if(o&&this.resetGroupPropertiesForFlags(e),this.register({$groups:i({},n,{[e]:t})}),(o||s)&&this._hasPersonProcessing()){var a={$group_type:e,$group_key:t};s&&(a.$group_set=s),this.capture(je,a)}s&&this.setGroupPropertiesForFlags({[e]:s}),o&&!s&&this.reloadFeatureFlags()}else Ji.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,t){var i;void 0===t&&(t=!0),null==(i=this.featureFlags)||i.setPersonPropertiesForFlags(e,t)}resetPersonPropertiesForFlags(e){var t;void 0===e&&(e=!0),null==(t=this.featureFlags)||t.resetPersonPropertiesForFlags(e)}setGroupPropertiesForFlags(e,t){var i;void 0===t&&(t=!0),this._requirePersonProcessing("posthog.setGroupPropertiesForFlags")&&(null==(i=this.featureFlags)||i.setGroupPropertiesForFlags(e,t))}resetGroupPropertiesForFlags(e){var t;null==(t=this.featureFlags)||t.resetGroupPropertiesForFlags(e)}reset(e){var t=xt(e)?e:null==e?void 0:e.resetDeviceID,i=xt(e)||null==e?void 0:e.bootstrap;this._reset(t,!1,i)}_reset(e,t,s){var r,n,o,a;if(void 0===t&&(t=!1),Ji.info("reset"),!this.__loaded)return Ji.uninitializedWarning("posthog.reset");var l=null==s?void 0:s.sessionID;this.config.bootstrap=s||(null==(r=this._originalUserConfig)?void 0:r.bootstrap)||{},null==(n=this.featureFlags)||null==n.updateConfig||n.updateConfig(this.config,this._shouldDisableFlags());var d=this.get_property(u),c=this.get_property(_),h=this.get_property(T);null==(o=this.sessionRecording)||o.flushBeforeIdentityReset();var p=this.is_capturing();this.consent.reset(),t||!p||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 g=null==(a=this.persistence)||null==a._beginCookieSyncSuppression?void 0:a._beginCookieSyncSuppression(),v=!1;try{var f,m,y,b,w,S,P,x,E,C,k,I,F;if(null==(f=this.persistence)||f.clear(),null==(m=this.sessionPersistence)||m.clear(),this._sessionRegisteredPropKeys.clear(),this._persistSessionRegisteredPropKeys(),ft(h)||null==(y=this.persistence)||y.register({[T]:h}),null==(b=this.surveys)||b.reset(),null==(w=this.featureFlags)||w.reset(),null==(S=this.conversations)||S.reset(),null==(P=this.logs)||P.reset(),null==(x=this.metrics)||x.reset(),null==(E=this.persistence)||E.set_property(me,Ne),null==(C=this.sessionManager)||C.resetSessionId(),this._cachedPersonProperties=null,"always"===this.config.cookieless_mode)this.register_once({distinct_id:Ee,$device_id:null},"");else{var R=this.config.get_device_id(cs());this.register_once({distinct_id:R,$device_id:e?R:d},""),e||ft(c)||this.register({[_]:c})}if(this.register({$last_posthog_reset:(new Date).toISOString()},1),s)if(s.distinctID&&!this._inCookielessMode()&&(null==(F=this.persistence)||F.set_property(me,s.isIdentifiedID?Be:Ne),this.register({distinct_id:s.distinctID})),null==(k=this.featureFlags)||k.initialize(),!(wt(l)||null!=(I=this.sessionManager)&&I.setBootstrapSessionId(l,!0))){var O=i({},s);delete O.sessionID,this.config.bootstrap=O}delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,v=!0}finally{var A;g&&(null==(A=this.persistence)||null==A._endCookieSyncSuppression||A._endCookieSyncSuppression(v))}this.reloadFeatureFlags()}shutdown(e){var t=this;return r(function*(){var e,i,s,r,n,o,a,l;if(t.__loaded){t._isShutdown=!0,t._getBrowserClientAdapter().dispose(),null==(e=t.sessionRecording)||e.dispose(),null==(i=t.logs)||i.flushLogs("sendBeacon"),null==(s=t.metrics)||s.flush("sendBeacon"),null==(r=t.metrics)||r.dispose(),null==(n=t._requestQueue)||n.unload(),null==(o=t._retryQueue)||o.unload();try{var d;null==(d=t.featureFlags)||d.destroy()}catch(e){Ji.error("Error while destroying feature flags",e)}null==(a=t.persistence)||a.destroy(),null==(l=t.sessionPersistence)||l.destroy()}else Ji.uninitializedWarning("posthog.shutdown")})()}setIdentity(e,t){var i;delete this.config.identity_claims,this.config.identity_distinct_id=e,this.config.identity_hash=t,this.alias(e),null==(i=this.conversations)||i._onIdentityChanged()}clearIdentity(){var e;delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,null==(e=this.conversations)||e._onIdentityCleared()}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var e,t;return null!==(e=null==(t=this.sessionManager)?void 0:t.checkAndGetSessionAndWindowId(!0).sessionId)&&void 0!==e?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";var t=this.sessionManager.checkAndGetSessionAndWindowId(!0),i=t.sessionStartTimestamp,s=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+t.sessionId);if(null!=e&&e.withTimestamp&&i){var r,n=null!==(r=e.timestampLookBack)&&void 0!==r?r:10;if(!i)return s;s+="?t="+Math.max(Math.floor(((new Date).getTime()-i)/1e3)-n,0)}return s}alias(e,t){return e===this.get_property("$people_distinct_id")?(Ji.critical("Attempting to create alias for existing People user - aborting."),-2):this._requirePersonProcessing("posthog.alias")?(ft(t)&&(t=this.get_distinct_id()),e!==t?(this._register_single(c,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(Ji.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var t=i({},this.config);if(gt(e)){var s,r,n,o,l,d,u,_,c,h,p,g,v,f;Zi(this.config,Ao(e));var m=this._is_persistence_disabled();null==(s=this.persistence)||s.update_config(this.config,t,m),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new Sr(i({},this.config,{persistence:"sessionStorage"}),m,!1);var y=this._checkLocalStorageForDebug(this.config.debug);xt(y)&&(this.config.debug=y),xt(this.config.debug)&&(this.config.debug?(a.DEBUG=!0,ys._is_supported()&&ys._set("ph_debug",!0),Ji.info("set_config",{config:e,oldConfig:t,newConfig:i({},this.config)})):(a.DEBUG=!1,ys._is_supported()&&ys._remove("ph_debug"))),null==(r=this.featureFlags)||null==r.updateConfig||r.updateConfig(this.config,this._shouldDisableFlags()),null==(n=this.exceptionObserver)||n.onConfigChange(),null==(o=this.exceptions)||o.onConfigChange(),null==(l=this.metrics)||l.onConfigChange(),null==(d=this.sessionRecording)||d.startIfEnabledOrStop(),null==(u=this.tracingHeaders)||u.startIfEnabledOrStop(),null==(_=this.autocapture)||_.startIfEnabled(),null==(c=this.heatmaps)||c.startIfEnabled(),("capture_pageview"in e||"disable_capture_url_hashes"in e)&&(null==(h=this.historyAutocapture)||h.startIfEnabledOrStop()),null==(p=this.exceptionObserver)||p.startIfEnabledOrStop(),null==(g=this.deadClicksAutocapture)||g.startIfEnabledOrStop(),null==(v=this.surveys)||v.loadIfEnabled(),this._sync_opt_out_with_persistence(),null==(f=this.externalIntegrations)||f.startIfEnabledOrStop(),!t.segment&&this.config.segment&&this.persistence&&Ns(this,wo,!1)}}_overrideSDKInfo(e,t){a.LIB_NAME=e,a.LIB_VERSION=t}startSessionRecording(e){var t,i,s,r,n,o=!0===e,a={sampling:o||!(null==e||!e.sampling),linked_flag:o||!(null==e||!e.linked_flag),url_trigger:o||!(null==e||!e.url_trigger),event_trigger:o||!(null==e||!e.event_trigger)};Object.values(a).some(Boolean)&&(null==(t=this.sessionManager)||t.checkAndGetSessionAndWindowId(),a.sampling&&(null==(i=this.sessionRecording)||i.overrideSampling()),a.linked_flag&&(null==(s=this.sessionRecording)||s.overrideLinkedFlag()),a.url_trigger&&(null==(r=this.sessionRecording)||r.overrideTrigger("url")),a.event_trigger&&(null==(n=this.sessionRecording)||n.overrideTrigger("event"))),this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var e;return!(null==(e=this.sessionRecording)||!e.started)}captureException(e,t){try{if(!this.exceptions)return;var s=this.exceptions.buildProperties(e,{handled:!0,syntheticException:new Error("PostHog syntheticException")});return this.exceptions.sendExceptionEvent(i({},s,t))}catch(e){return}}addExceptionStep(e,t){var i;null==(i=this.exceptions)||i.addExceptionStep(e,t)}captureLog(e){var t;null==(t=this.logs)||t.captureLog(e)}get logger(){var t,i;return null!==(t=null==(i=this.logs)?void 0:i.logger)&&void 0!==t?t:e._noopLogger}startExceptionAutocapture(e){this.set_config({capture_exceptions:null==e||e})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(e){var t,i;return null!==(t=null==(i=this.toolbar)?void 0:i.loadToolbar(e))&&void 0!==t&&t}get_property(e){var t;return null==(t=this.persistence)?void 0:t.props[e]}getSessionProperty(e){var t;return null==(t=this.sessionPersistence)?void 0:t.props[e]}toString(){var e,t=null!==(e=this.config.name)&&void 0!==e?e:$o;return t!==$o&&(t="posthog."+t),t}_isIdentified(){var e,t;return"identified"===(null==(e=this.persistence)?void 0:e.get_property("$user_state"))||"identified"===(null==(t=this.sessionPersistence)?void 0:t.get_property("$user_state"))}_hasPersonProcessing(){var e,t;return!("never"===this.config.person_profiles||"identified_only"===this.config.person_profiles&&!this._isIdentified()&&vt(this.getGroups())&&(null==(e=this.persistence)||null==(e=e.props)||!e.__alias)&&(null==(t=this.persistence)||null==(t=t.props)||!t.$epp))}_shouldCapturePageleave(){return!0===this.config.capture_pageleave||"if_capture_pageview"===this.config.capture_pageleave&&!!this.config.capture_pageview}createPersonProfile(){this._hasPersonProcessing()||this._requirePersonProcessing("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this._requirePersonProcessing("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}_requirePersonProcessing(e){return"never"===this.config.person_profiles?(Ji.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this._warnIfVolatileIdentityWithoutStableId(),this._register_single(xe,!0),!0)}_is_persistence_disabled(){if("always"===this.config.cookieless_mode)return!0;var e=this.consent.isOptedOut();return this.config.disable_persistence||e&&!(!this.config.opt_out_persistence_by_default&&"on_reject"!==this.config.cookieless_mode)}_sync_opt_out_with_persistence(){var e,t,i,s,r,n=this._is_persistence_disabled();return this.is_capturing()||null==(e=this.logs)||e._onOptOut(),(null==(t=this.persistence)?void 0:t._disabled)!==n&&(null==(i=this.persistence)||i.set_disabled(n)),(null==(s=this.sessionPersistence)?void 0:s._disabled)!==n&&(null==(r=this.sessionPersistence)||r.set_disabled(n)),n&&(this._sessionRegisteredPropKeys.clear(),this._persistSessionRegisteredPropKeys()),n}opt_in_capturing(t){var i,s,r;if("always"!==this.config.cookieless_mode){if(this._inCookielessMode()){var n,o,a,l,d,u;null==(n=this.sessionRecording)||n.dispose({discardBufferedEvents:!0}),this._reset(!0,!0),null==(o=this.sessionManager)||o.destroy(),null==(a=this.pageViewManager)||a.destroy(),this.sessionManager=new Zn(this),this.pageViewManager=new Hs(this),this.persistence&&(this.sessionPropsManager=new Jn(this,this.sessionManager,this.persistence));var _,c=null!==(l=null==(d=this.config.__extensionClasses)?void 0:d.sessionRecording)&&void 0!==l?l:null==(u=e.__defaultExtensionClasses)?void 0:u.sessionRecording;c&&(this.sessionRecording=this._replaceExtension(this.sessionRecording,new c(this)),this._lastRemoteConfig&&(null==(_=this.sessionRecording)||null==_.onRemoteConfig||_.onRemoteConfig(this._lastRemoteConfig)))}this.consent.optInOut(!0),this._sync_opt_out_with_persistence(),this._start_queue_if_opted_in(),null==(i=this.sessionRecording)||i.startIfEnabledOrStop(),"on_reject"==this.config.cookieless_mode&&(null==(s=this.surveys)||s.loadIfEnabled()),(ft(null==t?void 0:t.captureEventName)||null!=t&&t.captureEventName)&&this.capture(null!==(r=null==t?void 0:t.captureEventName)&&void 0!==r?r:"$opt_in",null==t?void 0:t.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this._captureInitialPageview()}else Ji.warn(So)}opt_out_capturing(){if("always"!==this.config.cookieless_mode){var e,t,i="on_reject"===this.config.cookieless_mode?this.sessionRecording:void 0;null==i||i.dispose({discardBufferedEvents:!0}),"on_reject"===this.config.cookieless_mode&&this.consent.isOptedIn()&&this._reset(!0,!0),this.consent.optInOut(!1),this._sync_opt_out_with_persistence(),"on_reject"===this.config.cookieless_mode&&(this.register({distinct_id:Ee,$device_id:null}),this._removeExtension(i),this.sessionRecording=void 0,null==(e=this.sessionManager)||e.destroy(),null==(t=this.pageViewManager)||t.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,this.config.capture_pageview&&this._captureInitialPageview(),this._start_queue_if_opted_in())}else Ji.warn(So)}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 1===e?"granted":0===e?"denied":"pending"}is_capturing(){return"always"===this.config.cookieless_mode||("on_reject"===this.config.cookieless_mode?this.consent.isRejected()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this._sync_opt_out_with_persistence()}_is_bot(){return Je?function(e,t){if(!e)return!1;var i=e.userAgent;if(i&&Rt(i,t))return!0;try{var s=null==e?void 0:e.userAgentData;if(null!=s&&s.brands&&s.brands.some(e=>Rt(null==e?void 0:e.brand,t)))return!0}catch(e){}return!!e.webdriver}(Je,this.config.custom_blocked_useragents):void 0}_captureInitialPageview(){Ye&&("visible"===Ye.visibilityState?this._initialPageviewCaptured||(this._initialPageviewCaptured=!0,this.capture(Ge,{title:Ye.title},{send_instantly:!0}),this._visibilityStateListener&&(Ye.removeEventListener(qe,this._visibilityStateListener),this._visibilityStateListener=null)):this._visibilityStateListener||(this._visibilityStateListener=this._captureInitialPageview.bind(this),ns(Ye,qe,this._visibilityStateListener)))}debug(e){!1===e?(null==ze||ze.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(null==ze||ze.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}))}_shouldDisableFlags(){var e=this._originalUserConfig||{};return"advanced_disable_flags"in e?!!e.advanced_disable_flags:!1!==this.config.advanced_disable_flags?!!this.config.advanced_disable_flags:!0===this.config.advanced_disable_decide?(Ji.warn("Config field 'advanced_disable_decide' is deprecated. Please use 'advanced_disable_flags' instead. The old field will be removed in a future major version."),!0):function(e,t,i,s,r){var n=t in e&&!wt(e[t]),o=i in e&&!wt(e[i]);return n?e[t]:!!o&&(r&&r.warn("Config field '"+i+"' is deprecated. Please use '"+t+"' instead. The old field will be removed in a future major version."),e[i])}(e,"advanced_disable_flags","advanced_disable_decide",0,Ji)}_runBeforeSend(e){var t;if(wt(this.config.before_send))return e;var i=Object.keys(null!==(t=e.properties)&&void 0!==t?t:{}).filter(Ct),s=ht(this.config.before_send)?this.config.before_send:[this.config.before_send],r=e;for(var n of s)try{if(r=n(r),wt(r)){var o="Event '"+e.event+"' was rejected in beforeSend function";return Et(e.event)?Ji.warn(o+". This can cause unexpected behavior."):Ji.info(o),null}r.properties&&!vt(r.properties)||Ji.warn("Event '"+e.event+"' has no properties after beforeSend function, this is likely an error.")}catch(t){return Ji.error("Error in beforeSend function for event '"+e.event+"':",t),null}for(var a of i)if(r.properties&&wt(r.properties[a]))return Ji.warn("Event '"+e.event+"' had its '"+a+"' property removed in a beforeSend function. This property is required for ingestion, so the event will be dropped."),null;return r}getPageViewId(){var e;return null==(e=this.pageViewManager._currentPageview)?void 0:e.pageViewId}captureTraceFeedback(e,t){this.capture("$ai_feedback",{$ai_trace_id:String(e),$ai_feedback_text:t})}captureTraceMetric(e,t,i){this.capture("$ai_metric",{$ai_trace_id:String(e),$ai_metric_name:t,$ai_metric_value:String(i)})}_checkLocalStorageForDebug(e){var t=xt(e)&&!e,i=ys._is_supported()&&"true"===ys._get("ph_debug");return!t&&(!!i||e)}},e.__defaultExtensionClasses={},e._noopLogger={trace:so=()=>{},debug:so,info:so,warn:so,error:so,fatal:so},e);!function(e,t){for(var i=0;t.length>i;i++)e.prototype[t[i]]=es(e.prototype[t[i]])}(Do,["identify"]);var Lo=function(){a.SDK_DIST_CHANNEL="npm";var e=yo[$o]=new Do;return function(){function e(){e.done||(e.done=!0,Gn=!1,Xi(yo,function(e){e._dom_loaded()}))}null!=Ye&&Ye.addEventListener?"complete"===Ye.readyState?e():ns(Ye,"DOMContentLoaded",e,{capture:!1}):ze&&Ji.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}(),e}();export{Pr as Compression,Dr as DEFAULT_PRODUCT_TOUR_APPEARANCE,Ar as DisplaySurveyType,Do as PostHog,Lr as ProductTourEventName,Nr as ProductTourEventProperties,Rr as SurveyEventName,Or as SurveyEventProperties,xr as SurveyEventType,Cr as SurveyPosition,$r as SurveyQuestionBranchingType,Tr as SurveyQuestionType,Fr as SurveySchedule,kr as SurveyTabPosition,Ir as SurveyType,Er as SurveyWidgetType,Lo as default,Lo as posthog,Gr as severityLevels};
1
+ var e,t=["retriesPerformedSoFar"];function i(){return i=Object.assign?Object.assign.bind():function(e){for(var t=1;arguments.length>t;t++){var i=arguments[t];for(var s in i)({}).hasOwnProperty.call(i,s)&&(e[s]=i[s])}return e},i.apply(null,arguments)}function s(e,t,i,s,r,n,o){try{var a=e[n](o),l=a.value}catch(e){return void i(e)}a.done?t(l):Promise.resolve(l).then(s,r)}function r(e){return function(){var t=this,i=arguments;return new Promise(function(r,n){var o=e.apply(t,i);function a(e){s(o,r,n,a,l,"next",e)}function l(e){s(o,r,n,a,l,"throw",e)}a(void 0)})}}var n="0.8.3",o={DEBUG:(!1,!1),LIB_VERSION:(n,"1.433.3"),LIB_NAME:("browser-common","web"),JS_SDK_VERSION:n},a=o,l="$people_distinct_id",d="distinct_id",u="$device_id",_="$device_model",c="__alias",h="__cmpns",p="$fbc",g="$fbc_persistence",v="$fbp",f="$fbp_persistence",m="__timers",y="$autocapture_disabled_server_side",b="$heatmaps_enabled_server_side",w="$exception_capture_enabled_server_side",S="$error_tracking_suppression_rules",P="$error_tracking_capture_extension_exceptions",x="$web_vitals_enabled_server_side",E="$dead_clicks_enabled_server_side",C="$product_tours_enabled_server_side",k="$logs_capture_enabled_server_side",I="$web_vitals_allowed_metrics",T="$session_recording_remote_config",F="$session_recording_enabled_server_side",R="$replay_sample_rate",O="$replay_override_sampling",A="$replay_override_linked_flag",M="$replay_override_url_trigger",D="$replay_override_event_trigger",L="$sesid",N="$session_is_sampled",B="$session_past_minimum_duration",U="$session_recording_url_trigger_activated_session",q="$session_recording_event_trigger_activated_session",H="$debug_first_full_snapshot_timestamp",G="$sess_rec_flush_size",W="$enabled_feature_flags",V="$active_feature_flags",j="$early_access_features",z="$feature_flag_details",K="$feature_flag_payloads",J="$feature_flag_request_id",Y="$minimal_flag_called_events",Q="$override_feature_flags",X="$override_feature_flag_payloads",Z="$stored_person_properties",ee="$stored_group_properties",te="$groups",ie="$surveys",se="$surveys_loaded_at",re="$surveys_activated",ne="$surveys_activated_session",oe="$surveys_activated_timestamps",ae="ph_product_tours",le="$product_tours_activated",de="$product_tours_activated_session",ue="$conversations_widget_session_id",_e="$conversations_ticket_id",ce="$conversations_widget_state",he="$conversations_user_traits",pe="$flag_call_reported",ge="$flag_call_reported_session_id",ve="$feature_flag_errors",fe="$feature_flag_evaluated_at",me="$user_state",ye="$client_session_props",be="$capture_rate_limit",we="$initial_campaign_params",Se="$initial_referrer_info",Pe="$initial_person_info",xe="$epp",Ee="$posthog_cookieless",Ce="$cookieless_mode",ke="$sdk_debug_extensions_init_method",Ie="$sdk_debug_extensions_init_time_ms",Te="$sdk_debug_recording_script_not_loaded",$e="$sdk_debug_replay_event_trigger_status",Fe="$sdk_debug_replay_linked_flag_trigger_status",Re="$sdk_debug_replay_matched_recording_trigger_groups",Oe="$sdk_debug_replay_pending_trigger_conditions",Ae="$sdk_debug_replay_remote_trigger_matching_config",Me="$sdk_debug_replay_trigger_groups_count",De="$sdk_debug_replay_url_trigger_status",Le="$session_recording_start_reason",Ne="anonymous",Be="identified",Ue="identified_only",qe="visibilitychange",He="beforeunload",Ge="$pageview",We="$pageleave",Ve="$identify",je="$groupidentify",ze="u">typeof window?window:void 0,Ke="u">typeof globalThis?globalThis:ze,Je=null==Ke?void 0:Ke.navigator,Ye=null==Ke?void 0:Ke.document,Qe=null==Ke?void 0:Ke.location,Xe=null==Ke?void 0:Ke.fetch,Ze=null!=Ke&&Ke.XMLHttpRequest&&"withCredentials"in new Ke.XMLHttpRequest?Ke.XMLHttpRequest:void 0,et=null==Ke?void 0:Ke.AbortController,tt=null==Ke?void 0:Ke.CompressionStream,it=null==Je?void 0:Je.userAgent,st="undefined"!=typeof globalThis?globalThis:ze;st&&"undefined"==typeof self&&(st.self=st),st&&"undefined"==typeof File&&(st.File=function(){});var rt=null!=ze?ze:{},nt=function(e){return e.GZipJS="gzip-js",e.Base64="base64",e}({}),ot=["$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"],at=["token"];function lt(e,t){return-1!==e.indexOf(t)}var dt=function(e){return e.replace(/^\$/,"")},ut=Object.prototype,_t=ut.hasOwnProperty,ct=ut.toString,ht=Array.isArray||function(e){return"[object Array]"===ct.call(e)},pt=e=>"function"==typeof e,gt=e=>e===Object(e)&&!ht(e),vt=e=>{if(gt(e)){for(var t in e)if(_t.call(e,t))return!1;return!0}return!1},ft=e=>void 0===e,mt=e=>"[object String]"==ct.call(e),yt=e=>mt(e)&&0===e.trim().length,bt=e=>null===e,wt=e=>ft(e)||bt(e),St=e=>"[object Number]"==ct.call(e)&&e==e,Pt=e=>St(e)&&e>0,xt=e=>"[object Boolean]"===ct.call(e),Et=e=>lt(ot,e),Ct=e=>lt(at,e);function kt(e){switch({}.toString.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object DOMError]":case"[object WebAssembly.Exception]":return!0;default:return function(e,t){try{return e instanceof t}catch(e){return!1}}(e,Error)}}var It=[!0,"true",1,"1","yes"],Tt=e=>lt(It,e),$t=[!1,"false",0,"0","no"],Ft=["amazonbot","amazonproductbot","app.hypefactors.com","applebot","archive.org_bot","awariobot","backlinksextendedbot","baiduspider","bingbot","bingpreview","chrome-lighthouse","dataforseobot","deepscan","duckduckbot","facebookexternal","facebookcatalog","http://yandex.com/bots","hubspot","ia_archiver","leikibot","linkedinbot","meta-externalagent","mj12bot","msnbot","nessus","petalbot","pinterestbot","prerender","rogerbot","screaming frog","sebot-wa","sitebulb","slackbot","slurp","trendictionbot","turnitin","twitterbot","vercel-screenshot","vercelbot","yahoo! slurp","yandexbot","zoombot","bot.htm","bot.php","(bot;","bot/","crawler","ahrefsbot","ahrefssiteaudit","semrushbot","siteauditbot","splitsignalbot","gptbot","oai-searchbot","chatgpt-user","perplexitybot","better uptime bot","sentryuptimebot","uptimerobot","headlesschrome","cypress","google-hoteladsverifier","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleother","google-cloudvertexbot","googleweblight","mediapartners-google","storebot-google","google-inspectiontool","bytespider"],Rt=function(e,t){if(void 0===t&&(t=[]),!e)return!1;var i=e.toLowerCase();return Ft.concat(t).some(e=>{var t=e.toLowerCase();return-1!==i.indexOf(t)})};function Ot(e,t,i,s,r){return t>i&&(s.warn("min cannot be greater than max."),t=i),St(e)?e>i?(s.warn(" cannot be greater than max: "+i+". Using max value instead."),i):t>e?(s.warn(" cannot be less than min: "+t+". Using min value instead."),t):e:(s.warn(" must be a number. using max or fallback. max: "+i+", fallback: "+r),Ot(null!=r?r:i,t,i,s))}var At="Mobile",Mt="Android",Dt="Tablet",Lt="Android Tablet",Nt="iPad",Bt="Apple Watch",Ut="Safari",qt="BlackBerry",Ht="Samsung Internet",Gt="Chrome",Wt="Chrome iOS",Vt="Internet Explorer",jt="Internet Explorer Mobile",zt="Opera",Kt="Microsoft Edge",Jt="Firefox",Yt="Firefox iOS",Qt="Nintendo",Xt="PlayStation",Zt="Xbox",ei="Android Mobile",ti="Mobile Safari",ii="Windows",si="Windows Phone",ri="Nokia",ni="Ouya",oi="Generic "+At.toLowerCase(),ai="Generic "+Dt.toLowerCase(),li="Konqueror",di="Oculus Browser",ui="Vivaldi",_i="Yandex",ci="Whale",hi="DuckDuckGo",pi="Pale Moon",gi="Waterfox",vi="Brave",fi="Claude",mi="Codex",yi="ChatGPT",bi="Google Search App",wi=new RegExp("Version/(\\d+(\\.\\d+)?)"),Si=new RegExp("(Claude|Codex|ChatGPT)\\/(\\d+(\\.\\d+)?)"),Pi=new RegExp(Zt,"i"),xi=new RegExp("PlayStation \\w+","i"),Ei=new RegExp("Nintendo \\w+","i"),Ci=new RegExp("BlackBerry|PlayBook|BB10","i"),ki={"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"},Ii=function(e,t,i,s){t=t||"";var r=function(e){return null!=e&&e.brave?vi:null}(i);return r||(null!=s&&s.detectGoogleSearchApp&&lt(e,"GSA/")?bi:lt(e," OPR/")&&lt(e,"Mini")?"Opera Mini":lt(e," OPR/")?zt:Ci.test(e)?qt:lt(e,"IEMobile")||lt(e,"WPDesktop")?jt:lt(e,"OculusBrowser")?di:lt(e,"SamsungBrowser")?Ht:lt(e,"Edge")||lt(e,"Edg/")?Kt:lt(e,"Vivaldi/")?ui:lt(e,"YaBrowser/")?_i:lt(e,"Whale/")?ci:lt(e,"DuckDuckGo/")||lt(e,"Ddg/")?hi:lt(e,"Claude/")?fi:lt(e,"Codex/")?mi:lt(e,"ChatGPT/")?yi:lt(e,"FBIOS")?"Facebook Mobile":lt(e,"UCWEB")||lt(e,"UCBrowser")?"UC Browser":lt(e,"CriOS")?Wt:lt(e,"CrMo")||lt(e,Gt)?Gt:lt(e,Mt)&&lt(e,Ut)?ei:lt(e,"FxiOS")?Yt:lt(e.toLowerCase(),li.toLowerCase())?li:lt(e,"Brave/")?vi:((e,t)=>t&&lt(t,"Apple")||function(e){return lt(e,Ut)&&!lt(e,Gt)&&!lt(e,Mt)}(e))(e,t)?lt(e,At)?ti:Ut:lt(e,"PaleMoon/")?pi:lt(e,"Waterfox/")?gi:lt(e,Jt)?Jt:lt(e,"MSIE")||lt(e,"Trident/")?Vt:lt(e,"Gecko")?Jt:"")},Ti={[jt]:[new RegExp("rv:(\\d+(\\.\\d+)?)")],[Kt]:[new RegExp("Edge?\\/(\\d+(\\.\\d+)?)")],[Gt]:[new RegExp("(Chrome|CrMo)\\/(\\d+(\\.\\d+)?)")],[Wt]:[new RegExp("CriOS\\/(\\d+(\\.\\d+)?)")],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/(\\d+(\\.\\d+)?)")],[Ut]:[wi],[ti]:[wi],[zt]:[new RegExp("(Opera|OPR)\\/(\\d+(\\.\\d+)?)")],[Jt]:[new RegExp("Firefox\\/(\\d+(\\.\\d+)?)")],[Yt]:[new RegExp("FxiOS\\/(\\d+(\\.\\d+)?)")],[li]:[new RegExp("Konqueror[:/]?(\\d+(\\.\\d+)?)","i")],[qt]:[new RegExp("BlackBerry (\\d+(\\.\\d+)?)"),wi],[ei]:[new RegExp("android\\s(\\d+(\\.\\d+)?)","i")],[Ht]:[new RegExp("SamsungBrowser\\/(\\d+(\\.\\d+)?)")],[di]:[new RegExp("OculusBrowser\\/(\\d+(\\.\\d+)?)")],[ui]:[new RegExp("Vivaldi\\/(\\d+(\\.\\d+)?)")],[_i]:[new RegExp("YaBrowser\\/(\\d+(\\.\\d+)?)")],[ci]:[new RegExp("Whale\\/(\\d+(\\.\\d+)?)")],[vi]:[new RegExp("Brave\\/(\\d+(\\.\\d+)?)")],[fi]:[Si],[mi]:[Si],[yi]:[Si],[hi]:[new RegExp("(DuckDuckGo|Ddg)\\/(\\d+(\\.\\d+)?)")],[pi]:[new RegExp("PaleMoon\\/(\\d+(\\.\\d+)?)")],[gi]:[new RegExp("Waterfox\\/(\\d+(\\.\\d+)?)")],[bi]:[new RegExp("GSA\\/(\\d+(\\.\\d+)?)")],[Vt]:[new RegExp("(rv:|MSIE )(\\d+(\\.\\d+)?)")],Mozilla:[new RegExp("rv:(\\d+(\\.\\d+)?)")]},$i=function(e,t,i,s){var r=Ti[Ii(e,t,i,s)];if(ft(r))return null;for(var n=0;r.length>n;n++){var o=e.match(r[n]);if(o)return parseFloat(o[o.length-2])}return null},Fi=[[new RegExp("Xbox; Xbox (.*?)[);]","i"),e=>[Zt,e&&e[1]||""]],[new RegExp(Qt,"i"),[Qt,""]],[new RegExp(Xt,"i"),[Xt,""]],[Ci,[qt,""]],[new RegExp(ii,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[si,""];if(new RegExp(At).test(t)&&!/IEMobile\b/.test(t))return["Windows Mobile",""];var i=/Windows NT ([0-9.]+)/i.exec(t);if(i&&i[1]){var s=ki[i[1]]||"";return/arm/i.test(t)&&(s="RT"),[ii,s]}return[ii,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>e&&e[3]?["iOS",[e[3],e[4],e[5]||"0"].join(".")]:["iOS",""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var t="";return e&&e.length>=3&&(t=ft(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("(Android (\\d+)\\.(\\d+)\\.?(\\d+)?|Android)","i"),e=>e&&e[2]?[Mt,[e[2],e[3],e[4]||"0"].join(".")]:[Mt,""]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{var t=["Mac OS X",""];return e&&e[1]&&(t[1]=[e[1],e[2],e[3]||"0"].join(".")),t}],[/Mac/i,["Mac OS X",""]],[/CrOS/,["Chrome OS",""]],[/Linux|debian/i,["Linux",""]]],Ri=function(e){return Ei.test(e)?Qt:xi.test(e)?Xt:Pi.test(e)?Zt:new RegExp(ni,"i").test(e)?ni:new RegExp("(Windows Phone|WPDesktop)","i").test(e)?si:/iPad/.test(e)?Nt:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?Bt:Ci.test(e)?qt:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(ri,"i").test(e)?ri:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(e)||/(kf[a-z]+)( bui|\)).+silk\//i.test(e)?"Kindle Fire":/(Android|ZTE)/i.test(e)?new RegExp(At).test(e)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(e)||/pixel[\daxl ]{1,6}/i.test(e)&&!/pixel c/i.test(e)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(e)||/lmy47v/i.test(e)&&!/QTAQZ3/i.test(e)?Mt:Lt:new RegExp("(pda|Mobile)","i").test(e)?oi:new RegExp(Dt,"i").test(e)&&!new RegExp("Tablet pc","i").test(e)?ai:""},Oi=/\bFBAV\/(\d+(?:\.\d+)*)/i,Ai=[[/\bInstagram(?:[ /](\d+(?:\.\d+)*))?\b/i,"Instagram"],[/\bBarcelona[ /](\d+(?:\.\d+)*)?/i,"Threads"],[/\b(?:MessengerForiOS|(?:FBAN|FB_IAB)\/Orca-Android)\b/i,"Messenger",Oi],[/\bFBAN\/EMA\b/i,"Facebook Lite",Oi],[/\b(?:FBIOS|(?:FBAN|FB_IAB)\/(?:FB4A|FBIOS))\b/i,"Facebook",Oi],[/\bLinkedInApp(?:\]?\/(\d+(?:\.\d+)*))?\b/i,"LinkedIn"],[/\bTwitter(?:Android| for (?:iPhone|iPad|Android))(?:\/(\d+(?:\.\d+)*))?\b/i,"Twitter"],[/\b(?:musical_ly|trill)(?:[_/](\d+\.\d+(?:\.\d+)*))?(?=\b|_)/i,"TikTok",/\bapp_version\/(\d+(?:\.\d+)*)/i],[/\b(?:MicroMessenger|WeChat)\/(\d+(?:\.\d+)*)?/i,"WeChat"],[/\bLine\/(\d+(?:\.\d+)*)?/i,"Line"],[/\bGSA\/(\d+(?:\.\d+)*)?/i,"Google"],[/\[Pinterest\/(?:iOS|Android)\b|\bPinterest(?: for (?:Android(?: Tablet)?|iOS))?\/(\d+(?:\.\d+)*)/i,"Pinterest"],[/\b(?:WA4A|WAiOS)\/(\d+(?:\.\d+)*)?/i,"WhatsApp"],[/\bSnapchat[ /](\d+(?:\.\d+)*)?/i,"Snapchat"],[/\bBing(?:Web|Sapphire)\/(\d+(?:\.\d+)*)?/i,"Bing"],[/\bNAVER\(inapp; search;/i,"Naver",/\bNAVER\(inapp; search;[^;)]*; (\d+(?:\.\d+)*)/i],[/\bKAKAOTALK[ /](\d+\.\d+(?:\.\d+)*)?/i,"KakaoTalk"]],Mi=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function Di(e,t){return"string"==typeof(i=e)&&Mi.test(i)?e:t();var i}function Li(e,t){var i=new Error(t);try{Object.defineProperty(i,"name",{value:e,writable:!0,enumerable:!0,configurable:!0})}catch(e){}return i}function Ni(e){return e?e.split("#")[0]:e}var Bi,Ui=["$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"],qi="NativeGzipValidationError",Hi=e=>e.length>=2&&31===e[0]&&139===e[1],Gi=(e,t)=>e===nt.GZipJS||t===nt.GZipJS||"gzip"===t,Wi=e=>!(!e||"object"!=typeof e)&&"NotReadableError"===("name"in e?String(e.name):""),Vi=e=>{throw Li(qi,"Native gzip produced invalid output: "+e)},ji=function(){var e=r(function*(e,t){18>e.size&&Vi("too-short");var i=new Uint8Array(yield e.slice(0,10).arrayBuffer());Hi(i)&&8===i[2]||Vi("invalid-header");var s=new DataView(yield e.slice(e.size-8).arrayBuffer());s.getUint32(0,!0)!==(e=>{for(var t=(()=>{if(Bi)return Bi;Bi=[];for(var e=0;256>e;e++){for(var t=e,i=0;8>i;i++)t=1&t?3988292384^t>>>1:t>>>1;Bi[e]=t>>>0}return Bi})(),i=4294967295,s=0;e.length>s;s++)i=t[255&(i^e[s])]^i>>>8;return(4294967295^i)>>>0})(t)&&Vi("invalid-crc");var r=t.length>>>0;s.getUint32(4,!0)!==r&&Vi("invalid-size")});return function(t,i){return e.apply(this,arguments)}}();function zi(){return zi=r(function*(e,t,i){void 0===t&&(t=!0);try{var s=(new TextEncoder).encode(e),n=new globalThis.CompressionStream("gzip"),o=n.writable.getWriter(),a=o.write(s).then(()=>o.close()).catch(function(){var e=r(function*(e){try{yield o.abort(e)}catch(e){}throw e});return function(t){return e.apply(this,arguments)}}()),l=new Response(n.readable).blob(),d=(yield Promise.all([l,a]))[0];return yield ji(d,s),d}catch(e){if(null!=i&&i.rethrow)throw e;return t&&console.error("Failed to gzip compress data",e),null}}),zi.apply(this,arguments)}var Ki=function(e,t){var i=(void 0===t?{}:t).debugEnabled,s={_log(t){for(var s=arguments.length,r=new Array(s>1?s-1:0),n=1;s>n;n++)r[n-1]=arguments[n];ze&&(o.DEBUG||ze.POSTHOG_DEBUG||i)&&!ft(ze.console)&&ze.console&&("__rrweb_original__"in ze.console[t]?ze.console[t].__rrweb_original__:ze.console[t])(e,...r)},debug(){for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];s._log("debug",...t)},info(){for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];s._log("log",...t)},warn(){for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];s._log("warn",...t)},error(){for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];s._log("error",...t)},critical(){for(var t=arguments.length,i=new Array(t),s=0;t>s;s++)i[s]=arguments[s];console.error(e,...i)},uninitializedWarning(e){s.error("You must initialize PostHog before calling "+e)},createLogger:(t,i)=>Ki(e+" "+t,i)};return s},Ji=Ki("[PostHog.js]"),Yi=Ji.createLogger;function Qi(e,t){ht(e)&&e.forEach(t)}function Xi(e,t){if(!wt(e))if(ht(e))e.forEach(t);else if((e=>e instanceof FormData)(e))e.forEach((e,i)=>t(e,i));else for(var i in e)_t.call(e,i)&&t(e[i],i)}var Zi=function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),s=1;t>s;s++)i[s-1]=arguments[s];for(var r of i)for(var n in r)void 0!==r[n]&&(e[n]=r[n]);return e},es=function(e){return function(){try{for(var t=arguments.length,i=new Array(t),s=0;t>s;s++)i[s]=arguments[s];return e.apply(this,i)}catch(e){Ji.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),Ji.critical(e)}}},ts=function(e){var t={};return Xi(e,function(e,i){(mt(e)&&e.length>0||St(e))&&(t[i]=e)}),t};function is(e){var t=i({},e);for(var s of["name","message","stack","cause","errors"])try{s in e&&(t[s]=e[s])}catch(e){}return t}var ss=["herokuapp.com","vercel.app","netlify.app"];function rs(e){var t=null==e?void 0:e.hostname;if(!mt(t))return!1;var i=t.split(".").slice(-2).join(".");for(var s of ss)if(i===s)return!1;return!0}function ns(e,t,i,s){var r=null!=s?s:{},n=r.capture,o=r.passive;null==e||e.addEventListener(t,i,{capture:void 0!==n&&n,passive:void 0===o||o})}var os=e=>{if(Ye){try{for(var t=e+"=",i=Ye.cookie.split(";").filter(e=>e.length),s=0;i.length>s;s++){for(var r=i[s];" "==r.charAt(0);)r=r.substring(1,r.length);if(0===r.indexOf(t))return decodeURIComponent(r.substring(t.length,r.length))}}catch(e){}return null}};Math.trunc||(Math.trunc=function(e){return 0>e?Math.ceil(e):Math.floor(e)}),Number.isInteger||(Number.isInteger=function(e){return St(e)&&isFinite(e)&&Math.floor(e)===e});var as=class e{constructor(e){if(this.bytes=e,16!==e.length)throw new TypeError("not 128-bit length")}static fromFieldsV7(t,i,s,r){if(!Number.isInteger(t)||!Number.isInteger(i)||!Number.isInteger(s)||!Number.isInteger(r)||0>t||0>i||0>s||0>r||t>0xffffffffffff||i>4095||s>1073741823||r>4294967295)throw new RangeError("invalid field value");var n=new Uint8Array(16);return n[0]=t/Math.pow(2,40),n[1]=t/Math.pow(2,32),n[2]=t/Math.pow(2,24),n[3]=t/Math.pow(2,16),n[4]=t/256,n[5]=t,n[6]=112|i>>>8,n[7]=i,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 e(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),3!==t&&5!==t&&7!==t&&9!==t||(e+="-");if(36!==e.length)throw new Error("Invalid UUIDv7 was generated");return e}clone(){return new e(this.bytes.slice(0))}equals(e){return 0===this.compareTo(e)}compareTo(e){for(var t=0;16>t;t++){var i=this.bytes[t]-e.bytes[t];if(0!==i)return Math.sign(i)}return 0}},ls=class{generate(){var e=this.generateOrAbort();if(!ft(e))return e;this._timestamp=0;var t=this.generateOrAbort();if(ft(t))throw new Error("Could not generate UUID after timestamp reset");return t}generateOrAbort(){var e,t=(e=Date.now(),St(e)&&isFinite(e)?Math.min(Math.max(Math.floor(e),0),0xffffffffffff):0);if(t>this._timestamp)this._timestamp=t,this._resetCounter();else{if(this._timestamp>=t+1e4)return;this._counter++,this._counter>4398046511103&&(this._timestamp++,this._resetCounter())}return as.fromFieldsV7(this._timestamp,Math.trunc(this._counter/Math.pow(2,30)),this._counter&Math.pow(2,30)-1,this._random.nextUint32())}_resetCounter(){this._counter=1024*this._random.nextUint32()+(1023&this._random.nextUint32())}constructor(){this._timestamp=0,this._counter=0,this._random=new _s}},ds=e=>{if("u">typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var t=0;e.length>t;t++)e[t]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return e};ze&&!ft(ze.crypto)&&crypto.getRandomValues&&(ds=e=>crypto.getRandomValues(e));var us,_s=class{nextUint32(){return this._buffer.length>this._cursor||(ds(this._buffer),this._cursor=0),this._buffer[this._cursor++]}constructor(){this._buffer=new Uint32Array(8),this._cursor=1/0}},cs=()=>hs().toString(),hs=()=>(us||(us=new ls)).generate(),ps="",gs=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;var vs=null,fs={_is_supported(){if(!bt(vs))return vs;if(vs=!1,Ye)try{var e="__ph_cookie_support_"+cs();fs._set(e,"xyz"),vs='"xyz"'===os(e),fs._remove(e)}catch(e){vs=!1}return vs},_error(e){Ji.error("cookieStore error: "+e)},_get:os,_parse(e){var t;try{t=JSON.parse(fs._get(e))||{}}catch(e){}return t},_set(e,t,i,s,r){if(!Ye)return!1;try{var n="",o="",a=function(e,t){if(t){var i=function(e,t){if(void 0===t&&(t=Ye),ps)return ps;if(!t)return"";if(["localhost","127.0.0.1"].includes(e))return"";for(var i=e.split("."),s=Math.min(i.length,8),r="dmn_chk_"+cs();!ps&&s--;){var n=i.slice(s).join("."),o=r+"=1;domain=."+n+";path=/";t.cookie=o+";max-age=3",t.cookie.includes(r)&&(t.cookie=o+";max-age=0",ps=n)}return ps}(e);if(!i){var s=(e=>{var t=e.match(gs);return t?t[0]:""})(e);s!==i&&Ji.info("Warning: cookie subdomain discovery mismatch",s,i),i=s}return i?"; domain=."+i:""}return""}(Ye.location.hostname,s);if(i){var l=new Date;l.setTime(l.getTime()+864e5*i),n="; expires="+l.toUTCString()}r&&(o="; secure");var d=e+"="+encodeURIComponent(JSON.stringify(t))+n+"; SameSite=Lax; path=/"+a+o;return d.length>3686.4&&Ji.warn("cookieStore warning: large cookie, len="+d.length),Ye.cookie=d,!0}catch(e){return!1}},_remove(e,t){if(null!=Ye&&Ye.cookie)try{fs._set(e,"",-1,t)}catch(e){return}}},ms=null,ys={_is_supported(){if(!bt(ms))return ms;var e=!0;if(ft(ze))e=!1;else try{var t="__mplssupport__";ys._set(t,"xyz"),'"xyz"'!==ys._get(t)&&(e=!1),ys._remove(t)}catch(t){e=!1}return e||Ji.error("localStorage unsupported; falling back to cookie store"),ms=e,e},_error(e){Ji.error("localStorage error: "+e)},_get(e){try{return null==ze?void 0:ze.localStorage.getItem(e)}catch(e){ys._error(e)}return null},_parse(e){try{return JSON.parse(ys._get(e))||{}}catch(e){}return null},_set(e,t){try{return null==ze||ze.localStorage.setItem(e,JSON.stringify(t)),!0}catch(e){ys._error(e)}return!1},_remove(e){try{null==ze||ze.localStorage.removeItem(e)}catch(e){ys._error(e)}}},bs=[Z,V,W,z,K,J,fe,ve,pe],ws=[u,d,L,N,xe,Pe,g,me],Ss=e=>e+"_cpm",Ps=["__proto__","constructor","prototype"],xs=e=>{if(!gt(e))return{};var t={};return Object.keys(e).forEach(i=>{-1===Ps.indexOf(i)&&(t[i]=e[i])}),t},Es=function(e,t){void 0===t&&(t=[]);var i={};return[...ws,...t].forEach(t=>{var s=e[t];ft(s)||bt(s)||""===s||(i[t]=s)}),i},Cs=e=>{for(var t=5381,i=2166136261,s=0;e.length>s;s++){var r=e.charCodeAt(s);t=33*t^r,i=Math.imul(i^r,16777619)}return e.length.toString(36)+"."+(t>>>0).toString(36)+"."+(i>>>0).toString(36)},ks=(e,t)=>({p:t,f:Cs(JSON.stringify(e))}),Is=(e,t)=>{if(!t)return{properties:[],isValid:!1};try{var i=fs._parse(Ss(e)),s=(null==i?void 0:i.f)===Cs(t)&&ht(i.p);return{properties:s?i.p:[],isValid:s}}catch(e){return{properties:[],isValid:!1}}},Ts=(e,t)=>t+"|"+(fs._get(Ss(e))||""),$s={},Fs={_is_supported:()=>!0,_error(e){Ji.error("memoryStorage error: "+e)},_get:e=>e in $s?$s[e]:null,_parse:e=>e in $s?$s[e]:null,_set:(e,t)=>($s[e]=t,!0),_remove(e){delete $s[e]}},Rs=null,Os={_is_supported(){if(!bt(Rs))return Rs;if(Rs=!0,ft(ze))Rs=!1;else try{var e="__support__";Os._set(e,"xyz"),'"xyz"'!==Os._get(e)&&(Rs=!1),Os._remove(e)}catch(e){Rs=!1}return Rs},_error(e){Ji.error("sessionStorage error: ",e)},_get(e){try{return null==ze?void 0:ze.sessionStorage.getItem(e)}catch(e){Os._error(e)}return null},_parse(e){try{return JSON.parse(Os._get(e))||null}catch(e){}return null},_set(e,t){try{return null==ze||ze.sessionStorage.setItem(e,JSON.stringify(t)),!0}catch(e){Os._error(e)}return!1},_remove(e){try{null==ze||ze.sessionStorage.removeItem(e)}catch(e){Os._error(e)}}},As=class{constructor(e){this._instance=e}get _config(){return this._instance.config}get consent(){return this._getDnt()?0:this._storedConsent}isOptedOut(){return"always"===this._config.cookieless_mode||this.isRejected()||-1===this.consent&&"on_reject"===this._config.cookieless_mode}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return 0===this.consent}isRejected(){return 0===this.consent||-1===this.consent&&this._config.opt_out_capturing_by_default}optInOut(e){this._storage._set(this._storageKey,e?1:0,this._config.cookie_expiration,this._config.cross_subdomain_cookie,this._config.secure_cookie)}reset(){this._storage._remove(this._storageKey,this._config.cross_subdomain_cookie)}get _storageKey(){var e=this._instance.config,t=e.token,i=e.opt_out_capturing_cookie_prefix;return e.consent_persistence_name||(i?i+t:"__ph_opt_in_out_"+t)}get _storedConsent(){var e=this._storage._get(this._storageKey);return Tt(e)?1:lt($t,e)?0:-1}get _storage(){var e=this._config.opt_out_capturing_persistence_type,t="localStorage"===e?ys:fs,i=t._is_supported()?t:Fs;if(!this._persistentStore||this._persistentStore!==i){this._persistentStore=i;var s="localStorage"===e?fs:ys;s._get(this._storageKey)&&(this._persistentStore._get(this._storageKey)||this.optInOut(Tt(s._get(this._storageKey))),s._remove(this._storageKey,this._config.cross_subdomain_cookie))}return this._persistentStore}_getDnt(){return!!this._config.respect_dnt&&[null==Je?void 0:Je.doNotTrack,null==Je?void 0:Je.msDoNotTrack,rt.doNotTrack,null==Je?void 0:Je.globalPrivacyControl].some(e=>Tt(e))}},Ms=["next","previous","prev",">","<","+","-","−","–"];Yi("[Dead Clicks]");var Ds=e=>{var t,i=!(null==(t=e.instance.persistence)||!t.get_property(E)),s=e.instance.config.capture_dead_clicks;return xt(s)?s:!!gt(s)||i},Ls=Yi("[SegmentIntegration]");function Ns(e,t,s){void 0===s&&(s=!0);var r=e.config.segment;if(!r)return t();var n,o=(e=>pt(e.register))(n=r)?{analytics:n}:n,a=o.analytics,l=o.filterProperties;!function(e,t,i,s){var r=t=>{var r=()=>t.anonymousId()||cs();e.config.get_device_id=r,s&&t.id()&&(e.register({distinct_id:t.id(),$device_id:r()}),e.persistence.set_property(me,Be)),i(s?void 0:t.anonymousId()||void 0)},n=t.user();"then"in n&&pt(n.then)?n.then(r):r(n)}(e,a,s=>{a.register(function(e,t,s){var r=(void 0===s?{}:s).filterProperties;"undefined"!=typeof Promise&&Promise.resolve||Ls.warn("This browser does not have Promise support, and can not use the segment integration");var n=(s,n)=>{if(!n)return s;var o=!!t&&s.event.anonymousId===t&&!s.event.userId;o||s.event.userId||s.event.anonymousId===e.get_distinct_id()||(Ls.info("No userId set, resetting PostHog"),e.reset()),o||(t=void 0),s.event.userId&&s.event.userId!==e.get_distinct_id()&&(Ls.info("UserId set, identifying with PostHog"),e.identify(s.event.userId));var a=e.calculateEventProperties(n,s.event.properties);if(!wt(r)){var l=s.event.properties||{},d={};for(var u of Object.keys(a))_t.call(l,u)||(d[u]=a[u]);var _=((e,t)=>{var s=ht(e)?e:[e],r=i({},t);for(var n of s)try{if(r=n(r),wt(r))return null}catch(e){return Ls.error("Error in Segment filterProperties:",e),null}return r})(r,d);if(wt(_))return s;a=_}return s.event.properties=Object.assign({},a,s.event.properties),s};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded(){return!0},load(){return Promise.resolve()},track(e){return n(e,e.event.event)},page(e){return n(e,Ge)},identify(e){return n(e,Ve)},screen(e){return n(e,"$screen")}}}(e,s,{filterProperties:l})).then(()=>{t()},e=>{Ls.error("Failed to register the Segment integration",e),t()})},s)}var Bs="posthog-js";function Us(e,t){var s=void 0===t?{}:t,r=s.organization,n=s.projectId,o=s.prefix,a=s.severityAllowList,l=void 0===a?["error"]:a,d=s.sendExceptionsToPostHog,u=void 0===d||d;return t=>{var s,a,d,_,c,h;if("*"!==l&&!l.includes(t.level)||!e.__loaded)return t;t.tags||(t.tags={});var p=e.requestRouter.endpointFor("ui","/project/"+e.config.token+"/person/"+e.get_distinct_id());t.tags["PostHog Person URL"]=p,e.sessionRecordingStarted()&&(t.tags["PostHog Recording URL"]=e.get_session_replay_url({withTimestamp:!0}));var g=(null==(s=t.exception)?void 0:s.values)||[],v=g.map(e=>i({},e,{stacktrace:e.stacktrace?i({},e.stacktrace,{type:"raw",frames:(e.stacktrace.frames||[]).map(e=>i({},e,{platform:"web:javascript"}))}):void 0})),f={$exception_message:(null==(a=g[0])?void 0:a.value)||t.message,$exception_type:null==(d=g[0])?void 0:d.type,$exception_level:t.level,$exception_list:v,$sentry_event_id:t.event_id,$sentry_exception:t.exception,$sentry_exception_message:(null==(_=g[0])?void 0:_.value)||t.message,$sentry_exception_type:null==(c=g[0])?void 0:c.type,$sentry_tags:t.tags};return r&&n&&(f.$sentry_url=(o||"https://sentry.io/organizations/")+r+"/issues/?project="+n+"&query="+t.event_id),u&&(null==(h=e.exceptions)||h.sendExceptionEvent(f)),t}}var qs=class{constructor(e,t,i,s,r,n){this.name=Bs,this.setupOnce=function(o){o(Us(e,{organization:t,projectId:i,prefix:s,severityAllowList:r,sendExceptionsToPostHog:null==n||n}))}}},Hs=class{constructor(e){this._onSessionIdChange=(e,t,i)=>{i&&(i.noSessionId||i.activityTimeout||i.sessionPastMaximumLength||i.crossTabAdoption)&&(Ji.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:e,changeReason:i}),this._currentPageview=void 0,this._instance.scrollManager.resetContext())},this._instance=e,this._setupSessionRotationHandler()}_setupSessionRotationHandler(){var e;this._unsubscribeSessionId=null==(e=this._instance.sessionManager)?void 0:e.onSessionId(this._onSessionIdChange)}destroy(){var e;null==(e=this._unsubscribeSessionId)||e.call(this),this._unsubscribeSessionId=void 0}doPageView(e,t){var i,s=this._previousPageViewProperties(e,t);return this._currentPageview={pathname:null!==(i=null==ze?void 0:ze.location.pathname)&&void 0!==i?i:"",pageViewId:t,timestamp:e},this._instance.scrollManager.resetContext(),s}doPageLeave(e){var t;return this._previousPageViewProperties(e,null==(t=this._currentPageview)?void 0:t.pageViewId)}doEvent(){var e;return{$pageview_id:null==(e=this._currentPageview)?void 0:e.pageViewId}}_previousPageViewProperties(e,t){var i=this._currentPageview;if(!i)return{$pageview_id:t};var s={$pageview_id:t,$prev_pageview_id:i.pageViewId},r=this._instance.scrollManager.getContext();if(r&&!this._instance.config.disable_scroll_properties){var n=r.maxScrollHeight,o=r.lastScrollY,a=r.maxScrollY,l=r.maxContentHeight,d=r.lastContentY,u=r.maxContentY;if(!(ft(n)||ft(o)||ft(a)||ft(l)||ft(d)||ft(u))){n=Math.ceil(n),o=Math.ceil(o),a=Math.ceil(a),l=Math.ceil(l),d=Math.ceil(d),u=Math.ceil(u);var _=n>1?Ot(o/n,0,1,Ji):1,c=n>1?Ot(a/n,0,1,Ji):1,h=l>1?Ot(d/l,0,1,Ji):1,p=l>1?Ot(u/l,0,1,Ji):1;s=Zi(s,{$prev_pageview_last_scroll:o,$prev_pageview_last_scroll_percentage:_,$prev_pageview_max_scroll:a,$prev_pageview_max_scroll_percentage:c,$prev_pageview_last_content:d,$prev_pageview_last_content_percentage:h,$prev_pageview_max_content:u,$prev_pageview_max_content_percentage:p})}}return i.pathname&&(s.$prev_pageview_pathname=i.pathname),i.timestamp&&(s.$prev_pageview_duration=(e.getTime()-i.timestamp.getTime())/1e3),s}},Gs=["flags","surveys"],Ws={[l]:{exposure:"hidden"},[c]:{exposure:"hidden"},[h]:{exposure:"hidden"},[m]:{exposure:"hidden"},[g]:{exposure:"hidden"},[f]:{exposure:"hidden"},[y]:{exposure:"event"},[b]:{exposure:"hidden"},[k]:{exposure:"hidden"},[w]:{exposure:"event"},[S]:{exposure:"hidden"},[P]:{exposure:"event"},[x]:{exposure:"event"},[E]:{exposure:"event"},[C]:{exposure:"hidden"},[I]:{exposure:"event"},[T]:{exposure:"hidden"},[F]:{exposure:"hidden"},[L]:{exposure:"hidden"},[N]:{exposure:"event"},[R]:{exposure:"event",shouldSkipFromEventProperties:e=>bt(e)},[B]:{exposure:"event"},[U]:{exposure:"event"},[q]:{exposure:"event"},[H]:{exposure:"event"},[G]:{exposure:"hidden"},[W]:{exposure:"hidden",storageGroup:"flags"},[V]:{exposure:"hidden",storageGroup:"flags"},[j]:{exposure:"hidden"},[z]:{exposure:"hidden",storageGroup:"flags"},[K]:{exposure:"hidden",storageGroup:"flags"},[J]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[Y]:{exposure:"hidden",storageGroup:"flags"},[Q]:{exposure:"hidden"},[X]:{exposure:"hidden"},[Z]:{exposure:"hidden"},[ee]:{exposure:"hidden"},[ie]:{exposure:"hidden",storageGroup:"surveys"},[se]:{exposure:"hidden",storageGroup:"surveys",volatile:!0},[re]:{exposure:"event"},[ne]:{exposure:"hidden"},[oe]:{exposure:"hidden"},[ae]:{exposure:"hidden"},[le]:{exposure:"hidden"},[de]:{exposure:"hidden"},[ue]:{exposure:"event"},[_e]:{exposure:"event"},[ce]:{exposure:"event"},[he]:{exposure:"event"},[pe]:{exposure:"hidden"},[ge]:{exposure:"hidden"},[te]:{exposure:"event"},[ve]:{exposure:"hidden"},[fe]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[me]:{exposure:"hidden"},[ye]:{exposure:"hidden"},[be]:{exposure:"hidden"},[we]:{exposure:"hidden"},[Se]:{exposure:"hidden"},[Pe]:{exposure:"hidden"},[xe]:{exposure:"hidden"},[O]:{exposure:"event"},[A]:{exposure:"event"},[M]:{exposure:"event"},[D]:{exposure:"event"},[ke]:{exposure:"event"},[Ie]:{exposure:"event"},[Te]:{exposure:"event"},[$e]:{exposure:"event"},[Fe]:{exposure:"event"},[Re]:{exposure:"event"},[Oe]:{exposure:"event"},[Ae]:{exposure:"event"},[Me]:{exposure:"event"},[De]:{exposure:"event"},[Le]:{exposure:"event"}},Vs=[["$posthog_sr_group_event_trigger_",{exposure:"hidden"}],["$posthog_sr_group_url_trigger_",{exposure:"hidden"}],["$posthog_sr_group_sampling_",{exposure:"hidden"}]],js=e=>{var t=Ws[e];if(t)return t;for(var i of Vs){var s=i[1];if(0===e.indexOf(i[0]))return s}},zs=(e,t)=>{try{var i;return JSON.stringify(e,(e,t)=>kt(t)?(null!=i||(i=new WeakMap),i.has(t)||i.set(t,is(t)),i.get(t)):"bigint"==typeof t?t.toString():t,t)}catch(t){return r=[],null!==(s=JSON.stringify(e,function(e,t){if("bigint"==typeof t)return t.toString();if("function"!=typeof t&&"symbol"!=typeof t){if(t instanceof Error)return{name:t.name,message:t.message,stack:t.stack};if(t&&"object"==typeof t){for(;r.length>0&&r[r.length-1]!==this;)r.pop();if(r.includes(t))return"[Circular]";r.push(t)}return t}}))&&void 0!==s?s:"null"}var s,r},Ks=e=>{var t=null==Ye?void 0:Ye.createElement("a");return ft(t)?null:(t.href=e,t)},Js=function(e,t){for(var i,s=((e.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),r=0;s.length>r;r++){var n=s[r].split("=");if(n[0]===t){i=n;break}}if(!ht(i)||2>i.length)return"";var o=i[1];try{o=decodeURIComponent(o)}catch(e){Ji.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},Ys=function(e,t,i){if(!e||!t||!t.length)return e;for(var s=e.split("#"),r=s[1],n=(s[0]||"").split("?"),o=n[1],a=n[0],l=(o||"").split("&"),d=[],u=0;l.length>u;u++){var _=l[u].split("=");ht(_)&&(t.includes(_[0])?d.push(_[0]+"="+i):d.push(l[u]))}var c=a;return null!=o&&(c+="?"+d.join("&")),null!=r&&(c+="#"+r),c},Qs=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],Xs=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...Qs],Zs="<masked>",er=["li_fat_id"];function tr(e,t){var i=Xs.concat(t||[]),s={};return Xi(i,function(t){var i=Js(e,t);s[t]=i||null}),s}function ir(e){var t=function(e){return e?0===e.search("https?://(.*)google.([^/?]*)")?"google":0===e.search("https?://(.*)bing.com")?"bing":0===e.search("https?://(.*)yahoo.com")?"yahoo":0===e.search("https?://(.*)duckduckgo.com")?"duckduckgo":null:null}(e),i="yahoo"!=t?"q":"p",s={};if(!bt(t)){s.$search_engine=t;var r=Ye?Js(Ye.referrer,i):"";r.length&&(s.ph_keyword=r)}return s}function sr(){return navigator.language||navigator.userLanguage}var rr="$direct";function nr(){return(null==Ye?void 0:Ye.referrer)||rr}function or(e,t,i){var s;void 0===i&&(i=!1);var r=e?[...Qs,...t||[]]:[],n=null==(s=i?Ni(null==Qe?void 0:Qe.href):null==Qe?void 0:Qe.href)?void 0:s.substring(0,1e3);return{r:nr().substring(0,1e3),u:n?Ys(n,r,Zs):void 0}}function ar(e,t){var i;void 0===t&&(t=!1);var s=e.r,r=e.u,n=t?Ni(r):r,o={$referrer:s,$referring_domain:null==s?void 0:s==rr?rr:null==(i=Ks(s))?void 0:i.host};if(n){o.$current_url=n;var a=Ks(n);o.$host=null==a?void 0:a.host,o.$pathname=null==a?void 0:a.pathname,Zi(o,tr(n))}return s&&Zi(o,ir(s)),o}function lr(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(e){return}}function dr(){try{return(new Date).getTimezoneOffset()}catch(e){return}}var ur={flags:fe,surveys:se},_r=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],cr=e=>e+"_cookie_identity_change_pending",hr=e=>{var t="",i=0;for(var s of e){var r=encodeURIComponent(JSON.stringify(s).slice(1,-1)).length;if(i+r>1e3)break;t+=s,i+=r}return t},pr="main",gr=[W,V,z,K,J,fe,Y,Z],vr=e=>-1!==gr.indexOf(e),fr=[g,f],mr=e=>-1!==fr.indexOf(e),yr=(e,t)=>{try{return JSON.stringify(e)===JSON.stringify(t)}catch(i){return e===t}},br=e=>{if(!e)return{};var t=JSON.parse(e);return gt(t)?t:{}},wr=(e,t)=>{Xi(e,(i,s)=>{var r=js(s);r&&"event"!==r.exposure||{}.hasOwnProperty.call(t,s)||delete e[s]})},Sr=class{constructor(e,t,s){if(void 0===s&&(s=!0),this._slotState={},this._splitStorageEligible=!1,this._storesIdentityInCookie=!1,this._splitStorage=!1,this._cookieIdentityChangePending=!1,this._cookieSyncSuppressed=!1,this._pendingCrossTabFeatureFlagChanges=new Map,this._storageMigrationInProgress=!1,this._localIdentityChangePending=!1,this._crossTabFeatureFlagIdentityMismatch=!1,this._metaIdentifierChangePending=new Set,this._crossTabFeatureFlagHandlers=new Set,this._config=e,this._ownsSplitStorage=s,this.props={},this._campaign_params_url=void 0,this._name=(e=>{var t="";return e.token&&(t=e.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),e.persistence_name?"ph_"+e.persistence_name:"ph_"+t+"_posthog"})(e),this._storage=this._buildStorage(e),this._splitStorage=this._resolveSplitStorage(e),this.load(),this._markLoadedCrossTabFeatureFlagChangesPending(),e.debug&&Ji.info("Persistence loaded",e.persistence,i({},this.props)),this.update_config(e,e,t),this.save(),ze){var r=()=>this.flush();ns(ze,"beforeunload",r,{capture:!1}),ns(ze,"pagehide",r,{capture:!1}),this._onStorage=e=>{if(this._splitStorageEligible&&(!e.storageArea||e.storageArea===(null==ze?void 0:ze.localStorage))&&e.key)if(e.key!==this._name){if(this._splitStorage){var t=Gs.find(t=>e.key===this._groupEntryName(t));t&&this._syncCrossTabFeatureFlagProperties(e.key,t)}}else this._syncCrossTabFeatureFlagProperties(e.key,pr)},ns(ze,"storage",this._onStorage)}}markCrossTabFeatureFlagChanges(e){Object.entries(e).forEach(e=>{var t=e[0],i=e[1],s=this._pendingCrossTabFeatureFlagChanges.get(t);if(vr(t)&&!0!==s)if(!0!==i){var r=new Set(s||[]);i.forEach(e=>r.add(e)),r.size&&this._setCrossTabFeatureFlagChangesPending(t,r)}else this._setCrossTabFeatureFlagChangesPending(t,!0)})}onCrossTabFeatureFlagChange(e){return this._crossTabFeatureFlagHandlers.add(e),()=>this._crossTabFeatureFlagHandlers.delete(e)}destroy(){this._onStorage&&ze&&(ze.removeEventListener("storage",this._onStorage),this._onStorage=void 0),this._crossTabFeatureFlagHandlers.clear()}_syncCrossTabFeatureFlagProperties(e,t,i){if(void 0===i&&(i=!0),this._disabled)return!1;var s,r;try{if(r=ys._get(e),bt(r)){var n=this._slotWriteState(t);return n.storageValue=null,t!==pr&&(n.persisted=!1),!1}s=br(r)}catch(e){return!1}var o=t===pr?s:ys._parse(this._name);if(o&&this._hasCrossTabFeatureFlagIdentityMismatch(o))return!1;var a=this._mergeCrossTabFeatureFlagProperties(s,t,i);return t===pr&&this._splitStorage&&!yr(this._partitionProps().main,s)||this._rememberCrossTabStorageFingerprint(s,t,!0,r),a}_hasCrossTabFeatureFlagIdentityMismatch(e){var t=this.props[d],i=e[d];return!ft(t)&&!ft(i)&&t!==i}_rememberCrossTabStorageFingerprint(e,t,i,s){var r=this._slotWriteState(t);r.storageValue=s,t!==pr&&(r.persisted=i);try{r.fingerprint=this._entryFingerprint(e,t)}catch(e){r.fingerprint=void 0}}_mergeCrossTabFeatureFlagProperties(e,t,i){var s=!1;return gr.forEach(i=>{var r,n=null==(r=js(i))?void 0:r.storageGroup;if(!(t===pr&&this._splitStorage&&n||t!==pr&&n!==t)){var o=i in e,a=this._mergePendingCrossTabFeatureFlagChanges(i,o?e[i]:void 0),l=this._pendingCrossTabFeatureFlagChanges.has(i)?i in this.props:o;l===i in this.props&&yr(a,this.props[i])||(l?this._setProp(i,a,!1):this._deleteProp(i,!1),s=!0)}}),s&&i&&this._crossTabFeatureFlagHandlers.forEach(e=>e()),s}_reconcileCrossTabFeatureFlagPropertiesBeforeWrite(){if(!this._splitStorageEligible)return!1;try{this._crossTabFeatureFlagIdentityMismatch=!1;var e,t=ys._get(this._name),i=this._slotWriteState(pr),s=!1,r=!1;if(t!==i.storageValue)if(bt(t))i.storageValue=null;else{if(e=br(t),this._crossTabFeatureFlagIdentityMismatch=!this._localIdentityChangePending&&this._hasCrossTabFeatureFlagIdentityMismatch(e),this._crossTabFeatureFlagIdentityMismatch)return!1;r=this._mergeCrossTabFeatureFlagProperties(e,pr,!1),!this._splitStorage||yr(this._partitionProps().main,e)?this._rememberCrossTabStorageFingerprint(e,pr,!0,t):i.storageValue=t,s=!0}return this._splitStorage&&Gs.forEach(t=>{var i=ys._get(this._groupEntryName(t)),n=this._slotWriteState(t),o=e||{},a=s&&gr.some(e=>{var i;return(null==(i=js(e))?void 0:i.storageGroup)===t&&e in o});if(i!==n.storageValue||a){if(bt(i))return n.storageValue=null,n.persisted=!1,void(a&&(r=this._mergeCrossTabFeatureFlagProperties(o,t,!1)||r));var l=br(i);r=this._mergeCrossTabFeatureFlagProperties(l,t,!1)||r,this._rememberCrossTabStorageFingerprint(l,t,!0,i)}}),r}catch(e){return!1}}_setCrossTabFeatureFlagChangesPending(e,t){this._pendingCrossTabFeatureFlagChanges.set(e,t);var i=js(e);null!=i&&i.volatile||(this._slotWriteState((this._splitStorage?null==i?void 0:i.storageGroup:void 0)||pr).fingerprint=void 0,this._markGroupDirty(e))}_markAllCrossTabFeatureFlagChangesPending(){gr.forEach(e=>this._pendingCrossTabFeatureFlagChanges.set(e,!0))}_markLoadedCrossTabFeatureFlagChangesPending(){if(this._splitStorageEligible)try{var e=ys._get(this._name),t=br(e);this._slotWriteState(pr).storageValue=e,gr.forEach(e=>{var i,s=this._splitStorage?null==(i=js(e))?void 0:i.storageGroup:void 0,r=s?ys._get(this._groupEntryName(s)):null;if(s){var n=this._slotWriteState(s);n.storageValue=r,n.persisted=!bt(r)}var o=s&&!bt(r)?br(r):t;e in this.props?this._markPendingCrossTabFeatureFlagChanges(e,o[e],this.props[e]):e in o&&this._setCrossTabFeatureFlagChangesPending(e,!0)})}catch(e){}}_mergePendingCrossTabFeatureFlagChanges(e,t){var s=this._pendingCrossTabFeatureFlagChanges.get(e);if(!s)return t;if(!0===s)return this.props[e];if("$active_feature_flags"===e){var r=new Set(ht(t)?t:[]),n=new Set(ht(this.props[e])?this.props[e]:[]);return s.forEach(e=>n.has(e)?r.add(e):r.delete(e)),Array.from(r)}var o=gt(t)?i({},t):{},a=gt(this.props[e])?this.props[e]:{};return s.forEach(e=>{e in a?o[e]=a[e]:delete o[e]}),o}_markPendingCrossTabFeatureFlagChanges(e,t,i){if(vr(e)){var s=this._pendingCrossTabFeatureFlagChanges.get(e);if(!0!==s){var r=t;if(this._splitStorageEligible)try{var n,o=this._splitStorage?null==(n=js(e))?void 0:n.storageGroup:void 0,a=o?this._groupEntryName(o):this._name;r=br(ys._get(a))[e]}catch(e){}var l=new Set(s||[]);if("$active_feature_flags"===e){if(!ft(t)&&!ht(t)||!ft(r)&&!ht(r)||!ht(i))return void this._setCrossTabFeatureFlagChangesPending(e,!0);var d=new Set(t||[]),u=new Set(r||[]),_=new Set(i);new Set([...d,..._]).forEach(e=>{d.has(e)!==_.has(e)&&l.add(e)}),l.forEach(e=>{u.has(e)===_.has(e)&&l.delete(e)})}else{if(!gt(i))return void(yr(r,i)?this._pendingCrossTabFeatureFlagChanges.delete(e):this._setCrossTabFeatureFlagChangesPending(e,!0));if(!ft(t)&&!gt(t)||ft(t)&&vt(i)&&ft(r))return void this._setCrossTabFeatureFlagChangesPending(e,!0);var c=gt(t)?t:{},h=gt(r)?r:{};new Set([...Object.keys(c),...Object.keys(i)]).forEach(e=>{e in c==e in i&&yr(c[e],i[e])||l.add(e)}),l.forEach(e=>{e in h==e in i&&yr(h[e],i[e])&&l.delete(e)})}l.size?this._setCrossTabFeatureFlagChangesPending(e,l):this._pendingCrossTabFeatureFlagChanges.delete(e)}}}_saveDebounceMs(){var e,t=null==(e=this._config)?void 0:e.persistence_save_debounce_ms;return St(t)&&t>0?t:0}_rememberCurrentCookieProperties(e){if(this._config.cookieWinsOnConflict&&"localstorage+cookie"===this._config.persistence.toLowerCase())if(e)try{var t=Es(e,this._config.cookie_persisted_properties||[]),i=ks(t,this._config.cookie_persisted_properties||[]),s=JSON.stringify(t)+"|"+JSON.stringify(i),r=fs._get(this._name)||void 0;r&&Ts(this._name,r)===s&&(this._lastSeenCookiePropertiesFingerprint=s,this._lastSeenMainCookieValue=r)}catch(e){}else try{var n=fs._get(this._name)||void 0;this._lastSeenCookiePropertiesFingerprint=n?Ts(this._name,n):void 0,this._lastSeenMainCookieValue=n}catch(e){}}syncCookieProperties(){return this._syncCookieProperties(this._config)}_syncCookieProperties(e,t){if(void 0===t&&(t=!1),this._disabled&&!t||this._cookieSyncSuppressed||!e.cookieWinsOnConflict||"localstorage+cookie"!==e.persistence.toLowerCase())return!1;var i;try{i=fs._get(this._name)||void 0}catch(e){}if(!i||i===this._lastSeenMainCookieValue)return!1;var s,r=Ts(this._name,i);try{s=xs(JSON.parse(i))}catch(e){return!1}if((fs._get(this._name)||void 0)!==i)return!1;this._lastSeenCookiePropertiesFingerprint=r,this._lastSeenMainCookieValue=i;var n=Is(this._name,i),o=[...ws,...n.properties],a={};if(Object.keys(s).forEach(e=>{var t=s[e];(ft(t)||bt(t)||""===t||"$user_state"===e&&"anonymous"!==t&&"identified"!==t)&&(a[e]=!0,delete s[e])}),vt(s))return!1;var l="distinct_id"in s||"anonymous"===s.$user_state||"identified"===s.$user_state,u=this.props,_=u[d],h=u[me],p=Zi({},u);[...ws,...e.cookie_persisted_properties||[]].forEach(e=>{if(-1!==o.indexOf(e)&&!(e in s)&&!a[e]&&(l||"distinct_id"!==e&&"$user_state"!==e)){var t=p[e];(n.isValid||-1===ws.indexOf(e)||!1!==t&&0!==t)&&delete p[e]}}),this.props=Zi(p,s),gr.forEach(e=>{var t=e in this.props;e in u===t&&yr(u[e],this.props[e])||(t?this._markPendingCrossTabFeatureFlagChanges(e,u[e],this.props[e]):this._setCrossTabFeatureFlagChangesPending(e,!0))}),!l||"$user_state"in s||"$user_state"in this.props||this._setProp(me,Ne);var g=this.props[d],v=this.props[me];return!l||g===_&&v===h||(this._localIdentityChangePending=!0,this._cookieIdentityChangePending=!0,Os._set(cr(this._name),!0),this._deleteProp(Z),this._deleteProp(V),this._deleteProp(W),this._deleteProp(z),this._deleteProp(K),this._deleteProp(J),this._deleteProp(fe),this._deleteProp(ve),this._deleteProp(pe),"anonymous"!==v||"identified"!==h&&"anonymous"!==s.$user_state&&(ft(_)||g===_)||(wr(this.props,s),this._deleteProp(ee)),"identified"===v?this.props.$user_id=g:delete this.props.$user_id,this._deleteProp(c)),!0}consumeCookieIdentityChange(){var e=cr(this._name),t=this._cookieIdentityChangePending||!!Os._get(e);return this._cookieIdentityChangePending=!1,t&&Os._remove(e),t}_beginCookieSyncSuppression(e){return void 0===e&&(e=!1),!(this._cookieSyncSuppressed||this._disabled&&!e||!this._config.cookieWinsOnConflict||"localstorage+cookie"!==this._config.persistence.toLowerCase()||(this._cookieSyncSuppressed=!0,0))}_publishSuppressedCookieSnapshot(){this._cookieSyncSuppressed&&(ft(this._pendingSaveTimer)||(clearTimeout(this._pendingSaveTimer),this._pendingSaveTimer=void 0),delete this._slotState[pr],this._writeNow(!0))}_endCookieSyncSuppression(e){if(void 0===e&&(e=!0),this._cookieSyncSuppressed)try{e?this._publishSuppressedCookieSnapshot():ft(this._pendingSaveTimer)||(clearTimeout(this._pendingSaveTimer),this._pendingSaveTimer=void 0)}finally{this._cookieSyncSuppressed=!1}}isDisabled(){return!!this._disabled}_buildStorage(e){-1===_r.indexOf(e.persistence.toLowerCase())&&(Ji.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var t,s=function(e,t){void 0===e&&(e=[]),void 0===t&&(t=!1);var s=[...ws,...e];return i({},ys,{_parse(e){try{var i,r={};try{i=fs._get(e)||void 0,r=i?xs(JSON.parse(i)):{}}catch(e){}var n,o=JSON.parse(ys._get(e)||"{}");if(t){var a=Is(e,i),l=[...ws,...a.properties],u={};Object.keys(r).forEach(e=>{var t=r[e];bt(t)||""===t||"$user_state"===e&&"anonymous"!==t&&"identified"!==t||(u[e]=t)});var _="distinct_id"in u||"anonymous"===u.$user_state||"identified"===u.$user_state;if(Object.keys(u).length>0){var c,h=o[d],p=null!==(c=o.$user_state)&&void 0!==c?c:"anonymous";s.forEach(e=>{if(-1!==l.indexOf(e)&&!(e in r)&&(_||"distinct_id"!==e&&"$user_state"!==e)){var t=o[e];(a.isValid||-1===ws.indexOf(e)||!1!==t&&0!==t)&&delete o[e]}}),!_||"$user_state"in r||"$user_state"in o||(o[me]=Ne),!_||("distinct_id"in u?u[d]:o[d])===h&&("$user_state"in u?u[me]:o[me])===p||(bs.forEach(e=>delete o[e]),"identified"===u.$user_state&&"distinct_id"in u?o.$user_id=u[d]:delete o.$user_id,"identified"!==u.$user_state&&(delete o[te],delete o[ee]),delete o.__alias)}n=Zi(o,u)}else n=Zi(r,o);return ys._set(e,n),n}catch(e){}return null},_set(i,s,r,n,o,a){var l=ys._set(i,s,void 0,void 0,a);try{var d=Es(s,e);if(Object.keys(d).length){if(t){var u=Ss(i),_=ks(d,e);if(fs._set(u,_,r,n,o,a),fs._get(u)!==JSON.stringify(_)){fs._remove(u,n);var c=Es(s);return fs._set(i,c,r,n,o,a),l}}fs._set(i,d,r,n,o,a)}}catch(e){ys._error(e)}return l},_remove(e,t){try{null==ze||ze.localStorage.removeItem(e),fs._remove(e,t),fs._remove(Ss(e),t)}catch(e){ys._error(e)}}})}(e.cookie_persisted_properties||[],e.cookieWinsOnConflict),r=!1,n=!1,o=e.persistence.toLowerCase();return"localstorage"===o&&ys._is_supported()?(t=ys,n=!0):"localstorage+cookie"===o&&s._is_supported()?(t=s,n=!0,r=!0):"sessionstorage"===o&&Os._is_supported()?t=Os:"memory"===o?t=Fs:"cookie"===o&&fs._is_supported()?(t=fs,r=!0):s._is_supported()?(t=s,n=!0,r=!0):fs._is_supported()?(t=fs,r=!0):t=Fs,this._splitStorageEligible=n,this._storesIdentityInCookie=r,t}_groupEntryName(e){return this._name+"__"+e}_resolveSplitStorage(e){return this._splitStorageEligible&&!!e.split_storage}properties(){var e={};return Xi(this.props,(t,i)=>{var s=js(i);if(!s||"event"===s.exposure){if(null!=s&&null!=s.shouldSkipFromEventProperties&&s.shouldSkipFromEventProperties(t))return;e[i]=t}}),e}load(e){if(void 0===e&&(e=!1),!this._disabled||e){var t=this._config.cookieWinsOnConflict&&"localstorage+cookie"===this._config.persistence.toLowerCase(),i=t?ys._parse(this._name):null,s={};if(t)try{Xi(s=xs(fs._parse(this._name)),(e,t)=>{(ft(e)||bt(e)||""===e)&&delete s[t]})}catch(e){}var r=this._storage._parse(this._name);if(r&&(this.props=Zi({},r)),this._splitStorage&&this._loadGroupEntries(),t&&r){var n,o,a=null==i?void 0:i[d],l=null!==(n=null==i?void 0:i.$user_state)&&void 0!==n?n:"anonymous",u=r[d],_=null!==(o=r.$user_state)&&void 0!==o?o:"anonymous";if(u!==a||_!==l){this._cookieIdentityChangePending=!0,Os._set(cr(this._name),!0);var c=Zi({},this.props);bs.forEach(e=>delete c[e]),"anonymous"!==_||"identified"!==l&&"anonymous"!==s.$user_state&&(ft(a)||u===a)||(wr(c,s),delete c[ee]),this.props=c;var h=new Set;bs.forEach(e=>{var t,i=null==(t=js(e))?void 0:t.storageGroup;i&&h.add(i)}),h.forEach(e=>{var t={};Xi(this.props,(i,s)=>{var r;(null==(r=js(s))?void 0:r.storageGroup)===e&&(t[s]=i)}),vt(t)?(ys._remove(this._groupEntryName(e)),this._slotState[e]={}):ys._set(this._groupEntryName(e),t)&&(this._slotState[e]={persisted:!0,fingerprint:this._entryFingerprint(t,e)})})}}Os._get(cr(this._name))&&(this._cookieIdentityChangePending=!0)}}_loadGroupEntries(){for(var e of Gs){var t=ys._parse(this._groupEntryName(e));if(t&&!vt(t)){var i=this._slotWriteState(e);i.persisted=!0,this._mainCarriesGroupKey(e)||(i.fingerprint=this._entryFingerprint(t,e)),this._groupEntryIsStale(e,t)||Zi(this.props,t)}}}_mainCarriesGroupKey(e){return Object.keys(this.props).some(t=>{var i;return(null==(i=js(t))?void 0:i.storageGroup)===e})}_groupEntryIsStale(e,t){var i=ur[e];if(!i)return!1;var s=t[i],r=this.props[i];return St(s)&&St(r)&&r>s}refreshKey(e){var t;if(!this._disabled&&!this._metaIdentifierChangePending.has(e)){var i=this._splitStorage?null==(t=js(e))?void 0:t.storageGroup:void 0,s=i?ys._parse(this._groupEntryName(i)):this._storage._parse(this._name);if(s&&e in s)this._setProp(e,s[e],!1);else{if(i){var r=this._storage._parse(this._name);if(r&&e in r)return void this._setProp(e,r[e],!1)}this._deleteProp(e,!1)}}}save(){if(!this._disabled){var e=this._saveDebounceMs();e>0?ft(this._pendingSaveTimer)&&(this._pendingSaveTimer=setTimeout(()=>{this._pendingSaveTimer=void 0,this._writeNow()},e)):this._writeNow()}}flush(){ft(this._pendingSaveTimer)||(clearTimeout(this._pendingSaveTimer),this._pendingSaveTimer=void 0,this._writeNow())}_writeNow(e){if(void 0===e&&(e=!1),!(this._disabled||this._cookieSyncSuppressed&&!e)){e||(this.syncCookieProperties(),this._config.cookieWinsOnConflict&&"localstorage+cookie"===this._config.persistence.toLowerCase()||fr.forEach(e=>this.refreshKey(e)));var t=!e&&!this._storageMigrationInProgress;t||(this._crossTabFeatureFlagIdentityMismatch=!1);var i=!!t&&this._reconcileCrossTabFeatureFlagPropertiesBeforeWrite();if(this._crossTabFeatureFlagIdentityMismatch)this._config.debug&&Ji.warn("skipping persistence write because storage belongs to a different distinct ID");else{if(this._splitStorage)return this._writeNowSplit(),void(i&&this._crossTabFeatureFlagHandlers.forEach(e=>e()));var s=this._writeEntry(this._storage,this._name,this.props,pr);"written"===s&&this._rememberCurrentCookieProperties(this.props),"failed"!==s&&(this._pendingCrossTabFeatureFlagChanges.clear(),this._localIdentityChangePending=!1,this._metaIdentifierChangePending.clear()),i&&this._crossTabFeatureFlagHandlers.forEach(e=>e())}}}_writeNowSplit(){var e=this,t=this._partitionProps(),i=t.main,s=t.groups,r=this._writeEntry(this._storage,this._name,i,pr);"written"===r&&this._rememberCurrentCookieProperties(i),"failed"!==r&&(this._localIdentityChangePending=!1,this._metaIdentifierChangePending.clear(),gr.forEach(e=>{var t;null!=(t=js(e))&&t.storageGroup||this._pendingCrossTabFeatureFlagChanges.delete(e)}));var n=function(t){var i,r=s[t];if(vt(r)&&(null==(i=e._slotState[t])||!i.persisted))return gr.forEach(i=>{var s;(null==(s=js(i))?void 0:s.storageGroup)===t&&e._pendingCrossTabFeatureFlagChanges.delete(i)}),1;var n=e._writeEntry(ys,e._groupEntryName(t),r,t);"failed"!==n&&gr.forEach(i=>{var s=js(i);(null==s?void 0:s.storageGroup)!==t||"written"!==n&&s.volatile||e._pendingCrossTabFeatureFlagChanges.delete(i)})};for(var o of Gs)if(n(o))continue}_partitionProps(){var e={},t={flags:{},surveys:{}};return Xi(this.props,(i,s)=>{var r,n=null==(r=js(s))?void 0:r.storageGroup;n?t[n][s]=i:e[s]=i}),{main:e,groups:t}}_entryFingerprint(e,t){if(t===pr)return JSON.stringify(e)+"|"+this._expire_days+"|"+this._cross_subdomain+"|"+this._secure;var i={};return Xi(e,(e,t)=>{var s;i[t]=null!=(s=js(t))&&s.volatile?"__volatile__":e}),JSON.stringify(i)}_writeEntry(e,t,i,s){var r,n=this._slotWriteState(s);if(s!==pr&&!n.dirty&&!ft(n.fingerprint))return"skipped";try{if((r=this._entryFingerprint(i,s))===n.fingerprint)return n.dirty=!1,"skipped"}catch(e){r=void 0}return e._set(t,i,this._expire_days,this._cross_subdomain,this._secure,this._config.debug)?(n.dirty=!1,s!==pr&&(n.persisted=!0),ft(r)||(n.fingerprint=r),this._splitStorageEligible&&(n.storageValue=ys._get(t)),"written"):(this._config.debug&&Ji.warn('failed to persist storage entry "'+t+'"; will retry on next save'),"failed")}remove(e){var t=(void 0===e?{}:e).keepGroupEntries,i=void 0!==t&&t;if(this._markAllCrossTabFeatureFlagChangesPending(),ft(this._pendingSaveTimer)||(clearTimeout(this._pendingSaveTimer),this._pendingSaveTimer=void 0),this._storage._remove(this._name,!1),this._storage._remove(this._name,!0),!i&&this._ownsSplitStorage)for(var s of Gs)ys._remove(this._groupEntryName(s));i?delete this._slotState[pr]:this._slotState={},this._lastSeenCookiePropertiesFingerprint=void 0,this._lastSeenMainCookieValue=void 0}clear(){this.remove(),this.props={}}register_once(e,t,i){if(gt(e)){this.syncCookieProperties(),ft(t)&&(t="None"),this._expire_days=ft(i)?this._default_expiry:i;var s=!1;if(Xi(e,(e,i)=>{this.props.hasOwnProperty(i)&&this.props[i]!==t||(this._setProp(i,e),s=!0)}),s)return this.save(),!0}return!1}register(e,t){if(gt(e)){this.syncCookieProperties(),this._expire_days=ft(t)?this._default_expiry:t;var i=!1;if(Xi(e,(t,s)=>{e.hasOwnProperty(s)&&(this.props[s]!==t||gt(t)||ht(t))&&(this._setProp(s,t),i=!0)}),i)return this.save(),!0}return!1}unregister(e){this.syncCookieProperties();var t="string"==typeof e?[e]:e,i=!1;for(var s of t)s in this.props&&(this._deleteProp(s),i=!0);i&&this.save()}update_campaign_params(){var e=null==Ye?void 0:Ye.URL;if(e!==this._campaign_params_url){var t=function(e,t,i){if(!Ye)return{};var s,r=t?[...Qs,...i||[]]:[],n=tr(Ys(Ye.URL,r,Zs),e);return Zi((s={},Xi(er,function(e){var t=os(e);s[e]=t||null}),s),n)}(this._config.custom_campaign_params,this._config.mask_personal_data_properties,this._config.custom_personal_data_properties),i=!vt(ts(t));return i&&this.register(t),this._campaign_params_url=e,i?t:void 0}}update_search_keyword(){var e;this.register((e=null==Ye?void 0:Ye.referrer)?ir(e):{})}update_referrer_info(){var e;this.register_once({$referrer:nr(),$referring_domain:null!=Ye&&Ye.referrer&&(null==(e=Ks(Ye.referrer))?void 0:e.host)||rr},void 0)}set_initial_person_info(){if(!this.props.$initial_campaign_params&&!this.props.$initial_referrer_info){var e=or(this._config.mask_personal_data_properties,this._config.custom_personal_data_properties,this._config.disable_capture_url_hashes);this.register_once({[Pe]:this._storesIdentityInCookie?{r:hr(e.r),u:e.u?hr(e.u):void 0}:e},void 0)}}get_initial_props(){var e={};Xi([Se,we],t=>{var i=this.props[t];i&&Xi(i,function(t,i){e["$initial_"+dt(i)]=t})});var t=this.props[Pe];return t&&Zi(e,function(e,t){void 0===t&&(t=!1);var i=ar(e,t),s={};return Xi(i,function(e,t){s["$initial_"+dt(t)]=e}),s}(t,this._config.disable_capture_url_hashes)),e}safe_merge(e){return Xi(this.props,function(t,i){i in e||(e[i]=t)}),e}update_config(e,t,s){var r=e.persistence!==t.persistence,n=!((e,t)=>{if(e.length!==t.length)return!1;var i=[...e].sort(),s=[...t].sort();return i.every((e,t)=>e===s[t])})(e.cookie_persisted_properties||[],t.cookie_persisted_properties||[]),o=r||n,a=e.cookieWinsOnConflict!==t.cookieWinsOnConflict,l=e.disable_persistence||!!s,d=!!this._disabled&&!l;l||this._syncCookieProperties(t,d),this._config=e,!l&&(r||n||a)&&(this._lastSeenCookiePropertiesFingerprint=void 0,this._lastSeenMainCookieValue=void 0,this._syncCookieProperties(i({},e,{cookie_persisted_properties:t.cookie_persisted_properties}),d));var u=o||a?this._buildStorage(e):this._storage;this._truncateExistingPersonInfoForCookie();var _=this._resolveSplitStorage(e),c=o||_!==this._splitStorage,h=!l&&(c||e.cross_subdomain_cookie!==this._cross_subdomain||e.secure_cookie!==this._secure)&&this._beginCookieSyncSuppression(d);this._storageMigrationInProgress=c;try{if(this._default_expiry=this._expire_days=e.cookie_expiration,this.set_disabled(l),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),c){var p=this.props;this.clear(),this._storage=u,this._splitStorage=_,this.props=p,this.save()}else a&&(this._storage=u,l||(delete this._slotState[pr],this._writeNow()))}finally{this._storageMigrationInProgress=!1,h&&this._endCookieSyncSuppression()}}_truncateExistingPersonInfoForCookie(){var e=this.props[Pe];if(this._storesIdentityInCookie&&gt(e)&&"string"==typeof e.r){var t=hr(e.r),s="string"==typeof e.u?hr(e.u):e.u;t===e.r&&s===e.u||this._setProp(Pe,i({},e,{r:t,u:s}))}}set_disabled(e){this._disabled=e,this._disabled?this.remove():this.save()}set_cross_subdomain(e){e!==this._cross_subdomain&&(this._cross_subdomain=e,this.remove({keepGroupEntries:!0}),this.save())}set_secure(e){e!==this._secure&&(this._secure=e,this.remove({keepGroupEntries:!0}),this.save())}set_event_timer(e,t){var i=this.props.__timers||{};i[e]=t,this._setProp(m,i),this.save()}remove_event_timer(e){var t=this.props.__timers||{},i=t[e];return ft(i)||(delete t[e],this._setProp(m,t),this.save()),i}get_property(e){return this.props[e]}set_property(e,t){this._setProp(e,t),this.save()}_setProp(e,t,i){var s;void 0===i&&(i=!0);var r=this.props[e];this.props[e]=t,i&&("distinct_id"!==e&&"$user_state"!==e||r===t||(this._localIdentityChangePending=!0),mr(e)&&!yr(r,t)&&this._metaIdentifierChangePending.add(e),this._markPendingCrossTabFeatureFlagChanges(e,r,t),null!=(s=js(e))&&s.volatile||this._markGroupDirty(e))}_deleteProp(e,t){void 0===t&&(t=!0),delete this.props[e],t&&(vr(e)&&this._setCrossTabFeatureFlagChangesPending(e,!0),mr(e)&&this._metaIdentifierChangePending.add(e),this._markGroupDirty(e))}_markGroupDirty(e){var t,i=null==(t=js(e))?void 0:t.storageGroup;i&&(this._slotWriteState(i).dirty=!0)}_slotWriteState(e){return this._slotState[e]||(this._slotState[e]={})}},Pr={GZipJS:"gzip-js",Base64:"base64"},xr={Activation:"events",Cancellation:"cancelEvents"},Er={Button:"button",Tab:"tab",Selector:"selector"},Cr={TopLeft:"top_left",TopRight:"top_right",TopCenter:"top_center",MiddleLeft:"middle_left",MiddleRight:"middle_right",MiddleCenter:"middle_center",Left:"left",Center:"center",Right:"right",NextToTrigger:"next_to_trigger"},kr={Top:"top",Left:"left",Right:"right",Bottom:"bottom"},Ir={Popover:"popover",API:"api",Widget:"widget",ExternalSurvey:"external_survey"},Tr={Open:"open",MultipleChoice:"multiple_choice",SingleChoice:"single_choice",Rating:"rating",Link:"link"},$r={NextQuestion:"next_question",End:"end",ResponseBased:"response_based",SpecificQuestion:"specific_question"},Fr={Once:"once",Recurring:"recurring",Always:"always"},Rr={SHOWN:"survey shown",DISMISSED:"survey dismissed",SENT:"survey sent",ABANDONED:"survey abandoned"},Or={SURVEY_ID:"$survey_id",SURVEY_NAME:"$survey_name",SURVEY_RESPONSE:"$survey_response",SURVEY_ITERATION:"$survey_iteration",SURVEY_ITERATION_START_DATE:"$survey_iteration_start_date",SURVEY_PARTIALLY_COMPLETED:"$survey_partially_completed",SURVEY_SUBMISSION_ID:"$survey_submission_id",SURVEY_QUESTIONS:"$survey_questions",SURVEY_COMPLETED:"$survey_completed",PRODUCT_TOUR_ID:"$product_tour_id",SURVEY_LAST_SEEN_DATE:"$survey_last_seen_date",SURVEY_LANGUAGE:"$survey_language"},Ar={Popover:"popover",Inline:"inline"};function Mr(e){var t=!0;return{dispose(){if(t){t=!1;var i=e();i&&pt(i.then)&&i.then(void 0,()=>{})}}}}var Dr={backgroundColor:"#ffffff",textColor:"#1d1f27",buttonColor:"#1d1f27",borderRadius:8,buttonBorderRadius:6,borderColor:"#e5e7eb",fontFamily:"system-ui",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",showOverlay:!0,whiteLabel:!1,dismissOnClickOutside:!0,zIndex:2147483646},Lr={SHOWN:"product tour shown",DISMISSED:"product tour dismissed",COMPLETED:"product tour completed",STEP_SHOWN:"product tour step shown",STEP_COMPLETED:"product tour step completed",BUTTON_CLICKED:"product tour button clicked",STEP_SELECTOR_FAILED:"product tour step selector failed",BANNER_CONTAINER_SELECTOR_FAILED:"product tour banner container selector failed",BANNER_ACTION_CLICKED:"product tour banner action clicked"},Nr={TOUR_ID:"$product_tour_id",TOUR_NAME:"$product_tour_name",TOUR_ITERATION:"$product_tour_iteration",TOUR_RENDER_REASON:"$product_tour_render_reason",TOUR_STEP_ID:"$product_tour_step_id",TOUR_STEP_ORDER:"$product_tour_step_order",TOUR_STEP_TYPE:"$product_tour_step_type",TOUR_DISMISS_REASON:"$product_tour_dismiss_reason",TOUR_BUTTON_TEXT:"$product_tour_button_text",TOUR_BUTTON_ACTION:"$product_tour_button_action",TOUR_BUTTON_LINK:"$product_tour_button_link",TOUR_BUTTON_TOUR_ID:"$product_tour_button_tour_id",TOUR_STEPS_COUNT:"$product_tour_steps_count",TOUR_STEP_SELECTOR:"$product_tour_step_selector",TOUR_STEP_SELECTOR_FOUND:"$product_tour_step_selector_found",TOUR_STEP_ELEMENT_TAG:"$product_tour_step_element_tag",TOUR_STEP_ELEMENT_ID:"$product_tour_step_element_id",TOUR_STEP_ELEMENT_CLASSES:"$product_tour_step_element_classes",TOUR_STEP_ELEMENT_TEXT:"$product_tour_step_element_text",TOUR_ERROR:"$product_tour_error",TOUR_MATCHES_COUNT:"$product_tour_matches_count",TOUR_FAILURE_PHASE:"$product_tour_failure_phase",TOUR_WAITED_FOR_ELEMENT:"$product_tour_waited_for_element",TOUR_WAIT_DURATION_MS:"$product_tour_wait_duration_ms",TOUR_BANNER_SELECTOR:"$product_tour_banner_selector",TOUR_LINKED_SURVEY_ID:"$product_tour_linked_survey_id",USE_MANUAL_SELECTOR:"$use_manual_selector",INFERENCE_DATA_PRESENT:"$inference_data_present",TOUR_LAST_SEEN_DATE:"$product_tour_last_seen_date",TOUR_TYPE:"$product_tour_type"},Br=Yi("[RateLimiter]"),Ur=class{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=e=>{var t=e.text;if(t&&t.length)try{(JSON.parse(t).quota_limited||[]).forEach(e=>{Br.info((e||"events")+" is quota limited."),this.serverLimits[e]=(new Date).getTime()+6e4})}catch(e){return void Br.warn('could not rate limit - continuing. Error: "'+(null==e?void 0:e.message)+'"',{text:t})}},this.instance=e,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var e;return(null==(e=this.instance.config.rate_limiting)?void 0:e.events_per_second)||10}get captureEventsBurstLimit(){var e;return Math.max((null==(e=this.instance.config.rate_limiting)?void 0:e.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(e){var t,i,s;void 0===e&&(e=!1);var r=this.captureEventsBurstLimit,n=this.captureEventsPerSecond,o=(new Date).getTime(),a=null!==(t=null==(i=this.instance.persistence)?void 0:i.get_property("$capture_rate_limit"))&&void 0!==t?t:{tokens:r,last:o};a.tokens+=(o-a.last)/1e3*n,a.last=o,a.tokens>r&&(a.tokens=r);var l=1>a.tokens;if(l||e||(a.tokens=Math.max(0,a.tokens-1)),l&&!e){var d=(St(a.dropped)?a.dropped:0)+1;a.dropped=d,!this.lastEventRateLimited&&this._captureWarning(d)&&(a.dropped=0)}return this.lastEventRateLimited=l,null==(s=this.instance.persistence)||s.set_property(be,a),{isRateLimited:l,remainingTokens:a.tokens}}_isPropertyAllowed(e){var t=this.instance.config.property_denylist;return!ht(t)||!t.includes(e)}_triggeringPage(){var e;if(this._isPropertyAllowed("$current_url")&&this._isPropertyAllowed("$pathname")&&null!=Qe&&Qe.pathname)return""+(null!==(e=Qe.origin)&&void 0!==e?e:"")+Qe.pathname}_captureWarning(e){var t,i,s=this.captureEventsBurstLimit,r=this.captureEventsPerSecond,n=this._triggeringPage(),o=this._isPropertyAllowed("$session_id")?null==(t=(i=this.instance).get_session_id)?void 0:t.call(i):void 0,a=[e+" event(s) dropped since the last warning",n?"triggered on "+n:void 0,o?"session "+o:void 0].filter(Boolean).join(", ");return!!this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited: "+a+". Config is set to "+r+" events per second and "+s+" events burst limit."},{skip_client_rate_limiting:!0})}isServerRateLimited(e){var t=this.serverLimits[e||"events"]||!1;return!1!==t&&(new Date).getTime()<t}},qr=Yi("[RemoteConfig]"),Hr=class{constructor(e){this._instance=e}get remoteConfig(){var e;return null==(e=rt._POSTHOG_REMOTE_CONFIG)||null==(e=e[this._instance.config.token])?void 0:e.config}_loadRemoteConfigJs(e){var t,i;null!=(t=rt.__PosthogExtensions__)&&t.loadExternalDependency?null==(i=rt.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"remote-config",()=>e(this.remoteConfig)):e()}_loadRemoteConfigJSON(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 qr.info("Using preloaded remote config",this.remoteConfig),void this._onRemoteConfig(this.remoteConfig);if(this._instance._shouldDisableFlags())return void qr.warn("Remote config is disabled. Falling back to local config.");this._loadRemoteConfigJs(e=>{if(!e)return qr.info("No config found after loading remote JS config. Falling back to JSON."),void this._loadRemoteConfigJSON(e=>{this._onRemoteConfig(e.json,e)});this._onRemoteConfig(e)})}catch(e){qr.error("Error loading remote config",e),this._onRemoteConfig()}}_onRemoteConfig(e,t){!e&&t&&(0===t.statusCode?t.error||qr.warn("Failed to fetch remote config from PostHog."):qr.error("Failed to fetch remote config from PostHog."));try{this._instance._onRemoteConfig(e?{ok:!0,config:e}:{ok:!1})}catch(e){qr.error("Error applying remote config",e)}if(!1!==(null==e?void 0:e.hasFeatureFlags)&&!this._instance.config.advanced_disable_feature_flags_on_first_load)try{var i;null==(i=this._instance.featureFlags)||i.ensureFlagsLoaded()}catch(e){qr.error("Error loading feature flags",e)}}},Gr=["fatal","error","warning","log","info","debug"],Wr=Uint8Array,Vr=Uint16Array,jr=Uint32Array,zr=new Wr([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]),Kr=new Wr([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]),Jr=new Wr([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Yr=function(e,t){for(var i=new Vr(31),s=0;31>s;++s)i[s]=t+=1<<e[s-1];var r=new jr(i[30]);for(s=1;30>s;++s)for(var n=i[s];i[s+1]>n;++n)r[n]=n-i[s]<<5|s;return[i,r]},Qr=Yr(zr,2),Xr=Qr[1];Qr[0][28]=258,Xr[258]=28;for(var Zr=Yr(Kr,0)[1],en=new Vr(32768),tn=0;32768>tn;++tn){var sn=(43690&tn)>>>1|(21845&tn)<<1;en[tn]=((65280&(sn=(61680&(sn=(52428&sn)>>>2|(13107&sn)<<2))>>>4|(3855&sn)<<4))>>>8|(255&sn)<<8)>>>1}var rn=function(e,t,i){for(var s=e.length,r=0,n=new Vr(t);s>r;++r)++n[e[r]-1];var o,a=new Vr(t);for(r=0;t>r;++r)a[r]=a[r-1]+n[r-1]<<1;if(i){o=new Vr(1<<t);var l=15-t;for(r=0;s>r;++r)if(e[r])for(var d=r<<4|e[r],u=t-e[r],_=a[e[r]-1]++<<u,c=_|(1<<u)-1;c>=_;++_)o[en[_]>>>l]=d}else for(o=new Vr(s),r=0;s>r;++r)o[r]=en[a[e[r]-1]++]>>>15-e[r];return o},nn=new Wr(288);for(tn=0;144>tn;++tn)nn[tn]=8;for(tn=144;256>tn;++tn)nn[tn]=9;for(tn=256;280>tn;++tn)nn[tn]=7;for(tn=280;288>tn;++tn)nn[tn]=8;var on=new Wr(32);for(tn=0;32>tn;++tn)on[tn]=5;var an=rn(nn,9,0),ln=rn(on,5,0),dn=function(e){return(e/8|0)+(7&e&&1)},un=function(e,t,i){(null==t||0>t)&&(t=0),(null==i||i>e.length)&&(i=e.length);var s=new(e instanceof Vr?Vr:e instanceof jr?jr:Wr)(i-t);return s.set(e.subarray(t,i)),s},_n=function(e,t,i){var s=t/8|0;e[s]|=i<<=7&t,e[s+1]|=i>>>8},cn=function(e,t,i){var s=t/8|0;e[s]|=i<<=7&t,e[s+1]|=i>>>8,e[s+2]|=i>>>16},hn=function(e,t){for(var i=[],s=0;e.length>s;++s)e[s]&&i.push({s:s,f:e[s]});var r=i.length,n=i.slice();if(!r)return[new Wr(0),0];if(1==r){var o=new Wr(i[0].s+1);return o[i[0].s]=1,[o,1]}i.sort(function(e,t){return e.f-t.f}),i.push({s:-1,f:25001});var a=i[0],l=i[1],d=0,u=1,_=2;for(i[0]={s:-1,f:a.f+l.f,l:a,r:l};u!=r-1;)a=i[i[_].f>i[d].f?d++:_++],l=i[d!=u&&i[_].f>i[d].f?d++:_++],i[u++]={s:-1,f:a.f+l.f,l:a,r:l};var c=n[0].s;for(s=1;r>s;++s)n[s].s>c&&(c=n[s].s);var h=new Vr(c+1),p=pn(i[u-1],h,0);if(p>t){s=0;var g=0,v=p-t,f=1<<v;for(n.sort(function(e,t){return h[t.s]-h[e.s]||e.f-t.f});r>s;++s){var m=n[s].s;if(t>=h[m])break;g+=f-(1<<p-h[m]),h[m]=t}for(g>>>=v;g>0;){var y=n[s].s;t>h[y]?g-=1<<t-h[y]++-1:++s}for(;s>=0&&g;--s){var b=n[s].s;h[b]==t&&(--h[b],++g)}p=t}return[new Wr(h),p]},pn=function(e,t,i){return-1==e.s?Math.max(pn(e.l,t,i+1),pn(e.r,t,i+1)):t[e.s]=i},gn=function(e){for(var t=e.length;t&&!e[--t];);for(var i=new Vr(++t),s=0,r=e[0],n=1,o=function(e){i[s++]=e},a=1;t>=a;++a)if(e[a]==r&&a!=t)++n;else{if(!r&&n>2){for(;n>138;n-=138)o(32754);n>2&&(o(n>10?n-11<<5|28690:n-3<<5|12305),n=0)}else if(n>3){for(o(r),--n;n>6;n-=6)o(8304);n>2&&(o(n-3<<5|8208),n=0)}for(;n--;)o(r);n=1,r=e[a]}return[i.subarray(0,s),t]},vn=function(e,t){for(var i=0,s=0;t.length>s;++s)i+=e[s]*t[s];return i},fn=function(e,t,i){var s=i.length,r=dn(t+2);e[r]=255&s,e[r+1]=s>>>8,e[r+2]=255^e[r],e[r+3]=255^e[r+1];for(var n=0;s>n;++n)e[r+n+4]=i[n];return 8*(r+4+s)},mn=function(e,t,i,s,r,n,o,a,l,d,u){_n(t,u++,i),++r[256];for(var _=hn(r,15),c=_[0],h=_[1],p=hn(n,15),g=p[0],v=p[1],f=gn(c),m=f[0],y=f[1],b=gn(g),w=b[0],S=b[1],P=new Vr(19),x=0;m.length>x;++x)P[31&m[x]]++;for(x=0;w.length>x;++x)P[31&w[x]]++;for(var E=hn(P,7),C=E[0],k=E[1],I=19;I>4&&!C[Jr[I-1]];--I);var T,F,R,O,A=d+5<<3,M=vn(r,nn)+vn(n,on)+o,D=vn(r,c)+vn(n,g)+o+14+3*I+vn(P,C)+(2*P[16]+3*P[17]+7*P[18]);if(M>=A&&D>=A)return fn(t,u,e.subarray(l,l+d));if(_n(t,u,1+(M>D)),u+=2,M>D){T=rn(c,h,0),F=c,R=rn(g,v,0),O=g;var L=rn(C,k,0);for(_n(t,u,y-257),_n(t,u+5,S-1),_n(t,u+10,I-4),u+=14,x=0;I>x;++x)_n(t,u+3*x,C[Jr[x]]);u+=3*I;for(var N=[m,w],B=0;2>B;++B){var U=N[B];for(x=0;U.length>x;++x)_n(t,u,L[q=31&U[x]]),u+=C[q],q>15&&(_n(t,u,U[x]>>>5&127),u+=U[x]>>>12)}}else T=an,F=nn,R=ln,O=on;for(x=0;a>x;++x)if(s[x]>255){var q;cn(t,u,T[257+(q=s[x]>>>18&31)]),u+=F[q+257],q>7&&(_n(t,u,s[x]>>>23&31),u+=zr[q]);var H=31&s[x];cn(t,u,R[H]),u+=O[H],H>3&&(cn(t,u,s[x]>>>5&8191),u+=Kr[H])}else cn(t,u,T[s[x]]),u+=F[s[x]];return cn(t,u,T[256]),u+F[256]},yn=new jr([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),bn=new Wr(0),wn=function(){for(var e=new jr(256),t=0;256>t;++t){for(var i=t,s=9;--s;)i=(1&i&&3988292384)^i>>>1;e[t]=i}return e}(),Sn=function(e,t,i){for(;i;++t)e[t]=i,i>>>=8};function Pn(e,t){void 0===t&&(t={});var i=function(){var e=4294967295;return{p(t){for(var i=e,s=0;t.length>s;++s)i=wn[255&i^t[s]]^i>>>8;e=i},d(){return 4294967295^e}}}(),s=e.length;i.p(e);var r,n,o,a,l,d,u=(a=10+((r=t).filename&&r.filename.length+1||0),l=8,function(e,t,i,s,r,n){var o=e.length,a=new Wr(s+o+5*(1+Math.floor(o/7e3))+r),l=a.subarray(s,a.length-r),d=0;if(!t||8>o)for(var u=0;o>=u;u+=65535){var _=u+65535;o>_?d=fn(l,d,e.subarray(u,_)):(l[u]=n,d=fn(l,d,e.subarray(u,o)))}else{for(var c=yn[t-1],h=c>>>13,p=8191&c,g=(1<<i)-1,v=new Vr(32768),f=new Vr(g+1),m=Math.ceil(i/3),y=2*m,b=function(t){return(e[t]^e[t+1]<<m^e[t+2]<<y)&g},w=new jr(25e3),S=new Vr(288),P=new Vr(32),x=0,E=0,C=(u=0,0),k=0,I=0;o>u;++u){var T=b(u),F=32767&u,R=f[T];if(v[F]=R,f[T]=F,u>=k){var O=o-u;if((x>7e3||C>24576)&&O>423){d=mn(e,l,0,w,S,P,E,C,I,u-I,d),C=x=E=0,I=u;for(var A=0;286>A;++A)S[A]=0;for(A=0;30>A;++A)P[A]=0}var M=2,D=0,L=p,N=F-R&32767;if(O>2&&T==b(u-N))for(var B=Math.min(h,O)-1,U=Math.min(32767,u),q=Math.min(258,O);U>=N&&--L&&F!=R;){if(e[u+M]==e[u+M-N]){for(var H=0;q>H&&e[u+H]==e[u+H-N];++H);if(H>M){if(M=H,D=N,H>B)break;var G=Math.min(N,H-2),W=0;for(A=0;G>A;++A){var V=u-N+A+32768&32767,j=V-v[V]+32768&32767;j>W&&(W=j,R=V)}}}N+=(F=R)-(R=v[F])+32768&32767}if(D){w[C++]=268435456|Xr[M]<<18|Zr[D];var z=31&Xr[M],K=31&Zr[D];E+=zr[z]+Kr[K],++S[257+z],++P[K],k=u+M,++x}else w[C++]=e[u],++S[e[u]]}}d=mn(e,l,n,w,S,P,E,C,I,u-I,d),n||(d=fn(l,d,bn))}return un(a,0,s+dn(d)+r)}(n=e,null==(o=t).level?6:o.level,null==o.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(n.length)))):12+o.mem,a,l,!d)),_=u.length;return function(e,t){var i=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=2>t.level?4:9==t.level?2:0,e[9]=3,0!=t.mtime&&Sn(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),i){e[3]=8;for(var s=0;i.length>=s;++s)e[s+10]=i.charCodeAt(s)}}(u,t),Sn(u,_-8,i.d()),Sn(u,_-4,s),u}var xn=!!Ze||!!Xe,En=new WeakMap,Cn="text/plain",kn=0,In=!1,Tn=(e,t)=>{var i=e.split("#"),s=i[1],r=i[0].split("?"),n=r[0],o=r[1];if(!o)return e;var a=o.split("&").filter(e=>e.split("=")[0]!==t).join("&");return n+(a?"?"+a:"")+(s?"#"+s:"")},$n=function(e,t,s){var r;void 0===s&&(s=!0);var n=e.split("?"),o=n[0],a=n[1],l=i({},t),d=null!==(r=null==a?void 0:a.split("&").map(e=>{var t,i=e.split("="),r=i[0],n=s&&null!==(t=l[r])&&void 0!==t?t:i[1];return delete l[r],r+"="+n}))&&void 0!==r?r:[],u=function(e,t){var i,s;void 0===t&&(t="&");var r=[];return Xi(e,function(e,t){ft(e)||ft(t)||"undefined"===t||(i=encodeURIComponent((e=>e instanceof File)(e)?e.name:e.toString()),s=encodeURIComponent(t),r[r.length]=s+"="+i)}),r.join(t)}(l);return u&&d.push(u),d.length>0?o+"?"+d.join("&"):o},Fn=e=>{if(e._encodedBody)return e._encodedBody;var t=e.data,i=e.compression;if(t){if(i===Pr.GZipJS){var s=Pn(function(e){var t=e.length;if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var i=new Wr(e.length+(e.length>>>1)),s=0,r=function(e){i[s++]=e},n=0;t>n;++n){if(s+5>i.length){var o=new Wr(s+8+(t-n<<1));o.set(i),i=o}var a=e.charCodeAt(n);128>a?r(a):2048>a?(r(192|a>>>6),r(128|63&a)):a>55295&&57344>a?(r(240|(a=65536+(1047552&a)|1023&e.charCodeAt(++n))>>>18),r(128|a>>>12&63),r(128|a>>>6&63),r(128|63&a)):(r(224|a>>>12),r(128|a>>>6&63),r(128|63&a))}return un(i,0,s)}(zs(t)),{mtime:0});return{contentType:Cn,body:s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength),estimatedSize:s.byteLength}}if(i===Pr.Base64){var r=(e=>"data="+encodeURIComponent("string"==typeof e?e:zs(e)))(function(e){return e?btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,(e,t)=>String.fromCharCode(parseInt(t,16)))):e}(zs(t)));return{contentType:"application/x-www-form-urlencoded",body:r,estimatedSize:new Blob([r]).size}}var n=zs(t);return{contentType:"application/json",body:n,estimatedSize:new Blob([n]).size}}},Rn=e=>{var t,s,r=()=>"sendBeacon"===e.transport?{url:$n(e.url,{compression:Pr.Base64}),encodedBody:Fn(i({},e,{compression:Pr.Base64,_encodedBody:void 0}))}:{url:Tn(e.url,"compression"),encodedBody:Fn(i({},e,{compression:void 0,_encodedBody:void 0}))};try{t=Fn(e)}catch(t){if(Gi(e.compression,Js(e.url,"compression")))return Ji.error("Failed to gzip request body, sending uncompressed payload",t),r();throw t}return t&&Gi(e.compression,Js(e.url,"compression"))&&!((s=t.body)instanceof ArrayBuffer?Hi(new Uint8Array(s)):ArrayBuffer.isView(s)&&Hi(new Uint8Array(s.buffer,s.byteOffset,s.byteLength)))?(In=!0,r()):{url:e.url,encodedBody:t}},On=e=>{try{return Rn(e)}catch(t){return Ji.error(t),void(null==e.callback||e.callback({statusCode:0,error:t}))}},An=function(){var e=r(function*(e){var t=yield function(e,t,i){return zi.apply(this,arguments)}(zs(e.data),a.DEBUG,{rethrow:!0});if(!t)return e;var s=yield t.arrayBuffer();return i({},e,{_encodedBody:{contentType:Cn,body:s,estimatedSize:s.byteLength}})});return function(t){return e.apply(this,arguments)}}(),Mn=/Failed to fetch|NetworkError|Load failed/i,Dn=e=>"TypeError"===(null==e?void 0:e.name)&&Mn.test((null==e?void 0:e.message)||""),Ln=e=>{try{var t=function(e,t){if(void 0===t&&(t=Date.now()),"string"==typeof e&&e){var i=e.trim(),s=/^\d+\s*,/.test(i)?i.slice(0,i.indexOf(",")).trim():i;if(/^\d+$/.test(s)){var r=1e3*Math.min(Number(s),300);return r>0?r:void 0}if(/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun)[a-z]*[ ,]/.test(s)){var n=/^\w{3} \w{3} /.test(s)?s+" GMT":s,o=Date.parse(n)-t;if(Number.isFinite(o)&&o>0)return Math.min(o,3e5)}}}(e());return ft(t)?void 0:Math.min(t,3e4)}catch(e){return}},Nn=e=>{var t=On(e);if(t){var i=new Ze;En.set(i,!0);var s=t.encodedBody;i.open(e.method||"GET",t.url,!0);var r=null!=s?s:{},n=r.contentType,o=r.body;Xi(e.headers,function(e,t){i.setRequestHeader(t,e)}),n&&i.setRequestHeader("Content-Type",n),e.timeout&&(i.timeout=e.timeout),i.onreadystatechange=()=>{if(4===i.readyState){var t={statusCode:i.status,text:i.responseText};if(200===i.status)try{t.json=JSON.parse(i.responseText)}catch(e){}null==e.callback||e.callback(t,Ln(()=>i.getResponseHeader("Retry-After")))}},i.send(o)}},Bn=e=>{var t=On(e);if(t){var s=t.url,r=t.encodedBody,n=null!=r?r:{},o=n.contentType,a=n.body,l=n.estimatedSize,d=new Headers;Xi(e.headers,function(e,t){d.append(t,e)}),o&&d.append("Content-Type",o);var u=null,_=!1;if(et){var c=new et;u={signal:c.signal,timeout:setTimeout(()=>{var t;_=!0,c.abort(Li("AbortError","PostHog request timed out"+((t=e.timeout)?" after "+t+"ms":"")))},e.timeout)}}var h=t=>{_&&"AbortError"===(null==t?void 0:t.name)||Dn(t)?Ji.warn(t):Ji.error(t),null==e.callback||e.callback({statusCode:0,error:t})},p=0,g=()=>{kn-=p,p=0,u&&clearTimeout(u.timeout)};try{var v,f=i({method:(null==e?void 0:e.method)||"GET",headers:d,referrerPolicy:"strict-origin",body:a,signal:null==(v=u)?void 0:v.signal},e.fetchOptions),m=null!=l?l:ft(a)?0:void 0;f.keepalive="POST"===f.method&&!e._keepaliveDisabled&&!1!==f.keepalive&&f.body===a&&!ft(m)&&m>=0&&52428.8>kn+m,f.keepalive&&(kn+=p=m),Xe(s,f).then(t=>t.text().then(i=>{var s={statusCode:t.status,text:i};if(200===t.status)try{s.json=JSON.parse(i)}catch(e){Ji.error(e)}g(),null==e.callback||e.callback(s,Ln(()=>t.headers.get("Retry-After")))})).catch(e=>{g(),h(e)}).finally(g)}catch(e){g(),h(e)}}},Un=e=>{try{var t,s=Rn(e),r=s.url,n=s.encodedBody,o=null!=n?n:{},a=o.body,l=o.estimatedSize;if(!a)return;var d=a instanceof Blob?a:new Blob([a],{type:o.contentType});if(Je.sendBeacon(r,d))return;var u=ht(e.data)?e.data:null==(t=e.data)?void 0:t.batch;if(ht(u)&&u.length>1&&(null!=l?l:0)>16384){var _=Math.ceil(u.length/2),c=t=>ht(e.data)?t:i({},e.data,{batch:t});return Un(i({},e,{data:c(u.slice(0,_))})),void Un(i({},e,{data:c(u.slice(_))}))}Ji.warn("Beacon of ~"+(null!=l?l:0)+" bytes was rejected by the browser, falling back to "+(Xe?"fetch":"XHR")),Xe?Bn(i({},e,{_keepaliveDisabled:!0})):Nn(e)}catch(e){Ji.warn("Beacon send failed",e)}},qn=(e,t,s,r)=>{var n="query"===r?"POST"===t?"sent_at":"_":void 0;return $n(s===Pr.GZipJS?Tn(e,"compression"):e,i({},n?{[n]:Date.now().toString()}:{},s===Pr.GZipJS?{}:{compression:s}))},Hn=(()=>{var e=[];return Xe&&e.push({transport:"fetch",method:Bn}),Ze&&e.push({transport:"XHR",method:Nn}),null!=Je&&Je.sendBeacon&&e.push({transport:"sendBeacon",method:Un}),e})(),Gn=!xn&&-1===(null==it?void 0:it.indexOf("MSIE"))&&-1===(null==it?void 0:it.indexOf("Mozilla"));function Wn(e,t,s){var r;s&&(t=i({},t,{callback:e=>s(e)})),e.__loaded?Gn?e.__request_queue.push(t):e.rateLimiter.isServerRateLimited(t.batchKey)?t.fireCallbackOnDrop&&(null==t.callback||t.callback({statusCode:429})):(t.transport=t.transport||e.config.api_transport,t.headers=i({},e.config.request_headers,t.headers),t.compression="best-available"===t.compression?null!==(r=e.compression)&&void 0!==r?r:t.compressionFallback:t.compression,(ft(e.config.disable_beacon)?e.config.__preview_disable_beacon:e.config.disable_beacon)&&(t.disableTransport=["sendBeacon"]),t.fetchOptions=t.fetchOptions||e.config.fetch_options,((e,t)=>{var s,r,n,o=i({},e,{callback:null!=t?t:t=>null==e.callback?void 0:e.callback(t)});o.timeout=o.timeout||6e4;var a,l,d,u,_,c=null!==(s=o.transport)&&void 0!==s?s:"fetch";"sendBeacon"===c&&ft(o.compression)&&o.data&&(o.compression=Pr.Base64),"POST"===o.method&&o.data&&("capture-body"===o.timestampMode?o.data={api_key:null!==(l=null==(_=(u=(ht(a=o.data)?a:[a]).map(e=>i({},e,e.timestamp instanceof Date&&!isNaN(e.timestamp.getTime())?{timestamp:e.timestamp.toISOString()}:{})))[0])||null==(d=_.properties)?void 0:d.token)&&void 0!==l?l:null==_?void 0:_.token,batch:u,sent_at:(new Date).toISOString()}:"body"===o.timestampMode&&(o.data=function(e,t){return void 0===t&&(t=(new Date).toISOString()),ht(e)?e.map(e=>i({},e,{sent_at:t})):i({},e,{sent_at:t})}(o.data))),o.url=qn(o.url,o.method,o.compression,o.timestampMode);var h=Hn.filter(e=>!o.disableTransport||!e.transport||!o.disableTransport.includes(e.transport)),p=null!==(r=null==(n=function(e,t){for(var i=0;e.length>i;i++)if(t(e[i]))return e[i]}(h,e=>e.transport===c))?void 0:n.method)&&void 0!==r?r:h[0].method;if(!p)throw new Error("No available transport method");var g=e=>{try{p(e)}catch(e){Dn(e)?Ji.warn(e):Ji.error(e),null==o.callback||o.callback({statusCode:0,error:e})}};"sendBeacon"!==c&&o.data&&o.compression===Pr.GZipJS&&tt&&"undefined"!=typeof Promise&&!In?An(o).then(e=>{g(e)}).catch(t=>{if(Wi(t))return In=!0,void g(i({},o,{compression:void 0,url:qn(e.url,e.method,void 0,e.timestampMode)}));(e=>{if(!e||"object"!=typeof e)return!1;var t="name"in e?String(e.name):"";return Wi(e)||t===qi})(t)&&(In=!0),g(o)}):p(o)})(t,(i,r)=>{e.rateLimiter.checkForLimiting(i),400>i.statusCode||null==e.config.on_request_error||e.config.on_request_error(i),s?s(i,r):null==t.callback||t.callback(i)})):t.fireCallbackOnDrop&&(null==t.callback||t.callback({statusCode:0}))}var Vn=class{constructor(e,t){this._isPaused=!0,this._queue=[],this._flushTimeoutMs=Ot((null==t?void 0:t.flush_interval_ms)||3e3,250,5e3,Ji.createLogger("flush interval"),3e3),this._sendRequest=e}enqueue(e){this._queue.push(e),this._flushTimeout||this._setFlushTimeout()}unload(){this._clearFlushTimeout();var e=this._queue.length>0?this._formatQueue():{},t=Object.values(e);[...t.filter(e=>0===e.url.indexOf("/e")),...t.filter(e=>0!==e.url.indexOf("/e"))].map(e=>{this._sendRequestSafely(e,"sendBeacon")})}enable(){this._isPaused=!1,this._setFlushTimeout()}_setFlushTimeout(){this._isPaused||(this._flushTimeout=setTimeout(()=>{if(this._clearFlushTimeout(),this._queue.length>0){var e=this._formatQueue();for(var t in e)this._sendRequestSafely(e[t])}},this._flushTimeoutMs))}_sendRequestSafely(e,t){try{this._sendRequest(e,t)}catch(e){Ji.error(e)}}_clearFlushTimeout(){clearTimeout(this._flushTimeout),this._flushTimeout=void 0}_formatQueue(){var e={};return Xi(this._queue,t=>{var s,r=t,n=((r?r.batchKey:null)||r.url)+(r.batchGroup?":"+r.batchGroup:"");ft(e[n])&&(e[n]=i({},r,{data:[]})),null==(s=e[n].data)||s.push(r.data)}),this._queue=[],e}},jn=class{constructor(e){this._instance=e,this._isPolling=!1,this._pollIntervalMs=3e3,this._queue=[],this._queue=[],this._areWeOnline=!0,this.resume()}resume(){if(!ft(ze)&&"onLine"in ze.navigator){if(this._areWeOnline=ze.navigator.onLine,this._onlineListener)return;this._onlineListener=()=>{this._areWeOnline=!0,this._flush()},this._offlineListener=()=>{this._areWeOnline=!1},ns(ze,"online",this._onlineListener),ns(ze,"offline",this._offlineListener)}}get length(){return this._queue.length}retriableRequest(e,s){var r=e.retriesPerformedSoFar,n=function(e,t){if(null==e)return{};var i={};for(var s in e)if({}.hasOwnProperty.call(e,s)){if(-1!==t.indexOf(s))continue;i[s]=e[s]}return i}(e,t);Pt(r)&&(n.url=$n(n.url,{retry_count:r})),Wn(this._instance,s?i({},n,{transport:s}):n,(e,t)=>{if(200!==e.statusCode&&(400>e.statusCode||e.statusCode>=500)){if((0===e.statusCode?3:10)>(null!=r?r:0))return void this._enqueue(i({retriesPerformedSoFar:r},n),t);0===e.statusCode&&Ji.warn("Request failed before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped retrying after "+(null!=r?r:0)+" retries.")}null==n.callback||n.callback(e)})}_enqueue(e,t){var i=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=i+1;var s=Math.max(function(e){var t=3e3*Math.pow(2,e),i=t/2,s=Math.min(18e5,t),r=(Math.random()-.5)*(s-i);return Math.ceil(s+r)}(i),null!=t?t:0),r=Date.now()+s;this._queue.push({retryAt:r,requestOptions:e});var n="Enqueued failed request for retry in "+s;navigator.onLine||(n+=" (Browser is offline)"),Ji.warn(n),this._isPolling||(this._isPolling=!0,this._poll())}_poll(){if(this._poller&&clearTimeout(this._poller),0===this._queue.length)return this._isPolling=!1,void(this._poller=void 0);this._poller=setTimeout(()=>{this._areWeOnline&&this._queue.length>0&&this._flush(),this._poll()},this._pollIntervalMs)}_flush(){var e=Date.now(),t=[],i=this._queue.filter(i=>e>i.retryAt||(t.push(i),!1));if(this._queue=t,i.length>0)for(var s of i)this.retriableRequest(s.requestOptions)}unload(){for(var e of(this._poller&&(clearTimeout(this._poller),this._poller=void 0),this._isPolling=!1,ft(ze)||(this._onlineListener&&(ze.removeEventListener("online",this._onlineListener),this._onlineListener=void 0),this._offlineListener&&(ze.removeEventListener("offline",this._offlineListener),this._offlineListener=void 0)),this._queue)){var t=e.requestOptions;try{this._instance._send_request(i({},t,{transport:"sendBeacon"}))}catch(e){Ji.error(e)}}this._queue=[]}},zn=class{constructor(e){this._instance=e,this._updateScrollData=()=>{var e,t,i,s;this._context||(this._context={});var r=this.scrollElement(),n=this.scrollY(),o=r?Math.max(0,r.scrollHeight-r.clientHeight):0,a=n+((null==r?void 0:r.clientHeight)||0),l=(null==r?void 0:r.scrollHeight)||0;this._context.lastScrollY=Math.ceil(n),this._context.maxScrollY=Math.max(n,null!==(e=this._context.maxScrollY)&&void 0!==e?e:0),this._context.maxScrollHeight=Math.max(o,null!==(t=this._context.maxScrollHeight)&&void 0!==t?t:0),this._context.lastContentY=a,this._context.maxContentY=Math.max(a,null!==(i=this._context.maxContentY)&&void 0!==i?i:0),this._context.maxContentHeight=Math.max(l,null!==(s=this._context.maxContentHeight)&&void 0!==s?s:0)}}get _scrollRoot(){return this._instance.config.scroll_root_selector}getContext(){return this._context}resetContext(){var e=this._context;return this._context=void 0,setTimeout(this._updateScrollData,0),e}startMeasuringScrollPosition(){ns(ze,"scroll",this._updateScrollData,{capture:!0}),ns(ze,"scrollend",this._updateScrollData,{capture:!0}),ns(ze,"resize",this._updateScrollData)}scrollElement(){var e;if(!this._scrollRoot)return null==ze||null==(e=ze.document)?void 0:e.documentElement;for(var t of ht(this._scrollRoot)?this._scrollRoot:[this._scrollRoot]){var i,s=null==ze||null==(i=ze.document)?void 0:i.querySelector(t);if(s)return s}}_scrollPosition(e){var t,i,s="y"===e?"scrollTop":"scrollLeft";if(this._scrollRoot){var r=this.scrollElement();return r&&r[s]||0}return ze?"y"===e?ze.scrollY||ze.pageYOffset||(null==(t=ze.document)||null==(t=t.documentElement)?void 0:t.scrollTop)||0:ze.scrollX||ze.pageXOffset||(null==(i=ze.document)||null==(i=i.documentElement)?void 0:i.scrollLeft)||0:0}scrollY(){return this._scrollPosition("y")}scrollX(){return this._scrollPosition("x")}},Kn=e=>or(null==e?void 0:e.config.mask_personal_data_properties,null==e?void 0:e.config.custom_personal_data_properties,null==e?void 0:e.config.disable_capture_url_hashes),Jn=class{constructor(e,t,i,s){this._onSessionIdCallback=e=>{var t=this._getStored();if(!t||t.sessionId!==e){var i={sessionId:e,props:this._sessionSourceParamGenerator(this._instance)};this._persistence.register({[ye]:i})}},this._instance=e,this._sessionIdManager=t,this._persistence=i,this._sessionSourceParamGenerator=s||Kn,this._sessionIdManager.onSessionId(this._onSessionIdCallback)}_getStored(){return this._persistence.props[ye]}getSetOnceProps(){var e,t=null==(e=this._getStored())?void 0:e.props;return t?"r"in t?ar(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 Xi(ts(this.getSetOnceProps()),(t,i)=>{"$current_url"===i&&(i="url"),e["$session_entry_"+dt(i)]=t}),e}},Yn=class{on(e,t){return this._events[e]||(this._events[e]=[]),this._events[e].push(t),()=>{this._events[e]=this._events[e].filter(e=>e!==t)}}emit(e,t){for(var i of this._events[e]||[])i(t);for(var s of this._events["*"]||[])s(e,t)}constructor(){this._events={}}},Qn=Yi("[SessionId]"),Xn=864e5,Zn=class{on(e,t){return this._eventEmitter.on(e,t)}constructor(e,t,i){var s;if(this._lastPersistedActivityTimestamp=null,this._lastCookieSyncTimestamp=null,this._sessionIdChangedHandlers=[],this._beforeUnloadListener=void 0,this._destroyed=!1,this._eventEmitter=new Yn,this._sessionHasBeenIdleTooLong=(e,t)=>!(!Pt(e)||!Pt(t))&&Math.abs(e-t)>this.sessionTimeoutMs,!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if("always"===e.config.cookieless_mode)throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this._config=e.config,this._persistence=e.persistence,this._windowId=void 0,this._sessionId=void 0,this._sessionStartTimestamp=null,this._pendingBootstrapSession=void 0,this._sessionActivityTimestamp=null,this._sessionIdGenerator=t||cs,this._windowIdGenerator=i||cs;var r=this._config.persistence_name||this._config.token;if(this._sessionTimeoutMs=1e3*Ot(this._config.session_idle_timeout_seconds||1800,60,36e3,Qn.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this._resetIdleTimer(),this._window_id_storage_key="ph_"+r+"_window_id",this._primary_window_exists_storage_key="ph_"+r+"_primary_window_exists",this._canUseSessionStorage()){var n=Os._parse(this._window_id_storage_key),o=Os._parse(this._primary_window_exists_storage_key);n&&!o?this._windowId=n:Os._remove(this._window_id_storage_key),Os._set(this._primary_window_exists_storage_key,!0)}null!=(s=this._config.bootstrap)&&s.sessionID&&this.setBootstrapSessionId(this._config.bootstrap.sessionID),this._listenToReloadWindow()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return ft(this._sessionIdChangedHandlers)&&(this._sessionIdChangedHandlers=[]),this._sessionIdChangedHandlers.push(e),this._sessionId&&e(this._sessionId,this._windowId),()=>{this._sessionIdChangedHandlers=this._sessionIdChangedHandlers.filter(t=>t!==e)}}_canUseSessionStorage(){return"memory"!==this._config.persistence&&!this._persistence._disabled&&Os._is_supported()}_setWindowId(e){e!==this._windowId&&(this._windowId=e,this._canUseSessionStorage()&&Os._set(this._window_id_storage_key,e))}_getWindowId(){return this._windowId?this._windowId:this._canUseSessionStorage()?Os._parse(this._window_id_storage_key):null}_isActivityChangeBelowGranularity(e){var t=this._lastPersistedActivityTimestamp;return!bt(t)&&!bt(e)&&5e3>Math.abs(e-t)}_setSessionId(e,t,i){var s=t!==this._sessionActivityTimestamp,r=!(e!==this._sessionId||i!==this._sessionStartTimestamp);this._sessionStartTimestamp=i,this._sessionActivityTimestamp=t,this._sessionId=e,r&&!s||r&&this._isActivityChangeBelowGranularity(t)||(this._lastPersistedActivityTimestamp=t,this._persistence.register({[L]:[t,e,i]}))}_useCrossTabRefreshHardening(){var e,t=null==(e=this._config)?void 0:e.persistence_save_debounce_ms;return Pt(t)&&t>0}_refreshSessionIdFromStorage(){this._useCrossTabRefreshHardening()?this._persistence.refreshKey(L):(this._persistence.flush(),this._persistence.load())}_flushPendingActivityTimestamp(){var e;if(!bt(this._sessionActivityTimestamp)&&this._sessionActivityTimestamp!==this._lastPersistedActivityTimestamp){this._refreshSessionIdFromStorage();var t=this._getSessionId();t[1]===this._sessionId&&t[2]===this._sessionStartTimestamp&&(this._lastPersistedActivityTimestamp=this._sessionActivityTimestamp,this._persistence.register({[L]:[this._sessionActivityTimestamp,null!==(e=this._sessionId)&&void 0!==e?e:null,this._sessionStartTimestamp]}),this._persistence.flush())}}_freshestActivityTimestamp(){var e=this._getSessionId()[0],t=Pt(e)?e:0,i=Pt(this._sessionActivityTimestamp)?this._sessionActivityTimestamp:0;return Math.max(t,i)}_isSessionIdleAfterCrossTabRefresh(e){return this._refreshSessionIdFromStorage(),this._sessionHasBeenIdleTooLong(e,this._freshestActivityTimestamp())}_getSessionId(){var e=this._persistence.props[L];return ht(e)&&2===e.length&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this._lastPersistedActivityTimestamp=null,this._pendingBootstrapSession=void 0,clearTimeout(this._enforceIdleTimeout),this._enforceIdleTimeout=void 0,this._setSessionId(null,null,null)}setBootstrapSessionId(e,t){void 0===t&&(t=!1);var i=function(e,t){void 0===t&&(t=(new Date).getTime());try{var i=(e=>{var t=e.replace(/-/g,"");if(32!==t.length)throw new Error("Not a valid UUID");if("7"!==t[12])throw new Error("Not a UUIDv7");return parseInt(t.substring(0,12),16)})(e);return i>t+6e4?void Qn.error("Bootstrap sessionID cannot be in the future"):i}catch(e){return void Qn.error("Invalid sessionID in bootstrap",e)}}(e);return!ft(i)&&(t?this._pendingBootstrapSession={sessionId:e,sessionStartTimestamp:i}:this._setSessionId(e,(new Date).getTime(),i),!0)}destroy(){this._destroyed=!0,this._flushPendingActivityTimestamp(),clearTimeout(this._enforceIdleTimeout),this._enforceIdleTimeout=void 0,this._beforeUnloadListener&&ze&&(ze.removeEventListener(He,this._beforeUnloadListener,{capture:!1}),this._beforeUnloadListener=void 0),this._sessionIdChangedHandlers=[]}_listenToReloadWindow(){this._beforeUnloadListener=()=>{this._flushPendingActivityTimestamp(),this._canUseSessionStorage()&&Os._remove(this._primary_window_exists_storage_key)},ns(ze,He,this._beforeUnloadListener,{capture:!1})}checkAndGetSessionAndWindowId(e,t,i){if(void 0===e&&(e=!1),void 0===t&&(t=null),void 0===i&&(i=!1),"always"===this._config.cookieless_mode)throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var s=t||(new Date).getTime(),r=this._sessionId;if(i)this._lastCookieSyncTimestamp=s;else if(bt(this._lastCookieSyncTimestamp)||this._lastCookieSyncTimestamp>s||s-this._lastCookieSyncTimestamp>=1e3){var n,o;null==(n=(o=this._persistence).syncCookieProperties)||n.call(o),this._lastCookieSyncTimestamp=s}var a=this._getSessionId(),l=a[1],d=a[2],u=!ft(r)&&l!==r,_=this._freshestActivityTimestamp(),c=this._getWindowId(),h=this._pendingBootstrapSession,p=!!h&&(h.sessionStartTimestamp>s+6e4||s-h.sessionStartTimestamp>Xn),g=h?p:Pt(d)&&Math.abs(s-d)>Xn,v=!1,f=u,m=!l||!!h,y=l,b=!m&&!e&&this._sessionHasBeenIdleTooLong(s,_);if(b){(b=this._isSessionIdleAfterCrossTabRefresh(s))||Qn.info("cross-tab refresh kept the session alive",{sessionId:l});var w=this._getSessionId();l=w[1],d=w[2]}if(m||b||g){f=!1;var S=h&&!p;l=S?h.sessionId:this._sessionIdGenerator(),c=this._windowIdGenerator(),Qn.info("new session ID assigned",{sessionId:l,windowId:c,bootstrapped:!!S,changeReason:{noSessionId:m,activityTimeout:b,sessionPastMaximumLength:g}}),d=S?h.sessionStartTimestamp:s,this._pendingBootstrapSession=void 0,v=!0}else c||(c=this._windowIdGenerator(),v=!0),(f=f||l!==y)&&(Qn.info("adopted cross-tab session id",{sessionId:l,windowId:c}),v=!0);var P=Pt(_)&&e&&!g?_:s,x=Pt(d)?d:(new Date).getTime();this._setWindowId(c),this._setSessionId(l,P,x),e||this._resetIdleTimer();var E={noSessionId:m,activityTimeout:b,sessionPastMaximumLength:g,crossTabAdoption:f};return v&&this._sessionIdChangedHandlers.forEach(e=>e(l,c,E)),{sessionId:l,windowId:c,sessionStartTimestamp:x,changeReason:v?E:void 0,lastActivityTimestamp:_}}_resetIdleTimer(){this._destroyed||(clearTimeout(this._enforceIdleTimeout),this._enforceIdleTimeout=setTimeout(()=>{if(!this._destroyed)if(this._isSessionIdleAfterCrossTabRefresh((new Date).getTime())){var e=this._sessionId;this.resetSessionId(),this._eventEmitter.emit("forcedIdleReset",{idleSessionId:e})}else this._resetIdleTimer()},1.1*this.sessionTimeoutMs))}};function eo(){return(eo=r(function*(){var e=null==Je?void 0:Je.userAgentData;if(null!=e&&e.getHighEntropyValues)try{var t,i=null==(t=yield e.getHighEntropyValues(["model"]))?void 0:t.model;return mt(i)&&i.length>0?i:void 0}catch(e){return void Ji.info("Unable to resolve $device_model from userAgentData.getHighEntropyValues",e)}})).apply(this,arguments)}function to(e,t){var i="$survey_"+t+"/"+e.id;return e.current_iteration&&e.current_iteration>0&&(i="$survey_"+t+"/"+e.id+"/"+e.current_iteration),i}function io(e,t,i){return zs({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:i})}var so,ro="custom",no="i.posthog.com",oo=/^\/static\//,ao=["/s/","/e/","/i/"],lo=class{constructor(e){this._regionCache={},this.instance=e}get apiHost(){var e=this.instance.config.api_host.trim().replace(/\/$/,"");return"https://app.posthog.com"===e?"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=null==(e=this.instance.config.ui_host)?void 0:e.replace(/\/$/,"");return t||(t=this.apiHost.replace("."+no,".posthog.com")),"https://app.posthog.com"===t?"https://us.posthog.com":t}get region(){return this._regionCache[this.apiHost]||(this._regionCache[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":ro),this._regionCache[this.apiHost]}_staticAssetHostOverride(e){if(oo.test(e)){var t=this.instance.config.asset_host;if("string"==typeof t)return t.trim().replace(/\/$/,"")||void 0}}_urlKey(e){var t=Ks(e);return t?t.protocol+"//"+t.host+t.pathname:void 0}_prepareEndpoint(e,t,i){if("ui"===e)return i;var s=i,r=this.instance.config.rewriteRequestPath;if(r){var n,o=(null==(n=Ks(i))?void 0:n.href)||i;s=r(new URL(o)).toString()}if(r&&"api"===e&&ao.some(e=>0===t.indexOf(e))){var a=this._urlKey(s);if(a){var l,d=this.apiHost,u=this._ingestionEndpoints;(null==(l=u)?void 0:l.apiHost)===d&&u.rewriteRequestPath===r||(this._ingestionEndpoints=u={apiHost:d,rewriteRequestPath:r,urls:new Set}),u.urls.add(a)}}return s}isIngestionEndpoint(e){var t=this._ingestionEndpoints,i=this._urlKey(e);return(null==t?void 0:t.apiHost)===this.apiHost&&t.rewriteRequestPath===this.instance.config.rewriteRequestPath&&!!i&&t.urls.has(i)}endpointFor(e,t){if(void 0===t&&(t=""),t&&(t="/"===t[0]?t:"/"+t),"ui"===e)return this._prepareEndpoint(e,t,this.uiHost+t);if("flags"===e)return this._prepareEndpoint(e,t,this.flagsApiHost+t);if("assets"===e){var i=this._staticAssetHostOverride(t);if(i)return this._prepareEndpoint(e,t,""+i+t)}if(this.region===ro)return this._prepareEndpoint(e,t,this.apiHost+t);var s=no+t;switch(e){case"assets":return this._prepareEndpoint(e,t,"https://"+this.region+"-assets."+s);case"api":return this._prepareEndpoint(e,t,"https://"+this.region+"."+s)}}},uo=Yi("[Surveys]"),_o={ignoreConditions:!1,ignoreDelay:!1,displayType:Ar.Popover},co=Yi("[PostHog ExternalIntegrations]"),ho={intercom:"intercom-integration",crispChat:"crisp-chat-integration"},po=class{constructor(e){this._instance=e}_loadScript(e,t){var i;null==(i=rt.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,e,e=>{if(e)return co.error("failed to load script",e);t()})}startIfEnabledOrStop(){var e=this,t=function(){var t,s,r,n=i[0],o=i[1];!o||null!=(t=rt.__PosthogExtensions__)&&null!=(t=t.integrations)&&t[n]||e._loadScript(ho[n],()=>{var t;null==(t=rt.__PosthogExtensions__)||null==(t=t.integrations)||null==(t=t[n])||t.start(e._instance)}),!o&&null!=(s=rt.__PosthogExtensions__)&&null!=(s=s.integrations)&&s[n]&&(null==(r=rt.__PosthogExtensions__)||null==(r=r.integrations)||null==(r=r[n])||r.stop())};for(var i of Object.entries(null!==(s=this._instance.config.integrations)&&void 0!==s?s:{})){var s;t()}}},go=class{constructor(e,t){this._logger=e,this._client=t,this._extensions=new Map,this._disposed=!1}add(e){var t=this;return r(function*(){if(t._disposed)throw new Error("Cannot add an extension to a disposed ExtensionRuntime");if(t._extensions.has(e.name))throw new Error('Browser extension "'+e.name+'" is already registered');t._extensions.set(e.name,e);try{var i=e.setup(t._client);i&&(yield i)}catch(i){var s=t._extensions.get(e.name)===e;s&&t._extensions.delete(e.name),t._logger.error('Failed to set up browser extension "'+e.name+'"',i),s&&t._disposeExtension(e)}})()}getExtension(e){return this._extensions.get(e)}dispose(){if(!this._disposed){this._disposed=!0;var e=Array.from(this._extensions.values()).reverse();for(var t of(this._extensions.clear(),e))this._disposeExtension(t)}}_disposeExtension(e){try{var t=null==e.dispose?void 0:e.dispose();t&&pt(t.then)&&t.then(void 0,t=>{this._logger.error('Failed to dispose browser extension "'+e.name+'"',t)})}catch(t){this._logger.error('Failed to dispose browser extension "'+e.name+'"',t)}}},vo=class{constructor(e){this._instance=e}initialize(){}get(e){var t=this._instance.persistence;if("string"==typeof e)return null==t?void 0:t.get_property(e);var i={};for(var s of e){var r=null==t?void 0:t.get_property(s);ft(r)||(i[s]=r)}return i}set(e,t){var i;null==(i=this._instance.persistence)||i.register("string"==typeof e?{[e]:t}:e)}remove(e){var t;null==(t=this._instance.persistence)||t.unregister(e)}},fo="extensionsRemoteConfig",mo=class{constructor(e){this.instance=e,this._disposed=!1,this._logger=Ji,this._latestRemoteConfigResult=e._lastRemoteConfig,this.kv=new vo(e),this.onEvent=e=>Mr(this.instance.on("eventCaptured",t=>{try{e({event:t.event,properties:t.properties})}catch(e){this._logger.error("Browser extension event listener failed",e)}})),this.onRemoteConfig=e=>{if(this._disposed)return Mr(()=>{});var t=t=>{try{e(t)}catch(e){this._logger.error("Browser extension remote config listener failed",e)}},i=this.instance._internalEventEmitter.on(fo,t);return this._latestRemoteConfigResult&&t(this._latestRemoteConfigResult),Mr(i)},this._runtime=new go(Ji.createLogger("[BrowserExtensions]"),this)}get logger(){return this._logger}get distinctId(){return this.instance.get_distinct_id()}get anonymousId(){var e;return null!==(e=this.instance.get_property("$device_id"))&&void 0!==e?e:this.distinctId}get deviceId(){var e=this.instance.get_property(u);return"string"==typeof e?e:void 0}get library(){return{name:a.LIB_NAME,version:a.LIB_VERSION}}get initialPersonProperties(){var e,t;return null!==(e=null==(t=this.instance.persistence)?void 0:t.get_initial_props())&&void 0!==e?e:{}}get groups(){return this.instance.getGroups()}get session(){try{var e,t,i,s,r=null==(e=this.instance.sessionManager)?void 0:e.checkAndGetSessionAndWindowId(!0);return{sessionId:null!==(t=null==r?void 0:r.sessionId)&&void 0!==t?t:"",windowId:null!==(i=null==r?void 0:r.windowId)&&void 0!==i?i:"",sessionStartTimestamp:null!==(s=null==r?void 0:r.sessionStartTimestamp)&&void 0!==s?s:0}}catch(e){return{sessionId:"",windowId:"",sessionStartTimestamp:0}}}get canCapture(){return this.instance.is_capturing()}get projectToken(){return this.instance.config.token}add(e){return this._runtime.add(e)}getExtension(e){return this._runtime.getExtension(e)}capture(e,t,i){var s=this;return r(function*(){i?s.instance.capture(e,t,{timestamp:i.timestamp,uuid:i.uuid,$set:i.set,$set_once:i.setOnce}):s.instance.capture(e,t)})()}registerDynamicEventProperties(e){return Mr(this.instance._registerExtensionEventProperties(e))}handleRemoteConfig(e){this._disposed||(this._latestRemoteConfigResult=e,this.instance._internalEventEmitter.emit(fo,e))}sendRequest(e,t){var i=this;return r(function*(){var s;void 0===t&&(t={});var r=i.instance.requestRouter.endpointFor(null!==(s=t.target)&&void 0!==s?s:"api",e),n={method:t.method,url:t.query?$n(r,t.query):r,data:t.body,headers:t.headers,timeout:t.timeoutMs,fireCallbackOnDrop:!0,transport:t.transport,compression:t.compression,compressionFallback:"flags"===t.target&&"best-available"===t.compression?nt.Base64:void 0,timestampMode:t.sentAt};return"sendBeacon"===t.transport?(i.instance._send_request(n),{statusCode:202}):new Promise(e=>{n.callback=e,i.instance._send_request(n)})})()}dispose(){this._disposed||(this._disposed=!0,this._runtime.dispose())}},yo={},bo=0,wo=()=>{},So='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',Po="Surveys module not available",xo="sanitize_properties is deprecated. Use before_send instead",Eo="Invalid value for property_denylist config: ",Co=/^[A-Za-z0-9_-]{1,400}$/,ko=/^fb\.[0-9]+\.[0-9]+\.[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)?$/,Io=/^fb\.[0-9]+\.[0-9]+\.[0-9]+$/,To=["token","distinct_id",Ce],$o="posthog",Fo=e=>{var t={};return e&&"unset"!==e?("2025-11-30">e||(t.strictMinimumDuration=!0),"2026-05-30">e||(t.canvasCapture={resolutionScale:.6}),"2026-06-25">e||(t.streamNetworkBody=!0),"2026-08-30">e||(t.captureJsonLd=!0),t):t},Ro=e=>{var t;return i({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,asset_host:null,token:"",autocapture:!0,cross_subdomain_cookie:rs(null==Ye?void 0:Ye.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:wo,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:null!=e?e:"unset",__preview_deferred_init_extensions:!1,__preview_external_dependency_versioned_paths:!1,__preview_cookie_wins_on_conflict:!1,debug:Qe&&mt(null==Qe?void 0:Qe.search)&&-1!==Qe.search.indexOf("__posthog_debug=true")||!1,cookie_expiration:365,upgrade:!1,disable_session_recording:!1,disable_persistence:!1,disable_web_experiments:!0,disable_surveys:!1,disable_surveys_automatic_display:!1,disable_conversations:!1,disable_product_tours:!1,disableDeviceModel:!1,reuseAnonymousId:!1,disable_external_dependency_loading:!1,strict_script_versioning:"fallback",enable_recording_console_log:void 0,secure_cookie:"https:"===(null==ze||null==(t=ze.location)?void 0:t.protocol),ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_flags:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_only_evaluate_survey_feature_flags:!1,advanced_feature_flags_dedup_per_session:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,surveys_request_timeout_ms:1e4,on_request_error(e){Ji.error("Bad HTTP status: "+e.statusCode+" "+e.text)},get_device_id:e=>e,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:Ue,before_send:void 0,get_current_url:void 0,request_queue_config:{flush_interval_ms:3e3},error_tracking:{},_onCapture:wo},(e=>({rageclick:e&&e>="2026-05-30"?{content_ignorelist:Ms,ignore_text_selection:!0}:!e||"2025-11-30">e||{content_ignorelist:!0},capture_pageview:!e||"2025-05-24">e||"history_change",session_recording:Fo(e),external_scripts_inject_target:e&&e>="2026-01-30"?"head":"body",internal_or_test_user_hostname:e&&e>="2026-01-30"?/^(localhost|127\.0\.0\.1)$/:void 0,persistence_save_debounce_ms:e&&e>="2026-05-30"?250:0,split_storage:!(!e||"2026-05-30">e),detect_google_search_app:!(!e||"2026-05-30">e),disable_capture_url_hashes:!(!e||"2026-06-25">e),cookieWinsOnConflict:!(!e||"unset"===e||"2026-08-29">e)}))(e))},Oo=[["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"]],Ao=e=>{var t={};for(var i of Oo){var s=i[0],r=i[1];ft(e[s])||(t[r]=e[s])}var n=Zi({},t,e),o=e.__preview_external_dependency_versioned_paths;return ft(o)||(ft(e.strict_script_versioning)&&(n.strict_script_versioning=!!o),mt(o)&&ft(e.asset_host)&&(n.asset_host=o)),ht(e.property_blacklist)&&(ft(e.property_denylist)?n.property_denylist=e.property_blacklist:ht(e.property_denylist)?n.property_denylist=[...e.property_blacklist,...e.property_denylist]:Ji.error(Eo+e.property_denylist)),n},Mo=class{constructor(){this.__forceAllowLocalhost=!1}get _forceAllowLocalhost(){return this.__forceAllowLocalhost}set _forceAllowLocalhost(e){Ji.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}},Do=(e=class e{_removeExtension(e){if(e){var t=this._extensions.indexOf(e);-1!==t&&this._extensions.splice(t,1)}}_replaceExtension(e,t){return this._removeExtension(e),this._extensions.push(t),null==t.initialize||t.initialize(),t}_inCookielessMode(){return"always"===this.config.cookieless_mode||"on_reject"===this.config.cookieless_mode&&this.consent.isRejected()}_warnIfVolatileIdentityWithoutStableId(){if(!(this._hasWarnedAboutVolatileIdentity||this.config.reuseAnonymousId||this.config.segment||this._inCookielessMode())){var e,t,i,s="memory"===this.config.persistence||"sessionStorage"===this.config.persistence;(s||this.config.disable_persistence)&&(this._hasStableInitialDistinctId||(s?(e="persistence is set to '"+this.config.persistence+"'",t="memory"===this.config.persistence?"on every page load":"for every new browser tab or window",i="Either set persistence to 'localStorage+cookie', keep this persistence and pass a stable ID through bootstrap.distinctID, or enable reuseAnonymousId."):(e="persistence is disabled (disable_persistence is true)",t="on every page load",i="Either set disable_persistence to false, keep persistence disabled and pass a stable ID through bootstrap.distinctID, or enable reuseAnonymousId."),this._hasWarnedAboutVolatileIdentity=!0,console.warn("[PostHog.js]",e+" but no bootstrap.distinctID was provided. PostHog will mint a new distinct ID "+t+", so calling identify() merges a new ID onto the person each time. A person can then pass the distinct-ID limit and its events stop appearing on person pages and the session tab. "+i)))}}_healCookielessSentinelDistinctId(){if(!this._inCookielessMode()&&"$posthog_cookieless"===this.get_distinct_id()){var e=this.persistence;if(e){this._is_persistence_disabled()||e.load(!0);var t=this.get_distinct_id();if(!t||"$posthog_cookieless"===t){var i=this.config.get_device_id(cs());this.register({distinct_id:i,$device_id:i}),e.set_property(me,Ne)}this._sync_opt_out_with_persistence()}}}get decideEndpointWasHit(){var e,t;return null!==(e=null==(t=this.featureFlags)?void 0:t.hasLoadedFlags)&&void 0!==e&&e}get flagsEndpointWasHit(){var e,t;return null!==(e=null==(t=this.featureFlags)?void 0:t.hasLoadedFlags)&&void 0!==e&&e}constructor(){var t;this._isPageUnloading=!1,this._isShutdown=!1,this.webPerformance=new Mo,this._personProcessingSetOncePropertiesSent=!1,this.version=a.LIB_VERSION,this._sessionRegisteredPropKeys=new Set,this._sessionRegisteredPropertiesStorageKey="",this._internalEventEmitter=new Yn,this._extensions=[],this._extensionEventPropertyProducers=[],this._hasStableInitialDistinctId=!1,this._hasWarnedAboutVolatileIdentity=!1,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=Ro(),this.SentryIntegration=qs,this.sentryIntegration=e=>function(e,t){var i=Us(e,t);return{name:Bs,processEvent:e=>i(e)}}(this,e),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this._initialPageviewCaptured=!1,this._visibilityStateListener=null,this._initialPersonProfilesConfig=null,this._cachedPersonProperties=null,this.scrollManager=new zn(this),this.pageViewManager=new Hs(this),this.rateLimiter=new Ur(this),this.requestRouter=new lo(this),this.consent=new As(this),this.externalIntegrations=new po(this);var i=null!==(t=e.__defaultExtensionClasses)&&void 0!==t?t:{};this.featureFlags=i.featureFlags&&new i.featureFlags(this),this.toolbar=i.toolbar&&new i.toolbar(this),this.surveys=i.surveys&&new i.surveys(this),this.conversations=i.conversations&&new i.conversations(this),this.logs=i.logs&&new i.logs(this),this.metrics=i.metrics&&new i.metrics(this),this.experiments=i.experiments&&new i.experiments(this),this.exceptions=i.exceptions&&new i.exceptions(this),this.people={set:(e,t,i)=>{var s=mt(e)?{[e]:t}:e;this.setPersonProperties(s),null==i||i({})},set_once:(e,t,i)=>{var s=mt(e)?{[e]:t}:e;this.setPersonProperties(void 0,s),null==i||i({})}},this.on("eventCaptured",e=>Ji.info('send "'+(null==e?void 0:e.event)+'"',e))}init(t,i,s){if(s&&s!==$o){var r,n=null!==(r=yo[s])&&void 0!==r?r:new e;return n._init(t,i,s),yo[s]=n,yo[$o][s]=n,n}return this._init(t,i,s)}_init(e,t,s){var r,n,o;void 0===t&&(t={});var l,d=mt(e)?e.trim():"";if(!d)return Ji.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 d!==(null==(l=this.config)?void 0:l.token)?console.warn("[PostHog.js]","You have already initialized PostHog with a different project token! Re-initializing is a no-op, so events will keep going to the project this instance was initialized with. To capture into a second project, load PostHog once, then initialize a named instance after the SDK has loaded, e.g. posthog.init('"+d+"', { ... }, 'project2')"):console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config=Ro(t.defaults),t.debug=this._checkLocalStorageForDebug(t.debug),this._originalUserConfig=t,this._triggered_notifs=[],t.person_profiles?this._initialPersonProfilesConfig=t.person_profiles:t.process_person&&(this._initialPersonProfilesConfig=t.process_person);var u=Ro(t.defaults),c=Ao(t),h=Zi({},u,c,{name:s,token:d});gt(u.rageclick)&&gt(c.rageclick)&&(h.rageclick=Zi({},u.rageclick,c.rageclick)),gt(u.session_recording)&&gt(c.session_recording)&&(h.session_recording=Zi({},u.session_recording,c.session_recording)),this.set_config(h),this.config.on_xhr_error&&Ji.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=t.disable_compression?void 0:Pr.GZipJS;var p=this._is_persistence_disabled();if(this.persistence=new Sr(this.config,p),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new Sr(i({},this.config,{persistence:"sessionStorage"}),p,!1),this._sessionRegisteredPropertiesStorageKey="ph_"+(this.config.persistence_name||this.config.token)+"_session_registered_properties","memory"!==this.config.persistence&&!p&&Os._is_supported()){var g=Os._parse(this._sessionRegisteredPropertiesStorageKey);ht(g)&&g.forEach(e=>{mt(e)&&this._sessionRegisteredPropKeys.add(e)})}else Os._remove(this._sessionRegisteredPropertiesStorageKey);var v=i({},this.persistence.props),f=i({},this.sessionPersistence.props);this.register({$initialization_time:(new Date).toISOString()}),this._requestQueue=new Vn((e,t)=>this._send_retriable_request(e,t),this.config.request_queue_config),this._retryQueue=new jn(this),this.__request_queue=[];var m=this._inCookielessMode();m||(this.sessionManager=new Zn(this),this.sessionPropsManager=new Jn(this,this.sessionManager,this.persistence),this.sessionManager.onSessionId((e,t,i)=>{(null!=i&&i.activityTimeout||null!=i&&i.sessionPastMaximumLength||null!=i&&i.crossTabAdoption)&&this._clearSessionRegisteredProps()})),this._enrollFeatureFlags(),this.config.__preview_deferred_init_extensions?(Ji.info("Deferring extension initialization to improve startup performance"),setTimeout(()=>{this._initExtensions(m)},0)):(Ji.info("Initializing extensions synchronously"),this._initExtensions(m)),a.DEBUG=a.DEBUG||this.config.debug,a.DEBUG&&Ji.info("Starting in debug mode",{this:this,config:t,thisC:i({},this.config),p:v,s:f}),!this.config.identity_distinct_id||null!=(r=t.bootstrap)&&r.distinctID||(t.bootstrap=i({},t.bootstrap,{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0}));var y=null==(n=t.bootstrap)?void 0:n.distinctID;if(this._hasStableInitialDistinctId=!!y&&!yt(y),null!=(o=t.bootstrap)&&o.distinctID){var b=t.bootstrap.distinctID,w=this.get_distinct_id(),S=this.persistence.get_property(me);if(t.bootstrap.isIdentifiedID&&null!=w&&w!==b&&"anonymous"===S)this.identify(b);else if(t.bootstrap.isIdentifiedID&&null!=w&&w!==b&&"identified"===S)Ji.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 P=this.config.get_device_id(cs()),x=t.bootstrap.isIdentifiedID?P:b;this.persistence.set_property(me,t.bootstrap.isIdentifiedID?Be:Ne),this.register({distinct_id:b,$device_id:x})}}if(m)this.register_once({distinct_id:Ee,$device_id:null},"");else if(!this.get_distinct_id()){var E=this.config.get_device_id(cs());this.register_once({distinct_id:E,$device_id:E},""),this.persistence.set_property(me,Ne)}return ns(ze,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),ns(ze,"pageshow",()=>{var e;this._isPageUnloading=!1,this._isShutdown||null==(e=this._retryQueue)||e.resume()}),t.segment?Ns(this,()=>this._loaded()):this._loaded(),pt(this.config._onCapture)&&this.config._onCapture!==wo&&(Ji.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",e=>this.config._onCapture(e.event,e))),this.config.ip&&Ji.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 eo.apply(this,arguments)}().then(e=>{e&&this.register({[_]:e})}).catch(wo),this}_isSharedExtension(e){var t=e;return mt(t.name)&&pt(t.setup)}_enrollExtension(e,t){this._isSharedExtension(e)?t.push(()=>{this._getBrowserClientAdapter().add(e).catch(()=>null==e.dispose?void 0:e.dispose()).catch(t=>{Ji.error('Failed to dispose browser extension "'+e.name+'"',t)})}):this._extensions.push(e)}_enrollFeatureFlags(){var t,i,s,r,n,o,a=null!==(t=null==(i=this.config.__extensionClasses)?void 0:i.featureFlags)&&void 0!==t?t:null==(s=e.__defaultExtensionClasses)?void 0:s.featureFlags;a&&(this.featureFlags&&this.featureFlags instanceof a||(null==(o=this._featureFlagsReloadingUnsubscribe)||o.call(this),this._featureFlagsReloadingUnsubscribe=void 0,this.featureFlags=new a(this)),pt(this.featureFlags.onReloading)&&pt(this.featureFlags.setup)?this._featureFlagsReloadingUnsubscribe||(this._featureFlagsReloadingUnsubscribe=this.featureFlags.onReloading(()=>{this._internalEventEmitter.emit("featureFlagsReloading",!0)}),this._getBrowserClientAdapter().add(this.featureFlags)):null==(r=(n=this.featureFlags).initialize)||r.call(n))}_initExtensions(t){var s,r,n,o,a,l,d,u=performance.now(),_=i({},e.__defaultExtensionClasses,this.config.__extensionClasses),c=[];_.exceptions&&this._extensions.push(this.exceptions=null!==(s=this.exceptions)&&void 0!==s?s:new _.exceptions(this)),_.historyAutocapture&&this._extensions.push(this.historyAutocapture=new _.historyAutocapture(this)),_.tracingHeaders&&this._extensions.push(this.tracingHeaders=new _.tracingHeaders(this)),_.siteApps&&this._extensions.push(this.siteApps=new _.siteApps(this)),_.sessionRecording&&!t&&this._extensions.push(this.sessionRecording=new _.sessionRecording(this)),this.config.disable_scroll_properties||c.push(()=>{this.scrollManager.startMeasuringScrollPosition()}),_.autocapture&&this._enrollExtension(this.autocapture=new _.autocapture(this),c),_.surveys&&this._enrollExtension(this.surveys=null!==(r=this.surveys)&&void 0!==r?r:new _.surveys(this),c),_.logs&&this._enrollExtension(this.logs=null!==(n=this.logs)&&void 0!==n?n:new _.logs(this),c),_.metrics&&this._extensions.push(this.metrics=null!==(o=this.metrics)&&void 0!==o?o:new _.metrics(this)),_.conversations&&this._extensions.push(this.conversations=null!==(a=this.conversations)&&void 0!==a?a:new _.conversations(this)),_.productTours&&this._extensions.push(this.productTours=new _.productTours(this)),_.heatmaps&&this._extensions.push(this.heatmaps=new _.heatmaps(this)),_.webVitalsAutocapture&&this._extensions.push(this.webVitalsAutocapture=new _.webVitalsAutocapture(this)),_.exceptionObserver&&this._extensions.push(this.exceptionObserver=new _.exceptionObserver(this)),_.deadClicksAutocapture&&this._extensions.push(this.deadClicksAutocapture=new _.deadClicksAutocapture(this,Ds)),_.toolbar&&this._extensions.push(this.toolbar=null!==(l=this.toolbar)&&void 0!==l?l:new _.toolbar(this)),_.experiments&&this._extensions.push(this.experiments=null!==(d=this.experiments)&&void 0!==d?d:new _.experiments(this)),this._extensions.forEach(e=>{e.initialize&&c.push(()=>{null==e.initialize||e.initialize()})}),c.push(()=>{if(this._pendingRemoteConfig){var e=this._pendingRemoteConfig;this._pendingRemoteConfig=void 0,this._extensions.forEach(t=>null==t.onRemoteConfig?void 0:t.onRemoteConfig(e))}}),this._processInitTaskQueue(c,u)}_processInitTaskQueue(e,t){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-t>=30&&e.length>0)return void setTimeout(()=>{this._processInitTaskQueue(e,t)},0);var i=e.shift();if(i)try{i()}catch(e){Ji.error("Error initializing extension:",e)}}var s=Math.round(performance.now()-t);this.register_for_session({[ke]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[Ie]:s}),this.config.__preview_deferred_init_extensions&&Ji.info("PostHog extensions initialized ("+s+"ms)")}_onRemoteConfig(e){var t;if(!Ye||!Ye.body)return Ji.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout(()=>{this._onRemoteConfig(e)},500);if(this.config.__preview_deferred_init_extensions&&(this._pendingRemoteConfig=e),this._lastRemoteConfig=e,this.compression=void 0,e.ok){var i,s=e.config;s.supportedCompression&&!this.config.disable_compression&&(this.compression=lt(s.supportedCompression,Pr.GZipJS)?Pr.GZipJS:lt(s.supportedCompression,Pr.Base64)?Pr.Base64:void 0),null!=(i=s.analytics)&&i.endpoint&&(this.analyticsDefaultEndpoint=s.analytics.endpoint)}this.set_config({person_profiles:this._initialPersonProfilesConfig?this._initialPersonProfilesConfig:Ue}),null==(t=this._browserClientAdapter)||t.handleRemoteConfig(e),this._extensions.forEach(t=>null==t.onRemoteConfig?void 0:t.onRemoteConfig(e))}_loaded(){try{this.config.loaded(this)}catch(e){Ji.critical("`loaded` function failed",e)}if(this._start_queue_if_opted_in(),this.config.internal_or_test_user_hostname&&null!=Qe&&Qe.hostname){var e=Qe.hostname,t=this.config.internal_or_test_user_hostname;("string"==typeof t?e===t:t.test(e))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout(()=>{(this.consent.isOptedIn()||this._inCookielessMode())&&this._captureInitialPageview()},1),this._remoteConfigLoader=new Hr(this),this._remoteConfigLoader.load()}_start_queue_if_opted_in(){var e;this.is_capturing()&&this.config.request_batching&&(null==(e=this._requestQueue)||e.enable())}_dom_loaded(){this.is_capturing()&&Qi(this.__request_queue,e=>this._send_retriable_request(e)),this.__request_queue=[],this._start_queue_if_opted_in()}_handle_unload(){var e,t,i,s,r;this._isPageUnloading=!0,null==(e=this.surveys)||null==e.handlePageUnload||e.handlePageUnload(),null==(t=this.metrics)||t.flush("sendBeacon"),this.config.request_batching?(this._shouldCapturePageleave()&&this.capture(We),null==(i=this.logs)||i.flushLogs("sendBeacon"),null==(s=this._requestQueue)||s.unload(),null==(r=this._retryQueue)||r.unload()):this._shouldCapturePageleave()&&this.capture(We,null,{transport:"sendBeacon"})}_send_request(e){Wn(this,e)}_send_retriable_request(e,t){this._retryQueue?this._retryQueue.retriableRequest(e,t):this._send_request(t?i({},e,{transport:t}):e)}_execute_array(e){bo++;try{var t,i=[],s=[],r=[];Qi(e,e=>{if(e)if(ht(t=e[0]))r.push(e);else if(pt(e))try{e.call(this)}catch(t){Ji.error("Error executing queued PostHog call",e,t)}else ht(e)&&"alias"===t?i.push(e):ht(e)&&-1!==t.indexOf("capture")&&pt(this[t])?r.push(e):s.push(e)});var n=function(e,t){Qi(e,function(e){try{if(ht(e[0])){var i=t;Xi(e,function(e){i=i[e[0]].apply(i,e.slice(1))})}else t[e[0]].apply(t,e.slice(1))}catch(t){Ji.error("Error executing queued PostHog call",e,t)}})};n(i,this),n(s,this),n(r,this)}finally{bo--}}push(t){if(bo>0&&ht(t)&&mt(t[0])){var i=e.prototype[t[0]];pt(i)&&i.apply(this,t.slice(1))}else this._execute_array([t])}get _facebookClickIdChannel(){return{property:p,persistenceKey:g,cookieName:"_fbc",pattern:ko,register:(e,t)=>{var i;return null==(i=this.persistence)?void 0:i.register({[g]:{value:e,delivered:t}})},unregister:()=>{var e;return null==(e=this.persistence)?void 0:e.unregister(g)}}}get _facebookBrowserIdChannel(){return{property:v,persistenceKey:f,cookieName:"_fbp",pattern:Io,register:(e,t)=>{var i;return null==(i=this.persistence)?void 0:i.register({[f]:{value:e,delivered:t}})},unregister:()=>{var e;return null==(e=this.persistence)?void 0:e.unregister(f)}}}_getPersistedMetaIdentifier(e){var t,i=null==(t=this.persistence)?void 0:t.get_property(e.persistenceKey);return mt(i)&&e.pattern.test(i)?{value:i,delivered:!1}:gt(i)&&mt(i.value)&&e.pattern.test(i.value)?{value:i.value,delivered:!0===i.delivered}:void 0}_storeMetaIdentifier(e,t,i){return t===(null==i?void 0:i.value)?{value:t,pending:!i.delivered}:(e.register(t,!1),{value:t,pending:!0})}_readMetaCookie(e){if(this.config.save_campaign_params&&!this._inCookielessMode()){var t=os(e.cookieName);return mt(t)&&e.pattern.test(t)?t:void 0}}_updateFacebookClickId(e,t,i,s){if(this.persistence){var r=this._facebookClickIdChannel;this.persistence.refreshKey(r.persistenceKey);var n=this._getPersistedMetaIdentifier(r);if(!s){if(i)return mt(t)&&ko.test(t)?this._storeMetaIdentifier(r,t,n):void r.unregister();var o=mt(e)&&Co.test(e)?e:void 0,a=this._readMetaCookie(r);return a&&((e,t,i)=>{var s=e.split(".");if(t)return s[3]===t;if(!i)return!0;var r=i.value.split(".");return s[3]===r[3]||Number(s[2])>Number(r[2])})(a,o,n)?this._storeMetaIdentifier(r,a,n):o?(null==n?void 0:n.value.split(".")[3])===o?{value:n.value,pending:!n.delivered}:this._storeMetaIdentifier(r,"fb.1."+Date.now()+"."+o,n):n?{value:n.value,pending:!n.delivered}:void 0}r.unregister()}}_updateFacebookBrowserId(e,t,i){if(this.persistence){var s=this._facebookBrowserIdChannel;this.persistence.refreshKey(s.persistenceKey);var r=this._getPersistedMetaIdentifier(s);if(!i){if(t)return mt(e)&&Io.test(e)?this._storeMetaIdentifier(s,e,r):void s.unregister();var n=this._readMetaCookie(s);return n?this._storeMetaIdentifier(s,n,r):r?{value:r.value,pending:!r.delivered}:void 0}s.unregister()}}_markMetaIdentifierDelivered(e,t){if(this.persistence){this.persistence.refreshKey(e.persistenceKey);var i=this._getPersistedMetaIdentifier(e);(null==i?void 0:i.value)!==t||i.delivered||e.register(t,!0)}}capture(e,t,s){var r,n,o,a,l,d,u;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this._requestQueue){if(this.is_capturing())if(!ft(e)&&mt(e)){this._healCookielessSentinelDistinctId();var _=!this.config.opt_out_useragent_filter&&this._is_bot();if(!_||this.config.__preview_capture_bot_pageviews){var c=null!=s&&s.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(null==c||!c.isRateLimited){var h;null!=t&&t.$current_url&&!mt(null==t?void 0:t.$current_url)&&(Ji.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),null==t||delete t.$current_url),"$exception"!==e||null!=s&&s._originatedFromCaptureException||Ji.warn("Using `posthog.capture('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureException(error)` instead, which attaches required metadata automatically."),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&(h=this.sessionPersistence.update_campaign_params()),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();var g=new Date,f=(null==s?void 0:s.timestamp)||g,m=Di(null==s?void 0:s.uuid,cs),y={uuid:m,event:e,properties:this.calculateEventProperties(e,t||{},f,m)};"$pageview"===e&&this.config.__preview_capture_bot_pageviews&&_&&(y.event="$bot_pageview",y.properties.$browser_type="bot"),c&&(y.properties.$lib_rate_limit_remaining_tokens=c.remainingTokens);var b="$feature_flag_called"===e&&!1===y.properties.$feature_flag_has_experiment&&!0===this.get_property("$minimal_flag_called_events");null!=s&&s.$set&&!b&&(y.$set=null==s?void 0:s.$set);var w=gt(null==t?void 0:t.$set)?t.$set:void 0,S=ht(null==t?void 0:t.$unset)?t.$unset:[],P=(null==s?void 0:s.$unset)||[],x=e=>{var t,i=!(null==s||!s.$set)&&e in s.$set;return{hasProvided:i||!!w&&e in w,provided:i?null==s||null==(t=s.$set)?void 0:t[e]:null==w?void 0:w[e],unset:-1!==S.indexOf(e)||-1!==P.indexOf(e)}},E=x(p),C=x(v),k=[{channel:this._facebookClickIdChannel,hasProvided:E.hasProvided,update:this._updateFacebookClickId(null==(r=h)?void 0:r.fbclid,E.provided,E.hasProvided,E.unset)},{channel:this._facebookBrowserIdChannel,hasProvided:C.hasProvided,update:this._updateFacebookBrowserId(C.provided,C.hasProvided,C.unset)}];for(var I of k){var T=I.channel,F=I.update;F&&!0===y.properties.$process_person_profile&&F.pending&&!I.hasProvided&&!b&&(y.$set=i({[T.property]:F.value},y.$set))}var R=null==s?void 0:s.$unset;R&&(y.$unset=R);var O=b?void 0:this._calculate_set_once_properties(null==s?void 0:s.$set_once,e!==je,e===Ve);if(O&&(y.$set_once=O),null!=s&&s._noTruncate||(a=this.config.properties_string_max_length,l=y,d=e=>mt(e)?e.slice(0,a):e,u=new Set,y=function e(t,i){if(t!==Object(t))return d?d(t):t;if(!u.has(t)){var s;if(u.add(t),ht(t))s=[],Qi(t,t=>{s.push(e(t))});else{var r={};Xi(kt(t)?is(t):t,(t,i)=>{u.has(t)||(r[i]=e(t,i))}),s=r}return s}}(l)),y.timestamp=f,ft(null==s?void 0:s.timestamp)||(y.properties.$event_time_override_provided=!0,y.properties.$event_time_override_system_time=g),b&&(y.properties=function(e,t){void 0===t&&(t=[]);var i={},s=t=>{void 0!==e[t]&&(i[t]=e[t])};return Ui.forEach(s),t.forEach(s),i}(y.properties,To)),e===Rr.DISMISSED||e===Rr.SENT){var A=null==t?void 0:t[Or.SURVEY_ID],M=null==t?void 0:t[Or.SURVEY_ITERATION];(e=>{try{var t=(e=>((e,t)=>"seenSurvey_"+function(e){return e.current_iteration&&e.current_iteration>0?e.id+"_"+e.current_iteration:e.id}(t))(0,e))(e);if(localStorage.getItem(t))return;localStorage.setItem(t,"true")}catch(e){uo.error("Failed to persist survey seen state",e)}})({id:A,current_iteration:M}),y.$set=i({},y.$set,{[to({id:A,current_iteration:M},e===Rr.SENT?"responded":"dismissed")]:!0})}else e===Rr.SHOWN&&(y.$set=i({},y.$set,{[Or.SURVEY_LAST_SEEN_DATE]:(new Date).toISOString()}));if(e===Lr.SHOWN){var D=null==t?void 0:t[Nr.TOUR_TYPE];D&&(y.$set=i({},y.$set,{[Nr.TOUR_LAST_SEEN_DATE+"/"+D]:(new Date).toISOString()}))}var L=i({},y.properties.$set,y.$set);if(vt(L)||this.setPersonPropertiesForFlags(L),!wt(this.config.before_send)){var N=this._runBeforeSend(y);if(!N)return;(y=N).uuid=Di(y.uuid,cs)}var B=k.filter(e=>{var t,i,s,r=e.channel,n=e.update,o=null!==(t=null==(i=y.$set)?void 0:i[r.property])&&void 0!==t?t:gt(null==(s=y.properties)?void 0:s.$set)?y.properties.$set[r.property]:void 0;return(null==n?void 0:n.pending)&&o===n.value});this._internalEventEmitter.emit("eventCaptured",y);var U,q,H=null!==(n=null==s?void 0:s._url)&&void 0!==n?n:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),G="recordings"===(null==s?void 0:s._batchKey)||/\/s\/(?:\?|$)/.test(H),W=i({method:"POST",url:H,data:y,compression:"best-available",timestampMode:G?"body":"capture-body",batchKey:null==s?void 0:s._batchKey},G&&null!=(o=y.properties)&&o.$session_id?{batchGroup:y.properties.$session_id+(y.properties.$window_id?"-"+y.properties.$window_id:"")}:{},null!=s&&s.transport?{transport:s.transport}:{},B.length?{fireCallbackOnDrop:!0,callback:e=>{if(e.statusCode>=200&&300>e.statusCode)for(var t of B)this._markMetaIdentifierDelivered(t.channel,t.update.value)}}:{});return!this.config.request_batching||s&&(null==s||!s._batchKey)||null!=s&&s.send_instantly||B.length?(!W.transport&&!W.callback&&vt(null!==(U=this.config.request_headers)&&void 0!==U?U:{})&&this._isPageUnloading&&(q="sendBeacon"),this._send_retriable_request(W,q)):this._requestQueue.enqueue(W),y}Ji.critical("This capture call is ignored due to client rate limiting.")}}else Ji.error("No event name provided to posthog.capture")}else Ji.uninitializedWarning("posthog.capture")}_addCaptureHook(e){return this.on("eventCaptured",t=>e(t.event,t))}getExtension(e){var t;return null==(t=this._browserClientAdapter)?void 0:t.getExtension(e)}_getBrowserClientAdapter(){var e;return null!==(e=this._browserClientAdapter)&&void 0!==e?e:this._browserClientAdapter=new mo(this)}_registerExtensionEventProperties(e){this._extensionEventPropertyProducers.push(e);var t=!0;return()=>{if(t){t=!1;var i=this._extensionEventPropertyProducers.indexOf(e);-1!==i&&this._extensionEventPropertyProducers.splice(i,1)}}}_processCookieIdentityChange(e){var t,i,s;return void 0===e&&(e=!0),!(null==(t=this.persistence)||!t.consumeCookieIdentityChange())&&(this._cachedPersonProperties=null,"anonymous"===this.persistence.get_property("$user_state")&&(null==(s=this.sessionPersistence)||s.clear(),this._sessionRegisteredPropKeys.clear(),this._persistSessionRegisteredPropKeys()),null==(i=this.featureFlags)||i.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._processCookieIdentityChange();var a=n?void 0:this.persistence.remove_event_timer(e),l=i({},t);if(l.token=this.config.token,l.$config_defaults=this.config.defaults,this._inCookielessMode()&&(l[Ce]=!0),"$snapshot"===e){var d=i({},this.persistence.properties(),this.sessionPersistence.properties());return l.distinct_id=d.distinct_id,(!mt(l.distinct_id)&&!St(l.distinct_id)||yt(l.distinct_id))&&Ji.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),l}var u,_=function(e,t,i,s){var r,n,a,l;if(void 0===s&&(s=!1),!it)return{};var d,u=e?[...Qs,...t||[]]:[],_=function(e){for(var t=0;Fi.length>t;t++){var i=Fi[t],s=i[1],r=i[0].exec(e),n=r&&(pt(s)?s(r,e):s);if(n)return n}return["",""]}(it),c=_[0],h=_[1],p=function(e){for(var t=0;Ai.length>t;t++){var i,s=Ai[t],r=s[1],n=s[2],o=e.match(s[0]);if(o)return[r,(null==(i=n&&e.match(n)||o)?void 0:i[1])||""]}return["",""]}(it),g=p[0],v=p[1],f=null!=(d="u">typeof navigator?navigator:void 0)&&d.brave?{brave:!0}:{},m={};ft(i)||(m.detectGoogleSearchApp=i);var y={},b=null==(r=navigator)||null==(r=r.userAgentData)?void 0:r.platform,w=null==(n=navigator)?void 0:n.maxTouchPoints,S=null==ze||null==(a=ze.screen)?void 0:a.width,P=null==ze||null==(l=ze.screen)?void 0:l.height,x=null==ze?void 0:ze.devicePixelRatio;ft(b)||(y.userAgentDataPlatform=b),ft(w)||(y.maxTouchPoints=w),ft(S)||(y.screenWidth=S),ft(P)||(y.screenHeight=P),ft(x)||(y.devicePixelRatio=x);var E,C,k,I,T,F,R,O,A=Zi(ts({$os:c,$os_version:h,$browser:Ii(it,navigator.vendor,f,m),$webview_app:g,$webview_app_version:v,$device:Ri(it),$device_type:(C=it,k=y,O=Ri(C),O===Nt||O===Lt||"Kobo"===O||"Kindle Fire"===O||O===ai?Dt:O===Qt||O===Zt||O===Xt||O===ni?"Console":O===Bt?"Wearable":O?At:"Android"===(null==k?void 0:k.userAgentDataPlatform)&&(null!==(I=null==k?void 0:k.maxTouchPoints)&&void 0!==I?I:0)>0?600>Math.min(null!==(T=null==k?void 0:k.screenWidth)&&void 0!==T?T:0,null!==(F=null==k?void 0:k.screenHeight)&&void 0!==F?F:0)/(null!==(R=null==k?void 0:k.devicePixelRatio)&&void 0!==R?R:1)?At:Dt:"Desktop"),$timezone:lr(),$timezone_offset:dr()}),{$current_url:Ys(s?Ni(null==Qe?void 0:Qe.href):null==Qe?void 0:Qe.href,u,Zs),$host:null==Qe?void 0:Qe.host,$pathname:null==Qe?void 0:Qe.pathname,$raw_user_agent:it.length>1e3?it.substring(0,997)+"...":it,$browser_version:$i(it,navigator.vendor,f,m),$browser_language:sr(),$browser_language_prefix:(E=sr(),"string"==typeof E?E.split("-")[0]:void 0),$screen_height:null==ze?void 0:ze.screen.height,$screen_width:null==ze?void 0:ze.screen.width,$viewport_height:null==ze?void 0:ze.innerHeight,$viewport_width:null==ze?void 0:ze.innerWidth,$lib:o.LIB_NAME,$lib_version:o.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3});return o.SDK_DIST_CHANNEL&&(A.$sdk_dist_channel=o.SDK_DIST_CHANNEL),A}(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),h=c.windowId;l.$session_id=c.sessionId,l.$window_id=h}this.sessionPropsManager&&Zi(l,this.sessionPropsManager.getSessionProps());try{var p;this.sessionRecording&&Zi(l,this.sessionRecording.sdkDebugProperties),l.$sdk_debug_retry_queue_size=null==(p=this._retryQueue)?void 0:p.length}catch(e){l.$sdk_debug_error_capturing_properties=String(e)}if(this.requestRouter.region===ro&&(l.$lib_custom_api_host=this.config.api_host),u="$pageview"!==e||n?"$pageleave"!==e||n?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(s):this.pageViewManager.doPageView(s,r),l=Zi(l,u),"$pageview"===e&&Ye&&(l.title=Ye.title),!ft(a)){var g=s.getTime()-a;l.$duration=parseFloat((g/1e3).toFixed(3))}it&&this.config.opt_out_useragent_filter&&(l.$browser_type=this._is_bot()?"bot":"browser");var v=this.persistence.properties(),f=this.sessionPersistence.properties(),m=l.$groups,y=v.$groups;gt(m)&&!vt(m)&&(l.$groups=i({},gt(y)?y:{},m)),Xi(["$referrer","$referring_domain"],e=>{e in v&&delete f[e]});var b={};if(this._extensionEventPropertyProducers.length>0)for(var w of this._extensionEventPropertyProducers.slice())try{Zi(b,w())}catch(e){Ji.error("Failed to produce browser extension event properties",e)}(l=Zi({},_,v,f,i({},b,l))).$is_identified=this._isIdentified(),ht(this.config.property_denylist)?Xi(this.config.property_denylist,function(e){delete l[e]}):Ji.error(Eo+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var S=this.config.sanitize_properties;S&&(Ji.error(xo),l=S(l,e));var P=this._hasPersonProcessing();return l.$process_person_profile=P,P&&!n&&this._requirePersonProcessing("_calculate_event_properties"),l}_calculate_set_once_properties(e,t,i){var s;if(void 0===t&&(t=!0),void 0===i&&(i=!1),!this.persistence||!this._hasPersonProcessing())return e;if(this._personProcessingSetOncePropertiesSent&&!i)return e;var r=Zi({},this.persistence.get_initial_props(),(null==(s=this.sessionPropsManager)?void 0:s.getSetOnceProps())||{},e||{}),n=this.config.sanitize_properties;return n&&(Ji.error(xo),r=n(r,"$set_once")),t&&(this._personProcessingSetOncePropertiesSent=!0),vt(r)?void 0:r}register(e,t){var i;null==(i=this.persistence)||i.register(e,t)}register_once(e,t,i){var s;null==(s=this.persistence)||s.register_once(e,t,i)}register_for_session(e){var t,i;null==(t=this.persistence)||t.syncCookieProperties(),this._processCookieIdentityChange(),null==(i=this.sessionPersistence)||i.register(e),Object.keys(e).forEach(e=>this._sessionRegisteredPropKeys.add(e)),this._persistSessionRegisteredPropKeys()}unregister(e){var t;null==(t=this.persistence)||t.unregister(e)}unregister_for_session(e){var t;null==(t=this.sessionPersistence)||t.unregister(e),this._sessionRegisteredPropKeys.delete(e),this._persistSessionRegisteredPropKeys()}_register_single(e,t){this.register({[e]:t})}_clearSessionRegisteredProps(){this._sessionRegisteredPropKeys.forEach(e=>{var t;null==(t=this.sessionPersistence)||t.unregister(e)}),this._sessionRegisteredPropKeys.clear(),this._persistSessionRegisteredPropKeys()}_persistSessionRegisteredPropKeys(){var e;if(this._sessionRegisteredPropertiesStorageKey)if("memory"===this.config.persistence||null!=(e=this.sessionPersistence)&&e._disabled||!Os._is_supported())Os._remove(this._sessionRegisteredPropertiesStorageKey);else{var t=[];this._sessionRegisteredPropKeys.forEach(e=>t.push(e)),t.length>0?Os._set(this._sessionRegisteredPropertiesStorageKey,t):Os._remove(this._sessionRegisteredPropertiesStorageKey)}}getFeatureFlag(e,t){var i;return null==(i=this.featureFlags)?void 0:i.getFeatureFlag(e,t)}getFeatureFlagPayload(e){var t;return null==(t=this.featureFlags)?void 0:t.getFeatureFlagPayload(e)}getFeatureFlagResult(e,t){var i;return null==(i=this.featureFlags)?void 0:i.getFeatureFlagResult(e,t)}getAllFeatureFlags(){var e,t;return null!==(e=null==(t=this.featureFlags)?void 0:t.getAllFeatureFlags())&&void 0!==e?e:[]}isFeatureEnabled(e,t){var i,s;return null!==(i=null==(s=this.featureFlags)?void 0:s.isFeatureEnabled(e,t))&&void 0!==i?i:null==t?void 0:t.defaultValue}reloadFeatureFlags(){var e;null==(e=this.featureFlags)||e.reloadFeatureFlags()}updateFlags(e,t,i){var s;null==(s=this.featureFlags)||s.updateFlags(e,t,i)}updateEarlyAccessFeatureEnrollment(e,t,i){var s;null==(s=this.featureFlags)||s.updateEarlyAccessFeatureEnrollment(e,t,i)}getEarlyAccessFeatures(e,t,i){var s;return void 0===t&&(t=!1),null==(s=this.featureFlags)?void 0:s.getEarlyAccessFeatures(e,t,i)}on(e,t){return this._internalEventEmitter.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:Po}),()=>{})}onSessionId(e){var t,i;return null!==(t=null==(i=this.sessionManager)?void 0:i.onSessionId(e))&&void 0!==t?t:()=>{}}getSurveys(e,t){void 0===t&&(t=!1),this.surveys?this.surveys.getSurveys(e,t):e([],{isLoaded:!1,error:Po})}getActiveMatchingSurveys(e,t){void 0===t&&(t=!1),this.surveys?this.surveys.getActiveMatchingSurveys(e,t):e([],{isLoaded:!1,error:Po})}renderSurvey(e,t){var i;null==(i=this.surveys)||i.renderSurvey(e,t)}displaySurvey(e,t){var i;void 0===t&&(t=_o),null==(i=this.surveys)||i.displaySurvey(e,t)}cancelPendingSurvey(e){var t;null==(t=this.surveys)||t.cancelPendingSurvey(e)}canRenderSurvey(e){var t,i;return null!==(t=null==(i=this.surveys)?void 0:i.canRenderSurvey(e))&&void 0!==t?t:{visible:!1,disabledReason:Po}}canRenderSurveyAsync(e,t){var i,s;return void 0===t&&(t=!1),null!==(i=null==(s=this.surveys)?void 0:s.canRenderSurveyAsync(e,t))&&void 0!==i?i:Promise.resolve({visible:!1,disabledReason:Po})}_validateIdentifyId(e){return!e||yt(e)?(Ji.critical("Unique user id has not been set in posthog.identify"),!1):"$posthog_cookieless"===e?(Ji.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())||(Ji.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,i){if(!this.__loaded||!this.persistence)return Ji.uninitializedWarning("posthog.identify");if(St(e)&&(e=e.toString(),Ji.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),this._validateIdentifyId(e)&&this._requirePersonProcessing("posthog.identify")){this._healCookielessSentinelDistinctId();var s=this.get_distinct_id(),r=this.persistence.syncCookieProperties()&&this.get_distinct_id()!==s,n=this._processCookieIdentityChange(!1),o=this.persistence._beginCookieSyncSuppression(),a=!1;try{var l=this.get_distinct_id();this.register({$user_id:e}),this.get_property("$device_id")||this.register_once({$had_persisted_distinct_id:!0,$device_id:l},""),e!==l&&e!==this.get_property("__alias")&&(this.unregister(c),this.register({distinct_id:e}));var d=(this.persistence.get_property("$user_state")||"anonymous")===Ne,u=e!==l,_=!u&&d;if(u&&d){var h,p=this.config.reuseAnonymousId?{distinct_id:e}:{distinct_id:e,$anon_distinct_id:l};this.persistence.set_property(me,Be),this.setPersonPropertiesForFlags({$set:t||{},$set_once:i||{}},!1),this.config.cookieWinsOnConflict&&this.persistence._publishSuppressedCookieSnapshot(),this.capture("$identify",p,{$set:t||{},$set_once:i||{}})&&(this._cachedPersonProperties=io(e,t,i)),null==(h=this.featureFlags)||h.setAnonymousDistinctId(this.config.reuseAnonymousId?void 0:l)}else if(_){this.persistence.set_property(me,Be);var g=t||{},v=i||{};this.setPersonPropertiesForFlags({$set:g,$set_once:v},!1),this.config.cookieWinsOnConflict&&this.persistence._publishSuppressedCookieSnapshot(),this.capture("$set",{$set:g,$set_once:v})&&(this._cachedPersonProperties=io(e,t,i))}else(t||i)&&this.setPersonProperties(t,i);u||r||n?(this.reloadFeatureFlags(),this.featureFlags?this.featureFlags.resetFlagCallReported():this.unregister(pe)):_&&(t||i)&&this.reloadFeatureFlags(),a=!0}finally{o&&this.persistence._endCookieSyncSuppression(a)}}}setPersonProperties(e,t){if((e||t)&&this._requirePersonProcessing("posthog.setPersonProperties")){var i=io(this.get_distinct_id(),e,t);this._cachedPersonProperties!==i?(this.setPersonPropertiesForFlags({$set:e||{},$set_once:t||{}},!0),this.capture("$set",{$set:e||{},$set_once:t||{}})&&(this._cachedPersonProperties=i)):Ji.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}unsetPersonProperties(e){var t,i=(ht(e)?e:[e]).filter(e=>mt(e)&&e.length>0);0!==i.length&&this._requirePersonProcessing("posthog.unsetPersonProperties")&&(null==(t=this.featureFlags)||t.unsetPersonPropertiesForFlags(i,!0),this.capture("$set",{$unset:i}),this._cachedPersonProperties=null)}group(e,t,s){var r;if(e&&t){null==(r=this.persistence)||r.syncCookieProperties(),this._processCookieIdentityChange();var n=this.getGroups(),o=n[e]!==t;if(o&&this.resetGroupPropertiesForFlags(e),this.register({$groups:i({},n,{[e]:t})}),(o||s)&&this._hasPersonProcessing()){var a={$group_type:e,$group_key:t};s&&(a.$group_set=s),this.capture(je,a)}s&&this.setGroupPropertiesForFlags({[e]:s}),o&&!s&&this.reloadFeatureFlags()}else Ji.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,t){var i;void 0===t&&(t=!0),null==(i=this.featureFlags)||i.setPersonPropertiesForFlags(e,t)}resetPersonPropertiesForFlags(e){var t;void 0===e&&(e=!0),null==(t=this.featureFlags)||t.resetPersonPropertiesForFlags(e)}setGroupPropertiesForFlags(e,t){var i;void 0===t&&(t=!0),this._requirePersonProcessing("posthog.setGroupPropertiesForFlags")&&(null==(i=this.featureFlags)||i.setGroupPropertiesForFlags(e,t))}resetGroupPropertiesForFlags(e){var t;null==(t=this.featureFlags)||t.resetGroupPropertiesForFlags(e)}reset(e){var t=xt(e)?e:null==e?void 0:e.resetDeviceID,i=xt(e)||null==e?void 0:e.bootstrap;this._reset(t,!1,i)}_reset(e,t,s){var r,n,o,a;if(void 0===t&&(t=!1),Ji.info("reset"),!this.__loaded)return Ji.uninitializedWarning("posthog.reset");var l=null==s?void 0:s.sessionID;this.config.bootstrap=s||(null==(r=this._originalUserConfig)?void 0:r.bootstrap)||{},null==(n=this.featureFlags)||null==n.updateConfig||n.updateConfig(this.config,this._shouldDisableFlags());var d=this.get_property(u),c=this.get_property(_),h=this.get_property(T);null==(o=this.sessionRecording)||o.flushBeforeIdentityReset();var p=this.is_capturing();this.consent.reset(),t||!p||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 g=null==(a=this.persistence)||null==a._beginCookieSyncSuppression?void 0:a._beginCookieSyncSuppression(),v=!1;try{var f,m,y,b,w,S,P,x,E,C,k,I,F;if(null==(f=this.persistence)||f.clear(),null==(m=this.sessionPersistence)||m.clear(),this._sessionRegisteredPropKeys.clear(),this._persistSessionRegisteredPropKeys(),ft(h)||null==(y=this.persistence)||y.register({[T]:h}),null==(b=this.surveys)||b.reset(),null==(w=this.featureFlags)||w.reset(),null==(S=this.conversations)||S.reset(),null==(P=this.logs)||P.reset(),null==(x=this.metrics)||x.reset(),null==(E=this.persistence)||E.set_property(me,Ne),null==(C=this.sessionManager)||C.resetSessionId(),this._cachedPersonProperties=null,"always"===this.config.cookieless_mode)this.register_once({distinct_id:Ee,$device_id:null},"");else{var R=this.config.get_device_id(cs());this.register_once({distinct_id:R,$device_id:e?R:d},""),e||ft(c)||this.register({[_]:c})}if(this.register({$last_posthog_reset:(new Date).toISOString()},1),s)if(s.distinctID&&!this._inCookielessMode()&&(null==(F=this.persistence)||F.set_property(me,s.isIdentifiedID?Be:Ne),this.register({distinct_id:s.distinctID})),null==(k=this.featureFlags)||k.initialize(),!(wt(l)||null!=(I=this.sessionManager)&&I.setBootstrapSessionId(l,!0))){var O=i({},s);delete O.sessionID,this.config.bootstrap=O}delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,v=!0}finally{var A;g&&(null==(A=this.persistence)||null==A._endCookieSyncSuppression||A._endCookieSyncSuppression(v))}this.reloadFeatureFlags()}shutdown(e){var t=this;return r(function*(){var e,i,s,r,n,o,a,l;if(t.__loaded){t._isShutdown=!0,t._getBrowserClientAdapter().dispose(),null==(e=t.sessionRecording)||e.dispose(),null==(i=t.logs)||i.flushLogs("sendBeacon"),null==(s=t.metrics)||s.flush("sendBeacon"),null==(r=t.metrics)||r.dispose(),null==(n=t._requestQueue)||n.unload(),null==(o=t._retryQueue)||o.unload();try{var d;null==(d=t.featureFlags)||d.destroy()}catch(e){Ji.error("Error while destroying feature flags",e)}null==(a=t.persistence)||a.destroy(),null==(l=t.sessionPersistence)||l.destroy()}else Ji.uninitializedWarning("posthog.shutdown")})()}setIdentity(e,t){var i;delete this.config.identity_claims,this.config.identity_distinct_id=e,this.config.identity_hash=t,this.alias(e),null==(i=this.conversations)||i._onIdentityChanged()}clearIdentity(){var e;delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,null==(e=this.conversations)||e._onIdentityCleared()}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var e,t;return null!==(e=null==(t=this.sessionManager)?void 0:t.checkAndGetSessionAndWindowId(!0).sessionId)&&void 0!==e?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";var t=this.sessionManager.checkAndGetSessionAndWindowId(!0),i=t.sessionStartTimestamp,s=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+t.sessionId);if(null!=e&&e.withTimestamp&&i){var r,n=null!==(r=e.timestampLookBack)&&void 0!==r?r:10;if(!i)return s;s+="?t="+Math.max(Math.floor(((new Date).getTime()-i)/1e3)-n,0)}return s}alias(e,t){return e===this.get_property("$people_distinct_id")?(Ji.critical("Attempting to create alias for existing People user - aborting."),-2):this._requirePersonProcessing("posthog.alias")?(ft(t)&&(t=this.get_distinct_id()),e!==t?(this._register_single(c,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(Ji.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var t=i({},this.config);if(gt(e)){var s,r,n,o,l,d,u,_,c,h,p,g,v,f;Zi(this.config,Ao(e));var m=this._is_persistence_disabled();null==(s=this.persistence)||s.update_config(this.config,t,m),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new Sr(i({},this.config,{persistence:"sessionStorage"}),m,!1);var y=this._checkLocalStorageForDebug(this.config.debug);xt(y)&&(this.config.debug=y),xt(this.config.debug)&&(this.config.debug?(a.DEBUG=!0,ys._is_supported()&&ys._set("ph_debug",!0),Ji.info("set_config",{config:e,oldConfig:t,newConfig:i({},this.config)})):(a.DEBUG=!1,ys._is_supported()&&ys._remove("ph_debug"))),null==(r=this.featureFlags)||null==r.updateConfig||r.updateConfig(this.config,this._shouldDisableFlags()),null==(n=this.exceptionObserver)||n.onConfigChange(),null==(o=this.exceptions)||o.onConfigChange(),null==(l=this.metrics)||l.onConfigChange(),null==(d=this.sessionRecording)||d.startIfEnabledOrStop(),null==(u=this.tracingHeaders)||u.startIfEnabledOrStop(),null==(_=this.autocapture)||_.startIfEnabled(),null==(c=this.heatmaps)||c.startIfEnabled(),("capture_pageview"in e||"disable_capture_url_hashes"in e)&&(null==(h=this.historyAutocapture)||h.startIfEnabledOrStop()),null==(p=this.exceptionObserver)||p.startIfEnabledOrStop(),null==(g=this.deadClicksAutocapture)||g.startIfEnabledOrStop(),null==(v=this.surveys)||v.loadIfEnabled(),this._sync_opt_out_with_persistence(),null==(f=this.externalIntegrations)||f.startIfEnabledOrStop(),!t.segment&&this.config.segment&&this.persistence&&Ns(this,wo,!1)}}_overrideSDKInfo(e,t){a.LIB_NAME=e,a.LIB_VERSION=t}startSessionRecording(e){var t,i,s,r,n,o=!0===e,a={sampling:o||!(null==e||!e.sampling),linked_flag:o||!(null==e||!e.linked_flag),url_trigger:o||!(null==e||!e.url_trigger),event_trigger:o||!(null==e||!e.event_trigger)};Object.values(a).some(Boolean)&&(null==(t=this.sessionManager)||t.checkAndGetSessionAndWindowId(),a.sampling&&(null==(i=this.sessionRecording)||i.overrideSampling()),a.linked_flag&&(null==(s=this.sessionRecording)||s.overrideLinkedFlag()),a.url_trigger&&(null==(r=this.sessionRecording)||r.overrideTrigger("url")),a.event_trigger&&(null==(n=this.sessionRecording)||n.overrideTrigger("event"))),this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var e;return!(null==(e=this.sessionRecording)||!e.started)}captureException(e,t){try{if(!this.exceptions)return;var s=this.exceptions.buildProperties(e,{handled:!0,syntheticException:new Error("PostHog syntheticException")});return this.exceptions.sendExceptionEvent(i({},s,t))}catch(e){return}}addExceptionStep(e,t){var i;null==(i=this.exceptions)||i.addExceptionStep(e,t)}captureLog(e){var t;null==(t=this.logs)||t.captureLog(e)}get logger(){var t,i;return null!==(t=null==(i=this.logs)?void 0:i.logger)&&void 0!==t?t:e._noopLogger}startExceptionAutocapture(e){this.set_config({capture_exceptions:null==e||e})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(e){var t,i;return null!==(t=null==(i=this.toolbar)?void 0:i.loadToolbar(e))&&void 0!==t&&t}get_property(e){var t;return null==(t=this.persistence)?void 0:t.props[e]}getSessionProperty(e){var t;return null==(t=this.sessionPersistence)?void 0:t.props[e]}toString(){var e,t=null!==(e=this.config.name)&&void 0!==e?e:$o;return t!==$o&&(t="posthog."+t),t}_isIdentified(){var e,t;return"identified"===(null==(e=this.persistence)?void 0:e.get_property("$user_state"))||"identified"===(null==(t=this.sessionPersistence)?void 0:t.get_property("$user_state"))}_hasPersonProcessing(){var e,t;return!("never"===this.config.person_profiles||"identified_only"===this.config.person_profiles&&!this._isIdentified()&&vt(this.getGroups())&&(null==(e=this.persistence)||null==(e=e.props)||!e.__alias)&&(null==(t=this.persistence)||null==(t=t.props)||!t.$epp))}_shouldCapturePageleave(){return!0===this.config.capture_pageleave||"if_capture_pageview"===this.config.capture_pageleave&&!!this.config.capture_pageview}createPersonProfile(){this._hasPersonProcessing()||this._requirePersonProcessing("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this._requirePersonProcessing("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}_requirePersonProcessing(e){return"never"===this.config.person_profiles?(Ji.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this._warnIfVolatileIdentityWithoutStableId(),this._register_single(xe,!0),!0)}_is_persistence_disabled(){if("always"===this.config.cookieless_mode)return!0;var e=this.consent.isOptedOut();return this.config.disable_persistence||e&&!(!this.config.opt_out_persistence_by_default&&"on_reject"!==this.config.cookieless_mode)}_sync_opt_out_with_persistence(){var e,t,i,s,r,n=this._is_persistence_disabled();return this.is_capturing()||null==(e=this.logs)||e._onOptOut(),(null==(t=this.persistence)?void 0:t._disabled)!==n&&(null==(i=this.persistence)||i.set_disabled(n)),(null==(s=this.sessionPersistence)?void 0:s._disabled)!==n&&(null==(r=this.sessionPersistence)||r.set_disabled(n)),n&&(this._sessionRegisteredPropKeys.clear(),this._persistSessionRegisteredPropKeys()),n}opt_in_capturing(t){var i,s,r;if("always"!==this.config.cookieless_mode){if(this._inCookielessMode()){var n,o,a,l,d,u;null==(n=this.sessionRecording)||n.dispose({discardBufferedEvents:!0}),this._reset(!0,!0),null==(o=this.sessionManager)||o.destroy(),null==(a=this.pageViewManager)||a.destroy(),this.sessionManager=new Zn(this),this.pageViewManager=new Hs(this),this.persistence&&(this.sessionPropsManager=new Jn(this,this.sessionManager,this.persistence));var _,c=null!==(l=null==(d=this.config.__extensionClasses)?void 0:d.sessionRecording)&&void 0!==l?l:null==(u=e.__defaultExtensionClasses)?void 0:u.sessionRecording;c&&(this.sessionRecording=this._replaceExtension(this.sessionRecording,new c(this)),this._lastRemoteConfig&&(null==(_=this.sessionRecording)||null==_.onRemoteConfig||_.onRemoteConfig(this._lastRemoteConfig)))}this.consent.optInOut(!0),this._sync_opt_out_with_persistence(),this._start_queue_if_opted_in(),null==(i=this.sessionRecording)||i.startIfEnabledOrStop(),"on_reject"==this.config.cookieless_mode&&(null==(s=this.surveys)||s.loadIfEnabled()),(ft(null==t?void 0:t.captureEventName)||null!=t&&t.captureEventName)&&this.capture(null!==(r=null==t?void 0:t.captureEventName)&&void 0!==r?r:"$opt_in",null==t?void 0:t.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this._captureInitialPageview()}else Ji.warn(So)}opt_out_capturing(){if("always"!==this.config.cookieless_mode){var e,t,i="on_reject"===this.config.cookieless_mode?this.sessionRecording:void 0;null==i||i.dispose({discardBufferedEvents:!0}),"on_reject"===this.config.cookieless_mode&&this.consent.isOptedIn()&&this._reset(!0,!0),this.consent.optInOut(!1),this._sync_opt_out_with_persistence(),"on_reject"===this.config.cookieless_mode&&(this.register({distinct_id:Ee,$device_id:null}),this._removeExtension(i),this.sessionRecording=void 0,null==(e=this.sessionManager)||e.destroy(),null==(t=this.pageViewManager)||t.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,this.config.capture_pageview&&this._captureInitialPageview(),this._start_queue_if_opted_in())}else Ji.warn(So)}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 1===e?"granted":0===e?"denied":"pending"}is_capturing(){return"always"===this.config.cookieless_mode||("on_reject"===this.config.cookieless_mode?this.consent.isRejected()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this._sync_opt_out_with_persistence()}_is_bot(){return Je?function(e,t){if(!e)return!1;var i=e.userAgent;if(i&&Rt(i,t))return!0;try{var s=null==e?void 0:e.userAgentData;if(null!=s&&s.brands&&s.brands.some(e=>Rt(null==e?void 0:e.brand,t)))return!0}catch(e){}return!!e.webdriver}(Je,this.config.custom_blocked_useragents):void 0}_captureInitialPageview(){Ye&&("visible"===Ye.visibilityState?this._initialPageviewCaptured||(this._initialPageviewCaptured=!0,this.capture(Ge,{title:Ye.title},{send_instantly:!0}),this._visibilityStateListener&&(Ye.removeEventListener(qe,this._visibilityStateListener),this._visibilityStateListener=null)):this._visibilityStateListener||(this._visibilityStateListener=this._captureInitialPageview.bind(this),ns(Ye,qe,this._visibilityStateListener)))}debug(e){!1===e?(null==ze||ze.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(null==ze||ze.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}))}_shouldDisableFlags(){var e=this._originalUserConfig||{};return"advanced_disable_flags"in e?!!e.advanced_disable_flags:!1!==this.config.advanced_disable_flags?!!this.config.advanced_disable_flags:!0===this.config.advanced_disable_decide?(Ji.warn("Config field 'advanced_disable_decide' is deprecated. Please use 'advanced_disable_flags' instead. The old field will be removed in a future major version."),!0):function(e,t,i,s,r){var n=t in e&&!wt(e[t]),o=i in e&&!wt(e[i]);return n?e[t]:!!o&&(r&&r.warn("Config field '"+i+"' is deprecated. Please use '"+t+"' instead. The old field will be removed in a future major version."),e[i])}(e,"advanced_disable_flags","advanced_disable_decide",0,Ji)}_runBeforeSend(e){var t;if(wt(this.config.before_send))return e;var i=Object.keys(null!==(t=e.properties)&&void 0!==t?t:{}).filter(Ct),s=ht(this.config.before_send)?this.config.before_send:[this.config.before_send],r=e;for(var n of s)try{if(r=n(r),wt(r)){var o="Event '"+e.event+"' was rejected in beforeSend function";return Et(e.event)?Ji.warn(o+". This can cause unexpected behavior."):Ji.info(o),null}r.properties&&!vt(r.properties)||Ji.warn("Event '"+e.event+"' has no properties after beforeSend function, this is likely an error.")}catch(t){return Ji.error("Error in beforeSend function for event '"+e.event+"':",t),null}for(var a of i)if(r.properties&&wt(r.properties[a]))return Ji.warn("Event '"+e.event+"' had its '"+a+"' property removed in a beforeSend function. This property is required for ingestion, so the event will be dropped."),null;return r}getPageViewId(){var e;return null==(e=this.pageViewManager._currentPageview)?void 0:e.pageViewId}captureTraceFeedback(e,t){this.capture("$ai_feedback",{$ai_trace_id:String(e),$ai_feedback_text:t})}captureTraceMetric(e,t,i){this.capture("$ai_metric",{$ai_trace_id:String(e),$ai_metric_name:t,$ai_metric_value:String(i)})}_checkLocalStorageForDebug(e){var t=xt(e)&&!e,i=ys._is_supported()&&"true"===ys._get("ph_debug");return!t&&(!!i||e)}},e.__defaultExtensionClasses={},e._noopLogger={trace:so=()=>{},debug:so,info:so,warn:so,error:so,fatal:so},e);!function(e,t){for(var i=0;t.length>i;i++)e.prototype[t[i]]=es(e.prototype[t[i]])}(Do,["identify"]);var Lo=function(){a.SDK_DIST_CHANNEL="npm";var e=yo[$o]=new Do;return function(){function e(){e.done||(e.done=!0,Gn=!1,Xi(yo,function(e){e._dom_loaded()}))}null!=Ye&&Ye.addEventListener?"complete"===Ye.readyState?e():ns(Ye,"DOMContentLoaded",e,{capture:!1}):ze&&Ji.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}(),e}();export{Pr as Compression,Dr as DEFAULT_PRODUCT_TOUR_APPEARANCE,Ar as DisplaySurveyType,Do as PostHog,Lr as ProductTourEventName,Nr as ProductTourEventProperties,Rr as SurveyEventName,Or as SurveyEventProperties,xr as SurveyEventType,Cr as SurveyPosition,$r as SurveyQuestionBranchingType,Tr as SurveyQuestionType,Fr as SurveySchedule,kr as SurveyTabPosition,Ir as SurveyType,Er as SurveyWidgetType,Lo as default,Lo as posthog,Gr as severityLevels};
2
2
  //# sourceMappingURL=module.slim.no-external.js.map