posthog-js 1.429.0 → 1.429.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- !function(){var t=["retriesPerformedSoFar"],i=["$set_once","$set"];function e(t,i){if(null==t)return{};var e={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(-1!==i.indexOf(r))continue;e[r]=t[r]}return e}function r(){return r=Object.assign?Object.assign.bind():function(t){for(var i=1;arguments.length>i;i++){var e=arguments[i];for(var r in e)({}).hasOwnProperty.call(e,r)&&(t[r]=e[r])}return t},r.apply(null,arguments)}function s(t,i,e,r,s,n,o){try{var a=t[n](o),l=a.value}catch(t){return void e(t)}a.done?i(l):Promise.resolve(l).then(r,s)}function n(t){return function(){var i=this,e=arguments;return new Promise(function(r,n){var o=t.apply(i,e);function a(t){s(o,r,n,a,l,"next",t)}function l(t){s(o,r,n,a,l,"throw",t)}a(void 0)})}}!function(s){var o="0.8.2",a={DEBUG:(!1,!1),LIB_VERSION:(o,"1.429.0"),LIB_NAME:("browser-common","web"),JS_SDK_VERSION:o},l=a,h="$people_distinct_id",u="distinct_id",d="$device_id",v="$device_model",c="__alias",f="__cmpns",p="$fbc",g="$fbc_persistence",_="__timers",m="$autocapture_disabled_server_side",b="$heatmaps_enabled_server_side",y="$exception_capture_enabled_server_side",w="$error_tracking_suppression_rules",x="$error_tracking_capture_extension_exceptions",S="$web_vitals_enabled_server_side",k="$dead_clicks_enabled_server_side",E="$product_tours_enabled_server_side",P="$logs_capture_enabled_server_side",T="$web_vitals_allowed_metrics",C="$session_recording_remote_config",F="$session_recording_enabled_server_side",A="$replay_sample_rate",I="$replay_override_sampling",R="$replay_override_linked_flag",O="$replay_override_url_trigger",M="$replay_override_event_trigger",D="$sesid",j="$session_is_sampled",B="$session_past_minimum_duration",L="$session_recording_url_trigger_activated_session",N="$session_recording_event_trigger_activated_session",z="$debug_first_full_snapshot_timestamp",U="$sess_rec_flush_size",H="$enabled_feature_flags",q="$active_feature_flags",V="$early_access_features",W="$feature_flag_details",G="$feature_flag_payloads",K="$feature_flag_request_id",J="$minimal_flag_called_events",X="$override_feature_flags",Y="$override_feature_flag_payloads",Z="$stored_person_properties",Q="$stored_group_properties",tt="$groups",it="$surveys",et="$surveys_loaded_at",rt="$surveys_activated",st="$surveys_activated_session",nt="$surveys_activated_timestamps",ot="ph_product_tours",at="$product_tours_activated",lt="$product_tours_activated_session",ht="$conversations_widget_session_id",ut="$conversations_ticket_id",dt="$conversations_widget_state",vt="$conversations_user_traits",ct="$flag_call_reported",ft="$flag_call_reported_session_id",pt="$feature_flag_errors",gt="$feature_flag_evaluated_at",_t="$user_state",mt="$client_session_props",bt="$capture_rate_limit",yt="$initial_campaign_params",wt="$initial_referrer_info",xt="$initial_person_info",St="$epp",kt="$posthog_cookieless",Et="$cookieless_mode",$t="$sdk_debug_extensions_init_method",Pt="$sdk_debug_extensions_init_time_ms",Tt="$sdk_debug_recording_script_not_loaded",Ct="$sdk_debug_replay_event_trigger_status",Ft="$sdk_debug_replay_linked_flag_trigger_status",At="$sdk_debug_replay_matched_recording_trigger_groups",It="$sdk_debug_replay_pending_trigger_conditions",Rt="$sdk_debug_replay_remote_trigger_matching_config",Ot="$sdk_debug_replay_trigger_groups_count",Mt="$sdk_debug_replay_url_trigger_status",Dt="$session_recording_start_reason",jt="PostHog loadExternalDependency extension not found.",Bt="anonymous",Lt="identified",Nt="identified_only",zt="visibilitychange",Ut="beforeunload",Ht="$pageview",qt="$pageleave",Vt="$identify",Wt="$groupidentify",Gt="u">typeof window?window:void 0,Kt="u">typeof globalThis?globalThis:Gt,Jt=null==Kt?void 0:Kt.navigator,Xt=null==Kt?void 0:Kt.document,Yt=null==Kt?void 0:Kt.location,Zt=null==Kt?void 0:Kt.fetch,Qt=null!=Kt&&Kt.XMLHttpRequest&&"withCredentials"in new Kt.XMLHttpRequest?Kt.XMLHttpRequest:void 0,ti=null==Kt?void 0:Kt.AbortController,ii=null==Kt?void 0:Kt.CompressionStream,ei=null==Jt?void 0:Jt.userAgent;function ri(){return!(!Gt||!1===Gt.navigator.onLine)}var si="undefined"!=typeof globalThis?globalThis:Gt;si&&"undefined"==typeof self&&(si.self=si),si&&"undefined"==typeof File&&(si.File=function(){});var ni=null!=Gt?Gt:{},oi=function(t){return t.AnonymousId="anonymous_id",t.DistinctId="distinct_id",t.Props="props",t.EnablePersonProcessing="enable_person_processing",t.PersonMode="person_mode",t.FeatureFlagDetails="feature_flag_details",t.FeatureFlags="feature_flags",t.FeatureFlagPayloads="feature_flag_payloads",t.BootstrapFeatureFlagDetails="bootstrap_feature_flag_details",t.BootstrapFeatureFlags="bootstrap_feature_flags",t.BootstrapFeatureFlagPayloads="bootstrap_feature_flag_payloads",t.OverrideFeatureFlags="override_feature_flags",t.Queue="queue",t.AiQueue="ai_queue",t.AiCaptureQueue="ai_capture_queue",t.LogsQueue="logs_queue",t.OptedOut="opted_out",t.SessionId="session_id",t.SessionStartTimestamp="session_start_timestamp",t.SessionLastTimestamp="session_timestamp",t.PersonProperties="person_properties",t.GroupProperties="group_properties",t.InstalledAppBuild="installed_app_build",t.InstalledAppVersion="installed_app_version",t.SessionReplay="session_replay",t.PushRegistered="push_registered",t.SessionReplayEventTriggerActivatedSession="session_replay_event_trigger_activated_session",t.SurveyLastSeenDate="survey_last_seen_date",t.SurveysSeen="surveys_seen",t.Surveys="surveys",t.RemoteConfig="remote_config",t.FlagsEndpointWasHit="flags_endpoint_was_hit",t.DeviceId="device_id",t}({}),ai=function(t){return t.GZipJS="gzip-js",t.Base64="base64",t}({}),li=["$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"],hi=["token"];function ui(t,i){return-1!==t.indexOf(i)}var di=function(t){return t.trim()},vi=function(t){return t.replace(/^\$/,"")};function ci(t){var i,e=[];return null!==(i=JSON.stringify(t,function(t,i){if("bigint"==typeof i)return i.toString();if("function"!=typeof i&&"symbol"!=typeof i){if(i instanceof Error)return{name:i.name,message:i.message,stack:i.stack};if(i&&"object"==typeof i){for(;e.length>0&&e[e.length-1]!==this;)e.pop();if(e.includes(i))return"[Circular]";e.push(i)}return i}}))&&void 0!==i?i:"null"}var fi=Object.prototype,pi=fi.hasOwnProperty,gi=fi.toString,_i=Array.isArray||function(t){return"[object Array]"===gi.call(t)},mi=t=>"function"==typeof t,bi=t=>t===Object(t)&&!_i(t),yi=t=>{if(bi(t)){for(var i in t)if(pi.call(t,i))return!1;return!0}return!1},wi=t=>void 0===t,xi=t=>"[object String]"==gi.call(t),Si=t=>xi(t)&&0===t.trim().length,ki=t=>null===t,Ei=t=>wi(t)||ki(t),$i=t=>"[object Number]"==gi.call(t)&&t==t,Pi=t=>$i(t)&&t>0,Ti=t=>"[object Boolean]"===gi.call(t),Ci=t=>ui(li,t),Fi=t=>ui(hi,t);function Ai(t){return null===t||"object"!=typeof t}function Ii(t,i){return{}.toString.call(t)==="[object "+i+"]"}function Ri(t){switch({}.toString.call(t)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object DOMError]":case"[object WebAssembly.Exception]":return!0;default:return Mi(t,Error)}}function Oi(t){return"u">typeof Event&&Mi(t,Event)}function Mi(t,i){try{return t instanceof i}catch(t){return!1}}var Di=[!0,"true",1,"1","yes"],ji=t=>ui(Di,t),Bi=[!1,"false",0,"0","no"],Li=["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"],Ni=function(t,i){if(void 0===i&&(i=[]),!t)return!1;var e=t.toLowerCase();return Li.concat(i).some(t=>{var i=t.toLowerCase();return-1!==e.indexOf(i)})};function zi(t,i,e,r,s){return i>e&&(r.warn("min cannot be greater than max."),i=e),$i(t)?t>e?(r.warn(" cannot be greater than max: "+e+". Using max value instead."),e):i>t?(r.warn(" cannot be less than min: "+i+". Using min value instead."),i):t:(r.warn(" must be a number. using max or fallback. max: "+e+", fallback: "+s),zi(null!=s?s:e,i,e,r))}var Ui=class{constructor(t){this.C={},this.I=t.I,this.R=zi(t.bucketSize,0,100,t.A),this.O=zi(t.refillRate,0,this.R,t.A),this.N=zi(t.refillInterval,0,864e5,t.A)}F(t,i){var e=Math.floor((i-t.lastAccess)/this.N);e>0&&(t.tokens=Math.min(t.tokens+e*this.O,this.R),t.lastAccess=t.lastAccess+e*this.N)}consumeRateLimit(t){var i,e=Date.now(),r=String(t),s=this.C[r];return s?this.F(s,e):this.C[r]=s={tokens:this.R,lastAccess:e},0===s.tokens||(s.tokens--,0===s.tokens&&(null==(i=this.I)||i.call(this,t)),0===s.tokens)}stop(){this.C={}}},Hi="Mobile",qi="Android",Vi="Tablet",Wi="Android Tablet",Gi="iPad",Ki="Apple Watch",Ji="Safari",Xi="BlackBerry",Yi="Samsung Internet",Zi="Chrome",Qi="Chrome iOS",te="Internet Explorer",ie="Internet Explorer Mobile",ee="Opera",re="Microsoft Edge",se="Firefox",ne="Firefox iOS",oe="Nintendo",ae="PlayStation",le="Xbox",he="Android Mobile",ue="Mobile Safari",de="Windows",ve="Windows Phone",ce="Nokia",fe="Ouya",pe="Generic "+Hi.toLowerCase(),ge="Generic "+Vi.toLowerCase(),_e="Konqueror",me="Oculus Browser",be="Vivaldi",ye="Yandex",we="Whale",xe="DuckDuckGo",Se="Pale Moon",ke="Waterfox",Ee="Brave",$e="Claude",Pe="Codex",Te="ChatGPT",Ce="Google Search App",Fe=new RegExp("Version/(\\d+(\\.\\d+)?)"),Ae=new RegExp("(Claude|Codex|ChatGPT)\\/(\\d+(\\.\\d+)?)"),Ie=new RegExp(le,"i"),Re=new RegExp("PlayStation \\w+","i"),Oe=new RegExp("Nintendo \\w+","i"),Me=new RegExp("BlackBerry|PlayBook|BB10","i"),De={"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"},je=function(t,i,e,r){i=i||"";var s=function(t){return null!=t&&t.brave?Ee:null}(e);return s||(null!=r&&r.detectGoogleSearchApp&&ui(t,"GSA/")?Ce:ui(t," OPR/")&&ui(t,"Mini")?"Opera Mini":ui(t," OPR/")?ee:Me.test(t)?Xi:ui(t,"IEMobile")||ui(t,"WPDesktop")?ie:ui(t,"OculusBrowser")?me:ui(t,"SamsungBrowser")?Yi:ui(t,"Edge")||ui(t,"Edg/")?re:ui(t,"Vivaldi/")?be:ui(t,"YaBrowser/")?ye:ui(t,"Whale/")?we:ui(t,"DuckDuckGo/")||ui(t,"Ddg/")?xe:ui(t,"Claude/")?$e:ui(t,"Codex/")?Pe:ui(t,"ChatGPT/")?Te:ui(t,"FBIOS")?"Facebook Mobile":ui(t,"UCWEB")||ui(t,"UCBrowser")?"UC Browser":ui(t,"CriOS")?Qi:ui(t,"CrMo")||ui(t,Zi)?Zi:ui(t,qi)&&ui(t,Ji)?he:ui(t,"FxiOS")?ne:ui(t.toLowerCase(),_e.toLowerCase())?_e:ui(t,"Brave/")?Ee:((t,i)=>i&&ui(i,"Apple")||function(t){return ui(t,Ji)&&!ui(t,Zi)&&!ui(t,qi)}(t))(t,i)?ui(t,Hi)?ue:Ji:ui(t,"PaleMoon/")?Se:ui(t,"Waterfox/")?ke:ui(t,se)?se:ui(t,"MSIE")||ui(t,"Trident/")?te:ui(t,"Gecko")?se:"")},Be={[ie]:[new RegExp("rv:(\\d+(\\.\\d+)?)")],[re]:[new RegExp("Edge?\\/(\\d+(\\.\\d+)?)")],[Zi]:[new RegExp("(Chrome|CrMo)\\/(\\d+(\\.\\d+)?)")],[Qi]:[new RegExp("CriOS\\/(\\d+(\\.\\d+)?)")],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/(\\d+(\\.\\d+)?)")],[Ji]:[Fe],[ue]:[Fe],[ee]:[new RegExp("(Opera|OPR)\\/(\\d+(\\.\\d+)?)")],[se]:[new RegExp("Firefox\\/(\\d+(\\.\\d+)?)")],[ne]:[new RegExp("FxiOS\\/(\\d+(\\.\\d+)?)")],[_e]:[new RegExp("Konqueror[:/]?(\\d+(\\.\\d+)?)","i")],[Xi]:[new RegExp("BlackBerry (\\d+(\\.\\d+)?)"),Fe],[he]:[new RegExp("android\\s(\\d+(\\.\\d+)?)","i")],[Yi]:[new RegExp("SamsungBrowser\\/(\\d+(\\.\\d+)?)")],[me]:[new RegExp("OculusBrowser\\/(\\d+(\\.\\d+)?)")],[be]:[new RegExp("Vivaldi\\/(\\d+(\\.\\d+)?)")],[ye]:[new RegExp("YaBrowser\\/(\\d+(\\.\\d+)?)")],[we]:[new RegExp("Whale\\/(\\d+(\\.\\d+)?)")],[Ee]:[new RegExp("Brave\\/(\\d+(\\.\\d+)?)")],[$e]:[Ae],[Pe]:[Ae],[Te]:[Ae],[xe]:[new RegExp("(DuckDuckGo|Ddg)\\/(\\d+(\\.\\d+)?)")],[Se]:[new RegExp("PaleMoon\\/(\\d+(\\.\\d+)?)")],[ke]:[new RegExp("Waterfox\\/(\\d+(\\.\\d+)?)")],[Ce]:[new RegExp("GSA\\/(\\d+(\\.\\d+)?)")],[te]:[new RegExp("(rv:|MSIE )(\\d+(\\.\\d+)?)")],Mozilla:[new RegExp("rv:(\\d+(\\.\\d+)?)")]},Le=function(t,i,e,r){var s=Be[je(t,i,e,r)];if(wi(s))return null;for(var n=0;s.length>n;n++){var o=t.match(s[n]);if(o)return parseFloat(o[o.length-2])}return null},Ne=[[new RegExp("Xbox; Xbox (.*?)[);]","i"),t=>[le,t&&t[1]||""]],[new RegExp(oe,"i"),[oe,""]],[new RegExp(ae,"i"),[ae,""]],[Me,[Xi,""]],[new RegExp(de,"i"),(t,i)=>{if(/Phone/.test(i)||/WPDesktop/.test(i))return[ve,""];if(new RegExp(Hi).test(i)&&!/IEMobile\b/.test(i))return["Windows Mobile",""];var e=/Windows NT ([0-9.]+)/i.exec(i);if(e&&e[1]){var r=De[e[1]]||"";return/arm/i.test(i)&&(r="RT"),[de,r]}return[de,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,t=>t&&t[3]?["iOS",[t[3],t[4],t[5]||"0"].join(".")]:["iOS",""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,t=>{var i="";return t&&t.length>=3&&(i=wi(t[2])?t[3]:t[2]),["watchOS",i]}],[new RegExp("(Android (\\d+)\\.(\\d+)\\.?(\\d+)?|Android)","i"),t=>t&&t[2]?[qi,[t[2],t[3],t[4]||"0"].join(".")]:[qi,""]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,t=>{var i=["Mac OS X",""];return t&&t[1]&&(i[1]=[t[1],t[2],t[3]||"0"].join(".")),i}],[/Mac/i,["Mac OS X",""]],[/CrOS/,["Chrome OS",""]],[/Linux|debian/i,["Linux",""]]],ze=function(t){for(var i=0;Ne.length>i;i++){var e=Ne[i],r=e[1],s=e[0].exec(t),n=s&&(mi(r)?r(s,t):r);if(n)return n}return["",""]},Ue=function(t){return Oe.test(t)?oe:Re.test(t)?ae:Ie.test(t)?le:new RegExp(fe,"i").test(t)?fe:new RegExp("(Windows Phone|WPDesktop)","i").test(t)?ve:/iPad/.test(t)?Gi:/iPod/.test(t)?"iPod Touch":/iPhone/.test(t)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(t)?Ki:Me.test(t)?Xi:/(kobo)\s(ereader|touch)/i.test(t)?"Kobo":new RegExp(ce,"i").test(t)?ce:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(t)||/(kf[a-z]+)( bui|\)).+silk\//i.test(t)?"Kindle Fire":/(Android|ZTE)/i.test(t)?new RegExp(Hi).test(t)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(t)||/pixel[\daxl ]{1,6}/i.test(t)&&!/pixel c/i.test(t)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(t)||/lmy47v/i.test(t)&&!/QTAQZ3/i.test(t)?qi:Wi:new RegExp("(pda|Mobile)","i").test(t)?pe:new RegExp(Vi,"i").test(t)&&!new RegExp("Tablet pc","i").test(t)?ge:""},He=/\bFBAV\/(\d+(?:\.\d+)*)/i,qe=[[/\bInstagram(?:[ /](\d+(?:\.\d+)*))?\b/i,"Instagram"],[/\bBarcelona[ /](\d+(?:\.\d+)*)?/i,"Threads"],[/\b(?:MessengerForiOS|(?:FBAN|FB_IAB)\/Orca-Android)\b/i,"Messenger",He],[/\bFBAN\/EMA\b/i,"Facebook Lite",He],[/\b(?:FBIOS|(?:FBAN|FB_IAB)\/(?:FB4A|FBIOS))\b/i,"Facebook",He],[/\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"]],Ve="[Truncated]",We="[Unserializable]";function Ge(t){for(var i="",e=0;t.length>e;e++){var r=t.charCodeAt(e);if(55296>r||r>56319)i+=56320>r||r>57343?t[e]:"�";else{var s=t.charCodeAt(e+1);56320>s||s>57343?i+="�":(i+=t[e]+t[e+1],e++)}}return i}Date,Date;var Ke,Je,Xe,Ye=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function Ze(t,i){return"string"==typeof(e=t)&&Ye.test(e)?t:i();var e}function Qe(t,i){var e=new Error(i);try{Object.defineProperty(e,"name",{value:t,writable:!0,enumerable:!0,configurable:!0})}catch(t){}return e}function tr(t){return t?t.split("#")[0]:t}function ir(t,i){var e=setTimeout(t,i);return null!=e&&e.unref&&(null==e||e.unref()),e}function er(t,i,e){return rr.apply(this,arguments)}function rr(){return(rr=n(function*(t,i,e){var r;try{return yield Promise.race([t,new Promise((t,s)=>{r=ir(()=>{try{null==e||e(),t()}catch(t){s(t)}},i)})])}finally{clearTimeout(r)}})).apply(this,arguments)}function sr(t){var i=globalThis._posthogChunkIds;if(i){var e=Object.keys(i);return Xe&&e.length===Je?Xe:(Je=e.length,Xe=e.reduce((e,r)=>{Ke||(Ke={});var s=Ke[r];if(s)e[s[0]]=s[1];else for(var n=t(r),o=n.length-1;o>=0;o--){var a,l=null==(a=n[o])?void 0:a.filename,h=i[r];if(l&&h){e[l]=h,Ke[r]=[l,h];break}}return e},{}))}}var nr=class{constructor(t,i,e){void 0===e&&(e=[]),this.coercers=t,this.stackParser=i,this.modifiers=e}buildFromUnknown(t,i){void 0===i&&(i={});var e=i&&i.mechanism||{handled:!0,type:"generic"},r=this.buildCoercingContext(e,i,0).apply(t),s=this.buildParsingContext(i),n=this.parseStacktrace(r,s);return{$exception_list:this.convertToExceptionList(n,e),$exception_level:"error"}}modifyFrames(t){var i=this;return n(function*(){for(var e of t)e.stacktrace&&e.stacktrace.frames&&_i(e.stacktrace.frames)&&(e.stacktrace.frames=yield i.applyModifiers(e.stacktrace.frames));return t})()}coerceFallback(t){var i;return{type:"Error",value:"Unknown error",stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}parseStacktrace(t,i){var e,s;return null!=t.cause&&(e=this.parseStacktrace(t.cause,i)),""!=t.stack&&null!=t.stack&&(s=this.applyChunkIds(this.stackParser(t.stack,t.synthetic?i.skipFirstLines:0),i.chunkIdMap)),r({},t,{cause:e,stack:s})}applyChunkIds(t,i){return t.map(t=>(t.filename&&i&&(t.chunk_id=i[t.filename]),t))}applyCoercers(t,i){for(var e of this.coercers)if(e.match(t))return e.coerce(t,i);return this.coerceFallback(i)}applyModifiers(t){var i=this;return n(function*(){var e=t;for(var r of i.modifiers)e=yield r(e);return e})()}convertToExceptionList(t,i){var e,s,n,o={type:t.type,value:t.value,mechanism:{type:null!==(e=i.type)&&void 0!==e?e:"generic",handled:null===(s=i.handled)||void 0===s||s,synthetic:null!==(n=t.synthetic)&&void 0!==n&&n}};t.stack&&(o.stacktrace={type:"raw",frames:t.stack});var a=[o];return null!=t.cause&&a.push(...this.convertToExceptionList(t.cause,r({},i,{handled:!0}))),a}buildParsingContext(t){var i;return{chunkIdMap:sr(this.stackParser),skipFirstLines:null!==(i=t.skipFirstLines)&&void 0!==i?i:1}}buildCoercingContext(t,i,e){void 0===e&&(e=0);var s=(e,r)=>{if(4>=r){var s=this.buildCoercingContext(t,i,r);return this.applyCoercers(e,s)}};return r({},i,{syntheticException:0==e?i.syntheticException:void 0,mechanism:t,apply:t=>s(t,e),next:t=>s(t,e+1)})}};function or(t,i,e,r,s){var n={platform:t,filename:i,function:"<anonymous>"===e?"?":e,in_app:!!i&&!i.startsWith("webkit-masked-url://")&&"<anonymous>"!==i};return wi(r)||(n.lineno=r),wi(s)||(n.colno=s),n}var ar=(t,i)=>{var e=-1!==t.indexOf("safari-extension"),r=-1!==t.indexOf("safari-web-extension");return e||r?[-1!==t.indexOf("@")?t.split("@")[0]:"?",e?"safari-extension:"+i:"safari-web-extension:"+i]:[t,i]},lr=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,hr=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,ur=/\((\S*)(?::(\d+))(?::(\d+))\)/,dr=(t,i)=>{var e=lr.exec(t);if(e)return or(i,e[1],"?",+e[2],+e[3]);var r=hr.exec(t);if(r){if(r[2]&&0===r[2].indexOf("eval")){var s=ur.exec(r[2]);s&&(r[2]=s[1],r[3]=s[2],r[4]=s[3])}var n=ar(r[1]||"?",r[2]);return or(i,n[1],n[0],r[3]?+r[3]:void 0,r[4]?+r[4]:void 0)}},vr=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,cr=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,fr=(t,i)=>{var e=vr.exec(t);if(e){if(e[3]&&e[3].indexOf(" > eval")>-1){var r=cr.exec(e[3]);r&&(e[1]=e[1]||"eval",e[3]=r[1],e[4]=r[2],e[5]="")}var s=e[3],n=e[1]||"?",o=ar(n,s);return or(i,s=o[1],n=o[0],e[4]?+e[4]:void 0,e[5]?+e[5]:void 0)}},pr=/\(error: (.*)\)/;function gr(t,i){return t.filename===i.filename&&t.function===i.function&&t.module===i.module&&t.lineno===i.lineno&&t.colno===i.colno}function _r(t){for(var i=1;10>=i;i++){var e=t.length-2*i;if(0>e)break;for(var r=!0,s=0;i>s;s++)if(!gr(t[e+s],t[e+i+s])){r=!1;break}if(r){for(var n=0;i>n;n++)t[e+n]=t[e+i+n];return t.length=e+i,{start:e,length:i}}}}function mr(t,i){var e=i.start+i.length,r=yr(t,i);r&&t.splice(e+r===t.length?e:i.start,r)}function br(t,i){for(var e=i.start;e>0&&gr(t[e-1],t[e-1+i.length]);)e--;return i.start-e}function yr(t,i){for(var e=i.start+i.length,r=e;t.length>r&&gr(t[r],t[r-i.length]);)r++;return r-e}function wr(t,i){var e=i[0],r=t.length-(e?br(t,e):0);for(var s of i)r-=yr(t,s);return r}function xr(t,i,e){for(var r=0;t.length>r;r++){var s=t[(i+r)%t.length],n=t[(e+r)%t.length];if(s!==n)return n>s}return!1}var Sr=class{match(t){return this.isDOMException(t)||this.isDOMError(t)}coerce(t,i){var e=xi(t.stack);return{type:this.getType(t),value:this.getValue(t),stack:e?t.stack:void 0,cause:t.cause?i.next(t.cause):void 0,synthetic:!1}}getType(t){return this.isDOMError(t)?"DOMError":"DOMException"}getValue(t){var i=t.name||(this.isDOMError(t)?"DOMError":"DOMException");return t.message?i+": "+t.message:i}isDOMException(t){return Ii(t,"DOMException")}isDOMError(t){return Ii(t,"DOMError")}},kr=class{match(t){return Ri(t)}coerce(t,i){var e,r=this.getStack(t),s=void 0===r;return{type:this.getType(t),value:this.getMessage(t,i),stack:null!=r?r:null==(e=i.syntheticException)?void 0:e.stack,cause:t.cause?i.next(t.cause):void 0,synthetic:s}}getType(t){return t.name||t.constructor.name}getMessage(t,i){var e=t.message;return String(e.error&&"string"==typeof e.error.message?e.error.message:e)}getStack(t){return t.stacktrace||t.stack||void 0}},Er=class{match(t){return!!Ii(t,"ErrorEvent")&&(null!=t.error||this.un(t))}coerce(t,i){var e;if(null!=t.error)return i.apply(t.error);var s=i.apply(t.message);return r({},s,{stack:null!==(e=this.ln(t))&&void 0!==e?e:s.stack,synthetic:!0})}un(t){return xi(t.message)&&t.message.length>0}ln(t){var i,e,r=t,s=null!==(i=r.lineno)&&void 0!==i?i:0,n=null!==(e=r.colno)&&void 0!==e?e:0;if(xi(r.filename)&&0!==r.filename.length&&0!==s)return"Error\n at "+r.filename+":"+s+":"+n}},$r=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,Pr=class{match(t){return"string"==typeof t}coerce(t,i){var e,r=this.getInfos(t),s=r[0],n=r[1];return{type:null!=s?s:"Error",value:null!=n?n:t,stack:null==(e=i.syntheticException)?void 0:e.stack,synthetic:!0}}getInfos(t){var i="Error",e=t,r=t.match($r);return r&&(i=r[1],e=r[2]),[i,e]}},Tr=["fatal","error","warning","log","info","debug"];function Cr(t,i){void 0===i&&(i=40);var e=Object.keys(t);if(e.sort(),!e.length)return"[object has no keys]";for(var r=e.length;r>0;r--){var s=e.slice(0,r).join(", ");if(i>=s.length)return r===e.length?s:s.length>i?s.slice(0,i)+"...":s}return""}var Fr=class{match(t){return"object"==typeof t&&null!==t}coerce(t,i){var e,r,s=this.getErrorPropertyFromObject(t);return s?i.apply(s):{type:this.getType(t),value:this.getValue(t),stack:null!==(e=this.getStack(t))&&void 0!==e?e:null==(r=i.syntheticException)?void 0:r.stack,level:this.isSeverityLevel(t.level)?t.level:"error",synthetic:!0}}getType(t){if(Oi(t))return t.constructor.name;var i="name"in t?t.name:void 0;return xi(i)&&!Si(i)?i:"Error"}getValue(t){if("name"in t&&"string"==typeof t.name){var i="'"+t.name+"' captured as exception";return"message"in t&&"string"==typeof t.message&&(i+=" with message: '"+t.message+"'"),i}if("message"in t&&"string"==typeof t.message)return t.message;var e=this.getObjectClassName(t);return(e&&"Object"!==e?"'"+e+"'":"Object")+" captured as exception with keys: "+Cr(t)}isSeverityLevel(t){return xi(t)&&!Si(t)&&Tr.indexOf(t)>=0}getStack(t){try{return xi(t.stacktrace)&&t.stacktrace.length>0?t.stacktrace:xi(t.stack)&&t.stack.length>0?t.stack:void 0}catch(t){return}}getErrorPropertyFromObject(t){for(var i in t)if({}.hasOwnProperty.call(t,i)){var e=t[i];if(Ri(e))return e}}getObjectClassName(t){try{var i=Object.getPrototypeOf(t);return i?i.constructor.name:void 0}catch(t){return}}},Ar=class{match(t){return Oi(t)}coerce(t,i){var e,r=t.constructor.name;return{type:r,value:r+" captured as exception with keys: "+Cr(t),stack:null==(e=i.syntheticException)?void 0:e.stack,synthetic:!0}}},Ir=class{match(t){return Ai(t)}coerce(t,i){var e;return{type:"Error",value:"Primitive value captured as exception: "+String(t),stack:null==(e=i.syntheticException)?void 0:e.stack,synthetic:!0}}},Rr=class{match(t){return Ii(t,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(t)}isCustomEventWrappingRejection(t){if(!Oi(t))return!1;try{var i=t.detail;return null!=i&&"object"==typeof i&&"reason"in i}catch(t){return!1}}coerce(t,i){var e,r=this.getUnhandledRejectionReason(t);return Ai(r)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(r),stack:null==(e=i.syntheticException)?void 0:e.stack,synthetic:!0}:i.apply(r)}getUnhandledRejectionReason(t){try{if("reason"in t)return t.reason;if("detail"in t&&null!=t.detail&&"object"==typeof t.detail&&"reason"in t.detail)return t.detail.reason}catch(t){}return t}},Or="$message",Mr="$timestamp",Dr=new Set([Or,Mr]),jr={enabled:!0,max_bytes:32768};function Br(t){var i;return t?{enabled:null!==(i=t.enabled)&&void 0!==i?i:jr.enabled,max_bytes:Nr(t.max_bytes,jr.max_bytes)}:r({},jr)}var Lr=class{constructor(t){this.ts=[],this.es=0,this.xn=Br(t)}setConfig(t){this.xn=Br(t),this.rs()}add(t){var i=function(t){var i;try{i=ci(t)}catch(t){return}try{var e=JSON.parse(i);if(!bi(e))return;var r=e,s=r[Or],n=r[Mr];if(!xi(s)||0===s.trim().length)return;if(!xi(n)&&!$i(n))return;return{step:r,json:i}}catch(t){return}}(t);if(i){var e=function(t){if("u">typeof TextEncoder)return(new TextEncoder).encode(t).length;for(var i=encodeURIComponent(t),e=0,r=0;i.length>r;r++)"%"===i[r]?(e+=1,r+=2):e+=1;return e}(i.json);e>this.xn.max_bytes||(this.ts.push({step:i.step,bytes:e}),this.es+=e,this.rs())}}getAttachable(){return this.ts.map(t=>t.step)}clear(){this.ts=[],this.es=0}size(){return this.ts.length}rs(){for(;this.es>this.xn.max_bytes&&this.ts.length>0;){var t=this.ts.shift();t&&(this.es-=t.bytes)}}};function Nr(t,i){if(!$i(t)||1/0===t||-1/0===t)return i;var e=Math.floor(t);return 0>e?i:e}var zr=t=>{if("string"!=typeof t)return t;try{return JSON.parse(t)}catch(i){return t}};function Ur(t){return"string"==typeof t||t}function Hr(t){return"string"==typeof t?t:void 0}var qr,Vr=["$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"],Wr="NativeGzipValidationError",Gr=t=>t.length>=2&&31===t[0]&&139===t[1],Kr=(t,i)=>t===ai.GZipJS||i===ai.GZipJS||"gzip"===i,Jr=t=>!(!t||"object"!=typeof t)&&"NotReadableError"===("name"in t?String(t.name):""),Xr=t=>{throw Qe(Wr,"Native gzip produced invalid output: "+t)},Yr=function(){var t=n(function*(t,i){18>t.size&&Xr("too-short");var e=new Uint8Array(yield t.slice(0,10).arrayBuffer());Gr(e)&&8===e[2]||Xr("invalid-header");var r=new DataView(yield t.slice(t.size-8).arrayBuffer());r.getUint32(0,!0)!==(t=>{for(var i=(()=>{if(qr)return qr;qr=[];for(var t=0;256>t;t++){for(var i=t,e=0;8>e;e++)i=1&i?3988292384^i>>>1:i>>>1;qr[t]=i>>>0}return qr})(),e=4294967295,r=0;t.length>r;r++)e=i[255&(e^t[r])]^e>>>8;return(4294967295^e)>>>0})(i)&&Xr("invalid-crc");var s=i.length>>>0;r.getUint32(4,!0)!==s&&Xr("invalid-size")});return function(i,e){return t.apply(this,arguments)}}();function Zr(){return Zr=n(function*(t,i,e){void 0===i&&(i=!0);try{var r=(new TextEncoder).encode(t),s=new globalThis.CompressionStream("gzip"),o=s.writable.getWriter(),a=o.write(r).then(()=>o.close()).catch(function(){var t=n(function*(t){try{yield o.abort(t)}catch(t){}throw t});return function(i){return t.apply(this,arguments)}}()),l=new Response(s.readable).blob(),h=(yield Promise.all([l,a]))[0];return yield Yr(h,r),h}catch(t){if(null!=e&&e.rethrow)throw t;return i&&console.error("Failed to gzip compress data",t),null}}),Zr.apply(this,arguments)}var Qr={}.propertyIsEnumerable;function ts(t,i){try{return rs(t,i,{ancestors:new WeakSet,remainingNodes:1e4},0)}catch(t){return[]}}function is(t,i,e,r){if(0>=e.remainingNodes)return{stringValue:Ve};if(e.remainingNodes--,Ti(t))return{boolValue:t};if("bigint"==typeof t)return function(t,i){var e=t.toString(),r=BigInt("9223372036854775808");return t>=r||-r>t?(null==i||i.debug("Attribute "+e+" is outside the int64 range; encoding it as a string"),{stringValue:e}):{intValue:e}}(t,i);if("number"==typeof t){if(!Number.isFinite(t))return{stringValue:String(t)};if(Number.isInteger(t)){if(Number.isSafeInteger(t))return{intValue:String(t)};if(typeof BigInt>"u")return{stringValue:String(t)};var s=BigInt(t).toString();return t>=0x8000000000000000||-0x8000000000000000>t?(null==i||i.debug("Attribute "+s+" is outside the int64 range; encoding it as a string"),{stringValue:s}):{intValue:s}}return{doubleValue:t}}if("string"==typeof t)return{stringValue:Ge(t)};if("function"==typeof t)return{stringValue:"[Function]"};if("symbol"==typeof t)return{stringValue:String(t)};if("object"==typeof t&&null!==t){if(e.ancestors.has(t))return{stringValue:"[Circular]"};if(r>=20)return{stringValue:Ve};if(t instanceof Date){var n=t.getTime(),o=Number.isFinite(n)?t.toISOString():String(t);return{stringValue:"string"==typeof o?Ge(o):String(o)}}e.ancestors.add(t);try{try{var a=t.toJSON;if("function"==typeof a)return is(a.call(t),i,e,r+1)}catch(t){}return _i(t)?{arrayValue:{values:es(t,i,e,r+1)}}:{kvlistValue:{values:rs(t,i,e,r+1)}}}finally{e.ancestors.delete(t)}}return{stringValue:Ge(String(t))}}function es(t,i,e,r){for(var s=[],n=Math.min(t.length,1e3),o=0;n>o&&e.remainingNodes>0;o++)try{var a=o in t?t[o]:void 0;if(Ei(a))continue;s.push(is(a,i,e,r))}catch(t){s.push({stringValue:We})}return t.length>o&&s.push({stringValue:Ve}),s}function rs(t,i,e,r){var s=[];for(var n in t)if(Qr.call(t,n)){if(!n){null==i||i.debug("Dropping an attribute with an empty key");continue}if(s.length>=1e3||0>=e.remainingNodes){null==i||i.debug("Attributes truncated: the value exceeds the OTLP encoder budget");break}try{var o=t[n];if(ki(o)||wi(o))continue;s.push({key:Ge(n),value:is(o,i,e,r)})}catch(t){s.push({key:Ge(n),value:{stringValue:We}})}}return s}function ss(t,i,e){return r({},t.resourceAttributes,{"service.name":t.serviceName||"unknown_service"},t.environment&&{"deployment.environment":t.environment},t.serviceVersion&&{"service.version":t.serviceVersion},{"telemetry.sdk.name":i,"telemetry.sdk.version":e})}var ns={darwin:"macOS",win32:"Windows",linux:"Linux",android:"Android",freebsd:"FreeBSD",openbsd:"OpenBSD",sunos:"SunOS",aix:"AIX","Mac OS X":"macOS"};var os={trace:{text:"TRACE",number:1},debug:{text:"DEBUG",number:5},info:{text:"INFO",number:9},warn:{text:"WARN",number:13},error:{text:"ERROR",number:17},fatal:{text:"FATAL",number:21}},as=os.info;function ls(t){try{return Ge(String(t))}catch(t){return We}}function hs(t,i,e,s){var n,o=os[t.level||"info"]||as,a=o.text,l=o.number,h=(void 0===(n=$i(s)?s:void 0)&&(n=Date.now()),String(n)+"000000"),u={};i.distinctId&&(u.posthogDistinctId=i.distinctId),i.sessionId&&(u.sessionId=i.sessionId),i.windowId&&(u["window.id"]=i.windowId),Ei(i.sessionStartTimestamp)||(u.sessionStartTimestamp=String(i.sessionStartTimestamp)),Ei(i.lastActivityTimestamp)||(u.lastActivityTimestamp=String(i.lastActivityTimestamp)),i.currentUrl&&(u["url.full"]=i.currentUrl),i.screenName&&(u["screen.name"]=i.screenName),i.appState&&(u["app.state"]=i.appState),i.activeFeatureFlags&&i.activeFeatureFlags.length>0&&(u.feature_flags=i.activeFeatureFlags);var d=r({},u),v=t.attributes;if(v){var c=[];try{c=Object.keys(v)}catch(t){c=[]}for(var f of c){var p=void 0;try{p=v[f]}catch(t){p=We}Object.defineProperty(d,f,{value:p,enumerable:!0,writable:!0,configurable:!0})}}var g={timeUnixNano:h,observedTimeUnixNano:h,severityNumber:l,severityText:a,body:{stringValue:ls(t.body)},attributes:ts(d,e)};return t.trace_id&&(g.traceId=t.trace_id),t.span_id&&(g.spanId=t.span_id),wi(t.trace_flags)||(g.flags=t.trace_flags),g}function us(t,i,e){return ss(t,i,e)}function ds(t,i,e,r){return{resourceLogs:[{resource:{attributes:ts(i)},scopeLogs:[{scope:{name:e,version:r},logRecords:t}]}]}}var vs=class{constructor(t,i,e,r,s,n,o){var a;void 0===n&&(n=()=>Promise.resolve()),this._instance=t,this.xn=i,this.A=e,this.ns=r,this.ss=s,this.ls=n,this.us=o,this.hs=null,this.ds=0,this.vs=0,this.cs=0,this.fs=0,this.ps=0,this.gs=!1,this.ys=i.maxBufferSize,this.bs=Math.max(null!==(a=i.maxQueueSize)&&void 0!==a?a:i.maxBufferSize,i.maxBufferSize),this._s=i.flushIntervalMs,this.ws=i.maxBatchRecordsPerPost,this.ks=i.rateCapWindowMs,this.Ss=i.maxLogsPerInterval}clearQueue(){this.vs++,this._instance.setPersistedProperty(oi.LogsQueue,[])}reset(){this.xs(),this.fs=0,this.ps=0,this.gs=!1,this.cs=0,this.ws=this.xn.maxBatchRecordsPerPost}onReconnect(){this.cs=0,this.Cs()}captureLog(t,i){var e;if(!this._instance.isDisabled&&!this._instance.optedOut&&null!=t&&t.body){var r=this.Ts(t);if(null!==r)if(r.body){if(this.Ms()){var s={record:hs(r,null!==(e=null==i?void 0:i.context)&&void 0!==e?e:this.ns(),this.A,null==i?void 0:i.occurredAtMs)};this.ss(()=>this.Is(s))}}else this.A.info("Log was rejected in beforeSend function")}}Ts(t){var i=this.xn.beforeSend;if(!i)return t;var e=_i(i)?i:[i],r=t;for(var s of e)try{var n=s(r);if(!n)return this.A.info("Log was rejected in beforeSend function"),null;r=n}catch(t){return this.A.error("Error in beforeSend function for log:",t),null}return r}Ms(){if(void 0===this.Ss)return!0;var t=Date.now(),i=t-this.fs;return this.ks>i&&i>=0||(this.fs=t,this.ps=0,this.gs=!1),this.Ss>this.ps?(this.ps++,!0):(this.gs||(this.A.warn("captureLog dropping logs: exceeded "+this.Ss+" logs per "+this.ks+"ms"),this.gs=!0),!1)}flush(){var t=this;return n(function*(){if(!t._instance.isDisabled)return t.hs||(t.hs=t.Es().finally(()=>{t.hs=null})),t.hs})()}Es(){var t=this;return n(function*(){var i;t.xs();var e=null!==(i=t._instance.getPersistedProperty(oi.LogsQueue))&&void 0!==i?i:[];if(0!==e.length)for(var r=e.length,s=0;e.length>0&&r>s;){var n,o,a=t.vs;t.ds=0;var l=Math.min(e.length,t.ws),h=e.slice(0,l),u=ds(h.map(t=>t.record),t.Rs(),null!==(n=t.us)&&void 0!==n?n:t._instance.getLibraryId(),t._instance.getLibraryVersion()),d=yield t._instance.As(u);if(t.vs!==a)return;if("too-large"===d.kind&&h.length>1)t.ws=Math.max(1,Math.floor(h.length/2)),t.A.warn("Received 413 when sending logs batch of size "+h.length+", reducing batch size to "+t.ws);else{if("retry-later"===d.kind)throw d.error;if("too-large"===d.kind?t.A.warn("Dropping a single log record after 413 with batch size 1 — the record is larger than the server cap and cannot be split further."):"ok"===d.kind&&t.xn.maxBatchRecordsPerPost>t.ws&&(t.ws=Math.min(t.xn.maxBatchRecordsPerPost,t.ws+1)),yield t.Ps(h.length),e=null!==(o=t._instance.getPersistedProperty(oi.LogsQueue))&&void 0!==o?o:[],s+=h.length,"fatal"===d.kind)throw d.error}}})()}Ps(t){var i=this;return n(function*(){var e,r=Math.max(0,t-i.ds),s=null!==(e=i._instance.getPersistedProperty(oi.LogsQueue))&&void 0!==e?e:[];i._instance.setPersistedProperty(oi.LogsQueue,s.slice(r)),yield i.ls()})()}Rs(){return us(this.xn,this._instance.getLibraryId(),this._instance.getLibraryVersion())}Is(t){var i;if(!this._instance.optedOut){var e=null!==(i=this._instance.getPersistedProperty(oi.LogsQueue))&&void 0!==i?i:[];this.bs>e.length||(e.shift(),this.ds++,this.A.info("Logs queue is full, dropping oldest record.")),e.push(t),this._instance.setPersistedProperty(oi.LogsQueue,e),this.ys>e.length?this.Fs():this.Cs()}}Fs(t){void 0===t&&(t=this._s),this.Os||(this.Os=ir(()=>{this.Os=void 0,this.Cs()},t))}$s(){var t=Math.min(Math.max(0,this.cs-1),6);return this._s*Math.pow(2,t)}Ds(){var t=this._instance.getPersistedProperty(oi.LogsQueue);return!!t&&t.length>0}shutdown(t){var i=this;return n(function*(){i.xs();var e=i.flush().catch(()=>{});void 0!==t?yield er(e,t):yield e})()}flushWithTimeout(t){var i=this;return n(function*(){var e=i.flush();yield er(e,t,()=>{e.catch(()=>{})})})()}Cs(){this.flush().then(()=>{this.cs=0},t=>{this.cs++,this.A.error("PostHog logs flush failed:",t)}).finally(()=>{!this._instance.isDisabled&&this.Ds()&&this.Fs(this.$s())})}xs(){this.Os&&(clearTimeout(this.Os),this.Os=void 0)}},cs=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function fs(t){return String(t)+"000000"}function ps(t,i,e,r){var s="";return r&&(s=Object.keys(r).sort().map(t=>JSON.stringify(t)+":"+JSON.stringify(r[t])).join(",")),t+"\0"+i+"\0"+(null!=e?e:"")+"\0"+s}var gs=class{constructor(t,i,e){this._instance=t,this.xn=i,this.A=e,this.Ls=new Map,this.hs=null,this.Ns=!1,this.qs=new Map,this.js=new Set,this.Bs=0}count(t,i,e){void 0===i&&(i=1),this.Hs({name:t,type:"count",value:i,unit:null==e?void 0:e.unit,attributes:null==e?void 0:e.attributes})}gauge(t,i,e){this.Hs({name:t,type:"gauge",value:i,unit:null==e?void 0:e.unit,attributes:null==e?void 0:e.attributes})}histogram(t,i,e){this.Hs({name:t,type:"histogram",value:i,unit:null==e?void 0:e.unit,attributes:null==e?void 0:e.attributes})}flush(){var t=this,i=this.hs,e=function(){var e=n(function*(){i&&(yield i.catch(()=>{})),yield t.zs()});return function(){return e.apply(this,arguments)}}()().finally(()=>{this.hs===e&&(this.hs=null)});return this.hs=e,e}drainWindow(){if(0===this.Ls.size)return null;var t=this.Ls;return this.Ls=new Map,this.Ns=!1,this.qs=new Map,this.js=new Set,this.Us(t)}reset(){this.Bs++,this.xs(),this.Ls=new Map,this.hs=null,this.Ns=!1,this.qs=new Map,this.js=new Set}Hs(t){if(!this._instance.isDisabled&&!this._instance.optedOut){var i=this.Ts(t);if(null!==i)if(i.name&&"string"==typeof i.name)if("number"==typeof i.value&&Number.isFinite(i.value))if("count"===i.type&&0>i.value)this.A.warn("Dropping count '"+i.name+"': counters are monotonic, value must be >= 0");else{var e,s;try{e=i.attributes?r({},i.attributes):void 0,s=ps(i.type,i.name,i.unit,e)}catch(t){return void this.A.warn("Dropping metric '"+i.name+"': attributes could not be serialized",t)}var n=this.Ls.get(s);if(!n){if(!this.Ws())return;n={name:i.name,type:i.type,unit:i.unit,attributes:e,windowStartMs:Date.now()},this.Ls.set(s,n)}var o=this.qs.get(i.name);void 0===o?this.qs.set(i.name,i.type):o===i.type||this.js.has(i.name)||(this.js.add(i.name),this.A.warn("Metric name '"+i.name+"' is already used as a "+o+"; recording it as a "+i.type+" too will blend both series in charts. Use a distinct name.")),this.Vs(n,i.value),this.Fs()}else this.A.warn("Dropping metric '"+i.name+"': value must be a finite number");else this.A.warn("Dropping metric with empty name")}}Ws(){return this.xn.maxSeriesPerFlush>this.Ls.size||(this.Ns||(this.Ns=!0,this.A.warn("Metric series cap reached ("+this.xn.maxSeriesPerFlush+" per flush window); dropping new series until the next flush. Reduce attribute cardinality.")),!1)}Vs(t,i){var e;switch(t.type){case"count":t.total=(null!==(e=t.total)&&void 0!==e?e:0)+i;break;case"gauge":t.last=i;break;case"histogram":t.hist||(t.hist={count:0,sum:0,min:i,max:i,bucketCounts:new Array(cs.length+1).fill(0)});var r=t.hist;r.count+=1,r.sum+=i,r.min=Math.min(r.min,i),r.max=Math.max(r.max,i),r.bucketCounts[function(t,i){for(var e=0;i.length>e;e++)if(i[e]>=t)return e;return i.length}(i,cs)]+=1}}Ts(t){var i=this.xn.beforeSend;if(!i)return t;var e=_i(i)?i:[i],r=t;for(var s of e)try{var n=s(r);if(!n)return this.A.info("Metric was rejected in beforeSend function"),null;r=n}catch(t){return this.A.error("Error in beforeSend function for metric:",t),null}return r}Fs(){this.Os||(this.Os=ir(()=>{this.Os=void 0,this.flush().catch(t=>{this.A.error("Metrics flush failed:",t)})},this.xn.flushIntervalMs))}xs(){this.Os&&(clearTimeout(this.Os),this.Os=void 0)}zs(){var t=this;return n(function*(){if(0!==t.Ls.size){var i=t.Ls;t.Ls=new Map,t.Ns=!1,t.qs=new Map,t.js=new Set;var e=t.Bs,r=yield t._instance.Gs(t.Us(i));if(e===t.Bs)switch(r.kind){case"ok":return;case"retry-later":return t.Zs(i),void t.Fs();case"too-large":return void t.A.warn("Metrics batch exceeded the server size limit and was dropped");case"fatal":return void t.A.error("Failed to send metrics batch:",r.error)}}})()}Us(t){return i=this.Js(t),e=function(t,i,e){return ss(t,i,e)}(this.xn,this._instance.getLibraryId(),this._instance.getLibraryVersion()),r=this._instance.getLibraryId(),s=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:ts(e)},scopeMetrics:[{scope:{name:r,version:s},metrics:i}]}]};var i,e,r,s}Js(t){var i=fs(Date.now()),e=new Map;for(var s of t.values()){var n,o=ps(s.type,s.name,s.unit,void 0),a=e.get(o);a||(a=r({name:s.name},s.unit&&{unit:s.unit}),"count"===s.type?a.sum={aggregationTemporality:1,isMonotonic:!0,dataPoints:[]}:"gauge"===s.type?a.gauge={dataPoints:[]}:a.histogram={aggregationTemporality:1,dataPoints:[]},e.set(o,a));var l=ts(null!==(n=s.attributes)&&void 0!==n?n:{},this.A),h=fs(s.windowStartMs);if("count"===s.type){var u,d={attributes:l,startTimeUnixNano:h,timeUnixNano:i,asDouble:null!==(u=s.total)&&void 0!==u?u:0};a.sum.dataPoints.push(d)}else if("gauge"===s.type){var v,c={attributes:l,timeUnixNano:i,asDouble:null!==(v=s.last)&&void 0!==v?v:0};a.gauge.dataPoints.push(c)}else s.hist&&a.histogram.dataPoints.push({attributes:l,startTimeUnixNano:h,timeUnixNano:i,count:s.hist.count,sum:s.hist.sum,min:s.hist.min,max:s.hist.max,bucketCounts:s.hist.bucketCounts,explicitBounds:cs})}return Array.from(e.values())}Zs(t){var i,e;for(var r of t){var s=r[0],n=r[1],o=this.Ls.get(s);if(o)switch(o.windowStartMs=Math.min(o.windowStartMs,n.windowStartMs),o.type){case"count":o.total=(null!==(i=o.total)&&void 0!==i?i:0)+(null!==(e=n.total)&&void 0!==e?e:0);break;case"gauge":break;case"histogram":if(n.hist)if(o.hist){o.hist.count+=n.hist.count,o.hist.sum+=n.hist.sum,o.hist.min=Math.min(o.hist.min,n.hist.min),o.hist.max=Math.max(o.hist.max,n.hist.max);for(var a=0;o.hist.bucketCounts.length>a;a++)o.hist.bucketCounts[a]+=n.hist.bucketCounts[a]}else o.hist=n.hist}else this.Ws()&&this.Ls.set(s,n)}}},_s=function(t,i){var e=(void 0===i?{}:i).debugEnabled,r={q(i){for(var r=arguments.length,s=new Array(r>1?r-1:0),n=1;r>n;n++)s[n-1]=arguments[n];Gt&&(a.DEBUG||Gt.POSTHOG_DEBUG||e)&&!wi(Gt.console)&&Gt.console&&("__rrweb_original__"in Gt.console[i]?Gt.console[i].__rrweb_original__:Gt.console[i])(t,...s)},debug(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];r.q("debug",...i)},info(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];r.q("log",...i)},warn(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];r.q("warn",...i)},error(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];r.q("error",...i)},critical(){for(var i=arguments.length,e=new Array(i),r=0;i>r;r++)e[r]=arguments[r];console.error(t,...e)},uninitializedWarning(t){r.error("You must initialize PostHog before calling "+t)},createLogger:(i,e)=>_s(t+" "+i,e)};return r},ms=_s("[PostHog.js]"),bs=ms.createLogger;function ys(t,i){_i(t)&&t.forEach(i)}function ws(t,i){if(!Ei(t))if(_i(t))t.forEach(i);else if((t=>t instanceof FormData)(t))t.forEach((t,e)=>i(t,e));else for(var e in t)pi.call(t,e)&&i(t[e],e)}var xs=function(t){for(var i=arguments.length,e=new Array(i>1?i-1:0),r=1;i>r;r++)e[r-1]=arguments[r];for(var s of e)for(var n in s)void 0!==s[n]&&(t[n]=s[n]);return t};function Ss(t){for(var i=Object.keys(t),e=i.length,r=new Array(e);e--;)r[e]=[i[e],t[i[e]]];return r}var ks=function(t){try{return t()}catch(t){return}},Es=function(t){return function(){try{for(var i=arguments.length,e=new Array(i),r=0;i>r;r++)e[r]=arguments[r];return t.apply(this,e)}catch(t){ms.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),ms.critical(t)}}},$s=function(t){var i={};return ws(t,function(t,e){(xi(t)&&t.length>0||$i(t))&&(i[e]=t)}),i};function Ps(t){var i=r({},t);for(var e of["name","message","stack","cause","errors"])try{e in t&&(i[e]=t[e])}catch(t){}return i}var Ts=["herokuapp.com","vercel.app","netlify.app"];function Cs(t){var i=null==t?void 0:t.hostname;if(!xi(i))return!1;var e=i.split(".").slice(-2).join(".");for(var r of Ts)if(e===r)return!1;return!0}function Fs(t,i,e,r){var s=null!=r?r:{},n=s.capture,o=s.passive;null==t||t.addEventListener(i,e,{capture:void 0!==n&&n,passive:void 0===o||o})}function As(t){return"ph_toolbar_internal"===t.name}var Is=t=>{if(Xt){try{for(var i=t+"=",e=Xt.cookie.split(";").filter(t=>t.length),r=0;e.length>r;r++){for(var s=e[r];" "==s.charAt(0);)s=s.substring(1,s.length);if(0===s.indexOf(i))return decodeURIComponent(s.substring(i.length,s.length))}}catch(t){}return null}};Math.trunc||(Math.trunc=function(t){return 0>t?Math.ceil(t):Math.floor(t)}),Number.isInteger||(Number.isInteger=function(t){return $i(t)&&isFinite(t)&&Math.floor(t)===t});var Rs=class t{constructor(t){if(this.bytes=t,16!==t.length)throw new TypeError("not 128-bit length")}static fromFieldsV7(i,e,r,s){if(!Number.isInteger(i)||!Number.isInteger(e)||!Number.isInteger(r)||!Number.isInteger(s)||0>i||0>e||0>r||0>s||i>0xffffffffffff||e>4095||r>1073741823||s>4294967295)throw new RangeError("invalid field value");var n=new Uint8Array(16);return n[0]=i/Math.pow(2,40),n[1]=i/Math.pow(2,32),n[2]=i/Math.pow(2,24),n[3]=i/Math.pow(2,16),n[4]=i/256,n[5]=i,n[6]=112|e>>>8,n[7]=e,n[8]=128|r>>>24,n[9]=r>>>16,n[10]=r>>>8,n[11]=r,n[12]=s>>>24,n[13]=s>>>16,n[14]=s>>>8,n[15]=s,new t(n)}toString(){for(var t="",i=0;this.bytes.length>i;i++)t=t+(this.bytes[i]>>>4).toString(16)+(15&this.bytes[i]).toString(16),3!==i&&5!==i&&7!==i&&9!==i||(t+="-");if(36!==t.length)throw new Error("Invalid UUIDv7 was generated");return t}clone(){return new t(this.bytes.slice(0))}equals(t){return 0===this.compareTo(t)}compareTo(t){for(var i=0;16>i;i++){var e=this.bytes[i]-t.bytes[i];if(0!==e)return Math.sign(e)}return 0}},Os=class{generate(){var t=this.generateOrAbort();if(!wi(t))return t;this.Ct=0;var i=this.generateOrAbort();if(wi(i))throw new Error("Could not generate UUID after timestamp reset");return i}generateOrAbort(){var t,i=(t=Date.now(),$i(t)&&isFinite(t)?Math.min(Math.max(Math.floor(t),0),0xffffffffffff):0);if(i>this.Ct)this.Ct=i,this.Mt();else{if(this.Ct>=i+1e4)return;this.Tt++,this.Tt>4398046511103&&(this.Ct++,this.Mt())}return Rs.fromFieldsV7(this.Ct,Math.trunc(this.Tt/Math.pow(2,30)),this.Tt&Math.pow(2,30)-1,this.It.nextUint32())}Mt(){this.Tt=1024*this.It.nextUint32()+(1023&this.It.nextUint32())}constructor(){this.Ct=0,this.Tt=0,this.It=new js}},Ms=t=>{if("u">typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var i=0;t.length>i;i++)t[i]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return t};Gt&&!wi(Gt.crypto)&&crypto.getRandomValues&&(Ms=t=>crypto.getRandomValues(t));var Ds,js=class{nextUint32(){return this.Rt.length>this.At||(Ms(this.Rt),this.At=0),this.Rt[this.At++]}constructor(){this.Rt=new Uint32Array(8),this.At=1/0}},Bs=()=>Ls().toString(),Ls=()=>(Ds||(Ds=new Os)).generate(),Ns="",zs=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;var Us=null,Hs={Et(){if(!ki(Us))return Us;if(Us=!1,Xt)try{var t="__ph_cookie_support_"+Bs();Hs.Ot(t,"xyz"),Us='"xyz"'===Is(t),Hs.Dt(t)}catch(t){Us=!1}return Us},Pt(t){ms.error("cookieStore error: "+t)},Lt:Is,Nt(t){var i;try{i=JSON.parse(Hs.Lt(t))||{}}catch(t){}return i},Ot(t,i,e,r,s){if(!Xt)return!1;try{var n="",o="",a=function(t,i){if(i){var e=function(t,i){if(void 0===i&&(i=Xt),Ns)return Ns;if(!i)return"";if(["localhost","127.0.0.1"].includes(t))return"";for(var e=t.split("."),r=Math.min(e.length,8),s="dmn_chk_"+Bs();!Ns&&r--;){var n=e.slice(r).join("."),o=s+"=1;domain=."+n+";path=/";i.cookie=o+";max-age=3",i.cookie.includes(s)&&(i.cookie=o+";max-age=0",Ns=n)}return Ns}(t);if(!e){var r=(t=>{var i=t.match(zs);return i?i[0]:""})(t);r!==e&&ms.info("Warning: cookie subdomain discovery mismatch",r,e),e=r}return e?"; domain=."+e:""}return""}(Xt.location.hostname,r);if(e){var l=new Date;l.setTime(l.getTime()+864e5*e),n="; expires="+l.toUTCString()}s&&(o="; secure");var h=t+"="+encodeURIComponent(JSON.stringify(i))+n+"; SameSite=Lax; path=/"+a+o;return h.length>3686.4&&ms.warn("cookieStore warning: large cookie, len="+h.length),Xt.cookie=h,!0}catch(t){return!1}},Dt(t,i){if(null!=Xt&&Xt.cookie)try{Hs.Ot(t,"",-1,i)}catch(t){return}}},qs=null,Vs={Et(){if(!ki(qs))return qs;var t=!0;if(wi(Gt))t=!1;else try{var i="__mplssupport__";Vs.Ot(i,"xyz"),'"xyz"'!==Vs.Lt(i)&&(t=!1),Vs.Dt(i)}catch(i){t=!1}return t||ms.error("localStorage unsupported; falling back to cookie store"),qs=t,t},Pt(t){ms.error("localStorage error: "+t)},Lt(t){try{return null==Gt?void 0:Gt.localStorage.getItem(t)}catch(t){Vs.Pt(t)}return null},Nt(t){try{return JSON.parse(Vs.Lt(t))||{}}catch(t){}return null},Ot(t,i){try{return null==Gt||Gt.localStorage.setItem(t,JSON.stringify(i)),!0}catch(t){Vs.Pt(t)}return!1},Dt(t){try{null==Gt||Gt.localStorage.removeItem(t)}catch(t){Vs.Pt(t)}}},Ws=[Z,q,H,W,G,K,gt,pt,ct],Gs=[d,u,D,j,St,xt,g,_t],Ks=t=>t+"_cpm",Js=["__proto__","constructor","prototype"],Xs=t=>{if(!bi(t))return{};var i={};return Object.keys(t).forEach(e=>{-1===Js.indexOf(e)&&(i[e]=t[e])}),i},Ys=function(t,i){void 0===i&&(i=[]);var e={};return[...Gs,...i].forEach(i=>{var r=t[i];wi(r)||ki(r)||""===r||(e[i]=r)}),e},Zs=t=>{for(var i=5381,e=2166136261,r=0;t.length>r;r++){var s=t.charCodeAt(r);i=33*i^s,e=Math.imul(e^s,16777619)}return t.length.toString(36)+"."+(i>>>0).toString(36)+"."+(e>>>0).toString(36)},Qs=(t,i)=>({p:i,f:Zs(JSON.stringify(t))}),tn=(t,i)=>{if(!i)return{properties:[],isValid:!1};try{var e=Hs.Nt(Ks(t)),r=(null==e?void 0:e.f)===Zs(i)&&_i(e.p);return{properties:r?e.p:[],isValid:r}}catch(t){return{properties:[],isValid:!1}}},en=(t,i)=>i+"|"+(Hs.Lt(Ks(t))||""),rn={},sn={Et:()=>!0,Pt(t){ms.error("memoryStorage error: "+t)},Lt:t=>t in rn?rn[t]:null,Nt:t=>t in rn?rn[t]:null,Ot:(t,i)=>(rn[t]=i,!0),Dt(t){delete rn[t]}},nn=null,on={Et(){if(!ki(nn))return nn;if(nn=!0,wi(Gt))nn=!1;else try{var t="__support__";on.Ot(t,"xyz"),'"xyz"'!==on.Lt(t)&&(nn=!1),on.Dt(t)}catch(t){nn=!1}return nn},Pt(t){ms.error("sessionStorage error: ",t)},Lt(t){try{return null==Gt?void 0:Gt.sessionStorage.getItem(t)}catch(t){on.Pt(t)}return null},Nt(t){try{return JSON.parse(on.Lt(t))||null}catch(t){}return null},Ot(t,i){try{return null==Gt||Gt.sessionStorage.setItem(t,JSON.stringify(i)),!0}catch(t){on.Pt(t)}return!1},Dt(t){try{null==Gt||Gt.sessionStorage.removeItem(t)}catch(t){on.Pt(t)}}},an=class{constructor(t){this._instance=t}get xn(){return this._instance.config}get consent(){return this.xo()?0:this.Co}isOptedOut(){return"always"===this.xn.cookieless_mode||this.isRejected()||-1===this.consent&&"on_reject"===this.xn.cookieless_mode}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return 0===this.consent}isRejected(){return 0===this.consent||-1===this.consent&&this.xn.opt_out_capturing_by_default}optInOut(t){this.To.Ot(this.Mo,t?1:0,this.xn.cookie_expiration,this.xn.cross_subdomain_cookie,this.xn.secure_cookie)}reset(){this.To.Dt(this.Mo,this.xn.cross_subdomain_cookie)}get Mo(){var t=this._instance.config,i=t.token,e=t.opt_out_capturing_cookie_prefix;return t.consent_persistence_name||(e?e+i:"__ph_opt_in_out_"+i)}get Co(){var t=this.To.Lt(this.Mo);return ji(t)?1:ui(Bi,t)?0:-1}get To(){var t=this.xn.opt_out_capturing_persistence_type,i="localStorage"===t?Vs:Hs,e=i.Et()?i:sn;if(!this.Io||this.Io!==e){this.Io=e;var r="localStorage"===t?Hs:Vs;r.Lt(this.Mo)&&(this.Io.Lt(this.Mo)||this.optInOut(ji(r.Lt(this.Mo))),r.Dt(this.Mo,this.xn.cross_subdomain_cookie))}return this.Io}xo(){return!!this.xn.respect_dnt&&[null==Jt?void 0:Jt.doNotTrack,null==Jt?void 0:Jt.msDoNotTrack,ni.doNotTrack,null==Jt?void 0:Jt.globalPrivacyControl].some(t=>ji(t))}};function ln(t,i){var e,r=null==t||null==(e=t.config)?void 0:e.get_current_url;if(!mi(r))return i;try{var s=r(i);return xi(s)&&s?s:i}catch(t){return ms.error("Error in get_current_url, falling back to window.location.href",t),i}}function hn(t){return t instanceof Element&&("__POSTHOG_TOOLBAR__"===t.id||!(null==t.closest||!t.closest(".toolbar-global-fade-container")))}function un(t){return!!t&&1===t.nodeType}function dn(t,i){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===i.toLowerCase()}function vn(t){return!!t&&3===t.nodeType}function cn(t){return!!t&&11===t.nodeType&&un(t.host)}function fn(t){return t?di(t).split(/\s+/):[]}function pn(t,i){var e=function(t){var i,e=null==Gt||null==(i=Gt.location)?void 0:i.href;return wi(e)?void 0:ln(t,e)}(i);return!!(e&&t&&t.some(t=>e.match(t)))}function gn(t){var i="";switch(typeof t.className){case"string":i=t.className;break;case"object":i=(t.className&&"baseVal"in t.className?t.className.baseVal:null)||t.getAttribute("class")||"";break;default:i=""}return fn(i)}function _n(t){return Ei(t)?null:di(t).split(/(\s+)/).filter(t=>Un(t)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function mn(t){var i="";return Rn(t)&&!On(t)&&t.childNodes&&t.childNodes.length&&ws(t.childNodes,function(t){var e;vn(t)&&t.textContent&&(i+=null!==(e=_n(t.textContent))&&void 0!==e?e:"")}),di(i)}function bn(t){var i;return wi(t.target)?t.srcElement||null:null!=(i=t.target)&&i.shadowRoot?t.composedPath()[0]||null:t.target||null}var yn=["a","button","form","input","select","textarea","label"];function wn(t,i){var e=t.matches||t.matchesSelector||t.msMatchesSelector||t.mozMatchesSelector||t.webkitMatchesSelector||t.oMatchesSelector;try{return!!e&&e.call(t,i)}catch(t){return!1}}function xn(t,i){if(wi(i))return!0;var e,r=function(t){if(i.some(i=>wn(t,i)))return{v:!0}};for(var s of t)if(e=r(s))return e.v;return!1}function Sn(t){var i=t.parentNode;return!(!i||!un(i))&&i}var kn=[".ph-no-autocapture","[data-ph-no-autocapture]"],En=["next","previous","prev",">","<"],$n=[...En,"+","-","−","–"],Pn=(t,i)=>/[a-z0-9]/i.test(i)?t.includes(i):t===i,Tn=[".ph-no-rageclick",".ph-no-capture"],Cn=["","text","search","email","password","url","tel","number"];function Fn(t,i){if(!Gt||An(t))return!1;var e,r,s,n,o;if(Ti(i)?(e=!!i&&Tn,r=void 0,s=!1):(e=null!==(n=null==i?void 0:i.css_selector_ignorelist)&&void 0!==n?n:Tn,r=null==i?void 0:i.content_ignorelist,s=null!==(o=null==i?void 0:i.ignore_text_selection)&&void 0!==o&&o),!1===e)return!1;if(s&&function(t){return!(!t||!un(t))&&(!!dn(t,"textarea")||(dn(t,"input")?ui(Cn,(t.getAttribute("type")||"").toLowerCase()):function(t){if(t.isContentEditable)return!0;var i=null==t.getAttribute?void 0:t.getAttribute("contenteditable");return"true"===i||""===i}(t)))}(t))return!1;var a=In(t,!1).targetElementList;return!function(t,i){if(!1===t||wi(t))return!1;var e;if(!0===t)e=En;else{if(!_i(t))return!1;if(t.length>10)return ms.error("[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching."),!1;e=t.map(t=>t.toLowerCase())}return i.some(t=>{var i=t.safeText,r=t.ariaLabel;return e.some(t=>Pn(i,t)||Pn(r,t))})}(r,a.map(t=>{var i;return{safeText:mn(t).toLowerCase(),ariaLabel:(null==(i=t.getAttribute("aria-label"))?void 0:i.toLowerCase().trim())||""}}))&&!xn(a,e)}var An=t=>!t||dn(t,"html")||!un(t),In=(t,i)=>{if(!Gt||An(t))return{parentIsUsefulElement:!1,targetElementList:[]};for(var e=!1,r=[t],s=t;s.parentNode&&!dn(s,"body");)if(cn(s.parentNode))r.push(s.parentNode.host),s=s.parentNode.host;else{var n=Sn(s);if(!n)break;if(i||yn.indexOf(n.tagName.toLowerCase())>-1)e=!0;else try{var o=Gt.getComputedStyle(n);o&&"pointer"===o.getPropertyValue("cursor")&&(e=!0)}catch(t){}r.push(n),s=n}return{parentIsUsefulElement:e,targetElementList:r}};function Rn(t){for(var i=new Set,e=0,r=t;r.parentNode&&!dn(r,"body");r=r.parentNode){if(e++>=1e3||i.has(r))return!1;i.add(r);var s=gn(r);if(ui(s,"ph-sensitive")||ui(s,"ph-no-capture"))return!1}if(ui(gn(t),"ph-include"))return!0;var n=t.type||"";if(xi(n))switch(n.toLowerCase()){case"hidden":case"password":return!1}var o=t.name||t.id||"";return!xi(o)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(o.replace(/[^a-zA-Z0-9]/g,""))}function On(t){return!!(dn(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||dn(t,"select")||dn(t,"textarea")||"true"===t.getAttribute("contenteditable"))}var Mn=new RegExp("^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$"),Dn=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,jn=[16,15,14,13],Bn=new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),Ln=new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),Nn=/[0-9A-Za-z_]/;function zn(t){for(var i=0,e=!1,r=t.length-1;r>=0;r--){var s=t.charCodeAt(r)-48;e&&(s*=2)>9&&(s-=9),i+=s,e=!e}return i%10==0}function Un(t,i){if(void 0===i&&(i=!0),Ei(t))return!1;if(xi(t)){if(t=di(t),i?Mn.test((t||"").replace(/[- ]/g,"")):function(t){var i;for(Dn.lastIndex=0;i=Dn.exec(t);){var e=i[2];if(e)for(var r=e.replace(/[- ]/g,""),s=0;r.length>s;s++)for(var n of jn){var o=s+n;if(r.length>=o){var a=r.slice(s,o);if(Mn.test(a)&&zn(a))return!0}}}return!1}(t))return!1;if(i?Bn.test(t):function(t){var i;for(Ln.lastIndex=0;i=Ln.exec(t);){var e=i[1],r=i[3];if(!(e&&r&&Nn.test(e)&&Nn.test(r)))return!0}return!1}(t))return!1}return!0}function Hn(t){var i=mn(t);return Un(i=(i+" "+qn(t)).trim())?i:""}function qn(t){var i="";return t&&t.childNodes&&t.childNodes.length&&ws(t.childNodes,function(t){var e;if(t&&"span"===(null==(e=t.tagName)?void 0:e.toLowerCase()))try{var r=mn(t);i=(i+" "+r).trim(),t.childNodes&&t.childNodes.length&&(i=(i+" "+qn(t)).trim())}catch(t){ms.error("[AutoCapture]",t)}}),i}function Vn(t){return t.replace(/"|\\"/g,'\\"')}function Wn(t){var i=t.attr__class;if(i)return _i(i)?i:fn(i)}var Gn=bs("[Dead Clicks]"),Kn=()=>!0,Jn=t=>{var i,e=!(null==(i=t.instance.persistence)||!i.get_property(k)),r=t.instance.config.capture_dead_clicks;return Ti(r)?r:!!bi(r)||e},Xn=class{get lazyLoadedDeadClicksAutocapture(){return this.Eo}constructor(t,i,e){this.instance=t,this.isEnabled=i,this.onCapture=e,this.startIfEnabledOrStop()}onRemoteConfig(t){if(t.ok){var i=t.config;"captureDeadClicks"in i&&(this.instance.persistence&&this.instance.persistence.register({[k]:i.captureDeadClicks}),this.startIfEnabledOrStop())}}startIfEnabledOrStop(){this.isEnabled(this)?this.Ro(()=>{this.Ao()}):this.stop()}Ro(t){var i,e;null!=(i=ni.__PosthogExtensions__)&&i.initDeadClicksAutocapture?t():null==(e=ni.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this.instance,"dead-clicks-autocapture",i=>{i?Gn.error("failed to load script",i):t()})}Ao(){var t;if(Xt){if(!this.Eo&&null!=(t=ni.__PosthogExtensions__)&&t.initDeadClicksAutocapture){var i=bi(this.instance.config.capture_dead_clicks)?r({},this.instance.config.capture_dead_clicks):{};i.__onCapture=this.onCapture,this.onCapture&&(i.capture_dead_swipes=!1),this.Eo=ni.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,i),this.Eo.start(Xt),Gn.info("starting...")}}else Gn.error("`document` not found. Cannot start.")}stop(){this.Eo&&(this.Eo.stop(),this.Eo=void 0,Gn.info("stopping..."))}},Yn=bs("[SegmentIntegration]");function Zn(t,i,e){void 0===e&&(e=!0);var s=t.config.segment;if(!s)return i();var n,o=(t=>mi(t.register))(n=s)?{analytics:n}:n,a=o.analytics,l=o.filterProperties;!function(t,i,e,r){var s=i=>{var s=()=>i.anonymousId()||Bs();t.config.get_device_id=s,r&&i.id()&&(t.register({distinct_id:i.id(),$device_id:s()}),t.persistence.set_property(_t,Lt)),e(r?void 0:i.anonymousId()||void 0)},n=i.user();"then"in n&&mi(n.then)?n.then(s):s(n)}(t,a,e=>{a.register(function(t,i,e){var s=(void 0===e?{}:e).filterProperties;"undefined"!=typeof Promise&&Promise.resolve||Yn.warn("This browser does not have Promise support, and can not use the segment integration");var n=(e,n)=>{if(!n)return e;var o=!!i&&e.event.anonymousId===i&&!e.event.userId;o||e.event.userId||e.event.anonymousId===t.get_distinct_id()||(Yn.info("No userId set, resetting PostHog"),t.reset()),o||(i=void 0),e.event.userId&&e.event.userId!==t.get_distinct_id()&&(Yn.info("UserId set, identifying with PostHog"),t.identify(e.event.userId));var a=t.calculateEventProperties(n,e.event.properties);if(!Ei(s)){var l=e.event.properties||{},h={};for(var u of Object.keys(a))pi.call(l,u)||(h[u]=a[u]);var d=((t,i)=>{var e=_i(t)?t:[t],s=r({},i);for(var n of e)try{if(s=n(s),Ei(s))return null}catch(t){return Yn.error("Error in Segment filterProperties:",t),null}return s})(s,h);if(Ei(d))return e;a=d}return e.event.properties=Object.assign({},a,e.event.properties),e};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded(){return!0},load(){return Promise.resolve()},track(t){return n(t,t.event.event)},page(t){return n(t,Ht)},identify(t){return n(t,Vt)},screen(t){return n(t,"$screen")}}}(t,e,{filterProperties:l})).then(()=>{i()},t=>{Yn.error("Failed to register the Segment integration",t),i()})},e)}var Qn="posthog-js";function to(t,i){var e=void 0===i?{}:i,s=e.organization,n=e.projectId,o=e.prefix,a=e.severityAllowList,l=void 0===a?["error"]:a,h=e.sendExceptionsToPostHog,u=void 0===h||h;return i=>{var e,a,h,d,v,c;if("*"!==l&&!l.includes(i.level)||!t.__loaded)return i;i.tags||(i.tags={});var f=t.requestRouter.endpointFor("ui","/project/"+t.config.token+"/person/"+t.get_distinct_id());i.tags["PostHog Person URL"]=f,t.sessionRecordingStarted()&&(i.tags["PostHog Recording URL"]=t.get_session_replay_url({withTimestamp:!0}));var p=(null==(e=i.exception)?void 0:e.values)||[],g=p.map(t=>r({},t,{stacktrace:t.stacktrace?r({},t.stacktrace,{type:"raw",frames:(t.stacktrace.frames||[]).map(t=>r({},t,{platform:"web:javascript"}))}):void 0})),_={$exception_message:(null==(a=p[0])?void 0:a.value)||i.message,$exception_type:null==(h=p[0])?void 0:h.type,$exception_level:i.level,$exception_list:g,$sentry_event_id:i.event_id,$sentry_exception:i.exception,$sentry_exception_message:(null==(d=p[0])?void 0:d.value)||i.message,$sentry_exception_type:null==(v=p[0])?void 0:v.type,$sentry_tags:i.tags};return s&&n&&(_.$sentry_url=(o||"https://sentry.io/organizations/")+s+"/issues/?project="+n+"&query="+i.event_id),u&&(null==(c=t.exceptions)||c.sendExceptionEvent(_)),i}}var io=class{constructor(t,i,e,r,s,n){this.name=Qn,this.setupOnce=function(o){o(to(t,{organization:i,projectId:e,prefix:r,severityAllowList:s,sendExceptionsToPostHog:null==n||n}))}}},eo=class{constructor(t){this.Po=(t,i,e)=>{e&&(e.noSessionId||e.activityTimeout||e.sessionPastMaximumLength||e.crossTabAdoption)&&(ms.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:t,changeReason:e}),this.Fo=void 0,this._instance.scrollManager.resetContext())},this._instance=t,this.Oo()}Oo(){var t;this.$o=null==(t=this._instance.sessionManager)?void 0:t.onSessionId(this.Po)}destroy(){var t;null==(t=this.$o)||t.call(this),this.$o=void 0}doPageView(t,i){var e,r=this.Do(t,i);return this.Fo={pathname:null!==(e=null==Gt?void 0:Gt.location.pathname)&&void 0!==e?e:"",pageViewId:i,timestamp:t},this._instance.scrollManager.resetContext(),r}doPageLeave(t){var i;return this.Do(t,null==(i=this.Fo)?void 0:i.pageViewId)}doEvent(){var t;return{$pageview_id:null==(t=this.Fo)?void 0:t.pageViewId}}Do(t,i){var e=this.Fo;if(!e)return{$pageview_id:i};var r={$pageview_id:i,$prev_pageview_id:e.pageViewId},s=this._instance.scrollManager.getContext();if(s&&!this._instance.config.disable_scroll_properties){var n=s.maxScrollHeight,o=s.lastScrollY,a=s.maxScrollY,l=s.maxContentHeight,h=s.lastContentY,u=s.maxContentY;if(!(wi(n)||wi(o)||wi(a)||wi(l)||wi(h)||wi(u))){n=Math.ceil(n),o=Math.ceil(o),a=Math.ceil(a),l=Math.ceil(l),h=Math.ceil(h),u=Math.ceil(u);var d=n>1?zi(o/n,0,1,ms):1,v=n>1?zi(a/n,0,1,ms):1,c=l>1?zi(h/l,0,1,ms):1,f=l>1?zi(u/l,0,1,ms):1;r=xs(r,{$prev_pageview_last_scroll:o,$prev_pageview_last_scroll_percentage:d,$prev_pageview_max_scroll:a,$prev_pageview_max_scroll_percentage:v,$prev_pageview_last_content:h,$prev_pageview_last_content_percentage:c,$prev_pageview_max_content:u,$prev_pageview_max_content_percentage:f})}}return e.pathname&&(r.$prev_pageview_pathname=e.pathname),e.timestamp&&(r.$prev_pageview_duration=(t.getTime()-e.timestamp.getTime())/1e3),r}},ro=["flags","surveys"],so={[h]:{exposure:"hidden"},[c]:{exposure:"hidden"},[f]:{exposure:"hidden"},[_]:{exposure:"hidden"},[g]:{exposure:"hidden"},[m]:{exposure:"event"},[b]:{exposure:"hidden"},[P]:{exposure:"hidden"},[y]:{exposure:"event"},[w]:{exposure:"hidden"},[x]:{exposure:"event"},[S]:{exposure:"event"},[k]:{exposure:"event"},[E]:{exposure:"hidden"},[T]:{exposure:"event"},[C]:{exposure:"hidden"},[F]:{exposure:"hidden"},[D]:{exposure:"hidden"},[j]:{exposure:"event"},[A]:{exposure:"event",shouldSkipFromEventProperties:t=>ki(t)},[B]:{exposure:"event"},[L]:{exposure:"event"},[N]:{exposure:"event"},[z]:{exposure:"event"},[U]:{exposure:"hidden"},[H]:{exposure:"hidden",storageGroup:"flags"},[q]:{exposure:"hidden",storageGroup:"flags"},[V]:{exposure:"hidden"},[W]:{exposure:"hidden",storageGroup:"flags"},[G]:{exposure:"hidden",storageGroup:"flags"},[K]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[J]:{exposure:"hidden",storageGroup:"flags"},[X]:{exposure:"hidden"},[Y]:{exposure:"hidden"},[Z]:{exposure:"hidden"},[Q]:{exposure:"hidden"},[it]:{exposure:"hidden",storageGroup:"surveys"},[et]:{exposure:"hidden",storageGroup:"surveys",volatile:!0},[rt]:{exposure:"event"},[st]:{exposure:"hidden"},[nt]:{exposure:"hidden"},[ot]:{exposure:"hidden"},[at]:{exposure:"hidden"},[lt]:{exposure:"hidden"},[ht]:{exposure:"event"},[ut]:{exposure:"event"},[dt]:{exposure:"event"},[vt]:{exposure:"event"},[ct]:{exposure:"hidden"},[ft]:{exposure:"hidden"},[tt]:{exposure:"event"},[pt]:{exposure:"hidden"},[gt]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[_t]:{exposure:"hidden"},[mt]:{exposure:"hidden"},[bt]:{exposure:"hidden"},[yt]:{exposure:"hidden"},[wt]:{exposure:"hidden"},[xt]:{exposure:"hidden"},[St]:{exposure:"hidden"},[I]:{exposure:"event"},[R]:{exposure:"event"},[O]:{exposure:"event"},[M]:{exposure:"event"},[$t]:{exposure:"event"},[Pt]:{exposure:"event"},[Tt]:{exposure:"event"},[Ct]:{exposure:"event"},[Ft]:{exposure:"event"},[At]:{exposure:"event"},[It]:{exposure:"event"},[Rt]:{exposure:"event"},[Ot]:{exposure:"event"},[Mt]:{exposure:"event"},[Dt]:{exposure:"event"}},no=[["$posthog_sr_group_event_trigger_",{exposure:"hidden"}],["$posthog_sr_group_url_trigger_",{exposure:"hidden"}],["$posthog_sr_group_sampling_",{exposure:"hidden"}]],oo=t=>{var i=so[t];if(i)return i;for(var e of no){var r=e[1];if(0===t.indexOf(e[0]))return r}},ao=(t,i)=>{try{var e;return JSON.stringify(t,(t,i)=>Ri(i)?(null!=e||(e=new WeakMap),e.has(i)||e.set(i,Ps(i)),e.get(i)):"bigint"==typeof i?i.toString():i,i)}catch(i){return ci(t)}},lo=t=>{var i=null==Xt?void 0:Xt.createElement("a");return wi(i)?null:(i.href=t,i)},ho=function(t,i){for(var e,r=((t.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),s=0;r.length>s;s++){var n=r[s].split("=");if(n[0]===i){e=n;break}}if(!_i(e)||2>e.length)return"";var o=e[1];try{o=decodeURIComponent(o)}catch(t){ms.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},uo=function(t,i,e){if(!t||!i||!i.length)return t;for(var r=t.split("#"),s=r[1],n=(r[0]||"").split("?"),o=n[1],a=n[0],l=(o||"").split("&"),h=[],u=0;l.length>u;u++){var d=l[u].split("=");_i(d)&&(i.includes(d[0])?h.push(d[0]+"="+e):h.push(l[u]))}var v=a;return null!=o&&(v+="?"+h.join("&")),null!=s&&(v+="#"+s),v},vo=function(t,i){var e=t.match(new RegExp(i+"=([^&]*)"));return e?e[1]:null},co=(t,i)=>t>=i&&ri(),fo=(t,i,e,r)=>{if(0===t){if(ri()){var s=i+1;return s===e&&r(),s}return i}return 0},po=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],go=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...po],_o="<masked>",mo=["li_fat_id"];function bo(t,i,e){if(!Xt)return{};var r,s=i?[...po,...e||[]]:[],n=yo(uo(Xt.URL,s,_o),t);return xs((r={},ws(mo,function(t){var i=Is(t);r[t]=i||null}),r),n)}function yo(t,i){var e=go.concat(i||[]),r={};return ws(e,function(i){var e=ho(t,i);r[i]=e||null}),r}function wo(t){var i=function(t){return t?0===t.search("https?://(.*)google.([^/?]*)")?"google":0===t.search("https?://(.*)bing.com")?"bing":0===t.search("https?://(.*)yahoo.com")?"yahoo":0===t.search("https?://(.*)duckduckgo.com")?"duckduckgo":null:null}(t),e="yahoo"!=i?"q":"p",r={};if(!ki(i)){r.$search_engine=i;var s=Xt?ho(Xt.referrer,e):"";s.length&&(r.ph_keyword=s)}return r}function xo(){return navigator.language||navigator.userLanguage}var So="$direct";function ko(){return(null==Xt?void 0:Xt.referrer)||So}function Eo(t,i,e){var r;void 0===e&&(e=!1);var s=t?[...po,...i||[]]:[],n=null==(r=e?tr(null==Yt?void 0:Yt.href):null==Yt?void 0:Yt.href)?void 0:r.substring(0,1e3);return{r:ko().substring(0,1e3),u:n?uo(n,s,_o):void 0}}function $o(t,i){var e;void 0===i&&(i=!1);var r=t.r,s=t.u,n=i?tr(s):s,o={$referrer:r,$referring_domain:null==r?void 0:r==So?So:null==(e=lo(r))?void 0:e.host};if(n){o.$current_url=n;var a=lo(n);o.$host=null==a?void 0:a.host,o.$pathname=null==a?void 0:a.pathname,xs(o,yo(n))}return r&&xs(o,wo(r)),o}function Po(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(t){return}}function To(){try{return(new Date).getTimezoneOffset()}catch(t){return}}var Co={flags:gt,surveys:et},Fo=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],Ao=t=>t+"_cookie_identity_change_pending",Io=t=>{var i="",e=0;for(var r of t){var s=encodeURIComponent(JSON.stringify(r).slice(1,-1)).length;if(e+s>1e3)break;i+=r,e+=s}return i},Ro="main",Oo=[H,q,W,G,K,gt,J,Z],Mo=t=>-1!==Oo.indexOf(t),Do=(t,i)=>{try{return JSON.stringify(t)===JSON.stringify(i)}catch(e){return t===i}},jo=t=>{if(!t)return{};var i=JSON.parse(t);return bi(i)?i:{}},Bo=(t,i)=>{ws(t,(e,r)=>{var s=oo(r);s&&"event"!==s.exposure||{}.hasOwnProperty.call(i,r)||delete t[r]})},Lo=class{constructor(t,i,e){if(void 0===e&&(e=!0),this.Lo={},this.No=!1,this.qo=!1,this.jo=!1,this.Bo=!1,this.Ho=!1,this.zo=new Map,this.Uo=!1,this.Wo=!1,this.Vo=!1,this.Go=!1,this.Zo=new Set,this.xn=t,this.Jo=e,this.props={},this.Qo=void 0,this.Ko=(t=>{var i="";return t.token&&(i=t.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),t.persistence_name?"ph_"+t.persistence_name:"ph_"+i+"_posthog"})(t),this.To=this.Xo(t),this.jo=this.Yo(t),this.load(),this.ta(),t.debug&&ms.info("Persistence loaded",t.persistence,r({},this.props)),this.update_config(t,t,i),this.save(),Gt){var s=()=>this.flush();Fs(Gt,"beforeunload",s,{capture:!1}),Fs(Gt,"pagehide",s,{capture:!1}),this.ea=t=>{if(this.No&&(!t.storageArea||t.storageArea===(null==Gt?void 0:Gt.localStorage))&&t.key)if(t.key!==this.Ko){if(this.jo){var i=ro.find(i=>t.key===this.ia(i));i&&this.ra(t.key,i)}}else this.ra(t.key,Ro)},Fs(Gt,"storage",this.ea)}}markCrossTabFeatureFlagChanges(t){Object.entries(t).forEach(t=>{var i=t[0],e=t[1],r=this.zo.get(i);if(Mo(i)&&!0!==r)if(!0!==e){var s=new Set(r||[]);e.forEach(t=>s.add(t)),s.size&&this.na(i,s)}else this.na(i,!0)})}onCrossTabFeatureFlagChange(t){return this.Zo.add(t),()=>this.Zo.delete(t)}destroy(){this.ea&&Gt&&(Gt.removeEventListener("storage",this.ea),this.ea=void 0),this.Zo.clear()}ra(t,i,e){if(void 0===e&&(e=!0),this.gi)return!1;var r,s;try{if(s=Vs.Lt(t),ki(s)){var n=this.sa(i);return n.storageValue=null,i!==Ro&&(n.persisted=!1),!1}r=jo(s)}catch(t){return!1}var o=i===Ro?r:Vs.Nt(this.Ko);if(o&&this.oa(o))return!1;var a=this.aa(r,i,e);return i===Ro&&this.jo&&!Do(this.la().main,r)||this.ua(r,i,!0,s),a}oa(t){var i=this.props[u],e=t[u];return!wi(i)&&!wi(e)&&i!==e}ua(t,i,e,r){var s=this.sa(i);s.storageValue=r,i!==Ro&&(s.persisted=e);try{s.fingerprint=this.ha(t,i)}catch(t){s.fingerprint=void 0}}aa(t,i,e){var r=!1;return Oo.forEach(e=>{var s,n=null==(s=oo(e))?void 0:s.storageGroup;if(!(i===Ro&&this.jo&&n||i!==Ro&&n!==i)){var o=e in t,a=this.da(e,o?t[e]:void 0),l=this.zo.has(e)?e in this.props:o;l===e in this.props&&Do(a,this.props[e])||(l?this.va(e,a,!1):this.ca(e,!1),r=!0)}}),r&&e&&this.Zo.forEach(t=>t()),r}fa(){if(!this.No)return!1;try{this.Vo=!1;var t,i=Vs.Lt(this.Ko),e=this.sa(Ro),r=!1,s=!1;if(i!==e.storageValue)if(ki(i))e.storageValue=null;else{if(t=jo(i),this.Vo=!this.Wo&&this.oa(t),this.Vo)return!1;s=this.aa(t,Ro,!1),!this.jo||Do(this.la().main,t)?this.ua(t,Ro,!0,i):e.storageValue=i,r=!0}return this.jo&&ro.forEach(i=>{var e=Vs.Lt(this.ia(i)),n=this.sa(i),o=t||{},a=r&&Oo.some(t=>{var e;return(null==(e=oo(t))?void 0:e.storageGroup)===i&&t in o});if(e!==n.storageValue||a){if(ki(e))return n.storageValue=null,n.persisted=!1,void(a&&(s=this.aa(o,i,!1)||s));var l=jo(e);s=this.aa(l,i,!1)||s,this.ua(l,i,!0,e)}}),s}catch(t){return!1}}na(t,i){this.zo.set(t,i);var e=oo(t);null!=e&&e.volatile||(this.sa((this.jo?null==e?void 0:e.storageGroup:void 0)||Ro).fingerprint=void 0,this.pa(t))}ga(){Oo.forEach(t=>this.zo.set(t,!0))}ta(){if(this.No)try{var t=Vs.Lt(this.Ko),i=jo(t);this.sa(Ro).storageValue=t,Oo.forEach(t=>{var e,r=this.jo?null==(e=oo(t))?void 0:e.storageGroup:void 0,s=r?Vs.Lt(this.ia(r)):null;if(r){var n=this.sa(r);n.storageValue=s,n.persisted=!ki(s)}var o=r&&!ki(s)?jo(s):i;t in this.props?this.ma(t,o[t],this.props[t]):t in o&&this.na(t,!0)})}catch(t){}}da(t,i){var e=this.zo.get(t);if(!e)return i;if(!0===e)return this.props[t];if("$active_feature_flags"===t){var s=new Set(_i(i)?i:[]),n=new Set(_i(this.props[t])?this.props[t]:[]);return e.forEach(t=>n.has(t)?s.add(t):s.delete(t)),Array.from(s)}var o=bi(i)?r({},i):{},a=bi(this.props[t])?this.props[t]:{};return e.forEach(t=>{t in a?o[t]=a[t]:delete o[t]}),o}ma(t,i,e){if(Mo(t)){var r=this.zo.get(t);if(!0!==r){var s=i;if(this.No)try{var n,o=this.jo?null==(n=oo(t))?void 0:n.storageGroup:void 0,a=o?this.ia(o):this.Ko;s=jo(Vs.Lt(a))[t]}catch(t){}var l=new Set(r||[]);if("$active_feature_flags"===t){if(!wi(i)&&!_i(i)||!wi(s)&&!_i(s)||!_i(e))return void this.na(t,!0);var h=new Set(i||[]),u=new Set(s||[]),d=new Set(e);new Set([...h,...d]).forEach(t=>{h.has(t)!==d.has(t)&&l.add(t)}),l.forEach(t=>{u.has(t)===d.has(t)&&l.delete(t)})}else{if(!bi(e))return void(Do(s,e)?this.zo.delete(t):this.na(t,!0));if(!wi(i)&&!bi(i)||wi(i)&&yi(e)&&wi(s))return void this.na(t,!0);var v=bi(i)?i:{},c=bi(s)?s:{};new Set([...Object.keys(v),...Object.keys(e)]).forEach(t=>{t in v==t in e&&Do(v[t],e[t])||l.add(t)}),l.forEach(t=>{t in c==t in e&&Do(c[t],e[t])&&l.delete(t)})}l.size?this.na(t,l):this.zo.delete(t)}}}ya(){var t,i=null==(t=this.xn)?void 0:t.persistence_save_debounce_ms;return $i(i)&&i>0?i:0}ba(t){if(this.xn.cookieWinsOnConflict&&"localstorage+cookie"===this.xn.persistence.toLowerCase())if(t)try{var i=Ys(t,this.xn.cookie_persisted_properties||[]),e=Qs(i,this.xn.cookie_persisted_properties||[]),r=JSON.stringify(i)+"|"+JSON.stringify(e),s=Hs.Lt(this.Ko)||void 0;s&&en(this.Ko,s)===r&&(this._a=r,this.wa=s)}catch(t){}else try{var n=Hs.Lt(this.Ko)||void 0;this._a=n?en(this.Ko,n):void 0,this.wa=n}catch(t){}}syncCookieProperties(){return this.ka(this.xn)}ka(t,i){if(void 0===i&&(i=!1),this.gi&&!i||this.Ho||!t.cookieWinsOnConflict||"localstorage+cookie"!==t.persistence.toLowerCase())return!1;var e;try{e=Hs.Lt(this.Ko)||void 0}catch(t){}if(!e||e===this.wa)return!1;var r,s=en(this.Ko,e);try{r=Xs(JSON.parse(e))}catch(t){return!1}if((Hs.Lt(this.Ko)||void 0)!==e)return!1;this._a=s,this.wa=e;var n=tn(this.Ko,e),o=[...Gs,...n.properties],a={};if(Object.keys(r).forEach(t=>{var i=r[t];(wi(i)||ki(i)||""===i||"$user_state"===t&&"anonymous"!==i&&"identified"!==i)&&(a[t]=!0,delete r[t])}),yi(r))return!1;var l="distinct_id"in r||"anonymous"===r.$user_state||"identified"===r.$user_state,h=this.props,d=h[u],v=h[_t],f=xs({},h);[...Gs,...t.cookie_persisted_properties||[]].forEach(t=>{if(-1!==o.indexOf(t)&&!(t in r)&&!a[t]&&(l||"distinct_id"!==t&&"$user_state"!==t)){var i=f[t];(n.isValid||-1===Gs.indexOf(t)||!1!==i&&0!==i)&&delete f[t]}}),this.props=xs(f,r),Oo.forEach(t=>{var i=t in this.props;t in h===i&&Do(h[t],this.props[t])||(i?this.ma(t,h[t],this.props[t]):this.na(t,!0))}),!l||"$user_state"in r||"$user_state"in this.props||this.va(_t,Bt);var p=this.props[u],g=this.props[_t];return!l||p===d&&g===v||(this.Wo=!0,this.Bo=!0,on.Ot(Ao(this.Ko),!0),this.ca(Z),this.ca(q),this.ca(H),this.ca(W),this.ca(G),this.ca(K),this.ca(gt),this.ca(pt),this.ca(ct),"anonymous"!==g||"identified"!==v&&"anonymous"!==r.$user_state&&(wi(d)||p===d)||(Bo(this.props,r),this.ca(Q)),"identified"===g?this.props.$user_id=p:delete this.props.$user_id,this.ca(c)),!0}consumeCookieIdentityChange(){var t=Ao(this.Ko),i=this.Bo||!!on.Lt(t);return this.Bo=!1,i&&on.Dt(t),i}Sa(t){return void 0===t&&(t=!1),!(this.Ho||this.gi&&!t||!this.xn.cookieWinsOnConflict||"localstorage+cookie"!==this.xn.persistence.toLowerCase()||(this.Ho=!0,0))}xa(){this.Ho&&(wi(this.Ca)||(clearTimeout(this.Ca),this.Ca=void 0),delete this.Lo[Ro],this.Ta(!0))}Ma(t){if(void 0===t&&(t=!0),this.Ho)try{t?this.xa():wi(this.Ca)||(clearTimeout(this.Ca),this.Ca=void 0)}finally{this.Ho=!1}}isDisabled(){return!!this.gi}Xo(t){-1===Fo.indexOf(t.persistence.toLowerCase())&&(ms.critical("Unknown persistence type "+t.persistence+"; falling back to localStorage+cookie"),t.persistence="localStorage+cookie");var i,e=function(t,i){void 0===t&&(t=[]),void 0===i&&(i=!1);var e=[...Gs,...t];return r({},Vs,{Nt(t){try{var r,s={};try{r=Hs.Lt(t)||void 0,s=r?Xs(JSON.parse(r)):{}}catch(t){}var n,o=JSON.parse(Vs.Lt(t)||"{}");if(i){var a=tn(t,r),l=[...Gs,...a.properties],h={};Object.keys(s).forEach(t=>{var i=s[t];ki(i)||""===i||"$user_state"===t&&"anonymous"!==i&&"identified"!==i||(h[t]=i)});var d="distinct_id"in h||"anonymous"===h.$user_state||"identified"===h.$user_state;if(Object.keys(h).length>0){var v,c=o[u],f=null!==(v=o.$user_state)&&void 0!==v?v:"anonymous";e.forEach(t=>{if(-1!==l.indexOf(t)&&!(t in s)&&(d||"distinct_id"!==t&&"$user_state"!==t)){var i=o[t];(a.isValid||-1===Gs.indexOf(t)||!1!==i&&0!==i)&&delete o[t]}}),!d||"$user_state"in s||"$user_state"in o||(o[_t]=Bt),!d||("distinct_id"in h?h[u]:o[u])===c&&("$user_state"in h?h[_t]:o[_t])===f||(Ws.forEach(t=>delete o[t]),"identified"===h.$user_state&&"distinct_id"in h?o.$user_id=h[u]:delete o.$user_id,"identified"!==h.$user_state&&(delete o[tt],delete o[Q]),delete o.__alias)}n=xs(o,h)}else n=xs(s,o);return Vs.Ot(t,n),n}catch(t){}return null},Ot(e,r,s,n,o,a){var l=Vs.Ot(e,r,void 0,void 0,a);try{var h=Ys(r,t);if(Object.keys(h).length){if(i){var u=Ks(e),d=Qs(h,t);if(Hs.Ot(u,d,s,n,o,a),Hs.Lt(u)!==JSON.stringify(d)){Hs.Dt(u,n);var v=Ys(r);return Hs.Ot(e,v,s,n,o,a),l}}Hs.Ot(e,h,s,n,o,a)}}catch(t){Vs.Pt(t)}return l},Dt(t,i){try{null==Gt||Gt.localStorage.removeItem(t),Hs.Dt(t,i),Hs.Dt(Ks(t),i)}catch(t){Vs.Pt(t)}}})}(t.cookie_persisted_properties||[],t.cookieWinsOnConflict),s=!1,n=!1,o=t.persistence.toLowerCase();return"localstorage"===o&&Vs.Et()?(i=Vs,n=!0):"localstorage+cookie"===o&&e.Et()?(i=e,n=!0,s=!0):"sessionstorage"===o&&on.Et()?i=on:"memory"===o?i=sn:"cookie"===o&&Hs.Et()?(i=Hs,s=!0):e.Et()?(i=e,n=!0,s=!0):Hs.Et()?(i=Hs,s=!0):i=sn,this.No=n,this.qo=s,i}ia(t){return this.Ko+"__"+t}Yo(t){return this.No&&!!t.split_storage}properties(){var t={};return ws(this.props,(i,e)=>{var r=oo(e);if(!r||"event"===r.exposure){if(null!=r&&null!=r.shouldSkipFromEventProperties&&r.shouldSkipFromEventProperties(i))return;t[e]=i}}),t}load(t){if(void 0===t&&(t=!1),!this.gi||t){var i=this.xn.cookieWinsOnConflict&&"localstorage+cookie"===this.xn.persistence.toLowerCase(),e=i?Vs.Nt(this.Ko):null,r={};if(i)try{ws(r=Xs(Hs.Nt(this.Ko)),(t,i)=>{(wi(t)||ki(t)||""===t)&&delete r[i]})}catch(t){}var s=this.To.Nt(this.Ko);if(s&&(this.props=xs({},s)),this.jo&&this.Ia(),i&&s){var n,o,a=null==e?void 0:e[u],l=null!==(n=null==e?void 0:e.$user_state)&&void 0!==n?n:"anonymous",h=s[u],d=null!==(o=s.$user_state)&&void 0!==o?o:"anonymous";if(h!==a||d!==l){this.Bo=!0,on.Ot(Ao(this.Ko),!0);var v=xs({},this.props);Ws.forEach(t=>delete v[t]),"anonymous"!==d||"identified"!==l&&"anonymous"!==r.$user_state&&(wi(a)||h===a)||(Bo(v,r),delete v[Q]),this.props=v;var c=new Set;Ws.forEach(t=>{var i,e=null==(i=oo(t))?void 0:i.storageGroup;e&&c.add(e)}),c.forEach(t=>{var i={};ws(this.props,(e,r)=>{var s;(null==(s=oo(r))?void 0:s.storageGroup)===t&&(i[r]=e)}),yi(i)?(Vs.Dt(this.ia(t)),this.Lo[t]={}):Vs.Ot(this.ia(t),i)&&(this.Lo[t]={persisted:!0,fingerprint:this.ha(i,t)})})}}on.Lt(Ao(this.Ko))&&(this.Bo=!0)}}Ia(){for(var t of ro){var i=Vs.Nt(this.ia(t));if(i&&!yi(i)){var e=this.sa(t);e.persisted=!0,this.Ea(t)||(e.fingerprint=this.ha(i,t)),this.Ra(t,i)||xs(this.props,i)}}}Ea(t){return Object.keys(this.props).some(i=>{var e;return(null==(e=oo(i))?void 0:e.storageGroup)===t})}Ra(t,i){var e=Co[t];if(!e)return!1;var r=i[e],s=this.props[e];return $i(r)&&$i(s)&&s>r}refreshKey(t){var i;if(!(this.gi||"$fbc_persistence"===t&&this.Go)){var e=this.jo?null==(i=oo(t))?void 0:i.storageGroup:void 0,r=e?Vs.Nt(this.ia(e)):this.To.Nt(this.Ko);if(r&&t in r)this.va(t,r[t],!1);else{if(e){var s=this.To.Nt(this.Ko);if(s&&t in s)return void this.va(t,s[t],!1)}this.ca(t,!1)}}}save(){if(!this.gi){var t=this.ya();t>0?wi(this.Ca)&&(this.Ca=setTimeout(()=>{this.Ca=void 0,this.Ta()},t)):this.Ta()}}flush(){wi(this.Ca)||(clearTimeout(this.Ca),this.Ca=void 0,this.Ta())}Ta(t){if(void 0===t&&(t=!1),!(this.gi||this.Ho&&!t)){t||(this.syncCookieProperties(),this.Go||this.xn.cookieWinsOnConflict&&"localstorage+cookie"===this.xn.persistence.toLowerCase()||this.refreshKey(g));var i=!t&&!this.Uo;i||(this.Vo=!1);var e=!!i&&this.fa();if(this.Vo)this.xn.debug&&ms.warn("skipping persistence write because storage belongs to a different distinct ID");else{if(this.jo)return this.Aa(),void(e&&this.Zo.forEach(t=>t()));var r=this.Pa(this.To,this.Ko,this.props,Ro);"written"===r&&this.ba(this.props),"failed"!==r&&(this.zo.clear(),this.Wo=!1,this.Go=!1),e&&this.Zo.forEach(t=>t())}}}Aa(){var t=this,i=this.la(),e=i.main,r=i.groups,s=this.Pa(this.To,this.Ko,e,Ro);"written"===s&&this.ba(e),"failed"!==s&&(this.Wo=!1,this.Go=!1,Oo.forEach(t=>{var i;null!=(i=oo(t))&&i.storageGroup||this.zo.delete(t)}));var n=function(i){var e,s=r[i];if(yi(s)&&(null==(e=t.Lo[i])||!e.persisted))return Oo.forEach(e=>{var r;(null==(r=oo(e))?void 0:r.storageGroup)===i&&t.zo.delete(e)}),1;var n=t.Pa(Vs,t.ia(i),s,i);"failed"!==n&&Oo.forEach(e=>{var r=oo(e);(null==r?void 0:r.storageGroup)!==i||"written"!==n&&r.volatile||t.zo.delete(e)})};for(var o of ro)if(n(o))continue}la(){var t={},i={flags:{},surveys:{}};return ws(this.props,(e,r)=>{var s,n=null==(s=oo(r))?void 0:s.storageGroup;n?i[n][r]=e:t[r]=e}),{main:t,groups:i}}ha(t,i){if(i===Ro)return JSON.stringify(t)+"|"+this.Fa+"|"+this.Oa+"|"+this.$a;var e={};return ws(t,(t,i)=>{var r;e[i]=null!=(r=oo(i))&&r.volatile?"__volatile__":t}),JSON.stringify(e)}Pa(t,i,e,r){var s,n=this.sa(r);if(r!==Ro&&!n.dirty&&!wi(n.fingerprint))return"skipped";try{if((s=this.ha(e,r))===n.fingerprint)return n.dirty=!1,"skipped"}catch(t){s=void 0}return t.Ot(i,e,this.Fa,this.Oa,this.$a,this.xn.debug)?(n.dirty=!1,r!==Ro&&(n.persisted=!0),wi(s)||(n.fingerprint=s),this.No&&(n.storageValue=Vs.Lt(i)),"written"):(this.xn.debug&&ms.warn('failed to persist storage entry "'+i+'"; will retry on next save'),"failed")}remove(t){var i=(void 0===t?{}:t).keepGroupEntries,e=void 0!==i&&i;if(this.ga(),wi(this.Ca)||(clearTimeout(this.Ca),this.Ca=void 0),this.To.Dt(this.Ko,!1),this.To.Dt(this.Ko,!0),!e&&this.Jo)for(var r of ro)Vs.Dt(this.ia(r));e?delete this.Lo[Ro]:this.Lo={},this._a=void 0,this.wa=void 0}clear(){this.remove(),this.props={}}register_once(t,i,e){if(bi(t)){this.syncCookieProperties(),wi(i)&&(i="None"),this.Fa=wi(e)?this.Da:e;var r=!1;if(ws(t,(t,e)=>{this.props.hasOwnProperty(e)&&this.props[e]!==i||(this.va(e,t),r=!0)}),r)return this.save(),!0}return!1}register(t,i){if(bi(t)){this.syncCookieProperties(),this.Fa=wi(i)?this.Da:i;var e=!1;if(ws(t,(i,r)=>{t.hasOwnProperty(r)&&(this.props[r]!==i||bi(i)||_i(i))&&(this.va(r,i),e=!0)}),e)return this.save(),!0}return!1}unregister(t){this.syncCookieProperties();var i="string"==typeof t?[t]:t,e=!1;for(var r of i)r in this.props&&(this.ca(r),e=!0);e&&this.save()}update_campaign_params(){var t=null==Xt?void 0:Xt.URL;if(t!==this.Qo){var i=bo(this.xn.custom_campaign_params,this.xn.mask_personal_data_properties,this.xn.custom_personal_data_properties),e=!yi($s(i));return e&&this.register(i),this.Qo=t,e?i:void 0}}update_search_keyword(){var t;this.register((t=null==Xt?void 0:Xt.referrer)?wo(t):{})}update_referrer_info(){var t;this.register_once({$referrer:ko(),$referring_domain:null!=Xt&&Xt.referrer&&(null==(t=lo(Xt.referrer))?void 0:t.host)||So},void 0)}set_initial_person_info(){if(!this.props.$initial_campaign_params&&!this.props.$initial_referrer_info){var t=Eo(this.xn.mask_personal_data_properties,this.xn.custom_personal_data_properties,this.xn.disable_capture_url_hashes);this.register_once({[xt]:this.qo?{r:Io(t.r),u:t.u?Io(t.u):void 0}:t},void 0)}}get_initial_props(){var t={};ws([wt,yt],i=>{var e=this.props[i];e&&ws(e,function(i,e){t["$initial_"+vi(e)]=i})});var i=this.props[xt];return i&&xs(t,function(t,i){void 0===i&&(i=!1);var e=$o(t,i),r={};return ws(e,function(t,i){r["$initial_"+vi(i)]=t}),r}(i,this.xn.disable_capture_url_hashes)),t}safe_merge(t){return ws(this.props,function(i,e){e in t||(t[e]=i)}),t}update_config(t,i,e){var s=t.persistence!==i.persistence,n=!((t,i)=>{if(t.length!==i.length)return!1;var e=[...t].sort(),r=[...i].sort();return e.every((t,i)=>t===r[i])})(t.cookie_persisted_properties||[],i.cookie_persisted_properties||[]),o=s||n,a=t.cookieWinsOnConflict!==i.cookieWinsOnConflict,l=t.disable_persistence||!!e,h=!!this.gi&&!l;l||this.ka(i,h),this.xn=t,!l&&(s||n||a)&&(this._a=void 0,this.wa=void 0,this.ka(r({},t,{cookie_persisted_properties:i.cookie_persisted_properties}),h));var u=o||a?this.Xo(t):this.To;this.La();var d=this.Yo(t),v=o||d!==this.jo,c=!l&&(v||t.cross_subdomain_cookie!==this.Oa||t.secure_cookie!==this.$a)&&this.Sa(h);this.Uo=v;try{if(this.Da=this.Fa=t.cookie_expiration,this.set_disabled(l),this.set_cross_subdomain(t.cross_subdomain_cookie),this.set_secure(t.secure_cookie),v){var f=this.props;this.clear(),this.To=u,this.jo=d,this.props=f,this.save()}else a&&(this.To=u,l||(delete this.Lo[Ro],this.Ta()))}finally{this.Uo=!1,c&&this.Ma()}}La(){var t=this.props[xt];if(this.qo&&bi(t)&&"string"==typeof t.r){var i=Io(t.r),e="string"==typeof t.u?Io(t.u):t.u;i===t.r&&e===t.u||this.va(xt,r({},t,{r:i,u:e}))}}set_disabled(t){this.gi=t,this.gi?this.remove():this.save()}set_cross_subdomain(t){t!==this.Oa&&(this.Oa=t,this.remove({keepGroupEntries:!0}),this.save())}set_secure(t){t!==this.$a&&(this.$a=t,this.remove({keepGroupEntries:!0}),this.save())}set_event_timer(t,i){var e=this.props.__timers||{};e[t]=i,this.va(_,e),this.save()}remove_event_timer(t){var i=this.props.__timers||{},e=i[t];return wi(e)||(delete i[t],this.va(_,i),this.save()),e}get_property(t){return this.props[t]}set_property(t,i){this.va(t,i),this.save()}va(t,i,e){var r;void 0===e&&(e=!0);var s=this.props[t];this.props[t]=i,e&&("distinct_id"!==t&&"$user_state"!==t||s===i||(this.Wo=!0),"$fbc_persistence"!==t||Do(s,i)||(this.Go=!0),this.ma(t,s,i),null!=(r=oo(t))&&r.volatile||this.pa(t))}ca(t,i){void 0===i&&(i=!0),delete this.props[t],i&&(Mo(t)&&this.na(t,!0),"$fbc_persistence"===t&&(this.Go=!0),this.pa(t))}pa(t){var i,e=null==(i=oo(t))?void 0:i.storageGroup;e&&(this.sa(e).dirty=!0)}sa(t){return this.Lo[t]||(this.Lo[t]={})}},No="gzip-js",zo="base64",Uo="events",Ho="cancelEvents",qo="survey shown",Vo="survey dismissed",Wo="survey sent",Go="$survey_last_seen_date",Ko="popover";function Jo(t){var i=!0;return{dispose(){if(i){i=!1;var e=t();e&&mi(e.then)&&e.then(void 0,()=>{})}}}}var Xo=bs("[RateLimiter]"),Yo=class{constructor(t){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=t=>{var i=t.text;if(i&&i.length)try{(JSON.parse(i).quota_limited||[]).forEach(t=>{Xo.info((t||"events")+" is quota limited."),this.serverLimits[t]=(new Date).getTime()+6e4})}catch(t){return void Xo.warn('could not rate limit - continuing. Error: "'+(null==t?void 0:t.message)+'"',{text:i})}},this.instance=t,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var t;return(null==(t=this.instance.config.rate_limiting)?void 0:t.events_per_second)||10}get captureEventsBurstLimit(){var t;return Math.max((null==(t=this.instance.config.rate_limiting)?void 0:t.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(t){var i,e,r;void 0===t&&(t=!1);var s=this.captureEventsBurstLimit,n=this.captureEventsPerSecond,o=(new Date).getTime(),a=null!==(i=null==(e=this.instance.persistence)?void 0:e.get_property("$capture_rate_limit"))&&void 0!==i?i:{tokens:s,last:o};a.tokens+=(o-a.last)/1e3*n,a.last=o,a.tokens>s&&(a.tokens=s);var l=1>a.tokens;if(l||t||(a.tokens=Math.max(0,a.tokens-1)),l&&!t){var h=($i(a.dropped)?a.dropped:0)+1;a.dropped=h,!this.lastEventRateLimited&&this.Na(h)&&(a.dropped=0)}return this.lastEventRateLimited=l,null==(r=this.instance.persistence)||r.set_property(bt,a),{isRateLimited:l,remainingTokens:a.tokens}}qa(t){var i=this.instance.config.property_denylist;return!_i(i)||!i.includes(t)}ja(){var t;if(this.qa("$current_url")&&this.qa("$pathname")&&null!=Yt&&Yt.pathname)return""+(null!==(t=Yt.origin)&&void 0!==t?t:"")+Yt.pathname}Na(t){var i,e,r=this.captureEventsBurstLimit,s=this.captureEventsPerSecond,n=this.ja(),o=this.qa("$session_id")?null==(i=(e=this.instance).get_session_id)?void 0:i.call(e):void 0,a=[t+" 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 "+s+" events per second and "+r+" events burst limit."},{skip_client_rate_limiting:!0})}isServerRateLimited(t){var i=this.serverLimits[t||"events"]||!1;return!1!==i&&(new Date).getTime()<i}},Zo=bs("[RemoteConfig]"),Qo=class{constructor(t){this._instance=t}get remoteConfig(){var t;return null==(t=ni._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.config}Ba(t){var i,e;null!=(i=ni.__PosthogExtensions__)&&i.loadExternalDependency?null==(e=ni.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,"remote-config",()=>t(this.remoteConfig)):t()}Ha(t){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback:t})}load(){try{if(this.remoteConfig)return Zo.info("Using preloaded remote config",this.remoteConfig),void this.za(this.remoteConfig);if(this._instance.Ua())return void Zo.warn("Remote config is disabled. Falling back to local config.");this.Ba(t=>{if(!t)return Zo.info("No config found after loading remote JS config. Falling back to JSON."),void this.Ha(t=>{this.za(t.json,t)});this.za(t)})}catch(t){Zo.error("Error loading remote config",t),this.za()}}za(t,i){!t&&i&&(0===i.statusCode?i.error||Zo.warn("Failed to fetch remote config from PostHog."):Zo.error("Failed to fetch remote config from PostHog."));try{this._instance.za(t?{ok:!0,config:t}:{ok:!1})}catch(t){Zo.error("Error applying remote config",t)}if(!1!==(null==t?void 0:t.hasFeatureFlags)&&!this._instance.config.advanced_disable_feature_flags_on_first_load)try{var e;null==(e=this._instance.featureFlags)||e.ensureFlagsLoaded()}catch(t){Zo.error("Error loading feature flags",t)}}},ta=Uint8Array,ia=Uint16Array,ea=Uint32Array,ra=new ta([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]),sa=new ta([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]),na=new ta([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),oa=function(t,i){for(var e=new ia(31),r=0;31>r;++r)e[r]=i+=1<<t[r-1];var s=new ea(e[30]);for(r=1;30>r;++r)for(var n=e[r];e[r+1]>n;++n)s[n]=n-e[r]<<5|r;return[e,s]},aa=oa(ra,2),la=aa[1];aa[0][28]=258,la[258]=28;for(var ha=oa(sa,0)[1],ua=new ia(32768),da=0;32768>da;++da){var va=(43690&da)>>>1|(21845&da)<<1;ua[da]=((65280&(va=(61680&(va=(52428&va)>>>2|(13107&va)<<2))>>>4|(3855&va)<<4))>>>8|(255&va)<<8)>>>1}var ca=function(t,i,e){for(var r=t.length,s=0,n=new ia(i);r>s;++s)++n[t[s]-1];var o,a=new ia(i);for(s=0;i>s;++s)a[s]=a[s-1]+n[s-1]<<1;if(e){o=new ia(1<<i);var l=15-i;for(s=0;r>s;++s)if(t[s])for(var h=s<<4|t[s],u=i-t[s],d=a[t[s]-1]++<<u,v=d|(1<<u)-1;v>=d;++d)o[ua[d]>>>l]=h}else for(o=new ia(r),s=0;r>s;++s)o[s]=ua[a[t[s]-1]++]>>>15-t[s];return o},fa=new ta(288);for(da=0;144>da;++da)fa[da]=8;for(da=144;256>da;++da)fa[da]=9;for(da=256;280>da;++da)fa[da]=7;for(da=280;288>da;++da)fa[da]=8;var pa=new ta(32);for(da=0;32>da;++da)pa[da]=5;var ga=ca(fa,9,0),_a=ca(pa,5,0),ma=function(t){return(t/8|0)+(7&t&&1)},ba=function(t,i,e){(null==i||0>i)&&(i=0),(null==e||e>t.length)&&(e=t.length);var r=new(t instanceof ia?ia:t instanceof ea?ea:ta)(e-i);return r.set(t.subarray(i,e)),r},ya=function(t,i,e){var r=i/8|0;t[r]|=e<<=7&i,t[r+1]|=e>>>8},wa=function(t,i,e){var r=i/8|0;t[r]|=e<<=7&i,t[r+1]|=e>>>8,t[r+2]|=e>>>16},xa=function(t,i){for(var e=[],r=0;t.length>r;++r)t[r]&&e.push({s:r,f:t[r]});var s=e.length,n=e.slice();if(!s)return[new ta(0),0];if(1==s){var o=new ta(e[0].s+1);return o[e[0].s]=1,[o,1]}e.sort(function(t,i){return t.f-i.f}),e.push({s:-1,f:25001});var a=e[0],l=e[1],h=0,u=1,d=2;for(e[0]={s:-1,f:a.f+l.f,l:a,r:l};u!=s-1;)a=e[e[d].f>e[h].f?h++:d++],l=e[h!=u&&e[d].f>e[h].f?h++:d++],e[u++]={s:-1,f:a.f+l.f,l:a,r:l};var v=n[0].s;for(r=1;s>r;++r)n[r].s>v&&(v=n[r].s);var c=new ia(v+1),f=Sa(e[u-1],c,0);if(f>i){r=0;var p=0,g=f-i,_=1<<g;for(n.sort(function(t,i){return c[i.s]-c[t.s]||t.f-i.f});s>r;++r){var m=n[r].s;if(i>=c[m])break;p+=_-(1<<f-c[m]),c[m]=i}for(p>>>=g;p>0;){var b=n[r].s;i>c[b]?p-=1<<i-c[b]++-1:++r}for(;r>=0&&p;--r){var y=n[r].s;c[y]==i&&(--c[y],++p)}f=i}return[new ta(c),f]},Sa=function(t,i,e){return-1==t.s?Math.max(Sa(t.l,i,e+1),Sa(t.r,i,e+1)):i[t.s]=e},ka=function(t){for(var i=t.length;i&&!t[--i];);for(var e=new ia(++i),r=0,s=t[0],n=1,o=function(t){e[r++]=t},a=1;i>=a;++a)if(t[a]==s&&a!=i)++n;else{if(!s&&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(s),--n;n>6;n-=6)o(8304);n>2&&(o(n-3<<5|8208),n=0)}for(;n--;)o(s);n=1,s=t[a]}return[e.subarray(0,r),i]},Ea=function(t,i){for(var e=0,r=0;i.length>r;++r)e+=t[r]*i[r];return e},$a=function(t,i,e){var r=e.length,s=ma(i+2);t[s]=255&r,t[s+1]=r>>>8,t[s+2]=255^t[s],t[s+3]=255^t[s+1];for(var n=0;r>n;++n)t[s+n+4]=e[n];return 8*(s+4+r)},Pa=function(t,i,e,r,s,n,o,a,l,h,u){ya(i,u++,e),++s[256];for(var d=xa(s,15),v=d[0],c=d[1],f=xa(n,15),p=f[0],g=f[1],_=ka(v),m=_[0],b=_[1],y=ka(p),w=y[0],x=y[1],S=new ia(19),k=0;m.length>k;++k)S[31&m[k]]++;for(k=0;w.length>k;++k)S[31&w[k]]++;for(var E=xa(S,7),P=E[0],T=E[1],C=19;C>4&&!P[na[C-1]];--C);var F,A,I,R,O=h+5<<3,M=Ea(s,fa)+Ea(n,pa)+o,D=Ea(s,v)+Ea(n,p)+o+14+3*C+Ea(S,P)+(2*S[16]+3*S[17]+7*S[18]);if(M>=O&&D>=O)return $a(i,u,t.subarray(l,l+h));if(ya(i,u,1+(M>D)),u+=2,M>D){F=ca(v,c,0),A=v,I=ca(p,g,0),R=p;var j=ca(P,T,0);for(ya(i,u,b-257),ya(i,u+5,x-1),ya(i,u+10,C-4),u+=14,k=0;C>k;++k)ya(i,u+3*k,P[na[k]]);u+=3*C;for(var B=[m,w],L=0;2>L;++L){var N=B[L];for(k=0;N.length>k;++k)ya(i,u,j[z=31&N[k]]),u+=P[z],z>15&&(ya(i,u,N[k]>>>5&127),u+=N[k]>>>12)}}else F=ga,A=fa,I=_a,R=pa;for(k=0;a>k;++k)if(r[k]>255){var z;wa(i,u,F[257+(z=r[k]>>>18&31)]),u+=A[z+257],z>7&&(ya(i,u,r[k]>>>23&31),u+=ra[z]);var U=31&r[k];wa(i,u,I[U]),u+=R[U],U>3&&(wa(i,u,r[k]>>>5&8191),u+=sa[U])}else wa(i,u,F[r[k]]),u+=A[r[k]];return wa(i,u,F[256]),u+A[256]},Ta=new ea([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Ca=new ta(0),Fa=function(){for(var t=new ea(256),i=0;256>i;++i){for(var e=i,r=9;--r;)e=(1&e&&3988292384)^e>>>1;t[i]=e}return t}(),Aa=function(t,i,e){for(;e;++i)t[i]=e,e>>>=8};function Ia(t,i){void 0===i&&(i={});var e=function(){var t=4294967295;return{p(i){for(var e=t,r=0;i.length>r;++r)e=Fa[255&e^i[r]]^e>>>8;t=e},d(){return 4294967295^t}}}(),r=t.length;e.p(t);var s,n,o,a,l,h,u=(a=10+((s=i).filename&&s.filename.length+1||0),l=8,function(t,i,e,r,s,n){var o=t.length,a=new ta(r+o+5*(1+Math.floor(o/7e3))+s),l=a.subarray(r,a.length-s),h=0;if(!i||8>o)for(var u=0;o>=u;u+=65535){var d=u+65535;o>d?h=$a(l,h,t.subarray(u,d)):(l[u]=n,h=$a(l,h,t.subarray(u,o)))}else{for(var v=Ta[i-1],c=v>>>13,f=8191&v,p=(1<<e)-1,g=new ia(32768),_=new ia(p+1),m=Math.ceil(e/3),b=2*m,y=function(i){return(t[i]^t[i+1]<<m^t[i+2]<<b)&p},w=new ea(25e3),x=new ia(288),S=new ia(32),k=0,E=0,P=(u=0,0),T=0,C=0;o>u;++u){var F=y(u),A=32767&u,I=_[F];if(g[A]=I,_[F]=A,u>=T){var R=o-u;if((k>7e3||P>24576)&&R>423){h=Pa(t,l,0,w,x,S,E,P,C,u-C,h),P=k=E=0,C=u;for(var O=0;286>O;++O)x[O]=0;for(O=0;30>O;++O)S[O]=0}var M=2,D=0,j=f,B=A-I&32767;if(R>2&&F==y(u-B))for(var L=Math.min(c,R)-1,N=Math.min(32767,u),z=Math.min(258,R);N>=B&&--j&&A!=I;){if(t[u+M]==t[u+M-B]){for(var U=0;z>U&&t[u+U]==t[u+U-B];++U);if(U>M){if(M=U,D=B,U>L)break;var H=Math.min(B,U-2),q=0;for(O=0;H>O;++O){var V=u-B+O+32768&32767,W=V-g[V]+32768&32767;W>q&&(q=W,I=V)}}}B+=(A=I)-(I=g[A])+32768&32767}if(D){w[P++]=268435456|la[M]<<18|ha[D];var G=31&la[M],K=31&ha[D];E+=ra[G]+sa[K],++x[257+G],++S[K],T=u+M,++k}else w[P++]=t[u],++x[t[u]]}}h=Pa(t,l,n,w,x,S,E,P,C,u-C,h),n||(h=$a(l,h,Ca))}return ba(a,0,r+ma(h)+s)}(n=t,null==(o=i).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,!h)),d=u.length;return function(t,i){var e=i.filename;if(t[0]=31,t[1]=139,t[2]=8,t[8]=2>i.level?4:9==i.level?2:0,t[9]=3,0!=i.mtime&&Aa(t,4,Math.floor(new Date(i.mtime||Date.now())/1e3)),e){t[3]=8;for(var r=0;e.length>=r;++r)t[r+10]=e.charCodeAt(r)}}(u,i),Aa(u,d-8,e.d()),Aa(u,d-4,r),u}var Ra=!!Qt||!!Zt,Oa="text/plain",Ma=!1,Da=(t,i)=>{var e=t.split("#"),r=e[1],s=e[0].split("?"),n=s[0],o=s[1];if(!o)return t;var a=o.split("&").filter(t=>t.split("=")[0]!==i).join("&");return n+(a?"?"+a:"")+(r?"#"+r:"")},ja=function(t,i,e){var s;void 0===e&&(e=!0);var n=t.split("?"),o=n[0],a=n[1],l=r({},i),h=null!==(s=null==a?void 0:a.split("&").map(t=>{var i,r=t.split("="),s=r[0],n=e&&null!==(i=l[s])&&void 0!==i?i:r[1];return delete l[s],s+"="+n}))&&void 0!==s?s:[],u=function(t,i){var e,r;void 0===i&&(i="&");var s=[];return ws(t,function(t,i){wi(t)||wi(i)||"undefined"===i||(e=encodeURIComponent((t=>t instanceof File)(t)?t.name:t.toString()),r=encodeURIComponent(i),s[s.length]=r+"="+e)}),s.join(i)}(l);return u&&h.push(u),h.length>0?o+"?"+h.join("&"):o},Ba=t=>{if(t.Wa)return t.Wa;var i=t.data,e=t.compression;if(i){if(e===No){var r=Ia(function(t){var i=t.length;if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(t);for(var e=new ta(t.length+(t.length>>>1)),r=0,s=function(t){e[r++]=t},n=0;i>n;++n){if(r+5>e.length){var o=new ta(r+8+(i-n<<1));o.set(e),e=o}var a=t.charCodeAt(n);128>a?s(a):2048>a?(s(192|a>>>6),s(128|63&a)):a>55295&&57344>a?(s(240|(a=65536+(1047552&a)|1023&t.charCodeAt(++n))>>>18),s(128|a>>>12&63),s(128|a>>>6&63),s(128|63&a)):(s(224|a>>>12),s(128|a>>>6&63),s(128|63&a))}return ba(e,0,r)}(ao(i)),{mtime:0});return{contentType:Oa,body:r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength),estimatedSize:r.byteLength}}if(e===zo){var s=(t=>"data="+encodeURIComponent("string"==typeof t?t:ao(t)))(function(t){return t?btoa(encodeURIComponent(t).replace(/%([0-9A-F]{2})/g,(t,i)=>String.fromCharCode(parseInt(i,16)))):t}(ao(i)));return{contentType:"application/x-www-form-urlencoded",body:s,estimatedSize:new Blob([s]).size}}var n=ao(i);return{contentType:"application/json",body:n,estimatedSize:new Blob([n]).size}}},La=t=>{var i,e,s=()=>"sendBeacon"===t.transport?{url:ja(t.url,{compression:zo}),encodedBody:Ba(r({},t,{compression:zo,Wa:void 0}))}:{url:Da(t.url,"compression"),encodedBody:Ba(r({},t,{compression:void 0,Wa:void 0}))};try{i=Ba(t)}catch(i){if(Kr(t.compression,ho(t.url,"compression")))return ms.error("Failed to gzip request body, sending uncompressed payload",i),s();throw i}return i&&Kr(t.compression,ho(t.url,"compression"))&&!((e=i.body)instanceof ArrayBuffer?Gr(new Uint8Array(e)):ArrayBuffer.isView(e)&&Gr(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)))?(Ma=!0,s()):{url:t.url,encodedBody:i}},Na=t=>{try{return La(t)}catch(i){return ms.error(i),void(null==t.callback||t.callback({statusCode:0,error:i}))}},za=function(){var t=n(function*(t){var i=yield function(t,i,e){return Zr.apply(this,arguments)}(ao(t.data),l.DEBUG,{rethrow:!0});if(!i)return t;var e=yield i.arrayBuffer();return r({},t,{Wa:{contentType:Oa,body:e,estimatedSize:e.byteLength}})});return function(i){return t.apply(this,arguments)}}(),Ua=/Failed to fetch|NetworkError|Load failed/i,Ha=t=>"TypeError"===(null==t?void 0:t.name)&&Ua.test((null==t?void 0:t.message)||""),qa=t=>{var i=Na(t);if(i){var e=new Qt,r=i.encodedBody;e.open(t.method||"GET",i.url,!0);var s=null!=r?r:{},n=s.contentType,o=s.body;ws(t.headers,function(t,i){e.setRequestHeader(i,t)}),n&&e.setRequestHeader("Content-Type",n),t.timeout&&(e.timeout=t.timeout),e.onreadystatechange=()=>{if(4===e.readyState){var i={statusCode:e.status,text:e.responseText};if(200===e.status)try{i.json=JSON.parse(e.responseText)}catch(t){}null==t.callback||t.callback(i)}},e.send(o)}},Va=t=>{var i=Na(t);if(i){var e=i.url,s=i.encodedBody,n=null!=s?s:{},o=n.contentType,a=n.body,l=n.estimatedSize,h=new Headers;ws(t.headers,function(t,i){h.append(i,t)}),o&&h.append("Content-Type",o);var u=null,d=!1;if(ti){var v=new ti;u={signal:v.signal,timeout:setTimeout(()=>{var i;d=!0,v.abort(Qe("AbortError","PostHog request timed out"+((i=t.timeout)?" after "+i+"ms":"")))},t.timeout)}}var c=i=>{d&&"AbortError"===(null==i?void 0:i.name)||Ha(i)?ms.warn(i):ms.error(i),null==t.callback||t.callback({statusCode:0,error:i})};try{var f;Zt(e,r({method:(null==t?void 0:t.method)||"GET",headers:h,keepalive:"POST"===t.method&&!t.Va&&52428.8>(l||0),body:a,signal:null==(f=u)?void 0:f.signal},t.fetchOptions)).then(i=>i.text().then(e=>{var r={statusCode:i.status,text:e};if(200===i.status)try{r.json=JSON.parse(e)}catch(t){ms.error(t)}null==t.callback||t.callback(r)})).catch(c).finally(()=>u?clearTimeout(u.timeout):null)}catch(t){u&&clearTimeout(u.timeout),c(t)}}},Wa=t=>{try{var i,e=La(t),s=e.url,n=e.encodedBody,o=null!=n?n:{},a=o.body,l=o.estimatedSize;if(!a)return;var h=a instanceof Blob?a:new Blob([a],{type:o.contentType});if(Jt.sendBeacon(s,h))return;var u=_i(t.data)?t.data:null==(i=t.data)?void 0:i.batch;if(_i(u)&&u.length>1&&(null!=l?l:0)>16384){var d=Math.ceil(u.length/2),v=i=>_i(t.data)?i:r({},t.data,{batch:i});return Wa(r({},t,{data:v(u.slice(0,d))})),void Wa(r({},t,{data:v(u.slice(d))}))}ms.warn("Beacon of ~"+(null!=l?l:0)+" bytes was rejected by the browser, falling back to "+(Zt?"fetch":"XHR")),Zt?Va(r({},t,{Va:!0})):qa(t)}catch(t){ms.warn("Beacon send failed",t)}},Ga=(t,i,e,s)=>{var n="query"===s?"POST"===i?"sent_at":"_":void 0;return ja(e===No?Da(t,"compression"):t,r({},n?{[n]:Date.now().toString()}:{},e===No?{}:{compression:e}))},Ka=[];Zt&&Ka.push({transport:"fetch",method:Va}),Qt&&Ka.push({transport:"XHR",method:qa}),null!=Jt&&Jt.sendBeacon&&Ka.push({transport:"sendBeacon",method:Wa});var Ja=class{constructor(t,i){this.Ga=!0,this.Za=[],this.Ja=zi((null==i?void 0:i.flush_interval_ms)||3e3,250,5e3,ms.createLogger("flush interval"),3e3),this.Qa=t}enqueue(t){this.Za.push(t),this.Ka||this.Xa()}unload(){this.Ya();var t=this.Za.length>0?this.tl():{},i=Object.values(t);[...i.filter(t=>0===t.url.indexOf("/e")),...i.filter(t=>0!==t.url.indexOf("/e"))].map(t=>{this.el(r({},t,{transport:"sendBeacon"}))})}enable(){this.Ga=!1,this.Xa()}Xa(){var t=this;this.Ga||(this.Ka=setTimeout(()=>{if(this.Ya(),this.Za.length>0){var i=this.tl(),e=function(){var e=i[r],s=(new Date).getTime();e.data&&_i(e.data)&&ws(e.data,t=>{t.offset=Math.abs(t.timestamp-s),delete t.timestamp}),t.el(e)};for(var r in i)e()}},this.Ja))}el(t){try{this.Qa(t)}catch(t){ms.error(t)}}Ya(){clearTimeout(this.Ka),this.Ka=void 0}tl(){var t={};return ws(this.Za,i=>{var e,s=i,n=(s?s.batchKey:null)||s.url;wi(t[n])&&(t[n]=r({},s,{data:[]})),null==(e=t[n].data)||e.push(s.data)}),this.Za=[],t}},Xa=class{constructor(t){this._instance=t,this.il=!1,this.rl=3e3,this.Za=[],this.Za=[],this.nl=!0,this.resume()}resume(){if(!wi(Gt)&&"onLine"in Gt.navigator){if(this.nl=Gt.navigator.onLine,this.sl)return;this.sl=()=>{this.nl=!0,this.ol()},this.al=()=>{this.nl=!1},Fs(Gt,"online",this.sl),Fs(Gt,"offline",this.al)}}get length(){return this.Za.length}retriableRequest(i){var s=i.retriesPerformedSoFar,n=e(i,t);Pi(s)&&(n.url=ja(n.url,{retry_count:s})),this._instance._send_request(r({},n,{callback:t=>{if(200!==t.statusCode&&(400>t.statusCode||t.statusCode>=500)){if((0===t.statusCode?3:10)>(null!=s?s:0))return void this.Is(r({retriesPerformedSoFar:s},n));0===t.statusCode&&ms.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!=s?s:0)+" retries.")}null==n.callback||n.callback(t)}}))}Is(t){var i=t.retriesPerformedSoFar||0;t.retriesPerformedSoFar=i+1;var e=function(t){var i=3e3*Math.pow(2,t),e=i/2,r=Math.min(18e5,i),s=(Math.random()-.5)*(r-e);return Math.ceil(r+s)}(i),r=Date.now()+e;this.Za.push({retryAt:r,requestOptions:t});var s="Enqueued failed request for retry in "+e;navigator.onLine||(s+=" (Browser is offline)"),ms.warn(s),this.il||(this.il=!0,this.ll())}ll(){if(this.ul&&clearTimeout(this.ul),0===this.Za.length)return this.il=!1,void(this.ul=void 0);this.ul=setTimeout(()=>{this.nl&&this.Za.length>0&&this.ol(),this.ll()},this.rl)}ol(){var t=Date.now(),i=[],e=this.Za.filter(e=>t>e.retryAt||(i.push(e),!1));if(this.Za=i,e.length>0)for(var r of e)this.retriableRequest(r.requestOptions)}unload(){for(var t of(this.ul&&(clearTimeout(this.ul),this.ul=void 0),this.il=!1,wi(Gt)||(this.sl&&(Gt.removeEventListener("online",this.sl),this.sl=void 0),this.al&&(Gt.removeEventListener("offline",this.al),this.al=void 0)),this.Za)){var i=t.requestOptions;try{this._instance._send_request(r({},i,{transport:"sendBeacon"}))}catch(t){ms.error(t)}}this.Za=[]}},Ya=class{constructor(t){this._instance=t,this.hl=()=>{var t,i,e,r;this.dl||(this.dl={});var s=this.scrollElement(),n=this.scrollY(),o=s?Math.max(0,s.scrollHeight-s.clientHeight):0,a=n+((null==s?void 0:s.clientHeight)||0),l=(null==s?void 0:s.scrollHeight)||0;this.dl.lastScrollY=Math.ceil(n),this.dl.maxScrollY=Math.max(n,null!==(t=this.dl.maxScrollY)&&void 0!==t?t:0),this.dl.maxScrollHeight=Math.max(o,null!==(i=this.dl.maxScrollHeight)&&void 0!==i?i:0),this.dl.lastContentY=a,this.dl.maxContentY=Math.max(a,null!==(e=this.dl.maxContentY)&&void 0!==e?e:0),this.dl.maxContentHeight=Math.max(l,null!==(r=this.dl.maxContentHeight)&&void 0!==r?r:0)}}get vl(){return this._instance.config.scroll_root_selector}getContext(){return this.dl}resetContext(){var t=this.dl;return setTimeout(this.hl,0),t}startMeasuringScrollPosition(){Fs(Gt,"scroll",this.hl,{capture:!0}),Fs(Gt,"scrollend",this.hl,{capture:!0}),Fs(Gt,"resize",this.hl)}scrollElement(){var t;if(!this.vl)return null==Gt||null==(t=Gt.document)?void 0:t.documentElement;for(var i of _i(this.vl)?this.vl:[this.vl]){var e,r=null==Gt||null==(e=Gt.document)?void 0:e.querySelector(i);if(r)return r}}cl(t){var i,e,r="y"===t?"scrollTop":"scrollLeft";if(this.vl){var s=this.scrollElement();return s&&s[r]||0}return Gt?"y"===t?Gt.scrollY||Gt.pageYOffset||(null==(i=Gt.document)||null==(i=i.documentElement)?void 0:i.scrollTop)||0:Gt.scrollX||Gt.pageXOffset||(null==(e=Gt.document)||null==(e=e.documentElement)?void 0:e.scrollLeft)||0:0}scrollY(){return this.cl("y")}scrollX(){return this.cl("x")}},Za=t=>Eo(null==t?void 0:t.config.mask_personal_data_properties,null==t?void 0:t.config.custom_personal_data_properties,null==t?void 0:t.config.disable_capture_url_hashes),Qa=class{constructor(t,i,e,r){this.Be=t=>{var i=this.fl();if(!i||i.sessionId!==t){var e={sessionId:t,props:this.pl(this._instance)};this.gl.register({[mt]:e})}},this._instance=t,this.ml=i,this.gl=e,this.pl=r||Za,this.ml.onSessionId(this.Be)}fl(){return this.gl.props[mt]}getSetOnceProps(){var t,i=null==(t=this.fl())?void 0:t.props;return i?"r"in i?$o(i,this._instance.config.disable_capture_url_hashes):{$referring_domain:i.referringDomain,$pathname:i.initialPathName,utm_source:i.utm_source,utm_campaign:i.utm_campaign,utm_medium:i.utm_medium,utm_content:i.utm_content,utm_term:i.utm_term}:{}}getSessionProps(){var t={};return ws($s(this.getSetOnceProps()),(i,e)=>{"$current_url"===e&&(e="url"),t["$session_entry_"+vi(e)]=i}),t}},tl=class{on(t,i){return this.yl[t]||(this.yl[t]=[]),this.yl[t].push(i),()=>{this.yl[t]=this.yl[t].filter(t=>t!==i)}}emit(t,i){for(var e of this.yl[t]||[])e(i);for(var r of this.yl["*"]||[])r(t,i)}constructor(){this.yl={}}},il=bs("[SessionId]"),el=864e5,rl=class{on(t,i){return this.bl.on(t,i)}constructor(t,i,e){var r;if(this._l=null,this.wl=null,this.kl=[],this.Sl=void 0,this.xl=!1,this.bl=new tl,this.Cl=(t,i)=>!(!Pi(t)||!Pi(i))&&Math.abs(t-i)>this.sessionTimeoutMs,!t.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if("always"===t.config.cookieless_mode)throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this.xn=t.config,this.gl=t.persistence,this.He=void 0,this.Xt=void 0,this._sessionStartTimestamp=null,this.Tl=void 0,this._sessionActivityTimestamp=null,this.Ml=i||Bs,this.Il=e||Bs;var s=this.xn.persistence_name||this.xn.token;if(this._sessionTimeoutMs=1e3*zi(this.xn.session_idle_timeout_seconds||1800,60,36e3,il.createLogger("session_idle_timeout_seconds"),1800),t.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.El(),this.Rl="ph_"+s+"_window_id",this.Al="ph_"+s+"_primary_window_exists",this.Pl()){var n=on.Nt(this.Rl),o=on.Nt(this.Al);n&&!o?this.He=n:on.Dt(this.Rl),on.Ot(this.Al,!0)}null!=(r=this.xn.bootstrap)&&r.sessionID&&this.setBootstrapSessionId(this.xn.bootstrap.sessionID),this.Fl()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(t){return wi(this.kl)&&(this.kl=[]),this.kl.push(t),this.Xt&&t(this.Xt,this.He),()=>{this.kl=this.kl.filter(i=>i!==t)}}Pl(){return"memory"!==this.xn.persistence&&!this.gl.gi&&on.Et()}Ol(t){t!==this.He&&(this.He=t,this.Pl()&&on.Ot(this.Rl,t))}$l(){return this.He?this.He:this.Pl()?on.Nt(this.Rl):null}Dl(t){var i=this._l;return!ki(i)&&!ki(t)&&5e3>Math.abs(t-i)}Ll(t,i,e){var r=i!==this._sessionActivityTimestamp,s=!(t!==this.Xt||e!==this._sessionStartTimestamp);this._sessionStartTimestamp=e,this._sessionActivityTimestamp=i,this.Xt=t,s&&!r||s&&this.Dl(i)||(this._l=i,this.gl.register({[D]:[i,t,e]}))}Nl(){var t,i=null==(t=this.xn)?void 0:t.persistence_save_debounce_ms;return Pi(i)&&i>0}ql(){this.Nl()?this.gl.refreshKey(D):(this.gl.flush(),this.gl.load())}jl(){var t;if(!ki(this._sessionActivityTimestamp)&&this._sessionActivityTimestamp!==this._l){this.ql();var i=this.Bl();i[1]===this.Xt&&i[2]===this._sessionStartTimestamp&&(this._l=this._sessionActivityTimestamp,this.gl.register({[D]:[this._sessionActivityTimestamp,null!==(t=this.Xt)&&void 0!==t?t:null,this._sessionStartTimestamp]}),this.gl.flush())}}Hl(){var t=this.Bl()[0],i=Pi(t)?t:0,e=Pi(this._sessionActivityTimestamp)?this._sessionActivityTimestamp:0;return Math.max(i,e)}zl(t){return this.ql(),this.Cl(t,this.Hl())}Bl(){var t=this.gl.props[D];return _i(t)&&2===t.length&&t.push(t[0]),t||[0,null,0]}resetSessionId(){this._l=null,this.Tl=void 0,clearTimeout(this.Ul),this.Ul=void 0,this.Ll(null,null,null)}setBootstrapSessionId(t,i){void 0===i&&(i=!1);var e=function(t,i){void 0===i&&(i=(new Date).getTime());try{var e=(t=>{var i=t.replace(/-/g,"");if(32!==i.length)throw new Error("Not a valid UUID");if("7"!==i[12])throw new Error("Not a UUIDv7");return parseInt(i.substring(0,12),16)})(t);return e>i+6e4?void il.error("Bootstrap sessionID cannot be in the future"):e}catch(t){return void il.error("Invalid sessionID in bootstrap",t)}}(t);return!wi(e)&&(i?this.Tl={sessionId:t,sessionStartTimestamp:e}:this.Ll(t,(new Date).getTime(),e),!0)}destroy(){this.xl=!0,this.jl(),clearTimeout(this.Ul),this.Ul=void 0,this.Sl&&Gt&&(Gt.removeEventListener(Ut,this.Sl,{capture:!1}),this.Sl=void 0),this.kl=[]}Fl(){this.Sl=()=>{this.jl(),this.Pl()&&on.Dt(this.Al)},Fs(Gt,Ut,this.Sl,{capture:!1})}checkAndGetSessionAndWindowId(t,i,e){if(void 0===t&&(t=!1),void 0===i&&(i=null),void 0===e&&(e=!1),"always"===this.xn.cookieless_mode)throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var r=i||(new Date).getTime(),s=this.Xt;if(e)this.wl=r;else if(ki(this.wl)||this.wl>r||r-this.wl>=1e3){var n,o;null==(n=(o=this.gl).syncCookieProperties)||n.call(o),this.wl=r}var a=this.Bl(),l=a[1],h=a[2],u=!wi(s)&&l!==s,d=this.Hl(),v=this.$l(),c=this.Tl,f=!!c&&(c.sessionStartTimestamp>r+6e4||r-c.sessionStartTimestamp>el),p=c?f:Pi(h)&&Math.abs(r-h)>el,g=!1,_=u,m=!l||!!c,b=l,y=!m&&!t&&this.Cl(r,d);if(y){(y=this.zl(r))||il.info("cross-tab refresh kept the session alive",{sessionId:l});var w=this.Bl();l=w[1],h=w[2]}if(m||y||p){_=!1;var x=c&&!f;l=x?c.sessionId:this.Ml(),v=this.Il(),il.info("new session ID assigned",{sessionId:l,windowId:v,bootstrapped:!!x,changeReason:{noSessionId:m,activityTimeout:y,sessionPastMaximumLength:p}}),h=x?c.sessionStartTimestamp:r,this.Tl=void 0,g=!0}else v||(v=this.Il(),g=!0),(_=_||l!==b)&&(il.info("adopted cross-tab session id",{sessionId:l,windowId:v}),g=!0);var S=Pi(d)&&t&&!p?d:r,k=Pi(h)?h:(new Date).getTime();this.Ol(v),this.Ll(l,S,k),t||this.El();var E={noSessionId:m,activityTimeout:y,sessionPastMaximumLength:p,crossTabAdoption:_};return g&&this.kl.forEach(t=>t(l,v,E)),{sessionId:l,windowId:v,sessionStartTimestamp:k,changeReason:g?E:void 0,lastActivityTimestamp:d}}El(){this.xl||(clearTimeout(this.Ul),this.Ul=setTimeout(()=>{if(!this.xl)if(this.zl((new Date).getTime())){var t=this.Xt;this.resetSessionId(),this.bl.emit("forcedIdleReset",{idleSessionId:t})}else this.El()},1.1*this.sessionTimeoutMs))}},sl=function(t,i){if(!t)return!1;var e=t.userAgent;if(e&&Ni(e,i))return!0;try{var r=null==t?void 0:t.userAgentData;if(null!=r&&r.brands&&r.brands.some(t=>Ni(null==t?void 0:t.brand,i)))return!0}catch(t){}return!!t.webdriver};function nl(){return(nl=n(function*(){var t=null==Jt?void 0:Jt.userAgentData;if(null!=t&&t.getHighEntropyValues)try{var i,e=null==(i=yield t.getHighEntropyValues(["model"]))?void 0:i.model;return xi(e)&&e.length>0?e:void 0}catch(t){return void ms.info("Unable to resolve $device_model from userAgentData.getHighEntropyValues",t)}})).apply(this,arguments)}function ol(t,i){var e="$survey_"+i+"/"+t.id;return t.current_iteration&&t.current_iteration>0&&(e="$survey_"+i+"/"+t.id+"/"+t.current_iteration),e}function al(t){var i;return!(null==(i=t.conditions)||null==(i=i.events)||null==(i=i.values)||!i.length)}var ll=(t,i)=>{if(!(t=>{try{new RegExp(t)}catch(t){return!1}return!0})(i))return!1;try{return new RegExp(i).test(t)}catch(t){return!1}},hl=t=>t.toLowerCase(),ul={exact:(t,i)=>i.some(i=>t.some(t=>i===t)),is_not:(t,i)=>i.every(i=>t.every(t=>i!==t)),regex:(t,i)=>i.some(i=>t.some(t=>ll(i,t))),not_regex:(t,i)=>i.every(i=>t.every(t=>!ll(i,t))),icontains:(t,i)=>i.map(hl).some(i=>t.map(hl).some(t=>i.includes(t))),not_icontains:(t,i)=>i.map(hl).every(i=>t.map(hl).every(t=>!i.includes(t))),gt:(t,i)=>i.some(i=>{var e=parseFloat(i);return!isNaN(e)&&t.some(t=>e>parseFloat(t))}),lt:(t,i)=>i.some(i=>{var e=parseFloat(i);return!isNaN(e)&&t.some(t=>e<parseFloat(t))})};function dl(t,i){return!t||Object.entries(t).every(t=>{var e=t[1],r=null==i?void 0:i[t[0]];if(null==r)return!1;var s=ul[e.operator];return!!s&&s(e.values,[String(r)])})}function vl(t,i,e){return ao({distinct_id:t,userPropertiesToSet:i,userPropertiesToSetOnce:e})}var cl="custom",fl="i.posthog.com",pl=/^\/static\//,gl=["/s/","/e/","/i/"],_l=class{constructor(t){this.Wl={},this.instance=t}get apiHost(){var t=this.instance.config.api_host.trim().replace(/\/$/,"");return"https://app.posthog.com"===t?"https://us.i.posthog.com":t}get flagsApiHost(){var t=this.instance.config.flags_api_host;return t?t.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var t,i=null==(t=this.instance.config.ui_host)?void 0:t.replace(/\/$/,"");return i||(i=this.apiHost.replace("."+fl,".posthog.com")),"https://app.posthog.com"===i?"https://us.posthog.com":i}get region(){return this.Wl[this.apiHost]||(this.Wl[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":cl),this.Wl[this.apiHost]}Vl(t){if(pl.test(t)){var i=this.instance.config.asset_host;if("string"==typeof i)return i.trim().replace(/\/$/,"")||void 0}}Gl(t){var i=lo(t);return i?i.protocol+"//"+i.host+i.pathname:void 0}Zl(t,i,e){if("ui"===t)return e;var r=e,s=this.instance.config.rewriteRequestPath;if(s){var n,o=(null==(n=lo(e))?void 0:n.href)||e;r=s(new URL(o)).toString()}if(s&&"api"===t&&gl.some(t=>0===i.indexOf(t))){var a=this.Gl(r);if(a){var l,h=this.apiHost,u=this.Jl;(null==(l=u)?void 0:l.apiHost)===h&&u.rewriteRequestPath===s||(this.Jl=u={apiHost:h,rewriteRequestPath:s,urls:new Set}),u.urls.add(a)}}return r}isIngestionEndpoint(t){var i=this.Jl,e=this.Gl(t);return(null==i?void 0:i.apiHost)===this.apiHost&&i.rewriteRequestPath===this.instance.config.rewriteRequestPath&&!!e&&i.urls.has(e)}endpointFor(t,i){if(void 0===i&&(i=""),i&&(i="/"===i[0]?i:"/"+i),"ui"===t)return this.Zl(t,i,this.uiHost+i);if("flags"===t)return this.Zl(t,i,this.flagsApiHost+i);if("assets"===t){var e=this.Vl(i);if(e)return this.Zl(t,i,""+e+i)}if(this.region===cl)return this.Zl(t,i,this.apiHost+i);var r=fl+i;switch(t){case"assets":return this.Zl(t,i,"https://"+this.region+"-assets."+r);case"api":return this.Zl(t,i,"https://"+this.region+"."+r)}}},ml=bs("[Surveys]"),bl=t=>{try{var i=(t=>((t,i)=>"seenSurvey_"+function(t){return t.current_iteration&&t.current_iteration>0?t.id+"_"+t.current_iteration:t.id}(i))(0,t))(t);if(localStorage.getItem(i))return;localStorage.setItem(i,"true")}catch(t){ml.error("Failed to persist survey seen state",t)}},yl=["popover","widget","api"],wl={ignoreConditions:!1,ignoreDelay:!1,displayType:Ko},xl=bs("[PostHog ExternalIntegrations]"),Sl={intercom:"intercom-integration",crispChat:"crisp-chat-integration"},kl=class{constructor(t){this._instance=t}Ro(t,i){var e;null==(e=ni.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,t,t=>{if(t)return xl.error("failed to load script",t);i()})}startIfEnabledOrStop(){var t=this,i=function(){var i,r,s,n=e[0],o=e[1];!o||null!=(i=ni.__PosthogExtensions__)&&null!=(i=i.integrations)&&i[n]||t.Ro(Sl[n],()=>{var i;null==(i=ni.__PosthogExtensions__)||null==(i=i.integrations)||null==(i=i[n])||i.start(t._instance)}),!o&&null!=(r=ni.__PosthogExtensions__)&&null!=(r=r.integrations)&&r[n]&&(null==(s=ni.__PosthogExtensions__)||null==(s=s.integrations)||null==(s=s[n])||s.stop())};for(var e of Object.entries(null!==(r=this._instance.config.integrations)&&void 0!==r?r:{})){var r;i()}}},El=class{constructor(t,i){this.A=t,this.ao=i,this.Ql=new Map,this.fo=!1}add(t){var i=this;return n(function*(){if(i.fo)throw new Error("Cannot add an extension to a disposed ExtensionRuntime");if(i.Ql.has(t.name))throw new Error('Browser extension "'+t.name+'" is already registered');i.Ql.set(t.name,t);try{var e=t.setup(i.ao);e&&(yield e)}catch(e){var r=i.Ql.get(t.name)===t;r&&i.Ql.delete(t.name),i.A.error('Failed to set up browser extension "'+t.name+'"',e),r&&i.Kl(t)}})()}getExtension(t){return this.Ql.get(t)}dispose(){if(!this.fo){this.fo=!0;var t=Array.from(this.Ql.values()).reverse();for(var i of(this.Ql.clear(),t))this.Kl(i)}}Kl(t){try{var i=null==t.dispose?void 0:t.dispose();i&&mi(i.then)&&i.then(void 0,i=>{this.A.error('Failed to dispose browser extension "'+t.name+'"',i)})}catch(i){this.A.error('Failed to dispose browser extension "'+t.name+'"',i)}}},$l=class{constructor(t){this._instance=t}initialize(){}get(t){var i=this._instance.persistence;if("string"==typeof t)return null==i?void 0:i.get_property(t);var e={};for(var r of t){var s=null==i?void 0:i.get_property(r);wi(s)||(e[r]=s)}return e}set(t,i){var e;null==(e=this._instance.persistence)||e.register("string"==typeof t?{[t]:i}:t)}remove(t){var i;null==(i=this._instance.persistence)||i.unregister(t)}},Pl="extensionsRemoteConfig",Tl=class{constructor(t){this.instance=t,this.fo=!1,this.A=ms,this.Xl=t.Yl,this.kv=new $l(t),this.onEvent=t=>Jo(this.instance.on("eventCaptured",i=>{try{t({event:i.event,properties:i.properties})}catch(t){this.A.error("Browser extension event listener failed",t)}})),this.onRemoteConfig=t=>{if(this.fo)return Jo(()=>{});var i=i=>{try{t(i)}catch(t){this.A.error("Browser extension remote config listener failed",t)}},e=this.instance.tu.on(Pl,i);return this.Xl&&i(this.Xl),Jo(e)},this.eu=new El(ms.createLogger("[BrowserExtensions]"),this)}get logger(){return this.A}get distinctId(){return this.instance.get_distinct_id()}get anonymousId(){var t;return null!==(t=this.instance.get_property("$device_id"))&&void 0!==t?t:this.distinctId}get deviceId(){var t=this.instance.get_property(d);return"string"==typeof t?t:void 0}get library(){return{name:l.LIB_NAME,version:l.LIB_VERSION}}get initialPersonProperties(){var t,i;return null!==(t=null==(i=this.instance.persistence)?void 0:i.get_initial_props())&&void 0!==t?t:{}}get groups(){return this.instance.getGroups()}get session(){try{var t,i,e,r,s=null==(t=this.instance.sessionManager)?void 0:t.checkAndGetSessionAndWindowId(!0);return{sessionId:null!==(i=null==s?void 0:s.sessionId)&&void 0!==i?i:"",windowId:null!==(e=null==s?void 0:s.windowId)&&void 0!==e?e:"",sessionStartTimestamp:null!==(r=null==s?void 0:s.sessionStartTimestamp)&&void 0!==r?r:0}}catch(t){return{sessionId:"",windowId:"",sessionStartTimestamp:0}}}get canCapture(){return this.instance.is_capturing()}get projectToken(){return this.instance.config.token}add(t){return this.eu.add(t)}getExtension(t){return this.eu.getExtension(t)}capture(t,i,e){var r=this;return n(function*(){e?r.instance.capture(t,i,{timestamp:e.timestamp,uuid:e.uuid,$set:e.set,$set_once:e.setOnce}):r.instance.capture(t,i)})()}registerDynamicEventProperties(t){return Jo(this.instance.iu(t))}handleRemoteConfig(t){this.fo||(this.Xl=t,this.instance.tu.emit(Pl,t))}sendRequest(t,i){var e=this;return n(function*(){var r;void 0===i&&(i={});var s=e.instance.requestRouter.endpointFor(null!==(r=i.target)&&void 0!==r?r:"api",t),n={method:i.method,url:i.query?ja(s,i.query):s,data:i.body,headers:i.headers,timeout:i.timeoutMs,fireCallbackOnDrop:!0,transport:i.transport,compression:i.compression,compressionFallback:"flags"===i.target&&"best-available"===i.compression?ai.Base64:void 0,timestampMode:i.sentAt};return"sendBeacon"===i.transport?(e.instance._send_request(n),{statusCode:202}):new Promise(t=>{n.callback=t,e.instance._send_request(n)})})()}dispose(){this.fo||(this.fo=!0,this.eu.dispose())}},Cl={},Fl=0,Al=()=>{},Il='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',Rl="Surveys module not available",Ol="sanitize_properties is deprecated. Use before_send instead",Ml="Invalid value for property_denylist config: ",Dl=/^[A-Za-z0-9_-]{1,400}$/,jl=/^fb\.[0-9]+\.[0-9]+\.[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)?$/,Bl=["token","distinct_id",Et],Ll="posthog",Nl=!Ra&&-1===(null==ei?void 0:ei.indexOf("MSIE"))&&-1===(null==ei?void 0:ei.indexOf("Mozilla")),zl=t=>{var i={};return t&&"unset"!==t?("2025-11-30">t||(i.strictMinimumDuration=!0),"2026-05-30">t||(i.canvasCapture={resolutionScale:.6}),"2026-06-25">t||(i.streamNetworkBody=!0),"2026-08-30">t||(i.captureJsonLd=!0),i):i},Ul=t=>{var i;return r({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,asset_host:null,token:"",autocapture:!0,cross_subdomain_cookie:Cs(null==Xt?void 0:Xt.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:Al,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:null!=t?t:"unset",__preview_deferred_init_extensions:!1,__preview_external_dependency_versioned_paths:!1,__preview_cookie_wins_on_conflict:!1,debug:Yt&&xi(null==Yt?void 0:Yt.search)&&-1!==Yt.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==Gt||null==(i=Gt.location)?void 0:i.protocol),ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_flags:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_only_evaluate_survey_feature_flags:!1,advanced_feature_flags_dedup_per_session:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,surveys_request_timeout_ms:1e4,on_request_error(t){ms.error("Bad HTTP status: "+t.statusCode+" "+t.text)},get_device_id:t=>t,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:Nt,before_send:void 0,get_current_url:void 0,request_queue_config:{flush_interval_ms:3e3},error_tracking:{},_onCapture:Al},(t=>({rageclick:t&&t>="2026-05-30"?{content_ignorelist:$n,ignore_text_selection:!0}:!t||"2025-11-30">t||{content_ignorelist:!0},capture_pageview:!t||"2025-05-24">t||"history_change",session_recording:zl(t),external_scripts_inject_target:t&&t>="2026-01-30"?"head":"body",internal_or_test_user_hostname:t&&t>="2026-01-30"?/^(localhost|127\.0\.0\.1)$/:void 0,persistence_save_debounce_ms:t&&t>="2026-05-30"?250:0,split_storage:!(!t||"2026-05-30">t),detect_google_search_app:!(!t||"2026-05-30">t),disable_capture_url_hashes:!(!t||"2026-06-25">t),cookieWinsOnConflict:!(!t||"unset"===t||"2026-08-29">t)}))(t))},Hl=[["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"]],ql=t=>{var i={};for(var e of Hl){var r=e[0],s=e[1];wi(t[r])||(i[s]=t[r])}var n=xs({},i,t),o=t.__preview_external_dependency_versioned_paths;return wi(o)||(wi(t.strict_script_versioning)&&(n.strict_script_versioning=!!o),xi(o)&&wi(t.asset_host)&&(n.asset_host=o)),_i(t.property_blacklist)&&(wi(t.property_denylist)?n.property_denylist=t.property_blacklist:_i(t.property_denylist)?n.property_denylist=[...t.property_blacklist,...t.property_denylist]:ms.error(Ml+t.property_denylist)),n},Vl=class{constructor(){this.__forceAllowLocalhost=!1}get ru(){return this.__forceAllowLocalhost}set ru(t){ms.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=t}},Wl=(s=class t{nu(t){if(t){var i=this.Ql.indexOf(t);-1!==i&&this.Ql.splice(i,1)}}su(t,i){return this.nu(t),this.Ql.push(i),null==i.initialize||i.initialize(),i}ou(){return"always"===this.config.cookieless_mode||"on_reject"===this.config.cookieless_mode&&this.consent.isRejected()}au(){if(!(this.lu||this.config.reuseAnonymousId||this.config.segment||this.ou())){var t,i,e,r="memory"===this.config.persistence||"sessionStorage"===this.config.persistence;(r||this.config.disable_persistence)&&(this.uu||(r?(t="persistence is set to '"+this.config.persistence+"'",i="memory"===this.config.persistence?"on every page load":"for every new browser tab or window",e="Either set persistence to 'localStorage+cookie', keep this persistence and pass a stable ID through bootstrap.distinctID, or enable reuseAnonymousId."):(t="persistence is disabled (disable_persistence is true)",i="on every page load",e="Either set disable_persistence to false, keep persistence disabled and pass a stable ID through bootstrap.distinctID, or enable reuseAnonymousId."),this.lu=!0,console.warn("[PostHog.js]",t+" but no bootstrap.distinctID was provided. PostHog will mint a new distinct ID "+i+", so calling identify() merges a new ID onto the person each time. A person can then pass the distinct-ID limit and its events stop appearing on person pages and the session tab. "+e)))}}hu(){if(!this.ou()&&"$posthog_cookieless"===this.get_distinct_id()){var t=this.persistence;if(t){this.du()||t.load(!0);var i=this.get_distinct_id();if(!i||"$posthog_cookieless"===i){var e=this.config.get_device_id(Bs());this.register({distinct_id:e,$device_id:e}),t.set_property(_t,Bt)}this.vu()}}}get decideEndpointWasHit(){var t,i;return null!==(t=null==(i=this.featureFlags)?void 0:i.hasLoadedFlags)&&void 0!==t&&t}get flagsEndpointWasHit(){var t,i;return null!==(t=null==(i=this.featureFlags)?void 0:i.hasLoadedFlags)&&void 0!==t&&t}constructor(){var i;this.cu=!1,this.fu=!1,this.webPerformance=new Vl,this.pu=!1,this.version=l.LIB_VERSION,this.gu=new Set,this.mu="",this.tu=new tl,this.Ql=[],this.yu=[],this.uu=!1,this.lu=!1,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=Ul(),this.SentryIntegration=io,this.sentryIntegration=t=>function(t,i){var e=to(t,i);return{name:Qn,processEvent:t=>e(t)}}(this,t),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.bu=!1,this._u=null,this.wu=null,this.ku=null,this.scrollManager=new Ya(this),this.pageViewManager=new eo(this),this.rateLimiter=new Yo(this),this.requestRouter=new _l(this),this.consent=new an(this),this.externalIntegrations=new kl(this);var e=null!==(i=t.__defaultExtensionClasses)&&void 0!==i?i:{};this.featureFlags=e.featureFlags&&new e.featureFlags(this),this.toolbar=e.toolbar&&new e.toolbar(this),this.surveys=e.surveys&&new e.surveys(this),this.conversations=e.conversations&&new e.conversations(this),this.logs=e.logs&&new e.logs(this),this.metrics=e.metrics&&new e.metrics(this),this.experiments=e.experiments&&new e.experiments(this),this.exceptions=e.exceptions&&new e.exceptions(this),this.people={set:(t,i,e)=>{var r=xi(t)?{[t]:i}:t;this.setPersonProperties(r),null==e||e({})},set_once:(t,i,e)=>{var r=xi(t)?{[t]:i}:t;this.setPersonProperties(void 0,r),null==e||e({})}},this.on("eventCaptured",t=>ms.info('send "'+(null==t?void 0:t.event)+'"',t))}init(i,e,r){if(r&&r!==Ll){var s,n=null!==(s=Cl[r])&&void 0!==s?s:new t;return n._init(i,e,r),Cl[r]=n,Cl[Ll][r]=n,n}return this._init(i,e,r)}_init(t,i,e){var s,n,o;void 0===i&&(i={});var a,h=xi(t)?t.trim():"";if(!h)return ms.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 h!==(null==(a=this.config)?void 0:a.token)?console.warn("[PostHog.js]","You have already initialized PostHog with a different project token! Re-initializing is a no-op, so events will keep going to the project this instance was initialized with. To capture into a second project, load PostHog once, then initialize a named instance after the SDK has loaded, e.g. posthog.init('"+h+"', { ... }, 'project2')"):console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config=Ul(i.defaults),i.debug=this.Su(i.debug),this.xu=i,this.Cu=[],i.person_profiles?this.wu=i.person_profiles:i.process_person&&(this.wu=i.process_person);var u=Ul(i.defaults),d=ql(i),c=xs({},u,d,{name:e,token:h});bi(u.rageclick)&&bi(d.rageclick)&&(c.rageclick=xs({},u.rageclick,d.rageclick)),bi(u.session_recording)&&bi(d.session_recording)&&(c.session_recording=xs({},u.session_recording,d.session_recording)),this.set_config(c),this.config.on_xhr_error&&ms.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=i.disable_compression?void 0:No;var f=this.du();if(this.persistence=new Lo(this.config,f),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new Lo(r({},this.config,{persistence:"sessionStorage"}),f,!1),this.mu="ph_"+(this.config.persistence_name||this.config.token)+"_session_registered_properties","memory"!==this.config.persistence&&!f&&on.Et()){var p=on.Nt(this.mu);_i(p)&&p.forEach(t=>{xi(t)&&this.gu.add(t)})}else on.Dt(this.mu);var g=r({},this.persistence.props),_=r({},this.sessionPersistence.props);this.register({$initialization_time:(new Date).toISOString()}),this.Tu=new Ja(t=>this.Mu(t),this.config.request_queue_config),this.Iu=new Xa(this),this.__request_queue=[];var m=this.ou();m||(this.sessionManager=new rl(this),this.sessionPropsManager=new Qa(this,this.sessionManager,this.persistence),this.sessionManager.onSessionId((t,i,e)=>{(null!=e&&e.activityTimeout||null!=e&&e.sessionPastMaximumLength||null!=e&&e.crossTabAdoption)&&this.Eu()})),this.Ru(),this.config.__preview_deferred_init_extensions?(ms.info("Deferring extension initialization to improve startup performance"),setTimeout(()=>{this.Au(m)},0)):(ms.info("Initializing extensions synchronously"),this.Au(m)),l.DEBUG=l.DEBUG||this.config.debug,l.DEBUG&&ms.info("Starting in debug mode",{this:this,config:i,thisC:r({},this.config),p:g,s:_}),!this.config.identity_distinct_id||null!=(s=i.bootstrap)&&s.distinctID||(i.bootstrap=r({},i.bootstrap,{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0}));var b=null==(n=i.bootstrap)?void 0:n.distinctID;if(this.uu=!!b&&!Si(b),void 0!==(null==(o=i.bootstrap)?void 0:o.distinctID)){var y=i.bootstrap.distinctID,w=this.get_distinct_id(),x=this.persistence.get_property(_t);if(i.bootstrap.isIdentifiedID&&null!=w&&w!==y&&"anonymous"===x)this.identify(y);else if(i.bootstrap.isIdentifiedID&&null!=w&&w!==y&&"identified"===x)ms.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 S=this.config.get_device_id(Bs()),k=i.bootstrap.isIdentifiedID?S:y;this.persistence.set_property(_t,i.bootstrap.isIdentifiedID?Lt:Bt),this.register({distinct_id:y,$device_id:k})}}if(m)this.register_once({distinct_id:kt,$device_id:null},"");else if(!this.get_distinct_id()){var E=this.config.get_device_id(Bs());this.register_once({distinct_id:E,$device_id:E},""),this.persistence.set_property(_t,Bt)}return Fs(Gt,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),Fs(Gt,"pageshow",()=>{var t;this.cu=!1,this.fu||null==(t=this.Iu)||t.resume()}),i.segment?Zn(this,()=>this.Pu()):this.Pu(),mi(this.config._onCapture)&&this.config._onCapture!==Al&&(ms.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",t=>this.config._onCapture(t.event,t))),this.config.ip&&ms.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 nl.apply(this,arguments)}().then(t=>{t&&this.register({[v]:t})}).catch(Al),this}Fu(t){var i=t;return xi(i.name)&&mi(i.setup)}Ou(t,i){this.Fu(t)?i.push(()=>{this.$u().add(t).catch(()=>null==t.dispose?void 0:t.dispose()).catch(i=>{ms.error('Failed to dispose browser extension "'+t.name+'"',i)})}):this.Ql.push(t)}Ru(){var i,e,r,s,n,o,a=null!==(i=null==(e=this.config.__extensionClasses)?void 0:e.featureFlags)&&void 0!==i?i:null==(r=t.__defaultExtensionClasses)?void 0:r.featureFlags;a&&(this.featureFlags&&this.featureFlags instanceof a||(null==(o=this.Du)||o.call(this),this.Du=void 0,this.featureFlags=new a(this)),mi(this.featureFlags.onReloading)&&mi(this.featureFlags.setup)?this.Du||(this.Du=this.featureFlags.onReloading(()=>{this.tu.emit("featureFlagsReloading",!0)}),this.$u().add(this.featureFlags)):null==(s=(n=this.featureFlags).initialize)||s.call(n))}Au(i){var e,s,n,o,a,l,h,u=performance.now(),d=r({},t.__defaultExtensionClasses,this.config.__extensionClasses),v=[];d.exceptions&&this.Ql.push(this.exceptions=null!==(e=this.exceptions)&&void 0!==e?e:new d.exceptions(this)),d.historyAutocapture&&this.Ql.push(this.historyAutocapture=new d.historyAutocapture(this)),d.tracingHeaders&&this.Ql.push(this.tracingHeaders=new d.tracingHeaders(this)),d.siteApps&&this.Ql.push(this.siteApps=new d.siteApps(this)),d.sessionRecording&&!i&&this.Ql.push(this.sessionRecording=new d.sessionRecording(this)),this.config.disable_scroll_properties||v.push(()=>{this.scrollManager.startMeasuringScrollPosition()}),d.autocapture&&this.Ou(this.autocapture=new d.autocapture(this),v),d.surveys&&this.Ou(this.surveys=null!==(s=this.surveys)&&void 0!==s?s:new d.surveys(this),v),d.logs&&this.Ou(this.logs=null!==(n=this.logs)&&void 0!==n?n:new d.logs(this),v),d.metrics&&this.Ql.push(this.metrics=null!==(o=this.metrics)&&void 0!==o?o:new d.metrics(this)),d.conversations&&this.Ql.push(this.conversations=null!==(a=this.conversations)&&void 0!==a?a:new d.conversations(this)),d.productTours&&this.Ql.push(this.productTours=new d.productTours(this)),d.heatmaps&&this.Ql.push(this.heatmaps=new d.heatmaps(this)),d.webVitalsAutocapture&&this.Ql.push(this.webVitalsAutocapture=new d.webVitalsAutocapture(this)),d.exceptionObserver&&this.Ql.push(this.exceptionObserver=new d.exceptionObserver(this)),d.deadClicksAutocapture&&this.Ql.push(this.deadClicksAutocapture=new d.deadClicksAutocapture(this,Jn)),d.toolbar&&this.Ql.push(this.toolbar=null!==(l=this.toolbar)&&void 0!==l?l:new d.toolbar(this)),d.experiments&&this.Ql.push(this.experiments=null!==(h=this.experiments)&&void 0!==h?h:new d.experiments(this)),this.Ql.forEach(t=>{t.initialize&&v.push(()=>{null==t.initialize||t.initialize()})}),v.push(()=>{if(this.Lu){var t=this.Lu;this.Lu=void 0,this.Ql.forEach(i=>null==i.onRemoteConfig?void 0:i.onRemoteConfig(t))}}),this.Nu(v,u)}Nu(t,i){for(;t.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-i>=30&&t.length>0)return void setTimeout(()=>{this.Nu(t,i)},0);var e=t.shift();if(e)try{e()}catch(t){ms.error("Error initializing extension:",t)}}var r=Math.round(performance.now()-i);this.register_for_session({[$t]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[Pt]:r}),this.config.__preview_deferred_init_extensions&&ms.info("PostHog extensions initialized ("+r+"ms)")}za(t){var i;if(!Xt||!Xt.body)return ms.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout(()=>{this.za(t)},500);if(this.config.__preview_deferred_init_extensions&&(this.Lu=t),this.Yl=t,this.compression=void 0,t.ok){var e,r=t.config;r.supportedCompression&&!this.config.disable_compression&&(this.compression=ui(r.supportedCompression,No)?No:ui(r.supportedCompression,zo)?zo:void 0),null!=(e=r.analytics)&&e.endpoint&&(this.analyticsDefaultEndpoint=r.analytics.endpoint)}this.set_config({person_profiles:this.wu?this.wu:Nt}),null==(i=this.qu)||i.handleRemoteConfig(t),this.Ql.forEach(i=>null==i.onRemoteConfig?void 0:i.onRemoteConfig(t))}Pu(){try{this.config.loaded(this)}catch(t){ms.critical("`loaded` function failed",t)}if(this.ju(),this.config.internal_or_test_user_hostname&&null!=Yt&&Yt.hostname){var t=Yt.hostname,i=this.config.internal_or_test_user_hostname;("string"==typeof i?t===i:i.test(t))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout(()=>{(this.consent.isOptedIn()||this.ou())&&this.Bu()},1),this.Hu=new Qo(this),this.Hu.load()}ju(){var t;this.is_capturing()&&this.config.request_batching&&(null==(t=this.Tu)||t.enable())}_dom_loaded(){this.is_capturing()&&ys(this.__request_queue,t=>this.Mu(t)),this.__request_queue=[],this.ju()}_handle_unload(){var t,i,e,r,s;this.cu=!0,null==(t=this.surveys)||null==t.handlePageUnload||t.handlePageUnload(),null==(i=this.metrics)||i.flush("sendBeacon"),this.config.request_batching?(this.zu()&&this.capture(qt),null==(e=this.logs)||e.flushLogs("sendBeacon"),null==(r=this.Tu)||r.unload(),null==(s=this.Iu)||s.unload()):this.zu()&&this.capture(qt,null,{transport:"sendBeacon"})}_send_request(t){var i;this.__loaded?Nl?this.__request_queue.push(t):this.rateLimiter.isServerRateLimited(t.batchKey)?t.fireCallbackOnDrop&&(null==t.callback||t.callback({statusCode:429})):(t.transport=t.transport||this.config.api_transport,t.headers=r({},this.config.request_headers,t.headers),t.compression="best-available"===t.compression?null!==(i=this.compression)&&void 0!==i?i:t.compressionFallback:t.compression,(wi(this.config.disable_beacon)?this.config.__preview_disable_beacon:this.config.disable_beacon)&&(t.disableTransport=["sendBeacon"]),t.fetchOptions=t.fetchOptions||this.config.fetch_options,(t=>{var i,e,s,n=r({},t);n.timeout=n.timeout||6e4;var o,a,l,h,u,d=null!==(i=n.transport)&&void 0!==i?i:"fetch";"sendBeacon"===d&&wi(n.compression)&&n.data&&(n.compression=zo),"POST"===n.method&&n.data&&("capture-body"===n.timestampMode?n.data={api_key:null!==(a=null==(u=(h=(_i(o=n.data)?o:[o]).map(t=>r({},t,t.timestamp instanceof Date&&!isNaN(t.timestamp.getTime())?{timestamp:t.timestamp.toISOString()}:{})))[0])||null==(l=u.properties)?void 0:l.token)&&void 0!==a?a:null==u?void 0:u.token,batch:h,sent_at:(new Date).toISOString()}:"body"===n.timestampMode&&(n.data=function(t,i){return void 0===i&&(i=(new Date).toISOString()),_i(t)?t.map(t=>r({},t,{sent_at:i})):r({},t,{sent_at:i})}(n.data))),n.url=Ga(n.url,n.method,n.compression,n.timestampMode);var v=Ka.filter(t=>!n.disableTransport||!t.transport||!n.disableTransport.includes(t.transport)),c=null!==(e=null==(s=function(t,i){for(var e=0;t.length>e;e++)if(i(t[e]))return t[e]}(v,t=>t.transport===d))?void 0:s.method)&&void 0!==e?e:v[0].method;if(!c)throw new Error("No available transport method");var f=t=>{try{c(t)}catch(t){Ha(t)?ms.warn(t):ms.error(t),null==n.callback||n.callback({statusCode:0,error:t})}};"sendBeacon"!==d&&n.data&&n.compression===No&&ii&&"undefined"!=typeof Promise&&!Ma?za(n).then(t=>{f(t)}).catch(i=>{if(Jr(i))return Ma=!0,void f(r({},n,{compression:void 0,url:Ga(t.url,t.method,void 0,t.timestampMode)}));(t=>{if(!t||"object"!=typeof t)return!1;var i="name"in t?String(t.name):"";return Jr(t)||i===Wr})(i)&&(Ma=!0),f(n)}):c(n)})(r({},t,{callback:i=>{var e,r;this.rateLimiter.checkForLimiting(i),400>i.statusCode||null==(e=(r=this.config).on_request_error)||e.call(r,i),null==t.callback||t.callback(i)}}))):t.fireCallbackOnDrop&&(null==t.callback||t.callback({statusCode:0}))}Mu(t){this.Iu?this.Iu.retriableRequest(t):this._send_request(t)}_execute_array(t){Fl++;try{var i,e=[],r=[],s=[];ys(t,t=>{if(t)if(_i(i=t[0]))s.push(t);else if(mi(t))try{t.call(this)}catch(i){ms.error("Error executing queued PostHog call",t,i)}else _i(t)&&"alias"===i?e.push(t):_i(t)&&-1!==i.indexOf("capture")&&mi(this[i])?s.push(t):r.push(t)});var n=function(t,i){ys(t,function(t){try{if(_i(t[0])){var e=i;ws(t,function(t){e=e[t[0]].apply(e,t.slice(1))})}else i[t[0]].apply(i,t.slice(1))}catch(i){ms.error("Error executing queued PostHog call",t,i)}})};n(e,this),n(r,this),n(s,this)}finally{Fl--}}push(i){if(Fl>0&&_i(i)&&xi(i[0])){var e=t.prototype[i[0]];mi(e)&&e.apply(this,i.slice(1))}else this._execute_array([i])}Uu(){var t,i=null==(t=this.persistence)?void 0:t.get_property(g);return xi(i)&&jl.test(i)?{value:i,delivered:!1}:bi(i)&&xi(i.value)&&jl.test(i.value)?{value:i.value,delivered:!0===i.delivered}:void 0}Wu(t,i,e,r){if(this.persistence){this.persistence.refreshKey(g);var s=this.Uu();if(!r){if(e)return xi(i)&&jl.test(i)?(i!==(null==s?void 0:s.value)&&this.persistence.register({[g]:{value:i,delivered:!1}}),{value:i,pending:i!==(null==s?void 0:s.value)||!s.delivered}):void this.persistence.unregister(g);if(xi(t)&&Dl.test(t)){if((null==s?void 0:s.value.split(".")[3])===t)return{value:s.value,pending:!s.delivered};var n="fb.1."+Date.now()+"."+t;return this.persistence.register({[g]:{value:n,delivered:!1}}),{value:n,pending:!0}}return s?{value:s.value,pending:!s.delivered}:void 0}this.persistence.unregister(g)}}Vu(t){if(this.persistence){this.persistence.refreshKey(g);var i=this.Uu();(null==i?void 0:i.value)!==t||i.delivered||this.persistence.register({[g]:{value:t,delivered:!0}})}}capture(t,i,e){var s,n,o,a,l,h,u,d,v,c;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.Tu){if(this.is_capturing())if(!wi(t)&&xi(t)){this.hu();var f=!this.config.opt_out_useragent_filter&&this._is_bot();if(!f||this.config.__preview_capture_bot_pageviews){var g=null!=e&&e.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(null==g||!g.isRateLimited){var _;null!=i&&i.$current_url&&!xi(null==i?void 0:i.$current_url)&&(ms.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),null==i||delete i.$current_url),"$exception"!==t||null!=e&&e.Gu||ms.warn("Using `posthog.capture('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureException(error)` instead, which attaches required metadata automatically."),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&(_=this.sessionPersistence.update_campaign_params()),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();var m=new Date,b=(null==e?void 0:e.timestamp)||m,y=Ze(null==e?void 0:e.uuid,Bs),w={uuid:y,event:t,properties:this.calculateEventProperties(t,i||{},b,y)};"$pageview"===t&&this.config.__preview_capture_bot_pageviews&&f&&(w.event="$bot_pageview",w.properties.$browser_type="bot"),g&&(w.properties.$lib_rate_limit_remaining_tokens=g.remainingTokens);var x="$feature_flag_called"===t&&!1===w.properties.$feature_flag_has_experiment&&!0===this.get_property("$minimal_flag_called_events");null!=e&&e.$set&&!x&&(w.$set=null==e?void 0:e.$set);var S=bi(null==i?void 0:i.$set)?i.$set:void 0,k=!(null==e||!e.$set)&&"$fbc"in e.$set,E=k||!!S&&"$fbc"in S,P=k?null==e||null==(s=e.$set)?void 0:s[p]:null==S?void 0:S[p],T=_i(null==i?void 0:i.$unset)?i.$unset:[],C=(null==e?void 0:e.$unset)||[],F=-1!==T.indexOf("$fbc")||-1!==C.indexOf("$fbc"),A=this.Wu(null==(n=_)?void 0:n.fbclid,P,E,F);A&&!0===w.properties.$process_person_profile&&A.pending&&!E&&!x&&(w.$set=r({[p]:A.value},w.$set));var I=null==e?void 0:e.$unset;I&&(w.$unset=I);var R=x?void 0:this.Zu(null==e?void 0:e.$set_once,t!==Wt,t===Vt);if(R&&(w.$set_once=R),null!=e&&e._noTruncate||(u=this.config.properties_string_max_length,d=w,v=t=>xi(t)?t.slice(0,u):t,c=new Set,w=function t(i,e){if(i!==Object(i))return v?v(i):i;if(!c.has(i)){var r;if(c.add(i),_i(i))r=[],ys(i,i=>{r.push(t(i))});else{var s={};ws(Ri(i)?Ps(i):i,(i,e)=>{c.has(i)||(s[e]=t(i,e))}),r=s}return r}}(d)),w.timestamp=b,wi(null==e?void 0:e.timestamp)||(w.properties.$event_time_override_provided=!0,w.properties.$event_time_override_system_time=m),x&&(w.properties=function(t,i){void 0===i&&(i=[]);var e={},r=i=>{void 0!==t[i]&&(e[i]=t[i])};return Vr.forEach(r),i.forEach(r),e}(w.properties,Bl)),t===Vo||t===Wo){var O=null==i?void 0:i.$survey_id,M=null==i?void 0:i.$survey_iteration;bl({id:O,current_iteration:M}),w.$set=r({},w.$set,{[ol({id:O,current_iteration:M},t===Wo?"responded":"dismissed")]:!0})}else t===qo&&(w.$set=r({},w.$set,{[Go]:(new Date).toISOString()}));if("product tour shown"===t){var D=null==i?void 0:i.$product_tour_type;D&&(w.$set=r({},w.$set,{["$product_tour_last_seen_date/"+D]:(new Date).toISOString()}))}var j=r({},w.properties.$set,w.$set);if(yi(j)||this.setPersonPropertiesForFlags(j),!Ei(this.config.before_send)){var B=this.Ts(w);if(!B)return;(w=B).uuid=Ze(w.uuid,Bs)}var L=null!==(o=null==(a=w.$set)?void 0:a.$fbc)&&void 0!==o?o:bi(null==(l=w.properties)?void 0:l.$set)?w.properties.$set.$fbc:void 0,N=null!=A&&A.pending&&L===A.value?A.value:void 0;this.tu.emit("eventCaptured",w);var z,U=null!==(h=null==e?void 0:e._url)&&void 0!==h?h:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),H=r({method:"POST",url:U,data:w,compression:"best-available",timestampMode:"recordings"===(null==e?void 0:e._batchKey)||/\/s\/(?:\?|$)/.test(U)?"body":"capture-body",batchKey:null==e?void 0:e._batchKey},null!=e&&e.transport?{transport:e.transport}:{},N?{fireCallbackOnDrop:!0,callback:t=>{t.statusCode>=200&&300>t.statusCode&&this.Vu(N)}}:{});return!this.config.request_batching||e&&(null==e||!e._batchKey)||null!=e&&e.send_instantly||N?(!H.transport&&!H.callback&&yi(null!==(z=this.config.request_headers)&&void 0!==z?z:{})&&this.cu&&(H.transport="sendBeacon"),this.Mu(H)):this.Tu.enqueue(H),w}ms.critical("This capture call is ignored due to client rate limiting.")}}else ms.error("No event name provided to posthog.capture")}else ms.uninitializedWarning("posthog.capture")}_addCaptureHook(t){return this.on("eventCaptured",i=>t(i.event,i))}getExtension(t){var i;return null==(i=this.qu)?void 0:i.getExtension(t)}$u(){var t;return null!==(t=this.qu)&&void 0!==t?t:this.qu=new Tl(this)}iu(t){this.yu.push(t);var i=!0;return()=>{if(i){i=!1;var e=this.yu.indexOf(t);-1!==e&&this.yu.splice(e,1)}}}Ju(t){var i,e,r;return void 0===t&&(t=!0),!(null==(i=this.persistence)||!i.consumeCookieIdentityChange())&&(this.ku=null,"anonymous"===this.persistence.get_property("$user_state")&&(null==(r=this.sessionPersistence)||r.clear(),this.gu.clear(),this.Qu()),null==(e=this.featureFlags)||e.reset(),t&&this.reloadFeatureFlags(),!0)}calculateEventProperties(t,i,e,s,n){if(e=e||new Date,!this.persistence||!this.sessionPersistence)return i;this.persistence.syncCookieProperties(),this.Ju();var o=n?void 0:this.persistence.remove_event_timer(t),l=r({},i);if(l.token=this.config.token,l.$config_defaults=this.config.defaults,this.ou()&&(l[Et]=!0),"$snapshot"===t){var h=r({},this.persistence.properties(),this.sessionPersistence.properties());return l.distinct_id=h.distinct_id,(!xi(l.distinct_id)&&!$i(l.distinct_id)||Si(l.distinct_id))&&ms.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),l}var u,d=function(t,i,e,r){var s,n,o,l;if(void 0===r&&(r=!1),!ei)return{};var h,u=t?[...po,...i||[]]:[],d=ze(ei),v=d[0],c=d[1],f=function(t){for(var i=0;qe.length>i;i++){var e,r=qe[i],s=r[1],n=r[2],o=t.match(r[0]);if(o)return[s,(null==(e=n&&t.match(n)||o)?void 0:e[1])||""]}return["",""]}(ei),p=f[0],g=f[1],_=null!=(h="u">typeof navigator?navigator:void 0)&&h.brave?{brave:!0}:{},m={};wi(e)||(m.detectGoogleSearchApp=e);var b={},y=null==(s=navigator)||null==(s=s.userAgentData)?void 0:s.platform,w=null==(n=navigator)?void 0:n.maxTouchPoints,x=null==Gt||null==(o=Gt.screen)?void 0:o.width,S=null==Gt||null==(l=Gt.screen)?void 0:l.height,k=null==Gt?void 0:Gt.devicePixelRatio;wi(y)||(b.userAgentDataPlatform=y),wi(w)||(b.maxTouchPoints=w),wi(x)||(b.screenWidth=x),wi(S)||(b.screenHeight=S),wi(k)||(b.devicePixelRatio=k);var E,P,T,C,F,A,I,R,O=xs($s({$os:v,$os_version:c,$browser:je(ei,navigator.vendor,_,m),$webview_app:p,$webview_app_version:g,$device:Ue(ei),$device_type:(P=ei,T=b,R=Ue(P),R===Gi||R===Wi||"Kobo"===R||"Kindle Fire"===R||R===ge?Vi:R===oe||R===le||R===ae||R===fe?"Console":R===Ki?"Wearable":R?Hi:"Android"===(null==T?void 0:T.userAgentDataPlatform)&&(null!==(C=null==T?void 0:T.maxTouchPoints)&&void 0!==C?C:0)>0?600>Math.min(null!==(F=null==T?void 0:T.screenWidth)&&void 0!==F?F:0,null!==(A=null==T?void 0:T.screenHeight)&&void 0!==A?A:0)/(null!==(I=null==T?void 0:T.devicePixelRatio)&&void 0!==I?I:1)?Hi:Vi:"Desktop"),$timezone:Po(),$timezone_offset:To()}),{$current_url:uo(r?tr(null==Yt?void 0:Yt.href):null==Yt?void 0:Yt.href,u,_o),$host:null==Yt?void 0:Yt.host,$pathname:null==Yt?void 0:Yt.pathname,$raw_user_agent:ei.length>1e3?ei.substring(0,997)+"...":ei,$browser_version:Le(ei,navigator.vendor,_,m),$browser_language:xo(),$browser_language_prefix:(E=xo(),"string"==typeof E?E.split("-")[0]:void 0),$screen_height:null==Gt?void 0:Gt.screen.height,$screen_width:null==Gt?void 0:Gt.screen.width,$viewport_height:null==Gt?void 0:Gt.innerHeight,$viewport_width:null==Gt?void 0:Gt.innerWidth,$lib:a.LIB_NAME,$lib_version:a.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3});return a.SDK_DIST_CHANNEL&&(O.$sdk_dist_channel=a.SDK_DIST_CHANNEL),O}(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 v=this.sessionManager.checkAndGetSessionAndWindowId(n,e.getTime(),!0),c=v.windowId;l.$session_id=v.sessionId,l.$window_id=c}this.sessionPropsManager&&xs(l,this.sessionPropsManager.getSessionProps());try{var f;this.sessionRecording&&xs(l,this.sessionRecording.sdkDebugProperties),l.$sdk_debug_retry_queue_size=null==(f=this.Iu)?void 0:f.length}catch(t){l.$sdk_debug_error_capturing_properties=String(t)}if(this.requestRouter.region===cl&&(l.$lib_custom_api_host=this.config.api_host),u="$pageview"!==t||n?"$pageleave"!==t||n?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(e):this.pageViewManager.doPageView(e,s),l=xs(l,u),"$pageview"===t&&Xt&&(l.title=Xt.title),!wi(o)){var p=e.getTime()-o;l.$duration=parseFloat((p/1e3).toFixed(3))}ei&&this.config.opt_out_useragent_filter&&(l.$browser_type=this._is_bot()?"bot":"browser");var g=this.persistence.properties(),_=this.sessionPersistence.properties(),m=l.$groups,b=g.$groups;bi(m)&&!yi(m)&&(l.$groups=r({},bi(b)?b:{},m)),ws(["$referrer","$referring_domain"],t=>{t in g&&delete _[t]});var y={};if(this.yu.length>0)for(var w of this.yu.slice())try{xs(y,w())}catch(t){ms.error("Failed to produce browser extension event properties",t)}(l=xs({},d,g,_,r({},y,l))).$is_identified=this._isIdentified(),_i(this.config.property_denylist)?ws(this.config.property_denylist,function(t){delete l[t]}):ms.error(Ml+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var x=this.config.sanitize_properties;x&&(ms.error(Ol),l=x(l,t));var S=this.Ku();return l.$process_person_profile=S,S&&!n&&this.Xu("_calculate_event_properties"),l}Zu(t,i,e){var r;if(void 0===i&&(i=!0),void 0===e&&(e=!1),!this.persistence||!this.Ku())return t;if(this.pu&&!e)return t;var s=xs({},this.persistence.get_initial_props(),(null==(r=this.sessionPropsManager)?void 0:r.getSetOnceProps())||{},t||{}),n=this.config.sanitize_properties;return n&&(ms.error(Ol),s=n(s,"$set_once")),i&&(this.pu=!0),yi(s)?void 0:s}register(t,i){var e;null==(e=this.persistence)||e.register(t,i)}register_once(t,i,e){var r;null==(r=this.persistence)||r.register_once(t,i,e)}register_for_session(t){var i,e;null==(i=this.persistence)||i.syncCookieProperties(),this.Ju(),null==(e=this.sessionPersistence)||e.register(t),Object.keys(t).forEach(t=>this.gu.add(t)),this.Qu()}unregister(t){var i;null==(i=this.persistence)||i.unregister(t)}unregister_for_session(t){var i;null==(i=this.sessionPersistence)||i.unregister(t),this.gu.delete(t),this.Qu()}Yu(t,i){this.register({[t]:i})}Eu(){this.gu.forEach(t=>{var i;null==(i=this.sessionPersistence)||i.unregister(t)}),this.gu.clear(),this.Qu()}Qu(){var t;if(this.mu)if("memory"===this.config.persistence||null!=(t=this.sessionPersistence)&&t.gi||!on.Et())on.Dt(this.mu);else{var i=[];this.gu.forEach(t=>i.push(t)),i.length>0?on.Ot(this.mu,i):on.Dt(this.mu)}}getFeatureFlag(t,i){var e;return null==(e=this.featureFlags)?void 0:e.getFeatureFlag(t,i)}getFeatureFlagPayload(t){var i;return null==(i=this.featureFlags)?void 0:i.getFeatureFlagPayload(t)}getFeatureFlagResult(t,i){var e;return null==(e=this.featureFlags)?void 0:e.getFeatureFlagResult(t,i)}getAllFeatureFlags(){var t,i;return null!==(t=null==(i=this.featureFlags)?void 0:i.getAllFeatureFlags())&&void 0!==t?t:[]}isFeatureEnabled(t,i){var e,r;return null!==(e=null==(r=this.featureFlags)?void 0:r.isFeatureEnabled(t,i))&&void 0!==e?e:null==i?void 0:i.defaultValue}reloadFeatureFlags(){var t;null==(t=this.featureFlags)||t.reloadFeatureFlags()}updateFlags(t,i,e){var r;null==(r=this.featureFlags)||r.updateFlags(t,i,e)}updateEarlyAccessFeatureEnrollment(t,i,e){var r;null==(r=this.featureFlags)||r.updateEarlyAccessFeatureEnrollment(t,i,e)}getEarlyAccessFeatures(t,i,e){var r;return void 0===i&&(i=!1),null==(r=this.featureFlags)?void 0:r.getEarlyAccessFeatures(t,i,e)}on(t,i){return this.tu.on(t,i)}onFeatureFlags(t){return this.featureFlags?this.featureFlags.onFeatureFlags(t):(t([],{},{errorsLoading:!0}),()=>{})}onSurveysLoaded(t){return this.surveys?this.surveys.onSurveysLoaded(t):(t([],{isLoaded:!1,error:Rl}),()=>{})}onSessionId(t){var i,e;return null!==(i=null==(e=this.sessionManager)?void 0:e.onSessionId(t))&&void 0!==i?i:()=>{}}getSurveys(t,i){void 0===i&&(i=!1),this.surveys?this.surveys.getSurveys(t,i):t([],{isLoaded:!1,error:Rl})}getActiveMatchingSurveys(t,i){void 0===i&&(i=!1),this.surveys?this.surveys.getActiveMatchingSurveys(t,i):t([],{isLoaded:!1,error:Rl})}renderSurvey(t,i){var e;null==(e=this.surveys)||e.renderSurvey(t,i)}displaySurvey(t,i){var e;void 0===i&&(i=wl),null==(e=this.surveys)||e.displaySurvey(t,i)}cancelPendingSurvey(t){var i;null==(i=this.surveys)||i.cancelPendingSurvey(t)}canRenderSurvey(t){var i,e;return null!==(i=null==(e=this.surveys)?void 0:e.canRenderSurvey(t))&&void 0!==i?i:{visible:!1,disabledReason:Rl}}canRenderSurveyAsync(t,i){var e,r;return void 0===i&&(i=!1),null!==(e=null==(r=this.surveys)?void 0:r.canRenderSurveyAsync(t,i))&&void 0!==e?e:Promise.resolve({visible:!1,disabledReason:Rl})}th(t){return!t||Si(t)?(ms.critical("Unique user id has not been set in posthog.identify"),!1):"$posthog_cookieless"===t?(ms.critical('The string "'+t+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.'),!1):!["distinct_id","distinctid"].includes(t.toLowerCase())&&!["undefined","null"].includes(t.toLowerCase())||(ms.critical('The string "'+t+'" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.'),!1)}identify(t,i,e){if(!this.__loaded||!this.persistence)return ms.uninitializedWarning("posthog.identify");if($i(t)&&(t=t.toString(),ms.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),this.th(t)&&this.Xu("posthog.identify")){this.hu();var r=this.get_distinct_id(),s=this.persistence.syncCookieProperties()&&this.get_distinct_id()!==r,n=this.Ju(!1),o=this.persistence.Sa(),a=!1;try{var l=this.get_distinct_id();this.register({$user_id:t}),this.get_property("$device_id")||this.register_once({$had_persisted_distinct_id:!0,$device_id:l},""),t!==l&&t!==this.get_property("__alias")&&(this.unregister(c),this.register({distinct_id:t}));var h=(this.persistence.get_property("$user_state")||"anonymous")===Bt,u=t!==l,d=!u&&h;if(u&&h){var v,f=this.config.reuseAnonymousId?{distinct_id:t}:{distinct_id:t,$anon_distinct_id:l};this.persistence.set_property(_t,Lt),this.setPersonPropertiesForFlags({$set:i||{},$set_once:e||{}},!1),this.config.cookieWinsOnConflict&&this.persistence.xa(),this.capture(Vt,f,{$set:i||{},$set_once:e||{}}),this.ku=vl(t,i,e),null==(v=this.featureFlags)||v.setAnonymousDistinctId(this.config.reuseAnonymousId?void 0:l)}else if(d){this.persistence.set_property(_t,Lt);var p=i||{},g=e||{};this.setPersonPropertiesForFlags({$set:p,$set_once:g},!1),this.config.cookieWinsOnConflict&&this.persistence.xa(),this.capture("$set",{$set:p,$set_once:g}),this.ku=vl(t,i,e)}else(i||e)&&this.setPersonProperties(i,e);u||s||n?(this.reloadFeatureFlags(),this.featureFlags?this.featureFlags.resetFlagCallReported():this.unregister(ct)):d&&(i||e)&&this.reloadFeatureFlags(),a=!0}finally{o&&this.persistence.Ma(a)}}}setPersonProperties(t,i){if((t||i)&&this.Xu("posthog.setPersonProperties")){var e=vl(this.get_distinct_id(),t,i);this.ku!==e?(this.setPersonPropertiesForFlags({$set:t||{},$set_once:i||{}},!0),this.capture("$set",{$set:t||{},$set_once:i||{}}),this.ku=e):ms.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}unsetPersonProperties(t){var i,e=(_i(t)?t:[t]).filter(t=>xi(t)&&t.length>0);0!==e.length&&this.Xu("posthog.unsetPersonProperties")&&(null==(i=this.featureFlags)||i.unsetPersonPropertiesForFlags(e,!0),this.capture("$set",{$unset:e}),this.ku=null)}group(t,i,e){var s;if(t&&i){null==(s=this.persistence)||s.syncCookieProperties(),this.Ju();var n=this.getGroups(),o=n[t]!==i;if(o&&this.resetGroupPropertiesForFlags(t),this.register({$groups:r({},n,{[t]:i})}),(o||e)&&this.Ku()){var a={$group_type:t,$group_key:i};e&&(a.$group_set=e),this.capture(Wt,a)}e&&this.setGroupPropertiesForFlags({[t]:e}),o&&!e&&this.reloadFeatureFlags()}else ms.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(t,i){var e;void 0===i&&(i=!0),null==(e=this.featureFlags)||e.setPersonPropertiesForFlags(t,i)}resetPersonPropertiesForFlags(t){var i;void 0===t&&(t=!0),null==(i=this.featureFlags)||i.resetPersonPropertiesForFlags(t)}setGroupPropertiesForFlags(t,i){var e;void 0===i&&(i=!0),this.Xu("posthog.setGroupPropertiesForFlags")&&(null==(e=this.featureFlags)||e.setGroupPropertiesForFlags(t,i))}resetGroupPropertiesForFlags(t){var i;null==(i=this.featureFlags)||i.resetGroupPropertiesForFlags(t)}reset(t){var i=Ti(t)?t:null==t?void 0:t.resetDeviceID,e=Ti(t)||null==t?void 0:t.bootstrap;this.eh(i,!1,e)}eh(t,i,e){var s,n,o,a;if(void 0===i&&(i=!1),ms.info("reset"),!this.__loaded)return ms.uninitializedWarning("posthog.reset");var l=null==e?void 0:e.sessionID;this.config.bootstrap=e||(null==(s=this.xu)?void 0:s.bootstrap)||{},null==(n=this.featureFlags)||null==n.updateConfig||n.updateConfig(this.config,this.Ua());var h=this.get_property(d),u=this.get_property(v),c=this.get_property(C);null==(o=this.sessionRecording)||o.flushBeforeIdentityReset();var f=this.is_capturing();this.consent.reset(),i||!f||this.is_capturing()||console.warn("[PostHog.js]","reset() cleared the stored consent, and capturing is now off because of `opt_out_capturing_by_default`. Call opt_in_capturing() again, and prefer calling reset() before opting in rather than after.");var p=null==(a=this.persistence)||null==a.Sa?void 0:a.Sa(),g=!1;try{var _,m,b,y,w,x,S,k,E,P,T,F,A;if(null==(_=this.persistence)||_.clear(),null==(m=this.sessionPersistence)||m.clear(),this.gu.clear(),this.Qu(),wi(c)||null==(b=this.persistence)||b.register({[C]:c}),null==(y=this.surveys)||y.reset(),null==(w=this.featureFlags)||w.reset(),null==(x=this.conversations)||x.reset(),null==(S=this.logs)||S.reset(),null==(k=this.metrics)||k.reset(),null==(E=this.persistence)||E.set_property(_t,Bt),null==(P=this.sessionManager)||P.resetSessionId(),this.ku=null,"always"===this.config.cookieless_mode)this.register_once({distinct_id:kt,$device_id:null},"");else{var I=this.config.get_device_id(Bs());this.register_once({distinct_id:I,$device_id:t?I:h},""),t||wi(u)||this.register({[v]:u})}if(this.register({$last_posthog_reset:(new Date).toISOString()},1),e)if(void 0===e.distinctID||this.ou()||(null==(A=this.persistence)||A.set_property(_t,e.isIdentifiedID?Lt:Bt),this.register({distinct_id:e.distinctID})),null==(T=this.featureFlags)||T.initialize(),!(wi(l)||null!=(F=this.sessionManager)&&F.setBootstrapSessionId(l,!0))){var R=r({},e);delete R.sessionID,this.config.bootstrap=R}delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,g=!0}finally{var O;p&&(null==(O=this.persistence)||null==O.Ma||O.Ma(g))}this.reloadFeatureFlags()}shutdown(t){var i=this;return n(function*(){var t,e,r,s,n,o,a;if(i.__loaded){i.fu=!0,i.$u().dispose(),null==(t=i.sessionRecording)||t.dispose(),null==(e=i.logs)||e.flushLogs("sendBeacon"),null==(r=i.metrics)||r.flush("sendBeacon"),null==(s=i.Tu)||s.unload(),null==(n=i.Iu)||n.unload();try{var l;null==(l=i.featureFlags)||l.destroy()}catch(t){ms.error("Error while destroying feature flags",t)}null==(o=i.persistence)||o.destroy(),null==(a=i.sessionPersistence)||a.destroy()}else ms.uninitializedWarning("posthog.shutdown")})()}setIdentity(t,i){var e;delete this.config.identity_claims,this.config.identity_distinct_id=t,this.config.identity_hash=i,this.alias(t),null==(e=this.conversations)||e.ih()}clearIdentity(){var t;delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,null==(t=this.conversations)||t.rh()}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var t,i;return null!==(t=null==(i=this.sessionManager)?void 0:i.checkAndGetSessionAndWindowId(!0).sessionId)&&void 0!==t?t:""}get_session_replay_url(t){if(!this.sessionManager)return"";var i=this.sessionManager.checkAndGetSessionAndWindowId(!0),e=i.sessionStartTimestamp,r=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+i.sessionId);if(null!=t&&t.withTimestamp&&e){var s,n=null!==(s=t.timestampLookBack)&&void 0!==s?s:10;if(!e)return r;r+="?t="+Math.max(Math.floor(((new Date).getTime()-e)/1e3)-n,0)}return r}alias(t,i){return t===this.get_property("$people_distinct_id")?(ms.critical("Attempting to create alias for existing People user - aborting."),-2):this.Xu("posthog.alias")?(wi(i)&&(i=this.get_distinct_id()),t!==i?(this.Yu(c,t),this.capture("$create_alias",{alias:t,distinct_id:i})):(ms.warn("alias matches current distinct_id - skipping api call."),this.identify(t),-1)):void 0}set_config(t){var i=r({},this.config);if(bi(t)){var e,s,n,o,a,h,u,d,v,c,f,p,g;xs(this.config,ql(t));var _=this.du();null==(e=this.persistence)||e.update_config(this.config,i,_),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new Lo(r({},this.config,{persistence:"sessionStorage"}),_,!1);var m=this.Su(this.config.debug);Ti(m)&&(this.config.debug=m),Ti(this.config.debug)&&(this.config.debug?(l.DEBUG=!0,Vs.Et()&&Vs.Ot("ph_debug",!0),ms.info("set_config",{config:t,oldConfig:i,newConfig:r({},this.config)})):(l.DEBUG=!1,Vs.Et()&&Vs.Dt("ph_debug"))),null==(s=this.featureFlags)||null==s.updateConfig||s.updateConfig(this.config,this.Ua()),null==(n=this.exceptionObserver)||n.onConfigChange(),null==(o=this.exceptions)||o.onConfigChange(),null==(a=this.sessionRecording)||a.startIfEnabledOrStop(),null==(h=this.tracingHeaders)||h.startIfEnabledOrStop(),null==(u=this.autocapture)||u.startIfEnabled(),null==(d=this.heatmaps)||d.startIfEnabled(),("capture_pageview"in t||"disable_capture_url_hashes"in t)&&(null==(v=this.historyAutocapture)||v.startIfEnabledOrStop()),null==(c=this.exceptionObserver)||c.startIfEnabledOrStop(),null==(f=this.deadClicksAutocapture)||f.startIfEnabledOrStop(),null==(p=this.surveys)||p.loadIfEnabled(),this.vu(),null==(g=this.externalIntegrations)||g.startIfEnabledOrStop(),!i.segment&&this.config.segment&&this.persistence&&Zn(this,Al,!1)}}_overrideSDKInfo(t,i){l.LIB_NAME=t,l.LIB_VERSION=i}startSessionRecording(t){var i,e,r,s,n,o=!0===t,a={sampling:o||!(null==t||!t.sampling),linked_flag:o||!(null==t||!t.linked_flag),url_trigger:o||!(null==t||!t.url_trigger),event_trigger:o||!(null==t||!t.event_trigger)};Object.values(a).some(Boolean)&&(null==(i=this.sessionManager)||i.checkAndGetSessionAndWindowId(),a.sampling&&(null==(e=this.sessionRecording)||e.overrideSampling()),a.linked_flag&&(null==(r=this.sessionRecording)||r.overrideLinkedFlag()),a.url_trigger&&(null==(s=this.sessionRecording)||s.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 t;return!(null==(t=this.sessionRecording)||!t.started)}captureException(t,i){try{if(!this.exceptions)return;var e=this.exceptions.buildProperties(t,{handled:!0,syntheticException:new Error("PostHog syntheticException")});return this.exceptions.sendExceptionEvent(r({},e,i))}catch(t){return}}addExceptionStep(t,i){var e;null==(e=this.exceptions)||e.addExceptionStep(t,i)}captureLog(t){var i;null==(i=this.logs)||i.captureLog(t)}get logger(){var i,e;return null!==(i=null==(e=this.logs)?void 0:e.logger)&&void 0!==i?i:t.nh}startExceptionAutocapture(t){this.set_config({capture_exceptions:null==t||t})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(t){var i,e;return null!==(i=null==(e=this.toolbar)?void 0:e.loadToolbar(t))&&void 0!==i&&i}get_property(t){var i;return null==(i=this.persistence)?void 0:i.props[t]}getSessionProperty(t){var i;return null==(i=this.sessionPersistence)?void 0:i.props[t]}toString(){var t,i=null!==(t=this.config.name)&&void 0!==t?t:Ll;return i!==Ll&&(i="posthog."+i),i}_isIdentified(){var t,i;return"identified"===(null==(t=this.persistence)?void 0:t.get_property("$user_state"))||"identified"===(null==(i=this.sessionPersistence)?void 0:i.get_property("$user_state"))}Ku(){var t,i;return!("never"===this.config.person_profiles||"identified_only"===this.config.person_profiles&&!this._isIdentified()&&yi(this.getGroups())&&(null==(t=this.persistence)||null==(t=t.props)||!t.__alias)&&(null==(i=this.persistence)||null==(i=i.props)||!i.$epp))}zu(){return!0===this.config.capture_pageleave||"if_capture_pageview"===this.config.capture_pageleave&&!!this.config.capture_pageview}createPersonProfile(){this.Ku()||this.Xu("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.Xu("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}Xu(t){return"never"===this.config.person_profiles?(ms.error(t+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.au(),this.Yu(St,!0),!0)}du(){if("always"===this.config.cookieless_mode)return!0;var t=this.consent.isOptedOut();return this.config.disable_persistence||t&&!(!this.config.opt_out_persistence_by_default&&"on_reject"!==this.config.cookieless_mode)}vu(){var t,i,e,r,s,n=this.du();return this.is_capturing()||null==(t=this.logs)||t.sh(),(null==(i=this.persistence)?void 0:i.gi)!==n&&(null==(e=this.persistence)||e.set_disabled(n)),(null==(r=this.sessionPersistence)?void 0:r.gi)!==n&&(null==(s=this.sessionPersistence)||s.set_disabled(n)),n&&(this.gu.clear(),this.Qu()),n}opt_in_capturing(i){var e,r,s;if("always"!==this.config.cookieless_mode){if(this.ou()){var n,o,a,l,h,u;null==(n=this.sessionRecording)||n.dispose({discardBufferedEvents:!0}),this.eh(!0,!0),null==(o=this.sessionManager)||o.destroy(),null==(a=this.pageViewManager)||a.destroy(),this.sessionManager=new rl(this),this.pageViewManager=new eo(this),this.persistence&&(this.sessionPropsManager=new Qa(this,this.sessionManager,this.persistence));var d,v=null!==(l=null==(h=this.config.__extensionClasses)?void 0:h.sessionRecording)&&void 0!==l?l:null==(u=t.__defaultExtensionClasses)?void 0:u.sessionRecording;v&&(this.sessionRecording=this.su(this.sessionRecording,new v(this)),this.Yl&&(null==(d=this.sessionRecording)||null==d.onRemoteConfig||d.onRemoteConfig(this.Yl)))}this.consent.optInOut(!0),this.vu(),this.ju(),null==(e=this.sessionRecording)||e.startIfEnabledOrStop(),"on_reject"==this.config.cookieless_mode&&(null==(r=this.surveys)||r.loadIfEnabled()),(wi(null==i?void 0:i.captureEventName)||null!=i&&i.captureEventName)&&this.capture(null!==(s=null==i?void 0:i.captureEventName)&&void 0!==s?s:"$opt_in",null==i?void 0:i.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.Bu()}else ms.warn(Il)}opt_out_capturing(){if("always"!==this.config.cookieless_mode){var t,i,e="on_reject"===this.config.cookieless_mode?this.sessionRecording:void 0;null==e||e.dispose({discardBufferedEvents:!0}),"on_reject"===this.config.cookieless_mode&&this.consent.isOptedIn()&&this.eh(!0,!0),this.consent.optInOut(!1),this.vu(),"on_reject"===this.config.cookieless_mode&&(this.register({distinct_id:kt,$device_id:null}),this.nu(e),this.sessionRecording=void 0,null==(t=this.sessionManager)||t.destroy(),null==(i=this.pageViewManager)||i.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,this.config.capture_pageview&&this.Bu(),this.ju())}else ms.warn(Il)}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){var t=this.consent.consent;return 1===t?"granted":0===t?"denied":"pending"}is_capturing(){return"always"===this.config.cookieless_mode||("on_reject"===this.config.cookieless_mode?this.consent.isRejected()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this.vu()}_is_bot(){return Jt?sl(Jt,this.config.custom_blocked_useragents):void 0}Bu(){Xt&&("visible"===Xt.visibilityState?this.bu||(this.bu=!0,this.capture(Ht,{title:Xt.title},{send_instantly:!0}),this._u&&(Xt.removeEventListener(zt,this._u),this._u=null)):this._u||(this._u=this.Bu.bind(this),Fs(Xt,zt,this._u)))}debug(t){!1===t?(null==Gt||Gt.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(null==Gt||Gt.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}))}Ua(){var t=this.xu||{};return"advanced_disable_flags"in t?!!t.advanced_disable_flags:!1!==this.config.advanced_disable_flags?!!this.config.advanced_disable_flags:!0===this.config.advanced_disable_decide?(ms.warn("Config field 'advanced_disable_decide' is deprecated. Please use 'advanced_disable_flags' instead. The old field will be removed in a future major version."),!0):function(t,i,e,r,s){var n=i in t&&!Ei(t[i]),o=e in t&&!Ei(t[e]);return n?t[i]:!!o&&(s&&s.warn("Config field '"+e+"' is deprecated. Please use '"+i+"' instead. The old field will be removed in a future major version."),t[e])}(t,"advanced_disable_flags","advanced_disable_decide",0,ms)}Ts(t){var i;if(Ei(this.config.before_send))return t;var e=Object.keys(null!==(i=t.properties)&&void 0!==i?i:{}).filter(Fi),r=_i(this.config.before_send)?this.config.before_send:[this.config.before_send],s=t;for(var n of r)try{if(s=n(s),Ei(s)){var o="Event '"+t.event+"' was rejected in beforeSend function";return Ci(t.event)?ms.warn(o+". This can cause unexpected behavior."):ms.info(o),null}s.properties&&!yi(s.properties)||ms.warn("Event '"+t.event+"' has no properties after beforeSend function, this is likely an error.")}catch(i){return ms.error("Error in beforeSend function for event '"+t.event+"':",i),null}for(var a of e)if(s.properties&&Ei(s.properties[a]))return ms.warn("Event '"+t.event+"' had its '"+a+"' property removed in a beforeSend function. This property is required for ingestion, so the event will be dropped."),null;return s}getPageViewId(){var t;return null==(t=this.pageViewManager.Fo)?void 0:t.pageViewId}captureTraceFeedback(t,i){this.capture("$ai_feedback",{$ai_trace_id:String(t),$ai_feedback_text:i})}captureTraceMetric(t,i,e){this.capture("$ai_metric",{$ai_trace_id:String(t),$ai_metric_name:i,$ai_metric_value:String(e)})}Su(t){var i=Ti(t)&&!t,e=Vs.Et()&&"true"===Vs.Lt("ph_debug");return!i&&(!!e||t)}},s.__defaultExtensionClasses={},s.nh=(()=>{var t=()=>{};return{trace:t,debug:t,info:t,warn:t,error:t,fatal:t}})(),s);!function(t,i){for(var e=0;i.length>e;e++)t.prototype[i[e]]=Es(t.prototype[i[e]])}(Wl,["identify"]);var Gl=class{constructor(t){this.disabled=!1===t;var i=bi(t)?t:{};this.thresholdPx=i.threshold_px||30,this.timeoutMs=i.timeout_ms||1e3,this.clickCount=i.click_count||3,this.clicks=[]}isRageClick(t,i,e){if(this.disabled)return!1;var r=this.clicks[this.clicks.length-1];if(r&&Math.abs(t-r.x)+Math.abs(i-r.y)<this.thresholdPx&&this.timeoutMs>e-r.timestamp){if(this.clicks.push({x:t,y:i,timestamp:e}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:t,y:i,timestamp:e}];return!1}},Kl="$copy_autocapture",Jl=bs("[AutoCapture]");function Xl(t,i){return i.length>t?i.slice(0,t)+"...":i}function Yl(t){if(t.previousElementSibling)return t.previousElementSibling;var i=t;do{i=i.previousSibling}while(i&&!un(i));return i}function Zl(t,i){var e,s,n=i.e,o=i.maskAllElementAttributes,a=i.maskAllText,l=i.elementAttributeIgnoreList,h=i.elementsChainAsString,u=i.disableCaptureUrlHashes;if(!un(t))return{props:{}};for(var d=[t],v=new Set([t]),c=t;c.parentNode&&!dn(c,"body")&&1e3>d.length;)if(cn(c.parentNode)){var f=c.parentNode.host;if(v.has(f))break;v.add(f),d.push(f),c=f}else{if(!un(c.parentNode))break;if(v.has(c.parentNode))break;v.add(c.parentNode),d.push(c.parentNode),c=c.parentNode}var p="click"===n.type&&"http://www.w3.org/2000/svg"===t.namespaceURI?d.findIndex(t=>dn(t,"button")||dn(t,"a")):-1;p>0&&(a=a||d.slice(0,p+1).some(t=>!Rn(t)||On(t)));var g,_,m,b=[],y={},w=!1,x=!1;if(ws(d,t=>{var i=Rn(t);if(dn(t,"a")){var e=t.getAttribute("href");w=!!(i&&e&&Un(e))&&(u?tr(e):e)}ui(gn(t),"ph-no-capture")&&(x=!0),b.push(function(t,i,e,r,s){void 0===s&&(s=!1);var n=t.tagName.toLowerCase(),o={tag_name:n};yn.indexOf(n)>-1&&!e&&(o.$el_text="a"===n.toLowerCase()||"button"===n.toLowerCase()?Xl(1024,Hn(t)):Xl(1024,mn(t)));var a=gn(t);a.length>0&&(o.classes=a.filter(function(t){return""!==t})),ws(t.attributes,function(e){var n;if((!On(t)||-1!==["name","id","class","aria-label"].indexOf(e.name))&&(null==r||!r.includes(e.name))&&!i&&Un(e.value)&&(!xi(n=e.name)||"_ngcontent"!==n.substring(0,10)&&"_nghost"!==n.substring(0,7))){var a=e.value;"class"===e.name&&(a=fn(a).join(" ")),o["attr__"+e.name]=Xl(1024,"href"===e.name&&s?tr(a):a)}});for(var l=1,h=1,u=t;u=Yl(u);)l++,u.tagName===t.tagName&&h++;return o.nth_child=l,o.nth_of_type=h,o}(t,o,a,l,u)),ws(function(t){if(!Rn(t))return{};var i={};return ws(t.attributes,function(t){if(t.name&&0===t.name.indexOf("data-ph-capture-attribute")){var e=t.name.replace("data-ph-capture-attribute-",""),r=t.value;e&&r&&Un(r)&&(i[e]=r)}}),i}(t),(t,i)=>{({}).hasOwnProperty.call(y,i)||(y[i]=t)})}),x)return{props:{},explicitNoCapture:x};if(p>0&&(t=d[p],b.splice(0,p)),a||(b[0].$el_text=dn(t,"a")||dn(t,"button")?Hn(t):mn(t)),w){var S,k;b[0].attr__href=w;var E=null==(S=lo(w))?void 0:S.host,P=null==Gt||null==(k=Gt.location)?void 0:k.host;E&&P&&E!==P&&(g=w)}return{props:xs((_=n.type,{$event_type:_,$ce_version:1}),h?{}:{$elements:b},{$elements_chain:(m=b,_i(m)?function(t){return t.map(t=>{var i,e,s="";if(t.tag_name&&(s+=t.tag_name),t.attr_class)for(var n of(t.attr_class.sort(),t.attr_class))s+="."+n.replace(/"/g,"");var o=r({},t.text?{text:t.text}:{},{"nth-child":null!==(i=t.nth_child)&&void 0!==i?i:0,"nth-of-type":null!==(e=t.nth_of_type)&&void 0!==e?e:0},t.href?{href:t.href}:{},t.attr_id?{attr_id:t.attr_id}:{},t.attributes),a={};return Ss(o).sort((t,i)=>{return(r=i[0])>(e=t[0])?-1:e>r?1:0;var e,r}).forEach(t=>{var i=t[1];return a[Vn(t[0].toString())]=Vn(i.toString())}),(s+=":")+Ss(a).map(t=>t[0]+'="'+t[1]+'"').join("")}).join(";")}(function(t){return t.map(t=>{var i,e,r={text:null==(i=t.$el_text)?void 0:i.slice(0,400),tag_name:t.tag_name,href:null==(e=t.attr__href)?void 0:e.slice(0,2048),attr_class:Wn(t),attr_id:t.attr__id,nth_child:t.nth_child,nth_of_type:t.nth_of_type,attributes:{}};return Ss(t).filter(t=>0===t[0].indexOf("attr__")).forEach(t=>r.attributes[t[0]]=t[1]),r})}(m)):"")},null!=(e=b[0])&&e.$el_text?{$el_text:null==(s=b[0])?void 0:s.$el_text}:{},g&&"click"===n.type?{$external_click_url:g}:{},y),target:t}}var Ql=class{Qs(){this.Ks=void 0,clearTimeout(this.Xs),this.Xs=void 0}Ys(t){var i;if(!Rn(t))return!0;for(var e,r=null!==(i=this.so().css_selector_ignorelist)&&void 0!==i?i:kn,s=new Set,n=t,o=function(){if(s.size>=1e3||s.has(n))return{v:!0};s.add(n);var t=n,i=gn(t);if(ui(i,"ph-no-capture")||ui(i,"ph-sensitive")||On(t)||r.some(i=>wn(t,i)))return{v:!0};var e=n.parentNode;n=cn(e)?e.host:e&&un(e)?e:null};n;)if(e=o())return e.v;return!1}oo(t){if(this.isEnabled&&"pointercancel"!==t.type)if("pointerdown"!==t.type){var i=this.Ks;i&&(t.pointerId!==i.id||Math.abs(t.clientX-i.x)>5||Math.abs(t.clientY-i.y)>5?this.Qs():"pointerup"===t.type&&(i.released=!0,this.Xs=setTimeout(()=>this.Qs(),0)))}else{var e;this.Qs();var r=bn(t);t.isPrimary&&0===t.button&&!t.ctrlKey&&r&&un(r)&&(this.Ks={target:r,excluded:this.Ys(r),id:t.pointerId,x:t.clientX,y:t.clientY,released:!1,distinctId:null==(e=this.ao)?void 0:e.distinctId})}else this.Qs()}lo(t){var i,e=this.Ks;this.Qs();var r=bn(t);if(null!=e&&e.released&&e.target.isConnected&&e.distinctId===(null==(i=this.ao)?void 0:i.distinctId)&&t.pointerId===e.id&&(t.detail>0||"touch"===t.pointerType||"pen"===t.pointerType)&&0===t.button&&5>=Math.abs(t.clientX-e.x)&&5>=Math.abs(t.clientY-e.y)&&r&&(dn(r,"html")||dn(r,"body"))){var s;if(e.excluded)return null;var n=null!==(s=this.so().css_selector_ignorelist)&&void 0!==s?s:kn;return[r,null==Xt?void 0:Xt.documentElement,null==Xt?void 0:Xt.body].some(t=>{if(!t)return!1;var i=gn(t);return ui(i,"ph-no-capture")||ui(i,"ph-sensitive")||!Rn(t)||On(t)||n.some(i=>wn(t,i))})?null:e.target}}constructor(t){this.uo=t,this.name="autocapture",this.ho=!1,this.do=null,this.vo=!1,this.co=!1,this.xn={enabled:!1,rageclick:!1,maskAllElementAttributes:!1,maskAllText:!1,disableCaptureUrlHashes:!1,remoteRequestsDisabled:!1},this.fo=!1,this.uo.refresh(this.xn),this.rageclicks=new Gl(this.xn.rageclick),this.po=null}setup(t){this.mo(),this.ao=t;var i=t.onRemoteConfig(this.onRemoteConfig.bind(this));this.fo?i.dispose():(this.yo=i,this.startIfEnabled())}dispose(){var t;this.fo||(this.fo=!0,this.ao=void 0,null==(t=this.yo)||t.dispose(),this.yo=void 0,this.bo())}so(){return this.uo.refresh(this.xn),this.xn}mo(){var t,i;return this.so(),this.xn.url_allowlist=null==(t=this.xn.url_allowlist)?void 0:t.map(t=>new RegExp(t)),this.xn.url_ignorelist=null==(i=this.xn.url_ignorelist)?void 0:i.map(t=>new RegExp(t)),this.xn}_o(){if(this.isBrowserSupported()){if(Gt&&Xt){var t=this.wo=t=>{t=t||(null==Gt?void 0:Gt.event);try{if("blur"===t.type)return void this.Qs();if(0===t.type.indexOf("pointer"))return void this.oo(t);var i="click"===t.type?this.lo(t):void 0;if(ki(i))return;this.ko(t,"$autocapture",i)}catch(t){Jl.error("Failed to capture event",t)}};if(Fs(Gt,"blur",t),Fs(Xt,"submit",t,{capture:!0}),Fs(Xt,"change",t,{capture:!0}),Fs(Xt,"click",t,{capture:!0}),ws(["pointerdown","pointermove","pointerup","pointercancel"],i=>{Fs(Xt,i,t,{capture:!0})}),this.so().capture_copied_text){var i=this.So=t=>{t=t||(null==Gt?void 0:Gt.event);try{this.ko(t,Kl)}catch(t){Jl.error("Failed to capture clipboard event",t)}};Fs(Xt,"copy",i,{capture:!0}),Fs(Xt,"cut",i,{capture:!0}),Fs(Xt,"paste",i,{capture:!0})}}}else Jl.info("Disabling Automatic Event Collection because this browser is not supported")}bo(){this.Qs(),this.wo&&(null==Gt||Gt.removeEventListener("blur",this.wo),ws(["pointerdown","pointermove","pointerup","pointercancel"],t=>{null==Xt||Xt.removeEventListener(t,this.wo,!0)}),null==Xt||Xt.removeEventListener("submit",this.wo,!0),null==Xt||Xt.removeEventListener("change",this.wo,!0),null==Xt||Xt.removeEventListener("click",this.wo,!0),this.wo=void 0),this.So&&(null==Xt||Xt.removeEventListener("copy",this.So,!0),null==Xt||Xt.removeEventListener("cut",this.So,!0),null==Xt||Xt.removeEventListener("paste",this.So,!0),this.So=void 0),this.ho=!1}startIfEnabled(){this.isEnabled||this.Qs(),!this.fo&&this.ao&&this.isEnabled&&!this.ho&&(this._o(),this.ho=!0)}onRemoteConfig(t){if(!this.fo)if(this.vo=!0,t.ok){var i=t.config;i.elementsChainAsString&&(this.co=i.elementsChainAsString);var e,r=i.autocapture_opt_out;Ti(r)&&(null==(e=this.ao)||e.kv.set(m,r),this.do=r),this.startIfEnabled()}else this.startIfEnabled()}setElementSelectors(t){this.po=t}getElementSelectors(t,i){var e,r=[];return null==(e=this.po)||e.forEach(e=>{var s;null==Xt||null==(s=Xt.querySelectorAll(e))||s.forEach(s=>{t!==s&&i!==s||ui(r,e)||r.push(e)})}),r}get isEnabled(){var t,i;if(this.fo)return!1;var e=null==(t=this.ao)?void 0:t.kv.get(m),r=this.do,s=this.so();if(!s.remoteRequestsDisabled&&!this.vo)return!1;var n=s.remoteRequestsDisabled&&!this.vo;if(ki(r)&&!Ti(e)&&!n)return!1;var o=null!==(i=this.do)&&void 0!==i?i:!!e;return!!s.enabled&&!o}ko(t,i,e){if(void 0===i&&(i="$autocapture"),this.isEnabled){var s=e||bn(t);vn(s)&&(s=s.parentNode||null);var n,o=this.mo();"$autocapture"===i&&"click"===t.type&&t instanceof MouseEvent&&o.rageclick&&null!=(n=this.rageclicks)&&n.isRageClick(t.clientX,t.clientY,t.timeStamp||(new Date).getTime())&&Fn(s,o.rageclick)&&this.ko(t,"$rageclick",e);var a=i===Kl,l=a?r({},o,{dom_event_allowlist:void 0}):o;if(s&&function(t,i,e,r,s,n){var o;if(!Gt||An(t))return!1;if(null!=e&&e.url_allowlist&&!pn(e.url_allowlist,n))return!1;if(null!=e&&e.url_ignorelist&&pn(e.url_ignorelist,n))return!1;if(null!=e&&e.dom_event_allowlist){var a=e.dom_event_allowlist;if(a&&!a.some(t=>i.type===t))return!1}var l=In(t,r),h=l.parentIsUsefulElement,u=l.targetElementList;if(!function(t,i){var e=null==i?void 0:i.element_allowlist;if(wi(e))return!0;var r,s=function(t){if(e.some(i=>t.tagName.toLowerCase()===i))return{v:!0}};for(var n of t)if(r=s(n))return r.v;return!1}(u,e))return!1;if(!xn(u,null==e?void 0:e.css_selector_allowlist))return!1;if(xn(u,null!==(o=null==e?void 0:e.css_selector_ignorelist)&&void 0!==o?o:kn))return!1;try{var d=Gt.getComputedStyle(t);if(d&&"pointer"===d.getPropertyValue("cursor")&&"click"===i.type)return!0}catch(t){}var v=t.tagName.toLowerCase();switch(v){case"html":return!1;case"form":return(s||["submit"]).indexOf(i.type)>=0;case"input":case"select":case"textarea":return(s||["change","click"]).indexOf(i.type)>=0;default:return h?(s||["click"]).indexOf(i.type)>=0:(s||["click"]).indexOf(i.type)>=0&&(yn.indexOf(v)>-1||"true"===t.getAttribute("contenteditable"))}}(s,t,l,a,a?["copy","cut","paste"]:void 0,{config:{get_current_url:o.getCurrentUrl}})){var h,u=Zl(s,{e:t,maskAllElementAttributes:o.maskAllElementAttributes,maskAllText:o.maskAllText,elementAttributeIgnoreList:o.element_attribute_ignorelist,elementsChainAsString:this.co,disableCaptureUrlHashes:o.disableCaptureUrlHashes}),d=u.props;if(u.explicitNoCapture)return!1;var v=this.getElementSelectors(s,u.target);if(v&&v.length>0&&(d.$element_selectors=v),i===Kl){var c=t.type||"clipboard";if("paste"!==c){var f,p,g=null==Gt||null==(f=Gt.getSelection())?void 0:f.toString(),_=_n(g);if(!_)return!1;d.$selected_content=_,d.$clipboard_text_length=null!==(p=null==g?void 0:g.length)&&void 0!==p?p:0}d.$copy_type=c}return null==(h=this.ao)||h.capture(i,d).catch(t=>Jl.error("Failed to capture event",t)),!0}}else this.Qs()}isBrowserSupported(){return mi(null==Xt?void 0:Xt.querySelectorAll)}},th=class{constructor(t){this._instance=t}refresh(t){var i=this._instance.config,e=bi(i.autocapture)?i.autocapture:void 0;t.enabled=!!i.autocapture,t.rageclick=i.rageclick,t.maskAllElementAttributes=i.mask_all_element_attributes,t.maskAllText=i.mask_all_text,t.disableCaptureUrlHashes=i.disable_capture_url_hashes,t.getCurrentUrl=i.get_current_url,t.remoteRequestsDisabled=this._instance.Ua(),t.url_allowlist=null==e?void 0:e.url_allowlist,t.url_ignorelist=null==e?void 0:e.url_ignorelist,t.dom_event_allowlist=null==e?void 0:e.dom_event_allowlist,t.element_allowlist=null==e?void 0:e.element_allowlist,t.css_selector_allowlist=null==e?void 0:e.css_selector_allowlist,t.css_selector_ignorelist=null==e?void 0:e.css_selector_ignorelist,t.element_attribute_ignorelist=null==e?void 0:e.element_attribute_ignorelist,t.capture_copied_text=null==e?void 0:e.capture_copied_text}},ih=bs("[ExceptionAutocapture]"),eh=()=>{},rh=t=>{var i;if(mi(t))return null!==(i=t.__posthog_layer__)&&void 0!==i?i:t.__rrweb_layer__};function sh(t,i,e){try{if(!(i in t))return eh;var r={next:t[i]},s=e(function(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];return r.next.apply(this,i)});return mi(s)&&(s.prototype=s.prototype||{},Object.defineProperties(s,{__posthog_wrapped__:{enumerable:!1,value:!0},__posthog_layer__:{enumerable:!1,value:r}})),t[i]=s,()=>{if(t[i]!==s)for(var e=t[i],n=rh(e);n;){if(n.next===s)return void(n.next=r.next);n=rh(e=n.next)}else t[i]=r.next}}catch(t){return eh}}var nh=bs("[TracingHeaders]"),oh=bs("[Web Vitals]"),ah=9e5,lh=["CLS","FCP","INP","LCP"],hh=["INP","LCP"],uh=["interactionTarget","interactionType","inputDelay","processingDuration","presentationDelay","loadState","target","url","timeToFirstByte","resourceLoadDelay","resourceLoadDuration","elementRenderDelay","largestShiftTarget","largestShiftTime","largestShiftValue","firstByteToFCP"],dh="disabled",vh="lazy_loading",ch=bs("[SessionRecording]"),fh=bs("[Heatmaps]");function ph(t){return bi(t)&&"clientX"in t&&"clientY"in t&&$i(t.clientX)&&$i(t.clientY)}var gh=bs("[Product Tours]"),_h=t=>{var i;return!t.config.disable_product_tours&&!(null==(i=t.persistence)||!i.get_property(E))},mh=bs("[SiteApps]"),bh="Error while initializing PostHog app with config id ",yh=(t,i)=>null!=t&&t.then?t.then(i):i(t),wh="SDK is not enabled or survey functionality is not yet loaded",xh="Disabled. Not loading surveys.",Sh=class{constructor(t,i){this.uo=t,this.oh=i,this.name="surveys",this._surveyEventReceiver=null,this._surveyManager=null,this.ah=!1,this.uh=[],this.hh=null,this.dh=null,this.fo=!1,this.fh=new Set,this.onRemoteConfig=t=>{if(!this.fo&&!this.xn.disableSurveys){if(!t.ok)return ml.warn("Remote config unavailable. Not loading surveys.");var i=t.config.surveys;if(Ei(i))return ml.warn("Flags not loaded yet. Not loading surveys.");this.ph=Ti(i)?i:i.length>0,ml.info("flags response received, isSurveysEnabled: "+this.ph),this.loadIfEnabled()}}}setup(t){if(!this.fo)return this.gh=t,yh(t.kv.initialize(),()=>{if(this.gh===t&&!this.fo){this.gh=void 0,this.ao=t;var i=t.onRemoteConfig(this.onRemoteConfig);this.fo?i.dispose():(this.yo=i,this.loadIfEnabled())}})}dispose(){var t,i,e;this.fo||(this.fo=!0,this.gh=void 0,this.ao=void 0,null==(t=this.yo)||t.dispose(),this.yo=void 0,null==(i=this._surveyEventReceiver)||i.dispose(),this._surveyEventReceiver=null,null==(e=this._surveyManager)||null==e.dispose||e.dispose(),this._surveyManager=null,this.uh=[],this.hh=null,this.fh.forEach(t=>clearTimeout(t)),this.fh.clear())}get xn(){return this.uo.get()}initialize(){this.loadIfEnabled()}reset(){try{var t;null==(t=this._surveyEventReceiver)||t.reset(),localStorage.removeItem("lastSeenSurveyDate");for(var i=[],e=0;e<localStorage.length;e++){var r=localStorage.key(e);(null!=r&&r.startsWith("seenSurvey_")||null!=r&&r.startsWith("inProgressSurvey_"))&&i.push(r)}i.forEach(t=>localStorage.removeItem(t))}catch(t){}}loadIfEnabled(){if(!this.fo&&this.ao){var t=this.xn;if(!this._surveyManager)if(this.ah)ml.info("Already initializing surveys, skipping...");else if(t.disableSurveys)ml.info(xh);else if(t.cookielessMode&&this.uo.isOptedOut())ml.info("Not loading surveys in cookieless mode without consent.");else{var i=this.uo.getExtensions();if(i){if(!wi(this.ph)||t.advancedEnableSurveys){var e=this.ph||t.advancedEnableSurveys;this.ah=!0;try{var r=i.generateSurveys;if(r)return this.mh(r,e),void(this.ah=!1);var s=i.loadExternalDependency;if(!s)return this.yh(jt),void(this.ah=!1);s(t=>{try{if(this.fo)return;var i=this.uo.getExtensions();t||null==i||!i.generateSurveys?this.yh("Could not load surveys script",t):this.mh(i.generateSurveys,e)}finally{this.ah=!1}})}catch(t){throw this.ah=!1,this.yh("Error initializing surveys",t),t}}}else ml.error("PostHog Extensions not found.")}}}mh(t,i){this.fo||(this._surveyManager=t(i),this._surveyEventReceiver=this.uo.createEventReceiver(),ml.info("Surveys loaded successfully"),this.bh({isLoaded:!0}))}yh(t,i){ml.error(t,i),this.bh({isLoaded:!1,error:t})}onSurveysLoaded(t){return this.uh.push(t),this._surveyManager&&this.bh({isLoaded:!0}),()=>{this.uh=this.uh.filter(i=>i!==t)}}getSurveys(t,i){var e;void 0===i&&(i=!1);var r=null!==(e=this.ao)&&void 0!==e?e:this.oh;if(r&&!this.fo){if(this.xn.disableSurveys)return ml.info(xh),t([]);var s=r.kv.get(it);if(s&&!i)return t(s,{isLoaded:!0}),void(this._h()&&this.getSurveys(()=>{},!0));if(this.hh)this.hh.then(i=>{this.fo||t(i.surveys,i.context)}).catch(t=>ml.error("Error in survey callback",t));else{var n=this.wh("/api/surveys/",{method:"GET",query:{token:r.projectToken},sentAt:"query",timeoutMs:this.xn.requestTimeoutMs}).then(t=>{try{return this.kh(r,t)}catch(t){return ml.error("Error processing surveys response",t),this.kh(r,{statusCode:0,error:t})}},t=>this.kh(r,{statusCode:0,error:t}));this.hh=n;var o=()=>{this.hh===n&&(this.hh=null)};n.then(i=>{o(),this.fo||t(i.surveys,i.context)},o).catch(t=>ml.error("Error in survey callback",t))}}}wh(t,i){var e=this.ao;return e?e.sendRequest(t,i):new Promise(t=>t({statusCode:0,error:new Error(wh)}))}kh(t,i){var e;if(this.fo)return{surveys:[],context:{isLoaded:!1,error:wh}};var r=i.statusCode;if(200!==r||!i.json){var s="Surveys API could not be loaded, status: "+r;return 0!==r?ml.error(s):i.error||ml.warn(s),this.dh=Date.now(),{surveys:[],context:{isLoaded:!1,error:s}}}this.dh=null;var n=i.json.surveys||[],o=n.filter(t=>function(t){return!(!t.start_date||t.end_date)}(t)&&(al(t)||function(t){var i;return!(null==(i=t.conditions)||null==(i=i.actions)||null==(i=i.values)||!i.length)}(t)));return o.length>0&&(null==(e=this._surveyEventReceiver)||e.register(o)),t.kv.set({[it]:n,[et]:Date.now()}),{surveys:n,context:{isLoaded:!0}}}_h(){return this.Sh()&&!this.hh&&!this.xh()}Sh(){var t,i,e=null==(t=null!==(i=this.ao)&&void 0!==i?i:this.oh)?void 0:t.kv.get(et);return $i(e)&&Date.now()-e>3e5}xh(){return $i(this.dh)&&3e5>Date.now()-this.dh}markSurveyAsSeen(t,i){var e;bl({id:t,current_iteration:null!==(e=null==i?void 0:i.iteration)&&void 0!==e?e:null});try{localStorage.setItem("lastSeenSurveyDate",(new Date).toISOString())}catch(t){}}bh(t){for(var i of this.uh)try{if(!t.isLoaded)return i([],t);this.getSurveys(i)}catch(t){ml.error("Error in survey callback",t)}}getActiveMatchingSurveys(t,i){if(void 0===i&&(i=!1),!Ei(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(t,i);ml.warn("init was not called")}Ch(t){var i=null;return this.getSurveys(e=>{var r;i=null!==(r=e.find(i=>i.id===t))&&void 0!==r?r:null}),i}Th(t){if(Ei(this._surveyManager))return{eligible:!1,reason:wh};var i="string"==typeof t?this.Ch(t):t;return i?this._surveyManager.checkSurveyEligibility(i):{eligible:!1,reason:"Survey not found"}}Mh(t){if(!this.uo.isCapturing())return{eligible:!1,reason:"PostHog is not capturing, so a survey response cannot be recorded"};if(Ei(this._surveyManager))return{eligible:!1,reason:wh};var i="string"==typeof t?this.Ch(t):t;return i?this._surveyManager.checkSurveyRenderability(i):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(t){if(Ei(this._surveyManager))return ml.warn("init was not called"),{visible:!1,disabledReason:wh};var i=this.Mh(t);return{visible:i.eligible,disabledReason:i.reason}}canRenderSurveyAsync(t,i){return Ei(this._surveyManager)?(ml.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:wh})):new Promise(e=>{this.getSurveys(i=>{var r,s=null!==(r=i.find(i=>i.id===t))&&void 0!==r?r:null;if(s){var n=this.Mh(s);e({visible:n.eligible,disabledReason:n.reason})}else e({visible:!1,disabledReason:"Survey not found"})},i)})}renderSurvey(t,i,e){var r;if(this.uo.isCapturing())if(Ei(this._surveyManager))ml.warn("init was not called");else{var s="string"==typeof t?this.Ch(t):t;if(null!=s&&s.id)if(yl.includes(s.type)){var n=null==Xt?void 0:Xt.querySelector(i);if(n)if(null!=(r=s.appearance)&&r.surveyPopupDelaySeconds){ml.info("Rendering survey "+s.id+" with delay of "+s.appearance.surveyPopupDelaySeconds+" seconds");var o=setTimeout(()=>{var t,i;this.fh.delete(o),!this.fo&&this.uo.isCapturing()&&(ml.info("Rendering survey "+s.id+" with delay of "+(null==(t=s.appearance)?void 0:t.surveyPopupDelaySeconds)+" seconds"),null==(i=this._surveyManager)||i.renderSurvey(s,n,e),ml.info("Survey "+s.id+" rendered"))},1e3*s.appearance.surveyPopupDelaySeconds);this.fh.add(o)}else this._surveyManager.renderSurvey(s,n,e);else ml.warn("Survey element not found")}else ml.warn("Surveys of type "+s.type+" cannot be rendered in the app");else ml.warn("Survey not found")}}displaySurvey(t,i){var e;if(this.uo.isCapturing())if(Ei(this._surveyManager))ml.warn("init was not called");else{var s=this.Ch(t);if(s){var n=s;if(null!=(e=s.appearance)&&e.surveyPopupDelaySeconds&&i.ignoreDelay&&(n=r({},s,{appearance:r({},s.appearance,{surveyPopupDelaySeconds:0})})),i.displayType!==Ko&&i.initialResponses&&ml.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),!1===i.ignoreConditions){var o=this.Th(s);if(!o.eligible)return void ml.warn("Survey is not eligible to be displayed: ",o.reason)}"inline"!==i.displayType?this._surveyManager.handlePopoverSurvey(n,i):this.renderSurvey(n,i.selector,i.properties)}else ml.warn("Survey not found")}}cancelPendingSurvey(t){Ei(this._surveyManager)?ml.warn("init was not called"):this._surveyManager.cancelSurvey(t)}handlePageUnload(){var t;null==(t=this._surveyManager)||null==t.handlePageUnload||t.handlePageUnload()}};function kh(t,i,e){if(Ei(t))return!1;switch(e){case"exact":return t===i;case"contains":var r=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(r,"i").test(t);case"regex":try{return new RegExp(i).test(t)}catch(t){return!1}default:return!1}}var Eh=class{constructor(t){this._instance=t,this.Ih=new Set,this.Eh=new Set,this.Rh=new tl,this.Ah=(t,i)=>this.Ph(t,i)&&this.Fh(t,i)&&this.Oh(t,i)&&this.$h(t,i),this.Ph=(t,i)=>null==i||!i.event||(null==t?void 0:t.event)===(null==i?void 0:i.event)}init(){var t,i;wi(null==(t=this._instance)?void 0:t._addCaptureHook)||(this.Dh=null==(i=this._instance)?void 0:i._addCaptureHook((t,i)=>{this.on(t,i)}))}dispose(){var t;null==(t=this.Dh)||t.call(this),this.Dh=void 0,this.Rh=new tl}register(t){var i,e;if(!wi(null==(i=this._instance)?void 0:i._addCaptureHook)&&(t.forEach(t=>{var i;this.Ih.add(t),null==(i=t.steps)||i.forEach(t=>{this.Eh.add((null==t?void 0:t.event)||"")})}),null!=(e=this._instance)&&e.autocapture)){var r=new Set;this.Ih.forEach(t=>{var i;null==(i=t.steps)||i.forEach(t=>{null!=t&&t.selector&&r.add(t.selector)})}),this._instance.autocapture.setElementSelectors(r)}}replace(t){this.Ih.clear(),this.Eh.clear(),this.register(t)}on(t,i){null!=i&&0!=t.length&&(this.Eh.has(t)||this.Eh.has(i.event))&&this.Ih.forEach(t=>{this.Lh(i,t)&&this.Rh.emit("actionCaptured",t.name)})}Nh(t){this.onAction("actionCaptured",i=>t(i))}Lh(t,i){if(null==(null==i?void 0:i.steps))return!1;for(var e of i.steps)if(this.Ah(t,e))return!0;return!1}onAction(t,i){return this.Rh.on(t,i)}Fh(t,i){if(null!=i&&i.url){var e,r=null==t||null==(e=t.properties)?void 0:e.$current_url;if(!r||"string"!=typeof r)return!1;if(!kh(r,i.url,i.url_matching||"contains"))return!1}return!0}Oh(t,i){return!!this.qh(t,i)&&!!this.jh(t,i)&&!!this.Bh(t,i)}qh(t,i){var e;if(null==i||!i.href)return!0;var r=this.Hh(t);if(r.length>0)return r.some(t=>kh(t.href,i.href,i.href_matching||"exact"));var s,n=(null==t||null==(e=t.properties)?void 0:e.$elements_chain)||"";return!!n&&kh((s=n.match(/(?::|")href="(.*?)"/))?s[1]:"",i.href,i.href_matching||"exact")}jh(t,i){var e;if(null==i||!i.text)return!0;var r=this.Hh(t);if(r.length>0)return r.some(t=>kh(t.text,i.text,i.text_matching||"exact")||kh(t.$el_text,i.text,i.text_matching||"exact"));var s,n,o,a=(null==t||null==(e=t.properties)?void 0:e.$elements_chain)||"";return!!a&&(s=function(t){for(var i,e=[],r=/(?::|")text="(.*?)"/g;!Ei(i=r.exec(t));)e.includes(i[1])||e.push(i[1]);return e}(a),n=i.text,o=i.text_matching||"exact",s.some(t=>kh(t,n,o)))}Bh(t,i){var e,r;if(null==i||!i.selector)return!0;if(null!=t&&null!=(e=t.properties)&&null!=(e=e.$element_selectors)&&e.includes(i.selector))return!0;var s=(null==t||null==(r=t.properties)?void 0:r.$elements_chain)||"";if(i.selector_regex&&s)try{return new RegExp(i.selector_regex).test(s)}catch(t){return!1}return!1}Hh(t){var i;return null==(null==t||null==(i=t.properties)?void 0:i.$elements)?[]:null==t?void 0:t.properties.$elements}$h(t,i){return null==i||!i.properties||0===i.properties.length||dl(i.properties.reduce((t,i)=>{var e=_i(i.value)?i.value.map(String):null!=i.value?[String(i.value)]:[];return t[i.key]={values:e,operator:i.operator||"exact"},t},{}),null==t?void 0:t.properties)}},$h=class{constructor(t){var i;this.zh=[],this._instance=t,this.Uh=new Map,this.Wh=new Map,this.Vh=new Map,this.Gh=null==(i=this._instance)||null==i.onSessionId?void 0:i.onSessionId(t=>this.Zh(t))}Jh(t){return!1}Qh(){return null}Kh(t){}Xh(){}Yh(t,i){return!!t&&dl(t.propertyFilters,null==i?void 0:i.properties)}td(t,i){var e=new Map;return t.forEach(t=>{var r;null==(r=t.conditions)||null==(r=r[i])||null==(r=r.values)||r.forEach(i=>{if(null!=i&&i.name){var r=e.get(i.name)||[];r.push(t.id),e.set(i.name,r)}})}),e}ed(t,i,e){var r=(e===Uo?this.Uh:this.Wh).get(t),s=[];return this.rd(t=>{s=t.filter(t=>null==r?void 0:r.includes(t.id))}),s.filter(r=>{var s,n=null==(s=r.conditions)||null==(s=s[e])||null==(s=s.values)?void 0:s.find(i=>i.name===t);return this.Yh(n,i)})}register(t){this.nd(t,!1)}replace(t){this.nd(t,!0)}nd(t,i){var e;wi(null==(e=this._instance)?void 0:e._addCaptureHook)||(this.sd(t,i),this.od(t,i))}od(t,i){var e=t.filter(t=>{var i;return null==(i=t.conditions)||null==(i=i.actions)||null==(i=i.values)?void 0:i.length});if(i&&this.Vh.clear(),0!==e.length){this.ad||(this.ad=new Eh(this._instance),this.ad.init(),this.ad.Nh(t=>this.onAction(t)));var r=[];e.forEach(t=>{var i;null==(i=t.conditions)||null==(i=i.actions)||i.values.forEach(i=>{if(r.push(i),i.name){var e,s=null!==(e=this.Vh.get(i.name))&&void 0!==e?e:[];s.includes(t.id)||s.push(t.id),this.Vh.set(i.name,s)}})}),i?this.ad.replace(r):this.ad.register(r)}else{var s;i&&(null==(s=this.ad)||s.replace([]))}}ld(t,i){i.forEach((i,e)=>{var r,s=null!==(r=t.get(e))&&void 0!==r?r:[];i.forEach(t=>{s.includes(t)||s.push(t)}),t.set(e,s)})}sd(t,i){var e,r,s=t.filter(t=>{var i,e;return(null==(i=t.conditions)?void 0:i.events)&&(null==(e=t.conditions)||null==(e=e.events)||null==(e=e.values)?void 0:e.length)>0}),n=t.filter(t=>{var i,e;return(null==(i=t.conditions)?void 0:i.cancelEvents)&&(null==(e=t.conditions)||null==(e=e.cancelEvents)||null==(e=e.values)?void 0:e.length)>0}),o=this.td(t,Uo),a=this.td(t,Ho);i?(this.Uh=o,this.Wh=a):(this.ld(this.Uh,o),this.ld(this.Wh,a)),(0!==s.length||0!==n.length)&&(null!==(e=this.Dh)&&void 0!==e||(this.Dh=null==(r=this._instance)?void 0:r._addCaptureHook((t,i)=>{this.onEvent(t,i)})))}onEvent(t,i){var e,r,s=this.ud(),n=(null==i||null==(e=i.properties)?void 0:e.$survey_id)||(null==i||null==(r=i.properties)?void 0:r.$product_tour_id);if(n&&this.getActivatedIds().includes(n)){var o=this.hd(t,n);if("consume"===o)return s.info("event consumed activated item, removing it",{event:t,itemId:n}),void this.dd([n]);if("persist"===o)return s.info("shown item promoted to persisted activation",{event:t,itemId:n}),this.vd(n),void this.fd([n])}if(this.Wh.has(t)){var a=this.ed(t,i,Ho);a.length>0&&(s.info("cancel event matched, cancelling items",{event:t,itemsToCancel:a.map(t=>t.id)}),this.dd(a.map(t=>t.id)),a.forEach(t=>this.pd(t.id)))}if(this.Uh.has(t)){s.info("event name matched",{event:t,eventPayload:i,items:this.Uh.get(t)});var l=this.ed(t,i,Uo);this.gd(l.map(t=>t.id))}}onAction(t){this.Vh.has(t)&&this.gd(this.Vh.get(t)||[])}gd(t){var i;if(0!==t.length){var e=!(null==(i=this._instance)||null==i.get_session_id||!i.get_session_id()),r=[];for(var s of t)e&&this.Jh(s)?this.vd(s)&&this.md(s):r.push(s);r.length>0&&(this.zh=[...new Set([...this.zh,...r])]),this.ud().info("updating activated items",{activatedItems:this.getActivatedIds()})}}vd(t){this.zh=this.zh.filter(i=>i!==t);var i=this.yd();return!i.includes(t)&&(this.bd([...i,t]),this._d(),!0)}dd(t){var i=new Set(t);this.zh=this.zh.filter(t=>!i.has(t));var e=this.wd(),r=e.filter(t=>!i.has(t));r.length!==e.length&&(this.bd(r),0===r.length&&this.kd()),this.fd(t)}Sd(){var t,i=this.Qh();if(!i)return{};var e=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[i];return e&&"object"==typeof e?e:{}}md(t){if(this.Qh()){var i=this.Sd();this.Kh(r({},i,{[t]:Date.now()}))}}fd(t){if(this.Qh()){var i=this.Sd(),e={},r=!1;for(var s of Object.entries(i)){var n=s[0],o=s[1];t.includes(n)?r=!0:e[n]=o}r&&(yi(e)?this.Xh():this.Kh(e))}}xd(){this.Qh()&&this.Xh()}getActivationTimestamp(t){if(this.yd().includes(t)){var i=this.Sd()[t];return $i(i)?i:void 0}}wd(){var t,i=this.Cd();return(null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[i])||[]}yd(){var t,i,e=this.wd();if(0===e.length)return[];var r=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[this.Td()],s=null==(i=this._instance)||null==i.get_session_id?void 0:i.get_session_id();return s&&r===s?e:[]}_d(){var t,i=null==(t=this._instance)||null==t.get_session_id?void 0:t.get_session_id();i&&this.Md(i)}kd(){this.Id()}Zh(t){var i,e=null==(i=this._instance)||null==(i=i.persistence)?void 0:i.props[this.Td()];if(e&&e!==t){var r=this.wd(),s=this.Sd();r.length>0&&(this.bd([]),r.filter(t=>$i(s[t])).forEach(t=>this.pd(t))),this.kd(),this.xd()}}getActivatedIds(){return[...new Set([...this.yd(),...this.zh])].filter(t=>!this.Ed(t))}dispose(){var t,i,e;null==(t=this.Gh)||t.call(this),this.Gh=void 0,null==(i=this.Dh)||i.call(this),this.Dh=void 0,null==(e=this.ad)||e.dispose(),this.ad=void 0}reset(){this.zh=[],this.wd().length>0&&this.bd([]),this.kd(),this.xd()}getEventToItemsMap(){return this.Uh}Rd(){return this.ad}},Ph=class extends $h{constructor(t){super(t)}Cd(){return rt}Td(){return st}Qh(){return nt}Kh(t){var i;null==(i=this._instance)||null==(i=i.persistence)||i.register({[nt]:t})}Xh(){var t;null==(t=this._instance)||null==(t=t.persistence)||t.unregister(nt)}Jh(t){var i,e;this.rd(i=>{e=i.find(i=>i.id===t)});var r=null==(i=e)||null==(i=i.appearance)?void 0:i.surveyPopupDelaySeconds;return $i(r)&&r>0}Ad(){return qo}rd(t){var i;null==(i=this._instance)||i.getSurveys(t)}pd(t){var i;null==(i=this._instance)||i.cancelPendingSurvey(t)}ud(){return ml}bd(t){var i;null==(i=this._instance)||null==(i=i.persistence)||i.register({[rt]:t})}Md(t){var i;null==(i=this._instance)||null==(i=i.persistence)||i.register({[st]:t})}Id(){var t;null==(t=this._instance)||null==(t=t.persistence)||t.unregister(st)}Ed(){return!1}hd(t,i){var e;return this.rd(t=>{e=t.find(t=>t.id===i)}),!e||function(t){var i;return al(t)&&!(null==(i=t.conditions)||null==(i=i.events)||!i.repeatedActivation)||"always"===t.schedule}(e)?t===qo?"consume":"ignore":t===qo?"persist":t===Vo||t===Wo?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},Th=class{constructor(t){this._instance=t}initialize(){}get(t){if("string"==typeof t)return this._instance.get_property(t);var i={};for(var e of t){var r=this._instance.get_property(e);wi(r)||(i[e]=r)}return i}set(t,i){this._instance.register("string"==typeof t?{[t]:i}:t)}remove(t){"string"!=typeof t?t.forEach(t=>this._instance.unregister(t)):this._instance.unregister(t)}},Ch=class{constructor(t){this._instance=t}get(){var t=this._instance.config;return{disableSurveys:t.disable_surveys,cookielessMode:!!t.cookieless_mode,advancedEnableSurveys:t.advanced_enable_surveys,requestTimeoutMs:t.surveys_request_timeout_ms}}isOptedOut(){return this._instance.consent.isOptedOut()}isCapturing(){return this._instance.is_capturing()}getExtensions(){var t=null==ni?void 0:ni.__PosthogExtensions__;if(t){var i=t.generateSurveys,e=t.loadExternalDependency;return{generateSurveys:i?t=>i(this._instance,t):void 0,loadExternalDependency:e?t=>e(this._instance,"surveys",t):void 0}}}createEventReceiver(){return new Ph(this._instance)}},Fh=null!=Gt&&Gt.location?vo(Gt.location.hash,"__posthog")||vo(location.hash,"state"):null,Ah="_postHogToolbarParams",Ih=bs("[Toolbar]"),Rh=bs("[FeatureFlags]"),Oh=class{constructor(t,i){void 0===i&&(i=!1),this.Pd=!1,this.update(t,i)}update(t,i){this.Fd=((t,i)=>{var e,r,s,n,o;return{bootstrap:{featureFlags:null==(e=t.bootstrap)?void 0:e.featureFlags,featureFlagPayloads:null==(r=t.bootstrap)?void 0:r.featureFlagPayloads},remoteRequestsDisabled:i,featureFlagsDisabled:!!t.advanced_disable_feature_flags,onlyEvaluateSurveyFeatureFlags:!!t.advanced_only_evaluate_survey_feature_flags,deduplicateCallsPerSession:!!t.advanced_feature_flags_dedup_per_session,cacheTtlMs:t.feature_flag_cache_ttl_ms,refreshIntervalMs:null!==(s=t.remote_config_refresh_interval_ms)&&void 0!==s?s:3e5,requestTimeoutMs:t.feature_flag_request_timeout_ms,compression:t.disable_compression?void 0:"best-available",evaluationContexts:null!==(n=null!==(o=t.evaluation_contexts)&&void 0!==o?o:t.evaluation_environments)&&void 0!==n?n:[],flagKeys:_i(t.flag_keys)?t.flag_keys:void 0}})(t,i),!t.evaluation_environments||t.evaluation_contexts||this.Pd||(Rh.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.Pd=!0),wi(t.flag_keys)||_i(t.flag_keys)||Rh.error("Invalid flag_keys found:",t.flag_keys,"Expected array of non-empty strings")}get(){return this.Fd}},Mh=bs("[FeatureFlags]"),Dh=bs("[FeatureFlags]",{debugEnabled:!0}),jh="\" failed. Feature flags didn't load in time.",Bh="connection_error",Lh=t=>{for(var i={},e=0;t.length>e;e++)i[t[e]]=!0;return i},Nh=t=>{var i={};for(var e of Ss(t||{})){var r=e[1];r&&(i[e[0]]=r)}return i},zh=t=>Ri(t)&&("RangeError"===t.name&&0===t.message.indexOf("Maximum call stack size exceeded")||"InternalError"===t.name&&"too much recursion"===t.message),Uh=bs("[Error tracking]"),Hh="webkit-masked-url:",qh=[{value:"isolatedAPI.contexts.topHostname",exact:!1},{value:"No response from target",exact:!0}],Vh=["chrome-extension://","moz-extension://","safari-extension:","safari-web-extension:",Hh],Wh=["__firefox__","__gCrWeb"],Gh="Refusing to render web experiment since the viewer is a likely bot",Kh={icontains:(t,i)=>i.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,i)=>-1===i.toLowerCase().indexOf(t.toLowerCase()),regex:(t,i)=>ll(i,t),not_regex:(t,i)=>!ll(i,t),exact:(t,i)=>i===t,is_not:(t,i)=>i!==t},Jh=bs("[Conversations]"),Xh="Conversations not available yet.";function Yh(t,i){var e,s,n,o,a,l,h,u=null!==(e=null==t?void 0:t.flushIntervalMs)&&void 0!==e?e:3e3,d=null!==(s=null==t?void 0:t.maxBufferSize)&&void 0!==s?s:100,v=null!=i&&i.consoleCapture?void 0:null!==(n=null==t?void 0:t.maxLogsPerInterval)&&void 0!==n?n:1e3,c=wi(v)?Math.max(d,2048):Math.max(d,v),f=r({},function(){var t="",i="";try{var e=null==Jt?void 0:Jt.userAgent;if(e){var s=ze(e);t=s[0],i=s[1]}}catch(t){}return function(t,i){var e=function(t){if(t)return{}.hasOwnProperty.call(ns,t)?ns[t]:t}(t);return r({},e?{"os.name":e}:{},i?{"os.version":i}:{})}(t,i)}(),null==t?void 0:t.resourceAttributes);return{serviceName:null!==(o=null!==(a=null==f?void 0:f["service.name"])&&void 0!==a?a:null==t?void 0:t.serviceName)&&void 0!==o?o:null==i?void 0:i.serviceNameDefault,serviceVersion:null!==(l=null==f?void 0:f["service.version"])&&void 0!==l?l:null==t?void 0:t.serviceVersion,environment:null!==(h=null==f?void 0:f["deployment.environment"])&&void 0!==h?h:null==t?void 0:t.environment,resourceAttributes:f,beforeSend:null==t?void 0:t.beforeSend,flushIntervalMs:u,maxBufferSize:d,maxQueueSize:c,maxBatchRecordsPerPost:100,rateCapWindowMs:u,maxLogsPerInterval:v,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}}var Zh=["debug","log","warn","error","info"],Qh="console",tu="__posthogHandledLogsRequestError",iu=(t,i)=>{var e=t instanceof Error?t:new Error(i);return e[tu]=!0,e},eu=t=>!!t&&"object"==typeof t&&!0===t[tu],ru={featureFlags:class{constructor(t){this.name="featureFlags",this.Od=!1,this.featureFlagEventHandlers=[],this.A=Mh,this.$d={},this.Dd={},this.Ld=[],this.Nd=!1,this.qd=!1,this.jd=0,this.Bd=!1,this.Hd=!1,this.zd=!1,this.Ud=!1,this.Wd=0,this.nr=()=>{var t=this.Vd();this.Wd=0,t&&this.reloadFeatureFlags()},this.Gd=()=>{var t,i=this.Zd;wi(i)||this.xn.remoteRequestsDisabled||!Xt||"hidden"===Xt.visibilityState||Date.now()-(null!==(t=this.Jd)&&void 0!==t?t:0)<i||(this.reloadFeatureFlags(),this.Qd())},this.ar=()=>{"visible"===(null==Xt?void 0:Xt.visibilityState)&&this.Gd()},"get"in t?this.uo=t:(this._instance=t,this.Kd=new Oh(t.config,t.Ua()),this.uo=this.Kd)}updateConfig(t,i){var e;null==(e=this.Kd)||e.update(t,i),this.ao&&this.Xd()}setup(t){return this.gh=t,this.A=t.logger.createLogger("[FeatureFlags]"),yh(t.kv.initialize(),()=>{this.gh===t&&(this.gh=void 0,this.ao=t,this.Yd(t))})}Yd(t){var i;if(this.ao===t)return Gt&&Fs(Gt,"online",this.nr),this.Xd(),this.tv=t.registerDynamicEventProperties(()=>this.ev()?this.$d:this.Dd),this.iv=null==(i=this._instance)||null==(i=i.persistence)?void 0:i.onCrossTabFeatureFlagChange(()=>{this.rv(),this.nv(),this.sv()}),this.nv(),this.initialize()}Xd(){var t=this.xn.refreshIntervalMs,i=!this.xn.remoteRequestsDisabled&&Xt&&!wi(t)&&t>0?t:void 0;i!==this.Zd&&(this.ov(),wi(i)||(this.Zd=i,this.Qd(),null!=Xt&&Xt.addEventListener&&Fs(Xt,zt,this.ar)))}Qd(){wi(this.Zd)||(wi(this.av)||clearInterval(this.av),this.Jd=Date.now(),this.av=setInterval(this.Gd,this.Zd))}ov(){wi(this.av)||(clearInterval(this.av),this.av=void 0,null==Xt||null==Xt.removeEventListener||Xt.removeEventListener(zt,this.ar)),this.Zd=void 0,this.Jd=void 0}destroy(){this.lv()}dispose(){this.lv()}lv(){var t,i;this.ov(),this.jd++,this.Hd=!1,this.gh=void 0,this.ao&&(this.uv(),null==(t=this.tv)||t.dispose(),this.tv=void 0,null==(i=this.iv)||i.call(this),this.iv=void 0,this.Ld=[],null==Gt||Gt.removeEventListener("online",this.nr),this.ao=void 0)}get xn(){return this.uo.get()}hv(t){var i;return this.dv&&t in this.dv?this.dv[t]:null==(i=this.ao)?void 0:i.kv.get(t)}rv(){return!!this.dv&&(this.dv=void 0,!0)}vv(){var t;return!wi(null==(t=this.ao)?void 0:t.kv.get("$enabled_feature_flags"))&&this.rv()}Ot(t){this.fv(()=>{var i;return null==(i=this.ao)?void 0:i.kv.set(t)})}pv(t,i,e){var r;if(null!=(r=this._instance)&&r.persistence&&t.$enabled_feature_flags){var s=this.hv("$enabled_feature_flags")||{},n=t.$enabled_feature_flags||{},o=i.flags||i.featureFlags,a=i.flags?Object.entries(i.flags).filter(t=>{var i=t[1];return!(null!=i&&i.failed)}).map(t=>t[0]):[],l=!!i.errorsWhileComputingFlags&&!!i.flags,h=l?a:e&&!_i(o)?Object.keys(o||{}):Array.from(new Set([...Object.keys(s),...Object.keys(n)])),u=this.hv("$feature_flag_payloads")||{},d=t.$feature_flag_payloads||{},v=l||e?h:Array.from(new Set([...Object.keys(u),...Object.keys(d)])),c=!l&&!e,f=!!c||h,p=!!c||v,g={[q]:f,[H]:f,[G]:p};for(var _ of(t.$feature_flag_details&&(g[W]=f),[K,gt,J]))wi(t[_])||(g[_]=!0);this._instance.persistence.markCrossTabFeatureFlagChanges(g)}}Dt(t){this.fv(()=>{var i;return null==(i=this.ao)?void 0:i.kv.remove(t)})}fv(t){try{t()}catch(t){this.A.error("Failed to update feature flag persistence",t)}}nv(){var t={};for(var i of[q,G,K,X]){var e=this.hv(i);wi(e)||(t[i]=e)}this.$d=t;var s=r({},t),n=this.hv(H);if(n)for(var o of Object.entries(n))s["$feature/"+o[0]]=o[1];this.Dd=s}ev(){var t=this.xn.cacheTtlMs;if(!t||0>=t)return!1;var i=this.hv(gt);return"number"!=typeof i||Date.now()-i>t}gv(){return!!this.ev()&&(this.Ud||this.qd||(this.Ud=!0,this.A.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}mv(){var t=this.xn.evaluationContexts;return null!=t&&t.length?t.filter(t=>{var i=t&&"string"==typeof t&&t.trim().length>0;return i||this.A.error("Invalid evaluation context found:",t,"Expected non-empty string"),i}):[]}yv(){var t=this.xn.flagKeys;if(!wi(t))return t.filter(t=>{var i=t&&"string"==typeof t&&t.trim().length>0;return i||this.A.error("Invalid flag key found:",t,"Expected non-empty string"),i})}initialize(){var t,i,e=this.xn,r=null!==(t=null==(i=e.bootstrap)?void 0:i.featureFlags)&&void 0!==t?t:{};if(Object.keys(r).length){var s,n,o=null!==(s=null==(n=e.bootstrap)?void 0:n.featureFlagPayloads)&&void 0!==s?s:{},a=Object.keys(r).filter(t=>!wi(r[t])).reduce((t,i)=>(t[i]=r[i],t),{}),l=Object.keys(o).filter(t=>a[t]).reduce((t,i)=>(t[i]=o[i],t),{});return this.bv({featureFlags:a,featureFlagPayloads:l},void 0,{persist:!1})}}updateFlags(t,i,e){var s,n,o=null!=e&&e.merge&&null!==(s=this.hv("$enabled_feature_flags"))&&void 0!==s?s:{},a=null!=e&&e.merge&&null!==(n=this.hv("$feature_flag_payloads"))&&void 0!==n?n:{},l=r({},o,t),h=r({},a,i),u={};for(var d of Object.entries(l)){var v=d[0],c=d[1];u[v]={key:v,enabled:Ur(c),variant:Hr(c),reason:void 0,metadata:wi(null==h?void 0:h[v])?void 0:{id:0,version:void 0,description:void 0,payload:h[v]}}}this.bv({flags:u})}get hasLoadedFlags(){return this.Nd}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var t=this.hv(W),i=this.hv(X),e=this.hv(Y);if(!e&&!i)return t||{};var s=xs({},t||{});for(var n of[...new Set([...Object.keys(e||{}),...Object.keys(i||{})])]){var o,a,l=s[n],h=null==i?void 0:i[n],u=wi(h)?null!==(o=null==l?void 0:l.enabled)&&void 0!==o&&o:!!h,d=wi(h)?null==l?void 0:l.variant:"string"==typeof h?h:void 0,v=null==e?void 0:e[n],c=r({},l,{enabled:u,variant:u?null!=d?d:null==l?void 0:l.variant:void 0});u!==(null==l?void 0:l.enabled)&&(c.original_enabled=null==l?void 0:l.enabled),d!==(null==l?void 0:l.variant)&&(c.original_variant=null==l?void 0:l.variant),v&&(c.metadata=r({},null==l?void 0:l.metadata,{payload:v,original_payload:null==l||null==(a=l.metadata)?void 0:a.payload})),s[n]=c}return this.Od||(this.A.warn(" Overriding feature flag details!",{flagDetails:t,overriddenPayloads:e,finalDetails:s}),this.Od=!0),s}getAllFeatureFlags(){var t=this.getFlagVariants(),i=this.getFlagPayloads();return Object.keys(t).map(e=>{var r=t[e];return{key:e,enabled:Ur(r),variant:Hr(r),payload:zr(i[e])}})}getFlagVariants(){var t=this.hv(H),i=this.hv(X);if(!i)return t||{};for(var e=xs({},t||{}),r=Object.keys(i),s=0;r.length>s;s++)e[r[s]]=i[r[s]];return this.Od||(this.A.warn(" Overriding feature flags!",{enabledFlags:t,overriddenFlags:i,finalFlags:e}),this.Od=!0),e}getFlagPayloads(){var t=this.hv(G),i=this.hv(Y);if(!i)return t||{};for(var e=xs({},t||{}),r=Object.keys(i),s=0;r.length>s;s++)e[r[s]]=i[r[s]];return this.Od||(this.A.warn(" Overriding feature flag payloads!",{flagPayloads:t,overriddenPayloads:i,finalPayloads:e}),this.Od=!0),e}reloadFeatureFlags(){this.Bd||this.xn.featureFlagsDisabled||this.Vd()||(this.qd&&(this.Hd=!0),this._v||(this.Ld.slice().forEach(t=>{try{t()}catch(t){this.A.error("Error while running feature flags reloading callback",t)}}),this._v=setTimeout(()=>{this.wv()},5)))}uv(){clearTimeout(this._v),this._v=void 0}onReloading(t){return this.Ld.push(t),()=>{this.Ld=this.Ld.filter(i=>i!==t)}}ensureFlagsLoaded(){this.Nd||this.qd||this._v||this.reloadFeatureFlags()}setAnonymousDistinctId(t){this.$anon_distinct_id=t}setReloadingPaused(t){this.Bd=t}resetFlagCallReported(){this.Dt(ct)}wv(t){this.uv();var i=this.ao;if(i&&!this.xn.remoteRequestsDisabled&&!this.Vd())if(this.qd)this.Hd=!0;else{var e={token:i.projectToken,distinct_id:i.distinctId,groups:i.groups,$anon_distinct_id:this.$anon_distinct_id,person_properties:r({},i.initialPersonProperties,this.hv("$stored_person_properties")||{},{$lib:i.library.name,$lib_version:i.library.version}),group_properties:this.hv(Q),timezone:Po()};wi(i.deviceId)||(e.$device_id=i.deviceId),(null!=t&&t.disableFlags||this.xn.featureFlagsDisabled)&&(e.disable_flags=!0);var s=this.mv();s.length&&(e.evaluation_contexts=s);var n=this.yv();wi(n)||(e.flag_keys=n);var o=this.xn.onlyEvaluateSurveyFeatureFlags,a="/flags/?v=2"+(o?"&only_evaluate_survey_feature_flags=true":""),l=this.jd;this.qd=!0;var h=()=>{this.Hd&&(this.Hd=!1,this.wv())},u=t=>{this.qd=!1,l===this.jd?(this.Ot({[pt]:[Bh]}),this.A.error("Feature flag request failed",t),this.vv()&&this.sv(!0),h()):h()};try{i.sendRequest(a,{target:"flags",method:"POST",body:e,compression:this.xn.compression,sentAt:"body",timeoutMs:this.xn.requestTimeoutMs}).then(t=>{var i,r,s=null!==(i=t.json)&&void 0!==i?i:{},n=200!==t.statusCode;if(this.qd=!1,l===this.jd){if(this.Sv(t.statusCode),n||this.Hd||(this.$anon_distinct_id=void 0),!e.disable_flags||this.Hd){this.zd=!n;var a=[];t.error?a.push(t.error instanceof Error&&"AbortError"===t.error.name?"timeout":t.error instanceof Error?Bh:"unknown_error"):200!==t.statusCode&&a.push("api_error_"+t.statusCode),s.errorsWhileComputingFlags&&a.push("errors_while_computing_flags");var u=!(null==(r=s.quotaLimited)||!r.includes("feature_flags"));u&&a.push("quota_limited"),this.Ot({[pt]:a}),u?this.A.warn("You have hit your feature flags quota limit, and will not be able to load feature flags until the quota is reset. Please visit https://posthog.com/docs/billing/limits-alerts to learn more."):e.disable_flags||this.bv(s,n,{partialResponse:o}),h()}}else h()}).catch(u)}catch(t){u(t)}}}Vd(){return co(this.Wd,3)}Sv(t){this.Wd=fo(t,this.Wd,3,()=>this.A.warn("Feature flag requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped refreshing feature flags; will try again when connectivity changes."))}getFeatureFlag(t,i){var e;if(void 0===i&&(i={}),!i.fresh||this.zd)if(this.Nd||this.getFlags()&&this.getFlags().length>0){if(!this.gv()){var r=this.getFeatureFlagResult(t,i);return null!==(e=null==r?void 0:r.variant)&&void 0!==e?e:null==r?void 0:r.enabled}}else this.A.warn('getFeatureFlag for key "'+t+jh)}getFeatureFlagDetails(t){return this.getFlagsWithDetails()[t]}getFeatureFlagPayload(t){var i;return null==(i=this.getFeatureFlagResult(t,{send_event:!1}))?void 0:i.payload}getFeatureFlagResult(t,i){if(void 0===i&&(i={}),!i.fresh||this.zd)if(this.Nd||this.getFlags()&&this.getFlags().length>0){if(!this.gv()){var e,s=this.getFlagVariants(),n=t in s,o=s[t],a=this.getFlagPayloads()[t],l=String(o),h=this.hv("$feature_flag_request_id")||void 0,u=this.hv("$feature_flag_evaluated_at")||void 0,d=this.hv("$flag_call_reported")||{};if(this.xn.deduplicateCallsPerSession){var v,c=null==(v=this.ao)?void 0:v.session.sessionId,f=this.hv(ft);c&&c!==f&&(d={},e=c)}if(i.send_event||!("send_event"in i))if(t in d&&d[t].includes(l))e&&this.Ot({[ct]:d,[ft]:e});else{var p,g,_,m,b,y,w,x,S,k,E,P,T;_i(d[t])?d[t].push(l):d[t]=[l],this.Ot(r({[ct]:d},e?{[ft]:e}:{}));var C=this.getFeatureFlagDetails(t),F=[...null!==(p=this.hv("$feature_flag_errors"))&&void 0!==p?p:[]];wi(o)&&F.push("flag_missing");var A={$feature_flag:t,$feature_flag_response:o,$feature_flag_payload:null!=a?a:null,$feature_flag_request_id:h,$feature_flag_evaluated_at:u,$feature_flag_bootstrapped_response:null!==(g=null==(_=this.xn.bootstrap)||null==(_=_.featureFlags)?void 0:_[t])&&void 0!==g?g:null,$feature_flag_bootstrapped_payload:null!==(m=null==(b=this.xn.bootstrap)||null==(b=b.featureFlagPayloads)?void 0:b[t])&&void 0!==m?m:null,$used_bootstrap_value:!this.zd};wi(null==C||null==(y=C.metadata)?void 0:y.has_experiment)||(A.$feature_flag_has_experiment=C.metadata.has_experiment),wi(null==C||null==(w=C.metadata)?void 0:w.version)||(A.$feature_flag_version=C.metadata.version);var I=null!==(x=null==C||null==(S=C.reason)?void 0:S.description)&&void 0!==x?x:null==C||null==(k=C.reason)?void 0:k.code;I&&(A.$feature_flag_reason=I),null!=C&&null!=(E=C.metadata)&&E.id&&(A.$feature_flag_id=C.metadata.id),wi(null==C?void 0:C.original_variant)&&wi(null==C?void 0:C.original_enabled)||(A.$feature_flag_original_response=wi(C.original_variant)?C.original_enabled:C.original_variant),null!=C&&null!=(P=C.metadata)&&P.original_payload&&(A.$feature_flag_original_payload=null==C||null==(T=C.metadata)?void 0:T.original_payload),F.length&&(A.$feature_flag_error=F.join(",")),this.xv(A)}else e&&this.Ot({[ct]:d,[ft]:e});if(n)return{key:t,enabled:!!o,variant:"string"==typeof o?o:void 0,payload:zr(a)}}}else this.A.warn('getFeatureFlagResult for key "'+t+jh)}xv(t){try{var i;null==(i=this.ao)||i.capture("$feature_flag_called",t).catch(t=>{this.A.error("Failed to capture feature flag call",t)})}catch(t){this.A.error("Failed to capture feature flag call",t)}}getRemoteConfigPayload(t,i){this.Cv(t,i)}Cv(t,i){var e=this;return n(function*(){var r=e.ao;if(r){var s={distinct_id:r.distinctId,token:r.projectToken,person_properties:{$lib:r.library.name,$lib_version:r.library.version}},n=e.mv();n.length&&(s.evaluation_contexts=n);var o,a=e.yv();wi(a)||(s.flag_keys=a);try{var l;o=(null==(l=(yield r.sendRequest("/flags/?v=2",{target:"flags",method:"POST",body:s,compression:e.xn.compression,sentAt:"body",timeoutMs:e.xn.requestTimeoutMs})).json)||null==(l=l.featureFlagPayloads)?void 0:l[t])||void 0}catch(t){return void e.A.error("Remote config feature flag request failed",t)}try{i(o)}catch(t){e.A.error("Remote config feature flag callback failed",t)}}})()}isFeatureEnabled(t,i){if(void 0===i&&(i={}),i.fresh&&!this.zd)return i.defaultValue;if(!(this.Nd||this.getFlags()&&this.getFlags().length>0))return this.A.warn('isFeatureEnabled for key "'+t+jh),i.defaultValue;var e=this.getFeatureFlag(t,i);return wi(e)?i.defaultValue:!!e}addFeatureFlagsHandler(t){this.featureFlagEventHandlers.push(t)}removeFeatureFlagsHandler(t){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter(i=>i!==t)}receivedFeatureFlags(t,i,e){this.bv(t,i,e)}bv(t,i,e){if(this.ao){this.Nd=!0;var s=function(t,i,e,s,n,o){void 0===i&&(i={}),void 0===e&&(e={}),void 0===s&&(s={}),void 0===o&&(o=Mh);var a=((t,i)=>{var e=t.flags;return e?r({},t,{featureFlags:Object.fromEntries(Object.keys(e).map(t=>{var i;return[t,null!==(i=e[t].variant)&&void 0!==i?i:e[t].enabled]})),featureFlagPayloads:Object.fromEntries(Object.keys(e).filter(t=>e[t].enabled).filter(t=>{var i;return!wi(null==(i=e[t].metadata)?void 0:i.payload)}).map(t=>{var i;return[t,null==(i=e[t].metadata)?void 0:i.payload]}))}):(t.featureFlags&&i.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),t)})(t,o),l=a.flags,h=a.featureFlags,u=a.featureFlagPayloads;if(h){var d=t.requestId,v=t.evaluatedAt;if(_i(h)){o.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var c={};if(h)for(var f=0;h.length>f;f++)c[h[f]]=!0;return{[q]:h,[H]:c,[J]:!1}}var p=h,g=u,_=l;if(null!=n&&n.partialResponse){var m=Object.keys(p),b=g||{};p=r({},i,p),g=r({},e,b),m.forEach(t=>{var i;t in b||null==(i=g)||delete i[t]}),_=r({},s,_)}else if(t.errorsWhileComputingFlags)if(l){var y=new Set(Object.keys(l).filter(t=>{var i;return!(null!=(i=l[t])&&i.failed)}));p=r({},i,Object.fromEntries(Object.entries(p).filter(t=>y.has(t[0]))));var w=Object.fromEntries(Object.entries(g||{}).filter(t=>y.has(t[0])));g=r({},e,w),y.forEach(t=>{var i;t in w||null==(i=g)||delete i[t]}),_=r({},s,Object.fromEntries(Object.entries(_||{}).filter(t=>y.has(t[0]))))}else p=r({},i,p),g=r({},e,g),_=r({},s,_);return r({[q]:Object.keys(Nh(p)),[H]:p||{},[G]:g||{},[W]:_||{},[J]:!0===t.minimalFlagCalledEvents},d?{[K]:d}:{},v?{[gt]:v}:{})}}(t,this.getFlagVariants(),this.getFlagPayloads(),this.getFlagsWithDetails(),e,this.A);if(s)if(!1===(null==e?void 0:e.persist)){var n=!wi(this.ao.kv.get(H));this.dv=s,n||this.Ot(s)}else this.rv(),this.pv(s,t,!(null==e||!e.partialResponse)),this.Ot(s);else i&&this.vv();i||(this.Ud=!1),this.sv(i)}}override(t,i){void 0===i&&(i=!1),this.A.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:t,suppressWarning:i})}overrideFeatureFlags(t){this.Tv(t)}Tv(t){if(this.ao){if(!1===t)return this.Dt([X,Y]),this.sv(),void Dh.info("All overrides cleared");if(_i(t))return this.Ot({[X]:Lh(t)}),this.sv(),void Dh.info("Flag overrides set",{flags:t});if(t&&"object"==typeof t&&("flags"in t||"payloads"in t)){var i,e=t;this.Od=Boolean(null!==(i=e.suppressWarning)&&void 0!==i&&i);var r={},s=e.flags,n=e.payloads;return s&&(r[X]=_i(s)?Lh(s):s),n&&(r[Y]=n),Object.keys(r).length&&this.Ot(r),!1===s&&!1===n?this.Dt([X,Y]):!1===s?this.Dt(X):!1===n&&this.Dt(Y),this.sv(),!1===s?Dh.info("Flag overrides cleared"):s&&Dh.info("Flag overrides set",{flags:s}),void(!1===n?Dh.info("Payload overrides cleared"):n&&Dh.info("Payload overrides set",{payloads:n}))}if(t&&"object"==typeof t)return this.Ot({[X]:t}),this.sv(),void Dh.info("Flag overrides set",{flags:t});this.A.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:t})}else this.A.warn("posthog.featureFlags.overrideFeatureFlags called before feature flags were ready")}onFeatureFlags(t){if(this.addFeatureFlagsHandler(t),this.Nd){var i=this.Mv(),e=i.flags,r=i.flagVariants;try{t(e,r)}catch(t){this.A.error("Error while running feature flags callback",t)}}return()=>this.removeFeatureFlagsHandler(t)}updateEarlyAccessFeatureEnrollment(t,i,e){var s,n=(this.hv("$early_access_features")||[]).find(i=>i.flagKey===t),o={["$feature_enrollment/"+t]:i},a={$feature_flag:t,$feature_enrollment:i,$set:o};n&&(a.$early_access_feature_name=n.name),e&&(a.$feature_enrollment_stage=e);var l=r({},this.getFlagVariants(),{[t]:i});null==(s=this._instance)||null==(s=s.persistence)||s.markCrossTabFeatureFlagChanges({[q]:[t],[H]:[t],[Z]:Object.keys(o)}),this.Ot({[q]:Object.keys(Nh(l)),[H]:l,[Z]:r({},this.hv("$stored_person_properties")||{},o)}),this.sv();try{var h;null==(h=this.ao)||h.capture("$feature_enrollment_update",a).catch(t=>{this.A.error("Failed to capture early access feature enrollment",t)})}catch(t){this.A.error("Failed to capture early access feature enrollment",t)}}getEarlyAccessFeatures(t,i,e){void 0===i&&(i=!1);var r=this.hv(V);!r||i?this.Iv(t,e):t(r)}Iv(t,i){var e=this;return n(function*(){var r=e.ao;if(r){var s,n=i?"&"+i.map(t=>"stage="+t).join("&"):"";try{var o=yield r.sendRequest("/api/early_access_features/?token="+r.projectToken+n,{target:"api",method:"GET",sentAt:"query"});if(!o.json)return;s=o.json.earlyAccessFeatures,e.Ot({[V]:s})}catch(t){return void e.A.error("Early access feature request failed",t)}try{t(s)}catch(t){e.A.error("Early access feature callback failed",t)}}})()}Mv(){var t=this.getFlags(),i=this.getFlagVariants();return{flags:t.filter(t=>i[t]),flagVariants:Object.keys(i).filter(t=>i[t]).reduce((t,e)=>(t[e]=i[e],t),{})}}sv(t){this.nv();var i=this.Mv(),e=i.flags,r=i.flagVariants;this.featureFlagEventHandlers.forEach(i=>{try{i(e,r,{errorsLoading:t})}catch(t){this.A.error("Error while running feature flags callback",t)}})}setPersonPropertiesForFlags(t,i){void 0===i&&(i=!0),this.Ev(t,i)}Ev(t,i){void 0===i&&(i=!0);var e=this.hv("$stored_person_properties")||{},s=(null==t?void 0:t.$set)||(null!=t&&t.$set_once?{}:t),n=null==t?void 0:t.$set_once,o={};if(n)for(var a in n)({}).hasOwnProperty.call(n,a)&&(a in e||(o[a]=n[a]));this.Ot({[Z]:r({},e,o,s)}),i&&this.reloadFeatureFlags()}unsetPersonPropertiesForFlags(t,i){void 0===i&&(i=!0);var e=r({},this.hv("$stored_person_properties")||{});t.forEach(t=>{delete e[t]}),this.Ot({[Z]:e}),i&&this.reloadFeatureFlags()}resetPersonPropertiesForFlags(t){void 0===t&&(t=!0),this.Dt(Z),t&&this.reloadFeatureFlags()}setGroupPropertiesForFlags(t,i){void 0===i&&(i=!0);var e=this.hv("$stored_group_properties")||{},s=r({},e);for(var n of Object.keys(t))s[n]=r({},e[n],t[n]);this.Ot({[Q]:s}),i&&this.reloadFeatureFlags()}resetGroupPropertiesForFlags(t){if(t){var i=this.hv("$stored_group_properties")||{};this.Ot({[Q]:r({},i,{[t]:{}})})}else this.Dt(Q)}reset(){this.jd++,this.Hd=!1,this.$d={},this.Dd={},this.dv=void 0,this.Nd=!1,this.Bd=!1,this.zd=!1,this.$anon_distinct_id=void 0,this.uv(),this.Od=!1,this.Wd=0}}},su={sessionRecording:class{get xn(){return this._instance.config}get gl(){return this._instance.persistence}get started(){var t;return!(null==(t=this.Rv)||!t.isStarted)}get status(){var t,i;return"awaiting_config"===this.Av||"missing_config"===this.Av?this.Av:null!==(t=null==(i=this.Rv)?void 0:i.status)&&void 0!==t?t:this.Av}constructor(t){if(this._instance=t,this._forceAllowLocalhostNetworkCapture=!1,this.Av=dh,this.Pv=void 0,this.Fv=!1,this.Ke=(()=>{var t;if(null==Xt||!Xt.visibilityState||"visible"===Xt.visibilityState)return!0;var i=null==Gt||null==(t=Gt.performance)||null==t.getEntriesByType?void 0:t.getEntriesByType("visibility-state");return!(null!=i&&i.length)||i.some(t=>"visible"===t.name)})(),this.ar=()=>{var t;"visible"===(null==Xt?void 0:Xt.visibilityState)&&(this.Ke=!0,null==(t=this.Rv)||null==t.setDocumentWasEverVisible||t.setDocumentWasEverVisible(!0))},!this._instance.sessionManager)throw ch.error("started without valid sessionManager"),new Error("[SessionRecording] started without valid sessionManager. This is a bug.");if("always"===this.xn.cookieless_mode)throw new Error('[SessionRecording] cannot be used with cookieless_mode="always"');null!=Xt&&Xt.addEventListener&&Fs(Xt,"visibilitychange",this.ar)}initialize(){this.startIfEnabledOrStop()}dispose(t){var i=(void 0===t?{}:t).discardBufferedEvents,e=void 0!==i&&i;this.Fv=!0,null==Xt||null==Xt.removeEventListener||Xt.removeEventListener("visibilitychange",this.ar),e?this.Ov(!0):this.stopRecording()}get $v(){var t,i=!(null==(t=this._instance.get_property(C))||!t.enabled),e=!this.xn.disable_session_recording,r=this.xn.disable_session_recording||this._instance.consent.isOptedOut();return Gt&&i&&e&&!r}startIfEnabledOrStop(t){var i;if(!(this.Fv||this.$v&&null!=(i=this.Rv)&&i.isStarted)){var e=!wi(Object.assign)&&!wi(Array.from);this.$v&&e?(this.Dv(t),ch.info("starting")):(this.Av=dh,this.stopRecording())}}Dv(t){var i,e;if(this.$v)if("awaiting_config"!==this.Av&&"missing_config"!==this.Av&&(this.Av=vh),null!=ni&&null!=(i=ni.__PosthogExtensions__)&&null!=(i=i.rrweb)&&i.record&&null!=(e=ni.__PosthogExtensions__)&&e.initSessionRecording)this.Lv(t);else{var r,s=this._instance.sessionManager;null==(r=ni.__PosthogExtensions__)||null==r.loadExternalDependency||r.loadExternalDependency(this._instance,this.Nv,i=>{if(!this.Fv&&this.$v&&this._instance.sessionManager===s)return i?(this._instance.register_for_session({[Tt]:!0}),ch.error("could not load recorder",i)):void this.Lv(t);this.Av=dh})}}stopRecording(){var t,i;null==(t=this.Pv)||t.call(this),this.Pv=void 0,null==(i=this.Rv)||i.stop()}Ov(t){var i,e;void 0===t&&(t=!1),null==(i=this.Pv)||i.call(this),this.Pv=void 0,null==(e=this.Rv)||e.discard({discardProducerEvents:t})}qv(){var t,i;null==(t=this.gl)||t.unregister(j),null==(i=this.gl)||i.unregister(A)}jv(t,i){if(Ei(t))return null;var e,r=$i(t)?t:parseFloat(t);return"number"!=typeof(e=r)||!Number.isFinite(e)||0>e||e>1?(ch.warn(i+" must be between 0 and 1. Ignoring invalid value:",t),null):r}Bv(t){if(this.gl){var i,e,s=this.gl,n=()=>{var i,e=!1===t.sessionRecording?void 0:t.sessionRecording,n=this.jv(null==(i=this.xn.session_recording)?void 0:i.sampleRate,"session_recording.sampleRate"),o=this.jv(null==e?void 0:e.sampleRate,"remote config sampleRate"),a=null!=n?n:o;Ei(a)&&this.qv();var l=null==e?void 0:e.minimumDurationMilliseconds;s.register({[C]:r({cache_timestamp:Date.now(),enabled:!!e},e,{networkPayloadCapture:r({capturePerformance:t.capturePerformance},null==e?void 0:e.networkPayloadCapture),canvasRecording:{enabled:null==e?void 0:e.recordCanvas,fps:null==e?void 0:e.canvasFps,quality:null==e?void 0:e.canvasQuality},sampleRate:a,minimumDurationMilliseconds:wi(l)?null:l,endpoint:null==e?void 0:e.endpoint,triggerMatchType:null==e?void 0:e.triggerMatchType,masking:null==e?void 0:e.masking,urlTriggers:null==e?void 0:e.urlTriggers,version:null==e?void 0:e.version,triggerGroups:null==e?void 0:e.triggerGroups})})};n(),null==(i=this.Pv)||i.call(this),this.Pv=null==(e=this._instance.sessionManager)?void 0:e.onSessionId(n)}}onRemoteConfig(t){var i=t.ok?t.config:void 0;return i&&"sessionRecording"in i?!1===i.sessionRecording?(this.Bv(i),void this.Ov()):(this.Bv(i),void this.startIfEnabledOrStop()):("awaiting_config"===this.Av&&(this.Av="missing_config",ch.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(t,i){var e;void 0===i&&(i="log"),null!=(e=this.Rv)&&e.log?this.Rv.log(t,i):ch.warn("log called before recorder was ready")}get Nv(){var t;return(null==(t=this._instance)||null==(t=t.persistence)||null==(t=t.get_property("$session_recording_remote_config"))||null==(t=t.scriptConfig)?void 0:t.script)||"lazy-recorder"}Hv(){var t,i=this._instance.get_property(C);if(!i)return!1;try{t="object"==typeof i?i:JSON.parse(i)}catch(t){return ch.warn("persisted remote config for session recording is invalid and will be ignored",t),!1}return!Ei(t.cache_timestamp)&&36e5>=Date.now()-t.cache_timestamp}Lv(t){var i,e,r;if(!this.Fv&&this.$v&&this._instance.sessionManager){if(null==(i=ni.__PosthogExtensions__)||!i.initSessionRecording)return ch.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[Tt]:!0});var s;if(this.Rv||(this.Rv=null==(s=ni.__PosthogExtensions__)?void 0:s.initSessionRecording(this._instance,this.Ke),this.Rv._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.Hv()){if("missing_config"===this.Av||"awaiting_config"===this.Av)return;return this.Av="awaiting_config",ch.info("persisted remote config is stale, requesting fresh config before starting"),void new Qo(this._instance).load()}this.Av=vh,null==(e=(r=this.Rv).setDocumentWasEverVisible)||e.call(r,this.Ke),this.Rv.start(t)}else this.Av=dh}onRRwebEmit(t){var i;null==(i=this.Rv)||null==i.onRRwebEmit||i.onRRwebEmit(t)}overrideLinkedFlag(){var t,i;this.Rv||null==(t=this.gl)||t.register({[R]:!0}),null==(i=this.Rv)||i.overrideLinkedFlag()}overrideSampling(){var t,i;this.Rv||null==(t=this.gl)||t.register({[I]:!0}),null==(i=this.Rv)||i.overrideSampling()}overrideTrigger(t){var i,e;this.Rv||null==(i=this.gl)||i.register({["url"===t?O:M]:!0}),null==(e=this.Rv)||e.overrideTrigger(t)}get sdkDebugProperties(){var t;return(null==(t=this.Rv)?void 0:t.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(t,i){var e;return!(null==(e=this.Rv)||!e.tryAddCustomEvent(t,i))}flushBeforeIdentityReset(){var t;null==(t=this.Rv)||null==t.flushBeforeIdentityReset||t.flushBeforeIdentityReset()}}},nu={autocapture:class extends Ql{constructor(t){super(new th(t)),this.instance=t}},historyAutocapture:class{constructor(t){this._instance=t,this.zv=this.Uv()}initialize(){this.startIfEnabled()}get isEnabled(){var t=this.Wv();return!!(t.path||t.search||this.Vv(t))}startIfEnabled(){this.isEnabled&&(ms.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}startIfEnabledOrStop(){this.stop(),this.zv=this.Uv(),this.startIfEnabled()}stop(){this.Gv&&this.Gv(),this.Gv=void 0,this.Zv&&this.Zv(),this.Zv=void 0,ms.info("History API monitoring stopped")}monitorHistoryChanges(){Gt&&Gt.history&&(this.Jv("pushState"),this.Jv("replaceState"),this.Qv(),this.Vv()&&this.Kv())}Jv(t){var i;if(Gt&&(null==(i=Gt.history[t])||!i.__posthog_wrapped__)){var e=this;sh(Gt.history,t,i=>function(r,s,n){i.call(this,r,s,n),e.Xv(t)})}}Uv(){var t=null==Gt?void 0:Gt.location;if(null!=t&&t.pathname)return{pathname:t.pathname,search:t.search,hash:t.hash}}Wv(){var t=this._instance.config.capture_pageview;return"history_change"===t?{path:!0}:bi(t)?t:{}}Vv(t){return void 0===t&&(t=this.Wv()),!!t.hash&&!this._instance.config.disable_capture_url_hashes}Yv(t){var i=this.Wv(),e=this.zv;return!(!e||!(i.path&&t.pathname!==e.pathname||i.search&&t.search!==e.search||this.Vv(i)&&t.hash!==e.hash))}Xv(t){try{var i=this.Uv();if(!i)return;this.Yv(i)&&this._instance.capture(Ht,{navigation_type:t}),this.zv=i}catch(i){ms.error("Error capturing "+t+" pageview",i)}}Qv(){if(!this.Gv){var t=()=>{this.Xv("popstate")};Fs(Gt,"popstate",t),this.Gv=()=>{Gt&&Gt.removeEventListener("popstate",t)}}}Kv(){if(!this.Zv){var t=()=>{this.Xv("hashchange")};Fs(Gt,"hashchange",t),this.Zv=()=>{Gt&&Gt.removeEventListener("hashchange",t)}}}},heatmaps:class{get xn(){return this.instance.config}constructor(t){var i;this.tc=!1,this.ho=!1,this.ec=null,this.instance=t,this.tc=!(null==(i=this.instance.persistence)||!i.props[b]),this.rageclicks=new Gl(t.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var t=5e3;return bi(this.xn.capture_heatmaps)&&this.xn.capture_heatmaps.flush_interval_milliseconds&&(t=this.xn.capture_heatmaps.flush_interval_milliseconds),t}get isEnabled(){return Ei(this.xn.capture_heatmaps)?Ei(this.xn.enable_heatmaps)?this.tc:this.xn.enable_heatmaps:!1!==this.xn.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this.ho)return;fh.info("starting..."),this.rc(),this.ar()}else{var t;clearInterval(null!==(t=this.ec)&&void 0!==t?t:void 0),this.nc(),this.getAndClearBuffer()}}onRemoteConfig(t){if(t.ok){var i=t.config;if("heatmaps"in i){var e=!!i.heatmaps;this.instance.persistence&&this.instance.persistence.register({[b]:e}),this.tc=e,this.startIfEnabled()}}}getAndClearBuffer(){var t=this.Rt;return this.Rt=void 0,t}sc(t){ph(t.originalEvent)&&this.Sn(t.originalEvent,"deadclick")}ar(){this.ec&&clearInterval(this.ec),this.ec=function(t){return"visible"===(null==t?void 0:t.visibilityState)}(Xt)?setInterval(this.ol.bind(this),this.flushIntervalMilliseconds):null}rc(){Gt&&Xt&&(this.oc=this.ol.bind(this),Fs(Gt,Ut,this.oc),this.ac=t=>this.Sn(t||(null==Gt?void 0:Gt.event)),Fs(Xt,"click",this.ac,{capture:!0}),this.lc=t=>this.uc(t||(null==Gt?void 0:Gt.event)),Fs(Xt,"mousemove",this.lc,{capture:!0}),this.hc=new Xn(this.instance,Kn,this.sc.bind(this)),this.hc.startIfEnabledOrStop(),this.dc=this.ar.bind(this),Fs(Xt,zt,this.dc),this.ho=!0)}nc(){var t;Gt&&Xt&&(this.oc&&Gt.removeEventListener(Ut,this.oc),this.ac&&Xt.removeEventListener("click",this.ac,{capture:!0}),this.lc&&Xt.removeEventListener("mousemove",this.lc,{capture:!0}),this.dc&&Xt.removeEventListener(zt,this.dc),clearTimeout(this.vc),null==(t=this.hc)||t.stop(),this.ho=!1)}cc(t,i){var e=this.instance.scrollManager.scrollY(),r=this.instance.scrollManager.scrollX(),s=this.instance.scrollManager.scrollElement(),n=function(t,i,e){for(var r=t;r&&un(r)&&!dn(r,"body");){if(r===e)return!1;var s=void 0;try{var n,o,a;s=null==(n=null!==(o=null==(a=r.ownerDocument)?void 0:a.defaultView)&&void 0!==o?o:Gt)?void 0:n.getComputedStyle(r).position}catch(t){return!1}if(ui(i,s))return!0;r=Sn(r)}return!1}(bn(t),["fixed","sticky"],s);return{x:t.clientX+(n?0:r),y:t.clientY+(n?0:e),target_fixed:n,type:i}}Sn(t,i){var e;if(void 0===i&&(i="click"),!hn(t.target)&&ph(t)){var s=this.cc(t,i);null!=(e=this.rageclicks)&&e.isRageClick(t.clientX,t.clientY,(new Date).getTime())&&Fn(bn(t),this.instance.config.rageclick)&&this.Hs(r({},s,{type:"rageclick"})),this.Hs(s)}}uc(t){!hn(t.target)&&ph(t)&&(clearTimeout(this.vc),this.vc=setTimeout(()=>{this.Hs(this.cc(t,"mousemove"))},500))}Hs(t){if(Gt){var i=this.xn.disable_capture_url_hashes?tr(Gt.location.href):Gt.location.href,e=this.xn.custom_personal_data_properties,r=uo(i,this.xn.mask_personal_data_properties?[...po,...e||[]]:[],_o);this.Rt=this.Rt||{},this.Rt[r]||(this.Rt[r]=[]),this.Rt[r].push(t)}}ol(){this.Rt&&!yi(this.Rt)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:Xn,webVitalsAutocapture:class{constructor(t){var i;this._instance=t,this.tc=!1,this.ho=!1,this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this.fc=()=>{clearTimeout(this.gc),this.gc=void 0,0!==this.Rt.metrics.length&&(this._instance.capture("$web_vitals",r({$current_url:this.Rt.url},this.Rt.metrics.reduce((t,i)=>r({},t,{["$web_vitals_"+i.name+"_event"]:r({},i),["$web_vitals_"+i.name+"_value"]:i.value}),{}))),this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.mc=t=>{var i;if(this.Rt=this.Rt||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},Ei(null==t?void 0:t.name)||Ei(null==t?void 0:t.value))oh.error("Invalid metric received",t);else{var e="string"==typeof t.navigationURL?t.navigationURL:void 0,s=this.yc(e);if(!wi(s)){var n=$i(t.navigationId)||"string"==typeof t.navigationId?"navigation:"+t.navigationId:"url:"+s;if(!this.bc||this.bc>t.value){this.Rt.navigationKey!==n&&(this.fc(),this.gc=setTimeout(this.fc,this.flushToCaptureTimeoutMs)),wi(this.Rt.navigationKey)&&(this.Rt.navigationKey=n,this.Rt.url=s),this.Rt.firstMetricTimestamp=wi(this.Rt.firstMetricTimestamp)?Date.now():this.Rt.firstMetricTimestamp;var o=null==(i=this._instance.sessionManager)?void 0:i.checkAndGetSessionAndWindowId(!0),a=r({},t,e?{navigationURL:s}:{},{$current_url:s,timestamp:Date.now()});if(delete a.entries,bi(t.attribution)&&this.attributionMetrics.indexOf(t.name)>-1){var l={};for(var h of uh){var u="url"===h&&"string"==typeof t.attribution[h]?this.yc(t.attribution[h]):t.attribution[h];wi(u)||(l[h]=u)}a.attribution=l}else delete a.attribution;wi(o)||(a.$session_id=o.sessionId,a.$window_id=o.windowId),this.Rt.metrics.push(a),this.Rt.metrics.length===this.allowedMetrics.length&&this.fc()}else oh.error("Ignoring metric with value >= "+this.bc,t)}}},this._c=()=>{if(!this.ho){var t,i,e,s,n=!1,o=ni.__PosthogExtensions__,a=null==o?void 0:o.postHogWebVitalsCallbacksByFlavor,l=(null==a?void 0:a[this.wc])||("web-vitals"===this.wc&&wi(a)?null==o?void 0:o.postHogWebVitalsCallbacks:void 0);if(!wi(l)){var h=l.withoutAttribution,u=this.attributionMetrics;n=!wi(h),t=u.indexOf("LCP")>-1?l.onLCP:(null==h?void 0:h.onLCP)||l.onLCP,i=u.indexOf("CLS")>-1?l.onCLS:(null==h?void 0:h.onCLS)||l.onCLS,e=u.indexOf("FCP")>-1?l.onFCP:(null==h?void 0:h.onFCP)||l.onFCP,s=u.indexOf("INP")>-1?l.onINP:(null==h?void 0:h.onINP)||l.onINP}if(t&&i&&e&&s){var d={reportSoftNavs:this.useSoftNavs},v=n&&this.attributionMetrics.indexOf("INP")>-1?r({},d,{includeProcessedEventEntries:!1}):d;this.allowedMetrics.indexOf("LCP")>-1&&t(this.mc.bind(this),d),this.allowedMetrics.indexOf("CLS")>-1&&i(this.mc.bind(this),d),this.allowedMetrics.indexOf("FCP")>-1&&e(this.mc.bind(this),d),this.allowedMetrics.indexOf("INP")>-1&&s(this.mc.bind(this),v),this.ho=!0}else oh.error("web vitals callbacks not loaded - not starting")}},this.tc=!(null==(i=this._instance.persistence)||!i.props[S]),this.startIfEnabled()}get kc(){return this._instance.config.capture_performance}get allowedMetrics(){var t,i,e=bi(this.kc)?null==(t=this.kc)?void 0:t.web_vitals_allowed_metrics:void 0;return Ei(e)?(null==(i=this._instance.persistence)?void 0:i.props.$web_vitals_allowed_metrics)||lh:e}get flushToCaptureTimeoutMs(){return(bi(this.kc)?this.kc.web_vitals_delayed_flush_ms:void 0)||5e3}get attributionMetrics(){var t=bi(this.kc)?this.kc.web_vitals_attribution:void 0;return Ti(t)?t?lh:[]:_i(t)?t:hh}get useAttribution(){return this.attributionMetrics.length>0}get useSoftNavs(){var t;return null!==(t=bi(this.kc)?this.kc.__preview_web_vitals_soft_navs:void 0)&&void 0!==t&&t}get bc(){var t=bi(this.kc)&&$i(this.kc.__web_vitals_max_value)?this.kc.__web_vitals_max_value:ah;return t>0&&6e4>=t?ah:t}get isEnabled(){var t=null==Yt?void 0:Yt.protocol;if("http:"!==t&&"https:"!==t)return oh.info("Web Vitals are disabled on non-http/https protocols"),!1;var i=bi(this.kc)?this.kc.web_vitals:Ti(this.kc)?this.kc:void 0;return Ti(i)?i:this.tc}startIfEnabled(){this.isEnabled&&!this.ho&&(oh.info("enabled, starting..."),this.Ro(this._c))}onRemoteConfig(t){if(t.ok){var i=t.config;if("capturePerformance"in i){var e=bi(i.capturePerformance)&&!!i.capturePerformance.web_vitals,r=bi(i.capturePerformance)?i.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[S]:e}),this._instance.persistence.register({[T]:r})),this.tc=e,this.startIfEnabled()}}}get wc(){return this.useSoftNavs?this.useAttribution?"web-vitals-with-attribution-soft-navs":"web-vitals-soft-navs":this.useAttribution?"web-vitals-with-attribution":"web-vitals"}Ro(t){var i=ni.__PosthogExtensions__,e=this.wc,r=null==i?void 0:i.postHogWebVitalsCallbacksByFlavor;null!=r&&r[e]||"web-vitals"===e&&wi(r)&&null!=i&&i.postHogWebVitalsCallbacks?t():null==i||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,e,i=>{i?oh.error("failed to load script",i):t()})}yc(t){var i=t||(null==Gt?void 0:Gt.location.href);if(i){var e=this._instance.config.disable_capture_url_hashes?tr(i):i,r=this._instance.config.custom_personal_data_properties;return uo(e,this._instance.config.mask_personal_data_properties?[...po,...r||[]]:[],_o)}oh.error("Could not determine current URL")}}},ou={exceptionObserver:class{constructor(t){var i;this._c=()=>{var t;if(Gt&&this.isEnabled&&null!=(t=ni.__PosthogExtensions__)&&t.errorWrappingFunctions){var i=ni.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,e=ni.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,r=ni.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.Sc&&this.xn.capture_unhandled_errors&&(this.Sc=i(this.captureException.bind(this))),!this.xc&&this.xn.capture_unhandled_rejections&&(this.xc=e(this.captureException.bind(this))),!this.Cc&&this.xn.capture_console_errors&&(this.Cc=r(this.captureException.bind(this)))}catch(t){ih.error("failed to start",t),this.Tc()}}},this._instance=t,this.Mc=!(null==(i=this._instance.persistence)||!i.props[y]),this.wt=new Ui(r({},function(t){var i,e,r,s;return void 0===t&&(t={}),{refillRate:null!==(i=null!==(e=t.exceptionRateLimiterRefillRate)&&void 0!==e?e:t.__exceptionRateLimiterRefillRate)&&void 0!==i?i:1,bucketSize:null!==(r=null!==(s=t.exceptionRateLimiterBucketSize)&&void 0!==s?s:t.__exceptionRateLimiterBucketSize)&&void 0!==r?r:10}}(this._instance.config.error_tracking),{refillInterval:1e4,A:ih})),this.xn=this.Ic(),this.startIfEnabledOrStop()}Ic(){var t=this._instance.config.capture_exceptions,i={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return bi(t)?i=r({},i,t):(wi(t)?this.Mc:t)&&(i=r({},i,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),i}get isEnabled(){return this.xn.capture_console_errors||this.xn.capture_unhandled_errors||this.xn.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(ih.info("enabled"),this.Tc(),this.Ro(this._c)):this.Tc()}Ro(t){var i,e;null!=(i=ni.__PosthogExtensions__)&&i.errorWrappingFunctions?t():null==(e=ni.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,"exception-autocapture",i=>{if(i)return ih.error("failed to load script",i);t()})}Tc(){var t,i,e;null==(t=this.Sc)||t.call(this),this.Sc=void 0,null==(i=this.xc)||i.call(this),this.xc=void 0,null==(e=this.Cc)||e.call(this),this.Cc=void 0}onRemoteConfig(t){if(t.ok){var i=t.config;"autocaptureExceptions"in i&&(this.Mc=!!i.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[y]:this.Mc}),this.xn=this.Ic(),this.startIfEnabledOrStop())}}onConfigChange(){this.xn=this.Ic()}captureException(t){try{var i,e,r,s=null!==(i=null==t||null==(e=t.$exception_list)||null==(e=e[0])?void 0:e.type)&&void 0!==i?i:"Exception";if(this.wt.consumeRateLimit(s))return void ih.info("Skipping exception capture because of client rate limiting.",{exception:s});null==(r=this._instance.exceptions)||r.sendExceptionEvent(t)}catch(t){}}},exceptions:class{constructor(t){var i,e;this.Ec=[],this.Rc=new nr([new Sr,new Rr,new Er,new kr,new Ar,new Fr,new Pr,new Ir],function(t){for(var i=arguments.length,e=new Array(i>1?i-1:0),s=1;i>s;s++)e[s-1]=arguments[s];return function(i,s){void 0===s&&(s=0);for(var n=[],o=i.split("\n"),a=Math.min(o.length,s+1e3),l=[],h=s;a>h;h++){var u=o[h];if(1024>=u.length){var d=pr.test(u)?u.replace(pr,"$1"):u;if(!d.match(/\S*Error: /)){for(var v of e){var c=v(d,t);if(c){n.push(c);var f=_r(n);if(f){for(var p=l.length-1;p>=0;p--){var g=l[p];if(f.start>=g.start+g.length)break;l.pop()}l.push(f)}break}}if(wr(n,l)>=50)break}}}var _=[...l].sort((t,i)=>i.start-t.start),m=_[_.length-1];if(m){var b=br(n,m);for(var y of(n.splice(m.start-b,b),_))y.start-=b}for(var w of _)mr(n,w);return l.some(t=>0===t.start&&n.length===t.length)&&function(t){for(var i=t.map(t=>t.function+"|"+t.filename+"|"+t.lineno+"|"+t.colno+"|"+t.module),e=0,r=1;i.length>r;r++)xr(i,r,e)&&(e=r);t.push(...t.splice(0,e))}(n),function(t){if(!t.length)return[];var i=Array.from(t);return i.reverse(),i.slice(0,50).map(t=>{return r({},t,{filename:t.filename||(e=i,e[e.length-1]||{}).filename,function:t.function||"?"});var e})}(n)}}("web:javascript",dr,fr)),this._instance=t,this.Ec=null!==(i=null==(e=this._instance.persistence)?void 0:e.get_property("$error_tracking_suppression_rules"))&&void 0!==i?i:[],this.Ac=Br(this.Pc()),this.Fc=new Lr(this.Ac)}onConfigChange(){this.Ac=Br(this.Pc()),this.Fc.setConfig(this.Ac)}onRemoteConfig(t){var i,e,r;if(t.ok){var s=t.config;if("errorTracking"in s){var n=null!==(i=null==(e=s.errorTracking)?void 0:e.suppressionRules)&&void 0!==i?i:[],o=null==(r=s.errorTracking)?void 0:r.captureExtensionExceptions;this.Ec=n,this._instance.persistence&&this._instance.persistence.register({[w]:this.Ec,[x]:o})}}}get Oc(){var t,i,e=!!this._instance.get_property(x);return null!==(t=null!==(i=this._instance.config.error_tracking.captureExtensionExceptions)&&void 0!==i?i:e)&&void 0!==t&&t}buildProperties(t,i){return this.Rc.buildFromUnknown(t,{syntheticException:null==i?void 0:i.syntheticException,mechanism:{handled:null==i?void 0:i.handled}})}addExceptionStep(t,i){if(this.Ac.enabled)try{if(!xi(t)||0===t.trim().length)return void Uh.warn("Ignoring exception step because message must be a non-empty string");var e=function(t){if(!t)return{sanitizedProperties:{},droppedKeys:[]};var i=[];return{sanitizedProperties:Object.keys(t).reduce((e,r)=>Dr.has(r)?(i.push(r),e):(e[r]=t[r],e),{}),droppedKeys:i}}(this.$c(i)),s=e.sanitizedProperties,n=e.droppedKeys;n.length>0&&Uh.warn("Ignoring reserved exception step fields",{droppedKeys:n}),this.Fc.add(r({[Or]:t,[Mr]:(new Date).toISOString()},s))}catch(t){Uh.error("Failed to add exception step. Ignoring breadcrumb.",t)}}sendExceptionEvent(t){try{var i=t.$exception_list;if(this.Dc(i)){if(this.Lc(i))return this.Nc("Exception dropped: matched a suppression rule"),void Uh.info("Skipping exception capture because a suppression rule matched");if(!this.Oc&&this.qc(i))return this.Nc("Exception dropped: thrown by a browser extension"),void Uh.info("Skipping exception capture because it was thrown by an extension");if(!this.Oc&&this.jc(i))return this.Nc("Exception dropped: thrown by an injected browser script"),void Uh.info("Skipping exception capture because it was thrown by an injected browser script");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.Bc(i))return this.Nc("Exception dropped: thrown by the PostHog SDK"),void Uh.info("Skipping exception capture because it was thrown by the PostHog SDK")}var e=this.Ac.enabled&&Ei(t.$exception_steps)?this.Hc(t):t,r="string"==typeof(n=globalThis._posthogReleaseId)&&n.length>0?n:void 0;r&&(e.$release_id=r);try{var s=this._instance.capture("$exception",e,{_noTruncate:!0,_batchKey:"exceptionEvent",Gu:!0});return s&&this.Fc.clear(),s}catch(t){return zh(t)||Uh.error("Failed to capture exception event. Dropping this exception.",t),void this.Fc.clear()}}catch(t){return void(zh(t)||Uh.error("Failed to process exception event. Ignoring this exception.",t))}var n}Hc(t){try{var i=this.Fc.getAttachable();return 0===i.length?t:r({},t,{$exception_steps:i})}catch(i){return Uh.error("Failed to read buffered exception steps. Capturing exception without steps.",i),t}}Nc(t){this.Ac.enabled&&this.Fc.add({[Or]:t,[Mr]:(new Date).toISOString()})}$c(t){return bi(t)?r({},t):{}}Pc(){var t,i;return null!==(t=null==(i=this._instance.config.error_tracking)?void 0:i.exception_steps)&&void 0!==t?t:{}}Lc(t){if(0===t.length)return!1;try{var i=t.reduce((t,i)=>{var e=i.type,r=i.value;return xi(e)&&e.length>0&&t.$exception_types.push(e),xi(r)&&r.length>0&&t.$exception_values.push(r),t},{$exception_types:[],$exception_values:[]});return this.Ec.some(t=>{var e=t.values.map(t=>{var e=ul[t.operator],r=i[t.key];if(!e||!r)return!1;var s=_i(t.value)?t.value:[t.value];return s.length>0&&e(s,r)});return"OR"===t.type?e.some(Boolean):e.every(Boolean)})}catch(t){return Uh.warn("Failed to evaluate suppression rules. Capturing the exception.",t),!1}}qc(t){var i=t.flatMap(t=>{var i,e;return null!==(i=null==(e=t.stacktrace)?void 0:e.frames)&&void 0!==i?i:[]}),e=i.filter(t=>{var i=t.filename;return!!i&&Vh.some(t=>i.startsWith(t))});return 0!==e.length&&(!e.every(t=>{var i=t.filename;return!!i&&i.startsWith(Hh)})||t.some(t=>{var i=t.value;return"NoResponse"===t.type||xi(i)&&qh.some(t=>{var e=t.value;return t.exact?i===e:i.includes(e)})})&&!i.some(t=>{var i=t.filename;return t.in_app&&!(null!=i&&i.startsWith(Hh))}))}jc(t){return t.some(t=>{var i=t.value;return xi(i)&&Wh.some(t=>i.includes(t))})}Bc(t){if(t.length>0){var i,e,r,s,n=null!==(i=null==(e=t[0].stacktrace)?void 0:e.frames)&&void 0!==i?i:[];return null!==(r=null==(s=n[n.length-1])||null==(s=s.filename)?void 0:s.includes("posthog.com/static"))&&void 0!==r&&r}return!1}Dc(t){return!Ei(t)&&_i(t)}}},au=r({productTours:class{get gl(){return this._instance.persistence}constructor(t){this.zc=null,this.Uc=null,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(t.ok){var i=t.config;if("productTours"in i){var e,r;if(this.gl&&this.gl.register({[E]:!!i.productTours}),!_h(this._instance))return!this.zc&&Ei(null==(e=this.gl)?void 0:e.props.ph_product_tours)||gh.info("product tours disabled; stopping and clearing cached tours"),null==(r=this.zc)||r.stop(),this.zc=null,void this.clearCache();this.loadIfEnabled()}}}loadIfEnabled(){!this.zc&&_h(this._instance)&&this.Ro(()=>this.Wc())}Ro(t){var i,e;null!=(i=ni.__PosthogExtensions__)&&i.generateProductTours?t():null==(e=ni.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,"product-tours",i=>{i?gh.error("Could not load product tours script",i):t()})}Wc(){var t;!this.zc&&null!=(t=ni.__PosthogExtensions__)&&t.generateProductTours&&(this.zc=ni.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(t,i){if(void 0===i&&(i=!1),!_i(this.Uc)||i){var e=this.gl;if(e){var r=e.props[ot];if(_i(r)&&!i)return this.Uc=r,void t(r,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/product_tours/?token="+this._instance.config.token),method:"GET",timestampMode:"query",callback:i=>{if(_h(this._instance)){var r=i.statusCode;if(200!==r||!i.json){var s="Product Tours API could not be loaded, status: "+r;return 0===r?i.error||gh.warn(s):gh.error(s),void t([],{isLoaded:!1,error:s})}var n=_i(i.json.product_tours)?i.json.product_tours:[];this.Uc=n,e&&e.register({[ot]:n}),t(n,{isLoaded:!0})}else t([],{isLoaded:!0})}})}else t(this.Uc,{isLoaded:!0})}getActiveProductTours(t){Ei(this.zc)?t([],{isLoaded:!1,error:"Product tours not loaded"}):this.zc.getActiveProductTours(t)}showProductTour(t){var i;null==(i=this.zc)||i.showTourById(t)}previewTour(t){this.zc?this.zc.previewTour(t):this.Ro(()=>{var i;this.Wc(),null==(i=this.zc)||i.previewTour(t)})}dismissProductTour(){var t;null==(t=this.zc)||t.dismissTour("user_clicked_skip")}nextStep(){var t;null==(t=this.zc)||t.nextStep()}previousStep(){var t;null==(t=this.zc)||t.previousStep()}clearCache(){var t;this.Uc=null,null==(t=this.gl)||t.unregister(ot)}resetTour(t){var i;null==(i=this.zc)||i.resetTour(t)}resetAllTours(){var t;null==(t=this.zc)||t.resetAllTours()}cancelPendingTour(t){var i;null==(i=this.zc)||i.cancelPendingTour(t)}}},ru),lu={siteApps:class{constructor(t){this._instance=t,this.Vc=0,this.Gc=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}Zc(t,i){if(i){var e=this.globalsForEvent(i);this.Gc.push(e),this.Gc.length>1e3&&(this.Gc=this.Gc.slice(10))}}get siteAppLoaders(){var t;return null==(t=ni._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.siteApps}initialize(){if(this.isEnabled){var t=this._instance._addCaptureHook(this.Zc.bind(this));this.Jc=()=>{t(),this.Gc=[],this.Jc=void 0}}}globalsForEvent(t){var s,n,o,a,l,h,u;if(!t)throw new Error("Event payload is required");var d={},v=this._instance.get_property("$groups")||[],c=this._instance.get_property("$stored_group_properties")||{};for(var f of Object.entries(c)){var p=f[0];d[p]={id:v[p],type:p,properties:f[1]}}var g=t.$set_once,_=t.$set;return{event:r({},e(t,i),{properties:r({},t.properties,_?{$set:r({},null!==(s=null==(n=t.properties)?void 0:n.$set)&&void 0!==s?s:{},_)}:{},g?{$set_once:r({},null!==(o=null==(a=t.properties)?void 0:a.$set_once)&&void 0!==o?o:{},g)}:{}),elements_chain:null!==(l=null==(h=t.properties)?void 0:h.$elements_chain)&&void 0!==l?l:"",distinct_id:null==(u=t.properties)?void 0:u.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:d}}Qc(t){var i,e=null==(i=t.tagName)?void 0:i.toLowerCase();return"style"===e&&this._instance.config.prepare_external_dependency_stylesheet?this._instance.config.prepare_external_dependency_stylesheet(t)||(mh.error("prepare_external_dependency_stylesheet returned null"),null):"script"===e&&this._instance.config.prepare_external_dependency_script?this._instance.config.prepare_external_dependency_script(t)||(mh.error("prepare_external_dependency_script returned null"),null):t}Kc(){var t,i,e,r,s,n,o,a;if(!this._instance.config.prepare_external_dependency_stylesheet&&!this._instance.config.prepare_external_dependency_script)return()=>{};var l=null==Xt?void 0:Xt.defaultView,h=null==l||null==(t=l.Node)?void 0:t.prototype;if(!l||!h)return()=>{};if(this.Vc++,this.Xc)return this.Yc();var u=[],d=this,v=new WeakSet,c=(t,i,e)=>{if(null!=t&&t[i]){var r=t[i];t[i]=e(r),u.push(()=>{t[i]=r})}},f=t=>{if(v.has(t))return t;var i=d.Qc(t);return i&&v.add(i),i},p=t=>t.map(t=>"string"==typeof t?t:f(t)).filter(t=>!ki(t));return c(h,"appendChild",t=>function(i){var e=f(i);return e?t.call(this,e):i}),c(h,"insertBefore",t=>function(i,e){var r=f(i);return r?t.call(this,r,e):i}),c(h,"replaceChild",t=>function(i,e){var r=f(i);return r?t.call(this,r,e):e}),[null==(i=l.Element)?void 0:i.prototype,null==(e=l.Document)?void 0:e.prototype,null==(r=l.DocumentFragment)?void 0:r.prototype].forEach(t=>{c(t,"append",t=>function(){for(var i=arguments.length,e=new Array(i),r=0;i>r;r++)e[r]=arguments[r];return t.apply(this,p(e))}),c(t,"prepend",t=>function(){for(var i=arguments.length,e=new Array(i),r=0;i>r;r++)e[r]=arguments[r];return t.apply(this,p(e))})}),[null==(s=l.Element)?void 0:s.prototype,null==(n=l.CharacterData)?void 0:n.prototype,null==(o=l.DocumentType)?void 0:o.prototype].forEach(t=>{c(t,"before",t=>function(){for(var i=arguments.length,e=new Array(i),r=0;i>r;r++)e[r]=arguments[r];return t.apply(this,p(e))}),c(t,"after",t=>function(){for(var i=arguments.length,e=new Array(i),r=0;i>r;r++)e[r]=arguments[r];return t.apply(this,p(e))}),c(t,"replaceWith",t=>function(){for(var i=arguments.length,e=new Array(i),r=0;i>r;r++)e[r]=arguments[r];var s=p(e);return e.length&&!s.length?void 0:t.apply(this,s)})}),c(null==(a=l.Element)?void 0:a.prototype,"insertAdjacentElement",t=>function(i,e){var r=f(e);return r?t.call(this,i,r):null}),this.Xc=()=>{u.forEach(t=>t()),this.Xc=void 0},this.Yc()}Yc(){var t=!1;return()=>{var i;t||(t=!0,this.Vc--,0===this.Vc&&(null==(i=this.Xc)||i.call(this)))}}tf(t,i){void 0===i&&(i=!0);var e=this.Kc();try{var r=t(e);return i&&e(),r}catch(t){throw e(),t}}setupSiteApp(t){var i=this.apps[t.id],e=()=>{var e;!i.errored&&this.Gc.length&&(mh.info("Processing "+this.Gc.length+" events for site app with id "+t.id),this.Gc.forEach(t=>this.tf(()=>null==i.processEvent?void 0:i.processEvent(t))),i.processedBuffer=!0),Object.values(this.apps).every(t=>t.processedBuffer||t.errored)&&(null==(e=this.Jc)||e.call(this))},r=!1,s=s=>{i.errored=!s,i.loaded=!0,mh.info("Site app with id "+t.id+" "+(s?"loaded":"errored")),r&&e()};try{var n=this.tf(i=>t.init({posthog:this._instance,callback(t){i(),s(t)}}),!1).processEvent;n&&(i.processEvent=n),r=!0}catch(i){mh.error(bh+t.id,i),s(!1)}if(r&&i.loaded)try{e()}catch(e){mh.error("Error while processing buffered events PostHog app with config id "+t.id,e),i.errored=!0}}ef(){var t=this.siteAppLoaders||[];for(var i of t)this.apps[i.id]={id:i.id,loaded:!1,errored:!1,processedBuffer:!1};for(var e of t)this.setupSiteApp(e)}if(t){var i=this;if(0!==Object.keys(this.apps).length){var e=this.globalsForEvent(t),r=function(r){try{i.tf(()=>null==r.processEvent?void 0:r.processEvent(e))}catch(i){mh.error("Error while processing event "+t.event+" for site app "+r.id,i)}};for(var s of Object.values(this.apps))r(s)}}onRemoteConfig(t){var i,e,r,s=this;if(null!=(i=this.siteAppLoaders)&&i.length)return this.isEnabled?(this.ef(),void this._instance.on("eventCaptured",t=>this.if(t))):void mh.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null==(e=this.Jc)||e.call(this),t.ok){var n=t.config;if(null!=(r=n.siteApps)&&r.length)if(this.isEnabled){var o=function(){var t,i=a.id,e=a.url;ni["__$$ph_site_app_"+i]=s._instance,null==(t=ni.__PosthogExtensions__)||null==t.loadSiteApp||t.loadSiteApp(s._instance,e,t=>{if(t)return mh.error(bh+i,t)})};for(var a of n.siteApps)o()}else mh.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}}},hu={tracingHeaders:class{constructor(t){this._instance=t,this.rf=void 0,this.nf=void 0,this.sf=void 0,this._c=()=>{var t,i,e=this.af();e?(wi(this.rf)&&(this.rf=null==(t=ni.__PosthogExtensions__)||null==(t=t.tracingHeadersPatchFns)?void 0:t._patchXHR(e,()=>this._instance.get_distinct_id(),this._instance.sessionManager)),wi(this.nf)&&(this.nf=null==(i=ni.__PosthogExtensions__)||null==(i=i.tracingHeadersPatchFns)?void 0:i._patchFetch(e,()=>this._instance.get_distinct_id(),this._instance.sessionManager))):this.Tc()}}initialize(){this.startIfEnabledOrStop()}Ro(t){var i,e;null!=(i=ni.__PosthogExtensions__)&&i.tracingHeadersPatchFns?t():null==(e=ni.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,"tracing-headers",i=>{if(i)return nh.error("failed to load script",i);t()})}lf(){var t,i;return null!==(t=null!==(i=this._instance.config.tracing_headers)&&void 0!==i?i:this._instance.config.addTracingHeaders)&&void 0!==t?t:this._instance.config.__add_tracing_headers}af(){var t=this.lf();return _i(t)?(_i(this.sf)?this.sf.splice(0,this.sf.length,...t):this.sf=[...t],t.length>0?this.sf:void 0):(_i(this.sf)&&this.sf.splice(0),this.sf=t||void 0,this.sf)}Tc(){var t,i;null==(t=this.rf)||t.call(this),null==(i=this.nf)||i.call(this),this.rf=void 0,this.nf=void 0}startIfEnabledOrStop(){this.af()?this.Ro(this._c):this.Tc()}}},uu=r({surveys:class extends Sh{constructor(t){var i;super(new Ch(t),(i=t,{get projectToken(){return i.config.token},kv:new Th(i)})),this._instance=t}wh(t,i){var e=i.query?ja(t,i.query):t;return new Promise(t=>{var r;this._instance._send_request({method:i.method,url:this._instance.requestRouter.endpointFor(null!==(r=i.target)&&void 0!==r?r:"api",e),data:i.body,headers:i.headers,timeout:i.timeoutMs,fireCallbackOnDrop:!0,transport:i.transport,compression:i.compression,timestampMode:i.sentAt,callback:t})})}}},ru),du={toolbar:class{constructor(t){this.instance=t}uf(t){ni.ph_toolbar_state=t}hf(){var t;return null!==(t=ni.ph_toolbar_state)&&void 0!==t?t:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(t,i,e){if(void 0===t&&(t=void 0),void 0===i&&(i=void 0),void 0===e&&(e=void 0),As(this.instance.config))return!1;if(!Gt||!Xt)return!1;t=null!=t?t:Gt.location,e=null!=e?e:Gt.history;try{if(!i){try{Gt.localStorage.setItem("test","test"),Gt.localStorage.removeItem("test")}catch(t){return!1}i=null==Gt?void 0:Gt.localStorage}var r,s=Fh||vo(t.hash,"__posthog")||vo(t.hash,"state"),n=s?ks(()=>JSON.parse(atob(decodeURIComponent(s))))||ks(()=>JSON.parse(decodeURIComponent(s))):null;return n&&"ph_authorize"===n.action?((r=n).source="url",r&&Object.keys(r).length>0&&(n.desiredHash?t.hash=n.desiredHash:e?e.replaceState(e.state,"",t.pathname+t.search):t.hash="")):((r=JSON.parse(i.getItem(Ah)||"{}")).source="localstorage",delete r.userIntent),!(!r.token||this.instance.config.token!==r.token||(this.loadToolbar(r),0))}catch(t){return!1}}df(t){var i=ni.ph_load_toolbar||ni.ph_load_editor;!Ei(i)&&mi(i)?i(t,this.instance):Ih.warn("No toolbar load function found")}loadToolbar(t){var i=!(null==Xt||!Xt.getElementById("__POSTHOG_TOOLBAR__"));if(!Gt||i)return!1;var e="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,s=r({token:this.instance.config.token},t,{apiURL:this.instance.requestRouter.endpointFor("ui")},e?{instrument:!1}:{});if(Gt.localStorage.setItem(Ah,JSON.stringify(r({},s,{source:void 0}))),2===this.hf())this.df(s);else if(0===this.hf()){var n;this.uf(1),null==(n=ni.__PosthogExtensions__)||null==n.loadExternalDependency||n.loadExternalDependency(this.instance,"toolbar",t=>{if(t)return Ih.error("[Toolbar] Failed to load",t),void this.uf(0);this.uf(2),this.df(s)}),Fs(Gt,"turbolinks:load",()=>{this.uf(0),this.loadToolbar(s)})}return!0}vf(t){return this.loadToolbar(t)}maybeLoadEditor(t,i,e){return void 0===t&&(t=void 0),void 0===i&&(i=void 0),void 0===e&&(e=void 0),this.maybeLoadToolbar(t,i,e)}}},vu=r({experiments:class t{get xn(){return this._instance.config}constructor(i){var e=this;this._instance=i,this.getWebExperimentsAndEvaluateDisplayLogic=function(i){void 0===i&&(i=!1),e.getWebExperiments(i=>{t.cf("retrieved web experiments from the server"),e.ff=new Map,i.forEach(i=>{if(i.feature_flag_key){var r;e.ff&&(t.cf("setting flag key ",i.feature_flag_key," to web experiment ",i),null==(r=e.ff)||r.set(i.feature_flag_key,i));var s=e._instance.getFeatureFlag(i.feature_flag_key);xi(s)&&i.variants[s]&&e.pf(i.name,s,i.variants[s].transforms)}else if(i.variants)for(var n in i.variants){var o=i.variants[n];t.gf(o,e._instance)&&e.pf(i.name,n,o.transforms)}})},i)},this._instance.onFeatureFlags(t=>{this.onFeatureFlags(t)})}initialize(){}onFeatureFlags(i){if(this._is_bot())t.cf(Gh);else if(!this.xn.disable_web_experiments){if(Ei(this.ff))return this.ff=new Map,this.loadIfEnabled(),void this.previewWebExperiment();t.cf("applying feature flags",i),i.forEach(t=>{var i;if(this.ff&&null!=(i=this.ff)&&i.has(t)){var e,r=this._instance.getFeatureFlag(t),s=null==(e=this.ff)?void 0:e.get(t);r&&null!=s&&s.variants[r]&&this.pf(s.name,r,s.variants[r].transforms)}})}}previewWebExperiment(){var i=t.getWindowLocation();if(null!=i&&i.search){var e=ho(null==i?void 0:i.search,"__experiment_id"),r=ho(null==i?void 0:i.search,"__experiment_variant");e&&r&&(t.cf("previewing web experiments "+e+" && "+r),this.getWebExperiments(t=>{this.mf(parseInt(e),r,t)},!1,!0))}}loadIfEnabled(){this.xn.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(t,i,e){if(this.xn.disable_web_experiments&&!e)return t([]);var r=this._instance.get_property("$web_experiments");if(r&&!i)return t(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this.xn.token),method:"GET",timestampMode:"query",callback:i=>t(200===i.statusCode&&i.json&&i.json.experiments||[])})}mf(i,e,r){var s=r.filter(t=>t.id===i);s&&s.length>0&&(t.cf("Previewing web experiment ["+s[0].name+"] with variant ["+e+"]"),this.pf(s[0].name,e,s[0].variants[e].transforms))}static gf(i,e){return!Ei(i.conditions)&&t.yf(i,e)&&t.bf(i)}static yf(i,e){var r;if(Ei(i.conditions)||Ei(null==(r=i.conditions)?void 0:r.url))return!0;var s=t.getWindowLocation();if(s){var n,o,a,l=ln(e,s.href);return null==(n=i.conditions)||!n.url||Kh[null!==(o=null==(a=i.conditions)?void 0:a.urlMatchType)&&void 0!==o?o:"icontains"](i.conditions.url,l)}return!1}static getWindowLocation(){return null==Gt?void 0:Gt.location}static bf(t){var i;if(Ei(t.conditions)||Ei(null==(i=t.conditions)?void 0:i.utm))return!0;var e=bo();if(e.utm_source){var r,s,n,o,a,l,h,u,d=null==(r=t.conditions)||null==(r=r.utm)||!r.utm_campaign||(null==(s=t.conditions)||null==(s=s.utm)?void 0:s.utm_campaign)==e.utm_campaign,v=null==(n=t.conditions)||null==(n=n.utm)||!n.utm_source||(null==(o=t.conditions)||null==(o=o.utm)?void 0:o.utm_source)==e.utm_source,c=null==(a=t.conditions)||null==(a=a.utm)||!a.utm_medium||(null==(l=t.conditions)||null==(l=l.utm)?void 0:l.utm_medium)==e.utm_medium,f=null==(h=t.conditions)||null==(h=h.utm)||!h.utm_term||(null==(u=t.conditions)||null==(u=u.utm)?void 0:u.utm_term)==e.utm_term;return d&&c&&f&&v}return!1}static cf(t){for(var i=arguments.length,e=new Array(i>1?i-1:0),r=1;i>r;r++)e[r-1]=arguments[r];ms.info("[WebExperiments] "+t,e)}pf(i,e,r){this._is_bot()?t.cf(Gh):"control"!==e?r.forEach(r=>{var s;r.selector&&(t.cf("applying transform of variant "+e+" for experiment "+i+" ",r),null==(s=document)||null==(s=s.querySelectorAll(r.selector))||s.forEach(t=>{var i=t;r.html&&(i.innerHTML=r.html),r.css&&i.setAttribute("style",r.css)}))}):t.cf("Control variants leave the page unmodified.")}_is_bot(){return Jt&&this._instance?sl(Jt,this.xn.custom_blocked_useragents):void 0}}},ru),cu=r({},ru,su,nu,ou,au,lu,uu,hu,du,vu,{conversations:class{constructor(t){this._instance=t,this._f=void 0,this._conversationsManager=null,this.wf=!1,this.re=null,this.kf=!1}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!this._instance.config.disable_conversations&&(this.Sf=t.ok,t.ok)){var i=t.config.conversations;Ei(i)||(Ti(i)?this._f=i:(this._f=i.enabled,this.re=i),this.loadIfEnabled())}}reset(){var t;null==(t=this._conversationsManager)||t.reset(),this._conversationsManager=null,this._f=void 0,this.re=null,this.Sf=void 0,this.kf=!1}loadIfEnabled(){if(!(this._conversationsManager||this.wf||this._instance.config.disable_conversations||As(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var t=null==ni?void 0:ni.__PosthogExtensions__;if(t&&!wi(this._f)&&this._f)if(this.re&&this.re.token){this.wf=!0;try{var i=t.initConversations;if(i)return this.xf(i),void(this.wf=!1);var e=t.loadExternalDependency;if(!e)return void this.Cf(jt);e(this._instance,"conversations",i=>{i||!t.initConversations?this.Cf("Could not load conversations script",i):this.xf(t.initConversations),this.wf=!1})}catch(t){this.Cf("Error initializing conversations",t),this.wf=!1}}else Jh.error("Conversations enabled but missing token in remote config.")}}xf(t){if(this.re)try{this._conversationsManager=t(this.re,this._instance),this.kf=!1,Jh.info("Conversations loaded successfully")}catch(t){this.Cf("Error completing conversations initialization",t)}else Jh.error("Cannot complete initialization: remote config is null")}Cf(t,i){Jh.error(t,i),this._conversationsManager=null,this.wf=!1,this.kf=!0}show(){this._conversationsManager?this._conversationsManager.show():Jh.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this._f&&!ki(this._conversationsManager)}getUnavailableReason(){return this.isAvailable()?null:this._instance.config.disable_conversations?"disabled_by_config":As(this._instance.config)?"disabled_for_toolbar":this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut()?"consent_opted_out":!1===this.Sf?"remote_config_failed":wi(this._f)?this.Sf?"disabled_in_project":"remote_config_pending":this._f?Ei(this.re)||!this.re.token?"missing_token":null!=ni&&ni.__PosthogExtensions__?this.wf?"initializing":this.kf?"load_failed":"not_loaded":"extensions_unavailable":"disabled_in_project"}isVisible(){var t,i;return null!==(t=null==(i=this._conversationsManager)?void 0:i.isVisible())&&void 0!==t&&t}sendMessage(t,i,e){var r=this;return n(function*(){return r._conversationsManager?r._conversationsManager.sendMessage(t,i,e):(Jh.warn(Xh),null)})()}getMessages(t,i){var e=this;return n(function*(){return e._conversationsManager?e._conversationsManager.getMessages(t,i):(Jh.warn(Xh),null)})()}markAsRead(t){var i=this;return n(function*(){return i._conversationsManager?i._conversationsManager.markAsRead(t):(Jh.warn(Xh),null)})()}getTickets(t){var i=this;return n(function*(){return i._conversationsManager?i._conversationsManager.getTickets(t):(Jh.warn(Xh),null)})()}requestRestoreLink(t){var i=this;return n(function*(){return i._conversationsManager?i._conversationsManager.requestRestoreLink(t):(Jh.warn(Xh),null)})()}restoreFromToken(t){var i=this;return n(function*(){return i._conversationsManager?i._conversationsManager.restoreFromToken(t):(Jh.warn(Xh),null)})()}restoreFromUrlToken(){var t=this;return n(function*(){return t._conversationsManager?t._conversationsManager.restoreFromUrlToken():(Jh.warn(Xh),null)})()}getCurrentTicketId(){var t,i;return null!==(t=null==(i=this._conversationsManager)?void 0:i.getCurrentTicketId())&&void 0!==t?t:null}getWidgetSessionId(){var t,i;return null!==(t=null==(i=this._conversationsManager)?void 0:i.getWidgetSessionId())&&void 0!==t?t:null}ih(){var t;null==(t=this._conversationsManager)||t.setIdentity()}rh(){var t;null==(t=this._conversationsManager)||t.clearIdentity()}}},{logs:class{constructor(t){var i,e=this;this._instance=t,this.name="logs",this.Tf=!1,this.Mf=!1,this.If=!1,this.A=bs("[logs]"),this.Ef=r({},this.A,{error(){for(var t=arguments.length,i=new Array(t),r=0;t>r;r++)i[r]=arguments[r];i.some(eu)||e.A.error(...i)}}),this.Za=[],this.Rf=[],this.Wd=0,this.fo=!1,this.Af=[],this.Pf=[],this.Ff=!1,this.Of=!1,this.$f=()=>{var t,i;this.fo||(this.Wd=0,null==(t=this.Df)||t.onReconnect(),null==(i=this.Lf)||i.onReconnect())},this._instance&&null!=(i=this._instance.config.logs)&&i.captureConsoleLogs&&(this.Tf=!0),Gt&&Fs(Gt,"online",this.$f)}Nf(t,i,e,r){var s,n=Yh(null==(s=this._instance)||null==(s=s.config)?void 0:s.logs,e);return[new vs(this.qf(t,i),n,this.Ef,()=>this.jf(),t=>t(),void 0,r),n]}Bf(){var t,i=null==(t=this._instance)||null==(t=t.config)?void 0:t.logs;if(!this.Df||this.Hf!==i){var e;null==(e=this.Df)||e.reset(),this.Hf=i;var r=this.Nf(()=>this.Za,t=>{this.Za=t});this.Df=r[0],this.zf=r[1]}return this.Df}Uf(){var t,i=null==(t=this._instance)||null==(t=t.config)?void 0:t.logs;if(!this.Lf||this.Wf!==i){var e;null==(e=this.Lf)||e.reset(),this.Wf=i;var r=this.Nf(()=>this.Rf,t=>{this.Rf=t},{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},Qh);this.Lf=r[0],this.Vf=r[1]}return this.Lf}setup(t){var i;if(!this.fo){this.ao=t,null!=(i=this._instance)&&null!=(i=i.config)&&null!=(i=i.logs)&&i.captureConsoleLogs&&(this.Tf=!0),(this.Tf||this.Gf()&&this.Zf())&&this.Jf();var e=!1,r=t.onRemoteConfig(t=>{var i;e=t.ok&&!0===(null==(i=t.config.logs)?void 0:i.captureConsoleLogs),this.onRemoteConfig(t)});this.fo?r.dispose():(this.yo=r,e||this.loadIfEnabled())}}dispose(){var t,i,e,r;this.fo||(this.fo=!0,this.Qf(),null==(t=this.yo)||t.dispose(),this.yo=void 0,this.ao=void 0,this.If=!1,null==Gt||Gt.removeEventListener("online",this.$f),null==(i=this.Kf)||i.call(this),this.Kf=void 0,null==(e=this.Df)||e.reset(),null==(r=this.Lf)||r.reset())}onRemoteConfig(t){var i,e;if(!this.fo){var r=t.ok?null==(i=t.config.logs)?void 0:i.captureConsoleLogs:void 0;Ei(r)?this.Xf():(null==(e=this._instance)||null==(e=e.persistence)||e.register({[P]:!!r}),r?(this.Tf=!0,this.Mf||this.Jf(),this.loadIfEnabled()):this.Xf())}}reset(){var t,i,e,r;this.Qf(),null==(t=this.Df)||t.clearQueue(),this.Za=[],null==(i=this.Df)||i.reset(),null==(e=this.Lf)||e.clearQueue(),this.Rf=[],null==(r=this.Lf)||r.reset(),this.Wd=0}captureLog(t){this.fo||this.Bf().captureLog(t)}captureConsoleLog(t){this.fo||this.Uf().captureLog(t)}captureBufferedConsoleLog(t,i,e){this.fo||this.Uf().captureLog(t,{context:i,occurredAtMs:e})}Zf(){var t;return!(null==(t=this._instance)||null==(t=t.persistence)||null==(t=t.props)||!t[P])}Gf(){var t,i;return null==(t=this._instance)||null==t.Ua||!t.Ua()||!(null==(i=ni._POSTHOG_REMOTE_CONFIG)||null==(i=i[this._instance.config.token])||!i.config)}sh(){var t;this.Qf(),null==(t=this.Lf)||t.clearQueue(),this.Rf=[]}Xf(){this.Tf||this.Qf()}Jf(){var t,i=this;if(!this.Ff&&null!=ni&&ni.console){var e=Yh(null==(t=this._instance)||null==(t=t.config)?void 0:t.logs).maxBufferSize,r=function(t){var r;try{r=(t=>{for(;null!=(i=t)&&i.__rrweb_original__;){var i;t=t.__rrweb_original__}return t})(ni.console[t])}catch(t){return 0}if(!r)return 0;i.Pf.push(sh(ni.console,t,s=>{var n=function(){for(var r=arguments.length,n=new Array(r),o=0;r>o;o++)n[o]=arguments[o];try{i.Yf(t,n,e)}catch(t){}return s.apply(ni.console,n)};return n.__rrweb_original__=r,n}))};for(var s of Zh)r(s);this.Ff=!0,this.tp=setTimeout(()=>{this.Qf()},3e4)}}Yf(t,i,e){var r;if(this.Ff&&!this.Of&&0!==i.length)if(null!=(r=this._instance)&&r.is_capturing()){if(e>this.Af.length){this.Of=!0;try{this.Af.push({level:t,args:i,occurredAtMs:Date.now(),context:this.jf()})}finally{this.Of=!1}}}else this.Qf()}Qf(){if(this.Af=[],this.Ff){for(var t of(this.Ff=!1,this.tp&&(clearTimeout(this.tp),this.tp=void 0),this.Pf))t();this.Pf=[]}}ep(){var t=this.Af;return this.Qf(),t}get logger(){return this.rp||(this.rp={trace:(t,i)=>this.captureLog({body:t,level:"trace",attributes:i}),debug:(t,i)=>this.captureLog({body:t,level:"debug",attributes:i}),info:(t,i)=>this.captureLog({body:t,level:"info",attributes:i}),warn:(t,i)=>this.captureLog({body:t,level:"warn",attributes:i}),error:(t,i)=>this.captureLog({body:t,level:"error",attributes:i}),fatal:(t,i)=>this.captureLog({body:t,level:"fatal",attributes:i})}),this.rp}flushLogs(t){t?this.np(t):(this.Df&&this.Df.flush().catch(t=>this.sp(t)),this.Lf&&this.Lf.flush().catch(t=>this.sp(t)))}sp(t){eu(t)||this.A.error("PostHog logs flush failed:",t)}loadIfEnabled(){if(!this.fo&&this.Tf&&!this.Mf&&!this.If){var t=null==ni?void 0:ni.__PosthogExtensions__;if(!t)return this.A.error("PostHog Extensions not found."),void this.Qf();var i=t.loadExternalDependency;if(!i)return this.A.error(jt),void this.Qf();this.If=!0;try{i(this._instance,"logs",i=>{if(this.If=!1,!this.fo&&this.Tf){var e=t.logs;if(i||null==e||!e.initializeLogs)this.A.error("Could not load logs script",i),this.Qf();else{var r,s,n=this.ep();this.Kf=e.initializeLogs(null!==(r=this.ao)&&void 0!==r?r:this._instance),this.Mf=!0,n.length>0&&(null==e.replayConsoleBuffer||e.replayConsoleBuffer(null!==(s=this.ao)&&void 0!==s?s:this._instance,n))}}})}catch(t){throw this.If=!1,t}}}qf(t,i){var e=this._instance;return{get isDisabled(){return!1},get optedOut(){return!e.is_capturing()},getPersistedProperty:i=>i===oi.LogsQueue?t():void 0,setPersistedProperty(t,e){t===oi.LogsQueue&&i(null!=e?e:[])},As:t=>this.As(t),getLibraryId:()=>l.LIB_NAME,getLibraryVersion:()=>l.LIB_VERSION}}As(t){return new Promise(i=>{if(co(this.Wd,3))i({kind:"fatal",error:iu(void 0,"logs endpoint is unreachable, dropping batch")});else{var e=!1,r=t=>{e||(e=!0,clearTimeout(s),i(t))},s=setTimeout(()=>{this.A.warn("Logs request timed out before receiving a response"),r({kind:"retry-later",error:iu(void 0,"logs request timed out")})},9e4);this._instance._send_request({method:"POST",url:this.op(),data:t,compression:"best-available",batchKey:"logs",fireCallbackOnDrop:!0,callback:t=>{var i=t.statusCode;if(this.ap(i),i>=200&&300>i)r({kind:"ok"});else if(413===i)r({kind:"too-large"});else if(0!==i&&408!==i&&429!==i&&500>i)r({kind:"fatal",error:new Error("logs request failed with status "+i)});else{var e;0===i?(t.error||this.A.warn("Logs request failed before receiving an HTTP response"),r({kind:"retry-later",error:iu(t.error,"logs request failed before receiving an HTTP response")})):r({kind:"retry-later",error:null!==(e=t.error)&&void 0!==e?e:new Error("logs request failed with status "+i)})}}})}})}ap(t){(0!==t||this._instance.__loaded)&&(this.Wd=fo(t,this.Wd,3,()=>this.A.warn("Log requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped sending logs; will try again when connectivity changes.")))}np(t){this.Za.length>0&&this.lp(t,this.Za,this.zf,l.LIB_NAME,t=>{this.Za=t}),this.Rf.length>0&&this.lp(t,this.Rf,this.Vf,Qh,t=>{this.Rf=t})}lp(t,i,e,r,s){if(0!==i.length){var n=i.map(t=>t.record);s([]);var o=ds(n,us(e,l.LIB_NAME,l.LIB_VERSION),r,l.LIB_VERSION);this._instance._send_request({method:"POST",url:this.op(),data:o,compression:"best-available",batchKey:"logs",transport:t})}}op(){return this._instance.requestRouter.endpointFor("api","/i/v1/logs")+"?token="+encodeURIComponent(this._instance.config.token)}jf(){var t,i={};if(i.distinctId=this._instance.get_distinct_id(),this._instance.sessionManager){var e=this._instance.sessionManager.checkAndGetSessionAndWindowId(!0),r=e.windowId,s=e.sessionStartTimestamp,n=e.lastActivityTimestamp;i.sessionId=e.sessionId,i.windowId=r,Ei(s)||(i.sessionStartTimestamp=s),Ei(n)||(i.lastActivityTimestamp=n)}if(null!=ni&&null!=(t=ni.location)&&t.href&&(i.currentUrl=this._instance.config.disable_capture_url_hashes?tr(ni.location.href):ni.location.href),this._instance.featureFlags){var o=this._instance.featureFlags.getFlags();o&&o.length>0&&(i.activeFeatureFlags=o)}return i}}},{metrics:class{constructor(t){this._instance=t,this.A=bs("[metrics]")}initialize(){}Bf(){var t,i,e=null==(t=this._instance)||null==(t=t.config)?void 0:t.metrics;return this.Df&&this.Hf===e||(null==(i=this.Df)||i.reset(),this.Hf=e,this.Df=new gs(this.qf(),function(t){var i,e,r,s,n,o=null==t?void 0:t.resourceAttributes;return{serviceName:null!==(i=null==o?void 0:o["service.name"])&&void 0!==i?i:null==t?void 0:t.serviceName,serviceVersion:null!==(e=null==o?void 0:o["service.version"])&&void 0!==e?e:null==t?void 0:t.serviceVersion,environment:null!==(r=null==o?void 0:o["deployment.environment"])&&void 0!==r?r:null==t?void 0:t.environment,resourceAttributes:o,beforeSend:null==t?void 0:t.beforeSend,flushIntervalMs:null!==(s=null==t?void 0:t.flushIntervalMs)&&void 0!==s?s:1e4,maxSeriesPerFlush:null!==(n=null==t?void 0:t.maxSeriesPerFlush)&&void 0!==n?n:1e3}}(e),this.A)),this.Df}count(t,i,e){void 0===i&&(i=1),this.Bf().count(t,i,e)}gauge(t,i,e){this.Bf().gauge(t,i,e)}histogram(t,i,e){this.Bf().histogram(t,i,e)}flush(t){if(!this.Df)return Promise.resolve();if(t){var i=this.Df.drainWindow();return i&&this.Gs(i,t),Promise.resolve()}return this.Df.flush().catch(t=>this.A.error("PostHog metrics flush failed:",t))}reset(){var t;null==(t=this.Df)||t.reset()}qf(){var t=this._instance,i=this;return{get isDisabled(){return!1},get optedOut(){return!t.is_capturing()},Gs:t=>i.Gs(t),getLibraryId:()=>l.LIB_NAME,getLibraryVersion:()=>l.LIB_VERSION}}Gs(t,i){return new Promise(e=>{var s=!1,n=t=>{s||(s=!0,clearTimeout(o),e(t))},o=setTimeout(()=>n({kind:"retry-later",error:new Error("metrics request timed out")}),9e4);this._instance._send_request(r({method:"POST",url:this.up(),data:t,compression:"best-available",batchKey:"metrics"},i&&{transport:i},{fireCallbackOnDrop:!0,callback(t){var i,e=t.statusCode;n(e>=200&&300>e?{kind:"ok"}:413===e?{kind:"too-large"}:0!==e&&408!==e&&429!==e&&500>e?{kind:"fatal",error:new Error("metrics request failed with status "+e)}:{kind:"retry-later",error:null!==(i=t.error)&&void 0!==i?i:new Error("metrics request failed with status "+e)})}}))})}up(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}}});Wl.__defaultExtensionClasses=r({},cu)}()}();
1
+ !function(){var t=["retriesPerformedSoFar"],i=["$set_once","$set"];function e(t,i){if(null==t)return{};var e={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(-1!==i.indexOf(r))continue;e[r]=t[r]}return e}function r(){return r=Object.assign?Object.assign.bind():function(t){for(var i=1;arguments.length>i;i++){var e=arguments[i];for(var r in e)({}).hasOwnProperty.call(e,r)&&(t[r]=e[r])}return t},r.apply(null,arguments)}function s(t,i,e,r,s,n,o){try{var a=t[n](o),l=a.value}catch(t){return void e(t)}a.done?i(l):Promise.resolve(l).then(r,s)}function n(t){return function(){var i=this,e=arguments;return new Promise(function(r,n){var o=t.apply(i,e);function a(t){s(o,r,n,a,l,"next",t)}function l(t){s(o,r,n,a,l,"throw",t)}a(void 0)})}}!function(s){var o="0.8.2",a={DEBUG:(!1,!1),LIB_VERSION:(o,"1.429.1"),LIB_NAME:("browser-common","web"),JS_SDK_VERSION:o},l=a,h="$people_distinct_id",u="distinct_id",d="$device_id",v="$device_model",c="__alias",f="__cmpns",p="$fbc",g="$fbc_persistence",_="__timers",m="$autocapture_disabled_server_side",b="$heatmaps_enabled_server_side",y="$exception_capture_enabled_server_side",w="$error_tracking_suppression_rules",x="$error_tracking_capture_extension_exceptions",S="$web_vitals_enabled_server_side",k="$dead_clicks_enabled_server_side",E="$product_tours_enabled_server_side",P="$logs_capture_enabled_server_side",T="$web_vitals_allowed_metrics",C="$session_recording_remote_config",F="$session_recording_enabled_server_side",A="$replay_sample_rate",I="$replay_override_sampling",R="$replay_override_linked_flag",O="$replay_override_url_trigger",M="$replay_override_event_trigger",D="$sesid",j="$session_is_sampled",B="$session_past_minimum_duration",L="$session_recording_url_trigger_activated_session",N="$session_recording_event_trigger_activated_session",z="$debug_first_full_snapshot_timestamp",U="$sess_rec_flush_size",H="$enabled_feature_flags",q="$active_feature_flags",V="$early_access_features",W="$feature_flag_details",G="$feature_flag_payloads",K="$feature_flag_request_id",J="$minimal_flag_called_events",X="$override_feature_flags",Y="$override_feature_flag_payloads",Z="$stored_person_properties",Q="$stored_group_properties",tt="$groups",it="$surveys",et="$surveys_loaded_at",rt="$surveys_activated",st="$surveys_activated_session",nt="$surveys_activated_timestamps",ot="ph_product_tours",at="$product_tours_activated",lt="$product_tours_activated_session",ht="$conversations_widget_session_id",ut="$conversations_ticket_id",dt="$conversations_widget_state",vt="$conversations_user_traits",ct="$flag_call_reported",ft="$flag_call_reported_session_id",pt="$feature_flag_errors",gt="$feature_flag_evaluated_at",_t="$user_state",mt="$client_session_props",bt="$capture_rate_limit",yt="$initial_campaign_params",wt="$initial_referrer_info",xt="$initial_person_info",St="$epp",kt="$posthog_cookieless",Et="$cookieless_mode",$t="$sdk_debug_extensions_init_method",Pt="$sdk_debug_extensions_init_time_ms",Tt="$sdk_debug_recording_script_not_loaded",Ct="$sdk_debug_replay_event_trigger_status",Ft="$sdk_debug_replay_linked_flag_trigger_status",At="$sdk_debug_replay_matched_recording_trigger_groups",It="$sdk_debug_replay_pending_trigger_conditions",Rt="$sdk_debug_replay_remote_trigger_matching_config",Ot="$sdk_debug_replay_trigger_groups_count",Mt="$sdk_debug_replay_url_trigger_status",Dt="$session_recording_start_reason",jt="PostHog loadExternalDependency extension not found.",Bt="anonymous",Lt="identified",Nt="identified_only",zt="visibilitychange",Ut="beforeunload",Ht="$pageview",qt="$pageleave",Vt="$identify",Wt="$groupidentify",Gt="u">typeof window?window:void 0,Kt="u">typeof globalThis?globalThis:Gt,Jt=null==Kt?void 0:Kt.navigator,Xt=null==Kt?void 0:Kt.document,Yt=null==Kt?void 0:Kt.location,Zt=null==Kt?void 0:Kt.fetch,Qt=null!=Kt&&Kt.XMLHttpRequest&&"withCredentials"in new Kt.XMLHttpRequest?Kt.XMLHttpRequest:void 0,ti=null==Kt?void 0:Kt.AbortController,ii=null==Kt?void 0:Kt.CompressionStream,ei=null==Jt?void 0:Jt.userAgent;function ri(){return!(!Gt||!1===Gt.navigator.onLine)}var si="undefined"!=typeof globalThis?globalThis:Gt;si&&"undefined"==typeof self&&(si.self=si),si&&"undefined"==typeof File&&(si.File=function(){});var ni=null!=Gt?Gt:{},oi=function(t){return t.AnonymousId="anonymous_id",t.DistinctId="distinct_id",t.Props="props",t.EnablePersonProcessing="enable_person_processing",t.PersonMode="person_mode",t.FeatureFlagDetails="feature_flag_details",t.FeatureFlags="feature_flags",t.FeatureFlagPayloads="feature_flag_payloads",t.BootstrapFeatureFlagDetails="bootstrap_feature_flag_details",t.BootstrapFeatureFlags="bootstrap_feature_flags",t.BootstrapFeatureFlagPayloads="bootstrap_feature_flag_payloads",t.OverrideFeatureFlags="override_feature_flags",t.Queue="queue",t.AiQueue="ai_queue",t.AiCaptureQueue="ai_capture_queue",t.LogsQueue="logs_queue",t.OptedOut="opted_out",t.SessionId="session_id",t.SessionStartTimestamp="session_start_timestamp",t.SessionLastTimestamp="session_timestamp",t.PersonProperties="person_properties",t.GroupProperties="group_properties",t.InstalledAppBuild="installed_app_build",t.InstalledAppVersion="installed_app_version",t.SessionReplay="session_replay",t.PushRegistered="push_registered",t.SessionReplayEventTriggerActivatedSession="session_replay_event_trigger_activated_session",t.SurveyLastSeenDate="survey_last_seen_date",t.SurveysSeen="surveys_seen",t.Surveys="surveys",t.RemoteConfig="remote_config",t.FlagsEndpointWasHit="flags_endpoint_was_hit",t.DeviceId="device_id",t}({}),ai=function(t){return t.GZipJS="gzip-js",t.Base64="base64",t}({}),li=["$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"],hi=["token"];function ui(t,i){return-1!==t.indexOf(i)}var di=function(t){return t.trim()},vi=function(t){return t.replace(/^\$/,"")};function ci(t){var i,e=[];return null!==(i=JSON.stringify(t,function(t,i){if("bigint"==typeof i)return i.toString();if("function"!=typeof i&&"symbol"!=typeof i){if(i instanceof Error)return{name:i.name,message:i.message,stack:i.stack};if(i&&"object"==typeof i){for(;e.length>0&&e[e.length-1]!==this;)e.pop();if(e.includes(i))return"[Circular]";e.push(i)}return i}}))&&void 0!==i?i:"null"}var fi=Object.prototype,pi=fi.hasOwnProperty,gi=fi.toString,_i=Array.isArray||function(t){return"[object Array]"===gi.call(t)},mi=t=>"function"==typeof t,bi=t=>t===Object(t)&&!_i(t),yi=t=>{if(bi(t)){for(var i in t)if(pi.call(t,i))return!1;return!0}return!1},wi=t=>void 0===t,xi=t=>"[object String]"==gi.call(t),Si=t=>xi(t)&&0===t.trim().length,ki=t=>null===t,Ei=t=>wi(t)||ki(t),$i=t=>"[object Number]"==gi.call(t)&&t==t,Pi=t=>$i(t)&&t>0,Ti=t=>"[object Boolean]"===gi.call(t),Ci=t=>ui(li,t),Fi=t=>ui(hi,t);function Ai(t){return null===t||"object"!=typeof t}function Ii(t,i){return{}.toString.call(t)==="[object "+i+"]"}function Ri(t){switch({}.toString.call(t)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object DOMError]":case"[object WebAssembly.Exception]":return!0;default:return Mi(t,Error)}}function Oi(t){return"u">typeof Event&&Mi(t,Event)}function Mi(t,i){try{return t instanceof i}catch(t){return!1}}var Di=[!0,"true",1,"1","yes"],ji=t=>ui(Di,t),Bi=[!1,"false",0,"0","no"],Li=["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"],Ni=function(t,i){if(void 0===i&&(i=[]),!t)return!1;var e=t.toLowerCase();return Li.concat(i).some(t=>{var i=t.toLowerCase();return-1!==e.indexOf(i)})};function zi(t,i,e,r,s){return i>e&&(r.warn("min cannot be greater than max."),i=e),$i(t)?t>e?(r.warn(" cannot be greater than max: "+e+". Using max value instead."),e):i>t?(r.warn(" cannot be less than min: "+i+". Using min value instead."),i):t:(r.warn(" must be a number. using max or fallback. max: "+e+", fallback: "+s),zi(null!=s?s:e,i,e,r))}var Ui=class{constructor(t){this.C={},this.I=t.I,this.R=zi(t.bucketSize,0,100,t.A),this.O=zi(t.refillRate,0,this.R,t.A),this.N=zi(t.refillInterval,0,864e5,t.A)}F(t,i){var e=Math.floor((i-t.lastAccess)/this.N);e>0&&(t.tokens=Math.min(t.tokens+e*this.O,this.R),t.lastAccess=t.lastAccess+e*this.N)}consumeRateLimit(t){var i,e=Date.now(),r=String(t),s=this.C[r];return s?this.F(s,e):this.C[r]=s={tokens:this.R,lastAccess:e},0===s.tokens||(s.tokens--,0===s.tokens&&(null==(i=this.I)||i.call(this,t)),0===s.tokens)}stop(){this.C={}}},Hi="Mobile",qi="Android",Vi="Tablet",Wi="Android Tablet",Gi="iPad",Ki="Apple Watch",Ji="Safari",Xi="BlackBerry",Yi="Samsung Internet",Zi="Chrome",Qi="Chrome iOS",te="Internet Explorer",ie="Internet Explorer Mobile",ee="Opera",re="Microsoft Edge",se="Firefox",ne="Firefox iOS",oe="Nintendo",ae="PlayStation",le="Xbox",he="Android Mobile",ue="Mobile Safari",de="Windows",ve="Windows Phone",ce="Nokia",fe="Ouya",pe="Generic "+Hi.toLowerCase(),ge="Generic "+Vi.toLowerCase(),_e="Konqueror",me="Oculus Browser",be="Vivaldi",ye="Yandex",we="Whale",xe="DuckDuckGo",Se="Pale Moon",ke="Waterfox",Ee="Brave",$e="Claude",Pe="Codex",Te="ChatGPT",Ce="Google Search App",Fe=new RegExp("Version/(\\d+(\\.\\d+)?)"),Ae=new RegExp("(Claude|Codex|ChatGPT)\\/(\\d+(\\.\\d+)?)"),Ie=new RegExp(le,"i"),Re=new RegExp("PlayStation \\w+","i"),Oe=new RegExp("Nintendo \\w+","i"),Me=new RegExp("BlackBerry|PlayBook|BB10","i"),De={"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"},je=function(t,i,e,r){i=i||"";var s=function(t){return null!=t&&t.brave?Ee:null}(e);return s||(null!=r&&r.detectGoogleSearchApp&&ui(t,"GSA/")?Ce:ui(t," OPR/")&&ui(t,"Mini")?"Opera Mini":ui(t," OPR/")?ee:Me.test(t)?Xi:ui(t,"IEMobile")||ui(t,"WPDesktop")?ie:ui(t,"OculusBrowser")?me:ui(t,"SamsungBrowser")?Yi:ui(t,"Edge")||ui(t,"Edg/")?re:ui(t,"Vivaldi/")?be:ui(t,"YaBrowser/")?ye:ui(t,"Whale/")?we:ui(t,"DuckDuckGo/")||ui(t,"Ddg/")?xe:ui(t,"Claude/")?$e:ui(t,"Codex/")?Pe:ui(t,"ChatGPT/")?Te:ui(t,"FBIOS")?"Facebook Mobile":ui(t,"UCWEB")||ui(t,"UCBrowser")?"UC Browser":ui(t,"CriOS")?Qi:ui(t,"CrMo")||ui(t,Zi)?Zi:ui(t,qi)&&ui(t,Ji)?he:ui(t,"FxiOS")?ne:ui(t.toLowerCase(),_e.toLowerCase())?_e:ui(t,"Brave/")?Ee:((t,i)=>i&&ui(i,"Apple")||function(t){return ui(t,Ji)&&!ui(t,Zi)&&!ui(t,qi)}(t))(t,i)?ui(t,Hi)?ue:Ji:ui(t,"PaleMoon/")?Se:ui(t,"Waterfox/")?ke:ui(t,se)?se:ui(t,"MSIE")||ui(t,"Trident/")?te:ui(t,"Gecko")?se:"")},Be={[ie]:[new RegExp("rv:(\\d+(\\.\\d+)?)")],[re]:[new RegExp("Edge?\\/(\\d+(\\.\\d+)?)")],[Zi]:[new RegExp("(Chrome|CrMo)\\/(\\d+(\\.\\d+)?)")],[Qi]:[new RegExp("CriOS\\/(\\d+(\\.\\d+)?)")],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/(\\d+(\\.\\d+)?)")],[Ji]:[Fe],[ue]:[Fe],[ee]:[new RegExp("(Opera|OPR)\\/(\\d+(\\.\\d+)?)")],[se]:[new RegExp("Firefox\\/(\\d+(\\.\\d+)?)")],[ne]:[new RegExp("FxiOS\\/(\\d+(\\.\\d+)?)")],[_e]:[new RegExp("Konqueror[:/]?(\\d+(\\.\\d+)?)","i")],[Xi]:[new RegExp("BlackBerry (\\d+(\\.\\d+)?)"),Fe],[he]:[new RegExp("android\\s(\\d+(\\.\\d+)?)","i")],[Yi]:[new RegExp("SamsungBrowser\\/(\\d+(\\.\\d+)?)")],[me]:[new RegExp("OculusBrowser\\/(\\d+(\\.\\d+)?)")],[be]:[new RegExp("Vivaldi\\/(\\d+(\\.\\d+)?)")],[ye]:[new RegExp("YaBrowser\\/(\\d+(\\.\\d+)?)")],[we]:[new RegExp("Whale\\/(\\d+(\\.\\d+)?)")],[Ee]:[new RegExp("Brave\\/(\\d+(\\.\\d+)?)")],[$e]:[Ae],[Pe]:[Ae],[Te]:[Ae],[xe]:[new RegExp("(DuckDuckGo|Ddg)\\/(\\d+(\\.\\d+)?)")],[Se]:[new RegExp("PaleMoon\\/(\\d+(\\.\\d+)?)")],[ke]:[new RegExp("Waterfox\\/(\\d+(\\.\\d+)?)")],[Ce]:[new RegExp("GSA\\/(\\d+(\\.\\d+)?)")],[te]:[new RegExp("(rv:|MSIE )(\\d+(\\.\\d+)?)")],Mozilla:[new RegExp("rv:(\\d+(\\.\\d+)?)")]},Le=function(t,i,e,r){var s=Be[je(t,i,e,r)];if(wi(s))return null;for(var n=0;s.length>n;n++){var o=t.match(s[n]);if(o)return parseFloat(o[o.length-2])}return null},Ne=[[new RegExp("Xbox; Xbox (.*?)[);]","i"),t=>[le,t&&t[1]||""]],[new RegExp(oe,"i"),[oe,""]],[new RegExp(ae,"i"),[ae,""]],[Me,[Xi,""]],[new RegExp(de,"i"),(t,i)=>{if(/Phone/.test(i)||/WPDesktop/.test(i))return[ve,""];if(new RegExp(Hi).test(i)&&!/IEMobile\b/.test(i))return["Windows Mobile",""];var e=/Windows NT ([0-9.]+)/i.exec(i);if(e&&e[1]){var r=De[e[1]]||"";return/arm/i.test(i)&&(r="RT"),[de,r]}return[de,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,t=>t&&t[3]?["iOS",[t[3],t[4],t[5]||"0"].join(".")]:["iOS",""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,t=>{var i="";return t&&t.length>=3&&(i=wi(t[2])?t[3]:t[2]),["watchOS",i]}],[new RegExp("(Android (\\d+)\\.(\\d+)\\.?(\\d+)?|Android)","i"),t=>t&&t[2]?[qi,[t[2],t[3],t[4]||"0"].join(".")]:[qi,""]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,t=>{var i=["Mac OS X",""];return t&&t[1]&&(i[1]=[t[1],t[2],t[3]||"0"].join(".")),i}],[/Mac/i,["Mac OS X",""]],[/CrOS/,["Chrome OS",""]],[/Linux|debian/i,["Linux",""]]],ze=function(t){for(var i=0;Ne.length>i;i++){var e=Ne[i],r=e[1],s=e[0].exec(t),n=s&&(mi(r)?r(s,t):r);if(n)return n}return["",""]},Ue=function(t){return Oe.test(t)?oe:Re.test(t)?ae:Ie.test(t)?le:new RegExp(fe,"i").test(t)?fe:new RegExp("(Windows Phone|WPDesktop)","i").test(t)?ve:/iPad/.test(t)?Gi:/iPod/.test(t)?"iPod Touch":/iPhone/.test(t)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(t)?Ki:Me.test(t)?Xi:/(kobo)\s(ereader|touch)/i.test(t)?"Kobo":new RegExp(ce,"i").test(t)?ce:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(t)||/(kf[a-z]+)( bui|\)).+silk\//i.test(t)?"Kindle Fire":/(Android|ZTE)/i.test(t)?new RegExp(Hi).test(t)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(t)||/pixel[\daxl ]{1,6}/i.test(t)&&!/pixel c/i.test(t)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(t)||/lmy47v/i.test(t)&&!/QTAQZ3/i.test(t)?qi:Wi:new RegExp("(pda|Mobile)","i").test(t)?pe:new RegExp(Vi,"i").test(t)&&!new RegExp("Tablet pc","i").test(t)?ge:""},He=/\bFBAV\/(\d+(?:\.\d+)*)/i,qe=[[/\bInstagram(?:[ /](\d+(?:\.\d+)*))?\b/i,"Instagram"],[/\bBarcelona[ /](\d+(?:\.\d+)*)?/i,"Threads"],[/\b(?:MessengerForiOS|(?:FBAN|FB_IAB)\/Orca-Android)\b/i,"Messenger",He],[/\bFBAN\/EMA\b/i,"Facebook Lite",He],[/\b(?:FBIOS|(?:FBAN|FB_IAB)\/(?:FB4A|FBIOS))\b/i,"Facebook",He],[/\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"]],Ve="[Truncated]",We="[Unserializable]";function Ge(t){for(var i="",e=0;t.length>e;e++){var r=t.charCodeAt(e);if(55296>r||r>56319)i+=56320>r||r>57343?t[e]:"�";else{var s=t.charCodeAt(e+1);56320>s||s>57343?i+="�":(i+=t[e]+t[e+1],e++)}}return i}Date,Date;var Ke,Je,Xe,Ye=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function Ze(t,i){return"string"==typeof(e=t)&&Ye.test(e)?t:i();var e}function Qe(t,i){var e=new Error(i);try{Object.defineProperty(e,"name",{value:t,writable:!0,enumerable:!0,configurable:!0})}catch(t){}return e}function tr(t){return t?t.split("#")[0]:t}function ir(t,i){var e=setTimeout(t,i);return null!=e&&e.unref&&(null==e||e.unref()),e}function er(t,i,e){return rr.apply(this,arguments)}function rr(){return(rr=n(function*(t,i,e){var r;try{return yield Promise.race([t,new Promise((t,s)=>{r=ir(()=>{try{null==e||e(),t()}catch(t){s(t)}},i)})])}finally{clearTimeout(r)}})).apply(this,arguments)}function sr(t){var i=globalThis._posthogChunkIds;if(i){var e=Object.keys(i);return Xe&&e.length===Je?Xe:(Je=e.length,Xe=e.reduce((e,r)=>{Ke||(Ke={});var s=Ke[r];if(s)e[s[0]]=s[1];else for(var n=t(r),o=n.length-1;o>=0;o--){var a,l=null==(a=n[o])?void 0:a.filename,h=i[r];if(l&&h){e[l]=h,Ke[r]=[l,h];break}}return e},{}))}}var nr=class{constructor(t,i,e){void 0===e&&(e=[]),this.coercers=t,this.stackParser=i,this.modifiers=e}buildFromUnknown(t,i){void 0===i&&(i={});var e=i&&i.mechanism||{handled:!0,type:"generic"},r=this.buildCoercingContext(e,i,0).apply(t),s=this.buildParsingContext(i),n=this.parseStacktrace(r,s);return{$exception_list:this.convertToExceptionList(n,e),$exception_level:"error"}}modifyFrames(t){var i=this;return n(function*(){for(var e of t)e.stacktrace&&e.stacktrace.frames&&_i(e.stacktrace.frames)&&(e.stacktrace.frames=yield i.applyModifiers(e.stacktrace.frames));return t})()}coerceFallback(t){var i;return{type:"Error",value:"Unknown error",stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}parseStacktrace(t,i){var e,s;return null!=t.cause&&(e=this.parseStacktrace(t.cause,i)),""!=t.stack&&null!=t.stack&&(s=this.applyChunkIds(this.stackParser(t.stack,t.synthetic?i.skipFirstLines:0),i.chunkIdMap)),r({},t,{cause:e,stack:s})}applyChunkIds(t,i){return t.map(t=>(t.filename&&i&&(t.chunk_id=i[t.filename]),t))}applyCoercers(t,i){for(var e of this.coercers)if(e.match(t))return e.coerce(t,i);return this.coerceFallback(i)}applyModifiers(t){var i=this;return n(function*(){var e=t;for(var r of i.modifiers)e=yield r(e);return e})()}convertToExceptionList(t,i){var e,s,n,o={type:t.type,value:t.value,mechanism:{type:null!==(e=i.type)&&void 0!==e?e:"generic",handled:null===(s=i.handled)||void 0===s||s,synthetic:null!==(n=t.synthetic)&&void 0!==n&&n}};t.stack&&(o.stacktrace={type:"raw",frames:t.stack});var a=[o];return null!=t.cause&&a.push(...this.convertToExceptionList(t.cause,r({},i,{handled:!0}))),a}buildParsingContext(t){var i;return{chunkIdMap:sr(this.stackParser),skipFirstLines:null!==(i=t.skipFirstLines)&&void 0!==i?i:1}}buildCoercingContext(t,i,e){void 0===e&&(e=0);var s=(e,r)=>{if(4>=r){var s=this.buildCoercingContext(t,i,r);return this.applyCoercers(e,s)}};return r({},i,{syntheticException:0==e?i.syntheticException:void 0,mechanism:t,apply:t=>s(t,e),next:t=>s(t,e+1)})}};function or(t,i,e,r,s){var n={platform:t,filename:i,function:"<anonymous>"===e?"?":e,in_app:!!i&&!i.startsWith("webkit-masked-url://")&&"<anonymous>"!==i};return wi(r)||(n.lineno=r),wi(s)||(n.colno=s),n}var ar=(t,i)=>{var e=-1!==t.indexOf("safari-extension"),r=-1!==t.indexOf("safari-web-extension");return e||r?[-1!==t.indexOf("@")?t.split("@")[0]:"?",e?"safari-extension:"+i:"safari-web-extension:"+i]:[t,i]},lr=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,hr=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,ur=/\((\S*)(?::(\d+))(?::(\d+))\)/,dr=(t,i)=>{var e=lr.exec(t);if(e)return or(i,e[1],"?",+e[2],+e[3]);var r=hr.exec(t);if(r){if(r[2]&&0===r[2].indexOf("eval")){var s=ur.exec(r[2]);s&&(r[2]=s[1],r[3]=s[2],r[4]=s[3])}var n=ar(r[1]||"?",r[2]);return or(i,n[1],n[0],r[3]?+r[3]:void 0,r[4]?+r[4]:void 0)}},vr=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,cr=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,fr=(t,i)=>{var e=vr.exec(t);if(e){if(e[3]&&e[3].indexOf(" > eval")>-1){var r=cr.exec(e[3]);r&&(e[1]=e[1]||"eval",e[3]=r[1],e[4]=r[2],e[5]="")}var s=e[3],n=e[1]||"?",o=ar(n,s);return or(i,s=o[1],n=o[0],e[4]?+e[4]:void 0,e[5]?+e[5]:void 0)}},pr=/\(error: (.*)\)/;function gr(t,i){return t.filename===i.filename&&t.function===i.function&&t.module===i.module&&t.lineno===i.lineno&&t.colno===i.colno}function _r(t){for(var i=1;10>=i;i++){var e=t.length-2*i;if(0>e)break;for(var r=!0,s=0;i>s;s++)if(!gr(t[e+s],t[e+i+s])){r=!1;break}if(r){for(var n=0;i>n;n++)t[e+n]=t[e+i+n];return t.length=e+i,{start:e,length:i}}}}function mr(t,i){var e=i.start+i.length,r=yr(t,i);r&&t.splice(e+r===t.length?e:i.start,r)}function br(t,i){for(var e=i.start;e>0&&gr(t[e-1],t[e-1+i.length]);)e--;return i.start-e}function yr(t,i){for(var e=i.start+i.length,r=e;t.length>r&&gr(t[r],t[r-i.length]);)r++;return r-e}function wr(t,i){var e=i[0],r=t.length-(e?br(t,e):0);for(var s of i)r-=yr(t,s);return r}function xr(t,i,e){for(var r=0;t.length>r;r++){var s=t[(i+r)%t.length],n=t[(e+r)%t.length];if(s!==n)return n>s}return!1}var Sr=class{match(t){return this.isDOMException(t)||this.isDOMError(t)}coerce(t,i){var e=xi(t.stack);return{type:this.getType(t),value:this.getValue(t),stack:e?t.stack:void 0,cause:t.cause?i.next(t.cause):void 0,synthetic:!1}}getType(t){return this.isDOMError(t)?"DOMError":"DOMException"}getValue(t){var i=t.name||(this.isDOMError(t)?"DOMError":"DOMException");return t.message?i+": "+t.message:i}isDOMException(t){return Ii(t,"DOMException")}isDOMError(t){return Ii(t,"DOMError")}},kr=class{match(t){return Ri(t)}coerce(t,i){var e,r=this.getStack(t),s=void 0===r;return{type:this.getType(t),value:this.getMessage(t,i),stack:null!=r?r:null==(e=i.syntheticException)?void 0:e.stack,cause:t.cause?i.next(t.cause):void 0,synthetic:s}}getType(t){return t.name||t.constructor.name}getMessage(t,i){var e=t.message;return String(e.error&&"string"==typeof e.error.message?e.error.message:e)}getStack(t){return t.stacktrace||t.stack||void 0}},Er=class{match(t){return!!Ii(t,"ErrorEvent")&&(null!=t.error||this.un(t))}coerce(t,i){var e;if(null!=t.error)return i.apply(t.error);var s=i.apply(t.message);return r({},s,{stack:null!==(e=this.ln(t))&&void 0!==e?e:s.stack,synthetic:!0})}un(t){return xi(t.message)&&t.message.length>0}ln(t){var i,e,r=t,s=null!==(i=r.lineno)&&void 0!==i?i:0,n=null!==(e=r.colno)&&void 0!==e?e:0;if(xi(r.filename)&&0!==r.filename.length&&0!==s)return"Error\n at "+r.filename+":"+s+":"+n}},$r=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,Pr=class{match(t){return"string"==typeof t}coerce(t,i){var e,r=this.getInfos(t),s=r[0],n=r[1];return{type:null!=s?s:"Error",value:null!=n?n:t,stack:null==(e=i.syntheticException)?void 0:e.stack,synthetic:!0}}getInfos(t){var i="Error",e=t,r=t.match($r);return r&&(i=r[1],e=r[2]),[i,e]}},Tr=["fatal","error","warning","log","info","debug"];function Cr(t,i){void 0===i&&(i=40);var e=Object.keys(t);if(e.sort(),!e.length)return"[object has no keys]";for(var r=e.length;r>0;r--){var s=e.slice(0,r).join(", ");if(i>=s.length)return r===e.length?s:s.length>i?s.slice(0,i)+"...":s}return""}var Fr=class{match(t){return"object"==typeof t&&null!==t}coerce(t,i){var e,r,s=this.getErrorPropertyFromObject(t);return s?i.apply(s):{type:this.getType(t),value:this.getValue(t),stack:null!==(e=this.getStack(t))&&void 0!==e?e:null==(r=i.syntheticException)?void 0:r.stack,level:this.isSeverityLevel(t.level)?t.level:"error",synthetic:!0}}getType(t){if(Oi(t))return t.constructor.name;var i="name"in t?t.name:void 0;return xi(i)&&!Si(i)?i:"Error"}getValue(t){if("name"in t&&"string"==typeof t.name){var i="'"+t.name+"' captured as exception";return"message"in t&&"string"==typeof t.message&&(i+=" with message: '"+t.message+"'"),i}if("message"in t&&"string"==typeof t.message)return t.message;var e=this.getObjectClassName(t);return(e&&"Object"!==e?"'"+e+"'":"Object")+" captured as exception with keys: "+Cr(t)}isSeverityLevel(t){return xi(t)&&!Si(t)&&Tr.indexOf(t)>=0}getStack(t){try{return xi(t.stacktrace)&&t.stacktrace.length>0?t.stacktrace:xi(t.stack)&&t.stack.length>0?t.stack:void 0}catch(t){return}}getErrorPropertyFromObject(t){for(var i in t)if({}.hasOwnProperty.call(t,i)){var e=t[i];if(Ri(e))return e}}getObjectClassName(t){try{var i=Object.getPrototypeOf(t);return i?i.constructor.name:void 0}catch(t){return}}},Ar=class{match(t){return Oi(t)}coerce(t,i){var e,r=t.constructor.name;return{type:r,value:r+" captured as exception with keys: "+Cr(t),stack:null==(e=i.syntheticException)?void 0:e.stack,synthetic:!0}}},Ir=class{match(t){return Ai(t)}coerce(t,i){var e;return{type:"Error",value:"Primitive value captured as exception: "+String(t),stack:null==(e=i.syntheticException)?void 0:e.stack,synthetic:!0}}},Rr=class{match(t){return Ii(t,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(t)}isCustomEventWrappingRejection(t){if(!Oi(t))return!1;try{var i=t.detail;return null!=i&&"object"==typeof i&&"reason"in i}catch(t){return!1}}coerce(t,i){var e,r=this.getUnhandledRejectionReason(t);return Ai(r)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(r),stack:null==(e=i.syntheticException)?void 0:e.stack,synthetic:!0}:i.apply(r)}getUnhandledRejectionReason(t){try{if("reason"in t)return t.reason;if("detail"in t&&null!=t.detail&&"object"==typeof t.detail&&"reason"in t.detail)return t.detail.reason}catch(t){}return t}},Or="$message",Mr="$timestamp",Dr=new Set([Or,Mr]),jr={enabled:!0,max_bytes:32768};function Br(t){var i;return t?{enabled:null!==(i=t.enabled)&&void 0!==i?i:jr.enabled,max_bytes:Nr(t.max_bytes,jr.max_bytes)}:r({},jr)}var Lr=class{constructor(t){this.ts=[],this.es=0,this.xn=Br(t)}setConfig(t){this.xn=Br(t),this.rs()}add(t){var i=function(t){var i;try{i=ci(t)}catch(t){return}try{var e=JSON.parse(i);if(!bi(e))return;var r=e,s=r[Or],n=r[Mr];if(!xi(s)||0===s.trim().length)return;if(!xi(n)&&!$i(n))return;return{step:r,json:i}}catch(t){return}}(t);if(i){var e=function(t){if("u">typeof TextEncoder)return(new TextEncoder).encode(t).length;for(var i=encodeURIComponent(t),e=0,r=0;i.length>r;r++)"%"===i[r]?(e+=1,r+=2):e+=1;return e}(i.json);e>this.xn.max_bytes||(this.ts.push({step:i.step,bytes:e}),this.es+=e,this.rs())}}getAttachable(){return this.ts.map(t=>t.step)}clear(){this.ts=[],this.es=0}size(){return this.ts.length}rs(){for(;this.es>this.xn.max_bytes&&this.ts.length>0;){var t=this.ts.shift();t&&(this.es-=t.bytes)}}};function Nr(t,i){if(!$i(t)||1/0===t||-1/0===t)return i;var e=Math.floor(t);return 0>e?i:e}var zr=t=>{if("string"!=typeof t)return t;try{return JSON.parse(t)}catch(i){return t}};function Ur(t){return"string"==typeof t||t}function Hr(t){return"string"==typeof t?t:void 0}var qr,Vr=["$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"],Wr="NativeGzipValidationError",Gr=t=>t.length>=2&&31===t[0]&&139===t[1],Kr=(t,i)=>t===ai.GZipJS||i===ai.GZipJS||"gzip"===i,Jr=t=>!(!t||"object"!=typeof t)&&"NotReadableError"===("name"in t?String(t.name):""),Xr=t=>{throw Qe(Wr,"Native gzip produced invalid output: "+t)},Yr=function(){var t=n(function*(t,i){18>t.size&&Xr("too-short");var e=new Uint8Array(yield t.slice(0,10).arrayBuffer());Gr(e)&&8===e[2]||Xr("invalid-header");var r=new DataView(yield t.slice(t.size-8).arrayBuffer());r.getUint32(0,!0)!==(t=>{for(var i=(()=>{if(qr)return qr;qr=[];for(var t=0;256>t;t++){for(var i=t,e=0;8>e;e++)i=1&i?3988292384^i>>>1:i>>>1;qr[t]=i>>>0}return qr})(),e=4294967295,r=0;t.length>r;r++)e=i[255&(e^t[r])]^e>>>8;return(4294967295^e)>>>0})(i)&&Xr("invalid-crc");var s=i.length>>>0;r.getUint32(4,!0)!==s&&Xr("invalid-size")});return function(i,e){return t.apply(this,arguments)}}();function Zr(){return Zr=n(function*(t,i,e){void 0===i&&(i=!0);try{var r=(new TextEncoder).encode(t),s=new globalThis.CompressionStream("gzip"),o=s.writable.getWriter(),a=o.write(r).then(()=>o.close()).catch(function(){var t=n(function*(t){try{yield o.abort(t)}catch(t){}throw t});return function(i){return t.apply(this,arguments)}}()),l=new Response(s.readable).blob(),h=(yield Promise.all([l,a]))[0];return yield Yr(h,r),h}catch(t){if(null!=e&&e.rethrow)throw t;return i&&console.error("Failed to gzip compress data",t),null}}),Zr.apply(this,arguments)}var Qr={}.propertyIsEnumerable;function ts(t,i){try{return rs(t,i,{ancestors:new WeakSet,remainingNodes:1e4},0)}catch(t){return[]}}function is(t,i,e,r){if(0>=e.remainingNodes)return{stringValue:Ve};if(e.remainingNodes--,Ti(t))return{boolValue:t};if("bigint"==typeof t)return function(t,i){var e=t.toString(),r=BigInt("9223372036854775808");return t>=r||-r>t?(null==i||i.debug("Attribute "+e+" is outside the int64 range; encoding it as a string"),{stringValue:e}):{intValue:e}}(t,i);if("number"==typeof t){if(!Number.isFinite(t))return{stringValue:String(t)};if(Number.isInteger(t)){if(Number.isSafeInteger(t))return{intValue:String(t)};if(typeof BigInt>"u")return{stringValue:String(t)};var s=BigInt(t).toString();return t>=0x8000000000000000||-0x8000000000000000>t?(null==i||i.debug("Attribute "+s+" is outside the int64 range; encoding it as a string"),{stringValue:s}):{intValue:s}}return{doubleValue:t}}if("string"==typeof t)return{stringValue:Ge(t)};if("function"==typeof t)return{stringValue:"[Function]"};if("symbol"==typeof t)return{stringValue:String(t)};if("object"==typeof t&&null!==t){if(e.ancestors.has(t))return{stringValue:"[Circular]"};if(r>=20)return{stringValue:Ve};if(t instanceof Date){var n=t.getTime(),o=Number.isFinite(n)?t.toISOString():String(t);return{stringValue:"string"==typeof o?Ge(o):String(o)}}e.ancestors.add(t);try{try{var a=t.toJSON;if("function"==typeof a)return is(a.call(t),i,e,r+1)}catch(t){}return _i(t)?{arrayValue:{values:es(t,i,e,r+1)}}:{kvlistValue:{values:rs(t,i,e,r+1)}}}finally{e.ancestors.delete(t)}}return{stringValue:Ge(String(t))}}function es(t,i,e,r){for(var s=[],n=Math.min(t.length,1e3),o=0;n>o&&e.remainingNodes>0;o++)try{var a=o in t?t[o]:void 0;if(Ei(a))continue;s.push(is(a,i,e,r))}catch(t){s.push({stringValue:We})}return t.length>o&&s.push({stringValue:Ve}),s}function rs(t,i,e,r){var s=[];for(var n in t)if(Qr.call(t,n)){if(!n){null==i||i.debug("Dropping an attribute with an empty key");continue}if(s.length>=1e3||0>=e.remainingNodes){null==i||i.debug("Attributes truncated: the value exceeds the OTLP encoder budget");break}try{var o=t[n];if(ki(o)||wi(o))continue;s.push({key:Ge(n),value:is(o,i,e,r)})}catch(t){s.push({key:Ge(n),value:{stringValue:We}})}}return s}function ss(t,i,e){return r({},t.resourceAttributes,{"service.name":t.serviceName||"unknown_service"},t.environment&&{"deployment.environment":t.environment},t.serviceVersion&&{"service.version":t.serviceVersion},{"telemetry.sdk.name":i,"telemetry.sdk.version":e})}var ns={darwin:"macOS",win32:"Windows",linux:"Linux",android:"Android",freebsd:"FreeBSD",openbsd:"OpenBSD",sunos:"SunOS",aix:"AIX","Mac OS X":"macOS"};var os={trace:{text:"TRACE",number:1},debug:{text:"DEBUG",number:5},info:{text:"INFO",number:9},warn:{text:"WARN",number:13},error:{text:"ERROR",number:17},fatal:{text:"FATAL",number:21}},as=os.info;function ls(t){try{return Ge(String(t))}catch(t){return We}}function hs(t,i,e,s){var n,o=os[t.level||"info"]||as,a=o.text,l=o.number,h=(void 0===(n=$i(s)?s:void 0)&&(n=Date.now()),String(n)+"000000"),u={};i.distinctId&&(u.posthogDistinctId=i.distinctId),i.sessionId&&(u.sessionId=i.sessionId),i.windowId&&(u["window.id"]=i.windowId),Ei(i.sessionStartTimestamp)||(u.sessionStartTimestamp=String(i.sessionStartTimestamp)),Ei(i.lastActivityTimestamp)||(u.lastActivityTimestamp=String(i.lastActivityTimestamp)),i.currentUrl&&(u["url.full"]=i.currentUrl),i.screenName&&(u["screen.name"]=i.screenName),i.appState&&(u["app.state"]=i.appState),i.activeFeatureFlags&&i.activeFeatureFlags.length>0&&(u.feature_flags=i.activeFeatureFlags);var d=r({},u),v=t.attributes;if(v){var c=[];try{c=Object.keys(v)}catch(t){c=[]}for(var f of c){var p=void 0;try{p=v[f]}catch(t){p=We}Object.defineProperty(d,f,{value:p,enumerable:!0,writable:!0,configurable:!0})}}var g={timeUnixNano:h,observedTimeUnixNano:h,severityNumber:l,severityText:a,body:{stringValue:ls(t.body)},attributes:ts(d,e)};return t.trace_id&&(g.traceId=t.trace_id),t.span_id&&(g.spanId=t.span_id),wi(t.trace_flags)||(g.flags=t.trace_flags),g}function us(t,i,e){return ss(t,i,e)}function ds(t,i,e,r){return{resourceLogs:[{resource:{attributes:ts(i)},scopeLogs:[{scope:{name:e,version:r},logRecords:t}]}]}}var vs=class{constructor(t,i,e,r,s,n,o){var a;void 0===n&&(n=()=>Promise.resolve()),this._instance=t,this.xn=i,this.A=e,this.ns=r,this.ss=s,this.ls=n,this.us=o,this.hs=null,this.ds=0,this.vs=0,this.cs=0,this.fs=0,this.ps=0,this.gs=!1,this.ys=i.maxBufferSize,this.bs=Math.max(null!==(a=i.maxQueueSize)&&void 0!==a?a:i.maxBufferSize,i.maxBufferSize),this._s=i.flushIntervalMs,this.ws=i.maxBatchRecordsPerPost,this.ks=i.rateCapWindowMs,this.Ss=i.maxLogsPerInterval}clearQueue(){this.vs++,this._instance.setPersistedProperty(oi.LogsQueue,[])}reset(){this.xs(),this.fs=0,this.ps=0,this.gs=!1,this.cs=0,this.ws=this.xn.maxBatchRecordsPerPost}onReconnect(){this.cs=0,this.Cs()}captureLog(t,i){var e;if(!this._instance.isDisabled&&!this._instance.optedOut&&null!=t&&t.body){var r=this.Ts(t);if(null!==r)if(r.body){if(this.Ms()){var s={record:hs(r,null!==(e=null==i?void 0:i.context)&&void 0!==e?e:this.ns(),this.A,null==i?void 0:i.occurredAtMs)};this.ss(()=>this.Is(s))}}else this.A.info("Log was rejected in beforeSend function")}}Ts(t){var i=this.xn.beforeSend;if(!i)return t;var e=_i(i)?i:[i],r=t;for(var s of e)try{var n=s(r);if(!n)return this.A.info("Log was rejected in beforeSend function"),null;r=n}catch(t){return this.A.error("Error in beforeSend function for log:",t),null}return r}Ms(){if(void 0===this.Ss)return!0;var t=Date.now(),i=t-this.fs;return this.ks>i&&i>=0||(this.fs=t,this.ps=0,this.gs=!1),this.Ss>this.ps?(this.ps++,!0):(this.gs||(this.A.warn("captureLog dropping logs: exceeded "+this.Ss+" logs per "+this.ks+"ms"),this.gs=!0),!1)}flush(){var t=this;return n(function*(){if(!t._instance.isDisabled)return t.hs||(t.hs=t.Es().finally(()=>{t.hs=null})),t.hs})()}Es(){var t=this;return n(function*(){var i;t.xs();var e=null!==(i=t._instance.getPersistedProperty(oi.LogsQueue))&&void 0!==i?i:[];if(0!==e.length)for(var r=e.length,s=0;e.length>0&&r>s;){var n,o,a=t.vs;t.ds=0;var l=Math.min(e.length,t.ws),h=e.slice(0,l),u=ds(h.map(t=>t.record),t.Rs(),null!==(n=t.us)&&void 0!==n?n:t._instance.getLibraryId(),t._instance.getLibraryVersion()),d=yield t._instance.As(u);if(t.vs!==a)return;if("too-large"===d.kind&&h.length>1)t.ws=Math.max(1,Math.floor(h.length/2)),t.A.warn("Received 413 when sending logs batch of size "+h.length+", reducing batch size to "+t.ws);else{if("retry-later"===d.kind)throw d.error;if("too-large"===d.kind?t.A.warn("Dropping a single log record after 413 with batch size 1 — the record is larger than the server cap and cannot be split further."):"ok"===d.kind&&t.xn.maxBatchRecordsPerPost>t.ws&&(t.ws=Math.min(t.xn.maxBatchRecordsPerPost,t.ws+1)),yield t.Ps(h.length),e=null!==(o=t._instance.getPersistedProperty(oi.LogsQueue))&&void 0!==o?o:[],s+=h.length,"fatal"===d.kind)throw d.error}}})()}Ps(t){var i=this;return n(function*(){var e,r=Math.max(0,t-i.ds),s=null!==(e=i._instance.getPersistedProperty(oi.LogsQueue))&&void 0!==e?e:[];i._instance.setPersistedProperty(oi.LogsQueue,s.slice(r)),yield i.ls()})()}Rs(){return us(this.xn,this._instance.getLibraryId(),this._instance.getLibraryVersion())}Is(t){var i;if(!this._instance.optedOut){var e=null!==(i=this._instance.getPersistedProperty(oi.LogsQueue))&&void 0!==i?i:[];this.bs>e.length||(e.shift(),this.ds++,this.A.info("Logs queue is full, dropping oldest record.")),e.push(t),this._instance.setPersistedProperty(oi.LogsQueue,e),this.ys>e.length?this.Fs():this.Cs()}}Fs(t){void 0===t&&(t=this._s),this.Os||(this.Os=ir(()=>{this.Os=void 0,this.Cs()},t))}$s(){var t=Math.min(Math.max(0,this.cs-1),6);return this._s*Math.pow(2,t)}Ds(){var t=this._instance.getPersistedProperty(oi.LogsQueue);return!!t&&t.length>0}shutdown(t){var i=this;return n(function*(){i.xs();var e=i.flush().catch(()=>{});void 0!==t?yield er(e,t):yield e})()}flushWithTimeout(t){var i=this;return n(function*(){var e=i.flush();yield er(e,t,()=>{e.catch(()=>{})})})()}Cs(){this.flush().then(()=>{this.cs=0},t=>{this.cs++,this.A.error("PostHog logs flush failed:",t)}).finally(()=>{!this._instance.isDisabled&&this.Ds()&&this.Fs(this.$s())})}xs(){this.Os&&(clearTimeout(this.Os),this.Os=void 0)}},cs=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function fs(t){return String(t)+"000000"}function ps(t,i,e,r){var s="";return r&&(s=Object.keys(r).sort().map(t=>JSON.stringify(t)+":"+JSON.stringify(r[t])).join(",")),t+"\0"+i+"\0"+(null!=e?e:"")+"\0"+s}var gs=class{constructor(t,i,e){this._instance=t,this.xn=i,this.A=e,this.Ls=new Map,this.hs=null,this.Ns=!1,this.qs=new Map,this.js=new Set,this.Bs=0}count(t,i,e){void 0===i&&(i=1),this.Hs({name:t,type:"count",value:i,unit:null==e?void 0:e.unit,attributes:null==e?void 0:e.attributes})}gauge(t,i,e){this.Hs({name:t,type:"gauge",value:i,unit:null==e?void 0:e.unit,attributes:null==e?void 0:e.attributes})}histogram(t,i,e){this.Hs({name:t,type:"histogram",value:i,unit:null==e?void 0:e.unit,attributes:null==e?void 0:e.attributes})}flush(){var t=this,i=this.hs,e=function(){var e=n(function*(){i&&(yield i.catch(()=>{})),yield t.zs()});return function(){return e.apply(this,arguments)}}()().finally(()=>{this.hs===e&&(this.hs=null)});return this.hs=e,e}drainWindow(){if(0===this.Ls.size)return null;var t=this.Ls;return this.Ls=new Map,this.Ns=!1,this.qs=new Map,this.js=new Set,this.Us(t)}reset(){this.Bs++,this.xs(),this.Ls=new Map,this.hs=null,this.Ns=!1,this.qs=new Map,this.js=new Set}Hs(t){if(!this._instance.isDisabled&&!this._instance.optedOut){var i=this.Ts(t);if(null!==i)if(i.name&&"string"==typeof i.name)if("number"==typeof i.value&&Number.isFinite(i.value))if("count"===i.type&&0>i.value)this.A.warn("Dropping count '"+i.name+"': counters are monotonic, value must be >= 0");else{var e,s;try{e=i.attributes?r({},i.attributes):void 0,s=ps(i.type,i.name,i.unit,e)}catch(t){return void this.A.warn("Dropping metric '"+i.name+"': attributes could not be serialized",t)}var n=this.Ls.get(s);if(!n){if(!this.Ws())return;n={name:i.name,type:i.type,unit:i.unit,attributes:e,windowStartMs:Date.now()},this.Ls.set(s,n)}var o=this.qs.get(i.name);void 0===o?this.qs.set(i.name,i.type):o===i.type||this.js.has(i.name)||(this.js.add(i.name),this.A.warn("Metric name '"+i.name+"' is already used as a "+o+"; recording it as a "+i.type+" too will blend both series in charts. Use a distinct name.")),this.Vs(n,i.value),this.Fs()}else this.A.warn("Dropping metric '"+i.name+"': value must be a finite number");else this.A.warn("Dropping metric with empty name")}}Ws(){return this.xn.maxSeriesPerFlush>this.Ls.size||(this.Ns||(this.Ns=!0,this.A.warn("Metric series cap reached ("+this.xn.maxSeriesPerFlush+" per flush window); dropping new series until the next flush. Reduce attribute cardinality.")),!1)}Vs(t,i){var e;switch(t.type){case"count":t.total=(null!==(e=t.total)&&void 0!==e?e:0)+i;break;case"gauge":t.last=i;break;case"histogram":t.hist||(t.hist={count:0,sum:0,min:i,max:i,bucketCounts:new Array(cs.length+1).fill(0)});var r=t.hist;r.count+=1,r.sum+=i,r.min=Math.min(r.min,i),r.max=Math.max(r.max,i),r.bucketCounts[function(t,i){for(var e=0;i.length>e;e++)if(i[e]>=t)return e;return i.length}(i,cs)]+=1}}Ts(t){var i=this.xn.beforeSend;if(!i)return t;var e=_i(i)?i:[i],r=t;for(var s of e)try{var n=s(r);if(!n)return this.A.info("Metric was rejected in beforeSend function"),null;r=n}catch(t){return this.A.error("Error in beforeSend function for metric:",t),null}return r}Fs(){this.Os||(this.Os=ir(()=>{this.Os=void 0,this.flush().catch(t=>{this.A.error("Metrics flush failed:",t)})},this.xn.flushIntervalMs))}xs(){this.Os&&(clearTimeout(this.Os),this.Os=void 0)}zs(){var t=this;return n(function*(){if(0!==t.Ls.size){var i=t.Ls;t.Ls=new Map,t.Ns=!1,t.qs=new Map,t.js=new Set;var e=t.Bs,r=yield t._instance.Gs(t.Us(i));if(e===t.Bs)switch(r.kind){case"ok":return;case"retry-later":return t.Zs(i),void t.Fs();case"too-large":return void t.A.warn("Metrics batch exceeded the server size limit and was dropped");case"fatal":return void t.A.error("Failed to send metrics batch:",r.error)}}})()}Us(t){return i=this.Js(t),e=function(t,i,e){return ss(t,i,e)}(this.xn,this._instance.getLibraryId(),this._instance.getLibraryVersion()),r=this._instance.getLibraryId(),s=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:ts(e)},scopeMetrics:[{scope:{name:r,version:s},metrics:i}]}]};var i,e,r,s}Js(t){var i=fs(Date.now()),e=new Map;for(var s of t.values()){var n,o=ps(s.type,s.name,s.unit,void 0),a=e.get(o);a||(a=r({name:s.name},s.unit&&{unit:s.unit}),"count"===s.type?a.sum={aggregationTemporality:1,isMonotonic:!0,dataPoints:[]}:"gauge"===s.type?a.gauge={dataPoints:[]}:a.histogram={aggregationTemporality:1,dataPoints:[]},e.set(o,a));var l=ts(null!==(n=s.attributes)&&void 0!==n?n:{},this.A),h=fs(s.windowStartMs);if("count"===s.type){var u,d={attributes:l,startTimeUnixNano:h,timeUnixNano:i,asDouble:null!==(u=s.total)&&void 0!==u?u:0};a.sum.dataPoints.push(d)}else if("gauge"===s.type){var v,c={attributes:l,timeUnixNano:i,asDouble:null!==(v=s.last)&&void 0!==v?v:0};a.gauge.dataPoints.push(c)}else s.hist&&a.histogram.dataPoints.push({attributes:l,startTimeUnixNano:h,timeUnixNano:i,count:s.hist.count,sum:s.hist.sum,min:s.hist.min,max:s.hist.max,bucketCounts:s.hist.bucketCounts,explicitBounds:cs})}return Array.from(e.values())}Zs(t){var i,e;for(var r of t){var s=r[0],n=r[1],o=this.Ls.get(s);if(o)switch(o.windowStartMs=Math.min(o.windowStartMs,n.windowStartMs),o.type){case"count":o.total=(null!==(i=o.total)&&void 0!==i?i:0)+(null!==(e=n.total)&&void 0!==e?e:0);break;case"gauge":break;case"histogram":if(n.hist)if(o.hist){o.hist.count+=n.hist.count,o.hist.sum+=n.hist.sum,o.hist.min=Math.min(o.hist.min,n.hist.min),o.hist.max=Math.max(o.hist.max,n.hist.max);for(var a=0;o.hist.bucketCounts.length>a;a++)o.hist.bucketCounts[a]+=n.hist.bucketCounts[a]}else o.hist=n.hist}else this.Ws()&&this.Ls.set(s,n)}}},_s=function(t,i){var e=(void 0===i?{}:i).debugEnabled,r={q(i){for(var r=arguments.length,s=new Array(r>1?r-1:0),n=1;r>n;n++)s[n-1]=arguments[n];Gt&&(a.DEBUG||Gt.POSTHOG_DEBUG||e)&&!wi(Gt.console)&&Gt.console&&("__rrweb_original__"in Gt.console[i]?Gt.console[i].__rrweb_original__:Gt.console[i])(t,...s)},debug(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];r.q("debug",...i)},info(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];r.q("log",...i)},warn(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];r.q("warn",...i)},error(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];r.q("error",...i)},critical(){for(var i=arguments.length,e=new Array(i),r=0;i>r;r++)e[r]=arguments[r];console.error(t,...e)},uninitializedWarning(t){r.error("You must initialize PostHog before calling "+t)},createLogger:(i,e)=>_s(t+" "+i,e)};return r},ms=_s("[PostHog.js]"),bs=ms.createLogger;function ys(t,i){_i(t)&&t.forEach(i)}function ws(t,i){if(!Ei(t))if(_i(t))t.forEach(i);else if((t=>t instanceof FormData)(t))t.forEach((t,e)=>i(t,e));else for(var e in t)pi.call(t,e)&&i(t[e],e)}var xs=function(t){for(var i=arguments.length,e=new Array(i>1?i-1:0),r=1;i>r;r++)e[r-1]=arguments[r];for(var s of e)for(var n in s)void 0!==s[n]&&(t[n]=s[n]);return t};function Ss(t){for(var i=Object.keys(t),e=i.length,r=new Array(e);e--;)r[e]=[i[e],t[i[e]]];return r}var ks=function(t){try{return t()}catch(t){return}},Es=function(t){return function(){try{for(var i=arguments.length,e=new Array(i),r=0;i>r;r++)e[r]=arguments[r];return t.apply(this,e)}catch(t){ms.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),ms.critical(t)}}},$s=function(t){var i={};return ws(t,function(t,e){(xi(t)&&t.length>0||$i(t))&&(i[e]=t)}),i};function Ps(t){var i=r({},t);for(var e of["name","message","stack","cause","errors"])try{e in t&&(i[e]=t[e])}catch(t){}return i}var Ts=["herokuapp.com","vercel.app","netlify.app"];function Cs(t){var i=null==t?void 0:t.hostname;if(!xi(i))return!1;var e=i.split(".").slice(-2).join(".");for(var r of Ts)if(e===r)return!1;return!0}function Fs(t,i,e,r){var s=null!=r?r:{},n=s.capture,o=s.passive;null==t||t.addEventListener(i,e,{capture:void 0!==n&&n,passive:void 0===o||o})}function As(t){return"ph_toolbar_internal"===t.name}var Is=t=>{if(Xt){try{for(var i=t+"=",e=Xt.cookie.split(";").filter(t=>t.length),r=0;e.length>r;r++){for(var s=e[r];" "==s.charAt(0);)s=s.substring(1,s.length);if(0===s.indexOf(i))return decodeURIComponent(s.substring(i.length,s.length))}}catch(t){}return null}};Math.trunc||(Math.trunc=function(t){return 0>t?Math.ceil(t):Math.floor(t)}),Number.isInteger||(Number.isInteger=function(t){return $i(t)&&isFinite(t)&&Math.floor(t)===t});var Rs=class t{constructor(t){if(this.bytes=t,16!==t.length)throw new TypeError("not 128-bit length")}static fromFieldsV7(i,e,r,s){if(!Number.isInteger(i)||!Number.isInteger(e)||!Number.isInteger(r)||!Number.isInteger(s)||0>i||0>e||0>r||0>s||i>0xffffffffffff||e>4095||r>1073741823||s>4294967295)throw new RangeError("invalid field value");var n=new Uint8Array(16);return n[0]=i/Math.pow(2,40),n[1]=i/Math.pow(2,32),n[2]=i/Math.pow(2,24),n[3]=i/Math.pow(2,16),n[4]=i/256,n[5]=i,n[6]=112|e>>>8,n[7]=e,n[8]=128|r>>>24,n[9]=r>>>16,n[10]=r>>>8,n[11]=r,n[12]=s>>>24,n[13]=s>>>16,n[14]=s>>>8,n[15]=s,new t(n)}toString(){for(var t="",i=0;this.bytes.length>i;i++)t=t+(this.bytes[i]>>>4).toString(16)+(15&this.bytes[i]).toString(16),3!==i&&5!==i&&7!==i&&9!==i||(t+="-");if(36!==t.length)throw new Error("Invalid UUIDv7 was generated");return t}clone(){return new t(this.bytes.slice(0))}equals(t){return 0===this.compareTo(t)}compareTo(t){for(var i=0;16>i;i++){var e=this.bytes[i]-t.bytes[i];if(0!==e)return Math.sign(e)}return 0}},Os=class{generate(){var t=this.generateOrAbort();if(!wi(t))return t;this.Ct=0;var i=this.generateOrAbort();if(wi(i))throw new Error("Could not generate UUID after timestamp reset");return i}generateOrAbort(){var t,i=(t=Date.now(),$i(t)&&isFinite(t)?Math.min(Math.max(Math.floor(t),0),0xffffffffffff):0);if(i>this.Ct)this.Ct=i,this.Mt();else{if(this.Ct>=i+1e4)return;this.Tt++,this.Tt>4398046511103&&(this.Ct++,this.Mt())}return Rs.fromFieldsV7(this.Ct,Math.trunc(this.Tt/Math.pow(2,30)),this.Tt&Math.pow(2,30)-1,this.It.nextUint32())}Mt(){this.Tt=1024*this.It.nextUint32()+(1023&this.It.nextUint32())}constructor(){this.Ct=0,this.Tt=0,this.It=new js}},Ms=t=>{if("u">typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var i=0;t.length>i;i++)t[i]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return t};Gt&&!wi(Gt.crypto)&&crypto.getRandomValues&&(Ms=t=>crypto.getRandomValues(t));var Ds,js=class{nextUint32(){return this.Rt.length>this.At||(Ms(this.Rt),this.At=0),this.Rt[this.At++]}constructor(){this.Rt=new Uint32Array(8),this.At=1/0}},Bs=()=>Ls().toString(),Ls=()=>(Ds||(Ds=new Os)).generate(),Ns="",zs=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;var Us=null,Hs={Et(){if(!ki(Us))return Us;if(Us=!1,Xt)try{var t="__ph_cookie_support_"+Bs();Hs.Ot(t,"xyz"),Us='"xyz"'===Is(t),Hs.Dt(t)}catch(t){Us=!1}return Us},Pt(t){ms.error("cookieStore error: "+t)},Lt:Is,Nt(t){var i;try{i=JSON.parse(Hs.Lt(t))||{}}catch(t){}return i},Ot(t,i,e,r,s){if(!Xt)return!1;try{var n="",o="",a=function(t,i){if(i){var e=function(t,i){if(void 0===i&&(i=Xt),Ns)return Ns;if(!i)return"";if(["localhost","127.0.0.1"].includes(t))return"";for(var e=t.split("."),r=Math.min(e.length,8),s="dmn_chk_"+Bs();!Ns&&r--;){var n=e.slice(r).join("."),o=s+"=1;domain=."+n+";path=/";i.cookie=o+";max-age=3",i.cookie.includes(s)&&(i.cookie=o+";max-age=0",Ns=n)}return Ns}(t);if(!e){var r=(t=>{var i=t.match(zs);return i?i[0]:""})(t);r!==e&&ms.info("Warning: cookie subdomain discovery mismatch",r,e),e=r}return e?"; domain=."+e:""}return""}(Xt.location.hostname,r);if(e){var l=new Date;l.setTime(l.getTime()+864e5*e),n="; expires="+l.toUTCString()}s&&(o="; secure");var h=t+"="+encodeURIComponent(JSON.stringify(i))+n+"; SameSite=Lax; path=/"+a+o;return h.length>3686.4&&ms.warn("cookieStore warning: large cookie, len="+h.length),Xt.cookie=h,!0}catch(t){return!1}},Dt(t,i){if(null!=Xt&&Xt.cookie)try{Hs.Ot(t,"",-1,i)}catch(t){return}}},qs=null,Vs={Et(){if(!ki(qs))return qs;var t=!0;if(wi(Gt))t=!1;else try{var i="__mplssupport__";Vs.Ot(i,"xyz"),'"xyz"'!==Vs.Lt(i)&&(t=!1),Vs.Dt(i)}catch(i){t=!1}return t||ms.error("localStorage unsupported; falling back to cookie store"),qs=t,t},Pt(t){ms.error("localStorage error: "+t)},Lt(t){try{return null==Gt?void 0:Gt.localStorage.getItem(t)}catch(t){Vs.Pt(t)}return null},Nt(t){try{return JSON.parse(Vs.Lt(t))||{}}catch(t){}return null},Ot(t,i){try{return null==Gt||Gt.localStorage.setItem(t,JSON.stringify(i)),!0}catch(t){Vs.Pt(t)}return!1},Dt(t){try{null==Gt||Gt.localStorage.removeItem(t)}catch(t){Vs.Pt(t)}}},Ws=[Z,q,H,W,G,K,gt,pt,ct],Gs=[d,u,D,j,St,xt,g,_t],Ks=t=>t+"_cpm",Js=["__proto__","constructor","prototype"],Xs=t=>{if(!bi(t))return{};var i={};return Object.keys(t).forEach(e=>{-1===Js.indexOf(e)&&(i[e]=t[e])}),i},Ys=function(t,i){void 0===i&&(i=[]);var e={};return[...Gs,...i].forEach(i=>{var r=t[i];wi(r)||ki(r)||""===r||(e[i]=r)}),e},Zs=t=>{for(var i=5381,e=2166136261,r=0;t.length>r;r++){var s=t.charCodeAt(r);i=33*i^s,e=Math.imul(e^s,16777619)}return t.length.toString(36)+"."+(i>>>0).toString(36)+"."+(e>>>0).toString(36)},Qs=(t,i)=>({p:i,f:Zs(JSON.stringify(t))}),tn=(t,i)=>{if(!i)return{properties:[],isValid:!1};try{var e=Hs.Nt(Ks(t)),r=(null==e?void 0:e.f)===Zs(i)&&_i(e.p);return{properties:r?e.p:[],isValid:r}}catch(t){return{properties:[],isValid:!1}}},en=(t,i)=>i+"|"+(Hs.Lt(Ks(t))||""),rn={},sn={Et:()=>!0,Pt(t){ms.error("memoryStorage error: "+t)},Lt:t=>t in rn?rn[t]:null,Nt:t=>t in rn?rn[t]:null,Ot:(t,i)=>(rn[t]=i,!0),Dt(t){delete rn[t]}},nn=null,on={Et(){if(!ki(nn))return nn;if(nn=!0,wi(Gt))nn=!1;else try{var t="__support__";on.Ot(t,"xyz"),'"xyz"'!==on.Lt(t)&&(nn=!1),on.Dt(t)}catch(t){nn=!1}return nn},Pt(t){ms.error("sessionStorage error: ",t)},Lt(t){try{return null==Gt?void 0:Gt.sessionStorage.getItem(t)}catch(t){on.Pt(t)}return null},Nt(t){try{return JSON.parse(on.Lt(t))||null}catch(t){}return null},Ot(t,i){try{return null==Gt||Gt.sessionStorage.setItem(t,JSON.stringify(i)),!0}catch(t){on.Pt(t)}return!1},Dt(t){try{null==Gt||Gt.sessionStorage.removeItem(t)}catch(t){on.Pt(t)}}},an=class{constructor(t){this._instance=t}get xn(){return this._instance.config}get consent(){return this.xo()?0:this.Co}isOptedOut(){return"always"===this.xn.cookieless_mode||this.isRejected()||-1===this.consent&&"on_reject"===this.xn.cookieless_mode}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return 0===this.consent}isRejected(){return 0===this.consent||-1===this.consent&&this.xn.opt_out_capturing_by_default}optInOut(t){this.To.Ot(this.Mo,t?1:0,this.xn.cookie_expiration,this.xn.cross_subdomain_cookie,this.xn.secure_cookie)}reset(){this.To.Dt(this.Mo,this.xn.cross_subdomain_cookie)}get Mo(){var t=this._instance.config,i=t.token,e=t.opt_out_capturing_cookie_prefix;return t.consent_persistence_name||(e?e+i:"__ph_opt_in_out_"+i)}get Co(){var t=this.To.Lt(this.Mo);return ji(t)?1:ui(Bi,t)?0:-1}get To(){var t=this.xn.opt_out_capturing_persistence_type,i="localStorage"===t?Vs:Hs,e=i.Et()?i:sn;if(!this.Io||this.Io!==e){this.Io=e;var r="localStorage"===t?Hs:Vs;r.Lt(this.Mo)&&(this.Io.Lt(this.Mo)||this.optInOut(ji(r.Lt(this.Mo))),r.Dt(this.Mo,this.xn.cross_subdomain_cookie))}return this.Io}xo(){return!!this.xn.respect_dnt&&[null==Jt?void 0:Jt.doNotTrack,null==Jt?void 0:Jt.msDoNotTrack,ni.doNotTrack,null==Jt?void 0:Jt.globalPrivacyControl].some(t=>ji(t))}};function ln(t,i){var e,r=null==t||null==(e=t.config)?void 0:e.get_current_url;if(!mi(r))return i;try{var s=r(i);return xi(s)&&s?s:i}catch(t){return ms.error("Error in get_current_url, falling back to window.location.href",t),i}}function hn(t){return t instanceof Element&&("__POSTHOG_TOOLBAR__"===t.id||!(null==t.closest||!t.closest(".toolbar-global-fade-container")))}function un(t){return!!t&&1===t.nodeType}function dn(t,i){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===i.toLowerCase()}function vn(t){return!!t&&3===t.nodeType}function cn(t){return!!t&&11===t.nodeType&&un(t.host)}function fn(t){return t?di(t).split(/\s+/):[]}function pn(t,i){var e=function(t){var i,e=null==Gt||null==(i=Gt.location)?void 0:i.href;return wi(e)?void 0:ln(t,e)}(i);return!!(e&&t&&t.some(t=>e.match(t)))}function gn(t){var i="";switch(typeof t.className){case"string":i=t.className;break;case"object":i=(t.className&&"baseVal"in t.className?t.className.baseVal:null)||t.getAttribute("class")||"";break;default:i=""}return fn(i)}function _n(t){return Ei(t)?null:di(t).split(/(\s+)/).filter(t=>Un(t)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function mn(t){var i="";return Rn(t)&&!On(t)&&t.childNodes&&t.childNodes.length&&ws(t.childNodes,function(t){var e;vn(t)&&t.textContent&&(i+=null!==(e=_n(t.textContent))&&void 0!==e?e:"")}),di(i)}function bn(t){var i;return wi(t.target)?t.srcElement||null:null!=(i=t.target)&&i.shadowRoot?t.composedPath()[0]||null:t.target||null}var yn=["a","button","form","input","select","textarea","label"];function wn(t,i){var e=t.matches||t.matchesSelector||t.msMatchesSelector||t.mozMatchesSelector||t.webkitMatchesSelector||t.oMatchesSelector;try{return!!e&&e.call(t,i)}catch(t){return!1}}function xn(t,i){if(wi(i))return!0;var e,r=function(t){if(i.some(i=>wn(t,i)))return{v:!0}};for(var s of t)if(e=r(s))return e.v;return!1}function Sn(t){var i=t.parentNode;return!(!i||!un(i))&&i}var kn=[".ph-no-autocapture","[data-ph-no-autocapture]"],En=["next","previous","prev",">","<"],$n=[...En,"+","-","−","–"],Pn=(t,i)=>/[a-z0-9]/i.test(i)?t.includes(i):t===i,Tn=[".ph-no-rageclick",".ph-no-capture"],Cn=["","text","search","email","password","url","tel","number"];function Fn(t,i){if(!Gt||An(t))return!1;var e,r,s,n,o;if(Ti(i)?(e=!!i&&Tn,r=void 0,s=!1):(e=null!==(n=null==i?void 0:i.css_selector_ignorelist)&&void 0!==n?n:Tn,r=null==i?void 0:i.content_ignorelist,s=null!==(o=null==i?void 0:i.ignore_text_selection)&&void 0!==o&&o),!1===e)return!1;if(s&&function(t){return!(!t||!un(t))&&(!!dn(t,"textarea")||(dn(t,"input")?ui(Cn,(t.getAttribute("type")||"").toLowerCase()):function(t){if(t.isContentEditable)return!0;var i=null==t.getAttribute?void 0:t.getAttribute("contenteditable");return"true"===i||""===i}(t)))}(t))return!1;var a=In(t,!1).targetElementList;return!function(t,i){if(!1===t||wi(t))return!1;var e;if(!0===t)e=En;else{if(!_i(t))return!1;if(t.length>10)return ms.error("[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching."),!1;e=t.map(t=>t.toLowerCase())}return i.some(t=>{var i=t.safeText,r=t.ariaLabel;return e.some(t=>Pn(i,t)||Pn(r,t))})}(r,a.map(t=>{var i;return{safeText:mn(t).toLowerCase(),ariaLabel:(null==(i=t.getAttribute("aria-label"))?void 0:i.toLowerCase().trim())||""}}))&&!xn(a,e)}var An=t=>!t||dn(t,"html")||!un(t),In=(t,i)=>{if(!Gt||An(t))return{parentIsUsefulElement:!1,targetElementList:[]};for(var e=!1,r=[t],s=t;s.parentNode&&!dn(s,"body");)if(cn(s.parentNode))r.push(s.parentNode.host),s=s.parentNode.host;else{var n=Sn(s);if(!n)break;if(i||yn.indexOf(n.tagName.toLowerCase())>-1)e=!0;else try{var o=Gt.getComputedStyle(n);o&&"pointer"===o.getPropertyValue("cursor")&&(e=!0)}catch(t){}r.push(n),s=n}return{parentIsUsefulElement:e,targetElementList:r}};function Rn(t){for(var i=new Set,e=0,r=t;r.parentNode&&!dn(r,"body");r=r.parentNode){if(e++>=1e3||i.has(r))return!1;i.add(r);var s=gn(r);if(ui(s,"ph-sensitive")||ui(s,"ph-no-capture"))return!1}if(ui(gn(t),"ph-include"))return!0;var n=t.type||"";if(xi(n))switch(n.toLowerCase()){case"hidden":case"password":return!1}var o=t.name||t.id||"";return!xi(o)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(o.replace(/[^a-zA-Z0-9]/g,""))}function On(t){return!!(dn(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||dn(t,"select")||dn(t,"textarea")||"true"===t.getAttribute("contenteditable"))}var Mn=new RegExp("^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$"),Dn=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,jn=[16,15,14,13],Bn=new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),Ln=new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),Nn=/[0-9A-Za-z_]/;function zn(t){for(var i=0,e=!1,r=t.length-1;r>=0;r--){var s=t.charCodeAt(r)-48;e&&(s*=2)>9&&(s-=9),i+=s,e=!e}return i%10==0}function Un(t,i){if(void 0===i&&(i=!0),Ei(t))return!1;if(xi(t)){if(t=di(t),i?Mn.test((t||"").replace(/[- ]/g,"")):function(t){var i;for(Dn.lastIndex=0;i=Dn.exec(t);){var e=i[2];if(e)for(var r=e.replace(/[- ]/g,""),s=0;r.length>s;s++)for(var n of jn){var o=s+n;if(r.length>=o){var a=r.slice(s,o);if(Mn.test(a)&&zn(a))return!0}}}return!1}(t))return!1;if(i?Bn.test(t):function(t){var i;for(Ln.lastIndex=0;i=Ln.exec(t);){var e=i[1],r=i[3];if(!(e&&r&&Nn.test(e)&&Nn.test(r)))return!0}return!1}(t))return!1}return!0}function Hn(t){var i=mn(t);return Un(i=(i+" "+qn(t)).trim())?i:""}function qn(t){var i="";return t&&t.childNodes&&t.childNodes.length&&ws(t.childNodes,function(t){var e;if(t&&"span"===(null==(e=t.tagName)?void 0:e.toLowerCase()))try{var r=mn(t);i=(i+" "+r).trim(),t.childNodes&&t.childNodes.length&&(i=(i+" "+qn(t)).trim())}catch(t){ms.error("[AutoCapture]",t)}}),i}function Vn(t){return t.replace(/"|\\"/g,'\\"')}function Wn(t){var i=t.attr__class;if(i)return _i(i)?i:fn(i)}var Gn=bs("[Dead Clicks]"),Kn=()=>!0,Jn=t=>{var i,e=!(null==(i=t.instance.persistence)||!i.get_property(k)),r=t.instance.config.capture_dead_clicks;return Ti(r)?r:!!bi(r)||e},Xn=class{get lazyLoadedDeadClicksAutocapture(){return this.Eo}constructor(t,i,e){this.instance=t,this.isEnabled=i,this.onCapture=e,this.startIfEnabledOrStop()}onRemoteConfig(t){if(t.ok){var i=t.config;"captureDeadClicks"in i&&(this.instance.persistence&&this.instance.persistence.register({[k]:i.captureDeadClicks}),this.startIfEnabledOrStop())}}startIfEnabledOrStop(){this.isEnabled(this)?this.Ro(()=>{this.Ao()}):this.stop()}Ro(t){var i,e;null!=(i=ni.__PosthogExtensions__)&&i.initDeadClicksAutocapture?t():null==(e=ni.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this.instance,"dead-clicks-autocapture",i=>{i?Gn.error("failed to load script",i):t()})}Ao(){var t;if(Xt){if(!this.Eo&&null!=(t=ni.__PosthogExtensions__)&&t.initDeadClicksAutocapture){var i=bi(this.instance.config.capture_dead_clicks)?r({},this.instance.config.capture_dead_clicks):{};i.__onCapture=this.onCapture,this.onCapture&&(i.capture_dead_swipes=!1),this.Eo=ni.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,i),this.Eo.start(Xt),Gn.info("starting...")}}else Gn.error("`document` not found. Cannot start.")}stop(){this.Eo&&(this.Eo.stop(),this.Eo=void 0,Gn.info("stopping..."))}},Yn=bs("[SegmentIntegration]");function Zn(t,i,e){void 0===e&&(e=!0);var s=t.config.segment;if(!s)return i();var n,o=(t=>mi(t.register))(n=s)?{analytics:n}:n,a=o.analytics,l=o.filterProperties;!function(t,i,e,r){var s=i=>{var s=()=>i.anonymousId()||Bs();t.config.get_device_id=s,r&&i.id()&&(t.register({distinct_id:i.id(),$device_id:s()}),t.persistence.set_property(_t,Lt)),e(r?void 0:i.anonymousId()||void 0)},n=i.user();"then"in n&&mi(n.then)?n.then(s):s(n)}(t,a,e=>{a.register(function(t,i,e){var s=(void 0===e?{}:e).filterProperties;"undefined"!=typeof Promise&&Promise.resolve||Yn.warn("This browser does not have Promise support, and can not use the segment integration");var n=(e,n)=>{if(!n)return e;var o=!!i&&e.event.anonymousId===i&&!e.event.userId;o||e.event.userId||e.event.anonymousId===t.get_distinct_id()||(Yn.info("No userId set, resetting PostHog"),t.reset()),o||(i=void 0),e.event.userId&&e.event.userId!==t.get_distinct_id()&&(Yn.info("UserId set, identifying with PostHog"),t.identify(e.event.userId));var a=t.calculateEventProperties(n,e.event.properties);if(!Ei(s)){var l=e.event.properties||{},h={};for(var u of Object.keys(a))pi.call(l,u)||(h[u]=a[u]);var d=((t,i)=>{var e=_i(t)?t:[t],s=r({},i);for(var n of e)try{if(s=n(s),Ei(s))return null}catch(t){return Yn.error("Error in Segment filterProperties:",t),null}return s})(s,h);if(Ei(d))return e;a=d}return e.event.properties=Object.assign({},a,e.event.properties),e};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded(){return!0},load(){return Promise.resolve()},track(t){return n(t,t.event.event)},page(t){return n(t,Ht)},identify(t){return n(t,Vt)},screen(t){return n(t,"$screen")}}}(t,e,{filterProperties:l})).then(()=>{i()},t=>{Yn.error("Failed to register the Segment integration",t),i()})},e)}var Qn="posthog-js";function to(t,i){var e=void 0===i?{}:i,s=e.organization,n=e.projectId,o=e.prefix,a=e.severityAllowList,l=void 0===a?["error"]:a,h=e.sendExceptionsToPostHog,u=void 0===h||h;return i=>{var e,a,h,d,v,c;if("*"!==l&&!l.includes(i.level)||!t.__loaded)return i;i.tags||(i.tags={});var f=t.requestRouter.endpointFor("ui","/project/"+t.config.token+"/person/"+t.get_distinct_id());i.tags["PostHog Person URL"]=f,t.sessionRecordingStarted()&&(i.tags["PostHog Recording URL"]=t.get_session_replay_url({withTimestamp:!0}));var p=(null==(e=i.exception)?void 0:e.values)||[],g=p.map(t=>r({},t,{stacktrace:t.stacktrace?r({},t.stacktrace,{type:"raw",frames:(t.stacktrace.frames||[]).map(t=>r({},t,{platform:"web:javascript"}))}):void 0})),_={$exception_message:(null==(a=p[0])?void 0:a.value)||i.message,$exception_type:null==(h=p[0])?void 0:h.type,$exception_level:i.level,$exception_list:g,$sentry_event_id:i.event_id,$sentry_exception:i.exception,$sentry_exception_message:(null==(d=p[0])?void 0:d.value)||i.message,$sentry_exception_type:null==(v=p[0])?void 0:v.type,$sentry_tags:i.tags};return s&&n&&(_.$sentry_url=(o||"https://sentry.io/organizations/")+s+"/issues/?project="+n+"&query="+i.event_id),u&&(null==(c=t.exceptions)||c.sendExceptionEvent(_)),i}}var io=class{constructor(t,i,e,r,s,n){this.name=Qn,this.setupOnce=function(o){o(to(t,{organization:i,projectId:e,prefix:r,severityAllowList:s,sendExceptionsToPostHog:null==n||n}))}}},eo=class{constructor(t){this.Po=(t,i,e)=>{e&&(e.noSessionId||e.activityTimeout||e.sessionPastMaximumLength||e.crossTabAdoption)&&(ms.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:t,changeReason:e}),this.Fo=void 0,this._instance.scrollManager.resetContext())},this._instance=t,this.Oo()}Oo(){var t;this.$o=null==(t=this._instance.sessionManager)?void 0:t.onSessionId(this.Po)}destroy(){var t;null==(t=this.$o)||t.call(this),this.$o=void 0}doPageView(t,i){var e,r=this.Do(t,i);return this.Fo={pathname:null!==(e=null==Gt?void 0:Gt.location.pathname)&&void 0!==e?e:"",pageViewId:i,timestamp:t},this._instance.scrollManager.resetContext(),r}doPageLeave(t){var i;return this.Do(t,null==(i=this.Fo)?void 0:i.pageViewId)}doEvent(){var t;return{$pageview_id:null==(t=this.Fo)?void 0:t.pageViewId}}Do(t,i){var e=this.Fo;if(!e)return{$pageview_id:i};var r={$pageview_id:i,$prev_pageview_id:e.pageViewId},s=this._instance.scrollManager.getContext();if(s&&!this._instance.config.disable_scroll_properties){var n=s.maxScrollHeight,o=s.lastScrollY,a=s.maxScrollY,l=s.maxContentHeight,h=s.lastContentY,u=s.maxContentY;if(!(wi(n)||wi(o)||wi(a)||wi(l)||wi(h)||wi(u))){n=Math.ceil(n),o=Math.ceil(o),a=Math.ceil(a),l=Math.ceil(l),h=Math.ceil(h),u=Math.ceil(u);var d=n>1?zi(o/n,0,1,ms):1,v=n>1?zi(a/n,0,1,ms):1,c=l>1?zi(h/l,0,1,ms):1,f=l>1?zi(u/l,0,1,ms):1;r=xs(r,{$prev_pageview_last_scroll:o,$prev_pageview_last_scroll_percentage:d,$prev_pageview_max_scroll:a,$prev_pageview_max_scroll_percentage:v,$prev_pageview_last_content:h,$prev_pageview_last_content_percentage:c,$prev_pageview_max_content:u,$prev_pageview_max_content_percentage:f})}}return e.pathname&&(r.$prev_pageview_pathname=e.pathname),e.timestamp&&(r.$prev_pageview_duration=(t.getTime()-e.timestamp.getTime())/1e3),r}},ro=["flags","surveys"],so={[h]:{exposure:"hidden"},[c]:{exposure:"hidden"},[f]:{exposure:"hidden"},[_]:{exposure:"hidden"},[g]:{exposure:"hidden"},[m]:{exposure:"event"},[b]:{exposure:"hidden"},[P]:{exposure:"hidden"},[y]:{exposure:"event"},[w]:{exposure:"hidden"},[x]:{exposure:"event"},[S]:{exposure:"event"},[k]:{exposure:"event"},[E]:{exposure:"hidden"},[T]:{exposure:"event"},[C]:{exposure:"hidden"},[F]:{exposure:"hidden"},[D]:{exposure:"hidden"},[j]:{exposure:"event"},[A]:{exposure:"event",shouldSkipFromEventProperties:t=>ki(t)},[B]:{exposure:"event"},[L]:{exposure:"event"},[N]:{exposure:"event"},[z]:{exposure:"event"},[U]:{exposure:"hidden"},[H]:{exposure:"hidden",storageGroup:"flags"},[q]:{exposure:"hidden",storageGroup:"flags"},[V]:{exposure:"hidden"},[W]:{exposure:"hidden",storageGroup:"flags"},[G]:{exposure:"hidden",storageGroup:"flags"},[K]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[J]:{exposure:"hidden",storageGroup:"flags"},[X]:{exposure:"hidden"},[Y]:{exposure:"hidden"},[Z]:{exposure:"hidden"},[Q]:{exposure:"hidden"},[it]:{exposure:"hidden",storageGroup:"surveys"},[et]:{exposure:"hidden",storageGroup:"surveys",volatile:!0},[rt]:{exposure:"event"},[st]:{exposure:"hidden"},[nt]:{exposure:"hidden"},[ot]:{exposure:"hidden"},[at]:{exposure:"hidden"},[lt]:{exposure:"hidden"},[ht]:{exposure:"event"},[ut]:{exposure:"event"},[dt]:{exposure:"event"},[vt]:{exposure:"event"},[ct]:{exposure:"hidden"},[ft]:{exposure:"hidden"},[tt]:{exposure:"event"},[pt]:{exposure:"hidden"},[gt]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[_t]:{exposure:"hidden"},[mt]:{exposure:"hidden"},[bt]:{exposure:"hidden"},[yt]:{exposure:"hidden"},[wt]:{exposure:"hidden"},[xt]:{exposure:"hidden"},[St]:{exposure:"hidden"},[I]:{exposure:"event"},[R]:{exposure:"event"},[O]:{exposure:"event"},[M]:{exposure:"event"},[$t]:{exposure:"event"},[Pt]:{exposure:"event"},[Tt]:{exposure:"event"},[Ct]:{exposure:"event"},[Ft]:{exposure:"event"},[At]:{exposure:"event"},[It]:{exposure:"event"},[Rt]:{exposure:"event"},[Ot]:{exposure:"event"},[Mt]:{exposure:"event"},[Dt]:{exposure:"event"}},no=[["$posthog_sr_group_event_trigger_",{exposure:"hidden"}],["$posthog_sr_group_url_trigger_",{exposure:"hidden"}],["$posthog_sr_group_sampling_",{exposure:"hidden"}]],oo=t=>{var i=so[t];if(i)return i;for(var e of no){var r=e[1];if(0===t.indexOf(e[0]))return r}},ao=(t,i)=>{try{var e;return JSON.stringify(t,(t,i)=>Ri(i)?(null!=e||(e=new WeakMap),e.has(i)||e.set(i,Ps(i)),e.get(i)):"bigint"==typeof i?i.toString():i,i)}catch(i){return ci(t)}},lo=t=>{var i=null==Xt?void 0:Xt.createElement("a");return wi(i)?null:(i.href=t,i)},ho=function(t,i){for(var e,r=((t.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),s=0;r.length>s;s++){var n=r[s].split("=");if(n[0]===i){e=n;break}}if(!_i(e)||2>e.length)return"";var o=e[1];try{o=decodeURIComponent(o)}catch(t){ms.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},uo=function(t,i,e){if(!t||!i||!i.length)return t;for(var r=t.split("#"),s=r[1],n=(r[0]||"").split("?"),o=n[1],a=n[0],l=(o||"").split("&"),h=[],u=0;l.length>u;u++){var d=l[u].split("=");_i(d)&&(i.includes(d[0])?h.push(d[0]+"="+e):h.push(l[u]))}var v=a;return null!=o&&(v+="?"+h.join("&")),null!=s&&(v+="#"+s),v},vo=function(t,i){var e=t.match(new RegExp(i+"=([^&]*)"));return e?e[1]:null},co=(t,i)=>t>=i&&ri(),fo=(t,i,e,r)=>{if(0===t){if(ri()){var s=i+1;return s===e&&r(),s}return i}return 0},po=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],go=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...po],_o="<masked>",mo=["li_fat_id"];function bo(t,i,e){if(!Xt)return{};var r,s=i?[...po,...e||[]]:[],n=yo(uo(Xt.URL,s,_o),t);return xs((r={},ws(mo,function(t){var i=Is(t);r[t]=i||null}),r),n)}function yo(t,i){var e=go.concat(i||[]),r={};return ws(e,function(i){var e=ho(t,i);r[i]=e||null}),r}function wo(t){var i=function(t){return t?0===t.search("https?://(.*)google.([^/?]*)")?"google":0===t.search("https?://(.*)bing.com")?"bing":0===t.search("https?://(.*)yahoo.com")?"yahoo":0===t.search("https?://(.*)duckduckgo.com")?"duckduckgo":null:null}(t),e="yahoo"!=i?"q":"p",r={};if(!ki(i)){r.$search_engine=i;var s=Xt?ho(Xt.referrer,e):"";s.length&&(r.ph_keyword=s)}return r}function xo(){return navigator.language||navigator.userLanguage}var So="$direct";function ko(){return(null==Xt?void 0:Xt.referrer)||So}function Eo(t,i,e){var r;void 0===e&&(e=!1);var s=t?[...po,...i||[]]:[],n=null==(r=e?tr(null==Yt?void 0:Yt.href):null==Yt?void 0:Yt.href)?void 0:r.substring(0,1e3);return{r:ko().substring(0,1e3),u:n?uo(n,s,_o):void 0}}function $o(t,i){var e;void 0===i&&(i=!1);var r=t.r,s=t.u,n=i?tr(s):s,o={$referrer:r,$referring_domain:null==r?void 0:r==So?So:null==(e=lo(r))?void 0:e.host};if(n){o.$current_url=n;var a=lo(n);o.$host=null==a?void 0:a.host,o.$pathname=null==a?void 0:a.pathname,xs(o,yo(n))}return r&&xs(o,wo(r)),o}function Po(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(t){return}}function To(){try{return(new Date).getTimezoneOffset()}catch(t){return}}var Co={flags:gt,surveys:et},Fo=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],Ao=t=>t+"_cookie_identity_change_pending",Io=t=>{var i="",e=0;for(var r of t){var s=encodeURIComponent(JSON.stringify(r).slice(1,-1)).length;if(e+s>1e3)break;i+=r,e+=s}return i},Ro="main",Oo=[H,q,W,G,K,gt,J,Z],Mo=t=>-1!==Oo.indexOf(t),Do=(t,i)=>{try{return JSON.stringify(t)===JSON.stringify(i)}catch(e){return t===i}},jo=t=>{if(!t)return{};var i=JSON.parse(t);return bi(i)?i:{}},Bo=(t,i)=>{ws(t,(e,r)=>{var s=oo(r);s&&"event"!==s.exposure||{}.hasOwnProperty.call(i,r)||delete t[r]})},Lo=class{constructor(t,i,e){if(void 0===e&&(e=!0),this.Lo={},this.No=!1,this.qo=!1,this.jo=!1,this.Bo=!1,this.Ho=!1,this.zo=new Map,this.Uo=!1,this.Wo=!1,this.Vo=!1,this.Go=!1,this.Zo=new Set,this.xn=t,this.Jo=e,this.props={},this.Qo=void 0,this.Ko=(t=>{var i="";return t.token&&(i=t.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),t.persistence_name?"ph_"+t.persistence_name:"ph_"+i+"_posthog"})(t),this.To=this.Xo(t),this.jo=this.Yo(t),this.load(),this.ta(),t.debug&&ms.info("Persistence loaded",t.persistence,r({},this.props)),this.update_config(t,t,i),this.save(),Gt){var s=()=>this.flush();Fs(Gt,"beforeunload",s,{capture:!1}),Fs(Gt,"pagehide",s,{capture:!1}),this.ea=t=>{if(this.No&&(!t.storageArea||t.storageArea===(null==Gt?void 0:Gt.localStorage))&&t.key)if(t.key!==this.Ko){if(this.jo){var i=ro.find(i=>t.key===this.ia(i));i&&this.ra(t.key,i)}}else this.ra(t.key,Ro)},Fs(Gt,"storage",this.ea)}}markCrossTabFeatureFlagChanges(t){Object.entries(t).forEach(t=>{var i=t[0],e=t[1],r=this.zo.get(i);if(Mo(i)&&!0!==r)if(!0!==e){var s=new Set(r||[]);e.forEach(t=>s.add(t)),s.size&&this.na(i,s)}else this.na(i,!0)})}onCrossTabFeatureFlagChange(t){return this.Zo.add(t),()=>this.Zo.delete(t)}destroy(){this.ea&&Gt&&(Gt.removeEventListener("storage",this.ea),this.ea=void 0),this.Zo.clear()}ra(t,i,e){if(void 0===e&&(e=!0),this.gi)return!1;var r,s;try{if(s=Vs.Lt(t),ki(s)){var n=this.sa(i);return n.storageValue=null,i!==Ro&&(n.persisted=!1),!1}r=jo(s)}catch(t){return!1}var o=i===Ro?r:Vs.Nt(this.Ko);if(o&&this.oa(o))return!1;var a=this.aa(r,i,e);return i===Ro&&this.jo&&!Do(this.la().main,r)||this.ua(r,i,!0,s),a}oa(t){var i=this.props[u],e=t[u];return!wi(i)&&!wi(e)&&i!==e}ua(t,i,e,r){var s=this.sa(i);s.storageValue=r,i!==Ro&&(s.persisted=e);try{s.fingerprint=this.ha(t,i)}catch(t){s.fingerprint=void 0}}aa(t,i,e){var r=!1;return Oo.forEach(e=>{var s,n=null==(s=oo(e))?void 0:s.storageGroup;if(!(i===Ro&&this.jo&&n||i!==Ro&&n!==i)){var o=e in t,a=this.da(e,o?t[e]:void 0),l=this.zo.has(e)?e in this.props:o;l===e in this.props&&Do(a,this.props[e])||(l?this.va(e,a,!1):this.ca(e,!1),r=!0)}}),r&&e&&this.Zo.forEach(t=>t()),r}fa(){if(!this.No)return!1;try{this.Vo=!1;var t,i=Vs.Lt(this.Ko),e=this.sa(Ro),r=!1,s=!1;if(i!==e.storageValue)if(ki(i))e.storageValue=null;else{if(t=jo(i),this.Vo=!this.Wo&&this.oa(t),this.Vo)return!1;s=this.aa(t,Ro,!1),!this.jo||Do(this.la().main,t)?this.ua(t,Ro,!0,i):e.storageValue=i,r=!0}return this.jo&&ro.forEach(i=>{var e=Vs.Lt(this.ia(i)),n=this.sa(i),o=t||{},a=r&&Oo.some(t=>{var e;return(null==(e=oo(t))?void 0:e.storageGroup)===i&&t in o});if(e!==n.storageValue||a){if(ki(e))return n.storageValue=null,n.persisted=!1,void(a&&(s=this.aa(o,i,!1)||s));var l=jo(e);s=this.aa(l,i,!1)||s,this.ua(l,i,!0,e)}}),s}catch(t){return!1}}na(t,i){this.zo.set(t,i);var e=oo(t);null!=e&&e.volatile||(this.sa((this.jo?null==e?void 0:e.storageGroup:void 0)||Ro).fingerprint=void 0,this.pa(t))}ga(){Oo.forEach(t=>this.zo.set(t,!0))}ta(){if(this.No)try{var t=Vs.Lt(this.Ko),i=jo(t);this.sa(Ro).storageValue=t,Oo.forEach(t=>{var e,r=this.jo?null==(e=oo(t))?void 0:e.storageGroup:void 0,s=r?Vs.Lt(this.ia(r)):null;if(r){var n=this.sa(r);n.storageValue=s,n.persisted=!ki(s)}var o=r&&!ki(s)?jo(s):i;t in this.props?this.ma(t,o[t],this.props[t]):t in o&&this.na(t,!0)})}catch(t){}}da(t,i){var e=this.zo.get(t);if(!e)return i;if(!0===e)return this.props[t];if("$active_feature_flags"===t){var s=new Set(_i(i)?i:[]),n=new Set(_i(this.props[t])?this.props[t]:[]);return e.forEach(t=>n.has(t)?s.add(t):s.delete(t)),Array.from(s)}var o=bi(i)?r({},i):{},a=bi(this.props[t])?this.props[t]:{};return e.forEach(t=>{t in a?o[t]=a[t]:delete o[t]}),o}ma(t,i,e){if(Mo(t)){var r=this.zo.get(t);if(!0!==r){var s=i;if(this.No)try{var n,o=this.jo?null==(n=oo(t))?void 0:n.storageGroup:void 0,a=o?this.ia(o):this.Ko;s=jo(Vs.Lt(a))[t]}catch(t){}var l=new Set(r||[]);if("$active_feature_flags"===t){if(!wi(i)&&!_i(i)||!wi(s)&&!_i(s)||!_i(e))return void this.na(t,!0);var h=new Set(i||[]),u=new Set(s||[]),d=new Set(e);new Set([...h,...d]).forEach(t=>{h.has(t)!==d.has(t)&&l.add(t)}),l.forEach(t=>{u.has(t)===d.has(t)&&l.delete(t)})}else{if(!bi(e))return void(Do(s,e)?this.zo.delete(t):this.na(t,!0));if(!wi(i)&&!bi(i)||wi(i)&&yi(e)&&wi(s))return void this.na(t,!0);var v=bi(i)?i:{},c=bi(s)?s:{};new Set([...Object.keys(v),...Object.keys(e)]).forEach(t=>{t in v==t in e&&Do(v[t],e[t])||l.add(t)}),l.forEach(t=>{t in c==t in e&&Do(c[t],e[t])&&l.delete(t)})}l.size?this.na(t,l):this.zo.delete(t)}}}ya(){var t,i=null==(t=this.xn)?void 0:t.persistence_save_debounce_ms;return $i(i)&&i>0?i:0}ba(t){if(this.xn.cookieWinsOnConflict&&"localstorage+cookie"===this.xn.persistence.toLowerCase())if(t)try{var i=Ys(t,this.xn.cookie_persisted_properties||[]),e=Qs(i,this.xn.cookie_persisted_properties||[]),r=JSON.stringify(i)+"|"+JSON.stringify(e),s=Hs.Lt(this.Ko)||void 0;s&&en(this.Ko,s)===r&&(this._a=r,this.wa=s)}catch(t){}else try{var n=Hs.Lt(this.Ko)||void 0;this._a=n?en(this.Ko,n):void 0,this.wa=n}catch(t){}}syncCookieProperties(){return this.ka(this.xn)}ka(t,i){if(void 0===i&&(i=!1),this.gi&&!i||this.Ho||!t.cookieWinsOnConflict||"localstorage+cookie"!==t.persistence.toLowerCase())return!1;var e;try{e=Hs.Lt(this.Ko)||void 0}catch(t){}if(!e||e===this.wa)return!1;var r,s=en(this.Ko,e);try{r=Xs(JSON.parse(e))}catch(t){return!1}if((Hs.Lt(this.Ko)||void 0)!==e)return!1;this._a=s,this.wa=e;var n=tn(this.Ko,e),o=[...Gs,...n.properties],a={};if(Object.keys(r).forEach(t=>{var i=r[t];(wi(i)||ki(i)||""===i||"$user_state"===t&&"anonymous"!==i&&"identified"!==i)&&(a[t]=!0,delete r[t])}),yi(r))return!1;var l="distinct_id"in r||"anonymous"===r.$user_state||"identified"===r.$user_state,h=this.props,d=h[u],v=h[_t],f=xs({},h);[...Gs,...t.cookie_persisted_properties||[]].forEach(t=>{if(-1!==o.indexOf(t)&&!(t in r)&&!a[t]&&(l||"distinct_id"!==t&&"$user_state"!==t)){var i=f[t];(n.isValid||-1===Gs.indexOf(t)||!1!==i&&0!==i)&&delete f[t]}}),this.props=xs(f,r),Oo.forEach(t=>{var i=t in this.props;t in h===i&&Do(h[t],this.props[t])||(i?this.ma(t,h[t],this.props[t]):this.na(t,!0))}),!l||"$user_state"in r||"$user_state"in this.props||this.va(_t,Bt);var p=this.props[u],g=this.props[_t];return!l||p===d&&g===v||(this.Wo=!0,this.Bo=!0,on.Ot(Ao(this.Ko),!0),this.ca(Z),this.ca(q),this.ca(H),this.ca(W),this.ca(G),this.ca(K),this.ca(gt),this.ca(pt),this.ca(ct),"anonymous"!==g||"identified"!==v&&"anonymous"!==r.$user_state&&(wi(d)||p===d)||(Bo(this.props,r),this.ca(Q)),"identified"===g?this.props.$user_id=p:delete this.props.$user_id,this.ca(c)),!0}consumeCookieIdentityChange(){var t=Ao(this.Ko),i=this.Bo||!!on.Lt(t);return this.Bo=!1,i&&on.Dt(t),i}Sa(t){return void 0===t&&(t=!1),!(this.Ho||this.gi&&!t||!this.xn.cookieWinsOnConflict||"localstorage+cookie"!==this.xn.persistence.toLowerCase()||(this.Ho=!0,0))}xa(){this.Ho&&(wi(this.Ca)||(clearTimeout(this.Ca),this.Ca=void 0),delete this.Lo[Ro],this.Ta(!0))}Ma(t){if(void 0===t&&(t=!0),this.Ho)try{t?this.xa():wi(this.Ca)||(clearTimeout(this.Ca),this.Ca=void 0)}finally{this.Ho=!1}}isDisabled(){return!!this.gi}Xo(t){-1===Fo.indexOf(t.persistence.toLowerCase())&&(ms.critical("Unknown persistence type "+t.persistence+"; falling back to localStorage+cookie"),t.persistence="localStorage+cookie");var i,e=function(t,i){void 0===t&&(t=[]),void 0===i&&(i=!1);var e=[...Gs,...t];return r({},Vs,{Nt(t){try{var r,s={};try{r=Hs.Lt(t)||void 0,s=r?Xs(JSON.parse(r)):{}}catch(t){}var n,o=JSON.parse(Vs.Lt(t)||"{}");if(i){var a=tn(t,r),l=[...Gs,...a.properties],h={};Object.keys(s).forEach(t=>{var i=s[t];ki(i)||""===i||"$user_state"===t&&"anonymous"!==i&&"identified"!==i||(h[t]=i)});var d="distinct_id"in h||"anonymous"===h.$user_state||"identified"===h.$user_state;if(Object.keys(h).length>0){var v,c=o[u],f=null!==(v=o.$user_state)&&void 0!==v?v:"anonymous";e.forEach(t=>{if(-1!==l.indexOf(t)&&!(t in s)&&(d||"distinct_id"!==t&&"$user_state"!==t)){var i=o[t];(a.isValid||-1===Gs.indexOf(t)||!1!==i&&0!==i)&&delete o[t]}}),!d||"$user_state"in s||"$user_state"in o||(o[_t]=Bt),!d||("distinct_id"in h?h[u]:o[u])===c&&("$user_state"in h?h[_t]:o[_t])===f||(Ws.forEach(t=>delete o[t]),"identified"===h.$user_state&&"distinct_id"in h?o.$user_id=h[u]:delete o.$user_id,"identified"!==h.$user_state&&(delete o[tt],delete o[Q]),delete o.__alias)}n=xs(o,h)}else n=xs(s,o);return Vs.Ot(t,n),n}catch(t){}return null},Ot(e,r,s,n,o,a){var l=Vs.Ot(e,r,void 0,void 0,a);try{var h=Ys(r,t);if(Object.keys(h).length){if(i){var u=Ks(e),d=Qs(h,t);if(Hs.Ot(u,d,s,n,o,a),Hs.Lt(u)!==JSON.stringify(d)){Hs.Dt(u,n);var v=Ys(r);return Hs.Ot(e,v,s,n,o,a),l}}Hs.Ot(e,h,s,n,o,a)}}catch(t){Vs.Pt(t)}return l},Dt(t,i){try{null==Gt||Gt.localStorage.removeItem(t),Hs.Dt(t,i),Hs.Dt(Ks(t),i)}catch(t){Vs.Pt(t)}}})}(t.cookie_persisted_properties||[],t.cookieWinsOnConflict),s=!1,n=!1,o=t.persistence.toLowerCase();return"localstorage"===o&&Vs.Et()?(i=Vs,n=!0):"localstorage+cookie"===o&&e.Et()?(i=e,n=!0,s=!0):"sessionstorage"===o&&on.Et()?i=on:"memory"===o?i=sn:"cookie"===o&&Hs.Et()?(i=Hs,s=!0):e.Et()?(i=e,n=!0,s=!0):Hs.Et()?(i=Hs,s=!0):i=sn,this.No=n,this.qo=s,i}ia(t){return this.Ko+"__"+t}Yo(t){return this.No&&!!t.split_storage}properties(){var t={};return ws(this.props,(i,e)=>{var r=oo(e);if(!r||"event"===r.exposure){if(null!=r&&null!=r.shouldSkipFromEventProperties&&r.shouldSkipFromEventProperties(i))return;t[e]=i}}),t}load(t){if(void 0===t&&(t=!1),!this.gi||t){var i=this.xn.cookieWinsOnConflict&&"localstorage+cookie"===this.xn.persistence.toLowerCase(),e=i?Vs.Nt(this.Ko):null,r={};if(i)try{ws(r=Xs(Hs.Nt(this.Ko)),(t,i)=>{(wi(t)||ki(t)||""===t)&&delete r[i]})}catch(t){}var s=this.To.Nt(this.Ko);if(s&&(this.props=xs({},s)),this.jo&&this.Ia(),i&&s){var n,o,a=null==e?void 0:e[u],l=null!==(n=null==e?void 0:e.$user_state)&&void 0!==n?n:"anonymous",h=s[u],d=null!==(o=s.$user_state)&&void 0!==o?o:"anonymous";if(h!==a||d!==l){this.Bo=!0,on.Ot(Ao(this.Ko),!0);var v=xs({},this.props);Ws.forEach(t=>delete v[t]),"anonymous"!==d||"identified"!==l&&"anonymous"!==r.$user_state&&(wi(a)||h===a)||(Bo(v,r),delete v[Q]),this.props=v;var c=new Set;Ws.forEach(t=>{var i,e=null==(i=oo(t))?void 0:i.storageGroup;e&&c.add(e)}),c.forEach(t=>{var i={};ws(this.props,(e,r)=>{var s;(null==(s=oo(r))?void 0:s.storageGroup)===t&&(i[r]=e)}),yi(i)?(Vs.Dt(this.ia(t)),this.Lo[t]={}):Vs.Ot(this.ia(t),i)&&(this.Lo[t]={persisted:!0,fingerprint:this.ha(i,t)})})}}on.Lt(Ao(this.Ko))&&(this.Bo=!0)}}Ia(){for(var t of ro){var i=Vs.Nt(this.ia(t));if(i&&!yi(i)){var e=this.sa(t);e.persisted=!0,this.Ea(t)||(e.fingerprint=this.ha(i,t)),this.Ra(t,i)||xs(this.props,i)}}}Ea(t){return Object.keys(this.props).some(i=>{var e;return(null==(e=oo(i))?void 0:e.storageGroup)===t})}Ra(t,i){var e=Co[t];if(!e)return!1;var r=i[e],s=this.props[e];return $i(r)&&$i(s)&&s>r}refreshKey(t){var i;if(!(this.gi||"$fbc_persistence"===t&&this.Go)){var e=this.jo?null==(i=oo(t))?void 0:i.storageGroup:void 0,r=e?Vs.Nt(this.ia(e)):this.To.Nt(this.Ko);if(r&&t in r)this.va(t,r[t],!1);else{if(e){var s=this.To.Nt(this.Ko);if(s&&t in s)return void this.va(t,s[t],!1)}this.ca(t,!1)}}}save(){if(!this.gi){var t=this.ya();t>0?wi(this.Ca)&&(this.Ca=setTimeout(()=>{this.Ca=void 0,this.Ta()},t)):this.Ta()}}flush(){wi(this.Ca)||(clearTimeout(this.Ca),this.Ca=void 0,this.Ta())}Ta(t){if(void 0===t&&(t=!1),!(this.gi||this.Ho&&!t)){t||(this.syncCookieProperties(),this.Go||this.xn.cookieWinsOnConflict&&"localstorage+cookie"===this.xn.persistence.toLowerCase()||this.refreshKey(g));var i=!t&&!this.Uo;i||(this.Vo=!1);var e=!!i&&this.fa();if(this.Vo)this.xn.debug&&ms.warn("skipping persistence write because storage belongs to a different distinct ID");else{if(this.jo)return this.Aa(),void(e&&this.Zo.forEach(t=>t()));var r=this.Pa(this.To,this.Ko,this.props,Ro);"written"===r&&this.ba(this.props),"failed"!==r&&(this.zo.clear(),this.Wo=!1,this.Go=!1),e&&this.Zo.forEach(t=>t())}}}Aa(){var t=this,i=this.la(),e=i.main,r=i.groups,s=this.Pa(this.To,this.Ko,e,Ro);"written"===s&&this.ba(e),"failed"!==s&&(this.Wo=!1,this.Go=!1,Oo.forEach(t=>{var i;null!=(i=oo(t))&&i.storageGroup||this.zo.delete(t)}));var n=function(i){var e,s=r[i];if(yi(s)&&(null==(e=t.Lo[i])||!e.persisted))return Oo.forEach(e=>{var r;(null==(r=oo(e))?void 0:r.storageGroup)===i&&t.zo.delete(e)}),1;var n=t.Pa(Vs,t.ia(i),s,i);"failed"!==n&&Oo.forEach(e=>{var r=oo(e);(null==r?void 0:r.storageGroup)!==i||"written"!==n&&r.volatile||t.zo.delete(e)})};for(var o of ro)if(n(o))continue}la(){var t={},i={flags:{},surveys:{}};return ws(this.props,(e,r)=>{var s,n=null==(s=oo(r))?void 0:s.storageGroup;n?i[n][r]=e:t[r]=e}),{main:t,groups:i}}ha(t,i){if(i===Ro)return JSON.stringify(t)+"|"+this.Fa+"|"+this.Oa+"|"+this.$a;var e={};return ws(t,(t,i)=>{var r;e[i]=null!=(r=oo(i))&&r.volatile?"__volatile__":t}),JSON.stringify(e)}Pa(t,i,e,r){var s,n=this.sa(r);if(r!==Ro&&!n.dirty&&!wi(n.fingerprint))return"skipped";try{if((s=this.ha(e,r))===n.fingerprint)return n.dirty=!1,"skipped"}catch(t){s=void 0}return t.Ot(i,e,this.Fa,this.Oa,this.$a,this.xn.debug)?(n.dirty=!1,r!==Ro&&(n.persisted=!0),wi(s)||(n.fingerprint=s),this.No&&(n.storageValue=Vs.Lt(i)),"written"):(this.xn.debug&&ms.warn('failed to persist storage entry "'+i+'"; will retry on next save'),"failed")}remove(t){var i=(void 0===t?{}:t).keepGroupEntries,e=void 0!==i&&i;if(this.ga(),wi(this.Ca)||(clearTimeout(this.Ca),this.Ca=void 0),this.To.Dt(this.Ko,!1),this.To.Dt(this.Ko,!0),!e&&this.Jo)for(var r of ro)Vs.Dt(this.ia(r));e?delete this.Lo[Ro]:this.Lo={},this._a=void 0,this.wa=void 0}clear(){this.remove(),this.props={}}register_once(t,i,e){if(bi(t)){this.syncCookieProperties(),wi(i)&&(i="None"),this.Fa=wi(e)?this.Da:e;var r=!1;if(ws(t,(t,e)=>{this.props.hasOwnProperty(e)&&this.props[e]!==i||(this.va(e,t),r=!0)}),r)return this.save(),!0}return!1}register(t,i){if(bi(t)){this.syncCookieProperties(),this.Fa=wi(i)?this.Da:i;var e=!1;if(ws(t,(i,r)=>{t.hasOwnProperty(r)&&(this.props[r]!==i||bi(i)||_i(i))&&(this.va(r,i),e=!0)}),e)return this.save(),!0}return!1}unregister(t){this.syncCookieProperties();var i="string"==typeof t?[t]:t,e=!1;for(var r of i)r in this.props&&(this.ca(r),e=!0);e&&this.save()}update_campaign_params(){var t=null==Xt?void 0:Xt.URL;if(t!==this.Qo){var i=bo(this.xn.custom_campaign_params,this.xn.mask_personal_data_properties,this.xn.custom_personal_data_properties),e=!yi($s(i));return e&&this.register(i),this.Qo=t,e?i:void 0}}update_search_keyword(){var t;this.register((t=null==Xt?void 0:Xt.referrer)?wo(t):{})}update_referrer_info(){var t;this.register_once({$referrer:ko(),$referring_domain:null!=Xt&&Xt.referrer&&(null==(t=lo(Xt.referrer))?void 0:t.host)||So},void 0)}set_initial_person_info(){if(!this.props.$initial_campaign_params&&!this.props.$initial_referrer_info){var t=Eo(this.xn.mask_personal_data_properties,this.xn.custom_personal_data_properties,this.xn.disable_capture_url_hashes);this.register_once({[xt]:this.qo?{r:Io(t.r),u:t.u?Io(t.u):void 0}:t},void 0)}}get_initial_props(){var t={};ws([wt,yt],i=>{var e=this.props[i];e&&ws(e,function(i,e){t["$initial_"+vi(e)]=i})});var i=this.props[xt];return i&&xs(t,function(t,i){void 0===i&&(i=!1);var e=$o(t,i),r={};return ws(e,function(t,i){r["$initial_"+vi(i)]=t}),r}(i,this.xn.disable_capture_url_hashes)),t}safe_merge(t){return ws(this.props,function(i,e){e in t||(t[e]=i)}),t}update_config(t,i,e){var s=t.persistence!==i.persistence,n=!((t,i)=>{if(t.length!==i.length)return!1;var e=[...t].sort(),r=[...i].sort();return e.every((t,i)=>t===r[i])})(t.cookie_persisted_properties||[],i.cookie_persisted_properties||[]),o=s||n,a=t.cookieWinsOnConflict!==i.cookieWinsOnConflict,l=t.disable_persistence||!!e,h=!!this.gi&&!l;l||this.ka(i,h),this.xn=t,!l&&(s||n||a)&&(this._a=void 0,this.wa=void 0,this.ka(r({},t,{cookie_persisted_properties:i.cookie_persisted_properties}),h));var u=o||a?this.Xo(t):this.To;this.La();var d=this.Yo(t),v=o||d!==this.jo,c=!l&&(v||t.cross_subdomain_cookie!==this.Oa||t.secure_cookie!==this.$a)&&this.Sa(h);this.Uo=v;try{if(this.Da=this.Fa=t.cookie_expiration,this.set_disabled(l),this.set_cross_subdomain(t.cross_subdomain_cookie),this.set_secure(t.secure_cookie),v){var f=this.props;this.clear(),this.To=u,this.jo=d,this.props=f,this.save()}else a&&(this.To=u,l||(delete this.Lo[Ro],this.Ta()))}finally{this.Uo=!1,c&&this.Ma()}}La(){var t=this.props[xt];if(this.qo&&bi(t)&&"string"==typeof t.r){var i=Io(t.r),e="string"==typeof t.u?Io(t.u):t.u;i===t.r&&e===t.u||this.va(xt,r({},t,{r:i,u:e}))}}set_disabled(t){this.gi=t,this.gi?this.remove():this.save()}set_cross_subdomain(t){t!==this.Oa&&(this.Oa=t,this.remove({keepGroupEntries:!0}),this.save())}set_secure(t){t!==this.$a&&(this.$a=t,this.remove({keepGroupEntries:!0}),this.save())}set_event_timer(t,i){var e=this.props.__timers||{};e[t]=i,this.va(_,e),this.save()}remove_event_timer(t){var i=this.props.__timers||{},e=i[t];return wi(e)||(delete i[t],this.va(_,i),this.save()),e}get_property(t){return this.props[t]}set_property(t,i){this.va(t,i),this.save()}va(t,i,e){var r;void 0===e&&(e=!0);var s=this.props[t];this.props[t]=i,e&&("distinct_id"!==t&&"$user_state"!==t||s===i||(this.Wo=!0),"$fbc_persistence"!==t||Do(s,i)||(this.Go=!0),this.ma(t,s,i),null!=(r=oo(t))&&r.volatile||this.pa(t))}ca(t,i){void 0===i&&(i=!0),delete this.props[t],i&&(Mo(t)&&this.na(t,!0),"$fbc_persistence"===t&&(this.Go=!0),this.pa(t))}pa(t){var i,e=null==(i=oo(t))?void 0:i.storageGroup;e&&(this.sa(e).dirty=!0)}sa(t){return this.Lo[t]||(this.Lo[t]={})}},No="gzip-js",zo="base64",Uo="events",Ho="cancelEvents",qo="survey shown",Vo="survey dismissed",Wo="survey sent",Go="$survey_last_seen_date",Ko="popover";function Jo(t){var i=!0;return{dispose(){if(i){i=!1;var e=t();e&&mi(e.then)&&e.then(void 0,()=>{})}}}}var Xo=bs("[RateLimiter]"),Yo=class{constructor(t){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=t=>{var i=t.text;if(i&&i.length)try{(JSON.parse(i).quota_limited||[]).forEach(t=>{Xo.info((t||"events")+" is quota limited."),this.serverLimits[t]=(new Date).getTime()+6e4})}catch(t){return void Xo.warn('could not rate limit - continuing. Error: "'+(null==t?void 0:t.message)+'"',{text:i})}},this.instance=t,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var t;return(null==(t=this.instance.config.rate_limiting)?void 0:t.events_per_second)||10}get captureEventsBurstLimit(){var t;return Math.max((null==(t=this.instance.config.rate_limiting)?void 0:t.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(t){var i,e,r;void 0===t&&(t=!1);var s=this.captureEventsBurstLimit,n=this.captureEventsPerSecond,o=(new Date).getTime(),a=null!==(i=null==(e=this.instance.persistence)?void 0:e.get_property("$capture_rate_limit"))&&void 0!==i?i:{tokens:s,last:o};a.tokens+=(o-a.last)/1e3*n,a.last=o,a.tokens>s&&(a.tokens=s);var l=1>a.tokens;if(l||t||(a.tokens=Math.max(0,a.tokens-1)),l&&!t){var h=($i(a.dropped)?a.dropped:0)+1;a.dropped=h,!this.lastEventRateLimited&&this.Na(h)&&(a.dropped=0)}return this.lastEventRateLimited=l,null==(r=this.instance.persistence)||r.set_property(bt,a),{isRateLimited:l,remainingTokens:a.tokens}}qa(t){var i=this.instance.config.property_denylist;return!_i(i)||!i.includes(t)}ja(){var t;if(this.qa("$current_url")&&this.qa("$pathname")&&null!=Yt&&Yt.pathname)return""+(null!==(t=Yt.origin)&&void 0!==t?t:"")+Yt.pathname}Na(t){var i,e,r=this.captureEventsBurstLimit,s=this.captureEventsPerSecond,n=this.ja(),o=this.qa("$session_id")?null==(i=(e=this.instance).get_session_id)?void 0:i.call(e):void 0,a=[t+" 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 "+s+" events per second and "+r+" events burst limit."},{skip_client_rate_limiting:!0})}isServerRateLimited(t){var i=this.serverLimits[t||"events"]||!1;return!1!==i&&(new Date).getTime()<i}},Zo=bs("[RemoteConfig]"),Qo=class{constructor(t){this._instance=t}get remoteConfig(){var t;return null==(t=ni._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.config}Ba(t){var i,e;null!=(i=ni.__PosthogExtensions__)&&i.loadExternalDependency?null==(e=ni.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,"remote-config",()=>t(this.remoteConfig)):t()}Ha(t){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback:t})}load(){try{if(this.remoteConfig)return Zo.info("Using preloaded remote config",this.remoteConfig),void this.za(this.remoteConfig);if(this._instance.Ua())return void Zo.warn("Remote config is disabled. Falling back to local config.");this.Ba(t=>{if(!t)return Zo.info("No config found after loading remote JS config. Falling back to JSON."),void this.Ha(t=>{this.za(t.json,t)});this.za(t)})}catch(t){Zo.error("Error loading remote config",t),this.za()}}za(t,i){!t&&i&&(0===i.statusCode?i.error||Zo.warn("Failed to fetch remote config from PostHog."):Zo.error("Failed to fetch remote config from PostHog."));try{this._instance.za(t?{ok:!0,config:t}:{ok:!1})}catch(t){Zo.error("Error applying remote config",t)}if(!1!==(null==t?void 0:t.hasFeatureFlags)&&!this._instance.config.advanced_disable_feature_flags_on_first_load)try{var e;null==(e=this._instance.featureFlags)||e.ensureFlagsLoaded()}catch(t){Zo.error("Error loading feature flags",t)}}},ta=Uint8Array,ia=Uint16Array,ea=Uint32Array,ra=new ta([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]),sa=new ta([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]),na=new ta([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),oa=function(t,i){for(var e=new ia(31),r=0;31>r;++r)e[r]=i+=1<<t[r-1];var s=new ea(e[30]);for(r=1;30>r;++r)for(var n=e[r];e[r+1]>n;++n)s[n]=n-e[r]<<5|r;return[e,s]},aa=oa(ra,2),la=aa[1];aa[0][28]=258,la[258]=28;for(var ha=oa(sa,0)[1],ua=new ia(32768),da=0;32768>da;++da){var va=(43690&da)>>>1|(21845&da)<<1;ua[da]=((65280&(va=(61680&(va=(52428&va)>>>2|(13107&va)<<2))>>>4|(3855&va)<<4))>>>8|(255&va)<<8)>>>1}var ca=function(t,i,e){for(var r=t.length,s=0,n=new ia(i);r>s;++s)++n[t[s]-1];var o,a=new ia(i);for(s=0;i>s;++s)a[s]=a[s-1]+n[s-1]<<1;if(e){o=new ia(1<<i);var l=15-i;for(s=0;r>s;++s)if(t[s])for(var h=s<<4|t[s],u=i-t[s],d=a[t[s]-1]++<<u,v=d|(1<<u)-1;v>=d;++d)o[ua[d]>>>l]=h}else for(o=new ia(r),s=0;r>s;++s)o[s]=ua[a[t[s]-1]++]>>>15-t[s];return o},fa=new ta(288);for(da=0;144>da;++da)fa[da]=8;for(da=144;256>da;++da)fa[da]=9;for(da=256;280>da;++da)fa[da]=7;for(da=280;288>da;++da)fa[da]=8;var pa=new ta(32);for(da=0;32>da;++da)pa[da]=5;var ga=ca(fa,9,0),_a=ca(pa,5,0),ma=function(t){return(t/8|0)+(7&t&&1)},ba=function(t,i,e){(null==i||0>i)&&(i=0),(null==e||e>t.length)&&(e=t.length);var r=new(t instanceof ia?ia:t instanceof ea?ea:ta)(e-i);return r.set(t.subarray(i,e)),r},ya=function(t,i,e){var r=i/8|0;t[r]|=e<<=7&i,t[r+1]|=e>>>8},wa=function(t,i,e){var r=i/8|0;t[r]|=e<<=7&i,t[r+1]|=e>>>8,t[r+2]|=e>>>16},xa=function(t,i){for(var e=[],r=0;t.length>r;++r)t[r]&&e.push({s:r,f:t[r]});var s=e.length,n=e.slice();if(!s)return[new ta(0),0];if(1==s){var o=new ta(e[0].s+1);return o[e[0].s]=1,[o,1]}e.sort(function(t,i){return t.f-i.f}),e.push({s:-1,f:25001});var a=e[0],l=e[1],h=0,u=1,d=2;for(e[0]={s:-1,f:a.f+l.f,l:a,r:l};u!=s-1;)a=e[e[d].f>e[h].f?h++:d++],l=e[h!=u&&e[d].f>e[h].f?h++:d++],e[u++]={s:-1,f:a.f+l.f,l:a,r:l};var v=n[0].s;for(r=1;s>r;++r)n[r].s>v&&(v=n[r].s);var c=new ia(v+1),f=Sa(e[u-1],c,0);if(f>i){r=0;var p=0,g=f-i,_=1<<g;for(n.sort(function(t,i){return c[i.s]-c[t.s]||t.f-i.f});s>r;++r){var m=n[r].s;if(i>=c[m])break;p+=_-(1<<f-c[m]),c[m]=i}for(p>>>=g;p>0;){var b=n[r].s;i>c[b]?p-=1<<i-c[b]++-1:++r}for(;r>=0&&p;--r){var y=n[r].s;c[y]==i&&(--c[y],++p)}f=i}return[new ta(c),f]},Sa=function(t,i,e){return-1==t.s?Math.max(Sa(t.l,i,e+1),Sa(t.r,i,e+1)):i[t.s]=e},ka=function(t){for(var i=t.length;i&&!t[--i];);for(var e=new ia(++i),r=0,s=t[0],n=1,o=function(t){e[r++]=t},a=1;i>=a;++a)if(t[a]==s&&a!=i)++n;else{if(!s&&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(s),--n;n>6;n-=6)o(8304);n>2&&(o(n-3<<5|8208),n=0)}for(;n--;)o(s);n=1,s=t[a]}return[e.subarray(0,r),i]},Ea=function(t,i){for(var e=0,r=0;i.length>r;++r)e+=t[r]*i[r];return e},$a=function(t,i,e){var r=e.length,s=ma(i+2);t[s]=255&r,t[s+1]=r>>>8,t[s+2]=255^t[s],t[s+3]=255^t[s+1];for(var n=0;r>n;++n)t[s+n+4]=e[n];return 8*(s+4+r)},Pa=function(t,i,e,r,s,n,o,a,l,h,u){ya(i,u++,e),++s[256];for(var d=xa(s,15),v=d[0],c=d[1],f=xa(n,15),p=f[0],g=f[1],_=ka(v),m=_[0],b=_[1],y=ka(p),w=y[0],x=y[1],S=new ia(19),k=0;m.length>k;++k)S[31&m[k]]++;for(k=0;w.length>k;++k)S[31&w[k]]++;for(var E=xa(S,7),P=E[0],T=E[1],C=19;C>4&&!P[na[C-1]];--C);var F,A,I,R,O=h+5<<3,M=Ea(s,fa)+Ea(n,pa)+o,D=Ea(s,v)+Ea(n,p)+o+14+3*C+Ea(S,P)+(2*S[16]+3*S[17]+7*S[18]);if(M>=O&&D>=O)return $a(i,u,t.subarray(l,l+h));if(ya(i,u,1+(M>D)),u+=2,M>D){F=ca(v,c,0),A=v,I=ca(p,g,0),R=p;var j=ca(P,T,0);for(ya(i,u,b-257),ya(i,u+5,x-1),ya(i,u+10,C-4),u+=14,k=0;C>k;++k)ya(i,u+3*k,P[na[k]]);u+=3*C;for(var B=[m,w],L=0;2>L;++L){var N=B[L];for(k=0;N.length>k;++k)ya(i,u,j[z=31&N[k]]),u+=P[z],z>15&&(ya(i,u,N[k]>>>5&127),u+=N[k]>>>12)}}else F=ga,A=fa,I=_a,R=pa;for(k=0;a>k;++k)if(r[k]>255){var z;wa(i,u,F[257+(z=r[k]>>>18&31)]),u+=A[z+257],z>7&&(ya(i,u,r[k]>>>23&31),u+=ra[z]);var U=31&r[k];wa(i,u,I[U]),u+=R[U],U>3&&(wa(i,u,r[k]>>>5&8191),u+=sa[U])}else wa(i,u,F[r[k]]),u+=A[r[k]];return wa(i,u,F[256]),u+A[256]},Ta=new ea([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Ca=new ta(0),Fa=function(){for(var t=new ea(256),i=0;256>i;++i){for(var e=i,r=9;--r;)e=(1&e&&3988292384)^e>>>1;t[i]=e}return t}(),Aa=function(t,i,e){for(;e;++i)t[i]=e,e>>>=8};function Ia(t,i){void 0===i&&(i={});var e=function(){var t=4294967295;return{p(i){for(var e=t,r=0;i.length>r;++r)e=Fa[255&e^i[r]]^e>>>8;t=e},d(){return 4294967295^t}}}(),r=t.length;e.p(t);var s,n,o,a,l,h,u=(a=10+((s=i).filename&&s.filename.length+1||0),l=8,function(t,i,e,r,s,n){var o=t.length,a=new ta(r+o+5*(1+Math.floor(o/7e3))+s),l=a.subarray(r,a.length-s),h=0;if(!i||8>o)for(var u=0;o>=u;u+=65535){var d=u+65535;o>d?h=$a(l,h,t.subarray(u,d)):(l[u]=n,h=$a(l,h,t.subarray(u,o)))}else{for(var v=Ta[i-1],c=v>>>13,f=8191&v,p=(1<<e)-1,g=new ia(32768),_=new ia(p+1),m=Math.ceil(e/3),b=2*m,y=function(i){return(t[i]^t[i+1]<<m^t[i+2]<<b)&p},w=new ea(25e3),x=new ia(288),S=new ia(32),k=0,E=0,P=(u=0,0),T=0,C=0;o>u;++u){var F=y(u),A=32767&u,I=_[F];if(g[A]=I,_[F]=A,u>=T){var R=o-u;if((k>7e3||P>24576)&&R>423){h=Pa(t,l,0,w,x,S,E,P,C,u-C,h),P=k=E=0,C=u;for(var O=0;286>O;++O)x[O]=0;for(O=0;30>O;++O)S[O]=0}var M=2,D=0,j=f,B=A-I&32767;if(R>2&&F==y(u-B))for(var L=Math.min(c,R)-1,N=Math.min(32767,u),z=Math.min(258,R);N>=B&&--j&&A!=I;){if(t[u+M]==t[u+M-B]){for(var U=0;z>U&&t[u+U]==t[u+U-B];++U);if(U>M){if(M=U,D=B,U>L)break;var H=Math.min(B,U-2),q=0;for(O=0;H>O;++O){var V=u-B+O+32768&32767,W=V-g[V]+32768&32767;W>q&&(q=W,I=V)}}}B+=(A=I)-(I=g[A])+32768&32767}if(D){w[P++]=268435456|la[M]<<18|ha[D];var G=31&la[M],K=31&ha[D];E+=ra[G]+sa[K],++x[257+G],++S[K],T=u+M,++k}else w[P++]=t[u],++x[t[u]]}}h=Pa(t,l,n,w,x,S,E,P,C,u-C,h),n||(h=$a(l,h,Ca))}return ba(a,0,r+ma(h)+s)}(n=t,null==(o=i).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,!h)),d=u.length;return function(t,i){var e=i.filename;if(t[0]=31,t[1]=139,t[2]=8,t[8]=2>i.level?4:9==i.level?2:0,t[9]=3,0!=i.mtime&&Aa(t,4,Math.floor(new Date(i.mtime||Date.now())/1e3)),e){t[3]=8;for(var r=0;e.length>=r;++r)t[r+10]=e.charCodeAt(r)}}(u,i),Aa(u,d-8,e.d()),Aa(u,d-4,r),u}var Ra=!!Qt||!!Zt,Oa="text/plain",Ma=!1,Da=(t,i)=>{var e=t.split("#"),r=e[1],s=e[0].split("?"),n=s[0],o=s[1];if(!o)return t;var a=o.split("&").filter(t=>t.split("=")[0]!==i).join("&");return n+(a?"?"+a:"")+(r?"#"+r:"")},ja=function(t,i,e){var s;void 0===e&&(e=!0);var n=t.split("?"),o=n[0],a=n[1],l=r({},i),h=null!==(s=null==a?void 0:a.split("&").map(t=>{var i,r=t.split("="),s=r[0],n=e&&null!==(i=l[s])&&void 0!==i?i:r[1];return delete l[s],s+"="+n}))&&void 0!==s?s:[],u=function(t,i){var e,r;void 0===i&&(i="&");var s=[];return ws(t,function(t,i){wi(t)||wi(i)||"undefined"===i||(e=encodeURIComponent((t=>t instanceof File)(t)?t.name:t.toString()),r=encodeURIComponent(i),s[s.length]=r+"="+e)}),s.join(i)}(l);return u&&h.push(u),h.length>0?o+"?"+h.join("&"):o},Ba=t=>{if(t.Wa)return t.Wa;var i=t.data,e=t.compression;if(i){if(e===No){var r=Ia(function(t){var i=t.length;if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(t);for(var e=new ta(t.length+(t.length>>>1)),r=0,s=function(t){e[r++]=t},n=0;i>n;++n){if(r+5>e.length){var o=new ta(r+8+(i-n<<1));o.set(e),e=o}var a=t.charCodeAt(n);128>a?s(a):2048>a?(s(192|a>>>6),s(128|63&a)):a>55295&&57344>a?(s(240|(a=65536+(1047552&a)|1023&t.charCodeAt(++n))>>>18),s(128|a>>>12&63),s(128|a>>>6&63),s(128|63&a)):(s(224|a>>>12),s(128|a>>>6&63),s(128|63&a))}return ba(e,0,r)}(ao(i)),{mtime:0});return{contentType:Oa,body:r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength),estimatedSize:r.byteLength}}if(e===zo){var s=(t=>"data="+encodeURIComponent("string"==typeof t?t:ao(t)))(function(t){return t?btoa(encodeURIComponent(t).replace(/%([0-9A-F]{2})/g,(t,i)=>String.fromCharCode(parseInt(i,16)))):t}(ao(i)));return{contentType:"application/x-www-form-urlencoded",body:s,estimatedSize:new Blob([s]).size}}var n=ao(i);return{contentType:"application/json",body:n,estimatedSize:new Blob([n]).size}}},La=t=>{var i,e,s=()=>"sendBeacon"===t.transport?{url:ja(t.url,{compression:zo}),encodedBody:Ba(r({},t,{compression:zo,Wa:void 0}))}:{url:Da(t.url,"compression"),encodedBody:Ba(r({},t,{compression:void 0,Wa:void 0}))};try{i=Ba(t)}catch(i){if(Kr(t.compression,ho(t.url,"compression")))return ms.error("Failed to gzip request body, sending uncompressed payload",i),s();throw i}return i&&Kr(t.compression,ho(t.url,"compression"))&&!((e=i.body)instanceof ArrayBuffer?Gr(new Uint8Array(e)):ArrayBuffer.isView(e)&&Gr(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)))?(Ma=!0,s()):{url:t.url,encodedBody:i}},Na=t=>{try{return La(t)}catch(i){return ms.error(i),void(null==t.callback||t.callback({statusCode:0,error:i}))}},za=function(){var t=n(function*(t){var i=yield function(t,i,e){return Zr.apply(this,arguments)}(ao(t.data),l.DEBUG,{rethrow:!0});if(!i)return t;var e=yield i.arrayBuffer();return r({},t,{Wa:{contentType:Oa,body:e,estimatedSize:e.byteLength}})});return function(i){return t.apply(this,arguments)}}(),Ua=/Failed to fetch|NetworkError|Load failed/i,Ha=t=>"TypeError"===(null==t?void 0:t.name)&&Ua.test((null==t?void 0:t.message)||""),qa=t=>{var i=Na(t);if(i){var e=new Qt,r=i.encodedBody;e.open(t.method||"GET",i.url,!0);var s=null!=r?r:{},n=s.contentType,o=s.body;ws(t.headers,function(t,i){e.setRequestHeader(i,t)}),n&&e.setRequestHeader("Content-Type",n),t.timeout&&(e.timeout=t.timeout),e.onreadystatechange=()=>{if(4===e.readyState){var i={statusCode:e.status,text:e.responseText};if(200===e.status)try{i.json=JSON.parse(e.responseText)}catch(t){}null==t.callback||t.callback(i)}},e.send(o)}},Va=t=>{var i=Na(t);if(i){var e=i.url,s=i.encodedBody,n=null!=s?s:{},o=n.contentType,a=n.body,l=n.estimatedSize,h=new Headers;ws(t.headers,function(t,i){h.append(i,t)}),o&&h.append("Content-Type",o);var u=null,d=!1;if(ti){var v=new ti;u={signal:v.signal,timeout:setTimeout(()=>{var i;d=!0,v.abort(Qe("AbortError","PostHog request timed out"+((i=t.timeout)?" after "+i+"ms":"")))},t.timeout)}}var c=i=>{d&&"AbortError"===(null==i?void 0:i.name)||Ha(i)?ms.warn(i):ms.error(i),null==t.callback||t.callback({statusCode:0,error:i})};try{var f;Zt(e,r({method:(null==t?void 0:t.method)||"GET",headers:h,keepalive:"POST"===t.method&&!t.Va&&52428.8>(l||0),body:a,signal:null==(f=u)?void 0:f.signal},t.fetchOptions)).then(i=>i.text().then(e=>{var r={statusCode:i.status,text:e};if(200===i.status)try{r.json=JSON.parse(e)}catch(t){ms.error(t)}null==t.callback||t.callback(r)})).catch(c).finally(()=>u?clearTimeout(u.timeout):null)}catch(t){u&&clearTimeout(u.timeout),c(t)}}},Wa=t=>{try{var i,e=La(t),s=e.url,n=e.encodedBody,o=null!=n?n:{},a=o.body,l=o.estimatedSize;if(!a)return;var h=a instanceof Blob?a:new Blob([a],{type:o.contentType});if(Jt.sendBeacon(s,h))return;var u=_i(t.data)?t.data:null==(i=t.data)?void 0:i.batch;if(_i(u)&&u.length>1&&(null!=l?l:0)>16384){var d=Math.ceil(u.length/2),v=i=>_i(t.data)?i:r({},t.data,{batch:i});return Wa(r({},t,{data:v(u.slice(0,d))})),void Wa(r({},t,{data:v(u.slice(d))}))}ms.warn("Beacon of ~"+(null!=l?l:0)+" bytes was rejected by the browser, falling back to "+(Zt?"fetch":"XHR")),Zt?Va(r({},t,{Va:!0})):qa(t)}catch(t){ms.warn("Beacon send failed",t)}},Ga=(t,i,e,s)=>{var n="query"===s?"POST"===i?"sent_at":"_":void 0;return ja(e===No?Da(t,"compression"):t,r({},n?{[n]:Date.now().toString()}:{},e===No?{}:{compression:e}))},Ka=[];Zt&&Ka.push({transport:"fetch",method:Va}),Qt&&Ka.push({transport:"XHR",method:qa}),null!=Jt&&Jt.sendBeacon&&Ka.push({transport:"sendBeacon",method:Wa});var Ja=class{constructor(t,i){this.Ga=!0,this.Za=[],this.Ja=zi((null==i?void 0:i.flush_interval_ms)||3e3,250,5e3,ms.createLogger("flush interval"),3e3),this.Qa=t}enqueue(t){this.Za.push(t),this.Ka||this.Xa()}unload(){this.Ya();var t=this.Za.length>0?this.tl():{},i=Object.values(t);[...i.filter(t=>0===t.url.indexOf("/e")),...i.filter(t=>0!==t.url.indexOf("/e"))].map(t=>{this.el(r({},t,{transport:"sendBeacon"}))})}enable(){this.Ga=!1,this.Xa()}Xa(){var t=this;this.Ga||(this.Ka=setTimeout(()=>{if(this.Ya(),this.Za.length>0){var i=this.tl(),e=function(){var e=i[r],s=(new Date).getTime();e.data&&_i(e.data)&&ws(e.data,t=>{t.offset=Math.abs(t.timestamp-s),delete t.timestamp}),t.el(e)};for(var r in i)e()}},this.Ja))}el(t){try{this.Qa(t)}catch(t){ms.error(t)}}Ya(){clearTimeout(this.Ka),this.Ka=void 0}tl(){var t={};return ws(this.Za,i=>{var e,s=i,n=(s?s.batchKey:null)||s.url;wi(t[n])&&(t[n]=r({},s,{data:[]})),null==(e=t[n].data)||e.push(s.data)}),this.Za=[],t}},Xa=class{constructor(t){this._instance=t,this.il=!1,this.rl=3e3,this.Za=[],this.Za=[],this.nl=!0,this.resume()}resume(){if(!wi(Gt)&&"onLine"in Gt.navigator){if(this.nl=Gt.navigator.onLine,this.sl)return;this.sl=()=>{this.nl=!0,this.ol()},this.al=()=>{this.nl=!1},Fs(Gt,"online",this.sl),Fs(Gt,"offline",this.al)}}get length(){return this.Za.length}retriableRequest(i){var s=i.retriesPerformedSoFar,n=e(i,t);Pi(s)&&(n.url=ja(n.url,{retry_count:s})),this._instance._send_request(r({},n,{callback:t=>{if(200!==t.statusCode&&(400>t.statusCode||t.statusCode>=500)){if((0===t.statusCode?3:10)>(null!=s?s:0))return void this.Is(r({retriesPerformedSoFar:s},n));0===t.statusCode&&ms.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!=s?s:0)+" retries.")}null==n.callback||n.callback(t)}}))}Is(t){var i=t.retriesPerformedSoFar||0;t.retriesPerformedSoFar=i+1;var e=function(t){var i=3e3*Math.pow(2,t),e=i/2,r=Math.min(18e5,i),s=(Math.random()-.5)*(r-e);return Math.ceil(r+s)}(i),r=Date.now()+e;this.Za.push({retryAt:r,requestOptions:t});var s="Enqueued failed request for retry in "+e;navigator.onLine||(s+=" (Browser is offline)"),ms.warn(s),this.il||(this.il=!0,this.ll())}ll(){if(this.ul&&clearTimeout(this.ul),0===this.Za.length)return this.il=!1,void(this.ul=void 0);this.ul=setTimeout(()=>{this.nl&&this.Za.length>0&&this.ol(),this.ll()},this.rl)}ol(){var t=Date.now(),i=[],e=this.Za.filter(e=>t>e.retryAt||(i.push(e),!1));if(this.Za=i,e.length>0)for(var r of e)this.retriableRequest(r.requestOptions)}unload(){for(var t of(this.ul&&(clearTimeout(this.ul),this.ul=void 0),this.il=!1,wi(Gt)||(this.sl&&(Gt.removeEventListener("online",this.sl),this.sl=void 0),this.al&&(Gt.removeEventListener("offline",this.al),this.al=void 0)),this.Za)){var i=t.requestOptions;try{this._instance._send_request(r({},i,{transport:"sendBeacon"}))}catch(t){ms.error(t)}}this.Za=[]}},Ya=class{constructor(t){this._instance=t,this.hl=()=>{var t,i,e,r;this.dl||(this.dl={});var s=this.scrollElement(),n=this.scrollY(),o=s?Math.max(0,s.scrollHeight-s.clientHeight):0,a=n+((null==s?void 0:s.clientHeight)||0),l=(null==s?void 0:s.scrollHeight)||0;this.dl.lastScrollY=Math.ceil(n),this.dl.maxScrollY=Math.max(n,null!==(t=this.dl.maxScrollY)&&void 0!==t?t:0),this.dl.maxScrollHeight=Math.max(o,null!==(i=this.dl.maxScrollHeight)&&void 0!==i?i:0),this.dl.lastContentY=a,this.dl.maxContentY=Math.max(a,null!==(e=this.dl.maxContentY)&&void 0!==e?e:0),this.dl.maxContentHeight=Math.max(l,null!==(r=this.dl.maxContentHeight)&&void 0!==r?r:0)}}get vl(){return this._instance.config.scroll_root_selector}getContext(){return this.dl}resetContext(){var t=this.dl;return setTimeout(this.hl,0),t}startMeasuringScrollPosition(){Fs(Gt,"scroll",this.hl,{capture:!0}),Fs(Gt,"scrollend",this.hl,{capture:!0}),Fs(Gt,"resize",this.hl)}scrollElement(){var t;if(!this.vl)return null==Gt||null==(t=Gt.document)?void 0:t.documentElement;for(var i of _i(this.vl)?this.vl:[this.vl]){var e,r=null==Gt||null==(e=Gt.document)?void 0:e.querySelector(i);if(r)return r}}cl(t){var i,e,r="y"===t?"scrollTop":"scrollLeft";if(this.vl){var s=this.scrollElement();return s&&s[r]||0}return Gt?"y"===t?Gt.scrollY||Gt.pageYOffset||(null==(i=Gt.document)||null==(i=i.documentElement)?void 0:i.scrollTop)||0:Gt.scrollX||Gt.pageXOffset||(null==(e=Gt.document)||null==(e=e.documentElement)?void 0:e.scrollLeft)||0:0}scrollY(){return this.cl("y")}scrollX(){return this.cl("x")}},Za=t=>Eo(null==t?void 0:t.config.mask_personal_data_properties,null==t?void 0:t.config.custom_personal_data_properties,null==t?void 0:t.config.disable_capture_url_hashes),Qa=class{constructor(t,i,e,r){this.Be=t=>{var i=this.fl();if(!i||i.sessionId!==t){var e={sessionId:t,props:this.pl(this._instance)};this.gl.register({[mt]:e})}},this._instance=t,this.ml=i,this.gl=e,this.pl=r||Za,this.ml.onSessionId(this.Be)}fl(){return this.gl.props[mt]}getSetOnceProps(){var t,i=null==(t=this.fl())?void 0:t.props;return i?"r"in i?$o(i,this._instance.config.disable_capture_url_hashes):{$referring_domain:i.referringDomain,$pathname:i.initialPathName,utm_source:i.utm_source,utm_campaign:i.utm_campaign,utm_medium:i.utm_medium,utm_content:i.utm_content,utm_term:i.utm_term}:{}}getSessionProps(){var t={};return ws($s(this.getSetOnceProps()),(i,e)=>{"$current_url"===e&&(e="url"),t["$session_entry_"+vi(e)]=i}),t}},tl=class{on(t,i){return this.yl[t]||(this.yl[t]=[]),this.yl[t].push(i),()=>{this.yl[t]=this.yl[t].filter(t=>t!==i)}}emit(t,i){for(var e of this.yl[t]||[])e(i);for(var r of this.yl["*"]||[])r(t,i)}constructor(){this.yl={}}},il=bs("[SessionId]"),el=864e5,rl=class{on(t,i){return this.bl.on(t,i)}constructor(t,i,e){var r;if(this._l=null,this.wl=null,this.kl=[],this.Sl=void 0,this.xl=!1,this.bl=new tl,this.Cl=(t,i)=>!(!Pi(t)||!Pi(i))&&Math.abs(t-i)>this.sessionTimeoutMs,!t.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if("always"===t.config.cookieless_mode)throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this.xn=t.config,this.gl=t.persistence,this.He=void 0,this.Xt=void 0,this._sessionStartTimestamp=null,this.Tl=void 0,this._sessionActivityTimestamp=null,this.Ml=i||Bs,this.Il=e||Bs;var s=this.xn.persistence_name||this.xn.token;if(this._sessionTimeoutMs=1e3*zi(this.xn.session_idle_timeout_seconds||1800,60,36e3,il.createLogger("session_idle_timeout_seconds"),1800),t.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.El(),this.Rl="ph_"+s+"_window_id",this.Al="ph_"+s+"_primary_window_exists",this.Pl()){var n=on.Nt(this.Rl),o=on.Nt(this.Al);n&&!o?this.He=n:on.Dt(this.Rl),on.Ot(this.Al,!0)}null!=(r=this.xn.bootstrap)&&r.sessionID&&this.setBootstrapSessionId(this.xn.bootstrap.sessionID),this.Fl()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(t){return wi(this.kl)&&(this.kl=[]),this.kl.push(t),this.Xt&&t(this.Xt,this.He),()=>{this.kl=this.kl.filter(i=>i!==t)}}Pl(){return"memory"!==this.xn.persistence&&!this.gl.gi&&on.Et()}Ol(t){t!==this.He&&(this.He=t,this.Pl()&&on.Ot(this.Rl,t))}$l(){return this.He?this.He:this.Pl()?on.Nt(this.Rl):null}Dl(t){var i=this._l;return!ki(i)&&!ki(t)&&5e3>Math.abs(t-i)}Ll(t,i,e){var r=i!==this._sessionActivityTimestamp,s=!(t!==this.Xt||e!==this._sessionStartTimestamp);this._sessionStartTimestamp=e,this._sessionActivityTimestamp=i,this.Xt=t,s&&!r||s&&this.Dl(i)||(this._l=i,this.gl.register({[D]:[i,t,e]}))}Nl(){var t,i=null==(t=this.xn)?void 0:t.persistence_save_debounce_ms;return Pi(i)&&i>0}ql(){this.Nl()?this.gl.refreshKey(D):(this.gl.flush(),this.gl.load())}jl(){var t;if(!ki(this._sessionActivityTimestamp)&&this._sessionActivityTimestamp!==this._l){this.ql();var i=this.Bl();i[1]===this.Xt&&i[2]===this._sessionStartTimestamp&&(this._l=this._sessionActivityTimestamp,this.gl.register({[D]:[this._sessionActivityTimestamp,null!==(t=this.Xt)&&void 0!==t?t:null,this._sessionStartTimestamp]}),this.gl.flush())}}Hl(){var t=this.Bl()[0],i=Pi(t)?t:0,e=Pi(this._sessionActivityTimestamp)?this._sessionActivityTimestamp:0;return Math.max(i,e)}zl(t){return this.ql(),this.Cl(t,this.Hl())}Bl(){var t=this.gl.props[D];return _i(t)&&2===t.length&&t.push(t[0]),t||[0,null,0]}resetSessionId(){this._l=null,this.Tl=void 0,clearTimeout(this.Ul),this.Ul=void 0,this.Ll(null,null,null)}setBootstrapSessionId(t,i){void 0===i&&(i=!1);var e=function(t,i){void 0===i&&(i=(new Date).getTime());try{var e=(t=>{var i=t.replace(/-/g,"");if(32!==i.length)throw new Error("Not a valid UUID");if("7"!==i[12])throw new Error("Not a UUIDv7");return parseInt(i.substring(0,12),16)})(t);return e>i+6e4?void il.error("Bootstrap sessionID cannot be in the future"):e}catch(t){return void il.error("Invalid sessionID in bootstrap",t)}}(t);return!wi(e)&&(i?this.Tl={sessionId:t,sessionStartTimestamp:e}:this.Ll(t,(new Date).getTime(),e),!0)}destroy(){this.xl=!0,this.jl(),clearTimeout(this.Ul),this.Ul=void 0,this.Sl&&Gt&&(Gt.removeEventListener(Ut,this.Sl,{capture:!1}),this.Sl=void 0),this.kl=[]}Fl(){this.Sl=()=>{this.jl(),this.Pl()&&on.Dt(this.Al)},Fs(Gt,Ut,this.Sl,{capture:!1})}checkAndGetSessionAndWindowId(t,i,e){if(void 0===t&&(t=!1),void 0===i&&(i=null),void 0===e&&(e=!1),"always"===this.xn.cookieless_mode)throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var r=i||(new Date).getTime(),s=this.Xt;if(e)this.wl=r;else if(ki(this.wl)||this.wl>r||r-this.wl>=1e3){var n,o;null==(n=(o=this.gl).syncCookieProperties)||n.call(o),this.wl=r}var a=this.Bl(),l=a[1],h=a[2],u=!wi(s)&&l!==s,d=this.Hl(),v=this.$l(),c=this.Tl,f=!!c&&(c.sessionStartTimestamp>r+6e4||r-c.sessionStartTimestamp>el),p=c?f:Pi(h)&&Math.abs(r-h)>el,g=!1,_=u,m=!l||!!c,b=l,y=!m&&!t&&this.Cl(r,d);if(y){(y=this.zl(r))||il.info("cross-tab refresh kept the session alive",{sessionId:l});var w=this.Bl();l=w[1],h=w[2]}if(m||y||p){_=!1;var x=c&&!f;l=x?c.sessionId:this.Ml(),v=this.Il(),il.info("new session ID assigned",{sessionId:l,windowId:v,bootstrapped:!!x,changeReason:{noSessionId:m,activityTimeout:y,sessionPastMaximumLength:p}}),h=x?c.sessionStartTimestamp:r,this.Tl=void 0,g=!0}else v||(v=this.Il(),g=!0),(_=_||l!==b)&&(il.info("adopted cross-tab session id",{sessionId:l,windowId:v}),g=!0);var S=Pi(d)&&t&&!p?d:r,k=Pi(h)?h:(new Date).getTime();this.Ol(v),this.Ll(l,S,k),t||this.El();var E={noSessionId:m,activityTimeout:y,sessionPastMaximumLength:p,crossTabAdoption:_};return g&&this.kl.forEach(t=>t(l,v,E)),{sessionId:l,windowId:v,sessionStartTimestamp:k,changeReason:g?E:void 0,lastActivityTimestamp:d}}El(){this.xl||(clearTimeout(this.Ul),this.Ul=setTimeout(()=>{if(!this.xl)if(this.zl((new Date).getTime())){var t=this.Xt;this.resetSessionId(),this.bl.emit("forcedIdleReset",{idleSessionId:t})}else this.El()},1.1*this.sessionTimeoutMs))}},sl=function(t,i){if(!t)return!1;var e=t.userAgent;if(e&&Ni(e,i))return!0;try{var r=null==t?void 0:t.userAgentData;if(null!=r&&r.brands&&r.brands.some(t=>Ni(null==t?void 0:t.brand,i)))return!0}catch(t){}return!!t.webdriver};function nl(){return(nl=n(function*(){var t=null==Jt?void 0:Jt.userAgentData;if(null!=t&&t.getHighEntropyValues)try{var i,e=null==(i=yield t.getHighEntropyValues(["model"]))?void 0:i.model;return xi(e)&&e.length>0?e:void 0}catch(t){return void ms.info("Unable to resolve $device_model from userAgentData.getHighEntropyValues",t)}})).apply(this,arguments)}function ol(t,i){var e="$survey_"+i+"/"+t.id;return t.current_iteration&&t.current_iteration>0&&(e="$survey_"+i+"/"+t.id+"/"+t.current_iteration),e}function al(t){var i;return!(null==(i=t.conditions)||null==(i=i.events)||null==(i=i.values)||!i.length)}var ll=(t,i)=>{if(!(t=>{try{new RegExp(t)}catch(t){return!1}return!0})(i))return!1;try{return new RegExp(i).test(t)}catch(t){return!1}},hl=t=>t.toLowerCase(),ul={exact:(t,i)=>i.some(i=>t.some(t=>i===t)),is_not:(t,i)=>i.every(i=>t.every(t=>i!==t)),regex:(t,i)=>i.some(i=>t.some(t=>ll(i,t))),not_regex:(t,i)=>i.every(i=>t.every(t=>!ll(i,t))),icontains:(t,i)=>i.map(hl).some(i=>t.map(hl).some(t=>i.includes(t))),not_icontains:(t,i)=>i.map(hl).every(i=>t.map(hl).every(t=>!i.includes(t))),gt:(t,i)=>i.some(i=>{var e=parseFloat(i);return!isNaN(e)&&t.some(t=>e>parseFloat(t))}),lt:(t,i)=>i.some(i=>{var e=parseFloat(i);return!isNaN(e)&&t.some(t=>e<parseFloat(t))})};function dl(t,i){return!t||Object.entries(t).every(t=>{var e=t[1],r=null==i?void 0:i[t[0]];if(null==r)return!1;var s=ul[e.operator];return!!s&&s(e.values,[String(r)])})}function vl(t,i,e){return ao({distinct_id:t,userPropertiesToSet:i,userPropertiesToSetOnce:e})}var cl="custom",fl="i.posthog.com",pl=/^\/static\//,gl=["/s/","/e/","/i/"],_l=class{constructor(t){this.Wl={},this.instance=t}get apiHost(){var t=this.instance.config.api_host.trim().replace(/\/$/,"");return"https://app.posthog.com"===t?"https://us.i.posthog.com":t}get flagsApiHost(){var t=this.instance.config.flags_api_host;return t?t.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var t,i=null==(t=this.instance.config.ui_host)?void 0:t.replace(/\/$/,"");return i||(i=this.apiHost.replace("."+fl,".posthog.com")),"https://app.posthog.com"===i?"https://us.posthog.com":i}get region(){return this.Wl[this.apiHost]||(this.Wl[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":cl),this.Wl[this.apiHost]}Vl(t){if(pl.test(t)){var i=this.instance.config.asset_host;if("string"==typeof i)return i.trim().replace(/\/$/,"")||void 0}}Gl(t){var i=lo(t);return i?i.protocol+"//"+i.host+i.pathname:void 0}Zl(t,i,e){if("ui"===t)return e;var r=e,s=this.instance.config.rewriteRequestPath;if(s){var n,o=(null==(n=lo(e))?void 0:n.href)||e;r=s(new URL(o)).toString()}if(s&&"api"===t&&gl.some(t=>0===i.indexOf(t))){var a=this.Gl(r);if(a){var l,h=this.apiHost,u=this.Jl;(null==(l=u)?void 0:l.apiHost)===h&&u.rewriteRequestPath===s||(this.Jl=u={apiHost:h,rewriteRequestPath:s,urls:new Set}),u.urls.add(a)}}return r}isIngestionEndpoint(t){var i=this.Jl,e=this.Gl(t);return(null==i?void 0:i.apiHost)===this.apiHost&&i.rewriteRequestPath===this.instance.config.rewriteRequestPath&&!!e&&i.urls.has(e)}endpointFor(t,i){if(void 0===i&&(i=""),i&&(i="/"===i[0]?i:"/"+i),"ui"===t)return this.Zl(t,i,this.uiHost+i);if("flags"===t)return this.Zl(t,i,this.flagsApiHost+i);if("assets"===t){var e=this.Vl(i);if(e)return this.Zl(t,i,""+e+i)}if(this.region===cl)return this.Zl(t,i,this.apiHost+i);var r=fl+i;switch(t){case"assets":return this.Zl(t,i,"https://"+this.region+"-assets."+r);case"api":return this.Zl(t,i,"https://"+this.region+"."+r)}}},ml=bs("[Surveys]"),bl=t=>{try{var i=(t=>((t,i)=>"seenSurvey_"+function(t){return t.current_iteration&&t.current_iteration>0?t.id+"_"+t.current_iteration:t.id}(i))(0,t))(t);if(localStorage.getItem(i))return;localStorage.setItem(i,"true")}catch(t){ml.error("Failed to persist survey seen state",t)}},yl=["popover","widget","api"],wl={ignoreConditions:!1,ignoreDelay:!1,displayType:Ko},xl=bs("[PostHog ExternalIntegrations]"),Sl={intercom:"intercom-integration",crispChat:"crisp-chat-integration"},kl=class{constructor(t){this._instance=t}Ro(t,i){var e;null==(e=ni.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,t,t=>{if(t)return xl.error("failed to load script",t);i()})}startIfEnabledOrStop(){var t=this,i=function(){var i,r,s,n=e[0],o=e[1];!o||null!=(i=ni.__PosthogExtensions__)&&null!=(i=i.integrations)&&i[n]||t.Ro(Sl[n],()=>{var i;null==(i=ni.__PosthogExtensions__)||null==(i=i.integrations)||null==(i=i[n])||i.start(t._instance)}),!o&&null!=(r=ni.__PosthogExtensions__)&&null!=(r=r.integrations)&&r[n]&&(null==(s=ni.__PosthogExtensions__)||null==(s=s.integrations)||null==(s=s[n])||s.stop())};for(var e of Object.entries(null!==(r=this._instance.config.integrations)&&void 0!==r?r:{})){var r;i()}}},El=class{constructor(t,i){this.A=t,this.ao=i,this.Ql=new Map,this.fo=!1}add(t){var i=this;return n(function*(){if(i.fo)throw new Error("Cannot add an extension to a disposed ExtensionRuntime");if(i.Ql.has(t.name))throw new Error('Browser extension "'+t.name+'" is already registered');i.Ql.set(t.name,t);try{var e=t.setup(i.ao);e&&(yield e)}catch(e){var r=i.Ql.get(t.name)===t;r&&i.Ql.delete(t.name),i.A.error('Failed to set up browser extension "'+t.name+'"',e),r&&i.Kl(t)}})()}getExtension(t){return this.Ql.get(t)}dispose(){if(!this.fo){this.fo=!0;var t=Array.from(this.Ql.values()).reverse();for(var i of(this.Ql.clear(),t))this.Kl(i)}}Kl(t){try{var i=null==t.dispose?void 0:t.dispose();i&&mi(i.then)&&i.then(void 0,i=>{this.A.error('Failed to dispose browser extension "'+t.name+'"',i)})}catch(i){this.A.error('Failed to dispose browser extension "'+t.name+'"',i)}}},$l=class{constructor(t){this._instance=t}initialize(){}get(t){var i=this._instance.persistence;if("string"==typeof t)return null==i?void 0:i.get_property(t);var e={};for(var r of t){var s=null==i?void 0:i.get_property(r);wi(s)||(e[r]=s)}return e}set(t,i){var e;null==(e=this._instance.persistence)||e.register("string"==typeof t?{[t]:i}:t)}remove(t){var i;null==(i=this._instance.persistence)||i.unregister(t)}},Pl="extensionsRemoteConfig",Tl=class{constructor(t){this.instance=t,this.fo=!1,this.A=ms,this.Xl=t.Yl,this.kv=new $l(t),this.onEvent=t=>Jo(this.instance.on("eventCaptured",i=>{try{t({event:i.event,properties:i.properties})}catch(t){this.A.error("Browser extension event listener failed",t)}})),this.onRemoteConfig=t=>{if(this.fo)return Jo(()=>{});var i=i=>{try{t(i)}catch(t){this.A.error("Browser extension remote config listener failed",t)}},e=this.instance.tu.on(Pl,i);return this.Xl&&i(this.Xl),Jo(e)},this.eu=new El(ms.createLogger("[BrowserExtensions]"),this)}get logger(){return this.A}get distinctId(){return this.instance.get_distinct_id()}get anonymousId(){var t;return null!==(t=this.instance.get_property("$device_id"))&&void 0!==t?t:this.distinctId}get deviceId(){var t=this.instance.get_property(d);return"string"==typeof t?t:void 0}get library(){return{name:l.LIB_NAME,version:l.LIB_VERSION}}get initialPersonProperties(){var t,i;return null!==(t=null==(i=this.instance.persistence)?void 0:i.get_initial_props())&&void 0!==t?t:{}}get groups(){return this.instance.getGroups()}get session(){try{var t,i,e,r,s=null==(t=this.instance.sessionManager)?void 0:t.checkAndGetSessionAndWindowId(!0);return{sessionId:null!==(i=null==s?void 0:s.sessionId)&&void 0!==i?i:"",windowId:null!==(e=null==s?void 0:s.windowId)&&void 0!==e?e:"",sessionStartTimestamp:null!==(r=null==s?void 0:s.sessionStartTimestamp)&&void 0!==r?r:0}}catch(t){return{sessionId:"",windowId:"",sessionStartTimestamp:0}}}get canCapture(){return this.instance.is_capturing()}get projectToken(){return this.instance.config.token}add(t){return this.eu.add(t)}getExtension(t){return this.eu.getExtension(t)}capture(t,i,e){var r=this;return n(function*(){e?r.instance.capture(t,i,{timestamp:e.timestamp,uuid:e.uuid,$set:e.set,$set_once:e.setOnce}):r.instance.capture(t,i)})()}registerDynamicEventProperties(t){return Jo(this.instance.iu(t))}handleRemoteConfig(t){this.fo||(this.Xl=t,this.instance.tu.emit(Pl,t))}sendRequest(t,i){var e=this;return n(function*(){var r;void 0===i&&(i={});var s=e.instance.requestRouter.endpointFor(null!==(r=i.target)&&void 0!==r?r:"api",t),n={method:i.method,url:i.query?ja(s,i.query):s,data:i.body,headers:i.headers,timeout:i.timeoutMs,fireCallbackOnDrop:!0,transport:i.transport,compression:i.compression,compressionFallback:"flags"===i.target&&"best-available"===i.compression?ai.Base64:void 0,timestampMode:i.sentAt};return"sendBeacon"===i.transport?(e.instance._send_request(n),{statusCode:202}):new Promise(t=>{n.callback=t,e.instance._send_request(n)})})()}dispose(){this.fo||(this.fo=!0,this.eu.dispose())}},Cl={},Fl=0,Al=()=>{},Il='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',Rl="Surveys module not available",Ol="sanitize_properties is deprecated. Use before_send instead",Ml="Invalid value for property_denylist config: ",Dl=/^[A-Za-z0-9_-]{1,400}$/,jl=/^fb\.[0-9]+\.[0-9]+\.[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)?$/,Bl=["token","distinct_id",Et],Ll="posthog",Nl=!Ra&&-1===(null==ei?void 0:ei.indexOf("MSIE"))&&-1===(null==ei?void 0:ei.indexOf("Mozilla")),zl=t=>{var i={};return t&&"unset"!==t?("2025-11-30">t||(i.strictMinimumDuration=!0),"2026-05-30">t||(i.canvasCapture={resolutionScale:.6}),"2026-06-25">t||(i.streamNetworkBody=!0),"2026-08-30">t||(i.captureJsonLd=!0),i):i},Ul=t=>{var i;return r({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,asset_host:null,token:"",autocapture:!0,cross_subdomain_cookie:Cs(null==Xt?void 0:Xt.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:Al,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:null!=t?t:"unset",__preview_deferred_init_extensions:!1,__preview_external_dependency_versioned_paths:!1,__preview_cookie_wins_on_conflict:!1,debug:Yt&&xi(null==Yt?void 0:Yt.search)&&-1!==Yt.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==Gt||null==(i=Gt.location)?void 0:i.protocol),ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_flags:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_only_evaluate_survey_feature_flags:!1,advanced_feature_flags_dedup_per_session:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,surveys_request_timeout_ms:1e4,on_request_error(t){ms.error("Bad HTTP status: "+t.statusCode+" "+t.text)},get_device_id:t=>t,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:Nt,before_send:void 0,get_current_url:void 0,request_queue_config:{flush_interval_ms:3e3},error_tracking:{},_onCapture:Al},(t=>({rageclick:t&&t>="2026-05-30"?{content_ignorelist:$n,ignore_text_selection:!0}:!t||"2025-11-30">t||{content_ignorelist:!0},capture_pageview:!t||"2025-05-24">t||"history_change",session_recording:zl(t),external_scripts_inject_target:t&&t>="2026-01-30"?"head":"body",internal_or_test_user_hostname:t&&t>="2026-01-30"?/^(localhost|127\.0\.0\.1)$/:void 0,persistence_save_debounce_ms:t&&t>="2026-05-30"?250:0,split_storage:!(!t||"2026-05-30">t),detect_google_search_app:!(!t||"2026-05-30">t),disable_capture_url_hashes:!(!t||"2026-06-25">t),cookieWinsOnConflict:!(!t||"unset"===t||"2026-08-29">t)}))(t))},Hl=[["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"]],ql=t=>{var i={};for(var e of Hl){var r=e[0],s=e[1];wi(t[r])||(i[s]=t[r])}var n=xs({},i,t),o=t.__preview_external_dependency_versioned_paths;return wi(o)||(wi(t.strict_script_versioning)&&(n.strict_script_versioning=!!o),xi(o)&&wi(t.asset_host)&&(n.asset_host=o)),_i(t.property_blacklist)&&(wi(t.property_denylist)?n.property_denylist=t.property_blacklist:_i(t.property_denylist)?n.property_denylist=[...t.property_blacklist,...t.property_denylist]:ms.error(Ml+t.property_denylist)),n},Vl=class{constructor(){this.__forceAllowLocalhost=!1}get ru(){return this.__forceAllowLocalhost}set ru(t){ms.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=t}},Wl=(s=class t{nu(t){if(t){var i=this.Ql.indexOf(t);-1!==i&&this.Ql.splice(i,1)}}su(t,i){return this.nu(t),this.Ql.push(i),null==i.initialize||i.initialize(),i}ou(){return"always"===this.config.cookieless_mode||"on_reject"===this.config.cookieless_mode&&this.consent.isRejected()}au(){if(!(this.lu||this.config.reuseAnonymousId||this.config.segment||this.ou())){var t,i,e,r="memory"===this.config.persistence||"sessionStorage"===this.config.persistence;(r||this.config.disable_persistence)&&(this.uu||(r?(t="persistence is set to '"+this.config.persistence+"'",i="memory"===this.config.persistence?"on every page load":"for every new browser tab or window",e="Either set persistence to 'localStorage+cookie', keep this persistence and pass a stable ID through bootstrap.distinctID, or enable reuseAnonymousId."):(t="persistence is disabled (disable_persistence is true)",i="on every page load",e="Either set disable_persistence to false, keep persistence disabled and pass a stable ID through bootstrap.distinctID, or enable reuseAnonymousId."),this.lu=!0,console.warn("[PostHog.js]",t+" but no bootstrap.distinctID was provided. PostHog will mint a new distinct ID "+i+", so calling identify() merges a new ID onto the person each time. A person can then pass the distinct-ID limit and its events stop appearing on person pages and the session tab. "+e)))}}hu(){if(!this.ou()&&"$posthog_cookieless"===this.get_distinct_id()){var t=this.persistence;if(t){this.du()||t.load(!0);var i=this.get_distinct_id();if(!i||"$posthog_cookieless"===i){var e=this.config.get_device_id(Bs());this.register({distinct_id:e,$device_id:e}),t.set_property(_t,Bt)}this.vu()}}}get decideEndpointWasHit(){var t,i;return null!==(t=null==(i=this.featureFlags)?void 0:i.hasLoadedFlags)&&void 0!==t&&t}get flagsEndpointWasHit(){var t,i;return null!==(t=null==(i=this.featureFlags)?void 0:i.hasLoadedFlags)&&void 0!==t&&t}constructor(){var i;this.cu=!1,this.fu=!1,this.webPerformance=new Vl,this.pu=!1,this.version=l.LIB_VERSION,this.gu=new Set,this.mu="",this.tu=new tl,this.Ql=[],this.yu=[],this.uu=!1,this.lu=!1,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=Ul(),this.SentryIntegration=io,this.sentryIntegration=t=>function(t,i){var e=to(t,i);return{name:Qn,processEvent:t=>e(t)}}(this,t),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.bu=!1,this._u=null,this.wu=null,this.ku=null,this.scrollManager=new Ya(this),this.pageViewManager=new eo(this),this.rateLimiter=new Yo(this),this.requestRouter=new _l(this),this.consent=new an(this),this.externalIntegrations=new kl(this);var e=null!==(i=t.__defaultExtensionClasses)&&void 0!==i?i:{};this.featureFlags=e.featureFlags&&new e.featureFlags(this),this.toolbar=e.toolbar&&new e.toolbar(this),this.surveys=e.surveys&&new e.surveys(this),this.conversations=e.conversations&&new e.conversations(this),this.logs=e.logs&&new e.logs(this),this.metrics=e.metrics&&new e.metrics(this),this.experiments=e.experiments&&new e.experiments(this),this.exceptions=e.exceptions&&new e.exceptions(this),this.people={set:(t,i,e)=>{var r=xi(t)?{[t]:i}:t;this.setPersonProperties(r),null==e||e({})},set_once:(t,i,e)=>{var r=xi(t)?{[t]:i}:t;this.setPersonProperties(void 0,r),null==e||e({})}},this.on("eventCaptured",t=>ms.info('send "'+(null==t?void 0:t.event)+'"',t))}init(i,e,r){if(r&&r!==Ll){var s,n=null!==(s=Cl[r])&&void 0!==s?s:new t;return n._init(i,e,r),Cl[r]=n,Cl[Ll][r]=n,n}return this._init(i,e,r)}_init(t,i,e){var s,n,o;void 0===i&&(i={});var a,h=xi(t)?t.trim():"";if(!h)return ms.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 h!==(null==(a=this.config)?void 0:a.token)?console.warn("[PostHog.js]","You have already initialized PostHog with a different project token! Re-initializing is a no-op, so events will keep going to the project this instance was initialized with. To capture into a second project, load PostHog once, then initialize a named instance after the SDK has loaded, e.g. posthog.init('"+h+"', { ... }, 'project2')"):console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config=Ul(i.defaults),i.debug=this.Su(i.debug),this.xu=i,this.Cu=[],i.person_profiles?this.wu=i.person_profiles:i.process_person&&(this.wu=i.process_person);var u=Ul(i.defaults),d=ql(i),c=xs({},u,d,{name:e,token:h});bi(u.rageclick)&&bi(d.rageclick)&&(c.rageclick=xs({},u.rageclick,d.rageclick)),bi(u.session_recording)&&bi(d.session_recording)&&(c.session_recording=xs({},u.session_recording,d.session_recording)),this.set_config(c),this.config.on_xhr_error&&ms.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=i.disable_compression?void 0:No;var f=this.du();if(this.persistence=new Lo(this.config,f),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new Lo(r({},this.config,{persistence:"sessionStorage"}),f,!1),this.mu="ph_"+(this.config.persistence_name||this.config.token)+"_session_registered_properties","memory"!==this.config.persistence&&!f&&on.Et()){var p=on.Nt(this.mu);_i(p)&&p.forEach(t=>{xi(t)&&this.gu.add(t)})}else on.Dt(this.mu);var g=r({},this.persistence.props),_=r({},this.sessionPersistence.props);this.register({$initialization_time:(new Date).toISOString()}),this.Tu=new Ja(t=>this.Mu(t),this.config.request_queue_config),this.Iu=new Xa(this),this.__request_queue=[];var m=this.ou();m||(this.sessionManager=new rl(this),this.sessionPropsManager=new Qa(this,this.sessionManager,this.persistence),this.sessionManager.onSessionId((t,i,e)=>{(null!=e&&e.activityTimeout||null!=e&&e.sessionPastMaximumLength||null!=e&&e.crossTabAdoption)&&this.Eu()})),this.Ru(),this.config.__preview_deferred_init_extensions?(ms.info("Deferring extension initialization to improve startup performance"),setTimeout(()=>{this.Au(m)},0)):(ms.info("Initializing extensions synchronously"),this.Au(m)),l.DEBUG=l.DEBUG||this.config.debug,l.DEBUG&&ms.info("Starting in debug mode",{this:this,config:i,thisC:r({},this.config),p:g,s:_}),!this.config.identity_distinct_id||null!=(s=i.bootstrap)&&s.distinctID||(i.bootstrap=r({},i.bootstrap,{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0}));var b=null==(n=i.bootstrap)?void 0:n.distinctID;if(this.uu=!!b&&!Si(b),void 0!==(null==(o=i.bootstrap)?void 0:o.distinctID)){var y=i.bootstrap.distinctID,w=this.get_distinct_id(),x=this.persistence.get_property(_t);if(i.bootstrap.isIdentifiedID&&null!=w&&w!==y&&"anonymous"===x)this.identify(y);else if(i.bootstrap.isIdentifiedID&&null!=w&&w!==y&&"identified"===x)ms.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 S=this.config.get_device_id(Bs()),k=i.bootstrap.isIdentifiedID?S:y;this.persistence.set_property(_t,i.bootstrap.isIdentifiedID?Lt:Bt),this.register({distinct_id:y,$device_id:k})}}if(m)this.register_once({distinct_id:kt,$device_id:null},"");else if(!this.get_distinct_id()){var E=this.config.get_device_id(Bs());this.register_once({distinct_id:E,$device_id:E},""),this.persistence.set_property(_t,Bt)}return Fs(Gt,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),Fs(Gt,"pageshow",()=>{var t;this.cu=!1,this.fu||null==(t=this.Iu)||t.resume()}),i.segment?Zn(this,()=>this.Pu()):this.Pu(),mi(this.config._onCapture)&&this.config._onCapture!==Al&&(ms.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",t=>this.config._onCapture(t.event,t))),this.config.ip&&ms.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 nl.apply(this,arguments)}().then(t=>{t&&this.register({[v]:t})}).catch(Al),this}Fu(t){var i=t;return xi(i.name)&&mi(i.setup)}Ou(t,i){this.Fu(t)?i.push(()=>{this.$u().add(t).catch(()=>null==t.dispose?void 0:t.dispose()).catch(i=>{ms.error('Failed to dispose browser extension "'+t.name+'"',i)})}):this.Ql.push(t)}Ru(){var i,e,r,s,n,o,a=null!==(i=null==(e=this.config.__extensionClasses)?void 0:e.featureFlags)&&void 0!==i?i:null==(r=t.__defaultExtensionClasses)?void 0:r.featureFlags;a&&(this.featureFlags&&this.featureFlags instanceof a||(null==(o=this.Du)||o.call(this),this.Du=void 0,this.featureFlags=new a(this)),mi(this.featureFlags.onReloading)&&mi(this.featureFlags.setup)?this.Du||(this.Du=this.featureFlags.onReloading(()=>{this.tu.emit("featureFlagsReloading",!0)}),this.$u().add(this.featureFlags)):null==(s=(n=this.featureFlags).initialize)||s.call(n))}Au(i){var e,s,n,o,a,l,h,u=performance.now(),d=r({},t.__defaultExtensionClasses,this.config.__extensionClasses),v=[];d.exceptions&&this.Ql.push(this.exceptions=null!==(e=this.exceptions)&&void 0!==e?e:new d.exceptions(this)),d.historyAutocapture&&this.Ql.push(this.historyAutocapture=new d.historyAutocapture(this)),d.tracingHeaders&&this.Ql.push(this.tracingHeaders=new d.tracingHeaders(this)),d.siteApps&&this.Ql.push(this.siteApps=new d.siteApps(this)),d.sessionRecording&&!i&&this.Ql.push(this.sessionRecording=new d.sessionRecording(this)),this.config.disable_scroll_properties||v.push(()=>{this.scrollManager.startMeasuringScrollPosition()}),d.autocapture&&this.Ou(this.autocapture=new d.autocapture(this),v),d.surveys&&this.Ou(this.surveys=null!==(s=this.surveys)&&void 0!==s?s:new d.surveys(this),v),d.logs&&this.Ou(this.logs=null!==(n=this.logs)&&void 0!==n?n:new d.logs(this),v),d.metrics&&this.Ql.push(this.metrics=null!==(o=this.metrics)&&void 0!==o?o:new d.metrics(this)),d.conversations&&this.Ql.push(this.conversations=null!==(a=this.conversations)&&void 0!==a?a:new d.conversations(this)),d.productTours&&this.Ql.push(this.productTours=new d.productTours(this)),d.heatmaps&&this.Ql.push(this.heatmaps=new d.heatmaps(this)),d.webVitalsAutocapture&&this.Ql.push(this.webVitalsAutocapture=new d.webVitalsAutocapture(this)),d.exceptionObserver&&this.Ql.push(this.exceptionObserver=new d.exceptionObserver(this)),d.deadClicksAutocapture&&this.Ql.push(this.deadClicksAutocapture=new d.deadClicksAutocapture(this,Jn)),d.toolbar&&this.Ql.push(this.toolbar=null!==(l=this.toolbar)&&void 0!==l?l:new d.toolbar(this)),d.experiments&&this.Ql.push(this.experiments=null!==(h=this.experiments)&&void 0!==h?h:new d.experiments(this)),this.Ql.forEach(t=>{t.initialize&&v.push(()=>{null==t.initialize||t.initialize()})}),v.push(()=>{if(this.Lu){var t=this.Lu;this.Lu=void 0,this.Ql.forEach(i=>null==i.onRemoteConfig?void 0:i.onRemoteConfig(t))}}),this.Nu(v,u)}Nu(t,i){for(;t.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-i>=30&&t.length>0)return void setTimeout(()=>{this.Nu(t,i)},0);var e=t.shift();if(e)try{e()}catch(t){ms.error("Error initializing extension:",t)}}var r=Math.round(performance.now()-i);this.register_for_session({[$t]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[Pt]:r}),this.config.__preview_deferred_init_extensions&&ms.info("PostHog extensions initialized ("+r+"ms)")}za(t){var i;if(!Xt||!Xt.body)return ms.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout(()=>{this.za(t)},500);if(this.config.__preview_deferred_init_extensions&&(this.Lu=t),this.Yl=t,this.compression=void 0,t.ok){var e,r=t.config;r.supportedCompression&&!this.config.disable_compression&&(this.compression=ui(r.supportedCompression,No)?No:ui(r.supportedCompression,zo)?zo:void 0),null!=(e=r.analytics)&&e.endpoint&&(this.analyticsDefaultEndpoint=r.analytics.endpoint)}this.set_config({person_profiles:this.wu?this.wu:Nt}),null==(i=this.qu)||i.handleRemoteConfig(t),this.Ql.forEach(i=>null==i.onRemoteConfig?void 0:i.onRemoteConfig(t))}Pu(){try{this.config.loaded(this)}catch(t){ms.critical("`loaded` function failed",t)}if(this.ju(),this.config.internal_or_test_user_hostname&&null!=Yt&&Yt.hostname){var t=Yt.hostname,i=this.config.internal_or_test_user_hostname;("string"==typeof i?t===i:i.test(t))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout(()=>{(this.consent.isOptedIn()||this.ou())&&this.Bu()},1),this.Hu=new Qo(this),this.Hu.load()}ju(){var t;this.is_capturing()&&this.config.request_batching&&(null==(t=this.Tu)||t.enable())}_dom_loaded(){this.is_capturing()&&ys(this.__request_queue,t=>this.Mu(t)),this.__request_queue=[],this.ju()}_handle_unload(){var t,i,e,r,s;this.cu=!0,null==(t=this.surveys)||null==t.handlePageUnload||t.handlePageUnload(),null==(i=this.metrics)||i.flush("sendBeacon"),this.config.request_batching?(this.zu()&&this.capture(qt),null==(e=this.logs)||e.flushLogs("sendBeacon"),null==(r=this.Tu)||r.unload(),null==(s=this.Iu)||s.unload()):this.zu()&&this.capture(qt,null,{transport:"sendBeacon"})}_send_request(t){var i;this.__loaded?Nl?this.__request_queue.push(t):this.rateLimiter.isServerRateLimited(t.batchKey)?t.fireCallbackOnDrop&&(null==t.callback||t.callback({statusCode:429})):(t.transport=t.transport||this.config.api_transport,t.headers=r({},this.config.request_headers,t.headers),t.compression="best-available"===t.compression?null!==(i=this.compression)&&void 0!==i?i:t.compressionFallback:t.compression,(wi(this.config.disable_beacon)?this.config.__preview_disable_beacon:this.config.disable_beacon)&&(t.disableTransport=["sendBeacon"]),t.fetchOptions=t.fetchOptions||this.config.fetch_options,(t=>{var i,e,s,n=r({},t);n.timeout=n.timeout||6e4;var o,a,l,h,u,d=null!==(i=n.transport)&&void 0!==i?i:"fetch";"sendBeacon"===d&&wi(n.compression)&&n.data&&(n.compression=zo),"POST"===n.method&&n.data&&("capture-body"===n.timestampMode?n.data={api_key:null!==(a=null==(u=(h=(_i(o=n.data)?o:[o]).map(t=>r({},t,t.timestamp instanceof Date&&!isNaN(t.timestamp.getTime())?{timestamp:t.timestamp.toISOString()}:{})))[0])||null==(l=u.properties)?void 0:l.token)&&void 0!==a?a:null==u?void 0:u.token,batch:h,sent_at:(new Date).toISOString()}:"body"===n.timestampMode&&(n.data=function(t,i){return void 0===i&&(i=(new Date).toISOString()),_i(t)?t.map(t=>r({},t,{sent_at:i})):r({},t,{sent_at:i})}(n.data))),n.url=Ga(n.url,n.method,n.compression,n.timestampMode);var v=Ka.filter(t=>!n.disableTransport||!t.transport||!n.disableTransport.includes(t.transport)),c=null!==(e=null==(s=function(t,i){for(var e=0;t.length>e;e++)if(i(t[e]))return t[e]}(v,t=>t.transport===d))?void 0:s.method)&&void 0!==e?e:v[0].method;if(!c)throw new Error("No available transport method");var f=t=>{try{c(t)}catch(t){Ha(t)?ms.warn(t):ms.error(t),null==n.callback||n.callback({statusCode:0,error:t})}};"sendBeacon"!==d&&n.data&&n.compression===No&&ii&&"undefined"!=typeof Promise&&!Ma?za(n).then(t=>{f(t)}).catch(i=>{if(Jr(i))return Ma=!0,void f(r({},n,{compression:void 0,url:Ga(t.url,t.method,void 0,t.timestampMode)}));(t=>{if(!t||"object"!=typeof t)return!1;var i="name"in t?String(t.name):"";return Jr(t)||i===Wr})(i)&&(Ma=!0),f(n)}):c(n)})(r({},t,{callback:i=>{var e,r;this.rateLimiter.checkForLimiting(i),400>i.statusCode||null==(e=(r=this.config).on_request_error)||e.call(r,i),null==t.callback||t.callback(i)}}))):t.fireCallbackOnDrop&&(null==t.callback||t.callback({statusCode:0}))}Mu(t){this.Iu?this.Iu.retriableRequest(t):this._send_request(t)}_execute_array(t){Fl++;try{var i,e=[],r=[],s=[];ys(t,t=>{if(t)if(_i(i=t[0]))s.push(t);else if(mi(t))try{t.call(this)}catch(i){ms.error("Error executing queued PostHog call",t,i)}else _i(t)&&"alias"===i?e.push(t):_i(t)&&-1!==i.indexOf("capture")&&mi(this[i])?s.push(t):r.push(t)});var n=function(t,i){ys(t,function(t){try{if(_i(t[0])){var e=i;ws(t,function(t){e=e[t[0]].apply(e,t.slice(1))})}else i[t[0]].apply(i,t.slice(1))}catch(i){ms.error("Error executing queued PostHog call",t,i)}})};n(e,this),n(r,this),n(s,this)}finally{Fl--}}push(i){if(Fl>0&&_i(i)&&xi(i[0])){var e=t.prototype[i[0]];mi(e)&&e.apply(this,i.slice(1))}else this._execute_array([i])}Uu(){var t,i=null==(t=this.persistence)?void 0:t.get_property(g);return xi(i)&&jl.test(i)?{value:i,delivered:!1}:bi(i)&&xi(i.value)&&jl.test(i.value)?{value:i.value,delivered:!0===i.delivered}:void 0}Wu(t,i,e,r){if(this.persistence){this.persistence.refreshKey(g);var s=this.Uu();if(!r){if(e)return xi(i)&&jl.test(i)?(i!==(null==s?void 0:s.value)&&this.persistence.register({[g]:{value:i,delivered:!1}}),{value:i,pending:i!==(null==s?void 0:s.value)||!s.delivered}):void this.persistence.unregister(g);if(xi(t)&&Dl.test(t)){if((null==s?void 0:s.value.split(".")[3])===t)return{value:s.value,pending:!s.delivered};var n="fb.1."+Date.now()+"."+t;return this.persistence.register({[g]:{value:n,delivered:!1}}),{value:n,pending:!0}}return s?{value:s.value,pending:!s.delivered}:void 0}this.persistence.unregister(g)}}Vu(t){if(this.persistence){this.persistence.refreshKey(g);var i=this.Uu();(null==i?void 0:i.value)!==t||i.delivered||this.persistence.register({[g]:{value:t,delivered:!0}})}}capture(t,i,e){var s,n,o,a,l,h,u,d,v,c;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.Tu){if(this.is_capturing())if(!wi(t)&&xi(t)){this.hu();var f=!this.config.opt_out_useragent_filter&&this._is_bot();if(!f||this.config.__preview_capture_bot_pageviews){var g=null!=e&&e.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(null==g||!g.isRateLimited){var _;null!=i&&i.$current_url&&!xi(null==i?void 0:i.$current_url)&&(ms.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),null==i||delete i.$current_url),"$exception"!==t||null!=e&&e.Gu||ms.warn("Using `posthog.capture('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureException(error)` instead, which attaches required metadata automatically."),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&(_=this.sessionPersistence.update_campaign_params()),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();var m=new Date,b=(null==e?void 0:e.timestamp)||m,y=Ze(null==e?void 0:e.uuid,Bs),w={uuid:y,event:t,properties:this.calculateEventProperties(t,i||{},b,y)};"$pageview"===t&&this.config.__preview_capture_bot_pageviews&&f&&(w.event="$bot_pageview",w.properties.$browser_type="bot"),g&&(w.properties.$lib_rate_limit_remaining_tokens=g.remainingTokens);var x="$feature_flag_called"===t&&!1===w.properties.$feature_flag_has_experiment&&!0===this.get_property("$minimal_flag_called_events");null!=e&&e.$set&&!x&&(w.$set=null==e?void 0:e.$set);var S=bi(null==i?void 0:i.$set)?i.$set:void 0,k=!(null==e||!e.$set)&&"$fbc"in e.$set,E=k||!!S&&"$fbc"in S,P=k?null==e||null==(s=e.$set)?void 0:s[p]:null==S?void 0:S[p],T=_i(null==i?void 0:i.$unset)?i.$unset:[],C=(null==e?void 0:e.$unset)||[],F=-1!==T.indexOf("$fbc")||-1!==C.indexOf("$fbc"),A=this.Wu(null==(n=_)?void 0:n.fbclid,P,E,F);A&&!0===w.properties.$process_person_profile&&A.pending&&!E&&!x&&(w.$set=r({[p]:A.value},w.$set));var I=null==e?void 0:e.$unset;I&&(w.$unset=I);var R=x?void 0:this.Zu(null==e?void 0:e.$set_once,t!==Wt,t===Vt);if(R&&(w.$set_once=R),null!=e&&e._noTruncate||(u=this.config.properties_string_max_length,d=w,v=t=>xi(t)?t.slice(0,u):t,c=new Set,w=function t(i,e){if(i!==Object(i))return v?v(i):i;if(!c.has(i)){var r;if(c.add(i),_i(i))r=[],ys(i,i=>{r.push(t(i))});else{var s={};ws(Ri(i)?Ps(i):i,(i,e)=>{c.has(i)||(s[e]=t(i,e))}),r=s}return r}}(d)),w.timestamp=b,wi(null==e?void 0:e.timestamp)||(w.properties.$event_time_override_provided=!0,w.properties.$event_time_override_system_time=m),x&&(w.properties=function(t,i){void 0===i&&(i=[]);var e={},r=i=>{void 0!==t[i]&&(e[i]=t[i])};return Vr.forEach(r),i.forEach(r),e}(w.properties,Bl)),t===Vo||t===Wo){var O=null==i?void 0:i.$survey_id,M=null==i?void 0:i.$survey_iteration;bl({id:O,current_iteration:M}),w.$set=r({},w.$set,{[ol({id:O,current_iteration:M},t===Wo?"responded":"dismissed")]:!0})}else t===qo&&(w.$set=r({},w.$set,{[Go]:(new Date).toISOString()}));if("product tour shown"===t){var D=null==i?void 0:i.$product_tour_type;D&&(w.$set=r({},w.$set,{["$product_tour_last_seen_date/"+D]:(new Date).toISOString()}))}var j=r({},w.properties.$set,w.$set);if(yi(j)||this.setPersonPropertiesForFlags(j),!Ei(this.config.before_send)){var B=this.Ts(w);if(!B)return;(w=B).uuid=Ze(w.uuid,Bs)}var L=null!==(o=null==(a=w.$set)?void 0:a.$fbc)&&void 0!==o?o:bi(null==(l=w.properties)?void 0:l.$set)?w.properties.$set.$fbc:void 0,N=null!=A&&A.pending&&L===A.value?A.value:void 0;this.tu.emit("eventCaptured",w);var z,U=null!==(h=null==e?void 0:e._url)&&void 0!==h?h:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),H=r({method:"POST",url:U,data:w,compression:"best-available",timestampMode:"recordings"===(null==e?void 0:e._batchKey)||/\/s\/(?:\?|$)/.test(U)?"body":"capture-body",batchKey:null==e?void 0:e._batchKey},null!=e&&e.transport?{transport:e.transport}:{},N?{fireCallbackOnDrop:!0,callback:t=>{t.statusCode>=200&&300>t.statusCode&&this.Vu(N)}}:{});return!this.config.request_batching||e&&(null==e||!e._batchKey)||null!=e&&e.send_instantly||N?(!H.transport&&!H.callback&&yi(null!==(z=this.config.request_headers)&&void 0!==z?z:{})&&this.cu&&(H.transport="sendBeacon"),this.Mu(H)):this.Tu.enqueue(H),w}ms.critical("This capture call is ignored due to client rate limiting.")}}else ms.error("No event name provided to posthog.capture")}else ms.uninitializedWarning("posthog.capture")}_addCaptureHook(t){return this.on("eventCaptured",i=>t(i.event,i))}getExtension(t){var i;return null==(i=this.qu)?void 0:i.getExtension(t)}$u(){var t;return null!==(t=this.qu)&&void 0!==t?t:this.qu=new Tl(this)}iu(t){this.yu.push(t);var i=!0;return()=>{if(i){i=!1;var e=this.yu.indexOf(t);-1!==e&&this.yu.splice(e,1)}}}Ju(t){var i,e,r;return void 0===t&&(t=!0),!(null==(i=this.persistence)||!i.consumeCookieIdentityChange())&&(this.ku=null,"anonymous"===this.persistence.get_property("$user_state")&&(null==(r=this.sessionPersistence)||r.clear(),this.gu.clear(),this.Qu()),null==(e=this.featureFlags)||e.reset(),t&&this.reloadFeatureFlags(),!0)}calculateEventProperties(t,i,e,s,n){if(e=e||new Date,!this.persistence||!this.sessionPersistence)return i;this.persistence.syncCookieProperties(),this.Ju();var o=n?void 0:this.persistence.remove_event_timer(t),l=r({},i);if(l.token=this.config.token,l.$config_defaults=this.config.defaults,this.ou()&&(l[Et]=!0),"$snapshot"===t){var h=r({},this.persistence.properties(),this.sessionPersistence.properties());return l.distinct_id=h.distinct_id,(!xi(l.distinct_id)&&!$i(l.distinct_id)||Si(l.distinct_id))&&ms.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),l}var u,d=function(t,i,e,r){var s,n,o,l;if(void 0===r&&(r=!1),!ei)return{};var h,u=t?[...po,...i||[]]:[],d=ze(ei),v=d[0],c=d[1],f=function(t){for(var i=0;qe.length>i;i++){var e,r=qe[i],s=r[1],n=r[2],o=t.match(r[0]);if(o)return[s,(null==(e=n&&t.match(n)||o)?void 0:e[1])||""]}return["",""]}(ei),p=f[0],g=f[1],_=null!=(h="u">typeof navigator?navigator:void 0)&&h.brave?{brave:!0}:{},m={};wi(e)||(m.detectGoogleSearchApp=e);var b={},y=null==(s=navigator)||null==(s=s.userAgentData)?void 0:s.platform,w=null==(n=navigator)?void 0:n.maxTouchPoints,x=null==Gt||null==(o=Gt.screen)?void 0:o.width,S=null==Gt||null==(l=Gt.screen)?void 0:l.height,k=null==Gt?void 0:Gt.devicePixelRatio;wi(y)||(b.userAgentDataPlatform=y),wi(w)||(b.maxTouchPoints=w),wi(x)||(b.screenWidth=x),wi(S)||(b.screenHeight=S),wi(k)||(b.devicePixelRatio=k);var E,P,T,C,F,A,I,R,O=xs($s({$os:v,$os_version:c,$browser:je(ei,navigator.vendor,_,m),$webview_app:p,$webview_app_version:g,$device:Ue(ei),$device_type:(P=ei,T=b,R=Ue(P),R===Gi||R===Wi||"Kobo"===R||"Kindle Fire"===R||R===ge?Vi:R===oe||R===le||R===ae||R===fe?"Console":R===Ki?"Wearable":R?Hi:"Android"===(null==T?void 0:T.userAgentDataPlatform)&&(null!==(C=null==T?void 0:T.maxTouchPoints)&&void 0!==C?C:0)>0?600>Math.min(null!==(F=null==T?void 0:T.screenWidth)&&void 0!==F?F:0,null!==(A=null==T?void 0:T.screenHeight)&&void 0!==A?A:0)/(null!==(I=null==T?void 0:T.devicePixelRatio)&&void 0!==I?I:1)?Hi:Vi:"Desktop"),$timezone:Po(),$timezone_offset:To()}),{$current_url:uo(r?tr(null==Yt?void 0:Yt.href):null==Yt?void 0:Yt.href,u,_o),$host:null==Yt?void 0:Yt.host,$pathname:null==Yt?void 0:Yt.pathname,$raw_user_agent:ei.length>1e3?ei.substring(0,997)+"...":ei,$browser_version:Le(ei,navigator.vendor,_,m),$browser_language:xo(),$browser_language_prefix:(E=xo(),"string"==typeof E?E.split("-")[0]:void 0),$screen_height:null==Gt?void 0:Gt.screen.height,$screen_width:null==Gt?void 0:Gt.screen.width,$viewport_height:null==Gt?void 0:Gt.innerHeight,$viewport_width:null==Gt?void 0:Gt.innerWidth,$lib:a.LIB_NAME,$lib_version:a.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3});return a.SDK_DIST_CHANNEL&&(O.$sdk_dist_channel=a.SDK_DIST_CHANNEL),O}(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 v=this.sessionManager.checkAndGetSessionAndWindowId(n,e.getTime(),!0),c=v.windowId;l.$session_id=v.sessionId,l.$window_id=c}this.sessionPropsManager&&xs(l,this.sessionPropsManager.getSessionProps());try{var f;this.sessionRecording&&xs(l,this.sessionRecording.sdkDebugProperties),l.$sdk_debug_retry_queue_size=null==(f=this.Iu)?void 0:f.length}catch(t){l.$sdk_debug_error_capturing_properties=String(t)}if(this.requestRouter.region===cl&&(l.$lib_custom_api_host=this.config.api_host),u="$pageview"!==t||n?"$pageleave"!==t||n?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(e):this.pageViewManager.doPageView(e,s),l=xs(l,u),"$pageview"===t&&Xt&&(l.title=Xt.title),!wi(o)){var p=e.getTime()-o;l.$duration=parseFloat((p/1e3).toFixed(3))}ei&&this.config.opt_out_useragent_filter&&(l.$browser_type=this._is_bot()?"bot":"browser");var g=this.persistence.properties(),_=this.sessionPersistence.properties(),m=l.$groups,b=g.$groups;bi(m)&&!yi(m)&&(l.$groups=r({},bi(b)?b:{},m)),ws(["$referrer","$referring_domain"],t=>{t in g&&delete _[t]});var y={};if(this.yu.length>0)for(var w of this.yu.slice())try{xs(y,w())}catch(t){ms.error("Failed to produce browser extension event properties",t)}(l=xs({},d,g,_,r({},y,l))).$is_identified=this._isIdentified(),_i(this.config.property_denylist)?ws(this.config.property_denylist,function(t){delete l[t]}):ms.error(Ml+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var x=this.config.sanitize_properties;x&&(ms.error(Ol),l=x(l,t));var S=this.Ku();return l.$process_person_profile=S,S&&!n&&this.Xu("_calculate_event_properties"),l}Zu(t,i,e){var r;if(void 0===i&&(i=!0),void 0===e&&(e=!1),!this.persistence||!this.Ku())return t;if(this.pu&&!e)return t;var s=xs({},this.persistence.get_initial_props(),(null==(r=this.sessionPropsManager)?void 0:r.getSetOnceProps())||{},t||{}),n=this.config.sanitize_properties;return n&&(ms.error(Ol),s=n(s,"$set_once")),i&&(this.pu=!0),yi(s)?void 0:s}register(t,i){var e;null==(e=this.persistence)||e.register(t,i)}register_once(t,i,e){var r;null==(r=this.persistence)||r.register_once(t,i,e)}register_for_session(t){var i,e;null==(i=this.persistence)||i.syncCookieProperties(),this.Ju(),null==(e=this.sessionPersistence)||e.register(t),Object.keys(t).forEach(t=>this.gu.add(t)),this.Qu()}unregister(t){var i;null==(i=this.persistence)||i.unregister(t)}unregister_for_session(t){var i;null==(i=this.sessionPersistence)||i.unregister(t),this.gu.delete(t),this.Qu()}Yu(t,i){this.register({[t]:i})}Eu(){this.gu.forEach(t=>{var i;null==(i=this.sessionPersistence)||i.unregister(t)}),this.gu.clear(),this.Qu()}Qu(){var t;if(this.mu)if("memory"===this.config.persistence||null!=(t=this.sessionPersistence)&&t.gi||!on.Et())on.Dt(this.mu);else{var i=[];this.gu.forEach(t=>i.push(t)),i.length>0?on.Ot(this.mu,i):on.Dt(this.mu)}}getFeatureFlag(t,i){var e;return null==(e=this.featureFlags)?void 0:e.getFeatureFlag(t,i)}getFeatureFlagPayload(t){var i;return null==(i=this.featureFlags)?void 0:i.getFeatureFlagPayload(t)}getFeatureFlagResult(t,i){var e;return null==(e=this.featureFlags)?void 0:e.getFeatureFlagResult(t,i)}getAllFeatureFlags(){var t,i;return null!==(t=null==(i=this.featureFlags)?void 0:i.getAllFeatureFlags())&&void 0!==t?t:[]}isFeatureEnabled(t,i){var e,r;return null!==(e=null==(r=this.featureFlags)?void 0:r.isFeatureEnabled(t,i))&&void 0!==e?e:null==i?void 0:i.defaultValue}reloadFeatureFlags(){var t;null==(t=this.featureFlags)||t.reloadFeatureFlags()}updateFlags(t,i,e){var r;null==(r=this.featureFlags)||r.updateFlags(t,i,e)}updateEarlyAccessFeatureEnrollment(t,i,e){var r;null==(r=this.featureFlags)||r.updateEarlyAccessFeatureEnrollment(t,i,e)}getEarlyAccessFeatures(t,i,e){var r;return void 0===i&&(i=!1),null==(r=this.featureFlags)?void 0:r.getEarlyAccessFeatures(t,i,e)}on(t,i){return this.tu.on(t,i)}onFeatureFlags(t){return this.featureFlags?this.featureFlags.onFeatureFlags(t):(t([],{},{errorsLoading:!0}),()=>{})}onSurveysLoaded(t){return this.surveys?this.surveys.onSurveysLoaded(t):(t([],{isLoaded:!1,error:Rl}),()=>{})}onSessionId(t){var i,e;return null!==(i=null==(e=this.sessionManager)?void 0:e.onSessionId(t))&&void 0!==i?i:()=>{}}getSurveys(t,i){void 0===i&&(i=!1),this.surveys?this.surveys.getSurveys(t,i):t([],{isLoaded:!1,error:Rl})}getActiveMatchingSurveys(t,i){void 0===i&&(i=!1),this.surveys?this.surveys.getActiveMatchingSurveys(t,i):t([],{isLoaded:!1,error:Rl})}renderSurvey(t,i){var e;null==(e=this.surveys)||e.renderSurvey(t,i)}displaySurvey(t,i){var e;void 0===i&&(i=wl),null==(e=this.surveys)||e.displaySurvey(t,i)}cancelPendingSurvey(t){var i;null==(i=this.surveys)||i.cancelPendingSurvey(t)}canRenderSurvey(t){var i,e;return null!==(i=null==(e=this.surveys)?void 0:e.canRenderSurvey(t))&&void 0!==i?i:{visible:!1,disabledReason:Rl}}canRenderSurveyAsync(t,i){var e,r;return void 0===i&&(i=!1),null!==(e=null==(r=this.surveys)?void 0:r.canRenderSurveyAsync(t,i))&&void 0!==e?e:Promise.resolve({visible:!1,disabledReason:Rl})}th(t){return!t||Si(t)?(ms.critical("Unique user id has not been set in posthog.identify"),!1):"$posthog_cookieless"===t?(ms.critical('The string "'+t+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.'),!1):!["distinct_id","distinctid"].includes(t.toLowerCase())&&!["undefined","null"].includes(t.toLowerCase())||(ms.critical('The string "'+t+'" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.'),!1)}identify(t,i,e){if(!this.__loaded||!this.persistence)return ms.uninitializedWarning("posthog.identify");if($i(t)&&(t=t.toString(),ms.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),this.th(t)&&this.Xu("posthog.identify")){this.hu();var r=this.get_distinct_id(),s=this.persistence.syncCookieProperties()&&this.get_distinct_id()!==r,n=this.Ju(!1),o=this.persistence.Sa(),a=!1;try{var l=this.get_distinct_id();this.register({$user_id:t}),this.get_property("$device_id")||this.register_once({$had_persisted_distinct_id:!0,$device_id:l},""),t!==l&&t!==this.get_property("__alias")&&(this.unregister(c),this.register({distinct_id:t}));var h=(this.persistence.get_property("$user_state")||"anonymous")===Bt,u=t!==l,d=!u&&h;if(u&&h){var v,f=this.config.reuseAnonymousId?{distinct_id:t}:{distinct_id:t,$anon_distinct_id:l};this.persistence.set_property(_t,Lt),this.setPersonPropertiesForFlags({$set:i||{},$set_once:e||{}},!1),this.config.cookieWinsOnConflict&&this.persistence.xa(),this.capture(Vt,f,{$set:i||{},$set_once:e||{}}),this.ku=vl(t,i,e),null==(v=this.featureFlags)||v.setAnonymousDistinctId(this.config.reuseAnonymousId?void 0:l)}else if(d){this.persistence.set_property(_t,Lt);var p=i||{},g=e||{};this.setPersonPropertiesForFlags({$set:p,$set_once:g},!1),this.config.cookieWinsOnConflict&&this.persistence.xa(),this.capture("$set",{$set:p,$set_once:g}),this.ku=vl(t,i,e)}else(i||e)&&this.setPersonProperties(i,e);u||s||n?(this.reloadFeatureFlags(),this.featureFlags?this.featureFlags.resetFlagCallReported():this.unregister(ct)):d&&(i||e)&&this.reloadFeatureFlags(),a=!0}finally{o&&this.persistence.Ma(a)}}}setPersonProperties(t,i){if((t||i)&&this.Xu("posthog.setPersonProperties")){var e=vl(this.get_distinct_id(),t,i);this.ku!==e?(this.setPersonPropertiesForFlags({$set:t||{},$set_once:i||{}},!0),this.capture("$set",{$set:t||{},$set_once:i||{}}),this.ku=e):ms.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}unsetPersonProperties(t){var i,e=(_i(t)?t:[t]).filter(t=>xi(t)&&t.length>0);0!==e.length&&this.Xu("posthog.unsetPersonProperties")&&(null==(i=this.featureFlags)||i.unsetPersonPropertiesForFlags(e,!0),this.capture("$set",{$unset:e}),this.ku=null)}group(t,i,e){var s;if(t&&i){null==(s=this.persistence)||s.syncCookieProperties(),this.Ju();var n=this.getGroups(),o=n[t]!==i;if(o&&this.resetGroupPropertiesForFlags(t),this.register({$groups:r({},n,{[t]:i})}),(o||e)&&this.Ku()){var a={$group_type:t,$group_key:i};e&&(a.$group_set=e),this.capture(Wt,a)}e&&this.setGroupPropertiesForFlags({[t]:e}),o&&!e&&this.reloadFeatureFlags()}else ms.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(t,i){var e;void 0===i&&(i=!0),null==(e=this.featureFlags)||e.setPersonPropertiesForFlags(t,i)}resetPersonPropertiesForFlags(t){var i;void 0===t&&(t=!0),null==(i=this.featureFlags)||i.resetPersonPropertiesForFlags(t)}setGroupPropertiesForFlags(t,i){var e;void 0===i&&(i=!0),this.Xu("posthog.setGroupPropertiesForFlags")&&(null==(e=this.featureFlags)||e.setGroupPropertiesForFlags(t,i))}resetGroupPropertiesForFlags(t){var i;null==(i=this.featureFlags)||i.resetGroupPropertiesForFlags(t)}reset(t){var i=Ti(t)?t:null==t?void 0:t.resetDeviceID,e=Ti(t)||null==t?void 0:t.bootstrap;this.eh(i,!1,e)}eh(t,i,e){var s,n,o,a;if(void 0===i&&(i=!1),ms.info("reset"),!this.__loaded)return ms.uninitializedWarning("posthog.reset");var l=null==e?void 0:e.sessionID;this.config.bootstrap=e||(null==(s=this.xu)?void 0:s.bootstrap)||{},null==(n=this.featureFlags)||null==n.updateConfig||n.updateConfig(this.config,this.Ua());var h=this.get_property(d),u=this.get_property(v),c=this.get_property(C);null==(o=this.sessionRecording)||o.flushBeforeIdentityReset();var f=this.is_capturing();this.consent.reset(),i||!f||this.is_capturing()||console.warn("[PostHog.js]","reset() cleared the stored consent, and capturing is now off because of `opt_out_capturing_by_default`. Call opt_in_capturing() again, and prefer calling reset() before opting in rather than after.");var p=null==(a=this.persistence)||null==a.Sa?void 0:a.Sa(),g=!1;try{var _,m,b,y,w,x,S,k,E,P,T,F,A;if(null==(_=this.persistence)||_.clear(),null==(m=this.sessionPersistence)||m.clear(),this.gu.clear(),this.Qu(),wi(c)||null==(b=this.persistence)||b.register({[C]:c}),null==(y=this.surveys)||y.reset(),null==(w=this.featureFlags)||w.reset(),null==(x=this.conversations)||x.reset(),null==(S=this.logs)||S.reset(),null==(k=this.metrics)||k.reset(),null==(E=this.persistence)||E.set_property(_t,Bt),null==(P=this.sessionManager)||P.resetSessionId(),this.ku=null,"always"===this.config.cookieless_mode)this.register_once({distinct_id:kt,$device_id:null},"");else{var I=this.config.get_device_id(Bs());this.register_once({distinct_id:I,$device_id:t?I:h},""),t||wi(u)||this.register({[v]:u})}if(this.register({$last_posthog_reset:(new Date).toISOString()},1),e)if(void 0===e.distinctID||this.ou()||(null==(A=this.persistence)||A.set_property(_t,e.isIdentifiedID?Lt:Bt),this.register({distinct_id:e.distinctID})),null==(T=this.featureFlags)||T.initialize(),!(wi(l)||null!=(F=this.sessionManager)&&F.setBootstrapSessionId(l,!0))){var R=r({},e);delete R.sessionID,this.config.bootstrap=R}delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,g=!0}finally{var O;p&&(null==(O=this.persistence)||null==O.Ma||O.Ma(g))}this.reloadFeatureFlags()}shutdown(t){var i=this;return n(function*(){var t,e,r,s,n,o,a;if(i.__loaded){i.fu=!0,i.$u().dispose(),null==(t=i.sessionRecording)||t.dispose(),null==(e=i.logs)||e.flushLogs("sendBeacon"),null==(r=i.metrics)||r.flush("sendBeacon"),null==(s=i.Tu)||s.unload(),null==(n=i.Iu)||n.unload();try{var l;null==(l=i.featureFlags)||l.destroy()}catch(t){ms.error("Error while destroying feature flags",t)}null==(o=i.persistence)||o.destroy(),null==(a=i.sessionPersistence)||a.destroy()}else ms.uninitializedWarning("posthog.shutdown")})()}setIdentity(t,i){var e;delete this.config.identity_claims,this.config.identity_distinct_id=t,this.config.identity_hash=i,this.alias(t),null==(e=this.conversations)||e.ih()}clearIdentity(){var t;delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,null==(t=this.conversations)||t.rh()}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var t,i;return null!==(t=null==(i=this.sessionManager)?void 0:i.checkAndGetSessionAndWindowId(!0).sessionId)&&void 0!==t?t:""}get_session_replay_url(t){if(!this.sessionManager)return"";var i=this.sessionManager.checkAndGetSessionAndWindowId(!0),e=i.sessionStartTimestamp,r=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+i.sessionId);if(null!=t&&t.withTimestamp&&e){var s,n=null!==(s=t.timestampLookBack)&&void 0!==s?s:10;if(!e)return r;r+="?t="+Math.max(Math.floor(((new Date).getTime()-e)/1e3)-n,0)}return r}alias(t,i){return t===this.get_property("$people_distinct_id")?(ms.critical("Attempting to create alias for existing People user - aborting."),-2):this.Xu("posthog.alias")?(wi(i)&&(i=this.get_distinct_id()),t!==i?(this.Yu(c,t),this.capture("$create_alias",{alias:t,distinct_id:i})):(ms.warn("alias matches current distinct_id - skipping api call."),this.identify(t),-1)):void 0}set_config(t){var i=r({},this.config);if(bi(t)){var e,s,n,o,a,h,u,d,v,c,f,p,g;xs(this.config,ql(t));var _=this.du();null==(e=this.persistence)||e.update_config(this.config,i,_),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new Lo(r({},this.config,{persistence:"sessionStorage"}),_,!1);var m=this.Su(this.config.debug);Ti(m)&&(this.config.debug=m),Ti(this.config.debug)&&(this.config.debug?(l.DEBUG=!0,Vs.Et()&&Vs.Ot("ph_debug",!0),ms.info("set_config",{config:t,oldConfig:i,newConfig:r({},this.config)})):(l.DEBUG=!1,Vs.Et()&&Vs.Dt("ph_debug"))),null==(s=this.featureFlags)||null==s.updateConfig||s.updateConfig(this.config,this.Ua()),null==(n=this.exceptionObserver)||n.onConfigChange(),null==(o=this.exceptions)||o.onConfigChange(),null==(a=this.sessionRecording)||a.startIfEnabledOrStop(),null==(h=this.tracingHeaders)||h.startIfEnabledOrStop(),null==(u=this.autocapture)||u.startIfEnabled(),null==(d=this.heatmaps)||d.startIfEnabled(),("capture_pageview"in t||"disable_capture_url_hashes"in t)&&(null==(v=this.historyAutocapture)||v.startIfEnabledOrStop()),null==(c=this.exceptionObserver)||c.startIfEnabledOrStop(),null==(f=this.deadClicksAutocapture)||f.startIfEnabledOrStop(),null==(p=this.surveys)||p.loadIfEnabled(),this.vu(),null==(g=this.externalIntegrations)||g.startIfEnabledOrStop(),!i.segment&&this.config.segment&&this.persistence&&Zn(this,Al,!1)}}_overrideSDKInfo(t,i){l.LIB_NAME=t,l.LIB_VERSION=i}startSessionRecording(t){var i,e,r,s,n,o=!0===t,a={sampling:o||!(null==t||!t.sampling),linked_flag:o||!(null==t||!t.linked_flag),url_trigger:o||!(null==t||!t.url_trigger),event_trigger:o||!(null==t||!t.event_trigger)};Object.values(a).some(Boolean)&&(null==(i=this.sessionManager)||i.checkAndGetSessionAndWindowId(),a.sampling&&(null==(e=this.sessionRecording)||e.overrideSampling()),a.linked_flag&&(null==(r=this.sessionRecording)||r.overrideLinkedFlag()),a.url_trigger&&(null==(s=this.sessionRecording)||s.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 t;return!(null==(t=this.sessionRecording)||!t.started)}captureException(t,i){try{if(!this.exceptions)return;var e=this.exceptions.buildProperties(t,{handled:!0,syntheticException:new Error("PostHog syntheticException")});return this.exceptions.sendExceptionEvent(r({},e,i))}catch(t){return}}addExceptionStep(t,i){var e;null==(e=this.exceptions)||e.addExceptionStep(t,i)}captureLog(t){var i;null==(i=this.logs)||i.captureLog(t)}get logger(){var i,e;return null!==(i=null==(e=this.logs)?void 0:e.logger)&&void 0!==i?i:t.nh}startExceptionAutocapture(t){this.set_config({capture_exceptions:null==t||t})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(t){var i,e;return null!==(i=null==(e=this.toolbar)?void 0:e.loadToolbar(t))&&void 0!==i&&i}get_property(t){var i;return null==(i=this.persistence)?void 0:i.props[t]}getSessionProperty(t){var i;return null==(i=this.sessionPersistence)?void 0:i.props[t]}toString(){var t,i=null!==(t=this.config.name)&&void 0!==t?t:Ll;return i!==Ll&&(i="posthog."+i),i}_isIdentified(){var t,i;return"identified"===(null==(t=this.persistence)?void 0:t.get_property("$user_state"))||"identified"===(null==(i=this.sessionPersistence)?void 0:i.get_property("$user_state"))}Ku(){var t,i;return!("never"===this.config.person_profiles||"identified_only"===this.config.person_profiles&&!this._isIdentified()&&yi(this.getGroups())&&(null==(t=this.persistence)||null==(t=t.props)||!t.__alias)&&(null==(i=this.persistence)||null==(i=i.props)||!i.$epp))}zu(){return!0===this.config.capture_pageleave||"if_capture_pageview"===this.config.capture_pageleave&&!!this.config.capture_pageview}createPersonProfile(){this.Ku()||this.Xu("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.Xu("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}Xu(t){return"never"===this.config.person_profiles?(ms.error(t+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.au(),this.Yu(St,!0),!0)}du(){if("always"===this.config.cookieless_mode)return!0;var t=this.consent.isOptedOut();return this.config.disable_persistence||t&&!(!this.config.opt_out_persistence_by_default&&"on_reject"!==this.config.cookieless_mode)}vu(){var t,i,e,r,s,n=this.du();return this.is_capturing()||null==(t=this.logs)||t.sh(),(null==(i=this.persistence)?void 0:i.gi)!==n&&(null==(e=this.persistence)||e.set_disabled(n)),(null==(r=this.sessionPersistence)?void 0:r.gi)!==n&&(null==(s=this.sessionPersistence)||s.set_disabled(n)),n&&(this.gu.clear(),this.Qu()),n}opt_in_capturing(i){var e,r,s;if("always"!==this.config.cookieless_mode){if(this.ou()){var n,o,a,l,h,u;null==(n=this.sessionRecording)||n.dispose({discardBufferedEvents:!0}),this.eh(!0,!0),null==(o=this.sessionManager)||o.destroy(),null==(a=this.pageViewManager)||a.destroy(),this.sessionManager=new rl(this),this.pageViewManager=new eo(this),this.persistence&&(this.sessionPropsManager=new Qa(this,this.sessionManager,this.persistence));var d,v=null!==(l=null==(h=this.config.__extensionClasses)?void 0:h.sessionRecording)&&void 0!==l?l:null==(u=t.__defaultExtensionClasses)?void 0:u.sessionRecording;v&&(this.sessionRecording=this.su(this.sessionRecording,new v(this)),this.Yl&&(null==(d=this.sessionRecording)||null==d.onRemoteConfig||d.onRemoteConfig(this.Yl)))}this.consent.optInOut(!0),this.vu(),this.ju(),null==(e=this.sessionRecording)||e.startIfEnabledOrStop(),"on_reject"==this.config.cookieless_mode&&(null==(r=this.surveys)||r.loadIfEnabled()),(wi(null==i?void 0:i.captureEventName)||null!=i&&i.captureEventName)&&this.capture(null!==(s=null==i?void 0:i.captureEventName)&&void 0!==s?s:"$opt_in",null==i?void 0:i.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.Bu()}else ms.warn(Il)}opt_out_capturing(){if("always"!==this.config.cookieless_mode){var t,i,e="on_reject"===this.config.cookieless_mode?this.sessionRecording:void 0;null==e||e.dispose({discardBufferedEvents:!0}),"on_reject"===this.config.cookieless_mode&&this.consent.isOptedIn()&&this.eh(!0,!0),this.consent.optInOut(!1),this.vu(),"on_reject"===this.config.cookieless_mode&&(this.register({distinct_id:kt,$device_id:null}),this.nu(e),this.sessionRecording=void 0,null==(t=this.sessionManager)||t.destroy(),null==(i=this.pageViewManager)||i.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,this.config.capture_pageview&&this.Bu(),this.ju())}else ms.warn(Il)}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){var t=this.consent.consent;return 1===t?"granted":0===t?"denied":"pending"}is_capturing(){return"always"===this.config.cookieless_mode||("on_reject"===this.config.cookieless_mode?this.consent.isRejected()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this.vu()}_is_bot(){return Jt?sl(Jt,this.config.custom_blocked_useragents):void 0}Bu(){Xt&&("visible"===Xt.visibilityState?this.bu||(this.bu=!0,this.capture(Ht,{title:Xt.title},{send_instantly:!0}),this._u&&(Xt.removeEventListener(zt,this._u),this._u=null)):this._u||(this._u=this.Bu.bind(this),Fs(Xt,zt,this._u)))}debug(t){!1===t?(null==Gt||Gt.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(null==Gt||Gt.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}))}Ua(){var t=this.xu||{};return"advanced_disable_flags"in t?!!t.advanced_disable_flags:!1!==this.config.advanced_disable_flags?!!this.config.advanced_disable_flags:!0===this.config.advanced_disable_decide?(ms.warn("Config field 'advanced_disable_decide' is deprecated. Please use 'advanced_disable_flags' instead. The old field will be removed in a future major version."),!0):function(t,i,e,r,s){var n=i in t&&!Ei(t[i]),o=e in t&&!Ei(t[e]);return n?t[i]:!!o&&(s&&s.warn("Config field '"+e+"' is deprecated. Please use '"+i+"' instead. The old field will be removed in a future major version."),t[e])}(t,"advanced_disable_flags","advanced_disable_decide",0,ms)}Ts(t){var i;if(Ei(this.config.before_send))return t;var e=Object.keys(null!==(i=t.properties)&&void 0!==i?i:{}).filter(Fi),r=_i(this.config.before_send)?this.config.before_send:[this.config.before_send],s=t;for(var n of r)try{if(s=n(s),Ei(s)){var o="Event '"+t.event+"' was rejected in beforeSend function";return Ci(t.event)?ms.warn(o+". This can cause unexpected behavior."):ms.info(o),null}s.properties&&!yi(s.properties)||ms.warn("Event '"+t.event+"' has no properties after beforeSend function, this is likely an error.")}catch(i){return ms.error("Error in beforeSend function for event '"+t.event+"':",i),null}for(var a of e)if(s.properties&&Ei(s.properties[a]))return ms.warn("Event '"+t.event+"' had its '"+a+"' property removed in a beforeSend function. This property is required for ingestion, so the event will be dropped."),null;return s}getPageViewId(){var t;return null==(t=this.pageViewManager.Fo)?void 0:t.pageViewId}captureTraceFeedback(t,i){this.capture("$ai_feedback",{$ai_trace_id:String(t),$ai_feedback_text:i})}captureTraceMetric(t,i,e){this.capture("$ai_metric",{$ai_trace_id:String(t),$ai_metric_name:i,$ai_metric_value:String(e)})}Su(t){var i=Ti(t)&&!t,e=Vs.Et()&&"true"===Vs.Lt("ph_debug");return!i&&(!!e||t)}},s.__defaultExtensionClasses={},s.nh=(()=>{var t=()=>{};return{trace:t,debug:t,info:t,warn:t,error:t,fatal:t}})(),s);!function(t,i){for(var e=0;i.length>e;e++)t.prototype[i[e]]=Es(t.prototype[i[e]])}(Wl,["identify"]);var Gl=class{constructor(t){this.disabled=!1===t;var i=bi(t)?t:{};this.thresholdPx=i.threshold_px||30,this.timeoutMs=i.timeout_ms||1e3,this.clickCount=i.click_count||3,this.clicks=[]}isRageClick(t,i,e){if(this.disabled)return!1;var r=this.clicks[this.clicks.length-1];if(r&&Math.abs(t-r.x)+Math.abs(i-r.y)<this.thresholdPx&&this.timeoutMs>e-r.timestamp){if(this.clicks.push({x:t,y:i,timestamp:e}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:t,y:i,timestamp:e}];return!1}},Kl="$copy_autocapture",Jl=bs("[AutoCapture]");function Xl(t,i){return i.length>t?i.slice(0,t)+"...":i}function Yl(t){if(t.previousElementSibling)return t.previousElementSibling;var i=t;do{i=i.previousSibling}while(i&&!un(i));return i}function Zl(t,i){var e,s,n=i.e,o=i.maskAllElementAttributes,a=i.maskAllText,l=i.elementAttributeIgnoreList,h=i.elementsChainAsString,u=i.disableCaptureUrlHashes;if(!un(t))return{props:{}};for(var d=[t],v=new Set([t]),c=t;c.parentNode&&!dn(c,"body")&&1e3>d.length;)if(cn(c.parentNode)){var f=c.parentNode.host;if(v.has(f))break;v.add(f),d.push(f),c=f}else{if(!un(c.parentNode))break;if(v.has(c.parentNode))break;v.add(c.parentNode),d.push(c.parentNode),c=c.parentNode}var p="click"===n.type&&"http://www.w3.org/2000/svg"===t.namespaceURI?d.findIndex(t=>dn(t,"button")||dn(t,"a")):-1;p>0&&(a=a||d.slice(0,p+1).some(t=>!Rn(t)||On(t)));var g,_,m,b=[],y={},w=!1,x=!1;if(ws(d,t=>{var i=Rn(t);if(dn(t,"a")){var e=t.getAttribute("href");w=!!(i&&e&&Un(e))&&(u?tr(e):e)}ui(gn(t),"ph-no-capture")&&(x=!0),b.push(function(t,i,e,r,s){void 0===s&&(s=!1);var n=t.tagName.toLowerCase(),o={tag_name:n};yn.indexOf(n)>-1&&!e&&(o.$el_text="a"===n.toLowerCase()||"button"===n.toLowerCase()?Xl(1024,Hn(t)):Xl(1024,mn(t)));var a=gn(t);a.length>0&&(o.classes=a.filter(function(t){return""!==t})),ws(t.attributes,function(e){var n;if((!On(t)||-1!==["name","id","class","aria-label"].indexOf(e.name))&&(null==r||!r.includes(e.name))&&!i&&Un(e.value)&&(!xi(n=e.name)||"_ngcontent"!==n.substring(0,10)&&"_nghost"!==n.substring(0,7))){var a=e.value;"class"===e.name&&(a=fn(a).join(" ")),o["attr__"+e.name]=Xl(1024,"href"===e.name&&s?tr(a):a)}});for(var l=1,h=1,u=t;u=Yl(u);)l++,u.tagName===t.tagName&&h++;return o.nth_child=l,o.nth_of_type=h,o}(t,o,a,l,u)),ws(function(t){if(!Rn(t))return{};var i={};return ws(t.attributes,function(t){if(t.name&&0===t.name.indexOf("data-ph-capture-attribute")){var e=t.name.replace("data-ph-capture-attribute-",""),r=t.value;e&&r&&Un(r)&&(i[e]=r)}}),i}(t),(t,i)=>{({}).hasOwnProperty.call(y,i)||(y[i]=t)})}),x)return{props:{},explicitNoCapture:x};if(p>0&&(t=d[p],b.splice(0,p)),a||(b[0].$el_text=dn(t,"a")||dn(t,"button")?Hn(t):mn(t)),w){var S,k;b[0].attr__href=w;var E=null==(S=lo(w))?void 0:S.host,P=null==Gt||null==(k=Gt.location)?void 0:k.host;E&&P&&E!==P&&(g=w)}return{props:xs((_=n.type,{$event_type:_,$ce_version:1}),h?{}:{$elements:b},{$elements_chain:(m=b,_i(m)?function(t){return t.map(t=>{var i,e,s="";if(t.tag_name&&(s+=t.tag_name),t.attr_class)for(var n of(t.attr_class.sort(),t.attr_class))s+="."+n.replace(/"/g,"");var o=r({},t.text?{text:t.text}:{},{"nth-child":null!==(i=t.nth_child)&&void 0!==i?i:0,"nth-of-type":null!==(e=t.nth_of_type)&&void 0!==e?e:0},t.href?{href:t.href}:{},t.attr_id?{attr_id:t.attr_id}:{},t.attributes),a={};return Ss(o).sort((t,i)=>{return(r=i[0])>(e=t[0])?-1:e>r?1:0;var e,r}).forEach(t=>{var i=t[1];return a[Vn(t[0].toString())]=Vn(i.toString())}),(s+=":")+Ss(a).map(t=>t[0]+'="'+t[1]+'"').join("")}).join(";")}(function(t){return t.map(t=>{var i,e,r={text:null==(i=t.$el_text)?void 0:i.slice(0,400),tag_name:t.tag_name,href:null==(e=t.attr__href)?void 0:e.slice(0,2048),attr_class:Wn(t),attr_id:t.attr__id,nth_child:t.nth_child,nth_of_type:t.nth_of_type,attributes:{}};return Ss(t).filter(t=>0===t[0].indexOf("attr__")).forEach(t=>r.attributes[t[0]]=t[1]),r})}(m)):"")},null!=(e=b[0])&&e.$el_text?{$el_text:null==(s=b[0])?void 0:s.$el_text}:{},g&&"click"===n.type?{$external_click_url:g}:{},y),target:t}}var Ql=class{Qs(){this.Ks=void 0,clearTimeout(this.Xs),this.Xs=void 0}Ys(t){var i;if(!Rn(t))return!0;for(var e,r=null!==(i=this.so().css_selector_ignorelist)&&void 0!==i?i:kn,s=new Set,n=t,o=function(){if(s.size>=1e3||s.has(n))return{v:!0};s.add(n);var t=n,i=gn(t);if(ui(i,"ph-no-capture")||ui(i,"ph-sensitive")||On(t)||r.some(i=>wn(t,i)))return{v:!0};var e=n.parentNode;n=cn(e)?e.host:e&&un(e)?e:null};n;)if(e=o())return e.v;return!1}oo(t){if(this.isEnabled&&"pointercancel"!==t.type)if("pointerdown"!==t.type){var i=this.Ks;i&&(t.pointerId!==i.id||Math.abs(t.clientX-i.x)>5||Math.abs(t.clientY-i.y)>5?this.Qs():"pointerup"===t.type&&(i.released=!0,this.Xs=setTimeout(()=>this.Qs(),0)))}else{var e;this.Qs();var r=bn(t);t.isPrimary&&0===t.button&&!t.ctrlKey&&r&&un(r)&&(this.Ks={target:r,excluded:this.Ys(r),id:t.pointerId,x:t.clientX,y:t.clientY,released:!1,distinctId:null==(e=this.ao)?void 0:e.distinctId})}else this.Qs()}lo(t){var i,e=this.Ks;this.Qs();var r=bn(t);if(null!=e&&e.released&&e.target.isConnected&&e.distinctId===(null==(i=this.ao)?void 0:i.distinctId)&&t.pointerId===e.id&&(t.detail>0||"touch"===t.pointerType||"pen"===t.pointerType)&&0===t.button&&5>=Math.abs(t.clientX-e.x)&&5>=Math.abs(t.clientY-e.y)&&r&&(dn(r,"html")||dn(r,"body"))){var s;if(e.excluded)return null;var n=null!==(s=this.so().css_selector_ignorelist)&&void 0!==s?s:kn;return[r,null==Xt?void 0:Xt.documentElement,null==Xt?void 0:Xt.body].some(t=>{if(!t)return!1;var i=gn(t);return ui(i,"ph-no-capture")||ui(i,"ph-sensitive")||!Rn(t)||On(t)||n.some(i=>wn(t,i))})?null:e.target}}constructor(t){this.uo=t,this.name="autocapture",this.ho=!1,this.do=null,this.vo=!1,this.co=!1,this.xn={enabled:!1,rageclick:!1,maskAllElementAttributes:!1,maskAllText:!1,disableCaptureUrlHashes:!1,remoteRequestsDisabled:!1},this.fo=!1,this.uo.refresh(this.xn),this.rageclicks=new Gl(this.xn.rageclick),this.po=null}setup(t){this.mo(),this.ao=t;var i=t.onRemoteConfig(this.onRemoteConfig.bind(this));this.fo?i.dispose():(this.yo=i,this.startIfEnabled())}dispose(){var t;this.fo||(this.fo=!0,this.ao=void 0,null==(t=this.yo)||t.dispose(),this.yo=void 0,this.bo())}so(){return this.uo.refresh(this.xn),this.xn}mo(){var t,i;return this.so(),this.xn.url_allowlist=null==(t=this.xn.url_allowlist)?void 0:t.map(t=>new RegExp(t)),this.xn.url_ignorelist=null==(i=this.xn.url_ignorelist)?void 0:i.map(t=>new RegExp(t)),this.xn}_o(){if(this.isBrowserSupported()){if(Gt&&Xt){var t=this.wo=t=>{t=t||(null==Gt?void 0:Gt.event);try{if("blur"===t.type)return void this.Qs();if(0===t.type.indexOf("pointer"))return void this.oo(t);var i="click"===t.type?this.lo(t):void 0;if(ki(i))return;this.ko(t,"$autocapture",i)}catch(t){Jl.error("Failed to capture event",t)}};if(Fs(Gt,"blur",t),Fs(Xt,"submit",t,{capture:!0}),Fs(Xt,"change",t,{capture:!0}),Fs(Xt,"click",t,{capture:!0}),ws(["pointerdown","pointermove","pointerup","pointercancel"],i=>{Fs(Xt,i,t,{capture:!0})}),this.so().capture_copied_text){var i=this.So=t=>{t=t||(null==Gt?void 0:Gt.event);try{this.ko(t,Kl)}catch(t){Jl.error("Failed to capture clipboard event",t)}};Fs(Xt,"copy",i,{capture:!0}),Fs(Xt,"cut",i,{capture:!0}),Fs(Xt,"paste",i,{capture:!0})}}}else Jl.info("Disabling Automatic Event Collection because this browser is not supported")}bo(){this.Qs(),this.wo&&(null==Gt||Gt.removeEventListener("blur",this.wo),ws(["pointerdown","pointermove","pointerup","pointercancel"],t=>{null==Xt||Xt.removeEventListener(t,this.wo,!0)}),null==Xt||Xt.removeEventListener("submit",this.wo,!0),null==Xt||Xt.removeEventListener("change",this.wo,!0),null==Xt||Xt.removeEventListener("click",this.wo,!0),this.wo=void 0),this.So&&(null==Xt||Xt.removeEventListener("copy",this.So,!0),null==Xt||Xt.removeEventListener("cut",this.So,!0),null==Xt||Xt.removeEventListener("paste",this.So,!0),this.So=void 0),this.ho=!1}startIfEnabled(){this.isEnabled||this.Qs(),!this.fo&&this.ao&&this.isEnabled&&!this.ho&&(this._o(),this.ho=!0)}onRemoteConfig(t){if(!this.fo)if(this.vo=!0,t.ok){var i=t.config;i.elementsChainAsString&&(this.co=i.elementsChainAsString);var e,r=i.autocapture_opt_out;Ti(r)&&(null==(e=this.ao)||e.kv.set(m,r),this.do=r),this.startIfEnabled()}else this.startIfEnabled()}setElementSelectors(t){this.po=t}getElementSelectors(t,i){var e,r=[];return null==(e=this.po)||e.forEach(e=>{var s;null==Xt||null==(s=Xt.querySelectorAll(e))||s.forEach(s=>{t!==s&&i!==s||ui(r,e)||r.push(e)})}),r}get isEnabled(){var t,i;if(this.fo)return!1;var e=null==(t=this.ao)?void 0:t.kv.get(m),r=this.do,s=this.so();if(!s.remoteRequestsDisabled&&!this.vo)return!1;var n=s.remoteRequestsDisabled&&!this.vo;if(ki(r)&&!Ti(e)&&!n)return!1;var o=null!==(i=this.do)&&void 0!==i?i:!!e;return!!s.enabled&&!o}ko(t,i,e){if(void 0===i&&(i="$autocapture"),this.isEnabled){var s=e||bn(t);vn(s)&&(s=s.parentNode||null);var n,o=this.mo();"$autocapture"===i&&"click"===t.type&&t instanceof MouseEvent&&o.rageclick&&null!=(n=this.rageclicks)&&n.isRageClick(t.clientX,t.clientY,t.timeStamp||(new Date).getTime())&&Fn(s,o.rageclick)&&this.ko(t,"$rageclick",e);var a=i===Kl,l=a?r({},o,{dom_event_allowlist:void 0}):o;if(s&&function(t,i,e,r,s,n){var o;if(!Gt||An(t))return!1;if(null!=e&&e.url_allowlist&&!pn(e.url_allowlist,n))return!1;if(null!=e&&e.url_ignorelist&&pn(e.url_ignorelist,n))return!1;if(null!=e&&e.dom_event_allowlist){var a=e.dom_event_allowlist;if(a&&!a.some(t=>i.type===t))return!1}var l=In(t,r),h=l.parentIsUsefulElement,u=l.targetElementList;if(!function(t,i){var e=null==i?void 0:i.element_allowlist;if(wi(e))return!0;var r,s=function(t){if(e.some(i=>t.tagName.toLowerCase()===i))return{v:!0}};for(var n of t)if(r=s(n))return r.v;return!1}(u,e))return!1;if(!xn(u,null==e?void 0:e.css_selector_allowlist))return!1;if(xn(u,null!==(o=null==e?void 0:e.css_selector_ignorelist)&&void 0!==o?o:kn))return!1;try{var d=Gt.getComputedStyle(t);if(d&&"pointer"===d.getPropertyValue("cursor")&&"click"===i.type)return!0}catch(t){}var v=t.tagName.toLowerCase();switch(v){case"html":return!1;case"form":return(s||["submit"]).indexOf(i.type)>=0;case"input":case"select":case"textarea":return(s||["change","click"]).indexOf(i.type)>=0;default:return h?(s||["click"]).indexOf(i.type)>=0:(s||["click"]).indexOf(i.type)>=0&&(yn.indexOf(v)>-1||"true"===t.getAttribute("contenteditable"))}}(s,t,l,a,a?["copy","cut","paste"]:void 0,{config:{get_current_url:o.getCurrentUrl}})){var h,u=Zl(s,{e:t,maskAllElementAttributes:o.maskAllElementAttributes,maskAllText:o.maskAllText,elementAttributeIgnoreList:o.element_attribute_ignorelist,elementsChainAsString:this.co,disableCaptureUrlHashes:o.disableCaptureUrlHashes}),d=u.props;if(u.explicitNoCapture)return!1;var v=this.getElementSelectors(s,u.target);if(v&&v.length>0&&(d.$element_selectors=v),i===Kl){var c=t.type||"clipboard";if("paste"!==c){var f,p,g=null==Gt||null==(f=Gt.getSelection())?void 0:f.toString(),_=_n(g);if(!_)return!1;d.$selected_content=_,d.$clipboard_text_length=null!==(p=null==g?void 0:g.length)&&void 0!==p?p:0}d.$copy_type=c}return null==(h=this.ao)||h.capture(i,d).catch(t=>Jl.error("Failed to capture event",t)),!0}}else this.Qs()}isBrowserSupported(){return mi(null==Xt?void 0:Xt.querySelectorAll)}},th=class{constructor(t){this._instance=t}refresh(t){var i=this._instance.config,e=bi(i.autocapture)?i.autocapture:void 0;t.enabled=!!i.autocapture,t.rageclick=i.rageclick,t.maskAllElementAttributes=i.mask_all_element_attributes,t.maskAllText=i.mask_all_text,t.disableCaptureUrlHashes=i.disable_capture_url_hashes,t.getCurrentUrl=i.get_current_url,t.remoteRequestsDisabled=this._instance.Ua(),t.url_allowlist=null==e?void 0:e.url_allowlist,t.url_ignorelist=null==e?void 0:e.url_ignorelist,t.dom_event_allowlist=null==e?void 0:e.dom_event_allowlist,t.element_allowlist=null==e?void 0:e.element_allowlist,t.css_selector_allowlist=null==e?void 0:e.css_selector_allowlist,t.css_selector_ignorelist=null==e?void 0:e.css_selector_ignorelist,t.element_attribute_ignorelist=null==e?void 0:e.element_attribute_ignorelist,t.capture_copied_text=null==e?void 0:e.capture_copied_text}},ih=bs("[ExceptionAutocapture]"),eh=()=>{},rh=t=>{var i;if(mi(t))return null!==(i=t.__posthog_layer__)&&void 0!==i?i:t.__rrweb_layer__};function sh(t,i,e){try{if(!(i in t))return eh;var r={next:t[i]},s=e(function(){for(var t=arguments.length,i=new Array(t),e=0;t>e;e++)i[e]=arguments[e];return r.next.apply(this,i)});return mi(s)&&(s.prototype=s.prototype||{},Object.defineProperties(s,{__posthog_wrapped__:{enumerable:!1,value:!0},__posthog_layer__:{enumerable:!1,value:r}})),t[i]=s,()=>{if(t[i]!==s)for(var e=t[i],n=rh(e);n;){if(n.next===s)return void(n.next=r.next);n=rh(e=n.next)}else t[i]=r.next}}catch(t){return eh}}var nh=bs("[TracingHeaders]"),oh=bs("[Web Vitals]"),ah=9e5,lh=["CLS","FCP","INP","LCP"],hh=["INP","LCP"],uh=["interactionTarget","interactionType","inputDelay","processingDuration","presentationDelay","loadState","target","url","timeToFirstByte","resourceLoadDelay","resourceLoadDuration","elementRenderDelay","largestShiftTarget","largestShiftTime","largestShiftValue","firstByteToFCP"],dh="disabled",vh="lazy_loading",ch=bs("[SessionRecording]"),fh=bs("[Heatmaps]");function ph(t){return bi(t)&&"clientX"in t&&"clientY"in t&&$i(t.clientX)&&$i(t.clientY)}var gh=bs("[Product Tours]"),_h=t=>{var i;return!t.config.disable_product_tours&&!(null==(i=t.persistence)||!i.get_property(E))},mh=bs("[SiteApps]"),bh="Error while initializing PostHog app with config id ",yh=(t,i)=>null!=t&&t.then?t.then(i):i(t),wh="SDK is not enabled or survey functionality is not yet loaded",xh="Disabled. Not loading surveys.",Sh=class{constructor(t,i){this.uo=t,this.oh=i,this.name="surveys",this._surveyEventReceiver=null,this._surveyManager=null,this.ah=!1,this.uh=[],this.hh=null,this.dh=null,this.fo=!1,this.fh=new Set,this.onRemoteConfig=t=>{if(!this.fo&&!this.xn.disableSurveys){if(!t.ok)return ml.warn("Remote config unavailable. Not loading surveys.");var i=t.config.surveys;if(Ei(i))return ml.warn("Flags not loaded yet. Not loading surveys.");this.ph=Ti(i)?i:i.length>0,ml.info("flags response received, isSurveysEnabled: "+this.ph),this.loadIfEnabled()}}}setup(t){if(!this.fo)return this.gh=t,yh(t.kv.initialize(),()=>{if(this.gh===t&&!this.fo){this.gh=void 0,this.ao=t;var i=t.onRemoteConfig(this.onRemoteConfig);this.fo?i.dispose():(this.yo=i,this.loadIfEnabled())}})}dispose(){var t,i,e;this.fo||(this.fo=!0,this.gh=void 0,this.ao=void 0,null==(t=this.yo)||t.dispose(),this.yo=void 0,null==(i=this._surveyEventReceiver)||i.dispose(),this._surveyEventReceiver=null,null==(e=this._surveyManager)||null==e.dispose||e.dispose(),this._surveyManager=null,this.uh=[],this.hh=null,this.fh.forEach(t=>clearTimeout(t)),this.fh.clear())}get xn(){return this.uo.get()}initialize(){this.loadIfEnabled()}reset(){try{var t;null==(t=this._surveyEventReceiver)||t.reset(),localStorage.removeItem("lastSeenSurveyDate");for(var i=[],e=0;e<localStorage.length;e++){var r=localStorage.key(e);(null!=r&&r.startsWith("seenSurvey_")||null!=r&&r.startsWith("inProgressSurvey_"))&&i.push(r)}i.forEach(t=>localStorage.removeItem(t))}catch(t){}}loadIfEnabled(){if(!this.fo&&this.ao){var t=this.xn;if(!this._surveyManager)if(this.ah)ml.info("Already initializing surveys, skipping...");else if(t.disableSurveys)ml.info(xh);else if(t.cookielessMode&&this.uo.isOptedOut())ml.info("Not loading surveys in cookieless mode without consent.");else{var i=this.uo.getExtensions();if(i){if(!wi(this.ph)||t.advancedEnableSurveys){var e=this.ph||t.advancedEnableSurveys;this.ah=!0;try{var r=i.generateSurveys;if(r)return this.mh(r,e),void(this.ah=!1);var s=i.loadExternalDependency;if(!s)return this.yh(jt),void(this.ah=!1);s(t=>{try{if(this.fo)return;var i=this.uo.getExtensions();t||null==i||!i.generateSurveys?this.yh("Could not load surveys script",t):this.mh(i.generateSurveys,e)}finally{this.ah=!1}})}catch(t){throw this.ah=!1,this.yh("Error initializing surveys",t),t}}}else ml.error("PostHog Extensions not found.")}}}mh(t,i){this.fo||(this._surveyManager=t(i),this._surveyEventReceiver=this.uo.createEventReceiver(),ml.info("Surveys loaded successfully"),this.bh({isLoaded:!0}))}yh(t,i){ml.error(t,i),this.bh({isLoaded:!1,error:t})}onSurveysLoaded(t){return this.uh.push(t),this._surveyManager&&this.bh({isLoaded:!0}),()=>{this.uh=this.uh.filter(i=>i!==t)}}getSurveys(t,i){var e;void 0===i&&(i=!1);var r=null!==(e=this.ao)&&void 0!==e?e:this.oh;if(r&&!this.fo){if(this.xn.disableSurveys)return ml.info(xh),t([]);var s=r.kv.get(it);if(s&&!i)return t(s,{isLoaded:!0}),void(this._h()&&this.getSurveys(()=>{},!0));if(this.hh)this.hh.then(i=>{this.fo||t(i.surveys,i.context)}).catch(t=>ml.error("Error in survey callback",t));else{var n=this.wh("/api/surveys/",{method:"GET",query:{token:r.projectToken},sentAt:"query",timeoutMs:this.xn.requestTimeoutMs}).then(t=>{try{return this.kh(r,t)}catch(t){return ml.error("Error processing surveys response",t),this.kh(r,{statusCode:0,error:t})}},t=>this.kh(r,{statusCode:0,error:t}));this.hh=n;var o=()=>{this.hh===n&&(this.hh=null)};n.then(i=>{o(),this.fo||t(i.surveys,i.context)},o).catch(t=>ml.error("Error in survey callback",t))}}}wh(t,i){var e=this.ao;return e?e.sendRequest(t,i):new Promise(t=>t({statusCode:0,error:new Error(wh)}))}kh(t,i){var e;if(this.fo)return{surveys:[],context:{isLoaded:!1,error:wh}};var r=i.statusCode;if(200!==r||!i.json){var s="Surveys API could not be loaded, status: "+r;return 0!==r?ml.error(s):i.error||ml.warn(s),this.dh=Date.now(),{surveys:[],context:{isLoaded:!1,error:s}}}this.dh=null;var n=i.json.surveys||[],o=n.filter(t=>function(t){return!(!t.start_date||t.end_date)}(t)&&(al(t)||function(t){var i;return!(null==(i=t.conditions)||null==(i=i.actions)||null==(i=i.values)||!i.length)}(t)));return o.length>0&&(null==(e=this._surveyEventReceiver)||e.register(o)),t.kv.set({[it]:n,[et]:Date.now()}),{surveys:n,context:{isLoaded:!0}}}_h(){return this.Sh()&&!this.hh&&!this.xh()}Sh(){var t,i,e=null==(t=null!==(i=this.ao)&&void 0!==i?i:this.oh)?void 0:t.kv.get(et);return $i(e)&&Date.now()-e>3e5}xh(){return $i(this.dh)&&3e5>Date.now()-this.dh}markSurveyAsSeen(t,i){var e;bl({id:t,current_iteration:null!==(e=null==i?void 0:i.iteration)&&void 0!==e?e:null});try{localStorage.setItem("lastSeenSurveyDate",(new Date).toISOString())}catch(t){}}bh(t){for(var i of this.uh)try{if(!t.isLoaded)return i([],t);this.getSurveys(i)}catch(t){ml.error("Error in survey callback",t)}}getActiveMatchingSurveys(t,i){if(void 0===i&&(i=!1),!Ei(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(t,i);ml.warn("init was not called")}Ch(t){var i=null;return this.getSurveys(e=>{var r;i=null!==(r=e.find(i=>i.id===t))&&void 0!==r?r:null}),i}Th(t){if(Ei(this._surveyManager))return{eligible:!1,reason:wh};var i="string"==typeof t?this.Ch(t):t;return i?this._surveyManager.checkSurveyEligibility(i):{eligible:!1,reason:"Survey not found"}}Mh(t){if(!this.uo.isCapturing())return{eligible:!1,reason:"PostHog is not capturing, so a survey response cannot be recorded"};if(Ei(this._surveyManager))return{eligible:!1,reason:wh};var i="string"==typeof t?this.Ch(t):t;return i?this._surveyManager.checkSurveyRenderability(i):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(t){if(Ei(this._surveyManager))return ml.warn("init was not called"),{visible:!1,disabledReason:wh};var i=this.Mh(t);return{visible:i.eligible,disabledReason:i.reason}}canRenderSurveyAsync(t,i){return Ei(this._surveyManager)?(ml.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:wh})):new Promise(e=>{this.getSurveys(i=>{var r,s=null!==(r=i.find(i=>i.id===t))&&void 0!==r?r:null;if(s){var n=this.Mh(s);e({visible:n.eligible,disabledReason:n.reason})}else e({visible:!1,disabledReason:"Survey not found"})},i)})}renderSurvey(t,i,e){var r;if(this.uo.isCapturing())if(Ei(this._surveyManager))ml.warn("init was not called");else{var s="string"==typeof t?this.Ch(t):t;if(null!=s&&s.id)if(yl.includes(s.type)){var n=null==Xt?void 0:Xt.querySelector(i);if(n)if(null!=(r=s.appearance)&&r.surveyPopupDelaySeconds){ml.info("Rendering survey "+s.id+" with delay of "+s.appearance.surveyPopupDelaySeconds+" seconds");var o=setTimeout(()=>{var t,i;this.fh.delete(o),!this.fo&&this.uo.isCapturing()&&(ml.info("Rendering survey "+s.id+" with delay of "+(null==(t=s.appearance)?void 0:t.surveyPopupDelaySeconds)+" seconds"),null==(i=this._surveyManager)||i.renderSurvey(s,n,e),ml.info("Survey "+s.id+" rendered"))},1e3*s.appearance.surveyPopupDelaySeconds);this.fh.add(o)}else this._surveyManager.renderSurvey(s,n,e);else ml.warn("Survey element not found")}else ml.warn("Surveys of type "+s.type+" cannot be rendered in the app");else ml.warn("Survey not found")}}displaySurvey(t,i){var e;if(this.uo.isCapturing())if(Ei(this._surveyManager))ml.warn("init was not called");else{var s=this.Ch(t);if(s){var n=s;if(null!=(e=s.appearance)&&e.surveyPopupDelaySeconds&&i.ignoreDelay&&(n=r({},s,{appearance:r({},s.appearance,{surveyPopupDelaySeconds:0})})),i.displayType!==Ko&&i.initialResponses&&ml.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),!1===i.ignoreConditions){var o=this.Th(s);if(!o.eligible)return void ml.warn("Survey is not eligible to be displayed: ",o.reason)}"inline"!==i.displayType?this._surveyManager.handlePopoverSurvey(n,i):this.renderSurvey(n,i.selector,i.properties)}else ml.warn("Survey not found")}}cancelPendingSurvey(t){Ei(this._surveyManager)?ml.warn("init was not called"):this._surveyManager.cancelSurvey(t)}handlePageUnload(){var t;null==(t=this._surveyManager)||null==t.handlePageUnload||t.handlePageUnload()}};function kh(t,i,e){if(Ei(t))return!1;switch(e){case"exact":return t===i;case"contains":var r=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(r,"i").test(t);case"regex":try{return new RegExp(i).test(t)}catch(t){return!1}default:return!1}}var Eh=class{constructor(t){this._instance=t,this.Ih=new Set,this.Eh=new Set,this.Rh=new tl,this.Ah=(t,i)=>this.Ph(t,i)&&this.Fh(t,i)&&this.Oh(t,i)&&this.$h(t,i),this.Ph=(t,i)=>null==i||!i.event||(null==t?void 0:t.event)===(null==i?void 0:i.event)}init(){var t,i;wi(null==(t=this._instance)?void 0:t._addCaptureHook)||(this.Dh=null==(i=this._instance)?void 0:i._addCaptureHook((t,i)=>{this.on(t,i)}))}dispose(){var t;null==(t=this.Dh)||t.call(this),this.Dh=void 0,this.Rh=new tl}register(t){var i,e;if(!wi(null==(i=this._instance)?void 0:i._addCaptureHook)&&(t.forEach(t=>{var i;this.Ih.add(t),null==(i=t.steps)||i.forEach(t=>{this.Eh.add((null==t?void 0:t.event)||"")})}),null!=(e=this._instance)&&e.autocapture)){var r=new Set;this.Ih.forEach(t=>{var i;null==(i=t.steps)||i.forEach(t=>{null!=t&&t.selector&&r.add(t.selector)})}),this._instance.autocapture.setElementSelectors(r)}}replace(t){this.Ih.clear(),this.Eh.clear(),this.register(t)}on(t,i){null!=i&&0!=t.length&&(this.Eh.has(t)||this.Eh.has(i.event))&&this.Ih.forEach(t=>{this.Lh(i,t)&&this.Rh.emit("actionCaptured",t.name)})}Nh(t){this.onAction("actionCaptured",i=>t(i))}Lh(t,i){if(null==(null==i?void 0:i.steps))return!1;for(var e of i.steps)if(this.Ah(t,e))return!0;return!1}onAction(t,i){return this.Rh.on(t,i)}Fh(t,i){if(null!=i&&i.url){var e,r=null==t||null==(e=t.properties)?void 0:e.$current_url;if(!r||"string"!=typeof r)return!1;if(!kh(r,i.url,i.url_matching||"contains"))return!1}return!0}Oh(t,i){return!!this.qh(t,i)&&!!this.jh(t,i)&&!!this.Bh(t,i)}qh(t,i){var e;if(null==i||!i.href)return!0;var r=this.Hh(t);if(r.length>0)return r.some(t=>kh(t.href,i.href,i.href_matching||"exact"));var s,n=(null==t||null==(e=t.properties)?void 0:e.$elements_chain)||"";return!!n&&kh((s=n.match(/(?::|")href="(.*?)"/))?s[1]:"",i.href,i.href_matching||"exact")}jh(t,i){var e;if(null==i||!i.text)return!0;var r=this.Hh(t);if(r.length>0)return r.some(t=>kh(t.text,i.text,i.text_matching||"exact")||kh(t.$el_text,i.text,i.text_matching||"exact"));var s,n,o,a=(null==t||null==(e=t.properties)?void 0:e.$elements_chain)||"";return!!a&&(s=function(t){for(var i,e=[],r=/(?::|")text="(.*?)"/g;!Ei(i=r.exec(t));)e.includes(i[1])||e.push(i[1]);return e}(a),n=i.text,o=i.text_matching||"exact",s.some(t=>kh(t,n,o)))}Bh(t,i){var e,r;if(null==i||!i.selector)return!0;if(null!=t&&null!=(e=t.properties)&&null!=(e=e.$element_selectors)&&e.includes(i.selector))return!0;var s=(null==t||null==(r=t.properties)?void 0:r.$elements_chain)||"";if(i.selector_regex&&s)try{return new RegExp(i.selector_regex).test(s)}catch(t){return!1}return!1}Hh(t){var i;return null==(null==t||null==(i=t.properties)?void 0:i.$elements)?[]:null==t?void 0:t.properties.$elements}$h(t,i){return null==i||!i.properties||0===i.properties.length||dl(i.properties.reduce((t,i)=>{var e=_i(i.value)?i.value.map(String):null!=i.value?[String(i.value)]:[];return t[i.key]={values:e,operator:i.operator||"exact"},t},{}),null==t?void 0:t.properties)}},$h=class{constructor(t){var i;this.zh=[],this._instance=t,this.Uh=new Map,this.Wh=new Map,this.Vh=new Map,this.Gh=null==(i=this._instance)||null==i.onSessionId?void 0:i.onSessionId(t=>this.Zh(t))}Jh(t){return!1}Qh(){return null}Kh(t){}Xh(){}Yh(t,i){return!!t&&dl(t.propertyFilters,null==i?void 0:i.properties)}td(t,i){var e=new Map;return t.forEach(t=>{var r;null==(r=t.conditions)||null==(r=r[i])||null==(r=r.values)||r.forEach(i=>{if(null!=i&&i.name){var r=e.get(i.name)||[];r.push(t.id),e.set(i.name,r)}})}),e}ed(t,i,e){var r=(e===Uo?this.Uh:this.Wh).get(t),s=[];return this.rd(t=>{s=t.filter(t=>null==r?void 0:r.includes(t.id))}),s.filter(r=>{var s,n=null==(s=r.conditions)||null==(s=s[e])||null==(s=s.values)?void 0:s.find(i=>i.name===t);return this.Yh(n,i)})}register(t){this.nd(t,!1)}replace(t){this.nd(t,!0)}nd(t,i){var e;wi(null==(e=this._instance)?void 0:e._addCaptureHook)||(this.sd(t,i),this.od(t,i))}od(t,i){var e=t.filter(t=>{var i;return null==(i=t.conditions)||null==(i=i.actions)||null==(i=i.values)?void 0:i.length});if(i&&this.Vh.clear(),0!==e.length){this.ad||(this.ad=new Eh(this._instance),this.ad.init(),this.ad.Nh(t=>this.onAction(t)));var r=[];e.forEach(t=>{var i;null==(i=t.conditions)||null==(i=i.actions)||i.values.forEach(i=>{if(r.push(i),i.name){var e,s=null!==(e=this.Vh.get(i.name))&&void 0!==e?e:[];s.includes(t.id)||s.push(t.id),this.Vh.set(i.name,s)}})}),i?this.ad.replace(r):this.ad.register(r)}else{var s;i&&(null==(s=this.ad)||s.replace([]))}}ld(t,i){i.forEach((i,e)=>{var r,s=null!==(r=t.get(e))&&void 0!==r?r:[];i.forEach(t=>{s.includes(t)||s.push(t)}),t.set(e,s)})}sd(t,i){var e,r,s=t.filter(t=>{var i,e;return(null==(i=t.conditions)?void 0:i.events)&&(null==(e=t.conditions)||null==(e=e.events)||null==(e=e.values)?void 0:e.length)>0}),n=t.filter(t=>{var i,e;return(null==(i=t.conditions)?void 0:i.cancelEvents)&&(null==(e=t.conditions)||null==(e=e.cancelEvents)||null==(e=e.values)?void 0:e.length)>0}),o=this.td(t,Uo),a=this.td(t,Ho);i?(this.Uh=o,this.Wh=a):(this.ld(this.Uh,o),this.ld(this.Wh,a)),(0!==s.length||0!==n.length)&&(null!==(e=this.Dh)&&void 0!==e||(this.Dh=null==(r=this._instance)?void 0:r._addCaptureHook((t,i)=>{this.onEvent(t,i)})))}onEvent(t,i){var e,r,s=this.ud(),n=(null==i||null==(e=i.properties)?void 0:e.$survey_id)||(null==i||null==(r=i.properties)?void 0:r.$product_tour_id);if(n&&this.getActivatedIds().includes(n)){var o=this.hd(t,n);if("consume"===o)return s.info("event consumed activated item, removing it",{event:t,itemId:n}),void this.dd([n]);if("persist"===o)return s.info("shown item promoted to persisted activation",{event:t,itemId:n}),this.vd(n),void this.fd([n])}if(this.Wh.has(t)){var a=this.ed(t,i,Ho);a.length>0&&(s.info("cancel event matched, cancelling items",{event:t,itemsToCancel:a.map(t=>t.id)}),this.dd(a.map(t=>t.id)),a.forEach(t=>this.pd(t.id)))}if(this.Uh.has(t)){s.info("event name matched",{event:t,eventPayload:i,items:this.Uh.get(t)});var l=this.ed(t,i,Uo);this.gd(l.map(t=>t.id))}}onAction(t){this.Vh.has(t)&&this.gd(this.Vh.get(t)||[])}gd(t){var i;if(0!==t.length){var e=!(null==(i=this._instance)||null==i.get_session_id||!i.get_session_id()),r=[];for(var s of t)e&&this.Jh(s)?this.vd(s)&&this.md(s):r.push(s);r.length>0&&(this.zh=[...new Set([...this.zh,...r])]),this.ud().info("updating activated items",{activatedItems:this.getActivatedIds()})}}vd(t){this.zh=this.zh.filter(i=>i!==t);var i=this.yd();return!i.includes(t)&&(this.bd([...i,t]),this._d(),!0)}dd(t){var i=new Set(t);this.zh=this.zh.filter(t=>!i.has(t));var e=this.wd(),r=e.filter(t=>!i.has(t));r.length!==e.length&&(this.bd(r),0===r.length&&this.kd()),this.fd(t)}Sd(){var t,i=this.Qh();if(!i)return{};var e=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[i];return e&&"object"==typeof e?e:{}}md(t){if(this.Qh()){var i=this.Sd();this.Kh(r({},i,{[t]:Date.now()}))}}fd(t){if(this.Qh()){var i=this.Sd(),e={},r=!1;for(var s of Object.entries(i)){var n=s[0],o=s[1];t.includes(n)?r=!0:e[n]=o}r&&(yi(e)?this.Xh():this.Kh(e))}}xd(){this.Qh()&&this.Xh()}getActivationTimestamp(t){if(this.yd().includes(t)){var i=this.Sd()[t];return $i(i)?i:void 0}}wd(){var t,i=this.Cd();return(null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[i])||[]}yd(){var t,i,e=this.wd();if(0===e.length)return[];var r=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[this.Td()],s=null==(i=this._instance)||null==i.get_session_id?void 0:i.get_session_id();return s&&r===s?e:[]}_d(){var t,i=null==(t=this._instance)||null==t.get_session_id?void 0:t.get_session_id();i&&this.Md(i)}kd(){this.Id()}Zh(t){var i,e=null==(i=this._instance)||null==(i=i.persistence)?void 0:i.props[this.Td()];if(e&&e!==t){var r=this.wd(),s=this.Sd();r.length>0&&(this.bd([]),r.filter(t=>$i(s[t])).forEach(t=>this.pd(t))),this.kd(),this.xd()}}getActivatedIds(){return[...new Set([...this.yd(),...this.zh])].filter(t=>!this.Ed(t))}dispose(){var t,i,e;null==(t=this.Gh)||t.call(this),this.Gh=void 0,null==(i=this.Dh)||i.call(this),this.Dh=void 0,null==(e=this.ad)||e.dispose(),this.ad=void 0}reset(){this.zh=[],this.wd().length>0&&this.bd([]),this.kd(),this.xd()}getEventToItemsMap(){return this.Uh}Rd(){return this.ad}},Ph=class extends $h{constructor(t){super(t)}Cd(){return rt}Td(){return st}Qh(){return nt}Kh(t){var i;null==(i=this._instance)||null==(i=i.persistence)||i.register({[nt]:t})}Xh(){var t;null==(t=this._instance)||null==(t=t.persistence)||t.unregister(nt)}Jh(t){var i,e;this.rd(i=>{e=i.find(i=>i.id===t)});var r=null==(i=e)||null==(i=i.appearance)?void 0:i.surveyPopupDelaySeconds;return $i(r)&&r>0}Ad(){return qo}rd(t){var i;null==(i=this._instance)||i.getSurveys(t)}pd(t){var i;null==(i=this._instance)||i.cancelPendingSurvey(t)}ud(){return ml}bd(t){var i;null==(i=this._instance)||null==(i=i.persistence)||i.register({[rt]:t})}Md(t){var i;null==(i=this._instance)||null==(i=i.persistence)||i.register({[st]:t})}Id(){var t;null==(t=this._instance)||null==(t=t.persistence)||t.unregister(st)}Ed(){return!1}hd(t,i){var e;return this.rd(t=>{e=t.find(t=>t.id===i)}),!e||function(t){var i;return al(t)&&!(null==(i=t.conditions)||null==(i=i.events)||!i.repeatedActivation)||"always"===t.schedule}(e)?t===qo?"consume":"ignore":t===qo?"persist":t===Vo||t===Wo?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},Th=class{constructor(t){this._instance=t}initialize(){}get(t){if("string"==typeof t)return this._instance.get_property(t);var i={};for(var e of t){var r=this._instance.get_property(e);wi(r)||(i[e]=r)}return i}set(t,i){this._instance.register("string"==typeof t?{[t]:i}:t)}remove(t){"string"!=typeof t?t.forEach(t=>this._instance.unregister(t)):this._instance.unregister(t)}},Ch=class{constructor(t){this._instance=t}get(){var t=this._instance.config;return{disableSurveys:t.disable_surveys,cookielessMode:!!t.cookieless_mode,advancedEnableSurveys:t.advanced_enable_surveys,requestTimeoutMs:t.surveys_request_timeout_ms}}isOptedOut(){return this._instance.consent.isOptedOut()}isCapturing(){return this._instance.is_capturing()}getExtensions(){var t=null==ni?void 0:ni.__PosthogExtensions__;if(t){var i=t.generateSurveys,e=t.loadExternalDependency;return{generateSurveys:i?t=>i(this._instance,t):void 0,loadExternalDependency:e?t=>e(this._instance,"surveys",t):void 0}}}createEventReceiver(){return new Ph(this._instance)}},Fh=null!=Gt&&Gt.location?vo(Gt.location.hash,"__posthog")||vo(location.hash,"state"):null,Ah="_postHogToolbarParams",Ih=bs("[Toolbar]"),Rh=bs("[FeatureFlags]"),Oh=class{constructor(t,i){void 0===i&&(i=!1),this.Pd=!1,this.update(t,i)}update(t,i){this.Fd=((t,i)=>{var e,r,s,n,o;return{bootstrap:{featureFlags:null==(e=t.bootstrap)?void 0:e.featureFlags,featureFlagPayloads:null==(r=t.bootstrap)?void 0:r.featureFlagPayloads},remoteRequestsDisabled:i,featureFlagsDisabled:!!t.advanced_disable_feature_flags,onlyEvaluateSurveyFeatureFlags:!!t.advanced_only_evaluate_survey_feature_flags,deduplicateCallsPerSession:!!t.advanced_feature_flags_dedup_per_session,cacheTtlMs:t.feature_flag_cache_ttl_ms,refreshIntervalMs:null!==(s=t.remote_config_refresh_interval_ms)&&void 0!==s?s:3e5,requestTimeoutMs:t.feature_flag_request_timeout_ms,compression:t.disable_compression?void 0:"best-available",evaluationContexts:null!==(n=null!==(o=t.evaluation_contexts)&&void 0!==o?o:t.evaluation_environments)&&void 0!==n?n:[],flagKeys:_i(t.flag_keys)?t.flag_keys:void 0}})(t,i),!t.evaluation_environments||t.evaluation_contexts||this.Pd||(Rh.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.Pd=!0),wi(t.flag_keys)||_i(t.flag_keys)||Rh.error("Invalid flag_keys found:",t.flag_keys,"Expected array of non-empty strings")}get(){return this.Fd}},Mh=bs("[FeatureFlags]"),Dh=bs("[FeatureFlags]",{debugEnabled:!0}),jh="\" failed. Feature flags didn't load in time.",Bh="connection_error",Lh=t=>{for(var i={},e=0;t.length>e;e++)i[t[e]]=!0;return i},Nh=t=>{var i={};for(var e of Ss(t||{})){var r=e[1];r&&(i[e[0]]=r)}return i},zh=t=>Ri(t)&&("RangeError"===t.name&&0===t.message.indexOf("Maximum call stack size exceeded")||"InternalError"===t.name&&"too much recursion"===t.message),Uh=bs("[Error tracking]"),Hh="webkit-masked-url:",qh=[{value:"isolatedAPI.contexts.topHostname",exact:!1},{value:"No response from target",exact:!0}],Vh=["chrome-extension://","moz-extension://","safari-extension:","safari-web-extension:",Hh],Wh=["__firefox__","__gCrWeb"],Gh="Refusing to render web experiment since the viewer is a likely bot",Kh={icontains:(t,i)=>i.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,i)=>-1===i.toLowerCase().indexOf(t.toLowerCase()),regex:(t,i)=>ll(i,t),not_regex:(t,i)=>!ll(i,t),exact:(t,i)=>i===t,is_not:(t,i)=>i!==t},Jh=bs("[Conversations]"),Xh="Conversations not available yet.";function Yh(t,i){var e,s,n,o,a,l,h,u=null!==(e=null==t?void 0:t.flushIntervalMs)&&void 0!==e?e:3e3,d=null!==(s=null==t?void 0:t.maxBufferSize)&&void 0!==s?s:100,v=null!=i&&i.consoleCapture?void 0:null!==(n=null==t?void 0:t.maxLogsPerInterval)&&void 0!==n?n:1e3,c=wi(v)?Math.max(d,2048):Math.max(d,v),f=r({},function(){var t="",i="";try{var e=null==Jt?void 0:Jt.userAgent;if(e){var s=ze(e);t=s[0],i=s[1]}}catch(t){}return function(t,i){var e=function(t){if(t)return{}.hasOwnProperty.call(ns,t)?ns[t]:t}(t);return r({},e?{"os.name":e}:{},i?{"os.version":i}:{})}(t,i)}(),null==t?void 0:t.resourceAttributes);return{serviceName:null!==(o=null!==(a=null==f?void 0:f["service.name"])&&void 0!==a?a:null==t?void 0:t.serviceName)&&void 0!==o?o:null==i?void 0:i.serviceNameDefault,serviceVersion:null!==(l=null==f?void 0:f["service.version"])&&void 0!==l?l:null==t?void 0:t.serviceVersion,environment:null!==(h=null==f?void 0:f["deployment.environment"])&&void 0!==h?h:null==t?void 0:t.environment,resourceAttributes:f,beforeSend:null==t?void 0:t.beforeSend,flushIntervalMs:u,maxBufferSize:d,maxQueueSize:c,maxBatchRecordsPerPost:100,rateCapWindowMs:u,maxLogsPerInterval:v,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}}var Zh=["debug","log","warn","error","info"],Qh="console",tu="__posthogHandledLogsRequestError",iu=(t,i)=>{var e=t instanceof Error?t:new Error(i);return e[tu]=!0,e},eu=t=>!!t&&"object"==typeof t&&!0===t[tu],ru={featureFlags:class{constructor(t){this.name="featureFlags",this.Od=!1,this.featureFlagEventHandlers=[],this.A=Mh,this.$d={},this.Dd={},this.Ld=[],this.Nd=!1,this.qd=!1,this.jd=0,this.Bd=!1,this.Hd=!1,this.zd=!1,this.Ud=!1,this.Wd=0,this.nr=()=>{var t=this.Vd();this.Wd=0,t&&this.reloadFeatureFlags()},this.Gd=()=>{var t,i=this.Zd;wi(i)||this.xn.remoteRequestsDisabled||!Xt||"hidden"===Xt.visibilityState||Date.now()-(null!==(t=this.Jd)&&void 0!==t?t:0)<i||(this.reloadFeatureFlags(),this.Qd())},this.ar=()=>{"visible"===(null==Xt?void 0:Xt.visibilityState)&&this.Gd()},"get"in t?this.uo=t:(this._instance=t,this.Kd=new Oh(t.config,t.Ua()),this.uo=this.Kd)}updateConfig(t,i){var e;null==(e=this.Kd)||e.update(t,i),this.ao&&this.Xd()}setup(t){return this.gh=t,this.A=t.logger.createLogger("[FeatureFlags]"),yh(t.kv.initialize(),()=>{this.gh===t&&(this.gh=void 0,this.ao=t,this.Yd(t))})}Yd(t){var i;if(this.ao===t)return Gt&&Fs(Gt,"online",this.nr),this.Xd(),this.tv=t.registerDynamicEventProperties(()=>this.ev()?this.$d:this.Dd),this.iv=null==(i=this._instance)||null==(i=i.persistence)?void 0:i.onCrossTabFeatureFlagChange(()=>{this.rv(),this.nv(),this.sv()}),this.nv(),this.initialize()}Xd(){var t=this.xn.refreshIntervalMs,i=!this.xn.remoteRequestsDisabled&&Xt&&!wi(t)&&t>0?t:void 0;i!==this.Zd&&(this.ov(),wi(i)||(this.Zd=i,this.Qd(),null!=Xt&&Xt.addEventListener&&Fs(Xt,zt,this.ar)))}Qd(){wi(this.Zd)||(wi(this.av)||clearInterval(this.av),this.Jd=Date.now(),this.av=setInterval(this.Gd,this.Zd))}ov(){wi(this.av)||(clearInterval(this.av),this.av=void 0,null==Xt||null==Xt.removeEventListener||Xt.removeEventListener(zt,this.ar)),this.Zd=void 0,this.Jd=void 0}destroy(){this.lv()}dispose(){this.lv()}lv(){var t,i;this.ov(),this.jd++,this.Hd=!1,this.gh=void 0,this.ao&&(this.uv(),null==(t=this.tv)||t.dispose(),this.tv=void 0,null==(i=this.iv)||i.call(this),this.iv=void 0,this.Ld=[],null==Gt||Gt.removeEventListener("online",this.nr),this.ao=void 0)}get xn(){return this.uo.get()}hv(t){var i;return this.dv&&t in this.dv?this.dv[t]:null==(i=this.ao)?void 0:i.kv.get(t)}rv(){return!!this.dv&&(this.dv=void 0,!0)}vv(){var t;return!wi(null==(t=this.ao)?void 0:t.kv.get("$enabled_feature_flags"))&&this.rv()}Ot(t){this.fv(()=>{var i;return null==(i=this.ao)?void 0:i.kv.set(t)})}pv(t,i,e){var r;if(null!=(r=this._instance)&&r.persistence&&t.$enabled_feature_flags){var s=this.hv("$enabled_feature_flags")||{},n=t.$enabled_feature_flags||{},o=i.flags||i.featureFlags,a=i.flags?Object.entries(i.flags).filter(t=>{var i=t[1];return!(null!=i&&i.failed)}).map(t=>t[0]):[],l=!!i.errorsWhileComputingFlags&&!!i.flags,h=l?a:e&&!_i(o)?Object.keys(o||{}):Array.from(new Set([...Object.keys(s),...Object.keys(n)])),u=this.hv("$feature_flag_payloads")||{},d=t.$feature_flag_payloads||{},v=l||e?h:Array.from(new Set([...Object.keys(u),...Object.keys(d)])),c=!l&&!e,f=!!c||h,p=!!c||v,g={[q]:f,[H]:f,[G]:p};for(var _ of(t.$feature_flag_details&&(g[W]=f),[K,gt,J]))wi(t[_])||(g[_]=!0);this._instance.persistence.markCrossTabFeatureFlagChanges(g)}}Dt(t){this.fv(()=>{var i;return null==(i=this.ao)?void 0:i.kv.remove(t)})}fv(t){try{t()}catch(t){this.A.error("Failed to update feature flag persistence",t)}}nv(){var t={};for(var i of[q,G,K,X]){var e=this.hv(i);wi(e)||(t[i]=e)}this.$d=t;var s=r({},t),n=this.hv(H);if(n)for(var o of Object.entries(n))s["$feature/"+o[0]]=o[1];this.Dd=s}ev(){var t=this.xn.cacheTtlMs;if(!t||0>=t)return!1;var i=this.hv(gt);return"number"!=typeof i||Date.now()-i>t}gv(){return!!this.ev()&&(this.Ud||this.qd||(this.Ud=!0,this.A.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}mv(){var t=this.xn.evaluationContexts;return null!=t&&t.length?t.filter(t=>{var i=t&&"string"==typeof t&&t.trim().length>0;return i||this.A.error("Invalid evaluation context found:",t,"Expected non-empty string"),i}):[]}yv(){var t=this.xn.flagKeys;if(!wi(t))return t.filter(t=>{var i=t&&"string"==typeof t&&t.trim().length>0;return i||this.A.error("Invalid flag key found:",t,"Expected non-empty string"),i})}initialize(){var t,i,e=this.xn,r=null!==(t=null==(i=e.bootstrap)?void 0:i.featureFlags)&&void 0!==t?t:{};if(Object.keys(r).length){var s,n,o=null!==(s=null==(n=e.bootstrap)?void 0:n.featureFlagPayloads)&&void 0!==s?s:{},a=Object.keys(r).filter(t=>!wi(r[t])).reduce((t,i)=>(t[i]=r[i],t),{}),l=Object.keys(o).filter(t=>a[t]).reduce((t,i)=>(t[i]=o[i],t),{});return this.bv({featureFlags:a,featureFlagPayloads:l},void 0,{persist:!1})}}updateFlags(t,i,e){var s,n,o=null!=e&&e.merge&&null!==(s=this.hv("$enabled_feature_flags"))&&void 0!==s?s:{},a=null!=e&&e.merge&&null!==(n=this.hv("$feature_flag_payloads"))&&void 0!==n?n:{},l=r({},o,t),h=r({},a,i),u={};for(var d of Object.entries(l)){var v=d[0],c=d[1];u[v]={key:v,enabled:Ur(c),variant:Hr(c),reason:void 0,metadata:wi(null==h?void 0:h[v])?void 0:{id:0,version:void 0,description:void 0,payload:h[v]}}}this.bv({flags:u})}get hasLoadedFlags(){return this.Nd}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var t=this.hv(W),i=this.hv(X),e=this.hv(Y);if(!e&&!i)return t||{};var s=xs({},t||{});for(var n of[...new Set([...Object.keys(e||{}),...Object.keys(i||{})])]){var o,a,l=s[n],h=null==i?void 0:i[n],u=wi(h)?null!==(o=null==l?void 0:l.enabled)&&void 0!==o&&o:!!h,d=wi(h)?null==l?void 0:l.variant:"string"==typeof h?h:void 0,v=null==e?void 0:e[n],c=r({},l,{enabled:u,variant:u?null!=d?d:null==l?void 0:l.variant:void 0});u!==(null==l?void 0:l.enabled)&&(c.original_enabled=null==l?void 0:l.enabled),d!==(null==l?void 0:l.variant)&&(c.original_variant=null==l?void 0:l.variant),v&&(c.metadata=r({},null==l?void 0:l.metadata,{payload:v,original_payload:null==l||null==(a=l.metadata)?void 0:a.payload})),s[n]=c}return this.Od||(this.A.warn(" Overriding feature flag details!",{flagDetails:t,overriddenPayloads:e,finalDetails:s}),this.Od=!0),s}getAllFeatureFlags(){var t=this.getFlagVariants(),i=this.getFlagPayloads();return Object.keys(t).map(e=>{var r=t[e];return{key:e,enabled:Ur(r),variant:Hr(r),payload:zr(i[e])}})}getFlagVariants(){var t=this.hv(H),i=this.hv(X);if(!i)return t||{};for(var e=xs({},t||{}),r=Object.keys(i),s=0;r.length>s;s++)e[r[s]]=i[r[s]];return this.Od||(this.A.warn(" Overriding feature flags!",{enabledFlags:t,overriddenFlags:i,finalFlags:e}),this.Od=!0),e}getFlagPayloads(){var t=this.hv(G),i=this.hv(Y);if(!i)return t||{};for(var e=xs({},t||{}),r=Object.keys(i),s=0;r.length>s;s++)e[r[s]]=i[r[s]];return this.Od||(this.A.warn(" Overriding feature flag payloads!",{flagPayloads:t,overriddenPayloads:i,finalPayloads:e}),this.Od=!0),e}reloadFeatureFlags(){this.Bd||this.xn.featureFlagsDisabled||this.Vd()||(this.qd&&(this.Hd=!0),this._v||(this.Ld.slice().forEach(t=>{try{t()}catch(t){this.A.error("Error while running feature flags reloading callback",t)}}),this._v=setTimeout(()=>{this.wv()},5)))}uv(){clearTimeout(this._v),this._v=void 0}onReloading(t){return this.Ld.push(t),()=>{this.Ld=this.Ld.filter(i=>i!==t)}}ensureFlagsLoaded(){this.Nd||this.qd||this._v||this.reloadFeatureFlags()}setAnonymousDistinctId(t){this.$anon_distinct_id=t}setReloadingPaused(t){this.Bd=t}resetFlagCallReported(){this.Dt(ct)}wv(t){this.uv();var i=this.ao;if(i&&!this.xn.remoteRequestsDisabled&&!this.Vd())if(this.qd)this.Hd=!0;else{var e={token:i.projectToken,distinct_id:i.distinctId,groups:i.groups,$anon_distinct_id:this.$anon_distinct_id,person_properties:r({},i.initialPersonProperties,this.hv("$stored_person_properties")||{},{$lib:i.library.name,$lib_version:i.library.version}),group_properties:this.hv(Q),timezone:Po()};wi(i.deviceId)||(e.$device_id=i.deviceId),(null!=t&&t.disableFlags||this.xn.featureFlagsDisabled)&&(e.disable_flags=!0);var s=this.mv();s.length&&(e.evaluation_contexts=s);var n=this.yv();wi(n)||(e.flag_keys=n);var o=this.xn.onlyEvaluateSurveyFeatureFlags,a="/flags/?v=2"+(o?"&only_evaluate_survey_feature_flags=true":""),l=this.jd;this.qd=!0;var h=()=>{this.Hd&&(this.Hd=!1,this.wv())},u=t=>{this.qd=!1,l===this.jd?(this.Ot({[pt]:[Bh]}),this.A.error("Feature flag request failed",t),this.vv()&&this.sv(!0),h()):h()};try{i.sendRequest(a,{target:"flags",method:"POST",body:e,compression:this.xn.compression,sentAt:"body",timeoutMs:this.xn.requestTimeoutMs}).then(t=>{var i,r,s=null!==(i=t.json)&&void 0!==i?i:{},n=200!==t.statusCode;if(this.qd=!1,l===this.jd){if(this.Sv(t.statusCode),n||this.Hd||(this.$anon_distinct_id=void 0),!e.disable_flags||this.Hd){this.zd=!n;var a=[];t.error?a.push(t.error instanceof Error&&"AbortError"===t.error.name?"timeout":t.error instanceof Error?Bh:"unknown_error"):200!==t.statusCode&&a.push("api_error_"+t.statusCode),s.errorsWhileComputingFlags&&a.push("errors_while_computing_flags");var u=!(null==(r=s.quotaLimited)||!r.includes("feature_flags"));u&&a.push("quota_limited"),this.Ot({[pt]:a}),u?this.A.warn("You have hit your feature flags quota limit, and will not be able to load feature flags until the quota is reset. Please visit https://posthog.com/docs/billing/limits-alerts to learn more."):e.disable_flags||this.bv(s,n,{partialResponse:o}),h()}}else h()}).catch(u)}catch(t){u(t)}}}Vd(){return co(this.Wd,3)}Sv(t){this.Wd=fo(t,this.Wd,3,()=>this.A.warn("Feature flag requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped refreshing feature flags; will try again when connectivity changes."))}getFeatureFlag(t,i){var e;if(void 0===i&&(i={}),!i.fresh||this.zd)if(this.Nd||this.getFlags()&&this.getFlags().length>0){if(!this.gv()){var r=this.getFeatureFlagResult(t,i);return null!==(e=null==r?void 0:r.variant)&&void 0!==e?e:null==r?void 0:r.enabled}}else this.A.warn('getFeatureFlag for key "'+t+jh)}getFeatureFlagDetails(t){return this.getFlagsWithDetails()[t]}getFeatureFlagPayload(t){var i;return null==(i=this.getFeatureFlagResult(t,{send_event:!1}))?void 0:i.payload}getFeatureFlagResult(t,i){if(void 0===i&&(i={}),!i.fresh||this.zd)if(this.Nd||this.getFlags()&&this.getFlags().length>0){if(!this.gv()){var e,s=this.getFlagVariants(),n=t in s,o=s[t],a=this.getFlagPayloads()[t],l=String(o),h=this.hv("$feature_flag_request_id")||void 0,u=this.hv("$feature_flag_evaluated_at")||void 0,d=this.hv("$flag_call_reported")||{};if(this.xn.deduplicateCallsPerSession){var v,c=null==(v=this.ao)?void 0:v.session.sessionId,f=this.hv(ft);c&&c!==f&&(d={},e=c)}if(i.send_event||!("send_event"in i))if(t in d&&d[t].includes(l))e&&this.Ot({[ct]:d,[ft]:e});else{var p,g,_,m,b,y,w,x,S,k,E,P,T;_i(d[t])?d[t].push(l):d[t]=[l],this.Ot(r({[ct]:d},e?{[ft]:e}:{}));var C=this.getFeatureFlagDetails(t),F=[...null!==(p=this.hv("$feature_flag_errors"))&&void 0!==p?p:[]];wi(o)&&F.push("flag_missing");var A={$feature_flag:t,$feature_flag_response:o,$feature_flag_payload:null!=a?a:null,$feature_flag_request_id:h,$feature_flag_evaluated_at:u,$feature_flag_bootstrapped_response:null!==(g=null==(_=this.xn.bootstrap)||null==(_=_.featureFlags)?void 0:_[t])&&void 0!==g?g:null,$feature_flag_bootstrapped_payload:null!==(m=null==(b=this.xn.bootstrap)||null==(b=b.featureFlagPayloads)?void 0:b[t])&&void 0!==m?m:null,$used_bootstrap_value:!this.zd};wi(null==C||null==(y=C.metadata)?void 0:y.has_experiment)||(A.$feature_flag_has_experiment=C.metadata.has_experiment),wi(null==C||null==(w=C.metadata)?void 0:w.version)||(A.$feature_flag_version=C.metadata.version);var I=null!==(x=null==C||null==(S=C.reason)?void 0:S.description)&&void 0!==x?x:null==C||null==(k=C.reason)?void 0:k.code;I&&(A.$feature_flag_reason=I),null!=C&&null!=(E=C.metadata)&&E.id&&(A.$feature_flag_id=C.metadata.id),wi(null==C?void 0:C.original_variant)&&wi(null==C?void 0:C.original_enabled)||(A.$feature_flag_original_response=wi(C.original_variant)?C.original_enabled:C.original_variant),null!=C&&null!=(P=C.metadata)&&P.original_payload&&(A.$feature_flag_original_payload=null==C||null==(T=C.metadata)?void 0:T.original_payload),F.length&&(A.$feature_flag_error=F.join(",")),this.xv(A)}else e&&this.Ot({[ct]:d,[ft]:e});if(n)return{key:t,enabled:!!o,variant:"string"==typeof o?o:void 0,payload:zr(a)}}}else this.A.warn('getFeatureFlagResult for key "'+t+jh)}xv(t){try{var i;null==(i=this.ao)||i.capture("$feature_flag_called",t).catch(t=>{this.A.error("Failed to capture feature flag call",t)})}catch(t){this.A.error("Failed to capture feature flag call",t)}}getRemoteConfigPayload(t,i){this.Cv(t,i)}Cv(t,i){var e=this;return n(function*(){var r=e.ao;if(r){var s={distinct_id:r.distinctId,token:r.projectToken,person_properties:{$lib:r.library.name,$lib_version:r.library.version}},n=e.mv();n.length&&(s.evaluation_contexts=n);var o,a=e.yv();wi(a)||(s.flag_keys=a);try{var l;o=(null==(l=(yield r.sendRequest("/flags/?v=2",{target:"flags",method:"POST",body:s,compression:e.xn.compression,sentAt:"body",timeoutMs:e.xn.requestTimeoutMs})).json)||null==(l=l.featureFlagPayloads)?void 0:l[t])||void 0}catch(t){return void e.A.error("Remote config feature flag request failed",t)}try{i(o)}catch(t){e.A.error("Remote config feature flag callback failed",t)}}})()}isFeatureEnabled(t,i){if(void 0===i&&(i={}),i.fresh&&!this.zd)return i.defaultValue;if(!(this.Nd||this.getFlags()&&this.getFlags().length>0))return this.A.warn('isFeatureEnabled for key "'+t+jh),i.defaultValue;var e=this.getFeatureFlag(t,i);return wi(e)?i.defaultValue:!!e}addFeatureFlagsHandler(t){this.featureFlagEventHandlers.push(t)}removeFeatureFlagsHandler(t){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter(i=>i!==t)}receivedFeatureFlags(t,i,e){this.bv(t,i,e)}bv(t,i,e){if(this.ao){this.Nd=!0;var s=function(t,i,e,s,n,o){void 0===i&&(i={}),void 0===e&&(e={}),void 0===s&&(s={}),void 0===o&&(o=Mh);var a=((t,i)=>{var e=t.flags;return e?r({},t,{featureFlags:Object.fromEntries(Object.keys(e).map(t=>{var i;return[t,null!==(i=e[t].variant)&&void 0!==i?i:e[t].enabled]})),featureFlagPayloads:Object.fromEntries(Object.keys(e).filter(t=>e[t].enabled).filter(t=>{var i;return!wi(null==(i=e[t].metadata)?void 0:i.payload)}).map(t=>{var i;return[t,null==(i=e[t].metadata)?void 0:i.payload]}))}):(t.featureFlags&&i.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),t)})(t,o),l=a.flags,h=a.featureFlags,u=a.featureFlagPayloads;if(h){var d=t.requestId,v=t.evaluatedAt;if(_i(h)){o.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var c={};if(h)for(var f=0;h.length>f;f++)c[h[f]]=!0;return{[q]:h,[H]:c,[J]:!1}}var p=h,g=u,_=l;if(null!=n&&n.partialResponse){var m=Object.keys(p),b=g||{};p=r({},i,p),g=r({},e,b),m.forEach(t=>{var i;t in b||null==(i=g)||delete i[t]}),_=r({},s,_)}else if(t.errorsWhileComputingFlags)if(l){var y=new Set(Object.keys(l).filter(t=>{var i;return!(null!=(i=l[t])&&i.failed)}));p=r({},i,Object.fromEntries(Object.entries(p).filter(t=>y.has(t[0]))));var w=Object.fromEntries(Object.entries(g||{}).filter(t=>y.has(t[0])));g=r({},e,w),y.forEach(t=>{var i;t in w||null==(i=g)||delete i[t]}),_=r({},s,Object.fromEntries(Object.entries(_||{}).filter(t=>y.has(t[0]))))}else p=r({},i,p),g=r({},e,g),_=r({},s,_);return r({[q]:Object.keys(Nh(p)),[H]:p||{},[G]:g||{},[W]:_||{},[J]:!0===t.minimalFlagCalledEvents},d?{[K]:d}:{},v?{[gt]:v}:{})}}(t,this.getFlagVariants(),this.getFlagPayloads(),this.getFlagsWithDetails(),e,this.A);if(s)if(!1===(null==e?void 0:e.persist)){var n=!wi(this.ao.kv.get(H));this.dv=s,n||this.Ot(s)}else this.rv(),this.pv(s,t,!(null==e||!e.partialResponse)),this.Ot(s);else i&&this.vv();i||(this.Ud=!1),this.sv(i)}}override(t,i){void 0===i&&(i=!1),this.A.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:t,suppressWarning:i})}overrideFeatureFlags(t){this.Tv(t)}Tv(t){if(this.ao){if(!1===t)return this.Dt([X,Y]),this.sv(),void Dh.info("All overrides cleared");if(_i(t))return this.Ot({[X]:Lh(t)}),this.sv(),void Dh.info("Flag overrides set",{flags:t});if(t&&"object"==typeof t&&("flags"in t||"payloads"in t)){var i,e=t;this.Od=Boolean(null!==(i=e.suppressWarning)&&void 0!==i&&i);var r={},s=e.flags,n=e.payloads;return s&&(r[X]=_i(s)?Lh(s):s),n&&(r[Y]=n),Object.keys(r).length&&this.Ot(r),!1===s&&!1===n?this.Dt([X,Y]):!1===s?this.Dt(X):!1===n&&this.Dt(Y),this.sv(),!1===s?Dh.info("Flag overrides cleared"):s&&Dh.info("Flag overrides set",{flags:s}),void(!1===n?Dh.info("Payload overrides cleared"):n&&Dh.info("Payload overrides set",{payloads:n}))}if(t&&"object"==typeof t)return this.Ot({[X]:t}),this.sv(),void Dh.info("Flag overrides set",{flags:t});this.A.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:t})}else this.A.warn("posthog.featureFlags.overrideFeatureFlags called before feature flags were ready")}onFeatureFlags(t){if(this.addFeatureFlagsHandler(t),this.Nd){var i=this.Mv(),e=i.flags,r=i.flagVariants;try{t(e,r)}catch(t){this.A.error("Error while running feature flags callback",t)}}return()=>this.removeFeatureFlagsHandler(t)}updateEarlyAccessFeatureEnrollment(t,i,e){var s,n=(this.hv("$early_access_features")||[]).find(i=>i.flagKey===t),o={["$feature_enrollment/"+t]:i},a={$feature_flag:t,$feature_enrollment:i,$set:o};n&&(a.$early_access_feature_name=n.name),e&&(a.$feature_enrollment_stage=e);var l=r({},this.getFlagVariants(),{[t]:i});null==(s=this._instance)||null==(s=s.persistence)||s.markCrossTabFeatureFlagChanges({[q]:[t],[H]:[t],[Z]:Object.keys(o)}),this.Ot({[q]:Object.keys(Nh(l)),[H]:l,[Z]:r({},this.hv("$stored_person_properties")||{},o)}),this.sv();try{var h;null==(h=this.ao)||h.capture("$feature_enrollment_update",a).catch(t=>{this.A.error("Failed to capture early access feature enrollment",t)})}catch(t){this.A.error("Failed to capture early access feature enrollment",t)}}getEarlyAccessFeatures(t,i,e){void 0===i&&(i=!1);var r=this.hv(V);!r||i?this.Iv(t,e):t(r)}Iv(t,i){var e=this;return n(function*(){var r=e.ao;if(r){var s,n=i?"&"+i.map(t=>"stage="+t).join("&"):"";try{var o=yield r.sendRequest("/api/early_access_features/?token="+r.projectToken+n,{target:"api",method:"GET",sentAt:"query"});if(!o.json)return;s=o.json.earlyAccessFeatures,e.Ot({[V]:s})}catch(t){return void e.A.error("Early access feature request failed",t)}try{t(s)}catch(t){e.A.error("Early access feature callback failed",t)}}})()}Mv(){var t=this.getFlags(),i=this.getFlagVariants();return{flags:t.filter(t=>i[t]),flagVariants:Object.keys(i).filter(t=>i[t]).reduce((t,e)=>(t[e]=i[e],t),{})}}sv(t){this.nv();var i=this.Mv(),e=i.flags,r=i.flagVariants;this.featureFlagEventHandlers.forEach(i=>{try{i(e,r,{errorsLoading:t})}catch(t){this.A.error("Error while running feature flags callback",t)}})}setPersonPropertiesForFlags(t,i){void 0===i&&(i=!0),this.Ev(t,i)}Ev(t,i){void 0===i&&(i=!0);var e=this.hv("$stored_person_properties")||{},s=(null==t?void 0:t.$set)||(null!=t&&t.$set_once?{}:t),n=null==t?void 0:t.$set_once,o={};if(n)for(var a in n)({}).hasOwnProperty.call(n,a)&&(a in e||(o[a]=n[a]));this.Ot({[Z]:r({},e,o,s)}),i&&this.reloadFeatureFlags()}unsetPersonPropertiesForFlags(t,i){void 0===i&&(i=!0);var e=r({},this.hv("$stored_person_properties")||{});t.forEach(t=>{delete e[t]}),this.Ot({[Z]:e}),i&&this.reloadFeatureFlags()}resetPersonPropertiesForFlags(t){void 0===t&&(t=!0),this.Dt(Z),t&&this.reloadFeatureFlags()}setGroupPropertiesForFlags(t,i){void 0===i&&(i=!0);var e=this.hv("$stored_group_properties")||{},s=r({},e);for(var n of Object.keys(t))s[n]=r({},e[n],t[n]);this.Ot({[Q]:s}),i&&this.reloadFeatureFlags()}resetGroupPropertiesForFlags(t){if(t){var i=this.hv("$stored_group_properties")||{};this.Ot({[Q]:r({},i,{[t]:{}})})}else this.Dt(Q)}reset(){this.jd++,this.Hd=!1,this.$d={},this.Dd={},this.dv=void 0,this.Nd=!1,this.Bd=!1,this.zd=!1,this.$anon_distinct_id=void 0,this.uv(),this.Od=!1,this.Wd=0}}},su={sessionRecording:class{get xn(){return this._instance.config}get gl(){return this._instance.persistence}get started(){var t;return!(null==(t=this.Rv)||!t.isStarted)}get status(){var t,i;return"awaiting_config"===this.Av||"missing_config"===this.Av?this.Av:null!==(t=null==(i=this.Rv)?void 0:i.status)&&void 0!==t?t:this.Av}constructor(t){if(this._instance=t,this._forceAllowLocalhostNetworkCapture=!1,this.Av=dh,this.Pv=void 0,this.Fv=!1,this.Ke=(()=>{var t;if(null==Xt||!Xt.visibilityState||"visible"===Xt.visibilityState)return!0;var i=null==Gt||null==(t=Gt.performance)||null==t.getEntriesByType?void 0:t.getEntriesByType("visibility-state");return!(null!=i&&i.length)||i.some(t=>"visible"===t.name)})(),this.ar=()=>{var t;"visible"===(null==Xt?void 0:Xt.visibilityState)&&(this.Ke=!0,null==(t=this.Rv)||null==t.setDocumentWasEverVisible||t.setDocumentWasEverVisible(!0))},!this._instance.sessionManager)throw ch.error("started without valid sessionManager"),new Error("[SessionRecording] started without valid sessionManager. This is a bug.");if("always"===this.xn.cookieless_mode)throw new Error('[SessionRecording] cannot be used with cookieless_mode="always"');null!=Xt&&Xt.addEventListener&&Fs(Xt,"visibilitychange",this.ar)}initialize(){this.startIfEnabledOrStop()}dispose(t){var i=(void 0===t?{}:t).discardBufferedEvents,e=void 0!==i&&i;this.Fv=!0,null==Xt||null==Xt.removeEventListener||Xt.removeEventListener("visibilitychange",this.ar),e?this.Ov(!0):this.stopRecording()}get $v(){var t,i=!(null==(t=this._instance.get_property(C))||!t.enabled),e=!this.xn.disable_session_recording,r=this.xn.disable_session_recording||this._instance.consent.isOptedOut();return Gt&&i&&e&&!r}startIfEnabledOrStop(t){var i;if(!(this.Fv||this.$v&&null!=(i=this.Rv)&&i.isStarted)){var e=!wi(Object.assign)&&!wi(Array.from);this.$v&&e?(this.Dv(t),ch.info("starting")):(this.Av=dh,this.stopRecording())}}Dv(t){var i,e;if(this.$v)if("awaiting_config"!==this.Av&&"missing_config"!==this.Av&&(this.Av=vh),null!=ni&&null!=(i=ni.__PosthogExtensions__)&&null!=(i=i.rrweb)&&i.record&&null!=(e=ni.__PosthogExtensions__)&&e.initSessionRecording)this.Lv(t);else{var r,s=this._instance.sessionManager;null==(r=ni.__PosthogExtensions__)||null==r.loadExternalDependency||r.loadExternalDependency(this._instance,this.Nv,i=>{if(!this.Fv&&this.$v&&this._instance.sessionManager===s)return i?(this._instance.register_for_session({[Tt]:!0}),ch.error("could not load recorder",i)):void this.Lv(t);this.Av=dh})}}stopRecording(){var t,i;null==(t=this.Pv)||t.call(this),this.Pv=void 0,null==(i=this.Rv)||i.stop()}Ov(t){var i,e;void 0===t&&(t=!1),null==(i=this.Pv)||i.call(this),this.Pv=void 0,null==(e=this.Rv)||e.discard({discardProducerEvents:t})}qv(){var t,i;null==(t=this.gl)||t.unregister(j),null==(i=this.gl)||i.unregister(A)}jv(t,i){if(Ei(t))return null;var e,r=$i(t)?t:parseFloat(t);return"number"!=typeof(e=r)||!Number.isFinite(e)||0>e||e>1?(ch.warn(i+" must be between 0 and 1. Ignoring invalid value:",t),null):r}Bv(t){if(this.gl){var i,e,s=this.gl,n=()=>{var i,e=!1===t.sessionRecording?void 0:t.sessionRecording,n=this.jv(null==(i=this.xn.session_recording)?void 0:i.sampleRate,"session_recording.sampleRate"),o=this.jv(null==e?void 0:e.sampleRate,"remote config sampleRate"),a=null!=n?n:o;Ei(a)&&this.qv();var l=null==e?void 0:e.minimumDurationMilliseconds;s.register({[C]:r({cache_timestamp:Date.now(),enabled:!!e},e,{networkPayloadCapture:r({capturePerformance:t.capturePerformance},null==e?void 0:e.networkPayloadCapture),canvasRecording:{enabled:null==e?void 0:e.recordCanvas,fps:null==e?void 0:e.canvasFps,quality:null==e?void 0:e.canvasQuality},sampleRate:a,minimumDurationMilliseconds:wi(l)?null:l,endpoint:null==e?void 0:e.endpoint,triggerMatchType:null==e?void 0:e.triggerMatchType,masking:null==e?void 0:e.masking,urlTriggers:null==e?void 0:e.urlTriggers,version:null==e?void 0:e.version,triggerGroups:null==e?void 0:e.triggerGroups})})};n(),null==(i=this.Pv)||i.call(this),this.Pv=null==(e=this._instance.sessionManager)?void 0:e.onSessionId(n)}}onRemoteConfig(t){var i=t.ok?t.config:void 0;return i&&"sessionRecording"in i?!1===i.sessionRecording?(this.Bv(i),void this.Ov()):(this.Bv(i),void this.startIfEnabledOrStop()):("awaiting_config"===this.Av&&(this.Av="missing_config",ch.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(t,i){var e;void 0===i&&(i="log"),null!=(e=this.Rv)&&e.log?this.Rv.log(t,i):ch.warn("log called before recorder was ready")}get Nv(){var t;return(null==(t=this._instance)||null==(t=t.persistence)||null==(t=t.get_property("$session_recording_remote_config"))||null==(t=t.scriptConfig)?void 0:t.script)||"lazy-recorder"}Hv(){var t,i=this._instance.get_property(C);if(!i)return!1;try{t="object"==typeof i?i:JSON.parse(i)}catch(t){return ch.warn("persisted remote config for session recording is invalid and will be ignored",t),!1}return!Ei(t.cache_timestamp)&&36e5>=Date.now()-t.cache_timestamp}Lv(t){var i,e,r;if(!this.Fv&&this.$v&&this._instance.sessionManager){if(null==(i=ni.__PosthogExtensions__)||!i.initSessionRecording)return ch.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[Tt]:!0});var s;if(this.Rv||(this.Rv=null==(s=ni.__PosthogExtensions__)?void 0:s.initSessionRecording(this._instance,this.Ke),this.Rv._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.Hv()){if("missing_config"===this.Av||"awaiting_config"===this.Av)return;return this.Av="awaiting_config",ch.info("persisted remote config is stale, requesting fresh config before starting"),void new Qo(this._instance).load()}this.Av=vh,null==(e=(r=this.Rv).setDocumentWasEverVisible)||e.call(r,this.Ke),this.Rv.start(t)}else this.Av=dh}onRRwebEmit(t){var i;null==(i=this.Rv)||null==i.onRRwebEmit||i.onRRwebEmit(t)}overrideLinkedFlag(){var t,i;this.Rv||null==(t=this.gl)||t.register({[R]:!0}),null==(i=this.Rv)||i.overrideLinkedFlag()}overrideSampling(){var t,i;this.Rv||null==(t=this.gl)||t.register({[I]:!0}),null==(i=this.Rv)||i.overrideSampling()}overrideTrigger(t){var i,e;this.Rv||null==(i=this.gl)||i.register({["url"===t?O:M]:!0}),null==(e=this.Rv)||e.overrideTrigger(t)}get sdkDebugProperties(){var t;return(null==(t=this.Rv)?void 0:t.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(t,i){var e;return!(null==(e=this.Rv)||!e.tryAddCustomEvent(t,i))}flushBeforeIdentityReset(){var t;null==(t=this.Rv)||null==t.flushBeforeIdentityReset||t.flushBeforeIdentityReset()}}},nu={autocapture:class extends Ql{constructor(t){super(new th(t)),this.instance=t}},historyAutocapture:class{constructor(t){this._instance=t,this.zv=this.Uv()}initialize(){this.startIfEnabled()}get isEnabled(){var t=this.Wv();return!!(t.path||t.search||this.Vv(t))}startIfEnabled(){this.isEnabled&&(ms.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}startIfEnabledOrStop(){this.stop(),this.zv=this.Uv(),this.startIfEnabled()}stop(){this.Gv&&this.Gv(),this.Gv=void 0,this.Zv&&this.Zv(),this.Zv=void 0,ms.info("History API monitoring stopped")}monitorHistoryChanges(){Gt&&Gt.history&&(this.Jv("pushState"),this.Jv("replaceState"),this.Qv(),this.Vv()&&this.Kv())}Jv(t){var i;if(Gt&&(null==(i=Gt.history[t])||!i.__posthog_wrapped__)){var e=this;sh(Gt.history,t,i=>function(r,s,n){i.call(this,r,s,n),e.Xv(t)})}}Uv(){var t=null==Gt?void 0:Gt.location;if(null!=t&&t.pathname)return{pathname:t.pathname,search:t.search,hash:t.hash}}Wv(){var t=this._instance.config.capture_pageview;return"history_change"===t?{path:!0}:bi(t)?t:{}}Vv(t){return void 0===t&&(t=this.Wv()),!!t.hash&&!this._instance.config.disable_capture_url_hashes}Yv(t){var i=this.Wv(),e=this.zv;return!(!e||!(i.path&&t.pathname!==e.pathname||i.search&&t.search!==e.search||this.Vv(i)&&t.hash!==e.hash))}Xv(t){try{var i=this.Uv();if(!i)return;this.Yv(i)&&this._instance.capture(Ht,{navigation_type:t}),this.zv=i}catch(i){ms.error("Error capturing "+t+" pageview",i)}}Qv(){if(!this.Gv){var t=()=>{this.Xv("popstate")};Fs(Gt,"popstate",t),this.Gv=()=>{Gt&&Gt.removeEventListener("popstate",t)}}}Kv(){if(!this.Zv){var t=()=>{this.Xv("hashchange")};Fs(Gt,"hashchange",t),this.Zv=()=>{Gt&&Gt.removeEventListener("hashchange",t)}}}},heatmaps:class{get xn(){return this.instance.config}constructor(t){var i;this.tc=!1,this.ho=!1,this.ec=null,this.instance=t,this.tc=!(null==(i=this.instance.persistence)||!i.props[b]),this.rageclicks=new Gl(t.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var t=5e3;return bi(this.xn.capture_heatmaps)&&this.xn.capture_heatmaps.flush_interval_milliseconds&&(t=this.xn.capture_heatmaps.flush_interval_milliseconds),t}get isEnabled(){return Ei(this.xn.capture_heatmaps)?Ei(this.xn.enable_heatmaps)?this.tc:this.xn.enable_heatmaps:!1!==this.xn.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this.ho)return;fh.info("starting..."),this.rc(),this.ar()}else{var t;clearInterval(null!==(t=this.ec)&&void 0!==t?t:void 0),this.nc(),this.getAndClearBuffer()}}onRemoteConfig(t){if(t.ok){var i=t.config;if("heatmaps"in i){var e=!!i.heatmaps;this.instance.persistence&&this.instance.persistence.register({[b]:e}),this.tc=e,this.startIfEnabled()}}}getAndClearBuffer(){var t=this.Rt;return this.Rt=void 0,t}sc(t){ph(t.originalEvent)&&this.Sn(t.originalEvent,"deadclick")}ar(){this.ec&&clearInterval(this.ec),this.ec=function(t){return"visible"===(null==t?void 0:t.visibilityState)}(Xt)?setInterval(this.ol.bind(this),this.flushIntervalMilliseconds):null}rc(){Gt&&Xt&&(this.oc=this.ol.bind(this),Fs(Gt,Ut,this.oc),this.ac=t=>this.Sn(t||(null==Gt?void 0:Gt.event)),Fs(Xt,"click",this.ac,{capture:!0}),this.lc=t=>this.uc(t||(null==Gt?void 0:Gt.event)),Fs(Xt,"mousemove",this.lc,{capture:!0}),this.hc=new Xn(this.instance,Kn,this.sc.bind(this)),this.hc.startIfEnabledOrStop(),this.dc=this.ar.bind(this),Fs(Xt,zt,this.dc),this.ho=!0)}nc(){var t;Gt&&Xt&&(this.oc&&Gt.removeEventListener(Ut,this.oc),this.ac&&Xt.removeEventListener("click",this.ac,{capture:!0}),this.lc&&Xt.removeEventListener("mousemove",this.lc,{capture:!0}),this.dc&&Xt.removeEventListener(zt,this.dc),clearTimeout(this.vc),null==(t=this.hc)||t.stop(),this.ho=!1)}cc(t,i){var e=this.instance.scrollManager.scrollY(),r=this.instance.scrollManager.scrollX(),s=this.instance.scrollManager.scrollElement(),n=function(t,i,e){for(var r=t;r&&un(r)&&!dn(r,"body");){if(r===e)return!1;var s=void 0;try{var n,o,a;s=null==(n=null!==(o=null==(a=r.ownerDocument)?void 0:a.defaultView)&&void 0!==o?o:Gt)?void 0:n.getComputedStyle(r).position}catch(t){return!1}if(ui(i,s))return!0;r=Sn(r)}return!1}(bn(t),["fixed","sticky"],s);return{x:t.clientX+(n?0:r),y:t.clientY+(n?0:e),target_fixed:n,type:i}}Sn(t,i){var e;if(void 0===i&&(i="click"),!hn(t.target)&&ph(t)){var s=this.cc(t,i);null!=(e=this.rageclicks)&&e.isRageClick(t.clientX,t.clientY,(new Date).getTime())&&Fn(bn(t),this.instance.config.rageclick)&&this.Hs(r({},s,{type:"rageclick"})),this.Hs(s)}}uc(t){!hn(t.target)&&ph(t)&&(clearTimeout(this.vc),this.vc=setTimeout(()=>{this.Hs(this.cc(t,"mousemove"))},500))}Hs(t){if(Gt){var i=this.xn.disable_capture_url_hashes?tr(Gt.location.href):Gt.location.href,e=this.xn.custom_personal_data_properties,r=uo(i,this.xn.mask_personal_data_properties?[...po,...e||[]]:[],_o);this.Rt=this.Rt||{},this.Rt[r]||(this.Rt[r]=[]),this.Rt[r].push(t)}}ol(){this.Rt&&!yi(this.Rt)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:Xn,webVitalsAutocapture:class{constructor(t){var i;this._instance=t,this.tc=!1,this.ho=!1,this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this.fc=()=>{clearTimeout(this.gc),this.gc=void 0,0!==this.Rt.metrics.length&&(this._instance.capture("$web_vitals",r({$current_url:this.Rt.url},this.Rt.metrics.reduce((t,i)=>r({},t,{["$web_vitals_"+i.name+"_event"]:r({},i),["$web_vitals_"+i.name+"_value"]:i.value}),{}))),this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.mc=t=>{var i;if(this.Rt=this.Rt||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},Ei(null==t?void 0:t.name)||Ei(null==t?void 0:t.value))oh.error("Invalid metric received",t);else{var e="string"==typeof t.navigationURL?t.navigationURL:void 0,s=this.yc(e);if(!wi(s)){var n=$i(t.navigationId)||"string"==typeof t.navigationId?"navigation:"+t.navigationId:"url:"+s;if(!this.bc||this.bc>t.value){this.Rt.navigationKey!==n&&(this.fc(),this.gc=setTimeout(this.fc,this.flushToCaptureTimeoutMs)),wi(this.Rt.navigationKey)&&(this.Rt.navigationKey=n,this.Rt.url=s),this.Rt.firstMetricTimestamp=wi(this.Rt.firstMetricTimestamp)?Date.now():this.Rt.firstMetricTimestamp;var o=null==(i=this._instance.sessionManager)?void 0:i.checkAndGetSessionAndWindowId(!0),a=r({},t,e?{navigationURL:s}:{},{$current_url:s,timestamp:Date.now()});if(delete a.entries,bi(t.attribution)&&this.attributionMetrics.indexOf(t.name)>-1){var l={};for(var h of uh){var u="url"===h&&"string"==typeof t.attribution[h]?this.yc(t.attribution[h]):t.attribution[h];wi(u)||(l[h]=u)}a.attribution=l}else delete a.attribution;wi(o)||(a.$session_id=o.sessionId,a.$window_id=o.windowId),this.Rt.metrics.push(a),this.Rt.metrics.length===this.allowedMetrics.length&&this.fc()}else oh.error("Ignoring metric with value >= "+this.bc,t)}}},this._c=()=>{if(!this.ho){var t,i,e,s,n=!1,o=ni.__PosthogExtensions__,a=null==o?void 0:o.postHogWebVitalsCallbacksByFlavor,l=(null==a?void 0:a[this.wc])||("web-vitals"===this.wc&&wi(a)?null==o?void 0:o.postHogWebVitalsCallbacks:void 0);if(!wi(l)){var h=l.withoutAttribution,u=this.attributionMetrics;n=!wi(h),t=u.indexOf("LCP")>-1?l.onLCP:(null==h?void 0:h.onLCP)||l.onLCP,i=u.indexOf("CLS")>-1?l.onCLS:(null==h?void 0:h.onCLS)||l.onCLS,e=u.indexOf("FCP")>-1?l.onFCP:(null==h?void 0:h.onFCP)||l.onFCP,s=u.indexOf("INP")>-1?l.onINP:(null==h?void 0:h.onINP)||l.onINP}if(t&&i&&e&&s){var d={reportSoftNavs:this.useSoftNavs},v=n&&this.attributionMetrics.indexOf("INP")>-1?r({},d,{includeProcessedEventEntries:!1}):d;this.allowedMetrics.indexOf("LCP")>-1&&t(this.mc.bind(this),d),this.allowedMetrics.indexOf("CLS")>-1&&i(this.mc.bind(this),d),this.allowedMetrics.indexOf("FCP")>-1&&e(this.mc.bind(this),d),this.allowedMetrics.indexOf("INP")>-1&&s(this.mc.bind(this),v),this.ho=!0}else oh.error("web vitals callbacks not loaded - not starting")}},this.tc=!(null==(i=this._instance.persistence)||!i.props[S]),this.startIfEnabled()}get kc(){return this._instance.config.capture_performance}get allowedMetrics(){var t,i,e=bi(this.kc)?null==(t=this.kc)?void 0:t.web_vitals_allowed_metrics:void 0;return Ei(e)?(null==(i=this._instance.persistence)?void 0:i.props.$web_vitals_allowed_metrics)||lh:e}get flushToCaptureTimeoutMs(){return(bi(this.kc)?this.kc.web_vitals_delayed_flush_ms:void 0)||5e3}get attributionMetrics(){var t=bi(this.kc)?this.kc.web_vitals_attribution:void 0;return Ti(t)?t?lh:[]:_i(t)?t:hh}get useAttribution(){return this.attributionMetrics.length>0}get useSoftNavs(){var t;return null!==(t=bi(this.kc)?this.kc.__preview_web_vitals_soft_navs:void 0)&&void 0!==t&&t}get bc(){var t=bi(this.kc)&&$i(this.kc.__web_vitals_max_value)?this.kc.__web_vitals_max_value:ah;return t>0&&6e4>=t?ah:t}get isEnabled(){var t=null==Yt?void 0:Yt.protocol;if("http:"!==t&&"https:"!==t)return oh.info("Web Vitals are disabled on non-http/https protocols"),!1;var i=bi(this.kc)?this.kc.web_vitals:Ti(this.kc)?this.kc:void 0;return Ti(i)?i:this.tc}startIfEnabled(){this.isEnabled&&!this.ho&&(oh.info("enabled, starting..."),this.Ro(this._c))}onRemoteConfig(t){if(t.ok){var i=t.config;if("capturePerformance"in i){var e=bi(i.capturePerformance)&&!!i.capturePerformance.web_vitals,r=bi(i.capturePerformance)?i.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[S]:e}),this._instance.persistence.register({[T]:r})),this.tc=e,this.startIfEnabled()}}}get wc(){return this.useSoftNavs?this.useAttribution?"web-vitals-with-attribution-soft-navs":"web-vitals-soft-navs":this.useAttribution?"web-vitals-with-attribution":"web-vitals"}Ro(t){var i=ni.__PosthogExtensions__,e=this.wc,r=null==i?void 0:i.postHogWebVitalsCallbacksByFlavor;null!=r&&r[e]||"web-vitals"===e&&wi(r)&&null!=i&&i.postHogWebVitalsCallbacks?t():null==i||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,e,i=>{i?oh.error("failed to load script",i):t()})}yc(t){var i=t||(null==Gt?void 0:Gt.location.href);if(i){var e=this._instance.config.disable_capture_url_hashes?tr(i):i,r=this._instance.config.custom_personal_data_properties;return uo(e,this._instance.config.mask_personal_data_properties?[...po,...r||[]]:[],_o)}oh.error("Could not determine current URL")}}},ou={exceptionObserver:class{constructor(t){var i;this._c=()=>{var t;if(Gt&&this.isEnabled&&null!=(t=ni.__PosthogExtensions__)&&t.errorWrappingFunctions){var i=ni.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,e=ni.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,r=ni.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.Sc&&this.xn.capture_unhandled_errors&&(this.Sc=i(this.captureException.bind(this))),!this.xc&&this.xn.capture_unhandled_rejections&&(this.xc=e(this.captureException.bind(this))),!this.Cc&&this.xn.capture_console_errors&&(this.Cc=r(this.captureException.bind(this)))}catch(t){ih.error("failed to start",t),this.Tc()}}},this._instance=t,this.Mc=!(null==(i=this._instance.persistence)||!i.props[y]),this.wt=new Ui(r({},function(t){var i,e,r,s;return void 0===t&&(t={}),{refillRate:null!==(i=null!==(e=t.exceptionRateLimiterRefillRate)&&void 0!==e?e:t.__exceptionRateLimiterRefillRate)&&void 0!==i?i:1,bucketSize:null!==(r=null!==(s=t.exceptionRateLimiterBucketSize)&&void 0!==s?s:t.__exceptionRateLimiterBucketSize)&&void 0!==r?r:10}}(this._instance.config.error_tracking),{refillInterval:1e4,A:ih})),this.xn=this.Ic(),this.startIfEnabledOrStop()}Ic(){var t=this._instance.config.capture_exceptions,i={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return bi(t)?i=r({},i,t):(wi(t)?this.Mc:t)&&(i=r({},i,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),i}get isEnabled(){return this.xn.capture_console_errors||this.xn.capture_unhandled_errors||this.xn.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(ih.info("enabled"),this.Tc(),this.Ro(this._c)):this.Tc()}Ro(t){var i,e;null!=(i=ni.__PosthogExtensions__)&&i.errorWrappingFunctions?t():null==(e=ni.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,"exception-autocapture",i=>{if(i)return ih.error("failed to load script",i);t()})}Tc(){var t,i,e;null==(t=this.Sc)||t.call(this),this.Sc=void 0,null==(i=this.xc)||i.call(this),this.xc=void 0,null==(e=this.Cc)||e.call(this),this.Cc=void 0}onRemoteConfig(t){if(t.ok){var i=t.config;"autocaptureExceptions"in i&&(this.Mc=!!i.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[y]:this.Mc}),this.xn=this.Ic(),this.startIfEnabledOrStop())}}onConfigChange(){this.xn=this.Ic()}captureException(t){try{var i,e,r,s=null!==(i=null==t||null==(e=t.$exception_list)||null==(e=e[0])?void 0:e.type)&&void 0!==i?i:"Exception";if(this.wt.consumeRateLimit(s))return void ih.info("Skipping exception capture because of client rate limiting.",{exception:s});null==(r=this._instance.exceptions)||r.sendExceptionEvent(t)}catch(t){}}},exceptions:class{constructor(t){var i,e;this.Ec=[],this.Rc=new nr([new Sr,new Rr,new Er,new kr,new Ar,new Fr,new Pr,new Ir],function(t){for(var i=arguments.length,e=new Array(i>1?i-1:0),s=1;i>s;s++)e[s-1]=arguments[s];return function(i,s){void 0===s&&(s=0);for(var n=[],o=i.split("\n"),a=Math.min(o.length,s+1e3),l=[],h=s;a>h;h++){var u=o[h];if(1024>=u.length){var d=pr.test(u)?u.replace(pr,"$1"):u;if(!d.match(/\S*Error: /)){for(var v of e){var c=v(d,t);if(c){n.push(c);var f=_r(n);if(f){for(var p=l.length-1;p>=0;p--){var g=l[p];if(f.start>=g.start+g.length)break;l.pop()}l.push(f)}break}}if(wr(n,l)>=50)break}}}var _=[...l].sort((t,i)=>i.start-t.start),m=_[_.length-1];if(m){var b=br(n,m);for(var y of(n.splice(m.start-b,b),_))y.start-=b}for(var w of _)mr(n,w);return l.some(t=>0===t.start&&n.length===t.length)&&function(t){for(var i=t.map(t=>t.function+"|"+t.filename+"|"+t.lineno+"|"+t.colno+"|"+t.module),e=0,r=1;i.length>r;r++)xr(i,r,e)&&(e=r);t.push(...t.splice(0,e))}(n),function(t){if(!t.length)return[];var i=Array.from(t);return i.reverse(),i.slice(0,50).map(t=>{return r({},t,{filename:t.filename||(e=i,e[e.length-1]||{}).filename,function:t.function||"?"});var e})}(n)}}("web:javascript",dr,fr)),this._instance=t,this.Ec=null!==(i=null==(e=this._instance.persistence)?void 0:e.get_property("$error_tracking_suppression_rules"))&&void 0!==i?i:[],this.Ac=Br(this.Pc()),this.Fc=new Lr(this.Ac)}onConfigChange(){this.Ac=Br(this.Pc()),this.Fc.setConfig(this.Ac)}onRemoteConfig(t){var i,e,r;if(t.ok){var s=t.config;if("errorTracking"in s){var n=null!==(i=null==(e=s.errorTracking)?void 0:e.suppressionRules)&&void 0!==i?i:[],o=null==(r=s.errorTracking)?void 0:r.captureExtensionExceptions;this.Ec=n,this._instance.persistence&&this._instance.persistence.register({[w]:this.Ec,[x]:o})}}}get Oc(){var t,i,e=!!this._instance.get_property(x);return null!==(t=null!==(i=this._instance.config.error_tracking.captureExtensionExceptions)&&void 0!==i?i:e)&&void 0!==t&&t}buildProperties(t,i){return this.Rc.buildFromUnknown(t,{syntheticException:null==i?void 0:i.syntheticException,mechanism:{handled:null==i?void 0:i.handled}})}addExceptionStep(t,i){if(this.Ac.enabled)try{if(!xi(t)||0===t.trim().length)return void Uh.warn("Ignoring exception step because message must be a non-empty string");var e=function(t){if(!t)return{sanitizedProperties:{},droppedKeys:[]};var i=[];return{sanitizedProperties:Object.keys(t).reduce((e,r)=>Dr.has(r)?(i.push(r),e):(e[r]=t[r],e),{}),droppedKeys:i}}(this.$c(i)),s=e.sanitizedProperties,n=e.droppedKeys;n.length>0&&Uh.warn("Ignoring reserved exception step fields",{droppedKeys:n}),this.Fc.add(r({[Or]:t,[Mr]:(new Date).toISOString()},s))}catch(t){Uh.error("Failed to add exception step. Ignoring breadcrumb.",t)}}sendExceptionEvent(t){try{var i=t.$exception_list;if(this.Dc(i)){if(this.Lc(i))return this.Nc("Exception dropped: matched a suppression rule"),void Uh.info("Skipping exception capture because a suppression rule matched");if(!this.Oc&&this.qc(i))return this.Nc("Exception dropped: thrown by a browser extension"),void Uh.info("Skipping exception capture because it was thrown by an extension");if(!this.Oc&&this.jc(i))return this.Nc("Exception dropped: thrown by an injected browser script"),void Uh.info("Skipping exception capture because it was thrown by an injected browser script");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.Bc(i))return this.Nc("Exception dropped: thrown by the PostHog SDK"),void Uh.info("Skipping exception capture because it was thrown by the PostHog SDK")}var e=this.Ac.enabled&&Ei(t.$exception_steps)?this.Hc(t):t,r="string"==typeof(n=globalThis._posthogReleaseId)&&n.length>0?n:void 0;r&&(e.$release_id=r);try{var s=this._instance.capture("$exception",e,{_noTruncate:!0,_batchKey:"exceptionEvent",Gu:!0});return s&&this.Fc.clear(),s}catch(t){return zh(t)||Uh.error("Failed to capture exception event. Dropping this exception.",t),void this.Fc.clear()}}catch(t){return void(zh(t)||Uh.error("Failed to process exception event. Ignoring this exception.",t))}var n}Hc(t){try{var i=this.Fc.getAttachable();return 0===i.length?t:r({},t,{$exception_steps:i})}catch(i){return Uh.error("Failed to read buffered exception steps. Capturing exception without steps.",i),t}}Nc(t){this.Ac.enabled&&this.Fc.add({[Or]:t,[Mr]:(new Date).toISOString()})}$c(t){return bi(t)?r({},t):{}}Pc(){var t,i;return null!==(t=null==(i=this._instance.config.error_tracking)?void 0:i.exception_steps)&&void 0!==t?t:{}}Lc(t){if(0===t.length)return!1;try{var i=t.reduce((t,i)=>{var e=i.type,r=i.value;return xi(e)&&e.length>0&&t.$exception_types.push(e),xi(r)&&r.length>0&&t.$exception_values.push(r),t},{$exception_types:[],$exception_values:[]});return this.Ec.some(t=>{var e=t.values.map(t=>{var e=ul[t.operator],r=i[t.key];if(!e||!r)return!1;var s=_i(t.value)?t.value:[t.value];return s.length>0&&e(s,r)});return"OR"===t.type?e.some(Boolean):e.every(Boolean)})}catch(t){return Uh.warn("Failed to evaluate suppression rules. Capturing the exception.",t),!1}}qc(t){var i=t.flatMap(t=>{var i,e;return null!==(i=null==(e=t.stacktrace)?void 0:e.frames)&&void 0!==i?i:[]}),e=i.filter(t=>{var i=t.filename;return!!i&&Vh.some(t=>i.startsWith(t))});return 0!==e.length&&(!e.every(t=>{var i=t.filename;return!!i&&i.startsWith(Hh)})||t.some(t=>{var i=t.value;return"NoResponse"===t.type||xi(i)&&qh.some(t=>{var e=t.value;return t.exact?i===e:i.includes(e)})})&&!i.some(t=>{var i=t.filename;return t.in_app&&!(null!=i&&i.startsWith(Hh))}))}jc(t){return t.some(t=>{var i=t.value;return xi(i)&&Wh.some(t=>i.includes(t))})}Bc(t){if(t.length>0){var i,e,r,s,n=null!==(i=null==(e=t[0].stacktrace)?void 0:e.frames)&&void 0!==i?i:[];return null!==(r=null==(s=n[n.length-1])||null==(s=s.filename)?void 0:s.includes("posthog.com/static"))&&void 0!==r&&r}return!1}Dc(t){return!Ei(t)&&_i(t)}}},au=r({productTours:class{get gl(){return this._instance.persistence}constructor(t){this.zc=null,this.Uc=null,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(t.ok){var i=t.config;if("productTours"in i){var e,r;if(this.gl&&this.gl.register({[E]:!!i.productTours}),!_h(this._instance))return!this.zc&&Ei(null==(e=this.gl)?void 0:e.props.ph_product_tours)||gh.info("product tours disabled; stopping and clearing cached tours"),null==(r=this.zc)||r.stop(),this.zc=null,void this.clearCache();this.loadIfEnabled()}}}loadIfEnabled(){!this.zc&&_h(this._instance)&&this.Ro(()=>this.Wc())}Ro(t){var i,e;null!=(i=ni.__PosthogExtensions__)&&i.generateProductTours?t():null==(e=ni.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,"product-tours",i=>{i?gh.error("Could not load product tours script",i):t()})}Wc(){var t;!this.zc&&null!=(t=ni.__PosthogExtensions__)&&t.generateProductTours&&(this.zc=ni.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(t,i){if(void 0===i&&(i=!1),!_i(this.Uc)||i){var e=this.gl;if(e){var r=e.props[ot];if(_i(r)&&!i)return this.Uc=r,void t(r,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/product_tours/?token="+this._instance.config.token),method:"GET",timestampMode:"query",callback:i=>{if(_h(this._instance)){var r=i.statusCode;if(200!==r||!i.json){var s="Product Tours API could not be loaded, status: "+r;return 0===r?i.error||gh.warn(s):gh.error(s),void t([],{isLoaded:!1,error:s})}var n=_i(i.json.product_tours)?i.json.product_tours:[];this.Uc=n,e&&e.register({[ot]:n}),t(n,{isLoaded:!0})}else t([],{isLoaded:!0})}})}else t(this.Uc,{isLoaded:!0})}getActiveProductTours(t){Ei(this.zc)?t([],{isLoaded:!1,error:"Product tours not loaded"}):this.zc.getActiveProductTours(t)}showProductTour(t){var i;null==(i=this.zc)||i.showTourById(t)}previewTour(t){this.zc?this.zc.previewTour(t):this.Ro(()=>{var i;this.Wc(),null==(i=this.zc)||i.previewTour(t)})}dismissProductTour(){var t;null==(t=this.zc)||t.dismissTour("user_clicked_skip")}nextStep(){var t;null==(t=this.zc)||t.nextStep()}previousStep(){var t;null==(t=this.zc)||t.previousStep()}clearCache(){var t;this.Uc=null,null==(t=this.gl)||t.unregister(ot)}resetTour(t){var i;null==(i=this.zc)||i.resetTour(t)}resetAllTours(){var t;null==(t=this.zc)||t.resetAllTours()}cancelPendingTour(t){var i;null==(i=this.zc)||i.cancelPendingTour(t)}}},ru),lu={siteApps:class{constructor(t){this._instance=t,this.Vc=0,this.Gc=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}Zc(t,i){if(i){var e=this.globalsForEvent(i);this.Gc.push(e),this.Gc.length>1e3&&(this.Gc=this.Gc.slice(10))}}get siteAppLoaders(){var t;return null==(t=ni._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.siteApps}initialize(){if(this.isEnabled){var t=this._instance._addCaptureHook(this.Zc.bind(this));this.Jc=()=>{t(),this.Gc=[],this.Jc=void 0}}}globalsForEvent(t){var s,n,o,a,l,h,u;if(!t)throw new Error("Event payload is required");var d={},v=this._instance.get_property("$groups")||[],c=this._instance.get_property("$stored_group_properties")||{};for(var f of Object.entries(c)){var p=f[0];d[p]={id:v[p],type:p,properties:f[1]}}var g=t.$set_once,_=t.$set;return{event:r({},e(t,i),{properties:r({},t.properties,_?{$set:r({},null!==(s=null==(n=t.properties)?void 0:n.$set)&&void 0!==s?s:{},_)}:{},g?{$set_once:r({},null!==(o=null==(a=t.properties)?void 0:a.$set_once)&&void 0!==o?o:{},g)}:{}),elements_chain:null!==(l=null==(h=t.properties)?void 0:h.$elements_chain)&&void 0!==l?l:"",distinct_id:null==(u=t.properties)?void 0:u.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:d}}Qc(t){var i,e=null==(i=t.tagName)?void 0:i.toLowerCase();return"style"===e&&this._instance.config.prepare_external_dependency_stylesheet?this._instance.config.prepare_external_dependency_stylesheet(t)||(mh.error("prepare_external_dependency_stylesheet returned null"),null):"script"===e&&this._instance.config.prepare_external_dependency_script?this._instance.config.prepare_external_dependency_script(t)||(mh.error("prepare_external_dependency_script returned null"),null):t}Kc(){var t,i,e,r,s,n,o,a;if(!this._instance.config.prepare_external_dependency_stylesheet&&!this._instance.config.prepare_external_dependency_script)return()=>{};var l=null==Xt?void 0:Xt.defaultView,h=null==l||null==(t=l.Node)?void 0:t.prototype;if(!l||!h)return()=>{};if(this.Vc++,this.Xc)return this.Yc();var u=[],d=this,v=new WeakSet,c=(t,i,e)=>{if(null!=t&&t[i]){var r=t[i];t[i]=e(r),u.push(()=>{t[i]=r})}},f=t=>{if(v.has(t))return t;var i=d.Qc(t);return i&&v.add(i),i},p=t=>t.map(t=>"string"==typeof t?t:f(t)).filter(t=>!ki(t));return c(h,"appendChild",t=>function(i){var e=f(i);return e?t.call(this,e):i}),c(h,"insertBefore",t=>function(i,e){var r=f(i);return r?t.call(this,r,e):i}),c(h,"replaceChild",t=>function(i,e){var r=f(i);return r?t.call(this,r,e):e}),[null==(i=l.Element)?void 0:i.prototype,null==(e=l.Document)?void 0:e.prototype,null==(r=l.DocumentFragment)?void 0:r.prototype].forEach(t=>{c(t,"append",t=>function(){for(var i=arguments.length,e=new Array(i),r=0;i>r;r++)e[r]=arguments[r];return t.apply(this,p(e))}),c(t,"prepend",t=>function(){for(var i=arguments.length,e=new Array(i),r=0;i>r;r++)e[r]=arguments[r];return t.apply(this,p(e))})}),[null==(s=l.Element)?void 0:s.prototype,null==(n=l.CharacterData)?void 0:n.prototype,null==(o=l.DocumentType)?void 0:o.prototype].forEach(t=>{c(t,"before",t=>function(){for(var i=arguments.length,e=new Array(i),r=0;i>r;r++)e[r]=arguments[r];return t.apply(this,p(e))}),c(t,"after",t=>function(){for(var i=arguments.length,e=new Array(i),r=0;i>r;r++)e[r]=arguments[r];return t.apply(this,p(e))}),c(t,"replaceWith",t=>function(){for(var i=arguments.length,e=new Array(i),r=0;i>r;r++)e[r]=arguments[r];var s=p(e);return e.length&&!s.length?void 0:t.apply(this,s)})}),c(null==(a=l.Element)?void 0:a.prototype,"insertAdjacentElement",t=>function(i,e){var r=f(e);return r?t.call(this,i,r):null}),this.Xc=()=>{u.forEach(t=>t()),this.Xc=void 0},this.Yc()}Yc(){var t=!1;return()=>{var i;t||(t=!0,this.Vc--,0===this.Vc&&(null==(i=this.Xc)||i.call(this)))}}tf(t,i){void 0===i&&(i=!0);var e=this.Kc();try{var r=t(e);return i&&e(),r}catch(t){throw e(),t}}setupSiteApp(t){var i=this.apps[t.id],e=()=>{var e;!i.errored&&this.Gc.length&&(mh.info("Processing "+this.Gc.length+" events for site app with id "+t.id),this.Gc.forEach(t=>this.tf(()=>null==i.processEvent?void 0:i.processEvent(t))),i.processedBuffer=!0),Object.values(this.apps).every(t=>t.processedBuffer||t.errored)&&(null==(e=this.Jc)||e.call(this))},r=!1,s=s=>{i.errored=!s,i.loaded=!0,mh.info("Site app with id "+t.id+" "+(s?"loaded":"errored")),r&&e()};try{var n=this.tf(i=>t.init({posthog:this._instance,callback(t){i(),s(t)}}),!1).processEvent;n&&(i.processEvent=n),r=!0}catch(i){mh.error(bh+t.id,i),s(!1)}if(r&&i.loaded)try{e()}catch(e){mh.error("Error while processing buffered events PostHog app with config id "+t.id,e),i.errored=!0}}ef(){var t=this.siteAppLoaders||[];for(var i of t)this.apps[i.id]={id:i.id,loaded:!1,errored:!1,processedBuffer:!1};for(var e of t)this.setupSiteApp(e)}if(t){var i=this;if(0!==Object.keys(this.apps).length){var e=this.globalsForEvent(t),r=function(r){try{i.tf(()=>null==r.processEvent?void 0:r.processEvent(e))}catch(i){mh.error("Error while processing event "+t.event+" for site app "+r.id,i)}};for(var s of Object.values(this.apps))r(s)}}onRemoteConfig(t){var i,e,r,s=this;if(null!=(i=this.siteAppLoaders)&&i.length)return this.isEnabled?(this.ef(),void this._instance.on("eventCaptured",t=>this.if(t))):void mh.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null==(e=this.Jc)||e.call(this),t.ok){var n=t.config;if(null!=(r=n.siteApps)&&r.length)if(this.isEnabled){var o=function(){var t,i=a.id,e=a.url;ni["__$$ph_site_app_"+i]=s._instance,null==(t=ni.__PosthogExtensions__)||null==t.loadSiteApp||t.loadSiteApp(s._instance,e,t=>{if(t)return mh.error(bh+i,t)})};for(var a of n.siteApps)o()}else mh.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}}},hu={tracingHeaders:class{constructor(t){this._instance=t,this.rf=void 0,this.nf=void 0,this.sf=void 0,this._c=()=>{var t,i,e=this.af();e?(wi(this.rf)&&(this.rf=null==(t=ni.__PosthogExtensions__)||null==(t=t.tracingHeadersPatchFns)?void 0:t._patchXHR(e,()=>this._instance.get_distinct_id(),this._instance.sessionManager)),wi(this.nf)&&(this.nf=null==(i=ni.__PosthogExtensions__)||null==(i=i.tracingHeadersPatchFns)?void 0:i._patchFetch(e,()=>this._instance.get_distinct_id(),this._instance.sessionManager))):this.Tc()}}initialize(){this.startIfEnabledOrStop()}Ro(t){var i,e;null!=(i=ni.__PosthogExtensions__)&&i.tracingHeadersPatchFns?t():null==(e=ni.__PosthogExtensions__)||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,"tracing-headers",i=>{if(i)return nh.error("failed to load script",i);t()})}lf(){var t,i;return null!==(t=null!==(i=this._instance.config.tracing_headers)&&void 0!==i?i:this._instance.config.addTracingHeaders)&&void 0!==t?t:this._instance.config.__add_tracing_headers}af(){var t=this.lf();return _i(t)?(_i(this.sf)?this.sf.splice(0,this.sf.length,...t):this.sf=[...t],t.length>0?this.sf:void 0):(_i(this.sf)&&this.sf.splice(0),this.sf=t||void 0,this.sf)}Tc(){var t,i;null==(t=this.rf)||t.call(this),null==(i=this.nf)||i.call(this),this.rf=void 0,this.nf=void 0}startIfEnabledOrStop(){this.af()?this.Ro(this._c):this.Tc()}}},uu=r({surveys:class extends Sh{constructor(t){var i;super(new Ch(t),(i=t,{get projectToken(){return i.config.token},kv:new Th(i)})),this._instance=t}wh(t,i){var e=i.query?ja(t,i.query):t;return new Promise(t=>{var r;this._instance._send_request({method:i.method,url:this._instance.requestRouter.endpointFor(null!==(r=i.target)&&void 0!==r?r:"api",e),data:i.body,headers:i.headers,timeout:i.timeoutMs,fireCallbackOnDrop:!0,transport:i.transport,compression:i.compression,timestampMode:i.sentAt,callback:t})})}}},ru),du={toolbar:class{constructor(t){this.instance=t}uf(t){ni.ph_toolbar_state=t}hf(){var t;return null!==(t=ni.ph_toolbar_state)&&void 0!==t?t:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(t,i,e){if(void 0===t&&(t=void 0),void 0===i&&(i=void 0),void 0===e&&(e=void 0),As(this.instance.config))return!1;if(!Gt||!Xt)return!1;t=null!=t?t:Gt.location,e=null!=e?e:Gt.history;try{if(!i){try{Gt.localStorage.setItem("test","test"),Gt.localStorage.removeItem("test")}catch(t){return!1}i=null==Gt?void 0:Gt.localStorage}var r,s=Fh||vo(t.hash,"__posthog")||vo(t.hash,"state"),n=s?ks(()=>JSON.parse(atob(decodeURIComponent(s))))||ks(()=>JSON.parse(decodeURIComponent(s))):null;return n&&"ph_authorize"===n.action?((r=n).source="url",r&&Object.keys(r).length>0&&(n.desiredHash?t.hash=n.desiredHash:e?e.replaceState(e.state,"",t.pathname+t.search):t.hash="")):((r=JSON.parse(i.getItem(Ah)||"{}")).source="localstorage",delete r.userIntent),!(!r.token||this.instance.config.token!==r.token||(this.loadToolbar(r),0))}catch(t){return!1}}df(t){var i=ni.ph_load_toolbar||ni.ph_load_editor;!Ei(i)&&mi(i)?i(t,this.instance):Ih.warn("No toolbar load function found")}loadToolbar(t){var i=!(null==Xt||!Xt.getElementById("__POSTHOG_TOOLBAR__"));if(!Gt||i)return!1;var e="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,s=r({token:this.instance.config.token},t,{apiURL:this.instance.requestRouter.endpointFor("ui")},e?{instrument:!1}:{});if(Gt.localStorage.setItem(Ah,JSON.stringify(r({},s,{source:void 0}))),2===this.hf())this.df(s);else if(0===this.hf()){var n;this.uf(1),null==(n=ni.__PosthogExtensions__)||null==n.loadExternalDependency||n.loadExternalDependency(this.instance,"toolbar",t=>{if(t)return Ih.error("[Toolbar] Failed to load",t),void this.uf(0);this.uf(2),this.df(s)}),Fs(Gt,"turbolinks:load",()=>{this.uf(0),this.loadToolbar(s)})}return!0}vf(t){return this.loadToolbar(t)}maybeLoadEditor(t,i,e){return void 0===t&&(t=void 0),void 0===i&&(i=void 0),void 0===e&&(e=void 0),this.maybeLoadToolbar(t,i,e)}}},vu=r({experiments:class t{get xn(){return this._instance.config}constructor(i){var e=this;this._instance=i,this.getWebExperimentsAndEvaluateDisplayLogic=function(i){void 0===i&&(i=!1),e.getWebExperiments(i=>{t.cf("retrieved web experiments from the server"),e.ff=new Map,i.forEach(i=>{if(i.feature_flag_key){var r;e.ff&&(t.cf("setting flag key ",i.feature_flag_key," to web experiment ",i),null==(r=e.ff)||r.set(i.feature_flag_key,i));var s=e._instance.getFeatureFlag(i.feature_flag_key);xi(s)&&i.variants[s]&&e.pf(i.name,s,i.variants[s].transforms)}else if(i.variants)for(var n in i.variants){var o=i.variants[n];t.gf(o,e._instance)&&e.pf(i.name,n,o.transforms)}})},i)},this._instance.onFeatureFlags(t=>{this.onFeatureFlags(t)})}initialize(){}onFeatureFlags(i){if(this._is_bot())t.cf(Gh);else if(!this.xn.disable_web_experiments){if(Ei(this.ff))return this.ff=new Map,this.loadIfEnabled(),void this.previewWebExperiment();t.cf("applying feature flags",i),i.forEach(t=>{var i;if(this.ff&&null!=(i=this.ff)&&i.has(t)){var e,r=this._instance.getFeatureFlag(t),s=null==(e=this.ff)?void 0:e.get(t);r&&null!=s&&s.variants[r]&&this.pf(s.name,r,s.variants[r].transforms)}})}}previewWebExperiment(){var i=t.getWindowLocation();if(null!=i&&i.search){var e=ho(null==i?void 0:i.search,"__experiment_id"),r=ho(null==i?void 0:i.search,"__experiment_variant");e&&r&&(t.cf("previewing web experiments "+e+" && "+r),this.getWebExperiments(t=>{this.mf(parseInt(e),r,t)},!1,!0))}}loadIfEnabled(){this.xn.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(t,i,e){if(this.xn.disable_web_experiments&&!e)return t([]);var r=this._instance.get_property("$web_experiments");if(r&&!i)return t(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this.xn.token),method:"GET",timestampMode:"query",callback:i=>t(200===i.statusCode&&i.json&&i.json.experiments||[])})}mf(i,e,r){var s=r.filter(t=>t.id===i);s&&s.length>0&&(t.cf("Previewing web experiment ["+s[0].name+"] with variant ["+e+"]"),this.pf(s[0].name,e,s[0].variants[e].transforms))}static gf(i,e){return!Ei(i.conditions)&&t.yf(i,e)&&t.bf(i)}static yf(i,e){var r;if(Ei(i.conditions)||Ei(null==(r=i.conditions)?void 0:r.url))return!0;var s=t.getWindowLocation();if(s){var n,o,a,l=ln(e,s.href);return null==(n=i.conditions)||!n.url||Kh[null!==(o=null==(a=i.conditions)?void 0:a.urlMatchType)&&void 0!==o?o:"icontains"](i.conditions.url,l)}return!1}static getWindowLocation(){return null==Gt?void 0:Gt.location}static bf(t){var i;if(Ei(t.conditions)||Ei(null==(i=t.conditions)?void 0:i.utm))return!0;var e=bo();if(e.utm_source){var r,s,n,o,a,l,h,u,d=null==(r=t.conditions)||null==(r=r.utm)||!r.utm_campaign||(null==(s=t.conditions)||null==(s=s.utm)?void 0:s.utm_campaign)==e.utm_campaign,v=null==(n=t.conditions)||null==(n=n.utm)||!n.utm_source||(null==(o=t.conditions)||null==(o=o.utm)?void 0:o.utm_source)==e.utm_source,c=null==(a=t.conditions)||null==(a=a.utm)||!a.utm_medium||(null==(l=t.conditions)||null==(l=l.utm)?void 0:l.utm_medium)==e.utm_medium,f=null==(h=t.conditions)||null==(h=h.utm)||!h.utm_term||(null==(u=t.conditions)||null==(u=u.utm)?void 0:u.utm_term)==e.utm_term;return d&&c&&f&&v}return!1}static cf(t){for(var i=arguments.length,e=new Array(i>1?i-1:0),r=1;i>r;r++)e[r-1]=arguments[r];ms.info("[WebExperiments] "+t,e)}pf(i,e,r){this._is_bot()?t.cf(Gh):"control"!==e?r.forEach(r=>{var s;r.selector&&(t.cf("applying transform of variant "+e+" for experiment "+i+" ",r),null==(s=document)||null==(s=s.querySelectorAll(r.selector))||s.forEach(t=>{var i=t;r.html&&(i.innerHTML=r.html),r.css&&i.setAttribute("style",r.css)}))}):t.cf("Control variants leave the page unmodified.")}_is_bot(){return Jt&&this._instance?sl(Jt,this.xn.custom_blocked_useragents):void 0}}},ru),cu=r({},ru,su,nu,ou,au,lu,uu,hu,du,vu,{conversations:class{constructor(t){this._instance=t,this._f=void 0,this._conversationsManager=null,this.wf=!1,this.re=null,this.kf=!1}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!this._instance.config.disable_conversations&&(this.Sf=t.ok,t.ok)){var i=t.config.conversations;Ei(i)||(Ti(i)?this._f=i:(this._f=i.enabled,this.re=i),this.loadIfEnabled())}}reset(){var t;null==(t=this._conversationsManager)||t.reset(),this._conversationsManager=null,this._f=void 0,this.re=null,this.Sf=void 0,this.kf=!1}loadIfEnabled(){if(!(this._conversationsManager||this.wf||this._instance.config.disable_conversations||As(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var t=null==ni?void 0:ni.__PosthogExtensions__;if(t&&!wi(this._f)&&this._f)if(this.re&&this.re.token){this.wf=!0;try{var i=t.initConversations;if(i)return this.xf(i),void(this.wf=!1);var e=t.loadExternalDependency;if(!e)return void this.Cf(jt);e(this._instance,"conversations",i=>{i||!t.initConversations?this.Cf("Could not load conversations script",i):this.xf(t.initConversations),this.wf=!1})}catch(t){this.Cf("Error initializing conversations",t),this.wf=!1}}else Jh.error("Conversations enabled but missing token in remote config.")}}xf(t){if(this.re)try{this._conversationsManager=t(this.re,this._instance),this.kf=!1,Jh.info("Conversations loaded successfully")}catch(t){this.Cf("Error completing conversations initialization",t)}else Jh.error("Cannot complete initialization: remote config is null")}Cf(t,i){Jh.error(t,i),this._conversationsManager=null,this.wf=!1,this.kf=!0}show(){this._conversationsManager?this._conversationsManager.show():Jh.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this._f&&!ki(this._conversationsManager)}getUnavailableReason(){return this.isAvailable()?null:this._instance.config.disable_conversations?"disabled_by_config":As(this._instance.config)?"disabled_for_toolbar":this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut()?"consent_opted_out":!1===this.Sf?"remote_config_failed":wi(this._f)?this.Sf?"disabled_in_project":"remote_config_pending":this._f?Ei(this.re)||!this.re.token?"missing_token":null!=ni&&ni.__PosthogExtensions__?this.wf?"initializing":this.kf?"load_failed":"not_loaded":"extensions_unavailable":"disabled_in_project"}isVisible(){var t,i;return null!==(t=null==(i=this._conversationsManager)?void 0:i.isVisible())&&void 0!==t&&t}sendMessage(t,i,e){var r=this;return n(function*(){return r._conversationsManager?r._conversationsManager.sendMessage(t,i,e):(Jh.warn(Xh),null)})()}getMessages(t,i){var e=this;return n(function*(){return e._conversationsManager?e._conversationsManager.getMessages(t,i):(Jh.warn(Xh),null)})()}markAsRead(t){var i=this;return n(function*(){return i._conversationsManager?i._conversationsManager.markAsRead(t):(Jh.warn(Xh),null)})()}getTickets(t){var i=this;return n(function*(){return i._conversationsManager?i._conversationsManager.getTickets(t):(Jh.warn(Xh),null)})()}requestRestoreLink(t){var i=this;return n(function*(){return i._conversationsManager?i._conversationsManager.requestRestoreLink(t):(Jh.warn(Xh),null)})()}restoreFromToken(t){var i=this;return n(function*(){return i._conversationsManager?i._conversationsManager.restoreFromToken(t):(Jh.warn(Xh),null)})()}restoreFromUrlToken(){var t=this;return n(function*(){return t._conversationsManager?t._conversationsManager.restoreFromUrlToken():(Jh.warn(Xh),null)})()}getCurrentTicketId(){var t,i;return null!==(t=null==(i=this._conversationsManager)?void 0:i.getCurrentTicketId())&&void 0!==t?t:null}getWidgetSessionId(){var t,i;return null!==(t=null==(i=this._conversationsManager)?void 0:i.getWidgetSessionId())&&void 0!==t?t:null}ih(){var t;null==(t=this._conversationsManager)||t.setIdentity()}rh(){var t;null==(t=this._conversationsManager)||t.clearIdentity()}}},{logs:class{constructor(t){var i,e=this;this._instance=t,this.name="logs",this.Tf=!1,this.Mf=!1,this.If=!1,this.A=bs("[logs]"),this.Ef=r({},this.A,{error(){for(var t=arguments.length,i=new Array(t),r=0;t>r;r++)i[r]=arguments[r];i.some(eu)||e.A.error(...i)}}),this.Za=[],this.Rf=[],this.Wd=0,this.fo=!1,this.Af=[],this.Pf=[],this.Ff=!1,this.Of=!1,this.$f=()=>{var t,i;this.fo||(this.Wd=0,null==(t=this.Df)||t.onReconnect(),null==(i=this.Lf)||i.onReconnect())},this._instance&&null!=(i=this._instance.config.logs)&&i.captureConsoleLogs&&(this.Tf=!0),Gt&&Fs(Gt,"online",this.$f)}Nf(t,i,e,r){var s,n=Yh(null==(s=this._instance)||null==(s=s.config)?void 0:s.logs,e);return[new vs(this.qf(t,i),n,this.Ef,()=>this.jf(),t=>t(),void 0,r),n]}Bf(){var t,i=null==(t=this._instance)||null==(t=t.config)?void 0:t.logs;if(!this.Df||this.Hf!==i){var e;null==(e=this.Df)||e.reset(),this.Hf=i;var r=this.Nf(()=>this.Za,t=>{this.Za=t});this.Df=r[0],this.zf=r[1]}return this.Df}Uf(){var t,i=null==(t=this._instance)||null==(t=t.config)?void 0:t.logs;if(!this.Lf||this.Wf!==i){var e;null==(e=this.Lf)||e.reset(),this.Wf=i;var r=this.Nf(()=>this.Rf,t=>{this.Rf=t},{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},Qh);this.Lf=r[0],this.Vf=r[1]}return this.Lf}setup(t){var i;if(!this.fo){this.ao=t,null!=(i=this._instance)&&null!=(i=i.config)&&null!=(i=i.logs)&&i.captureConsoleLogs&&(this.Tf=!0),(this.Tf||this.Gf()&&this.Zf())&&this.Jf();var e=!1,r=t.onRemoteConfig(t=>{var i;e=t.ok&&!0===(null==(i=t.config.logs)?void 0:i.captureConsoleLogs),this.onRemoteConfig(t)});this.fo?r.dispose():(this.yo=r,e||this.loadIfEnabled())}}dispose(){var t,i,e,r;this.fo||(this.fo=!0,this.Qf(),null==(t=this.yo)||t.dispose(),this.yo=void 0,this.ao=void 0,this.If=!1,null==Gt||Gt.removeEventListener("online",this.$f),null==(i=this.Kf)||i.call(this),this.Kf=void 0,null==(e=this.Df)||e.reset(),null==(r=this.Lf)||r.reset())}onRemoteConfig(t){var i,e;if(!this.fo){var r=t.ok?null==(i=t.config.logs)?void 0:i.captureConsoleLogs:void 0;Ei(r)?this.Xf():(null==(e=this._instance)||null==(e=e.persistence)||e.register({[P]:!!r}),r?(this.Tf=!0,this.Mf||this.Jf(),this.loadIfEnabled()):this.Xf())}}reset(){var t,i,e,r;this.Qf(),null==(t=this.Df)||t.clearQueue(),this.Za=[],null==(i=this.Df)||i.reset(),null==(e=this.Lf)||e.clearQueue(),this.Rf=[],null==(r=this.Lf)||r.reset(),this.Wd=0}captureLog(t){this.fo||this.Bf().captureLog(t)}captureConsoleLog(t){this.fo||this.Uf().captureLog(t)}captureBufferedConsoleLog(t,i,e){this.fo||this.Uf().captureLog(t,{context:i,occurredAtMs:e})}Zf(){var t;return!(null==(t=this._instance)||null==(t=t.persistence)||null==(t=t.props)||!t[P])}Gf(){var t,i;return null==(t=this._instance)||null==t.Ua||!t.Ua()||!(null==(i=ni._POSTHOG_REMOTE_CONFIG)||null==(i=i[this._instance.config.token])||!i.config)}sh(){var t;this.Qf(),null==(t=this.Lf)||t.clearQueue(),this.Rf=[]}Xf(){this.Tf||this.Qf()}Jf(){var t,i=this;if(!this.Ff&&null!=ni&&ni.console){var e=Yh(null==(t=this._instance)||null==(t=t.config)?void 0:t.logs).maxBufferSize,r=function(t){var r;try{r=(t=>{for(;null!=(i=t)&&i.__rrweb_original__;){var i;t=t.__rrweb_original__}return t})(ni.console[t])}catch(t){return 0}if(!r)return 0;i.Pf.push(sh(ni.console,t,s=>{var n=function(){for(var r=arguments.length,n=new Array(r),o=0;r>o;o++)n[o]=arguments[o];try{i.Yf(t,n,e)}catch(t){}return s.apply(ni.console,n)};return n.__rrweb_original__=r,n}))};for(var s of Zh)r(s);this.Ff=!0,this.tp=setTimeout(()=>{this.Qf()},3e4)}}Yf(t,i,e){var r;if(this.Ff&&!this.Of&&0!==i.length)if(null!=(r=this._instance)&&r.is_capturing()){if(e>this.Af.length){this.Of=!0;try{this.Af.push({level:t,args:i,occurredAtMs:Date.now(),context:this.jf()})}finally{this.Of=!1}}}else this.Qf()}Qf(){if(this.Af=[],this.Ff){for(var t of(this.Ff=!1,this.tp&&(clearTimeout(this.tp),this.tp=void 0),this.Pf))t();this.Pf=[]}}ep(){var t=this.Af;return this.Qf(),t}get logger(){return this.rp||(this.rp={trace:(t,i)=>this.captureLog({body:t,level:"trace",attributes:i}),debug:(t,i)=>this.captureLog({body:t,level:"debug",attributes:i}),info:(t,i)=>this.captureLog({body:t,level:"info",attributes:i}),warn:(t,i)=>this.captureLog({body:t,level:"warn",attributes:i}),error:(t,i)=>this.captureLog({body:t,level:"error",attributes:i}),fatal:(t,i)=>this.captureLog({body:t,level:"fatal",attributes:i})}),this.rp}flushLogs(t){t?this.np(t):(this.Df&&this.Df.flush().catch(t=>this.sp(t)),this.Lf&&this.Lf.flush().catch(t=>this.sp(t)))}sp(t){eu(t)||this.A.error("PostHog logs flush failed:",t)}loadIfEnabled(){if(!this.fo&&this.Tf&&!this.Mf&&!this.If){var t=null==ni?void 0:ni.__PosthogExtensions__;if(!t)return this.A.error("PostHog Extensions not found."),void this.Qf();var i=t.loadExternalDependency;if(!i)return this.A.error(jt),void this.Qf();this.If=!0;try{i(this._instance,"logs",i=>{if(this.If=!1,!this.fo&&this.Tf){var e=t.logs;if(i||null==e||!e.initializeLogs)this.A.error("Could not load logs script",i),this.Qf();else{var r,s,n=this.ep();this.Kf=e.initializeLogs(null!==(r=this.ao)&&void 0!==r?r:this._instance),this.Mf=!0,n.length>0&&(null==e.replayConsoleBuffer||e.replayConsoleBuffer(null!==(s=this.ao)&&void 0!==s?s:this._instance,n))}}})}catch(t){throw this.If=!1,t}}}qf(t,i){var e=this._instance;return{get isDisabled(){return!1},get optedOut(){return!e.is_capturing()},getPersistedProperty:i=>i===oi.LogsQueue?t():void 0,setPersistedProperty(t,e){t===oi.LogsQueue&&i(null!=e?e:[])},As:t=>this.As(t),getLibraryId:()=>l.LIB_NAME,getLibraryVersion:()=>l.LIB_VERSION}}As(t){return new Promise(i=>{if(co(this.Wd,3))i({kind:"fatal",error:iu(void 0,"logs endpoint is unreachable, dropping batch")});else{var e=!1,r=t=>{e||(e=!0,clearTimeout(s),i(t))},s=setTimeout(()=>{this.A.warn("Logs request timed out before receiving a response"),r({kind:"retry-later",error:iu(void 0,"logs request timed out")})},9e4);this._instance._send_request({method:"POST",url:this.op(),data:t,compression:"best-available",batchKey:"logs",fireCallbackOnDrop:!0,callback:t=>{var i=t.statusCode;if(this.ap(i),i>=200&&300>i)r({kind:"ok"});else if(413===i)r({kind:"too-large"});else if(0!==i&&408!==i&&429!==i&&500>i)r({kind:"fatal",error:new Error("logs request failed with status "+i)});else{var e;0===i?(t.error||this.A.warn("Logs request failed before receiving an HTTP response"),r({kind:"retry-later",error:iu(t.error,"logs request failed before receiving an HTTP response")})):r({kind:"retry-later",error:null!==(e=t.error)&&void 0!==e?e:new Error("logs request failed with status "+i)})}}})}})}ap(t){(0!==t||this._instance.__loaded)&&(this.Wd=fo(t,this.Wd,3,()=>this.A.warn("Log requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped sending logs; will try again when connectivity changes.")))}np(t){this.Za.length>0&&this.lp(t,this.Za,this.zf,l.LIB_NAME,t=>{this.Za=t}),this.Rf.length>0&&this.lp(t,this.Rf,this.Vf,Qh,t=>{this.Rf=t})}lp(t,i,e,r,s){if(0!==i.length){var n=i.map(t=>t.record);s([]);var o=ds(n,us(e,l.LIB_NAME,l.LIB_VERSION),r,l.LIB_VERSION);this._instance._send_request({method:"POST",url:this.op(),data:o,compression:"best-available",batchKey:"logs",transport:t})}}op(){return this._instance.requestRouter.endpointFor("api","/i/v1/logs")+"?token="+encodeURIComponent(this._instance.config.token)}jf(){var t,i={};if(i.distinctId=this._instance.get_distinct_id(),this._instance.sessionManager){var e=this._instance.sessionManager.checkAndGetSessionAndWindowId(!0),r=e.windowId,s=e.sessionStartTimestamp,n=e.lastActivityTimestamp;i.sessionId=e.sessionId,i.windowId=r,Ei(s)||(i.sessionStartTimestamp=s),Ei(n)||(i.lastActivityTimestamp=n)}if(null!=ni&&null!=(t=ni.location)&&t.href&&(i.currentUrl=this._instance.config.disable_capture_url_hashes?tr(ni.location.href):ni.location.href),this._instance.featureFlags){var o=this._instance.featureFlags.getFlags();o&&o.length>0&&(i.activeFeatureFlags=o)}return i}}},{metrics:class{constructor(t){this._instance=t,this.A=bs("[metrics]")}initialize(){}Bf(){var t,i,e=null==(t=this._instance)||null==(t=t.config)?void 0:t.metrics;return this.Df&&this.Hf===e||(null==(i=this.Df)||i.reset(),this.Hf=e,this.Df=new gs(this.qf(),function(t){var i,e,r,s,n,o=null==t?void 0:t.resourceAttributes;return{serviceName:null!==(i=null==o?void 0:o["service.name"])&&void 0!==i?i:null==t?void 0:t.serviceName,serviceVersion:null!==(e=null==o?void 0:o["service.version"])&&void 0!==e?e:null==t?void 0:t.serviceVersion,environment:null!==(r=null==o?void 0:o["deployment.environment"])&&void 0!==r?r:null==t?void 0:t.environment,resourceAttributes:o,beforeSend:null==t?void 0:t.beforeSend,flushIntervalMs:null!==(s=null==t?void 0:t.flushIntervalMs)&&void 0!==s?s:1e4,maxSeriesPerFlush:null!==(n=null==t?void 0:t.maxSeriesPerFlush)&&void 0!==n?n:1e3}}(e),this.A)),this.Df}count(t,i,e){void 0===i&&(i=1),this.Bf().count(t,i,e)}gauge(t,i,e){this.Bf().gauge(t,i,e)}histogram(t,i,e){this.Bf().histogram(t,i,e)}flush(t){if(!this.Df)return Promise.resolve();if(t){var i=this.Df.drainWindow();return i&&this.Gs(i,t),Promise.resolve()}return this.Df.flush().catch(t=>this.A.error("PostHog metrics flush failed:",t))}reset(){var t;null==(t=this.Df)||t.reset()}qf(){var t=this._instance,i=this;return{get isDisabled(){return!1},get optedOut(){return!t.is_capturing()},Gs:t=>i.Gs(t),getLibraryId:()=>l.LIB_NAME,getLibraryVersion:()=>l.LIB_VERSION}}Gs(t,i){return new Promise(e=>{var s=!1,n=t=>{s||(s=!0,clearTimeout(o),e(t))},o=setTimeout(()=>n({kind:"retry-later",error:new Error("metrics request timed out")}),9e4);this._instance._send_request(r({method:"POST",url:this.up(),data:t,compression:"best-available",batchKey:"metrics"},i&&{transport:i},{fireCallbackOnDrop:!0,callback(t){var i,e=t.statusCode;n(e>=200&&300>e?{kind:"ok"}:413===e?{kind:"too-large"}:0!==e&&408!==e&&429!==e&&500>e?{kind:"fatal",error:new Error("metrics request failed with status "+e)}:{kind:"retry-later",error:null!==(i=t.error)&&void 0!==i?i:new Error("metrics request failed with status "+e)})}}))})}up(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}}});Wl.__defaultExtensionClasses=r({},cu)}()}();
2
2
  //# sourceMappingURL=default-extensions.js.map