posthog-js 1.447.1 → 1.447.2
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.
- package/dist/all-external-dependencies.js +1 -1
- package/dist/all-external-dependencies.js.map +1 -1
- package/dist/array.full.es5.js +1 -1
- package/dist/array.full.js +1 -1
- package/dist/array.full.js.map +1 -1
- package/dist/array.full.no-external.js +1 -1
- package/dist/array.full.no-external.js.map +1 -1
- package/dist/array.js +1 -1
- package/dist/array.no-external.js +1 -1
- package/dist/customizations.full.js +1 -1
- package/dist/customizations.js +1 -1
- package/dist/default-extensions.js +1 -1
- package/dist/extension-bundles.js +1 -1
- package/dist/integrity.json +29 -29
- package/dist/lazy-recorder.js +1 -1
- package/dist/lazy-recorder.js.map +1 -1
- package/dist/main.js +1 -1
- package/dist/module.full.cjs +1 -1
- package/dist/module.full.js +1 -1
- package/dist/module.full.js.map +1 -1
- package/dist/module.full.no-external.cjs +1 -1
- package/dist/module.full.no-external.js +1 -1
- package/dist/module.full.no-external.js.map +1 -1
- package/dist/module.js +1 -1
- package/dist/module.mjs +1 -1
- package/dist/module.no-external.cjs +1 -1
- package/dist/module.no-external.js +1 -1
- package/dist/module.slim.js +1 -1
- package/dist/module.slim.no-external.js +1 -1
- package/dist/posthog-recorder.d.ts +1 -0
- package/dist/posthog-recorder.js +1 -1
- package/dist/posthog-recorder.js.map +1 -1
- package/dist/recorder-v2.js +1 -1
- package/dist/recorder-v2.js.map +1 -1
- package/dist/recorder.d.ts +1 -0
- package/dist/recorder.js +1 -1
- package/dist/recorder.js.map +1 -1
- package/dist/rrweb.d.ts +1 -0
- package/dist/rrweb.js +1 -1
- package/dist/rrweb.js.map +1 -1
- package/dist/src/extensions/replay/types/rrweb.d.ts +1 -0
- package/dist/surveys-preview.js +1 -1
- package/dist/surveys.js +1 -1
- package/lib/package.json +1 -1
- package/lib/src/extensions/replay/types/rrweb.d.ts +1 -0
- package/package.json +7 -7
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(){const e="0.10.7",t={DEBUG:(!1,!1),LIB_VERSION:(e,"1.447.1"),LIB_NAME:("browser-common","web"),JS_SDK_VERSION:e};var i=t;const s="$early_access_features",n="$active_feature_flags",r="$feature_flag_details",o="$feature_flag_errors",a="$feature_flag_evaluated_at",l="$feature_flag_request_id",c="$minimal_flag_called_events",u="$enabled_feature_flags",d="$stored_group_properties",h="$stored_person_properties",_="$flag_call_reported",p="$flag_call_reported_session_id",g="$feature_flag_payloads",f="$override_feature_flags",v="$override_feature_flag_payloads",m="visibilitychange",y="$autocapture_disabled_server_side",b="$surveys",w="$surveys_loaded_at",S="PostHog loadExternalDependency extension not found.",C="$surveys_activated",k="$surveys_activated_session",E="$surveys_activated_timestamps",x="$people_distinct_id",P="distinct_id",I="$device_id",F="$device_model",T="__alias",R="__cmpns",A="$fbc",M="$fbc_persistence",L="$fbp",O="$fbp_persistence",D="__timers",N="$heatmaps_enabled_server_side",B="$exception_capture_enabled_server_side",z="$error_tracking_suppression_rules",H="$error_tracking_capture_extension_exceptions",U="$web_vitals_enabled_server_side",q="$dead_clicks_enabled_server_side",j="$product_tours_enabled_server_side",W="$logs_capture_enabled_server_side",V="$web_vitals_allowed_metrics",G="$session_recording_remote_config",K="$session_recording_enabled_server_side",Q="$replay_sample_rate",J="$replay_override_sampling",Y="$replay_override_linked_flag",X="$replay_override_url_trigger",Z="$replay_override_event_trigger",ee="$sesid",te="$session_is_sampled",ie="$session_past_minimum_duration",se="$session_recording_url_trigger_activated_session",ne="$session_recording_event_trigger_activated_session",re="$debug_first_full_snapshot_timestamp",oe="$sess_rec_flush_size",ae="$groups",le="ph_product_tours",ce="$product_tours_activated",ue="$product_tours_activated_session",de="$conversations_widget_session_id",he="$conversations_ticket_id",_e="$conversations_widget_state",pe="$conversations_user_traits",ge="$user_state",fe="$client_session_props",ve="$capture_rate_limit",me="$initial_campaign_params",ye="$initial_referrer_info",be="$initial_person_info",we="$epp",Se="$posthog_cookieless",Ce="$cookieless_mode",ke="$sdk_debug_extensions_init_method",Ee="$sdk_debug_extensions_init_time_ms",xe="$sdk_debug_recording_script_not_loaded",Pe="$sdk_debug_replay_stale_config",Ie="$sdk_debug_replay_event_trigger_status",Fe="$sdk_debug_replay_linked_flag_trigger_status",Te="$sdk_debug_replay_matched_recording_trigger_groups",Re="$sdk_debug_replay_pending_trigger_conditions",Ae="$sdk_debug_replay_remote_trigger_matching_config",$e="$sdk_debug_replay_trigger_groups_count",Me="$sdk_debug_replay_url_trigger_status",Le="$session_recording_start_reason",Oe="anonymous",De="identified",Ne="identified_only",Be="beforeunload",ze="$pageview",He="$pageleave",Ue="$identify",qe="$groupidentify",je="u">typeof window?window:void 0,We="u">typeof globalThis?globalThis:je,Ve=null==We?void 0:We.navigator,Ge=null==We?void 0:We.document,Ke=null==We?void 0:We.location,Qe=null==We?void 0:We.fetch,Je=(null==We?void 0:We.XMLHttpRequest)&&"withCredentials"in new We.XMLHttpRequest?We.XMLHttpRequest:void 0,Ye=null==We?void 0:We.AbortController,Xe=null==We?void 0:We.CompressionStream,Ze=null==Ve?void 0:Ve.userAgent,et="undefined"!=typeof globalThis?globalThis:je;et&&"undefined"==typeof self&&(et.self=et),et&&"undefined"==typeof File&&(et.File=function(){});const tt=null!=je?je:{};var it=function(e){return e.AnonymousId="anonymous_id",e.DistinctId="distinct_id",e.Props="props",e.EnablePersonProcessing="enable_person_processing",e.PersonMode="person_mode",e.FeatureFlagDetails="feature_flag_details",e.FeatureFlags="feature_flags",e.FeatureFlagPayloads="feature_flag_payloads",e.BootstrapFeatureFlagDetails="bootstrap_feature_flag_details",e.BootstrapFeatureFlags="bootstrap_feature_flags",e.BootstrapFeatureFlagPayloads="bootstrap_feature_flag_payloads",e.OverrideFeatureFlags="override_feature_flags",e.Queue="queue",e.AiQueue="ai_queue",e.AiCaptureQueue="ai_capture_queue",e.LogsQueue="logs_queue",e.OptedOut="opted_out",e.SessionId="session_id",e.SessionStartTimestamp="session_start_timestamp",e.SessionLastTimestamp="session_timestamp",e.PersonProperties="person_properties",e.GroupProperties="group_properties",e.InstalledAppBuild="installed_app_build",e.InstalledAppVersion="installed_app_version",e.SessionReplay="session_replay",e.PushRegistered="push_registered",e.SessionReplayEventTriggerActivatedSession="session_replay_event_trigger_activated_session",e.SurveyLastSeenDate="survey_last_seen_date",e.SurveysInProgress="surveys_in_progress",e.SurveysSeen="surveys_seen",e.Surveys="surveys",e.RemoteConfig="remote_config",e.FlagsEndpointWasHit="flags_endpoint_was_hit",e.DeviceId="device_id",e}({}),st=function(e){return e.GZipJS="gzip-js",e.Base64="base64",e}({});const nt=["$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"],rt=["token"];function ot(e,t){return-1!==e.indexOf(t)}const at=function(e){return e.trim()},lt=function(e){return e.replace(/^\$/,"")};function ct(e){var t;const i=[];return null!==(t=JSON.stringify(e,function(e,t){if("bigint"==typeof t)return t.toString();if("function"!=typeof t&&"symbol"!=typeof t){if(t instanceof Error)return{name:t.name,message:t.message,stack:t.stack};if(t&&"object"==typeof t){for(;i.length>0&&i[i.length-1]!==this;)i.pop();if(i.includes(t))return"[Circular]";i.push(t)}return t}}))&&void 0!==t?t:"null"}const ut=Object.prototype,dt=ut.hasOwnProperty,ht=ut.toString,_t=Array.isArray||function(e){return"[object Array]"===ht.call(e)},pt=e=>"function"==typeof e,gt=e=>e===Object(e)&&!_t(e),ft=e=>{if(gt(e)){for(const t in e)if(dt.call(e,t))return!1;return!0}return!1},vt=e=>void 0===e,mt=e=>"[object String]"==ht.call(e),yt=e=>mt(e)&&0===e.trim().length,bt=e=>null===e,wt=e=>vt(e)||bt(e),St=e=>"[object Number]"==ht.call(e)&&e==e,Ct=e=>St(e)&&e>0,kt=e=>"[object Boolean]"===ht.call(e),Et=e=>ot(nt,e),xt=e=>ot(rt,e);function Pt(e){return null===e||"object"!=typeof e}function It(e,t){return{}.toString.call(e)===`[object ${t}]`}function Ft(e){switch({}.toString.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object DOMError]":case"[object WebAssembly.Exception]":return!0;default:return Rt(e,Error)}}function Tt(e){return"u">typeof Event&&Rt(e,Event)}function Rt(e,t){try{return e instanceof t}catch(e){return!1}}const At=[!0,"true",1,"1","yes"],$t=e=>ot(At,e),Mt=[!1,"false",0,"0","no"];function Lt(e,t,i,s,n,r,o){try{var a=e[r](o),l=a.value}catch(e){return void i(e)}a.done?t(l):Promise.resolve(l).then(s,n)}function Ot(e){return function(){var t=this,i=arguments;return new Promise(function(s,n){var r=e.apply(t,i);function o(e){Lt(r,s,n,o,a,"next",e)}function a(e){Lt(r,s,n,o,a,"throw",e)}o(void 0)})}}const Dt=["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","lightpanda","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"],Nt=new Map,Bt=function(e,t=[]){if(!e)return!1;const i=function(e,t){let i="";for(let e=0;t.length>e;e++){const s=t[e];i+=s.length+":"+s}return e.length+":"+e+"|"+t.length+":"+i}(e,t),s=Nt.get(i);if(void 0!==s)return s;const n=e.toLowerCase(),r=Dt.concat(t).some(e=>-1!==n.indexOf(e.toLowerCase()));return 256>Nt.size||Nt.clear(),Nt.set(i,r),r};function zt(e,t,i,s,n){return t>i&&(s.warn("min cannot be greater than max."),t=i),St(e)?e>i?(s.warn(" cannot be greater than max: "+i+". Using max value instead."),i):t>e?(s.warn(" cannot be less than min: "+t+". Using min value instead."),t):e:(s.warn(" must be a number. using max or fallback. max: "+i+", fallback: "+n),zt(null!=n?n:i,t,i,s))}var Ht=class{constructor(e){this._buckets={},this._onBucketRateLimited=e._onBucketRateLimited,this._bucketSize=zt(e.bucketSize,0,100,e._logger),this._refillRate=zt(e.refillRate,0,this._bucketSize,e._logger),this._refillInterval=zt(e.refillInterval,0,864e5,e._logger)}_applyRefill(e,t){const i=Math.floor((t-e.lastAccess)/this._refillInterval);i>0&&(e.tokens=Math.min(e.tokens+i*this._refillRate,this._bucketSize),e.lastAccess=e.lastAccess+i*this._refillInterval)}consumeRateLimit(e){var t;const i=Date.now(),s=String(e);let n=this._buckets[s];return n?this._applyRefill(n,i):(n={tokens:this._bucketSize,lastAccess:i},this._buckets[s]=n),0===n.tokens||(n.tokens--,0===n.tokens&&(null===(t=this._onBucketRateLimited)||void 0===t||t.call(this,e)),0===n.tokens)}stop(){this._buckets={}}};const Ut="Mobile",qt="Android",jt="Tablet",Wt="Android Tablet",Vt="iPad",Gt="Apple Watch",Kt="Safari",Qt="BlackBerry",Jt="Samsung Internet",Yt="Chrome",Xt="Chrome iOS",Zt="Internet Explorer",ei="Internet Explorer Mobile",ti="Opera",ii="Microsoft Edge",si="Firefox",ni="Firefox iOS",ri="Nintendo",oi="PlayStation",ai="Xbox",li="Android Mobile",ci="Mobile Safari",ui="Windows",di="Windows Phone",hi="Nokia",_i="Ouya",pi="Generic tablet",gi="Konqueror",fi="Oculus Browser",vi="Vivaldi",mi="Yandex",yi="Whale",bi="DuckDuckGo",wi="Pale Moon",Si="Waterfox",Ci="Brave",ki="Claude",Ei="Codex",xi="ChatGPT",Pi="Google Search App",Ii=new RegExp("Version/(\\d+(\\.\\d+)?)"),Fi=new RegExp("(Claude|Codex|ChatGPT)\\/(\\d+(\\.\\d+)?)"),Ti=new RegExp(ai,"i"),Ri=new RegExp("PlayStation \\w+","i"),Ai=new RegExp("Nintendo \\w+","i"),$i=new RegExp("BlackBerry|PlayBook|BB10","i"),Mi={"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"},Li=function(e,t,i,s){t=t||"";const n=function(e){return(null==e?void 0:e.brave)?Ci:null}(i);return n||((null==s?void 0:s.detectGoogleSearchApp)&&ot(e,"GSA/")?Pi:ot(e," OPR/")&&ot(e,"Mini")?"Opera Mini":ot(e," OPR/")?ti:$i.test(e)?Qt:ot(e,"IEMobile")||ot(e,"WPDesktop")?ei:ot(e,"OculusBrowser")?fi:ot(e,"SamsungBrowser")?Jt:ot(e,"Edge")||ot(e,"Edg/")?ii:ot(e,"Vivaldi/")?vi:ot(e,"YaBrowser/")?mi:ot(e,"Whale/")?yi:ot(e,"DuckDuckGo/")||ot(e,"Ddg/")?bi:ot(e,"Claude/")?ki:ot(e,"Codex/")?Ei:ot(e,"ChatGPT/")?xi:ot(e,"FBIOS")?"Facebook Mobile":ot(e,"UCWEB")||ot(e,"UCBrowser")?"UC Browser":ot(e,"CriOS")?Xt:ot(e,"CrMo")||ot(e,Yt)?Yt:ot(e,qt)&&ot(e,Kt)?li:ot(e,"FxiOS")?ni:ot(e.toLowerCase(),gi.toLowerCase())?gi:ot(e,"Brave/")?Ci:((e,t)=>t&&ot(t,"Apple")||function(e){return ot(e,Kt)&&!ot(e,Yt)&&!ot(e,qt)}(e))(e,t)?ot(e,Ut)?ci:Kt:ot(e,"PaleMoon/")?wi:ot(e,"Waterfox/")?Si:ot(e,si)?si:ot(e,"MSIE")||ot(e,"Trident/")?Zt:ot(e,"Gecko")?si:"")},Oi={[ei]:[new RegExp("rv:(\\d+(\\.\\d+)?)")],[ii]:[new RegExp("Edge?\\/(\\d+(\\.\\d+)?)")],[Yt]:[new RegExp("(Chrome|CrMo)\\/(\\d+(\\.\\d+)?)")],[Xt]:[new RegExp("CriOS\\/(\\d+(\\.\\d+)?)")],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/(\\d+(\\.\\d+)?)")],[Kt]:[Ii],[ci]:[Ii],[ti]:[new RegExp("(Opera|OPR)\\/(\\d+(\\.\\d+)?)")],[si]:[new RegExp("Firefox\\/(\\d+(\\.\\d+)?)")],[ni]:[new RegExp("FxiOS\\/(\\d+(\\.\\d+)?)")],[gi]:[new RegExp("Konqueror[:/]?(\\d+(\\.\\d+)?)","i")],[Qt]:[new RegExp("BlackBerry (\\d+(\\.\\d+)?)"),Ii],[li]:[new RegExp("android\\s(\\d+(\\.\\d+)?)","i")],[Jt]:[new RegExp("SamsungBrowser\\/(\\d+(\\.\\d+)?)")],[fi]:[new RegExp("OculusBrowser\\/(\\d+(\\.\\d+)?)")],[vi]:[new RegExp("Vivaldi\\/(\\d+(\\.\\d+)?)")],[mi]:[new RegExp("YaBrowser\\/(\\d+(\\.\\d+)?)")],[yi]:[new RegExp("Whale\\/(\\d+(\\.\\d+)?)")],[Ci]:[new RegExp("Brave\\/(\\d+(\\.\\d+)?)")],[ki]:[Fi],[Ei]:[Fi],[xi]:[Fi],[bi]:[new RegExp("(DuckDuckGo|Ddg)\\/(\\d+(\\.\\d+)?)")],[wi]:[new RegExp("PaleMoon\\/(\\d+(\\.\\d+)?)")],[Si]:[new RegExp("Waterfox\\/(\\d+(\\.\\d+)?)")],[Pi]:[new RegExp("GSA\\/(\\d+(\\.\\d+)?)")],[Zt]:[new RegExp("(rv:|MSIE )(\\d+(\\.\\d+)?)")],Mozilla:[new RegExp("rv:(\\d+(\\.\\d+)?)")]},Di=function(e,t,i,s){const n=Li(e,t,i,s),r=Oi[n];if(vt(r))return null;for(let t=0;r.length>t;t++){const i=e.match(r[t]);if(i)return parseFloat(i[i.length-2])}return null},Ni=[[new RegExp("Xbox; Xbox (.*?)[);]","i"),e=>[ai,e&&e[1]||""]],[new RegExp(ri,"i"),[ri,""]],[new RegExp(oi,"i"),[oi,""]],[$i,[Qt,""]],[new RegExp(ui,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[di,""];if(new RegExp(Ut).test(t)&&!/IEMobile\b/.test(t))return["Windows Mobile",""];const i=/Windows NT ([0-9.]+)/i.exec(t);if(i&&i[1]){let e=Mi[i[1]]||"";return/arm/i.test(t)&&(e="RT"),[ui,e]}return[ui,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>e&&e[3]?["iOS",[e[3],e[4],e[5]||"0"].join(".")]:["iOS",""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{let t="";return e&&e.length>=3&&(t=vt(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("(Android (\\d+)\\.(\\d+)\\.?(\\d+)?|Android)","i"),e=>e&&e[2]?[qt,[e[2],e[3],e[4]||"0"].join(".")]:[qt,""]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{const t=["Mac OS X",""];return e&&e[1]&&(t[1]=[e[1],e[2],e[3]||"0"].join(".")),t}],[/Mac/i,["Mac OS X",""]],[/CrOS/,["Chrome OS",""]],[/Linux|debian/i,["Linux",""]]],Bi=function(e){for(let t=0;Ni.length>t;t++){const[i,s]=Ni[t],n=i.exec(e),r=n&&(pt(s)?s(n,e):s);if(r)return r}return["",""]},zi=function(e){return Ai.test(e)?ri:Ri.test(e)?oi:Ti.test(e)?ai:new RegExp(_i,"i").test(e)?_i:new RegExp("(Windows Phone|WPDesktop)","i").test(e)?di:/iPad/.test(e)?Vt:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?Gt:$i.test(e)?Qt:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(hi,"i").test(e)?hi:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(e)||/(kf[a-z]+)( bui|\)).+silk\//i.test(e)?"Kindle Fire":/(Android|ZTE)/i.test(e)?new RegExp(Ut).test(e)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(e)||/pixel[\daxl ]{1,6}/i.test(e)&&!/pixel c/i.test(e)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(e)||/lmy47v/i.test(e)&&!/QTAQZ3/i.test(e)?qt:Wt:new RegExp("(pda|Mobile)","i").test(e)?"Generic mobile":new RegExp(jt,"i").test(e)&&!new RegExp("Tablet pc","i").test(e)?pi:""},Hi=function(e,t){var i;const s=zi(e);return s===Vt||s===Wt||"Kobo"===s||"Kindle Fire"===s||s===pi?jt:s===ri||s===ai||s===oi||s===_i?"Console":s===Gt?"Wearable":s?Ut:"Android"===(null==t?void 0:t.userAgentDataPlatform)&&(null!==(i=null==t?void 0:t.maxTouchPoints)&&void 0!==i?i:0)>0?600>Math.min(null!==(n=null==t?void 0:t.screenWidth)&&void 0!==n?n:0,null!==(r=null==t?void 0:t.screenHeight)&&void 0!==r?r:0)/(null!==(o=null==t?void 0:t.devicePixelRatio)&&void 0!==o?o:1)?Ut:jt:"Desktop";var n,r,o},Ui=/\bFBAV\/(\d+(?:\.\d+)*)/i,qi=[[/\bInstagram(?:[ /](\d+(?:\.\d+)*))?\b/i,"Instagram"],[/\bBarcelona[ /](\d+(?:\.\d+)*)?/i,"Threads"],[/\b(?:MessengerForiOS|(?:FBAN|FB_IAB)\/Orca-Android)\b/i,"Messenger",Ui],[/\bFBAN\/EMA\b/i,"Facebook Lite",Ui],[/\b(?:FBIOS|(?:FBAN|FB_IAB)\/(?:FB4A|FBIOS))\b/i,"Facebook",Ui],[/\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"]],ji="[Truncated]",Wi="[Unserializable]";function Vi(e){let t="";for(let i=0;e.length>i;i++){const s=e.charCodeAt(i);if(55296>s||s>56319)t+=56320>s||s>57343?e[i]:"�";else{const s=e.charCodeAt(i+1);56320>s||s>57343?t+="�":(t+=e[i]+e[i+1],i++)}}return t}function Gi(e,t){if(!t)return e;let i=[];try{i=Object.keys(t)}catch(e){i=[]}for(const s of i){let i;try{i=t[s]}catch(e){i=Wi}Object.defineProperty(e,s,{value:i,enumerable:!0,writable:!0,configurable:!0})}return e}Date,Date;const Ki=3e5;var Qi=class{record(e){if("too-large"===e.kind)return;if("retry-later"!==e.kind)return void this.reset();if(!e.retryAfterMs)return;const t=this.isOpen(),i=Date.now(),s=Math.min(e.retryAfterMs,Ki);if(!t)return this._installedAt=i,void(this._until=i+s);this._until=Math.max(this._until,Math.min(i+s,this._installedAt+Ki))}remainingMs(){const e=Date.now();if(this._installedAt-5e3>e)return this.reset(),0;const t=Math.min(Ki,Math.max(0,this._until-e));return 0===t&&this.reset(),t}isOpen(){return this.remainingMs()>0}reset(){this._until=0,this._installedAt=0}constructor(){this._until=0,this._installedAt=0}};const Ji=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function Yi(e,t){return"string"==typeof(i=e)&&Ji.test(i)?e:t();var i}function Xi(e,t){const i=new Error(t);try{Object.defineProperty(i,"name",{value:e,writable:!0,enumerable:!0,configurable:!0})}catch(e){}return i}function Zi(e){return e?e.split("#")[0]:e}function es(e){try{return e()}catch(e){return}}function ts(e,t){const i=setTimeout(e,t);return null!=i&&i.unref&&(null==i||i.unref()),i}function is(e,t,i){return ss.apply(this,arguments)}function ss(){return(ss=Ot(function*(e,t,i){let s;try{return yield Promise.race([e,new Promise((e,n)=>{s=ts(()=>{try{null==i||i(),e()}catch(e){n(e)}},t)})])}finally{clearTimeout(s)}})).apply(this,arguments)}function ns(e){return ns="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},ns(e)}function rs(e,t,i){return(t=function(e){var t=function(e){if("object"!=ns(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var i=t.call(e,"string");if("object"!=ns(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==ns(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function os(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),i.push.apply(i,s)}return i}function as(e){for(var t=1;arguments.length>t;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?os(Object(i),!0).forEach(function(t){rs(e,t,i[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):os(Object(i)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))})}return e}let ls,cs,us,ds;function hs(e){var t;const i=globalThis._posthogChunkIds,s=globalThis._debugIds;if(!i&&!s)return;const n=i?Object.keys(i):[],r=s?Object.keys(s):[];if(ds&&_s(i,n,cs)&&_s(s,r,us))return ds;cs=i?as({},i):void 0,us=s?as({},s):void 0,ds={},null!==(t=ls)&&void 0!==t||(ls={});const o=(t,i)=>{for(const n of t){const t=i[n];if(!t)continue;const r=null==ls?void 0:ls[n];if(r){ds[r]=t;continue}const o=e(n);for(let e=o.length-1;e>=0;e--){var s;const i=null===(s=o[e])||void 0===s?void 0:s.filename;if(i){ds[i]=t,ls[n]=i;break}}}};return s&&o(r,s),i&&o(n,i),ds}function _s(e,t,i){return e&&i?t.length===Object.keys(i).length&&t.every(t=>e[t]===i[t]):e===i}var ps=class{constructor(e,t,i=[]){this.coercers=e,this.stackParser=t,this.modifiers=i}buildFromUnknown(e,t={}){const i=t&&t.mechanism||{handled:!0,type:"generic"},s=this.buildCoercingContext(i,t,0).apply(e),n=this.buildParsingContext(t),r=this.parseStacktrace(s,n);return{$exception_list:this.convertToExceptionList(r,i),$exception_level:"error"}}modifyFrames(e){var t=this;return Ot(function*(){for(const i of e)i.stacktrace&&i.stacktrace.frames&&_t(i.stacktrace.frames)&&(i.stacktrace.frames=yield t.applyModifiers(i.stacktrace.frames));return e})()}coerceFallback(e){var t;return{type:"Error",value:"Unknown error",stack:null===(t=e.syntheticException)||void 0===t?void 0:t.stack,synthetic:!0}}parseStacktrace(e,t){var i;let s,n;if(null!=e.cause&&(s=this.parseStacktrace(e.cause,t)),""!=e.stack&&null!=e.stack)try{n=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?t.skipFirstLines:0),t.chunkIdMap)}catch(e){}return as(as({},e),{},{cause:s,stack:n,errors:null===(i=e.errors)||void 0===i?void 0:i.map(e=>this.parseStacktrace(e,t))})}applyChunkIds(e,t){return e.map(e=>(e.filename&&t&&(e.chunk_id=t[e.filename]),e))}applyCoercers(e,t){for(const i of this.coercers)if(i.match(e))return i.coerce(e,t);return this.coerceFallback(t)}applyModifiers(e){var t=this;return Ot(function*(){let i=e;for(const e of t.modifiers)i=yield e(i);return i})()}convertToExceptionList(e,t){const i=[],s=(e,n,r)=>{var o;const a=i.length,l=void 0===n?as(as({type:"string"==typeof t.type&&t.type.length>0?t.type:"generic"},"boolean"==typeof t.handled?{handled:t.handled}:void 0===t.handled?{handled:!0}:{}),{},{synthetic:"boolean"==typeof t.synthetic?t.synthetic:e.synthetic,exception_id:a}):{type:"chained",source:r,synthetic:e.synthetic,exception_id:a,parent_id:n},c={type:e.type,value:e.value,mechanism:l};e.stack&&(c.stacktrace={type:"raw",frames:e.stack}),i.push(c),e.cause&&s(e.cause,a,"cause");for(const t of null!==(o=e.errors)&&void 0!==o?o:[])s(t,a,"member")};return s(e),i}buildParsingContext(e){var t;return{chunkIdMap:hs(this.stackParser),skipFirstLines:null!==(t=e.skipFirstLines)&&void 0!==t?t:1}}getAggregateErrors(e){try{if(Ft(e)){let i=Object.getPrototypeOf(e);for(let s=0;i&&100>s;s++){var t;const s=null===(t=Object.getOwnPropertyDescriptor(i,"constructor"))||void 0===t?void 0:t.value;if("function"==typeof s&&"AggregateError"===s.name){const t=e.errors;return _t(t)?t:void 0}i=Object.getPrototypeOf(i)}}}catch(e){}}buildCoercingContext(e,t,i=0){let s=0,n=0,r=!1;const o=new Set,a=[],l={},c=(e,t,i=0)=>{const c=u(t,i),d=c.apply;if(c.apply=t=>{a.push(e);try{return d(t)}finally{a.pop()}},i>4||i>0&&-1!==a.indexOf(e))return this.coerceFallback(c);const h="object"==typeof e&&null!==e||"function"==typeof e;if(0===i&&s>=50||h&&o.has(e))return;h&&o.add(e),0===i&&s++;const _=this.getAggregateErrors(e);let p,g;r||(r=!!_);try{if(p=this.applyCoercers(e,c),!p)throw l}catch(e){if(e===l)return void(0===i&&s--);if(!r)throw e;p=this.coerceFallback(c)}if(!_||s>=50)return p;try{g=_.length}catch(e){return p}if(!Number.isInteger(g)||0>g||g>4294967295)return p;const f=[];for(let e=0;50>s&&1e3>n&&g>e;e++){let i;n++;try{i=c.next(_[e])}catch(e){s++,i=this.coerceFallback(u(t+1))}i&&f.push(i)}return as(as({},p),{},{errors:f})},u=(i,s=0)=>as(as({},t),{},{syntheticException:0==i?t.syntheticException:void 0,mechanism:0==i?e:{},apply(e){const t=c(e,i,s+1);if(!t)throw l;return t},next:e=>c(e,i+1)}),d=u(i);return as(as({},d),{},{apply:e=>{var t;return null!==(t=c(e,i))&&void 0!==t?t:this.coerceFallback(d)}})}};const gs=/^([a-z][a-z0-9.+-]+):/i,fs=["http","https","file","blob","app","capacitor","ionic","webpack","webpack-internal","ng"];function vs(e){if(!e||"<anonymous>"===e)return!1;const t=gs.exec(e);return!t||fs.includes(t[1].toLowerCase())}function ms(e,t,i,s,n){const r={platform:e,filename:t,function:"<anonymous>"===i?"?":i,in_app:vs(t)};return vt(s)||(r.lineno=s),vt(n)||(r.colno=n),r}const ys=(e,t)=>{const i=-1!==e.indexOf("safari-extension"),s=-1!==e.indexOf("safari-web-extension");return i||s?[-1!==e.indexOf("@")?e.split("@")[0]:"?",i?`safari-extension:${t}`:`safari-web-extension:${t}`]:[e,t]},bs=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,ws=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,Ss=/\((\S*)(?::(\d+))(?::(\d+))\)/,Cs=(e,t)=>{const i=bs.exec(e);if(i){const[,e,s,n]=i;return ms(t,e,"?",+s,+n)}const s=ws.exec(e);if(s){if(s[2]&&0===s[2].indexOf("eval")){const e=Ss.exec(s[2]);e&&(s[2]=e[1],s[3]=e[2],s[4]=e[3])}const[e,i]=ys(s[1]||"?",s[2]);return ms(t,i,e,s[3]?+s[3]:void 0,s[4]?+s[4]:void 0)}},ks=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,Es=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,xs=(e,t)=>{const i=ks.exec(e);if(i){if(i[3]&&i[3].indexOf(" > eval")>-1){const e=Es.exec(i[3]);e&&(i[1]=i[1]||"eval",i[3]=e[1],i[4]=e[2],i[5]="")}let e=i[3],s=i[1]||"?";return[s,e]=ys(s,e),ms(t,e,s,i[4]?+i[4]:void 0,i[5]?+i[5]:void 0)}},Ps=/\(error: (.*)\)/;function Is(e,t){return e.filename===t.filename&&e.function===t.function&&e.module===t.module&&e.lineno===t.lineno&&e.colno===t.colno}function Fs(e){for(let t=1;10>=t;t++){const i=e.length-2*t;if(0>i)break;let s=!0;for(let n=0;t>n;n++)if(!Is(e[i+n],e[i+t+n])){s=!1;break}if(s){for(let s=0;t>s;s++)e[i+s]=e[i+t+s];return e.length=i+t,{start:i,length:t}}}}function Ts(e,t){const i=t.start+t.length,s=As(e,t);s&&e.splice(i+s===e.length?i:t.start,s)}function Rs(e,t){let i=t.start;for(;i>0&&Is(e[i-1],e[i-1+t.length]);)i--;return t.start-i}function As(e,t){const i=t.start+t.length;let s=i;for(;e.length>s&&Is(e[s],e[s-t.length]);)s++;return s-i}function $s(e,t){const i=t[0];let s=e.length-(i?Rs(e,i):0);for(const i of t)s-=As(e,i);return s}function Ms(e,t,i){for(let s=0;e.length>s;s++){const n=e[(t+s)%e.length],r=e[(i+s)%e.length];if(n!==r)return r>n}return!1}var Ls=class{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){const i=mt(e.stack);return{type:this.getType(e),value:this.getValue(e),stack:i?e.stack:void 0,cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return this.isDOMError(e)?"DOMError":"DOMException"}getValue(e){const t=e.name||(this.isDOMError(e)?"DOMError":"DOMException");return e.message?`${t}: ${e.message}`:t}isDOMException(e){return It(e,"DOMException")}isDOMError(e){return It(e,"DOMError")}},Os=class{match(e){return Ft(e)}coerce(e,t){var i;const s=this.getStack(e),n=void 0===s?null===(i=t.syntheticException)||void 0===i?void 0:i.stack:void 0,r=!!n;return{type:this.getType(e),value:this.getMessage(e,t),stack:null!=s?s:n,cause:e.cause?t.next(e.cause):void 0,synthetic:r}}getType(e){return e.name||e.constructor.name}getMessage(e,t){const i=e.message;return String(i.error&&"string"==typeof i.error.message?i.error.message:i)}getStack(e){try{const t=e.stacktrace;if("string"==typeof t&&t.length>0)return t;const i=e.stack;return"string"==typeof i&&i.length>0?i:void 0}catch(e){return}}},Ds=class{match(e){return!!It(e,"ErrorEvent")&&(null!=e.error||this._hasUsableMessage(e))}coerce(e,t){var i;if(null!=e.error)return t.apply(e.error);const s=t.apply(e.message);return as(as({},s),{},{stack:null!==(i=this._buildLocationStack(e))&&void 0!==i?i:s.stack,synthetic:!0})}_hasUsableMessage(e){return mt(e.message)&&e.message.length>0}_buildLocationStack(e){var t,i;const s=e,n=null!==(t=s.lineno)&&void 0!==t?t:0,r=null!==(i=s.colno)&&void 0!==i?i:0;if(mt(s.filename)&&0!==s.filename.length&&0!==n)return`Error\n at ${s.filename}:${n}:${r}`}};const Ns=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;var Bs=class{match(e){return"string"==typeof e}coerce(e,t){var i;const[s,n]=this.getInfos(e);return{type:null!=s?s:"Error",value:null!=n?n:e,stack:null===(i=t.syntheticException)||void 0===i?void 0:i.stack,synthetic:!0}}getInfos(e){let t="Error",i=e;const s=e.match(Ns);return s&&(t=s[1],i=s[2]),[t,i]}};const zs=["fatal","error","warning","log","info","debug"];function Hs(e,t=40){const i=Object.keys(e);if(i.sort(),!i.length)return"[object has no keys]";for(let e=i.length;e>0;e--){const s=i.slice(0,e).join(", ");if(t>=s.length)return e===i.length?s:s.length>t?`${s.slice(0,t)}...`:s}return""}var Us=class{match(e){return"object"==typeof e&&null!==e}coerce(e,t){var i,s;const n=this.getErrorPropertyFromObject(e);return n?t.apply(n):{type:this.getType(e),value:this.getValue(e),stack:null!==(i=this.getStack(e))&&void 0!==i?i:null===(s=t.syntheticException)||void 0===s?void 0:s.stack,level:this.isSeverityLevel(e.level)?e.level:"error",synthetic:!0}}getType(e){if(Tt(e))return e.constructor.name;const t="name"in e?e.name:void 0;return mt(t)&&!yt(t)?t:"Error"}getValue(e){if("name"in e&&"string"==typeof e.name){let t=`'${e.name}' captured as exception`;return"message"in e&&"string"==typeof e.message&&(t+=` with message: '${e.message}'`),t}if("message"in e&&"string"==typeof e.message)return e.message;const t=this.getObjectClassName(e);return`${t&&"Object"!==t?`'${t}'`:"Object"} captured as exception with keys: ${Hs(e)}`}isSeverityLevel(e){return mt(e)&&!yt(e)&&zs.indexOf(e)>=0}getStack(e){try{return mt(e.stacktrace)&&e.stacktrace.length>0?e.stacktrace:mt(e.stack)&&e.stack.length>0?e.stack:void 0}catch(e){return}}getErrorPropertyFromObject(e){for(const t in e)if({}.hasOwnProperty.call(e,t)){const i=e[t];if(Ft(i))return i}}getObjectClassName(e){try{const t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch(e){return}}},qs=class{match(e){return Tt(e)}coerce(e,t){var i;const s=e.constructor.name;return{type:s,value:`${s} captured as exception with keys: ${Hs(e)}`,stack:null===(i=t.syntheticException)||void 0===i?void 0:i.stack,synthetic:!0}}},js=class{match(e){return Pt(e)}coerce(e,t){var i;return{type:"Error",value:`Primitive value captured as exception: ${String(e)}`,stack:null===(i=t.syntheticException)||void 0===i?void 0:i.stack,synthetic:!0}}},Ws=class{match(e){return It(e,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(e)}isCustomEventWrappingRejection(e){if(!Tt(e))return!1;try{const t=e.detail;return null!=t&&"object"==typeof t&&"reason"in t}catch(e){return!1}}coerce(e,t){var i;const s=this.getUnhandledRejectionReason(e);return Pt(s)?{type:"UnhandledRejection",value:`Non-Error promise rejection captured with value: ${String(s)}`,stack:null===(i=t.syntheticException)||void 0===i?void 0:i.stack,synthetic:!0}:t.apply(s)}getUnhandledRejectionReason(e){try{if("reason"in e)return e.reason;if("detail"in e&&null!=e.detail&&"object"==typeof e.detail&&"reason"in e.detail)return e.detail.reason}catch(e){}return e}};const Vs="$message",Gs="$timestamp",Ks=new Set([Vs,Gs]),Qs={enabled:!0,max_bytes:32768};function Js(e){var t;return e?{enabled:null!==(t=e.enabled)&&void 0!==t?t:Qs.enabled,max_bytes:Xs(e.max_bytes,Qs.max_bytes)}:as({},Qs)}var Ys=class{constructor(e){this._entries=[],this._totalBytes=0,this._config=Js(e)}setConfig(e){this._config=Js(e),this._trimToMaxBytes()}add(e){const t=function(e){let t;try{t=ct(e)}catch(e){return}try{const e=JSON.parse(t);if(!gt(e))return;const i=e,s=i[Vs],n=i[Gs];if(!mt(s)||0===s.trim().length)return;if(!mt(n)&&!St(n))return;return{step:i,json:t}}catch(e){return}}(e);if(!t)return;const i=function(e){if("u">typeof TextEncoder)return(new TextEncoder).encode(e).length;const t=encodeURIComponent(e);let i=0;for(let e=0;t.length>e;e++)"%"===t[e]?(i+=1,e+=2):i+=1;return i}(t.json);i>this._config.max_bytes||(this._entries.push({step:t.step,bytes:i}),this._totalBytes+=i,this._trimToMaxBytes())}getAttachable(){return this._entries.map(e=>e.step)}clear(){this._entries=[],this._totalBytes=0}size(){return this._entries.length}_trimToMaxBytes(){for(;this._totalBytes>this._config.max_bytes&&this._entries.length>0;){const e=this._entries.shift();e&&(this._totalBytes-=e.bytes)}}};function Xs(e,t){if(!St(e)||1/0===e||-1/0===e)return t;const i=Math.floor(e);return 0>i?t:i}const Zs=e=>{if("string"!=typeof e)return e;try{return JSON.parse(e)}catch(t){return e}};function en(e){return"string"==typeof e||e}function tn(e){return"string"==typeof e?e:void 0}const sn=["$feature_flag","$feature_flag_response","$feature_flag_has_experiment","$feature_flag_id","$feature_flag_version","$feature_flag_reason","$feature_flag_request_id","$feature_flag_evaluated_at","$feature_flag_error","locally_evaluated","$groups","$process_person_profile","$geoip_disable","$current_url","$pathname","$referring_domain","utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid","gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","oppref","bfcid","irclid","_kx","$session_id","$window_id","$lib","$lib_version","$device_id","$is_server"],nn="NativeGzipValidationError",rn=e=>e.length>=2&&31===e[0]&&139===e[1],on=(e,t)=>e===st.GZipJS||t===st.GZipJS||"gzip"===t,an=e=>!(!e||"object"!=typeof e)&&"NotReadableError"===("name"in e?String(e.name):"");let ln;const cn=e=>{throw Xi(nn,`Native gzip produced invalid output: ${e}`)},un=function(){var e=Ot(function*(e,t){18>e.size&&cn("too-short");const i=new Uint8Array(yield e.slice(0,10).arrayBuffer());rn(i)&&8===i[2]||cn("invalid-header");const s=new DataView(yield e.slice(e.size-8).arrayBuffer());s.getUint32(0,!0)!==(e=>{const t=(()=>{if(ln)return ln;ln=[];for(let e=0;256>e;e++){let t=e;for(let e=0;8>e;e++)t=1&t?3988292384^t>>>1:t>>>1;ln[e]=t>>>0}return ln})();let i=4294967295;for(let s=0;e.length>s;s++)i=t[255&(i^e[s])]^i>>>8;return(4294967295^i)>>>0})(t)&&cn("invalid-crc");const n=t.length>>>0;s.getUint32(4,!0)!==n&&cn("invalid-size")});return function(t,i){return e.apply(this,arguments)}}();function dn(){return dn=Ot(function*(e,t=!0,i){try{const t=(new TextEncoder).encode(e),i=new globalThis.CompressionStream("gzip"),n=i.writable.getWriter(),r=n.write(t).then(()=>n.close()).catch((s=Ot(function*(e){try{yield n.abort(e)}catch(e){}throw e}),function(e){return s.apply(this,arguments)})),o=new Response(i.readable).blob(),[a]=yield Promise.all([o,r]);return yield un(a,t),a}catch(e){if(null==i?void 0:i.rethrow)throw e;return t&&console.error("Failed to gzip compress data",e),null}var s}),dn.apply(this,arguments)}function hn(e,t){if(null==e)return{};var i,s,n=function(e,t){if(null==e)return{};var i={};for(var s in e)if({}.hasOwnProperty.call(e,s)){if(t.includes(s))continue;i[s]=e[s]}return i}(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(s=0;r.length>s;s++)t.includes(i=r[s])||{}.propertyIsEnumerable.call(e,i)&&(n[i]=e[i])}return n}const _n="[redacted]",pn=/^[A-Za-z0-9+/\n\r]+=*$/,gn=/^[A-Za-z0-9_-]+={0,2}$/,fn=/[-_]/,vn=/^data:[^,\s]*;base64,/i,mn=/^[A-Za-z0-9+/_-]+={0,2}$/,yn=/\bph[a-z]_[A-Za-z0-9_-]{20,}\b/g,bn=/^(authorization|cookie|set-cookie|x-api-key|api[-_]?key|api[-_]?token|access[-_]?token|refresh[-_]?token|token|password|secret|client[-_]?secret|private[-_]?key)$/i,wn=/[a-z][a-z0-9+.-]{0,63}:[^\s<>"]+/gi,Sn=/[\s<>"]/,Cn=(()=>new RegExp(wn.source,"i"))(),kn=/[a-z][a-z0-9+.-]{0,63}:\/\//i,En=(()=>new RegExp(`^${kn.source}`,"i"))(),xn=(()=>new RegExp(kn.source,"gi"))(),Pn=/(^|[-_./;])(auth|token|secret|password|passwd|pwd|credential|signature|sig|key|hmac|sas|bearer|jwt|session|sessionid)([-_./;]|$)/i,In=/^(code|AWSAccessKeyId|GoogleAccessId|Policy)$/i,Fn=/[\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]/g,Tn=/[A-Za-z0-9._%+-]{1,64}@[A-Za-z0-9.-]{1,255}\.[A-Za-z]{2,24}/g,Rn=/\b(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\b/g,An=/(^|[^\w:])((?:(?:[0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4}|(?:[0-9A-Fa-f]{1,4}:){1,7}:|(?:[0-9A-Fa-f]{1,4}:){1,6}:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4}){0,5}|::(?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4}){0,6})))(?=$|[^\w:])/g,$n=/\b\d{3}[ .-]\d{2}[ .-]\d{4}\b/g,Mn=/\b\d(?:[ ./-]?\d){12,}\b/g,Ln=/\d+/g,On=/(^|[^\w+])((?:\+?1[ ./-]?)?(?:\(\d{3}\)[ ./-]?|\d{3}[ ./-])\d{3}[ ./-]\d{4})(?![\w])/g,Dn=/(^|[^\w])(\+\d{1,3}(?:[ ./()-]{0,2}\d){7,13})(?![\w])/g;function Nn(e){return function(e){return bn.test(e)}(e)||Pn.test(e)||In.test(e)}function Bn(e){return e.split("&",129).length>128}function zn(e,t,i){return Nn(e)||t.includes(";")&&function(e){return e.split(";").some(e=>Nn(e.split("=",1)[0]))}(t)?_n:Cn.test(t)?i?Vn(t,{allowNestedUrls:!1,stripPunctuation:!0}):_n:t}function Hn(e,t){const i=new URLSearchParams;let s=!1,n=!1;for(const[r,o]of new URLSearchParams(e)){const e=Gn(r),a=Gn(o);s||(s=e!==r||a!==o);const l=zn(e,a,t);s||(s=l!==a),n=Nn(e)||l!==a,i.append(e,l)}return{changed:s,lastFieldSensitive:n,serialized:i.toString()}}function Un(e,t){if(!e.includes("="))return{value:qn(e,t),lastFieldSensitive:!1};const i=Hn(e,t);return{value:i.changed?i.serialized:e,lastFieldSensitive:i.lastFieldSensitive}}function qn(e,t){return t?Vn(e,{allowNestedUrls:!1,stripPunctuation:!0}):Cn.test(e)?_n:e}function jn(e,t,i){return"#"===e?!t.fragment&&(t.fragment=!0):"?"===e&&(t.fragment?"="!==i&&!t.fragmentQuery&&(t.fragmentQuery=!0):!t.query&&(t.query=!0))}function Wn(e,t){var i;if(e.length>8192&&En.test(e))return _n;const{address:s,suffix:n}=t.stripPunctuation?function(e){let t=e.length;for(;t>0&&".,;:!?)]}'".includes(e[t-1]);)t--;return{address:e.slice(0,t),suffix:e.slice(t)}}(e):{address:e,suffix:""};let r;try{r=new URL(s)}catch(e){return _n+n}const o=r.search.slice(1),a=""!==r.hash,l=function(e){const t=e.slice(1),i=t.indexOf("?");return 0>i?{head:t,tail:null}:{head:t.slice(0,i),tail:t.slice(i+1)}}(r.hash);if(Bn(o)||Bn(l.head)||Bn(null!==(i=l.tail)&&void 0!==i?i:""))return _n+n;let c=!1;(r.username||r.password)&&(r.username=_n,r.password="",c=!0);const u=Hn(o,t.allowNestedUrls);u.changed&&(r.search=u.serialized,c=!0);const d=Un(l.head,t.allowNestedUrls),h=null===l.tail?null:(_=l.tail,d.lastFieldSensitive?{value:""===_?"":_n,lastFieldSensitive:!0}:Un(_,t.allowNestedUrls));var _;const p=null===h?d.value:`${d.value}?${h.value}`;p!==r.hash.slice(1)&&(r.hash=p,c=!0);const g=a?null!=h?h:d:u;return(c?Gn(r.toString()):s)+(g.lastFieldSensitive?"":n)}function Vn(e,t){return e.replace(wn,i=>function(e,t){const i=function(e){if(!e.includes("://"))return[];const t=[...e.matchAll(xn)].map(e=>e.index),i=[],s={query:!1,fragment:!1,fragmentQuery:!1};let n=0,r=!1,o="";for(let a=0;e.length>a&&t.length>n;a++){t[n]===a&&(a>0&&"="!==o&&i.push(a),n++);const l=e[a];jn(l,s,o)?(o=l,r=!0):r&&"=&".includes(l)&&(o=l)}return i}(e);if(0===i.length)return Wn(e,t);let s="",n=0;for(const r of i)s+=Wn(e.slice(n,r),as(as({},t),{},{stripPunctuation:!1})),n=r;return s+Wn(e.slice(n),t)}(i,as(as({},t),{},{stripPunctuation:t.stripPunctuation&&i.length!==e.length})))}function Gn(e){return e.replace(yn,_n)}function Kn(e,t){return function(e){return e.length>=10240&&(pn.test(e)||function(e){const t=vn.exec(e);if(!t)return!1;let i;try{i=decodeURIComponent(e.slice(t[0].length))}catch(e){return!1}return mn.test(i.replace(/[\r\n]/g,""))}(e)||fn.test(e)&&gn.test(e))}(e)?"[binary data redacted - not supported by PostHog MCP analytics]":function(e,t,i){const s=4*i.maxStringLength;if(e.length>s){const n=t(e.slice(0,function(e,t){let i=t;for(;i>0&&!Sn.test(e[i-1]);)i--;return i}(e,s)));if(n.length>=2*i.maxStringLength)return n+i.truncationSuffix}return t(e)}(e,e=>function(e){return Vn(e,{allowNestedUrls:!0,stripPunctuation:!0})}(function(e){let t=e.replace(Fn," ");return t=t.replace(Tn,_n),t=t.replace(Rn,_n),t=t.replace(An,`$1${_n}`),t=t.replace(Mn,Jn),t=t.replace($n,_n),t=t.replace(On,`$1${_n}`),t=t.replace(Dn,`$1${_n}`),t}(Gn(e))),t)}function Qn(e){let t=0,i=!1;for(let s=e.length-1;s>=0;s--){let n=e.charCodeAt(s)-48;if(0>n||n>9)return!1;i&&(n*=2,n>9&&(n-=9)),t+=n,i=!i}return t%10==0}function Jn(e){const t=[];for(let i=Ln.exec(e);null!==i;i=Ln.exec(e))t.push({digits:i[0],start:i.index,end:i.index+i[0].length});let i="",s=0,n=0;for(;t.length>n;){let r="",o=-1;for(let e=n;t.length>e&&(r+=t[e].digits,19>=r.length);e++)r.length>=13&&Qn(r)&&(o=e);0>o?n++:(i+=e.slice(s,t[n].start)+_n,s=t[o].end,n=o+1)}return i+e.slice(s)}const Yn={}.propertyIsEnumerable;function Xn(e,t){try{return tr(e,t,{ancestors:new WeakSet,remainingNodes:1e4},0)}catch(e){return[]}}function Zn(e,t,i,s){if(0>=i.remainingNodes)return{stringValue:ji};if(i.remainingNodes--,kt(e))return{boolValue:e};if("bigint"==typeof e)return function(e,t){const i=e.toString(),s=BigInt("9223372036854775808");return e>=s||-s>e?(null==t||t.debug(`Attribute ${i} is outside the int64 range; encoding it as a string`),{stringValue:i}):{intValue:i}}(e,t);if("number"==typeof e){if(!Number.isFinite(e))return{stringValue:String(e)};if(Number.isInteger(e)){if(Number.isSafeInteger(e))return{intValue:String(e)};if(typeof BigInt>"u")return{stringValue:String(e)};const i=BigInt(e).toString();return e>=0x8000000000000000||-0x8000000000000000>e?(null==t||t.debug(`Attribute ${i} is outside the int64 range; encoding it as a string`),{stringValue:i}):{intValue:i}}return{doubleValue:e}}if("string"==typeof e)return{stringValue:Vi(e)};if("function"==typeof e)return{stringValue:"[Function]"};if("symbol"==typeof e)return{stringValue:String(e)};if("object"==typeof e&&null!==e){if(i.ancestors.has(e))return{stringValue:"[Circular]"};if(s>=20)return{stringValue:ji};if(e instanceof Date){const t=e.getTime(),i=Number.isFinite(t)?e.toISOString():String(e);return{stringValue:"string"==typeof i?Vi(i):String(i)}}i.ancestors.add(e);try{try{const n=e.toJSON;if("function"==typeof n)return Zn(n.call(e),t,i,s+1)}catch(e){}return _t(e)?{arrayValue:{values:er(e,t,i,s+1)}}:{kvlistValue:{values:tr(e,t,i,s+1)}}}finally{i.ancestors.delete(e)}}return{stringValue:Vi(String(e))}}function er(e,t,i,s){const n=[],r=Math.min(e.length,1e3);let o=0;for(;r>o&&i.remainingNodes>0;o++)try{const r=o in e?e[o]:void 0;if(wt(r))continue;n.push(Zn(r,t,i,s))}catch(e){n.push({stringValue:Wi})}return e.length>o&&n.push({stringValue:ji}),n}function tr(e,t,i,s){const n=[];for(const r in e)if(Yn.call(e,r)){if(!r){null==t||t.debug("Dropping an attribute with an empty key");continue}if(n.length>=1e3||0>=i.remainingNodes){null==t||t.debug("Attributes truncated: the value exceeds the OTLP encoder budget");break}try{const o=e[r];if(bt(o)||vt(o))continue;n.push({key:Vi(r),value:Zn(o,t,i,s)})}catch(e){n.push({key:Vi(r),value:{stringValue:Wi}})}}return n}function ir(e,t,i){return as(as(as(as({},Gi({},e.resourceAttributes)),{},{"service.name":e.serviceName||"unknown_service"},e.environment&&{"deployment.environment":e.environment}),e.serviceVersion&&{"service.version":e.serviceVersion}),{},{"telemetry.sdk.name":t,"telemetry.sdk.version":i})}const sr=["service.name","deployment.environment","service.version","telemetry.sdk.name","telemetry.sdk.version"];function nr(e,t){const i=Gi({},e),s={};for(const e of sr)({}).hasOwnProperty.call(i,e)&&(s[e]=i[e],delete i[e]);return[...Xn(i,t),...Xn(s,t)]}const rr={darwin:"macOS",win32:"Windows",cygwin:"Windows",linux:"Linux",android:"Android",freebsd:"FreeBSD",openbsd:"OpenBSD",netbsd:"NetBSD",sunos:"SunOS",aix:"AIX",haiku:"Haiku","Mac OS X":"macOS"};const or={text:"INFO",number:9},ar={trace:{text:"TRACE",number:1},debug:{text:"DEBUG",number:5},info:or,warn:{text:"WARN",number:13},error:{text:"ERROR",number:17},fatal:{text:"FATAL",number:21}};function lr(e){try{return Vi(String(e))}catch(e){return Wi}}function cr(e,t,i,s){const n=e.level||"info",{text:r,number:o}=ar[n]||or,a=function(e=Date.now()){return String(e)+"000000"}(St(s)?s:void 0),l={};t.distinctId&&(l.posthogDistinctId=t.distinctId),t.sessionId&&(l.sessionId=t.sessionId),t.windowId&&(l["window.id"]=t.windowId),wt(t.sessionStartTimestamp)||(l.sessionStartTimestamp=String(t.sessionStartTimestamp)),wt(t.lastActivityTimestamp)||(l.lastActivityTimestamp=String(t.lastActivityTimestamp)),t.currentUrl&&(l["url.full"]=t.currentUrl),t.screenName&&(l["screen.name"]=t.screenName),t.appState&&(l["app.state"]=t.appState),t.activeFeatureFlags&&t.activeFeatureFlags.length>0&&(l.feature_flags=t.activeFeatureFlags);const c=as({},l),u=e.attributes;if(u){let e=[];try{e=Object.keys(u)}catch(t){e=[]}for(const t of e){let e;try{e=u[t]}catch(t){e=Wi}Object.defineProperty(c,t,{value:e,enumerable:!0,writable:!0,configurable:!0})}}const d={timeUnixNano:a,observedTimeUnixNano:a,severityNumber:o,severityText:r,body:{stringValue:lr(e.body)},attributes:Xn(c,i)};return e.trace_id&&(d.traceId=e.trace_id),e.span_id&&(d.spanId=e.span_id),vt(e.trace_flags)||(d.flags=e.trace_flags),d}function ur(e,t,i){return ir(e,t,i)}function dr(e,t,i,s){return{resourceLogs:[{resource:{attributes:nr(t)},scopeLogs:[{scope:{name:i,version:s},logRecords:e}]}]}}var hr=class{constructor(e){this._onFire=e,this._firesAt=0}get pending(){return!!this._timer}arm(e){this.clear(),this._firesAt=Date.now()+e,this._timer=ts(()=>{this._timer=void 0,this._onFire()},e)}armNoEarlierThan(e){this._timer&&Date.now()+e<=this._firesAt||this.arm(e)}clear(){this._timer&&(clearTimeout(this._timer),this._timer=void 0)}};function _r(){return.75+.5*Math.random()}function pr(e,t,i,s){const n=Math.min(Math.max(0,t-1),6),r=e*Math.pow(2,n);return Math.round((void 0===s?r:Math.min(r,Math.max(s,e)))*i)}var gr=class{constructor(e,t,i,s,n,r=()=>Promise.resolve(),o){var a;this._instance=e,this._config=t,this._logger=i,this._getContext=s,this._onReady=n,this._waitForStoragePersist=r,this._scopeName=o,this._flushTimer=new hr(()=>this._flushInBackground()),this._flushPromise=null,this._evictedSinceAdvance=0,this._queueGeneration=0,this._retryAfter=new Qi,this._consecutiveFlushFailures=0,this._flushJitter=1,this._intervalWindowStart=0,this._intervalLogCount=0,this._droppedWarned=!1,this._maxBufferSize=t.maxBufferSize,this._maxQueueSize=Math.max(null!==(a=t.maxQueueSize)&&void 0!==a?a:t.maxBufferSize,t.maxBufferSize),this._flushIntervalMs=t.flushIntervalMs,this._maxBatchRecordsPerPost=t.maxBatchRecordsPerPost,this._rateCapWindowMs=t.rateCapWindowMs,this._maxLogsPerInterval=t.maxLogsPerInterval}clearQueue(){this._queueGeneration++,this._instance.setPersistedProperty(it.LogsQueue,[])}reset(){this._flushTimer.clear(),this._intervalWindowStart=0,this._intervalLogCount=0,this._droppedWarned=!1,this._consecutiveFlushFailures=0,this._flushJitter=1,this._retryAfter.reset(),this._maxBatchRecordsPerPost=this._config.maxBatchRecordsPerPost}onReconnect(){this._consecutiveFlushFailures=0,this._flushJitter=1,this._retryAfter.isOpen()?this._hasQueuedRecords()&&this._armFlushTimer():this._flushInBackground()}captureLog(e,t){var i;if(this._instance.isDisabled)return;if(this._instance.optedOut)return;if(!(null==e?void 0:e.body))return;const s=this._runBeforeSend(e);if(null===s)return;if(!s.body)return void this._logger.info("Log was rejected in beforeSend function");if(!this._checkRateLimit())return;const n={record:cr(s,null!==(i=null==t?void 0:t.context)&&void 0!==i?i:this._getContext(),this._logger,null==t?void 0:t.occurredAtMs)};this._onReady(()=>this._enqueue(n))}_runBeforeSend(e){const t=this._config.beforeSend;if(!t)return e;const i=_t(t)?t:[t];let s=e;for(const e of i)try{const t=e(s);if(!t)return this._logger.info("Log was rejected in beforeSend function"),null;s=t}catch(e){return this._logger.error("Error in beforeSend function for log:",e),null}return s}_checkRateLimit(){if(void 0===this._maxLogsPerInterval)return!0;const e=Date.now(),t=e-this._intervalWindowStart;return this._rateCapWindowMs>t&&t>=0||(this._intervalWindowStart=e,this._intervalLogCount=0,this._droppedWarned=!1),this._maxLogsPerInterval>this._intervalLogCount?(this._intervalLogCount++,!0):(this._droppedWarned||(this._logger.warn(`captureLog dropping logs: exceeded ${this._maxLogsPerInterval} logs per ${this._rateCapWindowMs}ms`),this._droppedWarned=!0),!1)}flush(){var e=this;return Ot(function*(){if(!e._instance.isDisabled)return e._flushPromise||(e._flushPromise=e._flushInner().finally(()=>{e._flushPromise=null})),e._flushPromise})()}_flushInner(){var e=this;return Ot(function*(){var t;e._flushTimer.clear();let i=null!==(t=e._instance.getPersistedProperty(it.LogsQueue))&&void 0!==t?t:[];if(0===i.length)return;const s=i.length;let n=0;for(;i.length>0&&s>n;){var r,o;const t=e._queueGeneration;e._evictedSinceAdvance=0;const s=Math.min(i.length,e._maxBatchRecordsPerPost),a=i.slice(0,s),l=dr(a.map(e=>e.record),e._buildResourceAttributes(),null!==(r=e._scopeName)&&void 0!==r?r:e._instance.getLibraryId(),e._instance.getLibraryVersion()),c=yield e._instance._sendLogsBatch(l);if(e._queueGeneration!==t)return;if("too-large"===c.kind&&a.length>1)e._maxBatchRecordsPerPost=Math.max(1,Math.floor(a.length/2)),e._logger.warn(`Logs batch of size ${a.length} was too large for the ingestion endpoint, reducing batch size to ${e._maxBatchRecordsPerPost}`);else{if(e._retryAfter.record(c),e._flushTimer.pending&&e._flushTimer.arm(Math.max(e._flushIntervalMs,e._retryAfter.remainingMs())),"retry-later"===c.kind)throw c.error;if("too-large"===c.kind?e._logger.warn("Dropping a single log record with batch size 1 — the record is larger than the server cap and cannot be split further."):"ok"===c.kind&&e._config.maxBatchRecordsPerPost>e._maxBatchRecordsPerPost&&(e._maxBatchRecordsPerPost=Math.min(e._config.maxBatchRecordsPerPost,e._maxBatchRecordsPerPost+1)),yield e._persistQueueAdvance(a.length),i=null!==(o=e._instance.getPersistedProperty(it.LogsQueue))&&void 0!==o?o:[],n+=a.length,"fatal"===c.kind)throw c.error}}})()}_persistQueueAdvance(e){var t=this;return Ot(function*(){var i;const s=Math.max(0,e-t._evictedSinceAdvance),n=null!==(i=t._instance.getPersistedProperty(it.LogsQueue))&&void 0!==i?i:[];t._instance.setPersistedProperty(it.LogsQueue,n.slice(s)),yield t._waitForStoragePersist()})()}_buildResourceAttributes(){return ur(this._config,this._instance.getLibraryId(),this._instance.getLibraryVersion())}_enqueue(e){var t;if(this._instance.optedOut)return;const i=null!==(t=this._instance.getPersistedProperty(it.LogsQueue))&&void 0!==t?t:[];this._maxQueueSize>i.length||(i.shift(),this._evictedSinceAdvance++,this._logger.info("Logs queue is full, dropping oldest record.")),i.push(e),this._instance.setPersistedProperty(it.LogsQueue,i),this._maxBufferSize>i.length||this._retryAfter.isOpen()?this._armFlushTimer():this._flushInBackground()}_armFlushTimer(){this._flushTimer.pending||this._flushTimer.arm(Math.max(this._flushIntervalMs,this._retryAfter.remainingMs()))}_nextFlushDelay(){return Math.max(pr(this._flushIntervalMs,this._consecutiveFlushFailures,this._flushJitter,3e4),this._retryAfter.remainingMs())}_hasQueuedRecords(){const e=this._instance.getPersistedProperty(it.LogsQueue);return!!e&&e.length>0}shutdown(e){var t=this;return Ot(function*(){t._flushTimer.clear();const i=t.flush().catch(()=>{});void 0!==e?yield is(i,e):yield i})()}flushWithTimeout(e){var t=this;return Ot(function*(){const i=t.flush();yield is(i,e,()=>{i.catch(()=>{})})})()}_flushInBackground(){this.flush().then(()=>{this._consecutiveFlushFailures=0,this._flushJitter=1},e=>{this._consecutiveFlushFailures++,this._flushJitter=_r(),this._logger.error("PostHog logs flush failed:",e)}).finally(()=>{!this._instance.isDisabled&&this._hasQueuedRecords()&&this._flushTimer.armNoEarlierThan(this._nextFlushDelay())})}};const fr=/^[0-9a-f]+$/;function vr(e,t,i){return"string"==typeof e&&e.length===t&&e!==i&&fr.test(e)}const mr=/^([0-9a-f]{2})-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})(-.*)?$/;const yr="00",br=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function wr(e){return String(e)+"000000"}function Sr(e,t,i,s){let n="";return s&&(n=Object.keys(s).sort().map(e=>`${JSON.stringify(e)}:${JSON.stringify(s[e])}`).join(",")),`${e}\0${t}\0${null!=i?i:""}\0${n}`}var Cr=class{constructor(e,t,i){this._instance=e,this._config=t,this._logger=i,this._series=new Map,this._flushTimer=new hr(()=>this.flush().catch(e=>{this._logger.error("Metrics flush failed:",e)})),this._flushPromise=null,this._seriesCapWarned=!1,this._typeByName=new Map,this._typeCollisionWarned=new Set,this._boundsByHistogram=new Map,this._boundsConflictWarned=new Set,this._boundsCapWarned=!1,this._retryAfter=new Qi,this._consecutiveFlushFailures=0,this._flushJitter=1,this._generation=0}count(e,t=1,i){this._capture({name:e,type:"count",value:t,unit:null==i?void 0:i.unit,attributes:null==i?void 0:i.attributes})}gauge(e,t,i){this._capture({name:e,type:"gauge",value:t,unit:null==i?void 0:i.unit,attributes:null==i?void 0:i.attributes})}histogram(e,t,i){this._capture({name:e,type:"histogram",value:t,unit:null==i?void 0:i.unit,attributes:null==i?void 0:i.attributes,bounds:_t(null==i?void 0:i.bounds)?i.bounds.slice():null==i?void 0:i.bounds})}flush(){var e=this;const t=this._flushPromise,i=function(){var i=Ot(function*(){t&&(yield t.catch(()=>{})),yield e._doFlush()});return function(){return i.apply(this,arguments)}}()().finally(()=>{this._flushPromise===i&&(this._flushPromise=null)});return this._flushPromise=i,i}drainWindow(){if(0===this._series.size)return null;const e=this._series;return this._startWindow(),this._buildPayload(e)}reset(){this._generation++,this._retryAfter.reset(),this._consecutiveFlushFailures=0,this._flushJitter=1,this._flushTimer.clear(),this._flushPromise=null,this._startWindow(),this._boundsByHistogram=new Map,this._boundsCapWarned=!1}_startWindow(){this._series=new Map,this._seriesCapWarned=!1,this._typeByName=new Map,this._typeCollisionWarned=new Set,this._boundsConflictWarned=new Set}_capture(e){if(this._instance.isDisabled||this._instance.optedOut)return;const t=this._runBeforeSend(e);if(null===t)return;if(!t.name||"string"!=typeof t.name)return void this._logger.warn("Dropping metric with empty name");if("number"!=typeof t.value||!Number.isFinite(t.value))return void this._logger.warn(`Dropping metric '${t.name}': value must be a finite number`);if("count"!==t.type&&"gauge"!==t.type&&"histogram"!==t.type)return void this._logger.warn(`Dropping metric '${t.name}': unknown type '${String(t.type)}'`);if("count"===t.type&&0>t.value)return void this._logger.warn(`Dropping count '${t.name}': counters are monotonic, value must be >= 0`);let i,s;try{i=t.attributes?as({},t.attributes):void 0,s=Sr(t.type,t.name,t.unit,i)}catch(e){return void this._logger.warn(`Dropping metric '${t.name}': attributes could not be serialized`,e)}let n,r=this._series.get(s);if(!r&&!this._admitNewSeries())return;if("histogram"===t.type&&(n=this._histogramBounds(t.name,t.unit,t.bounds),!n))return;r||(r={name:t.name,type:t.type,unit:t.unit,attributes:i,windowStartMs:Date.now(),hist:n&&Er(n)},this._series.set(s,r));const o=this._typeByName.get(t.name);void 0===o?this._typeByName.set(t.name,t.type):o===t.type||this._typeCollisionWarned.has(t.name)||(this._typeCollisionWarned.add(t.name),this._logger.warn(`Metric name '${t.name}' is already used as a ${o}; recording it as a ${t.type} too will blend both series in charts. Use a distinct name.`)),this._fold(r,t.value);const a=this._activeTraceContext();a&&(r.exemplar=as(as({},a),{},{value:t.value,timeMs:Date.now()})),this._armFlushTimer()}_activeTraceContext(){try{var e,t;const i=function(e){const t=function(e){if("string"!=typeof e)return;const t=mr.exec(e.trim());if(!t)return;const[,i,s,n,r,o]=t;return"ff"===i||"00"===i&&o||!function(e){return vr(e,32,"00000000000000000000000000000000")}(s)||!function(e){return vr(e,16,"0000000000000000")}(n)?void 0:{version:i,traceId:s,spanId:n,flags:r}}(e);return t&&{traceId:t.traceId,spanId:t.spanId,flags:(i=t.flags,1&parseInt(i,16)?"01":yr)};var i}(null===(e=(t=this._instance).getActiveSpan)||void 0===e||null===(e=e.call(t))||void 0===e?void 0:e.traceparent());if(i&&"01"===i.flags)return{traceId:i.traceId,spanId:i.spanId}}catch(e){}}_admitNewSeries(){return this._config.maxSeriesPerFlush>this._series.size||(this._seriesCapWarned||(this._seriesCapWarned=!0,this._logger.warn(`Metric series cap reached (${this._config.maxSeriesPerFlush} per flush window); dropping new series until the next flush. Reduce attribute cardinality.`)),!1)}_histogramBounds(e,t,i){if(void 0!==i&&!function(e){if(!_t(e)||0===e.length)return!1;for(let t=0;e.length>t;t++)if(!Number.isFinite(e[t])||t>0&&e[t-1]>=e[t])return!1;return!0}(i))return void this._logger.warn(`Dropping histogram '${e}': bounds must be a non-empty array of finite, strictly increasing numbers`);const s=Sr("histogram",e,t,void 0),n=this._boundsByHistogram.get(s);if(n)return this._warnOnBoundsConflict(e,s,n,i),n;if(this._boundsByHistogram.size>=this._config.maxSeriesPerFlush){if(this._boundsCapWarned||(this._boundsCapWarned=!0,this._logger.warn(`Histogram bounds limit reached (${this._config.maxSeriesPerFlush} distinct histograms); new histograms that pass custom bounds are dropped. Reduce histogram name cardinality.`)),i&&!kr(i,br))return;return br}const r=i?i.slice():br;return this._boundsByHistogram.set(s,r),r}_warnOnBoundsConflict(e,t,i,s){kr(i,null!=s?s:br)||this._boundsConflictWarned.has(t)||(this._boundsConflictWarned.add(t),this._logger.warn(`Histogram '${e}' already uses the bounds [${i.join(", ")}]; samples that pass different bounds are recorded in those buckets.`))}_fold(e,t){switch(e.type){case"count":var i;e.total=(null!==(i=e.total)&&void 0!==i?i:0)+t;break;case"gauge":e.last=t;break;case"histogram":{const i=e.hist;i.count+=1,i.sum+=t,i.min=Math.min(i.min,t),i.max=Math.max(i.max,t),i.bucketCounts[function(e,t){for(let i=0;t.length>i;i++)if(t[i]>=e)return i;return t.length}(t,i.bounds)]+=1;break}}}_runBeforeSend(e){const t=this._config.beforeSend;if(!t)return e;const i=_t(t)?t:[t];let s=e;for(const e of i)try{const t=e(s);if(!t)return this._logger.info("Metric was rejected in beforeSend function"),null;s=t}catch(e){return this._logger.error("Error in beforeSend function for metric:",e),null}return s}_armFlushTimer(){this._flushTimer.pending||this._flushTimer.arm(this._nextFlushDelay())}_nextFlushDelay(){return Math.max(pr(this._config.flushIntervalMs,this._consecutiveFlushFailures,this._flushJitter,3e4),this._retryAfter.remainingMs())}_doFlush(){var e=this;return Ot(function*(){if(e._flushTimer.clear(),0===e._series.size)return;const t=e._series;e._startWindow();const i=e._generation,s=yield e._instance._sendMetricsBatch(e._buildPayload(t));if(i===e._generation)switch(e._retryAfter.record(s),"retry-later"===s.kind?(e._consecutiveFlushFailures++,e._flushJitter=_r()):(e._consecutiveFlushFailures=0,e._flushJitter=1),e._flushTimer.pending&&e._flushTimer.arm(e._nextFlushDelay()),s.kind){case"ok":return;case"retry-later":return e._mergeWindowBack(t),void e._flushTimer.armNoEarlierThan(e._nextFlushDelay());case"too-large":return void e._logger.warn("Metrics batch exceeded the server size limit and was dropped");case"fatal":return void e._logger.error("Failed to send metrics batch:",s.error)}})()}_buildPayload(e){return t=this._buildMetrics(e),i=function(e,t,i){return ir(e,t,i)}(this._config,this._instance.getLibraryId(),this._instance.getLibraryVersion()),s=this._instance.getLibraryId(),n=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:nr(i)},scopeMetrics:[{scope:{name:s,version:n},metrics:t}]}]};var t,i,s,n}_buildMetrics(e){const t=wr(Date.now()),i=new Map;for(const o of e.values()){var s;const e=Sr(o.type,o.name,o.unit,void 0);let a=i.get(e);a||(a=as({name:o.name},o.unit&&{unit:o.unit}),"count"===o.type?a.sum={aggregationTemporality:1,isMonotonic:!0,dataPoints:[]}:"gauge"===o.type?a.gauge={dataPoints:[]}:a.histogram={aggregationTemporality:1,dataPoints:[]},i.set(e,a));const l=Xn(null!==(s=o.attributes)&&void 0!==s?s:{},this._logger),c=wr(o.windowStartMs),u=xr(o.exemplar);if("count"===o.type){var n;const e=as({attributes:l,startTimeUnixNano:c,timeUnixNano:t,asDouble:null!==(n=o.total)&&void 0!==n?n:0},u);a.sum.dataPoints.push(e)}else if("gauge"===o.type){var r;const e=as({attributes:l,timeUnixNano:t,asDouble:null!==(r=o.last)&&void 0!==r?r:0},u);a.gauge.dataPoints.push(e)}else{const e=o.hist,i=as({attributes:l,startTimeUnixNano:c,timeUnixNano:t,count:e.count,sum:e.sum,min:e.min,max:e.max,bucketCounts:e.bucketCounts,explicitBounds:e.bounds},u);a.histogram.dataPoints.push(i)}}return Array.from(i.values())}_mergeWindowBack(e){for(const[n,r]of e){var t;const e=this._series.get(n);if(e)switch(e.windowStartMs=Math.min(e.windowStartMs,r.windowStartMs),e.exemplar=null!==(t=e.exemplar)&&void 0!==t?t:r.exemplar,e.type){case"count":var i,s;e.total=(null!==(i=e.total)&&void 0!==i?i:0)+(null!==(s=r.total)&&void 0!==s?s:0);break;case"gauge":break;case"histogram":{const t=e.hist,i=r.hist;t.count+=i.count,t.sum+=i.sum,t.min=Math.min(t.min,i.min),t.max=Math.max(t.max,i.max);for(let e=0;t.bucketCounts.length>e;e++)t.bucketCounts[e]+=i.bucketCounts[e];break}}else this._admitNewSeries()&&this._series.set(n,r)}}};function kr(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let i=0;e.length>i;i++)if(e[i]!==t[i])return!1;return!0}function Er(e){return{bounds:e,count:0,sum:0,min:1/0,max:-1/0,bucketCounts:new Array(e.length+1).fill(0)}}function xr(e){return e?{exemplars:[{filteredAttributes:[],timeUnixNano:wr(e.timeMs),asDouble:e.value,traceId:e.traceId,spanId:e.spanId}]}:{}}const Pr=(e,{debugEnabled:i}={})=>{const s={_log(s,...n){let r;try{r=typeof window>"u"?void 0:window}catch(e){return}r&&(t.DEBUG||r.POSTHOG_DEBUG||i)&&!vt(r.console)&&r.console&&("__rrweb_original__"in r.console[s]?r.console[s].__rrweb_original__:r.console[s])(e,...n)},debug(...e){s._log("debug",...e)},info(...e){s._log("log",...e)},warn(...e){s._log("warn",...e)},error(...e){s._log("error",...e)},critical(...t){console.error(e,...t)},uninitializedWarning(e){s.error(`You must initialize PostHog before calling ${e}`)},createLogger:(t,i)=>Pr(`${e} ${t}`,i)};return s},Ir=Pr("[PostHog.js]"),Fr=(e,t)=>Ir.createLogger(e,t);function Tr(e,t){_t(e)&&e.forEach(t)}function Rr(e,t){if(!wt(e))if(_t(e))e.forEach(t);else if((e=>e instanceof FormData)(e))e.forEach((e,i)=>t(e,i));else for(const i in e)dt.call(e,i)&&t(e[i],i)}const Ar=function(e,...t){for(const i of t)for(const t in i)void 0!==i[t]&&(e[t]=i[t]);return e};function $r(e){const t=Object.keys(e);let i=t.length;const s=new Array(i);for(;i--;)s[i]=[t[i],e[t[i]]];return s}const Mr=function(e){return function(...t){try{return e.apply(this,t)}catch(e){Ir.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),Ir.critical(e)}}},Lr=function(e){const t={};return Rr(e,function(e,i){(mt(e)&&e.length>0||St(e))&&(t[i]=e)}),t};function Or(e){const t=as({},e);for(const i of["name","message","stack","cause","errors"])try{i in e&&(t[i]=e[i])}catch(e){}return t}const Dr=["herokuapp.com","vercel.app","netlify.app"];function Nr(e){const t=null==e?void 0:e.hostname;if(!mt(t))return!1;const i=t.split(".").slice(-2).join(".");for(const e of Dr)if(i===e)return!1;return!0}function Br(e,t,i,s){const{capture:n=!1,passive:r=!0}=null!=s?s:{};null==e||e.addEventListener(t,i,{capture:n,passive:r})}function zr(e){return"ph_toolbar_internal"===e.name}const Hr=e=>{if(Ge){try{const t=e+"=",i=Ge.cookie.split(";").filter(e=>e.length);for(let e=0;i.length>e;e++){let s=i[e];for(;" "==s.charAt(0);)s=s.substring(1,s.length);if(0===s.indexOf(t))return decodeURIComponent(s.substring(t.length,s.length))}}catch(e){}return null}};var Ur=class e{constructor(e){if(this.bytes=e,16!==e.length)throw new TypeError("not 128-bit length")}static fromFieldsV7(t,i,s,n){if(!Number.isInteger(t)||!Number.isInteger(i)||!Number.isInteger(s)||!Number.isInteger(n)||0>t||0>i||0>s||0>n||t>0xffffffffffff||i>4095||s>1073741823||n>4294967295)throw new RangeError("invalid field value");const r=new Uint8Array(16);return r[0]=t/Math.pow(2,40),r[1]=t/Math.pow(2,32),r[2]=t/Math.pow(2,24),r[3]=t/Math.pow(2,16),r[4]=t/256,r[5]=t,r[6]=112|i>>>8,r[7]=i,r[8]=128|s>>>24,r[9]=s>>>16,r[10]=s>>>8,r[11]=s,r[12]=n>>>24,r[13]=n>>>16,r[14]=n>>>8,r[15]=n,new e(r)}toString(){let e="";for(let t=0;this.bytes.length>t;t++)e=e+(this.bytes[t]>>>4).toString(16)+(15&this.bytes[t]).toString(16),3!==t&&5!==t&&7!==t&&9!==t||(e+="-");if(36!==e.length)throw new Error("Invalid UUIDv7 was generated");return e}clone(){return new e(this.bytes.slice(0))}equals(e){return 0===this.compareTo(e)}compareTo(e){for(let t=0;16>t;t++){const i=this.bytes[t]-e.bytes[t];if(0!==i)return Math.sign(i)}return 0}},qr=class{generate(){const e=this.generateOrAbort();if(!vt(e))return e;{this._timestamp=0;const e=this.generateOrAbort();if(vt(e))throw new Error("Could not generate UUID after timestamp reset");return e}}generateOrAbort(){const e=(()=>{const e=Date.now();return St(e)&&isFinite(e)?Math.min(Math.max(Math.floor(e),0),0xffffffffffff):0})();if(e>this._timestamp)this._timestamp=e,this._resetCounter();else{if(this._timestamp>=e+1e4)return;this._counter++,this._counter>4398046511103&&(this._timestamp++,this._resetCounter())}return Ur.fromFieldsV7(this._timestamp,Math.trunc(this._counter/Math.pow(2,30)),this._counter&Math.pow(2,30)-1,this._random.nextUint32())}_resetCounter(){this._counter=1024*this._random.nextUint32()+(1023&this._random.nextUint32())}constructor(){this._timestamp=0,this._counter=0,this._random=new Vr}};const jr=e=>{if("u">typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(let t=0;e.length>t;t++)e[t]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return e};let Wr;var Vr=class{nextUint32(){var e;return this._buffer.length>this._cursor||((null!==(e=Wr)&&void 0!==e?e:Wr="u">typeof window&&!vt(window.crypto)&&crypto.getRandomValues?e=>{try{return crypto.getRandomValues(e)}catch(t){return jr(e)}}:jr)(this._buffer),this._cursor=0),this._buffer[this._cursor++]}constructor(){this._buffer=new Uint32Array(8),this._cursor=1/0}};let Gr;const Kr=()=>Qr().toString(),Qr=()=>(Gr||(Gr=new qr)).generate();let Jr="";const Yr=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;let Xr=null;const Zr={_is_supported(){if(!bt(Xr))return Xr;if(Xr=!1,Ge)try{const e=`__ph_cookie_support_${Kr()}`;Zr._set(e,"xyz"),Xr='"xyz"'===Hr(e),Zr._remove(e)}catch(e){Xr=!1}return Xr},_error(e){Ir.error("cookieStore error: "+e)},_get:Hr,_parse(e){let t;try{t=JSON.parse(Zr._get(e))||{}}catch(e){}return t},_set(e,t,i,s,n){if(!Ge)return!1;try{let r="",o="";const a=function(e,t){if(t){let t=function(e,t=Ge){if(Jr)return Jr;if(!t)return"";if(["localhost","127.0.0.1"].includes(e))return"";const i=e.split(".");let s=Math.min(i.length,8);const n="dmn_chk_"+Kr();for(;!Jr&&s--;){const e=i.slice(s).join("."),r=n+"=1;domain=."+e+";path=/";t.cookie=r+";max-age=3",t.cookie.includes(n)&&(t.cookie=r+";max-age=0",Jr=e)}return Jr}(e);if(!t){const i=(e=>{const t=e.match(Yr);return t?t[0]:""})(e);i!==t&&Ir.info("Warning: cookie subdomain discovery mismatch",i,t),t=i}return t?"; domain=."+t:""}return""}(Ge.location.hostname,s);if(i){const e=new Date;e.setTime(e.getTime()+864e5*i),r="; expires="+e.toUTCString()}n&&(o="; secure");const l=e+"="+encodeURIComponent(JSON.stringify(t))+r+"; SameSite=Lax; path=/"+a+o;return l.length>3686.4&&Ir.warn("cookieStore warning: large cookie, len="+l.length),Ge.cookie=l,!0}catch(e){return!1}},_remove(e,t){if((null==Ge?void 0:Ge.cookie)&&(!t||!bt(Hr(e))))try{Zr._set(e,"",-1,t)}catch(e){return}}};let eo=null;const to={_is_supported(){if(!bt(eo))return eo;let e=!0;if(vt(je))e=!1;else try{const t="__mplssupport__";to._set(t,"xyz"),'"xyz"'!==to._get(t)&&(e=!1),to._remove(t)}catch(t){e=!1}return e||Ir.error("localStorage unsupported; falling back to cookie store"),eo=e,e},_error(e){Ir.error("localStorage error: "+e)},_get(e){try{return null==je?void 0:je.localStorage.getItem(e)}catch(e){to._error(e)}return null},_parse(e){try{return JSON.parse(to._get(e))||{}}catch(e){}return null},_set(e,t){try{return null==je||je.localStorage.setItem(e,JSON.stringify(t)),!0}catch(e){to._error(e)}return!1},_remove(e){try{null==je||je.localStorage.removeItem(e)}catch(e){to._error(e)}}},io=[h,n,u,r,g,l,a,o,_],so=[I,P,ee,te,we,be,M,ge],no=e=>e+"_cpm",ro=["__proto__","constructor","prototype"],oo=e=>{if(!gt(e))return{};const t={};return Object.keys(e).forEach(i=>{-1===ro.indexOf(i)&&(t[i]=e[i])}),t},ao=(e,t=[])=>{const i={};return[...so,...t].forEach(t=>{const s=e[t];vt(s)||bt(s)||""===s||(i[t]=s)}),i},lo=e=>{let t=5381,i=2166136261;for(let s=0;e.length>s;s++){const n=e.charCodeAt(s);t=33*t^n,i=Math.imul(i^n,16777619)}return e.length.toString(36)+"."+(t>>>0).toString(36)+"."+(i>>>0).toString(36)},co=(e,t)=>({p:t,f:lo(JSON.stringify(e))}),uo=(e,t)=>{if(!t)return{properties:[],isValid:!1};try{const i=Zr._parse(no(e)),s=(null==i?void 0:i.f)===lo(t)&&_t(i.p);return{properties:s?i.p:[],isValid:s}}catch(e){return{properties:[],isValid:!1}}},ho=(e,t)=>t+"|"+(Zr._get(no(e))||""),_o={},po={_is_supported:()=>!0,_error(e){Ir.error("memoryStorage error: "+e)},_get:e=>e in _o?_o[e]:null,_parse:e=>e in _o?_o[e]:null,_set:(e,t)=>(_o[e]=t,!0),_remove(e){delete _o[e]}};let go=null;const fo={_is_supported(){if(!bt(go))return go;if(go=!0,vt(je))go=!1;else try{const e="__support__";fo._set(e,"xyz"),'"xyz"'!==fo._get(e)&&(go=!1),fo._remove(e)}catch(e){go=!1}return go},_error(e){Ir.error("sessionStorage error: ",e)},_get(e){try{return null==je?void 0:je.sessionStorage.getItem(e)}catch(e){fo._error(e)}return null},_parse(e){try{return JSON.parse(fo._get(e))||null}catch(e){}return null},_set(e,t){try{return null==je||je.sessionStorage.setItem(e,JSON.stringify(t)),!0}catch(e){fo._error(e)}return!1},_remove(e){try{null==je||je.sessionStorage.removeItem(e)}catch(e){fo._error(e)}}};var vo=class{constructor(e){this._instance=e}get _config(){return this._instance.config}get consent(){return this._getDnt()?0:this._storedConsent}isOptedOut(){return"always"===this._config.cookieless_mode||this.isRejected()||-1===this.consent&&"on_reject"===this._config.cookieless_mode}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return 0===this.consent}isRejected(){return 0===this.consent||-1===this.consent&&this._config.opt_out_capturing_by_default}optInOut(e){this._storage._set(this._storageKey,e?1:0,this._config.cookie_expiration,this._config.cross_subdomain_cookie,this._config.secure_cookie)}reset(){this._storage._remove(this._storageKey,this._config.cross_subdomain_cookie)}get _storageKey(){const{token:e,opt_out_capturing_cookie_prefix:t,consent_persistence_name:i}=this._instance.config;return i||(t?t+e:"__ph_opt_in_out_"+e)}get _storedConsent(){const e=this._storage._get(this._storageKey);return $t(e)?1:ot(Mt,e)?0:-1}get _storage(){const e=this._config.opt_out_capturing_persistence_type,t="localStorage"===e?to:Zr,i=t._is_supported()?t:po;if(!this._persistentStore||this._persistentStore!==i){this._persistentStore=i;const t="localStorage"===e?Zr:to;t._get(this._storageKey)&&(this._persistentStore._get(this._storageKey)||this.optInOut($t(t._get(this._storageKey))),t._remove(this._storageKey,this._config.cross_subdomain_cookie))}return this._persistentStore}_getDnt(){return!!this._config.respect_dnt&&[null==Ve?void 0:Ve.doNotTrack,null==Ve?void 0:Ve.msDoNotTrack,tt.doNotTrack,null==Ve?void 0:Ve.globalPrivacyControl].some(e=>$t(e))}};function mo(e,t){var i;const s=null==e||null===(i=e.config)||void 0===i?void 0:i.get_current_url;if(!pt(s))return t;try{const e=s(t);return mt(e)&&e?e:t}catch(e){return Ir.error("Error in get_current_url, falling back to window.location.href",e),t}}function yo(e){var t;return e instanceof Element&&("__POSTHOG_TOOLBAR__"===e.id||!!(null===(t=e.closest)||void 0===t?void 0:t.call(e,".toolbar-global-fade-container")))}function bo(e){return!!e&&1===e.nodeType}function wo(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function So(e){return!!e&&3===e.nodeType}function Co(e){return!!e&&11===e.nodeType&&bo(e.host)}function ko(e){return e?at(e).split(/\s+/):[]}function Eo(e,t){const i=function(e){var t;const i=typeof window>"u"?void 0:window,s=null==i||null===(t=i.location)||void 0===t?void 0:t.href;return vt(s)?void 0:mo(e,s)}(t);return!!(i&&e&&e.some(e=>i.match(e)))}function xo(e){let t="";switch(typeof e.className){case"string":t=e.className;break;case"object":t=(e.className&&"baseVal"in e.className?e.className.baseVal:null)||e.getAttribute("class")||"";break;default:t=""}return ko(t)}function Po(e){return wt(e)?null:at(e).split(/(\s+)/).filter(e=>sa(e)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Io(e){let t="";return Ko(e)&&!Qo(e)&&e.childNodes&&e.childNodes.length&&Rr(e.childNodes,function(e){var i;So(e)&&e.textContent&&(t+=null!==(i=Po(e.textContent))&&void 0!==i?i:"")}),at(t)}function Fo(e){var t;return vt(e.target)?e.srcElement||null:(null===(t=e.target)||void 0===t?void 0:t.shadowRoot)?e.composedPath()[0]||null:e.target||null}const To=["a","button","form","input","select","textarea","label"];function Ro(e,t){const i=e.matches||e.matchesSelector||e.msMatchesSelector||e.mozMatchesSelector||e.webkitMatchesSelector||e.oMatchesSelector;try{return!!i&&i.call(e,t)}catch(e){return!1}}function Ao(e,t){if(vt(t))return!0;for(const i of e)if(t.some(e=>Ro(i,e)))return!0;return!1}function $o(e){const t=e.parentNode;return!(!t||!bo(t))&&t}const Mo=[".ph-no-autocapture","[data-ph-no-autocapture]"],Lo=["next","previous","prev",">","<","→","←","›","‹","»","«","▶","◀","❯","❮"],Oo=(()=>[...Lo,"+","-","−","–"])(),Do=(()=>Oo.length+10)(),No=["button","a","input","select","textarea","label"],Bo=["button","link","tab","menuitem","option"],zo=(e,t)=>/[a-z0-9]/i.test(t)?ot(Oo,t)?new RegExp(`\\b${t}\\b`).test(e):e.includes(t):e===t,Ho=e=>ot(No,e.tagName.toLowerCase())||ot(Bo,(e.getAttribute("role")||"").toLowerCase());function Uo(e){let t="",i="";const s=e=>{bo(e)&&Ko(e)&&!Qo(e)&&(t+=` ${Io(e)}`,i=i||e.getAttribute("aria-label")||"",Rr(e.childNodes,s))};s(e),t=at(t.replace(/\s+/g," "));const n=(sa(t)?t:"").toLowerCase(),r=e.getAttribute("aria-label")||(n?"":i);return{safeText:n,ariaLabel:at(r).toLowerCase()}}const qo=[".ph-no-rageclick",".ph-no-capture"],jo=["","text","search","email","password","url","tel","number"];function Wo(e,t){if(!(typeof window>"u"?void 0:window)||Vo(e))return!1;let i,s,n;var r,o;if(kt(t)?(i=!!t&&qo,s=void 0,n=!1):(i=null!==(r=null==t?void 0:t.css_selector_ignorelist)&&void 0!==r?r:qo,s=null==t?void 0:t.content_ignorelist,n=null!==(o=null==t?void 0:t.ignore_text_selection)&&void 0!==o&&o),!1===i)return!1;if(n&&function(e){return!(!e||!bo(e))&&(!!wo(e,"textarea")||(wo(e,"input")?ot(jo,(e.getAttribute("type")||"").toLowerCase()):function(e){var t;if(e.isContentEditable)return!0;const i=null===(t=e.getAttribute)||void 0===t?void 0:t.call(e,"contenteditable");return"true"===i||""===i}(e)))}(e))return!1;const{targetElementList:a}=Go(e,!1);return!(s&&function(e,{safeText:t,ariaLabel:i}){let s;if(!0===e)s=Lo;else{if(!_t(e))return!1;if(e.length>Do)return Ir.error(`[PostHog] content_ignorelist array cannot exceed ${Do} items. Use css_selector_ignorelist for more complex matching.`),!1;s=e.map(e=>e.toLowerCase())}return s.some(e=>zo(t,e)||zo(i,e))}(s,function(e,t){for(const e of t)if(Ho(e))return Uo(e);for(const e of t){try{var i;if("pointer"!==(null===(i=window)||void 0===i?void 0:i.getComputedStyle(e).getPropertyValue("cursor")))break}catch(e){break}const t=Uo(e);if(t.safeText||t.ariaLabel)return t}return Uo(e)}(e,a))||Ao(a,i))}const Vo=e=>!e||wo(e,"html")||!bo(e),Go=(e,t)=>{const i=typeof window>"u"?void 0:window;if(!i||Vo(e))return{parentIsUsefulElement:!1,targetElementList:[]};let s=!1;const n=[e];let r=e;for(;r.parentNode&&!wo(r,"body");){if(Co(r.parentNode)){n.push(r.parentNode.host),r=r.parentNode.host;continue}const e=$o(r);if(!e)break;if(t||To.indexOf(e.tagName.toLowerCase())>-1)s=!0;else try{const t=i.getComputedStyle(e);t&&"pointer"===t.getPropertyValue("cursor")&&(s=!0)}catch(e){}n.push(e),r=e}return{parentIsUsefulElement:s,targetElementList:n}};function Ko(e){const t=new Set;let i=0;for(let s=e;s.parentNode&&!wo(s,"body");s=s.parentNode){if(i++>=1e3||t.has(s))return!1;t.add(s);const e=xo(s);if(ot(e,"ph-sensitive")||ot(e,"ph-no-capture"))return!1}if(ot(xo(e),"ph-include"))return!0;const s=e.type||"";if(mt(s))switch(s.toLowerCase()){case"hidden":case"password":return!1}const n=e.name||e.id||"";return!mt(n)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(n.replace(/[^a-zA-Z0-9]/g,""))}function Qo(e){return!!(wo(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||wo(e,"select")||wo(e,"textarea")||"true"===e.getAttribute("contenteditable"))}const Jo=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}))$"),Yo=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,Xo=[16,15,14,13],Zo=new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),ea=new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),ta=/[0-9A-Za-z_]/;function ia(e){let t=0,i=!1;for(let s=e.length-1;s>=0;s--){let n=e.charCodeAt(s)-48;i&&(n*=2,n>9&&(n-=9)),t+=n,i=!i}return t%10==0}function sa(e,t=!0){if(wt(e))return!1;if(mt(e)){if(e=at(e),t?Jo.test((e||"").replace(/[- ]/g,"")):function(e){let t;for(Yo.lastIndex=0;t=Yo.exec(e);){const e=t[2];if(!e)continue;const i=e.replace(/[- ]/g,"");for(let e=0;i.length>e;e++)for(const t of Xo){const s=e+t;if(i.length>=s){const t=i.slice(e,s);if(Jo.test(t)&&ia(t))return!0}}}return!1}(e))return!1;if(t?Zo.test(e):function(e){let t;for(ea.lastIndex=0;t=ea.exec(e);){const e=t[1],i=t[3];if(!(e&&i&&ta.test(e)&&ta.test(i)))return!0}return!1}(e))return!1}return!0}function na(e){let t=Io(e);return t=`${t} ${ra(e)}`.trim(),sa(t)?t:""}function ra(e){let t="";return e&&e.childNodes&&e.childNodes.length&&Rr(e.childNodes,function(e){var i;if(e&&"span"===(null===(i=e.tagName)||void 0===i?void 0:i.toLowerCase()))try{const i=Io(e);t=`${t} ${i}`.trim(),e.childNodes&&e.childNodes.length&&(t=`${t} ${ra(e)}`.trim())}catch(e){Ir.error("[AutoCapture]",e)}}),t}function oa(e){return e.replace(/"|\\"/g,'\\"')}function aa(e){const t=e.attr__class;if(t)return _t(t)?t:ko(t)}const la=Fr("[Dead Clicks]"),ca=()=>!0,ua=e=>{var t;const i=!!(null===(t=e.instance.persistence)||void 0===t?void 0:t.get_property(q)),s=e.instance.config.capture_dead_clicks;return kt(s)?s:!!gt(s)||i};var da=class{get lazyLoadedDeadClicksAutocapture(){return this._lazyLoadedDeadClicksAutocapture}constructor(e,t,i){this.instance=e,this.isEnabled=t,this.onCapture=i,this.startIfEnabledOrStop()}onRemoteConfig(e){if(!e.ok)return;const t=e.config;"captureDeadClicks"in t&&(this.instance.persistence&&this.instance.persistence.register({[q]:t.captureDeadClicks}),this.startIfEnabledOrStop())}startIfEnabledOrStop(){this.isEnabled(this)?this._loadScript(()=>{this._start()}):this.stop()}_loadScript(e){var t,i,s;(null===(t=tt.__PosthogExtensions__)||void 0===t?void 0:t.initDeadClicksAutocapture)?e():null===(i=tt.__PosthogExtensions__)||void 0===i||null===(s=i.loadExternalDependency)||void 0===s||s.call(i,this.instance,"dead-clicks-autocapture",t=>{t?la.error("failed to load script",t):e()})}_start(){var e;if(Ge){if(!this._lazyLoadedDeadClicksAutocapture&&(null===(e=tt.__PosthogExtensions__)||void 0===e?void 0:e.initDeadClicksAutocapture)){const e=gt(this.instance.config.capture_dead_clicks)?as({},this.instance.config.capture_dead_clicks):{};e.__onCapture=this.onCapture,this.onCapture&&(e.capture_dead_swipes=!1),this._lazyLoadedDeadClicksAutocapture=tt.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,e),this._lazyLoadedDeadClicksAutocapture.start(Ge),la.info("starting...")}}else la.error("`document` not found. Cannot start.")}stop(){this._lazyLoadedDeadClicksAutocapture&&(this._lazyLoadedDeadClicksAutocapture.stop(),this._lazyLoadedDeadClicksAutocapture=void 0,la.info("stopping..."))}};const ha=Fr("[SegmentIntegration]");function _a(e,t,i=!0){const s=e.config.segment;if(!s)return t();const{analytics:n,filterProperties:r}=(e=>pt(e.register))(o=s)?{analytics:o}:o;var o;!function(e,t,i,s){const n=t=>{const n=()=>t.anonymousId()||Kr();e.config.get_device_id=n,s&&t.id()&&(e.register({distinct_id:t.id(),$device_id:n()}),e.persistence.set_property(ge,De)),i(s?void 0:t.anonymousId()||void 0)},r=t.user();"then"in r&&pt(r.then)?r.then(n):n(r)}(e,n,i=>{n.register(((e,t,{filterProperties:i}={})=>{"undefined"!=typeof Promise&&Promise.resolve||ha.warn("This browser does not have Promise support, and can not use the segment integration");const s=(s,n)=>{if(!n)return s;const r=!!t&&s.event.anonymousId===t&&!s.event.userId;r||s.event.userId||s.event.anonymousId===e.get_distinct_id()||(ha.info("No userId set, resetting PostHog"),e.reset()),r||(t=void 0),s.event.userId&&s.event.userId!==e.get_distinct_id()&&(ha.info("UserId set, identifying with PostHog"),e.identify(s.event.userId));let o=e.calculateEventProperties(n,s.event.properties);if(!wt(i)){const e=s.event.properties||{},t={};for(const i of Object.keys(o))dt.call(e,i)||(t[i]=o[i]);const n=((e,t)=>{const i=_t(e)?e:[e];let s=as({},t);for(const e of i)try{if(s=e(s),wt(s))return null}catch(e){return ha.error("Error in Segment filterProperties:",e),null}return s})(i,t);if(wt(n))return s;o=n}return s.event.properties=Object.assign({},o,s.event.properties),s};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded(){return!0},load(){return Promise.resolve()},track(e){return s(e,e.event.event)},page(e){return s(e,ze)},identify(e){return s(e,Ue)},screen(e){return s(e,"$screen")}}})(e,i,{filterProperties:r})).then(()=>{t()},e=>{ha.error("Failed to register the Segment integration",e),t()})},i)}const pa="posthog-js";function ga(e,{organization:t,projectId:i,prefix:s,severityAllowList:n=["error"],sendExceptionsToPostHog:r=!0}={}){return o=>{var a,l,c,u,d;if("*"!==n&&!n.includes(o.level)||!e.__loaded)return o;o.tags||(o.tags={});const h=e.requestRouter.endpointFor("ui",`/project/${e.config.token}/person/${e.get_distinct_id()}`);o.tags["PostHog Person URL"]=h,e.sessionRecordingStarted()&&(o.tags["PostHog Recording URL"]=e.get_session_replay_url({withTimestamp:!0}));const _=(null===(a=o.exception)||void 0===a?void 0:a.values)||[],p=_.map(e=>as(as({},e),{},{stacktrace:e.stacktrace?as(as({},e.stacktrace),{},{type:"raw",frames:(e.stacktrace.frames||[]).map(e=>as(as({},e),{},{platform:"web:javascript"}))}):void 0})),g={$exception_message:(null===(l=_[0])||void 0===l?void 0:l.value)||o.message,$exception_type:null===(c=_[0])||void 0===c?void 0:c.type,$exception_level:o.level,$exception_list:p,$sentry_event_id:o.event_id,$sentry_exception:o.exception,$sentry_exception_message:(null===(u=_[0])||void 0===u?void 0:u.value)||o.message,$sentry_exception_type:null===(d=_[0])||void 0===d?void 0:d.type,$sentry_tags:o.tags};var f;return t&&i&&(g.$sentry_url=(s||"https://sentry.io/organizations/")+t+"/issues/?project="+i+"&query="+o.event_id),r&&(null===(f=e.exceptions)||void 0===f||f.sendExceptionEvent(g)),o}}var fa=class{constructor(e,t,i,s,n,r){this.name=pa,this.setupOnce=function(o){o(ga(e,{organization:t,projectId:i,prefix:s,severityAllowList:n,sendExceptionsToPostHog:null==r||r}))}}},va=class{constructor(e){this._onSessionIdChange=(e,t,i)=>{i&&(i.noSessionId||i.activityTimeout||i.sessionPastMaximumLength||i.crossTabAdoption)&&(Ir.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:e,changeReason:i}),this._currentPageview=void 0,this._instance.scrollManager.resetContext())},this._instance=e,this._setupSessionRotationHandler()}_setupSessionRotationHandler(){var e;this._unsubscribeSessionId=null===(e=this._instance.sessionManager)||void 0===e?void 0:e.onSessionId(this._onSessionIdChange)}destroy(){var e;null===(e=this._unsubscribeSessionId)||void 0===e||e.call(this),this._unsubscribeSessionId=void 0}doPageView(e,t){var i;const s=this._previousPageViewProperties(e,t);return this._currentPageview={pathname:null!==(i=null==je?void 0:je.location.pathname)&&void 0!==i?i:"",pageViewId:t,timestamp:e},this._instance.scrollManager.resetContext(),s}doPageLeave(e){var t;return this._previousPageViewProperties(e,null===(t=this._currentPageview)||void 0===t?void 0:t.pageViewId)}doEvent(){var e;return{$pageview_id:null===(e=this._currentPageview)||void 0===e?void 0:e.pageViewId}}_previousPageViewProperties(e,t){const i=this._currentPageview;if(!i)return{$pageview_id:t};let s={$pageview_id:t,$prev_pageview_id:i.pageViewId};const n=this._instance.scrollManager.getContext();if(n&&!this._instance.config.disable_scroll_properties){let{maxScrollHeight:e,lastScrollY:t,maxScrollY:i,maxContentHeight:r,lastContentY:o,maxContentY:a}=n;if(!(vt(e)||vt(t)||vt(i)||vt(r)||vt(o)||vt(a))){e=Math.ceil(e),t=Math.ceil(t),i=Math.ceil(i),r=Math.ceil(r),o=Math.ceil(o),a=Math.ceil(a);const n=e>1?zt(t/e,0,1,Ir):1,l=e>1?zt(i/e,0,1,Ir):1,c=r>1?zt(o/r,0,1,Ir):1,u=r>1?zt(a/r,0,1,Ir):1;s=Ar(s,{$prev_pageview_last_scroll:t,$prev_pageview_last_scroll_percentage:n,$prev_pageview_max_scroll:i,$prev_pageview_max_scroll_percentage:l,$prev_pageview_last_content:o,$prev_pageview_last_content_percentage:c,$prev_pageview_max_content:a,$prev_pageview_max_content_percentage:u})}}return i.pathname&&(s.$prev_pageview_pathname=i.pathname),i.timestamp&&(s.$prev_pageview_duration=(e.getTime()-i.timestamp.getTime())/1e3),s}};const ma=["flags","surveys"],ya={[x]:{exposure:"hidden"},[T]:{exposure:"hidden"},[R]:{exposure:"hidden"},[D]:{exposure:"hidden"},[M]:{exposure:"hidden"},[O]:{exposure:"hidden"},[y]:{exposure:"event"},[N]:{exposure:"hidden"},[W]:{exposure:"hidden"},[B]:{exposure:"event"},[z]:{exposure:"hidden"},[H]:{exposure:"event"},[U]:{exposure:"event"},[q]:{exposure:"event"},[j]:{exposure:"hidden"},[V]:{exposure:"event"},[G]:{exposure:"hidden"},[K]:{exposure:"hidden"},[ee]:{exposure:"hidden"},[te]:{exposure:"event"},[Q]:{exposure:"event",shouldSkipFromEventProperties:e=>bt(e)},[ie]:{exposure:"event"},[se]:{exposure:"event"},[ne]:{exposure:"event"},[re]:{exposure:"event"},[oe]:{exposure:"hidden"},[u]:{exposure:"hidden",storageGroup:"flags"},[n]:{exposure:"hidden",storageGroup:"flags"},[s]:{exposure:"hidden"},[r]:{exposure:"hidden",storageGroup:"flags"},[g]:{exposure:"hidden",storageGroup:"flags"},[l]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[c]:{exposure:"hidden",storageGroup:"flags"},[f]:{exposure:"hidden"},[v]:{exposure:"hidden"},[h]:{exposure:"hidden"},[d]:{exposure:"hidden"},[b]:{exposure:"hidden",storageGroup:"surveys"},[w]:{exposure:"hidden",storageGroup:"surveys",volatile:!0},[C]:{exposure:"event"},[k]:{exposure:"hidden"},[E]:{exposure:"hidden"},[le]:{exposure:"hidden"},[ce]:{exposure:"hidden"},[ue]:{exposure:"hidden"},[de]:{exposure:"event"},[he]:{exposure:"event"},[_e]:{exposure:"event"},[pe]:{exposure:"event"},[_]:{exposure:"hidden"},[p]:{exposure:"hidden"},[ae]:{exposure:"event"},[o]:{exposure:"hidden"},[a]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[ge]:{exposure:"hidden"},[fe]:{exposure:"hidden"},[ve]:{exposure:"hidden"},[me]:{exposure:"hidden"},[ye]:{exposure:"hidden"},[be]:{exposure:"hidden"},[we]:{exposure:"hidden"},[J]:{exposure:"event"},[Y]:{exposure:"event"},[X]:{exposure:"event"},[Z]:{exposure:"event"},[ke]:{exposure:"event"},[Ee]:{exposure:"event"},[xe]:{exposure:"hidden"},[Pe]:{exposure:"hidden"},[Ie]:{exposure:"hidden"},[Fe]:{exposure:"hidden"},[Te]:{exposure:"hidden"},[Re]:{exposure:"hidden"},[Ae]:{exposure:"hidden"},[$e]:{exposure:"hidden"},[Me]:{exposure:"hidden"},[Le]:{exposure:"event"}},ba=[["$posthog_sr_group_event_trigger_",{exposure:"hidden"}],["$posthog_sr_group_url_trigger_",{exposure:"hidden"}],["$posthog_sr_group_sampling_",{exposure:"hidden"}]],wa=e=>{const t=ya[e];if(t)return t;for(const[t,i]of ba)if(0===e.indexOf(t))return i};function Sa(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(e){return}}const Ca=e=>{const t=typeof document>"u"?void 0:document,i=null==t?void 0:t.createElement("a");return vt(i)?null:(i.href=e,i)},ka=()=>{try{return"u">typeof window&&!1!==window.navigator.onLine}catch(e){return!1}},Ea=(e,t)=>e>=t&&ka(),xa=(e,t,i,s)=>{if(0===e){if(ka()){const e=t+1;return e===i&&s(),e}return t}return 0},Pa=(e,t)=>{try{let i;return JSON.stringify(e,(e,t)=>{var s;return Ft(t)?(null!==(s=i)&&void 0!==s||(i=new WeakMap),i.has(t)||i.set(t,Or(t)),i.get(t)):"bigint"==typeof t?t.toString():t},t)}catch(t){return ct(e)}},Ia=function(e,t){const i=((e.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&");let s;for(let e=0;i.length>e;e++){const n=i[e].split(/=(.*)/);if(n[0]===t){s=n;break}}if(!_t(s)||2>s.length)return"";{let e=s[1].replace(/\+/g," ");try{e=decodeURIComponent(e)}catch(t){Ir.error("Skipping decoding for malformed query param: "+e)}return e}},Fa=function(e,t,i){if(!e||!t||!t.length)return e;const s=e.split(/#(.*)/),n=s[1],r=(s[0]||"").split(/\?(.*)/),o=r[1],a=r[0],l=(o||"").split("&"),c=[];for(let e=0;l.length>e;e++){const s=l[e].split("?");let n=0;for(;s.length>n&&!t.includes(s[n].split("=")[0]);)n++;c.push(s.length>n?s.slice(0,n).concat(s[n].split("=")[0]+"="+i).join("?"):l[e])}let u=a;return null!=o&&(u+="?"+c.join("&")),null!=n&&(u+="#"+n),u},Ta=function(e,t){const i=e.match(new RegExp(t+"=([^&]*)"));return i?i[1]:null},Ra=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","oppref","bfcid","irclid","_kx"],Aa=(()=>["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...Ra])(),$a="<masked>",Ma=["li_fat_id"];function La(e,t,i){if(!Ge)return{};const s=t?[...Ra,...i||[]]:[],n=Oa(Fa(Ge.URL,s,$a),e),r=function(){const e={};return Rr(Ma,function(t){const i=Hr(t);e[t]=i||null}),e}();return Ar(r,n)}function Oa(e,t){const i=Aa.concat(t||[]),s={};return Rr(i,function(t){const i=Ia(e,t);s[t]=i||null}),s}function Da(e){const t=function(e){return e?0===e.search("https?://(.*)google.([^/?]*)")?"google":0===e.search("https?://(.*)bing.com")?"bing":0===e.search("https?://(.*)yahoo.com")?"yahoo":0===e.search("https?://(.*)duckduckgo.com")?"duckduckgo":null:null}(e),i="yahoo"!=t?"q":"p",s={};if(!bt(t)){s.$search_engine=t;const e=Ge?Ia(Ge.referrer,i):"";e.length&&(s.ph_keyword=e)}return s}function Na(){return navigator.language||navigator.userLanguage}function Ba(){const e=Na();return"string"==typeof e?e.split("-")[0]:void 0}const za="$direct";function Ha(){return(null==Ge?void 0:Ge.referrer)||za}function Ua(e,t,i=!1){const s=e?[...Ra,...t||[]]:[],n=i?Zi(null==Ke?void 0:Ke.href):null==Ke?void 0:Ke.href,r=null==n?void 0:n.substring(0,1e3);return{r:Ha().substring(0,1e3),u:r?Fa(r,s,$a):void 0}}function qa(e,t=!1){var i;const{r:s,u:n}=e,r=t?Zi(n):n,o={$referrer:s,$referring_domain:null==s?void 0:s==za?za:null===(i=Ca(s))||void 0===i?void 0:i.host};if(r){o.$current_url=r;const e=Ca(r);o.$host=null==e?void 0:e.host,o.$pathname=null==e?void 0:e.pathname;const t=Oa(r);Ar(o,t)}if(s){const e=Da(s);Ar(o,e)}return o}function ja(){try{return(new Date).getTimezoneOffset()}catch(e){return}}const Wa={flags:a,surveys:w},Va=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],Ga=e=>`${e}_cookie_identity_change_pending`,Ka=e=>{let t="",i=0;for(const s of e){const e=encodeURIComponent(JSON.stringify(s).slice(1,-1)).length;if(i+e>1e3)break;t+=s,i+=e}return t},Qa="main",Ja=[u,n,r,g,l,a,c,h],Ya=e=>-1!==Ja.indexOf(e),Xa=[M,O],Za=e=>-1!==Xa.indexOf(e),el=(e,t)=>{try{return JSON.stringify(e)===JSON.stringify(t)}catch(i){return e===t}},tl=e=>{if(!e)return{};const t=JSON.parse(e);return gt(t)?t:{}},il=(e,t)=>{Rr(e,(i,s)=>{const n=wa(s);n&&"event"!==n.exposure||{}.hasOwnProperty.call(t,s)||delete e[s]})};var sl=class{constructor(e,t,i=!0,s=!e.cookieless_mode){if(this._slotState={},this._splitStorageEligible=!1,this._storesIdentityInCookie=!1,this._splitStorage=!1,this._cookieIdentityChangePending=!1,this._cookieSyncSuppressed=!1,this._pendingCrossTabFeatureFlagChanges=new Map,this._storageMigrationInProgress=!1,this._localIdentityChangePending=!1,this._crossTabFeatureFlagIdentityMismatch=!1,this._metaIdentifierChangePending=new Set,this._crossTabFeatureFlagHandlers=new Set,this._config=e,this._ownsSplitStorage=i,this.props={},this._campaign_params_url=void 0,this._name=(e=>{let t="";return e.token&&(t=e.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),e.persistence_name?"ph_"+e.persistence_name:"ph_"+t+"_posthog"})(e),this._disabled=e.disable_persistence||!!t,this._storage=this._buildStorage(e),this._splitStorage=this._resolveSplitStorage(e),this.load(s),this._markLoadedCrossTabFeatureFlagChangesPending(),e.debug&&Ir.info("Persistence loaded",e.persistence,as({},this.props)),this.update_config(e,e,t),this.save(),je){const e=()=>this.flush();Br(je,"beforeunload",e,{capture:!1}),Br(je,"pagehide",e,{capture:!1}),this._onStorage=e=>{if(this._splitStorageEligible&&(!e.storageArea||e.storageArea===(null==je?void 0:je.localStorage))&&e.key)if(e.key!==this._name){if(this._splitStorage){const t=ma.find(t=>e.key===this._groupEntryName(t));t&&this._syncCrossTabFeatureFlagProperties(e.key,t)}}else this._syncCrossTabFeatureFlagProperties(e.key,Qa)},Br(je,"storage",this._onStorage)}}markCrossTabFeatureFlagChanges(e){Object.entries(e).forEach(([e,t])=>{const i=this._pendingCrossTabFeatureFlagChanges.get(e);if(!Ya(e)||!0===i)return;if(!0===t)return void this._setCrossTabFeatureFlagChangesPending(e,!0);const s=new Set(i||[]);t.forEach(e=>s.add(e)),s.size&&this._setCrossTabFeatureFlagChangesPending(e,s)})}onCrossTabFeatureFlagChange(e){return this._crossTabFeatureFlagHandlers.add(e),()=>this._crossTabFeatureFlagHandlers.delete(e)}destroy(){this._onStorage&&je&&(je.removeEventListener("storage",this._onStorage),this._onStorage=void 0),this._crossTabFeatureFlagHandlers.clear()}_syncCrossTabFeatureFlagProperties(e,t,i=!0){if(this._disabled)return!1;let s,n;try{if(n=to._get(e),bt(n)){const e=this._slotWriteState(t);return e.storageValue=null,t!==Qa&&(e.persisted=!1),!1}s=tl(n)}catch(e){return!1}const r=t===Qa?s:to._parse(this._name);if(r&&this._hasCrossTabFeatureFlagIdentityMismatch(r))return!1;const o=this._mergeCrossTabFeatureFlagProperties(s,t,i);return t===Qa&&this._splitStorage&&!el(this._partitionProps().main,s)||this._rememberCrossTabStorageFingerprint(s,t,!0,n),o}_hasCrossTabFeatureFlagIdentityMismatch(e){const t=this.props[P],i=e[P];return!vt(t)&&!vt(i)&&t!==i}_rememberCrossTabStorageFingerprint(e,t,i,s){const n=this._slotWriteState(t);n.storageValue=s,t!==Qa&&(n.persisted=i);try{n.fingerprint=this._entryFingerprint(e,t)}catch(e){n.fingerprint=void 0}}_mergeCrossTabFeatureFlagProperties(e,t,i){let s=!1;return Ja.forEach(i=>{var n;const r=null===(n=wa(i))||void 0===n?void 0:n.storageGroup;if(t===Qa&&this._splitStorage&&r||t!==Qa&&r!==t)return;const o=i in e,a=this._mergePendingCrossTabFeatureFlagChanges(i,o?e[i]:void 0),l=this._pendingCrossTabFeatureFlagChanges.has(i)?i in this.props:o;l===i in this.props&&el(a,this.props[i])||(l?this._setProp(i,a,!1):this._deleteProp(i,!1),s=!0)}),s&&i&&this._crossTabFeatureFlagHandlers.forEach(e=>e()),s}_reconcileCrossTabFeatureFlagPropertiesBeforeWrite(){if(!this._splitStorageEligible)return!1;try{this._crossTabFeatureFlagIdentityMismatch=!1;const e=to._get(this._name),t=this._slotWriteState(Qa);let i,s=!1,n=!1;if(e!==t.storageValue)if(bt(e))t.storageValue=null;else{if(i=tl(e),this._crossTabFeatureFlagIdentityMismatch=!this._localIdentityChangePending&&this._hasCrossTabFeatureFlagIdentityMismatch(i),this._crossTabFeatureFlagIdentityMismatch)return!1;n=this._mergeCrossTabFeatureFlagProperties(i,Qa,!1),!this._splitStorage||el(this._partitionProps().main,i)?this._rememberCrossTabStorageFingerprint(i,Qa,!0,e):t.storageValue=e,s=!0}return this._splitStorage&&ma.forEach(e=>{const t=to._get(this._groupEntryName(e)),r=this._slotWriteState(e),o=i||{},a=s&&Ja.some(t=>{var i;return(null===(i=wa(t))||void 0===i?void 0:i.storageGroup)===e&&t in o});if(t===r.storageValue&&!a)return;if(bt(t))return r.storageValue=null,r.persisted=!1,void(a&&(n=this._mergeCrossTabFeatureFlagProperties(o,e,!1)||n));const l=tl(t);n=this._mergeCrossTabFeatureFlagProperties(l,e,!1)||n,this._rememberCrossTabStorageFingerprint(l,e,!0,t)}),n}catch(e){return!1}}_setCrossTabFeatureFlagChangesPending(e,t){this._pendingCrossTabFeatureFlagChanges.set(e,t);const i=wa(e);(null==i?void 0:i.volatile)||(this._slotWriteState((this._splitStorage?null==i?void 0:i.storageGroup:void 0)||Qa).fingerprint=void 0,this._markGroupDirty(e))}_markAllCrossTabFeatureFlagChangesPending(){Ja.forEach(e=>this._pendingCrossTabFeatureFlagChanges.set(e,!0))}_markLoadedCrossTabFeatureFlagChangesPending(){if(this._splitStorageEligible)try{const e=to._get(this._name),t=tl(e);this._slotWriteState(Qa).storageValue=e,Ja.forEach(e=>{var i;const s=this._splitStorage?null===(i=wa(e))||void 0===i?void 0:i.storageGroup:void 0,n=s?to._get(this._groupEntryName(s)):null;if(s){const e=this._slotWriteState(s);e.storageValue=n,e.persisted=!bt(n)}const r=s&&!bt(n)?tl(n):t;e in this.props?this._markPendingCrossTabFeatureFlagChanges(e,r[e],this.props[e]):e in r&&this._setCrossTabFeatureFlagChangesPending(e,!0)})}catch(e){}}_mergePendingCrossTabFeatureFlagChanges(e,t){const i=this._pendingCrossTabFeatureFlagChanges.get(e);if(!i)return t;if(!0===i)return this.props[e];if("$active_feature_flags"===e){const s=new Set(_t(t)?t:[]),n=new Set(_t(this.props[e])?this.props[e]:[]);return i.forEach(e=>n.has(e)?s.add(e):s.delete(e)),Array.from(s)}const s=gt(t)?as({},t):{},n=gt(this.props[e])?this.props[e]:{};return i.forEach(e=>{e in n?s[e]=n[e]:delete s[e]}),s}_markPendingCrossTabFeatureFlagChanges(e,t,i){if(!Ya(e))return;const s=this._pendingCrossTabFeatureFlagChanges.get(e);if(!0===s)return;let n=t;if(this._splitStorageEligible)try{var r;const t=this._splitStorage?null===(r=wa(e))||void 0===r?void 0:r.storageGroup:void 0,i=t?this._groupEntryName(t):this._name;n=tl(to._get(i))[e]}catch(e){}const o=new Set(s||[]);if("$active_feature_flags"===e){if(!vt(t)&&!_t(t)||!vt(n)&&!_t(n)||!_t(i))return void this._setCrossTabFeatureFlagChangesPending(e,!0);const s=new Set(t||[]),r=new Set(n||[]),a=new Set(i);new Set([...s,...a]).forEach(e=>{s.has(e)!==a.has(e)&&o.add(e)}),o.forEach(e=>{r.has(e)===a.has(e)&&o.delete(e)})}else{if(!gt(i))return void(el(n,i)?this._pendingCrossTabFeatureFlagChanges.delete(e):this._setCrossTabFeatureFlagChangesPending(e,!0));{if(!vt(t)&&!gt(t)||vt(t)&&ft(i)&&vt(n))return void this._setCrossTabFeatureFlagChangesPending(e,!0);const s=gt(t)?t:{},r=gt(n)?n:{};new Set([...Object.keys(s),...Object.keys(i)]).forEach(e=>{e in s==e in i&&el(s[e],i[e])||o.add(e)}),o.forEach(e=>{e in r==e in i&&el(r[e],i[e])&&o.delete(e)})}}o.size?this._setCrossTabFeatureFlagChangesPending(e,o):this._pendingCrossTabFeatureFlagChanges.delete(e)}_saveDebounceMs(){var e;const t=null===(e=this._config)||void 0===e?void 0:e.persistence_save_debounce_ms;return St(t)&&t>0?t:0}_rememberCurrentCookieProperties(e){if(this._config.cookieWinsOnConflict&&"localstorage+cookie"===this._config.persistence.toLowerCase())if(e)try{const t=ao(e,this._config.cookie_persisted_properties||[]),i=co(t,this._config.cookie_persisted_properties||[]),s=JSON.stringify(t)+"|"+JSON.stringify(i),n=Zr._get(this._name)||void 0;n&&ho(this._name,n)===s&&(this._lastSeenCookiePropertiesFingerprint=s,this._lastSeenMainCookieValue=n)}catch(e){}else try{const e=Zr._get(this._name)||void 0;this._lastSeenCookiePropertiesFingerprint=e?ho(this._name,e):void 0,this._lastSeenMainCookieValue=e}catch(e){}}syncCookieProperties(){return this._syncCookieProperties(this._config)}_syncCookieProperties(e,t=!1){if(this._disabled&&!t||this._cookieSyncSuppressed||!e.cookieWinsOnConflict||"localstorage+cookie"!==e.persistence.toLowerCase())return!1;let i;try{i=Zr._get(this._name)||void 0}catch(e){}if(!i||i===this._lastSeenMainCookieValue)return!1;const s=ho(this._name,i);let c;try{c=oo(JSON.parse(i))}catch(e){return!1}if((Zr._get(this._name)||void 0)!==i)return!1;this._lastSeenCookiePropertiesFingerprint=s,this._lastSeenMainCookieValue=i;const p=uo(this._name,i),f=[...so,...p.properties],v={};if(Object.keys(c).forEach(e=>{const t=c[e];(vt(t)||bt(t)||""===t||"$user_state"===e&&"anonymous"!==t&&"identified"!==t)&&(v[e]=!0,delete c[e])}),ft(c))return!1;const m="distinct_id"in c||"anonymous"===c.$user_state||"identified"===c.$user_state,y=this.props,b=y[P],w=y[ge],S=Ar({},y);[...so,...e.cookie_persisted_properties||[]].forEach(e=>{if(-1!==f.indexOf(e)&&!(e in c)&&!v[e]&&(m||"distinct_id"!==e&&"$user_state"!==e)){const t=S[e];(p.isValid||-1===so.indexOf(e)||!1!==t&&0!==t)&&delete S[e]}}),this.props=Ar(S,c),Ja.forEach(e=>{const t=e in this.props;e in y===t&&el(y[e],this.props[e])||(t?this._markPendingCrossTabFeatureFlagChanges(e,y[e],this.props[e]):this._setCrossTabFeatureFlagChangesPending(e,!0))}),!m||"$user_state"in c||"$user_state"in this.props||this._setProp(ge,Oe);const C=this.props[P],k=this.props[ge];return!m||C===b&&k===w||(this._localIdentityChangePending=!0,this._cookieIdentityChangePending=!0,fo._set(Ga(this._name),!0),this._deleteProp(h),this._deleteProp(n),this._deleteProp(u),this._deleteProp(r),this._deleteProp(g),this._deleteProp(l),this._deleteProp(a),this._deleteProp(o),this._deleteProp(_),"anonymous"!==k||"identified"!==w&&"anonymous"!==c.$user_state&&(vt(b)||C===b)||(il(this.props,c),this._deleteProp(d)),"identified"===k?this.props.$user_id=C:delete this.props.$user_id,this._deleteProp(T)),!0}consumeCookieIdentityChange(){const e=Ga(this._name),t=this._cookieIdentityChangePending||!!fo._get(e);return this._cookieIdentityChangePending=!1,t&&fo._remove(e),t}_beginCookieSyncSuppression(e=!1){return!(this._cookieSyncSuppressed||this._disabled&&!e||!this._config.cookieWinsOnConflict||"localstorage+cookie"!==this._config.persistence.toLowerCase()||(this._cookieSyncSuppressed=!0,0))}_publishSuppressedCookieSnapshot(){this._cookieSyncSuppressed&&(vt(this._pendingSaveTimer)||(clearTimeout(this._pendingSaveTimer),this._pendingSaveTimer=void 0),delete this._slotState[Qa],this._writeNow(!0))}_endCookieSyncSuppression(e=!0){if(this._cookieSyncSuppressed)try{e?this._publishSuppressedCookieSnapshot():vt(this._pendingSaveTimer)||(clearTimeout(this._pendingSaveTimer),this._pendingSaveTimer=void 0)}finally{this._cookieSyncSuppressed=!1}}isDisabled(){return!!this._disabled}_buildStorage(e){-1===Va.indexOf(e.persistence.toLowerCase())&&(Ir.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");const t=((e=[],t=!1,i=()=>!1)=>{const s=[...so,...e];return as(as({},to),{},{_rawText(e){return[Zr._get(e),Zr._get(no(e)),to._get(e)].join("\0")},_parse(e){try{let r,o={};try{r=Zr._get(e)||void 0,o=r?oo(JSON.parse(r)):{}}catch(e){}const a=JSON.parse(to._get(e)||"{}");let l;if(t){const t=uo(e,r),i=[...so,...t.properties],c={};Object.keys(o).forEach(e=>{const t=o[e];bt(t)||""===t||"$user_state"===e&&"anonymous"!==t&&"identified"!==t||(c[e]=t)});const u="distinct_id"in c||"anonymous"===c.$user_state||"identified"===c.$user_state;if(Object.keys(c).length>0){var n;const e=a[P],r=null!==(n=a.$user_state)&&void 0!==n?n:Oe;s.forEach(e=>{if(-1!==i.indexOf(e)&&!(e in o)&&(u||"distinct_id"!==e&&"$user_state"!==e)){const i=a[e];(t.isValid||-1===so.indexOf(e)||!1!==i&&0!==i)&&delete a[e]}}),!u||"$user_state"in o||"$user_state"in a||(a[ge]=Oe),!u||("distinct_id"in c?c[P]:a[P])===e&&("$user_state"in c?c[ge]:a[ge])===r||(io.forEach(e=>delete a[e]),"identified"===c.$user_state&&"distinct_id"in c?a.$user_id=c[P]:delete a.$user_id,"identified"!==c.$user_state&&(delete a[ae],delete a[d]),delete a.__alias)}l=Ar(a,c)}else l=Ar(o,a);return i()||to._set(e,l),l}catch(e){}return null},_set(i,s,n,r,o,a){const l=to._set(i,s,void 0,void 0,a);try{const c=ao(s,e);if(Object.keys(c).length){if(t){const t=no(i),u=co(c,e);if(Zr._set(t,u,n,r,o,a),Zr._get(t)!==JSON.stringify(u)){Zr._remove(t,r);const e=ao(s);return Zr._set(i,e,n,r,o,a),l}}Zr._set(i,c,n,r,o,a)}}catch(e){to._error(e)}return l},_remove(e,t){try{null==je||je.localStorage.removeItem(e),Zr._remove(e,t),Zr._remove(no(e),t)}catch(e){to._error(e)}}})})(e.cookie_persisted_properties||[],e.cookieWinsOnConflict,()=>!!this._disabled);let i,s=!1,n=!1;const r=e.persistence.toLowerCase();return"localstorage"===r&&to._is_supported()?(i=to,n=!0):"localstorage+cookie"===r&&t._is_supported()?(i=t,n=!0,s=!0):"sessionstorage"===r&&fo._is_supported()?i=fo:"memory"===r?i=po:"cookie"===r&&Zr._is_supported()?(i=Zr,s=!0):t._is_supported()?(i=t,n=!0,s=!0):Zr._is_supported()?(i=Zr,s=!0):i=po,this._splitStorageEligible=n,this._storesIdentityInCookie=s,i}_groupEntryName(e){return`${this._name}__${e}`}_resolveSplitStorage(e){return this._splitStorageEligible&&!!e.split_storage}properties(){const e={};return Rr(this.props,(t,i)=>{const s=wa(i);if(!s||"event"===s.exposure){var n;if(null==s||null===(n=s.shouldSkipFromEventProperties)||void 0===n?void 0:n.call(s,t))return;e[i]=t}}),e}load(e=!1){if(this._disabled&&!e)return;const t=this._config.cookieWinsOnConflict&&"localstorage+cookie"===this._config.persistence.toLowerCase(),i=t?to._parse(this._name):null;let s={};if(t)try{s=oo(Zr._parse(this._name)),Rr(s,(e,t)=>{(vt(e)||bt(e)||""===e)&&delete s[t]})}catch(e){}const n=this._storage._parse(this._name);if(n&&(this.props=Ar({},n)),this._splitStorage&&this._loadGroupEntries(),t&&n){var r,o;const e=null==i?void 0:i[P],t=null!==(r=null==i?void 0:i.$user_state)&&void 0!==r?r:Oe,a=n[P],l=null!==(o=n.$user_state)&&void 0!==o?o:Oe;if(a!==e||l!==t){this._cookieIdentityChangePending=!0,this._disabled||fo._set(Ga(this._name),!0);const i=Ar({},this.props);io.forEach(e=>delete i[e]),"anonymous"!==l||"identified"!==t&&"anonymous"!==s.$user_state&&(vt(e)||a===e)||(il(i,s),delete i[d]),this.props=i;const n=new Set;io.forEach(e=>{var t;const i=null===(t=wa(e))||void 0===t?void 0:t.storageGroup;i&&n.add(i)}),n.forEach(e=>{if(this._disabled)return;const t={};Rr(this.props,(i,s)=>{var n;(null===(n=wa(s))||void 0===n?void 0:n.storageGroup)===e&&(t[s]=i)}),ft(t)?(to._remove(this._groupEntryName(e)),this._slotState[e]={}):to._set(this._groupEntryName(e),t)&&(this._slotState[e]={persisted:!0,fingerprint:this._entryFingerprint(t,e)})})}}fo._get(Ga(this._name))&&(this._cookieIdentityChangePending=!0)}_loadGroupEntries(){for(const e of ma){const t=to._parse(this._groupEntryName(e));if(t&&!ft(t)){const i=this._slotWriteState(e);i.persisted=!0,this._mainCarriesGroupKey(e)||(i.fingerprint=this._entryFingerprint(t,e)),this._groupEntryIsStale(e,t)||Ar(this.props,t)}}}_mainCarriesGroupKey(e){return Object.keys(this.props).some(t=>{var i;return(null===(i=wa(t))||void 0===i?void 0:i.storageGroup)===e})}_groupEntryIsStale(e,t){const i=Wa[e];if(!i)return!1;const s=t[i],n=this.props[i];return St(s)&&St(n)&&n>s}refreshKey(e){this._refreshKeys([e])}_refreshKeys(e){if(this._disabled)return;let t,i=!1;const s=()=>(i||(t=this._storage._parse(this._name),i=!0),t);e.forEach(e=>{var t;if(this._metaIdentifierChangePending.has(e))return;const i=this._splitStorage?null===(t=wa(e))||void 0===t?void 0:t.storageGroup:void 0,n=i?to._parse(this._groupEntryName(i)):s();if(n&&e in n)this._setProp(e,n[e],!1);else{if(i){const t=s();if(t&&e in t)return void this._setProp(e,t[e],!1)}this._deleteProp(e,!1)}})}refreshMetaIdentifiers(){if(this._disabled)return;const e=this._storageSnapshot();(vt(e)||e!==this._metaIdentifierStorageSnapshot)&&(this._refreshKeys(Xa),this._rememberMetaIdentifierStorageSnapshot(e))}_rememberMetaIdentifierStorageSnapshot(e=this._storageSnapshot()){this._metaIdentifierStorageSnapshot=0===this._metaIdentifierChangePending.size?e:void 0}_storageSnapshot(){const e=this._storage._rawText?this._storage._rawText(this._name):this._storage._get(this._name);return mt(e)?e:void 0}save(){if(this._disabled)return;const e=this._saveDebounceMs();e>0?vt(this._pendingSaveTimer)&&(this._pendingSaveTimer=setTimeout(()=>{this._pendingSaveTimer=void 0,this._writeNow()},e)):this._writeNow()}flush(){vt(this._pendingSaveTimer)||(clearTimeout(this._pendingSaveTimer),this._pendingSaveTimer=void 0,this._writeNow())}_writeNow(e=!1){if(this._disabled||this._cookieSyncSuppressed&&!e)return;e||(this.syncCookieProperties(),this._config.cookieWinsOnConflict&&"localstorage+cookie"===this._config.persistence.toLowerCase()||this.refreshMetaIdentifiers());const t=!e&&!this._storageMigrationInProgress;t||(this._crossTabFeatureFlagIdentityMismatch=!1);const i=!!t&&this._reconcileCrossTabFeatureFlagPropertiesBeforeWrite();if(this._crossTabFeatureFlagIdentityMismatch)return void(this._config.debug&&Ir.warn("skipping persistence write because storage belongs to a different distinct ID"));if(this._splitStorage)return this._writeNowSplit(),void(i&&this._crossTabFeatureFlagHandlers.forEach(e=>e()));const s=this._writeEntry(this._storage,this._name,this.props,Qa);"written"===s&&this._rememberCurrentCookieProperties(this.props),"failed"!==s&&(this._pendingCrossTabFeatureFlagChanges.clear(),this._localIdentityChangePending=!1,this._metaIdentifierChangePending.clear()),"written"===s&&this._rememberMetaIdentifierStorageSnapshot(),i&&this._crossTabFeatureFlagHandlers.forEach(e=>e())}_writeNowSplit(){const{main:e,groups:t}=this._partitionProps(),i=this._writeEntry(this._storage,this._name,e,Qa);"written"===i&&this._rememberCurrentCookieProperties(e),"failed"!==i&&(this._localIdentityChangePending=!1,this._metaIdentifierChangePending.clear(),Ja.forEach(e=>{var t;(null===(t=wa(e))||void 0===t?void 0:t.storageGroup)||this._pendingCrossTabFeatureFlagChanges.delete(e)})),"written"===i&&this._rememberMetaIdentifierStorageSnapshot();for(const e of ma){var s;const i=t[e];if(ft(i)&&!(null===(s=this._slotState[e])||void 0===s?void 0:s.persisted)){Ja.forEach(t=>{var i;(null===(i=wa(t))||void 0===i?void 0:i.storageGroup)===e&&this._pendingCrossTabFeatureFlagChanges.delete(t)});continue}const n=this._writeEntry(to,this._groupEntryName(e),i,e);"failed"!==n&&Ja.forEach(t=>{const i=wa(t);(null==i?void 0:i.storageGroup)!==e||"written"!==n&&i.volatile||this._pendingCrossTabFeatureFlagChanges.delete(t)})}}_partitionProps(){const e={},t={flags:{},surveys:{}};return Rr(this.props,(i,s)=>{var n;const r=null===(n=wa(s))||void 0===n?void 0:n.storageGroup;r?t[r][s]=i:e[s]=i}),{main:e,groups:t}}_entryFingerprint(e,t){if(t===Qa)return JSON.stringify(e)+"|"+this._expire_days+"|"+this._cross_subdomain+"|"+this._secure;const i={};return Rr(e,(e,t)=>{var s;i[t]=(null===(s=wa(t))||void 0===s?void 0:s.volatile)?"__volatile__":e}),JSON.stringify(i)}_writeEntry(e,t,i,s){const n=this._slotWriteState(s);if(s!==Qa&&!n.dirty&&!vt(n.fingerprint))return"skipped";let r;try{if(r=this._entryFingerprint(i,s),r===n.fingerprint)return n.dirty=!1,"skipped"}catch(e){r=void 0}return e._set(t,i,this._expire_days,this._cross_subdomain,this._secure,this._config.debug)?(n.dirty=!1,s!==Qa&&(n.persisted=!0),vt(r)||(n.fingerprint=r),this._splitStorageEligible&&(n.storageValue=to._get(t)),"written"):(this._config.debug&&Ir.warn(`failed to persist storage entry "${t}"; will retry on next save`),"failed")}remove({keepGroupEntries:e=!1}={}){if(this._markAllCrossTabFeatureFlagChangesPending(),vt(this._pendingSaveTimer)||(clearTimeout(this._pendingSaveTimer),this._pendingSaveTimer=void 0),this._storage._remove(this._name,!1),this._storage._remove(this._name,!0),!e&&this._ownsSplitStorage)for(const e of ma)to._remove(this._groupEntryName(e));e?delete this._slotState[Qa]:this._slotState={},this._lastSeenCookiePropertiesFingerprint=void 0,this._lastSeenMainCookieValue=void 0}clear(){this.remove(),this.props={}}register_once(e,t,i){if(gt(e)){this.syncCookieProperties(),vt(t)&&(t="None"),this._expire_days=vt(i)?this._default_expiry:i;let s=!1;if(Rr(e,(e,i)=>{this.props.hasOwnProperty(i)&&this.props[i]!==t||(this._setProp(i,e),s=!0)}),s)return this.save(),!0}return!1}register(e,t){if(gt(e)){this.syncCookieProperties(),this._expire_days=vt(t)?this._default_expiry:t;let i=!1;if(Rr(e,(t,s)=>{e.hasOwnProperty(s)&&(this.props[s]!==t||gt(t)||_t(t))&&(this._setProp(s,t),i=!0)}),i)return this.save(),!0}return!1}unregister(e){this.syncCookieProperties();const t="string"==typeof e?[e]:e;let i=!1;for(const e of t)e in this.props&&(this._deleteProp(e),i=!0);i&&this.save()}update_campaign_params(){const e=null==Ge?void 0:Ge.URL;if(e===this._campaign_params_url)return;const t=La(this._config.custom_campaign_params,this._config.mask_personal_data_properties,this._config.custom_personal_data_properties),i=!ft(Lr(t));return i&&this.register(t),this._campaign_params_url=e,i?t:void 0}update_search_keyword(){this.register(function(){const e=null==Ge?void 0:Ge.referrer;return e?Da(e):{}}())}update_referrer_info(){var e;this.register_once({$referrer:Ha(),$referring_domain:(null==Ge?void 0:Ge.referrer)&&(null===(e=Ca(Ge.referrer))||void 0===e?void 0:e.host)||za},void 0)}set_initial_person_info(){if(this.props.$initial_campaign_params||this.props.$initial_referrer_info)return;const e=Ua(this._config.mask_personal_data_properties,this._config.custom_personal_data_properties,this._config.disable_capture_url_hashes);this.register_once({[be]:this._storesIdentityInCookie?{r:Ka(e.r),u:e.u?Ka(e.u):void 0}:e},void 0)}get_initial_props(){const e={};Rr([ye,me],t=>{const i=this.props[t];i&&Rr(i,function(t,i){e["$initial_"+lt(i)]=t})});const t=this.props[be];if(t){const i=function(e,t=!1){const i=qa(e,t),s={};return Rr(i,function(e,t){s[`$initial_${lt(t)}`]=e}),s}(t,this._config.disable_capture_url_hashes);Ar(e,i)}return e}safe_merge(e){return Rr(this.props,function(t,i){i in e||(e[i]=t)}),e}update_config(e,t,i){const s=e.persistence!==t.persistence,n=!((e,t)=>{if(e.length!==t.length)return!1;const i=[...e].sort(),s=[...t].sort();return i.every((e,t)=>e===s[t])})(e.cookie_persisted_properties||[],t.cookie_persisted_properties||[]),r=s||n,o=e.cookieWinsOnConflict!==t.cookieWinsOnConflict,a=e.disable_persistence||!!i,l=!!this._disabled&&!a;a||this._syncCookieProperties(t,l),this._config=e,!a&&(s||n||o)&&(this._lastSeenCookiePropertiesFingerprint=void 0,this._lastSeenMainCookieValue=void 0,this._syncCookieProperties(as(as({},e),{},{cookie_persisted_properties:t.cookie_persisted_properties}),l));const c=r||o?this._buildStorage(e):this._storage;this._truncateExistingPersonInfoForCookie();const u=this._resolveSplitStorage(e),d=r||u!==this._splitStorage,h=!a&&(d||e.cross_subdomain_cookie!==this._cross_subdomain||e.secure_cookie!==this._secure)&&this._beginCookieSyncSuppression(l);this._storageMigrationInProgress=d;try{if(this._default_expiry=this._expire_days=e.cookie_expiration,this.set_disabled(a),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),d){const e=this.props;this.clear(),this._storage=c,this._splitStorage=u,this.props=e,this.save()}else o&&(this._storage=c,a||(delete this._slotState[Qa],this._writeNow()))}finally{this._storageMigrationInProgress=!1,h&&this._endCookieSyncSuppression()}}_truncateExistingPersonInfoForCookie(){const e=this.props[be];if(!this._storesIdentityInCookie||!gt(e)||"string"!=typeof e.r)return;const t=Ka(e.r),i="string"==typeof e.u?Ka(e.u):e.u;t===e.r&&i===e.u||this._setProp(be,as(as({},e),{},{r:t,u:i}))}set_disabled(e){this._disabled=e,this._disabled?this.remove():this.save()}set_cross_subdomain(e){e!==this._cross_subdomain&&(this._cross_subdomain=e,this.remove({keepGroupEntries:!0}),this.save())}set_secure(e){e!==this._secure&&(this._secure=e,this.remove({keepGroupEntries:!0}),this.save())}set_event_timer(e,t){const i=this.props.__timers||{};i[e]=t,this._setProp(D,i),this.save()}remove_event_timer(e){const t=this.props.__timers||{},i=t[e];return vt(i)||(delete t[e],this._setProp(D,t),this.save()),i}get_property(e){return this.props[e]}set_property(e,t){this._setProp(e,t),this.save()}_setProp(e,t,i=!0){var s;const n=this.props[e];this.props[e]=t,i&&("distinct_id"!==e&&"$user_state"!==e||n===t||(this._localIdentityChangePending=!0),Za(e)&&!el(n,t)&&this._metaIdentifierChangePending.add(e),this._markPendingCrossTabFeatureFlagChanges(e,n,t),(null===(s=wa(e))||void 0===s?void 0:s.volatile)||this._markGroupDirty(e))}_deleteProp(e,t=!0){delete this.props[e],t&&(Ya(e)&&this._setCrossTabFeatureFlagChangesPending(e,!0),Za(e)&&this._metaIdentifierChangePending.add(e),this._markGroupDirty(e))}_markGroupDirty(e){var t;const i=null===(t=wa(e))||void 0===t?void 0:t.storageGroup;i&&(this._slotWriteState(i).dirty=!0)}_slotWriteState(e){return this._slotState[e]||(this._slotState[e]={})}};const nl="gzip-js",rl="base64",ol="events",al="cancelEvents",ll="survey shown",cl="survey dismissed",ul="survey sent",dl="$survey_last_seen_date",hl="popover";function _l(e){let t=!0;return{dispose(){if(t){t=!1;const i=e();i&&pt(i.then)&&i.then(void 0,()=>{})}}}}const pl=Fr("[RateLimiter]");var gl=class{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=e=>{const t=e.text;if(t&&t.length)try{(JSON.parse(t).quota_limited||[]).forEach(e=>{pl.info(`${e||"events"} is quota limited.`),this.serverLimits[e]=(new Date).getTime()+6e4})}catch(e){return void pl.warn(`could not rate limit - continuing. Error: "${null==e?void 0:e.message}"`,{text:t})}},this.instance=e,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var e;return(null===(e=this.instance.config.rate_limiting)||void 0===e?void 0:e.events_per_second)||10}get captureEventsBurstLimit(){var e;return Math.max((null===(e=this.instance.config.rate_limiting)||void 0===e?void 0:e.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}get isClientRateLimited(){return 1>this._refilledBucket().tokens}clientRateLimitContext(e=!1){var t;const i=this._refilledBucket(),s=1>i.tokens;if(s||e||(i.tokens=Math.max(0,i.tokens-1)),s&&!e){const e=(St(i.dropped)?i.dropped:0)+1;i.dropped=e,!this.lastEventRateLimited&&this._captureWarning(e)&&(i.dropped=0)}return this.lastEventRateLimited=s,null===(t=this.instance.persistence)||void 0===t||t.set_property("$capture_rate_limit",i),{isRateLimited:s,remainingTokens:i.tokens}}_refilledBucket(){var e;const{captureEventsBurstLimit:t,captureEventsPerSecond:i}=this,s=(new Date).getTime(),n=null===(e=this.instance.persistence)||void 0===e?void 0:e.get_property(ve),r=n?as({},n):{tokens:t,last:s};return r.tokens+=Math.max(0,s-r.last)/1e3*i,r.last=Math.max(r.last,s),r.tokens>t&&(r.tokens=t),r}_isPropertyAllowed(e){const t=this.instance.config.property_denylist;return!_t(t)||!t.includes(e)}_triggeringPage(){var e;if(this._isPropertyAllowed("$current_url")&&this._isPropertyAllowed("$pathname")&&(null==Ke?void 0:Ke.pathname))return`${null!==(e=Ke.origin)&&void 0!==e?e:""}${Ke.pathname}`}_captureWarning(e){var t,i;const{captureEventsBurstLimit:s,captureEventsPerSecond:n}=this,r=this._triggeringPage(),o=this._isPropertyAllowed("$session_id")?null===(t=(i=this.instance).get_session_id)||void 0===t?void 0:t.call(i):void 0,a=[`${e} event(s) dropped since the last warning`,r?`triggered on ${r}`: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 ${n} events per second and ${s} events burst limit.`},{skip_client_rate_limiting:!0})}isServerRateLimited(e){const t=this.serverLimits[e||"events"]||!1;return!1!==t&&(new Date).getTime()<t}};const fl=Fr("[RemoteConfig]");var vl=class{constructor(e){this._instance=e}get remoteConfig(){var e;return null===(e=tt._POSTHOG_REMOTE_CONFIG)||void 0===e||null===(e=e[this._instance.config.token])||void 0===e?void 0:e.config}_loadRemoteConfigJs(e){var t,i,s;(null===(t=tt.__PosthogExtensions__)||void 0===t?void 0:t.loadExternalDependency)?null===(i=tt.__PosthogExtensions__)||void 0===i||null===(s=i.loadExternalDependency)||void 0===s||s.call(i,this._instance,"remote-config",()=>e(this.remoteConfig)):e()}_loadRemoteConfigJSON(e){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets",`/array/${this._instance.config.token}/config`),callback:e})}load(){try{if(this.remoteConfig)return fl.info("Using preloaded remote config",this.remoteConfig),void this._onRemoteConfig(this.remoteConfig);if(this._instance._shouldDisableFlags())return void fl.warn("Remote config is disabled. Falling back to local config.");this._loadRemoteConfigJs(e=>{if(!e)return fl.info("No config found after loading remote JS config. Falling back to JSON."),void this._loadRemoteConfigJSON(e=>{this._onRemoteConfig(e.json,e)});this._onRemoteConfig(e)})}catch(e){fl.error("Error loading remote config",e),this._onRemoteConfig()}}_onRemoteConfig(e,t){!e&&t&&(0===t.statusCode?t.error||fl.warn("Failed to fetch remote config from PostHog."):fl.error("Failed to fetch remote config from PostHog."));try{this._instance._onRemoteConfig(e?{ok:!0,config:e}:{ok:!1})}catch(e){fl.error("Error applying remote config",e)}if(!1!==(null==e?void 0:e.hasFeatureFlags)&&!this._instance.config.advanced_disable_feature_flags_on_first_load)try{var i;null===(i=this._instance.featureFlags)||void 0===i||i.ensureFlagsLoaded()}catch(e){fl.error("Error loading feature flags",e)}}},ml=Uint8Array,yl=Uint16Array,bl=Uint32Array,wl=new ml([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]),Sl=new ml([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]),Cl=new ml([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),kl=function(e,t){for(var i=new yl(31),s=0;31>s;++s)i[s]=t+=1<<e[s-1];var n=new bl(i[30]);for(s=1;30>s;++s)for(var r=i[s];i[s+1]>r;++r)n[r]=r-i[s]<<5|s;return[i,n]},El=kl(wl,2),xl=El[1];El[0][28]=258,xl[258]=28;for(var Pl=kl(Sl,0)[1],Il=new yl(32768),Fl=0;32768>Fl;++Fl){var Tl=(43690&Fl)>>>1|(21845&Fl)<<1;Il[Fl]=((65280&(Tl=(61680&(Tl=(52428&Tl)>>>2|(13107&Tl)<<2))>>>4|(3855&Tl)<<4))>>>8|(255&Tl)<<8)>>>1}var Rl=function(e,t,i){for(var s=e.length,n=0,r=new yl(t);s>n;++n)++r[e[n]-1];var o,a=new yl(t);for(n=0;t>n;++n)a[n]=a[n-1]+r[n-1]<<1;if(i){o=new yl(1<<t);var l=15-t;for(n=0;s>n;++n)if(e[n])for(var c=n<<4|e[n],u=t-e[n],d=a[e[n]-1]++<<u,h=d|(1<<u)-1;h>=d;++d)o[Il[d]>>>l]=c}else for(o=new yl(s),n=0;s>n;++n)o[n]=Il[a[e[n]-1]++]>>>15-e[n];return o},Al=new ml(288);for(Fl=0;144>Fl;++Fl)Al[Fl]=8;for(Fl=144;256>Fl;++Fl)Al[Fl]=9;for(Fl=256;280>Fl;++Fl)Al[Fl]=7;for(Fl=280;288>Fl;++Fl)Al[Fl]=8;var $l=new ml(32);for(Fl=0;32>Fl;++Fl)$l[Fl]=5;var Ml=Rl(Al,9,0),Ll=Rl($l,5,0),Ol=function(e){return(e/8|0)+(7&e&&1)},Dl=function(e,t,i){(null==t||0>t)&&(t=0),(null==i||i>e.length)&&(i=e.length);var s=new(e instanceof yl?yl:e instanceof bl?bl:ml)(i-t);return s.set(e.subarray(t,i)),s},Nl=function(e,t,i){var s=t/8|0;e[s]|=i<<=7&t,e[s+1]|=i>>>8},Bl=function(e,t,i){var s=t/8|0;e[s]|=i<<=7&t,e[s+1]|=i>>>8,e[s+2]|=i>>>16},zl=function(e,t){for(var i=[],s=0;e.length>s;++s)e[s]&&i.push({s:s,f:e[s]});var n=i.length,r=i.slice();if(!n)return[new ml(0),0];if(1==n){var o=new ml(i[0].s+1);return o[i[0].s]=1,[o,1]}i.sort(function(e,t){return e.f-t.f}),i.push({s:-1,f:25001});var a=i[0],l=i[1],c=0,u=1,d=2;for(i[0]={s:-1,f:a.f+l.f,l:a,r:l};u!=n-1;)a=i[i[d].f>i[c].f?c++:d++],l=i[c!=u&&i[d].f>i[c].f?c++:d++],i[u++]={s:-1,f:a.f+l.f,l:a,r:l};var h=r[0].s;for(s=1;n>s;++s)r[s].s>h&&(h=r[s].s);var _=new yl(h+1),p=Hl(i[u-1],_,0);if(p>t){s=0;var g=0,f=p-t,v=1<<f;for(r.sort(function(e,t){return _[t.s]-_[e.s]||e.f-t.f});n>s;++s){var m=r[s].s;if(t>=_[m])break;g+=v-(1<<p-_[m]),_[m]=t}for(g>>>=f;g>0;){var y=r[s].s;t>_[y]?g-=1<<t-_[y]++-1:++s}for(;s>=0&&g;--s){var b=r[s].s;_[b]==t&&(--_[b],++g)}p=t}return[new ml(_),p]},Hl=function(e,t,i){return-1==e.s?Math.max(Hl(e.l,t,i+1),Hl(e.r,t,i+1)):t[e.s]=i},Ul=function(e){for(var t=e.length;t&&!e[--t];);for(var i=new yl(++t),s=0,n=e[0],r=1,o=function(e){i[s++]=e},a=1;t>=a;++a)if(e[a]==n&&a!=t)++r;else{if(!n&&r>2){for(;r>138;r-=138)o(32754);r>2&&(o(r>10?r-11<<5|28690:r-3<<5|12305),r=0)}else if(r>3){for(o(n),--r;r>6;r-=6)o(8304);r>2&&(o(r-3<<5|8208),r=0)}for(;r--;)o(n);r=1,n=e[a]}return[i.subarray(0,s),t]},ql=function(e,t){for(var i=0,s=0;t.length>s;++s)i+=e[s]*t[s];return i},jl=function(e,t,i){var s=i.length,n=Ol(t+2);e[n]=255&s,e[n+1]=s>>>8,e[n+2]=255^e[n],e[n+3]=255^e[n+1];for(var r=0;s>r;++r)e[n+r+4]=i[r];return 8*(n+4+s)},Wl=function(e,t,i,s,n,r,o,a,l,c,u){Nl(t,u++,i),++n[256];for(var d=zl(n,15),h=d[0],_=d[1],p=zl(r,15),g=p[0],f=p[1],v=Ul(h),m=v[0],y=v[1],b=Ul(g),w=b[0],S=b[1],C=new yl(19),k=0;m.length>k;++k)C[31&m[k]]++;for(k=0;w.length>k;++k)C[31&w[k]]++;for(var E=zl(C,7),x=E[0],P=E[1],I=19;I>4&&!x[Cl[I-1]];--I);var F,T,R,A,M=c+5<<3,L=ql(n,Al)+ql(r,$l)+o,O=ql(n,h)+ql(r,g)+o+14+3*I+ql(C,x)+(2*C[16]+3*C[17]+7*C[18]);if(L>=M&&O>=M)return jl(t,u,e.subarray(l,l+c));if(Nl(t,u,1+(L>O)),u+=2,L>O){F=Rl(h,_,0),T=h,R=Rl(g,f,0),A=g;var D=Rl(x,P,0);for(Nl(t,u,y-257),Nl(t,u+5,S-1),Nl(t,u+10,I-4),u+=14,k=0;I>k;++k)Nl(t,u+3*k,x[Cl[k]]);u+=3*I;for(var N=[m,w],B=0;2>B;++B){var z=N[B];for(k=0;z.length>k;++k)Nl(t,u,D[H=31&z[k]]),u+=x[H],H>15&&(Nl(t,u,z[k]>>>5&127),u+=z[k]>>>12)}}else F=Ml,T=Al,R=Ll,A=$l;for(k=0;a>k;++k)if(s[k]>255){var H;Bl(t,u,F[257+(H=s[k]>>>18&31)]),u+=T[H+257],H>7&&(Nl(t,u,s[k]>>>23&31),u+=wl[H]);var U=31&s[k];Bl(t,u,R[U]),u+=A[U],U>3&&(Bl(t,u,s[k]>>>5&8191),u+=Sl[U])}else Bl(t,u,F[s[k]]),u+=T[s[k]];return Bl(t,u,F[256]),u+T[256]},Vl=new bl([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Gl=new ml(0),Kl=function(){for(var e=new bl(256),t=0;256>t;++t){for(var i=t,s=9;--s;)i=(1&i&&3988292384)^i>>>1;e[t]=i}return e}(),Ql=function(e,t,i){for(;i;++t)e[t]=i,i>>>=8};function Jl(e,t){void 0===t&&(t={});var i=function(){var e=4294967295;return{p(t){for(var i=e,s=0;t.length>s;++s)i=Kl[255&i^t[s]]^i>>>8;e=i},d(){return 4294967295^e}}}(),s=e.length;i.p(e);var n,r,o,a,l,c,u=(a=10+((n=t).filename&&n.filename.length+1||0),l=8,function(e,t,i,s,n,r){var o=e.length,a=new ml(s+o+5*(1+Math.floor(o/7e3))+n),l=a.subarray(s,a.length-n),c=0;if(!t||8>o)for(var u=0;o>=u;u+=65535){var d=u+65535;o>d?c=jl(l,c,e.subarray(u,d)):(l[u]=r,c=jl(l,c,e.subarray(u,o)))}else{for(var h=Vl[t-1],_=h>>>13,p=8191&h,g=(1<<i)-1,f=new yl(32768),v=new yl(g+1),m=Math.ceil(i/3),y=2*m,b=function(t){return(e[t]^e[t+1]<<m^e[t+2]<<y)&g},w=new bl(25e3),S=new yl(288),C=new yl(32),k=0,E=0,x=(u=0,0),P=0,I=0;o>u;++u){var F=b(u),T=32767&u,R=v[F];if(f[T]=R,v[F]=T,u>=P){var A=o-u;if((k>7e3||x>24576)&&A>423){c=Wl(e,l,0,w,S,C,E,x,I,u-I,c),x=k=E=0,I=u;for(var M=0;286>M;++M)S[M]=0;for(M=0;30>M;++M)C[M]=0}var L=2,O=0,D=p,N=T-R&32767;if(A>2&&F==b(u-N))for(var B=Math.min(_,A)-1,z=Math.min(32767,u),H=Math.min(258,A);z>=N&&--D&&T!=R;){if(e[u+L]==e[u+L-N]){for(var U=0;H>U&&e[u+U]==e[u+U-N];++U);if(U>L){if(L=U,O=N,U>B)break;var q=Math.min(N,U-2),j=0;for(M=0;q>M;++M){var W=u-N+M+32768&32767,V=W-f[W]+32768&32767;V>j&&(j=V,R=W)}}}N+=(T=R)-(R=f[T])+32768&32767}if(O){w[x++]=268435456|xl[L]<<18|Pl[O];var G=31&xl[L],K=31&Pl[O];E+=wl[G]+Sl[K],++S[257+G],++C[K],P=u+L,++k}else w[x++]=e[u],++S[e[u]]}}c=Wl(e,l,r,w,S,C,E,x,I,u-I,c),r||(c=jl(l,c,Gl))}return Dl(a,0,s+Ol(c)+n)}(r=e,null==(o=t).level?6:o.level,null==o.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(r.length)))):12+o.mem,a,l,!c)),d=u.length;return function(e,t){var i=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=2>t.level?4:9==t.level?2:0,e[9]=3,0!=t.mtime&&Ql(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),i){e[3]=8;for(var s=0;i.length>=s;++s)e[s+10]=i.charCodeAt(s)}}(u,t),Ql(u,d-8,i.d()),Ql(u,d-4,s),u}const Yl=!!Je||!!Qe,Xl=new WeakMap,Zl="text/plain";let ec=0,tc=!1;const ic=(e,t)=>{const[i,s]=e.split("#"),[n,r]=i.split("?");if(!r)return e;const o=r.split("&").filter(e=>e.split("=")[0]!==t).join("&");return`${n}${o?`?${o}`:""}${s?`#${s}`:""}`},sc=(e,t,i=!0)=>{var s;const[n,r]=e.split("?"),o=as({},t),a=null!==(s=null==r?void 0:r.split("&").map(e=>{var t;const[s,n]=e.split("="),r=i&&null!==(t=o[s])&&void 0!==t?t:n;return delete o[s],`${s}=${r}`}))&&void 0!==s?s:[],l=function(e,t="&"){let i,s;const n=[];return Rr(e,function(e,t){vt(e)||vt(t)||"undefined"===t||(i=encodeURIComponent((e=>e instanceof File)(e)?e.name:e.toString()),s=encodeURIComponent(t),n[n.length]=s+"="+i)}),n.join(t)}(o);return l&&a.push(l),a.length>0?`${n}?${a.join("&")}`:n},nc=e=>{if(e._encodedBody)return e._encodedBody;const{data:t,compression:i}=e;if(!t)return;if(i===nl){const e=Jl(function(e){var t=e.length;if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var i=new ml(e.length+(e.length>>>1)),s=0,n=function(e){i[s++]=e},r=0;t>r;++r){if(s+5>i.length){var o=new ml(s+8+(t-r<<1));o.set(i),i=o}var a=e.charCodeAt(r);128>a?n(a):2048>a?(n(192|a>>>6),n(128|63&a)):a>55295&&57344>a?(n(240|(a=65536+(1047552&a)|1023&e.charCodeAt(++r))>>>18),n(128|a>>>12&63),n(128|a>>>6&63),n(128|63&a)):(n(224|a>>>12),n(128|a>>>6&63),n(128|63&a))}return Dl(i,0,s)}(Pa(t)),{mtime:0});return{contentType:Zl,body:e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength),estimatedSize:e.byteLength}}if(i===rl){const e=function(e){return e?btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,(e,t)=>String.fromCharCode(parseInt(t,16)))):e}(Pa(t)),i=(e=>"data="+encodeURIComponent("string"==typeof e?e:Pa(e)))(e);return{contentType:"application/x-www-form-urlencoded",body:i,estimatedSize:new Blob([i]).size}}const s=Pa(t);return{contentType:"application/json",body:s,estimatedSize:new Blob([s]).size}},rc=e=>{const t=()=>"sendBeacon"===e.transport?{url:sc(e.url,{compression:rl}),encodedBody:nc(as(as({},e),{},{compression:rl,_encodedBody:void 0}))}:{url:ic(e.url,"compression"),encodedBody:nc(as(as({},e),{},{compression:void 0,_encodedBody:void 0}))};let i;try{i=nc(e)}catch(i){if(on(e.compression,Ia(e.url,"compression")))return Ir.error("Failed to gzip request body, sending uncompressed payload",i),t();throw i}return i&&on(e.compression,Ia(e.url,"compression"))&&!((s=i.body)instanceof ArrayBuffer?rn(new Uint8Array(s)):ArrayBuffer.isView(s)&&rn(new Uint8Array(s.buffer,s.byteOffset,s.byteLength)))?(tc=!0,t()):{url:e.url,encodedBody:i};var s},oc=e=>{try{return rc(e)}catch(i){var t;return Ir.error(i),void(null===(t=e.callback)||void 0===t||t.call(e,{statusCode:0,error:i}))}},ac=function(){var e=Ot(function*(e){const t=yield function(e){return dn.apply(this,arguments)}(Pa(e.data),i.DEBUG,{rethrow:!0});if(!t)return e;const s=yield t.arrayBuffer();return as(as({},e),{},{_encodedBody:{contentType:Zl,body:s,estimatedSize:s.byteLength}})});return function(t){return e.apply(this,arguments)}}(),lc=e=>Xi("AbortError","PostHog request timed out"+(e?` after ${e}ms`:"")),cc=/Failed to fetch|NetworkError|Load failed/i,uc=e=>"TypeError"===(null==e?void 0:e.name)&&cc.test((null==e?void 0:e.message)||""),dc=e=>{try{const t=function(e,t=Date.now(),i=3e5){if("string"!=typeof e||!e)return;const s=e.trim(),n=/^\d+\s*,/.test(s)?s.slice(0,s.indexOf(",")).trim():s;if(/^\d+$/.test(n)){const e=1e3*Math.min(Number(n),i/1e3);return e>0?e:void 0}if(!/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun)[a-z]*[ ,]/.test(n))return;const r=/^\w{3} \w{3} /.test(n)?n+" GMT":n,o=Date.parse(r)-t;return Number.isFinite(o)&&o>0?Math.min(o,i):void 0}(e());return vt(t)?void 0:Math.min(t,3e4)}catch(e){return}},hc=e=>{const t=oc(e);if(!t)return;const i=new Je;Xl.set(i,!0);const{url:s,encodedBody:n}=t;i.open(e.method||"GET",s,!0);const{contentType:r,body:o}=null!=n?n:{};Rr(e.headers,function(e,t){i.setRequestHeader(t,e)}),r&&i.setRequestHeader("Content-Type",r),e.timeout&&(i.timeout=e.timeout);let a=!1;i.ontimeout=()=>{a=!0},i.onloadend=()=>{var t;if(a){var s;const t=lc(e.timeout);return Ir.warn(t),void(null===(s=e.callback)||void 0===s||s.call(e,{statusCode:0,error:t}))}const n={statusCode:i.status,text:i.responseText};if(200===i.status)try{n.json=JSON.parse(i.responseText)}catch(e){}null===(t=e.callback)||void 0===t||t.call(e,n,dc(()=>i.getResponseHeader("Retry-After")))},i.send(o)},_c=e=>{const t=oc(e);if(!t)return;const{url:i,encodedBody:s}=t,{contentType:n,body:r,estimatedSize:o}=null!=s?s:{},a=new Headers;Rr(e.headers,function(e,t){a.append(t,e)}),n&&a.append("Content-Type",n);let l=null,c=!1;if(Ye){const t=new Ye;l={signal:t.signal,timeout:setTimeout(()=>{c=!0;try{t.abort(lc(e.timeout))}catch(e){d(e)}},e.timeout)}}let u=!1;const d=t=>{var i;u||(u=!0,c&&"AbortError"===(null==t?void 0:t.name)||uc(t)?Ir.warn(t):Ir.error(t),null===(i=e.callback)||void 0===i||i.call(e,{statusCode:0,error:t}))};let h=0;const _=()=>{ec-=h,h=0,l&&clearTimeout(l.timeout)};try{const t=as({method:(null==e?void 0:e.method)||"GET",headers:a,referrerPolicy:"strict-origin",body:r,signal:null==l?void 0:l.signal},e.fetchOptions),s=null!=o?o:vt(r)?0:void 0;t.keepalive="POST"===t.method&&!e._keepaliveDisabled&&!1!==t.keepalive&&t.body===r&&!vt(s)&&s>=0&&52428.8>ec+s,t.keepalive&&(h=s,ec+=h),Qe(i,t).then(t=>t.text().then(i=>{var s;if(u)return;const n={statusCode:t.status,text:i};if(200===t.status)try{n.json=JSON.parse(i)}catch(e){Ir.error(e)}u=!0,_(),null===(s=e.callback)||void 0===s||s.call(e,n,dc(()=>t.headers.get("Retry-After")))})).catch(e=>{_(),d(e)}).finally(_)}catch(e){_(),d(e)}},pc=e=>{try{var t;const{url:i,encodedBody:s}=rc(e),{contentType:n,body:r,estimatedSize:o}=null!=s?s:{};if(!r)return;const a=r instanceof Blob?r:new Blob([r],{type:n});if(Ve.sendBeacon(i,a))return;const l=_t(e.data)?e.data:null===(t=e.data)||void 0===t?void 0:t.batch;if(_t(l)&&l.length>1&&(null!=o?o:0)>16384){const t=Math.ceil(l.length/2),i=t=>_t(e.data)?t:as(as({},e.data),{},{batch:t});return pc(as(as({},e),{},{data:i(l.slice(0,t))})),void pc(as(as({},e),{},{data:i(l.slice(t))}))}Ir.warn(`Beacon of ~${null!=o?o:0} bytes was rejected by the browser, falling back to ${Qe?"fetch":"XHR"}`),Qe?_c(as(as({},e),{},{_keepaliveDisabled:!0})):hc(e)}catch(e){Ir.warn("Beacon send failed",e)}},gc=(e,t,i,s)=>{const n="query"===s?"POST"===t?"sent_at":"_":void 0;return sc(i===nl?ic(e,"compression"):e,as(as({},n?{[n]:Date.now().toString()}:{}),i===nl?{}:{compression:i}))},fc=(()=>{const e=[];return Qe&&e.push({transport:"fetch",method:_c}),Je&&e.push({transport:"XHR",method:hc}),(null==Ve?void 0:Ve.sendBeacon)&&e.push({transport:"sendBeacon",method:pc}),e})();let vc=!Yl&&-1===(null==Ze?void 0:Ze.indexOf("MSIE"))&&-1===(null==Ze?void 0:Ze.indexOf("Mozilla"));function mc(e,t,i){var s,n,r,o;i&&(t=as(as({},t),{},{callback:e=>i(e)})),e.__loaded?vc?e.__request_queue.push(t):e.rateLimiter.isServerRateLimited(t.batchKey)?t.fireCallbackOnDrop&&(null===(r=t.callback)||void 0===r||r.call(t,{statusCode:429})):(t.transport=t.transport||e.config.api_transport,t.headers=as(as({},e.config.request_headers),t.headers),t.compression="best-available"===t.compression?null!==(s=e.compression)&&void 0!==s?s:t.compressionFallback:t.compression,(vt(e.config.disable_beacon)?e.config.__preview_disable_beacon:e.config.disable_beacon)&&(t.disableTransport=["sendBeacon"]),t.fetchOptions=t.fetchOptions||e.config.fetch_options,null===(n=t.onDispatch)||void 0===n||n.call(t),((e,t)=>{var i,s,n;const r=as(as({},e),{},{callback:null!=t?t:t=>{var i;return null===(i=e.callback)||void 0===i?void 0:i.call(e,t)}});r.timeout=r.timeout||6e4;const o=null!==(i=r.transport)&&void 0!==i?i:"fetch";"sendBeacon"===o&&vt(r.compression)&&r.data&&(r.compression=rl),"POST"===r.method&&r.data&&("capture-body"===r.timestampMode?r.data=(e=>{var t,i;const s=(_t(e)?e:[e]).map(e=>as(as({},e),e.timestamp instanceof Date&&!isNaN(e.timestamp.getTime())?{timestamp:e.timestamp.toISOString()}:{})),n=s[0];return{api_key:null!==(t=null==n||null===(i=n.properties)||void 0===i?void 0:i.token)&&void 0!==t?t:null==n?void 0:n.token,batch:s,sent_at:(new Date).toISOString()}})(r.data):"body"===r.timestampMode&&(r.data=((e,t=(new Date).toISOString())=>_t(e)?e.map(e=>as(as({},e),{},{sent_at:t})):as(as({},e),{},{sent_at:t}))(r.data))),r.url=gc(r.url,r.method,r.compression,r.timestampMode);const a=fc.filter(e=>!r.disableTransport||!e.transport||!r.disableTransport.includes(e.transport)),l=null!==(s=null===(n=function(e,t){for(let i=0;e.length>i;i++)if(t(e[i]))return e[i]}(a,e=>e.transport===o))||void 0===n?void 0:n.method)&&void 0!==s?s:a[0].method;if(!l)throw new Error("No available transport method");const c=e=>{try{l(e)}catch(e){var t;uc(e)?Ir.warn(e):Ir.error(e),null===(t=r.callback)||void 0===t||t.call(r,{statusCode:0,error:e})}};"sendBeacon"!==o&&!r.preferSyncCompression&&r.data&&r.compression===nl&&Xe&&"undefined"!=typeof Promise&&!tc?ac(r).then(e=>{c(e)}).catch(t=>{if(an(t))return tc=!0,void c(as(as({},r),{},{compression:void 0,url:gc(e.url,e.method,void 0,e.timestampMode)}));(e=>{if(!e||"object"!=typeof e)return!1;const t="name"in e?String(e.name):"";return an(e)||t===nn})(t)&&(tc=!0),c(r)}):c(r)})(t,(s,n)=>{var r,o,a;e.rateLimiter.checkForLimiting(s),400>s.statusCode||null===(r=(o=e.config).on_request_error)||void 0===r||r.call(o,s),i?i(s,n):null===(a=t.callback)||void 0===a||a.call(t,s)})):t.fireCallbackOnDrop&&(null===(o=t.callback)||void 0===o||o.call(t,{statusCode:0}))}var yc=class{constructor(e,t){this._isPaused=!0,this._queue=[],this._flushTimeoutMs=zt((null==t?void 0:t.flush_interval_ms)||3e3,250,5e3,Ir.createLogger("flush interval"),3e3),this._sendRequest=e}enqueue(e){this._queue.push(e),this._flushTimeout||this._setFlushTimeout()}unload(){this._clearFlushTimeout();const e=this._queue.length>0?this._formatQueue():{},t=Object.values(e);[...t.filter(e=>0===e.url.indexOf("/e")),...t.filter(e=>0!==e.url.indexOf("/e"))].map(e=>{this._sendRequestSafely(as(as({},e),{},{callback:void 0}),"sendBeacon")})}enable(){this._isPaused=!1,this._setFlushTimeout()}_setFlushTimeout(){this._isPaused||(this._flushTimeout=setTimeout(()=>{this._clearFlushTimeout(),this._flush()},this._flushTimeoutMs))}_flush(){if(this._queue.length>0){const e=this._formatQueue();for(const t in e)this._sendRequestSafely(e[t])}}_sendRequestSafely(e,t){try{this._sendRequest(e,t)}catch(e){Ir.error(e)}}_clearFlushTimeout(){clearTimeout(this._flushTimeout),this._flushTimeout=void 0}_formatQueue(){const e={},t={};Rr(this._queue,i=>{var s;const n=i,r=((n?n.batchKey:null)||n.url)+(n.batchGroup?`:${n.batchGroup}`:"");vt(e[r])&&(e[r]=as(as({},n),{},{data:[],callback:void 0,fireCallbackOnDrop:void 0}),t[r]=[]),null===(s=e[r].data)||void 0===s||s.push(n.data),n.callback&&t[r].push(n.callback)});for(const i in t){const s=t[i];s.length&&(e[i].callback=e=>{for(const t of s)t(e)})}return this._queue=[],e}};const bc=["retriesPerformedSoFar"];var wc=class{constructor(e){this._instance=e,this._isPolling=!1,this._pollIntervalMs=3e3,this._queue=[],this._queue=[],this._areWeOnline=!0,this.resume()}resume(){if(!vt(je)&&"onLine"in je.navigator){if(this._areWeOnline=je.navigator.onLine,this._onlineListener)return;this._onlineListener=()=>{this._areWeOnline=!0,this._flush()},this._offlineListener=()=>{this._areWeOnline=!1},Br(je,"online",this._onlineListener),Br(je,"offline",this._offlineListener)}}get length(){return this._queue.length}retriableRequest(e,t){let{retriesPerformedSoFar:i}=e,s=hn(e,bc);Ct(i)&&(s.url=sc(s.url,{retry_count:i})),mc(this._instance,t?as(as({},s),{},{transport:t}):s,(e,t)=>{var n;if(200!==e.statusCode&&(400>e.statusCode||e.statusCode>=500)){if((0===e.statusCode?3:10)>(null!=i?i:0))return void this._enqueue(as({retriesPerformedSoFar:i},s),t);0===e.statusCode&&Ir.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!=i?i:0} retries.`)}null===(n=s.callback)||void 0===n||n.call(s,e)})}_enqueue(e,t){const i=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=i+1;const s=Math.max(function(e){const t=3e3*Math.pow(2,e),i=t/2,s=Math.min(18e5,t),n=(Math.random()-.5)*(s-i);return Math.ceil(s+n)}(i),null!=t?t:0),n=Date.now()+s;this._queue.push({retryAt:n,requestOptions:e});let r=`Enqueued failed request for retry in ${s}`;navigator.onLine||(r+=" (Browser is offline)"),Ir.warn(r),this._isPolling||(this._isPolling=!0,this._poll())}_poll(){if(this._poller&&clearTimeout(this._poller),0===this._queue.length)return this._isPolling=!1,void(this._poller=void 0);this._poller=setTimeout(()=>{this._areWeOnline&&this._queue.length>0&&this._flush(),this._poll()},this._pollIntervalMs)}_flush(){const e=Date.now(),t=[],i=this._queue.filter(i=>e>i.retryAt||(t.push(i),!1));if(this._queue=t,i.length>0)for(const{requestOptions:e}of i)this.retriableRequest(e)}unload(){this._poller&&(clearTimeout(this._poller),this._poller=void 0),this._isPolling=!1,vt(je)||(this._onlineListener&&(je.removeEventListener("online",this._onlineListener),this._onlineListener=void 0),this._offlineListener&&(je.removeEventListener("offline",this._offlineListener),this._offlineListener=void 0));for(const{requestOptions:e}of this._queue)try{this._instance._send_request(as(as({},e),{},{callback:_t(e.data)?void 0:e.callback,transport:"sendBeacon"}))}catch(e){Ir.error(e)}this._queue=[]}},Sc=class{constructor(e){this._instance=e,this._updateScrollData=()=>{var e,t,i,s;this._context||(this._context={});const n=this.scrollElement(),r=this.scrollY(),o=n?Math.max(0,n.scrollHeight-n.clientHeight):0,a=r+((null==n?void 0:n.clientHeight)||0),l=(null==n?void 0:n.scrollHeight)||0;this._context.lastScrollY=Math.ceil(r),this._context.maxScrollY=Math.max(r,null!==(e=this._context.maxScrollY)&&void 0!==e?e:0),this._context.maxScrollHeight=Math.max(o,null!==(t=this._context.maxScrollHeight)&&void 0!==t?t:0),this._context.lastContentY=a,this._context.maxContentY=Math.max(a,null!==(i=this._context.maxContentY)&&void 0!==i?i:0),this._context.maxContentHeight=Math.max(l,null!==(s=this._context.maxContentHeight)&&void 0!==s?s:0)}}get _scrollRoot(){return this._instance.config.scroll_root_selector}getContext(){return this._context}resetContext(){const e=this._context;return this._context=void 0,setTimeout(this._updateScrollData,0),e}startMeasuringScrollPosition(){Br(je,"scroll",this._updateScrollData,{capture:!0}),Br(je,"scrollend",this._updateScrollData,{capture:!0}),Br(je,"resize",this._updateScrollData)}scrollElement(){if(this._scrollRoot){const t=_t(this._scrollRoot)?this._scrollRoot:[this._scrollRoot];for(const i of t){var e;const t=null==je||null===(e=je.document)||void 0===e?void 0:e.querySelector(i);if(t)return t}return}var t;return null==je||null===(t=je.document)||void 0===t?void 0:t.documentElement}_scrollPosition(e){var t,i;const s="y"===e?"scrollTop":"scrollLeft";if(this._scrollRoot){const e=this.scrollElement();return e&&e[s]||0}return je?"y"===e?je.scrollY||je.pageYOffset||(null===(t=je.document)||void 0===t||null===(t=t.documentElement)||void 0===t?void 0:t.scrollTop)||0:je.scrollX||je.pageXOffset||(null===(i=je.document)||void 0===i||null===(i=i.documentElement)||void 0===i?void 0:i.scrollLeft)||0:0}scrollY(){return this._scrollPosition("y")}scrollX(){return this._scrollPosition("x")}};const Cc=e=>Ua(null==e?void 0:e.config.mask_personal_data_properties,null==e?void 0:e.config.custom_personal_data_properties,null==e?void 0:e.config.disable_capture_url_hashes);var kc=class{constructor(e,t,i,s){this._onSessionIdCallback=e=>{const t=this._getStored();if(t&&t.sessionId===e)return;const i={sessionId:e,props:this._sessionSourceParamGenerator(this._instance)};this._persistence.register({[fe]:i})},this._instance=e,this._sessionIdManager=t,this._persistence=i,this._sessionSourceParamGenerator=s||Cc,this._sessionIdManager.onSessionId(this._onSessionIdCallback)}_getStored(){return this._persistence.props[fe]}getSetOnceProps(){var e;const t=null===(e=this._getStored())||void 0===e?void 0:e.props;return t?"r"in t?qa(t,this._instance.config.disable_capture_url_hashes):{$referring_domain:t.referringDomain,$pathname:t.initialPathName,utm_source:t.utm_source,utm_campaign:t.utm_campaign,utm_medium:t.utm_medium,utm_content:t.utm_content,utm_term:t.utm_term}:{}}getSessionProps(){const e={};return Rr(Lr(this.getSetOnceProps()),(t,i)=>{"$current_url"===i&&(i="url"),e[`$session_entry_${lt(i)}`]=t}),e}},Ec=class{on(e,t){return this._events[e]||(this._events[e]=[]),this._events[e].push(t),()=>{this._events[e]=this._events[e].filter(e=>e!==t)}}emit(e,t){for(const i of this._events[e]||[])i(t);for(const i of this._events["*"]||[])i(e,t)}constructor(){this._events={}}};const xc=Fr("[SessionId]"),Pc=864e5;var Ic=class{on(e,t){return this._eventEmitter.on(e,t)}constructor(e,t,i){var s;if(this._lastPersistedActivityTimestamp=null,this._lastCookieSyncTimestamp=null,this._sessionIdChangedHandlers=[],this._beforeUnloadListener=void 0,this._destroyed=!1,this._eventEmitter=new Ec,this._sessionHasBeenIdleTooLong=(e,t)=>!(!Ct(e)||!Ct(t))&&Math.abs(e-t)>this.sessionTimeoutMs,!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if("always"===e.config.cookieless_mode)throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this._config=e.config,this._persistence=e.persistence,this._windowId=void 0,this._sessionId=void 0,this._sessionStartTimestamp=null,this._pendingBootstrapSession=void 0,this._sessionActivityTimestamp=null,this._sessionIdGenerator=t||Kr,this._windowIdGenerator=i||Kr;const n=this._config.persistence_name||this._config.token;if(this._sessionTimeoutMs=1e3*zt(this._config.session_idle_timeout_seconds||1800,60,36e3,xc.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this._resetIdleTimer(),this._window_id_storage_key="ph_"+n+"_window_id",this._primary_window_exists_storage_key="ph_"+n+"_primary_window_exists",this._canUseSessionStorage()){const e=fo._parse(this._window_id_storage_key),t=fo._parse(this._primary_window_exists_storage_key);e&&!t?this._windowId=e:fo._remove(this._window_id_storage_key),fo._set(this._primary_window_exists_storage_key,!0)}(null===(s=this._config.bootstrap)||void 0===s?void 0:s.sessionID)&&this.setBootstrapSessionId(this._config.bootstrap.sessionID),this._listenToReloadWindow()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return vt(this._sessionIdChangedHandlers)&&(this._sessionIdChangedHandlers=[]),this._sessionIdChangedHandlers.push(e),this._sessionId&&e(this._sessionId,this._windowId),()=>{this._sessionIdChangedHandlers=this._sessionIdChangedHandlers.filter(t=>t!==e)}}_canUseSessionStorage(){return"memory"!==this._config.persistence&&!this._persistence._disabled&&fo._is_supported()}_setWindowId(e){e!==this._windowId&&(this._windowId=e,this._canUseSessionStorage()&&fo._set(this._window_id_storage_key,e))}_getWindowId(){return this._windowId?this._windowId:this._canUseSessionStorage()?fo._parse(this._window_id_storage_key):null}_isActivityChangeBelowGranularity(e){const t=this._lastPersistedActivityTimestamp;return!bt(t)&&!bt(e)&&5e3>Math.abs(e-t)}_setSessionId(e,t,i){const s=t!==this._sessionActivityTimestamp,n=!(e!==this._sessionId||i!==this._sessionStartTimestamp);this._sessionStartTimestamp=i,this._sessionActivityTimestamp=t,this._sessionId=e,n&&!s||n&&this._isActivityChangeBelowGranularity(t)||(this._lastPersistedActivityTimestamp=t,this._persistence.register({[ee]:[t,e,i]}))}_useCrossTabRefreshHardening(){var e;const t=null===(e=this._config)||void 0===e?void 0:e.persistence_save_debounce_ms;return Ct(t)&&t>0}_refreshSessionIdFromStorage(){this._useCrossTabRefreshHardening()?this._persistence.refreshKey(ee):(this._persistence.flush(),this._persistence.load())}_flushPendingActivityTimestamp(){var e;if(bt(this._sessionActivityTimestamp)||this._sessionActivityTimestamp===this._lastPersistedActivityTimestamp)return;this._refreshSessionIdFromStorage();const[,t,i]=this._getSessionId();t===this._sessionId&&i===this._sessionStartTimestamp&&(this._lastPersistedActivityTimestamp=this._sessionActivityTimestamp,this._persistence.register({[ee]:[this._sessionActivityTimestamp,null!==(e=this._sessionId)&&void 0!==e?e:null,this._sessionStartTimestamp]}),this._persistence.flush())}_freshestActivityTimestamp(){const[e]=this._getSessionId(),t=Ct(e)?e:0,i=Ct(this._sessionActivityTimestamp)?this._sessionActivityTimestamp:0;return Math.max(t,i)}_isSessionIdleAfterCrossTabRefresh(e){return this._refreshSessionIdFromStorage(),this._sessionHasBeenIdleTooLong(e,this._freshestActivityTimestamp())}_getSessionId(){const e=this._persistence.props[ee];return _t(e)&&2===e.length&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this._lastPersistedActivityTimestamp=null,this._pendingBootstrapSession=void 0,clearTimeout(this._enforceIdleTimeout),this._enforceIdleTimeout=void 0,this._setSessionId(null,null,null)}setBootstrapSessionId(e,t=!1){const i=((e,t=(new Date).getTime())=>{try{const i=(e=>{const t=e.replace(/-/g,"");if(32!==t.length)throw new Error("Not a valid UUID");if("7"!==t[12])throw new Error("Not a UUIDv7");return parseInt(t.substring(0,12),16)})(e);return i>t+6e4?void xc.error("Bootstrap sessionID cannot be in the future"):i}catch(e){return void xc.error("Invalid sessionID in bootstrap",e)}})(e);return!vt(i)&&(t?this._pendingBootstrapSession={sessionId:e,sessionStartTimestamp:i}:this._setSessionId(e,(new Date).getTime(),i),!0)}destroy(){this._destroyed=!0,this._flushPendingActivityTimestamp(),clearTimeout(this._enforceIdleTimeout),this._enforceIdleTimeout=void 0,this._beforeUnloadListener&&je&&(je.removeEventListener(Be,this._beforeUnloadListener,{capture:!1}),this._beforeUnloadListener=void 0),this._sessionIdChangedHandlers=[]}_listenToReloadWindow(){this._beforeUnloadListener=()=>{this._flushPendingActivityTimestamp(),this._canUseSessionStorage()&&fo._remove(this._primary_window_exists_storage_key)},Br(je,Be,this._beforeUnloadListener,{capture:!1})}checkAndGetSessionAndWindowId(e=!1,t=null,i=!1){if("always"===this._config.cookieless_mode)throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');const s=t||(new Date).getTime(),n=this._sessionId;if(i)this._lastCookieSyncTimestamp=s;else if(bt(this._lastCookieSyncTimestamp)||this._lastCookieSyncTimestamp>s||s-this._lastCookieSyncTimestamp>=1e3){var r,o;null===(r=(o=this._persistence).syncCookieProperties)||void 0===r||r.call(o),this._lastCookieSyncTimestamp=s}let[,a,l]=this._getSessionId();const c=!vt(n)&&a!==n,u=this._freshestActivityTimestamp();let d=this._getWindowId();const h=this._pendingBootstrapSession,_=!!h&&(h.sessionStartTimestamp>s+6e4||s-h.sessionStartTimestamp>Pc),p=h?_:Ct(l)&&Math.abs(s-l)>Pc;let g=!1,f=c,v=!a||!!h;const m=a;let y=!v&&!e&&this._sessionHasBeenIdleTooLong(s,u);if(y&&(y=this._isSessionIdleAfterCrossTabRefresh(s),y||xc.info("cross-tab refresh kept the session alive",{sessionId:a}),[,a,l]=this._getSessionId(),y||(v=!a||!!h)),v||y||p){f=!1;const e=h&&!_;a=e?h.sessionId:this._sessionIdGenerator(),d=this._windowIdGenerator(),xc.info("new session ID assigned",{sessionId:a,windowId:d,bootstrapped:!!e,changeReason:{noSessionId:v,activityTimeout:y,sessionPastMaximumLength:p}}),l=e?h.sessionStartTimestamp:s,this._pendingBootstrapSession=void 0,g=!0}else d||(d=this._windowIdGenerator(),g=!0),f=f||a!==m,f&&(xc.info("adopted cross-tab session id",{sessionId:a,windowId:d}),g=!0);const b=Ct(u)&&e&&!p?u:s,w=Ct(l)?l:(new Date).getTime();this._setWindowId(d),this._setSessionId(a,b,w),e||this._resetIdleTimer();const S={noSessionId:v,activityTimeout:y,sessionPastMaximumLength:p,crossTabAdoption:f};return g&&this._sessionIdChangedHandlers.forEach(e=>e(a,d,S)),{sessionId:a,windowId:d,sessionStartTimestamp:w,changeReason:g?S:void 0,lastActivityTimestamp:u}}_resetIdleTimer(){this._destroyed||(clearTimeout(this._enforceIdleTimeout),this._enforceIdleTimeout=setTimeout(()=>{if(!this._destroyed)if(this._isSessionIdleAfterCrossTabRefresh((new Date).getTime())){const e=this._sessionId;this.resetSessionId(),this._eventEmitter.emit("forcedIdleReset",{idleSessionId:e})}else this._resetIdleTimer()},1.1*this.sessionTimeoutMs))}};const Fc=Object.freeze(["2026-08-30","2026-08-29","2026-06-25","2026-05-30","2026-01-30","2025-11-30","2025-05-24"]),Tc=function(e,t){if(!e)return!1;const i=e.userAgent;if(i&&Bt(i,t))return!0;try{const i=null==e?void 0:e.userAgentData;if((null==i?void 0:i.brands)&&i.brands.some(e=>Bt(null==e?void 0:e.brand,t)))return!0}catch(e){}return!!e.webdriver};function Rc(){return(Rc=Ot(function*(){const e=null==Ve?void 0:Ve.userAgentData;if(null==e?void 0:e.getHighEntropyValues)try{const t=yield e.getHighEntropyValues(["model"]),i=null==t?void 0:t.model;return mt(i)&&i.length>0?i:void 0}catch(e){return void Ir.info("Unable to resolve $device_model from userAgentData.getHighEntropyValues",e)}})).apply(this,arguments)}function Ac(e,t){let i=`$survey_${t}/${e.id}`;return e.current_iteration&&e.current_iteration>0&&(i=`$survey_${t}/${e.id}/${e.current_iteration}`),i}function $c(e){var t;return!!(null===(t=e.conditions)||void 0===t||null===(t=t.events)||void 0===t||null===(t=t.values)||void 0===t?void 0:t.length)}const Mc=(e,t)=>{if(!(e=>{try{new RegExp(e)}catch(e){return!1}return!0})(t))return!1;try{return new RegExp(t).test(e)}catch(e){return!1}},Lc=e=>e.toLowerCase(),Oc={exact:(e,t)=>t.some(t=>e.some(e=>t===e)),is_not:(e,t)=>t.every(t=>e.every(e=>t!==e)),regex:(e,t)=>t.some(t=>e.some(e=>Mc(t,e))),not_regex:(e,t)=>t.every(t=>e.every(e=>!Mc(t,e))),icontains:(e,t)=>t.map(Lc).some(t=>e.map(Lc).some(e=>t.includes(e))),not_icontains:(e,t)=>t.map(Lc).every(t=>e.map(Lc).every(e=>!t.includes(e))),gt:(e,t)=>t.some(t=>{const i=parseFloat(t);return!isNaN(i)&&e.some(e=>i>parseFloat(e))}),lt:(e,t)=>t.some(t=>{const i=parseFloat(t);return!isNaN(i)&&e.some(e=>i<parseFloat(e))})};function Dc(e,t){return!e||Object.entries(e).every(([e,i])=>{const s=null==t?void 0:t[e];if(null==s)return!1;const n=Oc[i.operator];return!!n&&n(i.values.map(String),[String(s)])})}function Nc(e,t,i){return Pa({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:i})}const Bc="custom",zc="i.posthog.com",Hc=/^\/static\//,Uc=["/s/","/e/","/i/"];var qc=class{constructor(e){this._regionCache={},this.instance=e}get apiHost(){const e=this.instance.config.api_host.trim().replace(/\/$/,"");return"https://app.posthog.com"===e?"https://us.i.posthog.com":e}get flagsApiHost(){const e=this.instance.config.flags_api_host;return e?e.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var e;let t=null===(e=this.instance.config.ui_host)||void 0===e?void 0:e.replace(/\/$/,"");return t||(t=this.apiHost.replace(`.${zc}`,".posthog.com")),"https://app.posthog.com"===t?"https://us.posthog.com":t}get region(){return this._regionCache[this.apiHost]||(this._regionCache[this.apiHost]=/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?"us":/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?"eu":Bc),this._regionCache[this.apiHost]}_staticAssetHostOverride(e){if(!Hc.test(e))return;const t=this.instance.config.asset_host;return"string"==typeof t&&t.trim().replace(/\/$/,"")||void 0}_urlKey(e){const t=Ca(e);return t?t.protocol+"//"+t.host+t.pathname:void 0}_prepareEndpoint(e,t,i){if("ui"===e)return i;let s=i;const n=this.instance.config.rewriteRequestPath;if(n){var r;const e=(null===(r=Ca(i))||void 0===r?void 0:r.href)||i;s=n(new URL(e)).toString()}if(n&&"api"===e&&Uc.some(e=>0===t.indexOf(e))){const e=this._urlKey(s);if(e){const t=this.apiHost;let i=this._ingestionEndpoints;(null==i?void 0:i.apiHost)===t&&i.rewriteRequestPath===n||(i={apiHost:t,rewriteRequestPath:n,urls:new Set},this._ingestionEndpoints=i),i.urls.add(e)}}return s}isIngestionEndpoint(e){const t=this._ingestionEndpoints,i=this._urlKey(e);return(null==t?void 0:t.apiHost)===this.apiHost&&t.rewriteRequestPath===this.instance.config.rewriteRequestPath&&!!i&&t.urls.has(i)}endpointFor(e,t=""){if(t&&(t="/"===t[0]?t:`/${t}`),"ui"===e)return this._prepareEndpoint(e,t,this.uiHost+t);if("flags"===e)return this._prepareEndpoint(e,t,this.flagsApiHost+t);if("assets"===e){const i=this._staticAssetHostOverride(t);if(i)return this._prepareEndpoint(e,t,`${i}${t}`)}if(this.region===Bc)return this._prepareEndpoint(e,t,this.apiHost+t);const i=zc+t;switch(e){case"assets":return this._prepareEndpoint(e,t,`https://${this.region}-assets.${i}`);case"api":return this._prepareEndpoint(e,t,`https://${this.region}.${i}`)}}};const jc=Fr("[Surveys]"),Wc=e=>{try{const t=(e=>((e,t)=>`seenSurvey_${function(e){return e.current_iteration&&e.current_iteration>0?`${e.id}_${e.current_iteration}`:e.id}(t)}`)(0,e))(e);if(localStorage.getItem(t))return;localStorage.setItem(t,"true")}catch(e){jc.error("Failed to persist survey seen state",e)}},Vc=["popover","widget","api"],Gc={ignoreConditions:!1,ignoreDelay:!1,displayType:hl},Kc=Fr("[PostHog ExternalIntegrations]"),Qc={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};var Jc=class{constructor(e){this._instance=e}_loadScript(e,t){var i,s;null===(i=tt.__PosthogExtensions__)||void 0===i||null===(s=i.loadExternalDependency)||void 0===s||s.call(i,this._instance,e,e=>{if(e)return Kc.error("failed to load script",e);t()})}startIfEnabledOrStop(){var e;for(const[n,r]of Object.entries(null!==(e=this._instance.config.integrations)&&void 0!==e?e:{})){var t,i,s;r&&!(null===(t=tt.__PosthogExtensions__)||void 0===t||null===(t=t.integrations)||void 0===t?void 0:t[n])&&this._loadScript(Qc[n],()=>{var e;null===(e=tt.__PosthogExtensions__)||void 0===e||null===(e=e.integrations)||void 0===e||null===(e=e[n])||void 0===e||e.start(this._instance)}),!r&&(null===(i=tt.__PosthogExtensions__)||void 0===i||null===(i=i.integrations)||void 0===i?void 0:i[n])&&(null===(s=tt.__PosthogExtensions__)||void 0===s||null===(s=s.integrations)||void 0===s||null===(s=s[n])||void 0===s||s.stop())}}},Yc=class{constructor(e){this.disabled=!1===e;const t=gt(e)?e:{};this.thresholdPx=t.threshold_px||30,this.timeoutMs=t.timeout_ms||1e3,this.clickCount=t.click_count||3,this.clicks=[]}isRageClick(e,t,i){if(this.disabled)return!1;const s=this.clicks[this.clicks.length-1];if(s&&Math.abs(e-s.x)+Math.abs(t-s.y)<this.thresholdPx&&this.timeoutMs>i-s.timestamp){if(this.clicks.push({x:e,y:t,timestamp:i}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:e,y:t,timestamp:i}];return!1}};const Xc=()=>typeof window>"u"?void 0:window,Zc=()=>typeof document>"u"?void 0:document,eu="$copy_autocapture",tu=["password","hidden","file","checkbox","button","submit","reset","image"],iu=Fr("[AutoCapture]");function su(e,t){return t.length>e?t.slice(0,e)+"...":t}function nu(e){if(e.previousElementSibling)return e.previousElementSibling;let t=e;do{t=t.previousSibling}while(t&&!bo(t));return t}function ru(e,{e:t,maskAllElementAttributes:i,maskAllText:s,elementAttributeIgnoreList:n,elementsChainAsString:r,disableCaptureUrlHashes:o}){var a,l;if(!bo(e))return{props:{}};const c=[e],u=new Set([e]);let d=e;for(;d.parentNode&&!wo(d,"body")&&1e3>c.length;){if(Co(d.parentNode)){const e=d.parentNode.host;if(u.has(e))break;u.add(e),c.push(e),d=e;continue}if(!bo(d.parentNode))break;if(u.has(d.parentNode))break;u.add(d.parentNode),c.push(d.parentNode),d=d.parentNode}const h="click"===t.type&&"http://www.w3.org/2000/svg"===e.namespaceURI?c.findIndex(e=>wo(e,"button")||wo(e,"a")):-1;h>0&&(s=s||c.slice(0,h+1).some(e=>!Ko(e)||Qo(e)));const _=[],p={};let g,f=!1,v=!1;if(Rr(c,e=>{const t=Ko(e);if(wo(e,"a")&&!i&&!(null==n?void 0:n.includes("href"))){const i=e.getAttribute("href");f=!!(t&&i&&sa(i))&&(o?Zi(i):i)}ot(xo(e),"ph-no-capture")&&(v=!0),_.push(function(e,t,i,s,n=!1){const r=e.tagName.toLowerCase(),o={tag_name:r};To.indexOf(r)>-1&&!i&&(o.$el_text="a"===r.toLowerCase()||"button"===r.toLowerCase()?su(1024,na(e)):su(1024,Io(e)));const a=xo(e);t||(null==s?void 0:s.includes("class"))||0>=a.length||(o.classes=a.filter(function(e){return""!==e})),Rr(e.attributes,function(i){var r;if((!Qo(e)||-1!==["name","id","class","aria-label"].indexOf(i.name))&&!(null==s?void 0:s.includes(i.name))&&!t&&sa(i.value)&&(!mt(r=i.name)||"_ngcontent"!==r.substring(0,10)&&"_nghost"!==r.substring(0,7))){let e=i.value;"class"===i.name&&(e=ko(e).join(" ")),o["attr__"+i.name]=su(1024,"href"===i.name&&n?Zi(e):e)}});let l=1,c=1,u=e;for(;u=nu(u);)l++,u.tagName===e.tagName&&c++;return o.nth_child=l,o.nth_of_type=c,o}(e,i,s,n,o)),Rr(function(e){if(!Ko(e))return{};const t={};return Rr(e.attributes,function(e){if(e.name&&0===e.name.indexOf("data-ph-capture-attribute")){const i=e.name.replace("data-ph-capture-attribute-",""),s=e.value;i&&s&&sa(s)&&(t[i]=s)}}),t}(e),(e,t)=>{({}).hasOwnProperty.call(p,t)||(p[t]=e)})}),v)return{props:{},explicitNoCapture:v};if(h>0&&(e=c[h],_.splice(0,h)),s||(_[0].$el_text=wo(e,"a")||wo(e,"button")?na(e):Io(e)),f){var m,y;_[0].attr__href=f;const e=null===(m=Ca(f))||void 0===m?void 0:m.host,t=null===(y=Xc())||void 0===y||null===(y=y.location)||void 0===y?void 0:y.host;e&&t&&e!==t&&(g=f)}return{props:Ar((w=t.type,{$event_type:w,$ce_version:1}),r?{}:{$elements:_},{$elements_chain:(b=_,_t(b)?function(e){return e.map(e=>{var t,i;let s="";if(e.tag_name&&(s+=e.tag_name),e.attr_class){e.attr_class.sort();for(const t of e.attr_class)s+=`.${t.replace(/"/g,"")}`}const n=as(as(as(as({},e.text?{text:e.text}:{}),{},{"nth-child":null!==(t=e.nth_child)&&void 0!==t?t:0,"nth-of-type":null!==(i=e.nth_of_type)&&void 0!==i?i:0},e.href?{href:e.href}:{}),e.attr_id?{attr_id:e.attr_id}:{}),e.attributes),r={};return $r(n).sort(([e],[t])=>function(e,t){return t>e?-1:e>t?1:0}(e,t)).forEach(([e,t])=>r[oa(e.toString())]=oa(t.toString())),s+=":",s+=$r(r).map(([e,t])=>`${e}="${t}"`).join(""),s}).join(";")}(function(e){return e.map(e=>{var t,i;const s={text:null===(t=e.$el_text)||void 0===t?void 0:t.slice(0,400),tag_name:e.tag_name,href:null===(i=e.attr__href)||void 0===i?void 0:i.slice(0,2048),attr_class:aa(e),attr_id:e.attr__id,nth_child:e.nth_child,nth_of_type:e.nth_of_type,attributes:{}};return $r(e).filter(([e])=>0===e.indexOf("attr__")).forEach(([e,t])=>s.attributes[e]=t),s})}(b)):"")},(null===(a=_[0])||void 0===a?void 0:a.$el_text)?{$el_text:null===(l=_[0])||void 0===l?void 0:l.$el_text}:{},g&&"click"===t.type?{$external_click_url:g}:{},p),target:e};var b,w}const ou="autocapture";var au=class{_clearPointer(){this._pointerDown=void 0,clearTimeout(this._pointerExpiry),this._pointerExpiry=void 0}_isExcludedPointerTarget(e){var t;if(!Ko(e))return!0;const i=null!==(t=this._refreshConfig().css_selector_ignorelist)&&void 0!==t?t:Mo,s=new Set;let n=e;for(;n;){if(s.size>=1e3||s.has(n))return!0;s.add(n);const e=n,t=xo(e);if(ot(t,"ph-no-capture")||ot(t,"ph-sensitive")||Qo(e)||i.some(t=>Ro(e,t)))return!0;const r=n.parentNode;n=Co(r)?r.host:r&&bo(r)?r:null}return!1}_trackPointer(e){if(!this.isEnabled||"pointercancel"===e.type)return void this._clearPointer();if("pointerdown"===e.type){var t;this._clearPointer();const i=Fo(e);return void(e.isPrimary&&0===e.button&&!e.ctrlKey&&i&&bo(i)&&(this._pointerDown={target:i,excluded:this._isExcludedPointerTarget(i),id:e.pointerId,x:e.clientX,y:e.clientY,released:!1,distinctId:null===(t=this._client)||void 0===t?void 0:t.distinctId}))}const i=this._pointerDown;i&&(e.pointerId!==i.id||Math.abs(e.clientX-i.x)>5||Math.abs(e.clientY-i.y)>5?this._clearPointer():"pointerup"===e.type&&(i.released=!0,this._pointerExpiry=setTimeout(()=>this._clearPointer(),0)))}_recoverClickTarget(e){var t;const i=this._pointerDown;this._clearPointer();const s=Fo(e);if((null==i?void 0:i.released)&&i.target.isConnected&&i.distinctId===(null===(t=this._client)||void 0===t?void 0:t.distinctId)&&e.pointerId===i.id&&(e.detail>0||"touch"===e.pointerType||"pen"===e.pointerType)&&0===e.button&&5>=Math.abs(e.clientX-i.x)&&5>=Math.abs(e.clientY-i.y)&&s&&(wo(s,"html")||wo(s,"body"))){var n,r,o;if(i.excluded)return null;const e=null!==(n=this._refreshConfig().css_selector_ignorelist)&&void 0!==n?n:Mo;return[s,null===(r=Zc())||void 0===r?void 0:r.documentElement,null===(o=Zc())||void 0===o?void 0:o.body].some(t=>{if(!t)return!1;const i=xo(t);return ot(i,"ph-no-capture")||ot(i,"ph-sensitive")||!Ko(t)||Qo(t)||e.some(e=>Ro(t,e))})?null:i.target}}constructor(e){this._configSource=e,this.name=ou,this._initialized=!1,this._isDisabledServerSide=null,this._hasReceivedConfigResponse=!1,this._elementSelectorsByOwner=new Map,this._elementsChainAsString=!1,this._config={enabled:!1,rageclick:!1,maskAllElementAttributes:!1,maskAllText:!1,disableCaptureUrlHashes:!1,remoteRequestsDisabled:!1},this._disposed=!1,this._configSource.refresh(this._config),this.rageclicks=new Yc(this._config.rageclick),this._elementSelectors=null}setup(e){this._compileUrlPatterns(),this._client=e;const t=e.onRemoteConfig(this.onRemoteConfig.bind(this));this._disposed?t.dispose():(this._remoteConfigSubscription=t,this.startIfEnabled())}dispose(){var e;this._disposed||(this._disposed=!0,this._client=void 0,null===(e=this._remoteConfigSubscription)||void 0===e||e.dispose(),this._remoteConfigSubscription=void 0,this._elementSelectorsByOwner.clear(),this._elementSelectors=null,this._removeDomEventHandlers())}_refreshConfig(){return this._configSource.refresh(this._config),this._config}_compileUrlPatterns(){var e,t;return this._refreshConfig(),this._config.url_allowlist=null===(e=this._config.url_allowlist)||void 0===e?void 0:e.map(e=>new RegExp(e)),this._config.url_ignorelist=null===(t=this._config.url_ignorelist)||void 0===t?void 0:t.map(e=>new RegExp(e)),this._config}_addDomEventHandlers(){const e=Xc(),t=Zc();if(!this.isBrowserSupported())return void iu.info("Disabling Automatic Event Collection because this browser is not supported");if(!e||!t)return;this._listenerWindow=e,this._listenerDocument=t;const i=this._domEventHandler=t=>{t=t||(null==e?void 0:e.event);try{if("blur"===t.type)return void this._clearPointer();if(0===t.type.indexOf("pointer"))return void this._trackPointer(t);const e="click"===t.type?this._recoverClickTarget(t):void 0;if(bt(e))return;this._captureEvent(t,"$autocapture",e)}catch(e){iu.error("Failed to capture event",e)}};if(Br(e,"blur",i),Br(t,"submit",i,{capture:!0}),Br(t,"change",i,{capture:!0}),Br(t,"click",i,{capture:!0}),Rr(["pointerdown","pointermove","pointerup","pointercancel"],e=>{Br(t,e,i,{capture:!0})}),this._refreshConfig().capture_copied_text){const i=this._copiedTextHandler=t=>{t=t||(null==e?void 0:e.event);try{this._captureEvent(t,eu)}catch(e){iu.error("Failed to capture clipboard event",e)}};Br(t,"copy",i,{capture:!0}),Br(t,"cut",i,{capture:!0}),Br(t,"paste",i,{capture:!0})}}_removeDomEventHandlers(){const e=this._listenerWindow,t=this._listenerDocument;this._clearPointer(),this._domEventHandler&&(null==e||e.removeEventListener("blur",this._domEventHandler),Rr(["pointerdown","pointermove","pointerup","pointercancel"],e=>{null==t||t.removeEventListener(e,this._domEventHandler,!0)}),null==t||t.removeEventListener("submit",this._domEventHandler,!0),null==t||t.removeEventListener("change",this._domEventHandler,!0),null==t||t.removeEventListener("click",this._domEventHandler,!0),this._domEventHandler=void 0),this._copiedTextHandler&&(null==t||t.removeEventListener("copy",this._copiedTextHandler,!0),null==t||t.removeEventListener("cut",this._copiedTextHandler,!0),null==t||t.removeEventListener("paste",this._copiedTextHandler,!0),this._copiedTextHandler=void 0),this._listenerWindow=void 0,this._listenerDocument=void 0,this._initialized=!1}startIfEnabled(){this.isEnabled||this._clearPointer(),!this._disposed&&this._client&&this.isEnabled&&!this._initialized&&(this._addDomEventHandlers(),this._initialized=!0)}onRemoteConfig(e){if(this._disposed)return;if(this._hasReceivedConfigResponse=!0,!e.ok)return void this.startIfEnabled();const t=e.config;t.elementsChainAsString&&(this._elementsChainAsString=t.elementsChainAsString);const i=t.autocapture_opt_out;var s;kt(i)&&(null===(s=this._client)||void 0===s||s.kv.set("$autocapture_disabled_server_side",i),this._isDisabledServerSide=i),this.startIfEnabled()}setElementSelectors(e,t=this){if(this._disposed)return;e.size?this._elementSelectorsByOwner.set(t,new Set(e)):this._elementSelectorsByOwner.delete(t);const i=new Set;this._elementSelectorsByOwner.forEach(e=>{e.forEach(e=>i.add(e))}),this._elementSelectors=i}getElementSelectors(e,t){var i;const s=[];return null===(i=this._elementSelectors)||void 0===i||i.forEach(i=>{var n;const r=null===(n=Zc())||void 0===n?void 0:n.querySelectorAll(i);null==r||r.forEach(n=>{e!==n&&t!==n||ot(s,i)||s.push(i)})}),s}get isEnabled(){var e,t;if(this._disposed)return!1;const i=null===(e=this._client)||void 0===e?void 0:e.kv.get(y),s=this._isDisabledServerSide,n=this._refreshConfig();if(!n.remoteRequestsDisabled&&!this._hasReceivedConfigResponse)return!1;const r=n.remoteRequestsDisabled&&!this._hasReceivedConfigResponse;if(bt(s)&&!kt(i)&&!r)return!1;const o=null!==(t=this._isDisabledServerSide)&&void 0!==t?t:!!i;return!!n.enabled&&!o}_captureEvent(e,t="$autocapture",i){if(!this.isEnabled)return void this._clearPointer();let s=i||Fo(e);So(s)&&(s=s.parentNode||null);const n=this._compileUrlPatterns();var r;"$autocapture"===t&&"click"===e.type&&e instanceof MouseEvent&&n.rageclick&&(null===(r=this.rageclicks)||void 0===r?void 0:r.isRageClick(e.clientX,e.clientY,e.timeStamp||(new Date).getTime()))&&Wo(s,n.rageclick)&&this._captureEvent(e,"$rageclick",i);const o=t===eu,a=o?as(as({},n),{},{dom_event_allowlist:void 0}):n;if(s&&function(e,t,i,s,n,r){var o;const a=typeof window>"u"?void 0:window;if(!a||Vo(e))return!1;if((null==i?void 0:i.url_allowlist)&&!Eo(i.url_allowlist,r))return!1;if((null==i?void 0:i.url_ignorelist)&&Eo(i.url_ignorelist,r))return!1;if(null==i?void 0:i.dom_event_allowlist){const e=i.dom_event_allowlist;if(e&&!e.some(e=>t.type===e))return!1}const{parentIsUsefulElement:l,targetElementList:c}=Go(e,s);if(!function(e,t){const i=null==t?void 0:t.element_allowlist;if(vt(i))return!0;for(const t of e)if(i.some(e=>t.tagName.toLowerCase()===e))return!0;return!1}(c,i))return!1;if(!Ao(c,null==i?void 0:i.css_selector_allowlist))return!1;if(Ao(c,null!==(o=null==i?void 0:i.css_selector_ignorelist)&&void 0!==o?o:Mo))return!1;try{const i=a.getComputedStyle(e);if(i&&"pointer"===i.getPropertyValue("cursor")&&"click"===t.type)return!0}catch(e){}const u=e.tagName.toLowerCase();switch(u){case"html":return!1;case"form":return(n||["submit"]).indexOf(t.type)>=0;case"input":case"select":case"textarea":return(n||["change","click"]).indexOf(t.type)>=0;default:return l?(n||["click"]).indexOf(t.type)>=0:(n||["click"]).indexOf(t.type)>=0&&(To.indexOf(u)>-1||"true"===e.getAttribute("contenteditable"))}}(s,e,a,o,o?["copy","cut","paste"]:void 0,{config:{get_current_url:n.getCurrentUrl}})){var l;const{props:i,explicitNoCapture:r,target:o}=ru(s,{e:e,maskAllElementAttributes:n.maskAllElementAttributes,maskAllText:n.maskAllText,elementAttributeIgnoreList:n.element_attribute_ignorelist,elementsChainAsString:this._elementsChainAsString,disableCaptureUrlHashes:n.disableCaptureUrlHashes});if(r)return!1;const a=this.getElementSelectors(s,o);if(a&&a.length>0&&(i.$element_selectors=a),t===eu){const t=e.type||"clipboard";if("paste"!==t){var c,u;const e=null===(c=Xc())||void 0===c||null===(c=c.getSelection())||void 0===c?void 0:c.toString(),t=Po(e);if(!t)return!1;i.$selected_content=t,i.$clipboard_text_length=null!==(u=null==e?void 0:e.length)&&void 0!==u?u:0}i.$copy_type=t}if("$autocapture"===t&&"change"===e.type&&n.capture_value_css_selector_allowlist&&!n.maskAllText&&(wo(d=s,"input")?!ot(tu,d.type):wo(d,"textarea")||wo(d,"select")&&!d.multiple)&&function(e,t){var i;if(!Ko(e))return!1;const s=null!==(i=t.css_selector_ignorelist)&&void 0!==i?i:Mo,n=new Set;let r=e;for(wo(e,"select")&&(r=e.options[e.selectedIndex]||e);r;){const e=r,t=xo(e);if(n.size>=1e3||n.has(r)||ot(t,"ph-sensitive")||ot(t,"ph-no-capture")||s.some(t=>Ro(e,t)))return!1;n.add(r);const i=r.assignedSlot||r.parentNode;r=Co(i)?i.host:i&&bo(i)?i:null}return!0}(s,n)&&!s.querySelector(".ph-no-capture, .ph-sensitive")){const e=n.capture_value_css_selector_allowlist;let t=!1;try{t=pt(e)?!!e(s):_t(e)&&e.some(e=>Ro(s,e))}catch(e){iu.error("capture_value_css_selector_allowlist threw",e)}t&&(i.$input_value=s.value)}return null===(l=this._client)||void 0===l||l.capture(t,i),!0}var d}isBrowserSupported(){var e;return pt(null===(e=Zc())||void 0===e?void 0:e.querySelectorAll)}};const lu="featureFlags",cu="logs",uu=()=>{var e;return(null==je||null===(e=je.performance)||void 0===e?void 0:e.now)?je.performance.now():Date.now()},du=[50,75,100,150,200,300,400,500,750,1e3,1500,2e3,3e3,5e3,1e4];var hu=class{constructor(e){this._instance=e}initialize(){}get(e){const t=this._instance.persistence;if("string"==typeof e)return null==t?void 0:t.get_property(e);const i={};for(const s of e){const e=null==t?void 0:t.get_property(s);vt(e)||(i[s]=e)}return i}set(e,t){var i;null===(i=this._instance.persistence)||void 0===i||i.register("string"==typeof e?{[e]:t}:e)}remove(e){var t;null===(t=this._instance.persistence)||void 0===t||t.unregister(e)}},_u=class{constructor(e){this.instance=e,this._logger=Ir,this.kv=new hu(e),this.onSession=e=>_l(this.instance.onSessionId(t=>{try{e(t)}catch(e){this._logger.error("Browser extension session listener failed",e)}})),this.onEvent=e=>_l(this.instance._addCaptureHook((t,i)=>{if(i)try{e({event:t,properties:i.properties})}catch(e){this._logger.error("Browser extension event listener failed",e)}})),this.onRemoteConfig=e=>{const t=t=>{try{e(t)}catch(e){this._logger.error("Browser extension remote config listener failed",e)}},i=this.instance._internalEventEmitter.on("extensionsRemoteConfig",t);return this.instance._lastRemoteConfig&&t(this.instance._lastRemoteConfig),_l(i)}}get logger(){return this._logger}get distinctId(){return this.instance.get_distinct_id()}get anonymousId(){var e;return null!==(e=this.instance.get_property("$device_id"))&&void 0!==e?e:this.distinctId}get deviceId(){const e=this.instance.get_property(I);return"string"==typeof e?e:void 0}get library(){return{name:i.LIB_NAME,version:i.LIB_VERSION}}get initialPersonProperties(){var e,t;return null!==(e=null===(t=this.instance.persistence)||void 0===t?void 0:t.get_initial_props())&&void 0!==e?e:{}}get groups(){return this.instance.getGroups()}get session(){try{var e,t,i,s,n;const r=null===(e=this.instance.sessionManager)||void 0===e?void 0:e.checkAndGetSessionAndWindowId(!0);return{sessionId:null!==(t=null==r?void 0:r.sessionId)&&void 0!==t?t:"",windowId:null!==(i=null==r?void 0:r.windowId)&&void 0!==i?i:"",sessionStartTimestamp:null!==(s=null==r?void 0:r.sessionStartTimestamp)&&void 0!==s?s:0,lastActivityTimestamp:null!==(n=null==r?void 0:r.lastActivityTimestamp)&&void 0!==n?n:0}}catch(e){return{sessionId:"",windowId:"",sessionStartTimestamp:0,lastActivityTimestamp:0}}}get isOptedOut(){return this.instance.has_opted_out_capturing()}get canCapture(){return pt(this.instance.is_capturing)?this.instance.is_capturing():!this.isOptedOut}get isRateLimited(){var e;return!!(null===(e=this.instance.rateLimiter)||void 0===e?void 0:e.isClientRateLimited)}get projectToken(){return this.instance.config.token}getExtension(e){let t;switch(e){case lu:case"featureFlagsCommon":t=this.instance.featureFlags;break;case cu:t=this.instance.logs;break;case"surveys":t=this.instance.surveys;break;case ou:t=this.instance.autocapture}return t}capture(e,t,i){if(!i)return this._notRateLimited(this.instance.capture(e,t));const s=as({timestamp:i.timestamp,uuid:i.uuid,$set:i.set,$set_once:i.setOnce},"unload"===i.delivery?{transport:"sendBeacon",send_instantly:!0}:{});return this._notRateLimited(this.instance.capture(e,t,s))}_notRateLimited(e){var t;return!vt(e)||!(null===(t=this.instance.rateLimiter)||void 0===t?void 0:t.lastEventRateLimited)}registerDynamicEventProperties(e){return _l(this.instance._registerExtensionEventProperties(e))}sendRequest(e){var t=this;return Ot(function*(e,i={}){var s;const n=null!==(s=i.target)&&void 0!==s?s:"api",r=i.query?sc(e,i.query):e,o=t.instance.requestRouter.endpointFor(n,r),a={method:i.method,url:o,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?st.Base64:void 0,timestampMode:i.sentAt};return"api"===n&&"/i/v1/logs"===e&&(a.batchKey="logs"),"sendBeacon"===i.transport?(t.instance._send_request(a),{statusCode:202}):new Promise(e=>{var i;if(a.callback=e,"flags"===n&&(null===(i=t.instance.config.metrics)||void 0===i?void 0:i.flags)){let i;a.onDispatch=()=>{i=uu()},a.callback=s=>{vt(i)||t._recordFlagsDuration(o,s,uu()-i),e(s)}}t.instance._send_request(a)})}).apply(this,arguments)}_recordFlagsDuration(e,t,i){try{var s,n,r;const o=t.statusCode||void 0,a={"server.address":(null!==(s=null===(n=Ca(e))||void 0===n?void 0:n.hostname)&&void 0!==s?s:e).replace(/^\[(.*)\]$/,"$1")};o&&(a["http.response.status_code"]=o);const l=((e,t)=>e?400>e?void 0:String(e):"AbortError"===(null==t?void 0:t.name)?"timeout":"_OTHER")(o,t.error);l&&(a["error.type"]=l);const c=Sa();c&&(a["client.timezone"]=c),null===(r=this.instance.metrics)||void 0===r||r.histogram("posthog.flags.request.duration",i,{unit:"ms",attributes:a,bounds:du})}catch(e){Ir.error("Failed to record the /flags request duration",e)}}};const pu={};let gu=0;const fu=()=>{},vu='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',mu="Surveys module not available",yu="sanitize_properties is deprecated. Use before_send instead",bu="Invalid value for property_denylist config: ",wu=["$recording_status","$sdk_debug_recording_script_not_loaded","$sdk_debug_replay_url_trigger_status","$sdk_debug_replay_event_trigger_status","$sdk_debug_replay_linked_flag_trigger_status","$sdk_debug_replay_rrweb_error","$sdk_debug_replay_internal_buffer_length","$sdk_debug_replay_flushed_size"],Su=["$feature_flag_called","$$heatmap","$snapshot"],Cu=e=>"$"===e.charAt(0)&&!ot(Su,e),ku=/^[A-Za-z0-9_-]{1,400}$/,Eu=/^fb\.[0-9]+\.[0-9]+\.[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)?$/,xu=/^fb\.[0-9]+\.[0-9]+\.[0-9]+$/,Pu=["token","distinct_id",Ce],Iu="posthog",Fu=[...Fc].sort()[Fc.length-1],Tu=e=>{const t={};return e&&"unset"!==e?("2025-11-30">e||(t.strictMinimumDuration=!0),"2026-05-30">e||(t.canvasCapture={resolutionScale:.6}),"2026-06-25">e||(t.streamNetworkBody=!0),"2026-08-30">e||(t.captureJsonLd=!0),t):t},Ru=e=>{var t;return as({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,asset_host:null,token:"",autocapture:!0,cross_subdomain_cookie:Nr(null==Ge?void 0:Ge.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:fu,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:null!=e?e:"unset",__preview_deferred_init_extensions:!1,__preview_replay_sync_fetch:!0,__preview_external_dependency_versioned_paths:!1,__preview_cookie_wins_on_conflict:!1,debug:Ke&&mt(null==Ke?void 0:Ke.search)&&-1!==Ke.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==je||null===(t=je.location)||void 0===t?void 0:t.protocol),ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_flags:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_only_evaluate_survey_feature_flags:!1,advanced_feature_flags_dedup_per_session:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,feature_flag_request_max_retries:1,surveys_request_timeout_ms:1e4,on_request_error(e){Ir.error("Bad HTTP status: "+e.statusCode+" "+e.text)},get_device_id:e=>e,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:Ne,before_send:void 0,get_current_url:void 0,request_queue_config:{flush_interval_ms:3e3},error_tracking:{},_onCapture:fu},(e=>({rageclick:e&&e>="2026-05-30"?{content_ignorelist:Oo,ignore_text_selection:!0}:!e||"2025-11-30">e||{content_ignorelist:!0},capture_pageview:!e||"2025-05-24">e||"history_change",session_recording:Tu(e),external_scripts_inject_target:e&&e>="2026-01-30"?"head":"body",internal_or_test_user_hostname:e&&e>="2026-01-30"?/^(localhost|127\.0\.0\.1)$/:void 0,persistence_save_debounce_ms:e&&e>="2026-05-30"?250:0,split_storage:!(!e||"2026-05-30">e),detect_google_search_app:!(!e||"2026-05-30">e),disable_capture_url_hashes:!(!e||"2026-06-25">e),cookieWinsOnConflict:!(!e||"unset"===e||"2026-08-29">e)}))(e))},Au=[["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"]],$u=e=>{const t={};for(const[i,s]of Au)vt(e[i])||(t[s]=e[i]);const i=Ar({},t,e),s=e.__preview_external_dependency_versioned_paths;return vt(s)||(vt(e.strict_script_versioning)&&(i.strict_script_versioning=!!s),mt(s)&&vt(e.asset_host)&&(i.asset_host=s)),_t(e.property_blacklist)&&(vt(e.property_denylist)?i.property_denylist=e.property_blacklist:_t(e.property_denylist)?i.property_denylist=[...e.property_blacklist,...e.property_denylist]:Ir.error(bu+e.property_denylist)),i};var Mu=class{constructor(){this.__forceAllowLocalhost=!1}get _forceAllowLocalhost(){return this.__forceAllowLocalhost}set _forceAllowLocalhost(e){Ir.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}},Lu=class e{_removeExtension(e){if(!e)return;const t=this._extensions.indexOf(e);-1!==t&&this._extensions.splice(t,1)}_replaceExtension(e,t){var i;return this._removeExtension(e),this._extensions.push(t),null===(i=t.initialize)||void 0===i||i.call(t),t}_inCookielessMode(){return"always"===this.config.cookieless_mode||"on_reject"===this.config.cookieless_mode&&this.consent.isRejected()}_warnIfVolatileIdentityWithoutStableId(){if(this._hasWarnedAboutVolatileIdentity)return;if(this.config.reuseAnonymousId)return;if(this.config.segment)return;if(this._inCookielessMode())return;const e="memory"===this.config.persistence||"sessionStorage"===this.config.persistence;if(!e&&!this.config.disable_persistence)return;if(this._hasStableInitialDistinctId)return;let t,i,s;e?(t=`persistence is set to '${this.config.persistence}'`,i="memory"===this.config.persistence?"on every page load":"for every new browser tab or window",s="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",s="Either set disable_persistence to false, keep persistence disabled and pass a stable ID through bootstrap.distinctID, or enable reuseAnonymousId."),this._hasWarnedAboutVolatileIdentity=!0,console.warn("[PostHog.js]",`${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. ${s}`)}_syncCookielessIdentity(){const e=this.persistence;if(!e||this._isConsentTransition)return;if(this._inCookielessMode())return void("on_reject"===this.config.cookieless_mode&&"$posthog_cookieless"!==this.get_distinct_id()&&(this._sync_opt_out_with_persistence(),this._enterCookielessMode()));if("$posthog_cookieless"!==this.get_distinct_id())return;this._is_persistence_disabled()||e.load(!0);const t=this.get_distinct_id();if(!t||"$posthog_cookieless"===t){const t=this.config.get_device_id(Kr());this.register({distinct_id:t,$device_id:t}),e.set_property(ge,Oe)}this._sync_opt_out_with_persistence()}get decideEndpointWasHit(){var e,t;return null!==(e=null===(t=this.featureFlags)||void 0===t?void 0:t.hasLoadedFlags)&&void 0!==e&&e}get flagsEndpointWasHit(){var e,t;return null!==(e=null===(t=this.featureFlags)||void 0===t?void 0:t.hasLoadedFlags)&&void 0!==e&&e}constructor(){var t;this._isPageUnloading=!1,this._isShutdown=!1,this.webPerformance=new Mu,this._personProcessingSetOncePropertiesSent=!1,this.version=i.LIB_VERSION,this._sessionRegisteredPropKeys=new Set,this._sessionRegisteredPropertiesStorageKey="",this._internalEventEmitter=new Ec,this._extensions=[],this._extensionEventPropertyProducers=[],this._replayDebugPropertiesPaused=!1,this._hasStableInitialDistinctId=!1,this._hasWarnedAboutVolatileIdentity=!1,this._isConsentTransition=!1,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=Ru(),this.SentryIntegration=fa,this.sentryIntegration=e=>function(e,t){const i=ga(e,t);return{name:pa,processEvent:e=>i(e)}}(this,e),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this._initialPageviewCaptured=!1,this._visibilityStateListener=null,this._initialPersonProfilesConfig=null,this._cachedPersonProperties=null,this.scrollManager=new Sc(this),this.pageViewManager=new va(this),this.rateLimiter=new gl(this),this.requestRouter=new qc(this),this.consent=new vo(this),this.externalIntegrations=new Jc(this);const s=null!==(t=e.__defaultExtensionClasses)&&void 0!==t?t:{};this.featureFlags=s.featureFlags&&new s.featureFlags(this),this.toolbar=s.toolbar&&new s.toolbar(this),this.surveys=s.surveys&&new s.surveys(this),this.conversations=s.conversations&&new s.conversations(this),this.logs=s.logs&&new s.logs(this),this.metrics=s.metrics&&new s.metrics(this),this.experiments=s.experiments&&new s.experiments(this),this.exceptions=s.exceptions&&new s.exceptions(this),this.people={set:(e,t,i)=>{const s=mt(e)?{[e]:t}:e;this.setPersonProperties(s),null==i||i({})},set_once:(e,t,i)=>{const s=mt(e)?{[e]:t}:e;this.setPersonProperties(void 0,s),null==i||i({})}},this.on("eventCaptured",e=>Ir.info(`send "${null==e?void 0:e.event}"`,e))}init(t,i,s){if(s&&s!==Iu){var n;const r=null!==(n=pu[s])&&void 0!==n?n:new e;return r._init(t,i,s),pu[s]=r,pu[Iu][s]=r,r}return this._init(t,i,s)}_init(e,t={},s){var n,r,o;const a=mt(e)?e.trim():"";if(!a)return Ir.critical("PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()"),this;var l;if(this.__loaded)return a!==(null===(l=this.config)||void 0===l?void 0:l.token)?console.warn("[PostHog.js]",`You have already initialized PostHog with a different project token! Re-initializing is a no-op, so events will keep going to the project this instance was initialized with. To capture into a second project, load PostHog once, then initialize a named instance after the SDK has loaded, e.g. posthog.init('${a}', { ... }, 'project2')`):console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config=Ru(t.defaults),t.debug=this._checkLocalStorageForDebug(t.debug),this._originalUserConfig=t,this._triggered_notifs=[],t.person_profiles?this._initialPersonProfilesConfig=t.person_profiles:t.process_person&&(this._initialPersonProfilesConfig=t.process_person);const c=Ru(t.defaults),u=$u(t),d=Ar({},c,u,{name:s,token:a});gt(c.rageclick)&>(u.rageclick)&&(d.rageclick=Ar({},c.rageclick,u.rageclick)),gt(c.session_recording)&>(u.session_recording)&&(d.session_recording=Ar({},c.session_recording,u.session_recording)),this.set_config(d),this.config.on_xhr_error&&Ir.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=t.disable_compression?void 0:nl;const h=this._is_persistence_disabled(),_=!this._inCookielessMode();if(this.persistence=new sl(this.config,h,!0,_),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new sl(as(as({},this.config),{},{persistence:"sessionStorage"}),h,!1,_),this._sessionRegisteredPropertiesStorageKey="ph_"+(this.config.persistence_name||this.config.token)+"_session_registered_properties","memory"!==this.config.persistence&&!h&&fo._is_supported()){const e=fo._parse(this._sessionRegisteredPropertiesStorageKey);_t(e)&&e.forEach(e=>{mt(e)&&this._sessionRegisteredPropKeys.add(e)})}else fo._remove(this._sessionRegisteredPropertiesStorageKey);const p=as({},this.persistence.props),g=as({},this.sessionPersistence.props);this.register({$initialization_time:(new Date).toISOString()}),this._requestQueue=new yc((e,t)=>this._send_retriable_request(e,t),this.config.request_queue_config),this._retryQueue=new wc(this),this.__request_queue=[];const f=this._inCookielessMode();f||(this.sessionManager=new Ic(this),this.sessionPropsManager=new kc(this,this.sessionManager,this.persistence),this.sessionManager.onSessionId((e,t,i)=>{((null==i?void 0:i.activityTimeout)||(null==i?void 0:i.sessionPastMaximumLength)||(null==i?void 0:i.crossTabAdoption))&&this._clearSessionRegisteredProps()})),this._enrollFeatureFlags(),this.config.__preview_deferred_init_extensions?(Ir.info("Deferring extension initialization to improve startup performance"),this._extensionInitTimeout=setTimeout(()=>{this._extensionInitTimeout=void 0,this._initExtensions(f)},0)):(Ir.info("Initializing extensions synchronously"),this._initExtensions(f)),i.DEBUG=i.DEBUG||this.config.debug,i.DEBUG&&Ir.info("Starting in debug mode",{this:this,config:t,thisC:as({},this.config),p:p,s:g}),this.config.identity_distinct_id&&!(null===(n=t.bootstrap)||void 0===n?void 0:n.distinctID)&&(t.bootstrap=as(as({},t.bootstrap),{},{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0}));const v=null===(r=t.bootstrap)||void 0===r?void 0:r.distinctID;if(this._hasStableInitialDistinctId=!!v&&!yt(v),null===(o=t.bootstrap)||void 0===o?void 0:o.distinctID){const e=t.bootstrap.distinctID,i=this.get_distinct_id(),s=this.persistence.get_property(ge);if(t.bootstrap.isIdentifiedID&&null!=i&&i!==e&&"anonymous"===s)this.identify(e);else if(t.bootstrap.isIdentifiedID&&null!=i&&i!==e&&"identified"===s)Ir.warn("Bootstrap distinctID differs from an already-identified user. The existing identity is preserved. Call reset() before reinitializing if you intend to switch users.");else{const i=this.config.get_device_id(Kr()),s=t.bootstrap.isIdentifiedID?i:e;this.persistence.set_property(ge,t.bootstrap.isIdentifiedID?De:Oe),this.register({distinct_id:e,$device_id:s})}}if(f)this.register_once({distinct_id:Se,$device_id:null},"");else if(!this.get_distinct_id()){const e=this.config.get_device_id(Kr());this.register_once({distinct_id:e,$device_id:e},""),this.persistence.set_property(ge,Oe)}return Br(je,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),Br(je,"pageshow",e=>{if(this._isPageUnloading=!1,!this._isShutdown){var t;if(e.persisted&&this.persistence){const e=this.persistence.get_property(P),t=this.persistence.get_property(ge);this.persistence.load(),this._processCookieIdentityChange()||e===this.persistence.get_property("distinct_id")&&t===this.persistence.get_property("$user_state")||this._processIdentityChange()}null===(t=this._retryQueue)||void 0===t||t.resume()}}),t.segment?_a(this,()=>this._loaded()):this._loaded(),pt(this.config._onCapture)&&this.config._onCapture!==fu&&(Ir.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",e=>this.config._onCapture(e.event,e))),this.config.ip&&Ir.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 Rc.apply(this,arguments)}().then(e=>{e&&this.register({[F]:e})}).catch(fu),this}_isSharedExtension(e){const t=e;return mt(t.name)&&pt(t.setup)}_enrollExtension(e,t){var i=this;this._isSharedExtension(e)?t.push(Ot(function*(){try{yield e.setup(i._getBrowserClientAdapter())}catch(i){Ir.error(`Failed to set up extension "${e.name}"`,i);try{var t;yield null===(t=e.dispose)||void 0===t?void 0:t.call(e)}catch(t){Ir.error(`Failed to dispose extension "${e.name}"`,t)}}})):this._extensions.push(e)}_enrollFeatureFlags(){var t,i,s,n=this;const r=null!==(t=null===(i=this.config.__extensionClasses)||void 0===i?void 0:i.featureFlags)&&void 0!==t?t:null===(s=e.__defaultExtensionClasses)||void 0===s?void 0:s.featureFlags;var o,a,l;if(r)if(this.featureFlags&&this.featureFlags instanceof r||(null===(o=this._featureFlagsReloadingUnsubscribe)||void 0===o||o.call(this),this._featureFlagsReloadingUnsubscribe=void 0,this.featureFlags=new r(this)),pt(this.featureFlags.onReloading)&&pt(this.featureFlags.setup)){if(!this._featureFlagsReloadingUnsubscribe){this._featureFlagsReloadingUnsubscribe=this.featureFlags.onReloading(()=>{this._internalEventEmitter.emit("featureFlagsReloading",!0)});const e=this.featureFlags;Ot(function*(){try{yield e.setup(n._getBrowserClientAdapter())}catch(t){Ir.error("Failed to set up feature flags",t);const i=n._featureFlagsReloadingUnsubscribe;n._featureFlagsReloadingUnsubscribe=void 0;try{null==i||i()}catch(e){Ir.error("Failed to unsubscribe feature flag reloading",e)}try{yield e.dispose()}catch(e){Ir.error("Failed to dispose feature flags",e)}}})()}}else null===(a=(l=this.featureFlags).initialize)||void 0===a||a.call(l)}_initExtensions(t){const i=performance.now(),s=as(as({},e.__defaultExtensionClasses),this.config.__extensionClasses),n=[];var r,o,a,l,c,u,d,h;s.exceptions&&this._extensions.push(this.exceptions=null!==(r=this.exceptions)&&void 0!==r?r:new s.exceptions(this)),s.historyAutocapture&&this._extensions.push(this.historyAutocapture=new s.historyAutocapture(this)),s.tracingHeaders&&this._extensions.push(this.tracingHeaders=new s.tracingHeaders(this)),s.siteApps&&this._extensions.push(this.siteApps=new s.siteApps(this)),s.sessionRecording&&!t&&this._extensions.push(this.sessionRecording=new s.sessionRecording(this)),this.config.disable_scroll_properties||n.push(()=>{this.scrollManager.startMeasuringScrollPosition()}),s.autocapture&&this._enrollExtension(this.autocapture=new s.autocapture(this),n),s.surveys&&this._enrollExtension(this.surveys=null!==(o=this.surveys)&&void 0!==o?o:new s.surveys(this),n),s.logs&&this._enrollExtension(this.logs=null!==(a=this.logs)&&void 0!==a?a:new s.logs(this),n),s.metrics&&this._extensions.push(this.metrics=null!==(l=this.metrics)&&void 0!==l?l:new s.metrics(this)),s.conversations&&this._extensions.push(this.conversations=null!==(c=this.conversations)&&void 0!==c?c:new s.conversations(this)),s.productTours&&this._extensions.push(this.productTours=new s.productTours(this)),s.heatmaps&&this._extensions.push(this.heatmaps=new s.heatmaps(this)),s.webVitalsAutocapture&&this._extensions.push(this.webVitalsAutocapture=new s.webVitalsAutocapture(this)),s.exceptionObserver&&this._extensions.push(this.exceptionObserver=new s.exceptionObserver(this)),s.deadClicksAutocapture&&this._extensions.push(this.deadClicksAutocapture=new s.deadClicksAutocapture(this,ua)),s.toolbar&&this._extensions.push(this.toolbar=null!==(u=this.toolbar)&&void 0!==u?u:new s.toolbar(this)),s.experiments&&this._extensions.push(this.experiments=null!==(d=this.experiments)&&void 0!==d?d:new s.experiments(this)),s.webMCP&&this._extensions.push(this.webMCP=null!==(h=this.webMCP)&&void 0!==h?h:new s.webMCP(this)),this._extensions.forEach(e=>{e.initialize&&n.push(()=>{var t;null===(t=e.initialize)||void 0===t||t.call(e)})}),n.push(()=>{if(this._pendingRemoteConfig){const e=this._pendingRemoteConfig;this._pendingRemoteConfig=void 0,this._extensions.forEach(t=>{var i;return null===(i=t.onRemoteConfig)||void 0===i?void 0:i.call(t,e)})}}),this._processInitTaskQueue(n,i)}_processInitTaskQueue(e,t){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-t>=30&&e.length>0)return void(this._extensionInitTimeout=setTimeout(()=>{this._extensionInitTimeout=void 0,this._processInitTaskQueue(e,t)},0));const i=e.shift();if(i)try{i()}catch(e){Ir.error("Error initializing extension:",e)}}const i=Math.round(performance.now()-t);this.register_for_session({[ke]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[Ee]:i}),this.config.__preview_deferred_init_extensions&&Ir.info(`PostHog extensions initialized (${i}ms)`)}_onRemoteConfig(e){if(!Ge||!Ge.body)return Ir.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout(()=>{this._onRemoteConfig(e)},500);if(this.config.__preview_deferred_init_extensions&&(this._pendingRemoteConfig=e),this._lastRemoteConfig=e,this.compression=void 0,e.ok){var t;const i=e.config;i.supportedCompression&&!this.config.disable_compression&&(this.compression=ot(i.supportedCompression,nl)?nl:ot(i.supportedCompression,rl)?rl:void 0),(null===(t=i.analytics)||void 0===t?void 0:t.endpoint)&&(this.analyticsDefaultEndpoint=i.analytics.endpoint)}this.set_config({person_profiles:this._initialPersonProfilesConfig?this._initialPersonProfilesConfig:Ne}),this._internalEventEmitter.emit("extensionsRemoteConfig",e),this._extensions.forEach(t=>{var i;return null===(i=t.onRemoteConfig)||void 0===i?void 0:i.call(t,e)})}_loaded(){try{this.config.loaded(this)}catch(e){Ir.critical("`loaded` function failed",e)}if(this._start_queue_if_opted_in(),this.config.internal_or_test_user_hostname&&(null==Ke?void 0:Ke.hostname)){const e=Ke.hostname,t=this.config.internal_or_test_user_hostname;("string"==typeof t?e===t:t.test(e))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout(()=>{(this.consent.isOptedIn()||this._inCookielessMode())&&this._captureInitialPageview()},1),this._remoteConfigLoader=new vl(this),this._remoteConfigLoader.load()}_start_queue_if_opted_in(){var e;this.is_capturing()&&this.config.request_batching&&(null===(e=this._requestQueue)||void 0===e||e.enable())}_dom_loaded(){this.is_capturing()&&Tr(this.__request_queue,e=>this._send_retriable_request(e)),this.__request_queue=[],this._start_queue_if_opted_in()}_handle_unload(){var e,t,i,s,n,r;this._isPageUnloading=!0,null===(e=this.surveys)||void 0===e||null===(t=e.handlePageUnload)||void 0===t||t.call(e),null===(i=this.metrics)||void 0===i||i.flush("sendBeacon"),this.config.request_batching?(this._shouldCapturePageleave()&&this.capture(He),null===(s=this.logs)||void 0===s||s.flushLogs("sendBeacon"),null===(n=this._requestQueue)||void 0===n||n.unload(),null===(r=this._retryQueue)||void 0===r||r.unload()):this._shouldCapturePageleave()&&this.capture(He,null,{transport:"sendBeacon"})}_send_request(e){mc(this,e)}_send_retriable_request(e,t){this._retryQueue?this._retryQueue.retriableRequest(e,t):this._send_request(t?as(as({},e),{},{transport:t}):e)}_execute_array(e){gu++;try{let t;const i=[],s=[],n=[];Tr(e,e=>{if(e)if(t=e[0],_t(t))n.push(e);else if(pt(e))try{e.call(this)}catch(t){Ir.error("Error executing queued PostHog call",e,t)}else _t(e)&&"alias"===t?i.push(e):_t(e)&&-1!==t.indexOf("capture")&&pt(this[t])?n.push(e):s.push(e)});const r=function(e,t){Tr(e,function(e){try{if(_t(e[0])){let i=t;Rr(e,function(e){i=i[e[0]].apply(i,e.slice(1))})}else t[e[0]].apply(t,e.slice(1))}catch(t){Ir.error("Error executing queued PostHog call",e,t)}})};r(i,this),r(s,this),r(n,this)}finally{gu--}}push(t){if(gu>0&&_t(t)&&mt(t[0])){const i=e.prototype[t[0]];return void(pt(i)&&i.apply(this,t.slice(1)))}this._execute_array([t])}get _facebookClickIdChannel(){return{property:A,persistenceKey:M,cookieName:"_fbc",pattern:Eu,register:(e,t)=>{var i;return null===(i=this.persistence)||void 0===i?void 0:i.register({[M]:{value:e,delivered:t}})},unregister:()=>{var e;return null===(e=this.persistence)||void 0===e?void 0:e.unregister(M)}}}get _facebookBrowserIdChannel(){return{property:L,persistenceKey:O,cookieName:"_fbp",pattern:xu,register:(e,t)=>{var i;return null===(i=this.persistence)||void 0===i?void 0:i.register({[O]:{value:e,delivered:t}})},unregister:()=>{var e;return null===(e=this.persistence)||void 0===e?void 0:e.unregister(O)}}}_getPersistedMetaIdentifier(e){var t;const i=null===(t=this.persistence)||void 0===t?void 0:t.get_property(e.persistenceKey);return mt(i)&&e.pattern.test(i)?{value:i,delivered:!1}:gt(i)&&mt(i.value)&&e.pattern.test(i.value)?{value:i.value,delivered:!0===i.delivered}:void 0}_storeMetaIdentifier(e,t,i){return t===(null==i?void 0:i.value)?{value:t,pending:!i.delivered}:(e.register(t,!1),{value:t,pending:!0})}_readMetaCookie(e){if(!this.config.save_campaign_params||this._inCookielessMode())return;const t=Hr(e.cookieName);return mt(t)&&e.pattern.test(t)?t:void 0}_updateFacebookClickId(e,t,i,s){if(!this.persistence)return;const n=this._facebookClickIdChannel;this.persistence.refreshMetaIdentifiers();const r=this._getPersistedMetaIdentifier(n);if(s)return void n.unregister();if(i)return mt(t)&&Eu.test(t)?this._storeMetaIdentifier(n,t,r):void n.unregister();const o=mt(e)&&ku.test(e)?e:void 0,a=this._readMetaCookie(n);return a&&((e,t,i)=>{const s=e.split(".");if(t)return s[3]===t;if(!i)return!0;const n=i.value.split(".");return s[3]===n[3]||Number(s[2])>Number(n[2])})(a,o,r)?this._storeMetaIdentifier(n,a,r):o?(null==r?void 0:r.value.split(".")[3])===o?{value:r.value,pending:!r.delivered}:this._storeMetaIdentifier(n,`fb.1.${Date.now()}.${o}`,r):r?{value:r.value,pending:!r.delivered}:void 0}_updateFacebookBrowserId(e,t,i){if(!this.persistence)return;const s=this._facebookBrowserIdChannel;this.persistence.refreshMetaIdentifiers();const n=this._getPersistedMetaIdentifier(s);if(i)return void s.unregister();if(t)return mt(e)&&xu.test(e)?this._storeMetaIdentifier(s,e,n):void s.unregister();const r=this._readMetaCookie(s);return r?this._storeMetaIdentifier(s,r,n):n?{value:n.value,pending:!n.delivered}:void 0}_markMetaIdentifierDelivered(e,t){if(!this.persistence)return;this.persistence.refreshMetaIdentifiers();const i=this._getPersistedMetaIdentifier(e);(null==i?void 0:i.value)!==t||i.delivered||e.register(t,!0)}capture(e,t,i){var s,n,r;if(!(this.__loaded&&this.persistence&&this.sessionPersistence&&this._requestQueue))return void Ir.uninitializedWarning("posthog.capture");if(!this.is_capturing())return void Ir.info(`Event "${e}" was not captured because capturing is disabled (opted out or consent pending).`);if(vt(e)||!mt(e))return void Ir.error("No event name provided to posthog.capture");if(this._syncCookielessIdentity(),"$snapshot"===e&&this._inCookielessMode())return;const o=!this.config.opt_out_useragent_filter&&this._is_bot();if(o&&!this.config.__preview_capture_bot_pageviews)return void Ir.info(`Event "${e}" was not captured because the user agent looks like a bot. Set \`opt_out_useragent_filter: true\` to capture it.`);const a=(null==i?void 0:i.skip_client_rate_limiting)?void 0:this.rateLimiter.clientRateLimitContext();if(null==a?void 0:a.isRateLimited)return void Ir.critical("This capture call is ignored due to client rate limiting.");let l;(null==t?void 0:t.$current_url)&&!mt(null==t?void 0:t.$current_url)&&(Ir.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),null==t||delete t.$current_url),"$exception"!==e||(null==i?void 0:i._originatedFromCaptureException)||Ir.warn("Using `posthog.capture('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureException(error)` instead, which attaches required metadata automatically."),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&(l=this.sessionPersistence.update_campaign_params()),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();const c=new Date,u=(null==i?void 0:i.timestamp)||c,d=Yi(null==i?void 0:i.uuid,Kr);let h={uuid:d,event:e,properties:this.calculateEventProperties(e,t||{},u,d)};"$pageview"===e&&this.config.__preview_capture_bot_pageviews&&o&&(h.event="$bot_pageview",h.properties.$browser_type="bot"),a&&(h.properties.$lib_rate_limit_remaining_tokens=a.remainingTokens);const _="$feature_flag_called"===e&&!1===h.properties.$feature_flag_has_experiment&&!0===this.get_property("$minimal_flag_called_events");(null==i?void 0:i.$set)&&!_&&(h.$set=null==i?void 0:i.$set);const p=gt(null==t?void 0:t.$set)?t.$set:void 0,g=_t(null==t?void 0:t.$unset)?t.$unset:[],f=(null==i?void 0:i.$unset)||[],v=e=>{var t;const s=!!(null==i?void 0:i.$set)&&e in i.$set;return{hasProvided:s||!!p&&e in p,provided:s?null==i||null===(t=i.$set)||void 0===t?void 0:t[e]:null==p?void 0:p[e],unset:-1!==g.indexOf(e)||-1!==f.indexOf(e)}},m=v(A),y=v(L),b=[{channel:this._facebookClickIdChannel,hasProvided:m.hasProvided,update:this._updateFacebookClickId(null==l?void 0:l.fbclid,m.provided,m.hasProvided,m.unset)},{channel:this._facebookBrowserIdChannel,hasProvided:y.hasProvided,update:this._updateFacebookBrowserId(y.provided,y.hasProvided,y.unset)}];for(const{channel:e,hasProvided:t,update:i}of b)i&&!0===h.properties.$process_person_profile&&i.pending&&!t&&!_&&(h.$set=as({[e.property]:i.value},h.$set));const w=null==i?void 0:i.$unset;w&&(h.$unset=w);const S=_?void 0:this._calculate_set_once_properties(null==i?void 0:i.$set_once,e!==qe,e===Ue);if(S&&(h.$set_once=S),(null==i?void 0:i._noTruncate)||(C=this.config.properties_string_max_length,h=function(e,t){const i=new Set;return function e(s,n){if(s!==Object(s))return t?t(s):s;if(i.has(s))return;let r;if(i.add(s),_t(s))r=[],Tr(s,t=>{r.push(e(t))});else{const t={};Rr(Ft(s)?Or(s):s,(s,n)=>{i.has(s)||(t[n]=e(s,n))}),r=t}return r}(e)}(h,e=>mt(e)?e.slice(0,C):e)),h.timestamp=u,vt(null==i?void 0:i.timestamp)||(h.properties.$event_time_override_provided=!0,h.properties.$event_time_override_system_time=c),_&&(h.properties=((e,t=[])=>{const i={},s=t=>{void 0!==e[t]&&(i[t]=e[t])};return sn.forEach(s),t.forEach(s),i})(h.properties,Pu)),e===cl||e===ul){const i=null==t?void 0:t.$survey_id,s=null==t?void 0:t.$survey_iteration;Wc({id:i,current_iteration:s}),h.$set=as(as({},h.$set),{},{[Ac({id:i,current_iteration:s},e===ul?"responded":"dismissed")]:!0})}else e===ll&&(h.$set=as(as({},h.$set),{},{[dl]:(new Date).toISOString()}));var C;if("product tour shown"===e){const e=null==t?void 0:t.$product_tour_type;e&&(h.$set=as(as({},h.$set),{},{[`$product_tour_last_seen_date/${e}`]:(new Date).toISOString()}))}const k=as(as({},h.properties.$set),h.$set);if(ft(k)||this.setPersonPropertiesForFlags(k),!wt(this.config.before_send)){const e=this._runBeforeSend(h);if(!e)return;h=e,h.uuid=Yi(h.uuid,Kr)}this.sessionRecording&&!this._replayDebugPropertiesPaused&&Cu(e)&&(this._replayDebugPropertiesPaused=!0,setTimeout(()=>this._replayDebugPropertiesPaused=!1,3e4));const E=b.filter(({channel:e,update:t})=>{var i,s,n;const r=null!==(i=null===(s=h.$set)||void 0===s?void 0:s[e.property])&&void 0!==i?i:gt(null===(n=h.properties)||void 0===n?void 0:n.$set)?h.properties.$set[e.property]:void 0;return(null==t?void 0:t.pending)&&r===t.value});this._internalEventEmitter.emit("eventCaptured",h);const x=null!==(s=null==i?void 0:i._url)&&void 0!==s?s:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),P="recordings"===(null==i?void 0:i._batchKey)||/\/s\/(?:\?|$)/.test(x),I=as(as(as({method:"POST",url:x,data:h,compression:"best-available",preferSyncCompression:null==i?void 0:i.send_instantly,timestampMode:P?"body":"capture-body",batchKey:null==i?void 0:i._batchKey},P&&(null===(n=h.properties)||void 0===n?void 0:n.$session_id)?{batchGroup:h.properties.$session_id+(h.properties.$window_id?`-${h.properties.$window_id}`:"")}:{}),(null==i?void 0:i.transport)?{transport:i.transport}:{}),E.length?{fireCallbackOnDrop:!0,callback:e=>{if(e.statusCode>=200&&300>e.statusCode)for(const{channel:e,update:t}of E)this._markMetaIdentifierDelivered(e,t.value)}}:{});if(!this.config.request_batching||i&&!(null==i?void 0:i._batchKey)||(null==i?void 0:i.send_instantly)){var F;let e;!I.transport&&!I.callback&&ft(null!==(F=this.config.request_headers)&&void 0!==F?F:{})&&this._isPageUnloading&&(e="sendBeacon"),this._send_retriable_request(I,e)}else this._requestQueue.enqueue(I);return null===(r=this.featureFlags)||void 0===r||r.sendFlagCallsPendingCapture(),h}_addCaptureHook(e){return this.on("eventCaptured",t=>e(t.event,t))}getExtension(e){var t;return null===(t=this._browserClientAdapter)||void 0===t?void 0:t.getExtension(e)}_getBrowserClientAdapter(){var e;return null!==(e=this._browserClientAdapter)&&void 0!==e?e:this._browserClientAdapter=new _u(this)}_registerExtensionEventProperties(e){this._extensionEventPropertyProducers.push(e);let t=!0;return()=>{if(!t)return;t=!1;const i=this._extensionEventPropertyProducers.indexOf(e);-1!==i&&this._extensionEventPropertyProducers.splice(i,1)}}_processCookieIdentityChange(e=!0){var t;return!!(null===(t=this.persistence)||void 0===t?void 0:t.consumeCookieIdentityChange())&&(this._processIdentityChange(e),!0)}_processIdentityChange(e=!0){var t,i,s;this._cachedPersonProperties=null,"anonymous"===(null===(t=this.persistence)||void 0===t?void 0:t.get_property("$user_state"))&&(null===(s=this.sessionPersistence)||void 0===s||s.clear(),this._sessionRegisteredPropKeys.clear(),this._persistSessionRegisteredPropKeys()),null===(i=this.featureFlags)||void 0===i||i.reset(),e&&this.reloadFeatureFlags()}calculateEventProperties(e,i,s,n,r){if(s=s||new Date,!this.persistence||!this.sessionPersistence)return i;this._syncCookielessIdentity(),this.persistence.syncCookieProperties(),this._processCookieIdentityChange();const o=r?void 0:this.persistence.remove_event_timer(e);let a=as({},i);if(a.token=this.config.token,a.$config_defaults="latest"===this.config.defaults?Fu:this.config.defaults,this._inCookielessMode()&&(a[Ce]=!0),"$snapshot"===e){const e=as(as({},this.persistence.properties()),this.sessionPersistence.properties());return a.distinct_id=e.distinct_id,(!mt(a.distinct_id)&&!St(a.distinct_id)||yt(a.distinct_id))&&Ir.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),a}const l=function(e,i,s,n=!1){var r,o,a,l;if(!Ze)return{};const c=e?[...Ra,...i||[]]:[],[u,d]=Bi(Ze),[h,_]=function(e){for(let t=0;qi.length>t;t++){const[i,s,n]=qi[t],r=e.match(i);if(r){const t=n&&e.match(n)||r;return[s,(null==t?void 0:t[1])||""]}}return["",""]}(Ze),p=function(){const e="u">typeof navigator?navigator:void 0;return(null==e?void 0:e.brave)?{brave:!0}:{}}(),g={};vt(s)||(g.detectGoogleSearchApp=s);const f={},v=null===(r=navigator)||void 0===r||null===(r=r.userAgentData)||void 0===r?void 0:r.platform,m=null===(o=navigator)||void 0===o?void 0:o.maxTouchPoints,y=null==je||null===(a=je.screen)||void 0===a?void 0:a.width,b=null==je||null===(l=je.screen)||void 0===l?void 0:l.height,w=null==je?void 0:je.devicePixelRatio;vt(v)||(f.userAgentDataPlatform=v),vt(m)||(f.maxTouchPoints=m),vt(y)||(f.screenWidth=y),vt(b)||(f.screenHeight=b),vt(w)||(f.devicePixelRatio=w);const S=Ar(Lr({$os:u,$os_version:d,$browser:Li(Ze,navigator.vendor,p,g),$webview_app:h,$webview_app_version:_,$device:zi(Ze),$device_type:Hi(Ze,f),$timezone:Sa(),$timezone_offset:ja()}),{$current_url:Fa(n?Zi(null==Ke?void 0:Ke.href):null==Ke?void 0:Ke.href,c,$a),$host:null==Ke?void 0:Ke.host,$pathname:null==Ke?void 0:Ke.pathname,$raw_user_agent:Ze.length>1e3?Ze.substring(0,997)+"...":Ze,$browser_version:Di(Ze,navigator.vendor,p,g),$browser_language:Na(),$browser_language_prefix:Ba(),$screen_height:null==je?void 0:je.screen.height,$screen_width:null==je?void 0:je.screen.width,$viewport_height:null==je?void 0:je.innerHeight,$viewport_width:null==je?void 0:je.innerWidth,$lib:t.LIB_NAME,$lib_version:t.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3});return t.SDK_DIST_CHANNEL&&(S.$sdk_dist_channel=t.SDK_DIST_CHANNEL),S}(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties,this.config.detect_google_search_app,this.config.disable_capture_url_hashes);if(this.sessionManager){const{sessionId:e,windowId:t}=this.sessionManager.checkAndGetSessionAndWindowId(r,s.getTime(),!0);a.$session_id=e,a.$window_id=t}this.sessionPropsManager&&Ar(a,this.sessionPropsManager.getSessionProps());try{var c;if(this.sessionRecording){const t=this.sessionRecording.sdkDebugProperties,i=!this._replayDebugPropertiesPaused&&Cu(e);for(const e in t)(i||ot(wu,e))&&(a[e]=t[e])}a.$sdk_debug_retry_queue_size=null===(c=this._retryQueue)||void 0===c?void 0:c.length}catch(e){a.$sdk_debug_error_capturing_properties=String(e)}let u;if(this.requestRouter.region===Bc&&(a.$lib_custom_api_host=this.config.api_host),u="$pageview"!==e||r?"$pageleave"!==e||r?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(s):this.pageViewManager.doPageView(s,n),a=Ar(a,u),"$pageview"===e&&Ge&&(a.title=Ge.title),!vt(o)){const e=s.getTime()-o;a.$duration=parseFloat((e/1e3).toFixed(3))}Ze&&this.config.opt_out_useragent_filter&&(a.$browser_type=this._is_bot()?"bot":"browser");const d=this.persistence.properties(),h=this.sessionPersistence.properties(),_=a.$groups,p=d.$groups;gt(_)&&!ft(_)&&(a.$groups=as(as({},gt(p)?p:{}),_)),Rr(["$referrer","$referring_domain"],e=>{e in d&&delete h[e]});const g={};if(this._extensionEventPropertyProducers.length>0)for(const e of this._extensionEventPropertyProducers.slice())try{Ar(g,e())}catch(e){Ir.error("Failed to produce browser extension event properties",e)}a=Ar({},l,d,h,as(as({},g),a)),a.$is_identified=this._isIdentified(),_t(this.config.property_denylist)?Rr(this.config.property_denylist,function(e){delete a[e]}):Ir.error(bu+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);const f=this.config.sanitize_properties;f&&(Ir.error(yu),a=f(a,e));const v=this._hasPersonProcessing();return a.$process_person_profile=v,v&&!r&&this._requirePersonProcessing("_calculate_event_properties"),a}_calculate_set_once_properties(e,t=!0,i=!1){var s;if(!this.persistence||!this._hasPersonProcessing())return e;if(this._personProcessingSetOncePropertiesSent&&!i)return e;const n=this.persistence.get_initial_props(),r=null===(s=this.sessionPropsManager)||void 0===s?void 0:s.getSetOnceProps();let o=Ar({},n,r||{},e||{});const a=this.config.sanitize_properties;return a&&(Ir.error(yu),o=a(o,"$set_once")),t&&(this._personProcessingSetOncePropertiesSent=!0),ft(o)?void 0:o}register(e,t){var i;null===(i=this.persistence)||void 0===i||i.register(e,t)}register_once(e,t,i){var s;null===(s=this.persistence)||void 0===s||s.register_once(e,t,i)}register_for_session(e){var t,i;null===(t=this.persistence)||void 0===t||t.syncCookieProperties(),this._processCookieIdentityChange(),null===(i=this.sessionPersistence)||void 0===i||i.register(e),Object.keys(e).forEach(e=>this._sessionRegisteredPropKeys.add(e)),this._persistSessionRegisteredPropKeys()}unregister(e){var t;null===(t=this.persistence)||void 0===t||t.unregister(e)}unregister_for_session(e){var t;null===(t=this.sessionPersistence)||void 0===t||t.unregister(e),this._sessionRegisteredPropKeys.delete(e),this._persistSessionRegisteredPropKeys()}_register_single(e,t){this.register({[e]:t})}_clearSessionRegisteredProps(){this._sessionRegisteredPropKeys.forEach(e=>{var t;null===(t=this.sessionPersistence)||void 0===t||t.unregister(e)}),this._sessionRegisteredPropKeys.clear(),this._persistSessionRegisteredPropKeys()}_persistSessionRegisteredPropKeys(){var e;if(!this._sessionRegisteredPropertiesStorageKey)return;if("memory"===this.config.persistence||(null===(e=this.sessionPersistence)||void 0===e?void 0:e._disabled)||!fo._is_supported())return void fo._remove(this._sessionRegisteredPropertiesStorageKey);const t=[];this._sessionRegisteredPropKeys.forEach(e=>t.push(e)),t.length>0?fo._set(this._sessionRegisteredPropertiesStorageKey,t):fo._remove(this._sessionRegisteredPropertiesStorageKey)}getFeatureFlag(e,t){var i;return null===(i=this.featureFlags)||void 0===i?void 0:i.getFeatureFlag(e,t)}getFeatureFlagPayload(e){var t;return null===(t=this.featureFlags)||void 0===t?void 0:t.getFeatureFlagPayload(e)}getFeatureFlagResult(e,t){var i;return null===(i=this.featureFlags)||void 0===i?void 0:i.getFeatureFlagResult(e,t)}getAllFeatureFlags(){var e,t;return null!==(e=null===(t=this.featureFlags)||void 0===t?void 0:t.getAllFeatureFlags())&&void 0!==e?e:[]}isFeatureEnabled(e,t){var i,s;return null!==(i=null===(s=this.featureFlags)||void 0===s?void 0:s.isFeatureEnabled(e,t))&&void 0!==i?i:null==t?void 0:t.defaultValue}reloadFeatureFlags(){var e;null===(e=this.featureFlags)||void 0===e||e.reloadFeatureFlags()}updateFlags(e,t,i){var s;null===(s=this.featureFlags)||void 0===s||s.updateFlags(e,t,i)}updateEarlyAccessFeatureEnrollment(e,t,i){var s;null===(s=this.featureFlags)||void 0===s||s.updateEarlyAccessFeatureEnrollment(e,t,i)}getEarlyAccessFeatures(e,t=!1,i){var s;return null===(s=this.featureFlags)||void 0===s?void 0:s.getEarlyAccessFeatures(e,t,i)}on(e,t){return this._internalEventEmitter.on(e,t)}onFeatureFlags(e){return this.featureFlags?this.featureFlags.onFeatureFlags(e):(e([],{},{errorsLoading:!0}),()=>{})}onSurveysLoaded(e){return this.surveys?this.surveys.onSurveysLoaded(e):(e([],{isLoaded:!1,error:mu}),()=>{})}onSessionId(e){var t,i;return null!==(t=null===(i=this.sessionManager)||void 0===i?void 0:i.onSessionId(e))&&void 0!==t?t:()=>{}}getSurveys(e,t=!1){this.surveys?this.surveys.getSurveys(e,t):e([],{isLoaded:!1,error:mu})}getActiveMatchingSurveys(e,t=!1){this.surveys?this.surveys.getActiveMatchingSurveys(e,t):e([],{isLoaded:!1,error:mu})}onActiveMatchingSurveysChanged(e){return this.surveys?this.surveys.onActiveMatchingSurveysChanged(e):(e([],{isLoaded:!1,error:mu}),()=>{})}renderSurvey(e,t){var i;null===(i=this.surveys)||void 0===i||i.renderSurvey(e,t)}displaySurvey(e,t=Gc){var i;null===(i=this.surveys)||void 0===i||i.displaySurvey(e,t)}cancelPendingSurvey(e){var t;null===(t=this.surveys)||void 0===t||t.cancelPendingSurvey(e)}canRenderSurvey(e){var t,i;return null!==(t=null===(i=this.surveys)||void 0===i?void 0:i.canRenderSurvey(e))&&void 0!==t?t:{visible:!1,disabledReason:mu}}canRenderSurveyAsync(e,t=!1){var i,s;return null!==(i=null===(s=this.surveys)||void 0===s?void 0:s.canRenderSurveyAsync(e,t))&&void 0!==i?i:Promise.resolve({visible:!1,disabledReason:mu})}_validateIdentifyId(e){return!e||yt(e)?(Ir.critical("Unique user id has not been set in posthog.identify"),!1):"$posthog_cookieless"===e?(Ir.critical(`The string "${e}" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.`),!1):!["distinct_id","distinctid"].includes(e.toLowerCase())&&!["undefined","null"].includes(e.toLowerCase())||(Ir.critical(`The string "${e}" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.`),!1)}identify(e,t,i){if(!this.__loaded||!this.persistence)return Ir.uninitializedWarning("posthog.identify");if(St(e)&&(e=e.toString(),Ir.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),!this._validateIdentifyId(e))return;if(!this._requirePersonProcessing("posthog.identify"))return;this._syncCookielessIdentity();const s=this.get_distinct_id(),n=this.persistence.syncCookieProperties()&&this.get_distinct_id()!==s,r=this._processCookieIdentityChange(!1),o=this.persistence._beginCookieSyncSuppression();let a=!1;try{const s=this.get_distinct_id();this.register({$user_id:e}),this.get_property("$device_id")||this.register_once({$had_persisted_distinct_id:!0,$device_id:s},""),e!==s&&e!==this.get_property("__alias")&&(this.unregister(T),this.register({distinct_id:e}));const o=(this.persistence.get_property("$user_state")||"anonymous")===Oe,c=e!==s,u=!c&&o;if(c&&o){var l;const n=this.config.reuseAnonymousId?{distinct_id:e}:{distinct_id:e,$anon_distinct_id:s};this.persistence.set_property(ge,De),this.setPersonPropertiesForFlags({$set:t||{},$set_once:i||{}},!1),this.config.cookieWinsOnConflict&&this.persistence._publishSuppressedCookieSnapshot(),this.capture("$identify",n,{$set:t||{},$set_once:i||{}})&&(this._cachedPersonProperties=Nc(e,t,i)),null===(l=this.featureFlags)||void 0===l||l.setAnonymousDistinctId(this.config.reuseAnonymousId?void 0:s)}else if(u){this.persistence.set_property(ge,De);const s=t||{},n=i||{};this.setPersonPropertiesForFlags({$set:s,$set_once:n},!1),this.config.cookieWinsOnConflict&&this.persistence._publishSuppressedCookieSnapshot(),this.capture("$set",{$set:s,$set_once:n})&&(this._cachedPersonProperties=Nc(e,t,i))}else(t||i)&&this.setPersonProperties(t,i);c||n||r?(this.reloadFeatureFlags(),this.featureFlags?this.featureFlags.resetFlagCallReported():this.unregister(_)):u&&(t||i)&&this.reloadFeatureFlags(),a=!0}finally{o&&this.persistence._endCookieSyncSuppression(a)}}setPersonProperties(e,t){if(!e&&!t)return;if(!this._requirePersonProcessing("posthog.setPersonProperties"))return;const i=Nc(this.get_distinct_id(),e,t);this._cachedPersonProperties!==i?(this.setPersonPropertiesForFlags({$set:e||{},$set_once:t||{}},!0),this.capture("$set",{$set:e||{},$set_once:t||{}})&&(this._cachedPersonProperties=i)):Ir.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}unsetPersonProperties(e){var t;const i=(_t(e)?e:[e]).filter(e=>mt(e)&&e.length>0);0!==i.length&&this._requirePersonProcessing("posthog.unsetPersonProperties")&&(null===(t=this.featureFlags)||void 0===t||t.unsetPersonPropertiesForFlags(i,!0),this.capture("$set",{$unset:i}),this._cachedPersonProperties=null)}group(e,t,i){var s;if(!e||!t)return void Ir.error("posthog.group requires a group type and group key");null===(s=this.persistence)||void 0===s||s.syncCookieProperties(),this._processCookieIdentityChange();const n=this.getGroups(),r=n[e]!==t;if(r&&this.resetGroupPropertiesForFlags(e),this.register({$groups:as(as({},n),{},{[e]:t})}),(r||i)&&this._hasPersonProcessing()){const s={$group_type:e,$group_key:t};i&&(s.$group_set=i),this.capture(qe,s)}i&&this.setGroupPropertiesForFlags({[e]:i}),r&&!i&&this.reloadFeatureFlags()}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,t=!0){var i;null===(i=this.featureFlags)||void 0===i||i.setPersonPropertiesForFlags(e,t)}resetPersonPropertiesForFlags(e=!0){var t;null===(t=this.featureFlags)||void 0===t||t.resetPersonPropertiesForFlags(e)}setGroupPropertiesForFlags(e,t=!0){var i;this._requirePersonProcessing("posthog.setGroupPropertiesForFlags")&&(null===(i=this.featureFlags)||void 0===i||i.setGroupPropertiesForFlags(e,t))}resetGroupPropertiesForFlags(e){var t;null===(t=this.featureFlags)||void 0===t||t.resetGroupPropertiesForFlags(e)}reset(e){const t=kt(e)?e:null==e?void 0:e.resetDeviceID,i=kt(e)||null==e?void 0:e.bootstrap;this._reset(t,!1,i)}_reset(e,t=!1,i){var s,n,r,o,a,l;if(Ir.info("reset"),!this.__loaded)return Ir.uninitializedWarning("posthog.reset");const c=null==i?void 0:i.sessionID;this.config.bootstrap=i||(null===(s=this._originalUserConfig)||void 0===s?void 0:s.bootstrap)||{},null===(n=this.featureFlags)||void 0===n||null===(r=n.updateConfig)||void 0===r||r.call(n,this.config,this._shouldDisableFlags());const u=this.get_property(I),d=this.get_property(F),h=this.get_property(G);null===(o=this.sessionRecording)||void 0===o||o.flushBeforeIdentityReset();const _=this.is_capturing();t||this.consent.reset(),t||!_||this.is_capturing()||console.warn("[PostHog.js]","reset() cleared the stored consent, and capturing is now off because of `opt_out_capturing_by_default`. Call opt_in_capturing() again, and prefer calling reset() before opting in rather than after.");const p=null===(a=this.persistence)||void 0===a||null===(l=a._beginCookieSyncSuppression)||void 0===l?void 0:l.call(a),g=this._isConsentTransition;this._isConsentTransition=g||t;let f=!1;try{var v,m,y,b,w,S,C,k,E,x,P,T,R;if(null===(v=this.persistence)||void 0===v||v.clear(),null===(m=this.sessionPersistence)||void 0===m||m.clear(),this._sessionRegisteredPropKeys.clear(),this._persistSessionRegisteredPropKeys(),vt(h)||null===(x=this.persistence)||void 0===x||x.register({$session_recording_remote_config:h}),null===(y=this.surveys)||void 0===y||y.reset(),null===(b=this.featureFlags)||void 0===b||b.reset(),null===(w=this.conversations)||void 0===w||w.reset(),null===(S=this.logs)||void 0===S||S.reset(),null===(C=this.metrics)||void 0===C||C.reset(),null===(k=this.persistence)||void 0===k||k.set_property("$user_state","anonymous"),null===(E=this.sessionManager)||void 0===E||E.resetSessionId(),this._cachedPersonProperties=null,"always"===this.config.cookieless_mode)this.register_once({distinct_id:Se,$device_id:null},"");else{const t=this.config.get_device_id(Kr());this.register_once({distinct_id:t,$device_id:e?t:u},""),e||vt(d)||this.register({[F]:d})}if(this.register({$last_posthog_reset:(new Date).toISOString()},1),i)if(i.distinctID&&!this._inCookielessMode()&&(null===(R=this.persistence)||void 0===R||R.set_property("$user_state",i.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:i.distinctID})),null===(P=this.featureFlags)||void 0===P||P.initialize(),!wt(c)&&!(null===(T=this.sessionManager)||void 0===T?void 0:T.setBootstrapSessionId(c,!0))){const e=as({},i);delete e.sessionID,this.config.bootstrap=e}delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,f=!0}finally{var A,M;this._isConsentTransition=g,p&&(null===(A=this.persistence)||void 0===A||null===(M=A._endCookieSyncSuppression)||void 0===M||M.call(A,f))}var L;this._lastRemoteConfig&&(null===(L=this.conversations)||void 0===L||L.onRemoteConfig(this._lastRemoteConfig)),this.reloadFeatureFlags()}shutdown(e){var t=this;return Ot(function*(){if(!t.__loaded)return void Ir.uninitializedWarning("posthog.shutdown");t._isShutdown=!0,clearTimeout(t._extensionInitTimeout),t._extensionInitTimeout=void 0;const e=t._featureFlagsReloadingUnsubscribe;t._featureFlagsReloadingUnsubscribe=void 0;for(const i of[()=>{var e;return null===(e=t.sessionRecording)||void 0===e?void 0:e.dispose()},()=>{var e;return null===(e=t.logs)||void 0===e?void 0:e.flushLogs("sendBeacon")},()=>{var e;return null===(e=t.metrics)||void 0===e?void 0:e.flush("sendBeacon")},()=>{var e;return null===(e=t.metrics)||void 0===e?void 0:e.dispose()},()=>{var e;return null===(e=t.logs)||void 0===e?void 0:e.dispose()},()=>{var e;return null===(e=t.surveys)||void 0===e?void 0:e.dispose()},()=>{var e;return null===(e=t.autocapture)||void 0===e?void 0:e.dispose()},()=>null==e?void 0:e(),()=>{var e;return null===(e=t._requestQueue)||void 0===e?void 0:e.unload()},()=>{var e;return null===(e=t._retryQueue)||void 0===e?void 0:e.unload()},()=>{var e;return null===(e=t.featureFlags)||void 0===e?void 0:e.destroy()},()=>{var e;return null===(e=t.persistence)||void 0===e?void 0:e.destroy()},()=>{var e;return null===(e=t.sessionPersistence)||void 0===e?void 0:e.destroy()}])try{const e=i();e&&pt(e.then)&&e.then(void 0,e=>{Ir.error("Error during shutdown",e)})}catch(e){Ir.error("Error during shutdown",e)}})()}setIdentity(e,t){var i;delete this.config.identity_claims,this.config.identity_distinct_id=e,this.config.identity_hash=t,this.alias(e),null===(i=this.conversations)||void 0===i||i._onIdentityChanged()}clearIdentity(){var e;delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,null===(e=this.conversations)||void 0===e||e._onIdentityCleared()}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var e,t;return null!==(e=null===(t=this.sessionManager)||void 0===t?void 0:t.checkAndGetSessionAndWindowId(!0).sessionId)&&void 0!==e?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";const{sessionId:t,sessionStartTimestamp:i}=this.sessionManager.checkAndGetSessionAndWindowId(!0);let s=this.requestRouter.endpointFor("ui",`/project/${this.config.token}/replay/${t}`);if((null==e?void 0:e.withTimestamp)&&i){var n;const t=null!==(n=e.timestampLookBack)&&void 0!==n?n:10;if(!i)return s;s+=`?t=${Math.max(Math.floor(((new Date).getTime()-i)/1e3)-t,0)}`}return s}alias(e,t){return e===this.get_property("$people_distinct_id")?(Ir.critical("Attempting to create alias for existing People user - aborting."),-2):this._requirePersonProcessing("posthog.alias")?(vt(t)&&(t=this.get_distinct_id()),e!==t?(this._register_single(T,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(Ir.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){const t=as({},this.config);if(gt(e)){var s,n,r,o,a,l,c,u,d,h,_,p,g,f;Ar(this.config,$u(e));const w=this._is_persistence_disabled();if(this.persistence){const e="sessionStorage"===this.config.persistence||"memory"===this.config.persistence;var v,m;if(e&&this.sessionPersistence!==this.persistence&&(null===(v=this.sessionPersistence)||void 0===v||v.remove(),null===(m=this.sessionPersistence)||void 0===m||m.destroy()),this.persistence.update_config(this.config,t,w),e)this.sessionPersistence=this.persistence;else if(this.sessionPersistence===this.persistence)this.sessionPersistence=new sl(as(as({},this.config),{},{persistence:"sessionStorage"}),w,!1);else{var y;null===(y=this.sessionPersistence)||void 0===y||y.update_config(as(as({},this.config),{},{persistence:"sessionStorage"}),as(as({},t),{},{persistence:"sessionStorage"}),w)}}const S=this._checkLocalStorageForDebug(this.config.debug);var b;kt(S)&&(this.config.debug=S),kt(this.config.debug)&&(this.config.debug?(i.DEBUG=!0,to._is_supported()&&to._set("ph_debug",!0),Ir.info("set_config",{config:e,oldConfig:t,newConfig:as({},this.config)})):(i.DEBUG=!1,to._is_supported()&&to._remove("ph_debug"))),null===(s=this.featureFlags)||void 0===s||null===(n=s.updateConfig)||void 0===n||n.call(s,this.config,this._shouldDisableFlags()),null===(r=this.exceptionObserver)||void 0===r||r.onConfigChange(),null===(o=this.exceptions)||void 0===o||o.onConfigChange(),null===(a=this.metrics)||void 0===a||a.onConfigChange(),null===(l=this.webMCP)||void 0===l||l.startIfEnabled(),null===(c=this.sessionRecording)||void 0===c||c.startIfEnabledOrStop(),null===(u=this.tracingHeaders)||void 0===u||u.startIfEnabledOrStop(),null===(d=this.autocapture)||void 0===d||d.startIfEnabled(),null===(h=this.heatmaps)||void 0===h||h.startIfEnabled(),("capture_pageview"in e||"disable_capture_url_hashes"in e)&&(null===(b=this.historyAutocapture)||void 0===b||b.startIfEnabledOrStop()),null===(_=this.exceptionObserver)||void 0===_||_.startIfEnabledOrStop(),null===(p=this.deadClicksAutocapture)||void 0===p||p.startIfEnabledOrStop(),null===(g=this.surveys)||void 0===g||g.loadIfEnabled(),this._sync_opt_out_with_persistence(),null===(f=this.externalIntegrations)||void 0===f||f.startIfEnabledOrStop(),!t.segment&&this.config.segment&&this.persistence&&_a(this,fu,!1)}}_overrideSDKInfo(e,t){i.LIB_NAME=e,i.LIB_VERSION=t}startSessionRecording(e){const t=!0===e,i={sampling:t||!!(null==e?void 0:e.sampling),linked_flag:t||!!(null==e?void 0:e.linked_flag),url_trigger:t||!!(null==e?void 0:e.url_trigger),event_trigger:t||!!(null==e?void 0:e.event_trigger)};var s,n,r,o,a;Object.values(i).some(Boolean)&&(null===(s=this.sessionManager)||void 0===s||s.checkAndGetSessionAndWindowId(),i.sampling&&(null===(n=this.sessionRecording)||void 0===n||n.overrideSampling()),i.linked_flag&&(null===(r=this.sessionRecording)||void 0===r||r.overrideLinkedFlag()),i.url_trigger&&(null===(o=this.sessionRecording)||void 0===o||o.overrideTrigger("url")),i.event_trigger&&(null===(a=this.sessionRecording)||void 0===a||a.overrideTrigger("event")));this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var e;return!!(null===(e=this.sessionRecording)||void 0===e?void 0:e.started)}captureException(e,t){try{if(!this.exceptions)return;const i=this.exceptions.buildProperties(e,{handled:!0,syntheticException:new Error("PostHog syntheticException")});return this.exceptions.sendExceptionEvent(as(as({},i),t))}catch(e){return}}addExceptionStep(e,t){var i;null===(i=this.exceptions)||void 0===i||i.addExceptionStep(e,t)}captureLog(e){var t;null===(t=this.logs)||void 0===t||t.captureLog(e)}get logger(){var t,i;return null!==(t=null===(i=this.logs)||void 0===i?void 0:i.logger)&&void 0!==t?t:e._noopLogger}startExceptionAutocapture(e){this.set_config({capture_exceptions:null==e||e})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(e){var t,i;return null!==(t=null===(i=this.toolbar)||void 0===i?void 0:i.loadToolbar(e))&&void 0!==t&&t}get_property(e){var t;return null===(t=this.persistence)||void 0===t?void 0:t.props[e]}getSessionProperty(e){var t;return null===(t=this.sessionPersistence)||void 0===t?void 0:t.props[e]}toString(){var e;let t=null!==(e=this.config.name)&&void 0!==e?e:Iu;return t!==Iu&&(t="posthog."+t),t}_isIdentified(){var e,t;return"identified"===(null===(e=this.persistence)||void 0===e?void 0:e.get_property("$user_state"))||"identified"===(null===(t=this.sessionPersistence)||void 0===t?void 0:t.get_property("$user_state"))}_hasPersonProcessing(){var e,t;return!("never"===this.config.person_profiles||"identified_only"===this.config.person_profiles&&!this._isIdentified()&&ft(this.getGroups())&&!(null===(e=this.persistence)||void 0===e||null===(e=e.props)||void 0===e?void 0:e.__alias)&&!(null===(t=this.persistence)||void 0===t||null===(t=t.props)||void 0===t?void 0:t.$epp))}_shouldCapturePageleave(){return!0===this.config.capture_pageleave||"if_capture_pageview"===this.config.capture_pageleave&&!!this.config.capture_pageview}createPersonProfile(){this._hasPersonProcessing()||this._requirePersonProcessing("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this._requirePersonProcessing("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}_requirePersonProcessing(e){return"never"===this.config.person_profiles?(Ir.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this._warnIfVolatileIdentityWithoutStableId(),this._register_single(we,!0),!0)}_is_persistence_disabled(){if("always"===this.config.cookieless_mode)return!0;const e=this.consent.isOptedOut();return this.config.disable_persistence||e&&!(!this.config.opt_out_persistence_by_default&&"on_reject"!==this.config.cookieless_mode)}_sync_opt_out_with_persistence(){var e,t;const i=this._is_persistence_disabled();var s,n,r;return this.is_capturing()||null===(s=this.logs)||void 0===s||s._onOptOut(),(null===(e=this.persistence)||void 0===e?void 0:e._disabled)!==i&&(null===(n=this.persistence)||void 0===n||n.set_disabled(i)),(null===(t=this.sessionPersistence)||void 0===t?void 0:t._disabled)!==i&&(null===(r=this.sessionPersistence)||void 0===r||r.set_disabled(i)),this._persistSessionRegisteredPropKeys(),i}opt_in_capturing(t){var i,s,n;if("always"===this.config.cookieless_mode)return void Ir.warn(vu);if(this._inCookielessMode()){var r,o,a,l,c,u;null===(r=this.sessionRecording)||void 0===r||r.dispose({discardBufferedEvents:!0}),this._reset(!0,!0),null===(o=this.sessionManager)||void 0===o||o.destroy(),null===(a=this.pageViewManager)||void 0===a||a.destroy(),this.sessionManager=new Ic(this),this.pageViewManager=new va(this),this.persistence&&(this.sessionPropsManager=new kc(this,this.sessionManager,this.persistence));const t=null!==(l=null===(c=this.config.__extensionClasses)||void 0===c?void 0:c.sessionRecording)&&void 0!==l?l:null===(u=e.__defaultExtensionClasses)||void 0===u?void 0:u.sessionRecording;var d,h;t&&(this.sessionRecording=this._replaceExtension(this.sessionRecording,new t(this)),this._lastRemoteConfig&&(null===(d=this.sessionRecording)||void 0===d||null===(h=d.onRemoteConfig)||void 0===h||h.call(d,this._lastRemoteConfig)))}const _=1===this.consent.consent;var p,g,f;_&&this._syncCookielessIdentity(),this.consent.optInOut(!0),this._sync_opt_out_with_persistence(),this._start_queue_if_opted_in(),null===(i=this.sessionRecording)||void 0===i||i.startIfEnabledOrStop(),"on_reject"==this.config.cookieless_mode&&(null===(p=this.surveys)||void 0===p||p.loadIfEnabled(),null===(g=this.conversations)||void 0===g||g.loadIfEnabled()),_||!vt(null==t?void 0:t.captureEventName)&&!(null==t?void 0:t.captureEventName)||this.capture(null!==(f=null==t?void 0:t.captureEventName)&&void 0!==f?f:"$opt_in",null==t?void 0:t.captureProperties,{send_instantly:!0}),null===(s=this.persistence)||void 0===s||s.syncCookieProperties(),this._processCookieIdentityChange(),null===(n=this.featureFlags)||void 0===n||n.sendFlagCallsPendingCapture(),this.config.capture_pageview&&this._captureInitialPageview()}opt_out_capturing(){"always"!==this.config.cookieless_mode?(this.consent.optInOut(!1),this._sync_opt_out_with_persistence(),"on_reject"===this.config.cookieless_mode&&this._enterCookielessMode()):Ir.warn(vu)}_enterCookielessMode(){var e,t;const i=this.sessionRecording;null==i||i.dispose({discardBufferedEvents:!0}),"$posthog_cookieless"!==this.get_distinct_id()&&this._reset(!0,!0),this.register({distinct_id:Se,$device_id:null}),this._removeExtension(i),this.sessionRecording=void 0,null===(e=this.sessionManager)||void 0===e||e.destroy(),null===(t=this.pageViewManager)||void 0===t||t.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,this.config.capture_pageview&&this._captureInitialPageview(),this._start_queue_if_opted_in()}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){const e=this.consent.consent;return 1===e?"granted":0===e?"denied":"pending"}is_capturing(){return!this._isConsentTransition&&("always"===this.config.cookieless_mode||("on_reject"===this.config.cookieless_mode?this.consent.isRejected()||this.consent.isOptedIn():!this.has_opted_out_capturing()))}clear_opt_in_out_capturing(){this.consent.reset(),this._sync_opt_out_with_persistence()}_is_bot(){return Ve?Tc(Ve,this.config.custom_blocked_useragents):void 0}_captureInitialPageview(){Ge&&("visible"===Ge.visibilityState?this._initialPageviewCaptured||(this._initialPageviewCaptured=!0,this.capture(ze,{title:Ge.title},{send_instantly:!0}),this._visibilityStateListener&&(Ge.removeEventListener(m,this._visibilityStateListener),this._visibilityStateListener=null)):this._visibilityStateListener||(this._visibilityStateListener=this._captureInitialPageview.bind(this),Br(Ge,m,this._visibilityStateListener)))}debug(e){!1===e?(null==je||je.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(null==je||je.console.log("You're now in debug mode. All calls to PostHog will be logged in your console.\nYou can disable this with `posthog.debug(false)`."),this.set_config({debug:!0}))}_shouldDisableFlags(){const e=this._originalUserConfig||{};return"advanced_disable_flags"in e?!!e.advanced_disable_flags:!1!==this.config.advanced_disable_flags?!!this.config.advanced_disable_flags:!0===this.config.advanced_disable_decide?(Ir.warn("Config field 'advanced_disable_decide' is deprecated. Please use 'advanced_disable_flags' instead. The old field will be removed in a future major version."),!0):function(e,t,i,s,n){const r=t in e&&!wt(e[t]),o=i in e&&!wt(e[i]);return r?e[t]:!!o&&(n&&n.warn(`Config field '${i}' is deprecated. Please use '${t}' instead. The old field will be removed in a future major version.`),e[i])}(e,"advanced_disable_flags","advanced_disable_decide",0,Ir)}_runBeforeSend(e){var t;if(wt(this.config.before_send))return e;const i=Object.keys(null!==(t=e.properties)&&void 0!==t?t:{}).filter(xt),s=_t(this.config.before_send)?this.config.before_send:[this.config.before_send];let n=e;for(const t of s)try{if(n=t(n),wt(n)){const t=`Event '${e.event}' was rejected in beforeSend function`;return Et(e.event)?Ir.warn(`${t}. This can cause unexpected behavior.`):Ir.info(t),null}n.properties&&!ft(n.properties)||Ir.warn(`Event '${e.event}' has no properties after beforeSend function, this is likely an error.`)}catch(t){return Ir.error(`Error in beforeSend function for event '${e.event}':`,t),null}for(const t of i)if(n.properties&&wt(n.properties[t]))return Ir.warn(`Event '${e.event}' had its '${t}' property removed in a beforeSend function. This property is required for ingestion, so the event will be dropped.`),null;return n}getPageViewId(){var e;return null===(e=this.pageViewManager._currentPageview)||void 0===e?void 0:e.pageViewId}captureTraceFeedback(e,t){this.capture("$ai_feedback",{$ai_trace_id:String(e),$ai_feedback_text:t})}captureTraceMetric(e,t,i){this.capture("$ai_metric",{$ai_trace_id:String(e),$ai_metric_name:t,$ai_metric_value:String(i)})}_checkLocalStorageForDebug(e){const t=kt(e)&&!e,i=to._is_supported()&&"true"===to._get("ph_debug");return!t&&(!!i||e)}};Lu.__defaultExtensionClasses={},Lu._noopLogger=(()=>{const e=()=>{};return{trace:e,debug:e,info:e,warn:e,error:e,fatal:e}})(),function(e,t){for(let i=0;t.length>i;i++)e.prototype[t[i]]=Mr(e.prototype[t[i]])}(Lu,["identify"]);const Ou=["[data-ph-capture-value]"];var Du=class{constructor(e){this._instance=e}refresh(e){var t;const i=this._instance.config,s=gt(i.autocapture)?i.autocapture:void 0;e.enabled=!!i.autocapture,e.rageclick=i.rageclick,e.maskAllElementAttributes=i.mask_all_element_attributes,e.maskAllText=i.mask_all_text,e.disableCaptureUrlHashes=i.disable_capture_url_hashes,e.getCurrentUrl=i.get_current_url,e.remoteRequestsDisabled=this._instance._shouldDisableFlags(),e.url_allowlist=null==s?void 0:s.url_allowlist,e.url_ignorelist=null==s?void 0:s.url_ignorelist,e.dom_event_allowlist=null==s?void 0:s.dom_event_allowlist,e.element_allowlist=null==s?void 0:s.element_allowlist,e.css_selector_allowlist=null==s?void 0:s.css_selector_allowlist,e.css_selector_ignorelist=null==s?void 0:s.css_selector_ignorelist,e.element_attribute_ignorelist=null==s?void 0:s.element_attribute_ignorelist,e.capture_copied_text=null==s?void 0:s.capture_copied_text,e.capture_value_css_selector_allowlist=null!==(t=null==s?void 0:s.capture_value_css_selector_allowlist)&&void 0!==t?t:Ou}};const Nu=Fr("[ExceptionAutocapture]"),Bu=()=>{},zu=e=>{var t;if(pt(e))return null!==(t=e.__posthog_layer__)&&void 0!==t?t:e.__rrweb_layer__};function Hu(e,t,i){try{if(!(t in e))return Bu;const s={next:e[t]},n=i(function(...e){return s.next.apply(this,e)});return pt(n)&&(n.prototype=n.prototype||{},Object.defineProperties(n,{__posthog_wrapped__:{enumerable:!1,value:!0},__posthog_layer__:{enumerable:!1,value:s}})),e[t]=n,()=>{if(e[t]===n)return void(e[t]=s.next);let i=e[t],r=zu(i);for(;r;){if(r.next===n)return void(r.next=s.next);i=r.next,r=zu(i)}}}catch(e){return Bu}}const Uu=Fr("[TracingHeaders]"),qu=Fr("[Web Vitals]"),ju=9e5,Wu=["CLS","FCP","INP","LCP"],Vu=["INP","LCP"],Gu=["interactionTarget","interactionType","inputDelay","processingDuration","presentationDelay","loadState","target","url","timeToFirstByte","resourceLoadDelay","resourceLoadDuration","elementRenderDelay","largestShiftTarget","largestShiftTime","largestShiftValue","firstByteToFCP"],Ku="disabled",Qu="lazy_loading",Ju=Fr("[SessionRecording]"),Yu=[xe,Pe,Ie,Fe,Te,Re,Ae,$e,Me],Xu=Fr("[Heatmaps]");function Zu(e){return gt(e)&&"clientX"in e&&"clientY"in e&&St(e.clientX)&&St(e.clientY)}const ed=Fr("[Product Tours]"),td=e=>{var t;return!e.config.disable_product_tours&&!!(null===(t=e.persistence)||void 0===t?void 0:t.get_property(j))},id=["$set_once","$set"],sd=Fr("[SiteApps]"),nd="Error while initializing PostHog app with config id ";function rd(e,t,i){if(wt(e))return!1;switch(i){case"exact":return e===t;case"contains":{const i=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(i,"i").test(e)}case"regex":try{return new RegExp(t).test(e)}catch(e){return!1}default:return!1}}var od=class{constructor(e){this._host=e,this._actionRegistry=new Set,this._actionEvents=new Set,this._debugEventEmitter=new Ec,this._checkStep=(e,t)=>this._checkStepEvent(e,t)&&this._checkStepUrl(e,t)&&this._checkStepElement(e,t)&&this._checkStepProperties(e,t),this._checkStepEvent=(e,t)=>!(null==t?void 0:t.event)||(null==e?void 0:e.event)===(null==t?void 0:t.event)}init(){var e,t;vt(null===(e=this._host)||void 0===e?void 0:e.subscribeCapture)||(this._captureHookUnsubscribe=null===(t=this._host)||void 0===t?void 0:t.subscribeCapture((e,t)=>{this.on(e,t)}))}dispose(){var e,t,i;null===(e=this._captureHookUnsubscribe)||void 0===e||e.call(this),this._captureHookUnsubscribe=void 0,null===(t=this._host)||void 0===t||null===(i=t.setElementSelectors)||void 0===i||i.call(t,new Set,this),this._debugEventEmitter=new Ec}register(e){var t,i;if(!vt(null===(t=this._host)||void 0===t?void 0:t.subscribeCapture)&&(e.forEach(e=>{var t;this._actionRegistry.add(e),null===(t=e.steps)||void 0===t||t.forEach(e=>{this._actionEvents.add((null==e?void 0:e.event)||"")})}),null===(i=this._host)||void 0===i?void 0:i.setElementSelectors)){const e=new Set;this._actionRegistry.forEach(t=>{var i;null===(i=t.steps)||void 0===i||i.forEach(t=>{(null==t?void 0:t.selector)&&e.add(t.selector)})}),this._host.setElementSelectors(e,this)}}replace(e){this._actionRegistry.clear(),this._actionEvents.clear(),this.register(e)}on(e,t){null!=t&&0!=e.length&&(this._actionEvents.has(e)||this._actionEvents.has(t.event))&&this._actionRegistry.forEach(e=>{this._checkAction(t,e)&&this._debugEventEmitter.emit("actionCaptured",e.name)})}_addActionHook(e){this.onAction("actionCaptured",t=>e(t))}_checkAction(e,t){if(null==(null==t?void 0:t.steps))return!1;for(const i of t.steps)if(this._checkStep(e,i))return!0;return!1}onAction(e,t){return this._debugEventEmitter.on(e,t)}_checkStepUrl(e,t){if(null==t?void 0:t.url){var i;let r=null==e||null===(i=e.properties)||void 0===i?void 0:i.$current_url;if(!(null==e?void 0:e.properties)||!("$current_url"in e.properties))try{var s,n;r=null===(s=this._host)||void 0===s||null===(n=s.getActionUrl)||void 0===n?void 0:n.call(s)}catch(e){return!1}if(!r||"string"!=typeof r)return!1;if(!rd(r,t.url,t.url_matching||"contains"))return!1}return!0}_checkStepElement(e,t){return!!this._checkStepHref(e,t)&&!!this._checkStepText(e,t)&&!!this._checkStepSelector(e,t)}_checkStepHref(e,t){var i;if(!(null==t?void 0:t.href))return!0;const s=this._getElementsList(e);if(s.length>0)return s.some(e=>rd(e.href,t.href,t.href_matching||"exact"));const n=(null==e||null===(i=e.properties)||void 0===i?void 0:i.$elements_chain)||"";return!!n&&rd(function(e){const t=e.match(/(?::|")href="(.*?)"/);return t?t[1]:""}(n),t.href,t.href_matching||"exact")}_checkStepText(e,t){var i;if(!(null==t?void 0:t.text))return!0;const s=this._getElementsList(e);if(s.length>0)return s.some(e=>rd(e.text,t.text,t.text_matching||"exact")||rd(e.$el_text,t.text,t.text_matching||"exact"));const n=(null==e||null===(i=e.properties)||void 0===i?void 0:i.$elements_chain)||"";return!!n&&(r=function(e){const t=[],i=/(?::|")text="(.*?)"/g;let s;for(;!wt(s=i.exec(e));)t.includes(s[1])||t.push(s[1]);return t}(n),o=t.text,a=t.text_matching||"exact",r.some(e=>rd(e,o,a)));var r,o,a}_checkStepSelector(e,t){var i,s;if(!(null==t?void 0:t.selector))return!0;const n=null==e||null===(i=e.properties)||void 0===i?void 0:i.$element_selectors;if(null==n?void 0:n.includes(t.selector))return!0;const r=(null==e||null===(s=e.properties)||void 0===s?void 0:s.$elements_chain)||"";if(t.selector_regex&&r)try{return new RegExp(t.selector_regex).test(r)}catch(e){}return!1}_getElementsList(e){var t;return null==(null==e||null===(t=e.properties)||void 0===t?void 0:t.$elements)?[]:null==e?void 0:e.properties.$elements}_checkStepProperties(e,t){return!(null==t?void 0:t.properties)||0===t.properties.length||Dc(t.properties.reduce((e,t)=>{const i=_t(t.value)?t.value.map(String):null!=t.value?[String(t.value)]:[];return e[t.key]={values:i,operator:t.operator||"exact"},e},{}),null==e?void 0:e.properties)}},ad=class{constructor(e,t){this._onActivationChanged=t,this._pendingActivatedItems=[],this._host=e,this._eventToItems=new Map,this._cancelEventToItems=new Map,this._actionToItems=new Map}_subscribeSession(){var e,t;this._sessionIdUnsubscribe=null===(e=(t=this._host).subscribeSession)||void 0===e?void 0:e.call(t,e=>this._onSessionIdChanged(e))}_shouldPersistArmedActivation(e){return!1}_getActivationTimestampsKey(){return null}_writeActivationTimestamps(e){}_clearActivationTimestampsStore(){}_doesEventMatchFilter(e,t){return!!e&&Dc(e.propertyFilters,null==t?void 0:t.properties)}_buildEventToItemMap(e,t){const i=new Map;return e.forEach(e=>{var s;null===(s=e.conditions)||void 0===s||null===(s=s[t])||void 0===s||null===(s=s.values)||void 0===s||s.forEach(t=>{if(null==t?void 0:t.name){const s=i.get(t.name)||[];s.push(e.id),i.set(t.name,s)}})}),i}_getMatchingItems(e,t,i){const s=(i===ol?this._eventToItems:this._cancelEventToItems).get(e);let n=[];return this._getItems(e=>{n=e.filter(e=>null==s?void 0:s.includes(e.id))}),n.filter(s=>{var n;const r=null===(n=s.conditions)||void 0===n||null===(n=n[i])||void 0===n||null===(n=n.values)||void 0===n?void 0:n.find(t=>t.name===e);return this._doesEventMatchFilter(r,t)})}register(e){this._register(e,!1)}replace(e){this._register(e,!0)}_register(e,t){vt(this._host.subscribeCapture)||(this._setupEventBasedItems(e,t),this._setupActionBasedItems(e,t))}_setupActionBasedItems(e,t){const i=e.filter(e=>{var t;return null===(t=e.conditions)||void 0===t||null===(t=t.actions)||void 0===t||null===(t=t.values)||void 0===t?void 0:t.length});var s;if(t&&this._actionToItems.clear(),0===i.length)return void(t&&(null===(s=this._actionMatcher)||void 0===s||s.replace([])));this._actionMatcher||(this._actionMatcher=new od(this._host),this._actionMatcher.init(),this._actionMatcher._addActionHook(e=>this.onAction(e)));const n=[];i.forEach(e=>{var t;null===(t=e.conditions)||void 0===t||null===(t=t.actions)||void 0===t||t.values.forEach(t=>{if(n.push(t),t.name){var i;const s=null!==(i=this._actionToItems.get(t.name))&&void 0!==i?i:[];s.includes(e.id)||s.push(e.id),this._actionToItems.set(t.name,s)}})}),t?this._actionMatcher.replace(n):this._actionMatcher.register(n)}_mergeItemMaps(e,t){t.forEach((t,i)=>{var s;const n=null!==(s=e.get(i))&&void 0!==s?s:[];t.forEach(e=>{n.includes(e)||n.push(e)}),e.set(i,n)})}_setupEventBasedItems(e,t){var i,s,n;const r=e.filter(e=>{var t,i;return(null===(t=e.conditions)||void 0===t?void 0:t.events)&&(null===(i=e.conditions)||void 0===i||null===(i=i.events)||void 0===i||null===(i=i.values)||void 0===i?void 0:i.length)>0}),o=e.filter(e=>{var t,i;return(null===(t=e.conditions)||void 0===t?void 0:t.cancelEvents)&&(null===(i=e.conditions)||void 0===i||null===(i=i.cancelEvents)||void 0===i||null===(i=i.values)||void 0===i?void 0:i.length)>0}),a=this._buildEventToItemMap(e,ol),l=this._buildEventToItemMap(e,al);t?(this._eventToItems=a,this._cancelEventToItems=l):(this._mergeItemMaps(this._eventToItems,a),this._mergeItemMaps(this._cancelEventToItems,l)),(0!==r.length||0!==o.length||e.some(e=>{var t;return null===(t=e.conditions)||void 0===t||null===(t=t.actions)||void 0===t||null===(t=t.values)||void 0===t?void 0:t.length}))&&(null!==(i=this._captureHookUnsubscribe)&&void 0!==i||(this._captureHookUnsubscribe=null===(s=(n=this._host).subscribeCapture)||void 0===s?void 0:s.call(n,(e,t)=>{this.onEvent(e,t)})))}onEvent(e,t){var i,s;const n=this._getLogger(),r=(null==t||null===(i=t.properties)||void 0===i?void 0:i.$survey_id)||(null==t||null===(s=t.properties)||void 0===s?void 0:s.$product_tour_id);if(r&&this.getActivatedIds().includes(r)){const i=this._activationOutcome(e,r,t);if("consume"===i)return n.info("event consumed activated item, removing it",{event:e,itemId:r}),void this._deactivateItems([r]);if("persist"===i)return n.info("shown item promoted to persisted activation",{event:e,itemId:r}),this._persistActivation(r),void this._clearActivationTimestamps([r])}if(this._cancelEventToItems.has(e)){const i=this._getMatchingItems(e,t,al);i.length>0&&(n.info("cancel event matched, cancelling items",{event:e,itemsToCancel:i.map(e=>e.id)}),this._deactivateItems(i.map(e=>e.id)),i.forEach(e=>this._cancelPendingItem(e.id)))}if(!this._eventToItems.has(e))return;n.info("event name matched",{event:e,eventPayload:t,items:this._eventToItems.get(e)});const o=this._getMatchingItems(e,t,ol);this._activateItems(o.map(e=>e.id))}onAction(e){this._actionToItems.has(e)&&this._activateItems(this._actionToItems.get(e)||[])}_activateItems(e){if(0===e.length)return;const t=!!this._host.getSessionId(),i=[];for(const s of e)t&&this._shouldPersistArmedActivation(s)?this._persistActivation(s)&&this._recordActivationTimestamp(s):i.push(s);i.length>0&&(this._pendingActivatedItems=[...new Set([...this._pendingActivatedItems,...i])]),this._getLogger().info("updating activated items",{activatedItems:this.getActivatedIds()}),this._notifyActivationChanged()}_persistActivation(e){this._pendingActivatedItems=this._pendingActivatedItems.filter(t=>t!==e);const t=this._getPersistedActivatedIds();return!t.includes(e)&&(this._setActivatedItems([...t,e]),this._stampActivationSession(),!0)}_deactivateItems(e){const t=new Set(e);this._pendingActivatedItems=this._pendingActivatedItems.filter(e=>!t.has(e));const i=this._getRawPersistedActivatedIds(),s=i.filter(e=>!t.has(e));s.length!==i.length&&(this._setActivatedItems(s),0===s.length&&this._clearActivationSession()),this._clearActivationTimestamps(e),this._notifyActivationChanged()}_notifyActivationChanged(){try{var e;null===(e=this._onActivationChanged)||void 0===e||e.call(this)}catch(e){this._getLogger().error("Error while handling activated items change",e)}}_getRawActivationTimestamps(){const e=this._getActivationTimestampsKey();if(!e)return{};const t=this._host.getProperty(e);return t&&"object"==typeof t?t:{}}_recordActivationTimestamp(e){if(!this._getActivationTimestampsKey())return;const t=this._getRawActivationTimestamps();this._writeActivationTimestamps(as(as({},t),{},{[e]:Date.now()}))}_clearActivationTimestamps(e){if(!this._getActivationTimestampsKey())return;const t=this._getRawActivationTimestamps(),i={};let s=!1;for(const[n,r]of Object.entries(t))e.includes(n)?s=!0:i[n]=r;s&&(ft(i)?this._clearActivationTimestampsStore():this._writeActivationTimestamps(i))}_clearAllActivationTimestamps(){this._getActivationTimestampsKey()&&this._clearActivationTimestampsStore()}getActivationTimestamp(e){if(!this._getPersistedActivatedIds().includes(e))return;const t=this._getRawActivationTimestamps()[e];return St(t)?t:void 0}_getRawPersistedActivatedIds(){const e=this._getActivatedKey();return this._host.getProperty(e)||[]}_getPersistedActivatedIds(){const e=this._getRawPersistedActivatedIds();if(0===e.length)return[];const t=this._host.getProperty(this._getActivatedSessionKey()),i=this._host.getSessionId();return i&&t===i?e:[]}_stampActivationSession(){const e=this._host.getSessionId();e&&this._setActivatedSession(e)}_clearActivationSession(){this._clearActivatedSession()}_onSessionIdChanged(e){const t=this._host.getProperty(this._getActivatedSessionKey());if(t&&t!==e){const e=this._getRawPersistedActivatedIds(),t=this._getRawActivationTimestamps();e.length>0&&(this._setActivatedItems([]),e.filter(e=>St(t[e])).forEach(e=>this._cancelPendingItem(e))),this._clearActivationSession(),this._clearAllActivationTimestamps(),e.length>0&&this._notifyActivationChanged()}}getActivatedIds(){return[...new Set([...this._getPersistedActivatedIds(),...this._pendingActivatedItems])].filter(e=>!this._isItemPermanentlyIneligible(e))}dispose(){var e,t,i;null===(e=this._sessionIdUnsubscribe)||void 0===e||e.call(this),this._sessionIdUnsubscribe=void 0,null===(t=this._captureHookUnsubscribe)||void 0===t||t.call(this),this._captureHookUnsubscribe=void 0,null===(i=this._actionMatcher)||void 0===i||i.dispose(),this._actionMatcher=void 0}reset(){this._pendingActivatedItems=[],this._getRawPersistedActivatedIds().length>0&&this._setActivatedItems([]),this._clearActivationSession(),this._clearAllActivationTimestamps(),this._notifyActivationChanged()}getEventToItemsMap(){return this._eventToItems}_getActionMatcher(){return this._actionMatcher}},ld=class extends ad{constructor(e,t,i,s){var n;super({subscribeCapture(t){const i=e.onEvent(e=>t(e.event,e));return()=>i.dispose()},subscribeSession(t){const i=e.onSession(t);return()=>i.dispose()},getSessionId(){var t;return null===(t=e.session)||void 0===t?void 0:t.sessionId},getProperty:t=>e.kv.get(t),getActionUrl:null==i?void 0:i.getActionUrl,setElementSelectors:null!==(n=null==i?void 0:i.setElementSelectors)&&void 0!==n?n:(t,i)=>{var s;return null===(s=e.getExtension("autocapture"))||void 0===s?void 0:s.setElementSelectors(t,i)}},s),this._client=e,this._surveys=t,this._subscribeSession()}_getActivatedKey(){return C}_getActivatedSessionKey(){return k}_getActivationTimestampsKey(){return E}_writeActivationTimestamps(e){this._client.kv.set({[E]:e})}_clearActivationTimestampsStore(){this._client.kv.remove(E)}_shouldPersistArmedActivation(e){var t;let i;this._getItems(t=>{i=t.find(t=>t.id===e)});const s=null==i||null===(t=i.appearance)||void 0===t?void 0:t.surveyPopupDelaySeconds;return St(s)&&s>0}_getShownEventName(){return ll}_getItems(e){this._surveys.getSurveys(e)}_cancelPendingItem(e){this._surveys.cancelPendingSurvey(e)}_getLogger(){return jc}_setActivatedItems(e){this._client.kv.set({[C]:e})}_setActivatedSession(e){this._client.kv.set({[k]:e})}_clearActivatedSession(){this._client.kv.remove(k)}_isItemPermanentlyIneligible(){return!1}_activationOutcome(e,t,i){var s;if(e===ul&&!1===(null==i||null===(s=i.properties)||void 0===s?void 0:s.$survey_completed))return"ignore";let n;return this._getItems(e=>{n=e.find(e=>e.id===t)}),!n||function(e){var t;return $c(e)&&!!(null===(t=e.conditions)||void 0===t||null===(t=t.events)||void 0===t?void 0:t.repeatedActivation)||"always"===e.schedule}(n)?e===ll?"consume":"ignore":e===ll?"persist":e===cl||e===ul?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}};const cd=(e,t)=>(null==e?void 0:e.then)?e.then(t):t(e),ud="SDK is not enabled or survey functionality is not yet loaded",dd="Disabled. Not loading surveys.";var hd=class{constructor(e){this._configSource=e,this.name="surveys",this._surveyEventReceiver=null,this._surveyManager=null,this._isInitializingSurveys=!1,this._surveyInitializationFailed=!1,this._surveyCallbacks=[],this._activeMatchingSurveyCallbacks=[],this._getSurveysInFlightPromise=null,this._lastSurveyRefreshFailedAt=null,this._disposed=!1,this._renderTimeouts=new Set,this.onRemoteConfig=e=>{if(this._disposed)return;if(this._config.disableSurveys)return;if(!e.ok)return this._surveyInitializationFailed=!0,this._notifyActiveMatchingSurveyCallbacks({isLoaded:!1,error:"Remote config unavailable. Not loading surveys."}),jc.warn("Remote config unavailable. Not loading surveys.");const t=e.config.surveys;if(wt(t))return jc.warn("Flags not loaded yet. Not loading surveys.");this._isSurveysEnabled=kt(t)?t:t.length>0,jc.info(`flags response received, isSurveysEnabled: ${this._isSurveysEnabled}`),this.loadIfEnabled()},this._notifyActiveMatchingSurveyCallbacks=e=>{this._activeMatchingSurveyCallbacks.slice().forEach(t=>this._notifyActiveMatchingSurveyCallback(t,e))}}setup(e){if(!this._disposed)return this._initializingClient=e,cd(e.kv.initialize(),()=>{if(this._initializingClient!==e||this._disposed)return;this._initializingClient=void 0,this._client=e;const t=e.onRemoteConfig(this.onRemoteConfig);this._disposed?t.dispose():(this._remoteConfigSubscription=t,this.loadIfEnabled())})}dispose(){var e,t,i,s,n;this._disposed||(this._disposed=!0,this._initializingClient=void 0,this._client=void 0,null===(e=this._remoteConfigSubscription)||void 0===e||e.dispose(),this._remoteConfigSubscription=void 0,null===(t=this._surveyEventReceiver)||void 0===t||t.dispose(),this._surveyEventReceiver=null,null===(i=this._surveyManager)||void 0===i||null===(s=i.dispose)||void 0===s||s.call(i),this._surveyManager=null,this._surveyCallbacks=[],this._activeMatchingSurveyCallbacks.forEach(e=>{e.active=!1}),this._activeMatchingSurveyCallbacks=[],null===(n=this._activeMatchingSurveyConditionsUnsubscribe)||void 0===n||n.call(this),this._activeMatchingSurveyConditionsUnsubscribe=void 0,this._getSurveysInFlightPromise=null,this._renderTimeouts.forEach(e=>clearTimeout(e)),this._renderTimeouts.clear())}get _config(){return this._configSource.get()}getRenderContext(){if(!this._client)return;const e=this;return{client:this._client,get config(){return e._config},surveys:e}}initialize(){this.loadIfEnabled()}reset(){var e,t;null===(e=this._surveyManager)||void 0===e||null===(t=e.clearInMemoryInProgressSurveyState)||void 0===t||t.call(e);try{var i;null===(i=this._surveyEventReceiver)||void 0===i||i.reset(),localStorage.removeItem("lastSeenSurveyDate");const e=[];for(let t=0;t<localStorage.length;t++){const i=localStorage.key(t);((null==i?void 0:i.startsWith("seenSurvey_"))||(null==i?void 0:i.startsWith("inProgressSurvey_")))&&e.push(i)}e.forEach(e=>localStorage.removeItem(e))}catch(e){}this._notifyActiveMatchingSurveyCallbacks()}loadIfEnabled(){if(this._disposed||!this._client)return;const e=this._config;if(this._surveyManager)return;if(this._isInitializingSurveys)return void jc.info("Already initializing surveys, skipping...");if(e.disableSurveys)return void jc.info(dd);if(e.cookielessMode&&this._client.isOptedOut)return void jc.info("Not loading surveys in cookieless mode without consent.");const t=this._configSource.getExtensions();if(!t)return void this._handleSurveyLoadError("PostHog Extensions not found.");if(vt(this._isSurveysEnabled)&&!e.advancedEnableSurveys)return;const i=this._isSurveysEnabled||e.advancedEnableSurveys;this._isInitializingSurveys=!0,this._surveyInitializationFailed=!1;try{const e=t.generateSurveys;if(e)return this._completeSurveyInitialization(e,i),void(this._isInitializingSurveys=!1);const s=t.loadExternalDependency;if(!s)return this._handleSurveyLoadError(S),void(this._isInitializingSurveys=!1);s(e=>{try{if(this._disposed)return;const t=this._configSource.getExtensions();e||!(null==t?void 0:t.generateSurveys)?this._handleSurveyLoadError("Could not load surveys script",e):this._completeSurveyInitialization(t.generateSurveys,i)}finally{this._isInitializingSurveys=!1}})}catch(e){throw this._isInitializingSurveys=!1,this._handleSurveyLoadError("Error initializing surveys",e),e}}_completeSurveyInitialization(e,t){var i;if(this._disposed)return;this._surveyManager=e(t),this._surveyEventReceiver=this._createEventReceiver(this._client,this._notifyActiveMatchingSurveyCallbacks);const s=null===(i=this._client)||void 0===i?void 0:i.kv.get(b);s&&this._registerEventOrActionBasedSurveys(s),jc.info("Surveys loaded successfully"),this._startActiveMatchingSurveyConditions(),this._notifyActiveMatchingSurveyCallbacks(),this._notifySurveyCallbacks({isLoaded:!0})}_createEventReceiver(e,t){return new ld(e,this,void 0,t)}_handleSurveyLoadError(e,t){this._surveyInitializationFailed=!0,jc.error(e,t),this._notifyActiveMatchingSurveyCallbacks({isLoaded:!1,error:e}),this._notifySurveyCallbacks({isLoaded:!1,error:e})}onSurveysLoaded(e){return this._surveyCallbacks.push(e),this._surveyManager&&this._notifySurveyCallbacks({isLoaded:!0}),()=>{this._surveyCallbacks=this._surveyCallbacks.filter(t=>t!==e)}}getSurveys(e,t=!1){if(this._disposed)return;const i=this._client;if(!i)return e([],{isLoaded:!1,error:ud});if(this._config.disableSurveys)return jc.info(dd),e([]);const s=i.kv.get(b);if(s&&!t)return e(s,{isLoaded:!0}),void(this._shouldBackgroundRefreshSurveys()&&this.getSurveys(()=>{},!0));if(this._getSurveysInFlightPromise)return void this._getSurveysInFlightPromise.then(({surveys:t,context:i})=>{this._disposed||e(t,i)}).catch(e=>jc.error("Error in survey callback",e));const n=i.sendRequest("/api/surveys/",{method:"GET",query:{token:i.projectToken},sentAt:"query",timeoutMs:this._config.requestTimeoutMs}).then(e=>{try{return this._handleSurveyResponse(i,e)}catch(e){return jc.error("Error processing surveys response",e),this._handleSurveyResponse(i,{statusCode:0,error:e})}},e=>this._handleSurveyResponse(i,{statusCode:0,error:e}));this._getSurveysInFlightPromise=n;const r=()=>{this._getSurveysInFlightPromise===n&&(this._getSurveysInFlightPromise=null)};n.then(t=>{r(),this._disposed||(this._notifyActiveMatchingSurveyCallbacks(t.context),e(t.surveys,t.context))},r).catch(e=>jc.error("Error in survey callback",e))}_handleSurveyResponse(e,t){if(this._disposed)return{surveys:[],context:{isLoaded:!1,error:ud}};const i=t.statusCode;if(200!==i||!t.json){const e=`Surveys API could not be loaded, status: ${i}`;return 0!==i?jc.error(e):t.error||jc.warn(e),this._lastSurveyRefreshFailedAt=Date.now(),{surveys:[],context:{isLoaded:!1,error:e}}}this._lastSurveyRefreshFailedAt=null;const s=t.json.surveys||[];return e.kv.set({[b]:s,[w]:Date.now()}),this._registerEventOrActionBasedSurveys(s),{surveys:s,context:{isLoaded:!0}}}_registerEventOrActionBasedSurveys(e){const t=e.filter(e=>function(e){return!(!e.start_date||e.end_date)}(e)&&($c(e)||function(e){var t;return!!(null===(t=e.conditions)||void 0===t||null===(t=t.actions)||void 0===t||null===(t=t.values)||void 0===t?void 0:t.length)}(e)));this._registerSurveyTriggers(t)}_registerSurveyTriggers(e){var t;null===(t=this._surveyEventReceiver)||void 0===t||t.replace(e)}_shouldBackgroundRefreshSurveys(){return this._isSurveyCacheStale()&&!this._getSurveysInFlightPromise&&!this._isSurveyRefreshBackingOff()}_isSurveyCacheStale(){var e;const t=null===(e=this._client)||void 0===e?void 0:e.kv.get(w);return St(t)&&Date.now()-t>3e5}_isSurveyRefreshBackingOff(){return St(this._lastSurveyRefreshFailedAt)&&3e5>Date.now()-this._lastSurveyRefreshFailedAt}markSurveyAsSeen(e,t){var i;const s={id:e,current_iteration:null!==(i=null==t?void 0:t.iteration)&&void 0!==i?i:null};Wc(s);try{localStorage.setItem("lastSeenSurveyDate",(new Date).toISOString())}catch(e){}this._notifyActiveMatchingSurveyCallbacks()}_notifySurveyCallbacks(e){for(const t of this._surveyCallbacks){if(this._disposed)return;try{e.isLoaded?this.getSurveys(t):t([],e)}catch(e){jc.error("Error in survey callback",e)}}}getActiveMatchingSurveys(e,t=!1){if(!wt(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);jc.warn("init was not called")}onActiveMatchingSurveysChanged(e){var t;if(this._disposed)return()=>{};const i={callback:e,active:!0,revision:0};this._activeMatchingSurveyCallbacks.push(i),this._startActiveMatchingSurveyConditions();const s=null===(t=this._client)||void 0===t?void 0:t.kv.get(b);return this._config.disableSurveys||!this._surveyManager&&this._surveyInitializationFailed&&!this._isInitializingSurveys||!s&&!wt(this._lastSurveyRefreshFailedAt)&&!this._getSurveysInFlightPromise?this._notifyActiveMatchingSurveyCallback(i,{isLoaded:!1}):this._surveyManager&&this._notifyActiveMatchingSurveyCallback(i),()=>{var e;i.active=!1,this._activeMatchingSurveyCallbacks=this._activeMatchingSurveyCallbacks.filter(e=>e!==i),0===this._activeMatchingSurveyCallbacks.length&&(null===(e=this._activeMatchingSurveyConditionsUnsubscribe)||void 0===e||e.call(this),this._activeMatchingSurveyConditionsUnsubscribe=void 0)}}_startActiveMatchingSurveyConditions(){var e,t,i;this._surveyManager&&this._activeMatchingSurveyCallbacks.length>0&&(null!==(e=this._activeMatchingSurveyConditionsUnsubscribe)&&void 0!==e||(this._activeMatchingSurveyConditionsUnsubscribe=null===(t=(i=this._configSource).onMatchingConditionsChanged)||void 0===t?void 0:t.call(i,this._notifyActiveMatchingSurveyCallbacks)))}_notifyActiveMatchingSurveyCallback(e,t){if(this._disposed||!e.active)return;const i=++e.revision,s=s=>{if(!this._disposed&&e.active&&i===e.revision)try{const i=null!=t?t:{isLoaded:!0},n=JSON.stringify([s,i]);if(n===e.lastResult)return;e.lastResult=n,e.callback(s,i)}catch(e){jc.error("Error in active matching surveys callback",e)}};try{t&&!t.isLoaded?s([]):this.getActiveMatchingSurveys(s)}catch(e){jc.error("Error in active matching surveys callback",e)}}_getSurveyById(e){let t=null;return this.getSurveys(i=>{var s;t=null!==(s=i.find(t=>t.id===e))&&void 0!==s?s:null}),t}_checkSurveyEligibility(e){if(wt(this._surveyManager))return{eligible:!1,reason:ud};const t="string"==typeof e?this._getSurveyById(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:"Survey not found"}}_checkSurveyRenderability(e){var t;if(!(null===(t=this._client)||void 0===t?void 0:t.canCapture))return{eligible:!1,reason:"PostHog is not capturing, so a survey response cannot be recorded"};if(wt(this._surveyManager))return{eligible:!1,reason:ud};const i="string"==typeof e?this._getSurveyById(e):e;return i?this._surveyManager.checkSurveyRenderability(i):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(e){if(wt(this._surveyManager))return jc.warn("init was not called"),{visible:!1,disabledReason:ud};const t=this._checkSurveyRenderability(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return wt(this._surveyManager)?(jc.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:ud})):new Promise(i=>{this.getSurveys(t=>{var s;const n=null!==(s=t.find(t=>t.id===e))&&void 0!==s?s:null;if(n){const e=this._checkSurveyRenderability(n);i({visible:e.eligible,disabledReason:e.reason})}else i({visible:!1,disabledReason:"Survey not found"})},t)})}renderSurvey(e,t,i){var s,n,r;if(!(null===(s=this._client)||void 0===s?void 0:s.canCapture))return;if(wt(this._surveyManager))return void jc.warn("init was not called");const o="string"==typeof e?this._getSurveyById(e):e;if(!(null==o?void 0:o.id))return void jc.warn("Survey not found");if(!Vc.includes(o.type))return void jc.warn(`Surveys of type ${o.type} cannot be rendered in the app`);const a=null===(n=typeof document>"u"?void 0:document)||void 0===n?void 0:n.querySelector(t);if(a){if(null===(r=o.appearance)||void 0===r?void 0:r.surveyPopupDelaySeconds){jc.info(`Rendering survey ${o.id} with delay of ${o.appearance.surveyPopupDelaySeconds} seconds`);const e=setTimeout(()=>{var t,s,n;this._renderTimeouts.delete(e),!this._disposed&&(null===(t=this._client)||void 0===t?void 0:t.canCapture)&&(jc.info(`Rendering survey ${o.id} with delay of ${null===(s=o.appearance)||void 0===s?void 0:s.surveyPopupDelaySeconds} seconds`),null===(n=this._surveyManager)||void 0===n||n.renderSurvey(o,a,i),jc.info(`Survey ${o.id} rendered`))},1e3*o.appearance.surveyPopupDelaySeconds);return void this._renderTimeouts.add(e)}this._surveyManager.renderSurvey(o,a,i)}else jc.warn("Survey element not found")}displaySurvey(e,t){var i,s;if(!(null===(i=this._client)||void 0===i?void 0:i.canCapture))return;if(wt(this._surveyManager))return void jc.warn("init was not called");const n=this._getSurveyById(e);if(!n)return void jc.warn("Survey not found");let r=n;if((null===(s=n.appearance)||void 0===s?void 0:s.surveyPopupDelaySeconds)&&t.ignoreDelay&&(r=as(as({},n),{},{appearance:as(as({},n.appearance),{},{surveyPopupDelaySeconds:0})})),t.displayType!==hl&&t.initialResponses&&jc.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),!1===t.ignoreConditions){const e=this._checkSurveyEligibility(n);if(!e.eligible)return void jc.warn("Survey is not eligible to be displayed: ",e.reason)}"inline"!==t.displayType?this._surveyManager.handlePopoverSurvey(r,t):this.renderSurvey(r,t.selector,t.properties)}cancelPendingSurvey(e){wt(this._surveyManager)?jc.warn("init was not called"):this._surveyManager.cancelSurvey(e)}handlePageUnload(){var e,t;null===(e=this._surveyManager)||void 0===e||null===(t=e.handlePageUnload)||void 0===t||t.call(e)}},_d=class{constructor(e){this._instance=e}get(){var e,t,i,s;const n=null===(e=this._instance)||void 0===e?void 0:e.config;return{disableSurveys:!!(null==n?void 0:n.disable_surveys),cookielessMode:!!(null==n?void 0:n.cookieless_mode),advancedEnableSurveys:!!(null==n?void 0:n.advanced_enable_surveys),requestTimeoutMs:null!==(t=null==n?void 0:n.surveys_request_timeout_ms)&&void 0!==t?t:1e4,prefillFromUrl:!!(null==n||null===(i=n.surveys)||void 0===i?void 0:i.prefillFromUrl),automaticDisplay:!(null==n?void 0:n.disable_surveys_automatic_display),featureFlagEvaluation:!(null==n?void 0:n.advanced_disable_feature_flags),overrideLanguage:null==n?void 0:n.override_display_language,prepareStylesheet:null==n?void 0:n.prepare_external_dependency_stylesheet,get_current_url:null==n?void 0:n.get_current_url,uiHost:null===(s=this._instance)||void 0===s||null===(s=s.requestRouter)||void 0===s?void 0:s.endpointFor("ui","")}}getExtensions(){const e=null==tt?void 0:tt.__PosthogExtensions__;if(!e||!this._instance)return;const t=this._instance,{generateSurveys:i,loadExternalDependency:s}=e;return{generateSurveys:i?e=>i(t,e):void 0,loadExternalDependency:s?e=>s(t,"surveys",e):void 0}}onMatchingConditionsChanged(e){var t,i;const s=null===(t=this._instance)||void 0===t?void 0:t._addCaptureHook(t=>{"$pageview"!==t&&t!==ll&&t!==cl&&t!==ul||e()}),n=()=>e();Br(je,"PHSurveyShown",n);let r=!1;const o=null===(i=this._instance)||void 0===i?void 0:i.onFeatureFlags(()=>{r&&e()});return r=!0,()=>{r=!1,null==s||s(),null==o||o(),null==je||je.removeEventListener("PHSurveyShown",n)}}};const pd=(()=>(null==je?void 0:je.location)?Ta(je.location.hash,"__posthog")||Ta(location.hash,"state"):null)(),gd="_postHogToolbarParams",fd=Fr("[Toolbar]"),vd=Fr("[FeatureFlags]"),md=Fr("[FeatureFlags]",{debugEnabled:!0}),yd="\" failed. Feature flags didn't load in time.",bd=[502,504],wd=["click","keydown","wheel","touchstart","pointerdown"],Sd="connection_error",Cd=e=>{const t={};for(let i=0;e.length>i;i++)t[e[i]]=!0;return t},kd=e=>{const t={};for(const[i,s]of $r(e||{}))s&&(t[i]=s);return t},Ed=(e,t)=>e.distinctId===t.distinctId&&e.sessionId===t.sessionId&&((e,t)=>{const i=Object.keys(e);return i.length===Object.keys(t).length&&i.every(i=>e[i]===t[i])})(e.groups,t.groups);var xd=class{constructor(e){this.name="featureFlags",this._override_warning=!1,this.featureFlagEventHandlers=[],this._logger=vd,this._baseEventProperties={},this._eventPropertiesWithFlagValues={},this._reloadingHandlers=[],this._pendingReloads=new Set,this._activeReloads=new Set,this._hasLoadedFlags=!1,this._requestInFlight=!1,this._requestGeneration=0,this._reloadingDisabled=!1,this._additionalReloadRequested=!1,this._firingFeatureFlagsCallbacks=!1,this._flagCallsPendingCapture=new Map,this._sendingFlagCallsPendingCapture=!1,this._flagsLoadedFromRemote=!1,this._staleCacheRefreshTriggered=!1,this._consecutiveStatusZeroFailures=0,this._hadUserInteraction=!1,this._onOnline=()=>{const e=this._hasStatusZeroCircuitBreakerTripped();this._consecutiveStatusZeroFailures=0,e&&this.reloadFeatureFlags()},this._refreshIfDue=()=>{var e,t;const i=this._refreshIntervalMs,s=null!==(e=this._dueRefreshIntervalMs)&&void 0!==e?e:i;vt(i)||vt(s)||this._config.remoteRequestsDisabled||!this._document||"hidden"===this._document.visibilityState||Date.now()-(null!==(t=this._lastRefreshAt)&&void 0!==t?t:0)<s||(this._dueRefreshIntervalMs=this._hadUserInteraction||!this._config.idleRefreshBackoff?i:Math.min(2*s,36e5),this._hadUserInteraction=!1,this.reloadFeatureFlags(),this._scheduleNextRefresh())},this._onUserInteraction=()=>{this._hadUserInteraction&&this._dueRefreshIntervalMs===this._refreshIntervalMs||this._resumeConfiguredInterval()},this._onVisibilityChange=()=>{var e;"visible"===(null===(e=this._document)||void 0===e?void 0:e.visibilityState)&&this._resumeConfiguredInterval()},this._configSource=e}get _crossTabPersistence(){}_onConfigUpdated(){this._client&&this._syncAutomaticRefresh()}setup(e){try{this._window=typeof window>"u"?void 0:window,this._document=typeof document>"u"?void 0:document}catch(e){this._window=void 0,this._document=void 0}return this._initializingClient=e,this._logger=e.logger.createLogger("[FeatureFlags]"),cd(e.kv.initialize(),()=>{this._initializingClient===e&&(this._initializingClient=void 0,this._client=e,this._finishSetup(e))})}_finishSetup(e){var t;if(this._client===e)return this._window&&Br(this._window,"online",this._onOnline),this._syncAutomaticRefresh(),this._dynamicProperties=e.registerDynamicEventProperties(()=>this._isCacheStale()?this._baseEventProperties:this._eventPropertiesWithFlagValues),this._crossTabPersistenceUnsubscribe=null===(t=this._crossTabPersistence)||void 0===t?void 0:t.onCrossTabFeatureFlagChange(()=>{this._clearBootstrapState(),this._rebuildEventProperties(),this._fireFeatureFlagsCallbacks()}),this._rebuildEventProperties(),this.initialize()}_resumeConfiguredInterval(){this._hadUserInteraction=!0,this._dueRefreshIntervalMs=this._refreshIntervalMs,this._refreshIfDue()}_syncAutomaticRefresh(){var e;const t=this._config.refreshIntervalMs,i=!this._config.remoteRequestsDisabled&&this._document&&!vt(t)&&t>0?t:void 0;this._config.idleRefreshBackoff||(this._dueRefreshIntervalMs=i),i!==this._refreshIntervalMs&&(this._stopAutomaticRefresh(),vt(i)||(this._refreshIntervalMs=i,this._dueRefreshIntervalMs=i,this._scheduleNextRefresh(),(null===(e=this._document)||void 0===e?void 0:e.addEventListener)&&(Br(this._document,m,this._onVisibilityChange),Tr(wd,e=>{Br(this._document,e,this._onUserInteraction,{capture:!0})}))))}_scheduleNextRefresh(){vt(this._refreshIntervalMs)||(vt(this._refreshInterval)||clearInterval(this._refreshInterval),this._lastRefreshAt=Date.now(),this._refreshInterval=setInterval(this._refreshIfDue,this._refreshIntervalMs))}_stopAutomaticRefresh(){var e,t;vt(this._refreshInterval)||(clearInterval(this._refreshInterval),this._refreshInterval=void 0,null===(e=this._document)||void 0===e||null===(t=e.removeEventListener)||void 0===t||t.call(e,"visibilitychange",this._onVisibilityChange),Tr(wd,e=>{var t,i;null===(t=this._document)||void 0===t||null===(i=t.removeEventListener)||void 0===i||i.call(t,e,this._onUserInteraction,{capture:!0})})),this._refreshIntervalMs=void 0,this._dueRefreshIntervalMs=void 0,this._hadUserInteraction=!1,this._lastRefreshAt=void 0}destroy(){this._dispose()}dispose(){this._dispose()}_dispose(){var e,t,i;this._stopAutomaticRefresh(),this._requestGeneration++,this._additionalReloadRequested=!1,this._initializingClient=void 0,this._settleReloads(this._pendingReloads,"cancelled"),this._settleReloads(this._activeReloads,"cancelled"),this._client&&(this._clearDebouncer(),null===(e=this._dynamicProperties)||void 0===e||e.dispose(),this._dynamicProperties=void 0,null===(t=this._crossTabPersistenceUnsubscribe)||void 0===t||t.call(this),this._crossTabPersistenceUnsubscribe=void 0,this._reloadingHandlers=[],null===(i=this._window)||void 0===i||i.removeEventListener("online",this._onOnline),this._client=void 0)}get _config(){return this._configSource.get()}_prop(e){var t;return this._bootstrapState&&e in this._bootstrapState?this._bootstrapState[e]:null===(t=this._client)||void 0===t?void 0:t.kv.get(e)}_clearBootstrapState(){return!!this._bootstrapState&&(this._bootstrapState=void 0,!0)}_fallBackToPersistedFlags(){var e;return!vt(null===(e=this._client)||void 0===e?void 0:e.kv.get("$enabled_feature_flags"))&&this._clearBootstrapState()}_set(e){this._persist(()=>{var t;return null===(t=this._client)||void 0===t?void 0:t.kv.set(e)})}_markCrossTabFeatureFlagSnapshot(e,t,i){if(!this._crossTabPersistence||!e.$enabled_feature_flags)return;const s=this._prop("$enabled_feature_flags")||{},o=e.$enabled_feature_flags||{},d=t.flags||t.featureFlags,h=t.flags?Object.entries(t.flags).filter(([,e])=>!(null==e?void 0:e.failed)).map(([e])=>e):[],_=!!t.errorsWhileComputingFlags&&!!t.flags,p=_?h:i&&!_t(d)?Object.keys(d||{}):Array.from(new Set([...Object.keys(s),...Object.keys(o)])),f=this._prop("$feature_flag_payloads")||{},v=e.$feature_flag_payloads||{},m=_||i?p:Array.from(new Set([...Object.keys(f),...Object.keys(v)])),y=!_&&!i,b=!!y||p,w=!!y||m,S={[n]:b,[u]:b,[g]:w};e.$feature_flag_details&&(S[r]=b);for(const t of[l,a,c])vt(e[t])||(S[t]=!0);this._crossTabPersistence.markCrossTabFeatureFlagChanges(S)}_remove(e){this._persist(()=>{var t;return null===(t=this._client)||void 0===t?void 0:t.kv.remove(e)})}_persist(e){try{e()}catch(e){this._logger.error("Failed to update feature flag persistence",e)}}_rebuildEventProperties(){const e={};for(const t of[n,g,l,f]){const i=this._prop(t);vt(i)||(e[t]=i)}this._baseEventProperties=e;const t=as({},e),i=this._prop(u);if(i)for(const[e,s]of Object.entries(i))t[`$feature/${e}`]=s;this._eventPropertiesWithFlagValues=t}_isCacheStale(){const e=this._config.cacheTtlMs;if(!e||0>=e)return!1;const t=this._prop(a);return"number"!=typeof t||Date.now()-t>e}_checkAndTriggerStaleRefresh(){return!!this._isCacheStale()&&(this._staleCacheRefreshTriggered||this._requestInFlight||(this._staleCacheRefreshTriggered=!0,this._logger.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}_getValidEvaluationEnvironments(){const e=this._config.evaluationContexts;return(null==e?void 0:e.length)?e.filter(e=>{const t=e&&"string"==typeof e&&e.trim().length>0;return t||this._logger.error("Invalid evaluation context found:",e,"Expected non-empty string"),t}):[]}_getValidFlagKeys(){const e=this._config.flagKeys;if(!vt(e))return e.filter(e=>{const t=e&&"string"==typeof e&&e.trim().length>0;return t||this._logger.error("Invalid flag key found:",e,"Expected non-empty string"),t})}initialize(){var e,t;const i=this._config,s=null!==(e=null===(t=i.bootstrap)||void 0===t?void 0:t.featureFlags)&&void 0!==e?e:{};if(Object.keys(s).length){var n,r;const e=null!==(n=null===(r=i.bootstrap)||void 0===r?void 0:r.featureFlagPayloads)&&void 0!==n?n:{},t=Object.keys(s).filter(e=>!vt(s[e])).reduce((e,t)=>(e[t]=s[t],e),{}),o=Object.keys(e).filter(e=>t[e]).reduce((t,i)=>(t[i]=e[i],t),{});return this._receivedFeatureFlags({featureFlags:t,featureFlagPayloads:o},void 0,{persist:!1})}}updateFlags(e,t,i){var s,n;const r=(null==i?void 0:i.merge)&&null!==(s=this._prop("$enabled_feature_flags"))&&void 0!==s?s:{},o=(null==i?void 0:i.merge)&&null!==(n=this._prop("$feature_flag_payloads"))&&void 0!==n?n:{},a=as(as({},r),e),l=as(as({},o),t),c={};for(const[e,t]of Object.entries(a))c[e]={key:e,enabled:en(t),variant:tn(t),reason:void 0,metadata:vt(null==l?void 0:l[e])?void 0:{id:0,version:void 0,description:void 0,payload:l[e]}};this._receivedFeatureFlags({flags:c})}get hasLoadedFlags(){return this._hasLoadedFlags}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){const e=this._prop(r),t=this._prop(f),i=this._prop(v);if(!i&&!t)return e||{};const s=Ar({},e||{}),n=[...new Set([...Object.keys(i||{}),...Object.keys(t||{})])];for(const e of n){var o,a;const n=s[e],r=null==t?void 0:t[e],l=vt(r)?null!==(o=null==n?void 0:n.enabled)&&void 0!==o&&o:!!r,c=vt(r)?null==n?void 0:n.variant:"string"==typeof r?r:void 0,u=null==i?void 0:i[e],d=as(as({},n),{},{enabled:l,variant:l?null!=c?c:null==n?void 0:n.variant:void 0});l!==(null==n?void 0:n.enabled)&&(d.original_enabled=null==n?void 0:n.enabled),c!==(null==n?void 0:n.variant)&&(d.original_variant=null==n?void 0:n.variant),u&&(d.metadata=as(as({},null==n?void 0:n.metadata),{},{payload:u,original_payload:null==n||null===(a=n.metadata)||void 0===a?void 0:a.payload})),s[e]=d}return this._override_warning||(this._logger.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:i,finalDetails:s}),this._override_warning=!0),s}getAllFeatureFlags(){const e=this.getFlagVariants(),t=this.getFlagPayloads();return Object.keys(e).map(i=>{const s=e[i];return{key:i,enabled:en(s),variant:tn(s),payload:Zs(t[i])}})}getFlagVariants(){const e=this._prop(u),t=this._prop(f);if(!t)return e||{};const i=Ar({},e||{}),s=Object.keys(t);for(let e=0;s.length>e;e++)i[s[e]]=t[s[e]];return this._override_warning||(this._logger.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:i}),this._override_warning=!0),i}getFlagPayloads(){const e=this._prop(g),t=this._prop(v);if(!t)return e||{};const i=Ar({},e||{}),s=Object.keys(t);for(let e=0;s.length>e;e++)i[s[e]]=t[s[e]];return this._override_warning||(this._logger.warn(" Overriding feature flag payloads!",{flagPayloads:e,overriddenPayloads:t,finalPayloads:i}),this._override_warning=!0),i}reloadFeatureFlags(){this._reloadingDisabled||this._config.featureFlagsDisabled||this._hasStatusZeroCircuitBreakerTripped()||(this._firingFeatureFlagsCallbacks&&this._logger.warn("reloadFeatureFlags() was called inside an onFeatureFlags callback. This callback also runs when flags change in other tabs, so this can cause a request loop."),this._requestInFlight&&(this._additionalReloadRequested=!0),this._reloadDebouncer||(this._reloadingHandlers.slice().forEach(e=>{try{e()}catch(e){this._logger.error("Error while running feature flags reloading callback",e)}}),this._reloadDebouncer=setTimeout(()=>{this._callFlagsEndpoint()},5)))}reloadFeatureFlagsAsync(){return!this._client||this._reloadingDisabled||this._config.featureFlagsDisabled||this._config.remoteRequestsDisabled||this._hasStatusZeroCircuitBreakerTripped()?Promise.resolve({status:"skipped"}):new Promise(e=>{this._pendingReloads.add(e),this.reloadFeatureFlags()})}_settleReloads(e,t){e.forEach(e=>e({status:t})),e.clear()}_clearDebouncer(){clearTimeout(this._reloadDebouncer),this._reloadDebouncer=void 0}onReloading(e){return this._reloadingHandlers.push(e),()=>{this._reloadingHandlers=this._reloadingHandlers.filter(t=>t!==e)}}ensureFlagsLoaded(){this._hasLoadedFlags||this._requestInFlight||this._reloadDebouncer||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this._reloadingDisabled=e}resetFlagCallReported(){this._remove(_),this._flagCallsPendingCapture=new Map}sendFlagCallsPendingCapture(){var e;if(0!==this._flagCallsPendingCapture.size&&!this._sendingFlagCallsPendingCapture&&(null===(e=this._client)||void 0===e?void 0:e.canCapture)&&!this._client.isRateLimited){this._sendingFlagCallsPendingCapture=!0;try{const e=this.getFlagVariants();for(const t of Array.from(this._flagCallsPendingCapture.keys())){const i=this._flagCallsPendingCapture.get(t);if(i){if(i.value!==String(e[t])||!Ed(i.context,this._flagCallContext())){this._flagCallsPendingCapture.delete(t);continue}if(this.getFeatureFlagResult(t),this._flagCallsPendingCapture.has(t))break}}}finally{this._sendingFlagCallsPendingCapture=!1}}}_callFlagsEndpoint(e){var t;this._clearDebouncer();const i=this._client;if(!i||this._config.remoteRequestsDisabled||this._hasStatusZeroCircuitBreakerTripped())return void this._settleReloads(this._pendingReloads,"skipped");if(this._requestInFlight)return void(this._additionalReloadRequested=!0);const s={token:i.projectToken,distinct_id:i.distinctId,groups:i.groups,$anon_distinct_id:this.$anon_distinct_id,person_properties:as(as(as({},i.initialPersonProperties),this._prop("$stored_person_properties")||{}),{},{$lib:i.library.name,$lib_version:i.library.version}),group_properties:this._prop(d),timezone:Sa()};vt(i.deviceId)||(s.$device_id=i.deviceId),((null==e?void 0:e.disableFlags)||this._config.featureFlagsDisabled)&&(s.disable_flags=!0);const n=this._getValidEvaluationEnvironments();n.length&&(s.evaluation_contexts=n);const r=this._getValidFlagKeys();vt(r)||(s.flag_keys=r);const a=this._config.onlyEvaluateSurveyFeatureFlags,l="/flags/?v=2"+(a?"&only_evaluate_survey_feature_flags=true":""),c=this._requestGeneration,u=this._pendingReloads;this._pendingReloads=new Set,this._activeReloads=u,this._requestInFlight=!0;const h=()=>{this._additionalReloadRequested&&(this._additionalReloadRequested=!1,this._callFlagsEndpoint())},_=e=>{var t,i;const n=null!==(t=e.json)&&void 0!==t?t:{},r=200!==e.statusCode;if(this._requestInFlight=!1,c!==this._requestGeneration)return void h();if(this._trackStatusZeroReachability(e.statusCode),r||this._additionalReloadRequested||(this.$anon_distinct_id=void 0),s.disable_flags&&!this._additionalReloadRequested)return void this._settleReloads(u,"skipped");this._flagsLoadedFromRemote=!r;const l=[];e.error?l.push(e.error instanceof Error&&"AbortError"===e.error.name?"timeout":e.error instanceof Error?Sd:"unknown_error"):200!==e.statusCode&&l.push(`api_error_${e.statusCode}`),n.errorsWhileComputingFlags&&l.push("errors_while_computing_flags");const d=!!(null===(i=n.quotaLimited)||void 0===i?void 0:i.includes("feature_flags"));d&&l.push("quota_limited"),this._set({[o]:l}),d?this._logger.warn("You have hit your feature flags quota limit, and will not be able to load feature flags until the quota is reset. Please visit https://posthog.com/docs/billing/limits-alerts to learn more."):s.disable_flags||this._receivedFeatureFlags(n,r,{partialResponse:a}),this._settleReloads(u,s.disable_flags?"skipped":l.length||!n.flags&&!n.featureFlags?"error":"loaded"),h()},p=e=>{this._requestInFlight=!1,c===this._requestGeneration?(this._set({[o]:[Sd]}),this._logger.error("Feature flag request failed",e),this._fallBackToPersistedFlags()&&this._fireFeatureFlagsCallbacks(!0),this._settleReloads(u,"error"),h()):h()};let g=null!==(t=this._config.requestMaxRetries)&&void 0!==t?t:1;const f=()=>g>0&&c===this._requestGeneration,v=()=>{if(c!==this._requestGeneration||!this._client||this._config.remoteRequestsDisabled)return this._requestInFlight=!1,this._settleReloads(u,"skipped"),void h();try{i.sendRequest(l,{target:"flags",method:"POST",body:s,compression:this._config.compression,sentAt:"body",timeoutMs:this._config.requestTimeoutMs}).then(e=>{if((e=>bd.includes(e.statusCode)||(e=>0===e.statusCode&&e.error instanceof Error&&"AbortError"===e.error.name)(e))(e)&&f())return g--,void setTimeout(v,500);_(e)}).catch(p)}catch(e){p(e)}};v()}_hasStatusZeroCircuitBreakerTripped(){return Ea(this._consecutiveStatusZeroFailures,3)}_trackStatusZeroReachability(e){this._consecutiveStatusZeroFailures=xa(e,this._consecutiveStatusZeroFailures,3,()=>this._logger.warn("Feature flag requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped refreshing feature flags; will try again when connectivity changes."))}getFeatureFlag(e,t={}){var i;if(t.fresh&&!this._flagsLoadedFromRemote)return;if(!(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0))return void this._logger.warn('getFeatureFlag for key "'+e+yd);if(this._checkAndTriggerStaleRefresh())return;const s=this.getFeatureFlagResult(e,t);return null!==(i=null==s?void 0:s.variant)&&void 0!==i?i:null==s?void 0:s.enabled}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){const t=this.getFeatureFlagResult(e,{send_event:!1});return null==t?void 0:t.payload}getFeatureFlagResult(e,t={}){if(t.fresh&&!this._flagsLoadedFromRemote)return;if(!(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0))return void this._logger.warn('getFeatureFlagResult for key "'+e+yd);if(this._checkAndTriggerStaleRefresh())return;const i=this.getFlagVariants(),s=e in i,n=i[e],r=this.getFlagPayloads()[e],o=String(n),a=this._prop("$feature_flag_request_id")||void 0,l=this._prop("$feature_flag_evaluated_at")||void 0;let c,u=this._prop("$flag_call_reported")||{};if(this._config.deduplicateCallsPerSession){var d;const e=null===(d=this._client)||void 0===d||null===(d=d.session)||void 0===d?void 0:d.sessionId,t=this._prop(p);e&&e!==t&&(u={},c=e)}if(!t.send_event&&"send_event"in t)c&&this._set({[_]:u,[p]:c});else{var h,g,f;const t=!(null===(h=this._client)||void 0===h?void 0:h.canCapture),i=!t&&!(null===(g=this._client)||void 0===g?void 0:g.isRateLimited);var v;if(i?this._flagCallsPendingCapture.delete(e):(t&&Object.keys(u).length>0&&(u={},this._set({[_]:u})),(null===(v=u[e])||void 0===v?void 0:v.includes(o))||this._holdFlagCall(e,o)),i&&!(null===(f=u[e])||void 0===f?void 0:f.includes(o))){var m,y,b,w,S,C,k,E,x,P,I,F,T;_t(u[e])?u[e].push(o):u[e]=[o],this._set(as({[_]:u},c?{[p]:c}:{}));const t=this.getFeatureFlagDetails(e),i=[...null!==(m=this._prop("$feature_flag_errors"))&&void 0!==m?m:[]];vt(n)&&i.push("flag_missing");const s={$feature_flag:e,$feature_flag_response:n,$feature_flag_payload:null!=r?r:null,$feature_flag_request_id:a,$feature_flag_evaluated_at:l,$feature_flag_bootstrapped_response:null!==(y=null===(b=this._config.bootstrap)||void 0===b||null===(b=b.featureFlags)||void 0===b?void 0:b[e])&&void 0!==y?y:null,$feature_flag_bootstrapped_payload:null!==(w=null===(S=this._config.bootstrap)||void 0===S||null===(S=S.featureFlagPayloads)||void 0===S?void 0:S[e])&&void 0!==w?w:null,$used_bootstrap_value:!this._flagsLoadedFromRemote};vt(null==t||null===(C=t.metadata)||void 0===C?void 0:C.has_experiment)||(s.$feature_flag_has_experiment=t.metadata.has_experiment),vt(null==t||null===(k=t.metadata)||void 0===k?void 0:k.version)||(s.$feature_flag_version=t.metadata.version);const d=null!==(E=null==t||null===(x=t.reason)||void 0===x?void 0:x.description)&&void 0!==E?E:null==t||null===(P=t.reason)||void 0===P?void 0:P.code;d&&(s.$feature_flag_reason=d),(null==t||null===(I=t.metadata)||void 0===I?void 0:I.id)&&(s.$feature_flag_id=t.metadata.id),vt(null==t?void 0:t.original_variant)&&vt(null==t?void 0:t.original_enabled)||(s.$feature_flag_original_response=vt(t.original_variant)?t.original_enabled:t.original_variant),(null==t||null===(F=t.metadata)||void 0===F?void 0:F.original_payload)&&(s.$feature_flag_original_payload=null==t||null===(T=t.metadata)||void 0===T?void 0:T.original_payload),i.length&&(s.$feature_flag_error=i.join(",")),this._captureFeatureFlagCalled(s)||(this._unmarkFlagCallReported(e,o),this._holdFlagCall(e,o))}else c&&this._set({[_]:u,[p]:c})}return s?{key:e,enabled:!!n,variant:"string"==typeof n?n:void 0,payload:Zs(r)}:void 0}_captureFeatureFlagCalled(e){try{var t;return!1!==(null===(t=this._client)||void 0===t?void 0:t.capture("$feature_flag_called",e))}catch(e){return this._logger.error("Failed to capture feature flag call",e),!0}}_holdFlagCall(e,t){this._flagCallsPendingCapture.set(e,{value:t,context:this._flagCallContext()})}_flagCallContext(){var e,t,i;return{distinctId:null===(e=this._client)||void 0===e?void 0:e.distinctId,groups:as({},null===(t=this._client)||void 0===t?void 0:t.groups),sessionId:this._config.deduplicateCallsPerSession?null===(i=this._client)||void 0===i||null===(i=i.session)||void 0===i?void 0:i.sessionId:void 0}}_unmarkFlagCallReported(e,t){const i=this._prop("$flag_call_reported")||{},s=i[e];_t(s)&&s.includes(t)&&(i[e]=s.filter(e=>e!==t),this._set({[_]:i}))}getRemoteConfigPayload(e,t){this._getRemoteConfigPayload(e,t)}_getRemoteConfigPayload(e,t){var i=this;return Ot(function*(){const s=i._client;if(!s)return;const n={distinct_id:s.distinctId,token:s.projectToken,person_properties:{$lib:s.library.name,$lib_version:s.library.version}},r=i._getValidEvaluationEnvironments();r.length&&(n.evaluation_contexts=r);const o=i._getValidFlagKeys();let a;vt(o)||(n.flag_keys=o);try{var l;const t=null===(l=(yield s.sendRequest("/flags/?v=2",{target:"flags",method:"POST",body:n,compression:i._config.compression,sentAt:"body",timeoutMs:i._config.requestTimeoutMs})).json)||void 0===l?void 0:l.featureFlagPayloads;a=(null==t?void 0:t[e])||void 0}catch(e){return void i._logger.error("Remote config feature flag request failed",e)}try{t(a)}catch(e){i._logger.error("Remote config feature flag callback failed",e)}})()}isFeatureEnabled(e,t={}){if(t.fresh&&!this._flagsLoadedFromRemote)return t.defaultValue;if(!(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0))return this._logger.warn('isFeatureEnabled for key "'+e+yd),t.defaultValue;const i=this.getFeatureFlag(e,t);return vt(i)?t.defaultValue:!!i}addFeatureFlagsHandler(e){this.featureFlagEventHandlers.push(e)}removeFeatureFlagsHandler(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter(t=>t!==e)}receivedFeatureFlags(e,t,i){this._receivedFeatureFlags(e,t,i)}_receivedFeatureFlags(e,t,i){if(!this._client)return;this._hasLoadedFlags=!0;const s=((e,t={},i={},s={},o,d=vd)=>{const h=((e,t)=>{const i=e.flags;if(i){const t=Object.fromEntries(Object.keys(i).map(e=>{var t;return[e,null!==(t=i[e].variant)&&void 0!==t?t:i[e].enabled]})),s=Object.fromEntries(Object.keys(i).filter(e=>i[e].enabled).filter(e=>{var t;return!vt(null===(t=i[e].metadata)||void 0===t?void 0:t.payload)}).map(e=>{var t;return[e,null===(t=i[e].metadata)||void 0===t?void 0:t.payload]}));return as(as({},e),{},{featureFlags:t,featureFlagPayloads:s})}return e.featureFlags&&t.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),e})(e,d),_=h.flags,p=h.featureFlags,f=h.featureFlagPayloads;if(!p)return;const v=e.requestId,m=e.evaluatedAt;if(_t(p)){d.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");const e={};if(p)for(let t=0;p.length>t;t++)e[p[t]]=!0;return{[n]:p,[u]:e,[c]:!1}}let y=p,b=f,w=_;if(null==o?void 0:o.partialResponse){const e=Object.keys(y),n=b||{};y=as(as({},t),y),b=as(as({},i),n),e.forEach(e=>{e in n||null==b||delete b[e]}),w=as(as({},s),w)}else if(e.errorsWhileComputingFlags)if(_){const e=new Set(Object.keys(_).filter(e=>{var t;return!(null===(t=_[e])||void 0===t?void 0:t.failed)}));y=as(as({},t),Object.fromEntries(Object.entries(y).filter(([t])=>e.has(t))));const n=Object.fromEntries(Object.entries(b||{}).filter(([t])=>e.has(t)));b=as(as({},i),n),e.forEach(e=>{e in n||null==b||delete b[e]}),w=as(as({},s),Object.fromEntries(Object.entries(w||{}).filter(([t])=>e.has(t))))}else y=as(as({},t),y),b=as(as({},i),b),w=as(as({},s),w);return as(as({[n]:Object.keys(kd(y)),[u]:y||{},[g]:b||{},[r]:w||{},[c]:!0===e.minimalFlagCalledEvents},v?{[l]:v}:{}),m?{[a]:m}:{})})(e,this.getFlagVariants(),this.getFlagPayloads(),this.getFlagsWithDetails(),i,this._logger);if(s)if(!1===(null==i?void 0:i.persist)){const e=!vt(this._client.kv.get(u));this._bootstrapState=s,e||this._set(s)}else this._clearBootstrapState(),this._markCrossTabFeatureFlagSnapshot(s,e,!!(null==i?void 0:i.partialResponse)),this._set(s);else t&&this._fallBackToPersistedFlags();t||(this._staleCacheRefreshTriggered=!1),this._fireFeatureFlagsCallbacks(t)}override(e,t=!1){this._logger.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){this._overrideFeatureFlags(e)}_overrideFeatureFlags(e){if(this._client){if(!1===e)return this._remove([f,v]),this._fireFeatureFlagsCallbacks(),void md.info("All overrides cleared");if(_t(e))return this._set({[f]:Cd(e)}),this._fireFeatureFlagsCallbacks(),void md.info("Flag overrides set",{flags:e});if(e&&"object"==typeof e&&("flags"in e||"payloads"in e)){var t;const i=e;this._override_warning=Boolean(null!==(t=i.suppressWarning)&&void 0!==t&&t);const s={},n=i.flags,r=i.payloads;return n&&(s[f]=_t(n)?Cd(n):n),r&&(s[v]=r),Object.keys(s).length&&this._set(s),!1===n&&!1===r?this._remove([f,v]):!1===n?this._remove(f):!1===r&&this._remove(v),this._fireFeatureFlagsCallbacks(),!1===n?md.info("Flag overrides cleared"):n&&md.info("Flag overrides set",{flags:n}),void(!1===r?md.info("Payload overrides cleared"):r&&md.info("Payload overrides set",{payloads:r}))}if(e&&"object"==typeof e)return this._set({[f]:e}),this._fireFeatureFlagsCallbacks(),void md.info("Flag overrides set",{flags:e});this._logger.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:e})}else this._logger.warn("posthog.featureFlags.overrideFeatureFlags called before feature flags were ready")}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this._hasLoadedFlags){const{flags:t,flagVariants:i}=this._prepareFeatureFlagsForCallbacks();try{e(t,i)}catch(e){this._logger.error("Error while running feature flags callback",e)}}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t,i){var s;const r=(this._prop("$early_access_features")||[]).find(t=>t.flagKey===e),o={[`$feature_enrollment/${e}`]:t},a={$feature_flag:e,$feature_enrollment:t,$set:o};r&&(a.$early_access_feature_name=r.name),i&&(a.$feature_enrollment_stage=i);const l=as(as({},this.getFlagVariants()),{},{[e]:t});null===(s=this._crossTabPersistence)||void 0===s||s.markCrossTabFeatureFlagChanges({$active_feature_flags:[e],$enabled_feature_flags:[e],$stored_person_properties:Object.keys(o)}),this._set({[n]:Object.keys(kd(l)),[u]:l,[h]:as(as({},this._prop("$stored_person_properties")||{}),o)}),this._fireFeatureFlagsCallbacks();try{var c;null===(c=this._client)||void 0===c||c.capture("$feature_enrollment_update",a)}catch(e){this._logger.error("Failed to capture early access feature enrollment",e)}}getEarlyAccessFeatures(e,t=!1,i){const n=this._prop(s);!n||t?this._getEarlyAccessFeatures(e,i):e(n)}_getEarlyAccessFeatures(e,t){var i=this;return Ot(function*(){const n=i._client;if(!n)return;const r=t?`&${t.map(e=>`stage=${e}`).join("&")}`:"";let o;try{const e=yield n.sendRequest(`/api/early_access_features/?token=${n.projectToken}${r}`,{target:"api",method:"GET",sentAt:"query"});if(!e.json)return;o=e.json.earlyAccessFeatures,i._set({[s]:o})}catch(e){return void i._logger.error("Early access feature request failed",e)}try{e(o)}catch(e){i._logger.error("Early access feature callback failed",e)}})()}_prepareFeatureFlagsForCallbacks(){const e=this.getFlags(),t=this.getFlagVariants();return{flags:e.filter(e=>t[e]),flagVariants:Object.keys(t).filter(e=>t[e]).reduce((e,i)=>(e[i]=t[i],e),{})}}_fireFeatureFlagsCallbacks(e){this._rebuildEventProperties();const{flags:t,flagVariants:i}=this._prepareFeatureFlagsForCallbacks(),s=this._firingFeatureFlagsCallbacks;this._firingFeatureFlagsCallbacks=!0,this.featureFlagEventHandlers.forEach(s=>{try{s(t,i,{errorsLoading:e})}catch(e){this._logger.error("Error while running feature flags callback",e)}}),this._firingFeatureFlagsCallbacks=s}setPersonPropertiesForFlags(e,t=!0){this._setPersonPropertiesForFlags(e,t)}_setPersonPropertiesForFlags(e,t=!0){const i=this._prop("$stored_person_properties")||{},s=(null==e?void 0:e.$set)||((null==e?void 0:e.$set_once)?{}:e),n=null==e?void 0:e.$set_once,r={};if(n)for(const e in n)({}).hasOwnProperty.call(n,e)&&(e in i||(r[e]=n[e]));this._set({[h]:as(as(as({},i),r),s)}),t&&this.reloadFeatureFlags()}unsetPersonPropertiesForFlags(e,t=!0){const i=as({},this._prop("$stored_person_properties")||{});e.forEach(e=>{delete i[e]}),this._set({[h]:i}),t&&this.reloadFeatureFlags()}resetPersonPropertiesForFlags(e=!0){this._remove(h),e&&this.reloadFeatureFlags()}setGroupPropertiesForFlags(e,t=!0){const i=this._prop("$stored_group_properties")||{},s=as({},i);for(const t of Object.keys(e))s[t]=as(as({},i[t]),e[t]);this._set({[d]:s}),t&&this.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){const t=this._prop("$stored_group_properties")||{};this._set({[d]:as(as({},t),{},{[e]:{}})})}else this._remove(d)}reset(){this._requestGeneration++,this._settleReloads(this._pendingReloads,"cancelled"),this._settleReloads(this._activeReloads,"cancelled"),this._additionalReloadRequested=!1,this._baseEventProperties={},this._eventPropertiesWithFlagValues={},this._bootstrapState=void 0,this._hasLoadedFlags=!1,this._reloadingDisabled=!1,this._flagsLoadedFromRemote=!1,this.$anon_distinct_id=void 0,this._clearDebouncer(),this._override_warning=!1,this._consecutiveStatusZeroFailures=0,this._flagCallsPendingCapture=new Map}};const Pd=Fr("[FeatureFlags]");var Id=class{constructor(e,t=!1){this._loggedEvaluationEnvironmentsDeprecation=!1,this.update(e,t)}update(e,t){this._snapshot=((e,t)=>{var i,s,n,r,o,a,l,c;return{bootstrap:{featureFlags:null!==(i=null===(s=e.bootstrap)||void 0===s?void 0:s.featureFlags)&&void 0!==i?i:void 0,featureFlagPayloads:null!==(n=null===(r=e.bootstrap)||void 0===r?void 0:r.featureFlagPayloads)&&void 0!==n?n:void 0},remoteRequestsDisabled:t,featureFlagsDisabled:!!e.advanced_disable_feature_flags,onlyEvaluateSurveyFeatureFlags:!!e.advanced_only_evaluate_survey_feature_flags,deduplicateCallsPerSession:!!e.advanced_feature_flags_dedup_per_session,cacheTtlMs:e.feature_flag_cache_ttl_ms,refreshIntervalMs:null!==(o=e.remote_config_refresh_interval_ms)&&void 0!==o?o:3e5,idleRefreshBackoff:vt(e.remote_config_refresh_interval_ms),requestTimeoutMs:e.feature_flag_request_timeout_ms,requestMaxRetries:Math.max(0,null!==(a=e.feature_flag_request_max_retries)&&void 0!==a?a:1),compression:e.disable_compression?void 0:"best-available",evaluationContexts:null!==(l=null!==(c=e.evaluation_contexts)&&void 0!==c?c:e.evaluation_environments)&&void 0!==l?l:[],flagKeys:_t(e.flag_keys)?e.flag_keys:void 0}})(e,t),!e.evaluation_environments||e.evaluation_contexts||this._loggedEvaluationEnvironmentsDeprecation||(Pd.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this._loggedEvaluationEnvironmentsDeprecation=!0),vt(e.flag_keys)||_t(e.flag_keys)||Pd.error("Invalid flag_keys found:",e.flag_keys,"Expected array of non-empty strings")}get(){return this._snapshot}},Fd=class extends xd{constructor(e){const t=new Id(e.config,e._shouldDisableFlags());super(t),this.name=lu,this._instance=e,this._mutableConfigSource=t}get _crossTabPersistence(){return this._instance.persistence}updateConfig(e,t){this._mutableConfigSource.update(e,t),this._onConfigUpdated()}};const Td=e=>Ft(e)&&("RangeError"===e.name&&0===e.message.indexOf("Maximum call stack size exceeded")||"InternalError"===e.name&&"too much recursion"===e.message),Rd=Fr("[Error tracking]"),Ad="webkit-masked-url:",$d=[{value:"isolatedAPI.contexts.topHostname",exact:!1},{value:"No response from target",exact:!0}],Md=["chrome-extension://","moz-extension://","safari-extension:","safari-web-extension:",Ad],Ld=["__firefox__","__gCrWeb"];function Od(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,s=Array(t);t>i;i++)s[i]=e[i];return s}function Dd(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var s,n,r,o,a=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t);else for(;!(l=(s=r.call(i)).done)&&(a.push(s.value),a.length!==t);l=!0);}catch(e){c=!0,n=e}finally{try{if(!l&&null!=i.return&&(o=i.return(),Object(o)!==o))return}finally{if(c)throw n}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return Od(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?Od(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}const Nd=Object.entries,Bd=Object.setPrototypeOf,zd=Object.isFrozen,Hd=Object.getPrototypeOf,Ud=Object.getOwnPropertyDescriptor;let qd=Object.freeze,jd=Object.seal,Wd=Object.create,Vd="undefined"!=typeof Reflect&&Reflect,Gd=Vd.apply,Kd=Vd.construct;qd||(qd=function(e){return e}),jd||(jd=function(e){return e}),Gd||(Gd=function(e,t){for(var i=arguments.length,s=new Array(i>2?i-2:0),n=2;i>n;n++)s[n-2]=arguments[n];return e.apply(t,s)}),Kd||(Kd=function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),s=1;t>s;s++)i[s-1]=arguments[s];return new e(...i)});const Qd=fh([].forEach),Jd=fh([].lastIndexOf),Yd=fh([].pop),Xd=fh([].push),Zd=fh([].splice),eh=Array.isArray,th=fh("".toLowerCase),ih=fh("".toString),sh=fh("".match),nh=fh("".replace),rh=fh("".indexOf),oh=fh("".trim),ah=fh((0).toString),lh=fh(Boolean.prototype.toString),ch="undefined"==typeof BigInt?null:fh(BigInt.prototype.toString),uh="undefined"==typeof Symbol?null:fh(Symbol.prototype.toString),dh=fh({}.hasOwnProperty),hh=fh({}.toString),_h=fh(/t/.test),ph=(gh=TypeError,function(){for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];return Kd(gh,t)});var gh;function fh(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var i=arguments.length,s=new Array(i>1?i-1:0),n=1;i>n;n++)s[n-1]=arguments[n];return Gd(e,t,s)}}function vh(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:th;if(Bd&&Bd(e,null),!eh(t))return e;let s=t.length;for(;s--;){let n=t[s];if("string"==typeof n){const e=i(n);e!==n&&(zd(t)||(t[s]=e),n=e)}e[n]=!0}return e}function mh(e){for(let t=0;e.length>t;t++)dh(e,t)||(e[t]=null);return e}function yh(e){const t=Wd(null);for(const s of Nd(e)){var i=Dd(s,2);const n=i[0],r=i[1];dh(e,n)&&(t[n]=eh(r)?mh(r):r&&"object"==typeof r&&r.constructor===Object?yh(r):r)}return t}function bh(e,t){for(;null!==e;){const i=Ud(e,t);if(i){if(i.get)return fh(i.get);if("function"==typeof i.value)return fh(i.value)}e=Hd(e)}return function(){return null}}const wh=qd(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Sh=qd(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Ch=qd(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),kh=qd(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Eh=qd(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),xh=qd(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Ph=qd(["#text"]),Ih=qd(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),Fh=qd(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dominant-baseline","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-orientation","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Th=qd(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Rh=qd(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Ah=jd(/{{[\w\W]*|^[\w\W]*}}/g),$h=jd(/<%[\w\W]*|^[\w\W]*%>/g),Mh=jd(/\${[\w\W]*/g),Lh=jd(/^data-[\-\w.\u00B7-\uFFFF]+$/),Oh=jd(/^aria-[\-\w]+$/),Dh=jd(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Nh=jd(/^(?:\w+script|data):/i),Bh=jd(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),zh=jd(/^html$/i),Hh=jd(/^[a-z][.\w]*(-[.\w]+)+$/i),Uh=jd(/<[/\w!]/g),qh=jd(/<[/\w]/g),jh=jd(/<\/no(script|embed|frames)/i),Wh=jd(/\/>/i),Vh=function(){return"undefined"==typeof window?null:window},Gh=function(e,t,i,s){return dh(e,t)&&eh(e[t])?vh(s.base?yh(s.base):{},e[t],s.transform):i};var Kh=function e(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Vh();const i=t=>e(t);if(i.version="3.4.13",i.removed=[],!t||!t.document||9!==t.document.nodeType||!t.Element)return i.isSupported=!1,i;let s=t.document;const n=s,r=n.currentScript,o=t.HTMLTemplateElement,a=t.Node,l=t.NodeFilter,c=t.DOMParser,u=t.trustedTypes,d=t.Element.prototype,h=bh(d,"cloneNode"),_=bh(d,"remove"),p=bh(d,"nextSibling"),g=bh(d,"childNodes"),f=bh(d,"parentNode"),v=bh(d,"shadowRoot"),m=bh(d,"attributes"),y=a&&a.prototype?bh(a.prototype,"nodeType"):null,b=a&&a.prototype?bh(a.prototype,"nodeName"):null,w=a&&a.prototype?bh(a.prototype,"ownerDocument"):null;if("function"==typeof o){const e=s.createElement("template");e.content&&e.content.ownerDocument&&(s=e.content.ownerDocument)}let S,C,k="",E=!1,x=0;const P=function(){if(x>0)throw ph('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},I=function(e){P(),x++;try{return S.createHTML(e)}finally{x--}},F=s.implementation,T=s.createNodeIterator,R=s.createDocumentFragment,A=s.getElementsByTagName,M=n.importNode;let L={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]};i.isSupported="function"==typeof Nd&&"function"==typeof f&&F&&void 0!==F.createHTMLDocument;const O=Ah,D=$h,N=Mh,B=Lh,z=Oh,H=Nh,U=Bh,q=Hh;let j=Dh,W=null;const V=vh({},[...wh,...Sh,...Ch,...Eh,...Ph]);let G=null;const K=vh({},[...Ih,...Fh,...Th,...Rh]);let Q=Object.seal(Wd(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),J=null,Y=null;const X=Object.seal(Wd(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Z=!0,ee=!0,te=!1,ie=!0,se=!1,ne=!0,re=!1,oe=!1,ae=null,le=null,ce=!1,ue=!1,de=!1,he=!1,_e=!0,pe=!1;const ge="user-content-";let fe=!0,ve=!1,me={},ye=null;const be=vh({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let we=null;const Se=vh({},["audio","video","img","source","image","track"]);let Ce=null;const ke=vh({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Ee="http://www.w3.org/1998/Math/MathML",xe="http://www.w3.org/2000/svg",Pe="http://www.w3.org/1999/xhtml";let Ie=Pe,Fe=!1,Te=null;const Re=vh({},[Ee,xe,Pe],ih),Ae=qd(["mi","mo","mn","ms","mtext"]);let $e=vh({},Ae);const Me=qd(["annotation-xml"]);let Le=vh({},Me);const Oe=vh({},["title","style","font","a","script"]);let De=null;const Ne=["application/xhtml+xml","text/html"];let Be=null,ze=null;const He=s.createElement("form"),Ue=function(e){return e instanceof RegExp||e instanceof Function},qe=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(ze&&ze===e)return;e&&"object"==typeof e||(e={}),e=yh(e),De=-1===Ne.indexOf(e.PARSER_MEDIA_TYPE)?"text/html":e.PARSER_MEDIA_TYPE,Be="application/xhtml+xml"===De?ih:th,W=Gh(e,"ALLOWED_TAGS",V,{transform:Be}),G=Gh(e,"ALLOWED_ATTR",K,{transform:Be}),Te=Gh(e,"ALLOWED_NAMESPACES",Re,{transform:ih}),Ce=Gh(e,"ADD_URI_SAFE_ATTR",ke,{transform:Be,base:ke}),we=Gh(e,"ADD_DATA_URI_TAGS",Se,{transform:Be,base:Se}),ye=Gh(e,"FORBID_CONTENTS",be,{transform:Be}),J=Gh(e,"FORBID_TAGS",yh({}),{transform:Be}),Y=Gh(e,"FORBID_ATTR",yh({}),{transform:Be}),me=!!dh(e,"USE_PROFILES")&&(e.USE_PROFILES&&"object"==typeof e.USE_PROFILES?yh(e.USE_PROFILES):e.USE_PROFILES),Z=!1!==e.ALLOW_ARIA_ATTR,ee=!1!==e.ALLOW_DATA_ATTR,te=e.ALLOW_UNKNOWN_PROTOCOLS||!1,ie=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,se=e.SAFE_FOR_TEMPLATES||!1,ne=!1!==e.SAFE_FOR_XML,re=e.WHOLE_DOCUMENT||!1,ue=e.RETURN_DOM||!1,de=e.RETURN_DOM_FRAGMENT||!1,he=e.RETURN_TRUSTED_TYPE||!1,ce=e.FORCE_BODY||!1,_e=!1!==e.SANITIZE_DOM,pe=e.SANITIZE_NAMED_PROPS||!1,fe=!1!==e.KEEP_CONTENT,ve=e.IN_PLACE||!1,j=function(e){try{return _h(e,""),!0}catch(e){return!1}}(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:Dh,Ie="string"==typeof e.NAMESPACE?e.NAMESPACE:Pe,$e=dh(e,"MATHML_TEXT_INTEGRATION_POINTS")&&e.MATHML_TEXT_INTEGRATION_POINTS&&"object"==typeof e.MATHML_TEXT_INTEGRATION_POINTS?yh(e.MATHML_TEXT_INTEGRATION_POINTS):vh({},Ae),Le=dh(e,"HTML_INTEGRATION_POINTS")&&e.HTML_INTEGRATION_POINTS&&"object"==typeof e.HTML_INTEGRATION_POINTS?yh(e.HTML_INTEGRATION_POINTS):vh({},Me);const t=dh(e,"CUSTOM_ELEMENT_HANDLING")&&e.CUSTOM_ELEMENT_HANDLING&&"object"==typeof e.CUSTOM_ELEMENT_HANDLING?yh(e.CUSTOM_ELEMENT_HANDLING):Wd(null);if(Q=Wd(null),dh(t,"tagNameCheck")&&Ue(t.tagNameCheck)&&(Q.tagNameCheck=t.tagNameCheck),dh(t,"attributeNameCheck")&&Ue(t.attributeNameCheck)&&(Q.attributeNameCheck=t.attributeNameCheck),dh(t,"allowCustomizedBuiltInElements")&&"boolean"==typeof t.allowCustomizedBuiltInElements&&(Q.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),jd(Q),se&&(ee=!1),de&&(ue=!0),me&&(W=vh({},Ph),G=Wd(null),!0===me.html&&(vh(W,wh),vh(G,Ih)),!0===me.svg&&(vh(W,Sh),vh(G,Fh),vh(G,Rh)),!0===me.svgFilters&&(vh(W,Ch),vh(G,Fh),vh(G,Rh)),!0===me.mathMl&&(vh(W,Eh),vh(G,Th),vh(G,Rh))),X.tagCheck=null,X.attributeCheck=null,dh(e,"ADD_TAGS")&&("function"==typeof e.ADD_TAGS?X.tagCheck=e.ADD_TAGS:eh(e.ADD_TAGS)&&(W===V&&(W=yh(W)),vh(W,e.ADD_TAGS,Be))),dh(e,"ADD_ATTR")&&("function"==typeof e.ADD_ATTR?X.attributeCheck=e.ADD_ATTR:eh(e.ADD_ATTR)&&(G===K&&(G=yh(G)),vh(G,e.ADD_ATTR,Be))),dh(e,"ADD_URI_SAFE_ATTR")&&eh(e.ADD_URI_SAFE_ATTR)&&vh(Ce,e.ADD_URI_SAFE_ATTR,Be),dh(e,"FORBID_CONTENTS")&&eh(e.FORBID_CONTENTS)&&(ye===be&&(ye=yh(ye)),vh(ye,e.FORBID_CONTENTS,Be)),dh(e,"ADD_FORBID_CONTENTS")&&eh(e.ADD_FORBID_CONTENTS)&&(ye===be&&(ye=yh(ye)),vh(ye,e.ADD_FORBID_CONTENTS,Be)),fe&&(W["#text"]=!0),re&&vh(W,["html","head","body"]),W.table&&(vh(W,["tbody"]),delete J.tbody),e.TRUSTED_TYPES_POLICY){if("function"!=typeof e.TRUSTED_TYPES_POLICY.createHTML)throw ph('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof e.TRUSTED_TYPES_POLICY.createScriptURL)throw ph('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const t=S;S=e.TRUSTED_TYPES_POLICY;try{k=I("")}catch(e){throw S=t,e}}else null===e.TRUSTED_TYPES_POLICY?(S=void 0,k=""):(void 0===S&&(E||(C=function(e,t){if("object"!=typeof e||"function"!=typeof e.createPolicy)return null;let i=null;const s="data-tt-policy-suffix";t&&t.hasAttribute(s)&&(i=t.getAttribute(s));const n="dompurify"+(i?"#"+i:"");try{return e.createPolicy(n,{createHTML:e=>e,createScriptURL:e=>e})}catch(e){return console.warn("TrustedTypes policy "+n+" could not be created."),null}}(u,r),E=!0),S=C),S&&"string"==typeof k&&(k=I("")));qd&&qd(e),ze=e},je=vh({},[...Sh,...Ch,...kh]),We=vh({},[...Eh,...xh]),Ve=function(e){Xd(i.removed,{element:e});try{f(e).removeChild(e)}catch(t){if(_(e),!f(e))throw ph("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Ge=function(e){Je(e);const t=g(e);if(t){const e=[];Qd(t,t=>{Xd(e,t)}),Qd(e,e=>{try{_(e)}catch(e){}})}const i=m(e);if(i)for(let t=i.length-1;t>=0;--t){const s=i[t],n=s&&s.name;if("string"==typeof n)try{e.removeAttribute(n)}catch(e){}}},Ke=function(e,t){try{Xd(i.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){Xd(i.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e)if(ue||de)try{Ve(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},Qe=function(e){const t=m(e);if(t)for(let i=t.length-1;i>=0;--i){const s=t[i],n=s&&s.name;if("string"==typeof n&&!G[Be(n)])try{e.removeAttribute(n)}catch(e){}}},Je=function(e){const t=[e];for(;t.length>0;){const e=t.pop();1===(y?y(e):e.nodeType)&&Qe(e);const i=g(e);if(i)for(let e=i.length-1;e>=0;--e)t.push(i[e])}},Ye=function(e){let t=null,i=null;if(ce)e="<remove></remove>"+e;else{const t=sh(e,/^[\r\n\t ]+/);i=t&&t[0]}"application/xhtml+xml"===De&&Ie===Pe&&(e='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+e+"</body></html>");const n=S?I(e):e;if(Ie===Pe)try{t=(new c).parseFromString(n,De)}catch(e){}if(!t||!t.documentElement){t=F.createDocument(Ie,"template",null);try{t.documentElement.innerHTML=Fe?k:n}catch(e){}}const r=t.body||t.documentElement;return e&&i&&r.insertBefore(s.createTextNode(i),r.childNodes[0]||null),Ie===Pe?A.call(t,re?"html":"body")[0]:re?t.documentElement:r},Xe=function(e){const t=w?w(e):e.ownerDocument;return T.call(t||e,e,l.SHOW_ELEMENT|l.SHOW_COMMENT|l.SHOW_TEXT|l.SHOW_PROCESSING_INSTRUCTION|l.SHOW_CDATA_SECTION,null)},Ze=function(e){return e=nh(e,O," "),e=nh(e,D," "),nh(e,N," ")},et=function(e){var t;e.normalize();const i=w?w(e):e.ownerDocument,s=T.call(i||e,e,l.SHOW_TEXT|l.SHOW_COMMENT|l.SHOW_CDATA_SECTION|l.SHOW_PROCESSING_INSTRUCTION,null);let n=s.nextNode();for(;n;)n.data=Ze(n.data),n=s.nextNode();const r=null===(t=e.querySelectorAll)||void 0===t?void 0:t.call(e,"template");r&&Qd(r,e=>{it(e.content)&&et(e.content)})},tt=function(e){const t=b?b(e):null;return"string"==typeof t&&"form"===Be(t)&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||e.attributes!==m(e)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore||"function"!=typeof e.hasChildNodes||e.nodeType!==y(e)||e.childNodes!==g(e))},it=function(e){if(!y||"object"!=typeof e||null===e)return!1;try{return 11===y(e)}catch(e){return!1}},st=function(e){if(!y||"object"!=typeof e||null===e)return!1;try{return"number"==typeof y(e)}catch(e){return!1}};function nt(e,t,s){0!==e.length&&Qd(e,e=>{e.call(i,t,s,ze)})}const rt=function(e,t,i,s){return 0===e.length?t:t===i||t===s?yh(t):t},ot=function(e,t){if(nt(L.beforeSanitizeElements,e,null),e!==t&&null===f(e))return ve&&Je(e),!0;if(tt(e))return Ve(e),!0;const s=Be(b?b(e):e.nodeName);if(W=rt(L.uponSanitizeElement,W,V,ae),nt(L.uponSanitizeElement,e,{tagName:s,allowedTags:W}),e!==t&&null===f(e))return ve&&Je(e),!0;if(function(e,t){return!!(ne&&e.hasChildNodes()&&!st(e.firstElementChild)&&_h(Uh,e.textContent)&&_h(Uh,e.innerHTML))||!(!ne||e.namespaceURI!==Pe||"style"!==t||!st(e.firstElementChild))||7===e.nodeType||!(!ne||8!==e.nodeType||!_h(qh,e.data))}(e,s))return Ve(e),!0;if(J[s]||!(X.tagCheck instanceof Function&&X.tagCheck(s))&&!W[s]){const i=function(e,t,i){if(!J[t]&&ct(t)){if(Q.tagNameCheck instanceof RegExp&&_h(Q.tagNameCheck,t))return!1;if(Q.tagNameCheck instanceof Function&&Q.tagNameCheck(t))return!1}if(fe&&!ye[t]){const t=f(e),s=g(e);if(s&&t)for(let n=s.length-1;n>=0;--n){const r=e===i?h(s[n],!0):s[n];t.insertBefore(r,p(e))}}return Ve(e),!0}(e,s,t);return!1===i&&nt(L.afterSanitizeElements,e,null),i}if(1===(y?y(e):e.nodeType)&&!function(e){let t=f(e);t&&t.tagName||(t={namespaceURI:Ie,tagName:"template"});const i=th(e.tagName),s=th(t.tagName);return!!Te[e.namespaceURI]&&(e.namespaceURI===xe?function(e,t,i){return t.namespaceURI===Pe?"svg"===e:t.namespaceURI===Ee?"svg"===e&&("annotation-xml"===i||$e[i]):Boolean(je[e])}(i,t,s):e.namespaceURI===Ee?function(e,t,i){return t.namespaceURI===Pe?"math"===e:t.namespaceURI===xe?"math"===e&&Le[i]:Boolean(We[e])}(i,t,s):e.namespaceURI===Pe?function(e,t,i){return!(t.namespaceURI===xe&&!Le[i])&&!(t.namespaceURI===Ee&&!$e[i])&&!We[e]&&(Oe[e]||!je[e])}(i,t,s):!("application/xhtml+xml"!==De||!Te[e.namespaceURI]))}(e))return Ve(e),!0;if(("noscript"===s||"noembed"===s||"noframes"===s)&&_h(jh,e.innerHTML))return Ve(e),!0;if(se&&3===e.nodeType){const t=Ze(e.textContent);e.textContent!==t&&(Xd(i.removed,{element:e.cloneNode()}),e.textContent=t)}return nt(L.afterSanitizeElements,e,null),!1},at=function(e,t,i){if(Y[t])return!1;if(ne&&"patchsrc"===t)return!1;if(ne&&"for"===t&&"label"!==e&&"output"!==e)return!1;if(_e&&("id"===t||"name"===t)&&(i in s||i in He))return!1;const n=G[t]||X.attributeCheck instanceof Function&&X.attributeCheck(t,e);if(ee&&_h(B,t));else if(Z&&_h(z,t));else if(n){if(Ce[t]);else if(_h(j,nh(i,U,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==rh(i,"data:")||!we[e])if(te&&!_h(H,nh(i,U,"")));else if(i)return!1}else if(!(ct(e)&&(Q.tagNameCheck instanceof RegExp&&_h(Q.tagNameCheck,e)||Q.tagNameCheck instanceof Function&&Q.tagNameCheck(e))&&(Q.attributeNameCheck instanceof RegExp&&_h(Q.attributeNameCheck,t)||Q.attributeNameCheck instanceof Function&&Q.attributeNameCheck(t,e))||"is"===t&&Q.allowCustomizedBuiltInElements&&(Q.tagNameCheck instanceof RegExp&&_h(Q.tagNameCheck,i)||Q.tagNameCheck instanceof Function&&Q.tagNameCheck(i))))return!1;return!0},lt=vh({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),ct=function(e){return!lt[th(e)]&&_h(q,e)},ut=function(e,t,i,s){if(S&&"object"==typeof u&&"function"==typeof u.getAttributeType&&!i)switch(u.getAttributeType(e,t)){case"TrustedHTML":return I(s);case"TrustedScriptURL":return function(e){P(),x++;try{return S.createScriptURL(e)}finally{x--}}(s)}return s},dt=function(e,t,s,n){try{s?e.setAttributeNS(s,t,n):e.setAttribute(t,n),tt(e)?Ve(e):Yd(i.removed)}catch(i){Ke(t,e)}},ht=function(e){nt(L.beforeSanitizeAttributes,e,null);const t=e.attributes;if(!t||tt(e))return;G=rt(L.uponSanitizeAttribute,G,K,le);const i={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:G,forceKeepAttr:void 0};let s=t.length;const n=Be(e.nodeName);for(;s--;){const r=t[s],o=r.name,a=r.namespaceURI,l=r.value,c=Be(o),u=l;let d="value"===o?u:oh(u);i.attrName=c,i.attrValue=d,i.keepAttr=!0,i.forceKeepAttr=void 0,nt(L.uponSanitizeAttribute,e,i),d=i.attrValue,!pe||"id"!==c&&"name"!==c||0===rh(d,ge)||(Ke(o,e),d=ge+d),ne&&_h(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,d)||"attributename"===c&&sh(d,"href")?Ke(o,e):i.forceKeepAttr||(!i.keepAttr||!ie&&_h(Wh,d)?Ke(o,e):(se&&(d=Ze(d)),at(n,c,d)?(d=ut(n,c,a,d),d!==u&&dt(e,o,a,d)):Ke(o,e)))}nt(L.afterSanitizeAttributes,e,null)},_t=function(e){let t=null;const i=Xe(e);for(nt(L.beforeSanitizeShadowDOM,e,null);t=i.nextNode();)if(nt(L.uponSanitizeShadowNode,t,null),ot(t,e),ht(t),it(t.content)&&_t(t.content),1===(y?y(t):t.nodeType)){const e=v(t);it(e)&&(pt(e),_t(e))}nt(L.afterSanitizeShadowDOM,e,null)},pt=function(e){const t=[{node:e,shadow:null}];for(;t.length>0;){const e=t.pop();if(e.shadow){_t(e.shadow);continue}const i=e.node,s=1===(y?y(i):i.nodeType),n=g(i);if(n)for(let e=n.length-1;e>=0;--e)t.push({node:n[e],shadow:null});if(s){const e=b?b(i):null;if("string"==typeof e&&"template"===Be(e)){const e=i.content;it(e)&&t.push({node:e,shadow:null})}}if(s){const e=v(i);it(e)&&t.push({node:null,shadow:e},{node:e,shadow:null})}}};return i.sanitize=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s=null,r=null,o=null,a=null;if(Fe=!e,Fe&&(e="\x3c!--\x3e"),"string"!=typeof e&&!st(e)&&"string"!=typeof(e=function(e){switch(typeof e){case"string":return e;case"number":return ah(e);case"boolean":return lh(e);case"bigint":return ch?ch(e):"0";case"symbol":return uh?uh(e):"Symbol()";case"undefined":default:return hh(e);case"function":case"object":{if(null===e)return hh(e);const t=e,i=bh(t,"toString");if("function"==typeof i){const e=i(t);return"string"==typeof e?e:hh(e)}return hh(e)}}}(e)))throw ph("dirty is not a string, aborting");if(!i.isSupported)return e;oe?(W=ae,G=le):qe(t),(L.uponSanitizeElement.length>0||L.uponSanitizeAttribute.length>0)&&(W=yh(W)),L.uponSanitizeAttribute.length>0&&(G=yh(G)),i.removed=[];const l=ve&&"string"!=typeof e&&st(e);if(l){!function(e){if(!ne)return;const t=[e];for(;t.length>0;){const e=t.pop(),i=y?y(e):e.nodeType;if(7===i||8===i&&_h(qh,e.data)){try{_(e)}catch(e){}continue}if(1===i){const t=e,i=Be(b?b(e):e.nodeName);try{t.hasAttribute&&t.hasAttribute("patchsrc")&&t.removeAttribute("patchsrc"),t.hasAttribute&&t.hasAttribute("for")&&"label"!==i&&"output"!==i&&t.removeAttribute("for")}catch(e){}}const s=g(e);if(s)for(let e=s.length-1;e>=0;--e)t.push(s[e])}}(e);const t=b?b(e):e.nodeName;if("string"==typeof t){const i=Be(t);if(!W[i]||J[i])throw Ge(e),ph("root node is forbidden and cannot be sanitized in-place")}if(tt(e))throw Ge(e),ph("root node is clobbered and cannot be sanitized in-place");try{pt(e)}catch(t){throw Ge(e),t}}else if(st(e))s=Ye("\x3c!----\x3e"),r=s.ownerDocument.importNode(e,!0),1===r.nodeType&&"BODY"===r.nodeName||"HTML"===r.nodeName?s=r:s.appendChild(r),pt(r);else{if(!ue&&!se&&!re&&-1===e.indexOf("<"))return S&&he?I(e):e;if(s=Ye(e),!s)return ue?null:he?k:""}s&&ce&&Ve(s.firstChild);const c=l?e:s;try{const e=Xe(c);for(;o=e.nextNode();)ot(o,c),ht(o),it(o.content)&&_t(o.content)}catch(t){throw l&&(Ge(e),Qd(i.removed,e=>{e.element&&Je(e.element)})),t}if(l)return Qd(i.removed,e=>{e.element&&Je(e.element)}),se&&et(e),e;if(ue){if(se&&et(s),de)for(a=R.call(s.ownerDocument);s.firstChild;)a.appendChild(s.firstChild);else a=s;return(G.shadowroot||G.shadowrootmode)&&(a=M.call(n,a,!0)),a}let u=re?s.outerHTML:s.innerHTML;return re&&W["!doctype"]&&s.ownerDocument&&s.ownerDocument.doctype&&s.ownerDocument.doctype.name&&_h(zh,s.ownerDocument.doctype.name)&&(u="<!DOCTYPE "+s.ownerDocument.doctype.name+">\n"+u),se&&(u=Ze(u)),S&&he?I(u):u},i.setConfig=function(){qe(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),oe=!0,ae=W,le=G},i.clearConfig=function(){ze=null,oe=!1,ae=null,le=null,S=C,k=""},i.isValidAttribute=function(e,t,i){ze||qe({});const s=Be(e),n=Be(t);return at(s,n,i)},i.addHook=function(e,t){"function"==typeof t&&dh(L,e)&&Xd(L[e],t)},i.removeHook=function(e,t){if(dh(L,e)){if(void 0!==t){const i=Jd(L[e],t);return-1===i?void 0:Zd(L[e],i,1)[0]}return Yd(L[e])}},i.removeHooks=function(e){dh(L,e)&&(L[e]=[])},i.removeAllHooks=function(){L={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},i}();const Qh="Refusing to render web experiment since the viewer is a likely bot",Jh={ADD_ATTR:(e,t)=>"target"===e&&"a"===t||"form"===e&&/^(button|fieldset|input|output|select|textarea)$/.test(t),ADD_URI_SAFE_ATTR:["form"]};let Yh;const Xh={icontains:(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())>-1,not_icontains:(e,t)=>-1===t.toLowerCase().indexOf(e.toLowerCase()),regex:(e,t)=>Mc(t,e),not_regex:(e,t)=>!Mc(t,e),exact:(e,t)=>t===e,is_not:(e,t)=>t!==e},Zh=Fr("[Conversations]"),e_="Conversations not available yet.";function t_(e,t){var i,s,n,r,o,a,l;const c=null!==(i=null==e?void 0:e.flushIntervalMs)&&void 0!==i?i:3e3,u=null!==(s=null==e?void 0:e.maxBufferSize)&&void 0!==s?s:100,d=(null==t?void 0:t.consoleCapture)?void 0:null!==(n=null==e?void 0:e.maxLogsPerInterval)&&void 0!==n?n:1e3,h=vt(d)?Math.max(u,2048):Math.max(u,d),_=as(as({},function(){let e="",t="";try{var i;const s="u">typeof globalThis?globalThis:"u">typeof window?window:void 0,n=null==s||null===(i=s.navigator)||void 0===i?void 0:i.userAgent;n&&([e,t]=Bi(n))}catch(e){}return function(e,t){const i=function(e){if(e)return{}.hasOwnProperty.call(rr,e)?rr[e]:e}(e);return as(as({},i?{"os.name":i}:{}),t?{"os.version":t}:{})}(e,t)}()),null==e?void 0:e.resourceAttributes);return{serviceName:null!==(r=null!==(o=null==_?void 0:_["service.name"])&&void 0!==o?o:null==e?void 0:e.serviceName)&&void 0!==r?r:null==t?void 0:t.serviceNameDefault,serviceVersion:null!==(a=null==_?void 0:_["service.version"])&&void 0!==a?a:null==e?void 0:e.serviceVersion,environment:null!==(l=null==_?void 0:_["deployment.environment"])&&void 0!==l?l:null==e?void 0:e.environment,resourceAttributes:_,beforeSend:null==e?void 0:e.beforeSend,flushIntervalMs:c,maxBufferSize:u,maxQueueSize:h,maxBatchRecordsPerPost:100,rateCapWindowMs:c,maxLogsPerInterval:d,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}}const i_=["debug","log","warn","error","info"],s_=e=>{for(;null==e?void 0:e.__rrweb_original__;)e=e.__rrweb_original__;return e},n_="console",r_="__posthogHandledLogsRequestError",o_=(e,t)=>{const i=e instanceof Error?e:new Error(t);return i[r_]=!0,i},a_=e=>!!e&&"object"==typeof e&&!0===e[r_];var l_=class{get _coreLogger(){return as(as({},this._logger),{},{error:(...e)=>{e.some(a_)||this._logger.error(...e)}})}constructor(e,t){var i;this._configSource=e,this._getSdkContext=t,this.name="logs",this._isLogsEnabled=!1,this._isLoaded=!1,this._isLoading=!1,this._logger=Fr("[logs]"),this._queue=[],this._consoleQueue=[],this._consecutiveStatusZeroFailures=0,this._setupStarted=!1,this._disposed=!1,this._consoleBuffer=[],this._consoleRecorderUnpatchers=[],this._isRecordingConsole=!1,this._isRecordingConsoleEntry=!1,this._listeningForReconnect=!1,this._onReconnect=()=>{var e,t;this._disposed||(this._consecutiveStatusZeroFailures=0,null===(e=this._core)||void 0===e||e.onReconnect(),null===(t=this._consoleCore)||void 0===t||t.onReconnect())},this._isLogsEnabled=!!(null===(i=e.get())||void 0===i?void 0:i.captureConsoleLogs)}get _isRequestReady(){return!0}_getConsoleLoader(){}_listenForReconnect(){if(!this._listeningForReconnect){try{this._window=typeof window>"u"?void 0:window}catch(e){this._window=void 0}this._window&&(Br(this._window,"online",this._onReconnect),this._listeningForReconnect=!0)}}_buildCore(e,t,i,s){this._listenForReconnect();const n=t_(this._configSource.get(),i);return[new gr(this._createHost(e,t),n,this._coreLogger,()=>this._getSdkContext(),e=>e(),void 0,s),n]}_getCore(){const e=this._configSource.get();var t;return this._core&&this._resolvedFrom===e||(null===(t=this._core)||void 0===t||t.reset(),this._resolvedFrom=e,[this._core,this._resolvedConfig]=this._buildCore(()=>this._queue,e=>{this._queue=e})),this._core}_getConsoleCore(){const e=this._configSource.get();var t;return this._consoleCore&&this._consoleResolvedFrom===e||(null===(t=this._consoleCore)||void 0===t||t.reset(),this._consoleResolvedFrom=e,[this._consoleCore,this._consoleResolvedConfig]=this._buildCore(()=>this._consoleQueue,e=>{this._consoleQueue=e},{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},n_)),this._consoleCore}setup(e){if(!this._disposed&&!this._setupStarted)return this._setupStarted=!0,this._client=e,this._logger=e.logger.createLogger("[logs]"),cd(e.kv.initialize(),()=>{this._disposed||this._finishSetup(e)})}_finishSetup(e){var t;this._listenForReconnect(),(null===(t=this._configSource.get())||void 0===t?void 0:t.captureConsoleLogs)&&(this._isLogsEnabled=!0),(this._isLogsEnabled||this._configSource.remoteConfigWillArrive&&e.kv.get(this._configSource.captureHintKey))&&this._startConsoleRecorder();let i=!1;const s=e.onRemoteConfig(e=>{var t;i=e.ok&&!0===(null===(t=e.config.logs)||void 0===t?void 0:t.captureConsoleLogs),this.onRemoteConfig(e)});this._disposed?s.dispose():(this._remoteConfigSubscription=s,i||this.loadIfEnabled())}dispose(){var e,t,i,s,n,r,o;this._disposed||(this._disposed=!0,this._stopConsoleRecorder(),null===(e=this._remoteConfigSubscription)||void 0===e||e.dispose(),this._remoteConfigSubscription=void 0,this._client=void 0,this._isLoading=!1,null===(t=this._window)||void 0===t||t.removeEventListener("online",this._onReconnect),null===(i=this._consoleLogsDispose)||void 0===i||i.call(this),this._consoleLogsDispose=void 0,null===(s=this._core)||void 0===s||s.clearQueue(),null===(n=this._consoleCore)||void 0===n||n.clearQueue(),null===(r=this._core)||void 0===r||r.reset(),null===(o=this._consoleCore)||void 0===o||o.reset())}onRemoteConfig(e){var t,i;if(this._disposed)return;const s=e.ok?null===(t=e.config.logs)||void 0===t?void 0:t.captureConsoleLogs:void 0;wt(s)?this._stopRecorderStartedByPersistedHint():(null===(i=this._client)||void 0===i||i.kv.set(this._configSource.captureHintKey,!!s),s?(this._isLogsEnabled=!0,this._isLoaded||this._startConsoleRecorder(),this.loadIfEnabled()):this._stopRecorderStartedByPersistedHint())}reset(){var e,t,i,s;this._stopConsoleRecorder(),null===(e=this._core)||void 0===e||e.clearQueue(),this._queue=[],null===(t=this._core)||void 0===t||t.reset(),null===(i=this._consoleCore)||void 0===i||i.clearQueue(),this._consoleQueue=[],null===(s=this._consoleCore)||void 0===s||s.reset(),this._consecutiveStatusZeroFailures=0}captureLog(e){!this._disposed&&this._client&&this._getCore().captureLog(e)}captureConsoleLog(e){!this._disposed&&this._client&&this._getConsoleCore().captureLog(e)}captureBufferedConsoleLog(e,t,i){!this._disposed&&this._client&&this._getConsoleCore().captureLog(e,{context:t,occurredAtMs:i})}_onOptOut(){var e;this._stopConsoleRecorder(),null===(e=this._consoleCore)||void 0===e||e.clearQueue(),this._consoleQueue=[]}_stopRecorderStartedByPersistedHint(){this._isLogsEnabled||this._stopConsoleRecorder()}_startConsoleRecorder(){var e;if(this._isRecordingConsole||!(null===(e=this._window)||void 0===e?void 0:e.console))return;const t=t_(this._configSource.get()).maxBufferSize;let i=!0;this._consoleRecorderUnpatchers.push(()=>{i=!1});for(const e of i_){let s;try{s=s_(this._window.console[e])}catch(e){continue}s&&this._consoleRecorderUnpatchers.push(Hu(this._window.console,e,n=>{const r=(...s)=>{try{i&&this._recordConsoleEntry(e,s,t)}catch(e){}return n.apply(this._window.console,s)};return r.__rrweb_original__=s,r}))}this._isRecordingConsole=!0,this._consoleRecorderTimeout=setTimeout(()=>{this._stopConsoleRecorder()},3e4)}_recordConsoleEntry(e,t,i){var s;if(this._isRecordingConsole&&!this._isRecordingConsoleEntry&&0!==t.length)if(null===(s=this._client)||void 0===s?void 0:s.canCapture){if(i>this._consoleBuffer.length){this._isRecordingConsoleEntry=!0;try{this._consoleBuffer.push({level:e,args:t,occurredAtMs:Date.now(),context:this._getSdkContext()})}finally{this._isRecordingConsoleEntry=!1}}}else this._stopConsoleRecorder()}_stopConsoleRecorder(){if(this._consoleBuffer=[],this._isRecordingConsole){this._isRecordingConsole=!1,this._consoleRecorderTimeout&&(clearTimeout(this._consoleRecorderTimeout),this._consoleRecorderTimeout=void 0);for(const e of this._consoleRecorderUnpatchers)e();this._consoleRecorderUnpatchers=[]}}_takeConsoleBuffer(){const e=this._consoleBuffer;return this._stopConsoleRecorder(),e}get logger(){return this._capture_logger||(this._capture_logger={trace:(e,t)=>this.captureLog({body:e,level:"trace",attributes:t}),debug:(e,t)=>this.captureLog({body:e,level:"debug",attributes:t}),info:(e,t)=>this.captureLog({body:e,level:"info",attributes:t}),warn:(e,t)=>this.captureLog({body:e,level:"warn",attributes:t}),error:(e,t)=>this.captureLog({body:e,level:"error",attributes:t}),fatal:(e,t)=>this.captureLog({body:e,level:"fatal",attributes:t})}),this._capture_logger}flushLogs(e){this._client&&(e?this._flushViaTransport(e):(this._core&&this._core.flush().catch(e=>this._logFlushError(e)),this._consoleCore&&this._consoleCore.flush().catch(e=>this._logFlushError(e))))}flush(){var e=this;return Ot(function*(){var t,i;const s=null===(t=e._core)||void 0===t?void 0:t.flush().catch(t=>e._logFlushError(t)),n=null===(i=e._consoleCore)||void 0===i?void 0:i.flush().catch(t=>e._logFlushError(t));yield s,yield n})()}_logFlushError(e){a_(e)||this._logger.error("PostHog logs flush failed:",e)}loadIfEnabled(){if(this._disposed||!this._isLogsEnabled||this._isLoaded||this._isLoading)return;const e=this._getConsoleLoader();if(e){this._isLoading=!0;try{e((e,t)=>{if(this._isLoading=!1,!this._disposed&&this._isLogsEnabled)if(e||!t)this._logger.error("Could not load logs script",e),this._stopConsoleRecorder();else{const e=this._takeConsoleBuffer();this._consoleLogsDispose=t.initialize(this._client),this._isLoaded=!0,e.length>0&&t.replay(this._client,e)}})}catch(e){throw this._isLoading=!1,e}}else this._stopConsoleRecorder()}_createHost(e,t){const i=this._client;return{get isDisabled(){return!1},get optedOut(){return!i.canCapture},getPersistedProperty:t=>t===it.LogsQueue?e():void 0,setPersistedProperty(e,i){e===it.LogsQueue&&t(null!=i?i:[])},_sendLogsBatch:e=>this._sendLogsBatch(e),getLibraryId:()=>i.library.name,getLibraryVersion:()=>i.library.version}}_sendLogsBatch(e){return new Promise(t=>{if(Ea(this._consecutiveStatusZeroFailures,3))return void t({kind:"fatal",error:o_(void 0,"logs endpoint is unreachable, dropping batch")});let i=!1;const s=e=>{i||(i=!0,clearTimeout(n),t(e))},n=setTimeout(()=>{this._logger.warn("Logs request timed out before receiving a response"),s({kind:"retry-later",error:o_(void 0,"logs request timed out")})},9e4),r=this._isRequestReady;this._client.sendRequest("/i/v1/logs",{method:"POST",query:{token:this._client.projectToken},body:e,compression:"best-available",timeoutMs:6e4}).then(e=>{var t;const i=e.statusCode;this._trackEndpointReachability(i,r),i>=200&&300>i?s({kind:"ok"}):413===i?s({kind:"too-large"}):0!==i&&408!==i&&429!==i&&500>i?s({kind:"fatal",error:new Error(`logs request failed with status ${i}`)}):0===i?(e.error||this._logger.warn("Logs request failed before receiving an HTTP response"),s({kind:"retry-later",error:o_(e.error,"logs request failed before receiving an HTTP response")})):s({kind:"retry-later",error:null!==(t=e.error)&&void 0!==t?t:new Error(`logs request failed with status ${i}`)})},e=>{s({kind:"retry-later",error:e})})})}_trackEndpointReachability(e,t){(0!==e||t)&&(this._consecutiveStatusZeroFailures=xa(e,this._consecutiveStatusZeroFailures,3,()=>this._logger.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.")))}_flushViaTransport(e){this._queue.length>0&&this._drainQueueViaTransport(e,this._queue,this._resolvedConfig,this._client.library.name,e=>{this._queue=e}),this._consoleQueue.length>0&&this._drainQueueViaTransport(e,this._consoleQueue,this._consoleResolvedConfig,n_,e=>{this._consoleQueue=e})}_drainQueueViaTransport(e,t,i,s,n){if(0===t.length)return;const r=t.map(e=>e.record);n([]);const o=dr(r,ur(i,this._client.library.name,this._client.library.version),s,this._client.library.version);this._client.sendRequest("/i/v1/logs",{method:"POST",query:{token:this._client.projectToken},body:o,compression:"best-available",transport:e,timeoutMs:6e4}).catch(e=>this._logFlushError(e))}};const c_=Fr("[NetworkMetrics]"),u_={"http:":80,"https:":443},d_=new Set(["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"]),h_=(e,t)=>{var i;const s=String(t);return{method:String(e).toUpperCase(),url:(null===(i=Ca(s))||void 0===i?void 0:i.href)||s}},__=(e,t,i,s,n,r,o=!1)=>{try{var a,l;const c=n();if(!c)return;const u=i||void 0,d=uu()-s,h=Ca(t.url);if(h&&"http:"!==h.protocol&&"https:"!==h.protocol)return;const _={url:(null==h?void 0:h.href)||t.url,method:t.method},p=pt(c.name)?c.name(_):mt(c.name)?c.name:"http.client.request.duration";if(!p)return;const g=o&&!u?void 0:((e,t)=>e?400>e?void 0:String(e):(null==t?void 0:t.name)||"_OTHER")(u,r),f=as(as(as(as(as({},(e=>{const t=d_.has(e)?e:"_OTHER";return as({"http.request.method":t},"_OTHER"===t&&e!==t?{"http.request.method_original":e}:{})})(_.method)),h?(e=>{return{"server.address":e.hostname.startsWith("[")&&e.hostname.endsWith("]")?e.hostname.slice(1,-1):e.hostname,"server.port":Number(e.port)||u_[e.protocol],"url.scheme":e.protocol.slice(0,-1),"url.template":(t=e.pathname,t.split("/").map(e=>(e=>/^\d+$/.test(e)||e.length>=8&&/^[0-9a-f-]*\d[0-9a-f-]*$/i.test(e))(e)?":id":e).join("/"))};var t})(h):{}),u?{"http.response.status_code":u}:{}),g?{"error.type":g}:{}),null===(a=c.attributes)||void 0===a?void 0:a.call(c,_,{status:u,durationMs:d}));null===(l=e.metrics)||void 0===l||l.histogram(p,d,{unit:"ms",attributes:f})}catch(e){c_.error("Failed to record network metric",e)}},p_=()=>{},g_=(e,t)=>pt(null==je?void 0:je.fetch)?Hu(je,"fetch",i=>function(...s){const n=uu(),r=i.apply(this,s);if(!t())return r;try{var o,a,l;const[i,c]=s,u=h_(null!==(o=null!==(a=null==c?void 0:c.method)&&void 0!==a?a:null==i?void 0:i.method)&&void 0!==o?o:"GET",null!==(l=null==i?void 0:i.url)&&void 0!==l?l:i);return r.then(i=>(__(e,u,null==i?void 0:i.status,n,t,void 0,!0),i),i=>{throw __(e,u,void 0,n,t,i),i})}catch(e){return c_.error("Failed to observe fetch",e),r}}):p_,f_=(e,t)=>{var i;const s=null==je||null===(i=je.XMLHttpRequest)||void 0===i?void 0:i.prototype;if(!s)return p_;const n=new WeakMap,r=Hu(s,"open",e=>function(...t){try{(()=>Xl.has(this))()||n.set(this,h_(t[0],t[1]))}catch(e){c_.error("Failed to observe XHR open",e)}return e.apply(this,t)}),o=Hu(s,"send",i=>function(...s){let r;try{const i=n.get(this);if(i&&t()){const s=uu();r=()=>{this.removeEventListener("loadend",r),__(e,i,this.status,s,t)},Br(this,"loadend",r)}}catch(e){c_.error("Failed to observe XHR send",e)}try{return i.apply(this,s)}catch(e){throw r&&this.removeEventListener("loadend",r),e}});return()=>{r(),o()}},v_=new WeakMap,m_=new Set(["$comment","$defs","$id","$schema","additionalProperties","default","definitions","deprecated","description","examples","minProperties","properties","readOnly","required","title","type","writeOnly"]),y_={maxStringLength:2048,truncationSuffix:"..."},b_={maxStringLength:2048,truncationSuffix:"..."};function w_(e){if(e)return!0===e?{intent:!0,model:!0}:{intent:!1!==e.intent,model:!1!==e.model}}function S_(e,t){return{}.hasOwnProperty.call(e,t)}function C_(e,t){const i=Object.create(e);return t&&Object.defineProperty(i,"inputSchema",{configurable:!0,enumerable:!0,writable:!0,value:t}),i}function k_(e,t,i=!1){if(!mt(e))return;const s=e.trim();return s?(i?Kn(s,y_):s).slice(0,t):void 0}function E_(e){try{return gt(e)&&!0===e.isError}catch(e){return!1}}function x_(e){return Kn(e||"Unknown error",b_).slice(0,2048)}function P_(e,t){try{return x_(t?function(e){try{if(!gt(e)||!_t(e.content))return;return e.content.filter(e=>gt(e)&&"text"===e.type&&mt(e.text)).map(e=>e.text).join(" ").trim()||void 0}catch(e){return}}(e):gt(e)&&mt(e.message)?e.message:mt(e)?e:String(e))}catch(e){return"Unknown error"}}function I_(e,t,i){return t.errorResult?[{type:"Error",value:i,mechanism:{type:"generic",handled:!0,synthetic:!0,exception_id:0}}]:e.buildProperties(t.error,{handled:!0}).$exception_list.map(e=>as(as({},e),{},{value:x_(e.value)}))}function F_(e,t){if(t)return"Error";try{if(!gt(e))return"Error";let t=mt(e.name)?e.name.trim():"";const i=e.constructor;return t&&"Error"!==t||!pt(i)||"Error"===i.name||(t=i.name),(t||"Error").slice(0,256)}catch(e){return"Error"}}function T_(e,t){return{message:P_(e,t),type:F_(e,t)}}Lu.__defaultExtensionClasses=as({},((...e)=>Ar({},...e))({featureFlags:Fd},{sessionRecording:class{get _config(){return this._instance.config}get _persistence(){return this._instance.persistence}get started(){var e;return!!(null===(e=this._lazyLoadedSessionRecording)||void 0===e?void 0:e.isStarted)}get status(){var e,t;return"awaiting_config"===this._recordingStatus||"missing_config"===this._recordingStatus?this._recordingStatus:null!==(e=null===(t=this._lazyLoadedSessionRecording)||void 0===t?void 0:t.status)&&void 0!==e?e:this._recordingStatus}constructor(e){if(this._instance=e,this._forceAllowLocalhostNetworkCapture=!1,this._recordingStatus=Ku,this._persistFlagsOnSessionListener=void 0,this._sessionRecordingDisposed=!1,this._documentWasEverVisible=(()=>{var e,t;if(!(null==Ge?void 0:Ge.visibilityState)||"visible"===Ge.visibilityState)return!0;const i=null==je||null===(e=je.performance)||void 0===e||null===(t=e.getEntriesByType)||void 0===t?void 0:t.call(e,"visibility-state");return!(null==i?void 0:i.length)||i.some(e=>"visible"===e.name)})(),this._onVisibilityChange=()=>{var e,t;"visible"===(null==Ge?void 0:Ge.visibilityState)&&(this._documentWasEverVisible=!0,null===(e=this._lazyLoadedSessionRecording)||void 0===e||null===(t=e.setDocumentWasEverVisible)||void 0===t||t.call(e,!0))},!this._instance.sessionManager)throw Ju.error("started without valid sessionManager"),new Error("[SessionRecording] started without valid sessionManager. This is a bug.");if("always"===this._config.cookieless_mode)throw new Error('[SessionRecording] cannot be used with cookieless_mode="always"');(null==Ge?void 0:Ge.addEventListener)&&Br(Ge,"visibilitychange",this._onVisibilityChange)}initialize(){this.startIfEnabledOrStop()}dispose({discardBufferedEvents:e=!1}={}){var t;this._sessionRecordingDisposed=!0,null==Ge||null===(t=Ge.removeEventListener)||void 0===t||t.call(Ge,"visibilitychange",this._onVisibilityChange),e?this._discardRecording(!0):this.stopRecording()}get _isRecordingEnabled(){var e;const t=!!(null===(e=this._instance.get_property("$session_recording_remote_config"))||void 0===e?void 0:e.enabled),i=!this._config.disable_session_recording,s=this._config.disable_session_recording||this._instance.consent.isOptedOut();return je&&t&&i&&!s}startIfEnabledOrStop(e){var t;if(this._sessionRecordingDisposed)return;if(this._isRecordingEnabled&&(null===(t=this._lazyLoadedSessionRecording)||void 0===t?void 0:t.isStarted))return;const i=!vt(Object.assign)&&!vt(Array.from);this._isRecordingEnabled&&i?(this._lazyLoadAndStart(e),Ju.info("starting")):(this._recordingStatus=Ku,this.stopRecording())}_lazyLoadAndStart(e){var t,i;if(this._isRecordingEnabled)if("awaiting_config"!==this._recordingStatus&&"missing_config"!==this._recordingStatus&&(this._recordingStatus=Qu),(null==tt||null===(t=tt.__PosthogExtensions__)||void 0===t||null===(t=t.rrweb)||void 0===t?void 0:t.record)&&(null===(i=tt.__PosthogExtensions__)||void 0===i?void 0:i.initSessionRecording))this._onScriptLoaded(e);else{var s,n;const t=this._instance.sessionManager;null===(s=tt.__PosthogExtensions__)||void 0===s||null===(n=s.loadExternalDependency)||void 0===n||n.call(s,this._instance,this._scriptName,i=>{if(!this._sessionRecordingDisposed&&this._isRecordingEnabled&&this._instance.sessionManager===t)return i?(this._instance.register_for_session({$sdk_debug_recording_script_not_loaded:!0}),Ju.error("could not load recorder",i)):void this._onScriptLoaded(e);this._recordingStatus="disabled"})}}stopRecording(){var e,t;null===(e=this._persistFlagsOnSessionListener)||void 0===e||e.call(this),this._persistFlagsOnSessionListener=void 0,null===(t=this._lazyLoadedSessionRecording)||void 0===t||t.stop()}_discardRecording(e=!1){var t,i;null===(t=this._persistFlagsOnSessionListener)||void 0===t||t.call(this),this._persistFlagsOnSessionListener=void 0,null===(i=this._lazyLoadedSessionRecording)||void 0===i||i.discard({discardProducerEvents:e})}_resetSampling(){var e,t;null===(e=this._persistence)||void 0===e||e.unregister("$session_is_sampled"),null===(t=this._persistence)||void 0===t||t.unregister("$replay_sample_rate")}_validateSampleRate(e,t){if(wt(e))return null;const i=St(e)?e:parseFloat(e);return"number"!=typeof(s=i)||!Number.isFinite(s)||0>s||s>1?(Ju.warn(`${t} must be between 0 and 1. Ignoring invalid value:`,e),null):i;var s}_persistRemoteConfig(e){if(this._persistence){var t,i;const s=this._persistence,n=()=>{var t;const i=!1===e.sessionRecording?void 0:e.sessionRecording,n=this._validateSampleRate(null===(t=this._config.session_recording)||void 0===t?void 0:t.sampleRate,"session_recording.sampleRate"),r=this._validateSampleRate(null==i?void 0:i.sampleRate,"remote config sampleRate"),o=null!=n?n:r;wt(o)&&this._resetSampling();const a=null==i?void 0:i.minimumDurationMilliseconds;s.register({[G]:as(as({cache_timestamp:Date.now(),enabled:!!i},i),{},{networkPayloadCapture:as({capturePerformance:e.capturePerformance},null==i?void 0:i.networkPayloadCapture),canvasRecording:{enabled:null==i?void 0:i.recordCanvas,fps:null==i?void 0:i.canvasFps,quality:null==i?void 0:i.canvasQuality},sampleRate:o,minimumDurationMilliseconds:vt(a)?null:a,endpoint:null==i?void 0:i.endpoint,triggerMatchType:null==i?void 0:i.triggerMatchType,masking:null==i?void 0:i.masking,urlTriggers:null==i?void 0:i.urlTriggers,version:null==i?void 0:i.version,triggerGroups:null==i?void 0:i.triggerGroups})})};n(),null===(t=this._persistFlagsOnSessionListener)||void 0===t||t.call(this),this._persistFlagsOnSessionListener=null===(i=this._instance.sessionManager)||void 0===i?void 0:i.onSessionId(n)}}onRemoteConfig(e){const t=e.ok?e.config:void 0;return t&&"sessionRecording"in t?!1===t.sessionRecording?(this._persistRemoteConfig(t),void this._discardRecording()):(this._persistRemoteConfig(t),void this.startIfEnabledOrStop()):("awaiting_config"===this._recordingStatus&&(this._recordingStatus="missing_config",this._instance.register_for_session({[Pe]:!0}),Ju.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(e,t="log"){var i;(null===(i=this._lazyLoadedSessionRecording)||void 0===i?void 0:i.log)?this._lazyLoadedSessionRecording.log(e,t):Ju.warn("log called before recorder was ready")}get _scriptName(){var e,t;const i=null===(e=this._instance)||void 0===e||null===(e=e.persistence)||void 0===e?void 0:e.get_property(G);return(null==i||null===(t=i.scriptConfig)||void 0===t?void 0:t.script)||"lazy-recorder"}_isRemoteConfigFresh(){const e=this._instance.get_property(G);if(!e)return!1;let t;try{t="object"==typeof e?e:JSON.parse(e)}catch(e){return Ju.warn("persisted remote config for session recording is invalid and will be ignored",e),!1}return!wt(t.cache_timestamp)&&36e5>=Date.now()-t.cache_timestamp}_onScriptLoaded(e){var t,i,s;if(!this._sessionRecordingDisposed&&this._isRecordingEnabled&&this._instance.sessionManager){if(!(null===(t=tt.__PosthogExtensions__)||void 0===t?void 0:t.initSessionRecording))return Ju.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[xe]:!0});var n;if(this._lazyLoadedSessionRecording||(this._lazyLoadedSessionRecording=null===(n=tt.__PosthogExtensions__)||void 0===n?void 0:n.initSessionRecording(this._instance,this._documentWasEverVisible),this._lazyLoadedSessionRecording._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this._isRemoteConfigFresh()){if("missing_config"===this._recordingStatus||"awaiting_config"===this._recordingStatus)return;return this._recordingStatus="awaiting_config",Ju.info("persisted remote config is stale, requesting fresh config before starting"),void new vl(this._instance).load()}this._recordingStatus=Qu,null===(i=(s=this._lazyLoadedSessionRecording).setDocumentWasEverVisible)||void 0===i||i.call(s,this._documentWasEverVisible),this._lazyLoadedSessionRecording.start(e)}else this._recordingStatus=Ku}onRRwebEmit(e){var t,i;null===(t=this._lazyLoadedSessionRecording)||void 0===t||null===(i=t.onRRwebEmit)||void 0===i||i.call(t,e)}overrideLinkedFlag(){var e,t;this._lazyLoadedSessionRecording||null===(t=this._persistence)||void 0===t||t.register({$replay_override_linked_flag:!0}),null===(e=this._lazyLoadedSessionRecording)||void 0===e||e.overrideLinkedFlag()}overrideSampling(){var e,t;this._lazyLoadedSessionRecording||null===(t=this._persistence)||void 0===t||t.register({$replay_override_sampling:!0}),null===(e=this._lazyLoadedSessionRecording)||void 0===e||e.overrideSampling()}overrideTrigger(e){var t,i;this._lazyLoadedSessionRecording||null===(i=this._persistence)||void 0===i||i.register({["url"===e?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),null===(t=this._lazyLoadedSessionRecording)||void 0===t||t.overrideTrigger(e)}get sdkDebugProperties(){var e;const t={};for(const e of Yu){var i;const s=null===(i=this._instance.sessionPersistence)||void 0===i?void 0:i.get_property(e);vt(s)||(t[e]=s)}return as(as({},t),(null===(e=this._lazyLoadedSessionRecording)||void 0===e?void 0:e.sdkDebugProperties)||{$recording_status:this.status})}tryAddCustomEvent(e,t){var i;return!!(null===(i=this._lazyLoadedSessionRecording)||void 0===i?void 0:i.tryAddCustomEvent(e,t))}flushBeforeIdentityReset(){var e,t;null===(e=this._lazyLoadedSessionRecording)||void 0===e||null===(t=e.flushBeforeIdentityReset)||void 0===t||t.call(e)}}},{autocapture:class extends au{constructor(e){super(new Du(e)),this.instance=e}},historyAutocapture:class{constructor(e){this._isFlushingPageview=!1,this._instance=e,this._lastLocation=this._getCurrentLocation()}initialize(){this.startIfEnabled()}get isEnabled(){const e=this._getCaptureOptions();return!!(e.path||e.search||this._shouldCaptureHashChanges(e))}startIfEnabled(){this.isEnabled&&(Ir.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}startIfEnabledOrStop(){this.stop(),this._lastLocation=this._getCurrentLocation(),this.startIfEnabled()}stop(){this._popstateListener&&this._popstateListener(),this._popstateListener=void 0,this._hashchangeListener&&this._hashchangeListener(),this._hashchangeListener=void 0,Ir.info("History API monitoring stopped")}monitorHistoryChanges(){je&&je.history&&(this._patchHistoryMethod("pushState"),this._patchHistoryMethod("replaceState"),this._setupPopstateListener(),this._shouldCaptureHashChanges()&&this._setupHashchangeListener())}_patchHistoryMethod(e){var t;if(!je||(null===(t=je.history[e])||void 0===t?void 0:t.__posthog_wrapped__))return;const i=this;Hu(je.history,e,t=>function(s,n,r){var o;i._isUrlChanging(r)&&i._flushPendingPageview(),t.call(this,s,n,r),i._capturePageview(e,!i._isFlushingPageview&&"popstate"!==(null==je||null===(o=je.event)||void 0===o?void 0:o.type))})}_getCurrentLocation(){const e=null==je?void 0:je.location;if(null==e?void 0:e.pathname)return{pathname:e.pathname,search:e.search,hash:e.hash}}_getCaptureOptions(){const e=this._instance.config.capture_pageview;return"history_change"===e?{path:!0}:gt(e)?e:{}}_shouldCaptureHashChanges(e=this._getCaptureOptions()){return!!e.hash&&!this._instance.config.disable_capture_url_hashes}_hasLocationChanged(e){const t=this._getCaptureOptions(),i=this._lastLocation;return!(!i||!(t.path&&e.pathname!==i.pathname||t.search&&e.search!==i.search||this._shouldCaptureHashChanges(t)&&e.hash!==i.hash))}_capturePageview(e,t=!1){try{t||this._flushPendingPageview();const i=this._getCurrentLocation();if(!i)return;if(this._hasLocationChanged(i)){const i=()=>this._instance.capture(ze,{navigation_type:e});t?(this._pendingPageview=i,Promise.resolve().then(()=>this._flushPendingPageview())):i()}this._lastLocation=i}catch(t){Ir.error(`Error capturing ${e} pageview`,t)}}_isUrlChanging(e){var t,i;return!(wt(e)||!je)&&(null===(t=Ca(String(e)))||void 0===t?void 0:t.href)!==(null===(i=je.location)||void 0===i?void 0:i.href)}_flushPendingPageview(){const e=this._pendingPageview;if(e){this._pendingPageview=void 0,this._isFlushingPageview=!0;try{e()}catch(e){Ir.error("Error capturing deferred pageview",e)}finally{this._isFlushingPageview=!1}this._lastLocation=this._getCurrentLocation()}}_setupPopstateListener(){if(this._popstateListener)return;const e=()=>{this._capturePageview("popstate")};Br(je,"popstate",e),this._popstateListener=()=>{je&&je.removeEventListener("popstate",e)}}_setupHashchangeListener(){if(this._hashchangeListener)return;const e=()=>{this._capturePageview("hashchange")};Br(je,"hashchange",e),this._hashchangeListener=()=>{je&&je.removeEventListener("hashchange",e)}}},heatmaps:class{get _config(){return this.instance.config}constructor(e){var t;this._enabledServerSide=!1,this._initialized=!1,this._flushInterval=null,this.instance=e,this._enabledServerSide=!!(null===(t=this.instance.persistence)||void 0===t?void 0:t.props[N]),this.rageclicks=new Yc(e.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){let e=5e3;return gt(this._config.capture_heatmaps)&&this._config.capture_heatmaps.flush_interval_milliseconds&&(e=this._config.capture_heatmaps.flush_interval_milliseconds),e}get isEnabled(){return wt(this._config.capture_heatmaps)?wt(this._config.enable_heatmaps)?this._enabledServerSide:this._config.enable_heatmaps:!1!==this._config.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this._initialized)return;Xu.info("starting..."),this._setupListeners(),this._onVisibilityChange()}else{var e;clearInterval(null!==(e=this._flushInterval)&&void 0!==e?e:void 0),this._removeListeners(),this.getAndClearBuffer()}}onRemoteConfig(e){if(!e.ok)return;const t=e.config;if(!("heatmaps"in t))return;const i=!!t.heatmaps;this.instance.persistence&&this.instance.persistence.register({[N]:i}),this._enabledServerSide=i,this.startIfEnabled()}getAndClearBuffer(){const e=this._buffer;return this._buffer=void 0,e}_onDeadClick(e){Zu(e.originalEvent)&&this._onClick(e.originalEvent,"deadclick")}_onVisibilityChange(){this._flushInterval&&clearInterval(this._flushInterval),this._flushInterval=function(e){return"visible"===(null==e?void 0:e.visibilityState)}(Ge)?setInterval(this._flush.bind(this),this.flushIntervalMilliseconds):null}_setupListeners(){je&&Ge&&(this._flushHandler=this._flush.bind(this),Br(je,Be,this._flushHandler),this._onClickHandler=e=>this._onClick(e||(null==je?void 0:je.event)),Br(Ge,"click",this._onClickHandler,{capture:!0}),this._onMouseMoveHandler=e=>this._onMouseMove(e||(null==je?void 0:je.event)),Br(Ge,"mousemove",this._onMouseMoveHandler,{capture:!0}),this._deadClicksCapture=new da(this.instance,ca,this._onDeadClick.bind(this)),this._deadClicksCapture.startIfEnabledOrStop(),this._onVisibilityChange_handler=this._onVisibilityChange.bind(this),Br(Ge,m,this._onVisibilityChange_handler),this._initialized=!0)}_removeListeners(){var e;je&&Ge&&(this._flushHandler&&je.removeEventListener(Be,this._flushHandler),this._onClickHandler&&Ge.removeEventListener("click",this._onClickHandler,{capture:!0}),this._onMouseMoveHandler&&Ge.removeEventListener("mousemove",this._onMouseMoveHandler,{capture:!0}),this._onVisibilityChange_handler&&Ge.removeEventListener(m,this._onVisibilityChange_handler),clearTimeout(this._mouseMoveTimeout),null===(e=this._deadClicksCapture)||void 0===e||e.stop(),this._initialized=!1)}_getProperties(e,t){const i=this.instance.scrollManager.scrollY(),s=this.instance.scrollManager.scrollX(),n=this.instance.scrollManager.scrollElement(),r=function(e,t,i){let s=e;for(;s&&bo(s)&&!wo(s,"body");){if(s===i)return!1;let e;try{var n,r,o;e=null===(n=null!==(r=null===(o=s.ownerDocument)||void 0===o?void 0:o.defaultView)&&void 0!==r?r:je)||void 0===n?void 0:n.getComputedStyle(s).position}catch(e){return!1}if(ot(t,e))return!0;s=$o(s)}return!1}(Fo(e),["fixed","sticky"],n);return{x:e.clientX+(r?0:s),y:e.clientY+(r?0:i),target_fixed:r,type:t}}_onClick(e,t="click"){var i;if(yo(e.target)||!Zu(e))return;const s=this._getProperties(e,t);(null===(i=this.rageclicks)||void 0===i?void 0:i.isRageClick(e.clientX,e.clientY,(new Date).getTime()))&&Wo(Fo(e),this.instance.config.rageclick)&&this._capture(as(as({},s),{},{type:"rageclick"})),this._capture(s)}_onMouseMove(e){!yo(e.target)&&Zu(e)&&(clearTimeout(this._mouseMoveTimeout),this._mouseMoveTimeout=setTimeout(()=>{this._capture(this._getProperties(e,"mousemove"))},500))}_capture(e){if(!je)return;const t=this._config.disable_capture_url_hashes?Zi(je.location.href):je.location.href,i=this._config.custom_personal_data_properties,s=this._config.mask_personal_data_properties?[...Ra,...i||[]]:[],n=Fa(t,s,$a);this._buffer=this._buffer||{},this._buffer[n]||(this._buffer[n]=[]),this._buffer[n].push(e)}_flush(){this._buffer&&!ft(this._buffer)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:da,webVitalsAutocapture:class{constructor(e){var t;this._instance=e,this._enabledServerSide=!1,this._initialized=!1,this._buffer={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this._flushToCapture=(e=!1)=>{clearTimeout(this._delayedFlushTimer),this._delayedFlushTimer=void 0,0!==this._buffer.metrics.length&&(this._instance.capture("$web_vitals",as({$current_url:this._buffer.url},this._buffer.metrics.reduce((e,t)=>as(as({},e),{},{[`$web_vitals_${t.name}_event`]:as({},t),[`$web_vitals_${t.name}_value`]:t.value}),{})),e?{transport:"sendBeacon",send_instantly:!0}:void 0),this._buffer={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0})},this._addToBuffer=e=>{var t;if(this._buffer=this._buffer||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},wt(null==e?void 0:e.name)||wt(null==e?void 0:e.value))return void qu.error("Invalid metric received",e);const i="string"==typeof e.navigationURL?e.navigationURL:void 0,s=this._maskedURL(i);if(vt(s))return;const n=St(e.navigationId)||"string"==typeof e.navigationId?`navigation:${e.navigationId}`:`url:${s}`;if(this._maxAllowedValue&&e.value>=this._maxAllowedValue)return void qu.error("Ignoring metric with value >= "+this._maxAllowedValue,e);this._buffer.navigationKey!==n&&(this._flushToCapture(),this._delayedFlushTimer=setTimeout(this._flushToCapture,this.flushToCaptureTimeoutMs)),vt(this._buffer.navigationKey)&&(this._buffer.navigationKey=n,this._buffer.url=s),this._buffer.firstMetricTimestamp=vt(this._buffer.firstMetricTimestamp)?Date.now():this._buffer.firstMetricTimestamp;const r=null===(t=this._instance.sessionManager)||void 0===t?void 0:t.checkAndGetSessionAndWindowId(!0),o=as(as(as({},e),i?{navigationURL:s}:{}),{},{$current_url:s,timestamp:Date.now()});if(delete o.entries,gt(e.attribution)&&this.attributionMetrics.indexOf(e.name)>-1){const t={};for(const i of Gu){const s="url"===i&&"string"==typeof e.attribution[i]?this._maskedURL(e.attribution[i]):e.attribution[i];vt(s)||(t[i]=s)}o.attribution=t}else delete o.attribution;vt(r)||(o.$session_id=r.sessionId,o.$window_id=r.windowId),this._buffer.metrics.push(o),this._buffer.metrics.length===this.allowedMetrics.length&&this._flushToCapture()},this._startCapturing=()=>{if(this._initialized)return;let e,t,i,s,n=!1;const r=tt.__PosthogExtensions__,o=null==r?void 0:r.postHogWebVitalsCallbacksByFlavor,a=(null==o?void 0:o[this._callbackFlavor])||("web-vitals"===this._callbackFlavor&&vt(o)?null==r?void 0:r.postHogWebVitalsCallbacks:void 0);if(!vt(a)){const r=a.withoutAttribution,o=this.attributionMetrics;n=!vt(r),e=o.indexOf("LCP")>-1?a.onLCP:(null==r?void 0:r.onLCP)||a.onLCP,t=o.indexOf("CLS")>-1?a.onCLS:(null==r?void 0:r.onCLS)||a.onCLS,i=o.indexOf("FCP")>-1?a.onFCP:(null==r?void 0:r.onFCP)||a.onFCP,s=o.indexOf("INP")>-1?a.onINP:(null==r?void 0:r.onINP)||a.onINP}if(!(e&&t&&i&&s))return void qu.error("web vitals callbacks not loaded - not starting");const l={reportSoftNavs:this.useSoftNavs},c=n&&this.attributionMetrics.indexOf("INP")>-1?as(as({},l),{},{includeProcessedEventEntries:!1}):l;this.allowedMetrics.indexOf("LCP")>-1&&e(this._addToBuffer.bind(this),l),this.allowedMetrics.indexOf("CLS")>-1&&t(this._addToBuffer.bind(this),l),this.allowedMetrics.indexOf("FCP")>-1&&i(this._addToBuffer.bind(this),l),this.allowedMetrics.indexOf("INP")>-1&&s(this._addToBuffer.bind(this),c);const u=null==je?void 0:je.document;Br(u,m,()=>{"hidden"===(null==u?void 0:u.visibilityState)&&this._flushToCapture(!0)}),Br(je,"pagehide",()=>this._flushToCapture(!0)),this._initialized=!0},this._enabledServerSide=!!(null===(t=this._instance.persistence)||void 0===t?void 0:t.props[U]),this.startIfEnabled()}get _perfConfig(){return this._instance.config.capture_performance}get allowedMetrics(){var e,t;const i=gt(this._perfConfig)?null===(e=this._perfConfig)||void 0===e?void 0:e.web_vitals_allowed_metrics:void 0;return wt(i)?(null===(t=this._instance.persistence)||void 0===t?void 0:t.props.$web_vitals_allowed_metrics)||Wu:i}get flushToCaptureTimeoutMs(){return(gt(this._perfConfig)?this._perfConfig.web_vitals_delayed_flush_ms:void 0)||5e3}get attributionMetrics(){const e=gt(this._perfConfig)?this._perfConfig.web_vitals_attribution:void 0;return kt(e)?e?Wu:[]:_t(e)?e:Vu}get useAttribution(){return this.attributionMetrics.length>0}get useSoftNavs(){const e=gt(this._perfConfig)?this._perfConfig.__preview_web_vitals_soft_navs:void 0;return null!=e&&e}get _maxAllowedValue(){const e=gt(this._perfConfig)&&St(this._perfConfig.__web_vitals_max_value)?this._perfConfig.__web_vitals_max_value:ju;return e>0&&6e4>=e?ju:e}get isEnabled(){const e=null==Ke?void 0:Ke.protocol;if("http:"!==e&&"https:"!==e)return qu.info("Web Vitals are disabled on non-http/https protocols"),!1;const t=gt(this._perfConfig)?this._perfConfig.web_vitals:kt(this._perfConfig)?this._perfConfig:void 0;return kt(t)?t:this._enabledServerSide}startIfEnabled(){this.isEnabled&&!this._initialized&&(qu.info("enabled, starting..."),this._loadScript(this._startCapturing))}onRemoteConfig(e){if(!e.ok)return;const t=e.config;if(!("capturePerformance"in t))return;const i=gt(t.capturePerformance)&&!!t.capturePerformance.web_vitals,s=gt(t.capturePerformance)?t.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[U]:i}),this._instance.persistence.register({[V]:s})),this._enabledServerSide=i,this.startIfEnabled()}get _callbackFlavor(){return this.useSoftNavs?this.useAttribution?"web-vitals-with-attribution-soft-navs":"web-vitals-soft-navs":this.useAttribution?"web-vitals-with-attribution":"web-vitals"}_loadScript(e){var t;const i=tt.__PosthogExtensions__,s=this._callbackFlavor,n=null==i?void 0:i.postHogWebVitalsCallbacksByFlavor;(null==n?void 0:n[s])||"web-vitals"===s&&vt(n)&&(null==i?void 0:i.postHogWebVitalsCallbacks)?e():null==i||null===(t=i.loadExternalDependency)||void 0===t||t.call(i,this._instance,s,t=>{t?qu.error("failed to load script",t):e()})}_maskedURL(e){const t=e||(null==je?void 0:je.location.href);if(!t)return void qu.error("Could not determine current URL");const i=this._instance.config.disable_capture_url_hashes?Zi(t):t,s=this._instance.config.custom_personal_data_properties,n=this._instance.config.mask_personal_data_properties?[...Ra,...s||[]]:[];return Fa(i,n,$a)}}},{exceptionObserver:class{constructor(e){var t;this._startCapturing=()=>{var e;if(!je||!this.isEnabled||!(null===(e=tt.__PosthogExtensions__)||void 0===e?void 0:e.errorWrappingFunctions))return;const t=tt.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,i=tt.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,s=tt.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this._unwrapOnError&&this._config.capture_unhandled_errors&&(this._unwrapOnError=t(this.captureException.bind(this))),!this._unwrapUnhandledRejection&&this._config.capture_unhandled_rejections&&(this._unwrapUnhandledRejection=i(this.captureException.bind(this))),!this._unwrapConsoleError&&this._config.capture_console_errors&&(this._unwrapConsoleError=s(this.captureException.bind(this)))}catch(e){Nu.error("failed to start",e),this._stopCapturing()}},this._instance=e,this._remoteEnabled=!!(null===(t=this._instance.persistence)||void 0===t?void 0:t.props[B]),this._rateLimiter=new Ht(as(as({},function(e={}){var t,i,s,n;return{refillRate:null!==(t=null!==(i=e.exceptionRateLimiterRefillRate)&&void 0!==i?i:e.__exceptionRateLimiterRefillRate)&&void 0!==t?t:1,bucketSize:null!==(s=null!==(n=e.exceptionRateLimiterBucketSize)&&void 0!==n?n:e.__exceptionRateLimiterBucketSize)&&void 0!==s?s:10}}(this._instance.config.error_tracking)),{},{refillInterval:1e4,_logger:Nu})),this._config=this._requiredConfig(),this.startIfEnabledOrStop()}_requiredConfig(){const e=this._instance.config.capture_exceptions;let t={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return gt(e)?t=as(as({},t),e):(vt(e)?this._remoteEnabled:e)&&(t=as(as({},t),{},{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),t}get isEnabled(){return this._config.capture_console_errors||this._config.capture_unhandled_errors||this._config.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(Nu.info("enabled"),this._stopCapturing(),this._loadScript(this._startCapturing)):this._stopCapturing()}_loadScript(e){var t,i,s;(null===(t=tt.__PosthogExtensions__)||void 0===t?void 0:t.errorWrappingFunctions)?e():null===(i=tt.__PosthogExtensions__)||void 0===i||null===(s=i.loadExternalDependency)||void 0===s||s.call(i,this._instance,"exception-autocapture",t=>{if(t)return Nu.error("failed to load script",t);e()})}_stopCapturing(){var e,t,i;null===(e=this._unwrapOnError)||void 0===e||e.call(this),this._unwrapOnError=void 0,null===(t=this._unwrapUnhandledRejection)||void 0===t||t.call(this),this._unwrapUnhandledRejection=void 0,null===(i=this._unwrapConsoleError)||void 0===i||i.call(this),this._unwrapConsoleError=void 0}onRemoteConfig(e){if(!e.ok)return;const t=e.config;"autocaptureExceptions"in t&&(this._remoteEnabled=!!t.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[B]:this._remoteEnabled}),this._config=this._requiredConfig(),this.startIfEnabledOrStop())}onConfigChange(){this._config=this._requiredConfig()}captureException(e){try{var t,i,s;const n=null!==(t=null==e||null===(i=e.$exception_list)||void 0===i||null===(i=i[0])||void 0===i?void 0:i.type)&&void 0!==t?t:"Exception";if(this._rateLimiter.consumeRateLimit(n))return void Nu.info("Skipping exception capture because of client rate limiting.",{exception:n});null===(s=this._instance.exceptions)||void 0===s||s.sendExceptionEvent(e)}catch(e){}}},exceptions:class{constructor(e){var t,i;this._suppressionRules=[],this._errorPropertiesBuilder=new ps([new Ls,new Ws,new Ds,new Os,new qs,new Us,new Bs,new js],function(e,...t){return(i,s=0)=>{const n=[],r=i.split("\n"),o=Math.min(r.length,s+1e3),a=[];for(let i=s;o>i;i++){const s=r[i];if(s.length>1024)continue;const o=Ps.test(s)?s.replace(Ps,"$1"):s;if(!o.match(/\S*Error: /)){for(const i of t){const t=i(o,e);if(t){n.push(t);const e=Fs(n);if(e){for(let t=a.length-1;t>=0;t--){const i=a[t];if(e.start>=i.start+i.length)break;a.pop()}a.push(e)}break}}if($s(n,a)>=50)break}}const l=[...a].sort((e,t)=>t.start-e.start),c=l[l.length-1];if(c){const e=Rs(n,c);n.splice(c.start-e,e);for(const t of l)t.start-=e}for(const e of l)Ts(n,e);return a.some(e=>0===e.start&&n.length===e.length)&&function(e){const t=e.map(e=>`${e.function}|${e.filename}|${e.lineno}|${e.colno}|${e.module}`);let i=0;for(let e=1;t.length>e;e++)Ms(t,e,i)&&(i=e);e.push(...e.splice(0,i))}(n),function(e){if(!e.length)return[];const t=Array.from(e);return t.reverse(),t.slice(0,50).map(e=>{return as(as({},e),{},{filename:e.filename||(i=t,i[i.length-1]||{}).filename,function:e.function||"?"});var i})}(n)}}("web:javascript",Cs,xs)),this._instance=e,this._suppressionRules=null!==(t=null===(i=this._instance.persistence)||void 0===i?void 0:i.get_property("$error_tracking_suppression_rules"))&&void 0!==t?t:[],this._exceptionStepsConfig=Js(this._getExceptionStepsConfig()),this._exceptionStepsBuffer=new Ys(this._exceptionStepsConfig)}onConfigChange(){this._exceptionStepsConfig=Js(this._getExceptionStepsConfig()),this._exceptionStepsBuffer.setConfig(this._exceptionStepsConfig)}onRemoteConfig(e){var t,i,s;if(!e.ok)return;const n=e.config;if(!("errorTracking"in n))return;const r=null!==(t=null===(i=n.errorTracking)||void 0===i?void 0:i.suppressionRules)&&void 0!==t?t:[],o=null===(s=n.errorTracking)||void 0===s?void 0:s.captureExtensionExceptions;this._suppressionRules=r,this._instance.persistence&&this._instance.persistence.register({[z]:this._suppressionRules,[H]:o})}get _captureExtensionExceptions(){var e;const t=!!this._instance.get_property(H),i=this._instance.config.error_tracking.captureExtensionExceptions;return null!==(e=null!=i?i:t)&&void 0!==e&&e}buildProperties(e,t){return this._errorPropertiesBuilder.buildFromUnknown(e,{syntheticException:null==t?void 0:t.syntheticException,mechanism:{handled:null==t?void 0:t.handled}})}addExceptionStep(e,t){if(this._exceptionStepsConfig.enabled)try{if(!mt(e)||0===e.trim().length)return void Rd.warn("Ignoring exception step because message must be a non-empty string");const{sanitizedProperties:i,droppedKeys:s}=function(e){if(!e)return{sanitizedProperties:{},droppedKeys:[]};const t=[];return{sanitizedProperties:Object.keys(e).reduce((i,s)=>Ks.has(s)?(t.push(s),i):(i[s]=e[s],i),{}),droppedKeys:t}}(this._coerceExceptionStepProperties(t));s.length>0&&Rd.warn("Ignoring reserved exception step fields",{droppedKeys:s}),this._exceptionStepsBuffer.add(as({[Vs]:e,[Gs]:(new Date).toISOString()},i))}catch(e){Rd.error("Failed to add exception step. Ignoring breadcrumb.",e)}}sendExceptionEvent(e){try{const t=e.$exception_list;if(this._isExceptionList(t)){if(this._matchesSuppressionRule(t))return this._addDroppedExceptionStep("Exception dropped: matched a suppression rule"),void Rd.info("Skipping exception capture because a suppression rule matched");if(!this._captureExtensionExceptions&&this._isExtensionException(t))return this._addDroppedExceptionStep("Exception dropped: thrown by a browser extension"),void Rd.info("Skipping exception capture because it was thrown by an extension");if(!this._captureExtensionExceptions&&this._isInjectedBrowserScriptException(t))return this._addDroppedExceptionStep("Exception dropped: thrown by an injected browser script"),void Rd.info("Skipping exception capture because it was thrown by an injected browser script");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this._isPostHogException(t))return this._addDroppedExceptionStep("Exception dropped: thrown by the PostHog SDK"),void Rd.info("Skipping exception capture because it was thrown by the PostHog SDK")}const i=this._exceptionStepsConfig.enabled&&wt(e.$exception_steps)?this._addBufferedExceptionSteps(e):e,s=function(){if("u">typeof process){var e;const t=null===(e=process.env.POSTHOG_RELEASE_ID)||void 0===e?void 0:e.trim();if(t)return t}const t=globalThis._posthogReleaseId;return"string"==typeof t&&t.length>0?t:void 0}();s&&(i.$release_id=s);try{const e=this._instance.capture("$exception",i,{_noTruncate:!0,_batchKey:"exceptionEvent",_originatedFromCaptureException:!0});return e&&this._exceptionStepsBuffer.clear(),e}catch(e){return Td(e)||Rd.error("Failed to capture exception event. Dropping this exception.",e),void this._exceptionStepsBuffer.clear()}}catch(e){return void(Td(e)||Rd.error("Failed to process exception event. Ignoring this exception.",e))}}_addBufferedExceptionSteps(e){try{const t=this._exceptionStepsBuffer.getAttachable();return 0===t.length?e:as(as({},e),{},{$exception_steps:t})}catch(t){return Rd.error("Failed to read buffered exception steps. Capturing exception without steps.",t),e}}_addDroppedExceptionStep(e){this._exceptionStepsConfig.enabled&&this._exceptionStepsBuffer.add({[Vs]:e,[Gs]:(new Date).toISOString()})}_coerceExceptionStepProperties(e){return gt(e)?as({},e):{}}_getExceptionStepsConfig(){var e,t;return null!==(e=null===(t=this._instance.config.error_tracking)||void 0===t?void 0:t.exception_steps)&&void 0!==e?e:{}}_matchesSuppressionRule(e){if(0===e.length)return!1;try{const t=e.reduce((e,{type:t,value:i})=>(mt(t)&&t.length>0&&e.$exception_types.push(t),mt(i)&&i.length>0&&e.$exception_values.push(i),e),{$exception_types:[],$exception_values:[]});return this._suppressionRules.some(e=>{const i=e.values.map(e=>{const i=Oc[e.operator],s=t[e.key];if(!i||!s)return!1;const n=_t(e.value)?e.value:[e.value];return n.length>0&&i(n,s)});return"OR"===e.type?i.some(Boolean):i.every(Boolean)})}catch(e){return Rd.warn("Failed to evaluate suppression rules. Capturing the exception.",e),!1}}_isExtensionException(e){const t=e.flatMap(e=>{var t,i;return null!==(t=null===(i=e.stacktrace)||void 0===i?void 0:i.frames)&&void 0!==t?t:[]}),i=t.filter(({filename:e})=>!!e&&Md.some(t=>e.startsWith(t)));return 0!==i.length&&(!i.every(({filename:e})=>!!e&&e.startsWith(Ad))||e.some(({type:e,value:t})=>"NoResponse"===e||mt(t)&&$d.some(({value:e,exact:i})=>i?t===e:t.includes(e)))&&!t.some(({in_app:e,filename:t})=>e&&!(null==t?void 0:t.startsWith(Ad))))}_isInjectedBrowserScriptException(e){return e.some(({value:e})=>mt(e)&&Ld.some(t=>e.includes(t)))}_isPostHogException(e){if(e.length>0){var t,i,s,n;const r=null!==(t=null===(i=e[0].stacktrace)||void 0===i?void 0:i.frames)&&void 0!==t?t:[],o=r[r.length-1];return null!==(s=null==o||null===(n=o.filename)||void 0===n?void 0:n.includes("posthog.com/static"))&&void 0!==s&&s}return!1}_isExceptionList(e){return!wt(e)&&_t(e)}}},{productTours:class{get _persistence(){return this._instance.persistence}constructor(e){this._productTourManager=null,this._cachedTours=null,this._instance=e}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(!e.ok)return;const t=e.config;if("productTours"in t){var i,s;if(this._persistence&&this._persistence.register({[j]:!!t.productTours}),!td(this._instance))return!this._productTourManager&&wt(null===(i=this._persistence)||void 0===i?void 0:i.props.ph_product_tours)||ed.info("product tours disabled; stopping and clearing cached tours"),null===(s=this._productTourManager)||void 0===s||s.stop(),this._productTourManager=null,void this.clearCache();this.loadIfEnabled()}}loadIfEnabled(){!this._productTourManager&&td(this._instance)&&this._loadScript(()=>this._startProductTours())}_loadScript(e){var t,i,s;(null===(t=tt.__PosthogExtensions__)||void 0===t?void 0:t.generateProductTours)?e():null===(i=tt.__PosthogExtensions__)||void 0===i||null===(s=i.loadExternalDependency)||void 0===s||s.call(i,this._instance,"product-tours",t=>{t?ed.error("Could not load product tours script",t):e()})}_startProductTours(){var e;!this._productTourManager&&(null===(e=tt.__PosthogExtensions__)||void 0===e?void 0:e.generateProductTours)&&(this._productTourManager=tt.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,t=!1){if(_t(this._cachedTours)&&!t)return void e(this._cachedTours,{isLoaded:!0});const i=this._persistence;if(i){const s=i.props[le];if(_t(s)&&!t)return this._cachedTours=s,void e(s,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api",`/api/product_tours/?token=${this._instance.config.token}`),method:"GET",timestampMode:"query",callback:t=>{if(!td(this._instance))return void e([],{isLoaded:!0});const s=t.statusCode;if(200!==s||!t.json){const i=`Product Tours API could not be loaded, status: ${s}`;return 0===s?t.error||ed.warn(i):ed.error(i),void e([],{isLoaded:!1,error:i})}const n=_t(t.json.product_tours)?t.json.product_tours:[];this._cachedTours=n,i&&i.register({[le]:n}),e(n,{isLoaded:!0})}})}getActiveProductTours(e){wt(this._productTourManager)?e([],{isLoaded:!1,error:"Product tours not loaded"}):this._productTourManager.getActiveProductTours(e)}showProductTour(e){var t;null===(t=this._productTourManager)||void 0===t||t.showTourById(e)}previewTour(e){this._productTourManager?this._productTourManager.previewTour(e):this._loadScript(()=>{var t;this._startProductTours(),null===(t=this._productTourManager)||void 0===t||t.previewTour(e)})}dismissProductTour(){var e;null===(e=this._productTourManager)||void 0===e||e.dismissTour("user_clicked_skip")}nextStep(){var e;null===(e=this._productTourManager)||void 0===e||e.nextStep()}previousStep(){var e;null===(e=this._productTourManager)||void 0===e||e.previousStep()}clearCache(){var e;this._cachedTours=null,null===(e=this._persistence)||void 0===e||e.unregister("ph_product_tours")}resetTour(e){var t;null===(t=this._productTourManager)||void 0===t||t.resetTour(e)}resetAllTours(){var e;null===(e=this._productTourManager)||void 0===e||e.resetAllTours()}cancelPendingTour(e){var t;null===(t=this._productTourManager)||void 0===t||t.cancelPendingTour(e)}},featureFlags:Fd},{siteApps:class{constructor(e){this._instance=e,this._siteAppElementPatchCount=0,this._bufferedInvocations=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}_eventCollector(e,t){if(!t)return;const i=this.globalsForEvent(t);this._bufferedInvocations.push(i),this._bufferedInvocations.length>1e3&&(this._bufferedInvocations=this._bufferedInvocations.slice(10))}get siteAppLoaders(){var e;return null===(e=tt._POSTHOG_REMOTE_CONFIG)||void 0===e||null===(e=e[this._instance.config.token])||void 0===e?void 0:e.siteApps}initialize(){if(this.isEnabled){const e=this._instance._addCaptureHook(this._eventCollector.bind(this));this._stopBuffering=()=>{e(),this._bufferedInvocations=[],this._stopBuffering=void 0}}}globalsForEvent(e){var t,i,s,n,r,o,a;if(!e)throw new Error("Event payload is required");const l={},c=this._instance.get_property("$groups")||[],u=this._instance.get_property("$stored_group_properties")||{};for(const[e,t]of Object.entries(u))l[e]={id:c[e],type:e,properties:t};const{$set_once:d,$set:h}=e;return{event:as(as({},hn(e,id)),{},{properties:as(as(as({},e.properties),h?{$set:as(as({},null!==(t=null===(i=e.properties)||void 0===i?void 0:i.$set)&&void 0!==t?t:{}),h)}:{}),d?{$set_once:as(as({},null!==(s=null===(n=e.properties)||void 0===n?void 0:n.$set_once)&&void 0!==s?s:{}),d)}:{}),elements_chain:null!==(r=null===(o=e.properties)||void 0===o?void 0:o.$elements_chain)&&void 0!==r?r:"",distinct_id:null===(a=e.properties)||void 0===a?void 0:a.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:l}}_prepareElementForSiteApp(e){var t;const i=null===(t=e.tagName)||void 0===t?void 0:t.toLowerCase();if("style"===i&&this._instance.config.prepare_external_dependency_stylesheet){return this._instance.config.prepare_external_dependency_stylesheet(e)||(sd.error("prepare_external_dependency_stylesheet returned null"),null)}if("script"===i&&this._instance.config.prepare_external_dependency_script){return this._instance.config.prepare_external_dependency_script(e)||(sd.error("prepare_external_dependency_script returned null"),null)}return e}_patchSiteAppElementInsertionMethods(){var e,t,i,s,n,r,o,a;if(!this._instance.config.prepare_external_dependency_stylesheet&&!this._instance.config.prepare_external_dependency_script)return()=>{};const l=null==Ge?void 0:Ge.defaultView,c=null==l||null===(e=l.Node)||void 0===e?void 0:e.prototype;if(!l||!c)return()=>{};if(this._siteAppElementPatchCount++,this._restoreSiteAppElementPatches)return this._releaseSiteAppElementPatches();const u=[],d=this,h=new WeakSet,_=(e,t,i)=>{if(!(null==e?void 0:e[t]))return;const s=e[t];e[t]=i(s),u.push(()=>{e[t]=s})},p=e=>{if(h.has(e))return e;const t=d._prepareElementForSiteApp(e);return t&&h.add(t),t},g=e=>e.map(e=>"string"==typeof e?e:p(e)).filter(e=>!bt(e));return _(c,"appendChild",e=>function(t){const i=p(t);return i?e.call(this,i):t}),_(c,"insertBefore",e=>function(t,i){const s=p(t);return s?e.call(this,s,i):t}),_(c,"replaceChild",e=>function(t,i){const s=p(t);return s?e.call(this,s,i):i}),[null===(t=l.Element)||void 0===t?void 0:t.prototype,null===(i=l.Document)||void 0===i?void 0:i.prototype,null===(s=l.DocumentFragment)||void 0===s?void 0:s.prototype].forEach(e=>{_(e,"append",e=>function(...t){return e.apply(this,g(t))}),_(e,"prepend",e=>function(...t){return e.apply(this,g(t))})}),[null===(n=l.Element)||void 0===n?void 0:n.prototype,null===(r=l.CharacterData)||void 0===r?void 0:r.prototype,null===(o=l.DocumentType)||void 0===o?void 0:o.prototype].forEach(e=>{_(e,"before",e=>function(...t){return e.apply(this,g(t))}),_(e,"after",e=>function(...t){return e.apply(this,g(t))}),_(e,"replaceWith",e=>function(...t){const i=g(t);return t.length&&!i.length?void 0:e.apply(this,i)})}),_(null===(a=l.Element)||void 0===a?void 0:a.prototype,"insertAdjacentElement",e=>function(t,i){const s=p(i);return s?e.call(this,t,s):null}),this._restoreSiteAppElementPatches=()=>{u.forEach(e=>e()),this._restoreSiteAppElementPatches=void 0},this._releaseSiteAppElementPatches()}_releaseSiteAppElementPatches(){let e=!1;return()=>{var t;e||(e=!0,this._siteAppElementPatchCount--,0===this._siteAppElementPatchCount&&(null===(t=this._restoreSiteAppElementPatches)||void 0===t||t.call(this)))}}_runWithPreparedSiteAppElements(e,t=!0){const i=this._patchSiteAppElementInsertionMethods();try{const s=e(i);return t&&i(),s}catch(e){throw i(),e}}setupSiteApp(e){const t=this.apps[e.id],i=()=>{var i;!t.errored&&this._bufferedInvocations.length&&(sd.info(`Processing ${this._bufferedInvocations.length} events for site app with id ${e.id}`),this._bufferedInvocations.forEach(e=>this._runWithPreparedSiteAppElements(()=>{var i;return null===(i=t.processEvent)||void 0===i?void 0:i.call(t,e)})),t.processedBuffer=!0),Object.values(this.apps).every(e=>e.processedBuffer||e.errored)&&(null===(i=this._stopBuffering)||void 0===i||i.call(this))};let s=!1;const n=n=>{t.errored=!n,t.loaded=!0,sd.info(`Site app with id ${e.id} ${n?"loaded":"errored"}`),s&&i()};try{const{processEvent:i}=this._runWithPreparedSiteAppElements(t=>e.init({posthog:this._instance,callback(e){t(),n(e)}}),!1);i&&(t.processEvent=i),s=!0}catch(t){sd.error(nd+e.id,t),n(!1)}if(s&&t.loaded)try{i()}catch(i){sd.error(`Error while processing buffered events PostHog app with config id ${e.id}`,i),t.errored=!0}}_setupSiteApps(){const e=this.siteAppLoaders||[];for(const t of e)this.apps[t.id]={id:t.id,loaded:!1,errored:!1,processedBuffer:!1};for(const t of e)this.setupSiteApp(t)}_onCapturedEvent(e){if(0===Object.keys(this.apps).length)return;const t=this.globalsForEvent(e);for(const i of Object.values(this.apps))try{this._runWithPreparedSiteAppElements(()=>{var e;return null===(e=i.processEvent)||void 0===e?void 0:e.call(i,t)})}catch(t){sd.error(`Error while processing event ${e.event} for site app ${i.id}`,t)}}onRemoteConfig(e){var t,i,s;if(null===(t=this.siteAppLoaders)||void 0===t?void 0:t.length)return this.isEnabled?(this._setupSiteApps(),void this._instance.on("eventCaptured",e=>this._onCapturedEvent(e))):void sd.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null===(i=this._stopBuffering)||void 0===i||i.call(this),!e.ok)return;const n=e.config;if(null===(s=n.siteApps)||void 0===s?void 0:s.length)if(this.isEnabled)for(const{id:e,url:t}of n.siteApps){var r,o;tt[`__$$ph_site_app_${e}`]=this._instance,null===(r=tt.__PosthogExtensions__)||void 0===r||null===(o=r.loadSiteApp)||void 0===o||o.call(r,this._instance,t,t=>{if(t)return sd.error(nd+e,t)})}else sd.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}},{surveys:class extends hd{constructor(e){super(new _d(e))}},featureFlags:Fd},{tracingHeaders:class{constructor(e){this._instance=e,this._restoreXHRPatch=void 0,this._restoreFetchPatch=void 0,this._hostnamesForPatch=void 0,this._startCapturing=()=>{const e=this._syncHostnamesForPatch();var t,i;e?(vt(this._restoreXHRPatch)&&(this._restoreXHRPatch=null===(t=tt.__PosthogExtensions__)||void 0===t||null===(t=t.tracingHeadersPatchFns)||void 0===t?void 0:t._patchXHR(e,()=>this._instance.get_distinct_id(),this._instance.sessionManager)),vt(this._restoreFetchPatch)&&(this._restoreFetchPatch=null===(i=tt.__PosthogExtensions__)||void 0===i||null===(i=i.tracingHeadersPatchFns)||void 0===i?void 0:i._patchFetch(e,()=>this._instance.get_distinct_id(),this._instance.sessionManager))):this._stopCapturing()}}initialize(){this.startIfEnabledOrStop()}_loadScript(e){var t,i,s;(null===(t=tt.__PosthogExtensions__)||void 0===t?void 0:t.tracingHeadersPatchFns)?e():null===(i=tt.__PosthogExtensions__)||void 0===i||null===(s=i.loadExternalDependency)||void 0===s||s.call(i,this._instance,"tracing-headers",t=>{if(t)return Uu.error("failed to load script",t);e()})}_getConfiguredHostnames(){var e,t;return null!==(e=null!==(t=this._instance.config.tracing_headers)&&void 0!==t?t:this._instance.config.addTracingHeaders)&&void 0!==e?e:this._instance.config.__add_tracing_headers}_syncHostnamesForPatch(){const e=this._getConfiguredHostnames();return _t(e)?(_t(this._hostnamesForPatch)?this._hostnamesForPatch.splice(0,this._hostnamesForPatch.length,...e):this._hostnamesForPatch=[...e],e.length>0?this._hostnamesForPatch:void 0):(_t(this._hostnamesForPatch)&&this._hostnamesForPatch.splice(0),this._hostnamesForPatch=e||void 0,this._hostnamesForPatch)}_stopCapturing(){var e,t;null===(e=this._restoreXHRPatch)||void 0===e||e.call(this),null===(t=this._restoreFetchPatch)||void 0===t||t.call(this),this._restoreXHRPatch=void 0,this._restoreFetchPatch=void 0}startIfEnabledOrStop(){this._syncHostnamesForPatch()?this._loadScript(this._startCapturing):this._stopCapturing()}}},{toolbar:class{constructor(e){this.instance=e}_setToolbarState(e){tt.ph_toolbar_state=e}_getToolbarState(){var e;return null!==(e=tt.ph_toolbar_state)&&void 0!==e?e:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(e=void 0,t=void 0,i=void 0){var s,n;if(zr(this.instance.config))return!1;if(!je||!Ge)return!1;e=null!==(s=e)&&void 0!==s?s:je.location,i=null!==(n=i)&&void 0!==n?n:je.history;try{if(!t){try{je.localStorage.setItem("test","test"),je.localStorage.removeItem("test")}catch(e){return!1}t=null==je?void 0:je.localStorage}const s=pd||Ta(e.hash,"__posthog")||Ta(e.hash,"state");let n;const r=s?es(()=>JSON.parse(atob(decodeURIComponent(s))))||es(()=>JSON.parse(decodeURIComponent(s))):null;return r&&"ph_authorize"===r.action?(n=r,n.source="url",n&&Object.keys(n).length>0&&(r.desiredHash?e.hash=r.desiredHash:i?i.replaceState(i.state,"",e.pathname+e.search):e.hash="")):(n=JSON.parse(t.getItem(gd)||"{}"),n.source="localstorage",delete n.userIntent),!(!n.token||this.instance.config.token!==n.token||(this.loadToolbar(n),0))}catch(e){return!1}}_callLoadToolbar(e){const t=tt.ph_load_toolbar||tt.ph_load_editor;!wt(t)&&pt(t)?t(e,this.instance):fd.warn("No toolbar load function found")}loadToolbar(e){const t=!!(null==Ge?void 0:Ge.getElementById("__POSTHOG_TOOLBAR__"));if(!je||t)return!1;const i="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,s=as(as({token:this.instance.config.token},e),{},{apiURL:this.instance.requestRouter.endpointFor("ui")},i?{instrument:!1}:{});if(je.localStorage.setItem(gd,JSON.stringify(as(as({},s),{},{source:void 0}))),2===this._getToolbarState())this._callLoadToolbar(s);else if(0===this._getToolbarState()){var n,r;this._setToolbarState(1),null===(n=tt.__PosthogExtensions__)||void 0===n||null===(r=n.loadExternalDependency)||void 0===r||r.call(n,this.instance,"toolbar",e=>{if(e)return fd.error("[Toolbar] Failed to load",e),void this._setToolbarState(0);this._setToolbarState(2),this._callLoadToolbar(s)}),Br(je,"turbolinks:load",()=>{this._setToolbarState(0),this.loadToolbar(s)})}return!0}_loadEditor(e){return this.loadToolbar(e)}maybeLoadEditor(e=void 0,t=void 0,i=void 0){return this.maybeLoadToolbar(e,t,i)}}},{experiments:class e{get _config(){return this._instance.config}constructor(t){this._instance=t,this.getWebExperimentsAndEvaluateDisplayLogic=(t=!1)=>{this.getWebExperiments(t=>{e._logInfo("retrieved web experiments from the server"),this._flagToExperiments=new Map,t.forEach(t=>{if(t.feature_flag_key){var i;this._flagToExperiments&&(e._logInfo("setting flag key ",t.feature_flag_key," to web experiment ",t),null===(i=this._flagToExperiments)||void 0===i||i.set(t.feature_flag_key,t));const s=this._instance.getFeatureFlag(t.feature_flag_key);mt(s)&&t.variants[s]&&this._applyVariantForFlag(t,s)}else if(t.variants)for(const i in t.variants){const s=t.variants[i];e._matchesTestVariant(s,this._instance)&&this._applyTransforms(t.name,i,s.transforms)}})},t)},this._instance.onFeatureFlags(e=>{this.onFeatureFlags(e)})}initialize(){}onFeatureFlags(t){if(this._is_bot())e._logInfo(Qh);else if(!this._config.disable_web_experiments){if(wt(this._flagToExperiments))return this._flagToExperiments=new Map,this.loadIfEnabled(),void this.previewWebExperiment();e._logInfo("applying feature flags",t),t.forEach(e=>{var t;if(this._flagToExperiments&&(null===(t=this._flagToExperiments)||void 0===t?void 0:t.has(e))){var i;const t=this._instance.getFeatureFlag(e),s=null===(i=this._flagToExperiments)||void 0===i?void 0:i.get(e);t&&(null==s?void 0:s.variants[t])&&this._applyVariantForFlag(s,t)}})}}previewWebExperiment(){const t=e.getWindowLocation();if(null==t?void 0:t.search){const i=Ia(null==t?void 0:t.search,"__experiment_id"),s=Ia(null==t?void 0:t.search,"__experiment_variant");i&&s&&(e._logInfo(`previewing web experiments ${i} && ${s}`),this.getWebExperiments(e=>{this._showPreviewWebExperiment(parseInt(i),s,e)},!1,!0))}}loadIfEnabled(){this._config.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,t,i){if(this._config.disable_web_experiments&&!i)return e([]);const s=this._instance.get_property("$web_experiments");if(s&&!t)return e(s);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api",`/api/web_experiments/?token=${this._config.token}`),method:"GET",timestampMode:"query",callback:t=>e(200===t.statusCode&&t.json&&t.json.experiments||[])})}_showPreviewWebExperiment(t,i,s){const n=s.filter(e=>e.id===t);n&&n.length>0&&(e._logInfo(`Previewing web experiment [${n[0].name}] with variant [${i}]`),this._applyTransforms(n[0].name,i,n[0].variants[i].transforms))}_applyVariantForFlag(t,i){const s=t.variants[i];e._matchUrlConditions(s,this._instance)?this._applyTransforms(t.name,i,s.transforms):e._logInfo(`skipping variant ${i} of experiment ${t.name} because this page does not match its url conditions`)}static _matchesTestVariant(t,i){return!wt(t.conditions)&&e._matchUrlConditions(t,i)&&e._matchUTMConditions(t)}static _matchUrlConditions(t,i){var s;if(wt(t.conditions)||wt(null===(s=t.conditions)||void 0===s?void 0:s.url))return!0;const n=e.getWindowLocation();if(n){var r,o,a;const e=mo(i,n.href);return!(null===(r=t.conditions)||void 0===r?void 0:r.url)||Xh[null!==(o=null===(a=t.conditions)||void 0===a?void 0:a.urlMatchType)&&void 0!==o?o:"icontains"](t.conditions.url,e)}return!1}static getWindowLocation(){return null==je?void 0:je.location}static _matchUTMConditions(e){var t;if(wt(e.conditions)||wt(null===(t=e.conditions)||void 0===t?void 0:t.utm))return!0;const i=La();if(i.utm_source){var s,n,r,o,a,l,c,u;const t=!(null===(s=e.conditions)||void 0===s||null===(s=s.utm)||void 0===s?void 0:s.utm_campaign)||(null===(n=e.conditions)||void 0===n||null===(n=n.utm)||void 0===n?void 0:n.utm_campaign)==i.utm_campaign,d=!(null===(r=e.conditions)||void 0===r||null===(r=r.utm)||void 0===r?void 0:r.utm_source)||(null===(o=e.conditions)||void 0===o||null===(o=o.utm)||void 0===o?void 0:o.utm_source)==i.utm_source,h=!(null===(a=e.conditions)||void 0===a||null===(a=a.utm)||void 0===a?void 0:a.utm_medium)||(null===(l=e.conditions)||void 0===l||null===(l=l.utm)||void 0===l?void 0:l.utm_medium)==i.utm_medium,_=!(null===(c=e.conditions)||void 0===c||null===(c=c.utm)||void 0===c?void 0:c.utm_term)||(null===(u=e.conditions)||void 0===u||null===(u=u.utm)||void 0===u?void 0:u.utm_term)==i.utm_term;return t&&h&&_&&d}return!1}static _logInfo(e,...t){Ir.info(`[WebExperiments] ${e}`,t)}static _logWarn(e,...t){Ir.warn(`[WebExperiments] ${e}`,t)}static _sanitizeLinkTargets(t){("http://www.w3.org/1999/xhtml"===t.namespaceURI&&"template"===t.localName?t.content:t).querySelectorAll("a[target], template").forEach(t=>{var i;if("template"===t.localName)return void("http://www.w3.org/1999/xhtml"===t.namespaceURI&&e._sanitizeLinkTargets(t));if("http://www.w3.org/1999/xhtml"!==t.namespaceURI||"_blank"!==(null===(i=t.getAttribute("target"))||void 0===i?void 0:i.toLowerCase()))return void t.removeAttribute("target");const s=(t.getAttribute("rel")||"").split(/\s+/).filter(e=>e&&!/^(opener|noopener)$/i.test(e));s.push("noopener"),t.setAttribute("rel",s.join(" "))})}_applyTransforms(t,i,s){this._is_bot()?e._logInfo(Qh):"control"!==i?s.forEach(s=>{if(s.selector){var n;e._logInfo(`applying transform of variant ${i} for experiment ${t} `,s);const r=null===(n=document)||void 0===n?void 0:n.querySelectorAll(s.selector);if(!(null==r?void 0:r.length))return void e._logWarn(`no element on this page matches selector ${s.selector} of variant ${i} for experiment ${t}`);const o=new Map;null==r||r.forEach(t=>{if("script"===t.localName.toLowerCase())return;const i=t;if(s.html){var n;const a="http://www.w3.org/1998/Math/MathML"===t.namespaceURI&&"annotation-xml"===t.localName&&(null===(n=t.getAttribute("encoding"))||void 0===n?void 0:n.toLowerCase())||"",l=JSON.stringify([t.namespaceURI,t.localName,a]);let c=o.get(l);if(wt(c)){var r;const i=null!==(r=Yh)&&void 0!==r?r:Yh=Kh(),n=t.ownerDocument.implementation.createHTMLDocument(""),u=n.createElementNS(t.namespaceURI,t.localName);a&&u.setAttribute("encoding",a);const d=n.createRange();d.selectNodeContents(u);const h="http://www.w3.org/2000/svg"===t.namespaceURI&&/^(foreignObject|desc|title)$/.test(t.localName)||/^(text\/html|application\/xhtml\+xml)$/.test(a)?"http://www.w3.org/1999/xhtml":t.namespaceURI,_=d.createContextualFragment(s.html);"http://www.w3.org/1998/Math/MathML"===t.namespaceURI&&/^(mi|mo|mn|ms|mtext)$/.test(t.localName)?(u.appendChild(_),i.sanitize(u,as(as({},Jh),{},{NAMESPACE:h||void 0,IN_PLACE:!0}))):("http://www.w3.org/1999/xhtml"===u.namespaceURI&&"template"===u.localName?u.content:u).appendChild(i.sanitize(_,as(as({},Jh),{},{NAMESPACE:h||void 0,RETURN_DOM_FRAGMENT:!0}))),e._sanitizeLinkTargets(u),c=u.innerHTML,o.set(l,c)}i.innerHTML=c}s.css&&i.setAttribute("style",s.css)})}}):e._logInfo("Control variants leave the page unmodified.")}_is_bot(){return Ve&&this._instance?Tc(Ve,this._config.custom_blocked_useragents):void 0}},featureFlags:Fd},{conversations:class{constructor(e){this._instance=e,this._isConversationsEnabled=void 0,this._conversationsManager=null,this._isInitializing=!1,this._remoteConfig=null,this._loadFailed=!1,this._resetGeneration=0,this._pendingPanelAction=null,this._theme=null}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(this._instance.config.disable_conversations)return void(this._pendingPanelAction=null);if(this._remoteConfigSuccessful=e.ok,!e.ok)return;const t=e.config.conversations;wt(t)?this._pendingPanelAction=null:(kt(t)?this._isConversationsEnabled=t:(this._isConversationsEnabled=t.enabled,this._remoteConfig=t),this._isConversationsEnabled||(this._pendingPanelAction=null),this.loadIfEnabled())}reset(){var e;null===(e=this._conversationsManager)||void 0===e||e.reset(),this._conversationsManager=null,this._resetGeneration++,this._isConversationsEnabled=void 0,this._remoteConfig=null,this._remoteConfigSuccessful=void 0,this._loadFailed=!1,this._pendingPanelAction=null}loadIfEnabled(){if(this._conversationsManager)return;if(this._isInitializing)return;if(this._instance.config.disable_conversations)return;if(zr(this._instance.config))return;if(this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())return;const e=null==tt?void 0:tt.__PosthogExtensions__;if(e&&!vt(this._isConversationsEnabled)&&this._isConversationsEnabled)if(this._remoteConfig&&this._remoteConfig.token){this._isInitializing=!0;try{const t=e.initConversations;if(t)return this._completeInitialization(t),void(this._isInitializing=!1);const i=e.loadExternalDependency;if(!i)return void this._handleLoadError(S);const s=this._resetGeneration;i(this._instance,"conversations",t=>{if(s!==this._resetGeneration)return this._isInitializing=!1,void this.loadIfEnabled();t||!e.initConversations?this._handleLoadError("Could not load conversations script",t):this._completeInitialization(e.initConversations),this._isInitializing=!1})}catch(e){this._handleLoadError("Error initializing conversations",e),this._isInitializing=!1}}else Zh.error("Conversations enabled but missing token in remote config.")}_completeInitialization(e){if(this._remoteConfig){try{this._conversationsManager=e(this._remoteConfig,this._instance),this._loadFailed=!1,Zh.info("Conversations loaded successfully")}catch(e){return void this._handleLoadError("Error completing conversations initialization",e)}this._theme&&this._conversationsManager.setTheme(this._theme),this._applyPendingPanelAction()}else Zh.error("Cannot complete initialization: remote config is null")}_applyPendingPanelAction(){const e=this._pendingPanelAction;this._pendingPanelAction=null,this._conversationsManager&&e&&("open"===e?this._conversationsManager.open():this._conversationsManager.close())}_handleLoadError(e,t){Zh.error(e,t),this._conversationsManager=null,this._isInitializing=!1,this._loadFailed=!0}show(){this._conversationsManager?this._conversationsManager.show():Zh.warn("Conversations not loaded yet.")}hide(){"open"===this._pendingPanelAction&&(this._pendingPanelAction=null),this._conversationsManager&&this._conversationsManager.hide()}open(){this._conversationsManager?(this._pendingPanelAction=null,this._conversationsManager.open()):this._pendingPanelAction="open"}close(){this._conversationsManager?(this._pendingPanelAction=null,this._conversationsManager.close()):this._pendingPanelAction="close"}setTheme(e){var t,i;this._theme=as(as(as({},this._theme),e),{},{dark:as(as({},null===(t=this._theme)||void 0===t?void 0:t.dark),null==e?void 0:e.dark)}),null===(i=this._conversationsManager)||void 0===i||i.setTheme(e)}isAvailable(){return!0===this._isConversationsEnabled&&!bt(this._conversationsManager)}getUnavailableReason(){return this.isAvailable()?null:this._instance.config.disable_conversations?"disabled_by_config":zr(this._instance.config)?"disabled_for_toolbar":this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut()?"consent_opted_out":!1===this._remoteConfigSuccessful?"remote_config_failed":vt(this._isConversationsEnabled)?this._remoteConfigSuccessful?"disabled_in_project":"remote_config_pending":this._isConversationsEnabled?wt(this._remoteConfig)||!this._remoteConfig.token?"missing_token":(null==tt?void 0:tt.__PosthogExtensions__)?this._isInitializing?"initializing":this._loadFailed?"load_failed":"not_loaded":"extensions_unavailable":"disabled_in_project"}isVisible(){var e,t;return null!==(e=null===(t=this._conversationsManager)||void 0===t?void 0:t.isVisible())&&void 0!==e&&e}sendMessage(e,t,i){var s=this;return Ot(function*(){return s._conversationsManager?s._conversationsManager.sendMessage(e,t,i):(Zh.warn(e_),null)})()}getMessages(e,t){var i=this;return Ot(function*(){return i._conversationsManager?i._conversationsManager.getMessages(e,t):(Zh.warn(e_),null)})()}markAsRead(e){var t=this;return Ot(function*(){return t._conversationsManager?t._conversationsManager.markAsRead(e):(Zh.warn(e_),null)})()}getTickets(e){var t=this;return Ot(function*(){return t._conversationsManager?t._conversationsManager.getTickets(e):(Zh.warn(e_),null)})()}requestRestoreLink(e){var t=this;return Ot(function*(){return t._conversationsManager?t._conversationsManager.requestRestoreLink(e):(Zh.warn(e_),null)})()}restoreFromToken(e){var t=this;return Ot(function*(){return t._conversationsManager?t._conversationsManager.restoreFromToken(e):(Zh.warn(e_),null)})()}restoreFromUrlToken(){var e=this;return Ot(function*(){return e._conversationsManager?e._conversationsManager.restoreFromUrlToken():(Zh.warn(e_),null)})()}getCurrentTicketId(){var e,t;return null!==(e=null===(t=this._conversationsManager)||void 0===t?void 0:t.getCurrentTicketId())&&void 0!==e?e:null}getWidgetSessionId(){var e,t;return null!==(e=null===(t=this._conversationsManager)||void 0===t?void 0:t.getWidgetSessionId())&&void 0!==e?e:null}_onIdentityChanged(){var e;null===(e=this._conversationsManager)||void 0===e||e.setIdentity()}_onIdentityCleared(){var e;null===(e=this._conversationsManager)||void 0===e||e.clearIdentity()}}},{logs:class extends l_{constructor(e){super({get(){var t;return null==e||null===(t=e.config)||void 0===t?void 0:t.logs},captureHintKey:W,get remoteConfigWillArrive(){var t,i;return!(null===(t=e._shouldDisableFlags)||void 0===t?void 0:t.call(e))||!!(null===(i=tt._POSTHOG_REMOTE_CONFIG)||void 0===i||null===(i=i[e.config.token])||void 0===i?void 0:i.config)}},()=>function(e){var t;const i={};if(i.distinctId=e.get_distinct_id(),e.sessionManager){const{sessionId:t,windowId:s,sessionStartTimestamp:n,lastActivityTimestamp:r}=e.sessionManager.checkAndGetSessionAndWindowId(!0);i.sessionId=t,i.windowId=s,wt(n)||(i.sessionStartTimestamp=n),wt(r)||(i.lastActivityTimestamp=r)}if((null==tt||null===(t=tt.location)||void 0===t?void 0:t.href)&&(i.currentUrl=e.config.disable_capture_url_hashes?Zi(tt.location.href):tt.location.href),e.featureFlags){const t=e.featureFlags.getFlags();t&&t.length>0&&(i.activeFeatureFlags=t)}return i}(e)),this._instance=e,this.name=cu,this._listenForReconnect()}get _isRequestReady(){return this._instance.__loaded}_getConsoleLoader(){const e=Fr("[logs]"),t=null==tt?void 0:tt.__PosthogExtensions__;if(!t)return void e.error("PostHog Extensions not found.");const i=t.loadExternalDependency;if(i)return e=>{i(this._instance,"logs",i=>{const s=t.logs;e(i,(null==s?void 0:s.initializeLogs)?{initialize:e=>s.initializeLogs(e),replay(e,t){var i;return null===(i=s.replayConsoleBuffer)||void 0===i?void 0:i.call(s,e,t)}}:void 0)})};e.error(S)}}},{metrics:class{constructor(e){this._instance=e,this._logger=Fr("[metrics]"),this._disposed=!1}initialize(){this.onConfigChange()}onConfigChange(){var e;if(this._disposed)return;const t=!!(null===(e=this._instance.config.metrics)||void 0===e?void 0:e.network);t&&!this._stopNetworkMetrics?this._stopNetworkMetrics=(e=>{let t=!0;const i=()=>t?(e=>{var t;const i=null===(t=e.config.metrics)||void 0===t?void 0:t.network;return!0===i?{}:i||void 0})(e):void 0,s=g_(e,i),n=f_(e,i);return()=>{t=!1,s(),n()}})(this._instance):!t&&this._stopNetworkMetrics&&(this._stopNetworkMetrics(),this._stopNetworkMetrics=void 0)}_getCore(){var e;if(this._disposed)return;const t=null===(e=this._instance)||void 0===e||null===(e=e.config)||void 0===e?void 0:e.metrics;var i;return this._core&&this._resolvedFrom===t||(null===(i=this._core)||void 0===i||i.reset(),this._resolvedFrom=t,this._core=new Cr(this._createHost(),function(e){var t,i,s,n,r;const o=null==e?void 0:e.resourceAttributes;return{serviceName:null!==(t=null==o?void 0:o["service.name"])&&void 0!==t?t:null==e?void 0:e.serviceName,serviceVersion:null!==(i=null==o?void 0:o["service.version"])&&void 0!==i?i:null==e?void 0:e.serviceVersion,environment:null!==(s=null==o?void 0:o["deployment.environment"])&&void 0!==s?s:null==e?void 0:e.environment,resourceAttributes:o,beforeSend:null==e?void 0:e.beforeSend,flushIntervalMs:null!==(n=null==e?void 0:e.flushIntervalMs)&&void 0!==n?n:1e4,maxSeriesPerFlush:null!==(r=null==e?void 0:e.maxSeriesPerFlush)&&void 0!==r?r:1e3}}(t),this._logger)),this._core}count(e,t=1,i){var s;null===(s=this._getCore())||void 0===s||s.count(e,t,i)}gauge(e,t,i){var s;null===(s=this._getCore())||void 0===s||s.gauge(e,t,i)}histogram(e,t,i){var s;null===(s=this._getCore())||void 0===s||s.histogram(e,t,i)}flush(e){if(!this._core)return Promise.resolve();if(e){const t=this._core.drainWindow();return t&&this._sendMetricsBatch(t,e),Promise.resolve()}return this._core.flush().catch(e=>this._logger.error("PostHog metrics flush failed:",e))}reset(){var e;null===(e=this._core)||void 0===e||e.reset()}dispose(){var e,t;this._disposed=!0,null===(e=this._stopNetworkMetrics)||void 0===e||e.call(this),this._stopNetworkMetrics=void 0,null===(t=this._core)||void 0===t||t.reset()}_createHost(){const e=this._instance,t=this;return{get isDisabled(){return!1},get optedOut(){return!e.is_capturing()},_sendMetricsBatch:e=>t._sendMetricsBatch(e),getLibraryId:()=>i.LIB_NAME,getLibraryVersion:()=>i.LIB_VERSION}}_sendMetricsBatch(e,t){return new Promise(i=>{let s=!1;const n=e=>{s||(s=!0,clearTimeout(r),i(e))},r=setTimeout(()=>n({kind:"retry-later",error:new Error("metrics request timed out")}),9e4);this._instance._send_request(as(as({method:"POST",url:this._metricsUrl(),data:e,compression:"best-available",batchKey:"metrics"},t&&{transport:t}),{},{fireCallbackOnDrop:!0,callback(e){const t=e.statusCode;if(t>=200&&300>t)n({kind:"ok"});else if(413===t)n({kind:"too-large"});else if(0!==t&&408!==t&&429!==t&&500>t)n({kind:"fatal",error:new Error(`metrics request failed with status ${t}`)});else{var i;n({kind:"retry-later",error:null!==(i=e.error)&&void 0!==i?i:new Error(`metrics request failed with status ${t}`)})}}}))})}_metricsUrl(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}}},{webMCP:class{constructor(e){this._instance=e,this._isPatched=!1}initialize(){this.startIfEnabled()}startIfEnabled(){if(!this._instance.config.capture_webmcp||this._isPatched)return;const e=null==Ge?void 0:Ge.modelContext;if(!e||!pt(e.registerTool))return;const t=v_.get(e);if(t)return t.instances.add(this._instance),void(this._isPatched=!0);const i={instances:new Set([this._instance])},s=e.registerTool,n=this;Hu(e,"registerTool",e=>{const t=e;return function(e,...s){let r=e;try{r=n._wrapTool(e,i)}catch(i){return t.call(this,e,...s)}return t.call(this,r,...s)}}),e.registerTool!==s&&(v_.set(e,i),this._isPatched=!0)}_wrapTool(e,t){if(!e||!pt(e.execute))return e;const i=e.execute,s=this,{tool:n,injected:r}=function(e,t){const i={intent:!1,model:!1},s=e.inputSchema;if(!function(e){return!!vt(e)||gt(e)&&Object.keys(e).every(e=>m_.has(e)||e.startsWith("x-"))&&!0!==e.additionalProperties&&!gt(e.additionalProperties)&&(!e.type||"object"===e.type)&&(!e.properties||gt(e.properties))&&(!e.required||_t(e.required))}(s))return{tool:C_(e),injected:i};const n=(null==s?void 0:s.properties)||{},r=e=>S_(n,e)||_t(null==s?void 0:s.required)&&s.required.includes(e);if(i.intent=t.intent&&!r("context"),i.model=t.model&&!r("llm_model"),!i.intent&&!i.model)return{tool:C_(e),injected:i};const o=as({},n),a=_t(null==s?void 0:s.required)?[...s.required]:[];return i.intent&&(o.context={type:"string",description:'Explain why this tool is called and how it supports the user\'s goal. Describe the abstract purpose only. Do not include personal or identifying information. Generalize specific entities as roles such as "a customer".'},a.includes("context")||a.push("context")),i.model&&(o.llm_model={type:"string",description:'The model identifier you are running as, for example "claude-opus-4-8" or "gpt-5.2". Pass "unknown" if you are not certain. Recorded for the site developer\'s analytics.'},a.includes("llm_model")||a.push("llm_model")),{tool:C_(e,as(as({},s),{},{type:(null==s?void 0:s.type)||"object",properties:o,required:a})),injected:i}}(e,function(e){const t={intent:!1,model:!1};for(const i of e.instances){const e=w_(i.config.capture_webmcp);t.intent||(t.intent=!0===(null==e?void 0:e.intent)),t.model||(t.model=!0===(null==e?void 0:e.model))}return t}(t));return Object.defineProperty(n,"execute",{configurable:!0,enumerable:!0,writable:!0,value(...o){const a=new Date,l=function(e,t){if(!gt(e))return{};try{const i=t.intent?k_(e.context,2048,!0):void 0,s=t.model?k_(e.llm_model,256):void 0;return as(as({},i&&"{}"!==i?{intent:i}:{}),s&&"unknown"!==s.toLowerCase()?{model:s}:{})}catch(e){return{}}}(o[0],r),c=function(e,t){const i=e[0];if(!gt(i))return e;try{const s=t.intent&&S_(i,"context"),n=t.model&&S_(i,"llm_model");if(!s&&!n)return e;const r=as({},i);return s&&delete r.context,n&&delete r.llm_model,[r,...e.slice(1)]}catch(t){return e}}(o,r);let u;try{u=i.apply(this===n?e:this,c)}catch(e){throw s._captureToolCall(t,n,a,{error:e,errorResult:!1},l),e}if((d=u)&&"function"==typeof d.then)return Promise.resolve(u).then(e=>{const i=E_(e)?{error:e,errorResult:!0}:void 0;return s._captureToolCall(t,n,a,i,l),e},e=>{throw s._captureToolCall(t,n,a,{error:e,errorResult:!1},l),e});var d;const h=E_(u)?{error:u,errorResult:!0}:void 0;return s._captureToolCall(t,n,a,h,l),u}}),n}_captureToolCall(e,t,i,s,n){const r=Date.now()-i.getTime();let o;for(const l of e.instances){var a;const e=w_(l.config.capture_webmcp);if(e){s&&!o&&(o=T_(s.error,s.errorResult));try{l.capture("$mcp_tool_call",as(as(as({$mcp_source:"posthog_mcp_analytics",$mcp_interface:"webmcp",$mcp_tool_name:t.name,$mcp_resource_name:t.name,$mcp_tool_description:t.description,$mcp_server_name:null==Ke?void 0:Ke.hostname,$mcp_duration_ms:r,$mcp_is_error:!!s},o?{$mcp_error_type:o.type,$mcp_error_message:o.message}:{}),e.intent&&n.intent?{$mcp_intent:n.intent,$mcp_intent_source:"context_parameter"}:{}),e.model&&n.model?{$mcp_llm_model:n.model,$mcp_llm_model_source:"self_reported"}:{}),{timestamp:i})}catch(e){continue}if(s&&o&&l.exceptions&&(null===(a=l.exceptionObserver)||void 0===a?void 0:a.isEnabled))try{const e={$exception_list:I_(l.exceptions,s,o.message),$exception_level:"error",$exception_source:"mcp.tool_call",$mcp_interface:"webmcp",$mcp_tool_name:t.name,$mcp_resource_name:t.name,$mcp_tool_description:t.description,$mcp_server_name:null==Ke?void 0:Ke.hostname};l.exceptionObserver.captureException(e)}catch(e){}}}}}})),function(){i.SDK_DIST_CHANNEL="cdn";const e=tt.posthog;if(e&&!_t(e._i)&&pt(e.init))return;const t=pu[Iu]=new Lu;if(e){const i=[];Rr(e._i,function(s){if(s&&_t(s)){const n=t.init(s[0],s[1],s[2]),r=e[s[2]]||e;n.__loaded&&-1===i.indexOf(r)&&(i.push(r),n._execute_array.call(n.people,r.people),n._execute_array(r))}});const s=e.people;if(!t.__loaded&&_t(e)){const i=t.init;let n=!0;t.init=(r,o,a)=>{const l=i.call(t,r,o,a);return n&&l===t&&l.__loaded&&(n=!1,t.init=i,l._execute_array.call(l.people,s),l._execute_array(e)),l}}}t.__SV=1,tt.posthog=t,function(){function e(){e.done||(e.done=!0,vc=!1,Rr(pu,function(e){e._dom_loaded()}))}(null==Ge?void 0:Ge.addEventListener)?"complete"===Ge.readyState?e():Br(Ge,"DOMContentLoaded",e,{capture:!1}):je&&Ir.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}()}()}();
|
|
1
|
+
!function(){const e="0.10.7",t={DEBUG:(!1,!1),LIB_VERSION:(e,"1.447.2"),LIB_NAME:("browser-common","web"),JS_SDK_VERSION:e};var i=t;const s="$early_access_features",n="$active_feature_flags",r="$feature_flag_details",o="$feature_flag_errors",a="$feature_flag_evaluated_at",l="$feature_flag_request_id",c="$minimal_flag_called_events",u="$enabled_feature_flags",d="$stored_group_properties",h="$stored_person_properties",_="$flag_call_reported",p="$flag_call_reported_session_id",g="$feature_flag_payloads",f="$override_feature_flags",v="$override_feature_flag_payloads",m="visibilitychange",y="$autocapture_disabled_server_side",b="$surveys",w="$surveys_loaded_at",S="PostHog loadExternalDependency extension not found.",C="$surveys_activated",k="$surveys_activated_session",E="$surveys_activated_timestamps",x="$people_distinct_id",P="distinct_id",I="$device_id",F="$device_model",T="__alias",R="__cmpns",A="$fbc",M="$fbc_persistence",L="$fbp",O="$fbp_persistence",D="__timers",N="$heatmaps_enabled_server_side",B="$exception_capture_enabled_server_side",z="$error_tracking_suppression_rules",H="$error_tracking_capture_extension_exceptions",U="$web_vitals_enabled_server_side",q="$dead_clicks_enabled_server_side",j="$product_tours_enabled_server_side",W="$logs_capture_enabled_server_side",V="$web_vitals_allowed_metrics",G="$session_recording_remote_config",K="$session_recording_enabled_server_side",Q="$replay_sample_rate",J="$replay_override_sampling",Y="$replay_override_linked_flag",X="$replay_override_url_trigger",Z="$replay_override_event_trigger",ee="$sesid",te="$session_is_sampled",ie="$session_past_minimum_duration",se="$session_recording_url_trigger_activated_session",ne="$session_recording_event_trigger_activated_session",re="$debug_first_full_snapshot_timestamp",oe="$sess_rec_flush_size",ae="$groups",le="ph_product_tours",ce="$product_tours_activated",ue="$product_tours_activated_session",de="$conversations_widget_session_id",he="$conversations_ticket_id",_e="$conversations_widget_state",pe="$conversations_user_traits",ge="$user_state",fe="$client_session_props",ve="$capture_rate_limit",me="$initial_campaign_params",ye="$initial_referrer_info",be="$initial_person_info",we="$epp",Se="$posthog_cookieless",Ce="$cookieless_mode",ke="$sdk_debug_extensions_init_method",Ee="$sdk_debug_extensions_init_time_ms",xe="$sdk_debug_recording_script_not_loaded",Pe="$sdk_debug_replay_stale_config",Ie="$sdk_debug_replay_event_trigger_status",Fe="$sdk_debug_replay_linked_flag_trigger_status",Te="$sdk_debug_replay_matched_recording_trigger_groups",Re="$sdk_debug_replay_pending_trigger_conditions",Ae="$sdk_debug_replay_remote_trigger_matching_config",$e="$sdk_debug_replay_trigger_groups_count",Me="$sdk_debug_replay_url_trigger_status",Le="$session_recording_start_reason",Oe="anonymous",De="identified",Ne="identified_only",Be="beforeunload",ze="$pageview",He="$pageleave",Ue="$identify",qe="$groupidentify",je="u">typeof window?window:void 0,We="u">typeof globalThis?globalThis:je,Ve=null==We?void 0:We.navigator,Ge=null==We?void 0:We.document,Ke=null==We?void 0:We.location,Qe=null==We?void 0:We.fetch,Je=(null==We?void 0:We.XMLHttpRequest)&&"withCredentials"in new We.XMLHttpRequest?We.XMLHttpRequest:void 0,Ye=null==We?void 0:We.AbortController,Xe=null==We?void 0:We.CompressionStream,Ze=null==Ve?void 0:Ve.userAgent,et="undefined"!=typeof globalThis?globalThis:je;et&&"undefined"==typeof self&&(et.self=et),et&&"undefined"==typeof File&&(et.File=function(){});const tt=null!=je?je:{};var it=function(e){return e.AnonymousId="anonymous_id",e.DistinctId="distinct_id",e.Props="props",e.EnablePersonProcessing="enable_person_processing",e.PersonMode="person_mode",e.FeatureFlagDetails="feature_flag_details",e.FeatureFlags="feature_flags",e.FeatureFlagPayloads="feature_flag_payloads",e.BootstrapFeatureFlagDetails="bootstrap_feature_flag_details",e.BootstrapFeatureFlags="bootstrap_feature_flags",e.BootstrapFeatureFlagPayloads="bootstrap_feature_flag_payloads",e.OverrideFeatureFlags="override_feature_flags",e.Queue="queue",e.AiQueue="ai_queue",e.AiCaptureQueue="ai_capture_queue",e.LogsQueue="logs_queue",e.OptedOut="opted_out",e.SessionId="session_id",e.SessionStartTimestamp="session_start_timestamp",e.SessionLastTimestamp="session_timestamp",e.PersonProperties="person_properties",e.GroupProperties="group_properties",e.InstalledAppBuild="installed_app_build",e.InstalledAppVersion="installed_app_version",e.SessionReplay="session_replay",e.PushRegistered="push_registered",e.SessionReplayEventTriggerActivatedSession="session_replay_event_trigger_activated_session",e.SurveyLastSeenDate="survey_last_seen_date",e.SurveysInProgress="surveys_in_progress",e.SurveysSeen="surveys_seen",e.Surveys="surveys",e.RemoteConfig="remote_config",e.FlagsEndpointWasHit="flags_endpoint_was_hit",e.DeviceId="device_id",e}({}),st=function(e){return e.GZipJS="gzip-js",e.Base64="base64",e}({});const nt=["$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"],rt=["token"];function ot(e,t){return-1!==e.indexOf(t)}const at=function(e){return e.trim()},lt=function(e){return e.replace(/^\$/,"")};function ct(e){var t;const i=[];return null!==(t=JSON.stringify(e,function(e,t){if("bigint"==typeof t)return t.toString();if("function"!=typeof t&&"symbol"!=typeof t){if(t instanceof Error)return{name:t.name,message:t.message,stack:t.stack};if(t&&"object"==typeof t){for(;i.length>0&&i[i.length-1]!==this;)i.pop();if(i.includes(t))return"[Circular]";i.push(t)}return t}}))&&void 0!==t?t:"null"}const ut=Object.prototype,dt=ut.hasOwnProperty,ht=ut.toString,_t=Array.isArray||function(e){return"[object Array]"===ht.call(e)},pt=e=>"function"==typeof e,gt=e=>e===Object(e)&&!_t(e),ft=e=>{if(gt(e)){for(const t in e)if(dt.call(e,t))return!1;return!0}return!1},vt=e=>void 0===e,mt=e=>"[object String]"==ht.call(e),yt=e=>mt(e)&&0===e.trim().length,bt=e=>null===e,wt=e=>vt(e)||bt(e),St=e=>"[object Number]"==ht.call(e)&&e==e,Ct=e=>St(e)&&e>0,kt=e=>"[object Boolean]"===ht.call(e),Et=e=>ot(nt,e),xt=e=>ot(rt,e);function Pt(e){return null===e||"object"!=typeof e}function It(e,t){return{}.toString.call(e)===`[object ${t}]`}function Ft(e){switch({}.toString.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object DOMError]":case"[object WebAssembly.Exception]":return!0;default:return Rt(e,Error)}}function Tt(e){return"u">typeof Event&&Rt(e,Event)}function Rt(e,t){try{return e instanceof t}catch(e){return!1}}const At=[!0,"true",1,"1","yes"],$t=e=>ot(At,e),Mt=[!1,"false",0,"0","no"];function Lt(e,t,i,s,n,r,o){try{var a=e[r](o),l=a.value}catch(e){return void i(e)}a.done?t(l):Promise.resolve(l).then(s,n)}function Ot(e){return function(){var t=this,i=arguments;return new Promise(function(s,n){var r=e.apply(t,i);function o(e){Lt(r,s,n,o,a,"next",e)}function a(e){Lt(r,s,n,o,a,"throw",e)}o(void 0)})}}const Dt=["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","lightpanda","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"],Nt=new Map,Bt=function(e,t=[]){if(!e)return!1;const i=function(e,t){let i="";for(let e=0;t.length>e;e++){const s=t[e];i+=s.length+":"+s}return e.length+":"+e+"|"+t.length+":"+i}(e,t),s=Nt.get(i);if(void 0!==s)return s;const n=e.toLowerCase(),r=Dt.concat(t).some(e=>-1!==n.indexOf(e.toLowerCase()));return 256>Nt.size||Nt.clear(),Nt.set(i,r),r};function zt(e,t,i,s,n){return t>i&&(s.warn("min cannot be greater than max."),t=i),St(e)?e>i?(s.warn(" cannot be greater than max: "+i+". Using max value instead."),i):t>e?(s.warn(" cannot be less than min: "+t+". Using min value instead."),t):e:(s.warn(" must be a number. using max or fallback. max: "+i+", fallback: "+n),zt(null!=n?n:i,t,i,s))}var Ht=class{constructor(e){this._buckets={},this._onBucketRateLimited=e._onBucketRateLimited,this._bucketSize=zt(e.bucketSize,0,100,e._logger),this._refillRate=zt(e.refillRate,0,this._bucketSize,e._logger),this._refillInterval=zt(e.refillInterval,0,864e5,e._logger)}_applyRefill(e,t){const i=Math.floor((t-e.lastAccess)/this._refillInterval);i>0&&(e.tokens=Math.min(e.tokens+i*this._refillRate,this._bucketSize),e.lastAccess=e.lastAccess+i*this._refillInterval)}consumeRateLimit(e){var t;const i=Date.now(),s=String(e);let n=this._buckets[s];return n?this._applyRefill(n,i):(n={tokens:this._bucketSize,lastAccess:i},this._buckets[s]=n),0===n.tokens||(n.tokens--,0===n.tokens&&(null===(t=this._onBucketRateLimited)||void 0===t||t.call(this,e)),0===n.tokens)}stop(){this._buckets={}}};const Ut="Mobile",qt="Android",jt="Tablet",Wt="Android Tablet",Vt="iPad",Gt="Apple Watch",Kt="Safari",Qt="BlackBerry",Jt="Samsung Internet",Yt="Chrome",Xt="Chrome iOS",Zt="Internet Explorer",ei="Internet Explorer Mobile",ti="Opera",ii="Microsoft Edge",si="Firefox",ni="Firefox iOS",ri="Nintendo",oi="PlayStation",ai="Xbox",li="Android Mobile",ci="Mobile Safari",ui="Windows",di="Windows Phone",hi="Nokia",_i="Ouya",pi="Generic tablet",gi="Konqueror",fi="Oculus Browser",vi="Vivaldi",mi="Yandex",yi="Whale",bi="DuckDuckGo",wi="Pale Moon",Si="Waterfox",Ci="Brave",ki="Claude",Ei="Codex",xi="ChatGPT",Pi="Google Search App",Ii=new RegExp("Version/(\\d+(\\.\\d+)?)"),Fi=new RegExp("(Claude|Codex|ChatGPT)\\/(\\d+(\\.\\d+)?)"),Ti=new RegExp(ai,"i"),Ri=new RegExp("PlayStation \\w+","i"),Ai=new RegExp("Nintendo \\w+","i"),$i=new RegExp("BlackBerry|PlayBook|BB10","i"),Mi={"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"},Li=function(e,t,i,s){t=t||"";const n=function(e){return(null==e?void 0:e.brave)?Ci:null}(i);return n||((null==s?void 0:s.detectGoogleSearchApp)&&ot(e,"GSA/")?Pi:ot(e," OPR/")&&ot(e,"Mini")?"Opera Mini":ot(e," OPR/")?ti:$i.test(e)?Qt:ot(e,"IEMobile")||ot(e,"WPDesktop")?ei:ot(e,"OculusBrowser")?fi:ot(e,"SamsungBrowser")?Jt:ot(e,"Edge")||ot(e,"Edg/")?ii:ot(e,"Vivaldi/")?vi:ot(e,"YaBrowser/")?mi:ot(e,"Whale/")?yi:ot(e,"DuckDuckGo/")||ot(e,"Ddg/")?bi:ot(e,"Claude/")?ki:ot(e,"Codex/")?Ei:ot(e,"ChatGPT/")?xi:ot(e,"FBIOS")?"Facebook Mobile":ot(e,"UCWEB")||ot(e,"UCBrowser")?"UC Browser":ot(e,"CriOS")?Xt:ot(e,"CrMo")||ot(e,Yt)?Yt:ot(e,qt)&&ot(e,Kt)?li:ot(e,"FxiOS")?ni:ot(e.toLowerCase(),gi.toLowerCase())?gi:ot(e,"Brave/")?Ci:((e,t)=>t&&ot(t,"Apple")||function(e){return ot(e,Kt)&&!ot(e,Yt)&&!ot(e,qt)}(e))(e,t)?ot(e,Ut)?ci:Kt:ot(e,"PaleMoon/")?wi:ot(e,"Waterfox/")?Si:ot(e,si)?si:ot(e,"MSIE")||ot(e,"Trident/")?Zt:ot(e,"Gecko")?si:"")},Oi={[ei]:[new RegExp("rv:(\\d+(\\.\\d+)?)")],[ii]:[new RegExp("Edge?\\/(\\d+(\\.\\d+)?)")],[Yt]:[new RegExp("(Chrome|CrMo)\\/(\\d+(\\.\\d+)?)")],[Xt]:[new RegExp("CriOS\\/(\\d+(\\.\\d+)?)")],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/(\\d+(\\.\\d+)?)")],[Kt]:[Ii],[ci]:[Ii],[ti]:[new RegExp("(Opera|OPR)\\/(\\d+(\\.\\d+)?)")],[si]:[new RegExp("Firefox\\/(\\d+(\\.\\d+)?)")],[ni]:[new RegExp("FxiOS\\/(\\d+(\\.\\d+)?)")],[gi]:[new RegExp("Konqueror[:/]?(\\d+(\\.\\d+)?)","i")],[Qt]:[new RegExp("BlackBerry (\\d+(\\.\\d+)?)"),Ii],[li]:[new RegExp("android\\s(\\d+(\\.\\d+)?)","i")],[Jt]:[new RegExp("SamsungBrowser\\/(\\d+(\\.\\d+)?)")],[fi]:[new RegExp("OculusBrowser\\/(\\d+(\\.\\d+)?)")],[vi]:[new RegExp("Vivaldi\\/(\\d+(\\.\\d+)?)")],[mi]:[new RegExp("YaBrowser\\/(\\d+(\\.\\d+)?)")],[yi]:[new RegExp("Whale\\/(\\d+(\\.\\d+)?)")],[Ci]:[new RegExp("Brave\\/(\\d+(\\.\\d+)?)")],[ki]:[Fi],[Ei]:[Fi],[xi]:[Fi],[bi]:[new RegExp("(DuckDuckGo|Ddg)\\/(\\d+(\\.\\d+)?)")],[wi]:[new RegExp("PaleMoon\\/(\\d+(\\.\\d+)?)")],[Si]:[new RegExp("Waterfox\\/(\\d+(\\.\\d+)?)")],[Pi]:[new RegExp("GSA\\/(\\d+(\\.\\d+)?)")],[Zt]:[new RegExp("(rv:|MSIE )(\\d+(\\.\\d+)?)")],Mozilla:[new RegExp("rv:(\\d+(\\.\\d+)?)")]},Di=function(e,t,i,s){const n=Li(e,t,i,s),r=Oi[n];if(vt(r))return null;for(let t=0;r.length>t;t++){const i=e.match(r[t]);if(i)return parseFloat(i[i.length-2])}return null},Ni=[[new RegExp("Xbox; Xbox (.*?)[);]","i"),e=>[ai,e&&e[1]||""]],[new RegExp(ri,"i"),[ri,""]],[new RegExp(oi,"i"),[oi,""]],[$i,[Qt,""]],[new RegExp(ui,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[di,""];if(new RegExp(Ut).test(t)&&!/IEMobile\b/.test(t))return["Windows Mobile",""];const i=/Windows NT ([0-9.]+)/i.exec(t);if(i&&i[1]){let e=Mi[i[1]]||"";return/arm/i.test(t)&&(e="RT"),[ui,e]}return[ui,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>e&&e[3]?["iOS",[e[3],e[4],e[5]||"0"].join(".")]:["iOS",""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{let t="";return e&&e.length>=3&&(t=vt(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("(Android (\\d+)\\.(\\d+)\\.?(\\d+)?|Android)","i"),e=>e&&e[2]?[qt,[e[2],e[3],e[4]||"0"].join(".")]:[qt,""]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{const t=["Mac OS X",""];return e&&e[1]&&(t[1]=[e[1],e[2],e[3]||"0"].join(".")),t}],[/Mac/i,["Mac OS X",""]],[/CrOS/,["Chrome OS",""]],[/Linux|debian/i,["Linux",""]]],Bi=function(e){for(let t=0;Ni.length>t;t++){const[i,s]=Ni[t],n=i.exec(e),r=n&&(pt(s)?s(n,e):s);if(r)return r}return["",""]},zi=function(e){return Ai.test(e)?ri:Ri.test(e)?oi:Ti.test(e)?ai:new RegExp(_i,"i").test(e)?_i:new RegExp("(Windows Phone|WPDesktop)","i").test(e)?di:/iPad/.test(e)?Vt:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?Gt:$i.test(e)?Qt:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(hi,"i").test(e)?hi:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(e)||/(kf[a-z]+)( bui|\)).+silk\//i.test(e)?"Kindle Fire":/(Android|ZTE)/i.test(e)?new RegExp(Ut).test(e)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(e)||/pixel[\daxl ]{1,6}/i.test(e)&&!/pixel c/i.test(e)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(e)||/lmy47v/i.test(e)&&!/QTAQZ3/i.test(e)?qt:Wt:new RegExp("(pda|Mobile)","i").test(e)?"Generic mobile":new RegExp(jt,"i").test(e)&&!new RegExp("Tablet pc","i").test(e)?pi:""},Hi=function(e,t){var i;const s=zi(e);return s===Vt||s===Wt||"Kobo"===s||"Kindle Fire"===s||s===pi?jt:s===ri||s===ai||s===oi||s===_i?"Console":s===Gt?"Wearable":s?Ut:"Android"===(null==t?void 0:t.userAgentDataPlatform)&&(null!==(i=null==t?void 0:t.maxTouchPoints)&&void 0!==i?i:0)>0?600>Math.min(null!==(n=null==t?void 0:t.screenWidth)&&void 0!==n?n:0,null!==(r=null==t?void 0:t.screenHeight)&&void 0!==r?r:0)/(null!==(o=null==t?void 0:t.devicePixelRatio)&&void 0!==o?o:1)?Ut:jt:"Desktop";var n,r,o},Ui=/\bFBAV\/(\d+(?:\.\d+)*)/i,qi=[[/\bInstagram(?:[ /](\d+(?:\.\d+)*))?\b/i,"Instagram"],[/\bBarcelona[ /](\d+(?:\.\d+)*)?/i,"Threads"],[/\b(?:MessengerForiOS|(?:FBAN|FB_IAB)\/Orca-Android)\b/i,"Messenger",Ui],[/\bFBAN\/EMA\b/i,"Facebook Lite",Ui],[/\b(?:FBIOS|(?:FBAN|FB_IAB)\/(?:FB4A|FBIOS))\b/i,"Facebook",Ui],[/\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"]],ji="[Truncated]",Wi="[Unserializable]";function Vi(e){let t="";for(let i=0;e.length>i;i++){const s=e.charCodeAt(i);if(55296>s||s>56319)t+=56320>s||s>57343?e[i]:"�";else{const s=e.charCodeAt(i+1);56320>s||s>57343?t+="�":(t+=e[i]+e[i+1],i++)}}return t}function Gi(e,t){if(!t)return e;let i=[];try{i=Object.keys(t)}catch(e){i=[]}for(const s of i){let i;try{i=t[s]}catch(e){i=Wi}Object.defineProperty(e,s,{value:i,enumerable:!0,writable:!0,configurable:!0})}return e}Date,Date;const Ki=3e5;var Qi=class{record(e){if("too-large"===e.kind)return;if("retry-later"!==e.kind)return void this.reset();if(!e.retryAfterMs)return;const t=this.isOpen(),i=Date.now(),s=Math.min(e.retryAfterMs,Ki);if(!t)return this._installedAt=i,void(this._until=i+s);this._until=Math.max(this._until,Math.min(i+s,this._installedAt+Ki))}remainingMs(){const e=Date.now();if(this._installedAt-5e3>e)return this.reset(),0;const t=Math.min(Ki,Math.max(0,this._until-e));return 0===t&&this.reset(),t}isOpen(){return this.remainingMs()>0}reset(){this._until=0,this._installedAt=0}constructor(){this._until=0,this._installedAt=0}};const Ji=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function Yi(e,t){return"string"==typeof(i=e)&&Ji.test(i)?e:t();var i}function Xi(e,t){const i=new Error(t);try{Object.defineProperty(i,"name",{value:e,writable:!0,enumerable:!0,configurable:!0})}catch(e){}return i}function Zi(e){return e?e.split("#")[0]:e}function es(e){try{return e()}catch(e){return}}function ts(e,t){const i=setTimeout(e,t);return null!=i&&i.unref&&(null==i||i.unref()),i}function is(e,t,i){return ss.apply(this,arguments)}function ss(){return(ss=Ot(function*(e,t,i){let s;try{return yield Promise.race([e,new Promise((e,n)=>{s=ts(()=>{try{null==i||i(),e()}catch(e){n(e)}},t)})])}finally{clearTimeout(s)}})).apply(this,arguments)}function ns(e){return ns="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},ns(e)}function rs(e,t,i){return(t=function(e){var t=function(e){if("object"!=ns(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var i=t.call(e,"string");if("object"!=ns(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==ns(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function os(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),i.push.apply(i,s)}return i}function as(e){for(var t=1;arguments.length>t;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?os(Object(i),!0).forEach(function(t){rs(e,t,i[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):os(Object(i)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))})}return e}let ls,cs,us,ds;function hs(e){var t;const i=globalThis._posthogChunkIds,s=globalThis._debugIds;if(!i&&!s)return;const n=i?Object.keys(i):[],r=s?Object.keys(s):[];if(ds&&_s(i,n,cs)&&_s(s,r,us))return ds;cs=i?as({},i):void 0,us=s?as({},s):void 0,ds={},null!==(t=ls)&&void 0!==t||(ls={});const o=(t,i)=>{for(const n of t){const t=i[n];if(!t)continue;const r=null==ls?void 0:ls[n];if(r){ds[r]=t;continue}const o=e(n);for(let e=o.length-1;e>=0;e--){var s;const i=null===(s=o[e])||void 0===s?void 0:s.filename;if(i){ds[i]=t,ls[n]=i;break}}}};return s&&o(r,s),i&&o(n,i),ds}function _s(e,t,i){return e&&i?t.length===Object.keys(i).length&&t.every(t=>e[t]===i[t]):e===i}var ps=class{constructor(e,t,i=[]){this.coercers=e,this.stackParser=t,this.modifiers=i}buildFromUnknown(e,t={}){const i=t&&t.mechanism||{handled:!0,type:"generic"},s=this.buildCoercingContext(i,t,0).apply(e),n=this.buildParsingContext(t),r=this.parseStacktrace(s,n);return{$exception_list:this.convertToExceptionList(r,i),$exception_level:"error"}}modifyFrames(e){var t=this;return Ot(function*(){for(const i of e)i.stacktrace&&i.stacktrace.frames&&_t(i.stacktrace.frames)&&(i.stacktrace.frames=yield t.applyModifiers(i.stacktrace.frames));return e})()}coerceFallback(e){var t;return{type:"Error",value:"Unknown error",stack:null===(t=e.syntheticException)||void 0===t?void 0:t.stack,synthetic:!0}}parseStacktrace(e,t){var i;let s,n;if(null!=e.cause&&(s=this.parseStacktrace(e.cause,t)),""!=e.stack&&null!=e.stack)try{n=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?t.skipFirstLines:0),t.chunkIdMap)}catch(e){}return as(as({},e),{},{cause:s,stack:n,errors:null===(i=e.errors)||void 0===i?void 0:i.map(e=>this.parseStacktrace(e,t))})}applyChunkIds(e,t){return e.map(e=>(e.filename&&t&&(e.chunk_id=t[e.filename]),e))}applyCoercers(e,t){for(const i of this.coercers)if(i.match(e))return i.coerce(e,t);return this.coerceFallback(t)}applyModifiers(e){var t=this;return Ot(function*(){let i=e;for(const e of t.modifiers)i=yield e(i);return i})()}convertToExceptionList(e,t){const i=[],s=(e,n,r)=>{var o;const a=i.length,l=void 0===n?as(as({type:"string"==typeof t.type&&t.type.length>0?t.type:"generic"},"boolean"==typeof t.handled?{handled:t.handled}:void 0===t.handled?{handled:!0}:{}),{},{synthetic:"boolean"==typeof t.synthetic?t.synthetic:e.synthetic,exception_id:a}):{type:"chained",source:r,synthetic:e.synthetic,exception_id:a,parent_id:n},c={type:e.type,value:e.value,mechanism:l};e.stack&&(c.stacktrace={type:"raw",frames:e.stack}),i.push(c),e.cause&&s(e.cause,a,"cause");for(const t of null!==(o=e.errors)&&void 0!==o?o:[])s(t,a,"member")};return s(e),i}buildParsingContext(e){var t;return{chunkIdMap:hs(this.stackParser),skipFirstLines:null!==(t=e.skipFirstLines)&&void 0!==t?t:1}}getAggregateErrors(e){try{if(Ft(e)){let i=Object.getPrototypeOf(e);for(let s=0;i&&100>s;s++){var t;const s=null===(t=Object.getOwnPropertyDescriptor(i,"constructor"))||void 0===t?void 0:t.value;if("function"==typeof s&&"AggregateError"===s.name){const t=e.errors;return _t(t)?t:void 0}i=Object.getPrototypeOf(i)}}}catch(e){}}buildCoercingContext(e,t,i=0){let s=0,n=0,r=!1;const o=new Set,a=[],l={},c=(e,t,i=0)=>{const c=u(t,i),d=c.apply;if(c.apply=t=>{a.push(e);try{return d(t)}finally{a.pop()}},i>4||i>0&&-1!==a.indexOf(e))return this.coerceFallback(c);const h="object"==typeof e&&null!==e||"function"==typeof e;if(0===i&&s>=50||h&&o.has(e))return;h&&o.add(e),0===i&&s++;const _=this.getAggregateErrors(e);let p,g;r||(r=!!_);try{if(p=this.applyCoercers(e,c),!p)throw l}catch(e){if(e===l)return void(0===i&&s--);if(!r)throw e;p=this.coerceFallback(c)}if(!_||s>=50)return p;try{g=_.length}catch(e){return p}if(!Number.isInteger(g)||0>g||g>4294967295)return p;const f=[];for(let e=0;50>s&&1e3>n&&g>e;e++){let i;n++;try{i=c.next(_[e])}catch(e){s++,i=this.coerceFallback(u(t+1))}i&&f.push(i)}return as(as({},p),{},{errors:f})},u=(i,s=0)=>as(as({},t),{},{syntheticException:0==i?t.syntheticException:void 0,mechanism:0==i?e:{},apply(e){const t=c(e,i,s+1);if(!t)throw l;return t},next:e=>c(e,i+1)}),d=u(i);return as(as({},d),{},{apply:e=>{var t;return null!==(t=c(e,i))&&void 0!==t?t:this.coerceFallback(d)}})}};const gs=/^([a-z][a-z0-9.+-]+):/i,fs=["http","https","file","blob","app","capacitor","ionic","webpack","webpack-internal","ng"];function vs(e){if(!e||"<anonymous>"===e)return!1;const t=gs.exec(e);return!t||fs.includes(t[1].toLowerCase())}function ms(e,t,i,s,n){const r={platform:e,filename:t,function:"<anonymous>"===i?"?":i,in_app:vs(t)};return vt(s)||(r.lineno=s),vt(n)||(r.colno=n),r}const ys=(e,t)=>{const i=-1!==e.indexOf("safari-extension"),s=-1!==e.indexOf("safari-web-extension");return i||s?[-1!==e.indexOf("@")?e.split("@")[0]:"?",i?`safari-extension:${t}`:`safari-web-extension:${t}`]:[e,t]},bs=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,ws=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,Ss=/\((\S*)(?::(\d+))(?::(\d+))\)/,Cs=(e,t)=>{const i=bs.exec(e);if(i){const[,e,s,n]=i;return ms(t,e,"?",+s,+n)}const s=ws.exec(e);if(s){if(s[2]&&0===s[2].indexOf("eval")){const e=Ss.exec(s[2]);e&&(s[2]=e[1],s[3]=e[2],s[4]=e[3])}const[e,i]=ys(s[1]||"?",s[2]);return ms(t,i,e,s[3]?+s[3]:void 0,s[4]?+s[4]:void 0)}},ks=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,Es=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,xs=(e,t)=>{const i=ks.exec(e);if(i){if(i[3]&&i[3].indexOf(" > eval")>-1){const e=Es.exec(i[3]);e&&(i[1]=i[1]||"eval",i[3]=e[1],i[4]=e[2],i[5]="")}let e=i[3],s=i[1]||"?";return[s,e]=ys(s,e),ms(t,e,s,i[4]?+i[4]:void 0,i[5]?+i[5]:void 0)}},Ps=/\(error: (.*)\)/;function Is(e,t){return e.filename===t.filename&&e.function===t.function&&e.module===t.module&&e.lineno===t.lineno&&e.colno===t.colno}function Fs(e){for(let t=1;10>=t;t++){const i=e.length-2*t;if(0>i)break;let s=!0;for(let n=0;t>n;n++)if(!Is(e[i+n],e[i+t+n])){s=!1;break}if(s){for(let s=0;t>s;s++)e[i+s]=e[i+t+s];return e.length=i+t,{start:i,length:t}}}}function Ts(e,t){const i=t.start+t.length,s=As(e,t);s&&e.splice(i+s===e.length?i:t.start,s)}function Rs(e,t){let i=t.start;for(;i>0&&Is(e[i-1],e[i-1+t.length]);)i--;return t.start-i}function As(e,t){const i=t.start+t.length;let s=i;for(;e.length>s&&Is(e[s],e[s-t.length]);)s++;return s-i}function $s(e,t){const i=t[0];let s=e.length-(i?Rs(e,i):0);for(const i of t)s-=As(e,i);return s}function Ms(e,t,i){for(let s=0;e.length>s;s++){const n=e[(t+s)%e.length],r=e[(i+s)%e.length];if(n!==r)return r>n}return!1}var Ls=class{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){const i=mt(e.stack);return{type:this.getType(e),value:this.getValue(e),stack:i?e.stack:void 0,cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return this.isDOMError(e)?"DOMError":"DOMException"}getValue(e){const t=e.name||(this.isDOMError(e)?"DOMError":"DOMException");return e.message?`${t}: ${e.message}`:t}isDOMException(e){return It(e,"DOMException")}isDOMError(e){return It(e,"DOMError")}},Os=class{match(e){return Ft(e)}coerce(e,t){var i;const s=this.getStack(e),n=void 0===s?null===(i=t.syntheticException)||void 0===i?void 0:i.stack:void 0,r=!!n;return{type:this.getType(e),value:this.getMessage(e,t),stack:null!=s?s:n,cause:e.cause?t.next(e.cause):void 0,synthetic:r}}getType(e){return e.name||e.constructor.name}getMessage(e,t){const i=e.message;return String(i.error&&"string"==typeof i.error.message?i.error.message:i)}getStack(e){try{const t=e.stacktrace;if("string"==typeof t&&t.length>0)return t;const i=e.stack;return"string"==typeof i&&i.length>0?i:void 0}catch(e){return}}},Ds=class{match(e){return!!It(e,"ErrorEvent")&&(null!=e.error||this._hasUsableMessage(e))}coerce(e,t){var i;if(null!=e.error)return t.apply(e.error);const s=t.apply(e.message);return as(as({},s),{},{stack:null!==(i=this._buildLocationStack(e))&&void 0!==i?i:s.stack,synthetic:!0})}_hasUsableMessage(e){return mt(e.message)&&e.message.length>0}_buildLocationStack(e){var t,i;const s=e,n=null!==(t=s.lineno)&&void 0!==t?t:0,r=null!==(i=s.colno)&&void 0!==i?i:0;if(mt(s.filename)&&0!==s.filename.length&&0!==n)return`Error\n at ${s.filename}:${n}:${r}`}};const Ns=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;var Bs=class{match(e){return"string"==typeof e}coerce(e,t){var i;const[s,n]=this.getInfos(e);return{type:null!=s?s:"Error",value:null!=n?n:e,stack:null===(i=t.syntheticException)||void 0===i?void 0:i.stack,synthetic:!0}}getInfos(e){let t="Error",i=e;const s=e.match(Ns);return s&&(t=s[1],i=s[2]),[t,i]}};const zs=["fatal","error","warning","log","info","debug"];function Hs(e,t=40){const i=Object.keys(e);if(i.sort(),!i.length)return"[object has no keys]";for(let e=i.length;e>0;e--){const s=i.slice(0,e).join(", ");if(t>=s.length)return e===i.length?s:s.length>t?`${s.slice(0,t)}...`:s}return""}var Us=class{match(e){return"object"==typeof e&&null!==e}coerce(e,t){var i,s;const n=this.getErrorPropertyFromObject(e);return n?t.apply(n):{type:this.getType(e),value:this.getValue(e),stack:null!==(i=this.getStack(e))&&void 0!==i?i:null===(s=t.syntheticException)||void 0===s?void 0:s.stack,level:this.isSeverityLevel(e.level)?e.level:"error",synthetic:!0}}getType(e){if(Tt(e))return e.constructor.name;const t="name"in e?e.name:void 0;return mt(t)&&!yt(t)?t:"Error"}getValue(e){if("name"in e&&"string"==typeof e.name){let t=`'${e.name}' captured as exception`;return"message"in e&&"string"==typeof e.message&&(t+=` with message: '${e.message}'`),t}if("message"in e&&"string"==typeof e.message)return e.message;const t=this.getObjectClassName(e);return`${t&&"Object"!==t?`'${t}'`:"Object"} captured as exception with keys: ${Hs(e)}`}isSeverityLevel(e){return mt(e)&&!yt(e)&&zs.indexOf(e)>=0}getStack(e){try{return mt(e.stacktrace)&&e.stacktrace.length>0?e.stacktrace:mt(e.stack)&&e.stack.length>0?e.stack:void 0}catch(e){return}}getErrorPropertyFromObject(e){for(const t in e)if({}.hasOwnProperty.call(e,t)){const i=e[t];if(Ft(i))return i}}getObjectClassName(e){try{const t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch(e){return}}},qs=class{match(e){return Tt(e)}coerce(e,t){var i;const s=e.constructor.name;return{type:s,value:`${s} captured as exception with keys: ${Hs(e)}`,stack:null===(i=t.syntheticException)||void 0===i?void 0:i.stack,synthetic:!0}}},js=class{match(e){return Pt(e)}coerce(e,t){var i;return{type:"Error",value:`Primitive value captured as exception: ${String(e)}`,stack:null===(i=t.syntheticException)||void 0===i?void 0:i.stack,synthetic:!0}}},Ws=class{match(e){return It(e,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(e)}isCustomEventWrappingRejection(e){if(!Tt(e))return!1;try{const t=e.detail;return null!=t&&"object"==typeof t&&"reason"in t}catch(e){return!1}}coerce(e,t){var i;const s=this.getUnhandledRejectionReason(e);return Pt(s)?{type:"UnhandledRejection",value:`Non-Error promise rejection captured with value: ${String(s)}`,stack:null===(i=t.syntheticException)||void 0===i?void 0:i.stack,synthetic:!0}:t.apply(s)}getUnhandledRejectionReason(e){try{if("reason"in e)return e.reason;if("detail"in e&&null!=e.detail&&"object"==typeof e.detail&&"reason"in e.detail)return e.detail.reason}catch(e){}return e}};const Vs="$message",Gs="$timestamp",Ks=new Set([Vs,Gs]),Qs={enabled:!0,max_bytes:32768};function Js(e){var t;return e?{enabled:null!==(t=e.enabled)&&void 0!==t?t:Qs.enabled,max_bytes:Xs(e.max_bytes,Qs.max_bytes)}:as({},Qs)}var Ys=class{constructor(e){this._entries=[],this._totalBytes=0,this._config=Js(e)}setConfig(e){this._config=Js(e),this._trimToMaxBytes()}add(e){const t=function(e){let t;try{t=ct(e)}catch(e){return}try{const e=JSON.parse(t);if(!gt(e))return;const i=e,s=i[Vs],n=i[Gs];if(!mt(s)||0===s.trim().length)return;if(!mt(n)&&!St(n))return;return{step:i,json:t}}catch(e){return}}(e);if(!t)return;const i=function(e){if("u">typeof TextEncoder)return(new TextEncoder).encode(e).length;const t=encodeURIComponent(e);let i=0;for(let e=0;t.length>e;e++)"%"===t[e]?(i+=1,e+=2):i+=1;return i}(t.json);i>this._config.max_bytes||(this._entries.push({step:t.step,bytes:i}),this._totalBytes+=i,this._trimToMaxBytes())}getAttachable(){return this._entries.map(e=>e.step)}clear(){this._entries=[],this._totalBytes=0}size(){return this._entries.length}_trimToMaxBytes(){for(;this._totalBytes>this._config.max_bytes&&this._entries.length>0;){const e=this._entries.shift();e&&(this._totalBytes-=e.bytes)}}};function Xs(e,t){if(!St(e)||1/0===e||-1/0===e)return t;const i=Math.floor(e);return 0>i?t:i}const Zs=e=>{if("string"!=typeof e)return e;try{return JSON.parse(e)}catch(t){return e}};function en(e){return"string"==typeof e||e}function tn(e){return"string"==typeof e?e:void 0}const sn=["$feature_flag","$feature_flag_response","$feature_flag_has_experiment","$feature_flag_id","$feature_flag_version","$feature_flag_reason","$feature_flag_request_id","$feature_flag_evaluated_at","$feature_flag_error","locally_evaluated","$groups","$process_person_profile","$geoip_disable","$current_url","$pathname","$referring_domain","utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid","gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","oppref","bfcid","irclid","_kx","$session_id","$window_id","$lib","$lib_version","$device_id","$is_server"],nn="NativeGzipValidationError",rn=e=>e.length>=2&&31===e[0]&&139===e[1],on=(e,t)=>e===st.GZipJS||t===st.GZipJS||"gzip"===t,an=e=>!(!e||"object"!=typeof e)&&"NotReadableError"===("name"in e?String(e.name):"");let ln;const cn=e=>{throw Xi(nn,`Native gzip produced invalid output: ${e}`)},un=function(){var e=Ot(function*(e,t){18>e.size&&cn("too-short");const i=new Uint8Array(yield e.slice(0,10).arrayBuffer());rn(i)&&8===i[2]||cn("invalid-header");const s=new DataView(yield e.slice(e.size-8).arrayBuffer());s.getUint32(0,!0)!==(e=>{const t=(()=>{if(ln)return ln;ln=[];for(let e=0;256>e;e++){let t=e;for(let e=0;8>e;e++)t=1&t?3988292384^t>>>1:t>>>1;ln[e]=t>>>0}return ln})();let i=4294967295;for(let s=0;e.length>s;s++)i=t[255&(i^e[s])]^i>>>8;return(4294967295^i)>>>0})(t)&&cn("invalid-crc");const n=t.length>>>0;s.getUint32(4,!0)!==n&&cn("invalid-size")});return function(t,i){return e.apply(this,arguments)}}();function dn(){return dn=Ot(function*(e,t=!0,i){try{const t=(new TextEncoder).encode(e),i=new globalThis.CompressionStream("gzip"),n=i.writable.getWriter(),r=n.write(t).then(()=>n.close()).catch((s=Ot(function*(e){try{yield n.abort(e)}catch(e){}throw e}),function(e){return s.apply(this,arguments)})),o=new Response(i.readable).blob(),[a]=yield Promise.all([o,r]);return yield un(a,t),a}catch(e){if(null==i?void 0:i.rethrow)throw e;return t&&console.error("Failed to gzip compress data",e),null}var s}),dn.apply(this,arguments)}function hn(e,t){if(null==e)return{};var i,s,n=function(e,t){if(null==e)return{};var i={};for(var s in e)if({}.hasOwnProperty.call(e,s)){if(t.includes(s))continue;i[s]=e[s]}return i}(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(s=0;r.length>s;s++)t.includes(i=r[s])||{}.propertyIsEnumerable.call(e,i)&&(n[i]=e[i])}return n}const _n="[redacted]",pn=/^[A-Za-z0-9+/\n\r]+=*$/,gn=/^[A-Za-z0-9_-]+={0,2}$/,fn=/[-_]/,vn=/^data:[^,\s]*;base64,/i,mn=/^[A-Za-z0-9+/_-]+={0,2}$/,yn=/\bph[a-z]_[A-Za-z0-9_-]{20,}\b/g,bn=/^(authorization|cookie|set-cookie|x-api-key|api[-_]?key|api[-_]?token|access[-_]?token|refresh[-_]?token|token|password|secret|client[-_]?secret|private[-_]?key)$/i,wn=/[a-z][a-z0-9+.-]{0,63}:[^\s<>"]+/gi,Sn=/[\s<>"]/,Cn=(()=>new RegExp(wn.source,"i"))(),kn=/[a-z][a-z0-9+.-]{0,63}:\/\//i,En=(()=>new RegExp(`^${kn.source}`,"i"))(),xn=(()=>new RegExp(kn.source,"gi"))(),Pn=/(^|[-_./;])(auth|token|secret|password|passwd|pwd|credential|signature|sig|key|hmac|sas|bearer|jwt|session|sessionid)([-_./;]|$)/i,In=/^(code|AWSAccessKeyId|GoogleAccessId|Policy)$/i,Fn=/[\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]/g,Tn=/[A-Za-z0-9._%+-]{1,64}@[A-Za-z0-9.-]{1,255}\.[A-Za-z]{2,24}/g,Rn=/\b(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\b/g,An=/(^|[^\w:])((?:(?:[0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4}|(?:[0-9A-Fa-f]{1,4}:){1,7}:|(?:[0-9A-Fa-f]{1,4}:){1,6}:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4}){0,5}|::(?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4}){0,6})))(?=$|[^\w:])/g,$n=/\b\d{3}[ .-]\d{2}[ .-]\d{4}\b/g,Mn=/\b\d(?:[ ./-]?\d){12,}\b/g,Ln=/\d+/g,On=/(^|[^\w+])((?:\+?1[ ./-]?)?(?:\(\d{3}\)[ ./-]?|\d{3}[ ./-])\d{3}[ ./-]\d{4})(?![\w])/g,Dn=/(^|[^\w])(\+\d{1,3}(?:[ ./()-]{0,2}\d){7,13})(?![\w])/g;function Nn(e){return function(e){return bn.test(e)}(e)||Pn.test(e)||In.test(e)}function Bn(e){return e.split("&",129).length>128}function zn(e,t,i){return Nn(e)||t.includes(";")&&function(e){return e.split(";").some(e=>Nn(e.split("=",1)[0]))}(t)?_n:Cn.test(t)?i?Vn(t,{allowNestedUrls:!1,stripPunctuation:!0}):_n:t}function Hn(e,t){const i=new URLSearchParams;let s=!1,n=!1;for(const[r,o]of new URLSearchParams(e)){const e=Gn(r),a=Gn(o);s||(s=e!==r||a!==o);const l=zn(e,a,t);s||(s=l!==a),n=Nn(e)||l!==a,i.append(e,l)}return{changed:s,lastFieldSensitive:n,serialized:i.toString()}}function Un(e,t){if(!e.includes("="))return{value:qn(e,t),lastFieldSensitive:!1};const i=Hn(e,t);return{value:i.changed?i.serialized:e,lastFieldSensitive:i.lastFieldSensitive}}function qn(e,t){return t?Vn(e,{allowNestedUrls:!1,stripPunctuation:!0}):Cn.test(e)?_n:e}function jn(e,t,i){return"#"===e?!t.fragment&&(t.fragment=!0):"?"===e&&(t.fragment?"="!==i&&!t.fragmentQuery&&(t.fragmentQuery=!0):!t.query&&(t.query=!0))}function Wn(e,t){var i;if(e.length>8192&&En.test(e))return _n;const{address:s,suffix:n}=t.stripPunctuation?function(e){let t=e.length;for(;t>0&&".,;:!?)]}'".includes(e[t-1]);)t--;return{address:e.slice(0,t),suffix:e.slice(t)}}(e):{address:e,suffix:""};let r;try{r=new URL(s)}catch(e){return _n+n}const o=r.search.slice(1),a=""!==r.hash,l=function(e){const t=e.slice(1),i=t.indexOf("?");return 0>i?{head:t,tail:null}:{head:t.slice(0,i),tail:t.slice(i+1)}}(r.hash);if(Bn(o)||Bn(l.head)||Bn(null!==(i=l.tail)&&void 0!==i?i:""))return _n+n;let c=!1;(r.username||r.password)&&(r.username=_n,r.password="",c=!0);const u=Hn(o,t.allowNestedUrls);u.changed&&(r.search=u.serialized,c=!0);const d=Un(l.head,t.allowNestedUrls),h=null===l.tail?null:(_=l.tail,d.lastFieldSensitive?{value:""===_?"":_n,lastFieldSensitive:!0}:Un(_,t.allowNestedUrls));var _;const p=null===h?d.value:`${d.value}?${h.value}`;p!==r.hash.slice(1)&&(r.hash=p,c=!0);const g=a?null!=h?h:d:u;return(c?Gn(r.toString()):s)+(g.lastFieldSensitive?"":n)}function Vn(e,t){return e.replace(wn,i=>function(e,t){const i=function(e){if(!e.includes("://"))return[];const t=[...e.matchAll(xn)].map(e=>e.index),i=[],s={query:!1,fragment:!1,fragmentQuery:!1};let n=0,r=!1,o="";for(let a=0;e.length>a&&t.length>n;a++){t[n]===a&&(a>0&&"="!==o&&i.push(a),n++);const l=e[a];jn(l,s,o)?(o=l,r=!0):r&&"=&".includes(l)&&(o=l)}return i}(e);if(0===i.length)return Wn(e,t);let s="",n=0;for(const r of i)s+=Wn(e.slice(n,r),as(as({},t),{},{stripPunctuation:!1})),n=r;return s+Wn(e.slice(n),t)}(i,as(as({},t),{},{stripPunctuation:t.stripPunctuation&&i.length!==e.length})))}function Gn(e){return e.replace(yn,_n)}function Kn(e,t){return function(e){return e.length>=10240&&(pn.test(e)||function(e){const t=vn.exec(e);if(!t)return!1;let i;try{i=decodeURIComponent(e.slice(t[0].length))}catch(e){return!1}return mn.test(i.replace(/[\r\n]/g,""))}(e)||fn.test(e)&&gn.test(e))}(e)?"[binary data redacted - not supported by PostHog MCP analytics]":function(e,t,i){const s=4*i.maxStringLength;if(e.length>s){const n=t(e.slice(0,function(e,t){let i=t;for(;i>0&&!Sn.test(e[i-1]);)i--;return i}(e,s)));if(n.length>=2*i.maxStringLength)return n+i.truncationSuffix}return t(e)}(e,e=>function(e){return Vn(e,{allowNestedUrls:!0,stripPunctuation:!0})}(function(e){let t=e.replace(Fn," ");return t=t.replace(Tn,_n),t=t.replace(Rn,_n),t=t.replace(An,`$1${_n}`),t=t.replace(Mn,Jn),t=t.replace($n,_n),t=t.replace(On,`$1${_n}`),t=t.replace(Dn,`$1${_n}`),t}(Gn(e))),t)}function Qn(e){let t=0,i=!1;for(let s=e.length-1;s>=0;s--){let n=e.charCodeAt(s)-48;if(0>n||n>9)return!1;i&&(n*=2,n>9&&(n-=9)),t+=n,i=!i}return t%10==0}function Jn(e){const t=[];for(let i=Ln.exec(e);null!==i;i=Ln.exec(e))t.push({digits:i[0],start:i.index,end:i.index+i[0].length});let i="",s=0,n=0;for(;t.length>n;){let r="",o=-1;for(let e=n;t.length>e&&(r+=t[e].digits,19>=r.length);e++)r.length>=13&&Qn(r)&&(o=e);0>o?n++:(i+=e.slice(s,t[n].start)+_n,s=t[o].end,n=o+1)}return i+e.slice(s)}const Yn={}.propertyIsEnumerable;function Xn(e,t){try{return tr(e,t,{ancestors:new WeakSet,remainingNodes:1e4},0)}catch(e){return[]}}function Zn(e,t,i,s){if(0>=i.remainingNodes)return{stringValue:ji};if(i.remainingNodes--,kt(e))return{boolValue:e};if("bigint"==typeof e)return function(e,t){const i=e.toString(),s=BigInt("9223372036854775808");return e>=s||-s>e?(null==t||t.debug(`Attribute ${i} is outside the int64 range; encoding it as a string`),{stringValue:i}):{intValue:i}}(e,t);if("number"==typeof e){if(!Number.isFinite(e))return{stringValue:String(e)};if(Number.isInteger(e)){if(Number.isSafeInteger(e))return{intValue:String(e)};if(typeof BigInt>"u")return{stringValue:String(e)};const i=BigInt(e).toString();return e>=0x8000000000000000||-0x8000000000000000>e?(null==t||t.debug(`Attribute ${i} is outside the int64 range; encoding it as a string`),{stringValue:i}):{intValue:i}}return{doubleValue:e}}if("string"==typeof e)return{stringValue:Vi(e)};if("function"==typeof e)return{stringValue:"[Function]"};if("symbol"==typeof e)return{stringValue:String(e)};if("object"==typeof e&&null!==e){if(i.ancestors.has(e))return{stringValue:"[Circular]"};if(s>=20)return{stringValue:ji};if(e instanceof Date){const t=e.getTime(),i=Number.isFinite(t)?e.toISOString():String(e);return{stringValue:"string"==typeof i?Vi(i):String(i)}}i.ancestors.add(e);try{try{const n=e.toJSON;if("function"==typeof n)return Zn(n.call(e),t,i,s+1)}catch(e){}return _t(e)?{arrayValue:{values:er(e,t,i,s+1)}}:{kvlistValue:{values:tr(e,t,i,s+1)}}}finally{i.ancestors.delete(e)}}return{stringValue:Vi(String(e))}}function er(e,t,i,s){const n=[],r=Math.min(e.length,1e3);let o=0;for(;r>o&&i.remainingNodes>0;o++)try{const r=o in e?e[o]:void 0;if(wt(r))continue;n.push(Zn(r,t,i,s))}catch(e){n.push({stringValue:Wi})}return e.length>o&&n.push({stringValue:ji}),n}function tr(e,t,i,s){const n=[];for(const r in e)if(Yn.call(e,r)){if(!r){null==t||t.debug("Dropping an attribute with an empty key");continue}if(n.length>=1e3||0>=i.remainingNodes){null==t||t.debug("Attributes truncated: the value exceeds the OTLP encoder budget");break}try{const o=e[r];if(bt(o)||vt(o))continue;n.push({key:Vi(r),value:Zn(o,t,i,s)})}catch(e){n.push({key:Vi(r),value:{stringValue:Wi}})}}return n}function ir(e,t,i){return as(as(as(as({},Gi({},e.resourceAttributes)),{},{"service.name":e.serviceName||"unknown_service"},e.environment&&{"deployment.environment":e.environment}),e.serviceVersion&&{"service.version":e.serviceVersion}),{},{"telemetry.sdk.name":t,"telemetry.sdk.version":i})}const sr=["service.name","deployment.environment","service.version","telemetry.sdk.name","telemetry.sdk.version"];function nr(e,t){const i=Gi({},e),s={};for(const e of sr)({}).hasOwnProperty.call(i,e)&&(s[e]=i[e],delete i[e]);return[...Xn(i,t),...Xn(s,t)]}const rr={darwin:"macOS",win32:"Windows",cygwin:"Windows",linux:"Linux",android:"Android",freebsd:"FreeBSD",openbsd:"OpenBSD",netbsd:"NetBSD",sunos:"SunOS",aix:"AIX",haiku:"Haiku","Mac OS X":"macOS"};const or={text:"INFO",number:9},ar={trace:{text:"TRACE",number:1},debug:{text:"DEBUG",number:5},info:or,warn:{text:"WARN",number:13},error:{text:"ERROR",number:17},fatal:{text:"FATAL",number:21}};function lr(e){try{return Vi(String(e))}catch(e){return Wi}}function cr(e,t,i,s){const n=e.level||"info",{text:r,number:o}=ar[n]||or,a=function(e=Date.now()){return String(e)+"000000"}(St(s)?s:void 0),l={};t.distinctId&&(l.posthogDistinctId=t.distinctId),t.sessionId&&(l.sessionId=t.sessionId),t.windowId&&(l["window.id"]=t.windowId),wt(t.sessionStartTimestamp)||(l.sessionStartTimestamp=String(t.sessionStartTimestamp)),wt(t.lastActivityTimestamp)||(l.lastActivityTimestamp=String(t.lastActivityTimestamp)),t.currentUrl&&(l["url.full"]=t.currentUrl),t.screenName&&(l["screen.name"]=t.screenName),t.appState&&(l["app.state"]=t.appState),t.activeFeatureFlags&&t.activeFeatureFlags.length>0&&(l.feature_flags=t.activeFeatureFlags);const c=as({},l),u=e.attributes;if(u){let e=[];try{e=Object.keys(u)}catch(t){e=[]}for(const t of e){let e;try{e=u[t]}catch(t){e=Wi}Object.defineProperty(c,t,{value:e,enumerable:!0,writable:!0,configurable:!0})}}const d={timeUnixNano:a,observedTimeUnixNano:a,severityNumber:o,severityText:r,body:{stringValue:lr(e.body)},attributes:Xn(c,i)};return e.trace_id&&(d.traceId=e.trace_id),e.span_id&&(d.spanId=e.span_id),vt(e.trace_flags)||(d.flags=e.trace_flags),d}function ur(e,t,i){return ir(e,t,i)}function dr(e,t,i,s){return{resourceLogs:[{resource:{attributes:nr(t)},scopeLogs:[{scope:{name:i,version:s},logRecords:e}]}]}}var hr=class{constructor(e){this._onFire=e,this._firesAt=0}get pending(){return!!this._timer}arm(e){this.clear(),this._firesAt=Date.now()+e,this._timer=ts(()=>{this._timer=void 0,this._onFire()},e)}armNoEarlierThan(e){this._timer&&Date.now()+e<=this._firesAt||this.arm(e)}clear(){this._timer&&(clearTimeout(this._timer),this._timer=void 0)}};function _r(){return.75+.5*Math.random()}function pr(e,t,i,s){const n=Math.min(Math.max(0,t-1),6),r=e*Math.pow(2,n);return Math.round((void 0===s?r:Math.min(r,Math.max(s,e)))*i)}var gr=class{constructor(e,t,i,s,n,r=()=>Promise.resolve(),o){var a;this._instance=e,this._config=t,this._logger=i,this._getContext=s,this._onReady=n,this._waitForStoragePersist=r,this._scopeName=o,this._flushTimer=new hr(()=>this._flushInBackground()),this._flushPromise=null,this._evictedSinceAdvance=0,this._queueGeneration=0,this._retryAfter=new Qi,this._consecutiveFlushFailures=0,this._flushJitter=1,this._intervalWindowStart=0,this._intervalLogCount=0,this._droppedWarned=!1,this._maxBufferSize=t.maxBufferSize,this._maxQueueSize=Math.max(null!==(a=t.maxQueueSize)&&void 0!==a?a:t.maxBufferSize,t.maxBufferSize),this._flushIntervalMs=t.flushIntervalMs,this._maxBatchRecordsPerPost=t.maxBatchRecordsPerPost,this._rateCapWindowMs=t.rateCapWindowMs,this._maxLogsPerInterval=t.maxLogsPerInterval}clearQueue(){this._queueGeneration++,this._instance.setPersistedProperty(it.LogsQueue,[])}reset(){this._flushTimer.clear(),this._intervalWindowStart=0,this._intervalLogCount=0,this._droppedWarned=!1,this._consecutiveFlushFailures=0,this._flushJitter=1,this._retryAfter.reset(),this._maxBatchRecordsPerPost=this._config.maxBatchRecordsPerPost}onReconnect(){this._consecutiveFlushFailures=0,this._flushJitter=1,this._retryAfter.isOpen()?this._hasQueuedRecords()&&this._armFlushTimer():this._flushInBackground()}captureLog(e,t){var i;if(this._instance.isDisabled)return;if(this._instance.optedOut)return;if(!(null==e?void 0:e.body))return;const s=this._runBeforeSend(e);if(null===s)return;if(!s.body)return void this._logger.info("Log was rejected in beforeSend function");if(!this._checkRateLimit())return;const n={record:cr(s,null!==(i=null==t?void 0:t.context)&&void 0!==i?i:this._getContext(),this._logger,null==t?void 0:t.occurredAtMs)};this._onReady(()=>this._enqueue(n))}_runBeforeSend(e){const t=this._config.beforeSend;if(!t)return e;const i=_t(t)?t:[t];let s=e;for(const e of i)try{const t=e(s);if(!t)return this._logger.info("Log was rejected in beforeSend function"),null;s=t}catch(e){return this._logger.error("Error in beforeSend function for log:",e),null}return s}_checkRateLimit(){if(void 0===this._maxLogsPerInterval)return!0;const e=Date.now(),t=e-this._intervalWindowStart;return this._rateCapWindowMs>t&&t>=0||(this._intervalWindowStart=e,this._intervalLogCount=0,this._droppedWarned=!1),this._maxLogsPerInterval>this._intervalLogCount?(this._intervalLogCount++,!0):(this._droppedWarned||(this._logger.warn(`captureLog dropping logs: exceeded ${this._maxLogsPerInterval} logs per ${this._rateCapWindowMs}ms`),this._droppedWarned=!0),!1)}flush(){var e=this;return Ot(function*(){if(!e._instance.isDisabled)return e._flushPromise||(e._flushPromise=e._flushInner().finally(()=>{e._flushPromise=null})),e._flushPromise})()}_flushInner(){var e=this;return Ot(function*(){var t;e._flushTimer.clear();let i=null!==(t=e._instance.getPersistedProperty(it.LogsQueue))&&void 0!==t?t:[];if(0===i.length)return;const s=i.length;let n=0;for(;i.length>0&&s>n;){var r,o;const t=e._queueGeneration;e._evictedSinceAdvance=0;const s=Math.min(i.length,e._maxBatchRecordsPerPost),a=i.slice(0,s),l=dr(a.map(e=>e.record),e._buildResourceAttributes(),null!==(r=e._scopeName)&&void 0!==r?r:e._instance.getLibraryId(),e._instance.getLibraryVersion()),c=yield e._instance._sendLogsBatch(l);if(e._queueGeneration!==t)return;if("too-large"===c.kind&&a.length>1)e._maxBatchRecordsPerPost=Math.max(1,Math.floor(a.length/2)),e._logger.warn(`Logs batch of size ${a.length} was too large for the ingestion endpoint, reducing batch size to ${e._maxBatchRecordsPerPost}`);else{if(e._retryAfter.record(c),e._flushTimer.pending&&e._flushTimer.arm(Math.max(e._flushIntervalMs,e._retryAfter.remainingMs())),"retry-later"===c.kind)throw c.error;if("too-large"===c.kind?e._logger.warn("Dropping a single log record with batch size 1 — the record is larger than the server cap and cannot be split further."):"ok"===c.kind&&e._config.maxBatchRecordsPerPost>e._maxBatchRecordsPerPost&&(e._maxBatchRecordsPerPost=Math.min(e._config.maxBatchRecordsPerPost,e._maxBatchRecordsPerPost+1)),yield e._persistQueueAdvance(a.length),i=null!==(o=e._instance.getPersistedProperty(it.LogsQueue))&&void 0!==o?o:[],n+=a.length,"fatal"===c.kind)throw c.error}}})()}_persistQueueAdvance(e){var t=this;return Ot(function*(){var i;const s=Math.max(0,e-t._evictedSinceAdvance),n=null!==(i=t._instance.getPersistedProperty(it.LogsQueue))&&void 0!==i?i:[];t._instance.setPersistedProperty(it.LogsQueue,n.slice(s)),yield t._waitForStoragePersist()})()}_buildResourceAttributes(){return ur(this._config,this._instance.getLibraryId(),this._instance.getLibraryVersion())}_enqueue(e){var t;if(this._instance.optedOut)return;const i=null!==(t=this._instance.getPersistedProperty(it.LogsQueue))&&void 0!==t?t:[];this._maxQueueSize>i.length||(i.shift(),this._evictedSinceAdvance++,this._logger.info("Logs queue is full, dropping oldest record.")),i.push(e),this._instance.setPersistedProperty(it.LogsQueue,i),this._maxBufferSize>i.length||this._retryAfter.isOpen()?this._armFlushTimer():this._flushInBackground()}_armFlushTimer(){this._flushTimer.pending||this._flushTimer.arm(Math.max(this._flushIntervalMs,this._retryAfter.remainingMs()))}_nextFlushDelay(){return Math.max(pr(this._flushIntervalMs,this._consecutiveFlushFailures,this._flushJitter,3e4),this._retryAfter.remainingMs())}_hasQueuedRecords(){const e=this._instance.getPersistedProperty(it.LogsQueue);return!!e&&e.length>0}shutdown(e){var t=this;return Ot(function*(){t._flushTimer.clear();const i=t.flush().catch(()=>{});void 0!==e?yield is(i,e):yield i})()}flushWithTimeout(e){var t=this;return Ot(function*(){const i=t.flush();yield is(i,e,()=>{i.catch(()=>{})})})()}_flushInBackground(){this.flush().then(()=>{this._consecutiveFlushFailures=0,this._flushJitter=1},e=>{this._consecutiveFlushFailures++,this._flushJitter=_r(),this._logger.error("PostHog logs flush failed:",e)}).finally(()=>{!this._instance.isDisabled&&this._hasQueuedRecords()&&this._flushTimer.armNoEarlierThan(this._nextFlushDelay())})}};const fr=/^[0-9a-f]+$/;function vr(e,t,i){return"string"==typeof e&&e.length===t&&e!==i&&fr.test(e)}const mr=/^([0-9a-f]{2})-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})(-.*)?$/;const yr="00",br=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function wr(e){return String(e)+"000000"}function Sr(e,t,i,s){let n="";return s&&(n=Object.keys(s).sort().map(e=>`${JSON.stringify(e)}:${JSON.stringify(s[e])}`).join(",")),`${e}\0${t}\0${null!=i?i:""}\0${n}`}var Cr=class{constructor(e,t,i){this._instance=e,this._config=t,this._logger=i,this._series=new Map,this._flushTimer=new hr(()=>this.flush().catch(e=>{this._logger.error("Metrics flush failed:",e)})),this._flushPromise=null,this._seriesCapWarned=!1,this._typeByName=new Map,this._typeCollisionWarned=new Set,this._boundsByHistogram=new Map,this._boundsConflictWarned=new Set,this._boundsCapWarned=!1,this._retryAfter=new Qi,this._consecutiveFlushFailures=0,this._flushJitter=1,this._generation=0}count(e,t=1,i){this._capture({name:e,type:"count",value:t,unit:null==i?void 0:i.unit,attributes:null==i?void 0:i.attributes})}gauge(e,t,i){this._capture({name:e,type:"gauge",value:t,unit:null==i?void 0:i.unit,attributes:null==i?void 0:i.attributes})}histogram(e,t,i){this._capture({name:e,type:"histogram",value:t,unit:null==i?void 0:i.unit,attributes:null==i?void 0:i.attributes,bounds:_t(null==i?void 0:i.bounds)?i.bounds.slice():null==i?void 0:i.bounds})}flush(){var e=this;const t=this._flushPromise,i=function(){var i=Ot(function*(){t&&(yield t.catch(()=>{})),yield e._doFlush()});return function(){return i.apply(this,arguments)}}()().finally(()=>{this._flushPromise===i&&(this._flushPromise=null)});return this._flushPromise=i,i}drainWindow(){if(0===this._series.size)return null;const e=this._series;return this._startWindow(),this._buildPayload(e)}reset(){this._generation++,this._retryAfter.reset(),this._consecutiveFlushFailures=0,this._flushJitter=1,this._flushTimer.clear(),this._flushPromise=null,this._startWindow(),this._boundsByHistogram=new Map,this._boundsCapWarned=!1}_startWindow(){this._series=new Map,this._seriesCapWarned=!1,this._typeByName=new Map,this._typeCollisionWarned=new Set,this._boundsConflictWarned=new Set}_capture(e){if(this._instance.isDisabled||this._instance.optedOut)return;const t=this._runBeforeSend(e);if(null===t)return;if(!t.name||"string"!=typeof t.name)return void this._logger.warn("Dropping metric with empty name");if("number"!=typeof t.value||!Number.isFinite(t.value))return void this._logger.warn(`Dropping metric '${t.name}': value must be a finite number`);if("count"!==t.type&&"gauge"!==t.type&&"histogram"!==t.type)return void this._logger.warn(`Dropping metric '${t.name}': unknown type '${String(t.type)}'`);if("count"===t.type&&0>t.value)return void this._logger.warn(`Dropping count '${t.name}': counters are monotonic, value must be >= 0`);let i,s;try{i=t.attributes?as({},t.attributes):void 0,s=Sr(t.type,t.name,t.unit,i)}catch(e){return void this._logger.warn(`Dropping metric '${t.name}': attributes could not be serialized`,e)}let n,r=this._series.get(s);if(!r&&!this._admitNewSeries())return;if("histogram"===t.type&&(n=this._histogramBounds(t.name,t.unit,t.bounds),!n))return;r||(r={name:t.name,type:t.type,unit:t.unit,attributes:i,windowStartMs:Date.now(),hist:n&&Er(n)},this._series.set(s,r));const o=this._typeByName.get(t.name);void 0===o?this._typeByName.set(t.name,t.type):o===t.type||this._typeCollisionWarned.has(t.name)||(this._typeCollisionWarned.add(t.name),this._logger.warn(`Metric name '${t.name}' is already used as a ${o}; recording it as a ${t.type} too will blend both series in charts. Use a distinct name.`)),this._fold(r,t.value);const a=this._activeTraceContext();a&&(r.exemplar=as(as({},a),{},{value:t.value,timeMs:Date.now()})),this._armFlushTimer()}_activeTraceContext(){try{var e,t;const i=function(e){const t=function(e){if("string"!=typeof e)return;const t=mr.exec(e.trim());if(!t)return;const[,i,s,n,r,o]=t;return"ff"===i||"00"===i&&o||!function(e){return vr(e,32,"00000000000000000000000000000000")}(s)||!function(e){return vr(e,16,"0000000000000000")}(n)?void 0:{version:i,traceId:s,spanId:n,flags:r}}(e);return t&&{traceId:t.traceId,spanId:t.spanId,flags:(i=t.flags,1&parseInt(i,16)?"01":yr)};var i}(null===(e=(t=this._instance).getActiveSpan)||void 0===e||null===(e=e.call(t))||void 0===e?void 0:e.traceparent());if(i&&"01"===i.flags)return{traceId:i.traceId,spanId:i.spanId}}catch(e){}}_admitNewSeries(){return this._config.maxSeriesPerFlush>this._series.size||(this._seriesCapWarned||(this._seriesCapWarned=!0,this._logger.warn(`Metric series cap reached (${this._config.maxSeriesPerFlush} per flush window); dropping new series until the next flush. Reduce attribute cardinality.`)),!1)}_histogramBounds(e,t,i){if(void 0!==i&&!function(e){if(!_t(e)||0===e.length)return!1;for(let t=0;e.length>t;t++)if(!Number.isFinite(e[t])||t>0&&e[t-1]>=e[t])return!1;return!0}(i))return void this._logger.warn(`Dropping histogram '${e}': bounds must be a non-empty array of finite, strictly increasing numbers`);const s=Sr("histogram",e,t,void 0),n=this._boundsByHistogram.get(s);if(n)return this._warnOnBoundsConflict(e,s,n,i),n;if(this._boundsByHistogram.size>=this._config.maxSeriesPerFlush){if(this._boundsCapWarned||(this._boundsCapWarned=!0,this._logger.warn(`Histogram bounds limit reached (${this._config.maxSeriesPerFlush} distinct histograms); new histograms that pass custom bounds are dropped. Reduce histogram name cardinality.`)),i&&!kr(i,br))return;return br}const r=i?i.slice():br;return this._boundsByHistogram.set(s,r),r}_warnOnBoundsConflict(e,t,i,s){kr(i,null!=s?s:br)||this._boundsConflictWarned.has(t)||(this._boundsConflictWarned.add(t),this._logger.warn(`Histogram '${e}' already uses the bounds [${i.join(", ")}]; samples that pass different bounds are recorded in those buckets.`))}_fold(e,t){switch(e.type){case"count":var i;e.total=(null!==(i=e.total)&&void 0!==i?i:0)+t;break;case"gauge":e.last=t;break;case"histogram":{const i=e.hist;i.count+=1,i.sum+=t,i.min=Math.min(i.min,t),i.max=Math.max(i.max,t),i.bucketCounts[function(e,t){for(let i=0;t.length>i;i++)if(t[i]>=e)return i;return t.length}(t,i.bounds)]+=1;break}}}_runBeforeSend(e){const t=this._config.beforeSend;if(!t)return e;const i=_t(t)?t:[t];let s=e;for(const e of i)try{const t=e(s);if(!t)return this._logger.info("Metric was rejected in beforeSend function"),null;s=t}catch(e){return this._logger.error("Error in beforeSend function for metric:",e),null}return s}_armFlushTimer(){this._flushTimer.pending||this._flushTimer.arm(this._nextFlushDelay())}_nextFlushDelay(){return Math.max(pr(this._config.flushIntervalMs,this._consecutiveFlushFailures,this._flushJitter,3e4),this._retryAfter.remainingMs())}_doFlush(){var e=this;return Ot(function*(){if(e._flushTimer.clear(),0===e._series.size)return;const t=e._series;e._startWindow();const i=e._generation,s=yield e._instance._sendMetricsBatch(e._buildPayload(t));if(i===e._generation)switch(e._retryAfter.record(s),"retry-later"===s.kind?(e._consecutiveFlushFailures++,e._flushJitter=_r()):(e._consecutiveFlushFailures=0,e._flushJitter=1),e._flushTimer.pending&&e._flushTimer.arm(e._nextFlushDelay()),s.kind){case"ok":return;case"retry-later":return e._mergeWindowBack(t),void e._flushTimer.armNoEarlierThan(e._nextFlushDelay());case"too-large":return void e._logger.warn("Metrics batch exceeded the server size limit and was dropped");case"fatal":return void e._logger.error("Failed to send metrics batch:",s.error)}})()}_buildPayload(e){return t=this._buildMetrics(e),i=function(e,t,i){return ir(e,t,i)}(this._config,this._instance.getLibraryId(),this._instance.getLibraryVersion()),s=this._instance.getLibraryId(),n=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:nr(i)},scopeMetrics:[{scope:{name:s,version:n},metrics:t}]}]};var t,i,s,n}_buildMetrics(e){const t=wr(Date.now()),i=new Map;for(const o of e.values()){var s;const e=Sr(o.type,o.name,o.unit,void 0);let a=i.get(e);a||(a=as({name:o.name},o.unit&&{unit:o.unit}),"count"===o.type?a.sum={aggregationTemporality:1,isMonotonic:!0,dataPoints:[]}:"gauge"===o.type?a.gauge={dataPoints:[]}:a.histogram={aggregationTemporality:1,dataPoints:[]},i.set(e,a));const l=Xn(null!==(s=o.attributes)&&void 0!==s?s:{},this._logger),c=wr(o.windowStartMs),u=xr(o.exemplar);if("count"===o.type){var n;const e=as({attributes:l,startTimeUnixNano:c,timeUnixNano:t,asDouble:null!==(n=o.total)&&void 0!==n?n:0},u);a.sum.dataPoints.push(e)}else if("gauge"===o.type){var r;const e=as({attributes:l,timeUnixNano:t,asDouble:null!==(r=o.last)&&void 0!==r?r:0},u);a.gauge.dataPoints.push(e)}else{const e=o.hist,i=as({attributes:l,startTimeUnixNano:c,timeUnixNano:t,count:e.count,sum:e.sum,min:e.min,max:e.max,bucketCounts:e.bucketCounts,explicitBounds:e.bounds},u);a.histogram.dataPoints.push(i)}}return Array.from(i.values())}_mergeWindowBack(e){for(const[n,r]of e){var t;const e=this._series.get(n);if(e)switch(e.windowStartMs=Math.min(e.windowStartMs,r.windowStartMs),e.exemplar=null!==(t=e.exemplar)&&void 0!==t?t:r.exemplar,e.type){case"count":var i,s;e.total=(null!==(i=e.total)&&void 0!==i?i:0)+(null!==(s=r.total)&&void 0!==s?s:0);break;case"gauge":break;case"histogram":{const t=e.hist,i=r.hist;t.count+=i.count,t.sum+=i.sum,t.min=Math.min(t.min,i.min),t.max=Math.max(t.max,i.max);for(let e=0;t.bucketCounts.length>e;e++)t.bucketCounts[e]+=i.bucketCounts[e];break}}else this._admitNewSeries()&&this._series.set(n,r)}}};function kr(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let i=0;e.length>i;i++)if(e[i]!==t[i])return!1;return!0}function Er(e){return{bounds:e,count:0,sum:0,min:1/0,max:-1/0,bucketCounts:new Array(e.length+1).fill(0)}}function xr(e){return e?{exemplars:[{filteredAttributes:[],timeUnixNano:wr(e.timeMs),asDouble:e.value,traceId:e.traceId,spanId:e.spanId}]}:{}}const Pr=(e,{debugEnabled:i}={})=>{const s={_log(s,...n){let r;try{r=typeof window>"u"?void 0:window}catch(e){return}r&&(t.DEBUG||r.POSTHOG_DEBUG||i)&&!vt(r.console)&&r.console&&("__rrweb_original__"in r.console[s]?r.console[s].__rrweb_original__:r.console[s])(e,...n)},debug(...e){s._log("debug",...e)},info(...e){s._log("log",...e)},warn(...e){s._log("warn",...e)},error(...e){s._log("error",...e)},critical(...t){console.error(e,...t)},uninitializedWarning(e){s.error(`You must initialize PostHog before calling ${e}`)},createLogger:(t,i)=>Pr(`${e} ${t}`,i)};return s},Ir=Pr("[PostHog.js]"),Fr=(e,t)=>Ir.createLogger(e,t);function Tr(e,t){_t(e)&&e.forEach(t)}function Rr(e,t){if(!wt(e))if(_t(e))e.forEach(t);else if((e=>e instanceof FormData)(e))e.forEach((e,i)=>t(e,i));else for(const i in e)dt.call(e,i)&&t(e[i],i)}const Ar=function(e,...t){for(const i of t)for(const t in i)void 0!==i[t]&&(e[t]=i[t]);return e};function $r(e){const t=Object.keys(e);let i=t.length;const s=new Array(i);for(;i--;)s[i]=[t[i],e[t[i]]];return s}const Mr=function(e){return function(...t){try{return e.apply(this,t)}catch(e){Ir.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),Ir.critical(e)}}},Lr=function(e){const t={};return Rr(e,function(e,i){(mt(e)&&e.length>0||St(e))&&(t[i]=e)}),t};function Or(e){const t=as({},e);for(const i of["name","message","stack","cause","errors"])try{i in e&&(t[i]=e[i])}catch(e){}return t}const Dr=["herokuapp.com","vercel.app","netlify.app"];function Nr(e){const t=null==e?void 0:e.hostname;if(!mt(t))return!1;const i=t.split(".").slice(-2).join(".");for(const e of Dr)if(i===e)return!1;return!0}function Br(e,t,i,s){const{capture:n=!1,passive:r=!0}=null!=s?s:{};null==e||e.addEventListener(t,i,{capture:n,passive:r})}function zr(e){return"ph_toolbar_internal"===e.name}const Hr=e=>{if(Ge){try{const t=e+"=",i=Ge.cookie.split(";").filter(e=>e.length);for(let e=0;i.length>e;e++){let s=i[e];for(;" "==s.charAt(0);)s=s.substring(1,s.length);if(0===s.indexOf(t))return decodeURIComponent(s.substring(t.length,s.length))}}catch(e){}return null}};var Ur=class e{constructor(e){if(this.bytes=e,16!==e.length)throw new TypeError("not 128-bit length")}static fromFieldsV7(t,i,s,n){if(!Number.isInteger(t)||!Number.isInteger(i)||!Number.isInteger(s)||!Number.isInteger(n)||0>t||0>i||0>s||0>n||t>0xffffffffffff||i>4095||s>1073741823||n>4294967295)throw new RangeError("invalid field value");const r=new Uint8Array(16);return r[0]=t/Math.pow(2,40),r[1]=t/Math.pow(2,32),r[2]=t/Math.pow(2,24),r[3]=t/Math.pow(2,16),r[4]=t/256,r[5]=t,r[6]=112|i>>>8,r[7]=i,r[8]=128|s>>>24,r[9]=s>>>16,r[10]=s>>>8,r[11]=s,r[12]=n>>>24,r[13]=n>>>16,r[14]=n>>>8,r[15]=n,new e(r)}toString(){let e="";for(let t=0;this.bytes.length>t;t++)e=e+(this.bytes[t]>>>4).toString(16)+(15&this.bytes[t]).toString(16),3!==t&&5!==t&&7!==t&&9!==t||(e+="-");if(36!==e.length)throw new Error("Invalid UUIDv7 was generated");return e}clone(){return new e(this.bytes.slice(0))}equals(e){return 0===this.compareTo(e)}compareTo(e){for(let t=0;16>t;t++){const i=this.bytes[t]-e.bytes[t];if(0!==i)return Math.sign(i)}return 0}},qr=class{generate(){const e=this.generateOrAbort();if(!vt(e))return e;{this._timestamp=0;const e=this.generateOrAbort();if(vt(e))throw new Error("Could not generate UUID after timestamp reset");return e}}generateOrAbort(){const e=(()=>{const e=Date.now();return St(e)&&isFinite(e)?Math.min(Math.max(Math.floor(e),0),0xffffffffffff):0})();if(e>this._timestamp)this._timestamp=e,this._resetCounter();else{if(this._timestamp>=e+1e4)return;this._counter++,this._counter>4398046511103&&(this._timestamp++,this._resetCounter())}return Ur.fromFieldsV7(this._timestamp,Math.trunc(this._counter/Math.pow(2,30)),this._counter&Math.pow(2,30)-1,this._random.nextUint32())}_resetCounter(){this._counter=1024*this._random.nextUint32()+(1023&this._random.nextUint32())}constructor(){this._timestamp=0,this._counter=0,this._random=new Vr}};const jr=e=>{if("u">typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(let t=0;e.length>t;t++)e[t]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return e};let Wr;var Vr=class{nextUint32(){var e;return this._buffer.length>this._cursor||((null!==(e=Wr)&&void 0!==e?e:Wr="u">typeof window&&!vt(window.crypto)&&crypto.getRandomValues?e=>{try{return crypto.getRandomValues(e)}catch(t){return jr(e)}}:jr)(this._buffer),this._cursor=0),this._buffer[this._cursor++]}constructor(){this._buffer=new Uint32Array(8),this._cursor=1/0}};let Gr;const Kr=()=>Qr().toString(),Qr=()=>(Gr||(Gr=new qr)).generate();let Jr="";const Yr=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;let Xr=null;const Zr={_is_supported(){if(!bt(Xr))return Xr;if(Xr=!1,Ge)try{const e=`__ph_cookie_support_${Kr()}`;Zr._set(e,"xyz"),Xr='"xyz"'===Hr(e),Zr._remove(e)}catch(e){Xr=!1}return Xr},_error(e){Ir.error("cookieStore error: "+e)},_get:Hr,_parse(e){let t;try{t=JSON.parse(Zr._get(e))||{}}catch(e){}return t},_set(e,t,i,s,n){if(!Ge)return!1;try{let r="",o="";const a=function(e,t){if(t){let t=function(e,t=Ge){if(Jr)return Jr;if(!t)return"";if(["localhost","127.0.0.1"].includes(e))return"";const i=e.split(".");let s=Math.min(i.length,8);const n="dmn_chk_"+Kr();for(;!Jr&&s--;){const e=i.slice(s).join("."),r=n+"=1;domain=."+e+";path=/";t.cookie=r+";max-age=3",t.cookie.includes(n)&&(t.cookie=r+";max-age=0",Jr=e)}return Jr}(e);if(!t){const i=(e=>{const t=e.match(Yr);return t?t[0]:""})(e);i!==t&&Ir.info("Warning: cookie subdomain discovery mismatch",i,t),t=i}return t?"; domain=."+t:""}return""}(Ge.location.hostname,s);if(i){const e=new Date;e.setTime(e.getTime()+864e5*i),r="; expires="+e.toUTCString()}n&&(o="; secure");const l=e+"="+encodeURIComponent(JSON.stringify(t))+r+"; SameSite=Lax; path=/"+a+o;return l.length>3686.4&&Ir.warn("cookieStore warning: large cookie, len="+l.length),Ge.cookie=l,!0}catch(e){return!1}},_remove(e,t){if((null==Ge?void 0:Ge.cookie)&&(!t||!bt(Hr(e))))try{Zr._set(e,"",-1,t)}catch(e){return}}};let eo=null;const to={_is_supported(){if(!bt(eo))return eo;let e=!0;if(vt(je))e=!1;else try{const t="__mplssupport__";to._set(t,"xyz"),'"xyz"'!==to._get(t)&&(e=!1),to._remove(t)}catch(t){e=!1}return e||Ir.error("localStorage unsupported; falling back to cookie store"),eo=e,e},_error(e){Ir.error("localStorage error: "+e)},_get(e){try{return null==je?void 0:je.localStorage.getItem(e)}catch(e){to._error(e)}return null},_parse(e){try{return JSON.parse(to._get(e))||{}}catch(e){}return null},_set(e,t){try{return null==je||je.localStorage.setItem(e,JSON.stringify(t)),!0}catch(e){to._error(e)}return!1},_remove(e){try{null==je||je.localStorage.removeItem(e)}catch(e){to._error(e)}}},io=[h,n,u,r,g,l,a,o,_],so=[I,P,ee,te,we,be,M,ge],no=e=>e+"_cpm",ro=["__proto__","constructor","prototype"],oo=e=>{if(!gt(e))return{};const t={};return Object.keys(e).forEach(i=>{-1===ro.indexOf(i)&&(t[i]=e[i])}),t},ao=(e,t=[])=>{const i={};return[...so,...t].forEach(t=>{const s=e[t];vt(s)||bt(s)||""===s||(i[t]=s)}),i},lo=e=>{let t=5381,i=2166136261;for(let s=0;e.length>s;s++){const n=e.charCodeAt(s);t=33*t^n,i=Math.imul(i^n,16777619)}return e.length.toString(36)+"."+(t>>>0).toString(36)+"."+(i>>>0).toString(36)},co=(e,t)=>({p:t,f:lo(JSON.stringify(e))}),uo=(e,t)=>{if(!t)return{properties:[],isValid:!1};try{const i=Zr._parse(no(e)),s=(null==i?void 0:i.f)===lo(t)&&_t(i.p);return{properties:s?i.p:[],isValid:s}}catch(e){return{properties:[],isValid:!1}}},ho=(e,t)=>t+"|"+(Zr._get(no(e))||""),_o={},po={_is_supported:()=>!0,_error(e){Ir.error("memoryStorage error: "+e)},_get:e=>e in _o?_o[e]:null,_parse:e=>e in _o?_o[e]:null,_set:(e,t)=>(_o[e]=t,!0),_remove(e){delete _o[e]}};let go=null;const fo={_is_supported(){if(!bt(go))return go;if(go=!0,vt(je))go=!1;else try{const e="__support__";fo._set(e,"xyz"),'"xyz"'!==fo._get(e)&&(go=!1),fo._remove(e)}catch(e){go=!1}return go},_error(e){Ir.error("sessionStorage error: ",e)},_get(e){try{return null==je?void 0:je.sessionStorage.getItem(e)}catch(e){fo._error(e)}return null},_parse(e){try{return JSON.parse(fo._get(e))||null}catch(e){}return null},_set(e,t){try{return null==je||je.sessionStorage.setItem(e,JSON.stringify(t)),!0}catch(e){fo._error(e)}return!1},_remove(e){try{null==je||je.sessionStorage.removeItem(e)}catch(e){fo._error(e)}}};var vo=class{constructor(e){this._instance=e}get _config(){return this._instance.config}get consent(){return this._getDnt()?0:this._storedConsent}isOptedOut(){return"always"===this._config.cookieless_mode||this.isRejected()||-1===this.consent&&"on_reject"===this._config.cookieless_mode}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return 0===this.consent}isRejected(){return 0===this.consent||-1===this.consent&&this._config.opt_out_capturing_by_default}optInOut(e){this._storage._set(this._storageKey,e?1:0,this._config.cookie_expiration,this._config.cross_subdomain_cookie,this._config.secure_cookie)}reset(){this._storage._remove(this._storageKey,this._config.cross_subdomain_cookie)}get _storageKey(){const{token:e,opt_out_capturing_cookie_prefix:t,consent_persistence_name:i}=this._instance.config;return i||(t?t+e:"__ph_opt_in_out_"+e)}get _storedConsent(){const e=this._storage._get(this._storageKey);return $t(e)?1:ot(Mt,e)?0:-1}get _storage(){const e=this._config.opt_out_capturing_persistence_type,t="localStorage"===e?to:Zr,i=t._is_supported()?t:po;if(!this._persistentStore||this._persistentStore!==i){this._persistentStore=i;const t="localStorage"===e?Zr:to;t._get(this._storageKey)&&(this._persistentStore._get(this._storageKey)||this.optInOut($t(t._get(this._storageKey))),t._remove(this._storageKey,this._config.cross_subdomain_cookie))}return this._persistentStore}_getDnt(){return!!this._config.respect_dnt&&[null==Ve?void 0:Ve.doNotTrack,null==Ve?void 0:Ve.msDoNotTrack,tt.doNotTrack,null==Ve?void 0:Ve.globalPrivacyControl].some(e=>$t(e))}};function mo(e,t){var i;const s=null==e||null===(i=e.config)||void 0===i?void 0:i.get_current_url;if(!pt(s))return t;try{const e=s(t);return mt(e)&&e?e:t}catch(e){return Ir.error("Error in get_current_url, falling back to window.location.href",e),t}}function yo(e){var t;return e instanceof Element&&("__POSTHOG_TOOLBAR__"===e.id||!!(null===(t=e.closest)||void 0===t?void 0:t.call(e,".toolbar-global-fade-container")))}function bo(e){return!!e&&1===e.nodeType}function wo(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function So(e){return!!e&&3===e.nodeType}function Co(e){return!!e&&11===e.nodeType&&bo(e.host)}function ko(e){return e?at(e).split(/\s+/):[]}function Eo(e,t){const i=function(e){var t;const i=typeof window>"u"?void 0:window,s=null==i||null===(t=i.location)||void 0===t?void 0:t.href;return vt(s)?void 0:mo(e,s)}(t);return!!(i&&e&&e.some(e=>i.match(e)))}function xo(e){let t="";switch(typeof e.className){case"string":t=e.className;break;case"object":t=(e.className&&"baseVal"in e.className?e.className.baseVal:null)||e.getAttribute("class")||"";break;default:t=""}return ko(t)}function Po(e){return wt(e)?null:at(e).split(/(\s+)/).filter(e=>sa(e)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Io(e){let t="";return Ko(e)&&!Qo(e)&&e.childNodes&&e.childNodes.length&&Rr(e.childNodes,function(e){var i;So(e)&&e.textContent&&(t+=null!==(i=Po(e.textContent))&&void 0!==i?i:"")}),at(t)}function Fo(e){var t;return vt(e.target)?e.srcElement||null:(null===(t=e.target)||void 0===t?void 0:t.shadowRoot)?e.composedPath()[0]||null:e.target||null}const To=["a","button","form","input","select","textarea","label"];function Ro(e,t){const i=e.matches||e.matchesSelector||e.msMatchesSelector||e.mozMatchesSelector||e.webkitMatchesSelector||e.oMatchesSelector;try{return!!i&&i.call(e,t)}catch(e){return!1}}function Ao(e,t){if(vt(t))return!0;for(const i of e)if(t.some(e=>Ro(i,e)))return!0;return!1}function $o(e){const t=e.parentNode;return!(!t||!bo(t))&&t}const Mo=[".ph-no-autocapture","[data-ph-no-autocapture]"],Lo=["next","previous","prev",">","<","→","←","›","‹","»","«","▶","◀","❯","❮"],Oo=(()=>[...Lo,"+","-","−","–"])(),Do=(()=>Oo.length+10)(),No=["button","a","input","select","textarea","label"],Bo=["button","link","tab","menuitem","option"],zo=(e,t)=>/[a-z0-9]/i.test(t)?ot(Oo,t)?new RegExp(`\\b${t}\\b`).test(e):e.includes(t):e===t,Ho=e=>ot(No,e.tagName.toLowerCase())||ot(Bo,(e.getAttribute("role")||"").toLowerCase());function Uo(e){let t="",i="";const s=e=>{bo(e)&&Ko(e)&&!Qo(e)&&(t+=` ${Io(e)}`,i=i||e.getAttribute("aria-label")||"",Rr(e.childNodes,s))};s(e),t=at(t.replace(/\s+/g," "));const n=(sa(t)?t:"").toLowerCase(),r=e.getAttribute("aria-label")||(n?"":i);return{safeText:n,ariaLabel:at(r).toLowerCase()}}const qo=[".ph-no-rageclick",".ph-no-capture"],jo=["","text","search","email","password","url","tel","number"];function Wo(e,t){if(!(typeof window>"u"?void 0:window)||Vo(e))return!1;let i,s,n;var r,o;if(kt(t)?(i=!!t&&qo,s=void 0,n=!1):(i=null!==(r=null==t?void 0:t.css_selector_ignorelist)&&void 0!==r?r:qo,s=null==t?void 0:t.content_ignorelist,n=null!==(o=null==t?void 0:t.ignore_text_selection)&&void 0!==o&&o),!1===i)return!1;if(n&&function(e){return!(!e||!bo(e))&&(!!wo(e,"textarea")||(wo(e,"input")?ot(jo,(e.getAttribute("type")||"").toLowerCase()):function(e){var t;if(e.isContentEditable)return!0;const i=null===(t=e.getAttribute)||void 0===t?void 0:t.call(e,"contenteditable");return"true"===i||""===i}(e)))}(e))return!1;const{targetElementList:a}=Go(e,!1);return!(s&&function(e,{safeText:t,ariaLabel:i}){let s;if(!0===e)s=Lo;else{if(!_t(e))return!1;if(e.length>Do)return Ir.error(`[PostHog] content_ignorelist array cannot exceed ${Do} items. Use css_selector_ignorelist for more complex matching.`),!1;s=e.map(e=>e.toLowerCase())}return s.some(e=>zo(t,e)||zo(i,e))}(s,function(e,t){for(const e of t)if(Ho(e))return Uo(e);for(const e of t){try{var i;if("pointer"!==(null===(i=window)||void 0===i?void 0:i.getComputedStyle(e).getPropertyValue("cursor")))break}catch(e){break}const t=Uo(e);if(t.safeText||t.ariaLabel)return t}return Uo(e)}(e,a))||Ao(a,i))}const Vo=e=>!e||wo(e,"html")||!bo(e),Go=(e,t)=>{const i=typeof window>"u"?void 0:window;if(!i||Vo(e))return{parentIsUsefulElement:!1,targetElementList:[]};let s=!1;const n=[e];let r=e;for(;r.parentNode&&!wo(r,"body");){if(Co(r.parentNode)){n.push(r.parentNode.host),r=r.parentNode.host;continue}const e=$o(r);if(!e)break;if(t||To.indexOf(e.tagName.toLowerCase())>-1)s=!0;else try{const t=i.getComputedStyle(e);t&&"pointer"===t.getPropertyValue("cursor")&&(s=!0)}catch(e){}n.push(e),r=e}return{parentIsUsefulElement:s,targetElementList:n}};function Ko(e){const t=new Set;let i=0;for(let s=e;s.parentNode&&!wo(s,"body");s=s.parentNode){if(i++>=1e3||t.has(s))return!1;t.add(s);const e=xo(s);if(ot(e,"ph-sensitive")||ot(e,"ph-no-capture"))return!1}if(ot(xo(e),"ph-include"))return!0;const s=e.type||"";if(mt(s))switch(s.toLowerCase()){case"hidden":case"password":return!1}const n=e.name||e.id||"";return!mt(n)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(n.replace(/[^a-zA-Z0-9]/g,""))}function Qo(e){return!!(wo(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||wo(e,"select")||wo(e,"textarea")||"true"===e.getAttribute("contenteditable"))}const Jo=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}))$"),Yo=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,Xo=[16,15,14,13],Zo=new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),ea=new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),ta=/[0-9A-Za-z_]/;function ia(e){let t=0,i=!1;for(let s=e.length-1;s>=0;s--){let n=e.charCodeAt(s)-48;i&&(n*=2,n>9&&(n-=9)),t+=n,i=!i}return t%10==0}function sa(e,t=!0){if(wt(e))return!1;if(mt(e)){if(e=at(e),t?Jo.test((e||"").replace(/[- ]/g,"")):function(e){let t;for(Yo.lastIndex=0;t=Yo.exec(e);){const e=t[2];if(!e)continue;const i=e.replace(/[- ]/g,"");for(let e=0;i.length>e;e++)for(const t of Xo){const s=e+t;if(i.length>=s){const t=i.slice(e,s);if(Jo.test(t)&&ia(t))return!0}}}return!1}(e))return!1;if(t?Zo.test(e):function(e){let t;for(ea.lastIndex=0;t=ea.exec(e);){const e=t[1],i=t[3];if(!(e&&i&&ta.test(e)&&ta.test(i)))return!0}return!1}(e))return!1}return!0}function na(e){let t=Io(e);return t=`${t} ${ra(e)}`.trim(),sa(t)?t:""}function ra(e){let t="";return e&&e.childNodes&&e.childNodes.length&&Rr(e.childNodes,function(e){var i;if(e&&"span"===(null===(i=e.tagName)||void 0===i?void 0:i.toLowerCase()))try{const i=Io(e);t=`${t} ${i}`.trim(),e.childNodes&&e.childNodes.length&&(t=`${t} ${ra(e)}`.trim())}catch(e){Ir.error("[AutoCapture]",e)}}),t}function oa(e){return e.replace(/"|\\"/g,'\\"')}function aa(e){const t=e.attr__class;if(t)return _t(t)?t:ko(t)}const la=Fr("[Dead Clicks]"),ca=()=>!0,ua=e=>{var t;const i=!!(null===(t=e.instance.persistence)||void 0===t?void 0:t.get_property(q)),s=e.instance.config.capture_dead_clicks;return kt(s)?s:!!gt(s)||i};var da=class{get lazyLoadedDeadClicksAutocapture(){return this._lazyLoadedDeadClicksAutocapture}constructor(e,t,i){this.instance=e,this.isEnabled=t,this.onCapture=i,this.startIfEnabledOrStop()}onRemoteConfig(e){if(!e.ok)return;const t=e.config;"captureDeadClicks"in t&&(this.instance.persistence&&this.instance.persistence.register({[q]:t.captureDeadClicks}),this.startIfEnabledOrStop())}startIfEnabledOrStop(){this.isEnabled(this)?this._loadScript(()=>{this._start()}):this.stop()}_loadScript(e){var t,i,s;(null===(t=tt.__PosthogExtensions__)||void 0===t?void 0:t.initDeadClicksAutocapture)?e():null===(i=tt.__PosthogExtensions__)||void 0===i||null===(s=i.loadExternalDependency)||void 0===s||s.call(i,this.instance,"dead-clicks-autocapture",t=>{t?la.error("failed to load script",t):e()})}_start(){var e;if(Ge){if(!this._lazyLoadedDeadClicksAutocapture&&(null===(e=tt.__PosthogExtensions__)||void 0===e?void 0:e.initDeadClicksAutocapture)){const e=gt(this.instance.config.capture_dead_clicks)?as({},this.instance.config.capture_dead_clicks):{};e.__onCapture=this.onCapture,this.onCapture&&(e.capture_dead_swipes=!1),this._lazyLoadedDeadClicksAutocapture=tt.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,e),this._lazyLoadedDeadClicksAutocapture.start(Ge),la.info("starting...")}}else la.error("`document` not found. Cannot start.")}stop(){this._lazyLoadedDeadClicksAutocapture&&(this._lazyLoadedDeadClicksAutocapture.stop(),this._lazyLoadedDeadClicksAutocapture=void 0,la.info("stopping..."))}};const ha=Fr("[SegmentIntegration]");function _a(e,t,i=!0){const s=e.config.segment;if(!s)return t();const{analytics:n,filterProperties:r}=(e=>pt(e.register))(o=s)?{analytics:o}:o;var o;!function(e,t,i,s){const n=t=>{const n=()=>t.anonymousId()||Kr();e.config.get_device_id=n,s&&t.id()&&(e.register({distinct_id:t.id(),$device_id:n()}),e.persistence.set_property(ge,De)),i(s?void 0:t.anonymousId()||void 0)},r=t.user();"then"in r&&pt(r.then)?r.then(n):n(r)}(e,n,i=>{n.register(((e,t,{filterProperties:i}={})=>{"undefined"!=typeof Promise&&Promise.resolve||ha.warn("This browser does not have Promise support, and can not use the segment integration");const s=(s,n)=>{if(!n)return s;const r=!!t&&s.event.anonymousId===t&&!s.event.userId;r||s.event.userId||s.event.anonymousId===e.get_distinct_id()||(ha.info("No userId set, resetting PostHog"),e.reset()),r||(t=void 0),s.event.userId&&s.event.userId!==e.get_distinct_id()&&(ha.info("UserId set, identifying with PostHog"),e.identify(s.event.userId));let o=e.calculateEventProperties(n,s.event.properties);if(!wt(i)){const e=s.event.properties||{},t={};for(const i of Object.keys(o))dt.call(e,i)||(t[i]=o[i]);const n=((e,t)=>{const i=_t(e)?e:[e];let s=as({},t);for(const e of i)try{if(s=e(s),wt(s))return null}catch(e){return ha.error("Error in Segment filterProperties:",e),null}return s})(i,t);if(wt(n))return s;o=n}return s.event.properties=Object.assign({},o,s.event.properties),s};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded(){return!0},load(){return Promise.resolve()},track(e){return s(e,e.event.event)},page(e){return s(e,ze)},identify(e){return s(e,Ue)},screen(e){return s(e,"$screen")}}})(e,i,{filterProperties:r})).then(()=>{t()},e=>{ha.error("Failed to register the Segment integration",e),t()})},i)}const pa="posthog-js";function ga(e,{organization:t,projectId:i,prefix:s,severityAllowList:n=["error"],sendExceptionsToPostHog:r=!0}={}){return o=>{var a,l,c,u,d;if("*"!==n&&!n.includes(o.level)||!e.__loaded)return o;o.tags||(o.tags={});const h=e.requestRouter.endpointFor("ui",`/project/${e.config.token}/person/${e.get_distinct_id()}`);o.tags["PostHog Person URL"]=h,e.sessionRecordingStarted()&&(o.tags["PostHog Recording URL"]=e.get_session_replay_url({withTimestamp:!0}));const _=(null===(a=o.exception)||void 0===a?void 0:a.values)||[],p=_.map(e=>as(as({},e),{},{stacktrace:e.stacktrace?as(as({},e.stacktrace),{},{type:"raw",frames:(e.stacktrace.frames||[]).map(e=>as(as({},e),{},{platform:"web:javascript"}))}):void 0})),g={$exception_message:(null===(l=_[0])||void 0===l?void 0:l.value)||o.message,$exception_type:null===(c=_[0])||void 0===c?void 0:c.type,$exception_level:o.level,$exception_list:p,$sentry_event_id:o.event_id,$sentry_exception:o.exception,$sentry_exception_message:(null===(u=_[0])||void 0===u?void 0:u.value)||o.message,$sentry_exception_type:null===(d=_[0])||void 0===d?void 0:d.type,$sentry_tags:o.tags};var f;return t&&i&&(g.$sentry_url=(s||"https://sentry.io/organizations/")+t+"/issues/?project="+i+"&query="+o.event_id),r&&(null===(f=e.exceptions)||void 0===f||f.sendExceptionEvent(g)),o}}var fa=class{constructor(e,t,i,s,n,r){this.name=pa,this.setupOnce=function(o){o(ga(e,{organization:t,projectId:i,prefix:s,severityAllowList:n,sendExceptionsToPostHog:null==r||r}))}}},va=class{constructor(e){this._onSessionIdChange=(e,t,i)=>{i&&(i.noSessionId||i.activityTimeout||i.sessionPastMaximumLength||i.crossTabAdoption)&&(Ir.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:e,changeReason:i}),this._currentPageview=void 0,this._instance.scrollManager.resetContext())},this._instance=e,this._setupSessionRotationHandler()}_setupSessionRotationHandler(){var e;this._unsubscribeSessionId=null===(e=this._instance.sessionManager)||void 0===e?void 0:e.onSessionId(this._onSessionIdChange)}destroy(){var e;null===(e=this._unsubscribeSessionId)||void 0===e||e.call(this),this._unsubscribeSessionId=void 0}doPageView(e,t){var i;const s=this._previousPageViewProperties(e,t);return this._currentPageview={pathname:null!==(i=null==je?void 0:je.location.pathname)&&void 0!==i?i:"",pageViewId:t,timestamp:e},this._instance.scrollManager.resetContext(),s}doPageLeave(e){var t;return this._previousPageViewProperties(e,null===(t=this._currentPageview)||void 0===t?void 0:t.pageViewId)}doEvent(){var e;return{$pageview_id:null===(e=this._currentPageview)||void 0===e?void 0:e.pageViewId}}_previousPageViewProperties(e,t){const i=this._currentPageview;if(!i)return{$pageview_id:t};let s={$pageview_id:t,$prev_pageview_id:i.pageViewId};const n=this._instance.scrollManager.getContext();if(n&&!this._instance.config.disable_scroll_properties){let{maxScrollHeight:e,lastScrollY:t,maxScrollY:i,maxContentHeight:r,lastContentY:o,maxContentY:a}=n;if(!(vt(e)||vt(t)||vt(i)||vt(r)||vt(o)||vt(a))){e=Math.ceil(e),t=Math.ceil(t),i=Math.ceil(i),r=Math.ceil(r),o=Math.ceil(o),a=Math.ceil(a);const n=e>1?zt(t/e,0,1,Ir):1,l=e>1?zt(i/e,0,1,Ir):1,c=r>1?zt(o/r,0,1,Ir):1,u=r>1?zt(a/r,0,1,Ir):1;s=Ar(s,{$prev_pageview_last_scroll:t,$prev_pageview_last_scroll_percentage:n,$prev_pageview_max_scroll:i,$prev_pageview_max_scroll_percentage:l,$prev_pageview_last_content:o,$prev_pageview_last_content_percentage:c,$prev_pageview_max_content:a,$prev_pageview_max_content_percentage:u})}}return i.pathname&&(s.$prev_pageview_pathname=i.pathname),i.timestamp&&(s.$prev_pageview_duration=(e.getTime()-i.timestamp.getTime())/1e3),s}};const ma=["flags","surveys"],ya={[x]:{exposure:"hidden"},[T]:{exposure:"hidden"},[R]:{exposure:"hidden"},[D]:{exposure:"hidden"},[M]:{exposure:"hidden"},[O]:{exposure:"hidden"},[y]:{exposure:"event"},[N]:{exposure:"hidden"},[W]:{exposure:"hidden"},[B]:{exposure:"event"},[z]:{exposure:"hidden"},[H]:{exposure:"event"},[U]:{exposure:"event"},[q]:{exposure:"event"},[j]:{exposure:"hidden"},[V]:{exposure:"event"},[G]:{exposure:"hidden"},[K]:{exposure:"hidden"},[ee]:{exposure:"hidden"},[te]:{exposure:"event"},[Q]:{exposure:"event",shouldSkipFromEventProperties:e=>bt(e)},[ie]:{exposure:"event"},[se]:{exposure:"event"},[ne]:{exposure:"event"},[re]:{exposure:"event"},[oe]:{exposure:"hidden"},[u]:{exposure:"hidden",storageGroup:"flags"},[n]:{exposure:"hidden",storageGroup:"flags"},[s]:{exposure:"hidden"},[r]:{exposure:"hidden",storageGroup:"flags"},[g]:{exposure:"hidden",storageGroup:"flags"},[l]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[c]:{exposure:"hidden",storageGroup:"flags"},[f]:{exposure:"hidden"},[v]:{exposure:"hidden"},[h]:{exposure:"hidden"},[d]:{exposure:"hidden"},[b]:{exposure:"hidden",storageGroup:"surveys"},[w]:{exposure:"hidden",storageGroup:"surveys",volatile:!0},[C]:{exposure:"event"},[k]:{exposure:"hidden"},[E]:{exposure:"hidden"},[le]:{exposure:"hidden"},[ce]:{exposure:"hidden"},[ue]:{exposure:"hidden"},[de]:{exposure:"event"},[he]:{exposure:"event"},[_e]:{exposure:"event"},[pe]:{exposure:"event"},[_]:{exposure:"hidden"},[p]:{exposure:"hidden"},[ae]:{exposure:"event"},[o]:{exposure:"hidden"},[a]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[ge]:{exposure:"hidden"},[fe]:{exposure:"hidden"},[ve]:{exposure:"hidden"},[me]:{exposure:"hidden"},[ye]:{exposure:"hidden"},[be]:{exposure:"hidden"},[we]:{exposure:"hidden"},[J]:{exposure:"event"},[Y]:{exposure:"event"},[X]:{exposure:"event"},[Z]:{exposure:"event"},[ke]:{exposure:"event"},[Ee]:{exposure:"event"},[xe]:{exposure:"hidden"},[Pe]:{exposure:"hidden"},[Ie]:{exposure:"hidden"},[Fe]:{exposure:"hidden"},[Te]:{exposure:"hidden"},[Re]:{exposure:"hidden"},[Ae]:{exposure:"hidden"},[$e]:{exposure:"hidden"},[Me]:{exposure:"hidden"},[Le]:{exposure:"event"}},ba=[["$posthog_sr_group_event_trigger_",{exposure:"hidden"}],["$posthog_sr_group_url_trigger_",{exposure:"hidden"}],["$posthog_sr_group_sampling_",{exposure:"hidden"}]],wa=e=>{const t=ya[e];if(t)return t;for(const[t,i]of ba)if(0===e.indexOf(t))return i};function Sa(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(e){return}}const Ca=e=>{const t=typeof document>"u"?void 0:document,i=null==t?void 0:t.createElement("a");return vt(i)?null:(i.href=e,i)},ka=()=>{try{return"u">typeof window&&!1!==window.navigator.onLine}catch(e){return!1}},Ea=(e,t)=>e>=t&&ka(),xa=(e,t,i,s)=>{if(0===e){if(ka()){const e=t+1;return e===i&&s(),e}return t}return 0},Pa=(e,t)=>{try{let i;return JSON.stringify(e,(e,t)=>{var s;return Ft(t)?(null!==(s=i)&&void 0!==s||(i=new WeakMap),i.has(t)||i.set(t,Or(t)),i.get(t)):"bigint"==typeof t?t.toString():t},t)}catch(t){return ct(e)}},Ia=function(e,t){const i=((e.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&");let s;for(let e=0;i.length>e;e++){const n=i[e].split(/=(.*)/);if(n[0]===t){s=n;break}}if(!_t(s)||2>s.length)return"";{let e=s[1].replace(/\+/g," ");try{e=decodeURIComponent(e)}catch(t){Ir.error("Skipping decoding for malformed query param: "+e)}return e}},Fa=function(e,t,i){if(!e||!t||!t.length)return e;const s=e.split(/#(.*)/),n=s[1],r=(s[0]||"").split(/\?(.*)/),o=r[1],a=r[0],l=(o||"").split("&"),c=[];for(let e=0;l.length>e;e++){const s=l[e].split("?");let n=0;for(;s.length>n&&!t.includes(s[n].split("=")[0]);)n++;c.push(s.length>n?s.slice(0,n).concat(s[n].split("=")[0]+"="+i).join("?"):l[e])}let u=a;return null!=o&&(u+="?"+c.join("&")),null!=n&&(u+="#"+n),u},Ta=function(e,t){const i=e.match(new RegExp(t+"=([^&]*)"));return i?i[1]:null},Ra=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","oppref","bfcid","irclid","_kx"],Aa=(()=>["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...Ra])(),$a="<masked>",Ma=["li_fat_id"];function La(e,t,i){if(!Ge)return{};const s=t?[...Ra,...i||[]]:[],n=Oa(Fa(Ge.URL,s,$a),e),r=function(){const e={};return Rr(Ma,function(t){const i=Hr(t);e[t]=i||null}),e}();return Ar(r,n)}function Oa(e,t){const i=Aa.concat(t||[]),s={};return Rr(i,function(t){const i=Ia(e,t);s[t]=i||null}),s}function Da(e){const t=function(e){return e?0===e.search("https?://(.*)google.([^/?]*)")?"google":0===e.search("https?://(.*)bing.com")?"bing":0===e.search("https?://(.*)yahoo.com")?"yahoo":0===e.search("https?://(.*)duckduckgo.com")?"duckduckgo":null:null}(e),i="yahoo"!=t?"q":"p",s={};if(!bt(t)){s.$search_engine=t;const e=Ge?Ia(Ge.referrer,i):"";e.length&&(s.ph_keyword=e)}return s}function Na(){return navigator.language||navigator.userLanguage}function Ba(){const e=Na();return"string"==typeof e?e.split("-")[0]:void 0}const za="$direct";function Ha(){return(null==Ge?void 0:Ge.referrer)||za}function Ua(e,t,i=!1){const s=e?[...Ra,...t||[]]:[],n=i?Zi(null==Ke?void 0:Ke.href):null==Ke?void 0:Ke.href,r=null==n?void 0:n.substring(0,1e3);return{r:Ha().substring(0,1e3),u:r?Fa(r,s,$a):void 0}}function qa(e,t=!1){var i;const{r:s,u:n}=e,r=t?Zi(n):n,o={$referrer:s,$referring_domain:null==s?void 0:s==za?za:null===(i=Ca(s))||void 0===i?void 0:i.host};if(r){o.$current_url=r;const e=Ca(r);o.$host=null==e?void 0:e.host,o.$pathname=null==e?void 0:e.pathname;const t=Oa(r);Ar(o,t)}if(s){const e=Da(s);Ar(o,e)}return o}function ja(){try{return(new Date).getTimezoneOffset()}catch(e){return}}const Wa={flags:a,surveys:w},Va=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],Ga=e=>`${e}_cookie_identity_change_pending`,Ka=e=>{let t="",i=0;for(const s of e){const e=encodeURIComponent(JSON.stringify(s).slice(1,-1)).length;if(i+e>1e3)break;t+=s,i+=e}return t},Qa="main",Ja=[u,n,r,g,l,a,c,h],Ya=e=>-1!==Ja.indexOf(e),Xa=[M,O],Za=e=>-1!==Xa.indexOf(e),el=(e,t)=>{try{return JSON.stringify(e)===JSON.stringify(t)}catch(i){return e===t}},tl=e=>{if(!e)return{};const t=JSON.parse(e);return gt(t)?t:{}},il=(e,t)=>{Rr(e,(i,s)=>{const n=wa(s);n&&"event"!==n.exposure||{}.hasOwnProperty.call(t,s)||delete e[s]})};var sl=class{constructor(e,t,i=!0,s=!e.cookieless_mode){if(this._slotState={},this._splitStorageEligible=!1,this._storesIdentityInCookie=!1,this._splitStorage=!1,this._cookieIdentityChangePending=!1,this._cookieSyncSuppressed=!1,this._pendingCrossTabFeatureFlagChanges=new Map,this._storageMigrationInProgress=!1,this._localIdentityChangePending=!1,this._crossTabFeatureFlagIdentityMismatch=!1,this._metaIdentifierChangePending=new Set,this._crossTabFeatureFlagHandlers=new Set,this._config=e,this._ownsSplitStorage=i,this.props={},this._campaign_params_url=void 0,this._name=(e=>{let t="";return e.token&&(t=e.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),e.persistence_name?"ph_"+e.persistence_name:"ph_"+t+"_posthog"})(e),this._disabled=e.disable_persistence||!!t,this._storage=this._buildStorage(e),this._splitStorage=this._resolveSplitStorage(e),this.load(s),this._markLoadedCrossTabFeatureFlagChangesPending(),e.debug&&Ir.info("Persistence loaded",e.persistence,as({},this.props)),this.update_config(e,e,t),this.save(),je){const e=()=>this.flush();Br(je,"beforeunload",e,{capture:!1}),Br(je,"pagehide",e,{capture:!1}),this._onStorage=e=>{if(this._splitStorageEligible&&(!e.storageArea||e.storageArea===(null==je?void 0:je.localStorage))&&e.key)if(e.key!==this._name){if(this._splitStorage){const t=ma.find(t=>e.key===this._groupEntryName(t));t&&this._syncCrossTabFeatureFlagProperties(e.key,t)}}else this._syncCrossTabFeatureFlagProperties(e.key,Qa)},Br(je,"storage",this._onStorage)}}markCrossTabFeatureFlagChanges(e){Object.entries(e).forEach(([e,t])=>{const i=this._pendingCrossTabFeatureFlagChanges.get(e);if(!Ya(e)||!0===i)return;if(!0===t)return void this._setCrossTabFeatureFlagChangesPending(e,!0);const s=new Set(i||[]);t.forEach(e=>s.add(e)),s.size&&this._setCrossTabFeatureFlagChangesPending(e,s)})}onCrossTabFeatureFlagChange(e){return this._crossTabFeatureFlagHandlers.add(e),()=>this._crossTabFeatureFlagHandlers.delete(e)}destroy(){this._onStorage&&je&&(je.removeEventListener("storage",this._onStorage),this._onStorage=void 0),this._crossTabFeatureFlagHandlers.clear()}_syncCrossTabFeatureFlagProperties(e,t,i=!0){if(this._disabled)return!1;let s,n;try{if(n=to._get(e),bt(n)){const e=this._slotWriteState(t);return e.storageValue=null,t!==Qa&&(e.persisted=!1),!1}s=tl(n)}catch(e){return!1}const r=t===Qa?s:to._parse(this._name);if(r&&this._hasCrossTabFeatureFlagIdentityMismatch(r))return!1;const o=this._mergeCrossTabFeatureFlagProperties(s,t,i);return t===Qa&&this._splitStorage&&!el(this._partitionProps().main,s)||this._rememberCrossTabStorageFingerprint(s,t,!0,n),o}_hasCrossTabFeatureFlagIdentityMismatch(e){const t=this.props[P],i=e[P];return!vt(t)&&!vt(i)&&t!==i}_rememberCrossTabStorageFingerprint(e,t,i,s){const n=this._slotWriteState(t);n.storageValue=s,t!==Qa&&(n.persisted=i);try{n.fingerprint=this._entryFingerprint(e,t)}catch(e){n.fingerprint=void 0}}_mergeCrossTabFeatureFlagProperties(e,t,i){let s=!1;return Ja.forEach(i=>{var n;const r=null===(n=wa(i))||void 0===n?void 0:n.storageGroup;if(t===Qa&&this._splitStorage&&r||t!==Qa&&r!==t)return;const o=i in e,a=this._mergePendingCrossTabFeatureFlagChanges(i,o?e[i]:void 0),l=this._pendingCrossTabFeatureFlagChanges.has(i)?i in this.props:o;l===i in this.props&&el(a,this.props[i])||(l?this._setProp(i,a,!1):this._deleteProp(i,!1),s=!0)}),s&&i&&this._crossTabFeatureFlagHandlers.forEach(e=>e()),s}_reconcileCrossTabFeatureFlagPropertiesBeforeWrite(){if(!this._splitStorageEligible)return!1;try{this._crossTabFeatureFlagIdentityMismatch=!1;const e=to._get(this._name),t=this._slotWriteState(Qa);let i,s=!1,n=!1;if(e!==t.storageValue)if(bt(e))t.storageValue=null;else{if(i=tl(e),this._crossTabFeatureFlagIdentityMismatch=!this._localIdentityChangePending&&this._hasCrossTabFeatureFlagIdentityMismatch(i),this._crossTabFeatureFlagIdentityMismatch)return!1;n=this._mergeCrossTabFeatureFlagProperties(i,Qa,!1),!this._splitStorage||el(this._partitionProps().main,i)?this._rememberCrossTabStorageFingerprint(i,Qa,!0,e):t.storageValue=e,s=!0}return this._splitStorage&&ma.forEach(e=>{const t=to._get(this._groupEntryName(e)),r=this._slotWriteState(e),o=i||{},a=s&&Ja.some(t=>{var i;return(null===(i=wa(t))||void 0===i?void 0:i.storageGroup)===e&&t in o});if(t===r.storageValue&&!a)return;if(bt(t))return r.storageValue=null,r.persisted=!1,void(a&&(n=this._mergeCrossTabFeatureFlagProperties(o,e,!1)||n));const l=tl(t);n=this._mergeCrossTabFeatureFlagProperties(l,e,!1)||n,this._rememberCrossTabStorageFingerprint(l,e,!0,t)}),n}catch(e){return!1}}_setCrossTabFeatureFlagChangesPending(e,t){this._pendingCrossTabFeatureFlagChanges.set(e,t);const i=wa(e);(null==i?void 0:i.volatile)||(this._slotWriteState((this._splitStorage?null==i?void 0:i.storageGroup:void 0)||Qa).fingerprint=void 0,this._markGroupDirty(e))}_markAllCrossTabFeatureFlagChangesPending(){Ja.forEach(e=>this._pendingCrossTabFeatureFlagChanges.set(e,!0))}_markLoadedCrossTabFeatureFlagChangesPending(){if(this._splitStorageEligible)try{const e=to._get(this._name),t=tl(e);this._slotWriteState(Qa).storageValue=e,Ja.forEach(e=>{var i;const s=this._splitStorage?null===(i=wa(e))||void 0===i?void 0:i.storageGroup:void 0,n=s?to._get(this._groupEntryName(s)):null;if(s){const e=this._slotWriteState(s);e.storageValue=n,e.persisted=!bt(n)}const r=s&&!bt(n)?tl(n):t;e in this.props?this._markPendingCrossTabFeatureFlagChanges(e,r[e],this.props[e]):e in r&&this._setCrossTabFeatureFlagChangesPending(e,!0)})}catch(e){}}_mergePendingCrossTabFeatureFlagChanges(e,t){const i=this._pendingCrossTabFeatureFlagChanges.get(e);if(!i)return t;if(!0===i)return this.props[e];if("$active_feature_flags"===e){const s=new Set(_t(t)?t:[]),n=new Set(_t(this.props[e])?this.props[e]:[]);return i.forEach(e=>n.has(e)?s.add(e):s.delete(e)),Array.from(s)}const s=gt(t)?as({},t):{},n=gt(this.props[e])?this.props[e]:{};return i.forEach(e=>{e in n?s[e]=n[e]:delete s[e]}),s}_markPendingCrossTabFeatureFlagChanges(e,t,i){if(!Ya(e))return;const s=this._pendingCrossTabFeatureFlagChanges.get(e);if(!0===s)return;let n=t;if(this._splitStorageEligible)try{var r;const t=this._splitStorage?null===(r=wa(e))||void 0===r?void 0:r.storageGroup:void 0,i=t?this._groupEntryName(t):this._name;n=tl(to._get(i))[e]}catch(e){}const o=new Set(s||[]);if("$active_feature_flags"===e){if(!vt(t)&&!_t(t)||!vt(n)&&!_t(n)||!_t(i))return void this._setCrossTabFeatureFlagChangesPending(e,!0);const s=new Set(t||[]),r=new Set(n||[]),a=new Set(i);new Set([...s,...a]).forEach(e=>{s.has(e)!==a.has(e)&&o.add(e)}),o.forEach(e=>{r.has(e)===a.has(e)&&o.delete(e)})}else{if(!gt(i))return void(el(n,i)?this._pendingCrossTabFeatureFlagChanges.delete(e):this._setCrossTabFeatureFlagChangesPending(e,!0));{if(!vt(t)&&!gt(t)||vt(t)&&ft(i)&&vt(n))return void this._setCrossTabFeatureFlagChangesPending(e,!0);const s=gt(t)?t:{},r=gt(n)?n:{};new Set([...Object.keys(s),...Object.keys(i)]).forEach(e=>{e in s==e in i&&el(s[e],i[e])||o.add(e)}),o.forEach(e=>{e in r==e in i&&el(r[e],i[e])&&o.delete(e)})}}o.size?this._setCrossTabFeatureFlagChangesPending(e,o):this._pendingCrossTabFeatureFlagChanges.delete(e)}_saveDebounceMs(){var e;const t=null===(e=this._config)||void 0===e?void 0:e.persistence_save_debounce_ms;return St(t)&&t>0?t:0}_rememberCurrentCookieProperties(e){if(this._config.cookieWinsOnConflict&&"localstorage+cookie"===this._config.persistence.toLowerCase())if(e)try{const t=ao(e,this._config.cookie_persisted_properties||[]),i=co(t,this._config.cookie_persisted_properties||[]),s=JSON.stringify(t)+"|"+JSON.stringify(i),n=Zr._get(this._name)||void 0;n&&ho(this._name,n)===s&&(this._lastSeenCookiePropertiesFingerprint=s,this._lastSeenMainCookieValue=n)}catch(e){}else try{const e=Zr._get(this._name)||void 0;this._lastSeenCookiePropertiesFingerprint=e?ho(this._name,e):void 0,this._lastSeenMainCookieValue=e}catch(e){}}syncCookieProperties(){return this._syncCookieProperties(this._config)}_syncCookieProperties(e,t=!1){if(this._disabled&&!t||this._cookieSyncSuppressed||!e.cookieWinsOnConflict||"localstorage+cookie"!==e.persistence.toLowerCase())return!1;let i;try{i=Zr._get(this._name)||void 0}catch(e){}if(!i||i===this._lastSeenMainCookieValue)return!1;const s=ho(this._name,i);let c;try{c=oo(JSON.parse(i))}catch(e){return!1}if((Zr._get(this._name)||void 0)!==i)return!1;this._lastSeenCookiePropertiesFingerprint=s,this._lastSeenMainCookieValue=i;const p=uo(this._name,i),f=[...so,...p.properties],v={};if(Object.keys(c).forEach(e=>{const t=c[e];(vt(t)||bt(t)||""===t||"$user_state"===e&&"anonymous"!==t&&"identified"!==t)&&(v[e]=!0,delete c[e])}),ft(c))return!1;const m="distinct_id"in c||"anonymous"===c.$user_state||"identified"===c.$user_state,y=this.props,b=y[P],w=y[ge],S=Ar({},y);[...so,...e.cookie_persisted_properties||[]].forEach(e=>{if(-1!==f.indexOf(e)&&!(e in c)&&!v[e]&&(m||"distinct_id"!==e&&"$user_state"!==e)){const t=S[e];(p.isValid||-1===so.indexOf(e)||!1!==t&&0!==t)&&delete S[e]}}),this.props=Ar(S,c),Ja.forEach(e=>{const t=e in this.props;e in y===t&&el(y[e],this.props[e])||(t?this._markPendingCrossTabFeatureFlagChanges(e,y[e],this.props[e]):this._setCrossTabFeatureFlagChangesPending(e,!0))}),!m||"$user_state"in c||"$user_state"in this.props||this._setProp(ge,Oe);const C=this.props[P],k=this.props[ge];return!m||C===b&&k===w||(this._localIdentityChangePending=!0,this._cookieIdentityChangePending=!0,fo._set(Ga(this._name),!0),this._deleteProp(h),this._deleteProp(n),this._deleteProp(u),this._deleteProp(r),this._deleteProp(g),this._deleteProp(l),this._deleteProp(a),this._deleteProp(o),this._deleteProp(_),"anonymous"!==k||"identified"!==w&&"anonymous"!==c.$user_state&&(vt(b)||C===b)||(il(this.props,c),this._deleteProp(d)),"identified"===k?this.props.$user_id=C:delete this.props.$user_id,this._deleteProp(T)),!0}consumeCookieIdentityChange(){const e=Ga(this._name),t=this._cookieIdentityChangePending||!!fo._get(e);return this._cookieIdentityChangePending=!1,t&&fo._remove(e),t}_beginCookieSyncSuppression(e=!1){return!(this._cookieSyncSuppressed||this._disabled&&!e||!this._config.cookieWinsOnConflict||"localstorage+cookie"!==this._config.persistence.toLowerCase()||(this._cookieSyncSuppressed=!0,0))}_publishSuppressedCookieSnapshot(){this._cookieSyncSuppressed&&(vt(this._pendingSaveTimer)||(clearTimeout(this._pendingSaveTimer),this._pendingSaveTimer=void 0),delete this._slotState[Qa],this._writeNow(!0))}_endCookieSyncSuppression(e=!0){if(this._cookieSyncSuppressed)try{e?this._publishSuppressedCookieSnapshot():vt(this._pendingSaveTimer)||(clearTimeout(this._pendingSaveTimer),this._pendingSaveTimer=void 0)}finally{this._cookieSyncSuppressed=!1}}isDisabled(){return!!this._disabled}_buildStorage(e){-1===Va.indexOf(e.persistence.toLowerCase())&&(Ir.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");const t=((e=[],t=!1,i=()=>!1)=>{const s=[...so,...e];return as(as({},to),{},{_rawText(e){return[Zr._get(e),Zr._get(no(e)),to._get(e)].join("\0")},_parse(e){try{let r,o={};try{r=Zr._get(e)||void 0,o=r?oo(JSON.parse(r)):{}}catch(e){}const a=JSON.parse(to._get(e)||"{}");let l;if(t){const t=uo(e,r),i=[...so,...t.properties],c={};Object.keys(o).forEach(e=>{const t=o[e];bt(t)||""===t||"$user_state"===e&&"anonymous"!==t&&"identified"!==t||(c[e]=t)});const u="distinct_id"in c||"anonymous"===c.$user_state||"identified"===c.$user_state;if(Object.keys(c).length>0){var n;const e=a[P],r=null!==(n=a.$user_state)&&void 0!==n?n:Oe;s.forEach(e=>{if(-1!==i.indexOf(e)&&!(e in o)&&(u||"distinct_id"!==e&&"$user_state"!==e)){const i=a[e];(t.isValid||-1===so.indexOf(e)||!1!==i&&0!==i)&&delete a[e]}}),!u||"$user_state"in o||"$user_state"in a||(a[ge]=Oe),!u||("distinct_id"in c?c[P]:a[P])===e&&("$user_state"in c?c[ge]:a[ge])===r||(io.forEach(e=>delete a[e]),"identified"===c.$user_state&&"distinct_id"in c?a.$user_id=c[P]:delete a.$user_id,"identified"!==c.$user_state&&(delete a[ae],delete a[d]),delete a.__alias)}l=Ar(a,c)}else l=Ar(o,a);return i()||to._set(e,l),l}catch(e){}return null},_set(i,s,n,r,o,a){const l=to._set(i,s,void 0,void 0,a);try{const c=ao(s,e);if(Object.keys(c).length){if(t){const t=no(i),u=co(c,e);if(Zr._set(t,u,n,r,o,a),Zr._get(t)!==JSON.stringify(u)){Zr._remove(t,r);const e=ao(s);return Zr._set(i,e,n,r,o,a),l}}Zr._set(i,c,n,r,o,a)}}catch(e){to._error(e)}return l},_remove(e,t){try{null==je||je.localStorage.removeItem(e),Zr._remove(e,t),Zr._remove(no(e),t)}catch(e){to._error(e)}}})})(e.cookie_persisted_properties||[],e.cookieWinsOnConflict,()=>!!this._disabled);let i,s=!1,n=!1;const r=e.persistence.toLowerCase();return"localstorage"===r&&to._is_supported()?(i=to,n=!0):"localstorage+cookie"===r&&t._is_supported()?(i=t,n=!0,s=!0):"sessionstorage"===r&&fo._is_supported()?i=fo:"memory"===r?i=po:"cookie"===r&&Zr._is_supported()?(i=Zr,s=!0):t._is_supported()?(i=t,n=!0,s=!0):Zr._is_supported()?(i=Zr,s=!0):i=po,this._splitStorageEligible=n,this._storesIdentityInCookie=s,i}_groupEntryName(e){return`${this._name}__${e}`}_resolveSplitStorage(e){return this._splitStorageEligible&&!!e.split_storage}properties(){const e={};return Rr(this.props,(t,i)=>{const s=wa(i);if(!s||"event"===s.exposure){var n;if(null==s||null===(n=s.shouldSkipFromEventProperties)||void 0===n?void 0:n.call(s,t))return;e[i]=t}}),e}load(e=!1){if(this._disabled&&!e)return;const t=this._config.cookieWinsOnConflict&&"localstorage+cookie"===this._config.persistence.toLowerCase(),i=t?to._parse(this._name):null;let s={};if(t)try{s=oo(Zr._parse(this._name)),Rr(s,(e,t)=>{(vt(e)||bt(e)||""===e)&&delete s[t]})}catch(e){}const n=this._storage._parse(this._name);if(n&&(this.props=Ar({},n)),this._splitStorage&&this._loadGroupEntries(),t&&n){var r,o;const e=null==i?void 0:i[P],t=null!==(r=null==i?void 0:i.$user_state)&&void 0!==r?r:Oe,a=n[P],l=null!==(o=n.$user_state)&&void 0!==o?o:Oe;if(a!==e||l!==t){this._cookieIdentityChangePending=!0,this._disabled||fo._set(Ga(this._name),!0);const i=Ar({},this.props);io.forEach(e=>delete i[e]),"anonymous"!==l||"identified"!==t&&"anonymous"!==s.$user_state&&(vt(e)||a===e)||(il(i,s),delete i[d]),this.props=i;const n=new Set;io.forEach(e=>{var t;const i=null===(t=wa(e))||void 0===t?void 0:t.storageGroup;i&&n.add(i)}),n.forEach(e=>{if(this._disabled)return;const t={};Rr(this.props,(i,s)=>{var n;(null===(n=wa(s))||void 0===n?void 0:n.storageGroup)===e&&(t[s]=i)}),ft(t)?(to._remove(this._groupEntryName(e)),this._slotState[e]={}):to._set(this._groupEntryName(e),t)&&(this._slotState[e]={persisted:!0,fingerprint:this._entryFingerprint(t,e)})})}}fo._get(Ga(this._name))&&(this._cookieIdentityChangePending=!0)}_loadGroupEntries(){for(const e of ma){const t=to._parse(this._groupEntryName(e));if(t&&!ft(t)){const i=this._slotWriteState(e);i.persisted=!0,this._mainCarriesGroupKey(e)||(i.fingerprint=this._entryFingerprint(t,e)),this._groupEntryIsStale(e,t)||Ar(this.props,t)}}}_mainCarriesGroupKey(e){return Object.keys(this.props).some(t=>{var i;return(null===(i=wa(t))||void 0===i?void 0:i.storageGroup)===e})}_groupEntryIsStale(e,t){const i=Wa[e];if(!i)return!1;const s=t[i],n=this.props[i];return St(s)&&St(n)&&n>s}refreshKey(e){this._refreshKeys([e])}_refreshKeys(e){if(this._disabled)return;let t,i=!1;const s=()=>(i||(t=this._storage._parse(this._name),i=!0),t);e.forEach(e=>{var t;if(this._metaIdentifierChangePending.has(e))return;const i=this._splitStorage?null===(t=wa(e))||void 0===t?void 0:t.storageGroup:void 0,n=i?to._parse(this._groupEntryName(i)):s();if(n&&e in n)this._setProp(e,n[e],!1);else{if(i){const t=s();if(t&&e in t)return void this._setProp(e,t[e],!1)}this._deleteProp(e,!1)}})}refreshMetaIdentifiers(){if(this._disabled)return;const e=this._storageSnapshot();(vt(e)||e!==this._metaIdentifierStorageSnapshot)&&(this._refreshKeys(Xa),this._rememberMetaIdentifierStorageSnapshot(e))}_rememberMetaIdentifierStorageSnapshot(e=this._storageSnapshot()){this._metaIdentifierStorageSnapshot=0===this._metaIdentifierChangePending.size?e:void 0}_storageSnapshot(){const e=this._storage._rawText?this._storage._rawText(this._name):this._storage._get(this._name);return mt(e)?e:void 0}save(){if(this._disabled)return;const e=this._saveDebounceMs();e>0?vt(this._pendingSaveTimer)&&(this._pendingSaveTimer=setTimeout(()=>{this._pendingSaveTimer=void 0,this._writeNow()},e)):this._writeNow()}flush(){vt(this._pendingSaveTimer)||(clearTimeout(this._pendingSaveTimer),this._pendingSaveTimer=void 0,this._writeNow())}_writeNow(e=!1){if(this._disabled||this._cookieSyncSuppressed&&!e)return;e||(this.syncCookieProperties(),this._config.cookieWinsOnConflict&&"localstorage+cookie"===this._config.persistence.toLowerCase()||this.refreshMetaIdentifiers());const t=!e&&!this._storageMigrationInProgress;t||(this._crossTabFeatureFlagIdentityMismatch=!1);const i=!!t&&this._reconcileCrossTabFeatureFlagPropertiesBeforeWrite();if(this._crossTabFeatureFlagIdentityMismatch)return void(this._config.debug&&Ir.warn("skipping persistence write because storage belongs to a different distinct ID"));if(this._splitStorage)return this._writeNowSplit(),void(i&&this._crossTabFeatureFlagHandlers.forEach(e=>e()));const s=this._writeEntry(this._storage,this._name,this.props,Qa);"written"===s&&this._rememberCurrentCookieProperties(this.props),"failed"!==s&&(this._pendingCrossTabFeatureFlagChanges.clear(),this._localIdentityChangePending=!1,this._metaIdentifierChangePending.clear()),"written"===s&&this._rememberMetaIdentifierStorageSnapshot(),i&&this._crossTabFeatureFlagHandlers.forEach(e=>e())}_writeNowSplit(){const{main:e,groups:t}=this._partitionProps(),i=this._writeEntry(this._storage,this._name,e,Qa);"written"===i&&this._rememberCurrentCookieProperties(e),"failed"!==i&&(this._localIdentityChangePending=!1,this._metaIdentifierChangePending.clear(),Ja.forEach(e=>{var t;(null===(t=wa(e))||void 0===t?void 0:t.storageGroup)||this._pendingCrossTabFeatureFlagChanges.delete(e)})),"written"===i&&this._rememberMetaIdentifierStorageSnapshot();for(const e of ma){var s;const i=t[e];if(ft(i)&&!(null===(s=this._slotState[e])||void 0===s?void 0:s.persisted)){Ja.forEach(t=>{var i;(null===(i=wa(t))||void 0===i?void 0:i.storageGroup)===e&&this._pendingCrossTabFeatureFlagChanges.delete(t)});continue}const n=this._writeEntry(to,this._groupEntryName(e),i,e);"failed"!==n&&Ja.forEach(t=>{const i=wa(t);(null==i?void 0:i.storageGroup)!==e||"written"!==n&&i.volatile||this._pendingCrossTabFeatureFlagChanges.delete(t)})}}_partitionProps(){const e={},t={flags:{},surveys:{}};return Rr(this.props,(i,s)=>{var n;const r=null===(n=wa(s))||void 0===n?void 0:n.storageGroup;r?t[r][s]=i:e[s]=i}),{main:e,groups:t}}_entryFingerprint(e,t){if(t===Qa)return JSON.stringify(e)+"|"+this._expire_days+"|"+this._cross_subdomain+"|"+this._secure;const i={};return Rr(e,(e,t)=>{var s;i[t]=(null===(s=wa(t))||void 0===s?void 0:s.volatile)?"__volatile__":e}),JSON.stringify(i)}_writeEntry(e,t,i,s){const n=this._slotWriteState(s);if(s!==Qa&&!n.dirty&&!vt(n.fingerprint))return"skipped";let r;try{if(r=this._entryFingerprint(i,s),r===n.fingerprint)return n.dirty=!1,"skipped"}catch(e){r=void 0}return e._set(t,i,this._expire_days,this._cross_subdomain,this._secure,this._config.debug)?(n.dirty=!1,s!==Qa&&(n.persisted=!0),vt(r)||(n.fingerprint=r),this._splitStorageEligible&&(n.storageValue=to._get(t)),"written"):(this._config.debug&&Ir.warn(`failed to persist storage entry "${t}"; will retry on next save`),"failed")}remove({keepGroupEntries:e=!1}={}){if(this._markAllCrossTabFeatureFlagChangesPending(),vt(this._pendingSaveTimer)||(clearTimeout(this._pendingSaveTimer),this._pendingSaveTimer=void 0),this._storage._remove(this._name,!1),this._storage._remove(this._name,!0),!e&&this._ownsSplitStorage)for(const e of ma)to._remove(this._groupEntryName(e));e?delete this._slotState[Qa]:this._slotState={},this._lastSeenCookiePropertiesFingerprint=void 0,this._lastSeenMainCookieValue=void 0}clear(){this.remove(),this.props={}}register_once(e,t,i){if(gt(e)){this.syncCookieProperties(),vt(t)&&(t="None"),this._expire_days=vt(i)?this._default_expiry:i;let s=!1;if(Rr(e,(e,i)=>{this.props.hasOwnProperty(i)&&this.props[i]!==t||(this._setProp(i,e),s=!0)}),s)return this.save(),!0}return!1}register(e,t){if(gt(e)){this.syncCookieProperties(),this._expire_days=vt(t)?this._default_expiry:t;let i=!1;if(Rr(e,(t,s)=>{e.hasOwnProperty(s)&&(this.props[s]!==t||gt(t)||_t(t))&&(this._setProp(s,t),i=!0)}),i)return this.save(),!0}return!1}unregister(e){this.syncCookieProperties();const t="string"==typeof e?[e]:e;let i=!1;for(const e of t)e in this.props&&(this._deleteProp(e),i=!0);i&&this.save()}update_campaign_params(){const e=null==Ge?void 0:Ge.URL;if(e===this._campaign_params_url)return;const t=La(this._config.custom_campaign_params,this._config.mask_personal_data_properties,this._config.custom_personal_data_properties),i=!ft(Lr(t));return i&&this.register(t),this._campaign_params_url=e,i?t:void 0}update_search_keyword(){this.register(function(){const e=null==Ge?void 0:Ge.referrer;return e?Da(e):{}}())}update_referrer_info(){var e;this.register_once({$referrer:Ha(),$referring_domain:(null==Ge?void 0:Ge.referrer)&&(null===(e=Ca(Ge.referrer))||void 0===e?void 0:e.host)||za},void 0)}set_initial_person_info(){if(this.props.$initial_campaign_params||this.props.$initial_referrer_info)return;const e=Ua(this._config.mask_personal_data_properties,this._config.custom_personal_data_properties,this._config.disable_capture_url_hashes);this.register_once({[be]:this._storesIdentityInCookie?{r:Ka(e.r),u:e.u?Ka(e.u):void 0}:e},void 0)}get_initial_props(){const e={};Rr([ye,me],t=>{const i=this.props[t];i&&Rr(i,function(t,i){e["$initial_"+lt(i)]=t})});const t=this.props[be];if(t){const i=function(e,t=!1){const i=qa(e,t),s={};return Rr(i,function(e,t){s[`$initial_${lt(t)}`]=e}),s}(t,this._config.disable_capture_url_hashes);Ar(e,i)}return e}safe_merge(e){return Rr(this.props,function(t,i){i in e||(e[i]=t)}),e}update_config(e,t,i){const s=e.persistence!==t.persistence,n=!((e,t)=>{if(e.length!==t.length)return!1;const i=[...e].sort(),s=[...t].sort();return i.every((e,t)=>e===s[t])})(e.cookie_persisted_properties||[],t.cookie_persisted_properties||[]),r=s||n,o=e.cookieWinsOnConflict!==t.cookieWinsOnConflict,a=e.disable_persistence||!!i,l=!!this._disabled&&!a;a||this._syncCookieProperties(t,l),this._config=e,!a&&(s||n||o)&&(this._lastSeenCookiePropertiesFingerprint=void 0,this._lastSeenMainCookieValue=void 0,this._syncCookieProperties(as(as({},e),{},{cookie_persisted_properties:t.cookie_persisted_properties}),l));const c=r||o?this._buildStorage(e):this._storage;this._truncateExistingPersonInfoForCookie();const u=this._resolveSplitStorage(e),d=r||u!==this._splitStorage,h=!a&&(d||e.cross_subdomain_cookie!==this._cross_subdomain||e.secure_cookie!==this._secure)&&this._beginCookieSyncSuppression(l);this._storageMigrationInProgress=d;try{if(this._default_expiry=this._expire_days=e.cookie_expiration,this.set_disabled(a),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),d){const e=this.props;this.clear(),this._storage=c,this._splitStorage=u,this.props=e,this.save()}else o&&(this._storage=c,a||(delete this._slotState[Qa],this._writeNow()))}finally{this._storageMigrationInProgress=!1,h&&this._endCookieSyncSuppression()}}_truncateExistingPersonInfoForCookie(){const e=this.props[be];if(!this._storesIdentityInCookie||!gt(e)||"string"!=typeof e.r)return;const t=Ka(e.r),i="string"==typeof e.u?Ka(e.u):e.u;t===e.r&&i===e.u||this._setProp(be,as(as({},e),{},{r:t,u:i}))}set_disabled(e){this._disabled=e,this._disabled?this.remove():this.save()}set_cross_subdomain(e){e!==this._cross_subdomain&&(this._cross_subdomain=e,this.remove({keepGroupEntries:!0}),this.save())}set_secure(e){e!==this._secure&&(this._secure=e,this.remove({keepGroupEntries:!0}),this.save())}set_event_timer(e,t){const i=this.props.__timers||{};i[e]=t,this._setProp(D,i),this.save()}remove_event_timer(e){const t=this.props.__timers||{},i=t[e];return vt(i)||(delete t[e],this._setProp(D,t),this.save()),i}get_property(e){return this.props[e]}set_property(e,t){this._setProp(e,t),this.save()}_setProp(e,t,i=!0){var s;const n=this.props[e];this.props[e]=t,i&&("distinct_id"!==e&&"$user_state"!==e||n===t||(this._localIdentityChangePending=!0),Za(e)&&!el(n,t)&&this._metaIdentifierChangePending.add(e),this._markPendingCrossTabFeatureFlagChanges(e,n,t),(null===(s=wa(e))||void 0===s?void 0:s.volatile)||this._markGroupDirty(e))}_deleteProp(e,t=!0){delete this.props[e],t&&(Ya(e)&&this._setCrossTabFeatureFlagChangesPending(e,!0),Za(e)&&this._metaIdentifierChangePending.add(e),this._markGroupDirty(e))}_markGroupDirty(e){var t;const i=null===(t=wa(e))||void 0===t?void 0:t.storageGroup;i&&(this._slotWriteState(i).dirty=!0)}_slotWriteState(e){return this._slotState[e]||(this._slotState[e]={})}};const nl="gzip-js",rl="base64",ol="events",al="cancelEvents",ll="survey shown",cl="survey dismissed",ul="survey sent",dl="$survey_last_seen_date",hl="popover";function _l(e){let t=!0;return{dispose(){if(t){t=!1;const i=e();i&&pt(i.then)&&i.then(void 0,()=>{})}}}}const pl=Fr("[RateLimiter]");var gl=class{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=e=>{const t=e.text;if(t&&t.length)try{(JSON.parse(t).quota_limited||[]).forEach(e=>{pl.info(`${e||"events"} is quota limited.`),this.serverLimits[e]=(new Date).getTime()+6e4})}catch(e){return void pl.warn(`could not rate limit - continuing. Error: "${null==e?void 0:e.message}"`,{text:t})}},this.instance=e,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var e;return(null===(e=this.instance.config.rate_limiting)||void 0===e?void 0:e.events_per_second)||10}get captureEventsBurstLimit(){var e;return Math.max((null===(e=this.instance.config.rate_limiting)||void 0===e?void 0:e.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}get isClientRateLimited(){return 1>this._refilledBucket().tokens}clientRateLimitContext(e=!1){var t;const i=this._refilledBucket(),s=1>i.tokens;if(s||e||(i.tokens=Math.max(0,i.tokens-1)),s&&!e){const e=(St(i.dropped)?i.dropped:0)+1;i.dropped=e,!this.lastEventRateLimited&&this._captureWarning(e)&&(i.dropped=0)}return this.lastEventRateLimited=s,null===(t=this.instance.persistence)||void 0===t||t.set_property("$capture_rate_limit",i),{isRateLimited:s,remainingTokens:i.tokens}}_refilledBucket(){var e;const{captureEventsBurstLimit:t,captureEventsPerSecond:i}=this,s=(new Date).getTime(),n=null===(e=this.instance.persistence)||void 0===e?void 0:e.get_property(ve),r=n?as({},n):{tokens:t,last:s};return r.tokens+=Math.max(0,s-r.last)/1e3*i,r.last=Math.max(r.last,s),r.tokens>t&&(r.tokens=t),r}_isPropertyAllowed(e){const t=this.instance.config.property_denylist;return!_t(t)||!t.includes(e)}_triggeringPage(){var e;if(this._isPropertyAllowed("$current_url")&&this._isPropertyAllowed("$pathname")&&(null==Ke?void 0:Ke.pathname))return`${null!==(e=Ke.origin)&&void 0!==e?e:""}${Ke.pathname}`}_captureWarning(e){var t,i;const{captureEventsBurstLimit:s,captureEventsPerSecond:n}=this,r=this._triggeringPage(),o=this._isPropertyAllowed("$session_id")?null===(t=(i=this.instance).get_session_id)||void 0===t?void 0:t.call(i):void 0,a=[`${e} event(s) dropped since the last warning`,r?`triggered on ${r}`: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 ${n} events per second and ${s} events burst limit.`},{skip_client_rate_limiting:!0})}isServerRateLimited(e){const t=this.serverLimits[e||"events"]||!1;return!1!==t&&(new Date).getTime()<t}};const fl=Fr("[RemoteConfig]");var vl=class{constructor(e){this._instance=e}get remoteConfig(){var e;return null===(e=tt._POSTHOG_REMOTE_CONFIG)||void 0===e||null===(e=e[this._instance.config.token])||void 0===e?void 0:e.config}_loadRemoteConfigJs(e){var t,i,s;(null===(t=tt.__PosthogExtensions__)||void 0===t?void 0:t.loadExternalDependency)?null===(i=tt.__PosthogExtensions__)||void 0===i||null===(s=i.loadExternalDependency)||void 0===s||s.call(i,this._instance,"remote-config",()=>e(this.remoteConfig)):e()}_loadRemoteConfigJSON(e){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets",`/array/${this._instance.config.token}/config`),callback:e})}load(){try{if(this.remoteConfig)return fl.info("Using preloaded remote config",this.remoteConfig),void this._onRemoteConfig(this.remoteConfig);if(this._instance._shouldDisableFlags())return void fl.warn("Remote config is disabled. Falling back to local config.");this._loadRemoteConfigJs(e=>{if(!e)return fl.info("No config found after loading remote JS config. Falling back to JSON."),void this._loadRemoteConfigJSON(e=>{this._onRemoteConfig(e.json,e)});this._onRemoteConfig(e)})}catch(e){fl.error("Error loading remote config",e),this._onRemoteConfig()}}_onRemoteConfig(e,t){!e&&t&&(0===t.statusCode?t.error||fl.warn("Failed to fetch remote config from PostHog."):fl.error("Failed to fetch remote config from PostHog."));try{this._instance._onRemoteConfig(e?{ok:!0,config:e}:{ok:!1})}catch(e){fl.error("Error applying remote config",e)}if(!1!==(null==e?void 0:e.hasFeatureFlags)&&!this._instance.config.advanced_disable_feature_flags_on_first_load)try{var i;null===(i=this._instance.featureFlags)||void 0===i||i.ensureFlagsLoaded()}catch(e){fl.error("Error loading feature flags",e)}}},ml=Uint8Array,yl=Uint16Array,bl=Uint32Array,wl=new ml([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]),Sl=new ml([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]),Cl=new ml([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),kl=function(e,t){for(var i=new yl(31),s=0;31>s;++s)i[s]=t+=1<<e[s-1];var n=new bl(i[30]);for(s=1;30>s;++s)for(var r=i[s];i[s+1]>r;++r)n[r]=r-i[s]<<5|s;return[i,n]},El=kl(wl,2),xl=El[1];El[0][28]=258,xl[258]=28;for(var Pl=kl(Sl,0)[1],Il=new yl(32768),Fl=0;32768>Fl;++Fl){var Tl=(43690&Fl)>>>1|(21845&Fl)<<1;Il[Fl]=((65280&(Tl=(61680&(Tl=(52428&Tl)>>>2|(13107&Tl)<<2))>>>4|(3855&Tl)<<4))>>>8|(255&Tl)<<8)>>>1}var Rl=function(e,t,i){for(var s=e.length,n=0,r=new yl(t);s>n;++n)++r[e[n]-1];var o,a=new yl(t);for(n=0;t>n;++n)a[n]=a[n-1]+r[n-1]<<1;if(i){o=new yl(1<<t);var l=15-t;for(n=0;s>n;++n)if(e[n])for(var c=n<<4|e[n],u=t-e[n],d=a[e[n]-1]++<<u,h=d|(1<<u)-1;h>=d;++d)o[Il[d]>>>l]=c}else for(o=new yl(s),n=0;s>n;++n)o[n]=Il[a[e[n]-1]++]>>>15-e[n];return o},Al=new ml(288);for(Fl=0;144>Fl;++Fl)Al[Fl]=8;for(Fl=144;256>Fl;++Fl)Al[Fl]=9;for(Fl=256;280>Fl;++Fl)Al[Fl]=7;for(Fl=280;288>Fl;++Fl)Al[Fl]=8;var $l=new ml(32);for(Fl=0;32>Fl;++Fl)$l[Fl]=5;var Ml=Rl(Al,9,0),Ll=Rl($l,5,0),Ol=function(e){return(e/8|0)+(7&e&&1)},Dl=function(e,t,i){(null==t||0>t)&&(t=0),(null==i||i>e.length)&&(i=e.length);var s=new(e instanceof yl?yl:e instanceof bl?bl:ml)(i-t);return s.set(e.subarray(t,i)),s},Nl=function(e,t,i){var s=t/8|0;e[s]|=i<<=7&t,e[s+1]|=i>>>8},Bl=function(e,t,i){var s=t/8|0;e[s]|=i<<=7&t,e[s+1]|=i>>>8,e[s+2]|=i>>>16},zl=function(e,t){for(var i=[],s=0;e.length>s;++s)e[s]&&i.push({s:s,f:e[s]});var n=i.length,r=i.slice();if(!n)return[new ml(0),0];if(1==n){var o=new ml(i[0].s+1);return o[i[0].s]=1,[o,1]}i.sort(function(e,t){return e.f-t.f}),i.push({s:-1,f:25001});var a=i[0],l=i[1],c=0,u=1,d=2;for(i[0]={s:-1,f:a.f+l.f,l:a,r:l};u!=n-1;)a=i[i[d].f>i[c].f?c++:d++],l=i[c!=u&&i[d].f>i[c].f?c++:d++],i[u++]={s:-1,f:a.f+l.f,l:a,r:l};var h=r[0].s;for(s=1;n>s;++s)r[s].s>h&&(h=r[s].s);var _=new yl(h+1),p=Hl(i[u-1],_,0);if(p>t){s=0;var g=0,f=p-t,v=1<<f;for(r.sort(function(e,t){return _[t.s]-_[e.s]||e.f-t.f});n>s;++s){var m=r[s].s;if(t>=_[m])break;g+=v-(1<<p-_[m]),_[m]=t}for(g>>>=f;g>0;){var y=r[s].s;t>_[y]?g-=1<<t-_[y]++-1:++s}for(;s>=0&&g;--s){var b=r[s].s;_[b]==t&&(--_[b],++g)}p=t}return[new ml(_),p]},Hl=function(e,t,i){return-1==e.s?Math.max(Hl(e.l,t,i+1),Hl(e.r,t,i+1)):t[e.s]=i},Ul=function(e){for(var t=e.length;t&&!e[--t];);for(var i=new yl(++t),s=0,n=e[0],r=1,o=function(e){i[s++]=e},a=1;t>=a;++a)if(e[a]==n&&a!=t)++r;else{if(!n&&r>2){for(;r>138;r-=138)o(32754);r>2&&(o(r>10?r-11<<5|28690:r-3<<5|12305),r=0)}else if(r>3){for(o(n),--r;r>6;r-=6)o(8304);r>2&&(o(r-3<<5|8208),r=0)}for(;r--;)o(n);r=1,n=e[a]}return[i.subarray(0,s),t]},ql=function(e,t){for(var i=0,s=0;t.length>s;++s)i+=e[s]*t[s];return i},jl=function(e,t,i){var s=i.length,n=Ol(t+2);e[n]=255&s,e[n+1]=s>>>8,e[n+2]=255^e[n],e[n+3]=255^e[n+1];for(var r=0;s>r;++r)e[n+r+4]=i[r];return 8*(n+4+s)},Wl=function(e,t,i,s,n,r,o,a,l,c,u){Nl(t,u++,i),++n[256];for(var d=zl(n,15),h=d[0],_=d[1],p=zl(r,15),g=p[0],f=p[1],v=Ul(h),m=v[0],y=v[1],b=Ul(g),w=b[0],S=b[1],C=new yl(19),k=0;m.length>k;++k)C[31&m[k]]++;for(k=0;w.length>k;++k)C[31&w[k]]++;for(var E=zl(C,7),x=E[0],P=E[1],I=19;I>4&&!x[Cl[I-1]];--I);var F,T,R,A,M=c+5<<3,L=ql(n,Al)+ql(r,$l)+o,O=ql(n,h)+ql(r,g)+o+14+3*I+ql(C,x)+(2*C[16]+3*C[17]+7*C[18]);if(L>=M&&O>=M)return jl(t,u,e.subarray(l,l+c));if(Nl(t,u,1+(L>O)),u+=2,L>O){F=Rl(h,_,0),T=h,R=Rl(g,f,0),A=g;var D=Rl(x,P,0);for(Nl(t,u,y-257),Nl(t,u+5,S-1),Nl(t,u+10,I-4),u+=14,k=0;I>k;++k)Nl(t,u+3*k,x[Cl[k]]);u+=3*I;for(var N=[m,w],B=0;2>B;++B){var z=N[B];for(k=0;z.length>k;++k)Nl(t,u,D[H=31&z[k]]),u+=x[H],H>15&&(Nl(t,u,z[k]>>>5&127),u+=z[k]>>>12)}}else F=Ml,T=Al,R=Ll,A=$l;for(k=0;a>k;++k)if(s[k]>255){var H;Bl(t,u,F[257+(H=s[k]>>>18&31)]),u+=T[H+257],H>7&&(Nl(t,u,s[k]>>>23&31),u+=wl[H]);var U=31&s[k];Bl(t,u,R[U]),u+=A[U],U>3&&(Bl(t,u,s[k]>>>5&8191),u+=Sl[U])}else Bl(t,u,F[s[k]]),u+=T[s[k]];return Bl(t,u,F[256]),u+T[256]},Vl=new bl([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Gl=new ml(0),Kl=function(){for(var e=new bl(256),t=0;256>t;++t){for(var i=t,s=9;--s;)i=(1&i&&3988292384)^i>>>1;e[t]=i}return e}(),Ql=function(e,t,i){for(;i;++t)e[t]=i,i>>>=8};function Jl(e,t){void 0===t&&(t={});var i=function(){var e=4294967295;return{p(t){for(var i=e,s=0;t.length>s;++s)i=Kl[255&i^t[s]]^i>>>8;e=i},d(){return 4294967295^e}}}(),s=e.length;i.p(e);var n,r,o,a,l,c,u=(a=10+((n=t).filename&&n.filename.length+1||0),l=8,function(e,t,i,s,n,r){var o=e.length,a=new ml(s+o+5*(1+Math.floor(o/7e3))+n),l=a.subarray(s,a.length-n),c=0;if(!t||8>o)for(var u=0;o>=u;u+=65535){var d=u+65535;o>d?c=jl(l,c,e.subarray(u,d)):(l[u]=r,c=jl(l,c,e.subarray(u,o)))}else{for(var h=Vl[t-1],_=h>>>13,p=8191&h,g=(1<<i)-1,f=new yl(32768),v=new yl(g+1),m=Math.ceil(i/3),y=2*m,b=function(t){return(e[t]^e[t+1]<<m^e[t+2]<<y)&g},w=new bl(25e3),S=new yl(288),C=new yl(32),k=0,E=0,x=(u=0,0),P=0,I=0;o>u;++u){var F=b(u),T=32767&u,R=v[F];if(f[T]=R,v[F]=T,u>=P){var A=o-u;if((k>7e3||x>24576)&&A>423){c=Wl(e,l,0,w,S,C,E,x,I,u-I,c),x=k=E=0,I=u;for(var M=0;286>M;++M)S[M]=0;for(M=0;30>M;++M)C[M]=0}var L=2,O=0,D=p,N=T-R&32767;if(A>2&&F==b(u-N))for(var B=Math.min(_,A)-1,z=Math.min(32767,u),H=Math.min(258,A);z>=N&&--D&&T!=R;){if(e[u+L]==e[u+L-N]){for(var U=0;H>U&&e[u+U]==e[u+U-N];++U);if(U>L){if(L=U,O=N,U>B)break;var q=Math.min(N,U-2),j=0;for(M=0;q>M;++M){var W=u-N+M+32768&32767,V=W-f[W]+32768&32767;V>j&&(j=V,R=W)}}}N+=(T=R)-(R=f[T])+32768&32767}if(O){w[x++]=268435456|xl[L]<<18|Pl[O];var G=31&xl[L],K=31&Pl[O];E+=wl[G]+Sl[K],++S[257+G],++C[K],P=u+L,++k}else w[x++]=e[u],++S[e[u]]}}c=Wl(e,l,r,w,S,C,E,x,I,u-I,c),r||(c=jl(l,c,Gl))}return Dl(a,0,s+Ol(c)+n)}(r=e,null==(o=t).level?6:o.level,null==o.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(r.length)))):12+o.mem,a,l,!c)),d=u.length;return function(e,t){var i=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=2>t.level?4:9==t.level?2:0,e[9]=3,0!=t.mtime&&Ql(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),i){e[3]=8;for(var s=0;i.length>=s;++s)e[s+10]=i.charCodeAt(s)}}(u,t),Ql(u,d-8,i.d()),Ql(u,d-4,s),u}const Yl=!!Je||!!Qe,Xl=new WeakMap,Zl="text/plain";let ec=0,tc=!1;const ic=(e,t)=>{const[i,s]=e.split("#"),[n,r]=i.split("?");if(!r)return e;const o=r.split("&").filter(e=>e.split("=")[0]!==t).join("&");return`${n}${o?`?${o}`:""}${s?`#${s}`:""}`},sc=(e,t,i=!0)=>{var s;const[n,r]=e.split("?"),o=as({},t),a=null!==(s=null==r?void 0:r.split("&").map(e=>{var t;const[s,n]=e.split("="),r=i&&null!==(t=o[s])&&void 0!==t?t:n;return delete o[s],`${s}=${r}`}))&&void 0!==s?s:[],l=function(e,t="&"){let i,s;const n=[];return Rr(e,function(e,t){vt(e)||vt(t)||"undefined"===t||(i=encodeURIComponent((e=>e instanceof File)(e)?e.name:e.toString()),s=encodeURIComponent(t),n[n.length]=s+"="+i)}),n.join(t)}(o);return l&&a.push(l),a.length>0?`${n}?${a.join("&")}`:n},nc=e=>{if(e._encodedBody)return e._encodedBody;const{data:t,compression:i}=e;if(!t)return;if(i===nl){const e=Jl(function(e){var t=e.length;if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var i=new ml(e.length+(e.length>>>1)),s=0,n=function(e){i[s++]=e},r=0;t>r;++r){if(s+5>i.length){var o=new ml(s+8+(t-r<<1));o.set(i),i=o}var a=e.charCodeAt(r);128>a?n(a):2048>a?(n(192|a>>>6),n(128|63&a)):a>55295&&57344>a?(n(240|(a=65536+(1047552&a)|1023&e.charCodeAt(++r))>>>18),n(128|a>>>12&63),n(128|a>>>6&63),n(128|63&a)):(n(224|a>>>12),n(128|a>>>6&63),n(128|63&a))}return Dl(i,0,s)}(Pa(t)),{mtime:0});return{contentType:Zl,body:e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength),estimatedSize:e.byteLength}}if(i===rl){const e=function(e){return e?btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,(e,t)=>String.fromCharCode(parseInt(t,16)))):e}(Pa(t)),i=(e=>"data="+encodeURIComponent("string"==typeof e?e:Pa(e)))(e);return{contentType:"application/x-www-form-urlencoded",body:i,estimatedSize:new Blob([i]).size}}const s=Pa(t);return{contentType:"application/json",body:s,estimatedSize:new Blob([s]).size}},rc=e=>{const t=()=>"sendBeacon"===e.transport?{url:sc(e.url,{compression:rl}),encodedBody:nc(as(as({},e),{},{compression:rl,_encodedBody:void 0}))}:{url:ic(e.url,"compression"),encodedBody:nc(as(as({},e),{},{compression:void 0,_encodedBody:void 0}))};let i;try{i=nc(e)}catch(i){if(on(e.compression,Ia(e.url,"compression")))return Ir.error("Failed to gzip request body, sending uncompressed payload",i),t();throw i}return i&&on(e.compression,Ia(e.url,"compression"))&&!((s=i.body)instanceof ArrayBuffer?rn(new Uint8Array(s)):ArrayBuffer.isView(s)&&rn(new Uint8Array(s.buffer,s.byteOffset,s.byteLength)))?(tc=!0,t()):{url:e.url,encodedBody:i};var s},oc=e=>{try{return rc(e)}catch(i){var t;return Ir.error(i),void(null===(t=e.callback)||void 0===t||t.call(e,{statusCode:0,error:i}))}},ac=function(){var e=Ot(function*(e){const t=yield function(e){return dn.apply(this,arguments)}(Pa(e.data),i.DEBUG,{rethrow:!0});if(!t)return e;const s=yield t.arrayBuffer();return as(as({},e),{},{_encodedBody:{contentType:Zl,body:s,estimatedSize:s.byteLength}})});return function(t){return e.apply(this,arguments)}}(),lc=e=>Xi("AbortError","PostHog request timed out"+(e?` after ${e}ms`:"")),cc=/Failed to fetch|NetworkError|Load failed/i,uc=e=>"TypeError"===(null==e?void 0:e.name)&&cc.test((null==e?void 0:e.message)||""),dc=e=>{try{const t=function(e,t=Date.now(),i=3e5){if("string"!=typeof e||!e)return;const s=e.trim(),n=/^\d+\s*,/.test(s)?s.slice(0,s.indexOf(",")).trim():s;if(/^\d+$/.test(n)){const e=1e3*Math.min(Number(n),i/1e3);return e>0?e:void 0}if(!/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun)[a-z]*[ ,]/.test(n))return;const r=/^\w{3} \w{3} /.test(n)?n+" GMT":n,o=Date.parse(r)-t;return Number.isFinite(o)&&o>0?Math.min(o,i):void 0}(e());return vt(t)?void 0:Math.min(t,3e4)}catch(e){return}},hc=e=>{const t=oc(e);if(!t)return;const i=new Je;Xl.set(i,!0);const{url:s,encodedBody:n}=t;i.open(e.method||"GET",s,!0);const{contentType:r,body:o}=null!=n?n:{};Rr(e.headers,function(e,t){i.setRequestHeader(t,e)}),r&&i.setRequestHeader("Content-Type",r),e.timeout&&(i.timeout=e.timeout);let a=!1;i.ontimeout=()=>{a=!0},i.onloadend=()=>{var t;if(a){var s;const t=lc(e.timeout);return Ir.warn(t),void(null===(s=e.callback)||void 0===s||s.call(e,{statusCode:0,error:t}))}const n={statusCode:i.status,text:i.responseText};if(200===i.status)try{n.json=JSON.parse(i.responseText)}catch(e){}null===(t=e.callback)||void 0===t||t.call(e,n,dc(()=>i.getResponseHeader("Retry-After")))},i.send(o)},_c=e=>{const t=oc(e);if(!t)return;const{url:i,encodedBody:s}=t,{contentType:n,body:r,estimatedSize:o}=null!=s?s:{},a=new Headers;Rr(e.headers,function(e,t){a.append(t,e)}),n&&a.append("Content-Type",n);let l=null,c=!1;if(Ye){const t=new Ye;l={signal:t.signal,timeout:setTimeout(()=>{c=!0;try{t.abort(lc(e.timeout))}catch(e){d(e)}},e.timeout)}}let u=!1;const d=t=>{var i;u||(u=!0,c&&"AbortError"===(null==t?void 0:t.name)||uc(t)?Ir.warn(t):Ir.error(t),null===(i=e.callback)||void 0===i||i.call(e,{statusCode:0,error:t}))};let h=0;const _=()=>{ec-=h,h=0,l&&clearTimeout(l.timeout)};try{const t=as({method:(null==e?void 0:e.method)||"GET",headers:a,referrerPolicy:"strict-origin",body:r,signal:null==l?void 0:l.signal},e.fetchOptions),s=null!=o?o:vt(r)?0:void 0;t.keepalive="POST"===t.method&&!e._keepaliveDisabled&&!1!==t.keepalive&&t.body===r&&!vt(s)&&s>=0&&52428.8>ec+s,t.keepalive&&(h=s,ec+=h),Qe(i,t).then(t=>t.text().then(i=>{var s;if(u)return;const n={statusCode:t.status,text:i};if(200===t.status)try{n.json=JSON.parse(i)}catch(e){Ir.error(e)}u=!0,_(),null===(s=e.callback)||void 0===s||s.call(e,n,dc(()=>t.headers.get("Retry-After")))})).catch(e=>{_(),d(e)}).finally(_)}catch(e){_(),d(e)}},pc=e=>{try{var t;const{url:i,encodedBody:s}=rc(e),{contentType:n,body:r,estimatedSize:o}=null!=s?s:{};if(!r)return;const a=r instanceof Blob?r:new Blob([r],{type:n});if(Ve.sendBeacon(i,a))return;const l=_t(e.data)?e.data:null===(t=e.data)||void 0===t?void 0:t.batch;if(_t(l)&&l.length>1&&(null!=o?o:0)>16384){const t=Math.ceil(l.length/2),i=t=>_t(e.data)?t:as(as({},e.data),{},{batch:t});return pc(as(as({},e),{},{data:i(l.slice(0,t))})),void pc(as(as({},e),{},{data:i(l.slice(t))}))}Ir.warn(`Beacon of ~${null!=o?o:0} bytes was rejected by the browser, falling back to ${Qe?"fetch":"XHR"}`),Qe?_c(as(as({},e),{},{_keepaliveDisabled:!0})):hc(e)}catch(e){Ir.warn("Beacon send failed",e)}},gc=(e,t,i,s)=>{const n="query"===s?"POST"===t?"sent_at":"_":void 0;return sc(i===nl?ic(e,"compression"):e,as(as({},n?{[n]:Date.now().toString()}:{}),i===nl?{}:{compression:i}))},fc=(()=>{const e=[];return Qe&&e.push({transport:"fetch",method:_c}),Je&&e.push({transport:"XHR",method:hc}),(null==Ve?void 0:Ve.sendBeacon)&&e.push({transport:"sendBeacon",method:pc}),e})();let vc=!Yl&&-1===(null==Ze?void 0:Ze.indexOf("MSIE"))&&-1===(null==Ze?void 0:Ze.indexOf("Mozilla"));function mc(e,t,i){var s,n,r,o;i&&(t=as(as({},t),{},{callback:e=>i(e)})),e.__loaded?vc?e.__request_queue.push(t):e.rateLimiter.isServerRateLimited(t.batchKey)?t.fireCallbackOnDrop&&(null===(r=t.callback)||void 0===r||r.call(t,{statusCode:429})):(t.transport=t.transport||e.config.api_transport,t.headers=as(as({},e.config.request_headers),t.headers),t.compression="best-available"===t.compression?null!==(s=e.compression)&&void 0!==s?s:t.compressionFallback:t.compression,(vt(e.config.disable_beacon)?e.config.__preview_disable_beacon:e.config.disable_beacon)&&(t.disableTransport=["sendBeacon"]),t.fetchOptions=t.fetchOptions||e.config.fetch_options,null===(n=t.onDispatch)||void 0===n||n.call(t),((e,t)=>{var i,s,n;const r=as(as({},e),{},{callback:null!=t?t:t=>{var i;return null===(i=e.callback)||void 0===i?void 0:i.call(e,t)}});r.timeout=r.timeout||6e4;const o=null!==(i=r.transport)&&void 0!==i?i:"fetch";"sendBeacon"===o&&vt(r.compression)&&r.data&&(r.compression=rl),"POST"===r.method&&r.data&&("capture-body"===r.timestampMode?r.data=(e=>{var t,i;const s=(_t(e)?e:[e]).map(e=>as(as({},e),e.timestamp instanceof Date&&!isNaN(e.timestamp.getTime())?{timestamp:e.timestamp.toISOString()}:{})),n=s[0];return{api_key:null!==(t=null==n||null===(i=n.properties)||void 0===i?void 0:i.token)&&void 0!==t?t:null==n?void 0:n.token,batch:s,sent_at:(new Date).toISOString()}})(r.data):"body"===r.timestampMode&&(r.data=((e,t=(new Date).toISOString())=>_t(e)?e.map(e=>as(as({},e),{},{sent_at:t})):as(as({},e),{},{sent_at:t}))(r.data))),r.url=gc(r.url,r.method,r.compression,r.timestampMode);const a=fc.filter(e=>!r.disableTransport||!e.transport||!r.disableTransport.includes(e.transport)),l=null!==(s=null===(n=function(e,t){for(let i=0;e.length>i;i++)if(t(e[i]))return e[i]}(a,e=>e.transport===o))||void 0===n?void 0:n.method)&&void 0!==s?s:a[0].method;if(!l)throw new Error("No available transport method");const c=e=>{try{l(e)}catch(e){var t;uc(e)?Ir.warn(e):Ir.error(e),null===(t=r.callback)||void 0===t||t.call(r,{statusCode:0,error:e})}};"sendBeacon"!==o&&!r.preferSyncCompression&&r.data&&r.compression===nl&&Xe&&"undefined"!=typeof Promise&&!tc?ac(r).then(e=>{c(e)}).catch(t=>{if(an(t))return tc=!0,void c(as(as({},r),{},{compression:void 0,url:gc(e.url,e.method,void 0,e.timestampMode)}));(e=>{if(!e||"object"!=typeof e)return!1;const t="name"in e?String(e.name):"";return an(e)||t===nn})(t)&&(tc=!0),c(r)}):c(r)})(t,(s,n)=>{var r,o,a;e.rateLimiter.checkForLimiting(s),400>s.statusCode||null===(r=(o=e.config).on_request_error)||void 0===r||r.call(o,s),i?i(s,n):null===(a=t.callback)||void 0===a||a.call(t,s)})):t.fireCallbackOnDrop&&(null===(o=t.callback)||void 0===o||o.call(t,{statusCode:0}))}var yc=class{constructor(e,t){this._isPaused=!0,this._queue=[],this._flushTimeoutMs=zt((null==t?void 0:t.flush_interval_ms)||3e3,250,5e3,Ir.createLogger("flush interval"),3e3),this._sendRequest=e}enqueue(e){this._queue.push(e),this._flushTimeout||this._setFlushTimeout()}unload(){this._clearFlushTimeout();const e=this._queue.length>0?this._formatQueue():{},t=Object.values(e);[...t.filter(e=>0===e.url.indexOf("/e")),...t.filter(e=>0!==e.url.indexOf("/e"))].map(e=>{this._sendRequestSafely(as(as({},e),{},{callback:void 0}),"sendBeacon")})}enable(){this._isPaused=!1,this._setFlushTimeout()}_setFlushTimeout(){this._isPaused||(this._flushTimeout=setTimeout(()=>{this._clearFlushTimeout(),this._flush()},this._flushTimeoutMs))}_flush(){if(this._queue.length>0){const e=this._formatQueue();for(const t in e)this._sendRequestSafely(e[t])}}_sendRequestSafely(e,t){try{this._sendRequest(e,t)}catch(e){Ir.error(e)}}_clearFlushTimeout(){clearTimeout(this._flushTimeout),this._flushTimeout=void 0}_formatQueue(){const e={},t={};Rr(this._queue,i=>{var s;const n=i,r=((n?n.batchKey:null)||n.url)+(n.batchGroup?`:${n.batchGroup}`:"");vt(e[r])&&(e[r]=as(as({},n),{},{data:[],callback:void 0,fireCallbackOnDrop:void 0}),t[r]=[]),null===(s=e[r].data)||void 0===s||s.push(n.data),n.callback&&t[r].push(n.callback)});for(const i in t){const s=t[i];s.length&&(e[i].callback=e=>{for(const t of s)t(e)})}return this._queue=[],e}};const bc=["retriesPerformedSoFar"];var wc=class{constructor(e){this._instance=e,this._isPolling=!1,this._pollIntervalMs=3e3,this._queue=[],this._queue=[],this._areWeOnline=!0,this.resume()}resume(){if(!vt(je)&&"onLine"in je.navigator){if(this._areWeOnline=je.navigator.onLine,this._onlineListener)return;this._onlineListener=()=>{this._areWeOnline=!0,this._flush()},this._offlineListener=()=>{this._areWeOnline=!1},Br(je,"online",this._onlineListener),Br(je,"offline",this._offlineListener)}}get length(){return this._queue.length}retriableRequest(e,t){let{retriesPerformedSoFar:i}=e,s=hn(e,bc);Ct(i)&&(s.url=sc(s.url,{retry_count:i})),mc(this._instance,t?as(as({},s),{},{transport:t}):s,(e,t)=>{var n;if(200!==e.statusCode&&(400>e.statusCode||e.statusCode>=500)){if((0===e.statusCode?3:10)>(null!=i?i:0))return void this._enqueue(as({retriesPerformedSoFar:i},s),t);0===e.statusCode&&Ir.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!=i?i:0} retries.`)}null===(n=s.callback)||void 0===n||n.call(s,e)})}_enqueue(e,t){const i=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=i+1;const s=Math.max(function(e){const t=3e3*Math.pow(2,e),i=t/2,s=Math.min(18e5,t),n=(Math.random()-.5)*(s-i);return Math.ceil(s+n)}(i),null!=t?t:0),n=Date.now()+s;this._queue.push({retryAt:n,requestOptions:e});let r=`Enqueued failed request for retry in ${s}`;navigator.onLine||(r+=" (Browser is offline)"),Ir.warn(r),this._isPolling||(this._isPolling=!0,this._poll())}_poll(){if(this._poller&&clearTimeout(this._poller),0===this._queue.length)return this._isPolling=!1,void(this._poller=void 0);this._poller=setTimeout(()=>{this._areWeOnline&&this._queue.length>0&&this._flush(),this._poll()},this._pollIntervalMs)}_flush(){const e=Date.now(),t=[],i=this._queue.filter(i=>e>i.retryAt||(t.push(i),!1));if(this._queue=t,i.length>0)for(const{requestOptions:e}of i)this.retriableRequest(e)}unload(){this._poller&&(clearTimeout(this._poller),this._poller=void 0),this._isPolling=!1,vt(je)||(this._onlineListener&&(je.removeEventListener("online",this._onlineListener),this._onlineListener=void 0),this._offlineListener&&(je.removeEventListener("offline",this._offlineListener),this._offlineListener=void 0));for(const{requestOptions:e}of this._queue)try{this._instance._send_request(as(as({},e),{},{callback:_t(e.data)?void 0:e.callback,transport:"sendBeacon"}))}catch(e){Ir.error(e)}this._queue=[]}},Sc=class{constructor(e){this._instance=e,this._updateScrollData=()=>{var e,t,i,s;this._context||(this._context={});const n=this.scrollElement(),r=this.scrollY(),o=n?Math.max(0,n.scrollHeight-n.clientHeight):0,a=r+((null==n?void 0:n.clientHeight)||0),l=(null==n?void 0:n.scrollHeight)||0;this._context.lastScrollY=Math.ceil(r),this._context.maxScrollY=Math.max(r,null!==(e=this._context.maxScrollY)&&void 0!==e?e:0),this._context.maxScrollHeight=Math.max(o,null!==(t=this._context.maxScrollHeight)&&void 0!==t?t:0),this._context.lastContentY=a,this._context.maxContentY=Math.max(a,null!==(i=this._context.maxContentY)&&void 0!==i?i:0),this._context.maxContentHeight=Math.max(l,null!==(s=this._context.maxContentHeight)&&void 0!==s?s:0)}}get _scrollRoot(){return this._instance.config.scroll_root_selector}getContext(){return this._context}resetContext(){const e=this._context;return this._context=void 0,setTimeout(this._updateScrollData,0),e}startMeasuringScrollPosition(){Br(je,"scroll",this._updateScrollData,{capture:!0}),Br(je,"scrollend",this._updateScrollData,{capture:!0}),Br(je,"resize",this._updateScrollData)}scrollElement(){if(this._scrollRoot){const t=_t(this._scrollRoot)?this._scrollRoot:[this._scrollRoot];for(const i of t){var e;const t=null==je||null===(e=je.document)||void 0===e?void 0:e.querySelector(i);if(t)return t}return}var t;return null==je||null===(t=je.document)||void 0===t?void 0:t.documentElement}_scrollPosition(e){var t,i;const s="y"===e?"scrollTop":"scrollLeft";if(this._scrollRoot){const e=this.scrollElement();return e&&e[s]||0}return je?"y"===e?je.scrollY||je.pageYOffset||(null===(t=je.document)||void 0===t||null===(t=t.documentElement)||void 0===t?void 0:t.scrollTop)||0:je.scrollX||je.pageXOffset||(null===(i=je.document)||void 0===i||null===(i=i.documentElement)||void 0===i?void 0:i.scrollLeft)||0:0}scrollY(){return this._scrollPosition("y")}scrollX(){return this._scrollPosition("x")}};const Cc=e=>Ua(null==e?void 0:e.config.mask_personal_data_properties,null==e?void 0:e.config.custom_personal_data_properties,null==e?void 0:e.config.disable_capture_url_hashes);var kc=class{constructor(e,t,i,s){this._onSessionIdCallback=e=>{const t=this._getStored();if(t&&t.sessionId===e)return;const i={sessionId:e,props:this._sessionSourceParamGenerator(this._instance)};this._persistence.register({[fe]:i})},this._instance=e,this._sessionIdManager=t,this._persistence=i,this._sessionSourceParamGenerator=s||Cc,this._sessionIdManager.onSessionId(this._onSessionIdCallback)}_getStored(){return this._persistence.props[fe]}getSetOnceProps(){var e;const t=null===(e=this._getStored())||void 0===e?void 0:e.props;return t?"r"in t?qa(t,this._instance.config.disable_capture_url_hashes):{$referring_domain:t.referringDomain,$pathname:t.initialPathName,utm_source:t.utm_source,utm_campaign:t.utm_campaign,utm_medium:t.utm_medium,utm_content:t.utm_content,utm_term:t.utm_term}:{}}getSessionProps(){const e={};return Rr(Lr(this.getSetOnceProps()),(t,i)=>{"$current_url"===i&&(i="url"),e[`$session_entry_${lt(i)}`]=t}),e}},Ec=class{on(e,t){return this._events[e]||(this._events[e]=[]),this._events[e].push(t),()=>{this._events[e]=this._events[e].filter(e=>e!==t)}}emit(e,t){for(const i of this._events[e]||[])i(t);for(const i of this._events["*"]||[])i(e,t)}constructor(){this._events={}}};const xc=Fr("[SessionId]"),Pc=864e5;var Ic=class{on(e,t){return this._eventEmitter.on(e,t)}constructor(e,t,i){var s;if(this._lastPersistedActivityTimestamp=null,this._lastCookieSyncTimestamp=null,this._sessionIdChangedHandlers=[],this._beforeUnloadListener=void 0,this._destroyed=!1,this._eventEmitter=new Ec,this._sessionHasBeenIdleTooLong=(e,t)=>!(!Ct(e)||!Ct(t))&&Math.abs(e-t)>this.sessionTimeoutMs,!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if("always"===e.config.cookieless_mode)throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this._config=e.config,this._persistence=e.persistence,this._windowId=void 0,this._sessionId=void 0,this._sessionStartTimestamp=null,this._pendingBootstrapSession=void 0,this._sessionActivityTimestamp=null,this._sessionIdGenerator=t||Kr,this._windowIdGenerator=i||Kr;const n=this._config.persistence_name||this._config.token;if(this._sessionTimeoutMs=1e3*zt(this._config.session_idle_timeout_seconds||1800,60,36e3,xc.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this._resetIdleTimer(),this._window_id_storage_key="ph_"+n+"_window_id",this._primary_window_exists_storage_key="ph_"+n+"_primary_window_exists",this._canUseSessionStorage()){const e=fo._parse(this._window_id_storage_key),t=fo._parse(this._primary_window_exists_storage_key);e&&!t?this._windowId=e:fo._remove(this._window_id_storage_key),fo._set(this._primary_window_exists_storage_key,!0)}(null===(s=this._config.bootstrap)||void 0===s?void 0:s.sessionID)&&this.setBootstrapSessionId(this._config.bootstrap.sessionID),this._listenToReloadWindow()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return vt(this._sessionIdChangedHandlers)&&(this._sessionIdChangedHandlers=[]),this._sessionIdChangedHandlers.push(e),this._sessionId&&e(this._sessionId,this._windowId),()=>{this._sessionIdChangedHandlers=this._sessionIdChangedHandlers.filter(t=>t!==e)}}_canUseSessionStorage(){return"memory"!==this._config.persistence&&!this._persistence._disabled&&fo._is_supported()}_setWindowId(e){e!==this._windowId&&(this._windowId=e,this._canUseSessionStorage()&&fo._set(this._window_id_storage_key,e))}_getWindowId(){return this._windowId?this._windowId:this._canUseSessionStorage()?fo._parse(this._window_id_storage_key):null}_isActivityChangeBelowGranularity(e){const t=this._lastPersistedActivityTimestamp;return!bt(t)&&!bt(e)&&5e3>Math.abs(e-t)}_setSessionId(e,t,i){const s=t!==this._sessionActivityTimestamp,n=!(e!==this._sessionId||i!==this._sessionStartTimestamp);this._sessionStartTimestamp=i,this._sessionActivityTimestamp=t,this._sessionId=e,n&&!s||n&&this._isActivityChangeBelowGranularity(t)||(this._lastPersistedActivityTimestamp=t,this._persistence.register({[ee]:[t,e,i]}))}_useCrossTabRefreshHardening(){var e;const t=null===(e=this._config)||void 0===e?void 0:e.persistence_save_debounce_ms;return Ct(t)&&t>0}_refreshSessionIdFromStorage(){this._useCrossTabRefreshHardening()?this._persistence.refreshKey(ee):(this._persistence.flush(),this._persistence.load())}_flushPendingActivityTimestamp(){var e;if(bt(this._sessionActivityTimestamp)||this._sessionActivityTimestamp===this._lastPersistedActivityTimestamp)return;this._refreshSessionIdFromStorage();const[,t,i]=this._getSessionId();t===this._sessionId&&i===this._sessionStartTimestamp&&(this._lastPersistedActivityTimestamp=this._sessionActivityTimestamp,this._persistence.register({[ee]:[this._sessionActivityTimestamp,null!==(e=this._sessionId)&&void 0!==e?e:null,this._sessionStartTimestamp]}),this._persistence.flush())}_freshestActivityTimestamp(){const[e]=this._getSessionId(),t=Ct(e)?e:0,i=Ct(this._sessionActivityTimestamp)?this._sessionActivityTimestamp:0;return Math.max(t,i)}_isSessionIdleAfterCrossTabRefresh(e){return this._refreshSessionIdFromStorage(),this._sessionHasBeenIdleTooLong(e,this._freshestActivityTimestamp())}_getSessionId(){const e=this._persistence.props[ee];return _t(e)&&2===e.length&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this._lastPersistedActivityTimestamp=null,this._pendingBootstrapSession=void 0,clearTimeout(this._enforceIdleTimeout),this._enforceIdleTimeout=void 0,this._setSessionId(null,null,null)}setBootstrapSessionId(e,t=!1){const i=((e,t=(new Date).getTime())=>{try{const i=(e=>{const t=e.replace(/-/g,"");if(32!==t.length)throw new Error("Not a valid UUID");if("7"!==t[12])throw new Error("Not a UUIDv7");return parseInt(t.substring(0,12),16)})(e);return i>t+6e4?void xc.error("Bootstrap sessionID cannot be in the future"):i}catch(e){return void xc.error("Invalid sessionID in bootstrap",e)}})(e);return!vt(i)&&(t?this._pendingBootstrapSession={sessionId:e,sessionStartTimestamp:i}:this._setSessionId(e,(new Date).getTime(),i),!0)}destroy(){this._destroyed=!0,this._flushPendingActivityTimestamp(),clearTimeout(this._enforceIdleTimeout),this._enforceIdleTimeout=void 0,this._beforeUnloadListener&&je&&(je.removeEventListener(Be,this._beforeUnloadListener,{capture:!1}),this._beforeUnloadListener=void 0),this._sessionIdChangedHandlers=[]}_listenToReloadWindow(){this._beforeUnloadListener=()=>{this._flushPendingActivityTimestamp(),this._canUseSessionStorage()&&fo._remove(this._primary_window_exists_storage_key)},Br(je,Be,this._beforeUnloadListener,{capture:!1})}checkAndGetSessionAndWindowId(e=!1,t=null,i=!1){if("always"===this._config.cookieless_mode)throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');const s=t||(new Date).getTime(),n=this._sessionId;if(i)this._lastCookieSyncTimestamp=s;else if(bt(this._lastCookieSyncTimestamp)||this._lastCookieSyncTimestamp>s||s-this._lastCookieSyncTimestamp>=1e3){var r,o;null===(r=(o=this._persistence).syncCookieProperties)||void 0===r||r.call(o),this._lastCookieSyncTimestamp=s}let[,a,l]=this._getSessionId();const c=!vt(n)&&a!==n,u=this._freshestActivityTimestamp();let d=this._getWindowId();const h=this._pendingBootstrapSession,_=!!h&&(h.sessionStartTimestamp>s+6e4||s-h.sessionStartTimestamp>Pc),p=h?_:Ct(l)&&Math.abs(s-l)>Pc;let g=!1,f=c,v=!a||!!h;const m=a;let y=!v&&!e&&this._sessionHasBeenIdleTooLong(s,u);if(y&&(y=this._isSessionIdleAfterCrossTabRefresh(s),y||xc.info("cross-tab refresh kept the session alive",{sessionId:a}),[,a,l]=this._getSessionId(),y||(v=!a||!!h)),v||y||p){f=!1;const e=h&&!_;a=e?h.sessionId:this._sessionIdGenerator(),d=this._windowIdGenerator(),xc.info("new session ID assigned",{sessionId:a,windowId:d,bootstrapped:!!e,changeReason:{noSessionId:v,activityTimeout:y,sessionPastMaximumLength:p}}),l=e?h.sessionStartTimestamp:s,this._pendingBootstrapSession=void 0,g=!0}else d||(d=this._windowIdGenerator(),g=!0),f=f||a!==m,f&&(xc.info("adopted cross-tab session id",{sessionId:a,windowId:d}),g=!0);const b=Ct(u)&&e&&!p?u:s,w=Ct(l)?l:(new Date).getTime();this._setWindowId(d),this._setSessionId(a,b,w),e||this._resetIdleTimer();const S={noSessionId:v,activityTimeout:y,sessionPastMaximumLength:p,crossTabAdoption:f};return g&&this._sessionIdChangedHandlers.forEach(e=>e(a,d,S)),{sessionId:a,windowId:d,sessionStartTimestamp:w,changeReason:g?S:void 0,lastActivityTimestamp:u}}_resetIdleTimer(){this._destroyed||(clearTimeout(this._enforceIdleTimeout),this._enforceIdleTimeout=setTimeout(()=>{if(!this._destroyed)if(this._isSessionIdleAfterCrossTabRefresh((new Date).getTime())){const e=this._sessionId;this.resetSessionId(),this._eventEmitter.emit("forcedIdleReset",{idleSessionId:e})}else this._resetIdleTimer()},1.1*this.sessionTimeoutMs))}};const Fc=Object.freeze(["2026-08-30","2026-08-29","2026-06-25","2026-05-30","2026-01-30","2025-11-30","2025-05-24"]),Tc=function(e,t){if(!e)return!1;const i=e.userAgent;if(i&&Bt(i,t))return!0;try{const i=null==e?void 0:e.userAgentData;if((null==i?void 0:i.brands)&&i.brands.some(e=>Bt(null==e?void 0:e.brand,t)))return!0}catch(e){}return!!e.webdriver};function Rc(){return(Rc=Ot(function*(){const e=null==Ve?void 0:Ve.userAgentData;if(null==e?void 0:e.getHighEntropyValues)try{const t=yield e.getHighEntropyValues(["model"]),i=null==t?void 0:t.model;return mt(i)&&i.length>0?i:void 0}catch(e){return void Ir.info("Unable to resolve $device_model from userAgentData.getHighEntropyValues",e)}})).apply(this,arguments)}function Ac(e,t){let i=`$survey_${t}/${e.id}`;return e.current_iteration&&e.current_iteration>0&&(i=`$survey_${t}/${e.id}/${e.current_iteration}`),i}function $c(e){var t;return!!(null===(t=e.conditions)||void 0===t||null===(t=t.events)||void 0===t||null===(t=t.values)||void 0===t?void 0:t.length)}const Mc=(e,t)=>{if(!(e=>{try{new RegExp(e)}catch(e){return!1}return!0})(t))return!1;try{return new RegExp(t).test(e)}catch(e){return!1}},Lc=e=>e.toLowerCase(),Oc={exact:(e,t)=>t.some(t=>e.some(e=>t===e)),is_not:(e,t)=>t.every(t=>e.every(e=>t!==e)),regex:(e,t)=>t.some(t=>e.some(e=>Mc(t,e))),not_regex:(e,t)=>t.every(t=>e.every(e=>!Mc(t,e))),icontains:(e,t)=>t.map(Lc).some(t=>e.map(Lc).some(e=>t.includes(e))),not_icontains:(e,t)=>t.map(Lc).every(t=>e.map(Lc).every(e=>!t.includes(e))),gt:(e,t)=>t.some(t=>{const i=parseFloat(t);return!isNaN(i)&&e.some(e=>i>parseFloat(e))}),lt:(e,t)=>t.some(t=>{const i=parseFloat(t);return!isNaN(i)&&e.some(e=>i<parseFloat(e))})};function Dc(e,t){return!e||Object.entries(e).every(([e,i])=>{const s=null==t?void 0:t[e];if(null==s)return!1;const n=Oc[i.operator];return!!n&&n(i.values.map(String),[String(s)])})}function Nc(e,t,i){return Pa({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:i})}const Bc="custom",zc="i.posthog.com",Hc=/^\/static\//,Uc=["/s/","/e/","/i/"];var qc=class{constructor(e){this._regionCache={},this.instance=e}get apiHost(){const e=this.instance.config.api_host.trim().replace(/\/$/,"");return"https://app.posthog.com"===e?"https://us.i.posthog.com":e}get flagsApiHost(){const e=this.instance.config.flags_api_host;return e?e.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var e;let t=null===(e=this.instance.config.ui_host)||void 0===e?void 0:e.replace(/\/$/,"");return t||(t=this.apiHost.replace(`.${zc}`,".posthog.com")),"https://app.posthog.com"===t?"https://us.posthog.com":t}get region(){return this._regionCache[this.apiHost]||(this._regionCache[this.apiHost]=/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?"us":/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?"eu":Bc),this._regionCache[this.apiHost]}_staticAssetHostOverride(e){if(!Hc.test(e))return;const t=this.instance.config.asset_host;return"string"==typeof t&&t.trim().replace(/\/$/,"")||void 0}_urlKey(e){const t=Ca(e);return t?t.protocol+"//"+t.host+t.pathname:void 0}_prepareEndpoint(e,t,i){if("ui"===e)return i;let s=i;const n=this.instance.config.rewriteRequestPath;if(n){var r;const e=(null===(r=Ca(i))||void 0===r?void 0:r.href)||i;s=n(new URL(e)).toString()}if(n&&"api"===e&&Uc.some(e=>0===t.indexOf(e))){const e=this._urlKey(s);if(e){const t=this.apiHost;let i=this._ingestionEndpoints;(null==i?void 0:i.apiHost)===t&&i.rewriteRequestPath===n||(i={apiHost:t,rewriteRequestPath:n,urls:new Set},this._ingestionEndpoints=i),i.urls.add(e)}}return s}isIngestionEndpoint(e){const t=this._ingestionEndpoints,i=this._urlKey(e);return(null==t?void 0:t.apiHost)===this.apiHost&&t.rewriteRequestPath===this.instance.config.rewriteRequestPath&&!!i&&t.urls.has(i)}endpointFor(e,t=""){if(t&&(t="/"===t[0]?t:`/${t}`),"ui"===e)return this._prepareEndpoint(e,t,this.uiHost+t);if("flags"===e)return this._prepareEndpoint(e,t,this.flagsApiHost+t);if("assets"===e){const i=this._staticAssetHostOverride(t);if(i)return this._prepareEndpoint(e,t,`${i}${t}`)}if(this.region===Bc)return this._prepareEndpoint(e,t,this.apiHost+t);const i=zc+t;switch(e){case"assets":return this._prepareEndpoint(e,t,`https://${this.region}-assets.${i}`);case"api":return this._prepareEndpoint(e,t,`https://${this.region}.${i}`)}}};const jc=Fr("[Surveys]"),Wc=e=>{try{const t=(e=>((e,t)=>`seenSurvey_${function(e){return e.current_iteration&&e.current_iteration>0?`${e.id}_${e.current_iteration}`:e.id}(t)}`)(0,e))(e);if(localStorage.getItem(t))return;localStorage.setItem(t,"true")}catch(e){jc.error("Failed to persist survey seen state",e)}},Vc=["popover","widget","api"],Gc={ignoreConditions:!1,ignoreDelay:!1,displayType:hl},Kc=Fr("[PostHog ExternalIntegrations]"),Qc={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};var Jc=class{constructor(e){this._instance=e}_loadScript(e,t){var i,s;null===(i=tt.__PosthogExtensions__)||void 0===i||null===(s=i.loadExternalDependency)||void 0===s||s.call(i,this._instance,e,e=>{if(e)return Kc.error("failed to load script",e);t()})}startIfEnabledOrStop(){var e;for(const[n,r]of Object.entries(null!==(e=this._instance.config.integrations)&&void 0!==e?e:{})){var t,i,s;r&&!(null===(t=tt.__PosthogExtensions__)||void 0===t||null===(t=t.integrations)||void 0===t?void 0:t[n])&&this._loadScript(Qc[n],()=>{var e;null===(e=tt.__PosthogExtensions__)||void 0===e||null===(e=e.integrations)||void 0===e||null===(e=e[n])||void 0===e||e.start(this._instance)}),!r&&(null===(i=tt.__PosthogExtensions__)||void 0===i||null===(i=i.integrations)||void 0===i?void 0:i[n])&&(null===(s=tt.__PosthogExtensions__)||void 0===s||null===(s=s.integrations)||void 0===s||null===(s=s[n])||void 0===s||s.stop())}}},Yc=class{constructor(e){this.disabled=!1===e;const t=gt(e)?e:{};this.thresholdPx=t.threshold_px||30,this.timeoutMs=t.timeout_ms||1e3,this.clickCount=t.click_count||3,this.clicks=[]}isRageClick(e,t,i){if(this.disabled)return!1;const s=this.clicks[this.clicks.length-1];if(s&&Math.abs(e-s.x)+Math.abs(t-s.y)<this.thresholdPx&&this.timeoutMs>i-s.timestamp){if(this.clicks.push({x:e,y:t,timestamp:i}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:e,y:t,timestamp:i}];return!1}};const Xc=()=>typeof window>"u"?void 0:window,Zc=()=>typeof document>"u"?void 0:document,eu="$copy_autocapture",tu=["password","hidden","file","checkbox","button","submit","reset","image"],iu=Fr("[AutoCapture]");function su(e,t){return t.length>e?t.slice(0,e)+"...":t}function nu(e){if(e.previousElementSibling)return e.previousElementSibling;let t=e;do{t=t.previousSibling}while(t&&!bo(t));return t}function ru(e,{e:t,maskAllElementAttributes:i,maskAllText:s,elementAttributeIgnoreList:n,elementsChainAsString:r,disableCaptureUrlHashes:o}){var a,l;if(!bo(e))return{props:{}};const c=[e],u=new Set([e]);let d=e;for(;d.parentNode&&!wo(d,"body")&&1e3>c.length;){if(Co(d.parentNode)){const e=d.parentNode.host;if(u.has(e))break;u.add(e),c.push(e),d=e;continue}if(!bo(d.parentNode))break;if(u.has(d.parentNode))break;u.add(d.parentNode),c.push(d.parentNode),d=d.parentNode}const h="click"===t.type&&"http://www.w3.org/2000/svg"===e.namespaceURI?c.findIndex(e=>wo(e,"button")||wo(e,"a")):-1;h>0&&(s=s||c.slice(0,h+1).some(e=>!Ko(e)||Qo(e)));const _=[],p={};let g,f=!1,v=!1;if(Rr(c,e=>{const t=Ko(e);if(wo(e,"a")&&!i&&!(null==n?void 0:n.includes("href"))){const i=e.getAttribute("href");f=!!(t&&i&&sa(i))&&(o?Zi(i):i)}ot(xo(e),"ph-no-capture")&&(v=!0),_.push(function(e,t,i,s,n=!1){const r=e.tagName.toLowerCase(),o={tag_name:r};To.indexOf(r)>-1&&!i&&(o.$el_text="a"===r.toLowerCase()||"button"===r.toLowerCase()?su(1024,na(e)):su(1024,Io(e)));const a=xo(e);t||(null==s?void 0:s.includes("class"))||0>=a.length||(o.classes=a.filter(function(e){return""!==e})),Rr(e.attributes,function(i){var r;if((!Qo(e)||-1!==["name","id","class","aria-label"].indexOf(i.name))&&!(null==s?void 0:s.includes(i.name))&&!t&&sa(i.value)&&(!mt(r=i.name)||"_ngcontent"!==r.substring(0,10)&&"_nghost"!==r.substring(0,7))){let e=i.value;"class"===i.name&&(e=ko(e).join(" ")),o["attr__"+i.name]=su(1024,"href"===i.name&&n?Zi(e):e)}});let l=1,c=1,u=e;for(;u=nu(u);)l++,u.tagName===e.tagName&&c++;return o.nth_child=l,o.nth_of_type=c,o}(e,i,s,n,o)),Rr(function(e){if(!Ko(e))return{};const t={};return Rr(e.attributes,function(e){if(e.name&&0===e.name.indexOf("data-ph-capture-attribute")){const i=e.name.replace("data-ph-capture-attribute-",""),s=e.value;i&&s&&sa(s)&&(t[i]=s)}}),t}(e),(e,t)=>{({}).hasOwnProperty.call(p,t)||(p[t]=e)})}),v)return{props:{},explicitNoCapture:v};if(h>0&&(e=c[h],_.splice(0,h)),s||(_[0].$el_text=wo(e,"a")||wo(e,"button")?na(e):Io(e)),f){var m,y;_[0].attr__href=f;const e=null===(m=Ca(f))||void 0===m?void 0:m.host,t=null===(y=Xc())||void 0===y||null===(y=y.location)||void 0===y?void 0:y.host;e&&t&&e!==t&&(g=f)}return{props:Ar((w=t.type,{$event_type:w,$ce_version:1}),r?{}:{$elements:_},{$elements_chain:(b=_,_t(b)?function(e){return e.map(e=>{var t,i;let s="";if(e.tag_name&&(s+=e.tag_name),e.attr_class){e.attr_class.sort();for(const t of e.attr_class)s+=`.${t.replace(/"/g,"")}`}const n=as(as(as(as({},e.text?{text:e.text}:{}),{},{"nth-child":null!==(t=e.nth_child)&&void 0!==t?t:0,"nth-of-type":null!==(i=e.nth_of_type)&&void 0!==i?i:0},e.href?{href:e.href}:{}),e.attr_id?{attr_id:e.attr_id}:{}),e.attributes),r={};return $r(n).sort(([e],[t])=>function(e,t){return t>e?-1:e>t?1:0}(e,t)).forEach(([e,t])=>r[oa(e.toString())]=oa(t.toString())),s+=":",s+=$r(r).map(([e,t])=>`${e}="${t}"`).join(""),s}).join(";")}(function(e){return e.map(e=>{var t,i;const s={text:null===(t=e.$el_text)||void 0===t?void 0:t.slice(0,400),tag_name:e.tag_name,href:null===(i=e.attr__href)||void 0===i?void 0:i.slice(0,2048),attr_class:aa(e),attr_id:e.attr__id,nth_child:e.nth_child,nth_of_type:e.nth_of_type,attributes:{}};return $r(e).filter(([e])=>0===e.indexOf("attr__")).forEach(([e,t])=>s.attributes[e]=t),s})}(b)):"")},(null===(a=_[0])||void 0===a?void 0:a.$el_text)?{$el_text:null===(l=_[0])||void 0===l?void 0:l.$el_text}:{},g&&"click"===t.type?{$external_click_url:g}:{},p),target:e};var b,w}const ou="autocapture";var au=class{_clearPointer(){this._pointerDown=void 0,clearTimeout(this._pointerExpiry),this._pointerExpiry=void 0}_isExcludedPointerTarget(e){var t;if(!Ko(e))return!0;const i=null!==(t=this._refreshConfig().css_selector_ignorelist)&&void 0!==t?t:Mo,s=new Set;let n=e;for(;n;){if(s.size>=1e3||s.has(n))return!0;s.add(n);const e=n,t=xo(e);if(ot(t,"ph-no-capture")||ot(t,"ph-sensitive")||Qo(e)||i.some(t=>Ro(e,t)))return!0;const r=n.parentNode;n=Co(r)?r.host:r&&bo(r)?r:null}return!1}_trackPointer(e){if(!this.isEnabled||"pointercancel"===e.type)return void this._clearPointer();if("pointerdown"===e.type){var t;this._clearPointer();const i=Fo(e);return void(e.isPrimary&&0===e.button&&!e.ctrlKey&&i&&bo(i)&&(this._pointerDown={target:i,excluded:this._isExcludedPointerTarget(i),id:e.pointerId,x:e.clientX,y:e.clientY,released:!1,distinctId:null===(t=this._client)||void 0===t?void 0:t.distinctId}))}const i=this._pointerDown;i&&(e.pointerId!==i.id||Math.abs(e.clientX-i.x)>5||Math.abs(e.clientY-i.y)>5?this._clearPointer():"pointerup"===e.type&&(i.released=!0,this._pointerExpiry=setTimeout(()=>this._clearPointer(),0)))}_recoverClickTarget(e){var t;const i=this._pointerDown;this._clearPointer();const s=Fo(e);if((null==i?void 0:i.released)&&i.target.isConnected&&i.distinctId===(null===(t=this._client)||void 0===t?void 0:t.distinctId)&&e.pointerId===i.id&&(e.detail>0||"touch"===e.pointerType||"pen"===e.pointerType)&&0===e.button&&5>=Math.abs(e.clientX-i.x)&&5>=Math.abs(e.clientY-i.y)&&s&&(wo(s,"html")||wo(s,"body"))){var n,r,o;if(i.excluded)return null;const e=null!==(n=this._refreshConfig().css_selector_ignorelist)&&void 0!==n?n:Mo;return[s,null===(r=Zc())||void 0===r?void 0:r.documentElement,null===(o=Zc())||void 0===o?void 0:o.body].some(t=>{if(!t)return!1;const i=xo(t);return ot(i,"ph-no-capture")||ot(i,"ph-sensitive")||!Ko(t)||Qo(t)||e.some(e=>Ro(t,e))})?null:i.target}}constructor(e){this._configSource=e,this.name=ou,this._initialized=!1,this._isDisabledServerSide=null,this._hasReceivedConfigResponse=!1,this._elementSelectorsByOwner=new Map,this._elementsChainAsString=!1,this._config={enabled:!1,rageclick:!1,maskAllElementAttributes:!1,maskAllText:!1,disableCaptureUrlHashes:!1,remoteRequestsDisabled:!1},this._disposed=!1,this._configSource.refresh(this._config),this.rageclicks=new Yc(this._config.rageclick),this._elementSelectors=null}setup(e){this._compileUrlPatterns(),this._client=e;const t=e.onRemoteConfig(this.onRemoteConfig.bind(this));this._disposed?t.dispose():(this._remoteConfigSubscription=t,this.startIfEnabled())}dispose(){var e;this._disposed||(this._disposed=!0,this._client=void 0,null===(e=this._remoteConfigSubscription)||void 0===e||e.dispose(),this._remoteConfigSubscription=void 0,this._elementSelectorsByOwner.clear(),this._elementSelectors=null,this._removeDomEventHandlers())}_refreshConfig(){return this._configSource.refresh(this._config),this._config}_compileUrlPatterns(){var e,t;return this._refreshConfig(),this._config.url_allowlist=null===(e=this._config.url_allowlist)||void 0===e?void 0:e.map(e=>new RegExp(e)),this._config.url_ignorelist=null===(t=this._config.url_ignorelist)||void 0===t?void 0:t.map(e=>new RegExp(e)),this._config}_addDomEventHandlers(){const e=Xc(),t=Zc();if(!this.isBrowserSupported())return void iu.info("Disabling Automatic Event Collection because this browser is not supported");if(!e||!t)return;this._listenerWindow=e,this._listenerDocument=t;const i=this._domEventHandler=t=>{t=t||(null==e?void 0:e.event);try{if("blur"===t.type)return void this._clearPointer();if(0===t.type.indexOf("pointer"))return void this._trackPointer(t);const e="click"===t.type?this._recoverClickTarget(t):void 0;if(bt(e))return;this._captureEvent(t,"$autocapture",e)}catch(e){iu.error("Failed to capture event",e)}};if(Br(e,"blur",i),Br(t,"submit",i,{capture:!0}),Br(t,"change",i,{capture:!0}),Br(t,"click",i,{capture:!0}),Rr(["pointerdown","pointermove","pointerup","pointercancel"],e=>{Br(t,e,i,{capture:!0})}),this._refreshConfig().capture_copied_text){const i=this._copiedTextHandler=t=>{t=t||(null==e?void 0:e.event);try{this._captureEvent(t,eu)}catch(e){iu.error("Failed to capture clipboard event",e)}};Br(t,"copy",i,{capture:!0}),Br(t,"cut",i,{capture:!0}),Br(t,"paste",i,{capture:!0})}}_removeDomEventHandlers(){const e=this._listenerWindow,t=this._listenerDocument;this._clearPointer(),this._domEventHandler&&(null==e||e.removeEventListener("blur",this._domEventHandler),Rr(["pointerdown","pointermove","pointerup","pointercancel"],e=>{null==t||t.removeEventListener(e,this._domEventHandler,!0)}),null==t||t.removeEventListener("submit",this._domEventHandler,!0),null==t||t.removeEventListener("change",this._domEventHandler,!0),null==t||t.removeEventListener("click",this._domEventHandler,!0),this._domEventHandler=void 0),this._copiedTextHandler&&(null==t||t.removeEventListener("copy",this._copiedTextHandler,!0),null==t||t.removeEventListener("cut",this._copiedTextHandler,!0),null==t||t.removeEventListener("paste",this._copiedTextHandler,!0),this._copiedTextHandler=void 0),this._listenerWindow=void 0,this._listenerDocument=void 0,this._initialized=!1}startIfEnabled(){this.isEnabled||this._clearPointer(),!this._disposed&&this._client&&this.isEnabled&&!this._initialized&&(this._addDomEventHandlers(),this._initialized=!0)}onRemoteConfig(e){if(this._disposed)return;if(this._hasReceivedConfigResponse=!0,!e.ok)return void this.startIfEnabled();const t=e.config;t.elementsChainAsString&&(this._elementsChainAsString=t.elementsChainAsString);const i=t.autocapture_opt_out;var s;kt(i)&&(null===(s=this._client)||void 0===s||s.kv.set("$autocapture_disabled_server_side",i),this._isDisabledServerSide=i),this.startIfEnabled()}setElementSelectors(e,t=this){if(this._disposed)return;e.size?this._elementSelectorsByOwner.set(t,new Set(e)):this._elementSelectorsByOwner.delete(t);const i=new Set;this._elementSelectorsByOwner.forEach(e=>{e.forEach(e=>i.add(e))}),this._elementSelectors=i}getElementSelectors(e,t){var i;const s=[];return null===(i=this._elementSelectors)||void 0===i||i.forEach(i=>{var n;const r=null===(n=Zc())||void 0===n?void 0:n.querySelectorAll(i);null==r||r.forEach(n=>{e!==n&&t!==n||ot(s,i)||s.push(i)})}),s}get isEnabled(){var e,t;if(this._disposed)return!1;const i=null===(e=this._client)||void 0===e?void 0:e.kv.get(y),s=this._isDisabledServerSide,n=this._refreshConfig();if(!n.remoteRequestsDisabled&&!this._hasReceivedConfigResponse)return!1;const r=n.remoteRequestsDisabled&&!this._hasReceivedConfigResponse;if(bt(s)&&!kt(i)&&!r)return!1;const o=null!==(t=this._isDisabledServerSide)&&void 0!==t?t:!!i;return!!n.enabled&&!o}_captureEvent(e,t="$autocapture",i){if(!this.isEnabled)return void this._clearPointer();let s=i||Fo(e);So(s)&&(s=s.parentNode||null);const n=this._compileUrlPatterns();var r;"$autocapture"===t&&"click"===e.type&&e instanceof MouseEvent&&n.rageclick&&(null===(r=this.rageclicks)||void 0===r?void 0:r.isRageClick(e.clientX,e.clientY,e.timeStamp||(new Date).getTime()))&&Wo(s,n.rageclick)&&this._captureEvent(e,"$rageclick",i);const o=t===eu,a=o?as(as({},n),{},{dom_event_allowlist:void 0}):n;if(s&&function(e,t,i,s,n,r){var o;const a=typeof window>"u"?void 0:window;if(!a||Vo(e))return!1;if((null==i?void 0:i.url_allowlist)&&!Eo(i.url_allowlist,r))return!1;if((null==i?void 0:i.url_ignorelist)&&Eo(i.url_ignorelist,r))return!1;if(null==i?void 0:i.dom_event_allowlist){const e=i.dom_event_allowlist;if(e&&!e.some(e=>t.type===e))return!1}const{parentIsUsefulElement:l,targetElementList:c}=Go(e,s);if(!function(e,t){const i=null==t?void 0:t.element_allowlist;if(vt(i))return!0;for(const t of e)if(i.some(e=>t.tagName.toLowerCase()===e))return!0;return!1}(c,i))return!1;if(!Ao(c,null==i?void 0:i.css_selector_allowlist))return!1;if(Ao(c,null!==(o=null==i?void 0:i.css_selector_ignorelist)&&void 0!==o?o:Mo))return!1;try{const i=a.getComputedStyle(e);if(i&&"pointer"===i.getPropertyValue("cursor")&&"click"===t.type)return!0}catch(e){}const u=e.tagName.toLowerCase();switch(u){case"html":return!1;case"form":return(n||["submit"]).indexOf(t.type)>=0;case"input":case"select":case"textarea":return(n||["change","click"]).indexOf(t.type)>=0;default:return l?(n||["click"]).indexOf(t.type)>=0:(n||["click"]).indexOf(t.type)>=0&&(To.indexOf(u)>-1||"true"===e.getAttribute("contenteditable"))}}(s,e,a,o,o?["copy","cut","paste"]:void 0,{config:{get_current_url:n.getCurrentUrl}})){var l;const{props:i,explicitNoCapture:r,target:o}=ru(s,{e:e,maskAllElementAttributes:n.maskAllElementAttributes,maskAllText:n.maskAllText,elementAttributeIgnoreList:n.element_attribute_ignorelist,elementsChainAsString:this._elementsChainAsString,disableCaptureUrlHashes:n.disableCaptureUrlHashes});if(r)return!1;const a=this.getElementSelectors(s,o);if(a&&a.length>0&&(i.$element_selectors=a),t===eu){const t=e.type||"clipboard";if("paste"!==t){var c,u;const e=null===(c=Xc())||void 0===c||null===(c=c.getSelection())||void 0===c?void 0:c.toString(),t=Po(e);if(!t)return!1;i.$selected_content=t,i.$clipboard_text_length=null!==(u=null==e?void 0:e.length)&&void 0!==u?u:0}i.$copy_type=t}if("$autocapture"===t&&"change"===e.type&&n.capture_value_css_selector_allowlist&&!n.maskAllText&&(wo(d=s,"input")?!ot(tu,d.type):wo(d,"textarea")||wo(d,"select")&&!d.multiple)&&function(e,t){var i;if(!Ko(e))return!1;const s=null!==(i=t.css_selector_ignorelist)&&void 0!==i?i:Mo,n=new Set;let r=e;for(wo(e,"select")&&(r=e.options[e.selectedIndex]||e);r;){const e=r,t=xo(e);if(n.size>=1e3||n.has(r)||ot(t,"ph-sensitive")||ot(t,"ph-no-capture")||s.some(t=>Ro(e,t)))return!1;n.add(r);const i=r.assignedSlot||r.parentNode;r=Co(i)?i.host:i&&bo(i)?i:null}return!0}(s,n)&&!s.querySelector(".ph-no-capture, .ph-sensitive")){const e=n.capture_value_css_selector_allowlist;let t=!1;try{t=pt(e)?!!e(s):_t(e)&&e.some(e=>Ro(s,e))}catch(e){iu.error("capture_value_css_selector_allowlist threw",e)}t&&(i.$input_value=s.value)}return null===(l=this._client)||void 0===l||l.capture(t,i),!0}var d}isBrowserSupported(){var e;return pt(null===(e=Zc())||void 0===e?void 0:e.querySelectorAll)}};const lu="featureFlags",cu="logs",uu=()=>{var e;return(null==je||null===(e=je.performance)||void 0===e?void 0:e.now)?je.performance.now():Date.now()},du=[50,75,100,150,200,300,400,500,750,1e3,1500,2e3,3e3,5e3,1e4];var hu=class{constructor(e){this._instance=e}initialize(){}get(e){const t=this._instance.persistence;if("string"==typeof e)return null==t?void 0:t.get_property(e);const i={};for(const s of e){const e=null==t?void 0:t.get_property(s);vt(e)||(i[s]=e)}return i}set(e,t){var i;null===(i=this._instance.persistence)||void 0===i||i.register("string"==typeof e?{[e]:t}:e)}remove(e){var t;null===(t=this._instance.persistence)||void 0===t||t.unregister(e)}},_u=class{constructor(e){this.instance=e,this._logger=Ir,this.kv=new hu(e),this.onSession=e=>_l(this.instance.onSessionId(t=>{try{e(t)}catch(e){this._logger.error("Browser extension session listener failed",e)}})),this.onEvent=e=>_l(this.instance._addCaptureHook((t,i)=>{if(i)try{e({event:t,properties:i.properties})}catch(e){this._logger.error("Browser extension event listener failed",e)}})),this.onRemoteConfig=e=>{const t=t=>{try{e(t)}catch(e){this._logger.error("Browser extension remote config listener failed",e)}},i=this.instance._internalEventEmitter.on("extensionsRemoteConfig",t);return this.instance._lastRemoteConfig&&t(this.instance._lastRemoteConfig),_l(i)}}get logger(){return this._logger}get distinctId(){return this.instance.get_distinct_id()}get anonymousId(){var e;return null!==(e=this.instance.get_property("$device_id"))&&void 0!==e?e:this.distinctId}get deviceId(){const e=this.instance.get_property(I);return"string"==typeof e?e:void 0}get library(){return{name:i.LIB_NAME,version:i.LIB_VERSION}}get initialPersonProperties(){var e,t;return null!==(e=null===(t=this.instance.persistence)||void 0===t?void 0:t.get_initial_props())&&void 0!==e?e:{}}get groups(){return this.instance.getGroups()}get session(){try{var e,t,i,s,n;const r=null===(e=this.instance.sessionManager)||void 0===e?void 0:e.checkAndGetSessionAndWindowId(!0);return{sessionId:null!==(t=null==r?void 0:r.sessionId)&&void 0!==t?t:"",windowId:null!==(i=null==r?void 0:r.windowId)&&void 0!==i?i:"",sessionStartTimestamp:null!==(s=null==r?void 0:r.sessionStartTimestamp)&&void 0!==s?s:0,lastActivityTimestamp:null!==(n=null==r?void 0:r.lastActivityTimestamp)&&void 0!==n?n:0}}catch(e){return{sessionId:"",windowId:"",sessionStartTimestamp:0,lastActivityTimestamp:0}}}get isOptedOut(){return this.instance.has_opted_out_capturing()}get canCapture(){return pt(this.instance.is_capturing)?this.instance.is_capturing():!this.isOptedOut}get isRateLimited(){var e;return!!(null===(e=this.instance.rateLimiter)||void 0===e?void 0:e.isClientRateLimited)}get projectToken(){return this.instance.config.token}getExtension(e){let t;switch(e){case lu:case"featureFlagsCommon":t=this.instance.featureFlags;break;case cu:t=this.instance.logs;break;case"surveys":t=this.instance.surveys;break;case ou:t=this.instance.autocapture}return t}capture(e,t,i){if(!i)return this._notRateLimited(this.instance.capture(e,t));const s=as({timestamp:i.timestamp,uuid:i.uuid,$set:i.set,$set_once:i.setOnce},"unload"===i.delivery?{transport:"sendBeacon",send_instantly:!0}:{});return this._notRateLimited(this.instance.capture(e,t,s))}_notRateLimited(e){var t;return!vt(e)||!(null===(t=this.instance.rateLimiter)||void 0===t?void 0:t.lastEventRateLimited)}registerDynamicEventProperties(e){return _l(this.instance._registerExtensionEventProperties(e))}sendRequest(e){var t=this;return Ot(function*(e,i={}){var s;const n=null!==(s=i.target)&&void 0!==s?s:"api",r=i.query?sc(e,i.query):e,o=t.instance.requestRouter.endpointFor(n,r),a={method:i.method,url:o,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?st.Base64:void 0,timestampMode:i.sentAt};return"api"===n&&"/i/v1/logs"===e&&(a.batchKey="logs"),"sendBeacon"===i.transport?(t.instance._send_request(a),{statusCode:202}):new Promise(e=>{var i;if(a.callback=e,"flags"===n&&(null===(i=t.instance.config.metrics)||void 0===i?void 0:i.flags)){let i;a.onDispatch=()=>{i=uu()},a.callback=s=>{vt(i)||t._recordFlagsDuration(o,s,uu()-i),e(s)}}t.instance._send_request(a)})}).apply(this,arguments)}_recordFlagsDuration(e,t,i){try{var s,n,r;const o=t.statusCode||void 0,a={"server.address":(null!==(s=null===(n=Ca(e))||void 0===n?void 0:n.hostname)&&void 0!==s?s:e).replace(/^\[(.*)\]$/,"$1")};o&&(a["http.response.status_code"]=o);const l=((e,t)=>e?400>e?void 0:String(e):"AbortError"===(null==t?void 0:t.name)?"timeout":"_OTHER")(o,t.error);l&&(a["error.type"]=l);const c=Sa();c&&(a["client.timezone"]=c),null===(r=this.instance.metrics)||void 0===r||r.histogram("posthog.flags.request.duration",i,{unit:"ms",attributes:a,bounds:du})}catch(e){Ir.error("Failed to record the /flags request duration",e)}}};const pu={};let gu=0;const fu=()=>{},vu='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',mu="Surveys module not available",yu="sanitize_properties is deprecated. Use before_send instead",bu="Invalid value for property_denylist config: ",wu=["$recording_status","$sdk_debug_recording_script_not_loaded","$sdk_debug_replay_url_trigger_status","$sdk_debug_replay_event_trigger_status","$sdk_debug_replay_linked_flag_trigger_status","$sdk_debug_replay_rrweb_error","$sdk_debug_replay_internal_buffer_length","$sdk_debug_replay_flushed_size"],Su=["$feature_flag_called","$$heatmap","$snapshot"],Cu=e=>"$"===e.charAt(0)&&!ot(Su,e),ku=/^[A-Za-z0-9_-]{1,400}$/,Eu=/^fb\.[0-9]+\.[0-9]+\.[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)?$/,xu=/^fb\.[0-9]+\.[0-9]+\.[0-9]+$/,Pu=["token","distinct_id",Ce],Iu="posthog",Fu=[...Fc].sort()[Fc.length-1],Tu=e=>{const t={};return e&&"unset"!==e?("2025-11-30">e||(t.strictMinimumDuration=!0),"2026-05-30">e||(t.canvasCapture={resolutionScale:.6}),"2026-06-25">e||(t.streamNetworkBody=!0),"2026-08-30">e||(t.captureJsonLd=!0),t):t},Ru=e=>{var t;return as({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,asset_host:null,token:"",autocapture:!0,cross_subdomain_cookie:Nr(null==Ge?void 0:Ge.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:fu,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:null!=e?e:"unset",__preview_deferred_init_extensions:!1,__preview_replay_sync_fetch:!0,__preview_external_dependency_versioned_paths:!1,__preview_cookie_wins_on_conflict:!1,debug:Ke&&mt(null==Ke?void 0:Ke.search)&&-1!==Ke.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==je||null===(t=je.location)||void 0===t?void 0:t.protocol),ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_flags:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_only_evaluate_survey_feature_flags:!1,advanced_feature_flags_dedup_per_session:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,feature_flag_request_max_retries:1,surveys_request_timeout_ms:1e4,on_request_error(e){Ir.error("Bad HTTP status: "+e.statusCode+" "+e.text)},get_device_id:e=>e,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:Ne,before_send:void 0,get_current_url:void 0,request_queue_config:{flush_interval_ms:3e3},error_tracking:{},_onCapture:fu},(e=>({rageclick:e&&e>="2026-05-30"?{content_ignorelist:Oo,ignore_text_selection:!0}:!e||"2025-11-30">e||{content_ignorelist:!0},capture_pageview:!e||"2025-05-24">e||"history_change",session_recording:Tu(e),external_scripts_inject_target:e&&e>="2026-01-30"?"head":"body",internal_or_test_user_hostname:e&&e>="2026-01-30"?/^(localhost|127\.0\.0\.1)$/:void 0,persistence_save_debounce_ms:e&&e>="2026-05-30"?250:0,split_storage:!(!e||"2026-05-30">e),detect_google_search_app:!(!e||"2026-05-30">e),disable_capture_url_hashes:!(!e||"2026-06-25">e),cookieWinsOnConflict:!(!e||"unset"===e||"2026-08-29">e)}))(e))},Au=[["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"]],$u=e=>{const t={};for(const[i,s]of Au)vt(e[i])||(t[s]=e[i]);const i=Ar({},t,e),s=e.__preview_external_dependency_versioned_paths;return vt(s)||(vt(e.strict_script_versioning)&&(i.strict_script_versioning=!!s),mt(s)&&vt(e.asset_host)&&(i.asset_host=s)),_t(e.property_blacklist)&&(vt(e.property_denylist)?i.property_denylist=e.property_blacklist:_t(e.property_denylist)?i.property_denylist=[...e.property_blacklist,...e.property_denylist]:Ir.error(bu+e.property_denylist)),i};var Mu=class{constructor(){this.__forceAllowLocalhost=!1}get _forceAllowLocalhost(){return this.__forceAllowLocalhost}set _forceAllowLocalhost(e){Ir.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}},Lu=class e{_removeExtension(e){if(!e)return;const t=this._extensions.indexOf(e);-1!==t&&this._extensions.splice(t,1)}_replaceExtension(e,t){var i;return this._removeExtension(e),this._extensions.push(t),null===(i=t.initialize)||void 0===i||i.call(t),t}_inCookielessMode(){return"always"===this.config.cookieless_mode||"on_reject"===this.config.cookieless_mode&&this.consent.isRejected()}_warnIfVolatileIdentityWithoutStableId(){if(this._hasWarnedAboutVolatileIdentity)return;if(this.config.reuseAnonymousId)return;if(this.config.segment)return;if(this._inCookielessMode())return;const e="memory"===this.config.persistence||"sessionStorage"===this.config.persistence;if(!e&&!this.config.disable_persistence)return;if(this._hasStableInitialDistinctId)return;let t,i,s;e?(t=`persistence is set to '${this.config.persistence}'`,i="memory"===this.config.persistence?"on every page load":"for every new browser tab or window",s="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",s="Either set disable_persistence to false, keep persistence disabled and pass a stable ID through bootstrap.distinctID, or enable reuseAnonymousId."),this._hasWarnedAboutVolatileIdentity=!0,console.warn("[PostHog.js]",`${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. ${s}`)}_syncCookielessIdentity(){const e=this.persistence;if(!e||this._isConsentTransition)return;if(this._inCookielessMode())return void("on_reject"===this.config.cookieless_mode&&"$posthog_cookieless"!==this.get_distinct_id()&&(this._sync_opt_out_with_persistence(),this._enterCookielessMode()));if("$posthog_cookieless"!==this.get_distinct_id())return;this._is_persistence_disabled()||e.load(!0);const t=this.get_distinct_id();if(!t||"$posthog_cookieless"===t){const t=this.config.get_device_id(Kr());this.register({distinct_id:t,$device_id:t}),e.set_property(ge,Oe)}this._sync_opt_out_with_persistence()}get decideEndpointWasHit(){var e,t;return null!==(e=null===(t=this.featureFlags)||void 0===t?void 0:t.hasLoadedFlags)&&void 0!==e&&e}get flagsEndpointWasHit(){var e,t;return null!==(e=null===(t=this.featureFlags)||void 0===t?void 0:t.hasLoadedFlags)&&void 0!==e&&e}constructor(){var t;this._isPageUnloading=!1,this._isShutdown=!1,this.webPerformance=new Mu,this._personProcessingSetOncePropertiesSent=!1,this.version=i.LIB_VERSION,this._sessionRegisteredPropKeys=new Set,this._sessionRegisteredPropertiesStorageKey="",this._internalEventEmitter=new Ec,this._extensions=[],this._extensionEventPropertyProducers=[],this._replayDebugPropertiesPaused=!1,this._hasStableInitialDistinctId=!1,this._hasWarnedAboutVolatileIdentity=!1,this._isConsentTransition=!1,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=Ru(),this.SentryIntegration=fa,this.sentryIntegration=e=>function(e,t){const i=ga(e,t);return{name:pa,processEvent:e=>i(e)}}(this,e),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this._initialPageviewCaptured=!1,this._visibilityStateListener=null,this._initialPersonProfilesConfig=null,this._cachedPersonProperties=null,this.scrollManager=new Sc(this),this.pageViewManager=new va(this),this.rateLimiter=new gl(this),this.requestRouter=new qc(this),this.consent=new vo(this),this.externalIntegrations=new Jc(this);const s=null!==(t=e.__defaultExtensionClasses)&&void 0!==t?t:{};this.featureFlags=s.featureFlags&&new s.featureFlags(this),this.toolbar=s.toolbar&&new s.toolbar(this),this.surveys=s.surveys&&new s.surveys(this),this.conversations=s.conversations&&new s.conversations(this),this.logs=s.logs&&new s.logs(this),this.metrics=s.metrics&&new s.metrics(this),this.experiments=s.experiments&&new s.experiments(this),this.exceptions=s.exceptions&&new s.exceptions(this),this.people={set:(e,t,i)=>{const s=mt(e)?{[e]:t}:e;this.setPersonProperties(s),null==i||i({})},set_once:(e,t,i)=>{const s=mt(e)?{[e]:t}:e;this.setPersonProperties(void 0,s),null==i||i({})}},this.on("eventCaptured",e=>Ir.info(`send "${null==e?void 0:e.event}"`,e))}init(t,i,s){if(s&&s!==Iu){var n;const r=null!==(n=pu[s])&&void 0!==n?n:new e;return r._init(t,i,s),pu[s]=r,pu[Iu][s]=r,r}return this._init(t,i,s)}_init(e,t={},s){var n,r,o;const a=mt(e)?e.trim():"";if(!a)return Ir.critical("PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()"),this;var l;if(this.__loaded)return a!==(null===(l=this.config)||void 0===l?void 0:l.token)?console.warn("[PostHog.js]",`You have already initialized PostHog with a different project token! Re-initializing is a no-op, so events will keep going to the project this instance was initialized with. To capture into a second project, load PostHog once, then initialize a named instance after the SDK has loaded, e.g. posthog.init('${a}', { ... }, 'project2')`):console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config=Ru(t.defaults),t.debug=this._checkLocalStorageForDebug(t.debug),this._originalUserConfig=t,this._triggered_notifs=[],t.person_profiles?this._initialPersonProfilesConfig=t.person_profiles:t.process_person&&(this._initialPersonProfilesConfig=t.process_person);const c=Ru(t.defaults),u=$u(t),d=Ar({},c,u,{name:s,token:a});gt(c.rageclick)&>(u.rageclick)&&(d.rageclick=Ar({},c.rageclick,u.rageclick)),gt(c.session_recording)&>(u.session_recording)&&(d.session_recording=Ar({},c.session_recording,u.session_recording)),this.set_config(d),this.config.on_xhr_error&&Ir.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=t.disable_compression?void 0:nl;const h=this._is_persistence_disabled(),_=!this._inCookielessMode();if(this.persistence=new sl(this.config,h,!0,_),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new sl(as(as({},this.config),{},{persistence:"sessionStorage"}),h,!1,_),this._sessionRegisteredPropertiesStorageKey="ph_"+(this.config.persistence_name||this.config.token)+"_session_registered_properties","memory"!==this.config.persistence&&!h&&fo._is_supported()){const e=fo._parse(this._sessionRegisteredPropertiesStorageKey);_t(e)&&e.forEach(e=>{mt(e)&&this._sessionRegisteredPropKeys.add(e)})}else fo._remove(this._sessionRegisteredPropertiesStorageKey);const p=as({},this.persistence.props),g=as({},this.sessionPersistence.props);this.register({$initialization_time:(new Date).toISOString()}),this._requestQueue=new yc((e,t)=>this._send_retriable_request(e,t),this.config.request_queue_config),this._retryQueue=new wc(this),this.__request_queue=[];const f=this._inCookielessMode();f||(this.sessionManager=new Ic(this),this.sessionPropsManager=new kc(this,this.sessionManager,this.persistence),this.sessionManager.onSessionId((e,t,i)=>{((null==i?void 0:i.activityTimeout)||(null==i?void 0:i.sessionPastMaximumLength)||(null==i?void 0:i.crossTabAdoption))&&this._clearSessionRegisteredProps()})),this._enrollFeatureFlags(),this.config.__preview_deferred_init_extensions?(Ir.info("Deferring extension initialization to improve startup performance"),this._extensionInitTimeout=setTimeout(()=>{this._extensionInitTimeout=void 0,this._initExtensions(f)},0)):(Ir.info("Initializing extensions synchronously"),this._initExtensions(f)),i.DEBUG=i.DEBUG||this.config.debug,i.DEBUG&&Ir.info("Starting in debug mode",{this:this,config:t,thisC:as({},this.config),p:p,s:g}),this.config.identity_distinct_id&&!(null===(n=t.bootstrap)||void 0===n?void 0:n.distinctID)&&(t.bootstrap=as(as({},t.bootstrap),{},{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0}));const v=null===(r=t.bootstrap)||void 0===r?void 0:r.distinctID;if(this._hasStableInitialDistinctId=!!v&&!yt(v),null===(o=t.bootstrap)||void 0===o?void 0:o.distinctID){const e=t.bootstrap.distinctID,i=this.get_distinct_id(),s=this.persistence.get_property(ge);if(t.bootstrap.isIdentifiedID&&null!=i&&i!==e&&"anonymous"===s)this.identify(e);else if(t.bootstrap.isIdentifiedID&&null!=i&&i!==e&&"identified"===s)Ir.warn("Bootstrap distinctID differs from an already-identified user. The existing identity is preserved. Call reset() before reinitializing if you intend to switch users.");else{const i=this.config.get_device_id(Kr()),s=t.bootstrap.isIdentifiedID?i:e;this.persistence.set_property(ge,t.bootstrap.isIdentifiedID?De:Oe),this.register({distinct_id:e,$device_id:s})}}if(f)this.register_once({distinct_id:Se,$device_id:null},"");else if(!this.get_distinct_id()){const e=this.config.get_device_id(Kr());this.register_once({distinct_id:e,$device_id:e},""),this.persistence.set_property(ge,Oe)}return Br(je,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),Br(je,"pageshow",e=>{if(this._isPageUnloading=!1,!this._isShutdown){var t;if(e.persisted&&this.persistence){const e=this.persistence.get_property(P),t=this.persistence.get_property(ge);this.persistence.load(),this._processCookieIdentityChange()||e===this.persistence.get_property("distinct_id")&&t===this.persistence.get_property("$user_state")||this._processIdentityChange()}null===(t=this._retryQueue)||void 0===t||t.resume()}}),t.segment?_a(this,()=>this._loaded()):this._loaded(),pt(this.config._onCapture)&&this.config._onCapture!==fu&&(Ir.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",e=>this.config._onCapture(e.event,e))),this.config.ip&&Ir.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 Rc.apply(this,arguments)}().then(e=>{e&&this.register({[F]:e})}).catch(fu),this}_isSharedExtension(e){const t=e;return mt(t.name)&&pt(t.setup)}_enrollExtension(e,t){var i=this;this._isSharedExtension(e)?t.push(Ot(function*(){try{yield e.setup(i._getBrowserClientAdapter())}catch(i){Ir.error(`Failed to set up extension "${e.name}"`,i);try{var t;yield null===(t=e.dispose)||void 0===t?void 0:t.call(e)}catch(t){Ir.error(`Failed to dispose extension "${e.name}"`,t)}}})):this._extensions.push(e)}_enrollFeatureFlags(){var t,i,s,n=this;const r=null!==(t=null===(i=this.config.__extensionClasses)||void 0===i?void 0:i.featureFlags)&&void 0!==t?t:null===(s=e.__defaultExtensionClasses)||void 0===s?void 0:s.featureFlags;var o,a,l;if(r)if(this.featureFlags&&this.featureFlags instanceof r||(null===(o=this._featureFlagsReloadingUnsubscribe)||void 0===o||o.call(this),this._featureFlagsReloadingUnsubscribe=void 0,this.featureFlags=new r(this)),pt(this.featureFlags.onReloading)&&pt(this.featureFlags.setup)){if(!this._featureFlagsReloadingUnsubscribe){this._featureFlagsReloadingUnsubscribe=this.featureFlags.onReloading(()=>{this._internalEventEmitter.emit("featureFlagsReloading",!0)});const e=this.featureFlags;Ot(function*(){try{yield e.setup(n._getBrowserClientAdapter())}catch(t){Ir.error("Failed to set up feature flags",t);const i=n._featureFlagsReloadingUnsubscribe;n._featureFlagsReloadingUnsubscribe=void 0;try{null==i||i()}catch(e){Ir.error("Failed to unsubscribe feature flag reloading",e)}try{yield e.dispose()}catch(e){Ir.error("Failed to dispose feature flags",e)}}})()}}else null===(a=(l=this.featureFlags).initialize)||void 0===a||a.call(l)}_initExtensions(t){const i=performance.now(),s=as(as({},e.__defaultExtensionClasses),this.config.__extensionClasses),n=[];var r,o,a,l,c,u,d,h;s.exceptions&&this._extensions.push(this.exceptions=null!==(r=this.exceptions)&&void 0!==r?r:new s.exceptions(this)),s.historyAutocapture&&this._extensions.push(this.historyAutocapture=new s.historyAutocapture(this)),s.tracingHeaders&&this._extensions.push(this.tracingHeaders=new s.tracingHeaders(this)),s.siteApps&&this._extensions.push(this.siteApps=new s.siteApps(this)),s.sessionRecording&&!t&&this._extensions.push(this.sessionRecording=new s.sessionRecording(this)),this.config.disable_scroll_properties||n.push(()=>{this.scrollManager.startMeasuringScrollPosition()}),s.autocapture&&this._enrollExtension(this.autocapture=new s.autocapture(this),n),s.surveys&&this._enrollExtension(this.surveys=null!==(o=this.surveys)&&void 0!==o?o:new s.surveys(this),n),s.logs&&this._enrollExtension(this.logs=null!==(a=this.logs)&&void 0!==a?a:new s.logs(this),n),s.metrics&&this._extensions.push(this.metrics=null!==(l=this.metrics)&&void 0!==l?l:new s.metrics(this)),s.conversations&&this._extensions.push(this.conversations=null!==(c=this.conversations)&&void 0!==c?c:new s.conversations(this)),s.productTours&&this._extensions.push(this.productTours=new s.productTours(this)),s.heatmaps&&this._extensions.push(this.heatmaps=new s.heatmaps(this)),s.webVitalsAutocapture&&this._extensions.push(this.webVitalsAutocapture=new s.webVitalsAutocapture(this)),s.exceptionObserver&&this._extensions.push(this.exceptionObserver=new s.exceptionObserver(this)),s.deadClicksAutocapture&&this._extensions.push(this.deadClicksAutocapture=new s.deadClicksAutocapture(this,ua)),s.toolbar&&this._extensions.push(this.toolbar=null!==(u=this.toolbar)&&void 0!==u?u:new s.toolbar(this)),s.experiments&&this._extensions.push(this.experiments=null!==(d=this.experiments)&&void 0!==d?d:new s.experiments(this)),s.webMCP&&this._extensions.push(this.webMCP=null!==(h=this.webMCP)&&void 0!==h?h:new s.webMCP(this)),this._extensions.forEach(e=>{e.initialize&&n.push(()=>{var t;null===(t=e.initialize)||void 0===t||t.call(e)})}),n.push(()=>{if(this._pendingRemoteConfig){const e=this._pendingRemoteConfig;this._pendingRemoteConfig=void 0,this._extensions.forEach(t=>{var i;return null===(i=t.onRemoteConfig)||void 0===i?void 0:i.call(t,e)})}}),this._processInitTaskQueue(n,i)}_processInitTaskQueue(e,t){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-t>=30&&e.length>0)return void(this._extensionInitTimeout=setTimeout(()=>{this._extensionInitTimeout=void 0,this._processInitTaskQueue(e,t)},0));const i=e.shift();if(i)try{i()}catch(e){Ir.error("Error initializing extension:",e)}}const i=Math.round(performance.now()-t);this.register_for_session({[ke]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[Ee]:i}),this.config.__preview_deferred_init_extensions&&Ir.info(`PostHog extensions initialized (${i}ms)`)}_onRemoteConfig(e){if(!Ge||!Ge.body)return Ir.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout(()=>{this._onRemoteConfig(e)},500);if(this.config.__preview_deferred_init_extensions&&(this._pendingRemoteConfig=e),this._lastRemoteConfig=e,this.compression=void 0,e.ok){var t;const i=e.config;i.supportedCompression&&!this.config.disable_compression&&(this.compression=ot(i.supportedCompression,nl)?nl:ot(i.supportedCompression,rl)?rl:void 0),(null===(t=i.analytics)||void 0===t?void 0:t.endpoint)&&(this.analyticsDefaultEndpoint=i.analytics.endpoint)}this.set_config({person_profiles:this._initialPersonProfilesConfig?this._initialPersonProfilesConfig:Ne}),this._internalEventEmitter.emit("extensionsRemoteConfig",e),this._extensions.forEach(t=>{var i;return null===(i=t.onRemoteConfig)||void 0===i?void 0:i.call(t,e)})}_loaded(){try{this.config.loaded(this)}catch(e){Ir.critical("`loaded` function failed",e)}if(this._start_queue_if_opted_in(),this.config.internal_or_test_user_hostname&&(null==Ke?void 0:Ke.hostname)){const e=Ke.hostname,t=this.config.internal_or_test_user_hostname;("string"==typeof t?e===t:t.test(e))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout(()=>{(this.consent.isOptedIn()||this._inCookielessMode())&&this._captureInitialPageview()},1),this._remoteConfigLoader=new vl(this),this._remoteConfigLoader.load()}_start_queue_if_opted_in(){var e;this.is_capturing()&&this.config.request_batching&&(null===(e=this._requestQueue)||void 0===e||e.enable())}_dom_loaded(){this.is_capturing()&&Tr(this.__request_queue,e=>this._send_retriable_request(e)),this.__request_queue=[],this._start_queue_if_opted_in()}_handle_unload(){var e,t,i,s,n,r;this._isPageUnloading=!0,null===(e=this.surveys)||void 0===e||null===(t=e.handlePageUnload)||void 0===t||t.call(e),null===(i=this.metrics)||void 0===i||i.flush("sendBeacon"),this.config.request_batching?(this._shouldCapturePageleave()&&this.capture(He),null===(s=this.logs)||void 0===s||s.flushLogs("sendBeacon"),null===(n=this._requestQueue)||void 0===n||n.unload(),null===(r=this._retryQueue)||void 0===r||r.unload()):this._shouldCapturePageleave()&&this.capture(He,null,{transport:"sendBeacon"})}_send_request(e){mc(this,e)}_send_retriable_request(e,t){this._retryQueue?this._retryQueue.retriableRequest(e,t):this._send_request(t?as(as({},e),{},{transport:t}):e)}_execute_array(e){gu++;try{let t;const i=[],s=[],n=[];Tr(e,e=>{if(e)if(t=e[0],_t(t))n.push(e);else if(pt(e))try{e.call(this)}catch(t){Ir.error("Error executing queued PostHog call",e,t)}else _t(e)&&"alias"===t?i.push(e):_t(e)&&-1!==t.indexOf("capture")&&pt(this[t])?n.push(e):s.push(e)});const r=function(e,t){Tr(e,function(e){try{if(_t(e[0])){let i=t;Rr(e,function(e){i=i[e[0]].apply(i,e.slice(1))})}else t[e[0]].apply(t,e.slice(1))}catch(t){Ir.error("Error executing queued PostHog call",e,t)}})};r(i,this),r(s,this),r(n,this)}finally{gu--}}push(t){if(gu>0&&_t(t)&&mt(t[0])){const i=e.prototype[t[0]];return void(pt(i)&&i.apply(this,t.slice(1)))}this._execute_array([t])}get _facebookClickIdChannel(){return{property:A,persistenceKey:M,cookieName:"_fbc",pattern:Eu,register:(e,t)=>{var i;return null===(i=this.persistence)||void 0===i?void 0:i.register({[M]:{value:e,delivered:t}})},unregister:()=>{var e;return null===(e=this.persistence)||void 0===e?void 0:e.unregister(M)}}}get _facebookBrowserIdChannel(){return{property:L,persistenceKey:O,cookieName:"_fbp",pattern:xu,register:(e,t)=>{var i;return null===(i=this.persistence)||void 0===i?void 0:i.register({[O]:{value:e,delivered:t}})},unregister:()=>{var e;return null===(e=this.persistence)||void 0===e?void 0:e.unregister(O)}}}_getPersistedMetaIdentifier(e){var t;const i=null===(t=this.persistence)||void 0===t?void 0:t.get_property(e.persistenceKey);return mt(i)&&e.pattern.test(i)?{value:i,delivered:!1}:gt(i)&&mt(i.value)&&e.pattern.test(i.value)?{value:i.value,delivered:!0===i.delivered}:void 0}_storeMetaIdentifier(e,t,i){return t===(null==i?void 0:i.value)?{value:t,pending:!i.delivered}:(e.register(t,!1),{value:t,pending:!0})}_readMetaCookie(e){if(!this.config.save_campaign_params||this._inCookielessMode())return;const t=Hr(e.cookieName);return mt(t)&&e.pattern.test(t)?t:void 0}_updateFacebookClickId(e,t,i,s){if(!this.persistence)return;const n=this._facebookClickIdChannel;this.persistence.refreshMetaIdentifiers();const r=this._getPersistedMetaIdentifier(n);if(s)return void n.unregister();if(i)return mt(t)&&Eu.test(t)?this._storeMetaIdentifier(n,t,r):void n.unregister();const o=mt(e)&&ku.test(e)?e:void 0,a=this._readMetaCookie(n);return a&&((e,t,i)=>{const s=e.split(".");if(t)return s[3]===t;if(!i)return!0;const n=i.value.split(".");return s[3]===n[3]||Number(s[2])>Number(n[2])})(a,o,r)?this._storeMetaIdentifier(n,a,r):o?(null==r?void 0:r.value.split(".")[3])===o?{value:r.value,pending:!r.delivered}:this._storeMetaIdentifier(n,`fb.1.${Date.now()}.${o}`,r):r?{value:r.value,pending:!r.delivered}:void 0}_updateFacebookBrowserId(e,t,i){if(!this.persistence)return;const s=this._facebookBrowserIdChannel;this.persistence.refreshMetaIdentifiers();const n=this._getPersistedMetaIdentifier(s);if(i)return void s.unregister();if(t)return mt(e)&&xu.test(e)?this._storeMetaIdentifier(s,e,n):void s.unregister();const r=this._readMetaCookie(s);return r?this._storeMetaIdentifier(s,r,n):n?{value:n.value,pending:!n.delivered}:void 0}_markMetaIdentifierDelivered(e,t){if(!this.persistence)return;this.persistence.refreshMetaIdentifiers();const i=this._getPersistedMetaIdentifier(e);(null==i?void 0:i.value)!==t||i.delivered||e.register(t,!0)}capture(e,t,i){var s,n,r;if(!(this.__loaded&&this.persistence&&this.sessionPersistence&&this._requestQueue))return void Ir.uninitializedWarning("posthog.capture");if(!this.is_capturing())return void Ir.info(`Event "${e}" was not captured because capturing is disabled (opted out or consent pending).`);if(vt(e)||!mt(e))return void Ir.error("No event name provided to posthog.capture");if(this._syncCookielessIdentity(),"$snapshot"===e&&this._inCookielessMode())return;const o=!this.config.opt_out_useragent_filter&&this._is_bot();if(o&&!this.config.__preview_capture_bot_pageviews)return void Ir.info(`Event "${e}" was not captured because the user agent looks like a bot. Set \`opt_out_useragent_filter: true\` to capture it.`);const a=(null==i?void 0:i.skip_client_rate_limiting)?void 0:this.rateLimiter.clientRateLimitContext();if(null==a?void 0:a.isRateLimited)return void Ir.critical("This capture call is ignored due to client rate limiting.");let l;(null==t?void 0:t.$current_url)&&!mt(null==t?void 0:t.$current_url)&&(Ir.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),null==t||delete t.$current_url),"$exception"!==e||(null==i?void 0:i._originatedFromCaptureException)||Ir.warn("Using `posthog.capture('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureException(error)` instead, which attaches required metadata automatically."),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&(l=this.sessionPersistence.update_campaign_params()),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();const c=new Date,u=(null==i?void 0:i.timestamp)||c,d=Yi(null==i?void 0:i.uuid,Kr);let h={uuid:d,event:e,properties:this.calculateEventProperties(e,t||{},u,d)};"$pageview"===e&&this.config.__preview_capture_bot_pageviews&&o&&(h.event="$bot_pageview",h.properties.$browser_type="bot"),a&&(h.properties.$lib_rate_limit_remaining_tokens=a.remainingTokens);const _="$feature_flag_called"===e&&!1===h.properties.$feature_flag_has_experiment&&!0===this.get_property("$minimal_flag_called_events");(null==i?void 0:i.$set)&&!_&&(h.$set=null==i?void 0:i.$set);const p=gt(null==t?void 0:t.$set)?t.$set:void 0,g=_t(null==t?void 0:t.$unset)?t.$unset:[],f=(null==i?void 0:i.$unset)||[],v=e=>{var t;const s=!!(null==i?void 0:i.$set)&&e in i.$set;return{hasProvided:s||!!p&&e in p,provided:s?null==i||null===(t=i.$set)||void 0===t?void 0:t[e]:null==p?void 0:p[e],unset:-1!==g.indexOf(e)||-1!==f.indexOf(e)}},m=v(A),y=v(L),b=[{channel:this._facebookClickIdChannel,hasProvided:m.hasProvided,update:this._updateFacebookClickId(null==l?void 0:l.fbclid,m.provided,m.hasProvided,m.unset)},{channel:this._facebookBrowserIdChannel,hasProvided:y.hasProvided,update:this._updateFacebookBrowserId(y.provided,y.hasProvided,y.unset)}];for(const{channel:e,hasProvided:t,update:i}of b)i&&!0===h.properties.$process_person_profile&&i.pending&&!t&&!_&&(h.$set=as({[e.property]:i.value},h.$set));const w=null==i?void 0:i.$unset;w&&(h.$unset=w);const S=_?void 0:this._calculate_set_once_properties(null==i?void 0:i.$set_once,e!==qe,e===Ue);if(S&&(h.$set_once=S),(null==i?void 0:i._noTruncate)||(C=this.config.properties_string_max_length,h=function(e,t){const i=new Set;return function e(s,n){if(s!==Object(s))return t?t(s):s;if(i.has(s))return;let r;if(i.add(s),_t(s))r=[],Tr(s,t=>{r.push(e(t))});else{const t={};Rr(Ft(s)?Or(s):s,(s,n)=>{i.has(s)||(t[n]=e(s,n))}),r=t}return r}(e)}(h,e=>mt(e)?e.slice(0,C):e)),h.timestamp=u,vt(null==i?void 0:i.timestamp)||(h.properties.$event_time_override_provided=!0,h.properties.$event_time_override_system_time=c),_&&(h.properties=((e,t=[])=>{const i={},s=t=>{void 0!==e[t]&&(i[t]=e[t])};return sn.forEach(s),t.forEach(s),i})(h.properties,Pu)),e===cl||e===ul){const i=null==t?void 0:t.$survey_id,s=null==t?void 0:t.$survey_iteration;Wc({id:i,current_iteration:s}),h.$set=as(as({},h.$set),{},{[Ac({id:i,current_iteration:s},e===ul?"responded":"dismissed")]:!0})}else e===ll&&(h.$set=as(as({},h.$set),{},{[dl]:(new Date).toISOString()}));var C;if("product tour shown"===e){const e=null==t?void 0:t.$product_tour_type;e&&(h.$set=as(as({},h.$set),{},{[`$product_tour_last_seen_date/${e}`]:(new Date).toISOString()}))}const k=as(as({},h.properties.$set),h.$set);if(ft(k)||this.setPersonPropertiesForFlags(k),!wt(this.config.before_send)){const e=this._runBeforeSend(h);if(!e)return;h=e,h.uuid=Yi(h.uuid,Kr)}this.sessionRecording&&!this._replayDebugPropertiesPaused&&Cu(e)&&(this._replayDebugPropertiesPaused=!0,setTimeout(()=>this._replayDebugPropertiesPaused=!1,3e4));const E=b.filter(({channel:e,update:t})=>{var i,s,n;const r=null!==(i=null===(s=h.$set)||void 0===s?void 0:s[e.property])&&void 0!==i?i:gt(null===(n=h.properties)||void 0===n?void 0:n.$set)?h.properties.$set[e.property]:void 0;return(null==t?void 0:t.pending)&&r===t.value});this._internalEventEmitter.emit("eventCaptured",h);const x=null!==(s=null==i?void 0:i._url)&&void 0!==s?s:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),P="recordings"===(null==i?void 0:i._batchKey)||/\/s\/(?:\?|$)/.test(x),I=as(as(as({method:"POST",url:x,data:h,compression:"best-available",preferSyncCompression:null==i?void 0:i.send_instantly,timestampMode:P?"body":"capture-body",batchKey:null==i?void 0:i._batchKey},P&&(null===(n=h.properties)||void 0===n?void 0:n.$session_id)?{batchGroup:h.properties.$session_id+(h.properties.$window_id?`-${h.properties.$window_id}`:"")}:{}),(null==i?void 0:i.transport)?{transport:i.transport}:{}),E.length?{fireCallbackOnDrop:!0,callback:e=>{if(e.statusCode>=200&&300>e.statusCode)for(const{channel:e,update:t}of E)this._markMetaIdentifierDelivered(e,t.value)}}:{});if(!this.config.request_batching||i&&!(null==i?void 0:i._batchKey)||(null==i?void 0:i.send_instantly)){var F;let e;!I.transport&&!I.callback&&ft(null!==(F=this.config.request_headers)&&void 0!==F?F:{})&&this._isPageUnloading&&(e="sendBeacon"),this._send_retriable_request(I,e)}else this._requestQueue.enqueue(I);return null===(r=this.featureFlags)||void 0===r||r.sendFlagCallsPendingCapture(),h}_addCaptureHook(e){return this.on("eventCaptured",t=>e(t.event,t))}getExtension(e){var t;return null===(t=this._browserClientAdapter)||void 0===t?void 0:t.getExtension(e)}_getBrowserClientAdapter(){var e;return null!==(e=this._browserClientAdapter)&&void 0!==e?e:this._browserClientAdapter=new _u(this)}_registerExtensionEventProperties(e){this._extensionEventPropertyProducers.push(e);let t=!0;return()=>{if(!t)return;t=!1;const i=this._extensionEventPropertyProducers.indexOf(e);-1!==i&&this._extensionEventPropertyProducers.splice(i,1)}}_processCookieIdentityChange(e=!0){var t;return!!(null===(t=this.persistence)||void 0===t?void 0:t.consumeCookieIdentityChange())&&(this._processIdentityChange(e),!0)}_processIdentityChange(e=!0){var t,i,s;this._cachedPersonProperties=null,"anonymous"===(null===(t=this.persistence)||void 0===t?void 0:t.get_property("$user_state"))&&(null===(s=this.sessionPersistence)||void 0===s||s.clear(),this._sessionRegisteredPropKeys.clear(),this._persistSessionRegisteredPropKeys()),null===(i=this.featureFlags)||void 0===i||i.reset(),e&&this.reloadFeatureFlags()}calculateEventProperties(e,i,s,n,r){if(s=s||new Date,!this.persistence||!this.sessionPersistence)return i;this._syncCookielessIdentity(),this.persistence.syncCookieProperties(),this._processCookieIdentityChange();const o=r?void 0:this.persistence.remove_event_timer(e);let a=as({},i);if(a.token=this.config.token,a.$config_defaults="latest"===this.config.defaults?Fu:this.config.defaults,this._inCookielessMode()&&(a[Ce]=!0),"$snapshot"===e){const e=as(as({},this.persistence.properties()),this.sessionPersistence.properties());return a.distinct_id=e.distinct_id,(!mt(a.distinct_id)&&!St(a.distinct_id)||yt(a.distinct_id))&&Ir.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),a}const l=function(e,i,s,n=!1){var r,o,a,l;if(!Ze)return{};const c=e?[...Ra,...i||[]]:[],[u,d]=Bi(Ze),[h,_]=function(e){for(let t=0;qi.length>t;t++){const[i,s,n]=qi[t],r=e.match(i);if(r){const t=n&&e.match(n)||r;return[s,(null==t?void 0:t[1])||""]}}return["",""]}(Ze),p=function(){const e="u">typeof navigator?navigator:void 0;return(null==e?void 0:e.brave)?{brave:!0}:{}}(),g={};vt(s)||(g.detectGoogleSearchApp=s);const f={},v=null===(r=navigator)||void 0===r||null===(r=r.userAgentData)||void 0===r?void 0:r.platform,m=null===(o=navigator)||void 0===o?void 0:o.maxTouchPoints,y=null==je||null===(a=je.screen)||void 0===a?void 0:a.width,b=null==je||null===(l=je.screen)||void 0===l?void 0:l.height,w=null==je?void 0:je.devicePixelRatio;vt(v)||(f.userAgentDataPlatform=v),vt(m)||(f.maxTouchPoints=m),vt(y)||(f.screenWidth=y),vt(b)||(f.screenHeight=b),vt(w)||(f.devicePixelRatio=w);const S=Ar(Lr({$os:u,$os_version:d,$browser:Li(Ze,navigator.vendor,p,g),$webview_app:h,$webview_app_version:_,$device:zi(Ze),$device_type:Hi(Ze,f),$timezone:Sa(),$timezone_offset:ja()}),{$current_url:Fa(n?Zi(null==Ke?void 0:Ke.href):null==Ke?void 0:Ke.href,c,$a),$host:null==Ke?void 0:Ke.host,$pathname:null==Ke?void 0:Ke.pathname,$raw_user_agent:Ze.length>1e3?Ze.substring(0,997)+"...":Ze,$browser_version:Di(Ze,navigator.vendor,p,g),$browser_language:Na(),$browser_language_prefix:Ba(),$screen_height:null==je?void 0:je.screen.height,$screen_width:null==je?void 0:je.screen.width,$viewport_height:null==je?void 0:je.innerHeight,$viewport_width:null==je?void 0:je.innerWidth,$lib:t.LIB_NAME,$lib_version:t.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3});return t.SDK_DIST_CHANNEL&&(S.$sdk_dist_channel=t.SDK_DIST_CHANNEL),S}(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties,this.config.detect_google_search_app,this.config.disable_capture_url_hashes);if(this.sessionManager){const{sessionId:e,windowId:t}=this.sessionManager.checkAndGetSessionAndWindowId(r,s.getTime(),!0);a.$session_id=e,a.$window_id=t}this.sessionPropsManager&&Ar(a,this.sessionPropsManager.getSessionProps());try{var c;if(this.sessionRecording){const t=this.sessionRecording.sdkDebugProperties,i=!this._replayDebugPropertiesPaused&&Cu(e);for(const e in t)(i||ot(wu,e))&&(a[e]=t[e])}a.$sdk_debug_retry_queue_size=null===(c=this._retryQueue)||void 0===c?void 0:c.length}catch(e){a.$sdk_debug_error_capturing_properties=String(e)}let u;if(this.requestRouter.region===Bc&&(a.$lib_custom_api_host=this.config.api_host),u="$pageview"!==e||r?"$pageleave"!==e||r?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(s):this.pageViewManager.doPageView(s,n),a=Ar(a,u),"$pageview"===e&&Ge&&(a.title=Ge.title),!vt(o)){const e=s.getTime()-o;a.$duration=parseFloat((e/1e3).toFixed(3))}Ze&&this.config.opt_out_useragent_filter&&(a.$browser_type=this._is_bot()?"bot":"browser");const d=this.persistence.properties(),h=this.sessionPersistence.properties(),_=a.$groups,p=d.$groups;gt(_)&&!ft(_)&&(a.$groups=as(as({},gt(p)?p:{}),_)),Rr(["$referrer","$referring_domain"],e=>{e in d&&delete h[e]});const g={};if(this._extensionEventPropertyProducers.length>0)for(const e of this._extensionEventPropertyProducers.slice())try{Ar(g,e())}catch(e){Ir.error("Failed to produce browser extension event properties",e)}a=Ar({},l,d,h,as(as({},g),a)),a.$is_identified=this._isIdentified(),_t(this.config.property_denylist)?Rr(this.config.property_denylist,function(e){delete a[e]}):Ir.error(bu+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);const f=this.config.sanitize_properties;f&&(Ir.error(yu),a=f(a,e));const v=this._hasPersonProcessing();return a.$process_person_profile=v,v&&!r&&this._requirePersonProcessing("_calculate_event_properties"),a}_calculate_set_once_properties(e,t=!0,i=!1){var s;if(!this.persistence||!this._hasPersonProcessing())return e;if(this._personProcessingSetOncePropertiesSent&&!i)return e;const n=this.persistence.get_initial_props(),r=null===(s=this.sessionPropsManager)||void 0===s?void 0:s.getSetOnceProps();let o=Ar({},n,r||{},e||{});const a=this.config.sanitize_properties;return a&&(Ir.error(yu),o=a(o,"$set_once")),t&&(this._personProcessingSetOncePropertiesSent=!0),ft(o)?void 0:o}register(e,t){var i;null===(i=this.persistence)||void 0===i||i.register(e,t)}register_once(e,t,i){var s;null===(s=this.persistence)||void 0===s||s.register_once(e,t,i)}register_for_session(e){var t,i;null===(t=this.persistence)||void 0===t||t.syncCookieProperties(),this._processCookieIdentityChange(),null===(i=this.sessionPersistence)||void 0===i||i.register(e),Object.keys(e).forEach(e=>this._sessionRegisteredPropKeys.add(e)),this._persistSessionRegisteredPropKeys()}unregister(e){var t;null===(t=this.persistence)||void 0===t||t.unregister(e)}unregister_for_session(e){var t;null===(t=this.sessionPersistence)||void 0===t||t.unregister(e),this._sessionRegisteredPropKeys.delete(e),this._persistSessionRegisteredPropKeys()}_register_single(e,t){this.register({[e]:t})}_clearSessionRegisteredProps(){this._sessionRegisteredPropKeys.forEach(e=>{var t;null===(t=this.sessionPersistence)||void 0===t||t.unregister(e)}),this._sessionRegisteredPropKeys.clear(),this._persistSessionRegisteredPropKeys()}_persistSessionRegisteredPropKeys(){var e;if(!this._sessionRegisteredPropertiesStorageKey)return;if("memory"===this.config.persistence||(null===(e=this.sessionPersistence)||void 0===e?void 0:e._disabled)||!fo._is_supported())return void fo._remove(this._sessionRegisteredPropertiesStorageKey);const t=[];this._sessionRegisteredPropKeys.forEach(e=>t.push(e)),t.length>0?fo._set(this._sessionRegisteredPropertiesStorageKey,t):fo._remove(this._sessionRegisteredPropertiesStorageKey)}getFeatureFlag(e,t){var i;return null===(i=this.featureFlags)||void 0===i?void 0:i.getFeatureFlag(e,t)}getFeatureFlagPayload(e){var t;return null===(t=this.featureFlags)||void 0===t?void 0:t.getFeatureFlagPayload(e)}getFeatureFlagResult(e,t){var i;return null===(i=this.featureFlags)||void 0===i?void 0:i.getFeatureFlagResult(e,t)}getAllFeatureFlags(){var e,t;return null!==(e=null===(t=this.featureFlags)||void 0===t?void 0:t.getAllFeatureFlags())&&void 0!==e?e:[]}isFeatureEnabled(e,t){var i,s;return null!==(i=null===(s=this.featureFlags)||void 0===s?void 0:s.isFeatureEnabled(e,t))&&void 0!==i?i:null==t?void 0:t.defaultValue}reloadFeatureFlags(){var e;null===(e=this.featureFlags)||void 0===e||e.reloadFeatureFlags()}updateFlags(e,t,i){var s;null===(s=this.featureFlags)||void 0===s||s.updateFlags(e,t,i)}updateEarlyAccessFeatureEnrollment(e,t,i){var s;null===(s=this.featureFlags)||void 0===s||s.updateEarlyAccessFeatureEnrollment(e,t,i)}getEarlyAccessFeatures(e,t=!1,i){var s;return null===(s=this.featureFlags)||void 0===s?void 0:s.getEarlyAccessFeatures(e,t,i)}on(e,t){return this._internalEventEmitter.on(e,t)}onFeatureFlags(e){return this.featureFlags?this.featureFlags.onFeatureFlags(e):(e([],{},{errorsLoading:!0}),()=>{})}onSurveysLoaded(e){return this.surveys?this.surveys.onSurveysLoaded(e):(e([],{isLoaded:!1,error:mu}),()=>{})}onSessionId(e){var t,i;return null!==(t=null===(i=this.sessionManager)||void 0===i?void 0:i.onSessionId(e))&&void 0!==t?t:()=>{}}getSurveys(e,t=!1){this.surveys?this.surveys.getSurveys(e,t):e([],{isLoaded:!1,error:mu})}getActiveMatchingSurveys(e,t=!1){this.surveys?this.surveys.getActiveMatchingSurveys(e,t):e([],{isLoaded:!1,error:mu})}onActiveMatchingSurveysChanged(e){return this.surveys?this.surveys.onActiveMatchingSurveysChanged(e):(e([],{isLoaded:!1,error:mu}),()=>{})}renderSurvey(e,t){var i;null===(i=this.surveys)||void 0===i||i.renderSurvey(e,t)}displaySurvey(e,t=Gc){var i;null===(i=this.surveys)||void 0===i||i.displaySurvey(e,t)}cancelPendingSurvey(e){var t;null===(t=this.surveys)||void 0===t||t.cancelPendingSurvey(e)}canRenderSurvey(e){var t,i;return null!==(t=null===(i=this.surveys)||void 0===i?void 0:i.canRenderSurvey(e))&&void 0!==t?t:{visible:!1,disabledReason:mu}}canRenderSurveyAsync(e,t=!1){var i,s;return null!==(i=null===(s=this.surveys)||void 0===s?void 0:s.canRenderSurveyAsync(e,t))&&void 0!==i?i:Promise.resolve({visible:!1,disabledReason:mu})}_validateIdentifyId(e){return!e||yt(e)?(Ir.critical("Unique user id has not been set in posthog.identify"),!1):"$posthog_cookieless"===e?(Ir.critical(`The string "${e}" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.`),!1):!["distinct_id","distinctid"].includes(e.toLowerCase())&&!["undefined","null"].includes(e.toLowerCase())||(Ir.critical(`The string "${e}" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.`),!1)}identify(e,t,i){if(!this.__loaded||!this.persistence)return Ir.uninitializedWarning("posthog.identify");if(St(e)&&(e=e.toString(),Ir.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),!this._validateIdentifyId(e))return;if(!this._requirePersonProcessing("posthog.identify"))return;this._syncCookielessIdentity();const s=this.get_distinct_id(),n=this.persistence.syncCookieProperties()&&this.get_distinct_id()!==s,r=this._processCookieIdentityChange(!1),o=this.persistence._beginCookieSyncSuppression();let a=!1;try{const s=this.get_distinct_id();this.register({$user_id:e}),this.get_property("$device_id")||this.register_once({$had_persisted_distinct_id:!0,$device_id:s},""),e!==s&&e!==this.get_property("__alias")&&(this.unregister(T),this.register({distinct_id:e}));const o=(this.persistence.get_property("$user_state")||"anonymous")===Oe,c=e!==s,u=!c&&o;if(c&&o){var l;const n=this.config.reuseAnonymousId?{distinct_id:e}:{distinct_id:e,$anon_distinct_id:s};this.persistence.set_property(ge,De),this.setPersonPropertiesForFlags({$set:t||{},$set_once:i||{}},!1),this.config.cookieWinsOnConflict&&this.persistence._publishSuppressedCookieSnapshot(),this.capture("$identify",n,{$set:t||{},$set_once:i||{}})&&(this._cachedPersonProperties=Nc(e,t,i)),null===(l=this.featureFlags)||void 0===l||l.setAnonymousDistinctId(this.config.reuseAnonymousId?void 0:s)}else if(u){this.persistence.set_property(ge,De);const s=t||{},n=i||{};this.setPersonPropertiesForFlags({$set:s,$set_once:n},!1),this.config.cookieWinsOnConflict&&this.persistence._publishSuppressedCookieSnapshot(),this.capture("$set",{$set:s,$set_once:n})&&(this._cachedPersonProperties=Nc(e,t,i))}else(t||i)&&this.setPersonProperties(t,i);c||n||r?(this.reloadFeatureFlags(),this.featureFlags?this.featureFlags.resetFlagCallReported():this.unregister(_)):u&&(t||i)&&this.reloadFeatureFlags(),a=!0}finally{o&&this.persistence._endCookieSyncSuppression(a)}}setPersonProperties(e,t){if(!e&&!t)return;if(!this._requirePersonProcessing("posthog.setPersonProperties"))return;const i=Nc(this.get_distinct_id(),e,t);this._cachedPersonProperties!==i?(this.setPersonPropertiesForFlags({$set:e||{},$set_once:t||{}},!0),this.capture("$set",{$set:e||{},$set_once:t||{}})&&(this._cachedPersonProperties=i)):Ir.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}unsetPersonProperties(e){var t;const i=(_t(e)?e:[e]).filter(e=>mt(e)&&e.length>0);0!==i.length&&this._requirePersonProcessing("posthog.unsetPersonProperties")&&(null===(t=this.featureFlags)||void 0===t||t.unsetPersonPropertiesForFlags(i,!0),this.capture("$set",{$unset:i}),this._cachedPersonProperties=null)}group(e,t,i){var s;if(!e||!t)return void Ir.error("posthog.group requires a group type and group key");null===(s=this.persistence)||void 0===s||s.syncCookieProperties(),this._processCookieIdentityChange();const n=this.getGroups(),r=n[e]!==t;if(r&&this.resetGroupPropertiesForFlags(e),this.register({$groups:as(as({},n),{},{[e]:t})}),(r||i)&&this._hasPersonProcessing()){const s={$group_type:e,$group_key:t};i&&(s.$group_set=i),this.capture(qe,s)}i&&this.setGroupPropertiesForFlags({[e]:i}),r&&!i&&this.reloadFeatureFlags()}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,t=!0){var i;null===(i=this.featureFlags)||void 0===i||i.setPersonPropertiesForFlags(e,t)}resetPersonPropertiesForFlags(e=!0){var t;null===(t=this.featureFlags)||void 0===t||t.resetPersonPropertiesForFlags(e)}setGroupPropertiesForFlags(e,t=!0){var i;this._requirePersonProcessing("posthog.setGroupPropertiesForFlags")&&(null===(i=this.featureFlags)||void 0===i||i.setGroupPropertiesForFlags(e,t))}resetGroupPropertiesForFlags(e){var t;null===(t=this.featureFlags)||void 0===t||t.resetGroupPropertiesForFlags(e)}reset(e){const t=kt(e)?e:null==e?void 0:e.resetDeviceID,i=kt(e)||null==e?void 0:e.bootstrap;this._reset(t,!1,i)}_reset(e,t=!1,i){var s,n,r,o,a,l;if(Ir.info("reset"),!this.__loaded)return Ir.uninitializedWarning("posthog.reset");const c=null==i?void 0:i.sessionID;this.config.bootstrap=i||(null===(s=this._originalUserConfig)||void 0===s?void 0:s.bootstrap)||{},null===(n=this.featureFlags)||void 0===n||null===(r=n.updateConfig)||void 0===r||r.call(n,this.config,this._shouldDisableFlags());const u=this.get_property(I),d=this.get_property(F),h=this.get_property(G);null===(o=this.sessionRecording)||void 0===o||o.flushBeforeIdentityReset();const _=this.is_capturing();t||this.consent.reset(),t||!_||this.is_capturing()||console.warn("[PostHog.js]","reset() cleared the stored consent, and capturing is now off because of `opt_out_capturing_by_default`. Call opt_in_capturing() again, and prefer calling reset() before opting in rather than after.");const p=null===(a=this.persistence)||void 0===a||null===(l=a._beginCookieSyncSuppression)||void 0===l?void 0:l.call(a),g=this._isConsentTransition;this._isConsentTransition=g||t;let f=!1;try{var v,m,y,b,w,S,C,k,E,x,P,T,R;if(null===(v=this.persistence)||void 0===v||v.clear(),null===(m=this.sessionPersistence)||void 0===m||m.clear(),this._sessionRegisteredPropKeys.clear(),this._persistSessionRegisteredPropKeys(),vt(h)||null===(x=this.persistence)||void 0===x||x.register({$session_recording_remote_config:h}),null===(y=this.surveys)||void 0===y||y.reset(),null===(b=this.featureFlags)||void 0===b||b.reset(),null===(w=this.conversations)||void 0===w||w.reset(),null===(S=this.logs)||void 0===S||S.reset(),null===(C=this.metrics)||void 0===C||C.reset(),null===(k=this.persistence)||void 0===k||k.set_property("$user_state","anonymous"),null===(E=this.sessionManager)||void 0===E||E.resetSessionId(),this._cachedPersonProperties=null,"always"===this.config.cookieless_mode)this.register_once({distinct_id:Se,$device_id:null},"");else{const t=this.config.get_device_id(Kr());this.register_once({distinct_id:t,$device_id:e?t:u},""),e||vt(d)||this.register({[F]:d})}if(this.register({$last_posthog_reset:(new Date).toISOString()},1),i)if(i.distinctID&&!this._inCookielessMode()&&(null===(R=this.persistence)||void 0===R||R.set_property("$user_state",i.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:i.distinctID})),null===(P=this.featureFlags)||void 0===P||P.initialize(),!wt(c)&&!(null===(T=this.sessionManager)||void 0===T?void 0:T.setBootstrapSessionId(c,!0))){const e=as({},i);delete e.sessionID,this.config.bootstrap=e}delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,f=!0}finally{var A,M;this._isConsentTransition=g,p&&(null===(A=this.persistence)||void 0===A||null===(M=A._endCookieSyncSuppression)||void 0===M||M.call(A,f))}var L;this._lastRemoteConfig&&(null===(L=this.conversations)||void 0===L||L.onRemoteConfig(this._lastRemoteConfig)),this.reloadFeatureFlags()}shutdown(e){var t=this;return Ot(function*(){if(!t.__loaded)return void Ir.uninitializedWarning("posthog.shutdown");t._isShutdown=!0,clearTimeout(t._extensionInitTimeout),t._extensionInitTimeout=void 0;const e=t._featureFlagsReloadingUnsubscribe;t._featureFlagsReloadingUnsubscribe=void 0;for(const i of[()=>{var e;return null===(e=t.sessionRecording)||void 0===e?void 0:e.dispose()},()=>{var e;return null===(e=t.logs)||void 0===e?void 0:e.flushLogs("sendBeacon")},()=>{var e;return null===(e=t.metrics)||void 0===e?void 0:e.flush("sendBeacon")},()=>{var e;return null===(e=t.metrics)||void 0===e?void 0:e.dispose()},()=>{var e;return null===(e=t.logs)||void 0===e?void 0:e.dispose()},()=>{var e;return null===(e=t.surveys)||void 0===e?void 0:e.dispose()},()=>{var e;return null===(e=t.autocapture)||void 0===e?void 0:e.dispose()},()=>null==e?void 0:e(),()=>{var e;return null===(e=t._requestQueue)||void 0===e?void 0:e.unload()},()=>{var e;return null===(e=t._retryQueue)||void 0===e?void 0:e.unload()},()=>{var e;return null===(e=t.featureFlags)||void 0===e?void 0:e.destroy()},()=>{var e;return null===(e=t.persistence)||void 0===e?void 0:e.destroy()},()=>{var e;return null===(e=t.sessionPersistence)||void 0===e?void 0:e.destroy()}])try{const e=i();e&&pt(e.then)&&e.then(void 0,e=>{Ir.error("Error during shutdown",e)})}catch(e){Ir.error("Error during shutdown",e)}})()}setIdentity(e,t){var i;delete this.config.identity_claims,this.config.identity_distinct_id=e,this.config.identity_hash=t,this.alias(e),null===(i=this.conversations)||void 0===i||i._onIdentityChanged()}clearIdentity(){var e;delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,null===(e=this.conversations)||void 0===e||e._onIdentityCleared()}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var e,t;return null!==(e=null===(t=this.sessionManager)||void 0===t?void 0:t.checkAndGetSessionAndWindowId(!0).sessionId)&&void 0!==e?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";const{sessionId:t,sessionStartTimestamp:i}=this.sessionManager.checkAndGetSessionAndWindowId(!0);let s=this.requestRouter.endpointFor("ui",`/project/${this.config.token}/replay/${t}`);if((null==e?void 0:e.withTimestamp)&&i){var n;const t=null!==(n=e.timestampLookBack)&&void 0!==n?n:10;if(!i)return s;s+=`?t=${Math.max(Math.floor(((new Date).getTime()-i)/1e3)-t,0)}`}return s}alias(e,t){return e===this.get_property("$people_distinct_id")?(Ir.critical("Attempting to create alias for existing People user - aborting."),-2):this._requirePersonProcessing("posthog.alias")?(vt(t)&&(t=this.get_distinct_id()),e!==t?(this._register_single(T,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(Ir.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){const t=as({},this.config);if(gt(e)){var s,n,r,o,a,l,c,u,d,h,_,p,g,f;Ar(this.config,$u(e));const w=this._is_persistence_disabled();if(this.persistence){const e="sessionStorage"===this.config.persistence||"memory"===this.config.persistence;var v,m;if(e&&this.sessionPersistence!==this.persistence&&(null===(v=this.sessionPersistence)||void 0===v||v.remove(),null===(m=this.sessionPersistence)||void 0===m||m.destroy()),this.persistence.update_config(this.config,t,w),e)this.sessionPersistence=this.persistence;else if(this.sessionPersistence===this.persistence)this.sessionPersistence=new sl(as(as({},this.config),{},{persistence:"sessionStorage"}),w,!1);else{var y;null===(y=this.sessionPersistence)||void 0===y||y.update_config(as(as({},this.config),{},{persistence:"sessionStorage"}),as(as({},t),{},{persistence:"sessionStorage"}),w)}}const S=this._checkLocalStorageForDebug(this.config.debug);var b;kt(S)&&(this.config.debug=S),kt(this.config.debug)&&(this.config.debug?(i.DEBUG=!0,to._is_supported()&&to._set("ph_debug",!0),Ir.info("set_config",{config:e,oldConfig:t,newConfig:as({},this.config)})):(i.DEBUG=!1,to._is_supported()&&to._remove("ph_debug"))),null===(s=this.featureFlags)||void 0===s||null===(n=s.updateConfig)||void 0===n||n.call(s,this.config,this._shouldDisableFlags()),null===(r=this.exceptionObserver)||void 0===r||r.onConfigChange(),null===(o=this.exceptions)||void 0===o||o.onConfigChange(),null===(a=this.metrics)||void 0===a||a.onConfigChange(),null===(l=this.webMCP)||void 0===l||l.startIfEnabled(),null===(c=this.sessionRecording)||void 0===c||c.startIfEnabledOrStop(),null===(u=this.tracingHeaders)||void 0===u||u.startIfEnabledOrStop(),null===(d=this.autocapture)||void 0===d||d.startIfEnabled(),null===(h=this.heatmaps)||void 0===h||h.startIfEnabled(),("capture_pageview"in e||"disable_capture_url_hashes"in e)&&(null===(b=this.historyAutocapture)||void 0===b||b.startIfEnabledOrStop()),null===(_=this.exceptionObserver)||void 0===_||_.startIfEnabledOrStop(),null===(p=this.deadClicksAutocapture)||void 0===p||p.startIfEnabledOrStop(),null===(g=this.surveys)||void 0===g||g.loadIfEnabled(),this._sync_opt_out_with_persistence(),null===(f=this.externalIntegrations)||void 0===f||f.startIfEnabledOrStop(),!t.segment&&this.config.segment&&this.persistence&&_a(this,fu,!1)}}_overrideSDKInfo(e,t){i.LIB_NAME=e,i.LIB_VERSION=t}startSessionRecording(e){const t=!0===e,i={sampling:t||!!(null==e?void 0:e.sampling),linked_flag:t||!!(null==e?void 0:e.linked_flag),url_trigger:t||!!(null==e?void 0:e.url_trigger),event_trigger:t||!!(null==e?void 0:e.event_trigger)};var s,n,r,o,a;Object.values(i).some(Boolean)&&(null===(s=this.sessionManager)||void 0===s||s.checkAndGetSessionAndWindowId(),i.sampling&&(null===(n=this.sessionRecording)||void 0===n||n.overrideSampling()),i.linked_flag&&(null===(r=this.sessionRecording)||void 0===r||r.overrideLinkedFlag()),i.url_trigger&&(null===(o=this.sessionRecording)||void 0===o||o.overrideTrigger("url")),i.event_trigger&&(null===(a=this.sessionRecording)||void 0===a||a.overrideTrigger("event")));this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var e;return!!(null===(e=this.sessionRecording)||void 0===e?void 0:e.started)}captureException(e,t){try{if(!this.exceptions)return;const i=this.exceptions.buildProperties(e,{handled:!0,syntheticException:new Error("PostHog syntheticException")});return this.exceptions.sendExceptionEvent(as(as({},i),t))}catch(e){return}}addExceptionStep(e,t){var i;null===(i=this.exceptions)||void 0===i||i.addExceptionStep(e,t)}captureLog(e){var t;null===(t=this.logs)||void 0===t||t.captureLog(e)}get logger(){var t,i;return null!==(t=null===(i=this.logs)||void 0===i?void 0:i.logger)&&void 0!==t?t:e._noopLogger}startExceptionAutocapture(e){this.set_config({capture_exceptions:null==e||e})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(e){var t,i;return null!==(t=null===(i=this.toolbar)||void 0===i?void 0:i.loadToolbar(e))&&void 0!==t&&t}get_property(e){var t;return null===(t=this.persistence)||void 0===t?void 0:t.props[e]}getSessionProperty(e){var t;return null===(t=this.sessionPersistence)||void 0===t?void 0:t.props[e]}toString(){var e;let t=null!==(e=this.config.name)&&void 0!==e?e:Iu;return t!==Iu&&(t="posthog."+t),t}_isIdentified(){var e,t;return"identified"===(null===(e=this.persistence)||void 0===e?void 0:e.get_property("$user_state"))||"identified"===(null===(t=this.sessionPersistence)||void 0===t?void 0:t.get_property("$user_state"))}_hasPersonProcessing(){var e,t;return!("never"===this.config.person_profiles||"identified_only"===this.config.person_profiles&&!this._isIdentified()&&ft(this.getGroups())&&!(null===(e=this.persistence)||void 0===e||null===(e=e.props)||void 0===e?void 0:e.__alias)&&!(null===(t=this.persistence)||void 0===t||null===(t=t.props)||void 0===t?void 0:t.$epp))}_shouldCapturePageleave(){return!0===this.config.capture_pageleave||"if_capture_pageview"===this.config.capture_pageleave&&!!this.config.capture_pageview}createPersonProfile(){this._hasPersonProcessing()||this._requirePersonProcessing("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this._requirePersonProcessing("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}_requirePersonProcessing(e){return"never"===this.config.person_profiles?(Ir.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this._warnIfVolatileIdentityWithoutStableId(),this._register_single(we,!0),!0)}_is_persistence_disabled(){if("always"===this.config.cookieless_mode)return!0;const e=this.consent.isOptedOut();return this.config.disable_persistence||e&&!(!this.config.opt_out_persistence_by_default&&"on_reject"!==this.config.cookieless_mode)}_sync_opt_out_with_persistence(){var e,t;const i=this._is_persistence_disabled();var s,n,r;return this.is_capturing()||null===(s=this.logs)||void 0===s||s._onOptOut(),(null===(e=this.persistence)||void 0===e?void 0:e._disabled)!==i&&(null===(n=this.persistence)||void 0===n||n.set_disabled(i)),(null===(t=this.sessionPersistence)||void 0===t?void 0:t._disabled)!==i&&(null===(r=this.sessionPersistence)||void 0===r||r.set_disabled(i)),this._persistSessionRegisteredPropKeys(),i}opt_in_capturing(t){var i,s,n;if("always"===this.config.cookieless_mode)return void Ir.warn(vu);if(this._inCookielessMode()){var r,o,a,l,c,u;null===(r=this.sessionRecording)||void 0===r||r.dispose({discardBufferedEvents:!0}),this._reset(!0,!0),null===(o=this.sessionManager)||void 0===o||o.destroy(),null===(a=this.pageViewManager)||void 0===a||a.destroy(),this.sessionManager=new Ic(this),this.pageViewManager=new va(this),this.persistence&&(this.sessionPropsManager=new kc(this,this.sessionManager,this.persistence));const t=null!==(l=null===(c=this.config.__extensionClasses)||void 0===c?void 0:c.sessionRecording)&&void 0!==l?l:null===(u=e.__defaultExtensionClasses)||void 0===u?void 0:u.sessionRecording;var d,h;t&&(this.sessionRecording=this._replaceExtension(this.sessionRecording,new t(this)),this._lastRemoteConfig&&(null===(d=this.sessionRecording)||void 0===d||null===(h=d.onRemoteConfig)||void 0===h||h.call(d,this._lastRemoteConfig)))}const _=1===this.consent.consent;var p,g,f;_&&this._syncCookielessIdentity(),this.consent.optInOut(!0),this._sync_opt_out_with_persistence(),this._start_queue_if_opted_in(),null===(i=this.sessionRecording)||void 0===i||i.startIfEnabledOrStop(),"on_reject"==this.config.cookieless_mode&&(null===(p=this.surveys)||void 0===p||p.loadIfEnabled(),null===(g=this.conversations)||void 0===g||g.loadIfEnabled()),_||!vt(null==t?void 0:t.captureEventName)&&!(null==t?void 0:t.captureEventName)||this.capture(null!==(f=null==t?void 0:t.captureEventName)&&void 0!==f?f:"$opt_in",null==t?void 0:t.captureProperties,{send_instantly:!0}),null===(s=this.persistence)||void 0===s||s.syncCookieProperties(),this._processCookieIdentityChange(),null===(n=this.featureFlags)||void 0===n||n.sendFlagCallsPendingCapture(),this.config.capture_pageview&&this._captureInitialPageview()}opt_out_capturing(){"always"!==this.config.cookieless_mode?(this.consent.optInOut(!1),this._sync_opt_out_with_persistence(),"on_reject"===this.config.cookieless_mode&&this._enterCookielessMode()):Ir.warn(vu)}_enterCookielessMode(){var e,t;const i=this.sessionRecording;null==i||i.dispose({discardBufferedEvents:!0}),"$posthog_cookieless"!==this.get_distinct_id()&&this._reset(!0,!0),this.register({distinct_id:Se,$device_id:null}),this._removeExtension(i),this.sessionRecording=void 0,null===(e=this.sessionManager)||void 0===e||e.destroy(),null===(t=this.pageViewManager)||void 0===t||t.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,this.config.capture_pageview&&this._captureInitialPageview(),this._start_queue_if_opted_in()}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){const e=this.consent.consent;return 1===e?"granted":0===e?"denied":"pending"}is_capturing(){return!this._isConsentTransition&&("always"===this.config.cookieless_mode||("on_reject"===this.config.cookieless_mode?this.consent.isRejected()||this.consent.isOptedIn():!this.has_opted_out_capturing()))}clear_opt_in_out_capturing(){this.consent.reset(),this._sync_opt_out_with_persistence()}_is_bot(){return Ve?Tc(Ve,this.config.custom_blocked_useragents):void 0}_captureInitialPageview(){Ge&&("visible"===Ge.visibilityState?this._initialPageviewCaptured||(this._initialPageviewCaptured=!0,this.capture(ze,{title:Ge.title},{send_instantly:!0}),this._visibilityStateListener&&(Ge.removeEventListener(m,this._visibilityStateListener),this._visibilityStateListener=null)):this._visibilityStateListener||(this._visibilityStateListener=this._captureInitialPageview.bind(this),Br(Ge,m,this._visibilityStateListener)))}debug(e){!1===e?(null==je||je.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(null==je||je.console.log("You're now in debug mode. All calls to PostHog will be logged in your console.\nYou can disable this with `posthog.debug(false)`."),this.set_config({debug:!0}))}_shouldDisableFlags(){const e=this._originalUserConfig||{};return"advanced_disable_flags"in e?!!e.advanced_disable_flags:!1!==this.config.advanced_disable_flags?!!this.config.advanced_disable_flags:!0===this.config.advanced_disable_decide?(Ir.warn("Config field 'advanced_disable_decide' is deprecated. Please use 'advanced_disable_flags' instead. The old field will be removed in a future major version."),!0):function(e,t,i,s,n){const r=t in e&&!wt(e[t]),o=i in e&&!wt(e[i]);return r?e[t]:!!o&&(n&&n.warn(`Config field '${i}' is deprecated. Please use '${t}' instead. The old field will be removed in a future major version.`),e[i])}(e,"advanced_disable_flags","advanced_disable_decide",0,Ir)}_runBeforeSend(e){var t;if(wt(this.config.before_send))return e;const i=Object.keys(null!==(t=e.properties)&&void 0!==t?t:{}).filter(xt),s=_t(this.config.before_send)?this.config.before_send:[this.config.before_send];let n=e;for(const t of s)try{if(n=t(n),wt(n)){const t=`Event '${e.event}' was rejected in beforeSend function`;return Et(e.event)?Ir.warn(`${t}. This can cause unexpected behavior.`):Ir.info(t),null}n.properties&&!ft(n.properties)||Ir.warn(`Event '${e.event}' has no properties after beforeSend function, this is likely an error.`)}catch(t){return Ir.error(`Error in beforeSend function for event '${e.event}':`,t),null}for(const t of i)if(n.properties&&wt(n.properties[t]))return Ir.warn(`Event '${e.event}' had its '${t}' property removed in a beforeSend function. This property is required for ingestion, so the event will be dropped.`),null;return n}getPageViewId(){var e;return null===(e=this.pageViewManager._currentPageview)||void 0===e?void 0:e.pageViewId}captureTraceFeedback(e,t){this.capture("$ai_feedback",{$ai_trace_id:String(e),$ai_feedback_text:t})}captureTraceMetric(e,t,i){this.capture("$ai_metric",{$ai_trace_id:String(e),$ai_metric_name:t,$ai_metric_value:String(i)})}_checkLocalStorageForDebug(e){const t=kt(e)&&!e,i=to._is_supported()&&"true"===to._get("ph_debug");return!t&&(!!i||e)}};Lu.__defaultExtensionClasses={},Lu._noopLogger=(()=>{const e=()=>{};return{trace:e,debug:e,info:e,warn:e,error:e,fatal:e}})(),function(e,t){for(let i=0;t.length>i;i++)e.prototype[t[i]]=Mr(e.prototype[t[i]])}(Lu,["identify"]);const Ou=["[data-ph-capture-value]"];var Du=class{constructor(e){this._instance=e}refresh(e){var t;const i=this._instance.config,s=gt(i.autocapture)?i.autocapture:void 0;e.enabled=!!i.autocapture,e.rageclick=i.rageclick,e.maskAllElementAttributes=i.mask_all_element_attributes,e.maskAllText=i.mask_all_text,e.disableCaptureUrlHashes=i.disable_capture_url_hashes,e.getCurrentUrl=i.get_current_url,e.remoteRequestsDisabled=this._instance._shouldDisableFlags(),e.url_allowlist=null==s?void 0:s.url_allowlist,e.url_ignorelist=null==s?void 0:s.url_ignorelist,e.dom_event_allowlist=null==s?void 0:s.dom_event_allowlist,e.element_allowlist=null==s?void 0:s.element_allowlist,e.css_selector_allowlist=null==s?void 0:s.css_selector_allowlist,e.css_selector_ignorelist=null==s?void 0:s.css_selector_ignorelist,e.element_attribute_ignorelist=null==s?void 0:s.element_attribute_ignorelist,e.capture_copied_text=null==s?void 0:s.capture_copied_text,e.capture_value_css_selector_allowlist=null!==(t=null==s?void 0:s.capture_value_css_selector_allowlist)&&void 0!==t?t:Ou}};const Nu=Fr("[ExceptionAutocapture]"),Bu=()=>{},zu=e=>{var t;if(pt(e))return null!==(t=e.__posthog_layer__)&&void 0!==t?t:e.__rrweb_layer__};function Hu(e,t,i){try{if(!(t in e))return Bu;const s={next:e[t]},n=i(function(...e){return s.next.apply(this,e)});return pt(n)&&(n.prototype=n.prototype||{},Object.defineProperties(n,{__posthog_wrapped__:{enumerable:!1,value:!0},__posthog_layer__:{enumerable:!1,value:s}})),e[t]=n,()=>{if(e[t]===n)return void(e[t]=s.next);let i=e[t],r=zu(i);for(;r;){if(r.next===n)return void(r.next=s.next);i=r.next,r=zu(i)}}}catch(e){return Bu}}const Uu=Fr("[TracingHeaders]"),qu=Fr("[Web Vitals]"),ju=9e5,Wu=["CLS","FCP","INP","LCP"],Vu=["INP","LCP"],Gu=["interactionTarget","interactionType","inputDelay","processingDuration","presentationDelay","loadState","target","url","timeToFirstByte","resourceLoadDelay","resourceLoadDuration","elementRenderDelay","largestShiftTarget","largestShiftTime","largestShiftValue","firstByteToFCP"],Ku="disabled",Qu="lazy_loading",Ju=Fr("[SessionRecording]"),Yu=[xe,Pe,Ie,Fe,Te,Re,Ae,$e,Me],Xu=Fr("[Heatmaps]");function Zu(e){return gt(e)&&"clientX"in e&&"clientY"in e&&St(e.clientX)&&St(e.clientY)}const ed=Fr("[Product Tours]"),td=e=>{var t;return!e.config.disable_product_tours&&!!(null===(t=e.persistence)||void 0===t?void 0:t.get_property(j))},id=["$set_once","$set"],sd=Fr("[SiteApps]"),nd="Error while initializing PostHog app with config id ";function rd(e,t,i){if(wt(e))return!1;switch(i){case"exact":return e===t;case"contains":{const i=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(i,"i").test(e)}case"regex":try{return new RegExp(t).test(e)}catch(e){return!1}default:return!1}}var od=class{constructor(e){this._host=e,this._actionRegistry=new Set,this._actionEvents=new Set,this._debugEventEmitter=new Ec,this._checkStep=(e,t)=>this._checkStepEvent(e,t)&&this._checkStepUrl(e,t)&&this._checkStepElement(e,t)&&this._checkStepProperties(e,t),this._checkStepEvent=(e,t)=>!(null==t?void 0:t.event)||(null==e?void 0:e.event)===(null==t?void 0:t.event)}init(){var e,t;vt(null===(e=this._host)||void 0===e?void 0:e.subscribeCapture)||(this._captureHookUnsubscribe=null===(t=this._host)||void 0===t?void 0:t.subscribeCapture((e,t)=>{this.on(e,t)}))}dispose(){var e,t,i;null===(e=this._captureHookUnsubscribe)||void 0===e||e.call(this),this._captureHookUnsubscribe=void 0,null===(t=this._host)||void 0===t||null===(i=t.setElementSelectors)||void 0===i||i.call(t,new Set,this),this._debugEventEmitter=new Ec}register(e){var t,i;if(!vt(null===(t=this._host)||void 0===t?void 0:t.subscribeCapture)&&(e.forEach(e=>{var t;this._actionRegistry.add(e),null===(t=e.steps)||void 0===t||t.forEach(e=>{this._actionEvents.add((null==e?void 0:e.event)||"")})}),null===(i=this._host)||void 0===i?void 0:i.setElementSelectors)){const e=new Set;this._actionRegistry.forEach(t=>{var i;null===(i=t.steps)||void 0===i||i.forEach(t=>{(null==t?void 0:t.selector)&&e.add(t.selector)})}),this._host.setElementSelectors(e,this)}}replace(e){this._actionRegistry.clear(),this._actionEvents.clear(),this.register(e)}on(e,t){null!=t&&0!=e.length&&(this._actionEvents.has(e)||this._actionEvents.has(t.event))&&this._actionRegistry.forEach(e=>{this._checkAction(t,e)&&this._debugEventEmitter.emit("actionCaptured",e.name)})}_addActionHook(e){this.onAction("actionCaptured",t=>e(t))}_checkAction(e,t){if(null==(null==t?void 0:t.steps))return!1;for(const i of t.steps)if(this._checkStep(e,i))return!0;return!1}onAction(e,t){return this._debugEventEmitter.on(e,t)}_checkStepUrl(e,t){if(null==t?void 0:t.url){var i;let r=null==e||null===(i=e.properties)||void 0===i?void 0:i.$current_url;if(!(null==e?void 0:e.properties)||!("$current_url"in e.properties))try{var s,n;r=null===(s=this._host)||void 0===s||null===(n=s.getActionUrl)||void 0===n?void 0:n.call(s)}catch(e){return!1}if(!r||"string"!=typeof r)return!1;if(!rd(r,t.url,t.url_matching||"contains"))return!1}return!0}_checkStepElement(e,t){return!!this._checkStepHref(e,t)&&!!this._checkStepText(e,t)&&!!this._checkStepSelector(e,t)}_checkStepHref(e,t){var i;if(!(null==t?void 0:t.href))return!0;const s=this._getElementsList(e);if(s.length>0)return s.some(e=>rd(e.href,t.href,t.href_matching||"exact"));const n=(null==e||null===(i=e.properties)||void 0===i?void 0:i.$elements_chain)||"";return!!n&&rd(function(e){const t=e.match(/(?::|")href="(.*?)"/);return t?t[1]:""}(n),t.href,t.href_matching||"exact")}_checkStepText(e,t){var i;if(!(null==t?void 0:t.text))return!0;const s=this._getElementsList(e);if(s.length>0)return s.some(e=>rd(e.text,t.text,t.text_matching||"exact")||rd(e.$el_text,t.text,t.text_matching||"exact"));const n=(null==e||null===(i=e.properties)||void 0===i?void 0:i.$elements_chain)||"";return!!n&&(r=function(e){const t=[],i=/(?::|")text="(.*?)"/g;let s;for(;!wt(s=i.exec(e));)t.includes(s[1])||t.push(s[1]);return t}(n),o=t.text,a=t.text_matching||"exact",r.some(e=>rd(e,o,a)));var r,o,a}_checkStepSelector(e,t){var i,s;if(!(null==t?void 0:t.selector))return!0;const n=null==e||null===(i=e.properties)||void 0===i?void 0:i.$element_selectors;if(null==n?void 0:n.includes(t.selector))return!0;const r=(null==e||null===(s=e.properties)||void 0===s?void 0:s.$elements_chain)||"";if(t.selector_regex&&r)try{return new RegExp(t.selector_regex).test(r)}catch(e){}return!1}_getElementsList(e){var t;return null==(null==e||null===(t=e.properties)||void 0===t?void 0:t.$elements)?[]:null==e?void 0:e.properties.$elements}_checkStepProperties(e,t){return!(null==t?void 0:t.properties)||0===t.properties.length||Dc(t.properties.reduce((e,t)=>{const i=_t(t.value)?t.value.map(String):null!=t.value?[String(t.value)]:[];return e[t.key]={values:i,operator:t.operator||"exact"},e},{}),null==e?void 0:e.properties)}},ad=class{constructor(e,t){this._onActivationChanged=t,this._pendingActivatedItems=[],this._host=e,this._eventToItems=new Map,this._cancelEventToItems=new Map,this._actionToItems=new Map}_subscribeSession(){var e,t;this._sessionIdUnsubscribe=null===(e=(t=this._host).subscribeSession)||void 0===e?void 0:e.call(t,e=>this._onSessionIdChanged(e))}_shouldPersistArmedActivation(e){return!1}_getActivationTimestampsKey(){return null}_writeActivationTimestamps(e){}_clearActivationTimestampsStore(){}_doesEventMatchFilter(e,t){return!!e&&Dc(e.propertyFilters,null==t?void 0:t.properties)}_buildEventToItemMap(e,t){const i=new Map;return e.forEach(e=>{var s;null===(s=e.conditions)||void 0===s||null===(s=s[t])||void 0===s||null===(s=s.values)||void 0===s||s.forEach(t=>{if(null==t?void 0:t.name){const s=i.get(t.name)||[];s.push(e.id),i.set(t.name,s)}})}),i}_getMatchingItems(e,t,i){const s=(i===ol?this._eventToItems:this._cancelEventToItems).get(e);let n=[];return this._getItems(e=>{n=e.filter(e=>null==s?void 0:s.includes(e.id))}),n.filter(s=>{var n;const r=null===(n=s.conditions)||void 0===n||null===(n=n[i])||void 0===n||null===(n=n.values)||void 0===n?void 0:n.find(t=>t.name===e);return this._doesEventMatchFilter(r,t)})}register(e){this._register(e,!1)}replace(e){this._register(e,!0)}_register(e,t){vt(this._host.subscribeCapture)||(this._setupEventBasedItems(e,t),this._setupActionBasedItems(e,t))}_setupActionBasedItems(e,t){const i=e.filter(e=>{var t;return null===(t=e.conditions)||void 0===t||null===(t=t.actions)||void 0===t||null===(t=t.values)||void 0===t?void 0:t.length});var s;if(t&&this._actionToItems.clear(),0===i.length)return void(t&&(null===(s=this._actionMatcher)||void 0===s||s.replace([])));this._actionMatcher||(this._actionMatcher=new od(this._host),this._actionMatcher.init(),this._actionMatcher._addActionHook(e=>this.onAction(e)));const n=[];i.forEach(e=>{var t;null===(t=e.conditions)||void 0===t||null===(t=t.actions)||void 0===t||t.values.forEach(t=>{if(n.push(t),t.name){var i;const s=null!==(i=this._actionToItems.get(t.name))&&void 0!==i?i:[];s.includes(e.id)||s.push(e.id),this._actionToItems.set(t.name,s)}})}),t?this._actionMatcher.replace(n):this._actionMatcher.register(n)}_mergeItemMaps(e,t){t.forEach((t,i)=>{var s;const n=null!==(s=e.get(i))&&void 0!==s?s:[];t.forEach(e=>{n.includes(e)||n.push(e)}),e.set(i,n)})}_setupEventBasedItems(e,t){var i,s,n;const r=e.filter(e=>{var t,i;return(null===(t=e.conditions)||void 0===t?void 0:t.events)&&(null===(i=e.conditions)||void 0===i||null===(i=i.events)||void 0===i||null===(i=i.values)||void 0===i?void 0:i.length)>0}),o=e.filter(e=>{var t,i;return(null===(t=e.conditions)||void 0===t?void 0:t.cancelEvents)&&(null===(i=e.conditions)||void 0===i||null===(i=i.cancelEvents)||void 0===i||null===(i=i.values)||void 0===i?void 0:i.length)>0}),a=this._buildEventToItemMap(e,ol),l=this._buildEventToItemMap(e,al);t?(this._eventToItems=a,this._cancelEventToItems=l):(this._mergeItemMaps(this._eventToItems,a),this._mergeItemMaps(this._cancelEventToItems,l)),(0!==r.length||0!==o.length||e.some(e=>{var t;return null===(t=e.conditions)||void 0===t||null===(t=t.actions)||void 0===t||null===(t=t.values)||void 0===t?void 0:t.length}))&&(null!==(i=this._captureHookUnsubscribe)&&void 0!==i||(this._captureHookUnsubscribe=null===(s=(n=this._host).subscribeCapture)||void 0===s?void 0:s.call(n,(e,t)=>{this.onEvent(e,t)})))}onEvent(e,t){var i,s;const n=this._getLogger(),r=(null==t||null===(i=t.properties)||void 0===i?void 0:i.$survey_id)||(null==t||null===(s=t.properties)||void 0===s?void 0:s.$product_tour_id);if(r&&this.getActivatedIds().includes(r)){const i=this._activationOutcome(e,r,t);if("consume"===i)return n.info("event consumed activated item, removing it",{event:e,itemId:r}),void this._deactivateItems([r]);if("persist"===i)return n.info("shown item promoted to persisted activation",{event:e,itemId:r}),this._persistActivation(r),void this._clearActivationTimestamps([r])}if(this._cancelEventToItems.has(e)){const i=this._getMatchingItems(e,t,al);i.length>0&&(n.info("cancel event matched, cancelling items",{event:e,itemsToCancel:i.map(e=>e.id)}),this._deactivateItems(i.map(e=>e.id)),i.forEach(e=>this._cancelPendingItem(e.id)))}if(!this._eventToItems.has(e))return;n.info("event name matched",{event:e,eventPayload:t,items:this._eventToItems.get(e)});const o=this._getMatchingItems(e,t,ol);this._activateItems(o.map(e=>e.id))}onAction(e){this._actionToItems.has(e)&&this._activateItems(this._actionToItems.get(e)||[])}_activateItems(e){if(0===e.length)return;const t=!!this._host.getSessionId(),i=[];for(const s of e)t&&this._shouldPersistArmedActivation(s)?this._persistActivation(s)&&this._recordActivationTimestamp(s):i.push(s);i.length>0&&(this._pendingActivatedItems=[...new Set([...this._pendingActivatedItems,...i])]),this._getLogger().info("updating activated items",{activatedItems:this.getActivatedIds()}),this._notifyActivationChanged()}_persistActivation(e){this._pendingActivatedItems=this._pendingActivatedItems.filter(t=>t!==e);const t=this._getPersistedActivatedIds();return!t.includes(e)&&(this._setActivatedItems([...t,e]),this._stampActivationSession(),!0)}_deactivateItems(e){const t=new Set(e);this._pendingActivatedItems=this._pendingActivatedItems.filter(e=>!t.has(e));const i=this._getRawPersistedActivatedIds(),s=i.filter(e=>!t.has(e));s.length!==i.length&&(this._setActivatedItems(s),0===s.length&&this._clearActivationSession()),this._clearActivationTimestamps(e),this._notifyActivationChanged()}_notifyActivationChanged(){try{var e;null===(e=this._onActivationChanged)||void 0===e||e.call(this)}catch(e){this._getLogger().error("Error while handling activated items change",e)}}_getRawActivationTimestamps(){const e=this._getActivationTimestampsKey();if(!e)return{};const t=this._host.getProperty(e);return t&&"object"==typeof t?t:{}}_recordActivationTimestamp(e){if(!this._getActivationTimestampsKey())return;const t=this._getRawActivationTimestamps();this._writeActivationTimestamps(as(as({},t),{},{[e]:Date.now()}))}_clearActivationTimestamps(e){if(!this._getActivationTimestampsKey())return;const t=this._getRawActivationTimestamps(),i={};let s=!1;for(const[n,r]of Object.entries(t))e.includes(n)?s=!0:i[n]=r;s&&(ft(i)?this._clearActivationTimestampsStore():this._writeActivationTimestamps(i))}_clearAllActivationTimestamps(){this._getActivationTimestampsKey()&&this._clearActivationTimestampsStore()}getActivationTimestamp(e){if(!this._getPersistedActivatedIds().includes(e))return;const t=this._getRawActivationTimestamps()[e];return St(t)?t:void 0}_getRawPersistedActivatedIds(){const e=this._getActivatedKey();return this._host.getProperty(e)||[]}_getPersistedActivatedIds(){const e=this._getRawPersistedActivatedIds();if(0===e.length)return[];const t=this._host.getProperty(this._getActivatedSessionKey()),i=this._host.getSessionId();return i&&t===i?e:[]}_stampActivationSession(){const e=this._host.getSessionId();e&&this._setActivatedSession(e)}_clearActivationSession(){this._clearActivatedSession()}_onSessionIdChanged(e){const t=this._host.getProperty(this._getActivatedSessionKey());if(t&&t!==e){const e=this._getRawPersistedActivatedIds(),t=this._getRawActivationTimestamps();e.length>0&&(this._setActivatedItems([]),e.filter(e=>St(t[e])).forEach(e=>this._cancelPendingItem(e))),this._clearActivationSession(),this._clearAllActivationTimestamps(),e.length>0&&this._notifyActivationChanged()}}getActivatedIds(){return[...new Set([...this._getPersistedActivatedIds(),...this._pendingActivatedItems])].filter(e=>!this._isItemPermanentlyIneligible(e))}dispose(){var e,t,i;null===(e=this._sessionIdUnsubscribe)||void 0===e||e.call(this),this._sessionIdUnsubscribe=void 0,null===(t=this._captureHookUnsubscribe)||void 0===t||t.call(this),this._captureHookUnsubscribe=void 0,null===(i=this._actionMatcher)||void 0===i||i.dispose(),this._actionMatcher=void 0}reset(){this._pendingActivatedItems=[],this._getRawPersistedActivatedIds().length>0&&this._setActivatedItems([]),this._clearActivationSession(),this._clearAllActivationTimestamps(),this._notifyActivationChanged()}getEventToItemsMap(){return this._eventToItems}_getActionMatcher(){return this._actionMatcher}},ld=class extends ad{constructor(e,t,i,s){var n;super({subscribeCapture(t){const i=e.onEvent(e=>t(e.event,e));return()=>i.dispose()},subscribeSession(t){const i=e.onSession(t);return()=>i.dispose()},getSessionId(){var t;return null===(t=e.session)||void 0===t?void 0:t.sessionId},getProperty:t=>e.kv.get(t),getActionUrl:null==i?void 0:i.getActionUrl,setElementSelectors:null!==(n=null==i?void 0:i.setElementSelectors)&&void 0!==n?n:(t,i)=>{var s;return null===(s=e.getExtension("autocapture"))||void 0===s?void 0:s.setElementSelectors(t,i)}},s),this._client=e,this._surveys=t,this._subscribeSession()}_getActivatedKey(){return C}_getActivatedSessionKey(){return k}_getActivationTimestampsKey(){return E}_writeActivationTimestamps(e){this._client.kv.set({[E]:e})}_clearActivationTimestampsStore(){this._client.kv.remove(E)}_shouldPersistArmedActivation(e){var t;let i;this._getItems(t=>{i=t.find(t=>t.id===e)});const s=null==i||null===(t=i.appearance)||void 0===t?void 0:t.surveyPopupDelaySeconds;return St(s)&&s>0}_getShownEventName(){return ll}_getItems(e){this._surveys.getSurveys(e)}_cancelPendingItem(e){this._surveys.cancelPendingSurvey(e)}_getLogger(){return jc}_setActivatedItems(e){this._client.kv.set({[C]:e})}_setActivatedSession(e){this._client.kv.set({[k]:e})}_clearActivatedSession(){this._client.kv.remove(k)}_isItemPermanentlyIneligible(){return!1}_activationOutcome(e,t,i){var s;if(e===ul&&!1===(null==i||null===(s=i.properties)||void 0===s?void 0:s.$survey_completed))return"ignore";let n;return this._getItems(e=>{n=e.find(e=>e.id===t)}),!n||function(e){var t;return $c(e)&&!!(null===(t=e.conditions)||void 0===t||null===(t=t.events)||void 0===t?void 0:t.repeatedActivation)||"always"===e.schedule}(n)?e===ll?"consume":"ignore":e===ll?"persist":e===cl||e===ul?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}};const cd=(e,t)=>(null==e?void 0:e.then)?e.then(t):t(e),ud="SDK is not enabled or survey functionality is not yet loaded",dd="Disabled. Not loading surveys.";var hd=class{constructor(e){this._configSource=e,this.name="surveys",this._surveyEventReceiver=null,this._surveyManager=null,this._isInitializingSurveys=!1,this._surveyInitializationFailed=!1,this._surveyCallbacks=[],this._activeMatchingSurveyCallbacks=[],this._getSurveysInFlightPromise=null,this._lastSurveyRefreshFailedAt=null,this._disposed=!1,this._renderTimeouts=new Set,this.onRemoteConfig=e=>{if(this._disposed)return;if(this._config.disableSurveys)return;if(!e.ok)return this._surveyInitializationFailed=!0,this._notifyActiveMatchingSurveyCallbacks({isLoaded:!1,error:"Remote config unavailable. Not loading surveys."}),jc.warn("Remote config unavailable. Not loading surveys.");const t=e.config.surveys;if(wt(t))return jc.warn("Flags not loaded yet. Not loading surveys.");this._isSurveysEnabled=kt(t)?t:t.length>0,jc.info(`flags response received, isSurveysEnabled: ${this._isSurveysEnabled}`),this.loadIfEnabled()},this._notifyActiveMatchingSurveyCallbacks=e=>{this._activeMatchingSurveyCallbacks.slice().forEach(t=>this._notifyActiveMatchingSurveyCallback(t,e))}}setup(e){if(!this._disposed)return this._initializingClient=e,cd(e.kv.initialize(),()=>{if(this._initializingClient!==e||this._disposed)return;this._initializingClient=void 0,this._client=e;const t=e.onRemoteConfig(this.onRemoteConfig);this._disposed?t.dispose():(this._remoteConfigSubscription=t,this.loadIfEnabled())})}dispose(){var e,t,i,s,n;this._disposed||(this._disposed=!0,this._initializingClient=void 0,this._client=void 0,null===(e=this._remoteConfigSubscription)||void 0===e||e.dispose(),this._remoteConfigSubscription=void 0,null===(t=this._surveyEventReceiver)||void 0===t||t.dispose(),this._surveyEventReceiver=null,null===(i=this._surveyManager)||void 0===i||null===(s=i.dispose)||void 0===s||s.call(i),this._surveyManager=null,this._surveyCallbacks=[],this._activeMatchingSurveyCallbacks.forEach(e=>{e.active=!1}),this._activeMatchingSurveyCallbacks=[],null===(n=this._activeMatchingSurveyConditionsUnsubscribe)||void 0===n||n.call(this),this._activeMatchingSurveyConditionsUnsubscribe=void 0,this._getSurveysInFlightPromise=null,this._renderTimeouts.forEach(e=>clearTimeout(e)),this._renderTimeouts.clear())}get _config(){return this._configSource.get()}getRenderContext(){if(!this._client)return;const e=this;return{client:this._client,get config(){return e._config},surveys:e}}initialize(){this.loadIfEnabled()}reset(){var e,t;null===(e=this._surveyManager)||void 0===e||null===(t=e.clearInMemoryInProgressSurveyState)||void 0===t||t.call(e);try{var i;null===(i=this._surveyEventReceiver)||void 0===i||i.reset(),localStorage.removeItem("lastSeenSurveyDate");const e=[];for(let t=0;t<localStorage.length;t++){const i=localStorage.key(t);((null==i?void 0:i.startsWith("seenSurvey_"))||(null==i?void 0:i.startsWith("inProgressSurvey_")))&&e.push(i)}e.forEach(e=>localStorage.removeItem(e))}catch(e){}this._notifyActiveMatchingSurveyCallbacks()}loadIfEnabled(){if(this._disposed||!this._client)return;const e=this._config;if(this._surveyManager)return;if(this._isInitializingSurveys)return void jc.info("Already initializing surveys, skipping...");if(e.disableSurveys)return void jc.info(dd);if(e.cookielessMode&&this._client.isOptedOut)return void jc.info("Not loading surveys in cookieless mode without consent.");const t=this._configSource.getExtensions();if(!t)return void this._handleSurveyLoadError("PostHog Extensions not found.");if(vt(this._isSurveysEnabled)&&!e.advancedEnableSurveys)return;const i=this._isSurveysEnabled||e.advancedEnableSurveys;this._isInitializingSurveys=!0,this._surveyInitializationFailed=!1;try{const e=t.generateSurveys;if(e)return this._completeSurveyInitialization(e,i),void(this._isInitializingSurveys=!1);const s=t.loadExternalDependency;if(!s)return this._handleSurveyLoadError(S),void(this._isInitializingSurveys=!1);s(e=>{try{if(this._disposed)return;const t=this._configSource.getExtensions();e||!(null==t?void 0:t.generateSurveys)?this._handleSurveyLoadError("Could not load surveys script",e):this._completeSurveyInitialization(t.generateSurveys,i)}finally{this._isInitializingSurveys=!1}})}catch(e){throw this._isInitializingSurveys=!1,this._handleSurveyLoadError("Error initializing surveys",e),e}}_completeSurveyInitialization(e,t){var i;if(this._disposed)return;this._surveyManager=e(t),this._surveyEventReceiver=this._createEventReceiver(this._client,this._notifyActiveMatchingSurveyCallbacks);const s=null===(i=this._client)||void 0===i?void 0:i.kv.get(b);s&&this._registerEventOrActionBasedSurveys(s),jc.info("Surveys loaded successfully"),this._startActiveMatchingSurveyConditions(),this._notifyActiveMatchingSurveyCallbacks(),this._notifySurveyCallbacks({isLoaded:!0})}_createEventReceiver(e,t){return new ld(e,this,void 0,t)}_handleSurveyLoadError(e,t){this._surveyInitializationFailed=!0,jc.error(e,t),this._notifyActiveMatchingSurveyCallbacks({isLoaded:!1,error:e}),this._notifySurveyCallbacks({isLoaded:!1,error:e})}onSurveysLoaded(e){return this._surveyCallbacks.push(e),this._surveyManager&&this._notifySurveyCallbacks({isLoaded:!0}),()=>{this._surveyCallbacks=this._surveyCallbacks.filter(t=>t!==e)}}getSurveys(e,t=!1){if(this._disposed)return;const i=this._client;if(!i)return e([],{isLoaded:!1,error:ud});if(this._config.disableSurveys)return jc.info(dd),e([]);const s=i.kv.get(b);if(s&&!t)return e(s,{isLoaded:!0}),void(this._shouldBackgroundRefreshSurveys()&&this.getSurveys(()=>{},!0));if(this._getSurveysInFlightPromise)return void this._getSurveysInFlightPromise.then(({surveys:t,context:i})=>{this._disposed||e(t,i)}).catch(e=>jc.error("Error in survey callback",e));const n=i.sendRequest("/api/surveys/",{method:"GET",query:{token:i.projectToken},sentAt:"query",timeoutMs:this._config.requestTimeoutMs}).then(e=>{try{return this._handleSurveyResponse(i,e)}catch(e){return jc.error("Error processing surveys response",e),this._handleSurveyResponse(i,{statusCode:0,error:e})}},e=>this._handleSurveyResponse(i,{statusCode:0,error:e}));this._getSurveysInFlightPromise=n;const r=()=>{this._getSurveysInFlightPromise===n&&(this._getSurveysInFlightPromise=null)};n.then(t=>{r(),this._disposed||(this._notifyActiveMatchingSurveyCallbacks(t.context),e(t.surveys,t.context))},r).catch(e=>jc.error("Error in survey callback",e))}_handleSurveyResponse(e,t){if(this._disposed)return{surveys:[],context:{isLoaded:!1,error:ud}};const i=t.statusCode;if(200!==i||!t.json){const e=`Surveys API could not be loaded, status: ${i}`;return 0!==i?jc.error(e):t.error||jc.warn(e),this._lastSurveyRefreshFailedAt=Date.now(),{surveys:[],context:{isLoaded:!1,error:e}}}this._lastSurveyRefreshFailedAt=null;const s=t.json.surveys||[];return e.kv.set({[b]:s,[w]:Date.now()}),this._registerEventOrActionBasedSurveys(s),{surveys:s,context:{isLoaded:!0}}}_registerEventOrActionBasedSurveys(e){const t=e.filter(e=>function(e){return!(!e.start_date||e.end_date)}(e)&&($c(e)||function(e){var t;return!!(null===(t=e.conditions)||void 0===t||null===(t=t.actions)||void 0===t||null===(t=t.values)||void 0===t?void 0:t.length)}(e)));this._registerSurveyTriggers(t)}_registerSurveyTriggers(e){var t;null===(t=this._surveyEventReceiver)||void 0===t||t.replace(e)}_shouldBackgroundRefreshSurveys(){return this._isSurveyCacheStale()&&!this._getSurveysInFlightPromise&&!this._isSurveyRefreshBackingOff()}_isSurveyCacheStale(){var e;const t=null===(e=this._client)||void 0===e?void 0:e.kv.get(w);return St(t)&&Date.now()-t>3e5}_isSurveyRefreshBackingOff(){return St(this._lastSurveyRefreshFailedAt)&&3e5>Date.now()-this._lastSurveyRefreshFailedAt}markSurveyAsSeen(e,t){var i;const s={id:e,current_iteration:null!==(i=null==t?void 0:t.iteration)&&void 0!==i?i:null};Wc(s);try{localStorage.setItem("lastSeenSurveyDate",(new Date).toISOString())}catch(e){}this._notifyActiveMatchingSurveyCallbacks()}_notifySurveyCallbacks(e){for(const t of this._surveyCallbacks){if(this._disposed)return;try{e.isLoaded?this.getSurveys(t):t([],e)}catch(e){jc.error("Error in survey callback",e)}}}getActiveMatchingSurveys(e,t=!1){if(!wt(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);jc.warn("init was not called")}onActiveMatchingSurveysChanged(e){var t;if(this._disposed)return()=>{};const i={callback:e,active:!0,revision:0};this._activeMatchingSurveyCallbacks.push(i),this._startActiveMatchingSurveyConditions();const s=null===(t=this._client)||void 0===t?void 0:t.kv.get(b);return this._config.disableSurveys||!this._surveyManager&&this._surveyInitializationFailed&&!this._isInitializingSurveys||!s&&!wt(this._lastSurveyRefreshFailedAt)&&!this._getSurveysInFlightPromise?this._notifyActiveMatchingSurveyCallback(i,{isLoaded:!1}):this._surveyManager&&this._notifyActiveMatchingSurveyCallback(i),()=>{var e;i.active=!1,this._activeMatchingSurveyCallbacks=this._activeMatchingSurveyCallbacks.filter(e=>e!==i),0===this._activeMatchingSurveyCallbacks.length&&(null===(e=this._activeMatchingSurveyConditionsUnsubscribe)||void 0===e||e.call(this),this._activeMatchingSurveyConditionsUnsubscribe=void 0)}}_startActiveMatchingSurveyConditions(){var e,t,i;this._surveyManager&&this._activeMatchingSurveyCallbacks.length>0&&(null!==(e=this._activeMatchingSurveyConditionsUnsubscribe)&&void 0!==e||(this._activeMatchingSurveyConditionsUnsubscribe=null===(t=(i=this._configSource).onMatchingConditionsChanged)||void 0===t?void 0:t.call(i,this._notifyActiveMatchingSurveyCallbacks)))}_notifyActiveMatchingSurveyCallback(e,t){if(this._disposed||!e.active)return;const i=++e.revision,s=s=>{if(!this._disposed&&e.active&&i===e.revision)try{const i=null!=t?t:{isLoaded:!0},n=JSON.stringify([s,i]);if(n===e.lastResult)return;e.lastResult=n,e.callback(s,i)}catch(e){jc.error("Error in active matching surveys callback",e)}};try{t&&!t.isLoaded?s([]):this.getActiveMatchingSurveys(s)}catch(e){jc.error("Error in active matching surveys callback",e)}}_getSurveyById(e){let t=null;return this.getSurveys(i=>{var s;t=null!==(s=i.find(t=>t.id===e))&&void 0!==s?s:null}),t}_checkSurveyEligibility(e){if(wt(this._surveyManager))return{eligible:!1,reason:ud};const t="string"==typeof e?this._getSurveyById(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:"Survey not found"}}_checkSurveyRenderability(e){var t;if(!(null===(t=this._client)||void 0===t?void 0:t.canCapture))return{eligible:!1,reason:"PostHog is not capturing, so a survey response cannot be recorded"};if(wt(this._surveyManager))return{eligible:!1,reason:ud};const i="string"==typeof e?this._getSurveyById(e):e;return i?this._surveyManager.checkSurveyRenderability(i):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(e){if(wt(this._surveyManager))return jc.warn("init was not called"),{visible:!1,disabledReason:ud};const t=this._checkSurveyRenderability(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return wt(this._surveyManager)?(jc.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:ud})):new Promise(i=>{this.getSurveys(t=>{var s;const n=null!==(s=t.find(t=>t.id===e))&&void 0!==s?s:null;if(n){const e=this._checkSurveyRenderability(n);i({visible:e.eligible,disabledReason:e.reason})}else i({visible:!1,disabledReason:"Survey not found"})},t)})}renderSurvey(e,t,i){var s,n,r;if(!(null===(s=this._client)||void 0===s?void 0:s.canCapture))return;if(wt(this._surveyManager))return void jc.warn("init was not called");const o="string"==typeof e?this._getSurveyById(e):e;if(!(null==o?void 0:o.id))return void jc.warn("Survey not found");if(!Vc.includes(o.type))return void jc.warn(`Surveys of type ${o.type} cannot be rendered in the app`);const a=null===(n=typeof document>"u"?void 0:document)||void 0===n?void 0:n.querySelector(t);if(a){if(null===(r=o.appearance)||void 0===r?void 0:r.surveyPopupDelaySeconds){jc.info(`Rendering survey ${o.id} with delay of ${o.appearance.surveyPopupDelaySeconds} seconds`);const e=setTimeout(()=>{var t,s,n;this._renderTimeouts.delete(e),!this._disposed&&(null===(t=this._client)||void 0===t?void 0:t.canCapture)&&(jc.info(`Rendering survey ${o.id} with delay of ${null===(s=o.appearance)||void 0===s?void 0:s.surveyPopupDelaySeconds} seconds`),null===(n=this._surveyManager)||void 0===n||n.renderSurvey(o,a,i),jc.info(`Survey ${o.id} rendered`))},1e3*o.appearance.surveyPopupDelaySeconds);return void this._renderTimeouts.add(e)}this._surveyManager.renderSurvey(o,a,i)}else jc.warn("Survey element not found")}displaySurvey(e,t){var i,s;if(!(null===(i=this._client)||void 0===i?void 0:i.canCapture))return;if(wt(this._surveyManager))return void jc.warn("init was not called");const n=this._getSurveyById(e);if(!n)return void jc.warn("Survey not found");let r=n;if((null===(s=n.appearance)||void 0===s?void 0:s.surveyPopupDelaySeconds)&&t.ignoreDelay&&(r=as(as({},n),{},{appearance:as(as({},n.appearance),{},{surveyPopupDelaySeconds:0})})),t.displayType!==hl&&t.initialResponses&&jc.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),!1===t.ignoreConditions){const e=this._checkSurveyEligibility(n);if(!e.eligible)return void jc.warn("Survey is not eligible to be displayed: ",e.reason)}"inline"!==t.displayType?this._surveyManager.handlePopoverSurvey(r,t):this.renderSurvey(r,t.selector,t.properties)}cancelPendingSurvey(e){wt(this._surveyManager)?jc.warn("init was not called"):this._surveyManager.cancelSurvey(e)}handlePageUnload(){var e,t;null===(e=this._surveyManager)||void 0===e||null===(t=e.handlePageUnload)||void 0===t||t.call(e)}},_d=class{constructor(e){this._instance=e}get(){var e,t,i,s;const n=null===(e=this._instance)||void 0===e?void 0:e.config;return{disableSurveys:!!(null==n?void 0:n.disable_surveys),cookielessMode:!!(null==n?void 0:n.cookieless_mode),advancedEnableSurveys:!!(null==n?void 0:n.advanced_enable_surveys),requestTimeoutMs:null!==(t=null==n?void 0:n.surveys_request_timeout_ms)&&void 0!==t?t:1e4,prefillFromUrl:!!(null==n||null===(i=n.surveys)||void 0===i?void 0:i.prefillFromUrl),automaticDisplay:!(null==n?void 0:n.disable_surveys_automatic_display),featureFlagEvaluation:!(null==n?void 0:n.advanced_disable_feature_flags),overrideLanguage:null==n?void 0:n.override_display_language,prepareStylesheet:null==n?void 0:n.prepare_external_dependency_stylesheet,get_current_url:null==n?void 0:n.get_current_url,uiHost:null===(s=this._instance)||void 0===s||null===(s=s.requestRouter)||void 0===s?void 0:s.endpointFor("ui","")}}getExtensions(){const e=null==tt?void 0:tt.__PosthogExtensions__;if(!e||!this._instance)return;const t=this._instance,{generateSurveys:i,loadExternalDependency:s}=e;return{generateSurveys:i?e=>i(t,e):void 0,loadExternalDependency:s?e=>s(t,"surveys",e):void 0}}onMatchingConditionsChanged(e){var t,i;const s=null===(t=this._instance)||void 0===t?void 0:t._addCaptureHook(t=>{"$pageview"!==t&&t!==ll&&t!==cl&&t!==ul||e()}),n=()=>e();Br(je,"PHSurveyShown",n);let r=!1;const o=null===(i=this._instance)||void 0===i?void 0:i.onFeatureFlags(()=>{r&&e()});return r=!0,()=>{r=!1,null==s||s(),null==o||o(),null==je||je.removeEventListener("PHSurveyShown",n)}}};const pd=(()=>(null==je?void 0:je.location)?Ta(je.location.hash,"__posthog")||Ta(location.hash,"state"):null)(),gd="_postHogToolbarParams",fd=Fr("[Toolbar]"),vd=Fr("[FeatureFlags]"),md=Fr("[FeatureFlags]",{debugEnabled:!0}),yd="\" failed. Feature flags didn't load in time.",bd=[502,504],wd=["click","keydown","wheel","touchstart","pointerdown"],Sd="connection_error",Cd=e=>{const t={};for(let i=0;e.length>i;i++)t[e[i]]=!0;return t},kd=e=>{const t={};for(const[i,s]of $r(e||{}))s&&(t[i]=s);return t},Ed=(e,t)=>e.distinctId===t.distinctId&&e.sessionId===t.sessionId&&((e,t)=>{const i=Object.keys(e);return i.length===Object.keys(t).length&&i.every(i=>e[i]===t[i])})(e.groups,t.groups);var xd=class{constructor(e){this.name="featureFlags",this._override_warning=!1,this.featureFlagEventHandlers=[],this._logger=vd,this._baseEventProperties={},this._eventPropertiesWithFlagValues={},this._reloadingHandlers=[],this._pendingReloads=new Set,this._activeReloads=new Set,this._hasLoadedFlags=!1,this._requestInFlight=!1,this._requestGeneration=0,this._reloadingDisabled=!1,this._additionalReloadRequested=!1,this._firingFeatureFlagsCallbacks=!1,this._flagCallsPendingCapture=new Map,this._sendingFlagCallsPendingCapture=!1,this._flagsLoadedFromRemote=!1,this._staleCacheRefreshTriggered=!1,this._consecutiveStatusZeroFailures=0,this._hadUserInteraction=!1,this._onOnline=()=>{const e=this._hasStatusZeroCircuitBreakerTripped();this._consecutiveStatusZeroFailures=0,e&&this.reloadFeatureFlags()},this._refreshIfDue=()=>{var e,t;const i=this._refreshIntervalMs,s=null!==(e=this._dueRefreshIntervalMs)&&void 0!==e?e:i;vt(i)||vt(s)||this._config.remoteRequestsDisabled||!this._document||"hidden"===this._document.visibilityState||Date.now()-(null!==(t=this._lastRefreshAt)&&void 0!==t?t:0)<s||(this._dueRefreshIntervalMs=this._hadUserInteraction||!this._config.idleRefreshBackoff?i:Math.min(2*s,36e5),this._hadUserInteraction=!1,this.reloadFeatureFlags(),this._scheduleNextRefresh())},this._onUserInteraction=()=>{this._hadUserInteraction&&this._dueRefreshIntervalMs===this._refreshIntervalMs||this._resumeConfiguredInterval()},this._onVisibilityChange=()=>{var e;"visible"===(null===(e=this._document)||void 0===e?void 0:e.visibilityState)&&this._resumeConfiguredInterval()},this._configSource=e}get _crossTabPersistence(){}_onConfigUpdated(){this._client&&this._syncAutomaticRefresh()}setup(e){try{this._window=typeof window>"u"?void 0:window,this._document=typeof document>"u"?void 0:document}catch(e){this._window=void 0,this._document=void 0}return this._initializingClient=e,this._logger=e.logger.createLogger("[FeatureFlags]"),cd(e.kv.initialize(),()=>{this._initializingClient===e&&(this._initializingClient=void 0,this._client=e,this._finishSetup(e))})}_finishSetup(e){var t;if(this._client===e)return this._window&&Br(this._window,"online",this._onOnline),this._syncAutomaticRefresh(),this._dynamicProperties=e.registerDynamicEventProperties(()=>this._isCacheStale()?this._baseEventProperties:this._eventPropertiesWithFlagValues),this._crossTabPersistenceUnsubscribe=null===(t=this._crossTabPersistence)||void 0===t?void 0:t.onCrossTabFeatureFlagChange(()=>{this._clearBootstrapState(),this._rebuildEventProperties(),this._fireFeatureFlagsCallbacks()}),this._rebuildEventProperties(),this.initialize()}_resumeConfiguredInterval(){this._hadUserInteraction=!0,this._dueRefreshIntervalMs=this._refreshIntervalMs,this._refreshIfDue()}_syncAutomaticRefresh(){var e;const t=this._config.refreshIntervalMs,i=!this._config.remoteRequestsDisabled&&this._document&&!vt(t)&&t>0?t:void 0;this._config.idleRefreshBackoff||(this._dueRefreshIntervalMs=i),i!==this._refreshIntervalMs&&(this._stopAutomaticRefresh(),vt(i)||(this._refreshIntervalMs=i,this._dueRefreshIntervalMs=i,this._scheduleNextRefresh(),(null===(e=this._document)||void 0===e?void 0:e.addEventListener)&&(Br(this._document,m,this._onVisibilityChange),Tr(wd,e=>{Br(this._document,e,this._onUserInteraction,{capture:!0})}))))}_scheduleNextRefresh(){vt(this._refreshIntervalMs)||(vt(this._refreshInterval)||clearInterval(this._refreshInterval),this._lastRefreshAt=Date.now(),this._refreshInterval=setInterval(this._refreshIfDue,this._refreshIntervalMs))}_stopAutomaticRefresh(){var e,t;vt(this._refreshInterval)||(clearInterval(this._refreshInterval),this._refreshInterval=void 0,null===(e=this._document)||void 0===e||null===(t=e.removeEventListener)||void 0===t||t.call(e,"visibilitychange",this._onVisibilityChange),Tr(wd,e=>{var t,i;null===(t=this._document)||void 0===t||null===(i=t.removeEventListener)||void 0===i||i.call(t,e,this._onUserInteraction,{capture:!0})})),this._refreshIntervalMs=void 0,this._dueRefreshIntervalMs=void 0,this._hadUserInteraction=!1,this._lastRefreshAt=void 0}destroy(){this._dispose()}dispose(){this._dispose()}_dispose(){var e,t,i;this._stopAutomaticRefresh(),this._requestGeneration++,this._additionalReloadRequested=!1,this._initializingClient=void 0,this._settleReloads(this._pendingReloads,"cancelled"),this._settleReloads(this._activeReloads,"cancelled"),this._client&&(this._clearDebouncer(),null===(e=this._dynamicProperties)||void 0===e||e.dispose(),this._dynamicProperties=void 0,null===(t=this._crossTabPersistenceUnsubscribe)||void 0===t||t.call(this),this._crossTabPersistenceUnsubscribe=void 0,this._reloadingHandlers=[],null===(i=this._window)||void 0===i||i.removeEventListener("online",this._onOnline),this._client=void 0)}get _config(){return this._configSource.get()}_prop(e){var t;return this._bootstrapState&&e in this._bootstrapState?this._bootstrapState[e]:null===(t=this._client)||void 0===t?void 0:t.kv.get(e)}_clearBootstrapState(){return!!this._bootstrapState&&(this._bootstrapState=void 0,!0)}_fallBackToPersistedFlags(){var e;return!vt(null===(e=this._client)||void 0===e?void 0:e.kv.get("$enabled_feature_flags"))&&this._clearBootstrapState()}_set(e){this._persist(()=>{var t;return null===(t=this._client)||void 0===t?void 0:t.kv.set(e)})}_markCrossTabFeatureFlagSnapshot(e,t,i){if(!this._crossTabPersistence||!e.$enabled_feature_flags)return;const s=this._prop("$enabled_feature_flags")||{},o=e.$enabled_feature_flags||{},d=t.flags||t.featureFlags,h=t.flags?Object.entries(t.flags).filter(([,e])=>!(null==e?void 0:e.failed)).map(([e])=>e):[],_=!!t.errorsWhileComputingFlags&&!!t.flags,p=_?h:i&&!_t(d)?Object.keys(d||{}):Array.from(new Set([...Object.keys(s),...Object.keys(o)])),f=this._prop("$feature_flag_payloads")||{},v=e.$feature_flag_payloads||{},m=_||i?p:Array.from(new Set([...Object.keys(f),...Object.keys(v)])),y=!_&&!i,b=!!y||p,w=!!y||m,S={[n]:b,[u]:b,[g]:w};e.$feature_flag_details&&(S[r]=b);for(const t of[l,a,c])vt(e[t])||(S[t]=!0);this._crossTabPersistence.markCrossTabFeatureFlagChanges(S)}_remove(e){this._persist(()=>{var t;return null===(t=this._client)||void 0===t?void 0:t.kv.remove(e)})}_persist(e){try{e()}catch(e){this._logger.error("Failed to update feature flag persistence",e)}}_rebuildEventProperties(){const e={};for(const t of[n,g,l,f]){const i=this._prop(t);vt(i)||(e[t]=i)}this._baseEventProperties=e;const t=as({},e),i=this._prop(u);if(i)for(const[e,s]of Object.entries(i))t[`$feature/${e}`]=s;this._eventPropertiesWithFlagValues=t}_isCacheStale(){const e=this._config.cacheTtlMs;if(!e||0>=e)return!1;const t=this._prop(a);return"number"!=typeof t||Date.now()-t>e}_checkAndTriggerStaleRefresh(){return!!this._isCacheStale()&&(this._staleCacheRefreshTriggered||this._requestInFlight||(this._staleCacheRefreshTriggered=!0,this._logger.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}_getValidEvaluationEnvironments(){const e=this._config.evaluationContexts;return(null==e?void 0:e.length)?e.filter(e=>{const t=e&&"string"==typeof e&&e.trim().length>0;return t||this._logger.error("Invalid evaluation context found:",e,"Expected non-empty string"),t}):[]}_getValidFlagKeys(){const e=this._config.flagKeys;if(!vt(e))return e.filter(e=>{const t=e&&"string"==typeof e&&e.trim().length>0;return t||this._logger.error("Invalid flag key found:",e,"Expected non-empty string"),t})}initialize(){var e,t;const i=this._config,s=null!==(e=null===(t=i.bootstrap)||void 0===t?void 0:t.featureFlags)&&void 0!==e?e:{};if(Object.keys(s).length){var n,r;const e=null!==(n=null===(r=i.bootstrap)||void 0===r?void 0:r.featureFlagPayloads)&&void 0!==n?n:{},t=Object.keys(s).filter(e=>!vt(s[e])).reduce((e,t)=>(e[t]=s[t],e),{}),o=Object.keys(e).filter(e=>t[e]).reduce((t,i)=>(t[i]=e[i],t),{});return this._receivedFeatureFlags({featureFlags:t,featureFlagPayloads:o},void 0,{persist:!1})}}updateFlags(e,t,i){var s,n;const r=(null==i?void 0:i.merge)&&null!==(s=this._prop("$enabled_feature_flags"))&&void 0!==s?s:{},o=(null==i?void 0:i.merge)&&null!==(n=this._prop("$feature_flag_payloads"))&&void 0!==n?n:{},a=as(as({},r),e),l=as(as({},o),t),c={};for(const[e,t]of Object.entries(a))c[e]={key:e,enabled:en(t),variant:tn(t),reason:void 0,metadata:vt(null==l?void 0:l[e])?void 0:{id:0,version:void 0,description:void 0,payload:l[e]}};this._receivedFeatureFlags({flags:c})}get hasLoadedFlags(){return this._hasLoadedFlags}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){const e=this._prop(r),t=this._prop(f),i=this._prop(v);if(!i&&!t)return e||{};const s=Ar({},e||{}),n=[...new Set([...Object.keys(i||{}),...Object.keys(t||{})])];for(const e of n){var o,a;const n=s[e],r=null==t?void 0:t[e],l=vt(r)?null!==(o=null==n?void 0:n.enabled)&&void 0!==o&&o:!!r,c=vt(r)?null==n?void 0:n.variant:"string"==typeof r?r:void 0,u=null==i?void 0:i[e],d=as(as({},n),{},{enabled:l,variant:l?null!=c?c:null==n?void 0:n.variant:void 0});l!==(null==n?void 0:n.enabled)&&(d.original_enabled=null==n?void 0:n.enabled),c!==(null==n?void 0:n.variant)&&(d.original_variant=null==n?void 0:n.variant),u&&(d.metadata=as(as({},null==n?void 0:n.metadata),{},{payload:u,original_payload:null==n||null===(a=n.metadata)||void 0===a?void 0:a.payload})),s[e]=d}return this._override_warning||(this._logger.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:i,finalDetails:s}),this._override_warning=!0),s}getAllFeatureFlags(){const e=this.getFlagVariants(),t=this.getFlagPayloads();return Object.keys(e).map(i=>{const s=e[i];return{key:i,enabled:en(s),variant:tn(s),payload:Zs(t[i])}})}getFlagVariants(){const e=this._prop(u),t=this._prop(f);if(!t)return e||{};const i=Ar({},e||{}),s=Object.keys(t);for(let e=0;s.length>e;e++)i[s[e]]=t[s[e]];return this._override_warning||(this._logger.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:i}),this._override_warning=!0),i}getFlagPayloads(){const e=this._prop(g),t=this._prop(v);if(!t)return e||{};const i=Ar({},e||{}),s=Object.keys(t);for(let e=0;s.length>e;e++)i[s[e]]=t[s[e]];return this._override_warning||(this._logger.warn(" Overriding feature flag payloads!",{flagPayloads:e,overriddenPayloads:t,finalPayloads:i}),this._override_warning=!0),i}reloadFeatureFlags(){this._reloadingDisabled||this._config.featureFlagsDisabled||this._hasStatusZeroCircuitBreakerTripped()||(this._firingFeatureFlagsCallbacks&&this._logger.warn("reloadFeatureFlags() was called inside an onFeatureFlags callback. This callback also runs when flags change in other tabs, so this can cause a request loop."),this._requestInFlight&&(this._additionalReloadRequested=!0),this._reloadDebouncer||(this._reloadingHandlers.slice().forEach(e=>{try{e()}catch(e){this._logger.error("Error while running feature flags reloading callback",e)}}),this._reloadDebouncer=setTimeout(()=>{this._callFlagsEndpoint()},5)))}reloadFeatureFlagsAsync(){return!this._client||this._reloadingDisabled||this._config.featureFlagsDisabled||this._config.remoteRequestsDisabled||this._hasStatusZeroCircuitBreakerTripped()?Promise.resolve({status:"skipped"}):new Promise(e=>{this._pendingReloads.add(e),this.reloadFeatureFlags()})}_settleReloads(e,t){e.forEach(e=>e({status:t})),e.clear()}_clearDebouncer(){clearTimeout(this._reloadDebouncer),this._reloadDebouncer=void 0}onReloading(e){return this._reloadingHandlers.push(e),()=>{this._reloadingHandlers=this._reloadingHandlers.filter(t=>t!==e)}}ensureFlagsLoaded(){this._hasLoadedFlags||this._requestInFlight||this._reloadDebouncer||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this._reloadingDisabled=e}resetFlagCallReported(){this._remove(_),this._flagCallsPendingCapture=new Map}sendFlagCallsPendingCapture(){var e;if(0!==this._flagCallsPendingCapture.size&&!this._sendingFlagCallsPendingCapture&&(null===(e=this._client)||void 0===e?void 0:e.canCapture)&&!this._client.isRateLimited){this._sendingFlagCallsPendingCapture=!0;try{const e=this.getFlagVariants();for(const t of Array.from(this._flagCallsPendingCapture.keys())){const i=this._flagCallsPendingCapture.get(t);if(i){if(i.value!==String(e[t])||!Ed(i.context,this._flagCallContext())){this._flagCallsPendingCapture.delete(t);continue}if(this.getFeatureFlagResult(t),this._flagCallsPendingCapture.has(t))break}}}finally{this._sendingFlagCallsPendingCapture=!1}}}_callFlagsEndpoint(e){var t;this._clearDebouncer();const i=this._client;if(!i||this._config.remoteRequestsDisabled||this._hasStatusZeroCircuitBreakerTripped())return void this._settleReloads(this._pendingReloads,"skipped");if(this._requestInFlight)return void(this._additionalReloadRequested=!0);const s={token:i.projectToken,distinct_id:i.distinctId,groups:i.groups,$anon_distinct_id:this.$anon_distinct_id,person_properties:as(as(as({},i.initialPersonProperties),this._prop("$stored_person_properties")||{}),{},{$lib:i.library.name,$lib_version:i.library.version}),group_properties:this._prop(d),timezone:Sa()};vt(i.deviceId)||(s.$device_id=i.deviceId),((null==e?void 0:e.disableFlags)||this._config.featureFlagsDisabled)&&(s.disable_flags=!0);const n=this._getValidEvaluationEnvironments();n.length&&(s.evaluation_contexts=n);const r=this._getValidFlagKeys();vt(r)||(s.flag_keys=r);const a=this._config.onlyEvaluateSurveyFeatureFlags,l="/flags/?v=2"+(a?"&only_evaluate_survey_feature_flags=true":""),c=this._requestGeneration,u=this._pendingReloads;this._pendingReloads=new Set,this._activeReloads=u,this._requestInFlight=!0;const h=()=>{this._additionalReloadRequested&&(this._additionalReloadRequested=!1,this._callFlagsEndpoint())},_=e=>{var t,i;const n=null!==(t=e.json)&&void 0!==t?t:{},r=200!==e.statusCode;if(this._requestInFlight=!1,c!==this._requestGeneration)return void h();if(this._trackStatusZeroReachability(e.statusCode),r||this._additionalReloadRequested||(this.$anon_distinct_id=void 0),s.disable_flags&&!this._additionalReloadRequested)return void this._settleReloads(u,"skipped");this._flagsLoadedFromRemote=!r;const l=[];e.error?l.push(e.error instanceof Error&&"AbortError"===e.error.name?"timeout":e.error instanceof Error?Sd:"unknown_error"):200!==e.statusCode&&l.push(`api_error_${e.statusCode}`),n.errorsWhileComputingFlags&&l.push("errors_while_computing_flags");const d=!!(null===(i=n.quotaLimited)||void 0===i?void 0:i.includes("feature_flags"));d&&l.push("quota_limited"),this._set({[o]:l}),d?this._logger.warn("You have hit your feature flags quota limit, and will not be able to load feature flags until the quota is reset. Please visit https://posthog.com/docs/billing/limits-alerts to learn more."):s.disable_flags||this._receivedFeatureFlags(n,r,{partialResponse:a}),this._settleReloads(u,s.disable_flags?"skipped":l.length||!n.flags&&!n.featureFlags?"error":"loaded"),h()},p=e=>{this._requestInFlight=!1,c===this._requestGeneration?(this._set({[o]:[Sd]}),this._logger.error("Feature flag request failed",e),this._fallBackToPersistedFlags()&&this._fireFeatureFlagsCallbacks(!0),this._settleReloads(u,"error"),h()):h()};let g=null!==(t=this._config.requestMaxRetries)&&void 0!==t?t:1;const f=()=>g>0&&c===this._requestGeneration,v=()=>{if(c!==this._requestGeneration||!this._client||this._config.remoteRequestsDisabled)return this._requestInFlight=!1,this._settleReloads(u,"skipped"),void h();try{i.sendRequest(l,{target:"flags",method:"POST",body:s,compression:this._config.compression,sentAt:"body",timeoutMs:this._config.requestTimeoutMs}).then(e=>{if((e=>bd.includes(e.statusCode)||(e=>0===e.statusCode&&e.error instanceof Error&&"AbortError"===e.error.name)(e))(e)&&f())return g--,void setTimeout(v,500);_(e)}).catch(p)}catch(e){p(e)}};v()}_hasStatusZeroCircuitBreakerTripped(){return Ea(this._consecutiveStatusZeroFailures,3)}_trackStatusZeroReachability(e){this._consecutiveStatusZeroFailures=xa(e,this._consecutiveStatusZeroFailures,3,()=>this._logger.warn("Feature flag requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped refreshing feature flags; will try again when connectivity changes."))}getFeatureFlag(e,t={}){var i;if(t.fresh&&!this._flagsLoadedFromRemote)return;if(!(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0))return void this._logger.warn('getFeatureFlag for key "'+e+yd);if(this._checkAndTriggerStaleRefresh())return;const s=this.getFeatureFlagResult(e,t);return null!==(i=null==s?void 0:s.variant)&&void 0!==i?i:null==s?void 0:s.enabled}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){const t=this.getFeatureFlagResult(e,{send_event:!1});return null==t?void 0:t.payload}getFeatureFlagResult(e,t={}){if(t.fresh&&!this._flagsLoadedFromRemote)return;if(!(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0))return void this._logger.warn('getFeatureFlagResult for key "'+e+yd);if(this._checkAndTriggerStaleRefresh())return;const i=this.getFlagVariants(),s=e in i,n=i[e],r=this.getFlagPayloads()[e],o=String(n),a=this._prop("$feature_flag_request_id")||void 0,l=this._prop("$feature_flag_evaluated_at")||void 0;let c,u=this._prop("$flag_call_reported")||{};if(this._config.deduplicateCallsPerSession){var d;const e=null===(d=this._client)||void 0===d||null===(d=d.session)||void 0===d?void 0:d.sessionId,t=this._prop(p);e&&e!==t&&(u={},c=e)}if(!t.send_event&&"send_event"in t)c&&this._set({[_]:u,[p]:c});else{var h,g,f;const t=!(null===(h=this._client)||void 0===h?void 0:h.canCapture),i=!t&&!(null===(g=this._client)||void 0===g?void 0:g.isRateLimited);var v;if(i?this._flagCallsPendingCapture.delete(e):(t&&Object.keys(u).length>0&&(u={},this._set({[_]:u})),(null===(v=u[e])||void 0===v?void 0:v.includes(o))||this._holdFlagCall(e,o)),i&&!(null===(f=u[e])||void 0===f?void 0:f.includes(o))){var m,y,b,w,S,C,k,E,x,P,I,F,T;_t(u[e])?u[e].push(o):u[e]=[o],this._set(as({[_]:u},c?{[p]:c}:{}));const t=this.getFeatureFlagDetails(e),i=[...null!==(m=this._prop("$feature_flag_errors"))&&void 0!==m?m:[]];vt(n)&&i.push("flag_missing");const s={$feature_flag:e,$feature_flag_response:n,$feature_flag_payload:null!=r?r:null,$feature_flag_request_id:a,$feature_flag_evaluated_at:l,$feature_flag_bootstrapped_response:null!==(y=null===(b=this._config.bootstrap)||void 0===b||null===(b=b.featureFlags)||void 0===b?void 0:b[e])&&void 0!==y?y:null,$feature_flag_bootstrapped_payload:null!==(w=null===(S=this._config.bootstrap)||void 0===S||null===(S=S.featureFlagPayloads)||void 0===S?void 0:S[e])&&void 0!==w?w:null,$used_bootstrap_value:!this._flagsLoadedFromRemote};vt(null==t||null===(C=t.metadata)||void 0===C?void 0:C.has_experiment)||(s.$feature_flag_has_experiment=t.metadata.has_experiment),vt(null==t||null===(k=t.metadata)||void 0===k?void 0:k.version)||(s.$feature_flag_version=t.metadata.version);const d=null!==(E=null==t||null===(x=t.reason)||void 0===x?void 0:x.description)&&void 0!==E?E:null==t||null===(P=t.reason)||void 0===P?void 0:P.code;d&&(s.$feature_flag_reason=d),(null==t||null===(I=t.metadata)||void 0===I?void 0:I.id)&&(s.$feature_flag_id=t.metadata.id),vt(null==t?void 0:t.original_variant)&&vt(null==t?void 0:t.original_enabled)||(s.$feature_flag_original_response=vt(t.original_variant)?t.original_enabled:t.original_variant),(null==t||null===(F=t.metadata)||void 0===F?void 0:F.original_payload)&&(s.$feature_flag_original_payload=null==t||null===(T=t.metadata)||void 0===T?void 0:T.original_payload),i.length&&(s.$feature_flag_error=i.join(",")),this._captureFeatureFlagCalled(s)||(this._unmarkFlagCallReported(e,o),this._holdFlagCall(e,o))}else c&&this._set({[_]:u,[p]:c})}return s?{key:e,enabled:!!n,variant:"string"==typeof n?n:void 0,payload:Zs(r)}:void 0}_captureFeatureFlagCalled(e){try{var t;return!1!==(null===(t=this._client)||void 0===t?void 0:t.capture("$feature_flag_called",e))}catch(e){return this._logger.error("Failed to capture feature flag call",e),!0}}_holdFlagCall(e,t){this._flagCallsPendingCapture.set(e,{value:t,context:this._flagCallContext()})}_flagCallContext(){var e,t,i;return{distinctId:null===(e=this._client)||void 0===e?void 0:e.distinctId,groups:as({},null===(t=this._client)||void 0===t?void 0:t.groups),sessionId:this._config.deduplicateCallsPerSession?null===(i=this._client)||void 0===i||null===(i=i.session)||void 0===i?void 0:i.sessionId:void 0}}_unmarkFlagCallReported(e,t){const i=this._prop("$flag_call_reported")||{},s=i[e];_t(s)&&s.includes(t)&&(i[e]=s.filter(e=>e!==t),this._set({[_]:i}))}getRemoteConfigPayload(e,t){this._getRemoteConfigPayload(e,t)}_getRemoteConfigPayload(e,t){var i=this;return Ot(function*(){const s=i._client;if(!s)return;const n={distinct_id:s.distinctId,token:s.projectToken,person_properties:{$lib:s.library.name,$lib_version:s.library.version}},r=i._getValidEvaluationEnvironments();r.length&&(n.evaluation_contexts=r);const o=i._getValidFlagKeys();let a;vt(o)||(n.flag_keys=o);try{var l;const t=null===(l=(yield s.sendRequest("/flags/?v=2",{target:"flags",method:"POST",body:n,compression:i._config.compression,sentAt:"body",timeoutMs:i._config.requestTimeoutMs})).json)||void 0===l?void 0:l.featureFlagPayloads;a=(null==t?void 0:t[e])||void 0}catch(e){return void i._logger.error("Remote config feature flag request failed",e)}try{t(a)}catch(e){i._logger.error("Remote config feature flag callback failed",e)}})()}isFeatureEnabled(e,t={}){if(t.fresh&&!this._flagsLoadedFromRemote)return t.defaultValue;if(!(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0))return this._logger.warn('isFeatureEnabled for key "'+e+yd),t.defaultValue;const i=this.getFeatureFlag(e,t);return vt(i)?t.defaultValue:!!i}addFeatureFlagsHandler(e){this.featureFlagEventHandlers.push(e)}removeFeatureFlagsHandler(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter(t=>t!==e)}receivedFeatureFlags(e,t,i){this._receivedFeatureFlags(e,t,i)}_receivedFeatureFlags(e,t,i){if(!this._client)return;this._hasLoadedFlags=!0;const s=((e,t={},i={},s={},o,d=vd)=>{const h=((e,t)=>{const i=e.flags;if(i){const t=Object.fromEntries(Object.keys(i).map(e=>{var t;return[e,null!==(t=i[e].variant)&&void 0!==t?t:i[e].enabled]})),s=Object.fromEntries(Object.keys(i).filter(e=>i[e].enabled).filter(e=>{var t;return!vt(null===(t=i[e].metadata)||void 0===t?void 0:t.payload)}).map(e=>{var t;return[e,null===(t=i[e].metadata)||void 0===t?void 0:t.payload]}));return as(as({},e),{},{featureFlags:t,featureFlagPayloads:s})}return e.featureFlags&&t.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),e})(e,d),_=h.flags,p=h.featureFlags,f=h.featureFlagPayloads;if(!p)return;const v=e.requestId,m=e.evaluatedAt;if(_t(p)){d.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");const e={};if(p)for(let t=0;p.length>t;t++)e[p[t]]=!0;return{[n]:p,[u]:e,[c]:!1}}let y=p,b=f,w=_;if(null==o?void 0:o.partialResponse){const e=Object.keys(y),n=b||{};y=as(as({},t),y),b=as(as({},i),n),e.forEach(e=>{e in n||null==b||delete b[e]}),w=as(as({},s),w)}else if(e.errorsWhileComputingFlags)if(_){const e=new Set(Object.keys(_).filter(e=>{var t;return!(null===(t=_[e])||void 0===t?void 0:t.failed)}));y=as(as({},t),Object.fromEntries(Object.entries(y).filter(([t])=>e.has(t))));const n=Object.fromEntries(Object.entries(b||{}).filter(([t])=>e.has(t)));b=as(as({},i),n),e.forEach(e=>{e in n||null==b||delete b[e]}),w=as(as({},s),Object.fromEntries(Object.entries(w||{}).filter(([t])=>e.has(t))))}else y=as(as({},t),y),b=as(as({},i),b),w=as(as({},s),w);return as(as({[n]:Object.keys(kd(y)),[u]:y||{},[g]:b||{},[r]:w||{},[c]:!0===e.minimalFlagCalledEvents},v?{[l]:v}:{}),m?{[a]:m}:{})})(e,this.getFlagVariants(),this.getFlagPayloads(),this.getFlagsWithDetails(),i,this._logger);if(s)if(!1===(null==i?void 0:i.persist)){const e=!vt(this._client.kv.get(u));this._bootstrapState=s,e||this._set(s)}else this._clearBootstrapState(),this._markCrossTabFeatureFlagSnapshot(s,e,!!(null==i?void 0:i.partialResponse)),this._set(s);else t&&this._fallBackToPersistedFlags();t||(this._staleCacheRefreshTriggered=!1),this._fireFeatureFlagsCallbacks(t)}override(e,t=!1){this._logger.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){this._overrideFeatureFlags(e)}_overrideFeatureFlags(e){if(this._client){if(!1===e)return this._remove([f,v]),this._fireFeatureFlagsCallbacks(),void md.info("All overrides cleared");if(_t(e))return this._set({[f]:Cd(e)}),this._fireFeatureFlagsCallbacks(),void md.info("Flag overrides set",{flags:e});if(e&&"object"==typeof e&&("flags"in e||"payloads"in e)){var t;const i=e;this._override_warning=Boolean(null!==(t=i.suppressWarning)&&void 0!==t&&t);const s={},n=i.flags,r=i.payloads;return n&&(s[f]=_t(n)?Cd(n):n),r&&(s[v]=r),Object.keys(s).length&&this._set(s),!1===n&&!1===r?this._remove([f,v]):!1===n?this._remove(f):!1===r&&this._remove(v),this._fireFeatureFlagsCallbacks(),!1===n?md.info("Flag overrides cleared"):n&&md.info("Flag overrides set",{flags:n}),void(!1===r?md.info("Payload overrides cleared"):r&&md.info("Payload overrides set",{payloads:r}))}if(e&&"object"==typeof e)return this._set({[f]:e}),this._fireFeatureFlagsCallbacks(),void md.info("Flag overrides set",{flags:e});this._logger.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:e})}else this._logger.warn("posthog.featureFlags.overrideFeatureFlags called before feature flags were ready")}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this._hasLoadedFlags){const{flags:t,flagVariants:i}=this._prepareFeatureFlagsForCallbacks();try{e(t,i)}catch(e){this._logger.error("Error while running feature flags callback",e)}}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t,i){var s;const r=(this._prop("$early_access_features")||[]).find(t=>t.flagKey===e),o={[`$feature_enrollment/${e}`]:t},a={$feature_flag:e,$feature_enrollment:t,$set:o};r&&(a.$early_access_feature_name=r.name),i&&(a.$feature_enrollment_stage=i);const l=as(as({},this.getFlagVariants()),{},{[e]:t});null===(s=this._crossTabPersistence)||void 0===s||s.markCrossTabFeatureFlagChanges({$active_feature_flags:[e],$enabled_feature_flags:[e],$stored_person_properties:Object.keys(o)}),this._set({[n]:Object.keys(kd(l)),[u]:l,[h]:as(as({},this._prop("$stored_person_properties")||{}),o)}),this._fireFeatureFlagsCallbacks();try{var c;null===(c=this._client)||void 0===c||c.capture("$feature_enrollment_update",a)}catch(e){this._logger.error("Failed to capture early access feature enrollment",e)}}getEarlyAccessFeatures(e,t=!1,i){const n=this._prop(s);!n||t?this._getEarlyAccessFeatures(e,i):e(n)}_getEarlyAccessFeatures(e,t){var i=this;return Ot(function*(){const n=i._client;if(!n)return;const r=t?`&${t.map(e=>`stage=${e}`).join("&")}`:"";let o;try{const e=yield n.sendRequest(`/api/early_access_features/?token=${n.projectToken}${r}`,{target:"api",method:"GET",sentAt:"query"});if(!e.json)return;o=e.json.earlyAccessFeatures,i._set({[s]:o})}catch(e){return void i._logger.error("Early access feature request failed",e)}try{e(o)}catch(e){i._logger.error("Early access feature callback failed",e)}})()}_prepareFeatureFlagsForCallbacks(){const e=this.getFlags(),t=this.getFlagVariants();return{flags:e.filter(e=>t[e]),flagVariants:Object.keys(t).filter(e=>t[e]).reduce((e,i)=>(e[i]=t[i],e),{})}}_fireFeatureFlagsCallbacks(e){this._rebuildEventProperties();const{flags:t,flagVariants:i}=this._prepareFeatureFlagsForCallbacks(),s=this._firingFeatureFlagsCallbacks;this._firingFeatureFlagsCallbacks=!0,this.featureFlagEventHandlers.forEach(s=>{try{s(t,i,{errorsLoading:e})}catch(e){this._logger.error("Error while running feature flags callback",e)}}),this._firingFeatureFlagsCallbacks=s}setPersonPropertiesForFlags(e,t=!0){this._setPersonPropertiesForFlags(e,t)}_setPersonPropertiesForFlags(e,t=!0){const i=this._prop("$stored_person_properties")||{},s=(null==e?void 0:e.$set)||((null==e?void 0:e.$set_once)?{}:e),n=null==e?void 0:e.$set_once,r={};if(n)for(const e in n)({}).hasOwnProperty.call(n,e)&&(e in i||(r[e]=n[e]));this._set({[h]:as(as(as({},i),r),s)}),t&&this.reloadFeatureFlags()}unsetPersonPropertiesForFlags(e,t=!0){const i=as({},this._prop("$stored_person_properties")||{});e.forEach(e=>{delete i[e]}),this._set({[h]:i}),t&&this.reloadFeatureFlags()}resetPersonPropertiesForFlags(e=!0){this._remove(h),e&&this.reloadFeatureFlags()}setGroupPropertiesForFlags(e,t=!0){const i=this._prop("$stored_group_properties")||{},s=as({},i);for(const t of Object.keys(e))s[t]=as(as({},i[t]),e[t]);this._set({[d]:s}),t&&this.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){const t=this._prop("$stored_group_properties")||{};this._set({[d]:as(as({},t),{},{[e]:{}})})}else this._remove(d)}reset(){this._requestGeneration++,this._settleReloads(this._pendingReloads,"cancelled"),this._settleReloads(this._activeReloads,"cancelled"),this._additionalReloadRequested=!1,this._baseEventProperties={},this._eventPropertiesWithFlagValues={},this._bootstrapState=void 0,this._hasLoadedFlags=!1,this._reloadingDisabled=!1,this._flagsLoadedFromRemote=!1,this.$anon_distinct_id=void 0,this._clearDebouncer(),this._override_warning=!1,this._consecutiveStatusZeroFailures=0,this._flagCallsPendingCapture=new Map}};const Pd=Fr("[FeatureFlags]");var Id=class{constructor(e,t=!1){this._loggedEvaluationEnvironmentsDeprecation=!1,this.update(e,t)}update(e,t){this._snapshot=((e,t)=>{var i,s,n,r,o,a,l,c;return{bootstrap:{featureFlags:null!==(i=null===(s=e.bootstrap)||void 0===s?void 0:s.featureFlags)&&void 0!==i?i:void 0,featureFlagPayloads:null!==(n=null===(r=e.bootstrap)||void 0===r?void 0:r.featureFlagPayloads)&&void 0!==n?n:void 0},remoteRequestsDisabled:t,featureFlagsDisabled:!!e.advanced_disable_feature_flags,onlyEvaluateSurveyFeatureFlags:!!e.advanced_only_evaluate_survey_feature_flags,deduplicateCallsPerSession:!!e.advanced_feature_flags_dedup_per_session,cacheTtlMs:e.feature_flag_cache_ttl_ms,refreshIntervalMs:null!==(o=e.remote_config_refresh_interval_ms)&&void 0!==o?o:3e5,idleRefreshBackoff:vt(e.remote_config_refresh_interval_ms),requestTimeoutMs:e.feature_flag_request_timeout_ms,requestMaxRetries:Math.max(0,null!==(a=e.feature_flag_request_max_retries)&&void 0!==a?a:1),compression:e.disable_compression?void 0:"best-available",evaluationContexts:null!==(l=null!==(c=e.evaluation_contexts)&&void 0!==c?c:e.evaluation_environments)&&void 0!==l?l:[],flagKeys:_t(e.flag_keys)?e.flag_keys:void 0}})(e,t),!e.evaluation_environments||e.evaluation_contexts||this._loggedEvaluationEnvironmentsDeprecation||(Pd.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this._loggedEvaluationEnvironmentsDeprecation=!0),vt(e.flag_keys)||_t(e.flag_keys)||Pd.error("Invalid flag_keys found:",e.flag_keys,"Expected array of non-empty strings")}get(){return this._snapshot}},Fd=class extends xd{constructor(e){const t=new Id(e.config,e._shouldDisableFlags());super(t),this.name=lu,this._instance=e,this._mutableConfigSource=t}get _crossTabPersistence(){return this._instance.persistence}updateConfig(e,t){this._mutableConfigSource.update(e,t),this._onConfigUpdated()}};const Td=e=>Ft(e)&&("RangeError"===e.name&&0===e.message.indexOf("Maximum call stack size exceeded")||"InternalError"===e.name&&"too much recursion"===e.message),Rd=Fr("[Error tracking]"),Ad="webkit-masked-url:",$d=[{value:"isolatedAPI.contexts.topHostname",exact:!1},{value:"No response from target",exact:!0}],Md=["chrome-extension://","moz-extension://","safari-extension:","safari-web-extension:",Ad],Ld=["__firefox__","__gCrWeb"];function Od(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,s=Array(t);t>i;i++)s[i]=e[i];return s}function Dd(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var s,n,r,o,a=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t);else for(;!(l=(s=r.call(i)).done)&&(a.push(s.value),a.length!==t);l=!0);}catch(e){c=!0,n=e}finally{try{if(!l&&null!=i.return&&(o=i.return(),Object(o)!==o))return}finally{if(c)throw n}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return Od(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?Od(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}const Nd=Object.entries,Bd=Object.setPrototypeOf,zd=Object.isFrozen,Hd=Object.getPrototypeOf,Ud=Object.getOwnPropertyDescriptor;let qd=Object.freeze,jd=Object.seal,Wd=Object.create,Vd="undefined"!=typeof Reflect&&Reflect,Gd=Vd.apply,Kd=Vd.construct;qd||(qd=function(e){return e}),jd||(jd=function(e){return e}),Gd||(Gd=function(e,t){for(var i=arguments.length,s=new Array(i>2?i-2:0),n=2;i>n;n++)s[n-2]=arguments[n];return e.apply(t,s)}),Kd||(Kd=function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),s=1;t>s;s++)i[s-1]=arguments[s];return new e(...i)});const Qd=fh([].forEach),Jd=fh([].lastIndexOf),Yd=fh([].pop),Xd=fh([].push),Zd=fh([].splice),eh=Array.isArray,th=fh("".toLowerCase),ih=fh("".toString),sh=fh("".match),nh=fh("".replace),rh=fh("".indexOf),oh=fh("".trim),ah=fh((0).toString),lh=fh(Boolean.prototype.toString),ch="undefined"==typeof BigInt?null:fh(BigInt.prototype.toString),uh="undefined"==typeof Symbol?null:fh(Symbol.prototype.toString),dh=fh({}.hasOwnProperty),hh=fh({}.toString),_h=fh(/t/.test),ph=(gh=TypeError,function(){for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];return Kd(gh,t)});var gh;function fh(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var i=arguments.length,s=new Array(i>1?i-1:0),n=1;i>n;n++)s[n-1]=arguments[n];return Gd(e,t,s)}}function vh(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:th;if(Bd&&Bd(e,null),!eh(t))return e;let s=t.length;for(;s--;){let n=t[s];if("string"==typeof n){const e=i(n);e!==n&&(zd(t)||(t[s]=e),n=e)}e[n]=!0}return e}function mh(e){for(let t=0;e.length>t;t++)dh(e,t)||(e[t]=null);return e}function yh(e){const t=Wd(null);for(const s of Nd(e)){var i=Dd(s,2);const n=i[0],r=i[1];dh(e,n)&&(t[n]=eh(r)?mh(r):r&&"object"==typeof r&&r.constructor===Object?yh(r):r)}return t}function bh(e,t){for(;null!==e;){const i=Ud(e,t);if(i){if(i.get)return fh(i.get);if("function"==typeof i.value)return fh(i.value)}e=Hd(e)}return function(){return null}}const wh=qd(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Sh=qd(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Ch=qd(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),kh=qd(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Eh=qd(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),xh=qd(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Ph=qd(["#text"]),Ih=qd(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),Fh=qd(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dominant-baseline","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-orientation","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Th=qd(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Rh=qd(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Ah=jd(/{{[\w\W]*|^[\w\W]*}}/g),$h=jd(/<%[\w\W]*|^[\w\W]*%>/g),Mh=jd(/\${[\w\W]*/g),Lh=jd(/^data-[\-\w.\u00B7-\uFFFF]+$/),Oh=jd(/^aria-[\-\w]+$/),Dh=jd(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Nh=jd(/^(?:\w+script|data):/i),Bh=jd(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),zh=jd(/^html$/i),Hh=jd(/^[a-z][.\w]*(-[.\w]+)+$/i),Uh=jd(/<[/\w!]/g),qh=jd(/<[/\w]/g),jh=jd(/<\/no(script|embed|frames)/i),Wh=jd(/\/>/i),Vh=function(){return"undefined"==typeof window?null:window},Gh=function(e,t,i,s){return dh(e,t)&&eh(e[t])?vh(s.base?yh(s.base):{},e[t],s.transform):i};var Kh=function e(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Vh();const i=t=>e(t);if(i.version="3.4.13",i.removed=[],!t||!t.document||9!==t.document.nodeType||!t.Element)return i.isSupported=!1,i;let s=t.document;const n=s,r=n.currentScript,o=t.HTMLTemplateElement,a=t.Node,l=t.NodeFilter,c=t.DOMParser,u=t.trustedTypes,d=t.Element.prototype,h=bh(d,"cloneNode"),_=bh(d,"remove"),p=bh(d,"nextSibling"),g=bh(d,"childNodes"),f=bh(d,"parentNode"),v=bh(d,"shadowRoot"),m=bh(d,"attributes"),y=a&&a.prototype?bh(a.prototype,"nodeType"):null,b=a&&a.prototype?bh(a.prototype,"nodeName"):null,w=a&&a.prototype?bh(a.prototype,"ownerDocument"):null;if("function"==typeof o){const e=s.createElement("template");e.content&&e.content.ownerDocument&&(s=e.content.ownerDocument)}let S,C,k="",E=!1,x=0;const P=function(){if(x>0)throw ph('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},I=function(e){P(),x++;try{return S.createHTML(e)}finally{x--}},F=s.implementation,T=s.createNodeIterator,R=s.createDocumentFragment,A=s.getElementsByTagName,M=n.importNode;let L={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]};i.isSupported="function"==typeof Nd&&"function"==typeof f&&F&&void 0!==F.createHTMLDocument;const O=Ah,D=$h,N=Mh,B=Lh,z=Oh,H=Nh,U=Bh,q=Hh;let j=Dh,W=null;const V=vh({},[...wh,...Sh,...Ch,...Eh,...Ph]);let G=null;const K=vh({},[...Ih,...Fh,...Th,...Rh]);let Q=Object.seal(Wd(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),J=null,Y=null;const X=Object.seal(Wd(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Z=!0,ee=!0,te=!1,ie=!0,se=!1,ne=!0,re=!1,oe=!1,ae=null,le=null,ce=!1,ue=!1,de=!1,he=!1,_e=!0,pe=!1;const ge="user-content-";let fe=!0,ve=!1,me={},ye=null;const be=vh({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let we=null;const Se=vh({},["audio","video","img","source","image","track"]);let Ce=null;const ke=vh({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Ee="http://www.w3.org/1998/Math/MathML",xe="http://www.w3.org/2000/svg",Pe="http://www.w3.org/1999/xhtml";let Ie=Pe,Fe=!1,Te=null;const Re=vh({},[Ee,xe,Pe],ih),Ae=qd(["mi","mo","mn","ms","mtext"]);let $e=vh({},Ae);const Me=qd(["annotation-xml"]);let Le=vh({},Me);const Oe=vh({},["title","style","font","a","script"]);let De=null;const Ne=["application/xhtml+xml","text/html"];let Be=null,ze=null;const He=s.createElement("form"),Ue=function(e){return e instanceof RegExp||e instanceof Function},qe=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(ze&&ze===e)return;e&&"object"==typeof e||(e={}),e=yh(e),De=-1===Ne.indexOf(e.PARSER_MEDIA_TYPE)?"text/html":e.PARSER_MEDIA_TYPE,Be="application/xhtml+xml"===De?ih:th,W=Gh(e,"ALLOWED_TAGS",V,{transform:Be}),G=Gh(e,"ALLOWED_ATTR",K,{transform:Be}),Te=Gh(e,"ALLOWED_NAMESPACES",Re,{transform:ih}),Ce=Gh(e,"ADD_URI_SAFE_ATTR",ke,{transform:Be,base:ke}),we=Gh(e,"ADD_DATA_URI_TAGS",Se,{transform:Be,base:Se}),ye=Gh(e,"FORBID_CONTENTS",be,{transform:Be}),J=Gh(e,"FORBID_TAGS",yh({}),{transform:Be}),Y=Gh(e,"FORBID_ATTR",yh({}),{transform:Be}),me=!!dh(e,"USE_PROFILES")&&(e.USE_PROFILES&&"object"==typeof e.USE_PROFILES?yh(e.USE_PROFILES):e.USE_PROFILES),Z=!1!==e.ALLOW_ARIA_ATTR,ee=!1!==e.ALLOW_DATA_ATTR,te=e.ALLOW_UNKNOWN_PROTOCOLS||!1,ie=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,se=e.SAFE_FOR_TEMPLATES||!1,ne=!1!==e.SAFE_FOR_XML,re=e.WHOLE_DOCUMENT||!1,ue=e.RETURN_DOM||!1,de=e.RETURN_DOM_FRAGMENT||!1,he=e.RETURN_TRUSTED_TYPE||!1,ce=e.FORCE_BODY||!1,_e=!1!==e.SANITIZE_DOM,pe=e.SANITIZE_NAMED_PROPS||!1,fe=!1!==e.KEEP_CONTENT,ve=e.IN_PLACE||!1,j=function(e){try{return _h(e,""),!0}catch(e){return!1}}(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:Dh,Ie="string"==typeof e.NAMESPACE?e.NAMESPACE:Pe,$e=dh(e,"MATHML_TEXT_INTEGRATION_POINTS")&&e.MATHML_TEXT_INTEGRATION_POINTS&&"object"==typeof e.MATHML_TEXT_INTEGRATION_POINTS?yh(e.MATHML_TEXT_INTEGRATION_POINTS):vh({},Ae),Le=dh(e,"HTML_INTEGRATION_POINTS")&&e.HTML_INTEGRATION_POINTS&&"object"==typeof e.HTML_INTEGRATION_POINTS?yh(e.HTML_INTEGRATION_POINTS):vh({},Me);const t=dh(e,"CUSTOM_ELEMENT_HANDLING")&&e.CUSTOM_ELEMENT_HANDLING&&"object"==typeof e.CUSTOM_ELEMENT_HANDLING?yh(e.CUSTOM_ELEMENT_HANDLING):Wd(null);if(Q=Wd(null),dh(t,"tagNameCheck")&&Ue(t.tagNameCheck)&&(Q.tagNameCheck=t.tagNameCheck),dh(t,"attributeNameCheck")&&Ue(t.attributeNameCheck)&&(Q.attributeNameCheck=t.attributeNameCheck),dh(t,"allowCustomizedBuiltInElements")&&"boolean"==typeof t.allowCustomizedBuiltInElements&&(Q.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),jd(Q),se&&(ee=!1),de&&(ue=!0),me&&(W=vh({},Ph),G=Wd(null),!0===me.html&&(vh(W,wh),vh(G,Ih)),!0===me.svg&&(vh(W,Sh),vh(G,Fh),vh(G,Rh)),!0===me.svgFilters&&(vh(W,Ch),vh(G,Fh),vh(G,Rh)),!0===me.mathMl&&(vh(W,Eh),vh(G,Th),vh(G,Rh))),X.tagCheck=null,X.attributeCheck=null,dh(e,"ADD_TAGS")&&("function"==typeof e.ADD_TAGS?X.tagCheck=e.ADD_TAGS:eh(e.ADD_TAGS)&&(W===V&&(W=yh(W)),vh(W,e.ADD_TAGS,Be))),dh(e,"ADD_ATTR")&&("function"==typeof e.ADD_ATTR?X.attributeCheck=e.ADD_ATTR:eh(e.ADD_ATTR)&&(G===K&&(G=yh(G)),vh(G,e.ADD_ATTR,Be))),dh(e,"ADD_URI_SAFE_ATTR")&&eh(e.ADD_URI_SAFE_ATTR)&&vh(Ce,e.ADD_URI_SAFE_ATTR,Be),dh(e,"FORBID_CONTENTS")&&eh(e.FORBID_CONTENTS)&&(ye===be&&(ye=yh(ye)),vh(ye,e.FORBID_CONTENTS,Be)),dh(e,"ADD_FORBID_CONTENTS")&&eh(e.ADD_FORBID_CONTENTS)&&(ye===be&&(ye=yh(ye)),vh(ye,e.ADD_FORBID_CONTENTS,Be)),fe&&(W["#text"]=!0),re&&vh(W,["html","head","body"]),W.table&&(vh(W,["tbody"]),delete J.tbody),e.TRUSTED_TYPES_POLICY){if("function"!=typeof e.TRUSTED_TYPES_POLICY.createHTML)throw ph('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof e.TRUSTED_TYPES_POLICY.createScriptURL)throw ph('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const t=S;S=e.TRUSTED_TYPES_POLICY;try{k=I("")}catch(e){throw S=t,e}}else null===e.TRUSTED_TYPES_POLICY?(S=void 0,k=""):(void 0===S&&(E||(C=function(e,t){if("object"!=typeof e||"function"!=typeof e.createPolicy)return null;let i=null;const s="data-tt-policy-suffix";t&&t.hasAttribute(s)&&(i=t.getAttribute(s));const n="dompurify"+(i?"#"+i:"");try{return e.createPolicy(n,{createHTML:e=>e,createScriptURL:e=>e})}catch(e){return console.warn("TrustedTypes policy "+n+" could not be created."),null}}(u,r),E=!0),S=C),S&&"string"==typeof k&&(k=I("")));qd&&qd(e),ze=e},je=vh({},[...Sh,...Ch,...kh]),We=vh({},[...Eh,...xh]),Ve=function(e){Xd(i.removed,{element:e});try{f(e).removeChild(e)}catch(t){if(_(e),!f(e))throw ph("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Ge=function(e){Je(e);const t=g(e);if(t){const e=[];Qd(t,t=>{Xd(e,t)}),Qd(e,e=>{try{_(e)}catch(e){}})}const i=m(e);if(i)for(let t=i.length-1;t>=0;--t){const s=i[t],n=s&&s.name;if("string"==typeof n)try{e.removeAttribute(n)}catch(e){}}},Ke=function(e,t){try{Xd(i.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){Xd(i.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e)if(ue||de)try{Ve(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},Qe=function(e){const t=m(e);if(t)for(let i=t.length-1;i>=0;--i){const s=t[i],n=s&&s.name;if("string"==typeof n&&!G[Be(n)])try{e.removeAttribute(n)}catch(e){}}},Je=function(e){const t=[e];for(;t.length>0;){const e=t.pop();1===(y?y(e):e.nodeType)&&Qe(e);const i=g(e);if(i)for(let e=i.length-1;e>=0;--e)t.push(i[e])}},Ye=function(e){let t=null,i=null;if(ce)e="<remove></remove>"+e;else{const t=sh(e,/^[\r\n\t ]+/);i=t&&t[0]}"application/xhtml+xml"===De&&Ie===Pe&&(e='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+e+"</body></html>");const n=S?I(e):e;if(Ie===Pe)try{t=(new c).parseFromString(n,De)}catch(e){}if(!t||!t.documentElement){t=F.createDocument(Ie,"template",null);try{t.documentElement.innerHTML=Fe?k:n}catch(e){}}const r=t.body||t.documentElement;return e&&i&&r.insertBefore(s.createTextNode(i),r.childNodes[0]||null),Ie===Pe?A.call(t,re?"html":"body")[0]:re?t.documentElement:r},Xe=function(e){const t=w?w(e):e.ownerDocument;return T.call(t||e,e,l.SHOW_ELEMENT|l.SHOW_COMMENT|l.SHOW_TEXT|l.SHOW_PROCESSING_INSTRUCTION|l.SHOW_CDATA_SECTION,null)},Ze=function(e){return e=nh(e,O," "),e=nh(e,D," "),nh(e,N," ")},et=function(e){var t;e.normalize();const i=w?w(e):e.ownerDocument,s=T.call(i||e,e,l.SHOW_TEXT|l.SHOW_COMMENT|l.SHOW_CDATA_SECTION|l.SHOW_PROCESSING_INSTRUCTION,null);let n=s.nextNode();for(;n;)n.data=Ze(n.data),n=s.nextNode();const r=null===(t=e.querySelectorAll)||void 0===t?void 0:t.call(e,"template");r&&Qd(r,e=>{it(e.content)&&et(e.content)})},tt=function(e){const t=b?b(e):null;return"string"==typeof t&&"form"===Be(t)&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||e.attributes!==m(e)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore||"function"!=typeof e.hasChildNodes||e.nodeType!==y(e)||e.childNodes!==g(e))},it=function(e){if(!y||"object"!=typeof e||null===e)return!1;try{return 11===y(e)}catch(e){return!1}},st=function(e){if(!y||"object"!=typeof e||null===e)return!1;try{return"number"==typeof y(e)}catch(e){return!1}};function nt(e,t,s){0!==e.length&&Qd(e,e=>{e.call(i,t,s,ze)})}const rt=function(e,t,i,s){return 0===e.length?t:t===i||t===s?yh(t):t},ot=function(e,t){if(nt(L.beforeSanitizeElements,e,null),e!==t&&null===f(e))return ve&&Je(e),!0;if(tt(e))return Ve(e),!0;const s=Be(b?b(e):e.nodeName);if(W=rt(L.uponSanitizeElement,W,V,ae),nt(L.uponSanitizeElement,e,{tagName:s,allowedTags:W}),e!==t&&null===f(e))return ve&&Je(e),!0;if(function(e,t){return!!(ne&&e.hasChildNodes()&&!st(e.firstElementChild)&&_h(Uh,e.textContent)&&_h(Uh,e.innerHTML))||!(!ne||e.namespaceURI!==Pe||"style"!==t||!st(e.firstElementChild))||7===e.nodeType||!(!ne||8!==e.nodeType||!_h(qh,e.data))}(e,s))return Ve(e),!0;if(J[s]||!(X.tagCheck instanceof Function&&X.tagCheck(s))&&!W[s]){const i=function(e,t,i){if(!J[t]&&ct(t)){if(Q.tagNameCheck instanceof RegExp&&_h(Q.tagNameCheck,t))return!1;if(Q.tagNameCheck instanceof Function&&Q.tagNameCheck(t))return!1}if(fe&&!ye[t]){const t=f(e),s=g(e);if(s&&t)for(let n=s.length-1;n>=0;--n){const r=e===i?h(s[n],!0):s[n];t.insertBefore(r,p(e))}}return Ve(e),!0}(e,s,t);return!1===i&&nt(L.afterSanitizeElements,e,null),i}if(1===(y?y(e):e.nodeType)&&!function(e){let t=f(e);t&&t.tagName||(t={namespaceURI:Ie,tagName:"template"});const i=th(e.tagName),s=th(t.tagName);return!!Te[e.namespaceURI]&&(e.namespaceURI===xe?function(e,t,i){return t.namespaceURI===Pe?"svg"===e:t.namespaceURI===Ee?"svg"===e&&("annotation-xml"===i||$e[i]):Boolean(je[e])}(i,t,s):e.namespaceURI===Ee?function(e,t,i){return t.namespaceURI===Pe?"math"===e:t.namespaceURI===xe?"math"===e&&Le[i]:Boolean(We[e])}(i,t,s):e.namespaceURI===Pe?function(e,t,i){return!(t.namespaceURI===xe&&!Le[i])&&!(t.namespaceURI===Ee&&!$e[i])&&!We[e]&&(Oe[e]||!je[e])}(i,t,s):!("application/xhtml+xml"!==De||!Te[e.namespaceURI]))}(e))return Ve(e),!0;if(("noscript"===s||"noembed"===s||"noframes"===s)&&_h(jh,e.innerHTML))return Ve(e),!0;if(se&&3===e.nodeType){const t=Ze(e.textContent);e.textContent!==t&&(Xd(i.removed,{element:e.cloneNode()}),e.textContent=t)}return nt(L.afterSanitizeElements,e,null),!1},at=function(e,t,i){if(Y[t])return!1;if(ne&&"patchsrc"===t)return!1;if(ne&&"for"===t&&"label"!==e&&"output"!==e)return!1;if(_e&&("id"===t||"name"===t)&&(i in s||i in He))return!1;const n=G[t]||X.attributeCheck instanceof Function&&X.attributeCheck(t,e);if(ee&&_h(B,t));else if(Z&&_h(z,t));else if(n){if(Ce[t]);else if(_h(j,nh(i,U,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==rh(i,"data:")||!we[e])if(te&&!_h(H,nh(i,U,"")));else if(i)return!1}else if(!(ct(e)&&(Q.tagNameCheck instanceof RegExp&&_h(Q.tagNameCheck,e)||Q.tagNameCheck instanceof Function&&Q.tagNameCheck(e))&&(Q.attributeNameCheck instanceof RegExp&&_h(Q.attributeNameCheck,t)||Q.attributeNameCheck instanceof Function&&Q.attributeNameCheck(t,e))||"is"===t&&Q.allowCustomizedBuiltInElements&&(Q.tagNameCheck instanceof RegExp&&_h(Q.tagNameCheck,i)||Q.tagNameCheck instanceof Function&&Q.tagNameCheck(i))))return!1;return!0},lt=vh({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),ct=function(e){return!lt[th(e)]&&_h(q,e)},ut=function(e,t,i,s){if(S&&"object"==typeof u&&"function"==typeof u.getAttributeType&&!i)switch(u.getAttributeType(e,t)){case"TrustedHTML":return I(s);case"TrustedScriptURL":return function(e){P(),x++;try{return S.createScriptURL(e)}finally{x--}}(s)}return s},dt=function(e,t,s,n){try{s?e.setAttributeNS(s,t,n):e.setAttribute(t,n),tt(e)?Ve(e):Yd(i.removed)}catch(i){Ke(t,e)}},ht=function(e){nt(L.beforeSanitizeAttributes,e,null);const t=e.attributes;if(!t||tt(e))return;G=rt(L.uponSanitizeAttribute,G,K,le);const i={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:G,forceKeepAttr:void 0};let s=t.length;const n=Be(e.nodeName);for(;s--;){const r=t[s],o=r.name,a=r.namespaceURI,l=r.value,c=Be(o),u=l;let d="value"===o?u:oh(u);i.attrName=c,i.attrValue=d,i.keepAttr=!0,i.forceKeepAttr=void 0,nt(L.uponSanitizeAttribute,e,i),d=i.attrValue,!pe||"id"!==c&&"name"!==c||0===rh(d,ge)||(Ke(o,e),d=ge+d),ne&&_h(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,d)||"attributename"===c&&sh(d,"href")?Ke(o,e):i.forceKeepAttr||(!i.keepAttr||!ie&&_h(Wh,d)?Ke(o,e):(se&&(d=Ze(d)),at(n,c,d)?(d=ut(n,c,a,d),d!==u&&dt(e,o,a,d)):Ke(o,e)))}nt(L.afterSanitizeAttributes,e,null)},_t=function(e){let t=null;const i=Xe(e);for(nt(L.beforeSanitizeShadowDOM,e,null);t=i.nextNode();)if(nt(L.uponSanitizeShadowNode,t,null),ot(t,e),ht(t),it(t.content)&&_t(t.content),1===(y?y(t):t.nodeType)){const e=v(t);it(e)&&(pt(e),_t(e))}nt(L.afterSanitizeShadowDOM,e,null)},pt=function(e){const t=[{node:e,shadow:null}];for(;t.length>0;){const e=t.pop();if(e.shadow){_t(e.shadow);continue}const i=e.node,s=1===(y?y(i):i.nodeType),n=g(i);if(n)for(let e=n.length-1;e>=0;--e)t.push({node:n[e],shadow:null});if(s){const e=b?b(i):null;if("string"==typeof e&&"template"===Be(e)){const e=i.content;it(e)&&t.push({node:e,shadow:null})}}if(s){const e=v(i);it(e)&&t.push({node:null,shadow:e},{node:e,shadow:null})}}};return i.sanitize=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s=null,r=null,o=null,a=null;if(Fe=!e,Fe&&(e="\x3c!--\x3e"),"string"!=typeof e&&!st(e)&&"string"!=typeof(e=function(e){switch(typeof e){case"string":return e;case"number":return ah(e);case"boolean":return lh(e);case"bigint":return ch?ch(e):"0";case"symbol":return uh?uh(e):"Symbol()";case"undefined":default:return hh(e);case"function":case"object":{if(null===e)return hh(e);const t=e,i=bh(t,"toString");if("function"==typeof i){const e=i(t);return"string"==typeof e?e:hh(e)}return hh(e)}}}(e)))throw ph("dirty is not a string, aborting");if(!i.isSupported)return e;oe?(W=ae,G=le):qe(t),(L.uponSanitizeElement.length>0||L.uponSanitizeAttribute.length>0)&&(W=yh(W)),L.uponSanitizeAttribute.length>0&&(G=yh(G)),i.removed=[];const l=ve&&"string"!=typeof e&&st(e);if(l){!function(e){if(!ne)return;const t=[e];for(;t.length>0;){const e=t.pop(),i=y?y(e):e.nodeType;if(7===i||8===i&&_h(qh,e.data)){try{_(e)}catch(e){}continue}if(1===i){const t=e,i=Be(b?b(e):e.nodeName);try{t.hasAttribute&&t.hasAttribute("patchsrc")&&t.removeAttribute("patchsrc"),t.hasAttribute&&t.hasAttribute("for")&&"label"!==i&&"output"!==i&&t.removeAttribute("for")}catch(e){}}const s=g(e);if(s)for(let e=s.length-1;e>=0;--e)t.push(s[e])}}(e);const t=b?b(e):e.nodeName;if("string"==typeof t){const i=Be(t);if(!W[i]||J[i])throw Ge(e),ph("root node is forbidden and cannot be sanitized in-place")}if(tt(e))throw Ge(e),ph("root node is clobbered and cannot be sanitized in-place");try{pt(e)}catch(t){throw Ge(e),t}}else if(st(e))s=Ye("\x3c!----\x3e"),r=s.ownerDocument.importNode(e,!0),1===r.nodeType&&"BODY"===r.nodeName||"HTML"===r.nodeName?s=r:s.appendChild(r),pt(r);else{if(!ue&&!se&&!re&&-1===e.indexOf("<"))return S&&he?I(e):e;if(s=Ye(e),!s)return ue?null:he?k:""}s&&ce&&Ve(s.firstChild);const c=l?e:s;try{const e=Xe(c);for(;o=e.nextNode();)ot(o,c),ht(o),it(o.content)&&_t(o.content)}catch(t){throw l&&(Ge(e),Qd(i.removed,e=>{e.element&&Je(e.element)})),t}if(l)return Qd(i.removed,e=>{e.element&&Je(e.element)}),se&&et(e),e;if(ue){if(se&&et(s),de)for(a=R.call(s.ownerDocument);s.firstChild;)a.appendChild(s.firstChild);else a=s;return(G.shadowroot||G.shadowrootmode)&&(a=M.call(n,a,!0)),a}let u=re?s.outerHTML:s.innerHTML;return re&&W["!doctype"]&&s.ownerDocument&&s.ownerDocument.doctype&&s.ownerDocument.doctype.name&&_h(zh,s.ownerDocument.doctype.name)&&(u="<!DOCTYPE "+s.ownerDocument.doctype.name+">\n"+u),se&&(u=Ze(u)),S&&he?I(u):u},i.setConfig=function(){qe(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),oe=!0,ae=W,le=G},i.clearConfig=function(){ze=null,oe=!1,ae=null,le=null,S=C,k=""},i.isValidAttribute=function(e,t,i){ze||qe({});const s=Be(e),n=Be(t);return at(s,n,i)},i.addHook=function(e,t){"function"==typeof t&&dh(L,e)&&Xd(L[e],t)},i.removeHook=function(e,t){if(dh(L,e)){if(void 0!==t){const i=Jd(L[e],t);return-1===i?void 0:Zd(L[e],i,1)[0]}return Yd(L[e])}},i.removeHooks=function(e){dh(L,e)&&(L[e]=[])},i.removeAllHooks=function(){L={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},i}();const Qh="Refusing to render web experiment since the viewer is a likely bot",Jh={ADD_ATTR:(e,t)=>"target"===e&&"a"===t||"form"===e&&/^(button|fieldset|input|output|select|textarea)$/.test(t),ADD_URI_SAFE_ATTR:["form"]};let Yh;const Xh={icontains:(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())>-1,not_icontains:(e,t)=>-1===t.toLowerCase().indexOf(e.toLowerCase()),regex:(e,t)=>Mc(t,e),not_regex:(e,t)=>!Mc(t,e),exact:(e,t)=>t===e,is_not:(e,t)=>t!==e},Zh=Fr("[Conversations]"),e_="Conversations not available yet.";function t_(e,t){var i,s,n,r,o,a,l;const c=null!==(i=null==e?void 0:e.flushIntervalMs)&&void 0!==i?i:3e3,u=null!==(s=null==e?void 0:e.maxBufferSize)&&void 0!==s?s:100,d=(null==t?void 0:t.consoleCapture)?void 0:null!==(n=null==e?void 0:e.maxLogsPerInterval)&&void 0!==n?n:1e3,h=vt(d)?Math.max(u,2048):Math.max(u,d),_=as(as({},function(){let e="",t="";try{var i;const s="u">typeof globalThis?globalThis:"u">typeof window?window:void 0,n=null==s||null===(i=s.navigator)||void 0===i?void 0:i.userAgent;n&&([e,t]=Bi(n))}catch(e){}return function(e,t){const i=function(e){if(e)return{}.hasOwnProperty.call(rr,e)?rr[e]:e}(e);return as(as({},i?{"os.name":i}:{}),t?{"os.version":t}:{})}(e,t)}()),null==e?void 0:e.resourceAttributes);return{serviceName:null!==(r=null!==(o=null==_?void 0:_["service.name"])&&void 0!==o?o:null==e?void 0:e.serviceName)&&void 0!==r?r:null==t?void 0:t.serviceNameDefault,serviceVersion:null!==(a=null==_?void 0:_["service.version"])&&void 0!==a?a:null==e?void 0:e.serviceVersion,environment:null!==(l=null==_?void 0:_["deployment.environment"])&&void 0!==l?l:null==e?void 0:e.environment,resourceAttributes:_,beforeSend:null==e?void 0:e.beforeSend,flushIntervalMs:c,maxBufferSize:u,maxQueueSize:h,maxBatchRecordsPerPost:100,rateCapWindowMs:c,maxLogsPerInterval:d,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}}const i_=["debug","log","warn","error","info"],s_=e=>{for(;null==e?void 0:e.__rrweb_original__;)e=e.__rrweb_original__;return e},n_="console",r_="__posthogHandledLogsRequestError",o_=(e,t)=>{const i=e instanceof Error?e:new Error(t);return i[r_]=!0,i},a_=e=>!!e&&"object"==typeof e&&!0===e[r_];var l_=class{get _coreLogger(){return as(as({},this._logger),{},{error:(...e)=>{e.some(a_)||this._logger.error(...e)}})}constructor(e,t){var i;this._configSource=e,this._getSdkContext=t,this.name="logs",this._isLogsEnabled=!1,this._isLoaded=!1,this._isLoading=!1,this._logger=Fr("[logs]"),this._queue=[],this._consoleQueue=[],this._consecutiveStatusZeroFailures=0,this._setupStarted=!1,this._disposed=!1,this._consoleBuffer=[],this._consoleRecorderUnpatchers=[],this._isRecordingConsole=!1,this._isRecordingConsoleEntry=!1,this._listeningForReconnect=!1,this._onReconnect=()=>{var e,t;this._disposed||(this._consecutiveStatusZeroFailures=0,null===(e=this._core)||void 0===e||e.onReconnect(),null===(t=this._consoleCore)||void 0===t||t.onReconnect())},this._isLogsEnabled=!!(null===(i=e.get())||void 0===i?void 0:i.captureConsoleLogs)}get _isRequestReady(){return!0}_getConsoleLoader(){}_listenForReconnect(){if(!this._listeningForReconnect){try{this._window=typeof window>"u"?void 0:window}catch(e){this._window=void 0}this._window&&(Br(this._window,"online",this._onReconnect),this._listeningForReconnect=!0)}}_buildCore(e,t,i,s){this._listenForReconnect();const n=t_(this._configSource.get(),i);return[new gr(this._createHost(e,t),n,this._coreLogger,()=>this._getSdkContext(),e=>e(),void 0,s),n]}_getCore(){const e=this._configSource.get();var t;return this._core&&this._resolvedFrom===e||(null===(t=this._core)||void 0===t||t.reset(),this._resolvedFrom=e,[this._core,this._resolvedConfig]=this._buildCore(()=>this._queue,e=>{this._queue=e})),this._core}_getConsoleCore(){const e=this._configSource.get();var t;return this._consoleCore&&this._consoleResolvedFrom===e||(null===(t=this._consoleCore)||void 0===t||t.reset(),this._consoleResolvedFrom=e,[this._consoleCore,this._consoleResolvedConfig]=this._buildCore(()=>this._consoleQueue,e=>{this._consoleQueue=e},{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},n_)),this._consoleCore}setup(e){if(!this._disposed&&!this._setupStarted)return this._setupStarted=!0,this._client=e,this._logger=e.logger.createLogger("[logs]"),cd(e.kv.initialize(),()=>{this._disposed||this._finishSetup(e)})}_finishSetup(e){var t;this._listenForReconnect(),(null===(t=this._configSource.get())||void 0===t?void 0:t.captureConsoleLogs)&&(this._isLogsEnabled=!0),(this._isLogsEnabled||this._configSource.remoteConfigWillArrive&&e.kv.get(this._configSource.captureHintKey))&&this._startConsoleRecorder();let i=!1;const s=e.onRemoteConfig(e=>{var t;i=e.ok&&!0===(null===(t=e.config.logs)||void 0===t?void 0:t.captureConsoleLogs),this.onRemoteConfig(e)});this._disposed?s.dispose():(this._remoteConfigSubscription=s,i||this.loadIfEnabled())}dispose(){var e,t,i,s,n,r,o;this._disposed||(this._disposed=!0,this._stopConsoleRecorder(),null===(e=this._remoteConfigSubscription)||void 0===e||e.dispose(),this._remoteConfigSubscription=void 0,this._client=void 0,this._isLoading=!1,null===(t=this._window)||void 0===t||t.removeEventListener("online",this._onReconnect),null===(i=this._consoleLogsDispose)||void 0===i||i.call(this),this._consoleLogsDispose=void 0,null===(s=this._core)||void 0===s||s.clearQueue(),null===(n=this._consoleCore)||void 0===n||n.clearQueue(),null===(r=this._core)||void 0===r||r.reset(),null===(o=this._consoleCore)||void 0===o||o.reset())}onRemoteConfig(e){var t,i;if(this._disposed)return;const s=e.ok?null===(t=e.config.logs)||void 0===t?void 0:t.captureConsoleLogs:void 0;wt(s)?this._stopRecorderStartedByPersistedHint():(null===(i=this._client)||void 0===i||i.kv.set(this._configSource.captureHintKey,!!s),s?(this._isLogsEnabled=!0,this._isLoaded||this._startConsoleRecorder(),this.loadIfEnabled()):this._stopRecorderStartedByPersistedHint())}reset(){var e,t,i,s;this._stopConsoleRecorder(),null===(e=this._core)||void 0===e||e.clearQueue(),this._queue=[],null===(t=this._core)||void 0===t||t.reset(),null===(i=this._consoleCore)||void 0===i||i.clearQueue(),this._consoleQueue=[],null===(s=this._consoleCore)||void 0===s||s.reset(),this._consecutiveStatusZeroFailures=0}captureLog(e){!this._disposed&&this._client&&this._getCore().captureLog(e)}captureConsoleLog(e){!this._disposed&&this._client&&this._getConsoleCore().captureLog(e)}captureBufferedConsoleLog(e,t,i){!this._disposed&&this._client&&this._getConsoleCore().captureLog(e,{context:t,occurredAtMs:i})}_onOptOut(){var e;this._stopConsoleRecorder(),null===(e=this._consoleCore)||void 0===e||e.clearQueue(),this._consoleQueue=[]}_stopRecorderStartedByPersistedHint(){this._isLogsEnabled||this._stopConsoleRecorder()}_startConsoleRecorder(){var e;if(this._isRecordingConsole||!(null===(e=this._window)||void 0===e?void 0:e.console))return;const t=t_(this._configSource.get()).maxBufferSize;let i=!0;this._consoleRecorderUnpatchers.push(()=>{i=!1});for(const e of i_){let s;try{s=s_(this._window.console[e])}catch(e){continue}s&&this._consoleRecorderUnpatchers.push(Hu(this._window.console,e,n=>{const r=(...s)=>{try{i&&this._recordConsoleEntry(e,s,t)}catch(e){}return n.apply(this._window.console,s)};return r.__rrweb_original__=s,r}))}this._isRecordingConsole=!0,this._consoleRecorderTimeout=setTimeout(()=>{this._stopConsoleRecorder()},3e4)}_recordConsoleEntry(e,t,i){var s;if(this._isRecordingConsole&&!this._isRecordingConsoleEntry&&0!==t.length)if(null===(s=this._client)||void 0===s?void 0:s.canCapture){if(i>this._consoleBuffer.length){this._isRecordingConsoleEntry=!0;try{this._consoleBuffer.push({level:e,args:t,occurredAtMs:Date.now(),context:this._getSdkContext()})}finally{this._isRecordingConsoleEntry=!1}}}else this._stopConsoleRecorder()}_stopConsoleRecorder(){if(this._consoleBuffer=[],this._isRecordingConsole){this._isRecordingConsole=!1,this._consoleRecorderTimeout&&(clearTimeout(this._consoleRecorderTimeout),this._consoleRecorderTimeout=void 0);for(const e of this._consoleRecorderUnpatchers)e();this._consoleRecorderUnpatchers=[]}}_takeConsoleBuffer(){const e=this._consoleBuffer;return this._stopConsoleRecorder(),e}get logger(){return this._capture_logger||(this._capture_logger={trace:(e,t)=>this.captureLog({body:e,level:"trace",attributes:t}),debug:(e,t)=>this.captureLog({body:e,level:"debug",attributes:t}),info:(e,t)=>this.captureLog({body:e,level:"info",attributes:t}),warn:(e,t)=>this.captureLog({body:e,level:"warn",attributes:t}),error:(e,t)=>this.captureLog({body:e,level:"error",attributes:t}),fatal:(e,t)=>this.captureLog({body:e,level:"fatal",attributes:t})}),this._capture_logger}flushLogs(e){this._client&&(e?this._flushViaTransport(e):(this._core&&this._core.flush().catch(e=>this._logFlushError(e)),this._consoleCore&&this._consoleCore.flush().catch(e=>this._logFlushError(e))))}flush(){var e=this;return Ot(function*(){var t,i;const s=null===(t=e._core)||void 0===t?void 0:t.flush().catch(t=>e._logFlushError(t)),n=null===(i=e._consoleCore)||void 0===i?void 0:i.flush().catch(t=>e._logFlushError(t));yield s,yield n})()}_logFlushError(e){a_(e)||this._logger.error("PostHog logs flush failed:",e)}loadIfEnabled(){if(this._disposed||!this._isLogsEnabled||this._isLoaded||this._isLoading)return;const e=this._getConsoleLoader();if(e){this._isLoading=!0;try{e((e,t)=>{if(this._isLoading=!1,!this._disposed&&this._isLogsEnabled)if(e||!t)this._logger.error("Could not load logs script",e),this._stopConsoleRecorder();else{const e=this._takeConsoleBuffer();this._consoleLogsDispose=t.initialize(this._client),this._isLoaded=!0,e.length>0&&t.replay(this._client,e)}})}catch(e){throw this._isLoading=!1,e}}else this._stopConsoleRecorder()}_createHost(e,t){const i=this._client;return{get isDisabled(){return!1},get optedOut(){return!i.canCapture},getPersistedProperty:t=>t===it.LogsQueue?e():void 0,setPersistedProperty(e,i){e===it.LogsQueue&&t(null!=i?i:[])},_sendLogsBatch:e=>this._sendLogsBatch(e),getLibraryId:()=>i.library.name,getLibraryVersion:()=>i.library.version}}_sendLogsBatch(e){return new Promise(t=>{if(Ea(this._consecutiveStatusZeroFailures,3))return void t({kind:"fatal",error:o_(void 0,"logs endpoint is unreachable, dropping batch")});let i=!1;const s=e=>{i||(i=!0,clearTimeout(n),t(e))},n=setTimeout(()=>{this._logger.warn("Logs request timed out before receiving a response"),s({kind:"retry-later",error:o_(void 0,"logs request timed out")})},9e4),r=this._isRequestReady;this._client.sendRequest("/i/v1/logs",{method:"POST",query:{token:this._client.projectToken},body:e,compression:"best-available",timeoutMs:6e4}).then(e=>{var t;const i=e.statusCode;this._trackEndpointReachability(i,r),i>=200&&300>i?s({kind:"ok"}):413===i?s({kind:"too-large"}):0!==i&&408!==i&&429!==i&&500>i?s({kind:"fatal",error:new Error(`logs request failed with status ${i}`)}):0===i?(e.error||this._logger.warn("Logs request failed before receiving an HTTP response"),s({kind:"retry-later",error:o_(e.error,"logs request failed before receiving an HTTP response")})):s({kind:"retry-later",error:null!==(t=e.error)&&void 0!==t?t:new Error(`logs request failed with status ${i}`)})},e=>{s({kind:"retry-later",error:e})})})}_trackEndpointReachability(e,t){(0!==e||t)&&(this._consecutiveStatusZeroFailures=xa(e,this._consecutiveStatusZeroFailures,3,()=>this._logger.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.")))}_flushViaTransport(e){this._queue.length>0&&this._drainQueueViaTransport(e,this._queue,this._resolvedConfig,this._client.library.name,e=>{this._queue=e}),this._consoleQueue.length>0&&this._drainQueueViaTransport(e,this._consoleQueue,this._consoleResolvedConfig,n_,e=>{this._consoleQueue=e})}_drainQueueViaTransport(e,t,i,s,n){if(0===t.length)return;const r=t.map(e=>e.record);n([]);const o=dr(r,ur(i,this._client.library.name,this._client.library.version),s,this._client.library.version);this._client.sendRequest("/i/v1/logs",{method:"POST",query:{token:this._client.projectToken},body:o,compression:"best-available",transport:e,timeoutMs:6e4}).catch(e=>this._logFlushError(e))}};const c_=Fr("[NetworkMetrics]"),u_={"http:":80,"https:":443},d_=new Set(["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"]),h_=(e,t)=>{var i;const s=String(t);return{method:String(e).toUpperCase(),url:(null===(i=Ca(s))||void 0===i?void 0:i.href)||s}},__=(e,t,i,s,n,r,o=!1)=>{try{var a,l;const c=n();if(!c)return;const u=i||void 0,d=uu()-s,h=Ca(t.url);if(h&&"http:"!==h.protocol&&"https:"!==h.protocol)return;const _={url:(null==h?void 0:h.href)||t.url,method:t.method},p=pt(c.name)?c.name(_):mt(c.name)?c.name:"http.client.request.duration";if(!p)return;const g=o&&!u?void 0:((e,t)=>e?400>e?void 0:String(e):(null==t?void 0:t.name)||"_OTHER")(u,r),f=as(as(as(as(as({},(e=>{const t=d_.has(e)?e:"_OTHER";return as({"http.request.method":t},"_OTHER"===t&&e!==t?{"http.request.method_original":e}:{})})(_.method)),h?(e=>{return{"server.address":e.hostname.startsWith("[")&&e.hostname.endsWith("]")?e.hostname.slice(1,-1):e.hostname,"server.port":Number(e.port)||u_[e.protocol],"url.scheme":e.protocol.slice(0,-1),"url.template":(t=e.pathname,t.split("/").map(e=>(e=>/^\d+$/.test(e)||e.length>=8&&/^[0-9a-f-]*\d[0-9a-f-]*$/i.test(e))(e)?":id":e).join("/"))};var t})(h):{}),u?{"http.response.status_code":u}:{}),g?{"error.type":g}:{}),null===(a=c.attributes)||void 0===a?void 0:a.call(c,_,{status:u,durationMs:d}));null===(l=e.metrics)||void 0===l||l.histogram(p,d,{unit:"ms",attributes:f})}catch(e){c_.error("Failed to record network metric",e)}},p_=()=>{},g_=(e,t)=>pt(null==je?void 0:je.fetch)?Hu(je,"fetch",i=>function(...s){const n=uu(),r=i.apply(this,s);if(!t())return r;try{var o,a,l;const[i,c]=s,u=h_(null!==(o=null!==(a=null==c?void 0:c.method)&&void 0!==a?a:null==i?void 0:i.method)&&void 0!==o?o:"GET",null!==(l=null==i?void 0:i.url)&&void 0!==l?l:i);return r.then(i=>(__(e,u,null==i?void 0:i.status,n,t,void 0,!0),i),i=>{throw __(e,u,void 0,n,t,i),i})}catch(e){return c_.error("Failed to observe fetch",e),r}}):p_,f_=(e,t)=>{var i;const s=null==je||null===(i=je.XMLHttpRequest)||void 0===i?void 0:i.prototype;if(!s)return p_;const n=new WeakMap,r=Hu(s,"open",e=>function(...t){try{(()=>Xl.has(this))()||n.set(this,h_(t[0],t[1]))}catch(e){c_.error("Failed to observe XHR open",e)}return e.apply(this,t)}),o=Hu(s,"send",i=>function(...s){let r;try{const i=n.get(this);if(i&&t()){const s=uu();r=()=>{this.removeEventListener("loadend",r),__(e,i,this.status,s,t)},Br(this,"loadend",r)}}catch(e){c_.error("Failed to observe XHR send",e)}try{return i.apply(this,s)}catch(e){throw r&&this.removeEventListener("loadend",r),e}});return()=>{r(),o()}},v_=new WeakMap,m_=new Set(["$comment","$defs","$id","$schema","additionalProperties","default","definitions","deprecated","description","examples","minProperties","properties","readOnly","required","title","type","writeOnly"]),y_={maxStringLength:2048,truncationSuffix:"..."},b_={maxStringLength:2048,truncationSuffix:"..."};function w_(e){if(e)return!0===e?{intent:!0,model:!0}:{intent:!1!==e.intent,model:!1!==e.model}}function S_(e,t){return{}.hasOwnProperty.call(e,t)}function C_(e,t){const i=Object.create(e);return t&&Object.defineProperty(i,"inputSchema",{configurable:!0,enumerable:!0,writable:!0,value:t}),i}function k_(e,t,i=!1){if(!mt(e))return;const s=e.trim();return s?(i?Kn(s,y_):s).slice(0,t):void 0}function E_(e){try{return gt(e)&&!0===e.isError}catch(e){return!1}}function x_(e){return Kn(e||"Unknown error",b_).slice(0,2048)}function P_(e,t){try{return x_(t?function(e){try{if(!gt(e)||!_t(e.content))return;return e.content.filter(e=>gt(e)&&"text"===e.type&&mt(e.text)).map(e=>e.text).join(" ").trim()||void 0}catch(e){return}}(e):gt(e)&&mt(e.message)?e.message:mt(e)?e:String(e))}catch(e){return"Unknown error"}}function I_(e,t,i){return t.errorResult?[{type:"Error",value:i,mechanism:{type:"generic",handled:!0,synthetic:!0,exception_id:0}}]:e.buildProperties(t.error,{handled:!0}).$exception_list.map(e=>as(as({},e),{},{value:x_(e.value)}))}function F_(e,t){if(t)return"Error";try{if(!gt(e))return"Error";let t=mt(e.name)?e.name.trim():"";const i=e.constructor;return t&&"Error"!==t||!pt(i)||"Error"===i.name||(t=i.name),(t||"Error").slice(0,256)}catch(e){return"Error"}}function T_(e,t){return{message:P_(e,t),type:F_(e,t)}}Lu.__defaultExtensionClasses=as({},((...e)=>Ar({},...e))({featureFlags:Fd},{sessionRecording:class{get _config(){return this._instance.config}get _persistence(){return this._instance.persistence}get started(){var e;return!!(null===(e=this._lazyLoadedSessionRecording)||void 0===e?void 0:e.isStarted)}get status(){var e,t;return"awaiting_config"===this._recordingStatus||"missing_config"===this._recordingStatus?this._recordingStatus:null!==(e=null===(t=this._lazyLoadedSessionRecording)||void 0===t?void 0:t.status)&&void 0!==e?e:this._recordingStatus}constructor(e){if(this._instance=e,this._forceAllowLocalhostNetworkCapture=!1,this._recordingStatus=Ku,this._persistFlagsOnSessionListener=void 0,this._sessionRecordingDisposed=!1,this._documentWasEverVisible=(()=>{var e,t;if(!(null==Ge?void 0:Ge.visibilityState)||"visible"===Ge.visibilityState)return!0;const i=null==je||null===(e=je.performance)||void 0===e||null===(t=e.getEntriesByType)||void 0===t?void 0:t.call(e,"visibility-state");return!(null==i?void 0:i.length)||i.some(e=>"visible"===e.name)})(),this._onVisibilityChange=()=>{var e,t;"visible"===(null==Ge?void 0:Ge.visibilityState)&&(this._documentWasEverVisible=!0,null===(e=this._lazyLoadedSessionRecording)||void 0===e||null===(t=e.setDocumentWasEverVisible)||void 0===t||t.call(e,!0))},!this._instance.sessionManager)throw Ju.error("started without valid sessionManager"),new Error("[SessionRecording] started without valid sessionManager. This is a bug.");if("always"===this._config.cookieless_mode)throw new Error('[SessionRecording] cannot be used with cookieless_mode="always"');(null==Ge?void 0:Ge.addEventListener)&&Br(Ge,"visibilitychange",this._onVisibilityChange)}initialize(){this.startIfEnabledOrStop()}dispose({discardBufferedEvents:e=!1}={}){var t;this._sessionRecordingDisposed=!0,null==Ge||null===(t=Ge.removeEventListener)||void 0===t||t.call(Ge,"visibilitychange",this._onVisibilityChange),e?this._discardRecording(!0):this.stopRecording()}get _isRecordingEnabled(){var e;const t=!!(null===(e=this._instance.get_property("$session_recording_remote_config"))||void 0===e?void 0:e.enabled),i=!this._config.disable_session_recording,s=this._config.disable_session_recording||this._instance.consent.isOptedOut();return je&&t&&i&&!s}startIfEnabledOrStop(e){var t;if(this._sessionRecordingDisposed)return;if(this._isRecordingEnabled&&(null===(t=this._lazyLoadedSessionRecording)||void 0===t?void 0:t.isStarted))return;const i=!vt(Object.assign)&&!vt(Array.from);this._isRecordingEnabled&&i?(this._lazyLoadAndStart(e),Ju.info("starting")):(this._recordingStatus=Ku,this.stopRecording())}_lazyLoadAndStart(e){var t,i;if(this._isRecordingEnabled)if("awaiting_config"!==this._recordingStatus&&"missing_config"!==this._recordingStatus&&(this._recordingStatus=Qu),(null==tt||null===(t=tt.__PosthogExtensions__)||void 0===t||null===(t=t.rrweb)||void 0===t?void 0:t.record)&&(null===(i=tt.__PosthogExtensions__)||void 0===i?void 0:i.initSessionRecording))this._onScriptLoaded(e);else{var s,n;const t=this._instance.sessionManager;null===(s=tt.__PosthogExtensions__)||void 0===s||null===(n=s.loadExternalDependency)||void 0===n||n.call(s,this._instance,this._scriptName,i=>{if(!this._sessionRecordingDisposed&&this._isRecordingEnabled&&this._instance.sessionManager===t)return i?(this._instance.register_for_session({$sdk_debug_recording_script_not_loaded:!0}),Ju.error("could not load recorder",i)):void this._onScriptLoaded(e);this._recordingStatus="disabled"})}}stopRecording(){var e,t;null===(e=this._persistFlagsOnSessionListener)||void 0===e||e.call(this),this._persistFlagsOnSessionListener=void 0,null===(t=this._lazyLoadedSessionRecording)||void 0===t||t.stop()}_discardRecording(e=!1){var t,i;null===(t=this._persistFlagsOnSessionListener)||void 0===t||t.call(this),this._persistFlagsOnSessionListener=void 0,null===(i=this._lazyLoadedSessionRecording)||void 0===i||i.discard({discardProducerEvents:e})}_resetSampling(){var e,t;null===(e=this._persistence)||void 0===e||e.unregister("$session_is_sampled"),null===(t=this._persistence)||void 0===t||t.unregister("$replay_sample_rate")}_validateSampleRate(e,t){if(wt(e))return null;const i=St(e)?e:parseFloat(e);return"number"!=typeof(s=i)||!Number.isFinite(s)||0>s||s>1?(Ju.warn(`${t} must be between 0 and 1. Ignoring invalid value:`,e),null):i;var s}_persistRemoteConfig(e){if(this._persistence){var t,i;const s=this._persistence,n=()=>{var t;const i=!1===e.sessionRecording?void 0:e.sessionRecording,n=this._validateSampleRate(null===(t=this._config.session_recording)||void 0===t?void 0:t.sampleRate,"session_recording.sampleRate"),r=this._validateSampleRate(null==i?void 0:i.sampleRate,"remote config sampleRate"),o=null!=n?n:r;wt(o)&&this._resetSampling();const a=null==i?void 0:i.minimumDurationMilliseconds;s.register({[G]:as(as({cache_timestamp:Date.now(),enabled:!!i},i),{},{networkPayloadCapture:as({capturePerformance:e.capturePerformance},null==i?void 0:i.networkPayloadCapture),canvasRecording:{enabled:null==i?void 0:i.recordCanvas,fps:null==i?void 0:i.canvasFps,quality:null==i?void 0:i.canvasQuality},sampleRate:o,minimumDurationMilliseconds:vt(a)?null:a,endpoint:null==i?void 0:i.endpoint,triggerMatchType:null==i?void 0:i.triggerMatchType,masking:null==i?void 0:i.masking,urlTriggers:null==i?void 0:i.urlTriggers,version:null==i?void 0:i.version,triggerGroups:null==i?void 0:i.triggerGroups})})};n(),null===(t=this._persistFlagsOnSessionListener)||void 0===t||t.call(this),this._persistFlagsOnSessionListener=null===(i=this._instance.sessionManager)||void 0===i?void 0:i.onSessionId(n)}}onRemoteConfig(e){const t=e.ok?e.config:void 0;return t&&"sessionRecording"in t?!1===t.sessionRecording?(this._persistRemoteConfig(t),void this._discardRecording()):(this._persistRemoteConfig(t),void this.startIfEnabledOrStop()):("awaiting_config"===this._recordingStatus&&(this._recordingStatus="missing_config",this._instance.register_for_session({[Pe]:!0}),Ju.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(e,t="log"){var i;(null===(i=this._lazyLoadedSessionRecording)||void 0===i?void 0:i.log)?this._lazyLoadedSessionRecording.log(e,t):Ju.warn("log called before recorder was ready")}get _scriptName(){var e,t;const i=null===(e=this._instance)||void 0===e||null===(e=e.persistence)||void 0===e?void 0:e.get_property(G);return(null==i||null===(t=i.scriptConfig)||void 0===t?void 0:t.script)||"lazy-recorder"}_isRemoteConfigFresh(){const e=this._instance.get_property(G);if(!e)return!1;let t;try{t="object"==typeof e?e:JSON.parse(e)}catch(e){return Ju.warn("persisted remote config for session recording is invalid and will be ignored",e),!1}return!wt(t.cache_timestamp)&&36e5>=Date.now()-t.cache_timestamp}_onScriptLoaded(e){var t,i,s;if(!this._sessionRecordingDisposed&&this._isRecordingEnabled&&this._instance.sessionManager){if(!(null===(t=tt.__PosthogExtensions__)||void 0===t?void 0:t.initSessionRecording))return Ju.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[xe]:!0});var n;if(this._lazyLoadedSessionRecording||(this._lazyLoadedSessionRecording=null===(n=tt.__PosthogExtensions__)||void 0===n?void 0:n.initSessionRecording(this._instance,this._documentWasEverVisible),this._lazyLoadedSessionRecording._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this._isRemoteConfigFresh()){if("missing_config"===this._recordingStatus||"awaiting_config"===this._recordingStatus)return;return this._recordingStatus="awaiting_config",Ju.info("persisted remote config is stale, requesting fresh config before starting"),void new vl(this._instance).load()}this._recordingStatus=Qu,null===(i=(s=this._lazyLoadedSessionRecording).setDocumentWasEverVisible)||void 0===i||i.call(s,this._documentWasEverVisible),this._lazyLoadedSessionRecording.start(e)}else this._recordingStatus=Ku}onRRwebEmit(e){var t,i;null===(t=this._lazyLoadedSessionRecording)||void 0===t||null===(i=t.onRRwebEmit)||void 0===i||i.call(t,e)}overrideLinkedFlag(){var e,t;this._lazyLoadedSessionRecording||null===(t=this._persistence)||void 0===t||t.register({$replay_override_linked_flag:!0}),null===(e=this._lazyLoadedSessionRecording)||void 0===e||e.overrideLinkedFlag()}overrideSampling(){var e,t;this._lazyLoadedSessionRecording||null===(t=this._persistence)||void 0===t||t.register({$replay_override_sampling:!0}),null===(e=this._lazyLoadedSessionRecording)||void 0===e||e.overrideSampling()}overrideTrigger(e){var t,i;this._lazyLoadedSessionRecording||null===(i=this._persistence)||void 0===i||i.register({["url"===e?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),null===(t=this._lazyLoadedSessionRecording)||void 0===t||t.overrideTrigger(e)}get sdkDebugProperties(){var e;const t={};for(const e of Yu){var i;const s=null===(i=this._instance.sessionPersistence)||void 0===i?void 0:i.get_property(e);vt(s)||(t[e]=s)}return as(as({},t),(null===(e=this._lazyLoadedSessionRecording)||void 0===e?void 0:e.sdkDebugProperties)||{$recording_status:this.status})}tryAddCustomEvent(e,t){var i;return!!(null===(i=this._lazyLoadedSessionRecording)||void 0===i?void 0:i.tryAddCustomEvent(e,t))}flushBeforeIdentityReset(){var e,t;null===(e=this._lazyLoadedSessionRecording)||void 0===e||null===(t=e.flushBeforeIdentityReset)||void 0===t||t.call(e)}}},{autocapture:class extends au{constructor(e){super(new Du(e)),this.instance=e}},historyAutocapture:class{constructor(e){this._isFlushingPageview=!1,this._instance=e,this._lastLocation=this._getCurrentLocation()}initialize(){this.startIfEnabled()}get isEnabled(){const e=this._getCaptureOptions();return!!(e.path||e.search||this._shouldCaptureHashChanges(e))}startIfEnabled(){this.isEnabled&&(Ir.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}startIfEnabledOrStop(){this.stop(),this._lastLocation=this._getCurrentLocation(),this.startIfEnabled()}stop(){this._popstateListener&&this._popstateListener(),this._popstateListener=void 0,this._hashchangeListener&&this._hashchangeListener(),this._hashchangeListener=void 0,Ir.info("History API monitoring stopped")}monitorHistoryChanges(){je&&je.history&&(this._patchHistoryMethod("pushState"),this._patchHistoryMethod("replaceState"),this._setupPopstateListener(),this._shouldCaptureHashChanges()&&this._setupHashchangeListener())}_patchHistoryMethod(e){var t;if(!je||(null===(t=je.history[e])||void 0===t?void 0:t.__posthog_wrapped__))return;const i=this;Hu(je.history,e,t=>function(s,n,r){var o;i._isUrlChanging(r)&&i._flushPendingPageview(),t.call(this,s,n,r),i._capturePageview(e,!i._isFlushingPageview&&"popstate"!==(null==je||null===(o=je.event)||void 0===o?void 0:o.type))})}_getCurrentLocation(){const e=null==je?void 0:je.location;if(null==e?void 0:e.pathname)return{pathname:e.pathname,search:e.search,hash:e.hash}}_getCaptureOptions(){const e=this._instance.config.capture_pageview;return"history_change"===e?{path:!0}:gt(e)?e:{}}_shouldCaptureHashChanges(e=this._getCaptureOptions()){return!!e.hash&&!this._instance.config.disable_capture_url_hashes}_hasLocationChanged(e){const t=this._getCaptureOptions(),i=this._lastLocation;return!(!i||!(t.path&&e.pathname!==i.pathname||t.search&&e.search!==i.search||this._shouldCaptureHashChanges(t)&&e.hash!==i.hash))}_capturePageview(e,t=!1){try{t||this._flushPendingPageview();const i=this._getCurrentLocation();if(!i)return;if(this._hasLocationChanged(i)){const i=()=>this._instance.capture(ze,{navigation_type:e});t?(this._pendingPageview=i,Promise.resolve().then(()=>this._flushPendingPageview())):i()}this._lastLocation=i}catch(t){Ir.error(`Error capturing ${e} pageview`,t)}}_isUrlChanging(e){var t,i;return!(wt(e)||!je)&&(null===(t=Ca(String(e)))||void 0===t?void 0:t.href)!==(null===(i=je.location)||void 0===i?void 0:i.href)}_flushPendingPageview(){const e=this._pendingPageview;if(e){this._pendingPageview=void 0,this._isFlushingPageview=!0;try{e()}catch(e){Ir.error("Error capturing deferred pageview",e)}finally{this._isFlushingPageview=!1}this._lastLocation=this._getCurrentLocation()}}_setupPopstateListener(){if(this._popstateListener)return;const e=()=>{this._capturePageview("popstate")};Br(je,"popstate",e),this._popstateListener=()=>{je&&je.removeEventListener("popstate",e)}}_setupHashchangeListener(){if(this._hashchangeListener)return;const e=()=>{this._capturePageview("hashchange")};Br(je,"hashchange",e),this._hashchangeListener=()=>{je&&je.removeEventListener("hashchange",e)}}},heatmaps:class{get _config(){return this.instance.config}constructor(e){var t;this._enabledServerSide=!1,this._initialized=!1,this._flushInterval=null,this.instance=e,this._enabledServerSide=!!(null===(t=this.instance.persistence)||void 0===t?void 0:t.props[N]),this.rageclicks=new Yc(e.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){let e=5e3;return gt(this._config.capture_heatmaps)&&this._config.capture_heatmaps.flush_interval_milliseconds&&(e=this._config.capture_heatmaps.flush_interval_milliseconds),e}get isEnabled(){return wt(this._config.capture_heatmaps)?wt(this._config.enable_heatmaps)?this._enabledServerSide:this._config.enable_heatmaps:!1!==this._config.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this._initialized)return;Xu.info("starting..."),this._setupListeners(),this._onVisibilityChange()}else{var e;clearInterval(null!==(e=this._flushInterval)&&void 0!==e?e:void 0),this._removeListeners(),this.getAndClearBuffer()}}onRemoteConfig(e){if(!e.ok)return;const t=e.config;if(!("heatmaps"in t))return;const i=!!t.heatmaps;this.instance.persistence&&this.instance.persistence.register({[N]:i}),this._enabledServerSide=i,this.startIfEnabled()}getAndClearBuffer(){const e=this._buffer;return this._buffer=void 0,e}_onDeadClick(e){Zu(e.originalEvent)&&this._onClick(e.originalEvent,"deadclick")}_onVisibilityChange(){this._flushInterval&&clearInterval(this._flushInterval),this._flushInterval=function(e){return"visible"===(null==e?void 0:e.visibilityState)}(Ge)?setInterval(this._flush.bind(this),this.flushIntervalMilliseconds):null}_setupListeners(){je&&Ge&&(this._flushHandler=this._flush.bind(this),Br(je,Be,this._flushHandler),this._onClickHandler=e=>this._onClick(e||(null==je?void 0:je.event)),Br(Ge,"click",this._onClickHandler,{capture:!0}),this._onMouseMoveHandler=e=>this._onMouseMove(e||(null==je?void 0:je.event)),Br(Ge,"mousemove",this._onMouseMoveHandler,{capture:!0}),this._deadClicksCapture=new da(this.instance,ca,this._onDeadClick.bind(this)),this._deadClicksCapture.startIfEnabledOrStop(),this._onVisibilityChange_handler=this._onVisibilityChange.bind(this),Br(Ge,m,this._onVisibilityChange_handler),this._initialized=!0)}_removeListeners(){var e;je&&Ge&&(this._flushHandler&&je.removeEventListener(Be,this._flushHandler),this._onClickHandler&&Ge.removeEventListener("click",this._onClickHandler,{capture:!0}),this._onMouseMoveHandler&&Ge.removeEventListener("mousemove",this._onMouseMoveHandler,{capture:!0}),this._onVisibilityChange_handler&&Ge.removeEventListener(m,this._onVisibilityChange_handler),clearTimeout(this._mouseMoveTimeout),null===(e=this._deadClicksCapture)||void 0===e||e.stop(),this._initialized=!1)}_getProperties(e,t){const i=this.instance.scrollManager.scrollY(),s=this.instance.scrollManager.scrollX(),n=this.instance.scrollManager.scrollElement(),r=function(e,t,i){let s=e;for(;s&&bo(s)&&!wo(s,"body");){if(s===i)return!1;let e;try{var n,r,o;e=null===(n=null!==(r=null===(o=s.ownerDocument)||void 0===o?void 0:o.defaultView)&&void 0!==r?r:je)||void 0===n?void 0:n.getComputedStyle(s).position}catch(e){return!1}if(ot(t,e))return!0;s=$o(s)}return!1}(Fo(e),["fixed","sticky"],n);return{x:e.clientX+(r?0:s),y:e.clientY+(r?0:i),target_fixed:r,type:t}}_onClick(e,t="click"){var i;if(yo(e.target)||!Zu(e))return;const s=this._getProperties(e,t);(null===(i=this.rageclicks)||void 0===i?void 0:i.isRageClick(e.clientX,e.clientY,(new Date).getTime()))&&Wo(Fo(e),this.instance.config.rageclick)&&this._capture(as(as({},s),{},{type:"rageclick"})),this._capture(s)}_onMouseMove(e){!yo(e.target)&&Zu(e)&&(clearTimeout(this._mouseMoveTimeout),this._mouseMoveTimeout=setTimeout(()=>{this._capture(this._getProperties(e,"mousemove"))},500))}_capture(e){if(!je)return;const t=this._config.disable_capture_url_hashes?Zi(je.location.href):je.location.href,i=this._config.custom_personal_data_properties,s=this._config.mask_personal_data_properties?[...Ra,...i||[]]:[],n=Fa(t,s,$a);this._buffer=this._buffer||{},this._buffer[n]||(this._buffer[n]=[]),this._buffer[n].push(e)}_flush(){this._buffer&&!ft(this._buffer)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:da,webVitalsAutocapture:class{constructor(e){var t;this._instance=e,this._enabledServerSide=!1,this._initialized=!1,this._buffer={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this._flushToCapture=(e=!1)=>{clearTimeout(this._delayedFlushTimer),this._delayedFlushTimer=void 0,0!==this._buffer.metrics.length&&(this._instance.capture("$web_vitals",as({$current_url:this._buffer.url},this._buffer.metrics.reduce((e,t)=>as(as({},e),{},{[`$web_vitals_${t.name}_event`]:as({},t),[`$web_vitals_${t.name}_value`]:t.value}),{})),e?{transport:"sendBeacon",send_instantly:!0}:void 0),this._buffer={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0})},this._addToBuffer=e=>{var t;if(this._buffer=this._buffer||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},wt(null==e?void 0:e.name)||wt(null==e?void 0:e.value))return void qu.error("Invalid metric received",e);const i="string"==typeof e.navigationURL?e.navigationURL:void 0,s=this._maskedURL(i);if(vt(s))return;const n=St(e.navigationId)||"string"==typeof e.navigationId?`navigation:${e.navigationId}`:`url:${s}`;if(this._maxAllowedValue&&e.value>=this._maxAllowedValue)return void qu.error("Ignoring metric with value >= "+this._maxAllowedValue,e);this._buffer.navigationKey!==n&&(this._flushToCapture(),this._delayedFlushTimer=setTimeout(this._flushToCapture,this.flushToCaptureTimeoutMs)),vt(this._buffer.navigationKey)&&(this._buffer.navigationKey=n,this._buffer.url=s),this._buffer.firstMetricTimestamp=vt(this._buffer.firstMetricTimestamp)?Date.now():this._buffer.firstMetricTimestamp;const r=null===(t=this._instance.sessionManager)||void 0===t?void 0:t.checkAndGetSessionAndWindowId(!0),o=as(as(as({},e),i?{navigationURL:s}:{}),{},{$current_url:s,timestamp:Date.now()});if(delete o.entries,gt(e.attribution)&&this.attributionMetrics.indexOf(e.name)>-1){const t={};for(const i of Gu){const s="url"===i&&"string"==typeof e.attribution[i]?this._maskedURL(e.attribution[i]):e.attribution[i];vt(s)||(t[i]=s)}o.attribution=t}else delete o.attribution;vt(r)||(o.$session_id=r.sessionId,o.$window_id=r.windowId),this._buffer.metrics.push(o),this._buffer.metrics.length===this.allowedMetrics.length&&this._flushToCapture()},this._startCapturing=()=>{if(this._initialized)return;let e,t,i,s,n=!1;const r=tt.__PosthogExtensions__,o=null==r?void 0:r.postHogWebVitalsCallbacksByFlavor,a=(null==o?void 0:o[this._callbackFlavor])||("web-vitals"===this._callbackFlavor&&vt(o)?null==r?void 0:r.postHogWebVitalsCallbacks:void 0);if(!vt(a)){const r=a.withoutAttribution,o=this.attributionMetrics;n=!vt(r),e=o.indexOf("LCP")>-1?a.onLCP:(null==r?void 0:r.onLCP)||a.onLCP,t=o.indexOf("CLS")>-1?a.onCLS:(null==r?void 0:r.onCLS)||a.onCLS,i=o.indexOf("FCP")>-1?a.onFCP:(null==r?void 0:r.onFCP)||a.onFCP,s=o.indexOf("INP")>-1?a.onINP:(null==r?void 0:r.onINP)||a.onINP}if(!(e&&t&&i&&s))return void qu.error("web vitals callbacks not loaded - not starting");const l={reportSoftNavs:this.useSoftNavs},c=n&&this.attributionMetrics.indexOf("INP")>-1?as(as({},l),{},{includeProcessedEventEntries:!1}):l;this.allowedMetrics.indexOf("LCP")>-1&&e(this._addToBuffer.bind(this),l),this.allowedMetrics.indexOf("CLS")>-1&&t(this._addToBuffer.bind(this),l),this.allowedMetrics.indexOf("FCP")>-1&&i(this._addToBuffer.bind(this),l),this.allowedMetrics.indexOf("INP")>-1&&s(this._addToBuffer.bind(this),c);const u=null==je?void 0:je.document;Br(u,m,()=>{"hidden"===(null==u?void 0:u.visibilityState)&&this._flushToCapture(!0)}),Br(je,"pagehide",()=>this._flushToCapture(!0)),this._initialized=!0},this._enabledServerSide=!!(null===(t=this._instance.persistence)||void 0===t?void 0:t.props[U]),this.startIfEnabled()}get _perfConfig(){return this._instance.config.capture_performance}get allowedMetrics(){var e,t;const i=gt(this._perfConfig)?null===(e=this._perfConfig)||void 0===e?void 0:e.web_vitals_allowed_metrics:void 0;return wt(i)?(null===(t=this._instance.persistence)||void 0===t?void 0:t.props.$web_vitals_allowed_metrics)||Wu:i}get flushToCaptureTimeoutMs(){return(gt(this._perfConfig)?this._perfConfig.web_vitals_delayed_flush_ms:void 0)||5e3}get attributionMetrics(){const e=gt(this._perfConfig)?this._perfConfig.web_vitals_attribution:void 0;return kt(e)?e?Wu:[]:_t(e)?e:Vu}get useAttribution(){return this.attributionMetrics.length>0}get useSoftNavs(){const e=gt(this._perfConfig)?this._perfConfig.__preview_web_vitals_soft_navs:void 0;return null!=e&&e}get _maxAllowedValue(){const e=gt(this._perfConfig)&&St(this._perfConfig.__web_vitals_max_value)?this._perfConfig.__web_vitals_max_value:ju;return e>0&&6e4>=e?ju:e}get isEnabled(){const e=null==Ke?void 0:Ke.protocol;if("http:"!==e&&"https:"!==e)return qu.info("Web Vitals are disabled on non-http/https protocols"),!1;const t=gt(this._perfConfig)?this._perfConfig.web_vitals:kt(this._perfConfig)?this._perfConfig:void 0;return kt(t)?t:this._enabledServerSide}startIfEnabled(){this.isEnabled&&!this._initialized&&(qu.info("enabled, starting..."),this._loadScript(this._startCapturing))}onRemoteConfig(e){if(!e.ok)return;const t=e.config;if(!("capturePerformance"in t))return;const i=gt(t.capturePerformance)&&!!t.capturePerformance.web_vitals,s=gt(t.capturePerformance)?t.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[U]:i}),this._instance.persistence.register({[V]:s})),this._enabledServerSide=i,this.startIfEnabled()}get _callbackFlavor(){return this.useSoftNavs?this.useAttribution?"web-vitals-with-attribution-soft-navs":"web-vitals-soft-navs":this.useAttribution?"web-vitals-with-attribution":"web-vitals"}_loadScript(e){var t;const i=tt.__PosthogExtensions__,s=this._callbackFlavor,n=null==i?void 0:i.postHogWebVitalsCallbacksByFlavor;(null==n?void 0:n[s])||"web-vitals"===s&&vt(n)&&(null==i?void 0:i.postHogWebVitalsCallbacks)?e():null==i||null===(t=i.loadExternalDependency)||void 0===t||t.call(i,this._instance,s,t=>{t?qu.error("failed to load script",t):e()})}_maskedURL(e){const t=e||(null==je?void 0:je.location.href);if(!t)return void qu.error("Could not determine current URL");const i=this._instance.config.disable_capture_url_hashes?Zi(t):t,s=this._instance.config.custom_personal_data_properties,n=this._instance.config.mask_personal_data_properties?[...Ra,...s||[]]:[];return Fa(i,n,$a)}}},{exceptionObserver:class{constructor(e){var t;this._startCapturing=()=>{var e;if(!je||!this.isEnabled||!(null===(e=tt.__PosthogExtensions__)||void 0===e?void 0:e.errorWrappingFunctions))return;const t=tt.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,i=tt.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,s=tt.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this._unwrapOnError&&this._config.capture_unhandled_errors&&(this._unwrapOnError=t(this.captureException.bind(this))),!this._unwrapUnhandledRejection&&this._config.capture_unhandled_rejections&&(this._unwrapUnhandledRejection=i(this.captureException.bind(this))),!this._unwrapConsoleError&&this._config.capture_console_errors&&(this._unwrapConsoleError=s(this.captureException.bind(this)))}catch(e){Nu.error("failed to start",e),this._stopCapturing()}},this._instance=e,this._remoteEnabled=!!(null===(t=this._instance.persistence)||void 0===t?void 0:t.props[B]),this._rateLimiter=new Ht(as(as({},function(e={}){var t,i,s,n;return{refillRate:null!==(t=null!==(i=e.exceptionRateLimiterRefillRate)&&void 0!==i?i:e.__exceptionRateLimiterRefillRate)&&void 0!==t?t:1,bucketSize:null!==(s=null!==(n=e.exceptionRateLimiterBucketSize)&&void 0!==n?n:e.__exceptionRateLimiterBucketSize)&&void 0!==s?s:10}}(this._instance.config.error_tracking)),{},{refillInterval:1e4,_logger:Nu})),this._config=this._requiredConfig(),this.startIfEnabledOrStop()}_requiredConfig(){const e=this._instance.config.capture_exceptions;let t={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return gt(e)?t=as(as({},t),e):(vt(e)?this._remoteEnabled:e)&&(t=as(as({},t),{},{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),t}get isEnabled(){return this._config.capture_console_errors||this._config.capture_unhandled_errors||this._config.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(Nu.info("enabled"),this._stopCapturing(),this._loadScript(this._startCapturing)):this._stopCapturing()}_loadScript(e){var t,i,s;(null===(t=tt.__PosthogExtensions__)||void 0===t?void 0:t.errorWrappingFunctions)?e():null===(i=tt.__PosthogExtensions__)||void 0===i||null===(s=i.loadExternalDependency)||void 0===s||s.call(i,this._instance,"exception-autocapture",t=>{if(t)return Nu.error("failed to load script",t);e()})}_stopCapturing(){var e,t,i;null===(e=this._unwrapOnError)||void 0===e||e.call(this),this._unwrapOnError=void 0,null===(t=this._unwrapUnhandledRejection)||void 0===t||t.call(this),this._unwrapUnhandledRejection=void 0,null===(i=this._unwrapConsoleError)||void 0===i||i.call(this),this._unwrapConsoleError=void 0}onRemoteConfig(e){if(!e.ok)return;const t=e.config;"autocaptureExceptions"in t&&(this._remoteEnabled=!!t.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[B]:this._remoteEnabled}),this._config=this._requiredConfig(),this.startIfEnabledOrStop())}onConfigChange(){this._config=this._requiredConfig()}captureException(e){try{var t,i,s;const n=null!==(t=null==e||null===(i=e.$exception_list)||void 0===i||null===(i=i[0])||void 0===i?void 0:i.type)&&void 0!==t?t:"Exception";if(this._rateLimiter.consumeRateLimit(n))return void Nu.info("Skipping exception capture because of client rate limiting.",{exception:n});null===(s=this._instance.exceptions)||void 0===s||s.sendExceptionEvent(e)}catch(e){}}},exceptions:class{constructor(e){var t,i;this._suppressionRules=[],this._errorPropertiesBuilder=new ps([new Ls,new Ws,new Ds,new Os,new qs,new Us,new Bs,new js],function(e,...t){return(i,s=0)=>{const n=[],r=i.split("\n"),o=Math.min(r.length,s+1e3),a=[];for(let i=s;o>i;i++){const s=r[i];if(s.length>1024)continue;const o=Ps.test(s)?s.replace(Ps,"$1"):s;if(!o.match(/\S*Error: /)){for(const i of t){const t=i(o,e);if(t){n.push(t);const e=Fs(n);if(e){for(let t=a.length-1;t>=0;t--){const i=a[t];if(e.start>=i.start+i.length)break;a.pop()}a.push(e)}break}}if($s(n,a)>=50)break}}const l=[...a].sort((e,t)=>t.start-e.start),c=l[l.length-1];if(c){const e=Rs(n,c);n.splice(c.start-e,e);for(const t of l)t.start-=e}for(const e of l)Ts(n,e);return a.some(e=>0===e.start&&n.length===e.length)&&function(e){const t=e.map(e=>`${e.function}|${e.filename}|${e.lineno}|${e.colno}|${e.module}`);let i=0;for(let e=1;t.length>e;e++)Ms(t,e,i)&&(i=e);e.push(...e.splice(0,i))}(n),function(e){if(!e.length)return[];const t=Array.from(e);return t.reverse(),t.slice(0,50).map(e=>{return as(as({},e),{},{filename:e.filename||(i=t,i[i.length-1]||{}).filename,function:e.function||"?"});var i})}(n)}}("web:javascript",Cs,xs)),this._instance=e,this._suppressionRules=null!==(t=null===(i=this._instance.persistence)||void 0===i?void 0:i.get_property("$error_tracking_suppression_rules"))&&void 0!==t?t:[],this._exceptionStepsConfig=Js(this._getExceptionStepsConfig()),this._exceptionStepsBuffer=new Ys(this._exceptionStepsConfig)}onConfigChange(){this._exceptionStepsConfig=Js(this._getExceptionStepsConfig()),this._exceptionStepsBuffer.setConfig(this._exceptionStepsConfig)}onRemoteConfig(e){var t,i,s;if(!e.ok)return;const n=e.config;if(!("errorTracking"in n))return;const r=null!==(t=null===(i=n.errorTracking)||void 0===i?void 0:i.suppressionRules)&&void 0!==t?t:[],o=null===(s=n.errorTracking)||void 0===s?void 0:s.captureExtensionExceptions;this._suppressionRules=r,this._instance.persistence&&this._instance.persistence.register({[z]:this._suppressionRules,[H]:o})}get _captureExtensionExceptions(){var e;const t=!!this._instance.get_property(H),i=this._instance.config.error_tracking.captureExtensionExceptions;return null!==(e=null!=i?i:t)&&void 0!==e&&e}buildProperties(e,t){return this._errorPropertiesBuilder.buildFromUnknown(e,{syntheticException:null==t?void 0:t.syntheticException,mechanism:{handled:null==t?void 0:t.handled}})}addExceptionStep(e,t){if(this._exceptionStepsConfig.enabled)try{if(!mt(e)||0===e.trim().length)return void Rd.warn("Ignoring exception step because message must be a non-empty string");const{sanitizedProperties:i,droppedKeys:s}=function(e){if(!e)return{sanitizedProperties:{},droppedKeys:[]};const t=[];return{sanitizedProperties:Object.keys(e).reduce((i,s)=>Ks.has(s)?(t.push(s),i):(i[s]=e[s],i),{}),droppedKeys:t}}(this._coerceExceptionStepProperties(t));s.length>0&&Rd.warn("Ignoring reserved exception step fields",{droppedKeys:s}),this._exceptionStepsBuffer.add(as({[Vs]:e,[Gs]:(new Date).toISOString()},i))}catch(e){Rd.error("Failed to add exception step. Ignoring breadcrumb.",e)}}sendExceptionEvent(e){try{const t=e.$exception_list;if(this._isExceptionList(t)){if(this._matchesSuppressionRule(t))return this._addDroppedExceptionStep("Exception dropped: matched a suppression rule"),void Rd.info("Skipping exception capture because a suppression rule matched");if(!this._captureExtensionExceptions&&this._isExtensionException(t))return this._addDroppedExceptionStep("Exception dropped: thrown by a browser extension"),void Rd.info("Skipping exception capture because it was thrown by an extension");if(!this._captureExtensionExceptions&&this._isInjectedBrowserScriptException(t))return this._addDroppedExceptionStep("Exception dropped: thrown by an injected browser script"),void Rd.info("Skipping exception capture because it was thrown by an injected browser script");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this._isPostHogException(t))return this._addDroppedExceptionStep("Exception dropped: thrown by the PostHog SDK"),void Rd.info("Skipping exception capture because it was thrown by the PostHog SDK")}const i=this._exceptionStepsConfig.enabled&&wt(e.$exception_steps)?this._addBufferedExceptionSteps(e):e,s=function(){if("u">typeof process){var e;const t=null===(e=process.env.POSTHOG_RELEASE_ID)||void 0===e?void 0:e.trim();if(t)return t}const t=globalThis._posthogReleaseId;return"string"==typeof t&&t.length>0?t:void 0}();s&&(i.$release_id=s);try{const e=this._instance.capture("$exception",i,{_noTruncate:!0,_batchKey:"exceptionEvent",_originatedFromCaptureException:!0});return e&&this._exceptionStepsBuffer.clear(),e}catch(e){return Td(e)||Rd.error("Failed to capture exception event. Dropping this exception.",e),void this._exceptionStepsBuffer.clear()}}catch(e){return void(Td(e)||Rd.error("Failed to process exception event. Ignoring this exception.",e))}}_addBufferedExceptionSteps(e){try{const t=this._exceptionStepsBuffer.getAttachable();return 0===t.length?e:as(as({},e),{},{$exception_steps:t})}catch(t){return Rd.error("Failed to read buffered exception steps. Capturing exception without steps.",t),e}}_addDroppedExceptionStep(e){this._exceptionStepsConfig.enabled&&this._exceptionStepsBuffer.add({[Vs]:e,[Gs]:(new Date).toISOString()})}_coerceExceptionStepProperties(e){return gt(e)?as({},e):{}}_getExceptionStepsConfig(){var e,t;return null!==(e=null===(t=this._instance.config.error_tracking)||void 0===t?void 0:t.exception_steps)&&void 0!==e?e:{}}_matchesSuppressionRule(e){if(0===e.length)return!1;try{const t=e.reduce((e,{type:t,value:i})=>(mt(t)&&t.length>0&&e.$exception_types.push(t),mt(i)&&i.length>0&&e.$exception_values.push(i),e),{$exception_types:[],$exception_values:[]});return this._suppressionRules.some(e=>{const i=e.values.map(e=>{const i=Oc[e.operator],s=t[e.key];if(!i||!s)return!1;const n=_t(e.value)?e.value:[e.value];return n.length>0&&i(n,s)});return"OR"===e.type?i.some(Boolean):i.every(Boolean)})}catch(e){return Rd.warn("Failed to evaluate suppression rules. Capturing the exception.",e),!1}}_isExtensionException(e){const t=e.flatMap(e=>{var t,i;return null!==(t=null===(i=e.stacktrace)||void 0===i?void 0:i.frames)&&void 0!==t?t:[]}),i=t.filter(({filename:e})=>!!e&&Md.some(t=>e.startsWith(t)));return 0!==i.length&&(!i.every(({filename:e})=>!!e&&e.startsWith(Ad))||e.some(({type:e,value:t})=>"NoResponse"===e||mt(t)&&$d.some(({value:e,exact:i})=>i?t===e:t.includes(e)))&&!t.some(({in_app:e,filename:t})=>e&&!(null==t?void 0:t.startsWith(Ad))))}_isInjectedBrowserScriptException(e){return e.some(({value:e})=>mt(e)&&Ld.some(t=>e.includes(t)))}_isPostHogException(e){if(e.length>0){var t,i,s,n;const r=null!==(t=null===(i=e[0].stacktrace)||void 0===i?void 0:i.frames)&&void 0!==t?t:[],o=r[r.length-1];return null!==(s=null==o||null===(n=o.filename)||void 0===n?void 0:n.includes("posthog.com/static"))&&void 0!==s&&s}return!1}_isExceptionList(e){return!wt(e)&&_t(e)}}},{productTours:class{get _persistence(){return this._instance.persistence}constructor(e){this._productTourManager=null,this._cachedTours=null,this._instance=e}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(!e.ok)return;const t=e.config;if("productTours"in t){var i,s;if(this._persistence&&this._persistence.register({[j]:!!t.productTours}),!td(this._instance))return!this._productTourManager&&wt(null===(i=this._persistence)||void 0===i?void 0:i.props.ph_product_tours)||ed.info("product tours disabled; stopping and clearing cached tours"),null===(s=this._productTourManager)||void 0===s||s.stop(),this._productTourManager=null,void this.clearCache();this.loadIfEnabled()}}loadIfEnabled(){!this._productTourManager&&td(this._instance)&&this._loadScript(()=>this._startProductTours())}_loadScript(e){var t,i,s;(null===(t=tt.__PosthogExtensions__)||void 0===t?void 0:t.generateProductTours)?e():null===(i=tt.__PosthogExtensions__)||void 0===i||null===(s=i.loadExternalDependency)||void 0===s||s.call(i,this._instance,"product-tours",t=>{t?ed.error("Could not load product tours script",t):e()})}_startProductTours(){var e;!this._productTourManager&&(null===(e=tt.__PosthogExtensions__)||void 0===e?void 0:e.generateProductTours)&&(this._productTourManager=tt.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,t=!1){if(_t(this._cachedTours)&&!t)return void e(this._cachedTours,{isLoaded:!0});const i=this._persistence;if(i){const s=i.props[le];if(_t(s)&&!t)return this._cachedTours=s,void e(s,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api",`/api/product_tours/?token=${this._instance.config.token}`),method:"GET",timestampMode:"query",callback:t=>{if(!td(this._instance))return void e([],{isLoaded:!0});const s=t.statusCode;if(200!==s||!t.json){const i=`Product Tours API could not be loaded, status: ${s}`;return 0===s?t.error||ed.warn(i):ed.error(i),void e([],{isLoaded:!1,error:i})}const n=_t(t.json.product_tours)?t.json.product_tours:[];this._cachedTours=n,i&&i.register({[le]:n}),e(n,{isLoaded:!0})}})}getActiveProductTours(e){wt(this._productTourManager)?e([],{isLoaded:!1,error:"Product tours not loaded"}):this._productTourManager.getActiveProductTours(e)}showProductTour(e){var t;null===(t=this._productTourManager)||void 0===t||t.showTourById(e)}previewTour(e){this._productTourManager?this._productTourManager.previewTour(e):this._loadScript(()=>{var t;this._startProductTours(),null===(t=this._productTourManager)||void 0===t||t.previewTour(e)})}dismissProductTour(){var e;null===(e=this._productTourManager)||void 0===e||e.dismissTour("user_clicked_skip")}nextStep(){var e;null===(e=this._productTourManager)||void 0===e||e.nextStep()}previousStep(){var e;null===(e=this._productTourManager)||void 0===e||e.previousStep()}clearCache(){var e;this._cachedTours=null,null===(e=this._persistence)||void 0===e||e.unregister("ph_product_tours")}resetTour(e){var t;null===(t=this._productTourManager)||void 0===t||t.resetTour(e)}resetAllTours(){var e;null===(e=this._productTourManager)||void 0===e||e.resetAllTours()}cancelPendingTour(e){var t;null===(t=this._productTourManager)||void 0===t||t.cancelPendingTour(e)}},featureFlags:Fd},{siteApps:class{constructor(e){this._instance=e,this._siteAppElementPatchCount=0,this._bufferedInvocations=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}_eventCollector(e,t){if(!t)return;const i=this.globalsForEvent(t);this._bufferedInvocations.push(i),this._bufferedInvocations.length>1e3&&(this._bufferedInvocations=this._bufferedInvocations.slice(10))}get siteAppLoaders(){var e;return null===(e=tt._POSTHOG_REMOTE_CONFIG)||void 0===e||null===(e=e[this._instance.config.token])||void 0===e?void 0:e.siteApps}initialize(){if(this.isEnabled){const e=this._instance._addCaptureHook(this._eventCollector.bind(this));this._stopBuffering=()=>{e(),this._bufferedInvocations=[],this._stopBuffering=void 0}}}globalsForEvent(e){var t,i,s,n,r,o,a;if(!e)throw new Error("Event payload is required");const l={},c=this._instance.get_property("$groups")||[],u=this._instance.get_property("$stored_group_properties")||{};for(const[e,t]of Object.entries(u))l[e]={id:c[e],type:e,properties:t};const{$set_once:d,$set:h}=e;return{event:as(as({},hn(e,id)),{},{properties:as(as(as({},e.properties),h?{$set:as(as({},null!==(t=null===(i=e.properties)||void 0===i?void 0:i.$set)&&void 0!==t?t:{}),h)}:{}),d?{$set_once:as(as({},null!==(s=null===(n=e.properties)||void 0===n?void 0:n.$set_once)&&void 0!==s?s:{}),d)}:{}),elements_chain:null!==(r=null===(o=e.properties)||void 0===o?void 0:o.$elements_chain)&&void 0!==r?r:"",distinct_id:null===(a=e.properties)||void 0===a?void 0:a.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:l}}_prepareElementForSiteApp(e){var t;const i=null===(t=e.tagName)||void 0===t?void 0:t.toLowerCase();if("style"===i&&this._instance.config.prepare_external_dependency_stylesheet){return this._instance.config.prepare_external_dependency_stylesheet(e)||(sd.error("prepare_external_dependency_stylesheet returned null"),null)}if("script"===i&&this._instance.config.prepare_external_dependency_script){return this._instance.config.prepare_external_dependency_script(e)||(sd.error("prepare_external_dependency_script returned null"),null)}return e}_patchSiteAppElementInsertionMethods(){var e,t,i,s,n,r,o,a;if(!this._instance.config.prepare_external_dependency_stylesheet&&!this._instance.config.prepare_external_dependency_script)return()=>{};const l=null==Ge?void 0:Ge.defaultView,c=null==l||null===(e=l.Node)||void 0===e?void 0:e.prototype;if(!l||!c)return()=>{};if(this._siteAppElementPatchCount++,this._restoreSiteAppElementPatches)return this._releaseSiteAppElementPatches();const u=[],d=this,h=new WeakSet,_=(e,t,i)=>{if(!(null==e?void 0:e[t]))return;const s=e[t];e[t]=i(s),u.push(()=>{e[t]=s})},p=e=>{if(h.has(e))return e;const t=d._prepareElementForSiteApp(e);return t&&h.add(t),t},g=e=>e.map(e=>"string"==typeof e?e:p(e)).filter(e=>!bt(e));return _(c,"appendChild",e=>function(t){const i=p(t);return i?e.call(this,i):t}),_(c,"insertBefore",e=>function(t,i){const s=p(t);return s?e.call(this,s,i):t}),_(c,"replaceChild",e=>function(t,i){const s=p(t);return s?e.call(this,s,i):i}),[null===(t=l.Element)||void 0===t?void 0:t.prototype,null===(i=l.Document)||void 0===i?void 0:i.prototype,null===(s=l.DocumentFragment)||void 0===s?void 0:s.prototype].forEach(e=>{_(e,"append",e=>function(...t){return e.apply(this,g(t))}),_(e,"prepend",e=>function(...t){return e.apply(this,g(t))})}),[null===(n=l.Element)||void 0===n?void 0:n.prototype,null===(r=l.CharacterData)||void 0===r?void 0:r.prototype,null===(o=l.DocumentType)||void 0===o?void 0:o.prototype].forEach(e=>{_(e,"before",e=>function(...t){return e.apply(this,g(t))}),_(e,"after",e=>function(...t){return e.apply(this,g(t))}),_(e,"replaceWith",e=>function(...t){const i=g(t);return t.length&&!i.length?void 0:e.apply(this,i)})}),_(null===(a=l.Element)||void 0===a?void 0:a.prototype,"insertAdjacentElement",e=>function(t,i){const s=p(i);return s?e.call(this,t,s):null}),this._restoreSiteAppElementPatches=()=>{u.forEach(e=>e()),this._restoreSiteAppElementPatches=void 0},this._releaseSiteAppElementPatches()}_releaseSiteAppElementPatches(){let e=!1;return()=>{var t;e||(e=!0,this._siteAppElementPatchCount--,0===this._siteAppElementPatchCount&&(null===(t=this._restoreSiteAppElementPatches)||void 0===t||t.call(this)))}}_runWithPreparedSiteAppElements(e,t=!0){const i=this._patchSiteAppElementInsertionMethods();try{const s=e(i);return t&&i(),s}catch(e){throw i(),e}}setupSiteApp(e){const t=this.apps[e.id],i=()=>{var i;!t.errored&&this._bufferedInvocations.length&&(sd.info(`Processing ${this._bufferedInvocations.length} events for site app with id ${e.id}`),this._bufferedInvocations.forEach(e=>this._runWithPreparedSiteAppElements(()=>{var i;return null===(i=t.processEvent)||void 0===i?void 0:i.call(t,e)})),t.processedBuffer=!0),Object.values(this.apps).every(e=>e.processedBuffer||e.errored)&&(null===(i=this._stopBuffering)||void 0===i||i.call(this))};let s=!1;const n=n=>{t.errored=!n,t.loaded=!0,sd.info(`Site app with id ${e.id} ${n?"loaded":"errored"}`),s&&i()};try{const{processEvent:i}=this._runWithPreparedSiteAppElements(t=>e.init({posthog:this._instance,callback(e){t(),n(e)}}),!1);i&&(t.processEvent=i),s=!0}catch(t){sd.error(nd+e.id,t),n(!1)}if(s&&t.loaded)try{i()}catch(i){sd.error(`Error while processing buffered events PostHog app with config id ${e.id}`,i),t.errored=!0}}_setupSiteApps(){const e=this.siteAppLoaders||[];for(const t of e)this.apps[t.id]={id:t.id,loaded:!1,errored:!1,processedBuffer:!1};for(const t of e)this.setupSiteApp(t)}_onCapturedEvent(e){if(0===Object.keys(this.apps).length)return;const t=this.globalsForEvent(e);for(const i of Object.values(this.apps))try{this._runWithPreparedSiteAppElements(()=>{var e;return null===(e=i.processEvent)||void 0===e?void 0:e.call(i,t)})}catch(t){sd.error(`Error while processing event ${e.event} for site app ${i.id}`,t)}}onRemoteConfig(e){var t,i,s;if(null===(t=this.siteAppLoaders)||void 0===t?void 0:t.length)return this.isEnabled?(this._setupSiteApps(),void this._instance.on("eventCaptured",e=>this._onCapturedEvent(e))):void sd.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null===(i=this._stopBuffering)||void 0===i||i.call(this),!e.ok)return;const n=e.config;if(null===(s=n.siteApps)||void 0===s?void 0:s.length)if(this.isEnabled)for(const{id:e,url:t}of n.siteApps){var r,o;tt[`__$$ph_site_app_${e}`]=this._instance,null===(r=tt.__PosthogExtensions__)||void 0===r||null===(o=r.loadSiteApp)||void 0===o||o.call(r,this._instance,t,t=>{if(t)return sd.error(nd+e,t)})}else sd.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}},{surveys:class extends hd{constructor(e){super(new _d(e))}},featureFlags:Fd},{tracingHeaders:class{constructor(e){this._instance=e,this._restoreXHRPatch=void 0,this._restoreFetchPatch=void 0,this._hostnamesForPatch=void 0,this._startCapturing=()=>{const e=this._syncHostnamesForPatch();var t,i;e?(vt(this._restoreXHRPatch)&&(this._restoreXHRPatch=null===(t=tt.__PosthogExtensions__)||void 0===t||null===(t=t.tracingHeadersPatchFns)||void 0===t?void 0:t._patchXHR(e,()=>this._instance.get_distinct_id(),this._instance.sessionManager)),vt(this._restoreFetchPatch)&&(this._restoreFetchPatch=null===(i=tt.__PosthogExtensions__)||void 0===i||null===(i=i.tracingHeadersPatchFns)||void 0===i?void 0:i._patchFetch(e,()=>this._instance.get_distinct_id(),this._instance.sessionManager))):this._stopCapturing()}}initialize(){this.startIfEnabledOrStop()}_loadScript(e){var t,i,s;(null===(t=tt.__PosthogExtensions__)||void 0===t?void 0:t.tracingHeadersPatchFns)?e():null===(i=tt.__PosthogExtensions__)||void 0===i||null===(s=i.loadExternalDependency)||void 0===s||s.call(i,this._instance,"tracing-headers",t=>{if(t)return Uu.error("failed to load script",t);e()})}_getConfiguredHostnames(){var e,t;return null!==(e=null!==(t=this._instance.config.tracing_headers)&&void 0!==t?t:this._instance.config.addTracingHeaders)&&void 0!==e?e:this._instance.config.__add_tracing_headers}_syncHostnamesForPatch(){const e=this._getConfiguredHostnames();return _t(e)?(_t(this._hostnamesForPatch)?this._hostnamesForPatch.splice(0,this._hostnamesForPatch.length,...e):this._hostnamesForPatch=[...e],e.length>0?this._hostnamesForPatch:void 0):(_t(this._hostnamesForPatch)&&this._hostnamesForPatch.splice(0),this._hostnamesForPatch=e||void 0,this._hostnamesForPatch)}_stopCapturing(){var e,t;null===(e=this._restoreXHRPatch)||void 0===e||e.call(this),null===(t=this._restoreFetchPatch)||void 0===t||t.call(this),this._restoreXHRPatch=void 0,this._restoreFetchPatch=void 0}startIfEnabledOrStop(){this._syncHostnamesForPatch()?this._loadScript(this._startCapturing):this._stopCapturing()}}},{toolbar:class{constructor(e){this.instance=e}_setToolbarState(e){tt.ph_toolbar_state=e}_getToolbarState(){var e;return null!==(e=tt.ph_toolbar_state)&&void 0!==e?e:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(e=void 0,t=void 0,i=void 0){var s,n;if(zr(this.instance.config))return!1;if(!je||!Ge)return!1;e=null!==(s=e)&&void 0!==s?s:je.location,i=null!==(n=i)&&void 0!==n?n:je.history;try{if(!t){try{je.localStorage.setItem("test","test"),je.localStorage.removeItem("test")}catch(e){return!1}t=null==je?void 0:je.localStorage}const s=pd||Ta(e.hash,"__posthog")||Ta(e.hash,"state");let n;const r=s?es(()=>JSON.parse(atob(decodeURIComponent(s))))||es(()=>JSON.parse(decodeURIComponent(s))):null;return r&&"ph_authorize"===r.action?(n=r,n.source="url",n&&Object.keys(n).length>0&&(r.desiredHash?e.hash=r.desiredHash:i?i.replaceState(i.state,"",e.pathname+e.search):e.hash="")):(n=JSON.parse(t.getItem(gd)||"{}"),n.source="localstorage",delete n.userIntent),!(!n.token||this.instance.config.token!==n.token||(this.loadToolbar(n),0))}catch(e){return!1}}_callLoadToolbar(e){const t=tt.ph_load_toolbar||tt.ph_load_editor;!wt(t)&&pt(t)?t(e,this.instance):fd.warn("No toolbar load function found")}loadToolbar(e){const t=!!(null==Ge?void 0:Ge.getElementById("__POSTHOG_TOOLBAR__"));if(!je||t)return!1;const i="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,s=as(as({token:this.instance.config.token},e),{},{apiURL:this.instance.requestRouter.endpointFor("ui")},i?{instrument:!1}:{});if(je.localStorage.setItem(gd,JSON.stringify(as(as({},s),{},{source:void 0}))),2===this._getToolbarState())this._callLoadToolbar(s);else if(0===this._getToolbarState()){var n,r;this._setToolbarState(1),null===(n=tt.__PosthogExtensions__)||void 0===n||null===(r=n.loadExternalDependency)||void 0===r||r.call(n,this.instance,"toolbar",e=>{if(e)return fd.error("[Toolbar] Failed to load",e),void this._setToolbarState(0);this._setToolbarState(2),this._callLoadToolbar(s)}),Br(je,"turbolinks:load",()=>{this._setToolbarState(0),this.loadToolbar(s)})}return!0}_loadEditor(e){return this.loadToolbar(e)}maybeLoadEditor(e=void 0,t=void 0,i=void 0){return this.maybeLoadToolbar(e,t,i)}}},{experiments:class e{get _config(){return this._instance.config}constructor(t){this._instance=t,this.getWebExperimentsAndEvaluateDisplayLogic=(t=!1)=>{this.getWebExperiments(t=>{e._logInfo("retrieved web experiments from the server"),this._flagToExperiments=new Map,t.forEach(t=>{if(t.feature_flag_key){var i;this._flagToExperiments&&(e._logInfo("setting flag key ",t.feature_flag_key," to web experiment ",t),null===(i=this._flagToExperiments)||void 0===i||i.set(t.feature_flag_key,t));const s=this._instance.getFeatureFlag(t.feature_flag_key);mt(s)&&t.variants[s]&&this._applyVariantForFlag(t,s)}else if(t.variants)for(const i in t.variants){const s=t.variants[i];e._matchesTestVariant(s,this._instance)&&this._applyTransforms(t.name,i,s.transforms)}})},t)},this._instance.onFeatureFlags(e=>{this.onFeatureFlags(e)})}initialize(){}onFeatureFlags(t){if(this._is_bot())e._logInfo(Qh);else if(!this._config.disable_web_experiments){if(wt(this._flagToExperiments))return this._flagToExperiments=new Map,this.loadIfEnabled(),void this.previewWebExperiment();e._logInfo("applying feature flags",t),t.forEach(e=>{var t;if(this._flagToExperiments&&(null===(t=this._flagToExperiments)||void 0===t?void 0:t.has(e))){var i;const t=this._instance.getFeatureFlag(e),s=null===(i=this._flagToExperiments)||void 0===i?void 0:i.get(e);t&&(null==s?void 0:s.variants[t])&&this._applyVariantForFlag(s,t)}})}}previewWebExperiment(){const t=e.getWindowLocation();if(null==t?void 0:t.search){const i=Ia(null==t?void 0:t.search,"__experiment_id"),s=Ia(null==t?void 0:t.search,"__experiment_variant");i&&s&&(e._logInfo(`previewing web experiments ${i} && ${s}`),this.getWebExperiments(e=>{this._showPreviewWebExperiment(parseInt(i),s,e)},!1,!0))}}loadIfEnabled(){this._config.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,t,i){if(this._config.disable_web_experiments&&!i)return e([]);const s=this._instance.get_property("$web_experiments");if(s&&!t)return e(s);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api",`/api/web_experiments/?token=${this._config.token}`),method:"GET",timestampMode:"query",callback:t=>e(200===t.statusCode&&t.json&&t.json.experiments||[])})}_showPreviewWebExperiment(t,i,s){const n=s.filter(e=>e.id===t);n&&n.length>0&&(e._logInfo(`Previewing web experiment [${n[0].name}] with variant [${i}]`),this._applyTransforms(n[0].name,i,n[0].variants[i].transforms))}_applyVariantForFlag(t,i){const s=t.variants[i];e._matchUrlConditions(s,this._instance)?this._applyTransforms(t.name,i,s.transforms):e._logInfo(`skipping variant ${i} of experiment ${t.name} because this page does not match its url conditions`)}static _matchesTestVariant(t,i){return!wt(t.conditions)&&e._matchUrlConditions(t,i)&&e._matchUTMConditions(t)}static _matchUrlConditions(t,i){var s;if(wt(t.conditions)||wt(null===(s=t.conditions)||void 0===s?void 0:s.url))return!0;const n=e.getWindowLocation();if(n){var r,o,a;const e=mo(i,n.href);return!(null===(r=t.conditions)||void 0===r?void 0:r.url)||Xh[null!==(o=null===(a=t.conditions)||void 0===a?void 0:a.urlMatchType)&&void 0!==o?o:"icontains"](t.conditions.url,e)}return!1}static getWindowLocation(){return null==je?void 0:je.location}static _matchUTMConditions(e){var t;if(wt(e.conditions)||wt(null===(t=e.conditions)||void 0===t?void 0:t.utm))return!0;const i=La();if(i.utm_source){var s,n,r,o,a,l,c,u;const t=!(null===(s=e.conditions)||void 0===s||null===(s=s.utm)||void 0===s?void 0:s.utm_campaign)||(null===(n=e.conditions)||void 0===n||null===(n=n.utm)||void 0===n?void 0:n.utm_campaign)==i.utm_campaign,d=!(null===(r=e.conditions)||void 0===r||null===(r=r.utm)||void 0===r?void 0:r.utm_source)||(null===(o=e.conditions)||void 0===o||null===(o=o.utm)||void 0===o?void 0:o.utm_source)==i.utm_source,h=!(null===(a=e.conditions)||void 0===a||null===(a=a.utm)||void 0===a?void 0:a.utm_medium)||(null===(l=e.conditions)||void 0===l||null===(l=l.utm)||void 0===l?void 0:l.utm_medium)==i.utm_medium,_=!(null===(c=e.conditions)||void 0===c||null===(c=c.utm)||void 0===c?void 0:c.utm_term)||(null===(u=e.conditions)||void 0===u||null===(u=u.utm)||void 0===u?void 0:u.utm_term)==i.utm_term;return t&&h&&_&&d}return!1}static _logInfo(e,...t){Ir.info(`[WebExperiments] ${e}`,t)}static _logWarn(e,...t){Ir.warn(`[WebExperiments] ${e}`,t)}static _sanitizeLinkTargets(t){("http://www.w3.org/1999/xhtml"===t.namespaceURI&&"template"===t.localName?t.content:t).querySelectorAll("a[target], template").forEach(t=>{var i;if("template"===t.localName)return void("http://www.w3.org/1999/xhtml"===t.namespaceURI&&e._sanitizeLinkTargets(t));if("http://www.w3.org/1999/xhtml"!==t.namespaceURI||"_blank"!==(null===(i=t.getAttribute("target"))||void 0===i?void 0:i.toLowerCase()))return void t.removeAttribute("target");const s=(t.getAttribute("rel")||"").split(/\s+/).filter(e=>e&&!/^(opener|noopener)$/i.test(e));s.push("noopener"),t.setAttribute("rel",s.join(" "))})}_applyTransforms(t,i,s){this._is_bot()?e._logInfo(Qh):"control"!==i?s.forEach(s=>{if(s.selector){var n;e._logInfo(`applying transform of variant ${i} for experiment ${t} `,s);const r=null===(n=document)||void 0===n?void 0:n.querySelectorAll(s.selector);if(!(null==r?void 0:r.length))return void e._logWarn(`no element on this page matches selector ${s.selector} of variant ${i} for experiment ${t}`);const o=new Map;null==r||r.forEach(t=>{if("script"===t.localName.toLowerCase())return;const i=t;if(s.html){var n;const a="http://www.w3.org/1998/Math/MathML"===t.namespaceURI&&"annotation-xml"===t.localName&&(null===(n=t.getAttribute("encoding"))||void 0===n?void 0:n.toLowerCase())||"",l=JSON.stringify([t.namespaceURI,t.localName,a]);let c=o.get(l);if(wt(c)){var r;const i=null!==(r=Yh)&&void 0!==r?r:Yh=Kh(),n=t.ownerDocument.implementation.createHTMLDocument(""),u=n.createElementNS(t.namespaceURI,t.localName);a&&u.setAttribute("encoding",a);const d=n.createRange();d.selectNodeContents(u);const h="http://www.w3.org/2000/svg"===t.namespaceURI&&/^(foreignObject|desc|title)$/.test(t.localName)||/^(text\/html|application\/xhtml\+xml)$/.test(a)?"http://www.w3.org/1999/xhtml":t.namespaceURI,_=d.createContextualFragment(s.html);"http://www.w3.org/1998/Math/MathML"===t.namespaceURI&&/^(mi|mo|mn|ms|mtext)$/.test(t.localName)?(u.appendChild(_),i.sanitize(u,as(as({},Jh),{},{NAMESPACE:h||void 0,IN_PLACE:!0}))):("http://www.w3.org/1999/xhtml"===u.namespaceURI&&"template"===u.localName?u.content:u).appendChild(i.sanitize(_,as(as({},Jh),{},{NAMESPACE:h||void 0,RETURN_DOM_FRAGMENT:!0}))),e._sanitizeLinkTargets(u),c=u.innerHTML,o.set(l,c)}i.innerHTML=c}s.css&&i.setAttribute("style",s.css)})}}):e._logInfo("Control variants leave the page unmodified.")}_is_bot(){return Ve&&this._instance?Tc(Ve,this._config.custom_blocked_useragents):void 0}},featureFlags:Fd},{conversations:class{constructor(e){this._instance=e,this._isConversationsEnabled=void 0,this._conversationsManager=null,this._isInitializing=!1,this._remoteConfig=null,this._loadFailed=!1,this._resetGeneration=0,this._pendingPanelAction=null,this._theme=null}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(this._instance.config.disable_conversations)return void(this._pendingPanelAction=null);if(this._remoteConfigSuccessful=e.ok,!e.ok)return;const t=e.config.conversations;wt(t)?this._pendingPanelAction=null:(kt(t)?this._isConversationsEnabled=t:(this._isConversationsEnabled=t.enabled,this._remoteConfig=t),this._isConversationsEnabled||(this._pendingPanelAction=null),this.loadIfEnabled())}reset(){var e;null===(e=this._conversationsManager)||void 0===e||e.reset(),this._conversationsManager=null,this._resetGeneration++,this._isConversationsEnabled=void 0,this._remoteConfig=null,this._remoteConfigSuccessful=void 0,this._loadFailed=!1,this._pendingPanelAction=null}loadIfEnabled(){if(this._conversationsManager)return;if(this._isInitializing)return;if(this._instance.config.disable_conversations)return;if(zr(this._instance.config))return;if(this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())return;const e=null==tt?void 0:tt.__PosthogExtensions__;if(e&&!vt(this._isConversationsEnabled)&&this._isConversationsEnabled)if(this._remoteConfig&&this._remoteConfig.token){this._isInitializing=!0;try{const t=e.initConversations;if(t)return this._completeInitialization(t),void(this._isInitializing=!1);const i=e.loadExternalDependency;if(!i)return void this._handleLoadError(S);const s=this._resetGeneration;i(this._instance,"conversations",t=>{if(s!==this._resetGeneration)return this._isInitializing=!1,void this.loadIfEnabled();t||!e.initConversations?this._handleLoadError("Could not load conversations script",t):this._completeInitialization(e.initConversations),this._isInitializing=!1})}catch(e){this._handleLoadError("Error initializing conversations",e),this._isInitializing=!1}}else Zh.error("Conversations enabled but missing token in remote config.")}_completeInitialization(e){if(this._remoteConfig){try{this._conversationsManager=e(this._remoteConfig,this._instance),this._loadFailed=!1,Zh.info("Conversations loaded successfully")}catch(e){return void this._handleLoadError("Error completing conversations initialization",e)}this._theme&&this._conversationsManager.setTheme(this._theme),this._applyPendingPanelAction()}else Zh.error("Cannot complete initialization: remote config is null")}_applyPendingPanelAction(){const e=this._pendingPanelAction;this._pendingPanelAction=null,this._conversationsManager&&e&&("open"===e?this._conversationsManager.open():this._conversationsManager.close())}_handleLoadError(e,t){Zh.error(e,t),this._conversationsManager=null,this._isInitializing=!1,this._loadFailed=!0}show(){this._conversationsManager?this._conversationsManager.show():Zh.warn("Conversations not loaded yet.")}hide(){"open"===this._pendingPanelAction&&(this._pendingPanelAction=null),this._conversationsManager&&this._conversationsManager.hide()}open(){this._conversationsManager?(this._pendingPanelAction=null,this._conversationsManager.open()):this._pendingPanelAction="open"}close(){this._conversationsManager?(this._pendingPanelAction=null,this._conversationsManager.close()):this._pendingPanelAction="close"}setTheme(e){var t,i;this._theme=as(as(as({},this._theme),e),{},{dark:as(as({},null===(t=this._theme)||void 0===t?void 0:t.dark),null==e?void 0:e.dark)}),null===(i=this._conversationsManager)||void 0===i||i.setTheme(e)}isAvailable(){return!0===this._isConversationsEnabled&&!bt(this._conversationsManager)}getUnavailableReason(){return this.isAvailable()?null:this._instance.config.disable_conversations?"disabled_by_config":zr(this._instance.config)?"disabled_for_toolbar":this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut()?"consent_opted_out":!1===this._remoteConfigSuccessful?"remote_config_failed":vt(this._isConversationsEnabled)?this._remoteConfigSuccessful?"disabled_in_project":"remote_config_pending":this._isConversationsEnabled?wt(this._remoteConfig)||!this._remoteConfig.token?"missing_token":(null==tt?void 0:tt.__PosthogExtensions__)?this._isInitializing?"initializing":this._loadFailed?"load_failed":"not_loaded":"extensions_unavailable":"disabled_in_project"}isVisible(){var e,t;return null!==(e=null===(t=this._conversationsManager)||void 0===t?void 0:t.isVisible())&&void 0!==e&&e}sendMessage(e,t,i){var s=this;return Ot(function*(){return s._conversationsManager?s._conversationsManager.sendMessage(e,t,i):(Zh.warn(e_),null)})()}getMessages(e,t){var i=this;return Ot(function*(){return i._conversationsManager?i._conversationsManager.getMessages(e,t):(Zh.warn(e_),null)})()}markAsRead(e){var t=this;return Ot(function*(){return t._conversationsManager?t._conversationsManager.markAsRead(e):(Zh.warn(e_),null)})()}getTickets(e){var t=this;return Ot(function*(){return t._conversationsManager?t._conversationsManager.getTickets(e):(Zh.warn(e_),null)})()}requestRestoreLink(e){var t=this;return Ot(function*(){return t._conversationsManager?t._conversationsManager.requestRestoreLink(e):(Zh.warn(e_),null)})()}restoreFromToken(e){var t=this;return Ot(function*(){return t._conversationsManager?t._conversationsManager.restoreFromToken(e):(Zh.warn(e_),null)})()}restoreFromUrlToken(){var e=this;return Ot(function*(){return e._conversationsManager?e._conversationsManager.restoreFromUrlToken():(Zh.warn(e_),null)})()}getCurrentTicketId(){var e,t;return null!==(e=null===(t=this._conversationsManager)||void 0===t?void 0:t.getCurrentTicketId())&&void 0!==e?e:null}getWidgetSessionId(){var e,t;return null!==(e=null===(t=this._conversationsManager)||void 0===t?void 0:t.getWidgetSessionId())&&void 0!==e?e:null}_onIdentityChanged(){var e;null===(e=this._conversationsManager)||void 0===e||e.setIdentity()}_onIdentityCleared(){var e;null===(e=this._conversationsManager)||void 0===e||e.clearIdentity()}}},{logs:class extends l_{constructor(e){super({get(){var t;return null==e||null===(t=e.config)||void 0===t?void 0:t.logs},captureHintKey:W,get remoteConfigWillArrive(){var t,i;return!(null===(t=e._shouldDisableFlags)||void 0===t?void 0:t.call(e))||!!(null===(i=tt._POSTHOG_REMOTE_CONFIG)||void 0===i||null===(i=i[e.config.token])||void 0===i?void 0:i.config)}},()=>function(e){var t;const i={};if(i.distinctId=e.get_distinct_id(),e.sessionManager){const{sessionId:t,windowId:s,sessionStartTimestamp:n,lastActivityTimestamp:r}=e.sessionManager.checkAndGetSessionAndWindowId(!0);i.sessionId=t,i.windowId=s,wt(n)||(i.sessionStartTimestamp=n),wt(r)||(i.lastActivityTimestamp=r)}if((null==tt||null===(t=tt.location)||void 0===t?void 0:t.href)&&(i.currentUrl=e.config.disable_capture_url_hashes?Zi(tt.location.href):tt.location.href),e.featureFlags){const t=e.featureFlags.getFlags();t&&t.length>0&&(i.activeFeatureFlags=t)}return i}(e)),this._instance=e,this.name=cu,this._listenForReconnect()}get _isRequestReady(){return this._instance.__loaded}_getConsoleLoader(){const e=Fr("[logs]"),t=null==tt?void 0:tt.__PosthogExtensions__;if(!t)return void e.error("PostHog Extensions not found.");const i=t.loadExternalDependency;if(i)return e=>{i(this._instance,"logs",i=>{const s=t.logs;e(i,(null==s?void 0:s.initializeLogs)?{initialize:e=>s.initializeLogs(e),replay(e,t){var i;return null===(i=s.replayConsoleBuffer)||void 0===i?void 0:i.call(s,e,t)}}:void 0)})};e.error(S)}}},{metrics:class{constructor(e){this._instance=e,this._logger=Fr("[metrics]"),this._disposed=!1}initialize(){this.onConfigChange()}onConfigChange(){var e;if(this._disposed)return;const t=!!(null===(e=this._instance.config.metrics)||void 0===e?void 0:e.network);t&&!this._stopNetworkMetrics?this._stopNetworkMetrics=(e=>{let t=!0;const i=()=>t?(e=>{var t;const i=null===(t=e.config.metrics)||void 0===t?void 0:t.network;return!0===i?{}:i||void 0})(e):void 0,s=g_(e,i),n=f_(e,i);return()=>{t=!1,s(),n()}})(this._instance):!t&&this._stopNetworkMetrics&&(this._stopNetworkMetrics(),this._stopNetworkMetrics=void 0)}_getCore(){var e;if(this._disposed)return;const t=null===(e=this._instance)||void 0===e||null===(e=e.config)||void 0===e?void 0:e.metrics;var i;return this._core&&this._resolvedFrom===t||(null===(i=this._core)||void 0===i||i.reset(),this._resolvedFrom=t,this._core=new Cr(this._createHost(),function(e){var t,i,s,n,r;const o=null==e?void 0:e.resourceAttributes;return{serviceName:null!==(t=null==o?void 0:o["service.name"])&&void 0!==t?t:null==e?void 0:e.serviceName,serviceVersion:null!==(i=null==o?void 0:o["service.version"])&&void 0!==i?i:null==e?void 0:e.serviceVersion,environment:null!==(s=null==o?void 0:o["deployment.environment"])&&void 0!==s?s:null==e?void 0:e.environment,resourceAttributes:o,beforeSend:null==e?void 0:e.beforeSend,flushIntervalMs:null!==(n=null==e?void 0:e.flushIntervalMs)&&void 0!==n?n:1e4,maxSeriesPerFlush:null!==(r=null==e?void 0:e.maxSeriesPerFlush)&&void 0!==r?r:1e3}}(t),this._logger)),this._core}count(e,t=1,i){var s;null===(s=this._getCore())||void 0===s||s.count(e,t,i)}gauge(e,t,i){var s;null===(s=this._getCore())||void 0===s||s.gauge(e,t,i)}histogram(e,t,i){var s;null===(s=this._getCore())||void 0===s||s.histogram(e,t,i)}flush(e){if(!this._core)return Promise.resolve();if(e){const t=this._core.drainWindow();return t&&this._sendMetricsBatch(t,e),Promise.resolve()}return this._core.flush().catch(e=>this._logger.error("PostHog metrics flush failed:",e))}reset(){var e;null===(e=this._core)||void 0===e||e.reset()}dispose(){var e,t;this._disposed=!0,null===(e=this._stopNetworkMetrics)||void 0===e||e.call(this),this._stopNetworkMetrics=void 0,null===(t=this._core)||void 0===t||t.reset()}_createHost(){const e=this._instance,t=this;return{get isDisabled(){return!1},get optedOut(){return!e.is_capturing()},_sendMetricsBatch:e=>t._sendMetricsBatch(e),getLibraryId:()=>i.LIB_NAME,getLibraryVersion:()=>i.LIB_VERSION}}_sendMetricsBatch(e,t){return new Promise(i=>{let s=!1;const n=e=>{s||(s=!0,clearTimeout(r),i(e))},r=setTimeout(()=>n({kind:"retry-later",error:new Error("metrics request timed out")}),9e4);this._instance._send_request(as(as({method:"POST",url:this._metricsUrl(),data:e,compression:"best-available",batchKey:"metrics"},t&&{transport:t}),{},{fireCallbackOnDrop:!0,callback(e){const t=e.statusCode;if(t>=200&&300>t)n({kind:"ok"});else if(413===t)n({kind:"too-large"});else if(0!==t&&408!==t&&429!==t&&500>t)n({kind:"fatal",error:new Error(`metrics request failed with status ${t}`)});else{var i;n({kind:"retry-later",error:null!==(i=e.error)&&void 0!==i?i:new Error(`metrics request failed with status ${t}`)})}}}))})}_metricsUrl(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}}},{webMCP:class{constructor(e){this._instance=e,this._isPatched=!1}initialize(){this.startIfEnabled()}startIfEnabled(){if(!this._instance.config.capture_webmcp||this._isPatched)return;const e=null==Ge?void 0:Ge.modelContext;if(!e||!pt(e.registerTool))return;const t=v_.get(e);if(t)return t.instances.add(this._instance),void(this._isPatched=!0);const i={instances:new Set([this._instance])},s=e.registerTool,n=this;Hu(e,"registerTool",e=>{const t=e;return function(e,...s){let r=e;try{r=n._wrapTool(e,i)}catch(i){return t.call(this,e,...s)}return t.call(this,r,...s)}}),e.registerTool!==s&&(v_.set(e,i),this._isPatched=!0)}_wrapTool(e,t){if(!e||!pt(e.execute))return e;const i=e.execute,s=this,{tool:n,injected:r}=function(e,t){const i={intent:!1,model:!1},s=e.inputSchema;if(!function(e){return!!vt(e)||gt(e)&&Object.keys(e).every(e=>m_.has(e)||e.startsWith("x-"))&&!0!==e.additionalProperties&&!gt(e.additionalProperties)&&(!e.type||"object"===e.type)&&(!e.properties||gt(e.properties))&&(!e.required||_t(e.required))}(s))return{tool:C_(e),injected:i};const n=(null==s?void 0:s.properties)||{},r=e=>S_(n,e)||_t(null==s?void 0:s.required)&&s.required.includes(e);if(i.intent=t.intent&&!r("context"),i.model=t.model&&!r("llm_model"),!i.intent&&!i.model)return{tool:C_(e),injected:i};const o=as({},n),a=_t(null==s?void 0:s.required)?[...s.required]:[];return i.intent&&(o.context={type:"string",description:'Explain why this tool is called and how it supports the user\'s goal. Describe the abstract purpose only. Do not include personal or identifying information. Generalize specific entities as roles such as "a customer".'},a.includes("context")||a.push("context")),i.model&&(o.llm_model={type:"string",description:'The model identifier you are running as, for example "claude-opus-4-8" or "gpt-5.2". Pass "unknown" if you are not certain. Recorded for the site developer\'s analytics.'},a.includes("llm_model")||a.push("llm_model")),{tool:C_(e,as(as({},s),{},{type:(null==s?void 0:s.type)||"object",properties:o,required:a})),injected:i}}(e,function(e){const t={intent:!1,model:!1};for(const i of e.instances){const e=w_(i.config.capture_webmcp);t.intent||(t.intent=!0===(null==e?void 0:e.intent)),t.model||(t.model=!0===(null==e?void 0:e.model))}return t}(t));return Object.defineProperty(n,"execute",{configurable:!0,enumerable:!0,writable:!0,value(...o){const a=new Date,l=function(e,t){if(!gt(e))return{};try{const i=t.intent?k_(e.context,2048,!0):void 0,s=t.model?k_(e.llm_model,256):void 0;return as(as({},i&&"{}"!==i?{intent:i}:{}),s&&"unknown"!==s.toLowerCase()?{model:s}:{})}catch(e){return{}}}(o[0],r),c=function(e,t){const i=e[0];if(!gt(i))return e;try{const s=t.intent&&S_(i,"context"),n=t.model&&S_(i,"llm_model");if(!s&&!n)return e;const r=as({},i);return s&&delete r.context,n&&delete r.llm_model,[r,...e.slice(1)]}catch(t){return e}}(o,r);let u;try{u=i.apply(this===n?e:this,c)}catch(e){throw s._captureToolCall(t,n,a,{error:e,errorResult:!1},l),e}if((d=u)&&"function"==typeof d.then)return Promise.resolve(u).then(e=>{const i=E_(e)?{error:e,errorResult:!0}:void 0;return s._captureToolCall(t,n,a,i,l),e},e=>{throw s._captureToolCall(t,n,a,{error:e,errorResult:!1},l),e});var d;const h=E_(u)?{error:u,errorResult:!0}:void 0;return s._captureToolCall(t,n,a,h,l),u}}),n}_captureToolCall(e,t,i,s,n){const r=Date.now()-i.getTime();let o;for(const l of e.instances){var a;const e=w_(l.config.capture_webmcp);if(e){s&&!o&&(o=T_(s.error,s.errorResult));try{l.capture("$mcp_tool_call",as(as(as({$mcp_source:"posthog_mcp_analytics",$mcp_interface:"webmcp",$mcp_tool_name:t.name,$mcp_resource_name:t.name,$mcp_tool_description:t.description,$mcp_server_name:null==Ke?void 0:Ke.hostname,$mcp_duration_ms:r,$mcp_is_error:!!s},o?{$mcp_error_type:o.type,$mcp_error_message:o.message}:{}),e.intent&&n.intent?{$mcp_intent:n.intent,$mcp_intent_source:"context_parameter"}:{}),e.model&&n.model?{$mcp_llm_model:n.model,$mcp_llm_model_source:"self_reported"}:{}),{timestamp:i})}catch(e){continue}if(s&&o&&l.exceptions&&(null===(a=l.exceptionObserver)||void 0===a?void 0:a.isEnabled))try{const e={$exception_list:I_(l.exceptions,s,o.message),$exception_level:"error",$exception_source:"mcp.tool_call",$mcp_interface:"webmcp",$mcp_tool_name:t.name,$mcp_resource_name:t.name,$mcp_tool_description:t.description,$mcp_server_name:null==Ke?void 0:Ke.hostname};l.exceptionObserver.captureException(e)}catch(e){}}}}}})),function(){i.SDK_DIST_CHANNEL="cdn";const e=tt.posthog;if(e&&!_t(e._i)&&pt(e.init))return;const t=pu[Iu]=new Lu;if(e){const i=[];Rr(e._i,function(s){if(s&&_t(s)){const n=t.init(s[0],s[1],s[2]),r=e[s[2]]||e;n.__loaded&&-1===i.indexOf(r)&&(i.push(r),n._execute_array.call(n.people,r.people),n._execute_array(r))}});const s=e.people;if(!t.__loaded&&_t(e)){const i=t.init;let n=!0;t.init=(r,o,a)=>{const l=i.call(t,r,o,a);return n&&l===t&&l.__loaded&&(n=!1,t.init=i,l._execute_array.call(l.people,s),l._execute_array(e)),l}}}t.__SV=1,tt.posthog=t,function(){function e(){e.done||(e.done=!0,vc=!1,Rr(pu,function(e){e._dom_loaded()}))}(null==Ge?void 0:Ge.addEventListener)?"complete"===Ge.readyState?e():Br(Ge,"DOMContentLoaded",e,{capture:!1}):je&&Ir.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}()}()}();
|
|
2
2
|
//# sourceMappingURL=array.no-external.js.map
|