posthog-js 1.391.7 → 1.391.8
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/array.full.es5.js +1 -1
- package/dist/array.full.js +1 -1
- package/dist/array.full.no-external.js +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/default-extensions.js +1 -1
- package/dist/extension-bundles.js +1 -1
- package/dist/lazy-recorder.js +1 -1
- package/dist/main.js +1 -1
- package/dist/module.full.js +1 -1
- package/dist/module.full.no-external.js +1 -1
- package/dist/module.js +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.js +1 -1
- package/dist/product-tours-preview.d.ts +4576 -3
- package/dist/product-tours-preview.js +1 -1
- package/dist/product-tours-preview.js.map +1 -1
- package/dist/product-tours.js +1 -1
- package/dist/product-tours.js.map +1 -1
- package/dist/src/extensions/product-tours/preview.d.ts +3 -1
- package/dist/src/extensions/product-tours/product-tours-utils.d.ts +2 -1
- package/lib/package.json +1 -1
- package/lib/src/extensions/product-tours/preview.d.ts +3 -1
- package/lib/src/extensions/product-tours/preview.js +2 -2
- package/lib/src/extensions/product-tours/preview.js.map +1 -1
- package/lib/src/extensions/product-tours/product-tours-utils.d.ts +2 -1
- package/lib/src/extensions/product-tours/product-tours-utils.js +2 -2
- package/lib/src/extensions/product-tours/product-tours-utils.js.map +1 -1
- package/lib/src/extensions/product-tours/product-tours.js +6 -6
- package/lib/src/extensions/product-tours/product-tours.js.map +1 -1
- package/package.json +4 -4
- package/react/dist/esm/index.js +9 -1
- package/react/dist/esm/index.js.map +1 -1
- package/react/dist/esm/slim/index.js +9 -1
- package/react/dist/esm/slim/index.js.map +1 -1
- package/react/dist/umd/index.js +9 -1
- package/react/dist/umd/index.js.map +1 -1
- package/react/dist/umd/slim/index.js +9 -1
- package/react/dist/umd/slim/index.js.map +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(){"use strict";function e(e,t,i,r,s,n,o){try{var a=e[n](o),l=a.value}catch(e){return void i(e)}a.done?t(l):Promise.resolve(l).then(r,s)}function t(t){return function(){var i=this,r=arguments;return new Promise((function(s,n){var o=t.apply(i,r);function a(t){e(o,s,n,a,l,"next",t)}function l(t){e(o,s,n,a,l,"throw",t)}a(void 0)}))}}function i(){return i=Object.assign?Object.assign.bind():function(e){for(var t=1;arguments.length>t;t++){var i=arguments[t];for(var r in i)({}).hasOwnProperty.call(i,r)&&(e[r]=i[r])}return e},i.apply(null,arguments)}function r(e,t){if(null==e)return{};var i={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;i[r]=e[r]}return i}var s="1.391.7",n={DEBUG:!1,LIB_VERSION:s,LIB_NAME:"web",JS_SDK_VERSION:s},o="$people_distinct_id",a="$device_id",l="__alias",u="__timers",c="$autocapture_disabled_server_side",d="$heatmaps_enabled_server_side",_="$exception_capture_enabled_server_side",h="$error_tracking_suppression_rules",p="$error_tracking_capture_extension_exceptions",g="$web_vitals_enabled_server_side",v="$dead_clicks_enabled_server_side",f="$product_tours_enabled_server_side",m="$web_vitals_allowed_metrics",y="$session_recording_remote_config",b="$replay_sample_rate",w="$replay_override_sampling",x="$replay_override_linked_flag",S="$replay_override_url_trigger",E="$replay_override_event_trigger",k="$sesid",P="$session_is_sampled",I="$enabled_feature_flags",C="$active_feature_flags",F="$early_access_features",T="$feature_flag_details",R="$feature_flag_payloads",L="$feature_flag_request_id",M="$override_feature_flags",A="$override_feature_flag_payloads",O="$stored_person_properties",D="$stored_group_properties",q="$surveys",B="$surveys_loaded_at",z="$surveys_activated",H="ph_product_tours",N="$flag_call_reported",j="$flag_call_reported_session_id",U="$feature_flag_errors",W="$feature_flag_evaluated_at",V="$user_state",G="$client_session_props",K="$capture_rate_limit",Q="$initial_campaign_params",J="$initial_referrer_info",Y="$initial_person_info",X="$epp",Z="__POSTHOG_TOOLBAR__",ee="$posthog_cookieless",te="$sdk_debug_extensions_init_method",ie="$sdk_debug_extensions_init_time_ms",re="$sdk_debug_recording_script_not_loaded",se="PostHog loadExternalDependency extension not found.",ne="on_reject",oe="always",ae="anonymous",le="identified",ue="identified_only",ce="visibilitychange",de="beforeunload",_e="$pageview",he="$pageleave",pe="$identify",ge="$groupidentify",ve="undefined"!=typeof window?window:void 0,fe="undefined"!=typeof globalThis?globalThis:ve;"undefined"==typeof self&&(fe.self=fe),"undefined"==typeof File&&(fe.File=function(){});var me=null==fe?void 0:fe.navigator,ye=null==fe?void 0:fe.document,be=null==fe?void 0:fe.location,we=null==fe?void 0:fe.fetch,xe=null!=fe&&fe.XMLHttpRequest&&"withCredentials"in new fe.XMLHttpRequest?fe.XMLHttpRequest:void 0,Se=null==fe?void 0:fe.AbortController,Ee=null==fe?void 0:fe.CompressionStream,ke=null==me?void 0:me.userAgent,Pe=null!=ve?ve:{},Ie=e=>{if("string"!=typeof e)return e;try{return JSON.parse(e)}catch(t){return e}};function Ce(e){return"string"==typeof e||e}function Fe(e){return"string"==typeof e?e:void 0}var Te,Re=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.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.SurveyLastSeenDate="survey_last_seen_date",e.SurveysSeen="surveys_seen",e.Surveys="surveys",e.RemoteConfig="remote_config",e.FlagsEndpointWasHit="flags_endpoint_was_hit",e.DeviceId="device_id",e}({}),Le=function(e){return e.GZipJS="gzip-js",e.Base64="base64",e}({}),Me=["$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"],$e=["token"],Ae="NativeGzipValidationError",Oe=e=>e.length>=2&&31===e[0]&&139===e[1],De=e=>!(!e||"object"!=typeof e)&&"NotReadableError"===("name"in e?String(e.name):""),qe=e=>{var t=new Error("Native gzip produced invalid output: "+e);throw t.name=Ae,t},Be=function(){var e=t((function*(e,t){18>e.size&&qe("too-short");var i=new Uint8Array(yield e.slice(0,10).arrayBuffer());Oe(i)&&8===i[2]||qe("invalid-header");var r=new DataView(yield e.slice(e.size-8).arrayBuffer());r.getUint32(0,!0)!==(e=>{for(var t=(()=>{if(Te)return Te;Te=[];for(var e=0;256>e;e++){for(var t=e,i=0;8>i;i++)t=1&t?3988292384^t>>>1:t>>>1;Te[e]=t>>>0}return Te})(),i=4294967295,r=0;e.length>r;r++)i=t[255&(i^e[r])]^i>>>8;return(4294967295^i)>>>0})(t)&&qe("invalid-crc");var s=t.length>>>0;r.getUint32(4,!0)!==s&&qe("invalid-size")}));return function(t,i){return e.apply(this,arguments)}}();function ze(){return ze=t((function*(e,i,r){void 0===i&&(i=!0);try{var s=(new TextEncoder).encode(e),n=new CompressionStream("gzip"),o=n.writable.getWriter(),a=o.write(s).then((()=>o.close())).catch(function(){var e=t((function*(e){try{yield o.abort(e)}catch(e){}throw e}));return function(t){return e.apply(this,arguments)}}()),l=new Response(n.readable).blob(),[u]=yield Promise.all([l,a]);return yield Be(u,s),u}catch(e){if(null!=r&&r.rethrow)throw e;return i&&console.error("Failed to gzip compress data",e),null}})),ze.apply(this,arguments)}var He=["amazonbot","amazonproductbot","app.hypefactors.com","applebot","archive.org_bot","awariobot","backlinksextendedbot","baiduspider","bingbot","bingpreview","chrome-lighthouse","dataforseobot","deepscan","duckduckbot","facebookexternal","facebookcatalog","http://yandex.com/bots","hubspot","ia_archiver","leikibot","linkedinbot","meta-externalagent","mj12bot","msnbot","nessus","petalbot","pinterest","prerender","rogerbot","screaming frog","sebot-wa","sitebulb","slackbot","slurp","trendictionbot","turnitin","twitterbot","vercel-screenshot","vercelbot","yahoo! slurp","yandexbot","zoombot","bot.htm","bot.php","(bot;","bot/","crawler","ahrefsbot","ahrefssiteaudit","semrushbot","siteauditbot","splitsignalbot","gptbot","oai-searchbot","chatgpt-user","perplexitybot","better uptime bot","sentryuptimebot","uptimerobot","headlesschrome","cypress","google-hoteladsverifier","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleother","google-cloudvertexbot","googleweblight","mediapartners-google","storebot-google","google-inspectiontool","bytespider"],Ne=function(e,t){if(void 0===t&&(t=[]),!e)return!1;var i=e.toLowerCase();return He.concat(t).some((e=>{var t=e.toLowerCase();return-1!==i.indexOf(t)}))};function je(e,t){return-1!==e.indexOf(t)}var Ue=function(e){return e.trim()},We=function(e){return e.replace(/^\$/,"")},Ve=Object.prototype,Ge=Ve.hasOwnProperty,Ke=Ve.toString,Qe=Array.isArray||function(e){return"[object Array]"===Ke.call(e)},Je=e=>"function"==typeof e,Ye=e=>e===Object(e)&&!Qe(e),Xe=e=>{if(Ye(e)){for(var t in e)if(Ge.call(e,t))return!1;return!0}return!1},Ze=e=>void 0===e,et=e=>"[object String]"==Ke.call(e),tt=e=>et(e)&&0===e.trim().length,it=e=>null===e,rt=e=>Ze(e)||it(e),st=e=>"[object Number]"==Ke.call(e)&&e==e,nt=e=>st(e)&&e>0,ot=e=>"[object Boolean]"===Ke.call(e),at=e=>e instanceof FormData,lt=e=>je(Me,e),ut=e=>je($e,e);function ct(e){return null===e||"object"!=typeof e}function dt(e,t){return{}.toString.call(e)==="[object "+t+"]"}function _t(e){return"undefined"!=typeof Event&&function(e,t){try{return e instanceof t}catch(e){return!1}}(e,Event)}var ht=[!0,"true",1,"1","yes"],pt=e=>je(ht,e),gt=[!1,"false",0,"0","no"];function vt(e,t,i,r,s){return t>i&&(r.warn("min cannot be greater than max."),t=i),st(e)?e>i?(r.warn(" cannot be greater than max: "+i+". Using max value instead."),i):t>e?(r.warn(" cannot be less than min: "+t+". Using min value instead."),t):e:(r.warn(" must be a number. using max or fallback. max: "+i+", fallback: "+s),vt(s||i,t,i,r))}class ft{constructor(e){this._buckets={},this._onBucketRateLimited=e._onBucketRateLimited,this._bucketSize=vt(e.bucketSize,0,100,e._logger),this._refillRate=vt(e.refillRate,0,this._bucketSize,e._logger),this._refillInterval=vt(e.refillInterval,0,864e5,e._logger)}_applyRefill(e,t){var 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,i=Date.now(),r=String(e),s=this._buckets[r];return s?this._applyRefill(s,i):this._buckets[r]=s={tokens:this._bucketSize,lastAccess:i},0===s.tokens||(s.tokens--,0===s.tokens&&(null==(t=this._onBucketRateLimited)||t.call(this,e)),0===s.tokens)}stop(){this._buckets={}}}var mt="Mobile",yt="iOS",bt="Android",wt="Tablet",xt=bt+" "+wt,St="iPad",Et="Apple",kt=Et+" Watch",Pt="Safari",It="BlackBerry",Ct="Samsung",Ft=Ct+"Browser",Tt=Ct+" Internet",Rt="Chrome",Lt=Rt+" OS",Mt=Rt+" "+yt,$t="Internet Explorer",At=$t+" "+mt,Ot="Opera",Dt=Ot+" Mini",qt="Edge",Bt="Microsoft "+qt,zt="Firefox",Ht=zt+" "+yt,Nt="Nintendo",jt="PlayStation",Ut="Xbox",Wt=bt+" "+mt,Vt=mt+" "+Pt,Gt="Windows",Kt=Gt+" Phone",Qt="Nokia",Jt="Ouya",Yt="Generic",Xt=Yt+" "+mt.toLowerCase(),Zt=Yt+" "+wt.toLowerCase(),ei="Konqueror",ti="Oculus Browser",ii="Vivaldi",ri="Yandex",si="Whale",ni="DuckDuckGo",oi="Pale Moon",ai="Waterfox",li="Brave",ui="Google Search App",ci="(\\d+(\\.\\d+)?)",di=new RegExp("Version/"+ci),_i=new RegExp(Ut,"i"),hi=new RegExp(jt+" \\w+","i"),pi=new RegExp(Nt+" \\w+","i"),gi=new RegExp(It+"|PlayBook|BB10","i"),vi={"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"},fi=function(e,t,i,r){t=t||"";var s=function(e){return null!=e&&e.brave?li:null}(i);return s||(null!=r&&r.detectGoogleSearchApp&&je(e,"GSA/")?ui:je(e," OPR/")&&je(e,"Mini")?Dt:je(e," OPR/")?Ot:gi.test(e)?It:je(e,"IE"+mt)||je(e,"WPDesktop")?At:je(e,"OculusBrowser")?ti:je(e,Ft)?Tt:je(e,qt)||je(e,"Edg/")?Bt:je(e,ii+"/")?ii:je(e,"YaBrowser/")?ri:je(e,si+"/")?si:je(e,ni+"/")||je(e,"Ddg/")?ni:je(e,"FBIOS")?"Facebook "+mt:je(e,"UCWEB")||je(e,"UCBrowser")?"UC Browser":je(e,"CriOS")?Mt:je(e,"CrMo")||je(e,Rt)?Rt:je(e,bt)&&je(e,Pt)?Wt:je(e,"FxiOS")?Ht:je(e.toLowerCase(),ei.toLowerCase())?ei:je(e,li+"/")?li:((e,t)=>t&&je(t,Et)||function(e){return je(e,Pt)&&!je(e,Rt)&&!je(e,bt)}(e))(e,t)?je(e,mt)?Vt:Pt:je(e,"PaleMoon/")?oi:je(e,ai+"/")?ai:je(e,zt)?zt:je(e,"MSIE")||je(e,"Trident/")?$t:je(e,"Gecko")?zt:"")},mi={[At]:[new RegExp("rv:"+ci)],[Bt]:[new RegExp(qt+"?\\/"+ci)],[Rt]:[new RegExp("("+Rt+"|CrMo)\\/"+ci)],[Mt]:[new RegExp("CriOS\\/"+ci)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+ci)],[Pt]:[di],[Vt]:[di],[Ot]:[new RegExp("(Opera|OPR)\\/"+ci)],[zt]:[new RegExp(zt+"\\/"+ci)],[Ht]:[new RegExp("FxiOS\\/"+ci)],[ei]:[new RegExp("Konqueror[:/]?"+ci,"i")],[It]:[new RegExp(It+" "+ci),di],[Wt]:[new RegExp("android\\s"+ci,"i")],[Tt]:[new RegExp(Ft+"\\/"+ci)],[ti]:[new RegExp("OculusBrowser\\/"+ci)],[ii]:[new RegExp(ii+"\\/"+ci)],[ri]:[new RegExp("YaBrowser\\/"+ci)],[si]:[new RegExp(si+"\\/"+ci)],[li]:[new RegExp(li+"\\/"+ci)],[ni]:[new RegExp("(DuckDuckGo|Ddg)\\/"+ci)],[oi]:[new RegExp("PaleMoon\\/"+ci)],[ai]:[new RegExp(ai+"\\/"+ci)],[ui]:[new RegExp("GSA\\/"+ci)],[$t]:[new RegExp("(rv:|MSIE )"+ci)],Mozilla:[new RegExp("rv:"+ci)]},yi=function(e,t,i,r){var s=fi(e,t,i,r),n=mi[s];if(Ze(n))return null;for(var o=0;n.length>o;o++){var a=e.match(n[o]);if(a)return parseFloat(a[a.length-2])}return null},bi=[[new RegExp(Ut+"; "+Ut+" (.*?)[);]","i"),e=>[Ut,e&&e[1]||""]],[new RegExp(Nt,"i"),[Nt,""]],[new RegExp(jt,"i"),[jt,""]],[gi,[It,""]],[new RegExp(Gt,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[Kt,""];if(new RegExp(mt).test(t)&&!/IEMobile\b/.test(t))return[Gt+" "+mt,""];var i=/Windows NT ([0-9.]+)/i.exec(t);if(i&&i[1]){var r=vi[i[1]]||"";return/arm/i.test(t)&&(r="RT"),[Gt,r]}return[Gt,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>e&&e[3]?[yt,[e[3],e[4],e[5]||"0"].join(".")]:[yt,""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var t="";return e&&e.length>=3&&(t=Ze(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("("+bt+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+bt+")","i"),e=>e&&e[2]?[bt,[e[2],e[3],e[4]||"0"].join(".")]:[bt,""]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{var t=["Mac OS X",""];return e&&e[1]&&(t[1]=[e[1],e[2],e[3]||"0"].join(".")),t}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[Lt,""]],[/Linux|debian/i,["Linux",""]]],wi=function(e){return pi.test(e)?Nt:hi.test(e)?jt:_i.test(e)?Ut:new RegExp(Jt,"i").test(e)?Jt:new RegExp("("+Kt+"|WPDesktop)","i").test(e)?Kt:/iPad/.test(e)?St:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?kt:gi.test(e)?It:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(Qt,"i").test(e)?Qt:/(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(mt).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)?bt:xt:new RegExp("(pda|"+mt+")","i").test(e)?Xt:new RegExp(wt,"i").test(e)&&!new RegExp(wt+" pc","i").test(e)?Zt:""},xi=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function Si(e,t){return"string"==typeof(i=e)&&xi.test(i)?e:t();var i}function Ei(e,t){var i=setTimeout(e,t);return(null==i?void 0:i.unref)&&(null==i||i.unref()),i}var ki=e=>e instanceof Error,Pi={trace:{text:"TRACE",number:1},debug:{text:"DEBUG",number:5},info:{text:"INFO",number:9},warn:{text:"WARN",number:13},error:{text:"ERROR",number:17},fatal:{text:"FATAL",number:21}},Ii=Pi.info;function Ci(e){if(ot(e))return{boolValue:e};if("number"==typeof e)return Number.isFinite(e)?Number.isInteger(e)?{intValue:e}:{doubleValue:e}:{stringValue:String(e)};if("string"==typeof e)return{stringValue:e};if(Qe(e))return{arrayValue:{values:e.map((e=>Ci(e)))}};try{return{stringValue:JSON.stringify(e)}}catch(t){return{stringValue:String(e)}}}function Fi(e){var t=[];for(var i in e){var r=e[i];it(r)||Ze(r)||t.push({key:i,value:Ci(r)})}return t}function Ti(e,t){var r=e.level||"info",{text:s,number:n}=Pi[r]||Ii,o=String(Date.now())+"000000",a={};t.distinctId&&(a.posthogDistinctId=t.distinctId),t.sessionId&&(a.sessionId=t.sessionId),t.currentUrl&&(a["url.full"]=t.currentUrl),t.screenName&&(a["screen.name"]=t.screenName),t.appState&&(a["app.state"]=t.appState),t.activeFeatureFlags&&t.activeFeatureFlags.length>0&&(a.feature_flags=t.activeFeatureFlags);var l=i({},a,e.attributes||{}),u={timeUnixNano:o,observedTimeUnixNano:o,severityNumber:n,severityText:s,body:{stringValue:e.body},attributes:Fi(l)};return e.trace_id&&(u.traceId=e.trace_id),e.span_id&&(u.spanId=e.span_id),Ze(e.trace_flags)||(u.flags=e.trace_flags),u}function Ri(e,t,r){return i({},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":r})}function Li(e,t,i,r){return{resourceLogs:[{resource:{attributes:Fi(t)},scopeLogs:[{scope:{name:i,version:r},logRecords:e}]}]}}let Mi=class{constructor(e,t,i,r,s,n){var o;void 0===n&&(n=()=>Promise.resolve()),this._instance=e,this._config=t,this._logger=i,this._getContext=r,this._onReady=s,this._waitForStoragePersist=n,this._flushPromise=null,this._evictedSinceAdvance=0,this._consecutiveFlushFailures=0,this._intervalWindowStart=0,this._intervalLogCount=0,this._droppedWarned=!1,this._maxBufferSize=t.maxBufferSize,this._maxQueueSize=Math.max(null!==(o=t.maxQueueSize)&&void 0!==o?o:t.maxBufferSize,t.maxBufferSize),this._flushIntervalMs=t.flushIntervalMs,this._maxBatchRecordsPerPost=t.maxBatchRecordsPerPost,this._rateCapWindowMs=t.rateCapWindowMs,this._maxLogsPerInterval=t.maxLogsPerInterval}reset(){this._clearFlushTimer(),this._flushPromise=null,this._intervalWindowStart=0,this._intervalLogCount=0,this._droppedWarned=!1,this._evictedSinceAdvance=0,this._consecutiveFlushFailures=0,this._maxBatchRecordsPerPost=this._config.maxBatchRecordsPerPost}onReconnect(){this._consecutiveFlushFailures=0,this._flushInBackground()}captureLog(e){if(!this._instance.isDisabled&&!this._instance.optedOut&&null!=e&&e.body){var t=this._runBeforeSend(e);if(null!==t)if(t.body){if(this._checkRateLimit()){var i={record:Ti(t,this._getContext())};this._onReady((()=>this._enqueue(i)))}}else this._logger.info("Log was rejected in beforeSend function")}}_runBeforeSend(e){var t=this._config.beforeSend;if(!t)return e;var i=Qe(t)?t:[t],r=e;for(var s of i)try{var n=s(r);if(!n)return this._logger.info("Log was rejected in beforeSend function"),null;r=n}catch(e){return this._logger.error("Error in beforeSend function for log:",e),null}return r}_checkRateLimit(){if(void 0===this._maxLogsPerInterval)return!0;var 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 t((function*(){if(!e._instance.isDisabled)return e._flushPromise||(e._flushPromise=e._flushInner().finally((()=>{e._flushPromise=null}))),e._flushPromise}))()}_flushInner(){var e=this;return t((function*(){var t;e._clearFlushTimer();var i=null!==(t=e._instance.getPersistedProperty(Re.LogsQueue))&&void 0!==t?t:[];if(0!==i.length)for(var r=i.length,s=0;i.length>0&&r>s;){var n;e._evictedSinceAdvance=0;var o=Math.min(i.length,e._maxBatchRecordsPerPost),a=i.slice(0,o),l=Li(a.map((e=>e.record)),e._buildResourceAttributes(),e._instance.getLibraryId(),e._instance.getLibraryVersion()),u=yield e._instance._sendLogsBatch(l);if("too-large"===u.kind&&a.length>1)e._maxBatchRecordsPerPost=Math.max(1,Math.floor(a.length/2)),e._logger.warn("Received 413 when sending logs batch of size "+a.length+", reducing batch size to "+e._maxBatchRecordsPerPost);else{if("retry-later"===u.kind)throw u.error;if("too-large"===u.kind?e._logger.warn("Dropping a single log record after 413 with batch size 1 — the record is larger than the server cap and cannot be split further."):"ok"===u.kind&&e._config.maxBatchRecordsPerPost>e._maxBatchRecordsPerPost&&(e._maxBatchRecordsPerPost=Math.min(e._config.maxBatchRecordsPerPost,e._maxBatchRecordsPerPost+1)),yield e._persistQueueAdvance(a.length),i=null!==(n=e._instance.getPersistedProperty(Re.LogsQueue))&&void 0!==n?n:[],s+=a.length,"fatal"===u.kind)throw u.error}}}))()}_persistQueueAdvance(e){var i=this;return t((function*(){var t,r=Math.max(0,e-i._evictedSinceAdvance),s=null!==(t=i._instance.getPersistedProperty(Re.LogsQueue))&&void 0!==t?t:[];i._instance.setPersistedProperty(Re.LogsQueue,s.slice(r)),yield i._waitForStoragePersist()}))()}_buildResourceAttributes(){return Ri(this._config,this._instance.getLibraryId(),this._instance.getLibraryVersion())}_enqueue(e){var t;if(!this._instance.optedOut){var i=null!==(t=this._instance.getPersistedProperty(Re.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(Re.LogsQueue,i),this._maxBufferSize>i.length?this._armFlushTimer():this._flushInBackground()}}_armFlushTimer(e){void 0===e&&(e=this._flushIntervalMs),this._flushTimer||(this._flushTimer=Ei((()=>{this._flushTimer=void 0,this._flushInBackground()}),e))}_nextFlushDelay(){var e=Math.min(Math.max(0,this._consecutiveFlushFailures-1),6);return this._flushIntervalMs*Math.pow(2,e)}_hasQueuedRecords(){var e=this._instance.getPersistedProperty(Re.LogsQueue);return!!e&&e.length>0}shutdown(e){var i=this;return t((function*(){i._clearFlushTimer();var t=i.flush().catch((()=>{}));void 0!==e?yield Promise.race([t,new Promise((t=>Ei(t,e)))]):yield t}))()}flushWithTimeout(e){var i=this;return t((function*(){var t=!1,r=i.flush(),s=new Promise((i=>Ei((()=>{t=!0,i()}),e)));try{yield Promise.race([r,s])}finally{t&&r.catch((()=>{}))}}))()}_flushInBackground(){this.flush().then((()=>{this._consecutiveFlushFailures=0}),(e=>{this._consecutiveFlushFailures++,this._logger.error("PostHog logs flush failed:",e)})).finally((()=>{!this._instance.isDisabled&&this._hasQueuedRecords()&&this._armFlushTimer(this._nextFlushDelay())}))}_clearFlushTimer(){this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=void 0)}};var $i,Ai,Oi;function Di(e){var t=globalThis._posthogChunkIds;if(t){var i=Object.keys(t);return Oi&&i.length===Ai||(Ai=i.length,Oi=i.reduce(((i,r)=>{$i||($i={});var s=$i[r];if(s)i[s[0]]=s[1];else for(var n=e(r),o=n.length-1;o>=0;o--){var a=n[o],l=null==a?void 0:a.filename,u=t[r];if(l&&u){i[l]=u,$i[r]=[l,u];break}}return i}),{})),Oi}}class qi{constructor(e,t,i){void 0===i&&(i=[]),this.coercers=e,this.stackParser=t,this.modifiers=i}buildFromUnknown(e,t){void 0===t&&(t={});var i=t&&t.mechanism||{handled:!0,type:"generic"},r=this.buildCoercingContext(i,t,0).apply(e),s=this.buildParsingContext(t),n=this.parseStacktrace(r,s);return{$exception_list:this.convertToExceptionList(n,i),$exception_level:"error"}}modifyFrames(e){var i=this;return t((function*(){for(var t of e)t.stacktrace&&t.stacktrace.frames&&Qe(t.stacktrace.frames)&&(t.stacktrace.frames=yield i.applyModifiers(t.stacktrace.frames));return e}))()}coerceFallback(e){var t;return{type:"Error",value:"Unknown error",stack:null==(t=e.syntheticException)?void 0:t.stack,synthetic:!0}}parseStacktrace(e,t){var r,s;return null!=e.cause&&(r=this.parseStacktrace(e.cause,t)),""!=e.stack&&null!=e.stack&&(s=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?t.skipFirstLines:0),t.chunkIdMap)),i({},e,{cause:r,stack:s})}applyChunkIds(e,t){return e.map((e=>(e.filename&&t&&(e.chunk_id=t[e.filename]),e)))}applyCoercers(e,t){for(var i of this.coercers)if(i.match(e))return i.coerce(e,t);return this.coerceFallback(t)}applyModifiers(e){var i=this;return t((function*(){var t=e;for(var r of i.modifiers)t=yield r(t);return t}))()}convertToExceptionList(e,t){var r,s,n,o={type:e.type,value:e.value,mechanism:{type:null!==(r=t.type)&&void 0!==r?r:"generic",handled:null===(s=t.handled)||void 0===s||s,synthetic:null!==(n=e.synthetic)&&void 0!==n&&n}};e.stack&&(o.stacktrace={type:"raw",frames:e.stack});var a=[o];return null!=e.cause&&a.push(...this.convertToExceptionList(e.cause,i({},t,{handled:!0}))),a}buildParsingContext(e){var t;return{chunkIdMap:Di(this.stackParser),skipFirstLines:null!==(t=e.skipFirstLines)&&void 0!==t?t:1}}buildCoercingContext(e,t,r){void 0===r&&(r=0);var s=(i,r)=>{if(4>=r){var s=this.buildCoercingContext(e,t,r);return this.applyCoercers(i,s)}};return i({},t,{syntheticException:0==r?t.syntheticException:void 0,mechanism:e,apply:e=>s(e,r),next:e=>s(e,r+1)})}}var Bi="?";function zi(e,t,i,r,s){var n={platform:e,filename:t,function:"<anonymous>"===i?Bi:i,in_app:!0};return Ze(r)||(n.lineno=r),Ze(s)||(n.colno=s),n}var Hi=(e,t)=>{var i=-1!==e.indexOf("safari-extension"),r=-1!==e.indexOf("safari-web-extension");return i||r?[-1!==e.indexOf("@")?e.split("@")[0]:Bi,i?"safari-extension:"+t:"safari-web-extension:"+t]:[e,t]},Ni=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,ji=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,Ui=/\((\S*)(?::(\d+))(?::(\d+))\)/,Wi=(e,t)=>{var i=Ni.exec(e);if(i){var[,r,s,n]=i;return zi(t,r,Bi,+s,+n)}var o=ji.exec(e);if(o){if(o[2]&&0===o[2].indexOf("eval")){var a=Ui.exec(o[2]);a&&(o[2]=a[1],o[3]=a[2],o[4]=a[3])}var[l,u]=Hi(o[1]||Bi,o[2]);return zi(t,u,l,o[3]?+o[3]:void 0,o[4]?+o[4]:void 0)}},Vi=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,Gi=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,Ki=(e,t)=>{var i=Vi.exec(e);if(i){if(i[3]&&i[3].indexOf(" > eval")>-1){var r=Gi.exec(i[3]);r&&(i[1]=i[1]||"eval",i[3]=r[1],i[4]=r[2],i[5]="")}var s=i[3],n=i[1]||Bi;return[n,s]=Hi(n,s),zi(t,s,n,i[4]?+i[4]:void 0,i[5]?+i[5]:void 0)}},Qi=/\(error: (.*)\)/;class Ji{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){var i=et(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){var t=e.name||(this.isDOMError(e)?"DOMError":"DOMException");return e.message?t+": "+e.message:t}isDOMException(e){return dt(e,"DOMException")}isDOMError(e){return dt(e,"DOMError")}}class Yi{match(e){return(e=>e instanceof Error)(e)}coerce(e,t){return{type:this.getType(e),value:this.getMessage(e,t),stack:this.getStack(e),cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return e.name||e.constructor.name}getMessage(e,t){var i=e.message;return String(i.error&&"string"==typeof i.error.message?i.error.message:i)}getStack(e){return e.stacktrace||e.stack||void 0}}class Xi{constructor(){}match(e){return dt(e,"ErrorEvent")&&null!=e.error}coerce(e,t){var i;return t.apply(e.error)||{type:"ErrorEvent",value:e.message,stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}}var Zi=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;class er{match(e){return"string"==typeof e}coerce(e,t){var i,[r,s]=this.getInfos(e);return{type:null!=r?r:"Error",value:null!=s?s:e,stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}getInfos(e){var t="Error",i=e,r=e.match(Zi);return r&&(t=r[1],i=r[2]),[t,i]}}var tr=["fatal","error","warning","log","info","debug"];function ir(e,t){void 0===t&&(t=40);var i=Object.keys(e);if(i.sort(),!i.length)return"[object has no keys]";for(var r=i.length;r>0;r--){var s=i.slice(0,r).join(", ");if(t>=s.length)return r===i.length?s:s.length>t?s.slice(0,t)+"...":s}return""}class rr{match(e){return"object"==typeof e&&null!==e}coerce(e,t){var i,r=this.getErrorPropertyFromObject(e);return r?t.apply(r):{type:this.getType(e),value:this.getValue(e),stack:null==(i=t.syntheticException)?void 0:i.stack,level:this.isSeverityLevel(e.level)?e.level:"error",synthetic:!0}}getType(e){return _t(e)?e.constructor.name:"Error"}getValue(e){if("name"in e&&"string"==typeof e.name){var 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;var i=this.getObjectClassName(e);return(i&&"Object"!==i?"'"+i+"'":"Object")+" captured as exception with keys: "+ir(e)}isSeverityLevel(e){return et(e)&&!tt(e)&&tr.indexOf(e)>=0}getErrorPropertyFromObject(e){for(var t in e)if({}.hasOwnProperty.call(e,t)){var i=e[t];if(ki(i))return i}}getObjectClassName(e){try{var t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch(e){return}}}class sr{match(e){return _t(e)}coerce(e,t){var i,r=e.constructor.name;return{type:r,value:r+" captured as exception with keys: "+ir(e),stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}}class nr{match(e){return ct(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.stack,synthetic:!0}}}class or{match(e){return dt(e,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(e)}isCustomEventWrappingRejection(e){if(!_t(e))return!1;try{var t=e.detail;return null!=t&&"object"==typeof t&&"reason"in t}catch(e){return!1}}coerce(e,t){var i,r=this.getUnhandledRejectionReason(e);return ct(r)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(r),stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}:t.apply(r)}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}}var ar="$message",lr="$timestamp",ur=new Set([ar,lr]),cr={enabled:!0,max_bytes:32768};function dr(e){var t;return e?{enabled:null!==(t=e.enabled)&&void 0!==t?t:cr.enabled,max_bytes:hr(e.max_bytes,cr.max_bytes)}:i({},cr)}class _r{constructor(e){this._entries=[],this._totalBytes=0,this._config=dr(e)}setConfig(e){this._config=dr(e),this._trimToMaxBytes()}add(e){var t=function(e){var t=function(e){var t=new WeakSet;try{return JSON.stringify(e,((e,i)=>{if("bigint"==typeof i)return i.toString();if("function"!=typeof i&&"symbol"!=typeof i){if(i instanceof Date)return i.toISOString();if(i instanceof Error)return{name:i.name,message:i.message,stack:i.stack};if(i&&"object"==typeof i){if(t.has(i))return"[Circular]";t.add(i)}return i}}))}catch(e){return}}(e);if(t)try{var i=JSON.parse(t);if(!Ye(i))return;var r=i,s=r[ar],n=r[lr];if(!et(s)||0===s.trim().length)return;if(!et(n)&&!st(n))return;return{step:r,json:t}}catch(e){return}}(e);if(t){var i=function(e){if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e).length;for(var t=encodeURIComponent(e),i=0,r=0;t.length>r;r++)"%"===t[r]?(i+=1,r+=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;){var e=this._entries.shift();e&&(this._totalBytes-=e.bytes)}}}function hr(e,t){if(!st(e)||e===1/0||e===-1/0)return t;var i=Math.floor(e);return 0>i?t:i}var pr=function(e,t){var{debugEnabled:i}=void 0===t?{}:t,r={_log(t){if(ve&&(n.DEBUG||Pe.POSTHOG_DEBUG||i)&&!Ze(ve.console)&&ve.console){for(var r=("__rrweb_original__"in ve.console[t]?ve.console[t].__rrweb_original__:ve.console[t]),s=arguments.length,o=new Array(s>1?s-1:0),a=1;s>a;a++)o[a-1]=arguments[a];r(e,...o)}},debug(){for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];r._log("debug",...t)},info(){for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];r._log("log",...t)},warn(){for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];r._log("warn",...t)},error(){for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];r._log("error",...t)},critical(){for(var t=arguments.length,i=new Array(t),r=0;t>r;r++)i[r]=arguments[r];console.error(e,...i)},uninitializedWarning(e){r.error("You must initialize PostHog before calling "+e)},createLogger:(t,i)=>pr(e+" "+t,i)};return r},gr=pr("[PostHog.js]"),vr=gr.createLogger;function fr(e,t){Qe(e)&&e.forEach(t)}function mr(e,t){if(!rt(e))if(Qe(e))e.forEach(t);else if(at(e))e.forEach(((e,i)=>t(e,i)));else for(var i in e)Ge.call(e,i)&&t(e[i],i)}var yr=function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;t>r;r++)i[r-1]=arguments[r];for(var s of i)for(var n in s)void 0!==s[n]&&(e[n]=s[n]);return e};function br(e){for(var t=Object.keys(e),i=t.length,r=new Array(i);i--;)r[i]=[t[i],e[t[i]]];return r}var wr=function(e){try{return e()}catch(e){return}},xr=function(e){return function(){try{for(var t=arguments.length,i=new Array(t),r=0;t>r;r++)i[r]=arguments[r];return e.apply(this,i)}catch(e){gr.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),gr.critical(e)}}},Sr=function(e){var t={};return mr(e,(function(e,i){(et(e)&&e.length>0||st(e))&&(t[i]=e)})),t};var Er=["herokuapp.com","vercel.app","netlify.app"];function kr(e){var t=null==e?void 0:e.hostname;if(!et(t))return!1;var i=t.split(".").slice(-2).join(".");for(var r of Er)if(i===r)return!1;return!0}function Pr(e,t,i,r){var{capture:s=!1,passive:n=!0}=null!=r?r:{};null==e||e.addEventListener(t,i,{capture:s,passive:n})}function Ir(e){return"ph_toolbar_internal"===e.name}Math.trunc||(Math.trunc=function(e){return 0>e?Math.ceil(e):Math.floor(e)}),Number.isInteger||(Number.isInteger=function(e){return st(e)&&isFinite(e)&&Math.floor(e)===e});class Cr{constructor(e){if(this.bytes=e,16!==e.length)throw new TypeError("not 128-bit length")}static fromFieldsV7(e,t,i,r){if(!Number.isInteger(e)||!Number.isInteger(t)||!Number.isInteger(i)||!Number.isInteger(r)||0>e||0>t||0>i||0>r||e>0xffffffffffff||t>4095||i>1073741823||r>4294967295)throw new RangeError("invalid field value");var s=new Uint8Array(16);return s[0]=e/Math.pow(2,40),s[1]=e/Math.pow(2,32),s[2]=e/Math.pow(2,24),s[3]=e/Math.pow(2,16),s[4]=e/Math.pow(2,8),s[5]=e,s[6]=112|t>>>8,s[7]=t,s[8]=128|i>>>24,s[9]=i>>>16,s[10]=i>>>8,s[11]=i,s[12]=r>>>24,s[13]=r>>>16,s[14]=r>>>8,s[15]=r,new Cr(s)}toString(){for(var e="",t=0;this.bytes.length>t;t++)e=e+(this.bytes[t]>>>4).toString(16)+(15&this.bytes[t]).toString(16),3!==t&&5!==t&&7!==t&&9!==t||(e+="-");if(36!==e.length)throw new Error("Invalid UUIDv7 was generated");return e}clone(){return new Cr(this.bytes.slice(0))}equals(e){return 0===this.compareTo(e)}compareTo(e){for(var t=0;16>t;t++){var i=this.bytes[t]-e.bytes[t];if(0!==i)return Math.sign(i)}return 0}}class Fr{constructor(){this._timestamp=0,this._counter=0,this._random=new Lr}generate(){var e=this.generateOrAbort();if(Ze(e)){this._timestamp=0;var t=this.generateOrAbort();if(Ze(t))throw new Error("Could not generate UUID after timestamp reset");return t}return e}generateOrAbort(){var e=Date.now();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 Cr.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())}}var Tr,Rr=e=>{if("undefined"!=typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var t=0;e.length>t;t++)e[t]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return e};ve&&!Ze(ve.crypto)&&crypto.getRandomValues&&(Rr=e=>crypto.getRandomValues(e));class Lr{constructor(){this._buffer=new Uint32Array(8),this._cursor=1/0}nextUint32(){return this._buffer.length>this._cursor||(Rr(this._buffer),this._cursor=0),this._buffer[this._cursor++]}}var Mr=()=>$r().toString(),$r=()=>(Tr||(Tr=new Fr)).generate(),Ar="",Or=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;var Dr={_is_supported:()=>!!ye,_error(e){gr.error("cookieStore error: "+e)},_get(e){if(ye){try{for(var t=e+"=",i=ye.cookie.split(";").filter((e=>e.length)),r=0;i.length>r;r++){for(var s=i[r];" "==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}},_parse(e){var t;try{t=JSON.parse(Dr._get(e))||{}}catch(e){}return t},_set(e,t,i,r,s){if(!ye)return!1;try{var n="",o="",a=function(e,t){if(t){var i=function(e,t){if(void 0===t&&(t=ye),Ar)return Ar;if(!t)return"";if(["localhost","127.0.0.1"].includes(e))return"";for(var i=e.split("."),r=Math.min(i.length,8),s="dmn_chk_"+Mr();!Ar&&r--;){var n=i.slice(r).join("."),o=s+"=1;domain=."+n+";path=/";t.cookie=o+";max-age=3",t.cookie.includes(s)&&(t.cookie=o+";max-age=0",Ar=n)}return Ar}(e);if(!i){var r=(e=>{var t=e.match(Or);return t?t[0]:""})(e);r!==i&&gr.info("Warning: cookie subdomain discovery mismatch",r,i),i=r}return i?"; domain=."+i:""}return""}(ye.location.hostname,r);if(i){var l=new Date;l.setTime(l.getTime()+864e5*i),n="; expires="+l.toUTCString()}s&&(o="; secure");var u=e+"="+encodeURIComponent(JSON.stringify(t))+n+"; SameSite=Lax; path=/"+a+o;return u.length>3686.4&&gr.warn("cookieStore warning: large cookie, len="+u.length),ye.cookie=u,!0}catch(e){return!1}},_remove(e,t){if(null!=ye&&ye.cookie)try{Dr._set(e,"",-1,t)}catch(e){return}}},qr=null,Br={_is_supported(){if(!it(qr))return qr;var e=!0;if(Ze(ve))e=!1;else try{var t="__mplssupport__";Br._set(t,"xyz"),'"xyz"'!==Br._get(t)&&(e=!1),Br._remove(t)}catch(t){e=!1}return e||gr.error("localStorage unsupported; falling back to cookie store"),qr=e,e},_error(e){gr.error("localStorage error: "+e)},_get(e){try{return null==ve?void 0:ve.localStorage.getItem(e)}catch(e){Br._error(e)}return null},_parse(e){try{return JSON.parse(Br._get(e))||{}}catch(e){}return null},_set(e,t){try{return null==ve||ve.localStorage.setItem(e,JSON.stringify(t)),!0}catch(e){Br._error(e)}return!1},_remove(e){try{null==ve||ve.localStorage.removeItem(e)}catch(e){Br._error(e)}}},zr=[a,"distinct_id",k,P,X,Y,V],Hr={},Nr={_is_supported:()=>!0,_error(e){gr.error("memoryStorage error: "+e)},_get:e=>Hr[e]||null,_parse:e=>Hr[e]||null,_set:(e,t)=>(Hr[e]=t,!0),_remove(e){delete Hr[e]}},jr=null,Ur={_is_supported(){if(!it(jr))return jr;if(jr=!0,Ze(ve))jr=!1;else try{var e="__support__";Ur._set(e,"xyz"),'"xyz"'!==Ur._get(e)&&(jr=!1),Ur._remove(e)}catch(e){jr=!1}return jr},_error(e){gr.error("sessionStorage error: ",e)},_get(e){try{return null==ve?void 0:ve.sessionStorage.getItem(e)}catch(e){Ur._error(e)}return null},_parse(e){try{return JSON.parse(Ur._get(e))||null}catch(e){}return null},_set(e,t){try{return null==ve||ve.sessionStorage.setItem(e,JSON.stringify(t)),!0}catch(e){Ur._error(e)}return!1},_remove(e){try{null==ve||ve.sessionStorage.removeItem(e)}catch(e){Ur._error(e)}}};class Wr{constructor(e){this._instance=e}get _config(){return this._instance.config}get consent(){return this._getDnt()?0:this._storedConsent}isOptedOut(){return this._config.cookieless_mode===oe||this.isRejected()||-1===this.consent&&this._config.cookieless_mode===ne}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return 0===this.consent}isRejected(){return 0===this.consent||-1===this.consent&&this._config.opt_out_capturing_by_default}optInOut(e){this._storage._set(this._storageKey,e?1:0,this._config.cookie_expiration,this._config.cross_subdomain_cookie,this._config.secure_cookie)}reset(){this._storage._remove(this._storageKey,this._config.cross_subdomain_cookie)}get _storageKey(){var{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(){var e=this._storage._get(this._storageKey);return pt(e)?1:je(gt,e)?0:-1}get _storage(){var e=this._config.opt_out_capturing_persistence_type,t="localStorage"===e?Br:Dr;if(!this._persistentStore||this._persistentStore!==t){this._persistentStore=t;var i="localStorage"===e?Dr:Br;i._get(this._storageKey)&&(this._persistentStore._get(this._storageKey)||this.optInOut(pt(i._get(this._storageKey))),i._remove(this._storageKey,this._config.cross_subdomain_cookie))}return this._persistentStore}_getDnt(){return!!this._config.respect_dnt&&[null==me?void 0:me.doNotTrack,null==me?void 0:me.msDoNotTrack,Pe.doNotTrack].some((e=>pt(e)))}}var Vr=1,Gr=3,Kr=11;function Qr(e){return e instanceof Element&&(e.id===Z||!(null==e.closest||!e.closest(".toolbar-global-fade-container")))}function Jr(e){return!!e&&e.nodeType===Vr}function Yr(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function Xr(e){return!!e&&e.nodeType===Gr}function Zr(e){return!!e&&e.nodeType===Kr&&Jr(e.host)}function es(e){return e?Ue(e).split(/\s+/):[]}function ts(e){var t=null==ve?void 0:ve.location.href;return!!(t&&e&&e.some((e=>t.match(e))))}function is(e){var 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 es(t)}function rs(e){return rt(e)?null:Ue(e).split(/(\s+)/).filter((e=>Ps(e))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function ss(e){var t="";return ms(e)&&!ys(e)&&e.childNodes&&e.childNodes.length&&mr(e.childNodes,(function(e){var i;Xr(e)&&e.textContent&&(t+=null!==(i=rs(e.textContent))&&void 0!==i?i:"")})),Ue(t)}function ns(e){return Ze(e.target)?e.srcElement||null:null!=(t=e.target)&&t.shadowRoot?e.composedPath()[0]||null:e.target||null;var t}var os=["a","button","form","input","select","textarea","label"];function as(e,t){if(Ze(t))return!0;var i,r=function(e){if(t.some((t=>function(e,t){var i=e.matches||e.matchesSelector||e.msMatchesSelector||e.mozMatchesSelector||e.webkitMatchesSelector||e.oMatchesSelector;try{return!!i&&i.call(e,t)}catch(e){return!1}}(e,t))))return{v:!0}};for(var s of e)if(i=r(s))return i.v;return!1}function ls(e){var t=e.parentNode;return!(!t||!Jr(t))&&t}var us=[".ph-no-autocapture","[data-ph-no-autocapture]"],cs=["next","previous","prev",">","<"],ds=[...cs,"+","-","−","–"],_s=(e,t)=>/[a-z0-9]/i.test(t)?e.includes(t):e===t,hs=[".ph-no-rageclick",".ph-no-capture"],ps=["","text","search","email","password","url","tel","number"];function gs(e,t){if(!ve||vs(e))return!1;var i,r,s,n,o;if(ot(t)?(i=!!t&&hs,r=void 0,s=!1):(i=null!==(n=null==t?void 0:t.css_selector_ignorelist)&&void 0!==n?n:hs,r=null==t?void 0:t.content_ignorelist,s=null!==(o=null==t?void 0:t.ignore_text_selection)&&void 0!==o&&o),!1===i)return!1;if(s&&function(e){return!(!e||!Jr(e))&&(!!Yr(e,"textarea")||(Yr(e,"input")?je(ps,(e.getAttribute("type")||"").toLowerCase()):function(e){if(e.isContentEditable)return!0;var t=null==e.getAttribute?void 0:e.getAttribute("contenteditable");return"true"===t||""===t}(e)))}(e))return!1;var{targetElementList:a}=fs(e,!1);return!function(e,t){if(!1===e||Ze(e))return!1;var i;if(!0===e)i=cs;else{if(!Qe(e))return!1;if(e.length>10)return gr.error("[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching."),!1;i=e.map((e=>e.toLowerCase()))}return t.some((e=>{var{safeText:t,ariaLabel:r}=e;return i.some((e=>_s(t,e)||_s(r,e)))}))}(r,a.map((e=>{var t;return{safeText:ss(e).toLowerCase(),ariaLabel:(null==(t=e.getAttribute("aria-label"))?void 0:t.toLowerCase().trim())||""}})))&&!as(a,i)}var vs=e=>!e||Yr(e,"html")||!Jr(e),fs=(e,t)=>{if(!ve||vs(e))return{parentIsUsefulElement:!1,targetElementList:[]};for(var i=!1,r=[e],s=e;s.parentNode&&!Yr(s,"body");)if(Zr(s.parentNode))r.push(s.parentNode.host),s=s.parentNode.host;else{var n=ls(s);if(!n)break;if(t||os.indexOf(n.tagName.toLowerCase())>-1)i=!0;else{var o=ve.getComputedStyle(n);o&&"pointer"===o.getPropertyValue("cursor")&&(i=!0)}r.push(n),s=n}return{parentIsUsefulElement:i,targetElementList:r}};function ms(e){for(var t=e;t.parentNode&&!Yr(t,"body");t=t.parentNode){var i=is(t);if(je(i,"ph-sensitive")||je(i,"ph-no-capture"))return!1}if(je(is(e),"ph-include"))return!0;var r=e.type||"";if(et(r))switch(r.toLowerCase()){case"hidden":case"password":return!1}var s=e.name||e.id||"";return!et(s)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(s.replace(/[^a-zA-Z0-9]/g,""))}function ys(e){return!!(Yr(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||Yr(e,"select")||Yr(e,"textarea")||"true"===e.getAttribute("contenteditable"))}var bs="(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})",ws=new RegExp("^(?:"+bs+")$"),xs=new RegExp(bs),Ss="\\d{3}-?\\d{2}-?\\d{4}",Es=new RegExp("^("+Ss+")$"),ks=new RegExp("("+Ss+")");function Ps(e,t){if(void 0===t&&(t=!0),rt(e))return!1;if(et(e)){if(e=Ue(e),(t?ws:xs).test((e||"").replace(/[- ]/g,"")))return!1;if((t?Es:ks).test(e))return!1}return!0}function Is(e){var t=ss(e);return Ps(t=(t+" "+Cs(e)).trim())?t:""}function Cs(e){var t="";return e&&e.childNodes&&e.childNodes.length&&mr(e.childNodes,(function(e){var i;if(e&&"span"===(null==(i=e.tagName)?void 0:i.toLowerCase()))try{var r=ss(e);t=(t+" "+r).trim(),e.childNodes&&e.childNodes.length&&(t=(t+" "+Cs(e)).trim())}catch(e){gr.error("[AutoCapture]",e)}})),t}function Fs(e){return e.replace(/"|\\"/g,'\\"')}function Ts(e){var t=e.attr__class;return t?Qe(t)?t:es(t):void 0}var Rs=vr("[Dead Clicks]"),Ls=()=>!0,Ms=e=>{var t,i=!(null==(t=e.instance.persistence)||!t.get_property(v)),r=e.instance.config.capture_dead_clicks;return ot(r)?r:!!Ye(r)||i};class $s{get lazyLoadedDeadClicksAutocapture(){return this._lazyLoadedDeadClicksAutocapture}constructor(e,t,i){this.instance=e,this.isEnabled=t,this.onCapture=i,this.startIfEnabledOrStop()}onRemoteConfig(e){"captureDeadClicks"in e&&(this.instance.persistence&&this.instance.persistence.register({[v]:e.captureDeadClicks}),this.startIfEnabledOrStop())}startIfEnabledOrStop(){this.isEnabled(this)?this._loadScript((()=>{this._start()})):this.stop()}_loadScript(e){var t,i;null!=(t=Pe.__PosthogExtensions__)&&t.initDeadClicksAutocapture?e():null==(i=Pe.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this.instance,"dead-clicks-autocapture",(t=>{t?Rs.error("failed to load script",t):e()}))}_start(){var e;if(ye){if(!this._lazyLoadedDeadClicksAutocapture&&null!=(e=Pe.__PosthogExtensions__)&&e.initDeadClicksAutocapture){var t=Ye(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};t.__onCapture=this.onCapture,this._lazyLoadedDeadClicksAutocapture=Pe.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this._lazyLoadedDeadClicksAutocapture.start(ye),Rs.info("starting...")}}else Rs.error("`document` not found. Cannot start.")}stop(){this._lazyLoadedDeadClicksAutocapture&&(this._lazyLoadedDeadClicksAutocapture.stop(),this._lazyLoadedDeadClicksAutocapture=void 0,Rs.info("stopping..."))}}var As=vr("[SegmentIntegration]");var Os="posthog-js";function Ds(e,t){var{organization:r,projectId:s,prefix:n,severityAllowList:o=["error"],sendExceptionsToPostHog:a=!0}=void 0===t?{}:t;return t=>{var l,u,c,d,_;if("*"!==o&&!o.includes(t.level)||!e.__loaded)return t;t.tags||(t.tags={});var h=e.requestRouter.endpointFor("ui","/project/"+e.config.token+"/person/"+e.get_distinct_id());t.tags["PostHog Person URL"]=h,e.sessionRecordingStarted()&&(t.tags["PostHog Recording URL"]=e.get_session_replay_url({withTimestamp:!0}));var p,g=(null==(l=t.exception)?void 0:l.values)||[],v=g.map((e=>i({},e,{stacktrace:e.stacktrace?i({},e.stacktrace,{type:"raw",frames:(e.stacktrace.frames||[]).map((e=>i({},e,{platform:"web:javascript"})))}):void 0}))),f={$exception_message:(null==(u=g[0])?void 0:u.value)||t.message,$exception_type:null==(c=g[0])?void 0:c.type,$exception_level:t.level,$exception_list:v,$sentry_event_id:t.event_id,$sentry_exception:t.exception,$sentry_exception_message:(null==(d=g[0])?void 0:d.value)||t.message,$sentry_exception_type:null==(_=g[0])?void 0:_.type,$sentry_tags:t.tags};return r&&s&&(f.$sentry_url=(n||"https://sentry.io/organizations/")+r+"/issues/?project="+s+"&query="+t.event_id),a&&(null==(p=e.exceptions)||p.sendExceptionEvent(f)),t}}class qs{constructor(e,t,i,r,s,n){this.name=Os,this.setupOnce=function(o){o(Ds(e,{organization:t,projectId:i,prefix:r,severityAllowList:s,sendExceptionsToPostHog:null==n||n}))}}}class Bs{constructor(e){this._onSessionIdChange=(e,t,i)=>{i&&(i.noSessionId||i.activityTimeout||i.sessionPastMaximumLength||i.crossTabAdoption)&&(gr.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:e,changeReason:i}),this._currentPageview=void 0,this._instance.scrollManager.resetContext())},this._instance=e,this._setupSessionRotationHandler()}_setupSessionRotationHandler(){var e;this._unsubscribeSessionId=null==(e=this._instance.sessionManager)?void 0:e.onSessionId(this._onSessionIdChange)}destroy(){var e;null==(e=this._unsubscribeSessionId)||e.call(this),this._unsubscribeSessionId=void 0}doPageView(e,t){var i,r=this._previousPageViewProperties(e,t);return this._currentPageview={pathname:null!==(i=null==ve?void 0:ve.location.pathname)&&void 0!==i?i:"",pageViewId:t,timestamp:e},this._instance.scrollManager.resetContext(),r}doPageLeave(e){var t;return this._previousPageViewProperties(e,null==(t=this._currentPageview)?void 0:t.pageViewId)}doEvent(){var e;return{$pageview_id:null==(e=this._currentPageview)?void 0:e.pageViewId}}_previousPageViewProperties(e,t){var i=this._currentPageview;if(!i)return{$pageview_id:t};var r={$pageview_id:t,$prev_pageview_id:i.pageViewId},s=this._instance.scrollManager.getContext();if(s&&!this._instance.config.disable_scroll_properties){var{maxScrollHeight:n,lastScrollY:o,maxScrollY:a,maxContentHeight:l,lastContentY:u,maxContentY:c}=s;if(!(Ze(n)||Ze(o)||Ze(a)||Ze(l)||Ze(u)||Ze(c))){n=Math.ceil(n),o=Math.ceil(o),a=Math.ceil(a),l=Math.ceil(l),u=Math.ceil(u),c=Math.ceil(c);var d=n>1?vt(o/n,0,1,gr):1,_=n>1?vt(a/n,0,1,gr):1,h=l>1?vt(u/l,0,1,gr):1,p=l>1?vt(c/l,0,1,gr):1;r=yr(r,{$prev_pageview_last_scroll:o,$prev_pageview_last_scroll_percentage:d,$prev_pageview_max_scroll:a,$prev_pageview_max_scroll_percentage:_,$prev_pageview_last_content:u,$prev_pageview_last_content_percentage:h,$prev_pageview_max_content:c,$prev_pageview_max_content_percentage:p})}}return i.pathname&&(r.$prev_pageview_pathname=i.pathname),i.timestamp&&(r.$prev_pageview_duration=(e.getTime()-i.timestamp.getTime())/1e3),r}}var zs=["flags","surveys"],Hs={[o]:{exposure:"hidden"},[l]:{exposure:"hidden"},__cmpns:{exposure:"hidden"},[u]:{exposure:"hidden"},[c]:{exposure:"event"},[d]:{exposure:"hidden"},[_]:{exposure:"event"},[h]:{exposure:"hidden"},[p]:{exposure:"event"},[g]:{exposure:"event"},[v]:{exposure:"event"},[f]:{exposure:"hidden"},[m]:{exposure:"event"},[y]:{exposure:"hidden"},$session_recording_enabled_server_side:{exposure:"hidden"},[k]:{exposure:"hidden"},[P]:{exposure:"event"},[b]:{exposure:"event",shouldSkipFromEventProperties:e=>it(e)},$session_past_minimum_duration:{exposure:"event"},$session_recording_url_trigger_activated_session:{exposure:"event"},$session_recording_event_trigger_activated_session:{exposure:"event"},$debug_first_full_snapshot_timestamp:{exposure:"event"},$sess_rec_flush_size:{exposure:"hidden"},[I]:{exposure:"derived",storageGroup:"flags",shouldSkipFromEventProperties:(e,t)=>t(),transformToEventProperties(e){if(!Ye(e))return{};for(var t={},i=Object.keys(e),r=0;i.length>r;r++)t["$feature/"+i[r]]=e[i[r]];return t}},[C]:{exposure:"event",storageGroup:"flags"},[F]:{exposure:"hidden"},[T]:{exposure:"hidden",storageGroup:"flags"},[R]:{exposure:"event",storageGroup:"flags"},[L]:{exposure:"event",storageGroup:"flags",volatile:!0},[M]:{exposure:"event"},[A]:{exposure:"hidden"},[O]:{exposure:"hidden"},[D]:{exposure:"hidden"},[q]:{exposure:"hidden",storageGroup:"surveys"},[B]:{exposure:"hidden",storageGroup:"surveys",volatile:!0},[z]:{exposure:"event"},[H]:{exposure:"hidden"},$product_tours_activated:{exposure:"hidden"},$conversations_widget_session_id:{exposure:"event"},$conversations_ticket_id:{exposure:"event"},$conversations_widget_state:{exposure:"event"},$conversations_user_traits:{exposure:"event"},[N]:{exposure:"hidden"},[j]:{exposure:"hidden"},[U]:{exposure:"hidden"},[W]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[V]:{exposure:"hidden"},[G]:{exposure:"hidden"},[K]:{exposure:"hidden"},[Q]:{exposure:"hidden"},[J]:{exposure:"hidden"},[Y]:{exposure:"hidden"},[X]:{exposure:"hidden"},[w]:{exposure:"event"},[x]:{exposure:"event"},[S]:{exposure:"event"},[E]:{exposure:"event"},[te]:{exposure:"event"},[ie]:{exposure:"event"},[re]:{exposure:"event"},$sdk_debug_replay_event_trigger_status:{exposure:"event"},$sdk_debug_replay_linked_flag_trigger_status:{exposure:"event"},$sdk_debug_replay_matched_recording_trigger_groups:{exposure:"event"},$sdk_debug_replay_remote_trigger_matching_config:{exposure:"event"},$sdk_debug_replay_trigger_groups_count:{exposure:"event"},$sdk_debug_replay_url_trigger_status:{exposure:"event"},$session_recording_start_reason:{exposure:"event"}},Ns=[["$posthog_sr_group_event_trigger_",{exposure:"hidden"}],["$posthog_sr_group_url_trigger_",{exposure:"hidden"}],["$posthog_sr_group_sampling_",{exposure:"hidden"}]],js=e=>{var t=Hs[e];if(t)return t;for(var[i,r]of Ns)if(0===e.indexOf(i))return r},Us=e=>{var t=null==ye?void 0:ye.createElement("a");return Ze(t)?null:(t.href=e,t)},Ws=function(e,t){for(var i,r=((e.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),s=0;r.length>s;s++){var n=r[s].split("=");if(n[0]===t){i=n;break}}if(!Qe(i)||2>i.length)return"";var o=i[1];try{o=decodeURIComponent(o)}catch(e){gr.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},Vs=function(e,t,i){if(!e||!t||!t.length)return e;for(var r=e.split("#"),s=r[1],n=(r[0]||"").split("?"),o=n[1],a=n[0],l=(o||"").split("&"),u=[],c=0;l.length>c;c++){var d=l[c].split("=");Qe(d)&&(t.includes(d[0])?u.push(d[0]+"="+i):u.push(l[c]))}var _=a;return null!=o&&(_+="?"+u.join("&")),null!=s&&(_+="#"+s),_},Gs=function(e,t){var i=e.match(new RegExp(t+"=([^&]*)"));return i?i[1]:null},Ks="https?://(.*)",Qs=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],Js=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...Qs],Ys="<masked>",Xs=["li_fat_id"];function Zs(e,t,i){if(!ye)return{};var r,s=t?[...Qs,...i||[]]:[],n=en(Vs(ye.URL,s,Ys),e),o=(r={},mr(Xs,(function(e){var t=Dr._get(e);r[e]=t||null})),r);return yr(o,n)}function en(e,t){var i=Js.concat(t||[]),r={};return mr(i,(function(t){var i=Ws(e,t);r[t]=i||null})),r}function tn(e){var t=function(e){return e?0===e.search(Ks+"google.([^/?]*)")?"google":0===e.search(Ks+"bing.com")?"bing":0===e.search(Ks+"yahoo.com")?"yahoo":0===e.search(Ks+"duckduckgo.com")?"duckduckgo":null:null}(e),i="yahoo"!=t?"q":"p",r={};if(!it(t)){r.$search_engine=t;var s=ye?Ws(ye.referrer,i):"";s.length&&(r.ph_keyword=s)}return r}function rn(){return navigator.language||navigator.userLanguage}var sn="$direct";function nn(){return(null==ye?void 0:ye.referrer)||sn}function on(e,t){var i=e?[...Qs,...t||[]]:[],r=null==be?void 0:be.href.substring(0,1e3);return{r:nn().substring(0,1e3),u:r?Vs(r,i,Ys):void 0}}function an(e){var t,{r:i,u:r}=e,s={$referrer:i,$referring_domain:null==i?void 0:i==sn?sn:null==(t=Us(i))?void 0:t.host};if(r){s.$current_url=r;var n=Us(r);s.$host=null==n?void 0:n.host,s.$pathname=null==n?void 0:n.pathname;var o=en(r);yr(s,o)}if(i){var a=tn(i);yr(s,a)}return s}function ln(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(e){return}}function un(){try{return(new Date).getTimezoneOffset()}catch(e){return}}var cn={flags:W,surveys:B},dn=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],_n="main";class hn{constructor(e,t,r){if(void 0===r&&(r=!0),this._slotState={},this._splitStorageEligible=!1,this._splitStorage=!1,this._config=e,this._ownsSplitStorage=r,this.props={},this._campaign_params_saved=!1,this._name=(e=>{var t="";return e.token&&(t=e.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),e.persistence_name?"ph_"+e.persistence_name:"ph_"+t+"_posthog"})(e),this._storage=this._buildStorage(e),this._splitStorage=this._resolveSplitStorage(e),this.load(),e.debug&&gr.info("Persistence loaded",e.persistence,i({},this.props)),this.update_config(e,e,t),this.save(),ve){var s=()=>this.flush();Pr(ve,"beforeunload",s,{capture:!1}),Pr(ve,"pagehide",s,{capture:!1})}}_saveDebounceMs(){var e,t=null==(e=this._config)?void 0:e.persistence_save_debounce_ms;return st(t)&&t>0?t:0}isDisabled(){return!!this._disabled}_buildStorage(e){-1===dn.indexOf(e.persistence.toLowerCase())&&(gr.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var t,r=function(e,t){void 0===e&&(e=[]),void 0===t&&(t=!1);var r=[...zr,...e];return i({},Br,{_parse(e){try{var i={};try{i=Dr._parse(e)||{}}catch(e){}var r,s=JSON.parse(Br._get(e)||"{}");if(t){var n={};for(var o in i){var a=i[o];it(a)||""===a||(n[o]=a)}r=yr(s,n)}else r=yr(i,s);return Br._set(e,r),r}catch(e){}return null},_set(e,t,i,s,n,o){var a=Br._set(e,t,void 0,void 0,o);try{var l={};r.forEach((e=>{t[e]&&(l[e]=t[e])})),Object.keys(l).length&&Dr._set(e,l,i,s,n,o)}catch(e){Br._error(e)}return a},_remove(e,t){try{null==ve||ve.localStorage.removeItem(e),Dr._remove(e,t)}catch(e){Br._error(e)}}})}(e.cookie_persisted_properties||[],e.__preview_cookie_wins_on_conflict||!1),s=!1,n=e.persistence.toLowerCase();return"localstorage"===n&&Br._is_supported()?(t=Br,s=!0):"localstorage+cookie"===n&&r._is_supported()?(t=r,s=!0):"sessionstorage"===n&&Ur._is_supported()?t=Ur:"memory"===n?t=Nr:"cookie"===n?t=Dr:r._is_supported()?(t=r,s=!0):t=Dr,this._splitStorageEligible=s,t}_groupEntryName(e){return this._name+"__"+e}_resolveSplitStorage(e){return this._splitStorageEligible&&!!e.split_storage}_isFeatureFlagCacheStale(e){var t=null!=e?e:this._config.feature_flag_cache_ttl_ms;if(!t||0>=t)return!1;var i=this.props[W];return!i||"number"!=typeof i||Date.now()-i>t}properties(){var e={};return mr(this.props,((t,i)=>{var r=js(i);if("derived"===(null==r?void 0:r.exposure)){if(null!=r.shouldSkipFromEventProperties&&r.shouldSkipFromEventProperties(t,i===I?()=>this._isFeatureFlagCacheStale():()=>!1))return;r.transformToEventProperties&&yr(e,r.transformToEventProperties(t))}else if(!r||"event"===r.exposure){if(null!=r&&null!=r.shouldSkipFromEventProperties&&r.shouldSkipFromEventProperties(t,(()=>!1)))return;e[i]=t}})),e}load(){if(!this._disabled){var e=this._storage._parse(this._name);e&&(this.props=yr({},e)),this._splitStorage&&this._loadGroupEntries()}}_loadGroupEntries(){for(var e of zs){var t=Br._parse(this._groupEntryName(e));if(t&&!Xe(t)){var i=this._slotWriteState(e);i.persisted=!0,this._mainCarriesGroupKey(e)||(i.fingerprint=this._entryFingerprint(t,e)),this._groupEntryIsStale(e,t)||yr(this.props,t)}}}_mainCarriesGroupKey(e){return Object.keys(this.props).some((t=>{var i;return(null==(i=js(t))?void 0:i.storageGroup)===e}))}_groupEntryIsStale(e,t){var i=cn[e];if(!i)return!1;var r=t[i],s=this.props[i];return st(r)&&st(s)&&s>r}refreshKey(e){var t;if(!this._disabled){var i=this._splitStorage?null==(t=js(e))?void 0:t.storageGroup:void 0,r=i?Br._parse(this._groupEntryName(i)):this._storage._parse(this._name);if(r&&e in r)this._setProp(e,r[e]);else{if(i){var s=this._storage._parse(this._name);if(s&&e in s)return void this._setProp(e,s[e])}this._deleteProp(e)}}}save(){if(!this._disabled){var e=this._saveDebounceMs();e>0?Ze(this._pendingSaveTimer)&&(this._pendingSaveTimer=setTimeout((()=>{this._pendingSaveTimer=void 0,this._writeNow()}),e)):this._writeNow()}}flush(){Ze(this._pendingSaveTimer)||(clearTimeout(this._pendingSaveTimer),this._pendingSaveTimer=void 0,this._writeNow())}_writeNow(){this._disabled||(this._splitStorage?this._writeNowSplit():this._writeEntry(this._storage,this._name,this.props,_n))}_writeNowSplit(){var{main:e,groups:t}=this._partitionProps();for(var i of(this._writeEntry(this._storage,this._name,e,_n),zs)){var r,s=t[i];(!Xe(s)||null!=(r=this._slotState[i])&&r.persisted)&&this._writeEntry(Br,this._groupEntryName(i),s,i)}}_partitionProps(){var e={},t={};for(var i of zs)t[i]={};return mr(this.props,((i,r)=>{var s,n=null==(s=js(r))?void 0:s.storageGroup;n?t[n][r]=i:e[r]=i})),{main:e,groups:t}}_entryFingerprint(e,t){if(t===_n)return JSON.stringify(e)+"|"+this._expire_days+"|"+this._cross_subdomain+"|"+this._secure;var i={};return mr(e,((e,t)=>{var r;i[t]=null!=(r=js(t))&&r.volatile?"__volatile__":e})),JSON.stringify(i)}_writeEntry(e,t,i,r){var s=this._slotWriteState(r);if(r===_n||s.dirty||Ze(s.fingerprint)){var n;try{if((n=this._entryFingerprint(i,r))===s.fingerprint)return void(s.dirty=!1)}catch(e){n=void 0}e._set(t,i,this._expire_days,this._cross_subdomain,this._secure,this._config.debug)?(s.dirty=!1,r!==_n&&(s.persisted=!0),Ze(n)||(s.fingerprint=n)):this._config.debug&&gr.warn('failed to persist storage entry "'+t+'"; will retry on next save')}}remove(e){var{keepGroupEntries:t=!1}=void 0===e?{}:e;if(Ze(this._pendingSaveTimer)||(clearTimeout(this._pendingSaveTimer),this._pendingSaveTimer=void 0),this._storage._remove(this._name,!1),this._storage._remove(this._name,!0),!t&&this._ownsSplitStorage)for(var i of zs)Br._remove(this._groupEntryName(i));t?delete this._slotState[_n]:this._slotState={}}clear(){this.remove(),this.props={}}register_once(e,t,i){if(Ye(e)){Ze(t)&&(t="None"),this._expire_days=Ze(i)?this._default_expiry:i;var r=!1;if(mr(e,((e,i)=>{this.props.hasOwnProperty(i)&&this.props[i]!==t||(this._setProp(i,e),r=!0)})),r)return this.save(),!0}return!1}register(e,t){if(Ye(e)){this._expire_days=Ze(t)?this._default_expiry:t;var i=!1;if(mr(e,((t,r)=>{e.hasOwnProperty(r)&&this.props[r]!==t&&(this._setProp(r,t),i=!0)})),i)return this.save(),!0}return!1}unregister(e){e in this.props&&(this._deleteProp(e),this.save())}update_campaign_params(){if(!this._campaign_params_saved){var e=Zs(this._config.custom_campaign_params,this._config.mask_personal_data_properties,this._config.custom_personal_data_properties);Xe(Sr(e))||this.register(e),this._campaign_params_saved=!0}}update_search_keyword(){var e;this.register((e=null==ye?void 0:ye.referrer)?tn(e):{})}update_referrer_info(){var e;this.register_once({$referrer:nn(),$referring_domain:null!=ye&&ye.referrer&&(null==(e=Us(ye.referrer))?void 0:e.host)||sn},void 0)}set_initial_person_info(){this.props[Q]||this.props[J]||this.register_once({[Y]:on(this._config.mask_personal_data_properties,this._config.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};mr([J,Q],(t=>{var i=this.props[t];i&&mr(i,(function(t,i){e["$initial_"+We(i)]=t}))}));var t,i,r=this.props[Y];if(r){var s=(t=an(r),i={},mr(t,(function(e,t){i["$initial_"+We(t)]=e})),i);yr(e,s)}return e}safe_merge(e){return mr(this.props,(function(t,i){i in e||(e[i]=t)})),e}update_config(e,t,i){this._default_expiry=this._expire_days=e.cookie_expiration,this.set_disabled(e.disable_persistence||!!i),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie);var r=e.persistence!==t.persistence||!((e,t)=>{if(e.length!==t.length)return!1;var i=[...e].sort(),r=[...t].sort();return i.every(((e,t)=>e===r[t]))})(e.cookie_persisted_properties||[],t.cookie_persisted_properties||[]),s=r?this._buildStorage(e):this._storage,n=this._resolveSplitStorage(e);if(r||n!==this._splitStorage){var o=this.props;this.clear(),this._storage=s,this._splitStorage=n,this.props=o,this.save()}}set_disabled(e){this._disabled=e,this._disabled?this.remove():this.save()}set_cross_subdomain(e){e!==this._cross_subdomain&&(this._cross_subdomain=e,this.remove({keepGroupEntries:!0}),this.save())}set_secure(e){e!==this._secure&&(this._secure=e,this.remove({keepGroupEntries:!0}),this.save())}set_event_timer(e,t){var i=this.props[u]||{};i[e]=t,this._setProp(u,i),this.save()}remove_event_timer(e){var t=this.props[u]||{},i=t[e];return Ze(i)||(delete t[e],this._setProp(u,t),this.save()),i}get_property(e){return this.props[e]}set_property(e,t){this._setProp(e,t),this.save()}_setProp(e,t){var i;this.props[e]=t,null!=(i=js(e))&&i.volatile||this._markGroupDirty(e)}_deleteProp(e){delete this.props[e],this._markGroupDirty(e)}_markGroupDirty(e){var t,i=null==(t=js(e))?void 0:t.storageGroup;i&&(this._slotWriteState(i).dirty=!0)}_slotWriteState(e){return this._slotState[e]||(this._slotState[e]={})}}var pn="events",gn="cancelEvents",vn="survey shown",fn="survey dismissed",mn="survey sent",yn="popover",bn=vr("[RateLimiter]");class wn{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=e=>{var t=e.text;if(t&&t.length)try{(JSON.parse(t).quota_limited||[]).forEach((e=>{bn.info((e||"events")+" is quota limited."),this.serverLimits[e]=(new Date).getTime()+6e4}))}catch(e){return void bn.warn('could not rate limit - continuing. Error: "'+(null==e?void 0:e.message)+'"',{text:t})}},this.instance=e,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var e;return(null==(e=this.instance.config.rate_limiting)?void 0:e.events_per_second)||10}get captureEventsBurstLimit(){var e;return Math.max((null==(e=this.instance.config.rate_limiting)?void 0:e.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(e){var t,i,r;void 0===e&&(e=!1);var{captureEventsBurstLimit:s,captureEventsPerSecond:n}=this,o=(new Date).getTime(),a=null!==(t=null==(i=this.instance.persistence)?void 0:i.get_property(K))&&void 0!==t?t:{tokens:s,last:o};a.tokens+=(o-a.last)/1e3*n,a.last=o,a.tokens>s&&(a.tokens=s);var l=1>a.tokens;return l||e||(a.tokens=Math.max(0,a.tokens-1)),!l||this.lastEventRateLimited||e||this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited. Config is set to "+n+" events per second and "+s+" events burst limit."},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=l,null==(r=this.instance.persistence)||r.set_property(K,a),{isRateLimited:l,remainingTokens:a.tokens}}isServerRateLimited(e){var t=this.serverLimits[e||"events"]||!1;return!1!==t&&(new Date).getTime()<t}}var xn=vr("[RemoteConfig]");class Sn{constructor(e){this._instance=e}get remoteConfig(){var e;return null==(e=Pe._POSTHOG_REMOTE_CONFIG)||null==(e=e[this._instance.config.token])?void 0:e.config}_loadRemoteConfigJs(e){var t,i;null!=(t=Pe.__PosthogExtensions__)&&t.loadExternalDependency?null==(i=Pe.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"remote-config",(()=>e(this.remoteConfig))):e()}_loadRemoteConfigJSON(e){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback(t){e(t.json)}})}load(){try{if(this.remoteConfig)return xn.info("Using preloaded remote config",this.remoteConfig),this._onRemoteConfig(this.remoteConfig),void this._startRefreshInterval();if(this._instance._shouldDisableFlags())return void xn.warn("Remote config is disabled. Falling back to local config.");this._loadRemoteConfigJs((e=>{if(!e)return xn.info("No config found after loading remote JS config. Falling back to JSON."),void this._loadRemoteConfigJSON((e=>{this._onRemoteConfig(e),this._startRefreshInterval()}));this._onRemoteConfig(e),this._startRefreshInterval()}))}catch(e){xn.error("Error loading remote config",e)}}stop(){this._refreshInterval&&(clearInterval(this._refreshInterval),this._refreshInterval=void 0)}refresh(){!this._instance._shouldDisableFlags()&&ye&&"hidden"!==ye.visibilityState&&this._instance.reloadFeatureFlags()}_startRefreshInterval(){var e;if(!this._refreshInterval){var t=null!==(e=this._instance.config.remote_config_refresh_interval_ms)&&void 0!==e?e:3e5;0!==t&&(this._refreshInterval=setInterval((()=>{this.refresh()}),t))}}_onRemoteConfig(e){var t;e||xn.error("Failed to fetch remote config from PostHog."),this._instance._onRemoteConfig(null!=e?e:{}),!1!==(null==e?void 0:e.hasFeatureFlags)&&(this._instance.config.advanced_disable_feature_flags_on_first_load||null==(t=this._instance.featureFlags)||t.ensureFlagsLoaded())}}var En="gzip-js",kn="base64",Pn=Uint8Array,In=Uint16Array,Cn=Uint32Array,Fn=new Pn([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]),Tn=new Pn([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]),Rn=new Pn([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ln=function(e,t){for(var i=new In(31),r=0;31>r;++r)i[r]=t+=1<<e[r-1];var s=new Cn(i[30]);for(r=1;30>r;++r)for(var n=i[r];i[r+1]>n;++n)s[n]=n-i[r]<<5|r;return[i,s]},Mn=Ln(Fn,2),$n=Mn[1];Mn[0][28]=258,$n[258]=28;for(var An=Ln(Tn,0)[1],On=new In(32768),Dn=0;32768>Dn;++Dn){var qn=(43690&Dn)>>>1|(21845&Dn)<<1;On[Dn]=((65280&(qn=(61680&(qn=(52428&qn)>>>2|(13107&qn)<<2))>>>4|(3855&qn)<<4))>>>8|(255&qn)<<8)>>>1}var Bn=function(e,t,i){for(var r=e.length,s=0,n=new In(t);r>s;++s)++n[e[s]-1];var o,a=new In(t);for(s=0;t>s;++s)a[s]=a[s-1]+n[s-1]<<1;if(i){o=new In(1<<t);var l=15-t;for(s=0;r>s;++s)if(e[s])for(var u=s<<4|e[s],c=t-e[s],d=a[e[s]-1]++<<c,_=d|(1<<c)-1;_>=d;++d)o[On[d]>>>l]=u}else for(o=new In(r),s=0;r>s;++s)o[s]=On[a[e[s]-1]++]>>>15-e[s];return o},zn=new Pn(288);for(Dn=0;144>Dn;++Dn)zn[Dn]=8;for(Dn=144;256>Dn;++Dn)zn[Dn]=9;for(Dn=256;280>Dn;++Dn)zn[Dn]=7;for(Dn=280;288>Dn;++Dn)zn[Dn]=8;var Hn=new Pn(32);for(Dn=0;32>Dn;++Dn)Hn[Dn]=5;var Nn=Bn(zn,9,0),jn=Bn(Hn,5,0),Un=function(e){return(e/8>>0)+(7&e&&1)},Wn=function(e,t,i){(null==i||i>e.length)&&(i=e.length);var r=new(e instanceof In?In:e instanceof Cn?Cn:Pn)(i-t);return r.set(e.subarray(t,i)),r},Vn=function(e,t,i){var r=t/8>>0;e[r]|=i<<=7&t,e[r+1]|=i>>>8},Gn=function(e,t,i){var r=t/8>>0;e[r]|=i<<=7&t,e[r+1]|=i>>>8,e[r+2]|=i>>>16},Kn=function(e,t){for(var i=[],r=0;e.length>r;++r)e[r]&&i.push({s:r,f:e[r]});var s=i.length,n=i.slice();if(!s)return[new Pn(0),0];if(1==s){var o=new Pn(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],u=0,c=1,d=2;for(i[0]={s:-1,f:a.f+l.f,l:a,r:l};c!=s-1;)a=i[i[d].f>i[u].f?u++:d++],l=i[u!=c&&i[d].f>i[u].f?u++:d++],i[c++]={s:-1,f:a.f+l.f,l:a,r:l};var _=n[0].s;for(r=1;s>r;++r)n[r].s>_&&(_=n[r].s);var h=new In(_+1),p=Qn(i[c-1],h,0);if(p>t){r=0;var g=0,v=p-t,f=1<<v;for(n.sort((function(e,t){return h[t.s]-h[e.s]||e.f-t.f}));s>r;++r){var m=n[r].s;if(t>=h[m])break;g+=f-(1<<p-h[m]),h[m]=t}for(g>>>=v;g>0;){var y=n[r].s;t>h[y]?g-=1<<t-h[y]++-1:++r}for(;r>=0&&g;--r){var b=n[r].s;h[b]==t&&(--h[b],++g)}p=t}return[new Pn(h),p]},Qn=function(e,t,i){return-1==e.s?Math.max(Qn(e.l,t,i+1),Qn(e.r,t,i+1)):t[e.s]=i},Jn=function(e){for(var t=e.length;t&&!e[--t];);for(var i=new In(++t),r=0,s=e[0],n=1,o=function(e){i[r++]=e},a=1;t>=a;++a)if(e[a]==s&&a!=t)++n;else{if(!s&&n>2){for(;n>138;n-=138)o(32754);n>2&&(o(n>10?n-11<<5|28690:n-3<<5|12305),n=0)}else if(n>3){for(o(s),--n;n>6;n-=6)o(8304);n>2&&(o(n-3<<5|8208),n=0)}for(;n--;)o(s);n=1,s=e[a]}return[i.subarray(0,r),t]},Yn=function(e,t){for(var i=0,r=0;t.length>r;++r)i+=e[r]*t[r];return i},Xn=function(e,t,i){var r=i.length,s=Un(t+2);e[s]=255&r,e[s+1]=r>>>8,e[s+2]=255^e[s],e[s+3]=255^e[s+1];for(var n=0;r>n;++n)e[s+n+4]=i[n];return 8*(s+4+r)},Zn=function(e,t,i,r,s,n,o,a,l,u,c){Vn(t,c++,i),++s[256];for(var d=Kn(s,15),_=d[0],h=d[1],p=Kn(n,15),g=p[0],v=p[1],f=Jn(_),m=f[0],y=f[1],b=Jn(g),w=b[0],x=b[1],S=new In(19),E=0;m.length>E;++E)S[31&m[E]]++;for(E=0;w.length>E;++E)S[31&w[E]]++;for(var k=Kn(S,7),P=k[0],I=k[1],C=19;C>4&&!P[Rn[C-1]];--C);var F,T,R,L,M=u+5<<3,A=Yn(s,zn)+Yn(n,Hn)+o,O=Yn(s,_)+Yn(n,g)+o+14+3*C+Yn(S,P)+(2*S[16]+3*S[17]+7*S[18]);if(A>=M&&O>=M)return Xn(t,c,e.subarray(l,l+u));if(Vn(t,c,1+(A>O)),c+=2,A>O){F=Bn(_,h,0),T=_,R=Bn(g,v,0),L=g;var D=Bn(P,I,0);for(Vn(t,c,y-257),Vn(t,c+5,x-1),Vn(t,c+10,C-4),c+=14,E=0;C>E;++E)Vn(t,c+3*E,P[Rn[E]]);c+=3*C;for(var q=[m,w],B=0;2>B;++B){var z=q[B];for(E=0;z.length>E;++E)Vn(t,c,D[H=31&z[E]]),c+=P[H],H>15&&(Vn(t,c,z[E]>>>5&127),c+=z[E]>>>12)}}else F=Nn,T=zn,R=jn,L=Hn;for(E=0;a>E;++E)if(r[E]>255){var H;Gn(t,c,F[257+(H=r[E]>>>18&31)]),c+=T[H+257],H>7&&(Vn(t,c,r[E]>>>23&31),c+=Fn[H]);var N=31&r[E];Gn(t,c,R[N]),c+=L[N],N>3&&(Gn(t,c,r[E]>>>5&8191),c+=Tn[N])}else Gn(t,c,F[r[E]]),c+=T[r[E]];return Gn(t,c,F[256]),c+T[256]},eo=new Cn([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),to=function(){for(var e=new Cn(256),t=0;256>t;++t){for(var i=t,r=9;--r;)i=(1&i&&3988292384)^i>>>1;e[t]=i}return e}(),io=function(e,t,i){for(;i;++t)e[t]=i,i>>>=8};function ro(e,t){void 0===t&&(t={});var i=function(){var e=4294967295;return{p(t){for(var i=e,r=0;t.length>r;++r)i=to[255&i^t[r]]^i>>>8;e=i},d(){return 4294967295^e}}}(),r=e.length;i.p(e);var s,n,o,a,l,u=(a=10+((s=t).filename&&s.filename.length+1||0),l=8,function(e,t,i,r,s,n){var o=e.length,a=new Pn(r+o+5*(1+Math.floor(o/7e3))+s),l=a.subarray(r,a.length-s),u=0;if(!t||8>o)for(var c=0;o>=c;c+=65535){var d=c+65535;o>d?u=Xn(l,u,e.subarray(c,d)):(l[c]=!0,u=Xn(l,u,e.subarray(c,o)))}else{for(var _=eo[t-1],h=_>>>13,p=8191&_,g=(1<<i)-1,v=new In(32768),f=new In(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 Cn(25e3),x=new In(288),S=new In(32),E=0,k=0,P=(c=0,0),I=0,C=0;o>c;++c){var F=b(c),T=32767&c,R=f[F];if(v[T]=R,f[F]=T,c>=I){var L=o-c;if((E>7e3||P>24576)&&L>423){u=Zn(e,l,0,w,x,S,k,P,C,c-C,u),P=E=k=0,C=c;for(var M=0;286>M;++M)x[M]=0;for(M=0;30>M;++M)S[M]=0}var A=2,O=0,D=p,q=T-R&32767;if(L>2&&F==b(c-q))for(var B=Math.min(h,L)-1,z=Math.min(32767,c),H=Math.min(258,L);z>=q&&--D&&T!=R;){if(e[c+A]==e[c+A-q]){for(var N=0;H>N&&e[c+N]==e[c+N-q];++N);if(N>A){if(A=N,O=q,N>B)break;var j=Math.min(q,N-2),U=0;for(M=0;j>M;++M){var W=c-q+M+32768&32767,V=W-v[W]+32768&32767;V>U&&(U=V,R=W)}}}q+=(T=R)-(R=v[T])+32768&32767}if(O){w[P++]=268435456|$n[A]<<18|An[O];var G=31&$n[A],K=31&An[O];k+=Fn[G]+Tn[K],++x[257+G],++S[K],I=c+A,++E}else w[P++]=e[c],++x[e[c]]}}u=Zn(e,l,!0,w,x,S,k,P,C,c-C,u)}return Wn(a,0,r+Un(u)+s)}(n=e,null==(o=t).level?6:o.level,null==o.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(n.length)))):12+o.mem,a,l)),c=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&&io(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),i){e[3]=8;for(var r=0;i.length>=r;++r)e[r+10]=i.charCodeAt(r)}}(u,t),io(u,c-8,i.d()),io(u,c-4,r),u}var so=!!xe||!!we,no="text/plain",oo=!1,ao=(e,t)=>{var[i,r]=e.split("#"),[s,n]=i.split("?");if(!n)return e;var o=n.split("&").filter((e=>e.split("=")[0]!==t)).join("&");return s+(o?"?"+o:"")+(r?"#"+r:"")},lo=function(e,t,r){var s;void 0===r&&(r=!0);var[n,o]=e.split("?"),a=i({},t),l=null!==(s=null==o?void 0:o.split("&").map((e=>{var t,[i,s]=e.split("="),n=r&&null!==(t=a[i])&&void 0!==t?t:s;return delete a[i],i+"="+n})))&&void 0!==s?s:[],u=function(e,t){var i,r;void 0===t&&(t="&");var s=[];return mr(e,(function(e,t){Ze(e)||Ze(t)||"undefined"===t||(i=encodeURIComponent((e=>e instanceof File)(e)?e.name:e.toString()),r=encodeURIComponent(t),s[s.length]=r+"="+i)})),s.join(t)}(a);return u&&l.push(u),n+"?"+l.join("&")},uo=(e,t)=>JSON.stringify(e,((e,t)=>"bigint"==typeof t?t.toString():t),t),co=e=>{if(e._encodedBody)return e._encodedBody;var{data:t,compression:i}=e;if(t){if(i===En){var r=ro(function(e,t){var i=e.length;if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var r=new Pn(e.length+(e.length>>>1)),s=0,n=function(e){r[s++]=e},o=0;i>o;++o){if(s+5>r.length){var a=new Pn(s+8+(i-o<<1));a.set(r),r=a}var l=e.charCodeAt(o);128>l?n(l):2048>l?(n(192|l>>>6),n(128|63&l)):l>55295&&57344>l?(n(240|(l=65536+(1047552&l)|1023&e.charCodeAt(++o))>>>18),n(128|l>>>12&63),n(128|l>>>6&63),n(128|63&l)):(n(224|l>>>12),n(128|l>>>6&63),n(128|63&l))}return Wn(r,0,s)}(uo(t)),{mtime:0});return{contentType:no,body:r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength),estimatedSize:r.byteLength}}if(i===kn){var s=function(e){return e?btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,((e,t)=>String.fromCharCode(parseInt(t,16))))):e}(uo(t)),n=(e=>"data="+encodeURIComponent("string"==typeof e?e:uo(e)))(s);return{contentType:"application/x-www-form-urlencoded",body:n,estimatedSize:new Blob([n]).size}}var o=uo(t);return{contentType:"application/json",body:o,estimatedSize:new Blob([o]).size}}},_o=e=>{var t,r,s,n=co(e);return!n||(r=e.compression,s=Ws(e.url,"compression"),r!==Le.GZipJS&&s!==Le.GZipJS&&"gzip"!==s)||((t=n.body)instanceof ArrayBuffer?Oe(new Uint8Array(t)):ArrayBuffer.isView(t)&&Oe(new Uint8Array(t.buffer,t.byteOffset,t.byteLength)))?{url:e.url,encodedBody:n}:(oo=!0,{url:ao(e.url,"compression"),encodedBody:co(i({},e,{compression:void 0,_encodedBody:void 0}))})},ho=function(){var e=t((function*(e){var t=uo(e.data),r=yield function(e,t,i){return ze.apply(this,arguments)}(t,n.DEBUG,{rethrow:!0});if(!r)return e;var s=yield r.arrayBuffer();return i({},e,{_encodedBody:{contentType:no,body:s,estimatedSize:s.byteLength}})}));return function(t){return e.apply(this,arguments)}}(),po=(e,t)=>lo(e,{_:(new Date).getTime().toString(),ver:n.JS_SDK_VERSION,compression:t}),go=[];we&&go.push({transport:"fetch",method(e){var t,{url:r,encodedBody:s}=_o(e),{contentType:n,body:o,estimatedSize:a}=null!=s?s:{},l=new Headers;mr(e.headers,(function(e,t){l.append(t,e)})),n&&l.append("Content-Type",n);var u=null;if(Se){var c=new Se;u={signal:c.signal,timeout:setTimeout((()=>c.abort()),e.timeout)}}we(r,i({method:(null==e?void 0:e.method)||"GET",headers:l,keepalive:"POST"===e.method&&52428.8>(a||0),body:o,signal:null==(t=u)?void 0:t.signal},e.fetchOptions)).then((t=>t.text().then((i=>{var r={statusCode:t.status,text:i};if(200===t.status)try{r.json=JSON.parse(i)}catch(e){gr.error(e)}null==e.callback||e.callback(r)})))).catch((t=>{gr.error(t),null==e.callback||e.callback({statusCode:0,error:t})})).finally((()=>u?clearTimeout(u.timeout):null))}}),xe&&go.push({transport:"XHR",method(e){var t=new xe,{url:i,encodedBody:r}=_o(e);t.open(e.method||"GET",i,!0);var{contentType:s,body:n}=null!=r?r:{};mr(e.headers,(function(e,i){t.setRequestHeader(i,e)})),s&&t.setRequestHeader("Content-Type",s),e.timeout&&(t.timeout=e.timeout),t.onreadystatechange=()=>{if(4===t.readyState){var i={statusCode:t.status,text:t.responseText};if(200===t.status)try{i.json=JSON.parse(t.responseText)}catch(e){}null==e.callback||e.callback(i)}},t.send(n)}}),null!=me&&me.sendBeacon&&go.push({transport:"sendBeacon",method(e){try{var{url:t,encodedBody:i}=_o(e),{contentType:r,body:s}=null!=i?i:{};if(!s)return;var n=s instanceof Blob?s:new Blob([s],{type:r});me.sendBeacon(t,n)}catch(e){}}});var vo=3e3;class fo{constructor(e,t){this._isPaused=!0,this._queue=[],this._flushTimeoutMs=vt((null==t?void 0:t.flush_interval_ms)||vo,250,5e3,gr.createLogger("flush interval"),vo),this._sendRequest=e}enqueue(e){this._queue.push(e),this._flushTimeout||this._setFlushTimeout()}unload(){this._clearFlushTimeout();var e=this._queue.length>0?this._formatQueue():{},t=Object.values(e);[...t.filter((e=>0===e.url.indexOf("/e"))),...t.filter((e=>0!==e.url.indexOf("/e")))].map((e=>{this._sendRequest(i({},e,{transport:"sendBeacon"}))}))}enable(){this._isPaused=!1,this._setFlushTimeout()}_setFlushTimeout(){var e=this;this._isPaused||(this._flushTimeout=setTimeout((()=>{if(this._clearFlushTimeout(),this._queue.length>0){var t=this._formatQueue(),i=function(){var i=t[r],s=(new Date).getTime();i.data&&Qe(i.data)&&mr(i.data,(e=>{e.offset=Math.abs(e.timestamp-s),delete e.timestamp})),e._sendRequest(i)};for(var r in t)i()}}),this._flushTimeoutMs))}_clearFlushTimeout(){clearTimeout(this._flushTimeout),this._flushTimeout=void 0}_formatQueue(){var e={};return mr(this._queue,(t=>{var r,s=t,n=(s?s.batchKey:null)||s.url;Ze(e[n])&&(e[n]=i({},s,{data:[]})),null==(r=e[n].data)||r.push(s.data)})),this._queue=[],e}}var mo=["retriesPerformedSoFar"];class yo{constructor(e){this._isPolling=!1,this._pollIntervalMs=3e3,this._queue=[],this._instance=e,this._queue=[],this._areWeOnline=!0,!Ze(ve)&&"onLine"in ve.navigator&&(this._areWeOnline=ve.navigator.onLine,this._onlineListener=()=>{this._areWeOnline=!0,this._flush()},this._offlineListener=()=>{this._areWeOnline=!1},Pr(ve,"online",this._onlineListener),Pr(ve,"offline",this._offlineListener))}get length(){return this._queue.length}retriableRequest(e){var{retriesPerformedSoFar:t}=e,s=r(e,mo);nt(t)&&(s.url=lo(s.url,{retry_count:t})),this._instance._send_request(i({},s,{callback:e=>{if(200!==e.statusCode&&(400>e.statusCode||e.statusCode>=500)){if((0===e.statusCode?3:10)>(null!=t?t:0))return void this._enqueue(i({retriesPerformedSoFar:t},s));0===e.statusCode&&gr.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!=t?t:0)+" retries.")}null==s.callback||s.callback(e)}}))}_enqueue(e){var t=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=t+1;var i=function(e){var t=3e3*Math.pow(2,e),i=t/2,r=Math.min(18e5,t),s=Math.random()-.5;return Math.ceil(r+s*(r-i))}(t),r=Date.now()+i;this._queue.push({retryAt:r,requestOptions:e});var s="Enqueued failed request for retry in "+i;navigator.onLine||(s+=" (Browser is offline)"),gr.warn(s),this._isPolling||(this._isPolling=!0,this._poll())}_poll(){if(this._poller&&clearTimeout(this._poller),0===this._queue.length)return this._isPolling=!1,void(this._poller=void 0);this._poller=setTimeout((()=>{this._areWeOnline&&this._queue.length>0&&this._flush(),this._poll()}),this._pollIntervalMs)}_flush(){var e=Date.now(),t=[],i=this._queue.filter((i=>e>i.retryAt||(t.push(i),!1)));if(this._queue=t,i.length>0)for(var{requestOptions:r}of i)this.retriableRequest(r)}unload(){for(var{requestOptions:e}of(this._poller&&(clearTimeout(this._poller),this._poller=void 0),this._isPolling=!1,Ze(ve)||(this._onlineListener&&(ve.removeEventListener("online",this._onlineListener),this._onlineListener=void 0),this._offlineListener&&(ve.removeEventListener("offline",this._offlineListener),this._offlineListener=void 0)),this._queue))try{this._instance._send_request(i({},e,{transport:"sendBeacon"}))}catch(e){gr.error(e)}this._queue=[]}}class bo{constructor(e){this._updateScrollData=()=>{var e,t,i,r;this._context||(this._context={});var s=this.scrollElement(),n=this.scrollY(),o=s?Math.max(0,s.scrollHeight-s.clientHeight):0,a=n+((null==s?void 0:s.clientHeight)||0),l=(null==s?void 0:s.scrollHeight)||0;this._context.lastScrollY=Math.ceil(n),this._context.maxScrollY=Math.max(n,null!==(e=this._context.maxScrollY)&&void 0!==e?e:0),this._context.maxScrollHeight=Math.max(o,null!==(t=this._context.maxScrollHeight)&&void 0!==t?t:0),this._context.lastContentY=a,this._context.maxContentY=Math.max(a,null!==(i=this._context.maxContentY)&&void 0!==i?i:0),this._context.maxContentHeight=Math.max(l,null!==(r=this._context.maxContentHeight)&&void 0!==r?r:0)},this._instance=e}get _scrollRoot(){return this._instance.config.scroll_root_selector}getContext(){return this._context}resetContext(){var e=this._context;return setTimeout(this._updateScrollData,0),e}startMeasuringScrollPosition(){Pr(ve,"scroll",this._updateScrollData,{capture:!0}),Pr(ve,"scrollend",this._updateScrollData,{capture:!0}),Pr(ve,"resize",this._updateScrollData)}scrollElement(){if(!this._scrollRoot)return null==ve?void 0:ve.document.documentElement;var e=Qe(this._scrollRoot)?this._scrollRoot:[this._scrollRoot];for(var t of e){var i=null==ve?void 0:ve.document.querySelector(t);if(i)return i}}_scrollPosition(e){var t="y"===e?"scrollTop":"scrollLeft";if(this._scrollRoot){var i=this.scrollElement();return i&&i[t]||0}return ve?"y"===e?ve.scrollY||ve.pageYOffset||ve.document.documentElement.scrollTop||0:ve.scrollX||ve.pageXOffset||ve.document.documentElement.scrollLeft||0:0}scrollY(){return this._scrollPosition("y")}scrollX(){return this._scrollPosition("x")}}var wo=e=>on(null==e?void 0:e.config.mask_personal_data_properties,null==e?void 0:e.config.custom_personal_data_properties);class xo{constructor(e,t,i,r){this._onSessionIdCallback=e=>{var t=this._getStored();if(!t||t.sessionId!==e){var i={sessionId:e,props:this._sessionSourceParamGenerator(this._instance)};this._persistence.register({[G]:i})}},this._instance=e,this._sessionIdManager=t,this._persistence=i,this._sessionSourceParamGenerator=r||wo,this._sessionIdManager.onSessionId(this._onSessionIdCallback)}_getStored(){return this._persistence.props[G]}getSetOnceProps(){var e,t=null==(e=this._getStored())?void 0:e.props;return t?"r"in t?an(t):{$referring_domain:t.referringDomain,$pathname:t.initialPathName,utm_source:t.utm_source,utm_campaign:t.utm_campaign,utm_medium:t.utm_medium,utm_content:t.utm_content,utm_term:t.utm_term}:{}}getSessionProps(){var e={};return mr(Sr(this.getSetOnceProps()),((t,i)=>{"$current_url"===i&&(i="url"),e["$session_entry_"+We(i)]=t})),e}}class So{constructor(){this._events={}}on(e,t){return this._events[e]||(this._events[e]=[]),this._events[e].push(t),()=>{this._events[e]=this._events[e].filter((e=>e!==t))}}emit(e,t){for(var i of this._events[e]||[])i(t);for(var r of this._events["*"]||[])r(e,t)}}var Eo=vr("[SessionId]");class ko{on(e,t){return this._eventEmitter.on(e,t)}constructor(e,t,i){var r;if(this._lastPersistedActivityTimestamp=null,this._sessionIdChangedHandlers=[],this._beforeUnloadListener=void 0,this._destroyed=!1,this._eventEmitter=new So,this._sessionHasBeenIdleTooLong=(e,t)=>!(!nt(e)||!nt(t))&&Math.abs(e-t)>this.sessionTimeoutMs,!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(e.config.cookieless_mode===oe)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._sessionActivityTimestamp=null,this._sessionIdGenerator=t||Mr,this._windowIdGenerator=i||Mr;var s=this._config.persistence_name||this._config.token;if(this._sessionTimeoutMs=1e3*vt(this._config.session_idle_timeout_seconds||1800,60,36e3,Eo.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this._resetIdleTimer(),this._window_id_storage_key="ph_"+s+"_window_id",this._primary_window_exists_storage_key="ph_"+s+"_primary_window_exists",this._canUseSessionStorage()){var n=Ur._parse(this._window_id_storage_key),o=Ur._parse(this._primary_window_exists_storage_key);n&&!o?this._windowId=n:Ur._remove(this._window_id_storage_key),Ur._set(this._primary_window_exists_storage_key,!0)}if(null!=(r=this._config.bootstrap)&&r.sessionID)try{var a=(e=>{var t=this._config.bootstrap.sessionID.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)})();this._setSessionId(this._config.bootstrap.sessionID,(new Date).getTime(),a)}catch(e){Eo.error("Invalid sessionID in bootstrap",e)}this._listenToReloadWindow()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return Ze(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&&Ur._is_supported()}_setWindowId(e){e!==this._windowId&&(this._windowId=e,this._canUseSessionStorage()&&Ur._set(this._window_id_storage_key,e))}_getWindowId(){return this._windowId?this._windowId:this._canUseSessionStorage()?Ur._parse(this._window_id_storage_key):null}_isActivityChangeBelowGranularity(e){var t=this._lastPersistedActivityTimestamp;return!it(t)&&!it(e)&&5e3>Math.abs(e-t)}_setSessionId(e,t,i){var r=t!==this._sessionActivityTimestamp,s=!(e!==this._sessionId||i!==this._sessionStartTimestamp);this._sessionStartTimestamp=i,this._sessionActivityTimestamp=t,this._sessionId=e,s&&!r||s&&this._isActivityChangeBelowGranularity(t)||(this._lastPersistedActivityTimestamp=t,this._persistence.register({[k]:[t,e,i]}))}_useCrossTabRefreshHardening(){var e,t=null==(e=this._config)?void 0:e.persistence_save_debounce_ms;return nt(t)&&t>0}_refreshSessionIdFromStorage(){this._useCrossTabRefreshHardening()?this._persistence.refreshKey(k):(this._persistence.flush(),this._persistence.load())}_flushPendingActivityTimestamp(){var e;if(!it(this._sessionActivityTimestamp)&&this._sessionActivityTimestamp!==this._lastPersistedActivityTimestamp){this._refreshSessionIdFromStorage();var[,t,i]=this._getSessionId();t===this._sessionId&&i===this._sessionStartTimestamp&&(this._lastPersistedActivityTimestamp=this._sessionActivityTimestamp,this._persistence.register({[k]:[this._sessionActivityTimestamp,null!==(e=this._sessionId)&&void 0!==e?e:null,this._sessionStartTimestamp]}),this._persistence.flush())}}_freshestActivityTimestamp(){var[e]=this._getSessionId(),t=nt(e)?e:0,i=nt(this._sessionActivityTimestamp)?this._sessionActivityTimestamp:0;return Math.max(t,i)}_isSessionIdleAfterCrossTabRefresh(e){return this._refreshSessionIdFromStorage(),this._sessionHasBeenIdleTooLong(e,this._freshestActivityTimestamp())}_getSessionId(){var e=this._persistence.props[k];return Qe(e)&&2===e.length&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this._lastPersistedActivityTimestamp=null,clearTimeout(this._enforceIdleTimeout),this._enforceIdleTimeout=void 0,this._setSessionId(null,null,null)}destroy(){this._destroyed=!0,this._flushPendingActivityTimestamp(),clearTimeout(this._enforceIdleTimeout),this._enforceIdleTimeout=void 0,this._beforeUnloadListener&&ve&&(ve.removeEventListener(de,this._beforeUnloadListener,{capture:!1}),this._beforeUnloadListener=void 0),this._sessionIdChangedHandlers=[]}_listenToReloadWindow(){this._beforeUnloadListener=()=>{this._flushPendingActivityTimestamp(),this._canUseSessionStorage()&&Ur._remove(this._primary_window_exists_storage_key)},Pr(ve,de,this._beforeUnloadListener,{capture:!1})}checkAndGetSessionAndWindowId(e,t){if(void 0===e&&(e=!1),void 0===t&&(t=null),this._config.cookieless_mode===oe)throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var i=t||(new Date).getTime(),[,r,s]=this._getSessionId(),n=this._freshestActivityTimestamp(),o=this._getWindowId(),a=nt(s)&&Math.abs(i-s)>864e5,l=!1,u=!1,c=!r,d=r,_=!c&&!e&&this._sessionHasBeenIdleTooLong(i,n);_&&((_=this._isSessionIdleAfterCrossTabRefresh(i))||Eo.info("cross-tab refresh kept the session alive",{sessionId:r}),[,r,s]=this._getSessionId()),c||_||a?(r=this._sessionIdGenerator(),o=this._windowIdGenerator(),Eo.info("new session ID generated",{sessionId:r,windowId:o,changeReason:{noSessionId:c,activityTimeout:_,sessionPastMaximumLength:a}}),s=i,l=!0):(o||(o=this._windowIdGenerator(),l=!0),(u=r!==d)&&(Eo.info("adopted cross-tab session id",{sessionId:r,windowId:o}),l=!0));var h=nt(n)&&e&&!a?n:i,p=nt(s)?s:(new Date).getTime();this._setWindowId(o),this._setSessionId(r,h,p),e||this._resetIdleTimer();var g={noSessionId:c,activityTimeout:_,sessionPastMaximumLength:a,crossTabAdoption:u};return l&&this._sessionIdChangedHandlers.forEach((e=>e(r,o,g))),{sessionId:r,windowId:o,sessionStartTimestamp:p,changeReason:l?g:void 0,lastActivityTimestamp:n}}_resetIdleTimer(){this._destroyed||(clearTimeout(this._enforceIdleTimeout),this._enforceIdleTimeout=setTimeout((()=>{if(!this._destroyed)if(this._isSessionIdleAfterCrossTabRefresh((new Date).getTime())){var e=this._sessionId;this.resetSessionId(),this._eventEmitter.emit("forcedIdleReset",{idleSessionId:e})}else this._resetIdleTimer()}),1.1*this.sessionTimeoutMs))}}var Po=function(e,t){if(!e)return!1;var i=e.userAgent;if(i&&Ne(i,t))return!0;try{var r=null==e?void 0:e.userAgentData;if(null!=r&&r.brands&&r.brands.some((e=>Ne(null==e?void 0:e.brand,t))))return!0}catch(e){}return!!e.webdriver},Io=function(e,t){if(!function(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}};function Co(e,t,i){return uo({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:i})}var Fo={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=>Io(t,e))))),not_regex:(e,t)=>t.every((t=>e.every((e=>!Io(t,e))))),icontains:(e,t)=>t.map(To).some((t=>e.map(To).some((e=>t.includes(e))))),not_icontains:(e,t)=>t.map(To).every((t=>e.map(To).every((e=>!t.includes(e))))),gt:(e,t)=>t.some((t=>{var i=parseFloat(t);return!isNaN(i)&&e.some((e=>i>parseFloat(e)))})),lt:(e,t)=>t.some((t=>{var i=parseFloat(t);return!isNaN(i)&&e.some((e=>i<parseFloat(e)))}))},To=e=>e.toLowerCase();function Ro(e,t){return!e||Object.entries(e).every((e=>{var[i,r]=e,s=null==t?void 0:t[i];if(Ze(s)||it(s))return!1;var n=[String(s)],o=Fo[r.operator];return!!o&&o(r.values,n)}))}var Lo="custom",Mo="i.posthog.com",$o=/^\/static\//;class Ao{constructor(e){this._regionCache={},this.instance=e}get apiHost(){var e=this.instance.config.api_host.trim().replace(/\/$/,"");return"https://app.posthog.com"===e?"https://us.i.posthog.com":e}get flagsApiHost(){var e=this.instance.config.flags_api_host;return e?e.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var e,t=null==(e=this.instance.config.ui_host)?void 0:e.replace(/\/$/,"");return t||(t=this.apiHost.replace("."+Mo,".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":Lo),this._regionCache[this.apiHost]}_staticAssetHostOverride(e){if($o.test(e)){var t=this.instance.config.asset_host;if("string"==typeof t)return t.trim().replace(/\/$/,"")||void 0}}endpointFor(e,t){if(void 0===t&&(t=""),t&&(t="/"===t[0]?t:"/"+t),"ui"===e)return this.uiHost+t;if("flags"===e)return this.flagsApiHost+t;if("assets"===e){var i=this._staticAssetHostOverride(t);if(i)return""+i+t}if(this.region===Lo)return this.apiHost+t;var r=Mo+t;switch(e){case"assets":return"https://"+this.region+"-assets."+r;case"api":return"https://"+this.region+"."+r}}}var Oo=vr("[Surveys]"),Do="seenSurvey_",qo=["popover","widget","api"],Bo={ignoreConditions:!1,ignoreDelay:!1,displayType:yn},zo=vr("[PostHog ExternalIntegrations]"),Ho={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};class No{constructor(e){this._instance=e}_loadScript(e,t){var i;null==(i=Pe.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,e,(e=>{if(e)return zo.error("failed to load script",e);t()}))}startIfEnabledOrStop(){var e=this,t=function(t){var i,s,n;!r||null!=(i=Pe.__PosthogExtensions__)&&null!=(i=i.integrations)&&i[t]||e._loadScript(Ho[t],(()=>{var i;null==(i=Pe.__PosthogExtensions__)||null==(i=i.integrations)||null==(i=i[t])||i.start(e._instance)})),!r&&null!=(s=Pe.__PosthogExtensions__)&&null!=(s=s.integrations)&&s[t]&&(null==(n=Pe.__PosthogExtensions__)||null==(n=n.integrations)||null==(n=n[t])||n.stop())};for(var[i,r]of Object.entries(null!==(s=this._instance.config.integrations)&&void 0!==s?s:{})){var s;t(i)}}}var jo,Uo={},Wo=0,Vo=()=>{},Go='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',Ko="Surveys module not available",Qo="sanitize_properties is deprecated. Use before_send instead",Jo="Invalid value for property_denylist config: ",Yo="posthog",Xo=!so&&-1===(null==ke?void 0:ke.indexOf("MSIE"))&&-1===(null==ke?void 0:ke.indexOf("Mozilla")),Zo=e=>{var t;return i({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,asset_host:null,token:"",autocapture:!0,cross_subdomain_cookie:kr(null==ye?void 0:ye.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:Vo,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:null!=e?e:"unset",__preview_deferred_init_extensions:!1,__preview_external_dependency_versioned_paths:!1,__preview_cookie_wins_on_conflict:!1,debug:be&&et(null==be?void 0:be.search)&&-1!==be.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,disable_external_dependency_loading:!1,strict_script_versioning:!1,enable_recording_console_log:void 0,secure_cookie:"https:"===(null==ve||null==(t=ve.location)?void 0:t.protocol),ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_flags:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_only_evaluate_survey_feature_flags:!1,advanced_feature_flags_dedup_per_session:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,surveys_request_timeout_ms:1e4,on_request_error(e){gr.error("Bad HTTP status: "+e.statusCode+" "+e.text)},get_device_id:e=>e,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:ue,before_send:void 0,request_queue_config:{flush_interval_ms:vo},error_tracking:{},_onCapture:Vo},(e=>({rageclick:e&&e>="2026-05-30"?{content_ignorelist:ds,ignore_text_selection:!0}:!e||"2025-11-30">e||{content_ignorelist:!0},capture_pageview:!e||"2025-05-24">e||"history_change",session_recording:e&&e>="2026-05-30"?{strictMinimumDuration:!0,canvasCapture:{resolutionScale:.6}}:e&&e>="2025-11-30"?{strictMinimumDuration:!0}:{},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)}))(e))},ea=[["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"]],ta=e=>{var t={};for(var[i,r]of ea)Ze(e[i])||(t[r]=e[i]);var s=yr({},t,e),n=e.__preview_external_dependency_versioned_paths;return Ze(n)||(Ze(e.strict_script_versioning)&&(s.strict_script_versioning=!!n),et(n)&&Ze(e.asset_host)&&(s.asset_host=n)),Qe(e.property_blacklist)&&(Ze(e.property_denylist)?s.property_denylist=e.property_blacklist:Qe(e.property_denylist)?s.property_denylist=[...e.property_blacklist,...e.property_denylist]:gr.error(Jo+e.property_denylist)),s};class ia{constructor(){this.__forceAllowLocalhost=!1}get _forceAllowLocalhost(){return this.__forceAllowLocalhost}set _forceAllowLocalhost(e){gr.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}}class ra{_replaceExtension(e,t){if(e){var i=this._extensions.indexOf(e);-1!==i&&this._extensions.splice(i,1)}return this._extensions.push(t),null==t.initialize||t.initialize(),t}_inCookielessMode(){return this.config.cookieless_mode===oe||this.config.cookieless_mode===ne&&this.consent.isRejected()}get decideEndpointWasHit(){var e,t;return null!==(e=null==(t=this.featureFlags)?void 0:t.hasLoadedFlags)&&void 0!==e&&e}get flagsEndpointWasHit(){var e,t;return null!==(e=null==(t=this.featureFlags)?void 0:t.hasLoadedFlags)&&void 0!==e&&e}constructor(){var e;this.webPerformance=new ia,this._personProcessingSetOncePropertiesSent=!1,this.version=n.LIB_VERSION,this._internalEventEmitter=new So,this._extensions=[],this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=Zo(),this.SentryIntegration=qs,this.sentryIntegration=e=>function(e,t){var i=Ds(e,t);return{name:Os,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 bo(this),this.pageViewManager=new Bs(this),this.rateLimiter=new wn(this),this.requestRouter=new Ao(this),this.consent=new Wr(this),this.externalIntegrations=new No(this);var t=null!==(e=ra.__defaultExtensionClasses)&&void 0!==e?e:{};this.featureFlags=t.featureFlags&&new t.featureFlags(this),this.toolbar=t.toolbar&&new t.toolbar(this),this.surveys=t.surveys&&new t.surveys(this),this.conversations=t.conversations&&new t.conversations(this),this.logs=t.logs&&new t.logs(this),this.experiments=t.experiments&&new t.experiments(this),this.exceptions=t.exceptions&&new t.exceptions(this),this.people={set:(e,t,i)=>{var r=et(e)?{[e]:t}:e;this.setPersonProperties(r),null==i||i({})},set_once:(e,t,i)=>{var r=et(e)?{[e]:t}:e;this.setPersonProperties(void 0,r),null==i||i({})}},this.on("eventCaptured",(e=>gr.info('send "'+(null==e?void 0:e.event)+'"',e)))}init(e,t,i){if(i&&i!==Yo){var r,s=null!==(r=Uo[i])&&void 0!==r?r:new ra;return s._init(e,t,i),Uo[i]=s,Uo[Yo][i]=s,s}return this._init(e,t,i)}_init(e,t,r){var s,o;void 0===t&&(t={});var a=et(e)?e.trim():"";if(!a)return gr.critical("PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()"),this;if(this.__loaded)return console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config={},t.debug=this._checkLocalStorageForDebug(t.debug),this._originalUserConfig=t,this._triggered_notifs=[],t.person_profiles?this._initialPersonProfilesConfig=t.person_profiles:t.process_person&&(this._initialPersonProfilesConfig=t.process_person);var l=Zo(t.defaults),u=ta(t),c=yr({},l,u,{name:r,token:a});Ye(l.rageclick)&&Ye(u.rageclick)&&(c.rageclick=yr({},l.rageclick,u.rageclick)),Ye(l.session_recording)&&Ye(u.session_recording)&&(c.session_recording=yr({},l.session_recording,u.session_recording)),this.set_config(c),this.config.on_xhr_error&&gr.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=t.disable_compression?void 0:En;var d=this._is_persistence_disabled();this.persistence=new hn(this.config,d),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new hn(i({},this.config,{persistence:"sessionStorage"}),d,!1);var _=i({},this.persistence.props),h=i({},this.sessionPersistence.props);this.register({$initialization_time:(new Date).toISOString()}),this._requestQueue=new fo((e=>this._send_retriable_request(e)),this.config.request_queue_config),this._retryQueue=new yo(this),this.__request_queue=[];var p=this._inCookielessMode();if(p||(this.sessionManager=new ko(this),this.sessionPropsManager=new xo(this,this.sessionManager,this.persistence)),this.config.__preview_deferred_init_extensions?(gr.info("Deferring extension initialization to improve startup performance"),setTimeout((()=>{this._initExtensions(p)}),0)):(gr.info("Initializing extensions synchronously"),this._initExtensions(p)),n.DEBUG=n.DEBUG||this.config.debug,n.DEBUG&&gr.info("Starting in debug mode",{this:this,config:t,thisC:i({},this.config),p:_,s:h}),!this.config.identity_distinct_id||null!=(s=t.bootstrap)&&s.distinctID||(t.bootstrap=i({},t.bootstrap,{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0})),void 0!==(null==(o=t.bootstrap)?void 0:o.distinctID)){var g=t.bootstrap.distinctID,v=this.get_distinct_id(),f=this.persistence.get_property(V);if(t.bootstrap.isIdentifiedID&&null!=v&&v!==g&&f===ae)this.identify(g);else if(t.bootstrap.isIdentifiedID&&null!=v&&v!==g&&f===le)gr.warn("Bootstrap distinctID differs from an already-identified user. The existing identity is preserved. Call reset() before reinitializing if you intend to switch users.");else{var m=this.config.get_device_id(Mr()),y=t.bootstrap.isIdentifiedID?m:g;this.persistence.set_property(V,t.bootstrap.isIdentifiedID?le:ae),this.register({distinct_id:g,$device_id:y})}}if(p)this.register_once({distinct_id:ee,$device_id:null},"");else if(!this.get_distinct_id()){var b=this.config.get_device_id(Mr());this.register_once({distinct_id:b,$device_id:b},""),this.persistence.set_property(V,ae)}return Pr(ve,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),t.segment?function(e,t){var i=e.config.segment;if(!i)return t();!function(e,t){var i=e.config.segment;if(!i)return t();var r=i=>{var r=()=>i.anonymousId()||Mr();e.config.get_device_id=r,i.id()&&(e.register({distinct_id:i.id(),$device_id:r()}),e.persistence.set_property(V,le)),t()},s=i.user();"then"in s&&Je(s.then)?s.then(r):r(s)}(e,(()=>{i.register((e=>{Promise&&Promise.resolve||As.warn("This browser does not have Promise support, and can not use the segment integration");var t=(t,i)=>{if(!i)return t;t.event.userId||t.event.anonymousId===e.get_distinct_id()||(As.info("No userId set, resetting PostHog"),e.reset()),t.event.userId&&t.event.userId!==e.get_distinct_id()&&(As.info("UserId set, identifying with PostHog"),e.identify(t.event.userId));var r=e.calculateEventProperties(i,t.event.properties);return t.event.properties=Object.assign({},r,t.event.properties),t};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:()=>!0,load:()=>Promise.resolve(),track:e=>t(e,e.event.event),page:e=>t(e,_e),identify:e=>t(e,pe),screen:e=>t(e,"$screen")}})(e)).then((()=>{t()}))}))}(this,(()=>this._loaded())):this._loaded(),Je(this.config._onCapture)&&this.config._onCapture!==Vo&&(gr.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",(e=>this.config._onCapture(e.event,e)))),this.config.ip&&gr.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}_initExtensions(e){var t,r,s,n,o,a,l,u=performance.now(),c=i({},ra.__defaultExtensionClasses,this.config.__extensionClasses),d=[];c.featureFlags&&this._extensions.push(this.featureFlags=null!==(t=this.featureFlags)&&void 0!==t?t:new c.featureFlags(this)),c.exceptions&&this._extensions.push(this.exceptions=null!==(r=this.exceptions)&&void 0!==r?r:new c.exceptions(this)),c.historyAutocapture&&this._extensions.push(this.historyAutocapture=new c.historyAutocapture(this)),c.tracingHeaders&&this._extensions.push(this.tracingHeaders=new c.tracingHeaders(this)),c.siteApps&&this._extensions.push(this.siteApps=new c.siteApps(this)),c.sessionRecording&&!e&&this._extensions.push(this.sessionRecording=new c.sessionRecording(this)),this.config.disable_scroll_properties||d.push((()=>{this.scrollManager.startMeasuringScrollPosition()})),c.autocapture&&this._extensions.push(this.autocapture=new c.autocapture(this)),c.surveys&&this._extensions.push(this.surveys=null!==(s=this.surveys)&&void 0!==s?s:new c.surveys(this)),c.logs&&this._extensions.push(this.logs=null!==(n=this.logs)&&void 0!==n?n:new c.logs(this)),c.conversations&&this._extensions.push(this.conversations=null!==(o=this.conversations)&&void 0!==o?o:new c.conversations(this)),c.productTours&&this._extensions.push(this.productTours=new c.productTours(this)),c.heatmaps&&this._extensions.push(this.heatmaps=new c.heatmaps(this)),c.webVitalsAutocapture&&this._extensions.push(this.webVitalsAutocapture=new c.webVitalsAutocapture(this)),c.exceptionObserver&&this._extensions.push(this.exceptionObserver=new c.exceptionObserver(this)),c.deadClicksAutocapture&&this._extensions.push(this.deadClicksAutocapture=new c.deadClicksAutocapture(this,Ms)),c.toolbar&&this._extensions.push(this.toolbar=null!==(a=this.toolbar)&&void 0!==a?a:new c.toolbar(this)),c.experiments&&this._extensions.push(this.experiments=null!==(l=this.experiments)&&void 0!==l?l:new c.experiments(this)),this._extensions.forEach((e=>{e.initialize&&d.push((()=>{null==e.initialize||e.initialize()}))})),d.push((()=>{if(this._pendingRemoteConfig){var e=this._pendingRemoteConfig;this._pendingRemoteConfig=void 0,this._onRemoteConfig(e)}})),this._processInitTaskQueue(d,u)}_processInitTaskQueue(e,t){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-t>=30&&e.length>0)return void setTimeout((()=>{this._processInitTaskQueue(e,t)}),0);var i=e.shift();if(i)try{i()}catch(e){gr.error("Error initializing extension:",e)}}var r=Math.round(performance.now()-t);this.register_for_session({[te]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[ie]:r}),this.config.__preview_deferred_init_extensions&&gr.info("PostHog extensions initialized ("+r+"ms)")}_onRemoteConfig(e){var t;if(!ye||!ye.body)return gr.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout((()=>{this._onRemoteConfig(e)}),500);this.config.__preview_deferred_init_extensions&&(this._pendingRemoteConfig=e),this._lastRemoteConfig=e,this.compression=void 0,e.supportedCompression&&!this.config.disable_compression&&(this.compression=je(e.supportedCompression,En)?En:je(e.supportedCompression,kn)?kn:void 0),null!=(t=e.analytics)&&t.endpoint&&(this.analyticsDefaultEndpoint=e.analytics.endpoint),this.set_config({person_profiles:this._initialPersonProfilesConfig?this._initialPersonProfilesConfig:ue}),this._extensions.forEach((t=>null==t.onRemoteConfig?void 0:t.onRemoteConfig(e)))}_loaded(){try{this.config.loaded(this)}catch(e){gr.critical("`loaded` function failed",e)}if(this._start_queue_if_opted_in(),this.config.internal_or_test_user_hostname&&null!=be&&be.hostname){var e=be.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 Sn(this),this._remoteConfigLoader.load()}_start_queue_if_opted_in(){var e;this.is_capturing()&&this.config.request_batching&&(null==(e=this._requestQueue)||e.enable())}_dom_loaded(){this.is_capturing()&&fr(this.__request_queue,(e=>this._send_retriable_request(e))),this.__request_queue=[],this._start_queue_if_opted_in()}_handle_unload(){var e,t,i,r;null==(e=this.surveys)||e.handlePageUnload(),this.config.request_batching?(this._shouldCapturePageleave()&&this.capture(he),null==(t=this.logs)||t.flushLogs("sendBeacon"),null==(i=this._requestQueue)||i.unload(),null==(r=this._retryQueue)||r.unload()):this._shouldCapturePageleave()&&this.capture(he,null,{transport:"sendBeacon"})}_send_request(e){this.__loaded?Xo?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)?e.fireCallbackOnDrop&&(null==e.callback||e.callback({statusCode:429})):(e.transport=e.transport||this.config.api_transport,e.headers=i({},this.config.request_headers,e.headers),e.compression="best-available"===e.compression?this.compression:e.compression,(Ze(this.config.disable_beacon)?this.config.__preview_disable_beacon:this.config.disable_beacon)&&(e.disableTransport=["sendBeacon"]),e.fetchOptions=e.fetchOptions||this.config.fetch_options,(e=>{var t,r,s,n=i({},e);n.timeout=n.timeout||6e4,n.url=po(n.url,n.compression);var o=null!==(t=n.transport)&&void 0!==t?t:"fetch",a=go.filter((e=>!n.disableTransport||!e.transport||!n.disableTransport.includes(e.transport))),l=null!==(r=null==(s=function(e,t){for(var i=0;e.length>i;i++)if(e[i].transport===o)return e[i]}(a))?void 0:s.method)&&void 0!==r?r:a[0].method;if(!l)throw new Error("No available transport method");"sendBeacon"!==o&&n.data&&n.compression===En&&Ee&&!oo?ho(n).then((e=>{l(e)})).catch((t=>{if(De(t))return oo=!0,void l(i({},n,{compression:void 0,url:po(e.url,void 0)}));(e=>{if(!e||"object"!=typeof e)return!1;var t="name"in e?String(e.name):"";return De(e)||t===Ae})(t)&&(oo=!0),l(n)})):l(n)})(i({},e,{callback:t=>{var i,r;this.rateLimiter.checkForLimiting(t),400>t.statusCode||null==(i=(r=this.config).on_request_error)||i.call(r,t),null==e.callback||e.callback(t)}}))):e.fireCallbackOnDrop&&(null==e.callback||e.callback({statusCode:0}))}_send_retriable_request(e){this._retryQueue?this._retryQueue.retriableRequest(e):this._send_request(e)}_execute_array(e){Wo++;try{var t,i=[],r=[],s=[];fr(e,(e=>{if(e)if(Qe(t=e[0]))s.push(e);else if(Je(e))try{e.call(this)}catch(t){gr.error("Error executing queued PostHog call",e,t)}else Qe(e)&&"alias"===t?i.push(e):Qe(e)&&-1!==t.indexOf("capture")&&Je(this[t])?s.push(e):r.push(e)}));var n=function(e,t){fr(e,(function(e){try{if(Qe(e[0])){var i=t;mr(e,(function(e){i=i[e[0]].apply(i,e.slice(1))}))}else t[e[0]].apply(t,e.slice(1))}catch(t){gr.error("Error executing queued PostHog call",e,t)}}))};n(i,this),n(r,this),n(s,this)}finally{Wo--}}push(e){if(Wo>0&&Qe(e)&&et(e[0])){var t=ra.prototype[e[0]];Je(t)&&t.apply(this,e.slice(1))}else this._execute_array([e])}capture(e,t,r){var s,n,o,a,l;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this._requestQueue){if(this.is_capturing())if(!Ze(e)&&et(e)){var u=!this.config.opt_out_useragent_filter&&this._is_bot();if(!u||this.config.__preview_capture_bot_pageviews){var c=null!=r&&r.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(null==c||!c.isRateLimited){null!=t&&t.$current_url&&!et(null==t?void 0:t.$current_url)&&(gr.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!=r&&r._originatedFromCaptureException||gr.warn("Using `posthog.capture('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureException(error)` instead, which attaches required metadata automatically."),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&this.sessionPersistence.update_campaign_params(),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();var d=new Date,_=(null==r?void 0:r.timestamp)||d,h=Si(null==r?void 0:r.uuid,Mr),p={uuid:h,event:e,properties:this.calculateEventProperties(e,t||{},_,h)};e===_e&&this.config.__preview_capture_bot_pageviews&&u&&(p.event="$bot_pageview",p.properties.$browser_type="bot"),c&&(p.properties.$lib_rate_limit_remaining_tokens=c.remainingTokens),(null==r?void 0:r.$set)&&(p.$set=null==r?void 0:r.$set);var g=null==r?void 0:r.$unset;g&&(p.$unset=g);var v,f,m,y=this._calculate_set_once_properties(null==r?void 0:r.$set_once,e!==ge,e===pe);if(y&&(p.$set_once=y),null!=r&&r._noTruncate||(n=this.config.properties_string_max_length,o=p,a=e=>et(e)?e.slice(0,n):e,l=new Set,p=function e(t,i){return t!==Object(t)?a?a(t):t:l.has(t)?void 0:(l.add(t),Qe(t)?(r=[],fr(t,(t=>{r.push(e(t))}))):(r={},mr(t,((t,i)=>{l.has(t)||(r[i]=e(t,i))}))),r);var r}(o)),p.timestamp=_,Ze(null==r?void 0:r.timestamp)||(p.properties.$event_time_override_provided=!0,p.properties.$event_time_override_system_time=d),e===fn||e===mn){var b=null==t?void 0:t.$survey_id,w=null==t?void 0:t.$survey_iteration;(e=>{try{var t=(e=>((e,t)=>{var i=""+e+t.id;return t.current_iteration&&t.current_iteration>0&&(i=""+e+t.id+"_"+t.current_iteration),i})(Do,e))(e);if(localStorage.getItem(t))return;localStorage.setItem(t,"true")}catch(e){Oo.error("Failed to persist survey seen state",e)}})({id:b,current_iteration:w}),p.$set=i({},p.$set,{[(v={id:b,current_iteration:w},f=e===mn?"responded":"dismissed",m="$survey_"+f+"/"+v.id,v.current_iteration&&v.current_iteration>0&&(m="$survey_"+f+"/"+v.id+"/"+v.current_iteration),m)]:!0})}else e===vn&&(p.$set=i({},p.$set,{$survey_last_seen_date:(new Date).toISOString()}));if("product tour shown"===e){var x=null==t?void 0:t.$product_tour_type;x&&(p.$set=i({},p.$set,{["$product_tour_last_seen_date/"+x]:(new Date).toISOString()}))}var S=i({},p.properties.$set,p.$set);if(Xe(S)||this.setPersonPropertiesForFlags(S),!rt(this.config.before_send)){var E=this._runBeforeSend(p);if(!E)return;(p=E).uuid=Si(p.uuid,Mr)}this._internalEventEmitter.emit("eventCaptured",p);var k={method:"POST",url:null!==(s=null==r?void 0:r._url)&&void 0!==s?s:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:p,compression:"best-available",batchKey:null==r?void 0:r._batchKey,transport:null==r?void 0:r.transport};return!this.config.request_batching||r&&(null==r||!r._batchKey)||null!=r&&r.send_instantly?this._send_retriable_request(k):this._requestQueue.enqueue(k),p}gr.critical("This capture call is ignored due to client rate limiting.")}}else gr.error("No event name provided to posthog.capture")}else gr.uninitializedWarning("posthog.capture")}_addCaptureHook(e){return this.on("eventCaptured",(t=>e(t.event,t)))}calculateEventProperties(e,t,r,s,o){if(r=r||new Date,!this.persistence||!this.sessionPersistence)return t;var a=o?void 0:this.persistence.remove_event_timer(e),l=i({},t);if(l.token=this.config.token,l.$config_defaults=this.config.defaults,this._inCookielessMode()&&(l.$cookieless_mode=!0),"$snapshot"===e){var u=i({},this.persistence.properties(),this.sessionPersistence.properties());return l.distinct_id=u.distinct_id,(!et(l.distinct_id)&&!st(l.distinct_id)||tt(l.distinct_id))&&gr.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),l}var c,d=function(e,t,i){var r,s,o,a;if(!ke)return{};var l,u,c,d,_,h,p,g,v,f=e?[...Qs,...t||[]]:[],[m,y]=function(e){for(var t=0;bi.length>t;t++){var[i,r]=bi[t],s=i.exec(e),n=s&&(Je(r)?r(s,e):r);if(n)return n}return["",""]}(ke),b=null!=(l="undefined"!=typeof navigator?navigator:void 0)&&l.brave?{brave:!0}:{},w={detectGoogleSearchApp:i},x=yr(Sr({$os:m,$os_version:y,$browser:fi(ke,navigator.vendor,b,w),$device:wi(ke),$device_type:(c=ke,d={userAgentDataPlatform:null==(r=navigator)||null==(r=r.userAgentData)?void 0:r.platform,maxTouchPoints:null==(s=navigator)?void 0:s.maxTouchPoints,screenWidth:null==ve||null==(o=ve.screen)?void 0:o.width,screenHeight:null==ve||null==(a=ve.screen)?void 0:a.height,devicePixelRatio:null==ve?void 0:ve.devicePixelRatio},v=wi(c),v===St||v===xt||"Kobo"===v||"Kindle Fire"===v||v===Zt?wt:v===Nt||v===Ut||v===jt||v===Jt?"Console":v===kt?"Wearable":v?mt:"Android"===(null==d?void 0:d.userAgentDataPlatform)&&(null!==(_=null==d?void 0:d.maxTouchPoints)&&void 0!==_?_:0)>0?600>Math.min(null!==(h=null==d?void 0:d.screenWidth)&&void 0!==h?h:0,null!==(p=null==d?void 0:d.screenHeight)&&void 0!==p?p:0)/(null!==(g=null==d?void 0:d.devicePixelRatio)&&void 0!==g?g:1)?mt:wt:"Desktop"),$timezone:ln(),$timezone_offset:un()}),{$current_url:Vs(null==be?void 0:be.href,f,Ys),$host:null==be?void 0:be.host,$pathname:null==be?void 0:be.pathname,$raw_user_agent:ke.length>1e3?ke.substring(0,997)+"...":ke,$browser_version:yi(ke,navigator.vendor,b,w),$browser_language:rn(),$browser_language_prefix:(u=rn(),"string"==typeof u?u.split("-")[0]:void 0),$screen_height:null==ve?void 0:ve.screen.height,$screen_width:null==ve?void 0:ve.screen.width,$viewport_height:null==ve?void 0:ve.innerHeight,$viewport_width:null==ve?void 0:ve.innerWidth,$lib:n.LIB_NAME,$lib_version:n.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3});return n.SDK_DIST_CHANNEL&&(x.$sdk_dist_channel=n.SDK_DIST_CHANNEL),x}(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties,this.config.detect_google_search_app);if(this.sessionManager){var{sessionId:_,windowId:h}=this.sessionManager.checkAndGetSessionAndWindowId(o,r.getTime());l.$session_id=_,l.$window_id=h}this.sessionPropsManager&&yr(l,this.sessionPropsManager.getSessionProps());try{var p;this.sessionRecording&&yr(l,this.sessionRecording.sdkDebugProperties),l.$sdk_debug_retry_queue_size=null==(p=this._retryQueue)?void 0:p.length}catch(e){l.$sdk_debug_error_capturing_properties=String(e)}if(this.requestRouter.region===Lo&&(l.$lib_custom_api_host=this.config.api_host),c=e!==_e||o?e!==he||o?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(r):this.pageViewManager.doPageView(r,s),l=yr(l,c),e===_e&&ye&&(l.title=ye.title),!Ze(a)){var g=r.getTime()-a;l.$duration=parseFloat((g/1e3).toFixed(3))}ke&&this.config.opt_out_useragent_filter&&(l.$browser_type=this._is_bot()?"bot":"browser"),(l=yr({},d,this.persistence.properties(),this.sessionPersistence.properties(),l)).$is_identified=this._isIdentified(),Qe(this.config.property_denylist)?mr(this.config.property_denylist,(function(e){delete l[e]})):gr.error(Jo+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var v=this.config.sanitize_properties;v&&(gr.error(Qo),l=v(l,e));var f=this._hasPersonProcessing();return l.$process_person_profile=f,f&&!o&&this._requirePersonProcessing("_calculate_event_properties"),l}_calculate_set_once_properties(e,t,i){var r;if(void 0===t&&(t=!0),void 0===i&&(i=!1),!this.persistence||!this._hasPersonProcessing())return e;if(this._personProcessingSetOncePropertiesSent&&!i)return e;var s=this.persistence.get_initial_props(),n=null==(r=this.sessionPropsManager)?void 0:r.getSetOnceProps(),o=yr({},s,n||{},e||{}),a=this.config.sanitize_properties;return a&&(gr.error(Qo),o=a(o,"$set_once")),t&&(this._personProcessingSetOncePropertiesSent=!0),Xe(o)?void 0:o}register(e,t){var i;null==(i=this.persistence)||i.register(e,t)}register_once(e,t,i){var r;null==(r=this.persistence)||r.register_once(e,t,i)}register_for_session(e){var t;null==(t=this.sessionPersistence)||t.register(e)}unregister(e){var t;null==(t=this.persistence)||t.unregister(e)}unregister_for_session(e){var t;null==(t=this.sessionPersistence)||t.unregister(e)}_register_single(e,t){this.register({[e]:t})}getFeatureFlag(e,t){var i;return null==(i=this.featureFlags)?void 0:i.getFeatureFlag(e,t)}getFeatureFlagPayload(e){var t;return null==(t=this.featureFlags)?void 0:t.getFeatureFlagPayload(e)}getFeatureFlagResult(e,t){var i;return null==(i=this.featureFlags)?void 0:i.getFeatureFlagResult(e,t)}isFeatureEnabled(e,t){var i;return null==(i=this.featureFlags)?void 0:i.isFeatureEnabled(e,t)}reloadFeatureFlags(){var e;null==(e=this.featureFlags)||e.reloadFeatureFlags()}updateFlags(e,t,i){var r;null==(r=this.featureFlags)||r.updateFlags(e,t,i)}updateEarlyAccessFeatureEnrollment(e,t,i){var r;null==(r=this.featureFlags)||r.updateEarlyAccessFeatureEnrollment(e,t,i)}getEarlyAccessFeatures(e,t,i){var r;return void 0===t&&(t=!1),null==(r=this.featureFlags)?void 0:r.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:Ko}),()=>{})}onSessionId(e){var t,i;return null!==(t=null==(i=this.sessionManager)?void 0:i.onSessionId(e))&&void 0!==t?t:()=>{}}getSurveys(e,t){void 0===t&&(t=!1),this.surveys?this.surveys.getSurveys(e,t):e([],{isLoaded:!1,error:Ko})}getActiveMatchingSurveys(e,t){void 0===t&&(t=!1),this.surveys?this.surveys.getActiveMatchingSurveys(e,t):e([],{isLoaded:!1,error:Ko})}renderSurvey(e,t){var i;null==(i=this.surveys)||i.renderSurvey(e,t)}displaySurvey(e,t){var i;void 0===t&&(t=Bo),null==(i=this.surveys)||i.displaySurvey(e,t)}cancelPendingSurvey(e){var t;null==(t=this.surveys)||t.cancelPendingSurvey(e)}canRenderSurvey(e){var t,i;return null!==(t=null==(i=this.surveys)?void 0:i.canRenderSurvey(e))&&void 0!==t?t:{visible:!1,disabledReason:Ko}}canRenderSurveyAsync(e,t){var i,r;return void 0===t&&(t=!1),null!==(i=null==(r=this.surveys)?void 0:r.canRenderSurveyAsync(e,t))&&void 0!==i?i:Promise.resolve({visible:!1,disabledReason:Ko})}_validateIdentifyId(e){return!e||tt(e)?(gr.critical("Unique user id has not been set in posthog.identify"),!1):e===ee?(gr.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())||(gr.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 gr.uninitializedWarning("posthog.identify");if(st(e)&&(e=e.toString(),gr.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),this._validateIdentifyId(e)&&this._requirePersonProcessing("posthog.identify")){var r=this.get_distinct_id();this.register({$user_id:e}),this.get_property(a)||this.register_once({$had_persisted_distinct_id:!0,$device_id:r},""),e!==r&&e!==this.get_property(l)&&(this.unregister(l),this.register({distinct_id:e}));var s,n=(this.persistence.get_property(V)||ae)===ae;e!==r&&n?(this.persistence.set_property(V,le),this.setPersonPropertiesForFlags({$set:t||{},$set_once:i||{}},!1),this.capture(pe,{distinct_id:e,$anon_distinct_id:r},{$set:t||{},$set_once:i||{}}),this._cachedPersonProperties=Co(e,t,i),null==(s=this.featureFlags)||s.setAnonymousDistinctId(r)):(t||i)&&this.setPersonProperties(t,i),e!==r&&(this.reloadFeatureFlags(),this.unregister(N))}}setPersonProperties(e,t){if((e||t)&&this._requirePersonProcessing("posthog.setPersonProperties")){var i=Co(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):gr.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}unsetPersonProperties(e){var t,i=(Qe(e)?e:[e]).filter((e=>et(e)&&e.length>0));0!==i.length&&this._requirePersonProcessing("posthog.unsetPersonProperties")&&(null==(t=this.featureFlags)||t.unsetPersonPropertiesForFlags(i,!0),this.capture("$set",{$unset:i}),this._cachedPersonProperties=null)}group(e,t,r){if(e&&t){var s=this.getGroups(),n=s[e]!==t;if(n&&this.resetGroupPropertiesForFlags(e),this.register({$groups:i({},s,{[e]:t})}),n||r){var o={$group_type:e,$group_key:t};r&&(o.$group_set=r),this.capture(ge,o)}r&&this.setGroupPropertiesForFlags({[e]:r}),n&&!r&&this.reloadFeatureFlags()}else gr.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,t){var i;void 0===t&&(t=!0),null==(i=this.featureFlags)||i.setPersonPropertiesForFlags(e,t)}resetPersonPropertiesForFlags(e){var t;void 0===e&&(e=!0),null==(t=this.featureFlags)||t.resetPersonPropertiesForFlags(e)}setGroupPropertiesForFlags(e,t){var i;void 0===t&&(t=!0),this._requirePersonProcessing("posthog.setGroupPropertiesForFlags")&&(null==(i=this.featureFlags)||i.setGroupPropertiesForFlags(e,t))}resetGroupPropertiesForFlags(e){var t;null==(t=this.featureFlags)||t.resetGroupPropertiesForFlags(e)}reset(e){var t,i,r,s,n,o,l,u,c;if(gr.info("reset"),!this.__loaded)return gr.uninitializedWarning("posthog.reset");var d,_=this.get_property(a),h=this.get_property(y);if(this.consent.reset(),null==(t=this.persistence)||t.clear(),null==(i=this.sessionPersistence)||i.clear(),Ze(h)||null==(d=this.persistence)||d.register({[y]:h}),null==(r=this.surveys)||r.reset(),null==(s=this._remoteConfigLoader)||s.stop(),null==(n=this.featureFlags)||n.reset(),null==(o=this.conversations)||o.reset(),null==(l=this.logs)||l.reset(),null==(u=this.persistence)||u.set_property(V,ae),null==(c=this.sessionManager)||c.resetSessionId(),this._cachedPersonProperties=null,this.config.cookieless_mode===oe)this.register_once({distinct_id:ee,$device_id:null},"");else{var p=this.config.get_device_id(Mr());this.register_once({distinct_id:p,$device_id:e?p:_},"")}this.register({$last_posthog_reset:(new Date).toISOString()},1),delete this.config.identity_distinct_id,delete this.config.identity_hash,this.reloadFeatureFlags()}setIdentity(e,t){var i;this.config.identity_distinct_id=e,this.config.identity_hash=t,this.alias(e),null==(i=this.conversations)||i._onIdentityChanged()}clearIdentity(){var e;delete this.config.identity_distinct_id,delete this.config.identity_hash,null==(e=this.conversations)||e._onIdentityCleared()}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var e,t;return null!==(e=null==(t=this.sessionManager)?void 0:t.checkAndGetSessionAndWindowId(!0).sessionId)&&void 0!==e?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";var{sessionId:t,sessionStartTimestamp:i}=this.sessionManager.checkAndGetSessionAndWindowId(!0),r=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+t);if(null!=e&&e.withTimestamp&&i){var s,n=null!==(s=e.timestampLookBack)&&void 0!==s?s:10;if(!i)return r;r+="?t="+Math.max(Math.floor(((new Date).getTime()-i)/1e3)-n,0)}return r}alias(e,t){return e===this.get_property(o)?(gr.critical("Attempting to create alias for existing People user - aborting."),-2):this._requirePersonProcessing("posthog.alias")?(Ze(t)&&(t=this.get_distinct_id()),e!==t?(this._register_single(l,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(gr.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var t=i({},this.config);if(Ye(e)){var r,s,o,a,l,u,c,d,_,h,p;yr(this.config,ta(e));var g=this._is_persistence_disabled();null==(r=this.persistence)||r.update_config(this.config,t,g),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new hn(i({},this.config,{persistence:"sessionStorage"}),g,!1);var v=this._checkLocalStorageForDebug(this.config.debug);ot(v)&&(this.config.debug=v),ot(this.config.debug)&&(this.config.debug?(n.DEBUG=!0,Br._is_supported()&&Br._set("ph_debug",!0),gr.info("set_config",{config:e,oldConfig:t,newConfig:i({},this.config)})):(n.DEBUG=!1,Br._is_supported()&&Br._remove("ph_debug"))),null==(s=this.exceptionObserver)||s.onConfigChange(),null==(o=this.exceptions)||o.onConfigChange(),null==(a=this.sessionRecording)||a.startIfEnabledOrStop(),null==(l=this.tracingHeaders)||l.startIfEnabledOrStop(),null==(u=this.autocapture)||u.startIfEnabled(),null==(c=this.heatmaps)||c.startIfEnabled(),null==(d=this.exceptionObserver)||d.startIfEnabledOrStop(),null==(_=this.deadClicksAutocapture)||_.startIfEnabledOrStop(),null==(h=this.surveys)||h.loadIfEnabled(),this._sync_opt_out_with_persistence(),null==(p=this.externalIntegrations)||p.startIfEnabledOrStop()}}_overrideSDKInfo(e,t){n.LIB_NAME=e,n.LIB_VERSION=t}startSessionRecording(e){var t,i,r,s,n,o=!0===e,a={sampling:o||!(null==e||!e.sampling),linked_flag:o||!(null==e||!e.linked_flag),url_trigger:o||!(null==e||!e.url_trigger),event_trigger:o||!(null==e||!e.event_trigger)};Object.values(a).some(Boolean)&&(null==(t=this.sessionManager)||t.checkAndGetSessionAndWindowId(),a.sampling&&(null==(i=this.sessionRecording)||i.overrideSampling()),a.linked_flag&&(null==(r=this.sessionRecording)||r.overrideLinkedFlag()),a.url_trigger&&(null==(s=this.sessionRecording)||s.overrideTrigger("url")),a.event_trigger&&(null==(n=this.sessionRecording)||n.overrideTrigger("event")));this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var e;return!(null==(e=this.sessionRecording)||!e.started)}captureException(e,t){if(this.exceptions){var r=new Error("PostHog syntheticException"),s=this.exceptions.buildProperties(e,{handled:!0,syntheticException:r});return this.exceptions.sendExceptionEvent(i({},s,t))}}addExceptionStep(e,t){var i;null==(i=this.exceptions)||i.addExceptionStep(e,t)}captureLog(e){var t;null==(t=this.logs)||t.captureLog(e)}get logger(){var e,t;return null!==(e=null==(t=this.logs)?void 0:t.logger)&&void 0!==e?e:ra._noopLogger}startExceptionAutocapture(e){this.set_config({capture_exceptions:null==e||e})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(e){var t,i;return null!==(t=null==(i=this.toolbar)?void 0:i.loadToolbar(e))&&void 0!==t&&t}get_property(e){var t;return null==(t=this.persistence)?void 0:t.props[e]}getSessionProperty(e){var t;return null==(t=this.sessionPersistence)?void 0:t.props[e]}toString(){var e,t=null!==(e=this.config.name)&&void 0!==e?e:Yo;return t!==Yo&&(t=Yo+"."+t),t}_isIdentified(){var e,t;return(null==(e=this.persistence)?void 0:e.get_property(V))===le||(null==(t=this.sessionPersistence)?void 0:t.get_property(V))===le}_hasPersonProcessing(){var e,t;return!("never"===this.config.person_profiles||this.config.person_profiles===ue&&!this._isIdentified()&&Xe(this.getGroups())&&(null==(e=this.persistence)||null==(e=e.props)||!e[l])&&(null==(t=this.persistence)||null==(t=t.props)||!t[X]))}_shouldCapturePageleave(){return!0===this.config.capture_pageleave||"if_capture_pageview"===this.config.capture_pageleave&&(!0===this.config.capture_pageview||"history_change"===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?(gr.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this._register_single(X,!0),!0)}_is_persistence_disabled(){if("always"===this.config.cookieless_mode)return!0;var e=this.consent.isOptedOut();return this.config.disable_persistence||e&&!(!this.config.opt_out_persistence_by_default&&this.config.cookieless_mode!==ne)}_sync_opt_out_with_persistence(){var e,t,i,r,s=this._is_persistence_disabled();return(null==(e=this.persistence)?void 0:e._disabled)!==s&&(null==(i=this.persistence)||i.set_disabled(s)),(null==(t=this.sessionPersistence)?void 0:t._disabled)!==s&&(null==(r=this.sessionPersistence)||r.set_disabled(s)),s}opt_in_capturing(e){var t;if(this.config.cookieless_mode!==oe){if(this._inCookielessMode()){var i,r,s,n,o;this.reset(!0),null==(i=this.sessionManager)||i.destroy(),null==(r=this.pageViewManager)||r.destroy(),this.sessionManager=new ko(this),this.pageViewManager=new Bs(this),this.persistence&&(this.sessionPropsManager=new xo(this,this.sessionManager,this.persistence));var a,l=null!==(s=null==(n=this.config.__extensionClasses)?void 0:n.sessionRecording)&&void 0!==s?s:null==(o=ra.__defaultExtensionClasses)?void 0:o.sessionRecording;l&&(this.sessionRecording=this._replaceExtension(this.sessionRecording,new l(this)),this._lastRemoteConfig&&(null==(a=this.sessionRecording)||null==a.onRemoteConfig||a.onRemoteConfig(this._lastRemoteConfig)))}var u,c;this.consent.optInOut(!0),this._sync_opt_out_with_persistence(),this._start_queue_if_opted_in(),null==(t=this.sessionRecording)||t.startIfEnabledOrStop(),this.config.cookieless_mode==ne&&(null==(u=this.surveys)||u.loadIfEnabled()),(Ze(null==e?void 0:e.captureEventName)||null!=e&&e.captureEventName)&&this.capture(null!==(c=null==e?void 0:e.captureEventName)&&void 0!==c?c:"$opt_in",null==e?void 0:e.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this._captureInitialPageview()}else gr.warn(Go)}opt_out_capturing(){var e,t,i;this.config.cookieless_mode!==oe?(this.config.cookieless_mode===ne&&this.consent.isOptedIn()&&this.reset(!0),this.consent.optInOut(!1),this._sync_opt_out_with_persistence(),this.config.cookieless_mode===ne&&(this.register({distinct_id:ee,$device_id:null}),null==(e=this.sessionRecording)||e.stopRecording(),this.sessionRecording=void 0,null==(t=this.sessionManager)||t.destroy(),null==(i=this.pageViewManager)||i.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,this.config.capture_pageview&&this._captureInitialPageview(),this._start_queue_if_opted_in())):gr.warn(Go)}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){var e=this.consent.consent;return 1===e?"granted":0===e?"denied":"pending"}is_capturing(){return this.config.cookieless_mode===oe||(this.config.cookieless_mode===ne?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 me?Po(me,this.config.custom_blocked_useragents):void 0}_captureInitialPageview(){ye&&("visible"===ye.visibilityState?this._initialPageviewCaptured||(this._initialPageviewCaptured=!0,this.capture(_e,{title:ye.title},{send_instantly:!0}),this._visibilityStateListener&&(ye.removeEventListener(ce,this._visibilityStateListener),this._visibilityStateListener=null)):this._visibilityStateListener||(this._visibilityStateListener=this._captureInitialPageview.bind(this),Pr(ye,ce,this._visibilityStateListener)))}debug(e){!1===e?(null==ve||ve.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(null==ve||ve.console.log("You're now in debug mode. All calls to PostHog will be logged in your console.\nYou can disable this with `posthog.debug(false)`."),this.set_config({debug:!0}))}_shouldDisableFlags(){var e,t,i,r,s,n,o=this._originalUserConfig||{};return"advanced_disable_flags"in o?!!o.advanced_disable_flags:!1!==this.config.advanced_disable_flags?!!this.config.advanced_disable_flags:!0===this.config.advanced_disable_decide?(gr.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):(i="advanced_disable_decide",!1,r=gr,s=(t="advanced_disable_flags")in(e=o)&&!rt(e[t]),n=i in e&&!rt(e[i]),s?e[t]:!!n&&(r&&r.warn("Config field '"+i+"' is deprecated. Please use '"+t+"' instead. The old field will be removed in a future major version."),e[i]))}_runBeforeSend(e){var t;if(rt(this.config.before_send))return e;var i=Object.keys(null!==(t=e.properties)&&void 0!==t?t:{}).filter(ut),r=Qe(this.config.before_send)?this.config.before_send:[this.config.before_send],s=e;for(var n of r){if(s=n(s),rt(s)){var o="Event '"+e.event+"' was rejected in beforeSend function";return lt(e.event)?gr.warn(o+". This can cause unexpected behavior."):gr.info(o),null}s.properties&&!Xe(s.properties)||gr.warn("Event '"+e.event+"' has no properties after beforeSend function, this is likely an error.")}for(var a of i)if(s.properties&&rt(s.properties[a]))return gr.warn("Event '"+e.event+"' had its '"+a+"' property removed in a beforeSend function. This property is required for ingestion, so the event will be dropped."),null;return s}getPageViewId(){var e;return null==(e=this.pageViewManager._currentPageview)?void 0:e.pageViewId}captureTraceFeedback(e,t){this.capture("$ai_feedback",{$ai_trace_id:String(e),$ai_feedback_text:t})}captureTraceMetric(e,t,i){this.capture("$ai_metric",{$ai_trace_id:String(e),$ai_metric_name:t,$ai_metric_value:String(i)})}_checkLocalStorageForDebug(e){var t=ot(e)&&!e,i=Br._is_supported()&&"true"===Br._get("ph_debug");return!t&&(!!i||e)}}ra.__defaultExtensionClasses={},ra._noopLogger={trace:jo=()=>{},debug:jo,info:jo,warn:jo,error:jo,fatal:jo},function(e,t){for(var i=0;t.length>i;i++)e.prototype[t[i]]=xr(e.prototype[t[i]])}(ra,["identify"]);class sa{constructor(e){this.disabled=!1===e;var t=Ye(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;var r=this.clicks[this.clicks.length-1];if(r&&Math.abs(e-r.x)+Math.abs(t-r.y)<this.thresholdPx&&this.timeoutMs>i-r.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}}var na="$copy_autocapture",oa=vr("[AutoCapture]");function aa(e,t){return t.length>e?t.slice(0,e)+"...":t}function la(e){if(e.previousElementSibling)return e.previousElementSibling;var t=e;do{t=t.previousSibling}while(t&&!Jr(t));return t}function ua(e,t){var r,s,{e:n,maskAllElementAttributes:o,maskAllText:a,elementAttributeIgnoreList:l,elementsChainAsString:u}=t;if(!Jr(e))return{props:{}};for(var c=[e],d=e;d.parentNode&&!Yr(d,"body");)if(Zr(d.parentNode))c.push(d.parentNode.host),d=d.parentNode.host;else{if(!Jr(d.parentNode))break;c.push(d.parentNode),d=d.parentNode}var _,h,p=[],g={},v=!1,f=!1;if(mr(c,(e=>{var t=ms(e);if(Yr(e,"a")){var i=e.getAttribute("href");v=t&&!!i&&Ps(i)&&i}je(is(e),"ph-no-capture")&&(f=!0),p.push(function(e,t,i,r){var s=e.tagName.toLowerCase(),n={tag_name:s};os.indexOf(s)>-1&&!i&&(n.$el_text="a"===s.toLowerCase()||"button"===s.toLowerCase()?aa(1024,Is(e)):aa(1024,ss(e)));var o=is(e);o.length>0&&(n.classes=o.filter((function(e){return""!==e}))),mr(e.attributes,(function(i){var s;if((!ys(e)||-1!==["name","id","class","aria-label"].indexOf(i.name))&&(null==r||!r.includes(i.name))&&!t&&Ps(i.value)&&(!et(s=i.name)||"_ngcontent"!==s.substring(0,10)&&"_nghost"!==s.substring(0,7))){var o=i.value;"class"===i.name&&(o=es(o).join(" ")),n["attr__"+i.name]=aa(1024,o)}}));for(var a=1,l=1,u=e;u=la(u);)a++,u.tagName===e.tagName&&l++;return n.nth_child=a,n.nth_of_type=l,n}(e,o,a,l));var r=function(e){if(!ms(e))return{};var t={};return mr(e.attributes,(function(e){if(e.name&&0===e.name.indexOf("data-ph-capture-attribute")){var i=e.name.replace("data-ph-capture-attribute-",""),r=e.value;i&&r&&Ps(r)&&(t[i]=r)}})),t}(e);yr(g,r)})),f)return{props:{},explicitNoCapture:f};if(a||(p[0].$el_text=Yr(e,"a")||Yr(e,"button")?Is(e):ss(e)),v){var m,y;p[0].attr__href=v;var b=null==(m=Us(v))?void 0:m.host,w=null==ve||null==(y=ve.location)?void 0:y.host;b&&w&&b!==w&&(_=v)}return{props:yr({$event_type:n.type,$ce_version:1},u?{}:{$elements:p},{$elements_chain:(h=p,function(e){return e.map((e=>{var t,r,s="";if(e.tag_name&&(s+=e.tag_name),e.attr_class)for(var n of(e.attr_class.sort(),e.attr_class))s+="."+n.replace(/"/g,"");var o=i({},e.text?{text:e.text}:{},{"nth-child":null!==(t=e.nth_child)&&void 0!==t?t:0,"nth-of-type":null!==(r=e.nth_of_type)&&void 0!==r?r:0},e.href?{href:e.href}:{},e.attr_id?{attr_id:e.attr_id}:{},e.attributes),a={};return br(o).sort(((e,t)=>{var[i]=e,[r]=t;return i.localeCompare(r)})).forEach((e=>{var[t,i]=e;return a[Fs(t.toString())]=Fs(i.toString())})),(s+=":")+br(a).map((e=>{var[t,i]=e;return t+'="'+i+'"'})).join("")})).join(";")}(function(e){return e.map((e=>{var t,i,r={text:null==(t=e.$el_text)?void 0:t.slice(0,400),tag_name:e.tag_name,href:null==(i=e.attr__href)?void 0:i.slice(0,2048),attr_class:Ts(e),attr_id:e.attr__id,nth_child:e.nth_child,nth_of_type:e.nth_of_type,attributes:{}};return br(e).filter((e=>{var[t]=e;return 0===t.indexOf("attr__")})).forEach((e=>{var[t,i]=e;return r.attributes[t]=i})),r}))}(h)))},null!=(r=p[0])&&r.$el_text?{$el_text:null==(s=p[0])?void 0:s.$el_text}:{},_&&"click"===n.type?{$external_click_url:_}:{},g)}}var ca=vr("[ExceptionAutocapture]"),da=vr("[TracingHeaders]"),_a=vr("[Web Vitals]"),ha=9e5,pa="disabled",ga="lazy_loading",va="awaiting_config",fa="missing_config";vr("[SessionRecording]"),vr("[SessionRecording]");var ma="[SessionRecording]",ya=vr(ma),ba=vr("[Heatmaps]");function wa(e){return Ye(e)&&"clientX"in e&&"clientY"in e&&st(e.clientX)&&st(e.clientY)}var xa=vr("[Product Tours]"),Sa=e=>{var t;return!e.config.disable_product_tours&&!(null==(t=e.persistence)||!t.get_property(f))},Ea=["$set_once","$set"],ka=vr("[SiteApps]"),Pa="Error while initializing PostHog app with config id ";function Ia(e,t,i){if(rt(e))return!1;switch(i){case"exact":return e===t;case"contains":var r=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(r,"i").test(e);case"regex":try{return new RegExp(t).test(e)}catch(e){return!1}default:return!1}}class Ca{constructor(e){this._debugEventEmitter=new So,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||!t.event||(null==e?void 0:e.event)===(null==t?void 0:t.event),this._instance=e,this._actionEvents=new Set,this._actionRegistry=new Set}init(){var e,t;Ze(null==(e=this._instance)?void 0:e._addCaptureHook)||(null==(t=this._instance)||t._addCaptureHook(((e,t)=>{this.on(e,t)})))}register(e){var t,i;if(!Ze(null==(t=this._instance)?void 0:t._addCaptureHook)&&(e.forEach((e=>{var t,i;null==(t=this._actionRegistry)||t.add(e),null==(i=e.steps)||i.forEach((e=>{var t;null==(t=this._actionEvents)||t.add((null==e?void 0:e.event)||"")}))})),null!=(i=this._instance)&&i.autocapture)){var r,s=new Set;e.forEach((e=>{var t;null==(t=e.steps)||t.forEach((e=>{null!=e&&e.selector&&s.add(null==e?void 0:e.selector)}))})),null==(r=this._instance)||r.autocapture.setElementSelectors(s)}}on(e,t){var i;null!=t&&0!=e.length&&(this._actionEvents.has(e)||this._actionEvents.has(null==t?void 0:t.event))&&this._actionRegistry&&(null==(i=this._actionRegistry)?void 0:i.size)>0&&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(var 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&&t.url){var i,r=null==e||null==(i=e.properties)?void 0:i.$current_url;if(!r||"string"!=typeof r)return!1;if(!Ia(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||!t.href)return!0;var r=this._getElementsList(e);if(r.length>0)return r.some((e=>Ia(e.href,t.href,t.href_matching||"exact")));var s,n=(null==e||null==(i=e.properties)?void 0:i.$elements_chain)||"";return!!n&&Ia((s=n.match(/(?::|")href="(.*?)"/))?s[1]:"",t.href,t.href_matching||"exact")}_checkStepText(e,t){var i;if(null==t||!t.text)return!0;var r=this._getElementsList(e);if(r.length>0)return r.some((e=>Ia(e.text,t.text,t.text_matching||"exact")||Ia(e.$el_text,t.text,t.text_matching||"exact")));var s,n,o,a=(null==e||null==(i=e.properties)?void 0:i.$elements_chain)||"";return!!a&&(s=function(e){for(var t,i=[],r=/(?::|")text="(.*?)"/g;!rt(t=r.exec(e));)i.includes(t[1])||i.push(t[1]);return i}(a),n=t.text,o=t.text_matching||"exact",s.some((e=>Ia(e,n,o))))}_checkStepSelector(e,t){var i,r;if(null==t||!t.selector)return!0;var s=null==e||null==(i=e.properties)?void 0:i.$element_selectors;if(null!=s&&s.includes(t.selector))return!0;var n=(null==e||null==(r=e.properties)?void 0:r.$elements_chain)||"";if(t.selector_regex&&n)try{return new RegExp(t.selector_regex).test(n)}catch(e){return!1}return!1}_getElementsList(e){var t;return null==(null==e||null==(t=e.properties)?void 0:t.$elements)?[]:null==e?void 0:e.properties.$elements}_checkStepProperties(e,t){return null==t||!t.properties||0===t.properties.length||Ro(t.properties.reduce(((e,t)=>{var i=Qe(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)}}class Fa{constructor(e){this._pendingActivatedItems=[],this._instance=e,this._eventToItems=new Map,this._cancelEventToItems=new Map,this._actionToItems=new Map}_doesEventMatchFilter(e,t){return!!e&&Ro(e.propertyFilters,null==t?void 0:t.properties)}_buildEventToItemMap(e,t){var i=new Map;return e.forEach((e=>{var r;null==(r=e.conditions)||null==(r=r[t])||null==(r=r.values)||r.forEach((t=>{if(null!=t&&t.name){var r=i.get(t.name)||[];r.push(e.id),i.set(t.name,r)}}))})),i}_getMatchingItems(e,t,i){var r=(i===pn?this._eventToItems:this._cancelEventToItems).get(e),s=[];return this._getItems((e=>{s=e.filter((e=>null==r?void 0:r.includes(e.id)))})),s.filter((r=>{var s,n=null==(s=r.conditions)||null==(s=s[i])||null==(s=s.values)?void 0:s.find((t=>t.name===e));return this._doesEventMatchFilter(n,t)}))}register(e){var t;Ze(null==(t=this._instance)?void 0:t._addCaptureHook)||(this._setupEventBasedItems(e),this._setupActionBasedItems(e))}_setupActionBasedItems(e){var t=e.filter((e=>{var t,i;return(null==(t=e.conditions)?void 0:t.actions)&&(null==(i=e.conditions)||null==(i=i.actions)||null==(i=i.values)?void 0:i.length)>0}));0!==t.length&&(null==this._actionMatcher&&(this._actionMatcher=new Ca(this._instance),this._actionMatcher.init(),this._actionMatcher._addActionHook((e=>{this.onAction(e)}))),t.forEach((e=>{var t,i,r,s,n;e.conditions&&null!=(t=e.conditions)&&t.actions&&null!=(i=e.conditions)&&null!=(i=i.actions)&&i.values&&(null==(r=e.conditions)||null==(r=r.actions)||null==(r=r.values)?void 0:r.length)>0&&(null==(s=this._actionMatcher)||s.register(e.conditions.actions.values),null==(n=e.conditions)||null==(n=n.actions)||null==(n=n.values)||n.forEach((t=>{if(t&&t.name){var i=this._actionToItems.get(t.name);i&&i.push(e.id),this._actionToItems.set(t.name,i||[e.id])}})))})))}_setupEventBasedItems(e){var t,i=e.filter((e=>{var t,i;return(null==(t=e.conditions)?void 0:t.events)&&(null==(i=e.conditions)||null==(i=i.events)||null==(i=i.values)?void 0:i.length)>0})),r=e.filter((e=>{var t,i;return(null==(t=e.conditions)?void 0:t.cancelEvents)&&(null==(i=e.conditions)||null==(i=i.cancelEvents)||null==(i=i.values)?void 0:i.length)>0}));0===i.length&&0===r.length||(null==(t=this._instance)||t._addCaptureHook(((e,t)=>{this.onEvent(e,t)})),this._eventToItems=this._buildEventToItemMap(e,pn),this._cancelEventToItems=this._buildEventToItemMap(e,gn))}onEvent(e,t){var i,r,s=this._getLogger(),n=(null==t||null==(i=t.properties)?void 0:i.$survey_id)||(null==t||null==(r=t.properties)?void 0:r.$product_tour_id);if(n&&this.getActivatedIds().includes(n)){var o=this._activationOutcome(e,n);if("consume"===o)return s.info("event consumed activated item, removing it",{event:e,itemId:n}),void this._deactivateItems([n]);if("persist"===o)return s.info("shown item promoted to persisted activation",{event:e,itemId:n}),void this._persistActivation(n)}if(this._cancelEventToItems.has(e)){var a=this._getMatchingItems(e,t,gn);a.length>0&&(s.info("cancel event matched, cancelling items",{event:e,itemsToCancel:a.map((e=>e.id))}),this._deactivateItems(a.map((e=>e.id))),a.forEach((e=>this._cancelPendingItem(e.id))))}if(this._eventToItems.has(e)){s.info("event name matched",{event:e,eventPayload:t,items:this._eventToItems.get(e)});var l=this._getMatchingItems(e,t,pn);this._activateItems(l.map((e=>e.id)))}}onAction(e){this._actionToItems.has(e)&&this._activateItems(this._actionToItems.get(e)||[])}_activateItems(e){0!==e.length&&(this._pendingActivatedItems=[...new Set([...this._pendingActivatedItems,...e])],this._getLogger().info("updating activated items",{activatedItems:this.getActivatedIds()}))}_persistActivation(e){this._pendingActivatedItems=this._pendingActivatedItems.filter((t=>t!==e));var t=this._getPersistedActivatedIds();t.includes(e)||this._setActivatedItems([...t,e])}_deactivateItems(e){var t=new Set(e);this._pendingActivatedItems=this._pendingActivatedItems.filter((e=>!t.has(e)));var i=this._getPersistedActivatedIds(),r=i.filter((e=>!t.has(e)));r.length!==i.length&&this._setActivatedItems(r)}_getPersistedActivatedIds(){var e,t=this._getActivatedKey();return(null==(e=this._instance)||null==(e=e.persistence)?void 0:e.props[t])||[]}getActivatedIds(){return[...new Set([...this._getPersistedActivatedIds(),...this._pendingActivatedItems])].filter((e=>!this._isItemPermanentlyIneligible(e)))}reset(){this._pendingActivatedItems=[],this._getPersistedActivatedIds().length>0&&this._setActivatedItems([])}getEventToItemsMap(){return this._eventToItems}_getActionMatcher(){return this._actionMatcher}}class Ta extends Fa{constructor(e){super(e)}_getActivatedKey(){return z}_getShownEventName(){return vn}_getItems(e){var t;null==(t=this._instance)||t.getSurveys(e)}_cancelPendingItem(e){var t;null==(t=this._instance)||t.cancelPendingSurvey(e)}_getLogger(){return Oo}_setActivatedItems(e){var t;null==(t=this._instance)||null==(t=t.persistence)||t.register({[z]:e})}_isItemPermanentlyIneligible(){return!1}_activationOutcome(e,t){var i;this._getItems((e=>{i=e.find((e=>e.id===t))}));var r=!i||function(e){var t,i,r,s=(null!==(t=null==(i=e.conditions)||null==(i=i.events)||null==(i=i.values)?void 0:i.length)&&void 0!==t?t:0)>0;return"always"===e.schedule||!(null==(r=e.conditions)||null==(r=r.events)||!r.repeatedActivation||!s)}(i);return r?e===vn?"consume":"ignore":e===vn?"persist":e===fn||e===mn?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}}var Ra="SDK is not enabled or survey functionality is not yet loaded",La="Disabled. Not loading surveys.",Ma=null!=ve&&ve.location?Gs(ve.location.hash,"__posthog")||Gs(location.hash,"state"):null,$a="_postHogToolbarParams",Aa=vr("[Toolbar]"),Oa=vr("[FeatureFlags]"),Da=vr("[FeatureFlags]",{debugEnabled:!0}),qa="\" failed. Feature flags didn't load in time.",Ba=e=>{for(var t={},i=0;e.length>i;i++)t[e[i]]=!0;return t},za=e=>{var t={};for(var[i,r]of br(e||{}))r&&(t[i]=r);return t},Ha=vr("[Error tracking]"),Na="Refusing to render web experiment since the viewer is a likely bot",ja={icontains:(e,t)=>!!ve&&t.href.toLowerCase().indexOf(e.toLowerCase())>-1,not_icontains:(e,t)=>!!ve&&-1===t.href.toLowerCase().indexOf(e.toLowerCase()),regex:(e,t)=>!!ve&&Io(t.href,e),not_regex:(e,t)=>!!ve&&!Io(t.href,e),exact:(e,t)=>t.href===e,is_not:(e,t)=>t.href!==e};class Ua{get _config(){return this._instance.config}constructor(e){var t=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(e){void 0===e&&(e=!1),t.getWebExperiments((e=>{Ua._logInfo("retrieved web experiments from the server"),t._flagToExperiments=new Map,e.forEach((e=>{if(e.feature_flag_key){var i;t._flagToExperiments&&(Ua._logInfo("setting flag key ",e.feature_flag_key," to web experiment ",e),null==(i=t._flagToExperiments)||i.set(e.feature_flag_key,e));var r=t._instance.getFeatureFlag(e.feature_flag_key);et(r)&&e.variants[r]&&t._applyTransforms(e.name,r,e.variants[r].transforms)}else if(e.variants)for(var s in e.variants){var n=e.variants[s];Ua._matchesTestVariant(n)&&t._applyTransforms(e.name,s,n.transforms)}}))}),e)},this._instance=e,this._instance.onFeatureFlags((e=>{this.onFeatureFlags(e)}))}initialize(){}onFeatureFlags(e){if(this._is_bot())Ua._logInfo(Na);else if(!this._config.disable_web_experiments){if(rt(this._flagToExperiments))return this._flagToExperiments=new Map,this.loadIfEnabled(),void this.previewWebExperiment();Ua._logInfo("applying feature flags",e),e.forEach((e=>{var t;if(this._flagToExperiments&&null!=(t=this._flagToExperiments)&&t.has(e)){var i,r=this._instance.getFeatureFlag(e),s=null==(i=this._flagToExperiments)?void 0:i.get(e);r&&null!=s&&s.variants[r]&&this._applyTransforms(s.name,r,s.variants[r].transforms)}}))}}previewWebExperiment(){var e=Ua.getWindowLocation();if(null!=e&&e.search){var t=Ws(null==e?void 0:e.search,"__experiment_id"),i=Ws(null==e?void 0:e.search,"__experiment_variant");t&&i&&(Ua._logInfo("previewing web experiments "+t+" && "+i),this.getWebExperiments((e=>{this._showPreviewWebExperiment(parseInt(t),i,e)}),!1,!0))}}loadIfEnabled(){this._config.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,t,i){if(this._config.disable_web_experiments&&!i)return e([]);var r=this._instance.get_property("$web_experiments");if(r&&!t)return e(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this._config.token),method:"GET",callback:t=>e(200===t.statusCode&&t.json&&t.json.experiments||[])})}_showPreviewWebExperiment(e,t,i){var r=i.filter((t=>t.id===e));r&&r.length>0&&(Ua._logInfo("Previewing web experiment ["+r[0].name+"] with variant ["+t+"]"),this._applyTransforms(r[0].name,t,r[0].variants[t].transforms))}static _matchesTestVariant(e){return!rt(e.conditions)&&Ua._matchUrlConditions(e)&&Ua._matchUTMConditions(e)}static _matchUrlConditions(e){var t;if(rt(e.conditions)||rt(null==(t=e.conditions)?void 0:t.url))return!0;var i,r,s,n=Ua.getWindowLocation();return!!n&&(null==(i=e.conditions)||!i.url||ja[null!==(r=null==(s=e.conditions)?void 0:s.urlMatchType)&&void 0!==r?r:"icontains"](e.conditions.url,n))}static getWindowLocation(){return null==ve?void 0:ve.location}static _matchUTMConditions(e){var t;if(rt(e.conditions)||rt(null==(t=e.conditions)?void 0:t.utm))return!0;var i=Zs();if(i.utm_source){var r,s,n,o,a,l,u,c,d=null==(r=e.conditions)||null==(r=r.utm)||!r.utm_campaign||(null==(s=e.conditions)||null==(s=s.utm)?void 0:s.utm_campaign)==i.utm_campaign,_=null==(n=e.conditions)||null==(n=n.utm)||!n.utm_source||(null==(o=e.conditions)||null==(o=o.utm)?void 0:o.utm_source)==i.utm_source,h=null==(a=e.conditions)||null==(a=a.utm)||!a.utm_medium||(null==(l=e.conditions)||null==(l=l.utm)?void 0:l.utm_medium)==i.utm_medium,p=null==(u=e.conditions)||null==(u=u.utm)||!u.utm_term||(null==(c=e.conditions)||null==(c=c.utm)?void 0:c.utm_term)==i.utm_term;return d&&h&&p&&_}return!1}static _logInfo(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;t>r;r++)i[r-1]=arguments[r];gr.info("[WebExperiments] "+e,i)}_applyTransforms(e,t,i){this._is_bot()?Ua._logInfo(Na):"control"!==t?i.forEach((i=>{if(i.selector){var r;Ua._logInfo("applying transform of variant "+t+" for experiment "+e+" ",i);var s=null==(r=document)?void 0:r.querySelectorAll(i.selector);null==s||s.forEach((e=>{var t=e;i.html&&(t.innerHTML=i.html),i.css&&t.setAttribute("style",i.css)}))}})):Ua._logInfo("Control variants leave the page unmodified.")}_is_bot(){return me&&this._instance?Po(me,this._config.custom_blocked_useragents):void 0}}var Wa=vr("[Conversations]"),Va="Conversations not available yet.",Ga={featureFlags:class{constructor(e){this._override_warning=!1,this._hasLoadedFlags=!1,this._requestInFlight=!1,this._reloadingDisabled=!1,this._additionalReloadRequested=!1,this._flagsLoadedFromRemote=!1,this._hasLoggedDeprecationWarning=!1,this._staleCacheRefreshTriggered=!1,this._instance=e,this.featureFlagEventHandlers=[]}get _config(){return this._instance.config}get _persistence(){return this._instance.persistence}_prop(e){return this._instance.get_property(e)}_isCacheStale(){var e,t;return null!==(e=null==(t=this._persistence)?void 0:t._isFeatureFlagCacheStale(this._config.feature_flag_cache_ttl_ms))&&void 0!==e&&e}_checkAndTriggerStaleRefresh(){return!!this._isCacheStale()&&(this._staleCacheRefreshTriggered||this._requestInFlight||(this._staleCacheRefreshTriggered=!0,Oa.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}_getValidEvaluationEnvironments(){var e,t=null!==(e=this._config.evaluation_contexts)&&void 0!==e?e:this._config.evaluation_environments;return!this._config.evaluation_environments||this._config.evaluation_contexts||this._hasLoggedDeprecationWarning||(Oa.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this._hasLoggedDeprecationWarning=!0),null!=t&&t.length?t.filter((e=>{var t=e&&"string"==typeof e&&e.trim().length>0;return t||Oa.error("Invalid evaluation context found:",e,"Expected non-empty string"),t})):[]}_shouldIncludeEvaluationEnvironments(){return this._getValidEvaluationEnvironments().length>0}_getValidFlagKeys(){var e=this._config.flag_keys;if(!Ze(e)){if(Qe(e))return e.filter((e=>{var t=e&&"string"==typeof e&&e.trim().length>0;return t||Oa.error("Invalid flag key found:",e,"Expected non-empty string"),t}));Oa.error("Invalid flag_keys found:",e,"Expected array of non-empty strings")}}initialize(){var e,t,{config:i}=this._instance,r=null!==(e=null==(t=i.bootstrap)?void 0:t.featureFlags)&&void 0!==e?e:{};if(Object.keys(r).length){var s,n,o=null!==(s=null==(n=i.bootstrap)?void 0:n.featureFlagPayloads)&&void 0!==s?s:{},a=Object.keys(r).filter((e=>!!r[e])).reduce(((e,t)=>(e[t]=r[t]||!1,e)),{}),l=Object.keys(o).filter((e=>a[e])).reduce(((e,t)=>(o[t]&&(e[t]=o[t]),e)),{});this.receivedFeatureFlags({featureFlags:a,featureFlagPayloads:l})}}updateFlags(e,t,r){var s,n,o=null!=r&&r.merge&&null!==(s=this._prop(I))&&void 0!==s?s:{},a=null!=r&&r.merge&&null!==(n=this._prop(R))&&void 0!==n?n:{},l=i({},o,e),u=i({},a,t),c={};for(var[d,_]of Object.entries(l))c[d]={key:d,enabled:Ce(_),variant:Fe(_),reason:void 0,metadata:Ze(null==u?void 0:u[d])?void 0:{id:0,version:void 0,description:void 0,payload:u[d]}};this.receivedFeatureFlags({flags:c})}get hasLoadedFlags(){return this._hasLoadedFlags}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var e=this._prop(T),t=this._prop(M),r=this._prop(A);if(!r&&!t)return e||{};var s=yr({},e||{}),n=[...new Set([...Object.keys(r||{}),...Object.keys(t||{})])];for(var o of n){var a,l,u=s[o],c=null==t?void 0:t[o],d=Ze(c)?null!==(a=null==u?void 0:u.enabled)&&void 0!==a&&a:!!c,_=Ze(c)?u.variant:"string"==typeof c?c:void 0,h=null==r?void 0:r[o],p=i({},u,{enabled:d,variant:d?null!=_?_:null==u?void 0:u.variant:void 0});d!==(null==u?void 0:u.enabled)&&(p.original_enabled=null==u?void 0:u.enabled),_!==(null==u?void 0:u.variant)&&(p.original_variant=null==u?void 0:u.variant),h&&(p.metadata=i({},null==u?void 0:u.metadata,{payload:h,original_payload:null==u||null==(l=u.metadata)?void 0:l.payload})),s[o]=p}return this._override_warning||(Oa.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:r,finalDetails:s}),this._override_warning=!0),s}getFlagVariants(){var e=this._prop(I),t=this._prop(M);if(!t)return e||{};for(var i=yr({},e),r=Object.keys(t),s=0;r.length>s;s++)i[r[s]]=t[r[s]];return this._override_warning||(Oa.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:i}),this._override_warning=!0),i}getFlagPayloads(){var e=this._prop(R),t=this._prop(A);if(!t)return e||{};for(var i=yr({},e||{}),r=Object.keys(t),s=0;r.length>s;s++)i[r[s]]=t[r[s]];return this._override_warning||(Oa.warn(" Overriding feature flag payloads!",{flagPayloads:e,overriddenPayloads:t,finalPayloads:i}),this._override_warning=!0),i}reloadFeatureFlags(){this._reloadingDisabled||this._config.advanced_disable_feature_flags||this._reloadDebouncer||(this._instance._internalEventEmitter.emit("featureFlagsReloading",!0),this._reloadDebouncer=setTimeout((()=>{this._callFlagsEndpoint()}),5))}_clearDebouncer(){clearTimeout(this._reloadDebouncer),this._reloadDebouncer=void 0}ensureFlagsLoaded(){this._hasLoadedFlags||this._requestInFlight||this._reloadDebouncer||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this._reloadingDisabled=e}_callFlagsEndpoint(e){var t;if(this._clearDebouncer(),!this._instance._shouldDisableFlags())if(this._requestInFlight)this._additionalReloadRequested=!0;else{var r=this._config.token,s=this._prop(a),n={token:r,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:i({},(null==(t=this._persistence)?void 0:t.get_initial_props())||{},this._prop(O)||{}),group_properties:this._prop(D),timezone:ln()};it(s)||Ze(s)||(n.$device_id=s),(null!=e&&e.disableFlags||this._config.advanced_disable_feature_flags)&&(n.disable_flags=!0),this._shouldIncludeEvaluationEnvironments()&&(n.evaluation_contexts=this._getValidEvaluationEnvironments());var o=this._getValidFlagKeys();Ze(o)||(n.flag_keys=o);var l=!!this._config.advanced_only_evaluate_survey_feature_flags,u=this._instance.requestRouter.endpointFor("flags","/flags/?v=2"+(this._config.advanced_only_evaluate_survey_feature_flags?"&only_evaluate_survey_feature_flags=true":""));this._requestInFlight=!0,this._instance._send_request({method:"POST",url:u,data:n,compression:this._config.disable_compression?void 0:kn,timeout:this._config.feature_flag_request_timeout_ms,callback:e=>{var t,i,r,s=!0;if(200===e.statusCode&&(this._additionalReloadRequested||(this.$anon_distinct_id=void 0),s=!1),this._requestInFlight=!1,!n.disable_flags||this._additionalReloadRequested){this._flagsLoadedFromRemote=!s;var o=[];e.error?e.error instanceof Error?o.push("AbortError"===e.error.name?"timeout":"connection_error"):o.push("unknown_error"):200!==e.statusCode&&o.push("api_error_"+e.statusCode),null!=(t=e.json)&&t.errorsWhileComputingFlags&&o.push("errors_while_computing_flags");var a,u=!(null==(i=e.json)||null==(i=i.quotaLimited)||!i.includes("feature_flags"));if(u&&o.push("quota_limited"),null==(r=this._persistence)||r.register({[U]:o}),u)Oa.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.");else n.disable_flags||this.receivedFeatureFlags(null!==(a=e.json)&&void 0!==a?a:{},s,{partialResponse:l}),this._additionalReloadRequested&&(this._additionalReloadRequested=!1,this._callFlagsEndpoint())}}})}}getFeatureFlag(e,t){var i;if(void 0===t&&(t={}),!t.fresh||this._flagsLoadedFromRemote)if(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0){if(!this._checkAndTriggerStaleRefresh()){var r=this.getFeatureFlagResult(e,t);return null!==(i=null==r?void 0:r.variant)&&void 0!==i?i:null==r?void 0:r.enabled}}else Oa.warn('getFeatureFlag for key "'+e+qa)}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){var t=this.getFeatureFlagResult(e,{send_event:!1});return null==t?void 0:t.payload}getFeatureFlagResult(e,t){if(void 0===t&&(t={}),!t.fresh||this._flagsLoadedFromRemote)if(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0){if(!this._checkAndTriggerStaleRefresh()){var i=this.getFlagVariants(),r=e in i,s=i[e],n=this.getFlagPayloads()[e],o=String(s),a=this._prop(L)||void 0,l=this._prop(W)||void 0,u=this._prop(N)||{};if(this._config.advanced_feature_flags_dedup_per_session){var c,d=this._instance.get_session_id(),_=this._prop(j);d&&d!==_&&(u={},null==(c=this._persistence)||c.register({[N]:u,[j]:d}))}if((t.send_event||!("send_event"in t))&&(!(e in u)||!u[e].includes(o))){var h,p,g,v,f,m,y,b,w,x;Qe(u[e])?u[e].push(o):u[e]=[o],null==(h=this._persistence)||h.register({[N]:u});var S=this.getFeatureFlagDetails(e),E=[...null!==(p=this._prop(U))&&void 0!==p?p:[]];Ze(s)&&E.push("flag_missing");var k={$feature_flag:e,$feature_flag_response:s,$feature_flag_payload:n||null,$feature_flag_request_id:a,$feature_flag_evaluated_at:l,$feature_flag_bootstrapped_response:(null==(g=this._config.bootstrap)||null==(g=g.featureFlags)?void 0:g[e])||null,$feature_flag_bootstrapped_payload:(null==(v=this._config.bootstrap)||null==(v=v.featureFlagPayloads)?void 0:v[e])||null,$used_bootstrap_value:!this._flagsLoadedFromRemote};Ze(null==S||null==(f=S.metadata)?void 0:f.version)||(k.$feature_flag_version=S.metadata.version);var P,I=null!==(m=null==S||null==(y=S.reason)?void 0:y.description)&&void 0!==m?m:null==S||null==(b=S.reason)?void 0:b.code;I&&(k.$feature_flag_reason=I),null!=S&&null!=(w=S.metadata)&&w.id&&(k.$feature_flag_id=S.metadata.id),Ze(null==S?void 0:S.original_variant)&&Ze(null==S?void 0:S.original_enabled)||(k.$feature_flag_original_response=Ze(S.original_variant)?S.original_enabled:S.original_variant),null!=S&&null!=(x=S.metadata)&&x.original_payload&&(k.$feature_flag_original_payload=null==S||null==(P=S.metadata)?void 0:P.original_payload),E.length&&(k.$feature_flag_error=E.join(",")),this._instance.capture("$feature_flag_called",k)}if(r)return{key:e,enabled:!!s,variant:"string"==typeof s?s:void 0,payload:Ie(n)}}}else Oa.warn('getFeatureFlagResult for key "'+e+qa)}getRemoteConfigPayload(e,t){var i=this._config.token,r={distinct_id:this._instance.get_distinct_id(),token:i};this._shouldIncludeEvaluationEnvironments()&&(r.evaluation_contexts=this._getValidEvaluationEnvironments());var s=this._getValidFlagKeys();Ze(s)||(r.flag_keys=s),this._instance._send_request({method:"POST",url:this._instance.requestRouter.endpointFor("flags","/flags/?v=2"),data:r,compression:this._config.disable_compression?void 0:kn,timeout:this._config.feature_flag_request_timeout_ms,callback(i){var r,s=null==(r=i.json)?void 0:r.featureFlagPayloads;t((null==s?void 0:s[e])||void 0)}})}isFeatureEnabled(e,t){if(void 0===t&&(t={}),!t.fresh||this._flagsLoadedFromRemote){if(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0){var i=this.getFeatureFlag(e,t);return Ze(i)?void 0:!!i}Oa.warn('isFeatureEnabled for key "'+e+qa)}}addFeatureFlagsHandler(e){this.featureFlagEventHandlers.push(e)}removeFeatureFlagsHandler(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((t=>t!==e))}receivedFeatureFlags(e,t,r){if(this._persistence){this._hasLoadedFlags=!0;var s=this.getFlagVariants(),n=this.getFlagPayloads(),o=this.getFlagsWithDetails();!function(e,t,r,s,n,o){void 0===r&&(r={}),void 0===s&&(s={}),void 0===n&&(n={});var a=(e=>{var t=e.flags;return t?(e.featureFlags=Object.fromEntries(Object.keys(t).map((e=>{var i;return[e,null!==(i=t[e].variant)&&void 0!==i?i:t[e].enabled]}))),e.featureFlagPayloads=Object.fromEntries(Object.keys(t).filter((e=>t[e].enabled)).filter((e=>{var i;return null==(i=t[e].metadata)?void 0:i.payload})).map((e=>{var i;return[e,null==(i=t[e].metadata)?void 0:i.payload]})))):Oa.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),e})(e),l=a.flags,u=a.featureFlags,c=a.featureFlagPayloads;if(u){var d=e.requestId,_=e.evaluatedAt;if(Qe(u)){Oa.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var h={};if(u)for(var p=0;u.length>p;p++)h[u[p]]=!0;t&&t.register({[C]:u,[I]:h})}else{var g=u,v=c,f=l;if(null!=o&&o.partialResponse)g=i({},r,g),v=i({},s,v),f=i({},n,f);else if(e.errorsWhileComputingFlags)if(l){var m=new Set(Object.keys(l).filter((e=>{var t;return!(null!=(t=l[e])&&t.failed)})));g=i({},r,Object.fromEntries(Object.entries(g).filter((e=>{var[t]=e;return m.has(t)})))),v=i({},s,Object.fromEntries(Object.entries(v||{}).filter((e=>{var[t]=e;return m.has(t)})))),f=i({},n,Object.fromEntries(Object.entries(f||{}).filter((e=>{var[t]=e;return m.has(t)}))))}else g=i({},r,g),v=i({},s,v),f=i({},n,f);t&&t.register(i({[C]:Object.keys(za(g)),[I]:g||{},[R]:v||{},[T]:f||{}},d?{[L]:d}:{},_?{[W]:_}:{}))}}}(e,this._persistence,s,n,o,r),t||(this._staleCacheRefreshTriggered=!1),this._fireFeatureFlagsCallbacks(t)}}override(e,t){void 0===t&&(t=!1),Oa.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){if(!this._instance.__loaded||!this._persistence)return Oa.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(!1===e)return this._persistence.unregister(M),this._persistence.unregister(A),this._fireFeatureFlagsCallbacks(),Da.info("All overrides cleared");if(Qe(e)){var t=Ba(e);return this._persistence.register({[M]:t}),this._fireFeatureFlagsCallbacks(),Da.info("Flag overrides set",{flags:e})}if(e&&"object"==typeof e&&("flags"in e||"payloads"in e)){var i,r=e;if(this._override_warning=Boolean(null!==(i=r.suppressWarning)&&void 0!==i&&i),"flags"in r)if(!1===r.flags)this._persistence.unregister(M),Da.info("Flag overrides cleared");else if(r.flags){if(Qe(r.flags)){var s=Ba(r.flags);this._persistence.register({[M]:s})}else this._persistence.register({[M]:r.flags});Da.info("Flag overrides set",{flags:r.flags})}return"payloads"in r&&(!1===r.payloads?(this._persistence.unregister(A),Da.info("Payload overrides cleared")):r.payloads&&(this._persistence.register({[A]:r.payloads}),Da.info("Payload overrides set",{payloads:r.payloads}))),void this._fireFeatureFlagsCallbacks()}if(e&&"object"==typeof e)return this._persistence.register({[M]:e}),this._fireFeatureFlagsCallbacks(),Da.info("Flag overrides set",{flags:e});Oa.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:e})}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this._hasLoadedFlags){var{flags:t,flagVariants:i}=this._prepareFeatureFlagsForCallbacks();e(t,i)}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t,r){var s,n=(this._prop(F)||[]).find((t=>t.flagKey===e)),o={["$feature_enrollment/"+e]:t},a={$feature_flag:e,$feature_enrollment:t,$set:o};n&&(a.$early_access_feature_name=n.name),r&&(a.$feature_enrollment_stage=r),this._instance.capture("$feature_enrollment_update",a),this.setPersonPropertiesForFlags(o,!1);var l=i({},this.getFlagVariants(),{[e]:t});null==(s=this._persistence)||s.register({[C]:Object.keys(za(l)),[I]:l}),this._fireFeatureFlagsCallbacks()}getEarlyAccessFeatures(e,t,i){void 0===t&&(t=!1);var r=this._prop(F),s=i?"&"+i.map((e=>"stage="+e)).join("&"):"";if(r&&!t)return e(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/early_access_features/?token="+this._config.token+s),method:"GET",callback:t=>{var i,r;if(t.json){var s=t.json.earlyAccessFeatures;return null==(i=this._persistence)||i.unregister(F),null==(r=this._persistence)||r.register({[F]:s}),e(s)}}})}_prepareFeatureFlagsForCallbacks(){var 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){var{flags:t,flagVariants:i}=this._prepareFeatureFlagsForCallbacks();this.featureFlagEventHandlers.forEach((r=>r(t,i,{errorsLoading:e})))}setPersonPropertiesForFlags(e,t){void 0===t&&(t=!0);var r=this._prop(O)||{},s=(null==e?void 0:e.$set)||(null!=e&&e.$set_once?{}:e),n=null==e?void 0:e.$set_once,o={};if(n)for(var a in n)({}).hasOwnProperty.call(n,a)&&(a in r||(o[a]=n[a]));this._instance.register({[O]:i({},r,o,s)}),t&&this._instance.reloadFeatureFlags()}unsetPersonPropertiesForFlags(e,t){void 0===t&&(t=!0);var r=i({},this._prop(O)||{});e.forEach((e=>{delete r[e]})),this._instance.register({[O]:r}),t&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(e){void 0===e&&(e=!0),this._instance.unregister(O),e&&this._instance.reloadFeatureFlags()}setGroupPropertiesForFlags(e,t){void 0===t&&(t=!0);var r=this._prop(D)||{};0!==Object.keys(r).length&&Object.keys(r).forEach((t=>{r[t]=i({},r[t],e[t]),delete e[t]})),this._instance.register({[D]:i({},r,e)}),t&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var t=this._prop(D)||{};this._instance.register({[D]:i({},t,{[e]:{}})})}else this._instance.unregister(D)}reset(){this._hasLoadedFlags=!1,this._requestInFlight=!1,this._reloadingDisabled=!1,this._additionalReloadRequested=!1,this._flagsLoadedFromRemote=!1,this.$anon_distinct_id=void 0,this._clearDebouncer(),this._override_warning=!1}}},Ka={sessionRecording:class{get _config(){return this._instance.config}get _persistence(){return this._instance.persistence}get started(){var e;return!(null==(e=this._lazyLoadedSessionRecording)||!e.isStarted)}get status(){var e,t;return this._recordingStatus===va||this._recordingStatus===fa?this._recordingStatus:null!==(e=null==(t=this._lazyLoadedSessionRecording)?void 0:t.status)&&void 0!==e?e:this._recordingStatus}constructor(e){if(this._forceAllowLocalhostNetworkCapture=!1,this._recordingStatus=pa,this._persistFlagsOnSessionListener=void 0,this._instance=e,!this._instance.sessionManager)throw ya.error("started without valid sessionManager"),new Error(ma+" started without valid sessionManager. This is a bug.");if(this._config.cookieless_mode===oe)throw new Error(ma+' cannot be used with cookieless_mode="always"')}initialize(){this.startIfEnabledOrStop()}get _isRecordingEnabled(){var e,t=!(null==(e=this._instance.get_property(y))||!e.enabled),i=!this._config.disable_session_recording,r=this._config.disable_session_recording||this._instance.consent.isOptedOut();return ve&&t&&i&&!r}startIfEnabledOrStop(e){var t;if(!this._isRecordingEnabled||null==(t=this._lazyLoadedSessionRecording)||!t.isStarted){var i=!Ze(Object.assign)&&!Ze(Array.from);this._isRecordingEnabled&&i?(this._lazyLoadAndStart(e),ya.info("starting")):(this._recordingStatus=pa,this.stopRecording())}}_lazyLoadAndStart(e){var t,i,r;this._isRecordingEnabled&&(this._recordingStatus!==va&&this._recordingStatus!==fa&&(this._recordingStatus=ga),null!=Pe&&null!=(t=Pe.__PosthogExtensions__)&&null!=(t=t.rrweb)&&t.record&&null!=(i=Pe.__PosthogExtensions__)&&i.initSessionRecording?this._onScriptLoaded(e):null==(r=Pe.__PosthogExtensions__)||null==r.loadExternalDependency||r.loadExternalDependency(this._instance,this._scriptName,(t=>{if(t)return ya.error("could not load recorder",t);this._onScriptLoaded(e)})))}stopRecording(){var e,t;null==(e=this._persistFlagsOnSessionListener)||e.call(this),this._persistFlagsOnSessionListener=void 0,null==(t=this._lazyLoadedSessionRecording)||t.stop()}_discardRecording(){var e,t;null==(e=this._persistFlagsOnSessionListener)||e.call(this),this._persistFlagsOnSessionListener=void 0,null==(t=this._lazyLoadedSessionRecording)||t.discard()}_resetSampling(){var e,t;null==(e=this._persistence)||e.unregister(P),null==(t=this._persistence)||t.unregister(b)}_validateSampleRate(e,t){if(rt(e))return null;var i,r=st(e)?e:parseFloat(e);return"number"!=typeof(i=r)||!Number.isFinite(i)||0>i||i>1?(ya.warn(t+" must be between 0 and 1. Ignoring invalid value:",e),null):r}_persistRemoteConfig(e){if(this._persistence){var t,r,s=this._persistence,n=()=>{var t,r=!1===e.sessionRecording?void 0:e.sessionRecording,n=this._validateSampleRate(null==(t=this._config.session_recording)?void 0:t.sampleRate,"session_recording.sampleRate"),o=this._validateSampleRate(null==r?void 0:r.sampleRate,"remote config sampleRate"),a=null!=n?n:o;rt(a)&&this._resetSampling();var l=null==r?void 0:r.minimumDurationMilliseconds;s.register({[y]:i({cache_timestamp:Date.now(),enabled:!!r},r,{networkPayloadCapture:i({capturePerformance:e.capturePerformance},null==r?void 0:r.networkPayloadCapture),canvasRecording:{enabled:null==r?void 0:r.recordCanvas,fps:null==r?void 0:r.canvasFps,quality:null==r?void 0:r.canvasQuality},sampleRate:a,minimumDurationMilliseconds:Ze(l)?null:l,endpoint:null==r?void 0:r.endpoint,triggerMatchType:null==r?void 0:r.triggerMatchType,masking:null==r?void 0:r.masking,urlTriggers:null==r?void 0:r.urlTriggers,version:null==r?void 0:r.version,triggerGroups:null==r?void 0:r.triggerGroups})})};n(),null==(t=this._persistFlagsOnSessionListener)||t.call(this),this._persistFlagsOnSessionListener=null==(r=this._instance.sessionManager)?void 0:r.onSessionId(n)}}onRemoteConfig(e){return"sessionRecording"in e?!1===e.sessionRecording?(this._persistRemoteConfig(e),void this._discardRecording()):(this._persistRemoteConfig(e),void this.startIfEnabledOrStop()):(this._recordingStatus===va&&(this._recordingStatus=fa,ya.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(e,t){var i;void 0===t&&(t="log"),null!=(i=this._lazyLoadedSessionRecording)&&i.log?this._lazyLoadedSessionRecording.log(e,t):ya.warn("log called before recorder was ready")}get _scriptName(){var e,t,i=null==(e=this._instance)||null==(e=e.persistence)?void 0:e.get_property(y);return(null==i||null==(t=i.scriptConfig)?void 0:t.script)||"lazy-recorder"}_isRemoteConfigFresh(){var e,t,i=this._instance.get_property(y);if(!i)return!1;try{t="object"==typeof i?i:JSON.parse(i)}catch(e){return ya.warn("persisted remote config for session recording is invalid and will be ignored",e),!1}var r=null!==(e=t.cache_timestamp)&&void 0!==e?e:Date.now();return 36e5>=Date.now()-r}_onScriptLoaded(e){var t,i;if(null==(t=Pe.__PosthogExtensions__)||!t.initSessionRecording)return ya.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[re]:!0});if(this._lazyLoadedSessionRecording||(this._lazyLoadedSessionRecording=null==(i=Pe.__PosthogExtensions__)?void 0:i.initSessionRecording(this._instance),this._lazyLoadedSessionRecording._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this._isRemoteConfigFresh()){if(this._recordingStatus===fa||this._recordingStatus===va)return;return this._recordingStatus=va,ya.info("persisted remote config is stale, requesting fresh config before starting"),void new Sn(this._instance).load()}this._recordingStatus=ga,this._lazyLoadedSessionRecording.start(e)}onRRwebEmit(e){var t;null==(t=this._lazyLoadedSessionRecording)||null==t.onRRwebEmit||t.onRRwebEmit(e)}overrideLinkedFlag(){var e,t;this._lazyLoadedSessionRecording||null==(t=this._persistence)||t.register({[x]:!0}),null==(e=this._lazyLoadedSessionRecording)||e.overrideLinkedFlag()}overrideSampling(){var e,t;this._lazyLoadedSessionRecording||null==(t=this._persistence)||t.register({[w]:!0}),null==(e=this._lazyLoadedSessionRecording)||e.overrideSampling()}overrideTrigger(e){var t,i;this._lazyLoadedSessionRecording||null==(i=this._persistence)||i.register({["url"===e?S:E]:!0}),null==(t=this._lazyLoadedSessionRecording)||t.overrideTrigger(e)}get sdkDebugProperties(){var e;return(null==(e=this._lazyLoadedSessionRecording)?void 0:e.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(e,t){var i;return!(null==(i=this._lazyLoadedSessionRecording)||!i.tryAddCustomEvent(e,t))}}},Qa={autocapture:class{constructor(e){this._initialized=!1,this._isDisabledServerSide=null,this._elementsChainAsString=!1,this.instance=e,this.rageclicks=new sa(e.config.rageclick),this._elementSelectors=null}initialize(){this.startIfEnabled()}get _config(){var e,t,i=Ye(this.instance.config.autocapture)?this.instance.config.autocapture:{};return i.url_allowlist=null==(e=i.url_allowlist)?void 0:e.map((e=>new RegExp(e))),i.url_ignorelist=null==(t=i.url_ignorelist)?void 0:t.map((e=>new RegExp(e))),i}_addDomEventHandlers(){if(this.isBrowserSupported()){if(ve&&ye){var e=e=>{e=e||(null==ve?void 0:ve.event);try{this._captureEvent(e)}catch(e){oa.error("Failed to capture event",e)}};if(Pr(ye,"submit",e,{capture:!0}),Pr(ye,"change",e,{capture:!0}),Pr(ye,"click",e,{capture:!0}),this._config.capture_copied_text){var t=e=>{e=e||(null==ve?void 0:ve.event);try{this._captureEvent(e,na)}catch(e){oa.error("Failed to capture copy/cut event",e)}};Pr(ye,"copy",t,{capture:!0}),Pr(ye,"cut",t,{capture:!0})}}}else oa.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this._initialized&&(this._addDomEventHandlers(),this._initialized=!0)}onRemoteConfig(e){e.elementsChainAsString&&(this._elementsChainAsString=e.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[c]:!!e.autocapture_opt_out}),this._isDisabledServerSide=!!e.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(e){this._elementSelectors=e}getElementSelectors(e){var t,i=[];return null==(t=this._elementSelectors)||t.forEach((t=>{var r=null==ye?void 0:ye.querySelectorAll(t);null==r||r.forEach((r=>{e===r&&i.push(t)}))})),i}get isEnabled(){var e,t,i=null==(e=this.instance.persistence)?void 0:e.props[c];if(it(this._isDisabledServerSide)&&!ot(i)&&!this.instance._shouldDisableFlags())return!1;var r=null!==(t=this._isDisabledServerSide)&&void 0!==t?t:!!i;return!!this.instance.config.autocapture&&!r}_captureEvent(e,t){if(void 0===t&&(t="$autocapture"),this.isEnabled){var i,r=ns(e);Xr(r)&&(r=r.parentNode||null),"$autocapture"===t&&"click"===e.type&&e instanceof MouseEvent&&this.instance.config.rageclick&&null!=(i=this.rageclicks)&&i.isRageClick(e.clientX,e.clientY,e.timeStamp||(new Date).getTime())&&gs(r,this.instance.config.rageclick)&&this._captureEvent(e,"$rageclick");var s=t===na;if(r&&function(e,t,i,r,s){var n,o,a,l,u,c;if(void 0===i&&(i=void 0),!ve||vs(e))return!1;if(null!=(n=i)&&n.url_allowlist&&!ts(i.url_allowlist))return!1;if(null!=(o=i)&&o.url_ignorelist&&ts(i.url_ignorelist))return!1;if(null!=(a=i)&&a.dom_event_allowlist){var d=i.dom_event_allowlist;if(d&&!d.some((e=>t.type===e)))return!1}var{parentIsUsefulElement:_,targetElementList:h}=fs(e,r);if(!function(e,t){var i=null==t?void 0:t.element_allowlist;if(Ze(i))return!0;var r,s=function(e){if(i.some((t=>e.tagName.toLowerCase()===t)))return{v:!0}};for(var n of e)if(r=s(n))return r.v;return!1}(h,i))return!1;if(!as(h,null==(l=i)?void 0:l.css_selector_allowlist))return!1;if(as(h,null!==(u=null==(c=i)?void 0:c.css_selector_ignorelist)&&void 0!==u?u:us))return!1;var p=ve.getComputedStyle(e);if(p&&"pointer"===p.getPropertyValue("cursor")&&"click"===t.type)return!0;var g=e.tagName.toLowerCase();switch(g){case"html":return!1;case"form":return(s||["submit"]).indexOf(t.type)>=0;case"input":case"select":case"textarea":return(s||["change","click"]).indexOf(t.type)>=0;default:return _?(s||["click"]).indexOf(t.type)>=0:(s||["click"]).indexOf(t.type)>=0&&(os.indexOf(g)>-1||"true"===e.getAttribute("contenteditable"))}}(r,e,this._config,s,s?["copy","cut"]:void 0)){var{props:n,explicitNoCapture:o}=ua(r,{e:e,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this._config.element_attribute_ignorelist,elementsChainAsString:this._elementsChainAsString});if(o)return!1;var a=this.getElementSelectors(r);if(a&&a.length>0&&(n.$element_selectors=a),t===na){var l,u=rs(null==ve||null==(l=ve.getSelection())?void 0:l.toString()),c=e.type||"clipboard";if(!u)return!1;n.$selected_content=u,n.$copy_type=c}return this.instance.capture(t,n),!0}}}isBrowserSupported(){return Je(null==ye?void 0:ye.querySelectorAll)}},historyAutocapture:class{constructor(e){var t;this._instance=e,this._lastPathname=(null==ve||null==(t=ve.location)?void 0:t.pathname)||""}initialize(){this.startIfEnabled()}get isEnabled(){return"history_change"===this._instance.config.capture_pageview}startIfEnabled(){this.isEnabled&&(gr.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this._popstateListener&&this._popstateListener(),this._popstateListener=void 0,gr.info("History API monitoring stopped")}monitorHistoryChanges(){ve&&ve.history&&(this._patchHistoryMethod("pushState"),this._patchHistoryMethod("replaceState"),this._setupPopstateListener())}_patchHistoryMethod(e){var t;if(ve&&(null==(t=ve.history[e])||!t.__posthog_wrapped__)){var i=this;!function(e,t,i){try{if(!(t in e))return()=>{};var r=e[t],s=i(r);return Je(s)&&(s.prototype=s.prototype||{},Object.defineProperties(s,{__posthog_wrapped__:{enumerable:!1,value:!0}})),e[t]=s,()=>{e[t]===s&&(e[t]=r)}}catch(e){return()=>{}}}(ve.history,e,(t=>function(r,s,n){t.call(this,r,s,n),i._capturePageview(e)}))}}_capturePageview(e){try{var t,i=null==ve||null==(t=ve.location)?void 0:t.pathname;if(!i)return;i!==this._lastPathname&&this.isEnabled&&this._instance.capture(_e,{navigation_type:e}),this._lastPathname=i}catch(t){gr.error("Error capturing "+e+" pageview",t)}}_setupPopstateListener(){if(!this._popstateListener){var e=()=>{this._capturePageview("popstate")};Pr(ve,"popstate",e),this._popstateListener=()=>{ve&&ve.removeEventListener("popstate",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)||!t.props[d]),this.rageclicks=new sa(e.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var e=5e3;return Ye(this._config.capture_heatmaps)&&this._config.capture_heatmaps.flush_interval_milliseconds&&(e=this._config.capture_heatmaps.flush_interval_milliseconds),e}get isEnabled(){return rt(this._config.capture_heatmaps)?rt(this._config.enable_heatmaps)?this._enabledServerSide:this._config.enable_heatmaps:!1!==this._config.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this._initialized)return;ba.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("heatmaps"in e){var t=!!e.heatmaps;this.instance.persistence&&this.instance.persistence.register({[d]:t}),this._enabledServerSide=t,this.startIfEnabled()}}getAndClearBuffer(){var e=this._buffer;return this._buffer=void 0,e}_onDeadClick(e){this._onClick(e.originalEvent,"deadclick")}_onVisibilityChange(){this._flushInterval&&clearInterval(this._flushInterval),this._flushInterval=function(e){return"visible"===(null==e?void 0:e.visibilityState)}(ye)?setInterval(this._flush.bind(this),this.flushIntervalMilliseconds):null}_setupListeners(){ve&&ye&&(this._flushHandler=this._flush.bind(this),Pr(ve,de,this._flushHandler),this._onClickHandler=e=>this._onClick(e||(null==ve?void 0:ve.event)),Pr(ye,"click",this._onClickHandler,{capture:!0}),this._onMouseMoveHandler=e=>this._onMouseMove(e||(null==ve?void 0:ve.event)),Pr(ye,"mousemove",this._onMouseMoveHandler,{capture:!0}),this._deadClicksCapture=new $s(this.instance,Ls,this._onDeadClick.bind(this)),this._deadClicksCapture.startIfEnabledOrStop(),this._onVisibilityChange_handler=this._onVisibilityChange.bind(this),Pr(ye,ce,this._onVisibilityChange_handler),this._initialized=!0)}_removeListeners(){var e;ve&&ye&&(this._flushHandler&&ve.removeEventListener(de,this._flushHandler),this._onClickHandler&&ye.removeEventListener("click",this._onClickHandler,{capture:!0}),this._onMouseMoveHandler&&ye.removeEventListener("mousemove",this._onMouseMoveHandler,{capture:!0}),this._onVisibilityChange_handler&&ye.removeEventListener(ce,this._onVisibilityChange_handler),clearTimeout(this._mouseMoveTimeout),null==(e=this._deadClicksCapture)||e.stop(),this._initialized=!1)}_getProperties(e,t){var i=this.instance.scrollManager.scrollY(),r=this.instance.scrollManager.scrollX(),s=this.instance.scrollManager.scrollElement(),n=function(e,t,i){for(var r=e;r&&Jr(r)&&!Yr(r,"body");){if(r===i)return!1;if(je(t,null==ve?void 0:ve.getComputedStyle(r).position))return!0;r=ls(r)}return!1}(ns(e),["fixed","sticky"],s);return{x:e.clientX+(n?0:r),y:e.clientY+(n?0:i),target_fixed:n,type:t}}_onClick(e,t){var r;if(void 0===t&&(t="click"),!Qr(e.target)&&wa(e)){var s=this._getProperties(e,t);null!=(r=this.rageclicks)&&r.isRageClick(e.clientX,e.clientY,(new Date).getTime())&&gs(ns(e),this.instance.config.rageclick)&&this._capture(i({},s,{type:"rageclick"})),this._capture(s)}}_onMouseMove(e){!Qr(e.target)&&wa(e)&&(clearTimeout(this._mouseMoveTimeout),this._mouseMoveTimeout=setTimeout((()=>{this._capture(this._getProperties(e,"mousemove"))}),500))}_capture(e){if(ve){var t=ve.location.href,i=this._config.custom_personal_data_properties,r=this._config.mask_personal_data_properties?[...Qs,...i||[]]:[],s=Vs(t,r,Ys);this._buffer=this._buffer||{},this._buffer[s]||(this._buffer[s]=[]),this._buffer[s].push(e)}}_flush(){this._buffer&&!Xe(this._buffer)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:$s,webVitalsAutocapture:class{constructor(e){var t;this._enabledServerSide=!1,this._initialized=!1,this._buffer={url:void 0,metrics:[],firstMetricTimestamp:void 0},this._flushToCapture=()=>{clearTimeout(this._delayedFlushTimer),0!==this._buffer.metrics.length&&(this._instance.capture("$web_vitals",this._buffer.metrics.reduce(((e,t)=>i({},e,{["$web_vitals_"+t.name+"_event"]:i({},t),["$web_vitals_"+t.name+"_value"]:t.value})),{})),this._buffer={url:void 0,metrics:[],firstMetricTimestamp:void 0})},this._addToBuffer=e=>{var t;this._buffer=this._buffer||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var r=this._currentURL();if(!Ze(r))if(rt(null==e?void 0:e.name)||rt(null==e?void 0:e.value))_a.error("Invalid metric received",e);else if(!this._maxAllowedValue||this._maxAllowedValue>e.value){this._buffer.url!==r&&(this._flushToCapture(),this._delayedFlushTimer=setTimeout(this._flushToCapture,this.flushToCaptureTimeoutMs)),Ze(this._buffer.url)&&(this._buffer.url=r),this._buffer.firstMetricTimestamp=Ze(this._buffer.firstMetricTimestamp)?Date.now():this._buffer.firstMetricTimestamp,e.attribution&&e.attribution.interactionTargetElement&&(e.attribution.interactionTargetElement=void 0);var s=null==(t=this._instance.sessionManager)?void 0:t.checkAndGetSessionAndWindowId(!0),n=i({},e,{$current_url:r,timestamp:Date.now()});Ze(s)||(n.$session_id=s.sessionId,n.$window_id=s.windowId),this._buffer.metrics.push(n),this._buffer.metrics.length===this.allowedMetrics.length&&this._flushToCapture()}else _a.error("Ignoring metric with value >= "+this._maxAllowedValue,e)},this._startCapturing=()=>{if(!this._initialized){var e,t,i,r,s=Pe.__PosthogExtensions__;Ze(s)||Ze(s.postHogWebVitalsCallbacks)||({onLCP:e,onCLS:t,onFCP:i,onINP:r}=s.postHogWebVitalsCallbacks),e&&t&&i&&r?(this.allowedMetrics.indexOf("LCP")>-1&&e(this._addToBuffer.bind(this)),this.allowedMetrics.indexOf("CLS")>-1&&t(this._addToBuffer.bind(this)),this.allowedMetrics.indexOf("FCP")>-1&&i(this._addToBuffer.bind(this)),this.allowedMetrics.indexOf("INP")>-1&&r(this._addToBuffer.bind(this)),this._initialized=!0):_a.error("web vitals callbacks not loaded - not starting")}},this._instance=e,this._enabledServerSide=!(null==(t=this._instance.persistence)||!t.props[g]),this.startIfEnabled()}get _perfConfig(){return this._instance.config.capture_performance}get allowedMetrics(){var e,t,i=Ye(this._perfConfig)?null==(e=this._perfConfig)?void 0:e.web_vitals_allowed_metrics:void 0;return rt(i)?(null==(t=this._instance.persistence)?void 0:t.props[m])||["CLS","FCP","INP","LCP"]:i}get flushToCaptureTimeoutMs(){return(Ye(this._perfConfig)?this._perfConfig.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var e=Ye(this._perfConfig)?this._perfConfig.web_vitals_attribution:void 0;return null!=e&&e}get _maxAllowedValue(){var e=Ye(this._perfConfig)&&st(this._perfConfig.__web_vitals_max_value)?this._perfConfig.__web_vitals_max_value:ha;return e>0&&6e4>=e?ha:e}get isEnabled(){var e=null==be?void 0:be.protocol;if("http:"!==e&&"https:"!==e)return _a.info("Web Vitals are disabled on non-http/https protocols"),!1;var t=Ye(this._perfConfig)?this._perfConfig.web_vitals:ot(this._perfConfig)?this._perfConfig:void 0;return ot(t)?t:this._enabledServerSide}startIfEnabled(){this.isEnabled&&!this._initialized&&(_a.info("enabled, starting..."),this._loadScript(this._startCapturing))}onRemoteConfig(e){if("capturePerformance"in e){var t=Ye(e.capturePerformance)&&!!e.capturePerformance.web_vitals,i=Ye(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[g]:t}),this._instance.persistence.register({[m]:i})),this._enabledServerSide=t,this.startIfEnabled()}}_loadScript(e){var t,i;null!=(t=Pe.__PosthogExtensions__)&&t.postHogWebVitalsCallbacks?e():null==(i=Pe.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,this.useAttribution?"web-vitals-with-attribution":"web-vitals",(t=>{t?_a.error("failed to load script",t):e()}))}_currentURL(){var e=ve?ve.location.href:void 0;if(e){var t=this._instance.config.custom_personal_data_properties,i=this._instance.config.mask_personal_data_properties?[...Qs,...t||[]]:[];return Vs(e,i,Ys)}_a.error("Could not determine current URL")}}},Ja={exceptionObserver:class{constructor(e){var t,i,r;this._startCapturing=()=>{var e;if(ve&&this.isEnabled&&null!=(e=Pe.__PosthogExtensions__)&&e.errorWrappingFunctions){var t=Pe.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,i=Pe.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,r=Pe.__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=r(this.captureException.bind(this)))}catch(e){ca.error("failed to start",e),this._stopCapturing()}}},this._instance=e,this._remoteEnabled=!(null==(t=this._instance.persistence)||!t.props[_]),this._rateLimiter=new ft({refillRate:null!==(i=this._instance.config.error_tracking.__exceptionRateLimiterRefillRate)&&void 0!==i?i:1,bucketSize:null!==(r=this._instance.config.error_tracking.__exceptionRateLimiterBucketSize)&&void 0!==r?r:10,refillInterval:1e4,_logger:ca}),this._config=this._requiredConfig(),this.startIfEnabledOrStop()}_requiredConfig(){var e=this._instance.config.capture_exceptions,t={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return Ye(e)?t=i({},t,e):(Ze(e)?this._remoteEnabled:e)&&(t=i({},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?(ca.info("enabled"),this._stopCapturing(),this._loadScript(this._startCapturing)):this._stopCapturing()}_loadScript(e){var t,i;null!=(t=Pe.__PosthogExtensions__)&&t.errorWrappingFunctions?e():null==(i=Pe.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"exception-autocapture",(t=>{if(t)return ca.error("failed to load script",t);e()}))}_stopCapturing(){var e,t,i;null==(e=this._unwrapOnError)||e.call(this),this._unwrapOnError=void 0,null==(t=this._unwrapUnhandledRejection)||t.call(this),this._unwrapUnhandledRejection=void 0,null==(i=this._unwrapConsoleError)||i.call(this),this._unwrapConsoleError=void 0}onRemoteConfig(e){"autocaptureExceptions"in e&&(this._remoteEnabled=!!e.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[_]:this._remoteEnabled}),this._config=this._requiredConfig(),this.startIfEnabledOrStop())}onConfigChange(){this._config=this._requiredConfig()}captureException(e){var t,i,r,s=null!==(t=null==e||null==(i=e.$exception_list)||null==(i=i[0])?void 0:i.type)&&void 0!==t?t:"Exception";this._rateLimiter.consumeRateLimit(s)?ca.info("Skipping exception capture because of client rate limiting.",{exception:s}):null==(r=this._instance.exceptions)||r.sendExceptionEvent(e)}},exceptions:class{constructor(e){var t,r;this._suppressionRules=[],this._errorPropertiesBuilder=new qi([new Ji,new or,new Xi,new Yi,new sr,new rr,new er,new nr],function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),s=1;t>s;s++)r[s-1]=arguments[s];return function(t,s){void 0===s&&(s=0);for(var n=[],o=t.split("\n"),a=s;o.length>a;a++){var l=o[a];if(1024>=l.length){var u=Qi.test(l)?l.replace(Qi,"$1"):l;if(!u.match(/\S*Error: /)){for(var c of r){var d=c(u,e);if(d){n.push(d);break}}if(n.length>=50)break}}}return function(e){if(!e.length)return[];var t=Array.from(e);return t.reverse(),t.slice(0,50).map((e=>{return i({},e,{filename:e.filename||(r=t,r[r.length-1]||{}).filename,function:e.function||Bi});var r}))}(n)}}("web:javascript",Wi,Ki)),this._instance=e,this._suppressionRules=null!==(t=null==(r=this._instance.persistence)?void 0:r.get_property(h))&&void 0!==t?t:[],this._exceptionStepsConfig=dr(this._getExceptionStepsConfig()),this._exceptionStepsBuffer=new _r(this._exceptionStepsConfig)}onConfigChange(){this._exceptionStepsConfig=dr(this._getExceptionStepsConfig()),this._exceptionStepsBuffer.setConfig(this._exceptionStepsConfig)}onRemoteConfig(e){var t,i,r;if("errorTracking"in e){var s=null!==(t=null==(i=e.errorTracking)?void 0:i.suppressionRules)&&void 0!==t?t:[],n=null==(r=e.errorTracking)?void 0:r.captureExtensionExceptions;this._suppressionRules=s,this._instance.persistence&&this._instance.persistence.register({[h]:this._suppressionRules,[p]:n})}}get _captureExtensionExceptions(){var e,t=!!this._instance.get_property(p),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(!et(e)||0===e.trim().length)return void Ha.warn("Ignoring exception step because message must be a non-empty string");var r=this._coerceExceptionStepProperties(t),{sanitizedProperties:s,droppedKeys:n}=function(e){if(!e)return{sanitizedProperties:{},droppedKeys:[]};var t=[];return{sanitizedProperties:Object.keys(e).reduce(((i,r)=>ur.has(r)?(t.push(r),i):(i[r]=e[r],i)),{}),droppedKeys:t}}(r);n.length>0&&Ha.warn("Ignoring reserved exception step fields",{droppedKeys:n}),this._exceptionStepsBuffer.add(i({[ar]:e,[lr]:(new Date).toISOString()},s))}catch(e){Ha.error("Failed to add exception step. Ignoring breadcrumb.",e)}}sendExceptionEvent(e){try{var t=e.$exception_list;if(this._isExceptionList(t)){if(this._matchesSuppressionRule(t))return this._addDroppedExceptionStep("Exception dropped: matched a suppression rule"),void Ha.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 Ha.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this._isPostHogException(t))return this._addDroppedExceptionStep("Exception dropped: thrown by the PostHog SDK"),void Ha.info("Skipping exception capture because it was thrown by the PostHog SDK")}var i=this._exceptionStepsConfig.enabled&&rt(e.$exception_steps)?this._addBufferedExceptionSteps(e):e;try{var r=this._instance.capture("$exception",i,{_noTruncate:!0,_batchKey:"exceptionEvent",_originatedFromCaptureException:!0});return r&&this._exceptionStepsBuffer.clear(),r}catch(e){return Ha.error("Failed to capture exception event. Dropping this exception.",e),void this._exceptionStepsBuffer.clear()}}catch(e){return void Ha.error("Failed to process exception event. Ignoring this exception.",e)}}_addBufferedExceptionSteps(e){try{var t=this._exceptionStepsBuffer.getAttachable();return 0===t.length?e:i({},e,{$exception_steps:t})}catch(t){return Ha.error("Failed to read buffered exception steps. Capturing exception without steps.",t),e}}_addDroppedExceptionStep(e){this._exceptionStepsConfig.enabled&&this._exceptionStepsBuffer.add({[ar]:e,[lr]:(new Date).toISOString()})}_coerceExceptionStepProperties(e){return Ye(e)?i({},e):{}}_getExceptionStepsConfig(){var e,t;return null!==(e=null==(t=this._instance.config.error_tracking)?void 0:t.exception_steps)&&void 0!==e?e:{}}_matchesSuppressionRule(e){if(0===e.length)return!1;var t=e.reduce(((e,t)=>{var{type:i,value:r}=t;return et(i)&&i.length>0&&e.$exception_types.push(i),et(r)&&r.length>0&&e.$exception_values.push(r),e}),{$exception_types:[],$exception_values:[]});return this._suppressionRules.some((e=>{var i=e.values.map((e=>{var i,r=Fo[e.operator],s=Qe(e.value)?e.value:[e.value],n=null!==(i=t[e.key])&&void 0!==i?i:[];return s.length>0&&r(s,n)}));return"OR"===e.type?i.some(Boolean):i.every(Boolean)}))}_isExtensionException(e){return e.flatMap((e=>{var t,i;return null!==(t=null==(i=e.stacktrace)?void 0:i.frames)&&void 0!==t?t:[]})).some((e=>e.filename&&e.filename.startsWith("chrome-extension://")))}_isPostHogException(e){if(e.length>0){var t,i,r,s,n=null!==(t=null==(i=e[0].stacktrace)?void 0:i.frames)&&void 0!==t?t:[],o=n[n.length-1];return null!==(r=null==o||null==(s=o.filename)?void 0:s.includes("posthog.com/static"))&&void 0!==r&&r}return!1}_isExceptionList(e){return!rt(e)&&Qe(e)}}},Ya=i({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("productTours"in e){var t,i;if(this._persistence&&this._persistence.register({[f]:!!e.productTours}),!Sa(this._instance))return!this._productTourManager&&rt(null==(t=this._persistence)?void 0:t.props[H])||xa.info("product tours disabled; stopping and clearing cached tours"),null==(i=this._productTourManager)||i.stop(),this._productTourManager=null,void this.clearCache();this.loadIfEnabled()}}loadIfEnabled(){!this._productTourManager&&Sa(this._instance)&&this._loadScript((()=>this._startProductTours()))}_loadScript(e){var t,i;null!=(t=Pe.__PosthogExtensions__)&&t.generateProductTours?e():null==(i=Pe.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"product-tours",(t=>{t?xa.error("Could not load product tours script",t):e()}))}_startProductTours(){var e;!this._productTourManager&&null!=(e=Pe.__PosthogExtensions__)&&e.generateProductTours&&(this._productTourManager=Pe.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,t){if(void 0===t&&(t=!1),!Qe(this._cachedTours)||t){var i=this._persistence;if(i){var r=i.props[H];if(Qe(r)&&!t)return this._cachedTours=r,void e(r,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/product_tours/?token="+this._instance.config.token),method:"GET",callback:t=>{if(Sa(this._instance)){var r=t.statusCode;if(200!==r||!t.json){var s="Product Tours API could not be loaded, status: "+r;return xa.error(s),void e([],{isLoaded:!1,error:s})}var n=Qe(t.json.product_tours)?t.json.product_tours:[];this._cachedTours=n,i&&i.register({[H]:n}),e(n,{isLoaded:!0})}else e([],{isLoaded:!0})}})}else e(this._cachedTours,{isLoaded:!0})}getActiveProductTours(e){rt(this._productTourManager)?e([],{isLoaded:!1,error:"Product tours not loaded"}):this._productTourManager.getActiveProductTours(e)}showProductTour(e){var t;null==(t=this._productTourManager)||t.showTourById(e)}previewTour(e){this._productTourManager?this._productTourManager.previewTour(e):this._loadScript((()=>{var t;this._startProductTours(),null==(t=this._productTourManager)||t.previewTour(e)}))}dismissProductTour(){var e;null==(e=this._productTourManager)||e.dismissTour("user_clicked_skip")}nextStep(){var e;null==(e=this._productTourManager)||e.nextStep()}previousStep(){var e;null==(e=this._productTourManager)||e.previousStep()}clearCache(){var e;this._cachedTours=null,null==(e=this._persistence)||e.unregister(H)}resetTour(e){var t;null==(t=this._productTourManager)||t.resetTour(e)}resetAllTours(){var e;null==(e=this._productTourManager)||e.resetAllTours()}cancelPendingTour(e){var t;null==(t=this._productTourManager)||t.cancelPendingTour(e)}}},Ga),Xa={siteApps:class{constructor(e){this._siteAppElementPatchCount=0,this._instance=e,this._bufferedInvocations=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}_eventCollector(e,t){if(t){var 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=Pe._POSTHOG_REMOTE_CONFIG)||null==(e=e[this._instance.config.token])?void 0:e.siteApps}initialize(){if(this.isEnabled){var e=this._instance._addCaptureHook(this._eventCollector.bind(this));this._stopBuffering=()=>{e(),this._bufferedInvocations=[],this._stopBuffering=void 0}}}globalsForEvent(e){var t,s,n,o,a,l,u;if(!e)throw new Error("Event payload is required");var c={},d=this._instance.get_property("$groups")||[],_=this._instance.get_property("$stored_group_properties")||{};for(var[h,p]of Object.entries(_))c[h]={id:d[h],type:h,properties:p};var{$set_once:g,$set:v}=e;return{event:i({},r(e,Ea),{properties:i({},e.properties,v?{$set:i({},null!==(t=null==(s=e.properties)?void 0:s.$set)&&void 0!==t?t:{},v)}:{},g?{$set_once:i({},null!==(n=null==(o=e.properties)?void 0:o.$set_once)&&void 0!==n?n:{},g)}:{}),elements_chain:null!==(a=null==(l=e.properties)?void 0:l.$elements_chain)&&void 0!==a?a:"",distinct_id:null==(u=e.properties)?void 0:u.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:c}}_prepareElementForSiteApp(e){var t,i=null==(t=e.tagName)?void 0:t.toLowerCase();return"style"===i&&this._instance.config.prepare_external_dependency_stylesheet?this._instance.config.prepare_external_dependency_stylesheet(e)||(ka.error("prepare_external_dependency_stylesheet returned null"),null):"script"===i&&this._instance.config.prepare_external_dependency_script?this._instance.config.prepare_external_dependency_script(e)||(ka.error("prepare_external_dependency_script returned null"),null):e}_patchSiteAppElementInsertionMethods(){var e,t,i,r,s,n,o,a;if(!this._instance.config.prepare_external_dependency_stylesheet&&!this._instance.config.prepare_external_dependency_script)return()=>{};var l=null==ye?void 0:ye.defaultView,u=null==l||null==(e=l.Node)?void 0:e.prototype;if(!l||!u)return()=>{};if(this._siteAppElementPatchCount++,this._restoreSiteAppElementPatches)return this._releaseSiteAppElementPatches();var c=[],d=this,_=new WeakSet,h=(e,t,i)=>{if(null!=e&&e[t]){var r=e[t];e[t]=i(r),c.push((()=>{e[t]=r}))}},p=e=>{if(_.has(e))return e;var t=d._prepareElementForSiteApp(e);return t&&_.add(t),t},g=e=>e.map((e=>"string"==typeof e?e:p(e))).filter((e=>!it(e)));return h(u,"appendChild",(e=>function(t){var i=p(t);return i?e.call(this,i):t})),h(u,"insertBefore",(e=>function(t,i){var r=p(t);return r?e.call(this,r,i):t})),h(u,"replaceChild",(e=>function(t,i){var r=p(t);return r?e.call(this,r,i):i})),[null==(t=l.Element)?void 0:t.prototype,null==(i=l.Document)?void 0:i.prototype,null==(r=l.DocumentFragment)?void 0:r.prototype].forEach((e=>{h(e,"append",(e=>function(){for(var t=arguments.length,i=new Array(t),r=0;t>r;r++)i[r]=arguments[r];return e.apply(this,g(i))})),h(e,"prepend",(e=>function(){for(var t=arguments.length,i=new Array(t),r=0;t>r;r++)i[r]=arguments[r];return e.apply(this,g(i))}))})),[null==(s=l.Element)?void 0:s.prototype,null==(n=l.CharacterData)?void 0:n.prototype,null==(o=l.DocumentType)?void 0:o.prototype].forEach((e=>{h(e,"before",(e=>function(){for(var t=arguments.length,i=new Array(t),r=0;t>r;r++)i[r]=arguments[r];return e.apply(this,g(i))})),h(e,"after",(e=>function(){for(var t=arguments.length,i=new Array(t),r=0;t>r;r++)i[r]=arguments[r];return e.apply(this,g(i))})),h(e,"replaceWith",(e=>function(){for(var t=arguments.length,i=new Array(t),r=0;t>r;r++)i[r]=arguments[r];var s=g(i);return i.length&&!s.length?void 0:e.apply(this,s)}))})),h(null==(a=l.Element)?void 0:a.prototype,"insertAdjacentElement",(e=>function(t,i){var r=p(i);return r?e.call(this,t,r):null})),this._restoreSiteAppElementPatches=()=>{c.forEach((e=>e())),this._restoreSiteAppElementPatches=void 0},this._releaseSiteAppElementPatches()}_releaseSiteAppElementPatches(){var e=!1;return()=>{var t;e||(e=!0,this._siteAppElementPatchCount--,0===this._siteAppElementPatchCount&&(null==(t=this._restoreSiteAppElementPatches)||t.call(this)))}}_runWithPreparedSiteAppElements(e,t){void 0===t&&(t=!0);var i=this._patchSiteAppElementInsertionMethods();try{var r=e(i);return t&&i(),r}catch(e){throw i(),e}}setupSiteApp(e){var t=this.apps[e.id],i=()=>{var i;!t.errored&&this._bufferedInvocations.length&&(ka.info("Processing "+this._bufferedInvocations.length+" events for site app with id "+e.id),this._bufferedInvocations.forEach((e=>this._runWithPreparedSiteAppElements((()=>null==t.processEvent?void 0:t.processEvent(e))))),t.processedBuffer=!0),Object.values(this.apps).every((e=>e.processedBuffer||e.errored))&&(null==(i=this._stopBuffering)||i.call(this))},r=!1,s=s=>{t.errored=!s,t.loaded=!0,ka.info("Site app with id "+e.id+" "+(s?"loaded":"errored")),r&&i()};try{var{processEvent:n}=this._runWithPreparedSiteAppElements((t=>e.init({posthog:this._instance,callback(e){t(),s(e)}})),!1);n&&(t.processEvent=n),r=!0}catch(t){ka.error(Pa+e.id,t),s(!1)}if(r&&t.loaded)try{i()}catch(i){ka.error("Error while processing buffered events PostHog app with config id "+e.id,i),t.errored=!0}}_setupSiteApps(){var e=this.siteAppLoaders||[];for(var t of e)this.apps[t.id]={id:t.id,loaded:!1,errored:!1,processedBuffer:!1};for(var i of e)this.setupSiteApp(i)}_onCapturedEvent(e){var t=this;if(0!==Object.keys(this.apps).length){var i=this.globalsForEvent(e),r=function(r){try{t._runWithPreparedSiteAppElements((()=>null==r.processEvent?void 0:r.processEvent(i)))}catch(t){ka.error("Error while processing event "+e.event+" for site app "+r.id,t)}};for(var s of Object.values(this.apps))r(s)}}onRemoteConfig(e){var t,i,r,s=this;if(null!=(t=this.siteAppLoaders)&&t.length)return this.isEnabled?(this._setupSiteApps(),void this._instance.on("eventCaptured",(e=>this._onCapturedEvent(e)))):void ka.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null==(i=this._stopBuffering)||i.call(this),null!=(r=e.siteApps)&&r.length)if(this.isEnabled){var n=function(e){var t;Pe["__$$ph_site_app_"+e]=s._instance,null==(t=Pe.__PosthogExtensions__)||null==t.loadSiteApp||t.loadSiteApp(s._instance,a,(t=>{if(t)return ka.error(Pa+e,t)}))};for(var{id:o,url:a}of e.siteApps)n(o)}else ka.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}},Za={tracingHeaders:class{constructor(e){this._restoreXHRPatch=void 0,this._restoreFetchPatch=void 0,this._hostnamesForPatch=void 0,this._startCapturing=()=>{var e,t,i=this._syncHostnamesForPatch();i?(Ze(this._restoreXHRPatch)&&(this._restoreXHRPatch=null==(e=Pe.__PosthogExtensions__)||null==(e=e.tracingHeadersPatchFns)?void 0:e._patchXHR(i,(()=>this._instance.get_distinct_id()),this._instance.sessionManager)),Ze(this._restoreFetchPatch)&&(this._restoreFetchPatch=null==(t=Pe.__PosthogExtensions__)||null==(t=t.tracingHeadersPatchFns)?void 0:t._patchFetch(i,(()=>this._instance.get_distinct_id()),this._instance.sessionManager))):this._stopCapturing()},this._instance=e}initialize(){this.startIfEnabledOrStop()}_loadScript(e){var t,i;null!=(t=Pe.__PosthogExtensions__)&&t.tracingHeadersPatchFns?e():null==(i=Pe.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"tracing-headers",(t=>{if(t)return da.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(){var e=this._getConfiguredHostnames();return Qe(e)?(Qe(this._hostnamesForPatch)?this._hostnamesForPatch.splice(0,this._hostnamesForPatch.length,...e):this._hostnamesForPatch=[...e],e.length>0?this._hostnamesForPatch:void 0):(Qe(this._hostnamesForPatch)&&this._hostnamesForPatch.splice(0),this._hostnamesForPatch=e||void 0,this._hostnamesForPatch)}_stopCapturing(){var e,t;null==(e=this._restoreXHRPatch)||e.call(this),null==(t=this._restoreFetchPatch)||t.call(this),this._restoreXHRPatch=void 0,this._restoreFetchPatch=void 0}startIfEnabledOrStop(){this._syncHostnamesForPatch()?this._loadScript(this._startCapturing):this._stopCapturing()}}},el=i({surveys:class{get _config(){return this._instance.config}constructor(e){this._isSurveysEnabled=void 0,this._surveyManager=null,this._isInitializingSurveys=!1,this._surveyCallbacks=[],this._getSurveysInFlightPromise=null,this._instance=e,this._surveyEventReceiver=null}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(!this._config.disable_surveys){var t=e.surveys;if(rt(t))return Oo.warn("Flags not loaded yet. Not loading surveys.");var i=Qe(t);this._isSurveysEnabled=i?t.length>0:t,Oo.info("flags response received, isSurveysEnabled: "+this._isSurveysEnabled),this.loadIfEnabled()}}reset(){try{var e;null==(e=this._surveyEventReceiver)||e.reset(),localStorage.removeItem("lastSeenSurveyDate");for(var t=[],i=0;i<localStorage.length;i++){var r=localStorage.key(i);(null!=r&&r.startsWith(Do)||null!=r&&r.startsWith("inProgressSurvey_"))&&t.push(r)}t.forEach((e=>localStorage.removeItem(e)))}catch(e){}}loadIfEnabled(){if(!this._surveyManager)if(this._isInitializingSurveys)Oo.info("Already initializing surveys, skipping...");else if(this._config.disable_surveys)Oo.info(La);else if(this._config.cookieless_mode&&this._instance.consent.isOptedOut())Oo.info("Not loading surveys in cookieless mode without consent.");else{var e=null==Pe?void 0:Pe.__PosthogExtensions__;if(e){if(!Ze(this._isSurveysEnabled)||this._config.advanced_enable_surveys){var t=this._isSurveysEnabled||this._config.advanced_enable_surveys;this._isInitializingSurveys=!0;try{var i=e.generateSurveys;if(i)return void this._completeSurveyInitialization(i,t);var r=e.loadExternalDependency;if(!r)return void this._handleSurveyLoadError(se);r(this._instance,"surveys",(i=>{i||!e.generateSurveys?this._handleSurveyLoadError("Could not load surveys script",i):this._completeSurveyInitialization(e.generateSurveys,t)}))}catch(e){throw this._handleSurveyLoadError("Error initializing surveys",e),e}finally{this._isInitializingSurveys=!1}}}else Oo.error("PostHog Extensions not found.")}}_completeSurveyInitialization(e,t){this._surveyManager=e(this._instance,t),this._surveyEventReceiver=new Ta(this._instance),Oo.info("Surveys loaded successfully"),this._notifySurveyCallbacks({isLoaded:!0})}_handleSurveyLoadError(e,t){Oo.error(e,t),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){if(void 0===t&&(t=!1),this._config.disable_surveys)return Oo.info(La),e([]);var i,r=this._instance.get_property(q);if(r&&!t)return e(r,{isLoaded:!0});"undefined"!=typeof Promise&&this._getSurveysInFlightPromise?this._getSurveysInFlightPromise.then((t=>{var{surveys:i,context:r}=t;return e(i,r)})):("undefined"!=typeof Promise&&(this._getSurveysInFlightPromise=new Promise((e=>{i=e}))),this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/surveys/?token="+this._config.token),method:"GET",timeout:this._config.surveys_request_timeout_ms,callback:t=>{var r;this._getSurveysInFlightPromise=null;var s=t.statusCode;if(200!==s||!t.json){var n="Surveys API could not be loaded, status: "+s;Oo.error(n);var o={isLoaded:!1,error:n};return e([],o),void(null==i||i({surveys:[],context:o}))}var a,l=t.json.surveys||[],u=l.filter((e=>function(e){return!(!e.start_date||e.end_date)}(e)&&(function(e){var t;return!(null==(t=e.conditions)||null==(t=t.events)||null==(t=t.values)||!t.length)}(e)||function(e){var t;return!(null==(t=e.conditions)||null==(t=t.actions)||null==(t=t.values)||!t.length)}(e))));u.length>0&&(null==(a=this._surveyEventReceiver)||a.register(u)),null==(r=this._instance.persistence)||r.register({[q]:l,[B]:Date.now()});var c={isLoaded:!0};e(l,c),null==i||i({surveys:l,context:c})}}))}_notifySurveyCallbacks(e){for(var t of this._surveyCallbacks)try{if(!e.isLoaded)return t([],e);this.getSurveys(t)}catch(e){Oo.error("Error in survey callback",e)}}getActiveMatchingSurveys(e,t){if(void 0===t&&(t=!1),!rt(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);Oo.warn("init was not called")}_getSurveyById(e){var t=null;return this.getSurveys((i=>{var r;t=null!==(r=i.find((t=>t.id===e)))&&void 0!==r?r:null})),t}_checkSurveyEligibility(e){if(rt(this._surveyManager))return{eligible:!1,reason:Ra};var t="string"==typeof e?this._getSurveyById(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(e){if(rt(this._surveyManager))return Oo.warn("init was not called"),{visible:!1,disabledReason:Ra};var t=this._checkSurveyEligibility(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return rt(this._surveyManager)?(Oo.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:Ra})):new Promise((i=>{this.getSurveys((t=>{var r,s=null!==(r=t.find((t=>t.id===e)))&&void 0!==r?r:null;if(s){var n=this._checkSurveyEligibility(s);i({visible:n.eligible,disabledReason:n.reason})}else i({visible:!1,disabledReason:"Survey not found"})}),t)}))}renderSurvey(e,t,i){var r;if(rt(this._surveyManager))Oo.warn("init was not called");else{var s="string"==typeof e?this._getSurveyById(e):e;if(null!=s&&s.id)if(qo.includes(s.type)){var n=null==ye?void 0:ye.querySelector(t);if(n)return null!=(r=s.appearance)&&r.surveyPopupDelaySeconds?(Oo.info("Rendering survey "+s.id+" with delay of "+s.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var e,t;Oo.info("Rendering survey "+s.id+" with delay of "+(null==(e=s.appearance)?void 0:e.surveyPopupDelaySeconds)+" seconds"),null==(t=this._surveyManager)||t.renderSurvey(s,n,i),Oo.info("Survey "+s.id+" rendered")}),1e3*s.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(s,n,i);Oo.warn("Survey element not found")}else Oo.warn("Surveys of type "+s.type+" cannot be rendered in the app");else Oo.warn("Survey not found")}}displaySurvey(e,t){var r;if(rt(this._surveyManager))Oo.warn("init was not called");else{var s=this._getSurveyById(e);if(s){var n=s;if(null!=(r=s.appearance)&&r.surveyPopupDelaySeconds&&t.ignoreDelay&&(n=i({},s,{appearance:i({},s.appearance,{surveyPopupDelaySeconds:0})})),t.displayType!==yn&&t.initialResponses&&Oo.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),!1===t.ignoreConditions){var o=this.canRenderSurvey(s);if(!o.visible)return void Oo.warn("Survey is not eligible to be displayed: ",o.disabledReason)}"inline"!==t.displayType?this._surveyManager.handlePopoverSurvey(n,t):this.renderSurvey(n,t.selector,t.properties)}else Oo.warn("Survey not found")}}cancelPendingSurvey(e){rt(this._surveyManager)?Oo.warn("init was not called"):this._surveyManager.cancelSurvey(e)}handlePageUnload(){var e;null==(e=this._surveyManager)||e.handlePageUnload()}}},Ga),tl={toolbar:class{constructor(e){this.instance=e}_setToolbarState(e){Pe.ph_toolbar_state=e}_getToolbarState(){var e;return null!==(e=Pe.ph_toolbar_state)&&void 0!==e?e:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(e,t,i){if(void 0===e&&(e=void 0),void 0===t&&(t=void 0),void 0===i&&(i=void 0),Ir(this.instance.config))return!1;if(!ve||!ye)return!1;e=null!=e?e:ve.location,i=null!=i?i:ve.history;try{if(!t){try{ve.localStorage.setItem("test","test"),ve.localStorage.removeItem("test")}catch(e){return!1}t=null==ve?void 0:ve.localStorage}var r,s=Ma||Gs(e.hash,"__posthog")||Gs(e.hash,"state"),n=s?wr((()=>JSON.parse(atob(decodeURIComponent(s)))))||wr((()=>JSON.parse(decodeURIComponent(s)))):null;return n&&"ph_authorize"===n.action?((r=n).source="url",r&&Object.keys(r).length>0&&(n.desiredHash?e.hash=n.desiredHash:i?i.replaceState(i.state,"",e.pathname+e.search):e.hash="")):((r=JSON.parse(t.getItem($a)||"{}")).source="localstorage",delete r.userIntent),!(!r.token||this.instance.config.token!==r.token||(this.loadToolbar(r),0))}catch(e){return!1}}_callLoadToolbar(e){var t=Pe.ph_load_toolbar||Pe.ph_load_editor;!rt(t)&&Je(t)?t(e,this.instance):Aa.warn("No toolbar load function found")}loadToolbar(e){var t=!(null==ye||!ye.getElementById(Z));if(!ve||t)return!1;var r="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,s=i({token:this.instance.config.token},e,{apiURL:this.instance.requestRouter.endpointFor("ui")},r?{instrument:!1}:{});if(ve.localStorage.setItem($a,JSON.stringify(i({},s,{source:void 0}))),2===this._getToolbarState())this._callLoadToolbar(s);else if(0===this._getToolbarState()){var n;this._setToolbarState(1),null==(n=Pe.__PosthogExtensions__)||null==n.loadExternalDependency||n.loadExternalDependency(this.instance,"toolbar",(e=>{if(e)return Aa.error("[Toolbar] Failed to load",e),void this._setToolbarState(0);this._setToolbarState(2),this._callLoadToolbar(s)})),Pr(ve,"turbolinks:load",(()=>{this._setToolbarState(0),this.loadToolbar(s)}))}return!0}_loadEditor(e){return this.loadToolbar(e)}maybeLoadEditor(e,t,i){return void 0===e&&(e=void 0),void 0===t&&(t=void 0),void 0===i&&(i=void 0),this.maybeLoadToolbar(e,t,i)}}},il=i({experiments:Ua},Ga),rl=i({},Ga,Ka,Qa,Ja,Ya,Xa,el,Za,tl,il,{conversations:class{constructor(e){this._isConversationsEnabled=void 0,this._conversationsManager=null,this._isInitializing=!1,this._remoteConfig=null,this._instance=e}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(!this._instance.config.disable_conversations){var t=e.conversations;rt(t)||(ot(t)?this._isConversationsEnabled=t:(this._isConversationsEnabled=t.enabled,this._remoteConfig=t),this.loadIfEnabled())}}reset(){var e;null==(e=this._conversationsManager)||e.reset(),this._conversationsManager=null,this._isConversationsEnabled=void 0,this._remoteConfig=null}loadIfEnabled(){if(!(this._conversationsManager||this._isInitializing||this._instance.config.disable_conversations||Ir(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var e=null==Pe?void 0:Pe.__PosthogExtensions__;if(e&&!Ze(this._isConversationsEnabled)&&this._isConversationsEnabled)if(this._remoteConfig&&this._remoteConfig.token){this._isInitializing=!0;try{var t=e.initConversations;if(t)return this._completeInitialization(t),void(this._isInitializing=!1);var i=e.loadExternalDependency;if(!i)return void this._handleLoadError(se);i(this._instance,"conversations",(t=>{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 Wa.error("Conversations enabled but missing token in remote config.")}}_completeInitialization(e){if(this._remoteConfig)try{this._conversationsManager=e(this._remoteConfig,this._instance),Wa.info("Conversations loaded successfully")}catch(e){this._handleLoadError("Error completing conversations initialization",e)}else Wa.error("Cannot complete initialization: remote config is null")}_handleLoadError(e,t){Wa.error(e,t),this._conversationsManager=null,this._isInitializing=!1}show(){this._conversationsManager?this._conversationsManager.show():Wa.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this._isConversationsEnabled&&!it(this._conversationsManager)}isVisible(){var e,t;return null!==(e=null==(t=this._conversationsManager)?void 0:t.isVisible())&&void 0!==e&&e}sendMessage(e,i,r){var s=this;return t((function*(){return s._conversationsManager?s._conversationsManager.sendMessage(e,i,r):(Wa.warn(Va),null)}))()}getMessages(e,i){var r=this;return t((function*(){return r._conversationsManager?r._conversationsManager.getMessages(e,i):(Wa.warn(Va),null)}))()}markAsRead(e){var i=this;return t((function*(){return i._conversationsManager?i._conversationsManager.markAsRead(e):(Wa.warn(Va),null)}))()}getTickets(e){var i=this;return t((function*(){return i._conversationsManager?i._conversationsManager.getTickets(e):(Wa.warn(Va),null)}))()}requestRestoreLink(e){var i=this;return t((function*(){return i._conversationsManager?i._conversationsManager.requestRestoreLink(e):(Wa.warn(Va),null)}))()}restoreFromToken(e){var i=this;return t((function*(){return i._conversationsManager?i._conversationsManager.restoreFromToken(e):(Wa.warn(Va),null)}))()}restoreFromUrlToken(){var e=this;return t((function*(){return e._conversationsManager?e._conversationsManager.restoreFromUrlToken():(Wa.warn(Va),null)}))()}getCurrentTicketId(){var e,t;return null!==(e=null==(t=this._conversationsManager)?void 0:t.getCurrentTicketId())&&void 0!==e?e:null}getWidgetSessionId(){var e,t;return null!==(e=null==(t=this._conversationsManager)?void 0:t.getWidgetSessionId())&&void 0!==e?e:null}_onIdentityChanged(){var e;null==(e=this._conversationsManager)||e.setIdentity()}_onIdentityCleared(){var e;null==(e=this._conversationsManager)||e.clearIdentity()}}},{logs:class{constructor(e){var t;this._isLogsEnabled=!1,this._isLoaded=!1,this._logger=vr("[logs]"),this._queue=[],this._onReconnect=()=>{var e;null==(e=this._core)||e.onReconnect()},this._instance=e,this._instance&&null!=(t=this._instance.config.logs)&&t.captureConsoleLogs&&(this._isLogsEnabled=!0),ve&&Pr(ve,"online",this._onReconnect)}_getCore(){var e,t,i,r,s,n,o,a,l,u,c,d,_,h,p=null==(e=this._instance)||null==(e=e.config)?void 0:e.logs;return this._core&&this._resolvedFrom===p||(null==(t=this._core)||t.reset(),this._resolvedFrom=p,this._resolvedConfig=(u=null!==(r=null==(i=p)?void 0:i.flushIntervalMs)&&void 0!==r?r:3e3,c=null!==(s=null==i?void 0:i.maxBufferSize)&&void 0!==s?s:100,d=null!==(n=null==i?void 0:i.maxLogsPerInterval)&&void 0!==n?n:1e3,_=Math.max(c,d),{serviceName:null!==(o=null==(h=null==i?void 0:i.resourceAttributes)?void 0:h["service.name"])&&void 0!==o?o:null==i?void 0:i.serviceName,serviceVersion:null!==(a=null==h?void 0:h["service.version"])&&void 0!==a?a:null==i?void 0:i.serviceVersion,environment:null!==(l=null==h?void 0:h["deployment.environment"])&&void 0!==l?l:null==i?void 0:i.environment,resourceAttributes:h,beforeSend:null==i?void 0:i.beforeSend,flushIntervalMs:u,maxBufferSize:c,maxQueueSize:_,maxBatchRecordsPerPost:100,rateCapWindowMs:u,maxLogsPerInterval:d,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}),this._core=new Mi(this._createHost(),this._resolvedConfig,this._logger,(()=>this._getSdkContext()),(e=>e()))),this._core}_getResolvedConfig(){return this._getCore(),this._resolvedConfig}initialize(){this.loadIfEnabled()}onRemoteConfig(e){var t,i=null==(t=e.logs)?void 0:t.captureConsoleLogs;!rt(i)&&i&&(this._isLogsEnabled=!0,this.loadIfEnabled())}reset(){var e;this._queue=[],null==(e=this._core)||e.reset()}captureLog(e){this._getCore().captureLog(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){e?this._flushViaTransport(e):this._getCore().flush().catch((e=>this._logger.error("PostHog logs flush failed:",e)))}loadIfEnabled(){if(this._isLogsEnabled&&!this._isLoaded){var e=null==Pe?void 0:Pe.__PosthogExtensions__;if(e){var t=e.loadExternalDependency;t?t(this._instance,"logs",(t=>{var i;t||null==(i=e.logs)||!i.initializeLogs?this._logger.error("Could not load logs script",t):(e.logs.initializeLogs(this._instance),this._isLoaded=!0)})):this._logger.error(se)}else this._logger.error("PostHog Extensions not found.")}}_createHost(){var e=this._instance;return{get isDisabled(){return!1},get optedOut(){return!e.is_capturing()},getPersistedProperty:e=>e===Re.LogsQueue?this._queue:void 0,setPersistedProperty:(e,t)=>{var i;e===Re.LogsQueue&&(this._queue=null!==(i=t)&&void 0!==i?i:[])},_sendLogsBatch:e=>this._sendLogsBatch(e),getLibraryId:()=>n.LIB_NAME,getLibraryVersion:()=>n.LIB_VERSION}}_sendLogsBatch(e){return new Promise((t=>{var i=!1,r=e=>{i||(i=!0,clearTimeout(s),t(e))},s=setTimeout((()=>r({kind:"retry-later",error:new Error("logs request timed out")})),9e4);this._instance._send_request({method:"POST",url:this._logsUrl(),data:e,compression:"best-available",batchKey:"logs",fireCallbackOnDrop:!0,callback(e){var t=e.statusCode;if(t>=200&&300>t)r({kind:"ok"});else if(413===t)r({kind:"too-large"});else if(0!==t&&429!==t&&500>t)r({kind:"fatal",error:new Error("logs request failed with status "+t)});else{var i;r({kind:"retry-later",error:null!==(i=e.error)&&void 0!==i?i:new Error("logs request failed with status "+t)})}}})}))}_flushViaTransport(e){var t=this._getResolvedConfig();if(0!==this._queue.length){var i=this._queue.map((e=>e.record));this._queue=[];var r=Li(i,Ri(t,n.LIB_NAME,n.LIB_VERSION),n.LIB_NAME,n.LIB_VERSION);this._instance._send_request({method:"POST",url:this._logsUrl(),data:r,compression:"best-available",batchKey:"logs",transport:e})}}_logsUrl(){return this._instance.requestRouter.endpointFor("api","/i/v1/logs")+"?token="+encodeURIComponent(this._instance.config.token)}_getSdkContext(){var e,t={};if(t.distinctId=this._instance.get_distinct_id(),this._instance.sessionManager){var{sessionId:i}=this._instance.sessionManager.checkAndGetSessionAndWindowId(!0);t.sessionId=i}if(null!=Pe&&null!=(e=Pe.location)&&e.href&&(t.currentUrl=Pe.location.href),this._instance.featureFlags){var r=this._instance.featureFlags.getFlags();r&&r.length>0&&(t.activeFeatureFlags=r)}return t}}});ra.__defaultExtensionClasses=i({},rl),function(){n.SDK_DIST_CHANNEL="cdn";var e=Uo[Yo]=new ra,t=Pe.posthog;t&&mr(t._i,(function(i){if(i&&Qe(i)){var r=e.init(i[0],i[1],i[2]),s=t[i[2]]||t;r&&(r._execute_array.call(r.people,s.people),r._execute_array(s))}})),Pe.posthog=e,function(){function e(){e.done||(e.done=!0,Xo=!1,mr(Uo,(function(e){e._dom_loaded()})))}null!=ye&&ye.addEventListener?"complete"===ye.readyState?e():Pr(ye,"DOMContentLoaded",e,{capture:!1}):ve&&gr.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}()}()}();
|
|
1
|
+
!function(){"use strict";function e(e,t,i,r,s,n,o){try{var a=e[n](o),l=a.value}catch(e){return void i(e)}a.done?t(l):Promise.resolve(l).then(r,s)}function t(t){return function(){var i=this,r=arguments;return new Promise((function(s,n){var o=t.apply(i,r);function a(t){e(o,s,n,a,l,"next",t)}function l(t){e(o,s,n,a,l,"throw",t)}a(void 0)}))}}function i(){return i=Object.assign?Object.assign.bind():function(e){for(var t=1;arguments.length>t;t++){var i=arguments[t];for(var r in i)({}).hasOwnProperty.call(i,r)&&(e[r]=i[r])}return e},i.apply(null,arguments)}function r(e,t){if(null==e)return{};var i={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;i[r]=e[r]}return i}var s="1.391.8",n={DEBUG:!1,LIB_VERSION:s,LIB_NAME:"web",JS_SDK_VERSION:s},o="$people_distinct_id",a="$device_id",l="__alias",u="__timers",c="$autocapture_disabled_server_side",d="$heatmaps_enabled_server_side",_="$exception_capture_enabled_server_side",h="$error_tracking_suppression_rules",p="$error_tracking_capture_extension_exceptions",g="$web_vitals_enabled_server_side",v="$dead_clicks_enabled_server_side",f="$product_tours_enabled_server_side",m="$web_vitals_allowed_metrics",y="$session_recording_remote_config",b="$replay_sample_rate",w="$replay_override_sampling",x="$replay_override_linked_flag",S="$replay_override_url_trigger",E="$replay_override_event_trigger",k="$sesid",P="$session_is_sampled",I="$enabled_feature_flags",C="$active_feature_flags",F="$early_access_features",T="$feature_flag_details",R="$feature_flag_payloads",L="$feature_flag_request_id",M="$override_feature_flags",A="$override_feature_flag_payloads",O="$stored_person_properties",D="$stored_group_properties",q="$surveys",B="$surveys_loaded_at",z="$surveys_activated",H="ph_product_tours",N="$flag_call_reported",j="$flag_call_reported_session_id",U="$feature_flag_errors",W="$feature_flag_evaluated_at",V="$user_state",G="$client_session_props",K="$capture_rate_limit",Q="$initial_campaign_params",J="$initial_referrer_info",Y="$initial_person_info",X="$epp",Z="__POSTHOG_TOOLBAR__",ee="$posthog_cookieless",te="$sdk_debug_extensions_init_method",ie="$sdk_debug_extensions_init_time_ms",re="$sdk_debug_recording_script_not_loaded",se="PostHog loadExternalDependency extension not found.",ne="on_reject",oe="always",ae="anonymous",le="identified",ue="identified_only",ce="visibilitychange",de="beforeunload",_e="$pageview",he="$pageleave",pe="$identify",ge="$groupidentify",ve="undefined"!=typeof window?window:void 0,fe="undefined"!=typeof globalThis?globalThis:ve;"undefined"==typeof self&&(fe.self=fe),"undefined"==typeof File&&(fe.File=function(){});var me=null==fe?void 0:fe.navigator,ye=null==fe?void 0:fe.document,be=null==fe?void 0:fe.location,we=null==fe?void 0:fe.fetch,xe=null!=fe&&fe.XMLHttpRequest&&"withCredentials"in new fe.XMLHttpRequest?fe.XMLHttpRequest:void 0,Se=null==fe?void 0:fe.AbortController,Ee=null==fe?void 0:fe.CompressionStream,ke=null==me?void 0:me.userAgent,Pe=null!=ve?ve:{},Ie=e=>{if("string"!=typeof e)return e;try{return JSON.parse(e)}catch(t){return e}};function Ce(e){return"string"==typeof e||e}function Fe(e){return"string"==typeof e?e:void 0}var Te,Re=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.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.SurveyLastSeenDate="survey_last_seen_date",e.SurveysSeen="surveys_seen",e.Surveys="surveys",e.RemoteConfig="remote_config",e.FlagsEndpointWasHit="flags_endpoint_was_hit",e.DeviceId="device_id",e}({}),Le=function(e){return e.GZipJS="gzip-js",e.Base64="base64",e}({}),Me=["$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"],$e=["token"],Ae="NativeGzipValidationError",Oe=e=>e.length>=2&&31===e[0]&&139===e[1],De=e=>!(!e||"object"!=typeof e)&&"NotReadableError"===("name"in e?String(e.name):""),qe=e=>{var t=new Error("Native gzip produced invalid output: "+e);throw t.name=Ae,t},Be=function(){var e=t((function*(e,t){18>e.size&&qe("too-short");var i=new Uint8Array(yield e.slice(0,10).arrayBuffer());Oe(i)&&8===i[2]||qe("invalid-header");var r=new DataView(yield e.slice(e.size-8).arrayBuffer());r.getUint32(0,!0)!==(e=>{for(var t=(()=>{if(Te)return Te;Te=[];for(var e=0;256>e;e++){for(var t=e,i=0;8>i;i++)t=1&t?3988292384^t>>>1:t>>>1;Te[e]=t>>>0}return Te})(),i=4294967295,r=0;e.length>r;r++)i=t[255&(i^e[r])]^i>>>8;return(4294967295^i)>>>0})(t)&&qe("invalid-crc");var s=t.length>>>0;r.getUint32(4,!0)!==s&&qe("invalid-size")}));return function(t,i){return e.apply(this,arguments)}}();function ze(){return ze=t((function*(e,i,r){void 0===i&&(i=!0);try{var s=(new TextEncoder).encode(e),n=new CompressionStream("gzip"),o=n.writable.getWriter(),a=o.write(s).then((()=>o.close())).catch(function(){var e=t((function*(e){try{yield o.abort(e)}catch(e){}throw e}));return function(t){return e.apply(this,arguments)}}()),l=new Response(n.readable).blob(),[u]=yield Promise.all([l,a]);return yield Be(u,s),u}catch(e){if(null!=r&&r.rethrow)throw e;return i&&console.error("Failed to gzip compress data",e),null}})),ze.apply(this,arguments)}var He=["amazonbot","amazonproductbot","app.hypefactors.com","applebot","archive.org_bot","awariobot","backlinksextendedbot","baiduspider","bingbot","bingpreview","chrome-lighthouse","dataforseobot","deepscan","duckduckbot","facebookexternal","facebookcatalog","http://yandex.com/bots","hubspot","ia_archiver","leikibot","linkedinbot","meta-externalagent","mj12bot","msnbot","nessus","petalbot","pinterest","prerender","rogerbot","screaming frog","sebot-wa","sitebulb","slackbot","slurp","trendictionbot","turnitin","twitterbot","vercel-screenshot","vercelbot","yahoo! slurp","yandexbot","zoombot","bot.htm","bot.php","(bot;","bot/","crawler","ahrefsbot","ahrefssiteaudit","semrushbot","siteauditbot","splitsignalbot","gptbot","oai-searchbot","chatgpt-user","perplexitybot","better uptime bot","sentryuptimebot","uptimerobot","headlesschrome","cypress","google-hoteladsverifier","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleother","google-cloudvertexbot","googleweblight","mediapartners-google","storebot-google","google-inspectiontool","bytespider"],Ne=function(e,t){if(void 0===t&&(t=[]),!e)return!1;var i=e.toLowerCase();return He.concat(t).some((e=>{var t=e.toLowerCase();return-1!==i.indexOf(t)}))};function je(e,t){return-1!==e.indexOf(t)}var Ue=function(e){return e.trim()},We=function(e){return e.replace(/^\$/,"")},Ve=Object.prototype,Ge=Ve.hasOwnProperty,Ke=Ve.toString,Qe=Array.isArray||function(e){return"[object Array]"===Ke.call(e)},Je=e=>"function"==typeof e,Ye=e=>e===Object(e)&&!Qe(e),Xe=e=>{if(Ye(e)){for(var t in e)if(Ge.call(e,t))return!1;return!0}return!1},Ze=e=>void 0===e,et=e=>"[object String]"==Ke.call(e),tt=e=>et(e)&&0===e.trim().length,it=e=>null===e,rt=e=>Ze(e)||it(e),st=e=>"[object Number]"==Ke.call(e)&&e==e,nt=e=>st(e)&&e>0,ot=e=>"[object Boolean]"===Ke.call(e),at=e=>e instanceof FormData,lt=e=>je(Me,e),ut=e=>je($e,e);function ct(e){return null===e||"object"!=typeof e}function dt(e,t){return{}.toString.call(e)==="[object "+t+"]"}function _t(e){return"undefined"!=typeof Event&&function(e,t){try{return e instanceof t}catch(e){return!1}}(e,Event)}var ht=[!0,"true",1,"1","yes"],pt=e=>je(ht,e),gt=[!1,"false",0,"0","no"];function vt(e,t,i,r,s){return t>i&&(r.warn("min cannot be greater than max."),t=i),st(e)?e>i?(r.warn(" cannot be greater than max: "+i+". Using max value instead."),i):t>e?(r.warn(" cannot be less than min: "+t+". Using min value instead."),t):e:(r.warn(" must be a number. using max or fallback. max: "+i+", fallback: "+s),vt(s||i,t,i,r))}class ft{constructor(e){this._buckets={},this._onBucketRateLimited=e._onBucketRateLimited,this._bucketSize=vt(e.bucketSize,0,100,e._logger),this._refillRate=vt(e.refillRate,0,this._bucketSize,e._logger),this._refillInterval=vt(e.refillInterval,0,864e5,e._logger)}_applyRefill(e,t){var 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,i=Date.now(),r=String(e),s=this._buckets[r];return s?this._applyRefill(s,i):this._buckets[r]=s={tokens:this._bucketSize,lastAccess:i},0===s.tokens||(s.tokens--,0===s.tokens&&(null==(t=this._onBucketRateLimited)||t.call(this,e)),0===s.tokens)}stop(){this._buckets={}}}var mt="Mobile",yt="iOS",bt="Android",wt="Tablet",xt=bt+" "+wt,St="iPad",Et="Apple",kt=Et+" Watch",Pt="Safari",It="BlackBerry",Ct="Samsung",Ft=Ct+"Browser",Tt=Ct+" Internet",Rt="Chrome",Lt=Rt+" OS",Mt=Rt+" "+yt,$t="Internet Explorer",At=$t+" "+mt,Ot="Opera",Dt=Ot+" Mini",qt="Edge",Bt="Microsoft "+qt,zt="Firefox",Ht=zt+" "+yt,Nt="Nintendo",jt="PlayStation",Ut="Xbox",Wt=bt+" "+mt,Vt=mt+" "+Pt,Gt="Windows",Kt=Gt+" Phone",Qt="Nokia",Jt="Ouya",Yt="Generic",Xt=Yt+" "+mt.toLowerCase(),Zt=Yt+" "+wt.toLowerCase(),ei="Konqueror",ti="Oculus Browser",ii="Vivaldi",ri="Yandex",si="Whale",ni="DuckDuckGo",oi="Pale Moon",ai="Waterfox",li="Brave",ui="Google Search App",ci="(\\d+(\\.\\d+)?)",di=new RegExp("Version/"+ci),_i=new RegExp(Ut,"i"),hi=new RegExp(jt+" \\w+","i"),pi=new RegExp(Nt+" \\w+","i"),gi=new RegExp(It+"|PlayBook|BB10","i"),vi={"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"},fi=function(e,t,i,r){t=t||"";var s=function(e){return null!=e&&e.brave?li:null}(i);return s||(null!=r&&r.detectGoogleSearchApp&&je(e,"GSA/")?ui:je(e," OPR/")&&je(e,"Mini")?Dt:je(e," OPR/")?Ot:gi.test(e)?It:je(e,"IE"+mt)||je(e,"WPDesktop")?At:je(e,"OculusBrowser")?ti:je(e,Ft)?Tt:je(e,qt)||je(e,"Edg/")?Bt:je(e,ii+"/")?ii:je(e,"YaBrowser/")?ri:je(e,si+"/")?si:je(e,ni+"/")||je(e,"Ddg/")?ni:je(e,"FBIOS")?"Facebook "+mt:je(e,"UCWEB")||je(e,"UCBrowser")?"UC Browser":je(e,"CriOS")?Mt:je(e,"CrMo")||je(e,Rt)?Rt:je(e,bt)&&je(e,Pt)?Wt:je(e,"FxiOS")?Ht:je(e.toLowerCase(),ei.toLowerCase())?ei:je(e,li+"/")?li:((e,t)=>t&&je(t,Et)||function(e){return je(e,Pt)&&!je(e,Rt)&&!je(e,bt)}(e))(e,t)?je(e,mt)?Vt:Pt:je(e,"PaleMoon/")?oi:je(e,ai+"/")?ai:je(e,zt)?zt:je(e,"MSIE")||je(e,"Trident/")?$t:je(e,"Gecko")?zt:"")},mi={[At]:[new RegExp("rv:"+ci)],[Bt]:[new RegExp(qt+"?\\/"+ci)],[Rt]:[new RegExp("("+Rt+"|CrMo)\\/"+ci)],[Mt]:[new RegExp("CriOS\\/"+ci)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+ci)],[Pt]:[di],[Vt]:[di],[Ot]:[new RegExp("(Opera|OPR)\\/"+ci)],[zt]:[new RegExp(zt+"\\/"+ci)],[Ht]:[new RegExp("FxiOS\\/"+ci)],[ei]:[new RegExp("Konqueror[:/]?"+ci,"i")],[It]:[new RegExp(It+" "+ci),di],[Wt]:[new RegExp("android\\s"+ci,"i")],[Tt]:[new RegExp(Ft+"\\/"+ci)],[ti]:[new RegExp("OculusBrowser\\/"+ci)],[ii]:[new RegExp(ii+"\\/"+ci)],[ri]:[new RegExp("YaBrowser\\/"+ci)],[si]:[new RegExp(si+"\\/"+ci)],[li]:[new RegExp(li+"\\/"+ci)],[ni]:[new RegExp("(DuckDuckGo|Ddg)\\/"+ci)],[oi]:[new RegExp("PaleMoon\\/"+ci)],[ai]:[new RegExp(ai+"\\/"+ci)],[ui]:[new RegExp("GSA\\/"+ci)],[$t]:[new RegExp("(rv:|MSIE )"+ci)],Mozilla:[new RegExp("rv:"+ci)]},yi=function(e,t,i,r){var s=fi(e,t,i,r),n=mi[s];if(Ze(n))return null;for(var o=0;n.length>o;o++){var a=e.match(n[o]);if(a)return parseFloat(a[a.length-2])}return null},bi=[[new RegExp(Ut+"; "+Ut+" (.*?)[);]","i"),e=>[Ut,e&&e[1]||""]],[new RegExp(Nt,"i"),[Nt,""]],[new RegExp(jt,"i"),[jt,""]],[gi,[It,""]],[new RegExp(Gt,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[Kt,""];if(new RegExp(mt).test(t)&&!/IEMobile\b/.test(t))return[Gt+" "+mt,""];var i=/Windows NT ([0-9.]+)/i.exec(t);if(i&&i[1]){var r=vi[i[1]]||"";return/arm/i.test(t)&&(r="RT"),[Gt,r]}return[Gt,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>e&&e[3]?[yt,[e[3],e[4],e[5]||"0"].join(".")]:[yt,""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var t="";return e&&e.length>=3&&(t=Ze(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("("+bt+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+bt+")","i"),e=>e&&e[2]?[bt,[e[2],e[3],e[4]||"0"].join(".")]:[bt,""]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{var t=["Mac OS X",""];return e&&e[1]&&(t[1]=[e[1],e[2],e[3]||"0"].join(".")),t}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[Lt,""]],[/Linux|debian/i,["Linux",""]]],wi=function(e){return pi.test(e)?Nt:hi.test(e)?jt:_i.test(e)?Ut:new RegExp(Jt,"i").test(e)?Jt:new RegExp("("+Kt+"|WPDesktop)","i").test(e)?Kt:/iPad/.test(e)?St:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?kt:gi.test(e)?It:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(Qt,"i").test(e)?Qt:/(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(mt).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)?bt:xt:new RegExp("(pda|"+mt+")","i").test(e)?Xt:new RegExp(wt,"i").test(e)&&!new RegExp(wt+" pc","i").test(e)?Zt:""},xi=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function Si(e,t){return"string"==typeof(i=e)&&xi.test(i)?e:t();var i}function Ei(e,t){var i=setTimeout(e,t);return(null==i?void 0:i.unref)&&(null==i||i.unref()),i}var ki=e=>e instanceof Error,Pi={trace:{text:"TRACE",number:1},debug:{text:"DEBUG",number:5},info:{text:"INFO",number:9},warn:{text:"WARN",number:13},error:{text:"ERROR",number:17},fatal:{text:"FATAL",number:21}},Ii=Pi.info;function Ci(e){if(ot(e))return{boolValue:e};if("number"==typeof e)return Number.isFinite(e)?Number.isInteger(e)?{intValue:e}:{doubleValue:e}:{stringValue:String(e)};if("string"==typeof e)return{stringValue:e};if(Qe(e))return{arrayValue:{values:e.map((e=>Ci(e)))}};try{return{stringValue:JSON.stringify(e)}}catch(t){return{stringValue:String(e)}}}function Fi(e){var t=[];for(var i in e){var r=e[i];it(r)||Ze(r)||t.push({key:i,value:Ci(r)})}return t}function Ti(e,t){var r=e.level||"info",{text:s,number:n}=Pi[r]||Ii,o=String(Date.now())+"000000",a={};t.distinctId&&(a.posthogDistinctId=t.distinctId),t.sessionId&&(a.sessionId=t.sessionId),t.currentUrl&&(a["url.full"]=t.currentUrl),t.screenName&&(a["screen.name"]=t.screenName),t.appState&&(a["app.state"]=t.appState),t.activeFeatureFlags&&t.activeFeatureFlags.length>0&&(a.feature_flags=t.activeFeatureFlags);var l=i({},a,e.attributes||{}),u={timeUnixNano:o,observedTimeUnixNano:o,severityNumber:n,severityText:s,body:{stringValue:e.body},attributes:Fi(l)};return e.trace_id&&(u.traceId=e.trace_id),e.span_id&&(u.spanId=e.span_id),Ze(e.trace_flags)||(u.flags=e.trace_flags),u}function Ri(e,t,r){return i({},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":r})}function Li(e,t,i,r){return{resourceLogs:[{resource:{attributes:Fi(t)},scopeLogs:[{scope:{name:i,version:r},logRecords:e}]}]}}let Mi=class{constructor(e,t,i,r,s,n){var o;void 0===n&&(n=()=>Promise.resolve()),this._instance=e,this._config=t,this._logger=i,this._getContext=r,this._onReady=s,this._waitForStoragePersist=n,this._flushPromise=null,this._evictedSinceAdvance=0,this._consecutiveFlushFailures=0,this._intervalWindowStart=0,this._intervalLogCount=0,this._droppedWarned=!1,this._maxBufferSize=t.maxBufferSize,this._maxQueueSize=Math.max(null!==(o=t.maxQueueSize)&&void 0!==o?o:t.maxBufferSize,t.maxBufferSize),this._flushIntervalMs=t.flushIntervalMs,this._maxBatchRecordsPerPost=t.maxBatchRecordsPerPost,this._rateCapWindowMs=t.rateCapWindowMs,this._maxLogsPerInterval=t.maxLogsPerInterval}reset(){this._clearFlushTimer(),this._flushPromise=null,this._intervalWindowStart=0,this._intervalLogCount=0,this._droppedWarned=!1,this._evictedSinceAdvance=0,this._consecutiveFlushFailures=0,this._maxBatchRecordsPerPost=this._config.maxBatchRecordsPerPost}onReconnect(){this._consecutiveFlushFailures=0,this._flushInBackground()}captureLog(e){if(!this._instance.isDisabled&&!this._instance.optedOut&&null!=e&&e.body){var t=this._runBeforeSend(e);if(null!==t)if(t.body){if(this._checkRateLimit()){var i={record:Ti(t,this._getContext())};this._onReady((()=>this._enqueue(i)))}}else this._logger.info("Log was rejected in beforeSend function")}}_runBeforeSend(e){var t=this._config.beforeSend;if(!t)return e;var i=Qe(t)?t:[t],r=e;for(var s of i)try{var n=s(r);if(!n)return this._logger.info("Log was rejected in beforeSend function"),null;r=n}catch(e){return this._logger.error("Error in beforeSend function for log:",e),null}return r}_checkRateLimit(){if(void 0===this._maxLogsPerInterval)return!0;var 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 t((function*(){if(!e._instance.isDisabled)return e._flushPromise||(e._flushPromise=e._flushInner().finally((()=>{e._flushPromise=null}))),e._flushPromise}))()}_flushInner(){var e=this;return t((function*(){var t;e._clearFlushTimer();var i=null!==(t=e._instance.getPersistedProperty(Re.LogsQueue))&&void 0!==t?t:[];if(0!==i.length)for(var r=i.length,s=0;i.length>0&&r>s;){var n;e._evictedSinceAdvance=0;var o=Math.min(i.length,e._maxBatchRecordsPerPost),a=i.slice(0,o),l=Li(a.map((e=>e.record)),e._buildResourceAttributes(),e._instance.getLibraryId(),e._instance.getLibraryVersion()),u=yield e._instance._sendLogsBatch(l);if("too-large"===u.kind&&a.length>1)e._maxBatchRecordsPerPost=Math.max(1,Math.floor(a.length/2)),e._logger.warn("Received 413 when sending logs batch of size "+a.length+", reducing batch size to "+e._maxBatchRecordsPerPost);else{if("retry-later"===u.kind)throw u.error;if("too-large"===u.kind?e._logger.warn("Dropping a single log record after 413 with batch size 1 — the record is larger than the server cap and cannot be split further."):"ok"===u.kind&&e._config.maxBatchRecordsPerPost>e._maxBatchRecordsPerPost&&(e._maxBatchRecordsPerPost=Math.min(e._config.maxBatchRecordsPerPost,e._maxBatchRecordsPerPost+1)),yield e._persistQueueAdvance(a.length),i=null!==(n=e._instance.getPersistedProperty(Re.LogsQueue))&&void 0!==n?n:[],s+=a.length,"fatal"===u.kind)throw u.error}}}))()}_persistQueueAdvance(e){var i=this;return t((function*(){var t,r=Math.max(0,e-i._evictedSinceAdvance),s=null!==(t=i._instance.getPersistedProperty(Re.LogsQueue))&&void 0!==t?t:[];i._instance.setPersistedProperty(Re.LogsQueue,s.slice(r)),yield i._waitForStoragePersist()}))()}_buildResourceAttributes(){return Ri(this._config,this._instance.getLibraryId(),this._instance.getLibraryVersion())}_enqueue(e){var t;if(!this._instance.optedOut){var i=null!==(t=this._instance.getPersistedProperty(Re.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(Re.LogsQueue,i),this._maxBufferSize>i.length?this._armFlushTimer():this._flushInBackground()}}_armFlushTimer(e){void 0===e&&(e=this._flushIntervalMs),this._flushTimer||(this._flushTimer=Ei((()=>{this._flushTimer=void 0,this._flushInBackground()}),e))}_nextFlushDelay(){var e=Math.min(Math.max(0,this._consecutiveFlushFailures-1),6);return this._flushIntervalMs*Math.pow(2,e)}_hasQueuedRecords(){var e=this._instance.getPersistedProperty(Re.LogsQueue);return!!e&&e.length>0}shutdown(e){var i=this;return t((function*(){i._clearFlushTimer();var t=i.flush().catch((()=>{}));void 0!==e?yield Promise.race([t,new Promise((t=>Ei(t,e)))]):yield t}))()}flushWithTimeout(e){var i=this;return t((function*(){var t=!1,r=i.flush(),s=new Promise((i=>Ei((()=>{t=!0,i()}),e)));try{yield Promise.race([r,s])}finally{t&&r.catch((()=>{}))}}))()}_flushInBackground(){this.flush().then((()=>{this._consecutiveFlushFailures=0}),(e=>{this._consecutiveFlushFailures++,this._logger.error("PostHog logs flush failed:",e)})).finally((()=>{!this._instance.isDisabled&&this._hasQueuedRecords()&&this._armFlushTimer(this._nextFlushDelay())}))}_clearFlushTimer(){this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=void 0)}};var $i,Ai,Oi;function Di(e){var t=globalThis._posthogChunkIds;if(t){var i=Object.keys(t);return Oi&&i.length===Ai||(Ai=i.length,Oi=i.reduce(((i,r)=>{$i||($i={});var s=$i[r];if(s)i[s[0]]=s[1];else for(var n=e(r),o=n.length-1;o>=0;o--){var a=n[o],l=null==a?void 0:a.filename,u=t[r];if(l&&u){i[l]=u,$i[r]=[l,u];break}}return i}),{})),Oi}}class qi{constructor(e,t,i){void 0===i&&(i=[]),this.coercers=e,this.stackParser=t,this.modifiers=i}buildFromUnknown(e,t){void 0===t&&(t={});var i=t&&t.mechanism||{handled:!0,type:"generic"},r=this.buildCoercingContext(i,t,0).apply(e),s=this.buildParsingContext(t),n=this.parseStacktrace(r,s);return{$exception_list:this.convertToExceptionList(n,i),$exception_level:"error"}}modifyFrames(e){var i=this;return t((function*(){for(var t of e)t.stacktrace&&t.stacktrace.frames&&Qe(t.stacktrace.frames)&&(t.stacktrace.frames=yield i.applyModifiers(t.stacktrace.frames));return e}))()}coerceFallback(e){var t;return{type:"Error",value:"Unknown error",stack:null==(t=e.syntheticException)?void 0:t.stack,synthetic:!0}}parseStacktrace(e,t){var r,s;return null!=e.cause&&(r=this.parseStacktrace(e.cause,t)),""!=e.stack&&null!=e.stack&&(s=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?t.skipFirstLines:0),t.chunkIdMap)),i({},e,{cause:r,stack:s})}applyChunkIds(e,t){return e.map((e=>(e.filename&&t&&(e.chunk_id=t[e.filename]),e)))}applyCoercers(e,t){for(var i of this.coercers)if(i.match(e))return i.coerce(e,t);return this.coerceFallback(t)}applyModifiers(e){var i=this;return t((function*(){var t=e;for(var r of i.modifiers)t=yield r(t);return t}))()}convertToExceptionList(e,t){var r,s,n,o={type:e.type,value:e.value,mechanism:{type:null!==(r=t.type)&&void 0!==r?r:"generic",handled:null===(s=t.handled)||void 0===s||s,synthetic:null!==(n=e.synthetic)&&void 0!==n&&n}};e.stack&&(o.stacktrace={type:"raw",frames:e.stack});var a=[o];return null!=e.cause&&a.push(...this.convertToExceptionList(e.cause,i({},t,{handled:!0}))),a}buildParsingContext(e){var t;return{chunkIdMap:Di(this.stackParser),skipFirstLines:null!==(t=e.skipFirstLines)&&void 0!==t?t:1}}buildCoercingContext(e,t,r){void 0===r&&(r=0);var s=(i,r)=>{if(4>=r){var s=this.buildCoercingContext(e,t,r);return this.applyCoercers(i,s)}};return i({},t,{syntheticException:0==r?t.syntheticException:void 0,mechanism:e,apply:e=>s(e,r),next:e=>s(e,r+1)})}}var Bi="?";function zi(e,t,i,r,s){var n={platform:e,filename:t,function:"<anonymous>"===i?Bi:i,in_app:!0};return Ze(r)||(n.lineno=r),Ze(s)||(n.colno=s),n}var Hi=(e,t)=>{var i=-1!==e.indexOf("safari-extension"),r=-1!==e.indexOf("safari-web-extension");return i||r?[-1!==e.indexOf("@")?e.split("@")[0]:Bi,i?"safari-extension:"+t:"safari-web-extension:"+t]:[e,t]},Ni=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,ji=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,Ui=/\((\S*)(?::(\d+))(?::(\d+))\)/,Wi=(e,t)=>{var i=Ni.exec(e);if(i){var[,r,s,n]=i;return zi(t,r,Bi,+s,+n)}var o=ji.exec(e);if(o){if(o[2]&&0===o[2].indexOf("eval")){var a=Ui.exec(o[2]);a&&(o[2]=a[1],o[3]=a[2],o[4]=a[3])}var[l,u]=Hi(o[1]||Bi,o[2]);return zi(t,u,l,o[3]?+o[3]:void 0,o[4]?+o[4]:void 0)}},Vi=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,Gi=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,Ki=(e,t)=>{var i=Vi.exec(e);if(i){if(i[3]&&i[3].indexOf(" > eval")>-1){var r=Gi.exec(i[3]);r&&(i[1]=i[1]||"eval",i[3]=r[1],i[4]=r[2],i[5]="")}var s=i[3],n=i[1]||Bi;return[n,s]=Hi(n,s),zi(t,s,n,i[4]?+i[4]:void 0,i[5]?+i[5]:void 0)}},Qi=/\(error: (.*)\)/;class Ji{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){var i=et(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){var t=e.name||(this.isDOMError(e)?"DOMError":"DOMException");return e.message?t+": "+e.message:t}isDOMException(e){return dt(e,"DOMException")}isDOMError(e){return dt(e,"DOMError")}}class Yi{match(e){return(e=>e instanceof Error)(e)}coerce(e,t){return{type:this.getType(e),value:this.getMessage(e,t),stack:this.getStack(e),cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return e.name||e.constructor.name}getMessage(e,t){var i=e.message;return String(i.error&&"string"==typeof i.error.message?i.error.message:i)}getStack(e){return e.stacktrace||e.stack||void 0}}class Xi{constructor(){}match(e){return dt(e,"ErrorEvent")&&null!=e.error}coerce(e,t){var i;return t.apply(e.error)||{type:"ErrorEvent",value:e.message,stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}}var Zi=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;class er{match(e){return"string"==typeof e}coerce(e,t){var i,[r,s]=this.getInfos(e);return{type:null!=r?r:"Error",value:null!=s?s:e,stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}getInfos(e){var t="Error",i=e,r=e.match(Zi);return r&&(t=r[1],i=r[2]),[t,i]}}var tr=["fatal","error","warning","log","info","debug"];function ir(e,t){void 0===t&&(t=40);var i=Object.keys(e);if(i.sort(),!i.length)return"[object has no keys]";for(var r=i.length;r>0;r--){var s=i.slice(0,r).join(", ");if(t>=s.length)return r===i.length?s:s.length>t?s.slice(0,t)+"...":s}return""}class rr{match(e){return"object"==typeof e&&null!==e}coerce(e,t){var i,r=this.getErrorPropertyFromObject(e);return r?t.apply(r):{type:this.getType(e),value:this.getValue(e),stack:null==(i=t.syntheticException)?void 0:i.stack,level:this.isSeverityLevel(e.level)?e.level:"error",synthetic:!0}}getType(e){return _t(e)?e.constructor.name:"Error"}getValue(e){if("name"in e&&"string"==typeof e.name){var 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;var i=this.getObjectClassName(e);return(i&&"Object"!==i?"'"+i+"'":"Object")+" captured as exception with keys: "+ir(e)}isSeverityLevel(e){return et(e)&&!tt(e)&&tr.indexOf(e)>=0}getErrorPropertyFromObject(e){for(var t in e)if({}.hasOwnProperty.call(e,t)){var i=e[t];if(ki(i))return i}}getObjectClassName(e){try{var t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch(e){return}}}class sr{match(e){return _t(e)}coerce(e,t){var i,r=e.constructor.name;return{type:r,value:r+" captured as exception with keys: "+ir(e),stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}}class nr{match(e){return ct(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.stack,synthetic:!0}}}class or{match(e){return dt(e,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(e)}isCustomEventWrappingRejection(e){if(!_t(e))return!1;try{var t=e.detail;return null!=t&&"object"==typeof t&&"reason"in t}catch(e){return!1}}coerce(e,t){var i,r=this.getUnhandledRejectionReason(e);return ct(r)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(r),stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}:t.apply(r)}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}}var ar="$message",lr="$timestamp",ur=new Set([ar,lr]),cr={enabled:!0,max_bytes:32768};function dr(e){var t;return e?{enabled:null!==(t=e.enabled)&&void 0!==t?t:cr.enabled,max_bytes:hr(e.max_bytes,cr.max_bytes)}:i({},cr)}class _r{constructor(e){this._entries=[],this._totalBytes=0,this._config=dr(e)}setConfig(e){this._config=dr(e),this._trimToMaxBytes()}add(e){var t=function(e){var t=function(e){var t=new WeakSet;try{return JSON.stringify(e,((e,i)=>{if("bigint"==typeof i)return i.toString();if("function"!=typeof i&&"symbol"!=typeof i){if(i instanceof Date)return i.toISOString();if(i instanceof Error)return{name:i.name,message:i.message,stack:i.stack};if(i&&"object"==typeof i){if(t.has(i))return"[Circular]";t.add(i)}return i}}))}catch(e){return}}(e);if(t)try{var i=JSON.parse(t);if(!Ye(i))return;var r=i,s=r[ar],n=r[lr];if(!et(s)||0===s.trim().length)return;if(!et(n)&&!st(n))return;return{step:r,json:t}}catch(e){return}}(e);if(t){var i=function(e){if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e).length;for(var t=encodeURIComponent(e),i=0,r=0;t.length>r;r++)"%"===t[r]?(i+=1,r+=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;){var e=this._entries.shift();e&&(this._totalBytes-=e.bytes)}}}function hr(e,t){if(!st(e)||e===1/0||e===-1/0)return t;var i=Math.floor(e);return 0>i?t:i}var pr=function(e,t){var{debugEnabled:i}=void 0===t?{}:t,r={_log(t){if(ve&&(n.DEBUG||Pe.POSTHOG_DEBUG||i)&&!Ze(ve.console)&&ve.console){for(var r=("__rrweb_original__"in ve.console[t]?ve.console[t].__rrweb_original__:ve.console[t]),s=arguments.length,o=new Array(s>1?s-1:0),a=1;s>a;a++)o[a-1]=arguments[a];r(e,...o)}},debug(){for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];r._log("debug",...t)},info(){for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];r._log("log",...t)},warn(){for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];r._log("warn",...t)},error(){for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];r._log("error",...t)},critical(){for(var t=arguments.length,i=new Array(t),r=0;t>r;r++)i[r]=arguments[r];console.error(e,...i)},uninitializedWarning(e){r.error("You must initialize PostHog before calling "+e)},createLogger:(t,i)=>pr(e+" "+t,i)};return r},gr=pr("[PostHog.js]"),vr=gr.createLogger;function fr(e,t){Qe(e)&&e.forEach(t)}function mr(e,t){if(!rt(e))if(Qe(e))e.forEach(t);else if(at(e))e.forEach(((e,i)=>t(e,i)));else for(var i in e)Ge.call(e,i)&&t(e[i],i)}var yr=function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;t>r;r++)i[r-1]=arguments[r];for(var s of i)for(var n in s)void 0!==s[n]&&(e[n]=s[n]);return e};function br(e){for(var t=Object.keys(e),i=t.length,r=new Array(i);i--;)r[i]=[t[i],e[t[i]]];return r}var wr=function(e){try{return e()}catch(e){return}},xr=function(e){return function(){try{for(var t=arguments.length,i=new Array(t),r=0;t>r;r++)i[r]=arguments[r];return e.apply(this,i)}catch(e){gr.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),gr.critical(e)}}},Sr=function(e){var t={};return mr(e,(function(e,i){(et(e)&&e.length>0||st(e))&&(t[i]=e)})),t};var Er=["herokuapp.com","vercel.app","netlify.app"];function kr(e){var t=null==e?void 0:e.hostname;if(!et(t))return!1;var i=t.split(".").slice(-2).join(".");for(var r of Er)if(i===r)return!1;return!0}function Pr(e,t,i,r){var{capture:s=!1,passive:n=!0}=null!=r?r:{};null==e||e.addEventListener(t,i,{capture:s,passive:n})}function Ir(e){return"ph_toolbar_internal"===e.name}Math.trunc||(Math.trunc=function(e){return 0>e?Math.ceil(e):Math.floor(e)}),Number.isInteger||(Number.isInteger=function(e){return st(e)&&isFinite(e)&&Math.floor(e)===e});class Cr{constructor(e){if(this.bytes=e,16!==e.length)throw new TypeError("not 128-bit length")}static fromFieldsV7(e,t,i,r){if(!Number.isInteger(e)||!Number.isInteger(t)||!Number.isInteger(i)||!Number.isInteger(r)||0>e||0>t||0>i||0>r||e>0xffffffffffff||t>4095||i>1073741823||r>4294967295)throw new RangeError("invalid field value");var s=new Uint8Array(16);return s[0]=e/Math.pow(2,40),s[1]=e/Math.pow(2,32),s[2]=e/Math.pow(2,24),s[3]=e/Math.pow(2,16),s[4]=e/Math.pow(2,8),s[5]=e,s[6]=112|t>>>8,s[7]=t,s[8]=128|i>>>24,s[9]=i>>>16,s[10]=i>>>8,s[11]=i,s[12]=r>>>24,s[13]=r>>>16,s[14]=r>>>8,s[15]=r,new Cr(s)}toString(){for(var e="",t=0;this.bytes.length>t;t++)e=e+(this.bytes[t]>>>4).toString(16)+(15&this.bytes[t]).toString(16),3!==t&&5!==t&&7!==t&&9!==t||(e+="-");if(36!==e.length)throw new Error("Invalid UUIDv7 was generated");return e}clone(){return new Cr(this.bytes.slice(0))}equals(e){return 0===this.compareTo(e)}compareTo(e){for(var t=0;16>t;t++){var i=this.bytes[t]-e.bytes[t];if(0!==i)return Math.sign(i)}return 0}}class Fr{constructor(){this._timestamp=0,this._counter=0,this._random=new Lr}generate(){var e=this.generateOrAbort();if(Ze(e)){this._timestamp=0;var t=this.generateOrAbort();if(Ze(t))throw new Error("Could not generate UUID after timestamp reset");return t}return e}generateOrAbort(){var e=Date.now();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 Cr.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())}}var Tr,Rr=e=>{if("undefined"!=typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var t=0;e.length>t;t++)e[t]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return e};ve&&!Ze(ve.crypto)&&crypto.getRandomValues&&(Rr=e=>crypto.getRandomValues(e));class Lr{constructor(){this._buffer=new Uint32Array(8),this._cursor=1/0}nextUint32(){return this._buffer.length>this._cursor||(Rr(this._buffer),this._cursor=0),this._buffer[this._cursor++]}}var Mr=()=>$r().toString(),$r=()=>(Tr||(Tr=new Fr)).generate(),Ar="",Or=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;var Dr={_is_supported:()=>!!ye,_error(e){gr.error("cookieStore error: "+e)},_get(e){if(ye){try{for(var t=e+"=",i=ye.cookie.split(";").filter((e=>e.length)),r=0;i.length>r;r++){for(var s=i[r];" "==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}},_parse(e){var t;try{t=JSON.parse(Dr._get(e))||{}}catch(e){}return t},_set(e,t,i,r,s){if(!ye)return!1;try{var n="",o="",a=function(e,t){if(t){var i=function(e,t){if(void 0===t&&(t=ye),Ar)return Ar;if(!t)return"";if(["localhost","127.0.0.1"].includes(e))return"";for(var i=e.split("."),r=Math.min(i.length,8),s="dmn_chk_"+Mr();!Ar&&r--;){var n=i.slice(r).join("."),o=s+"=1;domain=."+n+";path=/";t.cookie=o+";max-age=3",t.cookie.includes(s)&&(t.cookie=o+";max-age=0",Ar=n)}return Ar}(e);if(!i){var r=(e=>{var t=e.match(Or);return t?t[0]:""})(e);r!==i&&gr.info("Warning: cookie subdomain discovery mismatch",r,i),i=r}return i?"; domain=."+i:""}return""}(ye.location.hostname,r);if(i){var l=new Date;l.setTime(l.getTime()+864e5*i),n="; expires="+l.toUTCString()}s&&(o="; secure");var u=e+"="+encodeURIComponent(JSON.stringify(t))+n+"; SameSite=Lax; path=/"+a+o;return u.length>3686.4&&gr.warn("cookieStore warning: large cookie, len="+u.length),ye.cookie=u,!0}catch(e){return!1}},_remove(e,t){if(null!=ye&&ye.cookie)try{Dr._set(e,"",-1,t)}catch(e){return}}},qr=null,Br={_is_supported(){if(!it(qr))return qr;var e=!0;if(Ze(ve))e=!1;else try{var t="__mplssupport__";Br._set(t,"xyz"),'"xyz"'!==Br._get(t)&&(e=!1),Br._remove(t)}catch(t){e=!1}return e||gr.error("localStorage unsupported; falling back to cookie store"),qr=e,e},_error(e){gr.error("localStorage error: "+e)},_get(e){try{return null==ve?void 0:ve.localStorage.getItem(e)}catch(e){Br._error(e)}return null},_parse(e){try{return JSON.parse(Br._get(e))||{}}catch(e){}return null},_set(e,t){try{return null==ve||ve.localStorage.setItem(e,JSON.stringify(t)),!0}catch(e){Br._error(e)}return!1},_remove(e){try{null==ve||ve.localStorage.removeItem(e)}catch(e){Br._error(e)}}},zr=[a,"distinct_id",k,P,X,Y,V],Hr={},Nr={_is_supported:()=>!0,_error(e){gr.error("memoryStorage error: "+e)},_get:e=>Hr[e]||null,_parse:e=>Hr[e]||null,_set:(e,t)=>(Hr[e]=t,!0),_remove(e){delete Hr[e]}},jr=null,Ur={_is_supported(){if(!it(jr))return jr;if(jr=!0,Ze(ve))jr=!1;else try{var e="__support__";Ur._set(e,"xyz"),'"xyz"'!==Ur._get(e)&&(jr=!1),Ur._remove(e)}catch(e){jr=!1}return jr},_error(e){gr.error("sessionStorage error: ",e)},_get(e){try{return null==ve?void 0:ve.sessionStorage.getItem(e)}catch(e){Ur._error(e)}return null},_parse(e){try{return JSON.parse(Ur._get(e))||null}catch(e){}return null},_set(e,t){try{return null==ve||ve.sessionStorage.setItem(e,JSON.stringify(t)),!0}catch(e){Ur._error(e)}return!1},_remove(e){try{null==ve||ve.sessionStorage.removeItem(e)}catch(e){Ur._error(e)}}};class Wr{constructor(e){this._instance=e}get _config(){return this._instance.config}get consent(){return this._getDnt()?0:this._storedConsent}isOptedOut(){return this._config.cookieless_mode===oe||this.isRejected()||-1===this.consent&&this._config.cookieless_mode===ne}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return 0===this.consent}isRejected(){return 0===this.consent||-1===this.consent&&this._config.opt_out_capturing_by_default}optInOut(e){this._storage._set(this._storageKey,e?1:0,this._config.cookie_expiration,this._config.cross_subdomain_cookie,this._config.secure_cookie)}reset(){this._storage._remove(this._storageKey,this._config.cross_subdomain_cookie)}get _storageKey(){var{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(){var e=this._storage._get(this._storageKey);return pt(e)?1:je(gt,e)?0:-1}get _storage(){var e=this._config.opt_out_capturing_persistence_type,t="localStorage"===e?Br:Dr;if(!this._persistentStore||this._persistentStore!==t){this._persistentStore=t;var i="localStorage"===e?Dr:Br;i._get(this._storageKey)&&(this._persistentStore._get(this._storageKey)||this.optInOut(pt(i._get(this._storageKey))),i._remove(this._storageKey,this._config.cross_subdomain_cookie))}return this._persistentStore}_getDnt(){return!!this._config.respect_dnt&&[null==me?void 0:me.doNotTrack,null==me?void 0:me.msDoNotTrack,Pe.doNotTrack].some((e=>pt(e)))}}var Vr=1,Gr=3,Kr=11;function Qr(e){return e instanceof Element&&(e.id===Z||!(null==e.closest||!e.closest(".toolbar-global-fade-container")))}function Jr(e){return!!e&&e.nodeType===Vr}function Yr(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function Xr(e){return!!e&&e.nodeType===Gr}function Zr(e){return!!e&&e.nodeType===Kr&&Jr(e.host)}function es(e){return e?Ue(e).split(/\s+/):[]}function ts(e){var t=null==ve?void 0:ve.location.href;return!!(t&&e&&e.some((e=>t.match(e))))}function is(e){var 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 es(t)}function rs(e){return rt(e)?null:Ue(e).split(/(\s+)/).filter((e=>Ps(e))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function ss(e){var t="";return ms(e)&&!ys(e)&&e.childNodes&&e.childNodes.length&&mr(e.childNodes,(function(e){var i;Xr(e)&&e.textContent&&(t+=null!==(i=rs(e.textContent))&&void 0!==i?i:"")})),Ue(t)}function ns(e){return Ze(e.target)?e.srcElement||null:null!=(t=e.target)&&t.shadowRoot?e.composedPath()[0]||null:e.target||null;var t}var os=["a","button","form","input","select","textarea","label"];function as(e,t){if(Ze(t))return!0;var i,r=function(e){if(t.some((t=>function(e,t){var i=e.matches||e.matchesSelector||e.msMatchesSelector||e.mozMatchesSelector||e.webkitMatchesSelector||e.oMatchesSelector;try{return!!i&&i.call(e,t)}catch(e){return!1}}(e,t))))return{v:!0}};for(var s of e)if(i=r(s))return i.v;return!1}function ls(e){var t=e.parentNode;return!(!t||!Jr(t))&&t}var us=[".ph-no-autocapture","[data-ph-no-autocapture]"],cs=["next","previous","prev",">","<"],ds=[...cs,"+","-","−","–"],_s=(e,t)=>/[a-z0-9]/i.test(t)?e.includes(t):e===t,hs=[".ph-no-rageclick",".ph-no-capture"],ps=["","text","search","email","password","url","tel","number"];function gs(e,t){if(!ve||vs(e))return!1;var i,r,s,n,o;if(ot(t)?(i=!!t&&hs,r=void 0,s=!1):(i=null!==(n=null==t?void 0:t.css_selector_ignorelist)&&void 0!==n?n:hs,r=null==t?void 0:t.content_ignorelist,s=null!==(o=null==t?void 0:t.ignore_text_selection)&&void 0!==o&&o),!1===i)return!1;if(s&&function(e){return!(!e||!Jr(e))&&(!!Yr(e,"textarea")||(Yr(e,"input")?je(ps,(e.getAttribute("type")||"").toLowerCase()):function(e){if(e.isContentEditable)return!0;var t=null==e.getAttribute?void 0:e.getAttribute("contenteditable");return"true"===t||""===t}(e)))}(e))return!1;var{targetElementList:a}=fs(e,!1);return!function(e,t){if(!1===e||Ze(e))return!1;var i;if(!0===e)i=cs;else{if(!Qe(e))return!1;if(e.length>10)return gr.error("[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching."),!1;i=e.map((e=>e.toLowerCase()))}return t.some((e=>{var{safeText:t,ariaLabel:r}=e;return i.some((e=>_s(t,e)||_s(r,e)))}))}(r,a.map((e=>{var t;return{safeText:ss(e).toLowerCase(),ariaLabel:(null==(t=e.getAttribute("aria-label"))?void 0:t.toLowerCase().trim())||""}})))&&!as(a,i)}var vs=e=>!e||Yr(e,"html")||!Jr(e),fs=(e,t)=>{if(!ve||vs(e))return{parentIsUsefulElement:!1,targetElementList:[]};for(var i=!1,r=[e],s=e;s.parentNode&&!Yr(s,"body");)if(Zr(s.parentNode))r.push(s.parentNode.host),s=s.parentNode.host;else{var n=ls(s);if(!n)break;if(t||os.indexOf(n.tagName.toLowerCase())>-1)i=!0;else{var o=ve.getComputedStyle(n);o&&"pointer"===o.getPropertyValue("cursor")&&(i=!0)}r.push(n),s=n}return{parentIsUsefulElement:i,targetElementList:r}};function ms(e){for(var t=e;t.parentNode&&!Yr(t,"body");t=t.parentNode){var i=is(t);if(je(i,"ph-sensitive")||je(i,"ph-no-capture"))return!1}if(je(is(e),"ph-include"))return!0;var r=e.type||"";if(et(r))switch(r.toLowerCase()){case"hidden":case"password":return!1}var s=e.name||e.id||"";return!et(s)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(s.replace(/[^a-zA-Z0-9]/g,""))}function ys(e){return!!(Yr(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||Yr(e,"select")||Yr(e,"textarea")||"true"===e.getAttribute("contenteditable"))}var bs="(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})",ws=new RegExp("^(?:"+bs+")$"),xs=new RegExp(bs),Ss="\\d{3}-?\\d{2}-?\\d{4}",Es=new RegExp("^("+Ss+")$"),ks=new RegExp("("+Ss+")");function Ps(e,t){if(void 0===t&&(t=!0),rt(e))return!1;if(et(e)){if(e=Ue(e),(t?ws:xs).test((e||"").replace(/[- ]/g,"")))return!1;if((t?Es:ks).test(e))return!1}return!0}function Is(e){var t=ss(e);return Ps(t=(t+" "+Cs(e)).trim())?t:""}function Cs(e){var t="";return e&&e.childNodes&&e.childNodes.length&&mr(e.childNodes,(function(e){var i;if(e&&"span"===(null==(i=e.tagName)?void 0:i.toLowerCase()))try{var r=ss(e);t=(t+" "+r).trim(),e.childNodes&&e.childNodes.length&&(t=(t+" "+Cs(e)).trim())}catch(e){gr.error("[AutoCapture]",e)}})),t}function Fs(e){return e.replace(/"|\\"/g,'\\"')}function Ts(e){var t=e.attr__class;return t?Qe(t)?t:es(t):void 0}var Rs=vr("[Dead Clicks]"),Ls=()=>!0,Ms=e=>{var t,i=!(null==(t=e.instance.persistence)||!t.get_property(v)),r=e.instance.config.capture_dead_clicks;return ot(r)?r:!!Ye(r)||i};class $s{get lazyLoadedDeadClicksAutocapture(){return this._lazyLoadedDeadClicksAutocapture}constructor(e,t,i){this.instance=e,this.isEnabled=t,this.onCapture=i,this.startIfEnabledOrStop()}onRemoteConfig(e){"captureDeadClicks"in e&&(this.instance.persistence&&this.instance.persistence.register({[v]:e.captureDeadClicks}),this.startIfEnabledOrStop())}startIfEnabledOrStop(){this.isEnabled(this)?this._loadScript((()=>{this._start()})):this.stop()}_loadScript(e){var t,i;null!=(t=Pe.__PosthogExtensions__)&&t.initDeadClicksAutocapture?e():null==(i=Pe.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this.instance,"dead-clicks-autocapture",(t=>{t?Rs.error("failed to load script",t):e()}))}_start(){var e;if(ye){if(!this._lazyLoadedDeadClicksAutocapture&&null!=(e=Pe.__PosthogExtensions__)&&e.initDeadClicksAutocapture){var t=Ye(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};t.__onCapture=this.onCapture,this._lazyLoadedDeadClicksAutocapture=Pe.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this._lazyLoadedDeadClicksAutocapture.start(ye),Rs.info("starting...")}}else Rs.error("`document` not found. Cannot start.")}stop(){this._lazyLoadedDeadClicksAutocapture&&(this._lazyLoadedDeadClicksAutocapture.stop(),this._lazyLoadedDeadClicksAutocapture=void 0,Rs.info("stopping..."))}}var As=vr("[SegmentIntegration]");var Os="posthog-js";function Ds(e,t){var{organization:r,projectId:s,prefix:n,severityAllowList:o=["error"],sendExceptionsToPostHog:a=!0}=void 0===t?{}:t;return t=>{var l,u,c,d,_;if("*"!==o&&!o.includes(t.level)||!e.__loaded)return t;t.tags||(t.tags={});var h=e.requestRouter.endpointFor("ui","/project/"+e.config.token+"/person/"+e.get_distinct_id());t.tags["PostHog Person URL"]=h,e.sessionRecordingStarted()&&(t.tags["PostHog Recording URL"]=e.get_session_replay_url({withTimestamp:!0}));var p,g=(null==(l=t.exception)?void 0:l.values)||[],v=g.map((e=>i({},e,{stacktrace:e.stacktrace?i({},e.stacktrace,{type:"raw",frames:(e.stacktrace.frames||[]).map((e=>i({},e,{platform:"web:javascript"})))}):void 0}))),f={$exception_message:(null==(u=g[0])?void 0:u.value)||t.message,$exception_type:null==(c=g[0])?void 0:c.type,$exception_level:t.level,$exception_list:v,$sentry_event_id:t.event_id,$sentry_exception:t.exception,$sentry_exception_message:(null==(d=g[0])?void 0:d.value)||t.message,$sentry_exception_type:null==(_=g[0])?void 0:_.type,$sentry_tags:t.tags};return r&&s&&(f.$sentry_url=(n||"https://sentry.io/organizations/")+r+"/issues/?project="+s+"&query="+t.event_id),a&&(null==(p=e.exceptions)||p.sendExceptionEvent(f)),t}}class qs{constructor(e,t,i,r,s,n){this.name=Os,this.setupOnce=function(o){o(Ds(e,{organization:t,projectId:i,prefix:r,severityAllowList:s,sendExceptionsToPostHog:null==n||n}))}}}class Bs{constructor(e){this._onSessionIdChange=(e,t,i)=>{i&&(i.noSessionId||i.activityTimeout||i.sessionPastMaximumLength||i.crossTabAdoption)&&(gr.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:e,changeReason:i}),this._currentPageview=void 0,this._instance.scrollManager.resetContext())},this._instance=e,this._setupSessionRotationHandler()}_setupSessionRotationHandler(){var e;this._unsubscribeSessionId=null==(e=this._instance.sessionManager)?void 0:e.onSessionId(this._onSessionIdChange)}destroy(){var e;null==(e=this._unsubscribeSessionId)||e.call(this),this._unsubscribeSessionId=void 0}doPageView(e,t){var i,r=this._previousPageViewProperties(e,t);return this._currentPageview={pathname:null!==(i=null==ve?void 0:ve.location.pathname)&&void 0!==i?i:"",pageViewId:t,timestamp:e},this._instance.scrollManager.resetContext(),r}doPageLeave(e){var t;return this._previousPageViewProperties(e,null==(t=this._currentPageview)?void 0:t.pageViewId)}doEvent(){var e;return{$pageview_id:null==(e=this._currentPageview)?void 0:e.pageViewId}}_previousPageViewProperties(e,t){var i=this._currentPageview;if(!i)return{$pageview_id:t};var r={$pageview_id:t,$prev_pageview_id:i.pageViewId},s=this._instance.scrollManager.getContext();if(s&&!this._instance.config.disable_scroll_properties){var{maxScrollHeight:n,lastScrollY:o,maxScrollY:a,maxContentHeight:l,lastContentY:u,maxContentY:c}=s;if(!(Ze(n)||Ze(o)||Ze(a)||Ze(l)||Ze(u)||Ze(c))){n=Math.ceil(n),o=Math.ceil(o),a=Math.ceil(a),l=Math.ceil(l),u=Math.ceil(u),c=Math.ceil(c);var d=n>1?vt(o/n,0,1,gr):1,_=n>1?vt(a/n,0,1,gr):1,h=l>1?vt(u/l,0,1,gr):1,p=l>1?vt(c/l,0,1,gr):1;r=yr(r,{$prev_pageview_last_scroll:o,$prev_pageview_last_scroll_percentage:d,$prev_pageview_max_scroll:a,$prev_pageview_max_scroll_percentage:_,$prev_pageview_last_content:u,$prev_pageview_last_content_percentage:h,$prev_pageview_max_content:c,$prev_pageview_max_content_percentage:p})}}return i.pathname&&(r.$prev_pageview_pathname=i.pathname),i.timestamp&&(r.$prev_pageview_duration=(e.getTime()-i.timestamp.getTime())/1e3),r}}var zs=["flags","surveys"],Hs={[o]:{exposure:"hidden"},[l]:{exposure:"hidden"},__cmpns:{exposure:"hidden"},[u]:{exposure:"hidden"},[c]:{exposure:"event"},[d]:{exposure:"hidden"},[_]:{exposure:"event"},[h]:{exposure:"hidden"},[p]:{exposure:"event"},[g]:{exposure:"event"},[v]:{exposure:"event"},[f]:{exposure:"hidden"},[m]:{exposure:"event"},[y]:{exposure:"hidden"},$session_recording_enabled_server_side:{exposure:"hidden"},[k]:{exposure:"hidden"},[P]:{exposure:"event"},[b]:{exposure:"event",shouldSkipFromEventProperties:e=>it(e)},$session_past_minimum_duration:{exposure:"event"},$session_recording_url_trigger_activated_session:{exposure:"event"},$session_recording_event_trigger_activated_session:{exposure:"event"},$debug_first_full_snapshot_timestamp:{exposure:"event"},$sess_rec_flush_size:{exposure:"hidden"},[I]:{exposure:"derived",storageGroup:"flags",shouldSkipFromEventProperties:(e,t)=>t(),transformToEventProperties(e){if(!Ye(e))return{};for(var t={},i=Object.keys(e),r=0;i.length>r;r++)t["$feature/"+i[r]]=e[i[r]];return t}},[C]:{exposure:"event",storageGroup:"flags"},[F]:{exposure:"hidden"},[T]:{exposure:"hidden",storageGroup:"flags"},[R]:{exposure:"event",storageGroup:"flags"},[L]:{exposure:"event",storageGroup:"flags",volatile:!0},[M]:{exposure:"event"},[A]:{exposure:"hidden"},[O]:{exposure:"hidden"},[D]:{exposure:"hidden"},[q]:{exposure:"hidden",storageGroup:"surveys"},[B]:{exposure:"hidden",storageGroup:"surveys",volatile:!0},[z]:{exposure:"event"},[H]:{exposure:"hidden"},$product_tours_activated:{exposure:"hidden"},$conversations_widget_session_id:{exposure:"event"},$conversations_ticket_id:{exposure:"event"},$conversations_widget_state:{exposure:"event"},$conversations_user_traits:{exposure:"event"},[N]:{exposure:"hidden"},[j]:{exposure:"hidden"},[U]:{exposure:"hidden"},[W]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[V]:{exposure:"hidden"},[G]:{exposure:"hidden"},[K]:{exposure:"hidden"},[Q]:{exposure:"hidden"},[J]:{exposure:"hidden"},[Y]:{exposure:"hidden"},[X]:{exposure:"hidden"},[w]:{exposure:"event"},[x]:{exposure:"event"},[S]:{exposure:"event"},[E]:{exposure:"event"},[te]:{exposure:"event"},[ie]:{exposure:"event"},[re]:{exposure:"event"},$sdk_debug_replay_event_trigger_status:{exposure:"event"},$sdk_debug_replay_linked_flag_trigger_status:{exposure:"event"},$sdk_debug_replay_matched_recording_trigger_groups:{exposure:"event"},$sdk_debug_replay_remote_trigger_matching_config:{exposure:"event"},$sdk_debug_replay_trigger_groups_count:{exposure:"event"},$sdk_debug_replay_url_trigger_status:{exposure:"event"},$session_recording_start_reason:{exposure:"event"}},Ns=[["$posthog_sr_group_event_trigger_",{exposure:"hidden"}],["$posthog_sr_group_url_trigger_",{exposure:"hidden"}],["$posthog_sr_group_sampling_",{exposure:"hidden"}]],js=e=>{var t=Hs[e];if(t)return t;for(var[i,r]of Ns)if(0===e.indexOf(i))return r},Us=e=>{var t=null==ye?void 0:ye.createElement("a");return Ze(t)?null:(t.href=e,t)},Ws=function(e,t){for(var i,r=((e.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),s=0;r.length>s;s++){var n=r[s].split("=");if(n[0]===t){i=n;break}}if(!Qe(i)||2>i.length)return"";var o=i[1];try{o=decodeURIComponent(o)}catch(e){gr.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},Vs=function(e,t,i){if(!e||!t||!t.length)return e;for(var r=e.split("#"),s=r[1],n=(r[0]||"").split("?"),o=n[1],a=n[0],l=(o||"").split("&"),u=[],c=0;l.length>c;c++){var d=l[c].split("=");Qe(d)&&(t.includes(d[0])?u.push(d[0]+"="+i):u.push(l[c]))}var _=a;return null!=o&&(_+="?"+u.join("&")),null!=s&&(_+="#"+s),_},Gs=function(e,t){var i=e.match(new RegExp(t+"=([^&]*)"));return i?i[1]:null},Ks="https?://(.*)",Qs=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],Js=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...Qs],Ys="<masked>",Xs=["li_fat_id"];function Zs(e,t,i){if(!ye)return{};var r,s=t?[...Qs,...i||[]]:[],n=en(Vs(ye.URL,s,Ys),e),o=(r={},mr(Xs,(function(e){var t=Dr._get(e);r[e]=t||null})),r);return yr(o,n)}function en(e,t){var i=Js.concat(t||[]),r={};return mr(i,(function(t){var i=Ws(e,t);r[t]=i||null})),r}function tn(e){var t=function(e){return e?0===e.search(Ks+"google.([^/?]*)")?"google":0===e.search(Ks+"bing.com")?"bing":0===e.search(Ks+"yahoo.com")?"yahoo":0===e.search(Ks+"duckduckgo.com")?"duckduckgo":null:null}(e),i="yahoo"!=t?"q":"p",r={};if(!it(t)){r.$search_engine=t;var s=ye?Ws(ye.referrer,i):"";s.length&&(r.ph_keyword=s)}return r}function rn(){return navigator.language||navigator.userLanguage}var sn="$direct";function nn(){return(null==ye?void 0:ye.referrer)||sn}function on(e,t){var i=e?[...Qs,...t||[]]:[],r=null==be?void 0:be.href.substring(0,1e3);return{r:nn().substring(0,1e3),u:r?Vs(r,i,Ys):void 0}}function an(e){var t,{r:i,u:r}=e,s={$referrer:i,$referring_domain:null==i?void 0:i==sn?sn:null==(t=Us(i))?void 0:t.host};if(r){s.$current_url=r;var n=Us(r);s.$host=null==n?void 0:n.host,s.$pathname=null==n?void 0:n.pathname;var o=en(r);yr(s,o)}if(i){var a=tn(i);yr(s,a)}return s}function ln(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(e){return}}function un(){try{return(new Date).getTimezoneOffset()}catch(e){return}}var cn={flags:W,surveys:B},dn=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],_n="main";class hn{constructor(e,t,r){if(void 0===r&&(r=!0),this._slotState={},this._splitStorageEligible=!1,this._splitStorage=!1,this._config=e,this._ownsSplitStorage=r,this.props={},this._campaign_params_saved=!1,this._name=(e=>{var t="";return e.token&&(t=e.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),e.persistence_name?"ph_"+e.persistence_name:"ph_"+t+"_posthog"})(e),this._storage=this._buildStorage(e),this._splitStorage=this._resolveSplitStorage(e),this.load(),e.debug&&gr.info("Persistence loaded",e.persistence,i({},this.props)),this.update_config(e,e,t),this.save(),ve){var s=()=>this.flush();Pr(ve,"beforeunload",s,{capture:!1}),Pr(ve,"pagehide",s,{capture:!1})}}_saveDebounceMs(){var e,t=null==(e=this._config)?void 0:e.persistence_save_debounce_ms;return st(t)&&t>0?t:0}isDisabled(){return!!this._disabled}_buildStorage(e){-1===dn.indexOf(e.persistence.toLowerCase())&&(gr.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var t,r=function(e,t){void 0===e&&(e=[]),void 0===t&&(t=!1);var r=[...zr,...e];return i({},Br,{_parse(e){try{var i={};try{i=Dr._parse(e)||{}}catch(e){}var r,s=JSON.parse(Br._get(e)||"{}");if(t){var n={};for(var o in i){var a=i[o];it(a)||""===a||(n[o]=a)}r=yr(s,n)}else r=yr(i,s);return Br._set(e,r),r}catch(e){}return null},_set(e,t,i,s,n,o){var a=Br._set(e,t,void 0,void 0,o);try{var l={};r.forEach((e=>{t[e]&&(l[e]=t[e])})),Object.keys(l).length&&Dr._set(e,l,i,s,n,o)}catch(e){Br._error(e)}return a},_remove(e,t){try{null==ve||ve.localStorage.removeItem(e),Dr._remove(e,t)}catch(e){Br._error(e)}}})}(e.cookie_persisted_properties||[],e.__preview_cookie_wins_on_conflict||!1),s=!1,n=e.persistence.toLowerCase();return"localstorage"===n&&Br._is_supported()?(t=Br,s=!0):"localstorage+cookie"===n&&r._is_supported()?(t=r,s=!0):"sessionstorage"===n&&Ur._is_supported()?t=Ur:"memory"===n?t=Nr:"cookie"===n?t=Dr:r._is_supported()?(t=r,s=!0):t=Dr,this._splitStorageEligible=s,t}_groupEntryName(e){return this._name+"__"+e}_resolveSplitStorage(e){return this._splitStorageEligible&&!!e.split_storage}_isFeatureFlagCacheStale(e){var t=null!=e?e:this._config.feature_flag_cache_ttl_ms;if(!t||0>=t)return!1;var i=this.props[W];return!i||"number"!=typeof i||Date.now()-i>t}properties(){var e={};return mr(this.props,((t,i)=>{var r=js(i);if("derived"===(null==r?void 0:r.exposure)){if(null!=r.shouldSkipFromEventProperties&&r.shouldSkipFromEventProperties(t,i===I?()=>this._isFeatureFlagCacheStale():()=>!1))return;r.transformToEventProperties&&yr(e,r.transformToEventProperties(t))}else if(!r||"event"===r.exposure){if(null!=r&&null!=r.shouldSkipFromEventProperties&&r.shouldSkipFromEventProperties(t,(()=>!1)))return;e[i]=t}})),e}load(){if(!this._disabled){var e=this._storage._parse(this._name);e&&(this.props=yr({},e)),this._splitStorage&&this._loadGroupEntries()}}_loadGroupEntries(){for(var e of zs){var t=Br._parse(this._groupEntryName(e));if(t&&!Xe(t)){var i=this._slotWriteState(e);i.persisted=!0,this._mainCarriesGroupKey(e)||(i.fingerprint=this._entryFingerprint(t,e)),this._groupEntryIsStale(e,t)||yr(this.props,t)}}}_mainCarriesGroupKey(e){return Object.keys(this.props).some((t=>{var i;return(null==(i=js(t))?void 0:i.storageGroup)===e}))}_groupEntryIsStale(e,t){var i=cn[e];if(!i)return!1;var r=t[i],s=this.props[i];return st(r)&&st(s)&&s>r}refreshKey(e){var t;if(!this._disabled){var i=this._splitStorage?null==(t=js(e))?void 0:t.storageGroup:void 0,r=i?Br._parse(this._groupEntryName(i)):this._storage._parse(this._name);if(r&&e in r)this._setProp(e,r[e]);else{if(i){var s=this._storage._parse(this._name);if(s&&e in s)return void this._setProp(e,s[e])}this._deleteProp(e)}}}save(){if(!this._disabled){var e=this._saveDebounceMs();e>0?Ze(this._pendingSaveTimer)&&(this._pendingSaveTimer=setTimeout((()=>{this._pendingSaveTimer=void 0,this._writeNow()}),e)):this._writeNow()}}flush(){Ze(this._pendingSaveTimer)||(clearTimeout(this._pendingSaveTimer),this._pendingSaveTimer=void 0,this._writeNow())}_writeNow(){this._disabled||(this._splitStorage?this._writeNowSplit():this._writeEntry(this._storage,this._name,this.props,_n))}_writeNowSplit(){var{main:e,groups:t}=this._partitionProps();for(var i of(this._writeEntry(this._storage,this._name,e,_n),zs)){var r,s=t[i];(!Xe(s)||null!=(r=this._slotState[i])&&r.persisted)&&this._writeEntry(Br,this._groupEntryName(i),s,i)}}_partitionProps(){var e={},t={};for(var i of zs)t[i]={};return mr(this.props,((i,r)=>{var s,n=null==(s=js(r))?void 0:s.storageGroup;n?t[n][r]=i:e[r]=i})),{main:e,groups:t}}_entryFingerprint(e,t){if(t===_n)return JSON.stringify(e)+"|"+this._expire_days+"|"+this._cross_subdomain+"|"+this._secure;var i={};return mr(e,((e,t)=>{var r;i[t]=null!=(r=js(t))&&r.volatile?"__volatile__":e})),JSON.stringify(i)}_writeEntry(e,t,i,r){var s=this._slotWriteState(r);if(r===_n||s.dirty||Ze(s.fingerprint)){var n;try{if((n=this._entryFingerprint(i,r))===s.fingerprint)return void(s.dirty=!1)}catch(e){n=void 0}e._set(t,i,this._expire_days,this._cross_subdomain,this._secure,this._config.debug)?(s.dirty=!1,r!==_n&&(s.persisted=!0),Ze(n)||(s.fingerprint=n)):this._config.debug&&gr.warn('failed to persist storage entry "'+t+'"; will retry on next save')}}remove(e){var{keepGroupEntries:t=!1}=void 0===e?{}:e;if(Ze(this._pendingSaveTimer)||(clearTimeout(this._pendingSaveTimer),this._pendingSaveTimer=void 0),this._storage._remove(this._name,!1),this._storage._remove(this._name,!0),!t&&this._ownsSplitStorage)for(var i of zs)Br._remove(this._groupEntryName(i));t?delete this._slotState[_n]:this._slotState={}}clear(){this.remove(),this.props={}}register_once(e,t,i){if(Ye(e)){Ze(t)&&(t="None"),this._expire_days=Ze(i)?this._default_expiry:i;var r=!1;if(mr(e,((e,i)=>{this.props.hasOwnProperty(i)&&this.props[i]!==t||(this._setProp(i,e),r=!0)})),r)return this.save(),!0}return!1}register(e,t){if(Ye(e)){this._expire_days=Ze(t)?this._default_expiry:t;var i=!1;if(mr(e,((t,r)=>{e.hasOwnProperty(r)&&this.props[r]!==t&&(this._setProp(r,t),i=!0)})),i)return this.save(),!0}return!1}unregister(e){e in this.props&&(this._deleteProp(e),this.save())}update_campaign_params(){if(!this._campaign_params_saved){var e=Zs(this._config.custom_campaign_params,this._config.mask_personal_data_properties,this._config.custom_personal_data_properties);Xe(Sr(e))||this.register(e),this._campaign_params_saved=!0}}update_search_keyword(){var e;this.register((e=null==ye?void 0:ye.referrer)?tn(e):{})}update_referrer_info(){var e;this.register_once({$referrer:nn(),$referring_domain:null!=ye&&ye.referrer&&(null==(e=Us(ye.referrer))?void 0:e.host)||sn},void 0)}set_initial_person_info(){this.props[Q]||this.props[J]||this.register_once({[Y]:on(this._config.mask_personal_data_properties,this._config.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};mr([J,Q],(t=>{var i=this.props[t];i&&mr(i,(function(t,i){e["$initial_"+We(i)]=t}))}));var t,i,r=this.props[Y];if(r){var s=(t=an(r),i={},mr(t,(function(e,t){i["$initial_"+We(t)]=e})),i);yr(e,s)}return e}safe_merge(e){return mr(this.props,(function(t,i){i in e||(e[i]=t)})),e}update_config(e,t,i){this._default_expiry=this._expire_days=e.cookie_expiration,this.set_disabled(e.disable_persistence||!!i),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie);var r=e.persistence!==t.persistence||!((e,t)=>{if(e.length!==t.length)return!1;var i=[...e].sort(),r=[...t].sort();return i.every(((e,t)=>e===r[t]))})(e.cookie_persisted_properties||[],t.cookie_persisted_properties||[]),s=r?this._buildStorage(e):this._storage,n=this._resolveSplitStorage(e);if(r||n!==this._splitStorage){var o=this.props;this.clear(),this._storage=s,this._splitStorage=n,this.props=o,this.save()}}set_disabled(e){this._disabled=e,this._disabled?this.remove():this.save()}set_cross_subdomain(e){e!==this._cross_subdomain&&(this._cross_subdomain=e,this.remove({keepGroupEntries:!0}),this.save())}set_secure(e){e!==this._secure&&(this._secure=e,this.remove({keepGroupEntries:!0}),this.save())}set_event_timer(e,t){var i=this.props[u]||{};i[e]=t,this._setProp(u,i),this.save()}remove_event_timer(e){var t=this.props[u]||{},i=t[e];return Ze(i)||(delete t[e],this._setProp(u,t),this.save()),i}get_property(e){return this.props[e]}set_property(e,t){this._setProp(e,t),this.save()}_setProp(e,t){var i;this.props[e]=t,null!=(i=js(e))&&i.volatile||this._markGroupDirty(e)}_deleteProp(e){delete this.props[e],this._markGroupDirty(e)}_markGroupDirty(e){var t,i=null==(t=js(e))?void 0:t.storageGroup;i&&(this._slotWriteState(i).dirty=!0)}_slotWriteState(e){return this._slotState[e]||(this._slotState[e]={})}}var pn="events",gn="cancelEvents",vn="survey shown",fn="survey dismissed",mn="survey sent",yn="popover",bn=vr("[RateLimiter]");class wn{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=e=>{var t=e.text;if(t&&t.length)try{(JSON.parse(t).quota_limited||[]).forEach((e=>{bn.info((e||"events")+" is quota limited."),this.serverLimits[e]=(new Date).getTime()+6e4}))}catch(e){return void bn.warn('could not rate limit - continuing. Error: "'+(null==e?void 0:e.message)+'"',{text:t})}},this.instance=e,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var e;return(null==(e=this.instance.config.rate_limiting)?void 0:e.events_per_second)||10}get captureEventsBurstLimit(){var e;return Math.max((null==(e=this.instance.config.rate_limiting)?void 0:e.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(e){var t,i,r;void 0===e&&(e=!1);var{captureEventsBurstLimit:s,captureEventsPerSecond:n}=this,o=(new Date).getTime(),a=null!==(t=null==(i=this.instance.persistence)?void 0:i.get_property(K))&&void 0!==t?t:{tokens:s,last:o};a.tokens+=(o-a.last)/1e3*n,a.last=o,a.tokens>s&&(a.tokens=s);var l=1>a.tokens;return l||e||(a.tokens=Math.max(0,a.tokens-1)),!l||this.lastEventRateLimited||e||this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited. Config is set to "+n+" events per second and "+s+" events burst limit."},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=l,null==(r=this.instance.persistence)||r.set_property(K,a),{isRateLimited:l,remainingTokens:a.tokens}}isServerRateLimited(e){var t=this.serverLimits[e||"events"]||!1;return!1!==t&&(new Date).getTime()<t}}var xn=vr("[RemoteConfig]");class Sn{constructor(e){this._instance=e}get remoteConfig(){var e;return null==(e=Pe._POSTHOG_REMOTE_CONFIG)||null==(e=e[this._instance.config.token])?void 0:e.config}_loadRemoteConfigJs(e){var t,i;null!=(t=Pe.__PosthogExtensions__)&&t.loadExternalDependency?null==(i=Pe.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"remote-config",(()=>e(this.remoteConfig))):e()}_loadRemoteConfigJSON(e){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback(t){e(t.json)}})}load(){try{if(this.remoteConfig)return xn.info("Using preloaded remote config",this.remoteConfig),this._onRemoteConfig(this.remoteConfig),void this._startRefreshInterval();if(this._instance._shouldDisableFlags())return void xn.warn("Remote config is disabled. Falling back to local config.");this._loadRemoteConfigJs((e=>{if(!e)return xn.info("No config found after loading remote JS config. Falling back to JSON."),void this._loadRemoteConfigJSON((e=>{this._onRemoteConfig(e),this._startRefreshInterval()}));this._onRemoteConfig(e),this._startRefreshInterval()}))}catch(e){xn.error("Error loading remote config",e)}}stop(){this._refreshInterval&&(clearInterval(this._refreshInterval),this._refreshInterval=void 0)}refresh(){!this._instance._shouldDisableFlags()&&ye&&"hidden"!==ye.visibilityState&&this._instance.reloadFeatureFlags()}_startRefreshInterval(){var e;if(!this._refreshInterval){var t=null!==(e=this._instance.config.remote_config_refresh_interval_ms)&&void 0!==e?e:3e5;0!==t&&(this._refreshInterval=setInterval((()=>{this.refresh()}),t))}}_onRemoteConfig(e){var t;e||xn.error("Failed to fetch remote config from PostHog."),this._instance._onRemoteConfig(null!=e?e:{}),!1!==(null==e?void 0:e.hasFeatureFlags)&&(this._instance.config.advanced_disable_feature_flags_on_first_load||null==(t=this._instance.featureFlags)||t.ensureFlagsLoaded())}}var En="gzip-js",kn="base64",Pn=Uint8Array,In=Uint16Array,Cn=Uint32Array,Fn=new Pn([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]),Tn=new Pn([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]),Rn=new Pn([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ln=function(e,t){for(var i=new In(31),r=0;31>r;++r)i[r]=t+=1<<e[r-1];var s=new Cn(i[30]);for(r=1;30>r;++r)for(var n=i[r];i[r+1]>n;++n)s[n]=n-i[r]<<5|r;return[i,s]},Mn=Ln(Fn,2),$n=Mn[1];Mn[0][28]=258,$n[258]=28;for(var An=Ln(Tn,0)[1],On=new In(32768),Dn=0;32768>Dn;++Dn){var qn=(43690&Dn)>>>1|(21845&Dn)<<1;On[Dn]=((65280&(qn=(61680&(qn=(52428&qn)>>>2|(13107&qn)<<2))>>>4|(3855&qn)<<4))>>>8|(255&qn)<<8)>>>1}var Bn=function(e,t,i){for(var r=e.length,s=0,n=new In(t);r>s;++s)++n[e[s]-1];var o,a=new In(t);for(s=0;t>s;++s)a[s]=a[s-1]+n[s-1]<<1;if(i){o=new In(1<<t);var l=15-t;for(s=0;r>s;++s)if(e[s])for(var u=s<<4|e[s],c=t-e[s],d=a[e[s]-1]++<<c,_=d|(1<<c)-1;_>=d;++d)o[On[d]>>>l]=u}else for(o=new In(r),s=0;r>s;++s)o[s]=On[a[e[s]-1]++]>>>15-e[s];return o},zn=new Pn(288);for(Dn=0;144>Dn;++Dn)zn[Dn]=8;for(Dn=144;256>Dn;++Dn)zn[Dn]=9;for(Dn=256;280>Dn;++Dn)zn[Dn]=7;for(Dn=280;288>Dn;++Dn)zn[Dn]=8;var Hn=new Pn(32);for(Dn=0;32>Dn;++Dn)Hn[Dn]=5;var Nn=Bn(zn,9,0),jn=Bn(Hn,5,0),Un=function(e){return(e/8>>0)+(7&e&&1)},Wn=function(e,t,i){(null==i||i>e.length)&&(i=e.length);var r=new(e instanceof In?In:e instanceof Cn?Cn:Pn)(i-t);return r.set(e.subarray(t,i)),r},Vn=function(e,t,i){var r=t/8>>0;e[r]|=i<<=7&t,e[r+1]|=i>>>8},Gn=function(e,t,i){var r=t/8>>0;e[r]|=i<<=7&t,e[r+1]|=i>>>8,e[r+2]|=i>>>16},Kn=function(e,t){for(var i=[],r=0;e.length>r;++r)e[r]&&i.push({s:r,f:e[r]});var s=i.length,n=i.slice();if(!s)return[new Pn(0),0];if(1==s){var o=new Pn(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],u=0,c=1,d=2;for(i[0]={s:-1,f:a.f+l.f,l:a,r:l};c!=s-1;)a=i[i[d].f>i[u].f?u++:d++],l=i[u!=c&&i[d].f>i[u].f?u++:d++],i[c++]={s:-1,f:a.f+l.f,l:a,r:l};var _=n[0].s;for(r=1;s>r;++r)n[r].s>_&&(_=n[r].s);var h=new In(_+1),p=Qn(i[c-1],h,0);if(p>t){r=0;var g=0,v=p-t,f=1<<v;for(n.sort((function(e,t){return h[t.s]-h[e.s]||e.f-t.f}));s>r;++r){var m=n[r].s;if(t>=h[m])break;g+=f-(1<<p-h[m]),h[m]=t}for(g>>>=v;g>0;){var y=n[r].s;t>h[y]?g-=1<<t-h[y]++-1:++r}for(;r>=0&&g;--r){var b=n[r].s;h[b]==t&&(--h[b],++g)}p=t}return[new Pn(h),p]},Qn=function(e,t,i){return-1==e.s?Math.max(Qn(e.l,t,i+1),Qn(e.r,t,i+1)):t[e.s]=i},Jn=function(e){for(var t=e.length;t&&!e[--t];);for(var i=new In(++t),r=0,s=e[0],n=1,o=function(e){i[r++]=e},a=1;t>=a;++a)if(e[a]==s&&a!=t)++n;else{if(!s&&n>2){for(;n>138;n-=138)o(32754);n>2&&(o(n>10?n-11<<5|28690:n-3<<5|12305),n=0)}else if(n>3){for(o(s),--n;n>6;n-=6)o(8304);n>2&&(o(n-3<<5|8208),n=0)}for(;n--;)o(s);n=1,s=e[a]}return[i.subarray(0,r),t]},Yn=function(e,t){for(var i=0,r=0;t.length>r;++r)i+=e[r]*t[r];return i},Xn=function(e,t,i){var r=i.length,s=Un(t+2);e[s]=255&r,e[s+1]=r>>>8,e[s+2]=255^e[s],e[s+3]=255^e[s+1];for(var n=0;r>n;++n)e[s+n+4]=i[n];return 8*(s+4+r)},Zn=function(e,t,i,r,s,n,o,a,l,u,c){Vn(t,c++,i),++s[256];for(var d=Kn(s,15),_=d[0],h=d[1],p=Kn(n,15),g=p[0],v=p[1],f=Jn(_),m=f[0],y=f[1],b=Jn(g),w=b[0],x=b[1],S=new In(19),E=0;m.length>E;++E)S[31&m[E]]++;for(E=0;w.length>E;++E)S[31&w[E]]++;for(var k=Kn(S,7),P=k[0],I=k[1],C=19;C>4&&!P[Rn[C-1]];--C);var F,T,R,L,M=u+5<<3,A=Yn(s,zn)+Yn(n,Hn)+o,O=Yn(s,_)+Yn(n,g)+o+14+3*C+Yn(S,P)+(2*S[16]+3*S[17]+7*S[18]);if(A>=M&&O>=M)return Xn(t,c,e.subarray(l,l+u));if(Vn(t,c,1+(A>O)),c+=2,A>O){F=Bn(_,h,0),T=_,R=Bn(g,v,0),L=g;var D=Bn(P,I,0);for(Vn(t,c,y-257),Vn(t,c+5,x-1),Vn(t,c+10,C-4),c+=14,E=0;C>E;++E)Vn(t,c+3*E,P[Rn[E]]);c+=3*C;for(var q=[m,w],B=0;2>B;++B){var z=q[B];for(E=0;z.length>E;++E)Vn(t,c,D[H=31&z[E]]),c+=P[H],H>15&&(Vn(t,c,z[E]>>>5&127),c+=z[E]>>>12)}}else F=Nn,T=zn,R=jn,L=Hn;for(E=0;a>E;++E)if(r[E]>255){var H;Gn(t,c,F[257+(H=r[E]>>>18&31)]),c+=T[H+257],H>7&&(Vn(t,c,r[E]>>>23&31),c+=Fn[H]);var N=31&r[E];Gn(t,c,R[N]),c+=L[N],N>3&&(Gn(t,c,r[E]>>>5&8191),c+=Tn[N])}else Gn(t,c,F[r[E]]),c+=T[r[E]];return Gn(t,c,F[256]),c+T[256]},eo=new Cn([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),to=function(){for(var e=new Cn(256),t=0;256>t;++t){for(var i=t,r=9;--r;)i=(1&i&&3988292384)^i>>>1;e[t]=i}return e}(),io=function(e,t,i){for(;i;++t)e[t]=i,i>>>=8};function ro(e,t){void 0===t&&(t={});var i=function(){var e=4294967295;return{p(t){for(var i=e,r=0;t.length>r;++r)i=to[255&i^t[r]]^i>>>8;e=i},d(){return 4294967295^e}}}(),r=e.length;i.p(e);var s,n,o,a,l,u=(a=10+((s=t).filename&&s.filename.length+1||0),l=8,function(e,t,i,r,s,n){var o=e.length,a=new Pn(r+o+5*(1+Math.floor(o/7e3))+s),l=a.subarray(r,a.length-s),u=0;if(!t||8>o)for(var c=0;o>=c;c+=65535){var d=c+65535;o>d?u=Xn(l,u,e.subarray(c,d)):(l[c]=!0,u=Xn(l,u,e.subarray(c,o)))}else{for(var _=eo[t-1],h=_>>>13,p=8191&_,g=(1<<i)-1,v=new In(32768),f=new In(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 Cn(25e3),x=new In(288),S=new In(32),E=0,k=0,P=(c=0,0),I=0,C=0;o>c;++c){var F=b(c),T=32767&c,R=f[F];if(v[T]=R,f[F]=T,c>=I){var L=o-c;if((E>7e3||P>24576)&&L>423){u=Zn(e,l,0,w,x,S,k,P,C,c-C,u),P=E=k=0,C=c;for(var M=0;286>M;++M)x[M]=0;for(M=0;30>M;++M)S[M]=0}var A=2,O=0,D=p,q=T-R&32767;if(L>2&&F==b(c-q))for(var B=Math.min(h,L)-1,z=Math.min(32767,c),H=Math.min(258,L);z>=q&&--D&&T!=R;){if(e[c+A]==e[c+A-q]){for(var N=0;H>N&&e[c+N]==e[c+N-q];++N);if(N>A){if(A=N,O=q,N>B)break;var j=Math.min(q,N-2),U=0;for(M=0;j>M;++M){var W=c-q+M+32768&32767,V=W-v[W]+32768&32767;V>U&&(U=V,R=W)}}}q+=(T=R)-(R=v[T])+32768&32767}if(O){w[P++]=268435456|$n[A]<<18|An[O];var G=31&$n[A],K=31&An[O];k+=Fn[G]+Tn[K],++x[257+G],++S[K],I=c+A,++E}else w[P++]=e[c],++x[e[c]]}}u=Zn(e,l,!0,w,x,S,k,P,C,c-C,u)}return Wn(a,0,r+Un(u)+s)}(n=e,null==(o=t).level?6:o.level,null==o.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(n.length)))):12+o.mem,a,l)),c=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&&io(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),i){e[3]=8;for(var r=0;i.length>=r;++r)e[r+10]=i.charCodeAt(r)}}(u,t),io(u,c-8,i.d()),io(u,c-4,r),u}var so=!!xe||!!we,no="text/plain",oo=!1,ao=(e,t)=>{var[i,r]=e.split("#"),[s,n]=i.split("?");if(!n)return e;var o=n.split("&").filter((e=>e.split("=")[0]!==t)).join("&");return s+(o?"?"+o:"")+(r?"#"+r:"")},lo=function(e,t,r){var s;void 0===r&&(r=!0);var[n,o]=e.split("?"),a=i({},t),l=null!==(s=null==o?void 0:o.split("&").map((e=>{var t,[i,s]=e.split("="),n=r&&null!==(t=a[i])&&void 0!==t?t:s;return delete a[i],i+"="+n})))&&void 0!==s?s:[],u=function(e,t){var i,r;void 0===t&&(t="&");var s=[];return mr(e,(function(e,t){Ze(e)||Ze(t)||"undefined"===t||(i=encodeURIComponent((e=>e instanceof File)(e)?e.name:e.toString()),r=encodeURIComponent(t),s[s.length]=r+"="+i)})),s.join(t)}(a);return u&&l.push(u),n+"?"+l.join("&")},uo=(e,t)=>JSON.stringify(e,((e,t)=>"bigint"==typeof t?t.toString():t),t),co=e=>{if(e._encodedBody)return e._encodedBody;var{data:t,compression:i}=e;if(t){if(i===En){var r=ro(function(e,t){var i=e.length;if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var r=new Pn(e.length+(e.length>>>1)),s=0,n=function(e){r[s++]=e},o=0;i>o;++o){if(s+5>r.length){var a=new Pn(s+8+(i-o<<1));a.set(r),r=a}var l=e.charCodeAt(o);128>l?n(l):2048>l?(n(192|l>>>6),n(128|63&l)):l>55295&&57344>l?(n(240|(l=65536+(1047552&l)|1023&e.charCodeAt(++o))>>>18),n(128|l>>>12&63),n(128|l>>>6&63),n(128|63&l)):(n(224|l>>>12),n(128|l>>>6&63),n(128|63&l))}return Wn(r,0,s)}(uo(t)),{mtime:0});return{contentType:no,body:r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength),estimatedSize:r.byteLength}}if(i===kn){var s=function(e){return e?btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,((e,t)=>String.fromCharCode(parseInt(t,16))))):e}(uo(t)),n=(e=>"data="+encodeURIComponent("string"==typeof e?e:uo(e)))(s);return{contentType:"application/x-www-form-urlencoded",body:n,estimatedSize:new Blob([n]).size}}var o=uo(t);return{contentType:"application/json",body:o,estimatedSize:new Blob([o]).size}}},_o=e=>{var t,r,s,n=co(e);return!n||(r=e.compression,s=Ws(e.url,"compression"),r!==Le.GZipJS&&s!==Le.GZipJS&&"gzip"!==s)||((t=n.body)instanceof ArrayBuffer?Oe(new Uint8Array(t)):ArrayBuffer.isView(t)&&Oe(new Uint8Array(t.buffer,t.byteOffset,t.byteLength)))?{url:e.url,encodedBody:n}:(oo=!0,{url:ao(e.url,"compression"),encodedBody:co(i({},e,{compression:void 0,_encodedBody:void 0}))})},ho=function(){var e=t((function*(e){var t=uo(e.data),r=yield function(e,t,i){return ze.apply(this,arguments)}(t,n.DEBUG,{rethrow:!0});if(!r)return e;var s=yield r.arrayBuffer();return i({},e,{_encodedBody:{contentType:no,body:s,estimatedSize:s.byteLength}})}));return function(t){return e.apply(this,arguments)}}(),po=(e,t)=>lo(e,{_:(new Date).getTime().toString(),ver:n.JS_SDK_VERSION,compression:t}),go=[];we&&go.push({transport:"fetch",method(e){var t,{url:r,encodedBody:s}=_o(e),{contentType:n,body:o,estimatedSize:a}=null!=s?s:{},l=new Headers;mr(e.headers,(function(e,t){l.append(t,e)})),n&&l.append("Content-Type",n);var u=null;if(Se){var c=new Se;u={signal:c.signal,timeout:setTimeout((()=>c.abort()),e.timeout)}}we(r,i({method:(null==e?void 0:e.method)||"GET",headers:l,keepalive:"POST"===e.method&&52428.8>(a||0),body:o,signal:null==(t=u)?void 0:t.signal},e.fetchOptions)).then((t=>t.text().then((i=>{var r={statusCode:t.status,text:i};if(200===t.status)try{r.json=JSON.parse(i)}catch(e){gr.error(e)}null==e.callback||e.callback(r)})))).catch((t=>{gr.error(t),null==e.callback||e.callback({statusCode:0,error:t})})).finally((()=>u?clearTimeout(u.timeout):null))}}),xe&&go.push({transport:"XHR",method(e){var t=new xe,{url:i,encodedBody:r}=_o(e);t.open(e.method||"GET",i,!0);var{contentType:s,body:n}=null!=r?r:{};mr(e.headers,(function(e,i){t.setRequestHeader(i,e)})),s&&t.setRequestHeader("Content-Type",s),e.timeout&&(t.timeout=e.timeout),t.onreadystatechange=()=>{if(4===t.readyState){var i={statusCode:t.status,text:t.responseText};if(200===t.status)try{i.json=JSON.parse(t.responseText)}catch(e){}null==e.callback||e.callback(i)}},t.send(n)}}),null!=me&&me.sendBeacon&&go.push({transport:"sendBeacon",method(e){try{var{url:t,encodedBody:i}=_o(e),{contentType:r,body:s}=null!=i?i:{};if(!s)return;var n=s instanceof Blob?s:new Blob([s],{type:r});me.sendBeacon(t,n)}catch(e){}}});var vo=3e3;class fo{constructor(e,t){this._isPaused=!0,this._queue=[],this._flushTimeoutMs=vt((null==t?void 0:t.flush_interval_ms)||vo,250,5e3,gr.createLogger("flush interval"),vo),this._sendRequest=e}enqueue(e){this._queue.push(e),this._flushTimeout||this._setFlushTimeout()}unload(){this._clearFlushTimeout();var e=this._queue.length>0?this._formatQueue():{},t=Object.values(e);[...t.filter((e=>0===e.url.indexOf("/e"))),...t.filter((e=>0!==e.url.indexOf("/e")))].map((e=>{this._sendRequest(i({},e,{transport:"sendBeacon"}))}))}enable(){this._isPaused=!1,this._setFlushTimeout()}_setFlushTimeout(){var e=this;this._isPaused||(this._flushTimeout=setTimeout((()=>{if(this._clearFlushTimeout(),this._queue.length>0){var t=this._formatQueue(),i=function(){var i=t[r],s=(new Date).getTime();i.data&&Qe(i.data)&&mr(i.data,(e=>{e.offset=Math.abs(e.timestamp-s),delete e.timestamp})),e._sendRequest(i)};for(var r in t)i()}}),this._flushTimeoutMs))}_clearFlushTimeout(){clearTimeout(this._flushTimeout),this._flushTimeout=void 0}_formatQueue(){var e={};return mr(this._queue,(t=>{var r,s=t,n=(s?s.batchKey:null)||s.url;Ze(e[n])&&(e[n]=i({},s,{data:[]})),null==(r=e[n].data)||r.push(s.data)})),this._queue=[],e}}var mo=["retriesPerformedSoFar"];class yo{constructor(e){this._isPolling=!1,this._pollIntervalMs=3e3,this._queue=[],this._instance=e,this._queue=[],this._areWeOnline=!0,!Ze(ve)&&"onLine"in ve.navigator&&(this._areWeOnline=ve.navigator.onLine,this._onlineListener=()=>{this._areWeOnline=!0,this._flush()},this._offlineListener=()=>{this._areWeOnline=!1},Pr(ve,"online",this._onlineListener),Pr(ve,"offline",this._offlineListener))}get length(){return this._queue.length}retriableRequest(e){var{retriesPerformedSoFar:t}=e,s=r(e,mo);nt(t)&&(s.url=lo(s.url,{retry_count:t})),this._instance._send_request(i({},s,{callback:e=>{if(200!==e.statusCode&&(400>e.statusCode||e.statusCode>=500)){if((0===e.statusCode?3:10)>(null!=t?t:0))return void this._enqueue(i({retriesPerformedSoFar:t},s));0===e.statusCode&&gr.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!=t?t:0)+" retries.")}null==s.callback||s.callback(e)}}))}_enqueue(e){var t=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=t+1;var i=function(e){var t=3e3*Math.pow(2,e),i=t/2,r=Math.min(18e5,t),s=Math.random()-.5;return Math.ceil(r+s*(r-i))}(t),r=Date.now()+i;this._queue.push({retryAt:r,requestOptions:e});var s="Enqueued failed request for retry in "+i;navigator.onLine||(s+=" (Browser is offline)"),gr.warn(s),this._isPolling||(this._isPolling=!0,this._poll())}_poll(){if(this._poller&&clearTimeout(this._poller),0===this._queue.length)return this._isPolling=!1,void(this._poller=void 0);this._poller=setTimeout((()=>{this._areWeOnline&&this._queue.length>0&&this._flush(),this._poll()}),this._pollIntervalMs)}_flush(){var e=Date.now(),t=[],i=this._queue.filter((i=>e>i.retryAt||(t.push(i),!1)));if(this._queue=t,i.length>0)for(var{requestOptions:r}of i)this.retriableRequest(r)}unload(){for(var{requestOptions:e}of(this._poller&&(clearTimeout(this._poller),this._poller=void 0),this._isPolling=!1,Ze(ve)||(this._onlineListener&&(ve.removeEventListener("online",this._onlineListener),this._onlineListener=void 0),this._offlineListener&&(ve.removeEventListener("offline",this._offlineListener),this._offlineListener=void 0)),this._queue))try{this._instance._send_request(i({},e,{transport:"sendBeacon"}))}catch(e){gr.error(e)}this._queue=[]}}class bo{constructor(e){this._updateScrollData=()=>{var e,t,i,r;this._context||(this._context={});var s=this.scrollElement(),n=this.scrollY(),o=s?Math.max(0,s.scrollHeight-s.clientHeight):0,a=n+((null==s?void 0:s.clientHeight)||0),l=(null==s?void 0:s.scrollHeight)||0;this._context.lastScrollY=Math.ceil(n),this._context.maxScrollY=Math.max(n,null!==(e=this._context.maxScrollY)&&void 0!==e?e:0),this._context.maxScrollHeight=Math.max(o,null!==(t=this._context.maxScrollHeight)&&void 0!==t?t:0),this._context.lastContentY=a,this._context.maxContentY=Math.max(a,null!==(i=this._context.maxContentY)&&void 0!==i?i:0),this._context.maxContentHeight=Math.max(l,null!==(r=this._context.maxContentHeight)&&void 0!==r?r:0)},this._instance=e}get _scrollRoot(){return this._instance.config.scroll_root_selector}getContext(){return this._context}resetContext(){var e=this._context;return setTimeout(this._updateScrollData,0),e}startMeasuringScrollPosition(){Pr(ve,"scroll",this._updateScrollData,{capture:!0}),Pr(ve,"scrollend",this._updateScrollData,{capture:!0}),Pr(ve,"resize",this._updateScrollData)}scrollElement(){if(!this._scrollRoot)return null==ve?void 0:ve.document.documentElement;var e=Qe(this._scrollRoot)?this._scrollRoot:[this._scrollRoot];for(var t of e){var i=null==ve?void 0:ve.document.querySelector(t);if(i)return i}}_scrollPosition(e){var t="y"===e?"scrollTop":"scrollLeft";if(this._scrollRoot){var i=this.scrollElement();return i&&i[t]||0}return ve?"y"===e?ve.scrollY||ve.pageYOffset||ve.document.documentElement.scrollTop||0:ve.scrollX||ve.pageXOffset||ve.document.documentElement.scrollLeft||0:0}scrollY(){return this._scrollPosition("y")}scrollX(){return this._scrollPosition("x")}}var wo=e=>on(null==e?void 0:e.config.mask_personal_data_properties,null==e?void 0:e.config.custom_personal_data_properties);class xo{constructor(e,t,i,r){this._onSessionIdCallback=e=>{var t=this._getStored();if(!t||t.sessionId!==e){var i={sessionId:e,props:this._sessionSourceParamGenerator(this._instance)};this._persistence.register({[G]:i})}},this._instance=e,this._sessionIdManager=t,this._persistence=i,this._sessionSourceParamGenerator=r||wo,this._sessionIdManager.onSessionId(this._onSessionIdCallback)}_getStored(){return this._persistence.props[G]}getSetOnceProps(){var e,t=null==(e=this._getStored())?void 0:e.props;return t?"r"in t?an(t):{$referring_domain:t.referringDomain,$pathname:t.initialPathName,utm_source:t.utm_source,utm_campaign:t.utm_campaign,utm_medium:t.utm_medium,utm_content:t.utm_content,utm_term:t.utm_term}:{}}getSessionProps(){var e={};return mr(Sr(this.getSetOnceProps()),((t,i)=>{"$current_url"===i&&(i="url"),e["$session_entry_"+We(i)]=t})),e}}class So{constructor(){this._events={}}on(e,t){return this._events[e]||(this._events[e]=[]),this._events[e].push(t),()=>{this._events[e]=this._events[e].filter((e=>e!==t))}}emit(e,t){for(var i of this._events[e]||[])i(t);for(var r of this._events["*"]||[])r(e,t)}}var Eo=vr("[SessionId]");class ko{on(e,t){return this._eventEmitter.on(e,t)}constructor(e,t,i){var r;if(this._lastPersistedActivityTimestamp=null,this._sessionIdChangedHandlers=[],this._beforeUnloadListener=void 0,this._destroyed=!1,this._eventEmitter=new So,this._sessionHasBeenIdleTooLong=(e,t)=>!(!nt(e)||!nt(t))&&Math.abs(e-t)>this.sessionTimeoutMs,!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(e.config.cookieless_mode===oe)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._sessionActivityTimestamp=null,this._sessionIdGenerator=t||Mr,this._windowIdGenerator=i||Mr;var s=this._config.persistence_name||this._config.token;if(this._sessionTimeoutMs=1e3*vt(this._config.session_idle_timeout_seconds||1800,60,36e3,Eo.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this._resetIdleTimer(),this._window_id_storage_key="ph_"+s+"_window_id",this._primary_window_exists_storage_key="ph_"+s+"_primary_window_exists",this._canUseSessionStorage()){var n=Ur._parse(this._window_id_storage_key),o=Ur._parse(this._primary_window_exists_storage_key);n&&!o?this._windowId=n:Ur._remove(this._window_id_storage_key),Ur._set(this._primary_window_exists_storage_key,!0)}if(null!=(r=this._config.bootstrap)&&r.sessionID)try{var a=(e=>{var t=this._config.bootstrap.sessionID.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)})();this._setSessionId(this._config.bootstrap.sessionID,(new Date).getTime(),a)}catch(e){Eo.error("Invalid sessionID in bootstrap",e)}this._listenToReloadWindow()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return Ze(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&&Ur._is_supported()}_setWindowId(e){e!==this._windowId&&(this._windowId=e,this._canUseSessionStorage()&&Ur._set(this._window_id_storage_key,e))}_getWindowId(){return this._windowId?this._windowId:this._canUseSessionStorage()?Ur._parse(this._window_id_storage_key):null}_isActivityChangeBelowGranularity(e){var t=this._lastPersistedActivityTimestamp;return!it(t)&&!it(e)&&5e3>Math.abs(e-t)}_setSessionId(e,t,i){var r=t!==this._sessionActivityTimestamp,s=!(e!==this._sessionId||i!==this._sessionStartTimestamp);this._sessionStartTimestamp=i,this._sessionActivityTimestamp=t,this._sessionId=e,s&&!r||s&&this._isActivityChangeBelowGranularity(t)||(this._lastPersistedActivityTimestamp=t,this._persistence.register({[k]:[t,e,i]}))}_useCrossTabRefreshHardening(){var e,t=null==(e=this._config)?void 0:e.persistence_save_debounce_ms;return nt(t)&&t>0}_refreshSessionIdFromStorage(){this._useCrossTabRefreshHardening()?this._persistence.refreshKey(k):(this._persistence.flush(),this._persistence.load())}_flushPendingActivityTimestamp(){var e;if(!it(this._sessionActivityTimestamp)&&this._sessionActivityTimestamp!==this._lastPersistedActivityTimestamp){this._refreshSessionIdFromStorage();var[,t,i]=this._getSessionId();t===this._sessionId&&i===this._sessionStartTimestamp&&(this._lastPersistedActivityTimestamp=this._sessionActivityTimestamp,this._persistence.register({[k]:[this._sessionActivityTimestamp,null!==(e=this._sessionId)&&void 0!==e?e:null,this._sessionStartTimestamp]}),this._persistence.flush())}}_freshestActivityTimestamp(){var[e]=this._getSessionId(),t=nt(e)?e:0,i=nt(this._sessionActivityTimestamp)?this._sessionActivityTimestamp:0;return Math.max(t,i)}_isSessionIdleAfterCrossTabRefresh(e){return this._refreshSessionIdFromStorage(),this._sessionHasBeenIdleTooLong(e,this._freshestActivityTimestamp())}_getSessionId(){var e=this._persistence.props[k];return Qe(e)&&2===e.length&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this._lastPersistedActivityTimestamp=null,clearTimeout(this._enforceIdleTimeout),this._enforceIdleTimeout=void 0,this._setSessionId(null,null,null)}destroy(){this._destroyed=!0,this._flushPendingActivityTimestamp(),clearTimeout(this._enforceIdleTimeout),this._enforceIdleTimeout=void 0,this._beforeUnloadListener&&ve&&(ve.removeEventListener(de,this._beforeUnloadListener,{capture:!1}),this._beforeUnloadListener=void 0),this._sessionIdChangedHandlers=[]}_listenToReloadWindow(){this._beforeUnloadListener=()=>{this._flushPendingActivityTimestamp(),this._canUseSessionStorage()&&Ur._remove(this._primary_window_exists_storage_key)},Pr(ve,de,this._beforeUnloadListener,{capture:!1})}checkAndGetSessionAndWindowId(e,t){if(void 0===e&&(e=!1),void 0===t&&(t=null),this._config.cookieless_mode===oe)throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var i=t||(new Date).getTime(),[,r,s]=this._getSessionId(),n=this._freshestActivityTimestamp(),o=this._getWindowId(),a=nt(s)&&Math.abs(i-s)>864e5,l=!1,u=!1,c=!r,d=r,_=!c&&!e&&this._sessionHasBeenIdleTooLong(i,n);_&&((_=this._isSessionIdleAfterCrossTabRefresh(i))||Eo.info("cross-tab refresh kept the session alive",{sessionId:r}),[,r,s]=this._getSessionId()),c||_||a?(r=this._sessionIdGenerator(),o=this._windowIdGenerator(),Eo.info("new session ID generated",{sessionId:r,windowId:o,changeReason:{noSessionId:c,activityTimeout:_,sessionPastMaximumLength:a}}),s=i,l=!0):(o||(o=this._windowIdGenerator(),l=!0),(u=r!==d)&&(Eo.info("adopted cross-tab session id",{sessionId:r,windowId:o}),l=!0));var h=nt(n)&&e&&!a?n:i,p=nt(s)?s:(new Date).getTime();this._setWindowId(o),this._setSessionId(r,h,p),e||this._resetIdleTimer();var g={noSessionId:c,activityTimeout:_,sessionPastMaximumLength:a,crossTabAdoption:u};return l&&this._sessionIdChangedHandlers.forEach((e=>e(r,o,g))),{sessionId:r,windowId:o,sessionStartTimestamp:p,changeReason:l?g:void 0,lastActivityTimestamp:n}}_resetIdleTimer(){this._destroyed||(clearTimeout(this._enforceIdleTimeout),this._enforceIdleTimeout=setTimeout((()=>{if(!this._destroyed)if(this._isSessionIdleAfterCrossTabRefresh((new Date).getTime())){var e=this._sessionId;this.resetSessionId(),this._eventEmitter.emit("forcedIdleReset",{idleSessionId:e})}else this._resetIdleTimer()}),1.1*this.sessionTimeoutMs))}}var Po=function(e,t){if(!e)return!1;var i=e.userAgent;if(i&&Ne(i,t))return!0;try{var r=null==e?void 0:e.userAgentData;if(null!=r&&r.brands&&r.brands.some((e=>Ne(null==e?void 0:e.brand,t))))return!0}catch(e){}return!!e.webdriver},Io=function(e,t){if(!function(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}};function Co(e,t,i){return uo({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:i})}var Fo={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=>Io(t,e))))),not_regex:(e,t)=>t.every((t=>e.every((e=>!Io(t,e))))),icontains:(e,t)=>t.map(To).some((t=>e.map(To).some((e=>t.includes(e))))),not_icontains:(e,t)=>t.map(To).every((t=>e.map(To).every((e=>!t.includes(e))))),gt:(e,t)=>t.some((t=>{var i=parseFloat(t);return!isNaN(i)&&e.some((e=>i>parseFloat(e)))})),lt:(e,t)=>t.some((t=>{var i=parseFloat(t);return!isNaN(i)&&e.some((e=>i<parseFloat(e)))}))},To=e=>e.toLowerCase();function Ro(e,t){return!e||Object.entries(e).every((e=>{var[i,r]=e,s=null==t?void 0:t[i];if(Ze(s)||it(s))return!1;var n=[String(s)],o=Fo[r.operator];return!!o&&o(r.values,n)}))}var Lo="custom",Mo="i.posthog.com",$o=/^\/static\//;class Ao{constructor(e){this._regionCache={},this.instance=e}get apiHost(){var e=this.instance.config.api_host.trim().replace(/\/$/,"");return"https://app.posthog.com"===e?"https://us.i.posthog.com":e}get flagsApiHost(){var e=this.instance.config.flags_api_host;return e?e.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var e,t=null==(e=this.instance.config.ui_host)?void 0:e.replace(/\/$/,"");return t||(t=this.apiHost.replace("."+Mo,".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":Lo),this._regionCache[this.apiHost]}_staticAssetHostOverride(e){if($o.test(e)){var t=this.instance.config.asset_host;if("string"==typeof t)return t.trim().replace(/\/$/,"")||void 0}}endpointFor(e,t){if(void 0===t&&(t=""),t&&(t="/"===t[0]?t:"/"+t),"ui"===e)return this.uiHost+t;if("flags"===e)return this.flagsApiHost+t;if("assets"===e){var i=this._staticAssetHostOverride(t);if(i)return""+i+t}if(this.region===Lo)return this.apiHost+t;var r=Mo+t;switch(e){case"assets":return"https://"+this.region+"-assets."+r;case"api":return"https://"+this.region+"."+r}}}var Oo=vr("[Surveys]"),Do="seenSurvey_",qo=["popover","widget","api"],Bo={ignoreConditions:!1,ignoreDelay:!1,displayType:yn},zo=vr("[PostHog ExternalIntegrations]"),Ho={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};class No{constructor(e){this._instance=e}_loadScript(e,t){var i;null==(i=Pe.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,e,(e=>{if(e)return zo.error("failed to load script",e);t()}))}startIfEnabledOrStop(){var e=this,t=function(t){var i,s,n;!r||null!=(i=Pe.__PosthogExtensions__)&&null!=(i=i.integrations)&&i[t]||e._loadScript(Ho[t],(()=>{var i;null==(i=Pe.__PosthogExtensions__)||null==(i=i.integrations)||null==(i=i[t])||i.start(e._instance)})),!r&&null!=(s=Pe.__PosthogExtensions__)&&null!=(s=s.integrations)&&s[t]&&(null==(n=Pe.__PosthogExtensions__)||null==(n=n.integrations)||null==(n=n[t])||n.stop())};for(var[i,r]of Object.entries(null!==(s=this._instance.config.integrations)&&void 0!==s?s:{})){var s;t(i)}}}var jo,Uo={},Wo=0,Vo=()=>{},Go='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',Ko="Surveys module not available",Qo="sanitize_properties is deprecated. Use before_send instead",Jo="Invalid value for property_denylist config: ",Yo="posthog",Xo=!so&&-1===(null==ke?void 0:ke.indexOf("MSIE"))&&-1===(null==ke?void 0:ke.indexOf("Mozilla")),Zo=e=>{var t;return i({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,asset_host:null,token:"",autocapture:!0,cross_subdomain_cookie:kr(null==ye?void 0:ye.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:Vo,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:null!=e?e:"unset",__preview_deferred_init_extensions:!1,__preview_external_dependency_versioned_paths:!1,__preview_cookie_wins_on_conflict:!1,debug:be&&et(null==be?void 0:be.search)&&-1!==be.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,disable_external_dependency_loading:!1,strict_script_versioning:!1,enable_recording_console_log:void 0,secure_cookie:"https:"===(null==ve||null==(t=ve.location)?void 0:t.protocol),ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_flags:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_only_evaluate_survey_feature_flags:!1,advanced_feature_flags_dedup_per_session:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,surveys_request_timeout_ms:1e4,on_request_error(e){gr.error("Bad HTTP status: "+e.statusCode+" "+e.text)},get_device_id:e=>e,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:ue,before_send:void 0,request_queue_config:{flush_interval_ms:vo},error_tracking:{},_onCapture:Vo},(e=>({rageclick:e&&e>="2026-05-30"?{content_ignorelist:ds,ignore_text_selection:!0}:!e||"2025-11-30">e||{content_ignorelist:!0},capture_pageview:!e||"2025-05-24">e||"history_change",session_recording:e&&e>="2026-05-30"?{strictMinimumDuration:!0,canvasCapture:{resolutionScale:.6}}:e&&e>="2025-11-30"?{strictMinimumDuration:!0}:{},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)}))(e))},ea=[["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"]],ta=e=>{var t={};for(var[i,r]of ea)Ze(e[i])||(t[r]=e[i]);var s=yr({},t,e),n=e.__preview_external_dependency_versioned_paths;return Ze(n)||(Ze(e.strict_script_versioning)&&(s.strict_script_versioning=!!n),et(n)&&Ze(e.asset_host)&&(s.asset_host=n)),Qe(e.property_blacklist)&&(Ze(e.property_denylist)?s.property_denylist=e.property_blacklist:Qe(e.property_denylist)?s.property_denylist=[...e.property_blacklist,...e.property_denylist]:gr.error(Jo+e.property_denylist)),s};class ia{constructor(){this.__forceAllowLocalhost=!1}get _forceAllowLocalhost(){return this.__forceAllowLocalhost}set _forceAllowLocalhost(e){gr.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}}class ra{_replaceExtension(e,t){if(e){var i=this._extensions.indexOf(e);-1!==i&&this._extensions.splice(i,1)}return this._extensions.push(t),null==t.initialize||t.initialize(),t}_inCookielessMode(){return this.config.cookieless_mode===oe||this.config.cookieless_mode===ne&&this.consent.isRejected()}get decideEndpointWasHit(){var e,t;return null!==(e=null==(t=this.featureFlags)?void 0:t.hasLoadedFlags)&&void 0!==e&&e}get flagsEndpointWasHit(){var e,t;return null!==(e=null==(t=this.featureFlags)?void 0:t.hasLoadedFlags)&&void 0!==e&&e}constructor(){var e;this.webPerformance=new ia,this._personProcessingSetOncePropertiesSent=!1,this.version=n.LIB_VERSION,this._internalEventEmitter=new So,this._extensions=[],this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=Zo(),this.SentryIntegration=qs,this.sentryIntegration=e=>function(e,t){var i=Ds(e,t);return{name:Os,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 bo(this),this.pageViewManager=new Bs(this),this.rateLimiter=new wn(this),this.requestRouter=new Ao(this),this.consent=new Wr(this),this.externalIntegrations=new No(this);var t=null!==(e=ra.__defaultExtensionClasses)&&void 0!==e?e:{};this.featureFlags=t.featureFlags&&new t.featureFlags(this),this.toolbar=t.toolbar&&new t.toolbar(this),this.surveys=t.surveys&&new t.surveys(this),this.conversations=t.conversations&&new t.conversations(this),this.logs=t.logs&&new t.logs(this),this.experiments=t.experiments&&new t.experiments(this),this.exceptions=t.exceptions&&new t.exceptions(this),this.people={set:(e,t,i)=>{var r=et(e)?{[e]:t}:e;this.setPersonProperties(r),null==i||i({})},set_once:(e,t,i)=>{var r=et(e)?{[e]:t}:e;this.setPersonProperties(void 0,r),null==i||i({})}},this.on("eventCaptured",(e=>gr.info('send "'+(null==e?void 0:e.event)+'"',e)))}init(e,t,i){if(i&&i!==Yo){var r,s=null!==(r=Uo[i])&&void 0!==r?r:new ra;return s._init(e,t,i),Uo[i]=s,Uo[Yo][i]=s,s}return this._init(e,t,i)}_init(e,t,r){var s,o;void 0===t&&(t={});var a=et(e)?e.trim():"";if(!a)return gr.critical("PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()"),this;if(this.__loaded)return console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config={},t.debug=this._checkLocalStorageForDebug(t.debug),this._originalUserConfig=t,this._triggered_notifs=[],t.person_profiles?this._initialPersonProfilesConfig=t.person_profiles:t.process_person&&(this._initialPersonProfilesConfig=t.process_person);var l=Zo(t.defaults),u=ta(t),c=yr({},l,u,{name:r,token:a});Ye(l.rageclick)&&Ye(u.rageclick)&&(c.rageclick=yr({},l.rageclick,u.rageclick)),Ye(l.session_recording)&&Ye(u.session_recording)&&(c.session_recording=yr({},l.session_recording,u.session_recording)),this.set_config(c),this.config.on_xhr_error&&gr.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=t.disable_compression?void 0:En;var d=this._is_persistence_disabled();this.persistence=new hn(this.config,d),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new hn(i({},this.config,{persistence:"sessionStorage"}),d,!1);var _=i({},this.persistence.props),h=i({},this.sessionPersistence.props);this.register({$initialization_time:(new Date).toISOString()}),this._requestQueue=new fo((e=>this._send_retriable_request(e)),this.config.request_queue_config),this._retryQueue=new yo(this),this.__request_queue=[];var p=this._inCookielessMode();if(p||(this.sessionManager=new ko(this),this.sessionPropsManager=new xo(this,this.sessionManager,this.persistence)),this.config.__preview_deferred_init_extensions?(gr.info("Deferring extension initialization to improve startup performance"),setTimeout((()=>{this._initExtensions(p)}),0)):(gr.info("Initializing extensions synchronously"),this._initExtensions(p)),n.DEBUG=n.DEBUG||this.config.debug,n.DEBUG&&gr.info("Starting in debug mode",{this:this,config:t,thisC:i({},this.config),p:_,s:h}),!this.config.identity_distinct_id||null!=(s=t.bootstrap)&&s.distinctID||(t.bootstrap=i({},t.bootstrap,{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0})),void 0!==(null==(o=t.bootstrap)?void 0:o.distinctID)){var g=t.bootstrap.distinctID,v=this.get_distinct_id(),f=this.persistence.get_property(V);if(t.bootstrap.isIdentifiedID&&null!=v&&v!==g&&f===ae)this.identify(g);else if(t.bootstrap.isIdentifiedID&&null!=v&&v!==g&&f===le)gr.warn("Bootstrap distinctID differs from an already-identified user. The existing identity is preserved. Call reset() before reinitializing if you intend to switch users.");else{var m=this.config.get_device_id(Mr()),y=t.bootstrap.isIdentifiedID?m:g;this.persistence.set_property(V,t.bootstrap.isIdentifiedID?le:ae),this.register({distinct_id:g,$device_id:y})}}if(p)this.register_once({distinct_id:ee,$device_id:null},"");else if(!this.get_distinct_id()){var b=this.config.get_device_id(Mr());this.register_once({distinct_id:b,$device_id:b},""),this.persistence.set_property(V,ae)}return Pr(ve,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),t.segment?function(e,t){var i=e.config.segment;if(!i)return t();!function(e,t){var i=e.config.segment;if(!i)return t();var r=i=>{var r=()=>i.anonymousId()||Mr();e.config.get_device_id=r,i.id()&&(e.register({distinct_id:i.id(),$device_id:r()}),e.persistence.set_property(V,le)),t()},s=i.user();"then"in s&&Je(s.then)?s.then(r):r(s)}(e,(()=>{i.register((e=>{Promise&&Promise.resolve||As.warn("This browser does not have Promise support, and can not use the segment integration");var t=(t,i)=>{if(!i)return t;t.event.userId||t.event.anonymousId===e.get_distinct_id()||(As.info("No userId set, resetting PostHog"),e.reset()),t.event.userId&&t.event.userId!==e.get_distinct_id()&&(As.info("UserId set, identifying with PostHog"),e.identify(t.event.userId));var r=e.calculateEventProperties(i,t.event.properties);return t.event.properties=Object.assign({},r,t.event.properties),t};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:()=>!0,load:()=>Promise.resolve(),track:e=>t(e,e.event.event),page:e=>t(e,_e),identify:e=>t(e,pe),screen:e=>t(e,"$screen")}})(e)).then((()=>{t()}))}))}(this,(()=>this._loaded())):this._loaded(),Je(this.config._onCapture)&&this.config._onCapture!==Vo&&(gr.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",(e=>this.config._onCapture(e.event,e)))),this.config.ip&&gr.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}_initExtensions(e){var t,r,s,n,o,a,l,u=performance.now(),c=i({},ra.__defaultExtensionClasses,this.config.__extensionClasses),d=[];c.featureFlags&&this._extensions.push(this.featureFlags=null!==(t=this.featureFlags)&&void 0!==t?t:new c.featureFlags(this)),c.exceptions&&this._extensions.push(this.exceptions=null!==(r=this.exceptions)&&void 0!==r?r:new c.exceptions(this)),c.historyAutocapture&&this._extensions.push(this.historyAutocapture=new c.historyAutocapture(this)),c.tracingHeaders&&this._extensions.push(this.tracingHeaders=new c.tracingHeaders(this)),c.siteApps&&this._extensions.push(this.siteApps=new c.siteApps(this)),c.sessionRecording&&!e&&this._extensions.push(this.sessionRecording=new c.sessionRecording(this)),this.config.disable_scroll_properties||d.push((()=>{this.scrollManager.startMeasuringScrollPosition()})),c.autocapture&&this._extensions.push(this.autocapture=new c.autocapture(this)),c.surveys&&this._extensions.push(this.surveys=null!==(s=this.surveys)&&void 0!==s?s:new c.surveys(this)),c.logs&&this._extensions.push(this.logs=null!==(n=this.logs)&&void 0!==n?n:new c.logs(this)),c.conversations&&this._extensions.push(this.conversations=null!==(o=this.conversations)&&void 0!==o?o:new c.conversations(this)),c.productTours&&this._extensions.push(this.productTours=new c.productTours(this)),c.heatmaps&&this._extensions.push(this.heatmaps=new c.heatmaps(this)),c.webVitalsAutocapture&&this._extensions.push(this.webVitalsAutocapture=new c.webVitalsAutocapture(this)),c.exceptionObserver&&this._extensions.push(this.exceptionObserver=new c.exceptionObserver(this)),c.deadClicksAutocapture&&this._extensions.push(this.deadClicksAutocapture=new c.deadClicksAutocapture(this,Ms)),c.toolbar&&this._extensions.push(this.toolbar=null!==(a=this.toolbar)&&void 0!==a?a:new c.toolbar(this)),c.experiments&&this._extensions.push(this.experiments=null!==(l=this.experiments)&&void 0!==l?l:new c.experiments(this)),this._extensions.forEach((e=>{e.initialize&&d.push((()=>{null==e.initialize||e.initialize()}))})),d.push((()=>{if(this._pendingRemoteConfig){var e=this._pendingRemoteConfig;this._pendingRemoteConfig=void 0,this._onRemoteConfig(e)}})),this._processInitTaskQueue(d,u)}_processInitTaskQueue(e,t){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-t>=30&&e.length>0)return void setTimeout((()=>{this._processInitTaskQueue(e,t)}),0);var i=e.shift();if(i)try{i()}catch(e){gr.error("Error initializing extension:",e)}}var r=Math.round(performance.now()-t);this.register_for_session({[te]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[ie]:r}),this.config.__preview_deferred_init_extensions&&gr.info("PostHog extensions initialized ("+r+"ms)")}_onRemoteConfig(e){var t;if(!ye||!ye.body)return gr.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout((()=>{this._onRemoteConfig(e)}),500);this.config.__preview_deferred_init_extensions&&(this._pendingRemoteConfig=e),this._lastRemoteConfig=e,this.compression=void 0,e.supportedCompression&&!this.config.disable_compression&&(this.compression=je(e.supportedCompression,En)?En:je(e.supportedCompression,kn)?kn:void 0),null!=(t=e.analytics)&&t.endpoint&&(this.analyticsDefaultEndpoint=e.analytics.endpoint),this.set_config({person_profiles:this._initialPersonProfilesConfig?this._initialPersonProfilesConfig:ue}),this._extensions.forEach((t=>null==t.onRemoteConfig?void 0:t.onRemoteConfig(e)))}_loaded(){try{this.config.loaded(this)}catch(e){gr.critical("`loaded` function failed",e)}if(this._start_queue_if_opted_in(),this.config.internal_or_test_user_hostname&&null!=be&&be.hostname){var e=be.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 Sn(this),this._remoteConfigLoader.load()}_start_queue_if_opted_in(){var e;this.is_capturing()&&this.config.request_batching&&(null==(e=this._requestQueue)||e.enable())}_dom_loaded(){this.is_capturing()&&fr(this.__request_queue,(e=>this._send_retriable_request(e))),this.__request_queue=[],this._start_queue_if_opted_in()}_handle_unload(){var e,t,i,r;null==(e=this.surveys)||e.handlePageUnload(),this.config.request_batching?(this._shouldCapturePageleave()&&this.capture(he),null==(t=this.logs)||t.flushLogs("sendBeacon"),null==(i=this._requestQueue)||i.unload(),null==(r=this._retryQueue)||r.unload()):this._shouldCapturePageleave()&&this.capture(he,null,{transport:"sendBeacon"})}_send_request(e){this.__loaded?Xo?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)?e.fireCallbackOnDrop&&(null==e.callback||e.callback({statusCode:429})):(e.transport=e.transport||this.config.api_transport,e.headers=i({},this.config.request_headers,e.headers),e.compression="best-available"===e.compression?this.compression:e.compression,(Ze(this.config.disable_beacon)?this.config.__preview_disable_beacon:this.config.disable_beacon)&&(e.disableTransport=["sendBeacon"]),e.fetchOptions=e.fetchOptions||this.config.fetch_options,(e=>{var t,r,s,n=i({},e);n.timeout=n.timeout||6e4,n.url=po(n.url,n.compression);var o=null!==(t=n.transport)&&void 0!==t?t:"fetch",a=go.filter((e=>!n.disableTransport||!e.transport||!n.disableTransport.includes(e.transport))),l=null!==(r=null==(s=function(e,t){for(var i=0;e.length>i;i++)if(e[i].transport===o)return e[i]}(a))?void 0:s.method)&&void 0!==r?r:a[0].method;if(!l)throw new Error("No available transport method");"sendBeacon"!==o&&n.data&&n.compression===En&&Ee&&!oo?ho(n).then((e=>{l(e)})).catch((t=>{if(De(t))return oo=!0,void l(i({},n,{compression:void 0,url:po(e.url,void 0)}));(e=>{if(!e||"object"!=typeof e)return!1;var t="name"in e?String(e.name):"";return De(e)||t===Ae})(t)&&(oo=!0),l(n)})):l(n)})(i({},e,{callback:t=>{var i,r;this.rateLimiter.checkForLimiting(t),400>t.statusCode||null==(i=(r=this.config).on_request_error)||i.call(r,t),null==e.callback||e.callback(t)}}))):e.fireCallbackOnDrop&&(null==e.callback||e.callback({statusCode:0}))}_send_retriable_request(e){this._retryQueue?this._retryQueue.retriableRequest(e):this._send_request(e)}_execute_array(e){Wo++;try{var t,i=[],r=[],s=[];fr(e,(e=>{if(e)if(Qe(t=e[0]))s.push(e);else if(Je(e))try{e.call(this)}catch(t){gr.error("Error executing queued PostHog call",e,t)}else Qe(e)&&"alias"===t?i.push(e):Qe(e)&&-1!==t.indexOf("capture")&&Je(this[t])?s.push(e):r.push(e)}));var n=function(e,t){fr(e,(function(e){try{if(Qe(e[0])){var i=t;mr(e,(function(e){i=i[e[0]].apply(i,e.slice(1))}))}else t[e[0]].apply(t,e.slice(1))}catch(t){gr.error("Error executing queued PostHog call",e,t)}}))};n(i,this),n(r,this),n(s,this)}finally{Wo--}}push(e){if(Wo>0&&Qe(e)&&et(e[0])){var t=ra.prototype[e[0]];Je(t)&&t.apply(this,e.slice(1))}else this._execute_array([e])}capture(e,t,r){var s,n,o,a,l;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this._requestQueue){if(this.is_capturing())if(!Ze(e)&&et(e)){var u=!this.config.opt_out_useragent_filter&&this._is_bot();if(!u||this.config.__preview_capture_bot_pageviews){var c=null!=r&&r.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(null==c||!c.isRateLimited){null!=t&&t.$current_url&&!et(null==t?void 0:t.$current_url)&&(gr.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!=r&&r._originatedFromCaptureException||gr.warn("Using `posthog.capture('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureException(error)` instead, which attaches required metadata automatically."),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&this.sessionPersistence.update_campaign_params(),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();var d=new Date,_=(null==r?void 0:r.timestamp)||d,h=Si(null==r?void 0:r.uuid,Mr),p={uuid:h,event:e,properties:this.calculateEventProperties(e,t||{},_,h)};e===_e&&this.config.__preview_capture_bot_pageviews&&u&&(p.event="$bot_pageview",p.properties.$browser_type="bot"),c&&(p.properties.$lib_rate_limit_remaining_tokens=c.remainingTokens),(null==r?void 0:r.$set)&&(p.$set=null==r?void 0:r.$set);var g=null==r?void 0:r.$unset;g&&(p.$unset=g);var v,f,m,y=this._calculate_set_once_properties(null==r?void 0:r.$set_once,e!==ge,e===pe);if(y&&(p.$set_once=y),null!=r&&r._noTruncate||(n=this.config.properties_string_max_length,o=p,a=e=>et(e)?e.slice(0,n):e,l=new Set,p=function e(t,i){return t!==Object(t)?a?a(t):t:l.has(t)?void 0:(l.add(t),Qe(t)?(r=[],fr(t,(t=>{r.push(e(t))}))):(r={},mr(t,((t,i)=>{l.has(t)||(r[i]=e(t,i))}))),r);var r}(o)),p.timestamp=_,Ze(null==r?void 0:r.timestamp)||(p.properties.$event_time_override_provided=!0,p.properties.$event_time_override_system_time=d),e===fn||e===mn){var b=null==t?void 0:t.$survey_id,w=null==t?void 0:t.$survey_iteration;(e=>{try{var t=(e=>((e,t)=>{var i=""+e+t.id;return t.current_iteration&&t.current_iteration>0&&(i=""+e+t.id+"_"+t.current_iteration),i})(Do,e))(e);if(localStorage.getItem(t))return;localStorage.setItem(t,"true")}catch(e){Oo.error("Failed to persist survey seen state",e)}})({id:b,current_iteration:w}),p.$set=i({},p.$set,{[(v={id:b,current_iteration:w},f=e===mn?"responded":"dismissed",m="$survey_"+f+"/"+v.id,v.current_iteration&&v.current_iteration>0&&(m="$survey_"+f+"/"+v.id+"/"+v.current_iteration),m)]:!0})}else e===vn&&(p.$set=i({},p.$set,{$survey_last_seen_date:(new Date).toISOString()}));if("product tour shown"===e){var x=null==t?void 0:t.$product_tour_type;x&&(p.$set=i({},p.$set,{["$product_tour_last_seen_date/"+x]:(new Date).toISOString()}))}var S=i({},p.properties.$set,p.$set);if(Xe(S)||this.setPersonPropertiesForFlags(S),!rt(this.config.before_send)){var E=this._runBeforeSend(p);if(!E)return;(p=E).uuid=Si(p.uuid,Mr)}this._internalEventEmitter.emit("eventCaptured",p);var k={method:"POST",url:null!==(s=null==r?void 0:r._url)&&void 0!==s?s:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:p,compression:"best-available",batchKey:null==r?void 0:r._batchKey,transport:null==r?void 0:r.transport};return!this.config.request_batching||r&&(null==r||!r._batchKey)||null!=r&&r.send_instantly?this._send_retriable_request(k):this._requestQueue.enqueue(k),p}gr.critical("This capture call is ignored due to client rate limiting.")}}else gr.error("No event name provided to posthog.capture")}else gr.uninitializedWarning("posthog.capture")}_addCaptureHook(e){return this.on("eventCaptured",(t=>e(t.event,t)))}calculateEventProperties(e,t,r,s,o){if(r=r||new Date,!this.persistence||!this.sessionPersistence)return t;var a=o?void 0:this.persistence.remove_event_timer(e),l=i({},t);if(l.token=this.config.token,l.$config_defaults=this.config.defaults,this._inCookielessMode()&&(l.$cookieless_mode=!0),"$snapshot"===e){var u=i({},this.persistence.properties(),this.sessionPersistence.properties());return l.distinct_id=u.distinct_id,(!et(l.distinct_id)&&!st(l.distinct_id)||tt(l.distinct_id))&&gr.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),l}var c,d=function(e,t,i){var r,s,o,a;if(!ke)return{};var l,u,c,d,_,h,p,g,v,f=e?[...Qs,...t||[]]:[],[m,y]=function(e){for(var t=0;bi.length>t;t++){var[i,r]=bi[t],s=i.exec(e),n=s&&(Je(r)?r(s,e):r);if(n)return n}return["",""]}(ke),b=null!=(l="undefined"!=typeof navigator?navigator:void 0)&&l.brave?{brave:!0}:{},w={detectGoogleSearchApp:i},x=yr(Sr({$os:m,$os_version:y,$browser:fi(ke,navigator.vendor,b,w),$device:wi(ke),$device_type:(c=ke,d={userAgentDataPlatform:null==(r=navigator)||null==(r=r.userAgentData)?void 0:r.platform,maxTouchPoints:null==(s=navigator)?void 0:s.maxTouchPoints,screenWidth:null==ve||null==(o=ve.screen)?void 0:o.width,screenHeight:null==ve||null==(a=ve.screen)?void 0:a.height,devicePixelRatio:null==ve?void 0:ve.devicePixelRatio},v=wi(c),v===St||v===xt||"Kobo"===v||"Kindle Fire"===v||v===Zt?wt:v===Nt||v===Ut||v===jt||v===Jt?"Console":v===kt?"Wearable":v?mt:"Android"===(null==d?void 0:d.userAgentDataPlatform)&&(null!==(_=null==d?void 0:d.maxTouchPoints)&&void 0!==_?_:0)>0?600>Math.min(null!==(h=null==d?void 0:d.screenWidth)&&void 0!==h?h:0,null!==(p=null==d?void 0:d.screenHeight)&&void 0!==p?p:0)/(null!==(g=null==d?void 0:d.devicePixelRatio)&&void 0!==g?g:1)?mt:wt:"Desktop"),$timezone:ln(),$timezone_offset:un()}),{$current_url:Vs(null==be?void 0:be.href,f,Ys),$host:null==be?void 0:be.host,$pathname:null==be?void 0:be.pathname,$raw_user_agent:ke.length>1e3?ke.substring(0,997)+"...":ke,$browser_version:yi(ke,navigator.vendor,b,w),$browser_language:rn(),$browser_language_prefix:(u=rn(),"string"==typeof u?u.split("-")[0]:void 0),$screen_height:null==ve?void 0:ve.screen.height,$screen_width:null==ve?void 0:ve.screen.width,$viewport_height:null==ve?void 0:ve.innerHeight,$viewport_width:null==ve?void 0:ve.innerWidth,$lib:n.LIB_NAME,$lib_version:n.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3});return n.SDK_DIST_CHANNEL&&(x.$sdk_dist_channel=n.SDK_DIST_CHANNEL),x}(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties,this.config.detect_google_search_app);if(this.sessionManager){var{sessionId:_,windowId:h}=this.sessionManager.checkAndGetSessionAndWindowId(o,r.getTime());l.$session_id=_,l.$window_id=h}this.sessionPropsManager&&yr(l,this.sessionPropsManager.getSessionProps());try{var p;this.sessionRecording&&yr(l,this.sessionRecording.sdkDebugProperties),l.$sdk_debug_retry_queue_size=null==(p=this._retryQueue)?void 0:p.length}catch(e){l.$sdk_debug_error_capturing_properties=String(e)}if(this.requestRouter.region===Lo&&(l.$lib_custom_api_host=this.config.api_host),c=e!==_e||o?e!==he||o?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(r):this.pageViewManager.doPageView(r,s),l=yr(l,c),e===_e&&ye&&(l.title=ye.title),!Ze(a)){var g=r.getTime()-a;l.$duration=parseFloat((g/1e3).toFixed(3))}ke&&this.config.opt_out_useragent_filter&&(l.$browser_type=this._is_bot()?"bot":"browser"),(l=yr({},d,this.persistence.properties(),this.sessionPersistence.properties(),l)).$is_identified=this._isIdentified(),Qe(this.config.property_denylist)?mr(this.config.property_denylist,(function(e){delete l[e]})):gr.error(Jo+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var v=this.config.sanitize_properties;v&&(gr.error(Qo),l=v(l,e));var f=this._hasPersonProcessing();return l.$process_person_profile=f,f&&!o&&this._requirePersonProcessing("_calculate_event_properties"),l}_calculate_set_once_properties(e,t,i){var r;if(void 0===t&&(t=!0),void 0===i&&(i=!1),!this.persistence||!this._hasPersonProcessing())return e;if(this._personProcessingSetOncePropertiesSent&&!i)return e;var s=this.persistence.get_initial_props(),n=null==(r=this.sessionPropsManager)?void 0:r.getSetOnceProps(),o=yr({},s,n||{},e||{}),a=this.config.sanitize_properties;return a&&(gr.error(Qo),o=a(o,"$set_once")),t&&(this._personProcessingSetOncePropertiesSent=!0),Xe(o)?void 0:o}register(e,t){var i;null==(i=this.persistence)||i.register(e,t)}register_once(e,t,i){var r;null==(r=this.persistence)||r.register_once(e,t,i)}register_for_session(e){var t;null==(t=this.sessionPersistence)||t.register(e)}unregister(e){var t;null==(t=this.persistence)||t.unregister(e)}unregister_for_session(e){var t;null==(t=this.sessionPersistence)||t.unregister(e)}_register_single(e,t){this.register({[e]:t})}getFeatureFlag(e,t){var i;return null==(i=this.featureFlags)?void 0:i.getFeatureFlag(e,t)}getFeatureFlagPayload(e){var t;return null==(t=this.featureFlags)?void 0:t.getFeatureFlagPayload(e)}getFeatureFlagResult(e,t){var i;return null==(i=this.featureFlags)?void 0:i.getFeatureFlagResult(e,t)}isFeatureEnabled(e,t){var i;return null==(i=this.featureFlags)?void 0:i.isFeatureEnabled(e,t)}reloadFeatureFlags(){var e;null==(e=this.featureFlags)||e.reloadFeatureFlags()}updateFlags(e,t,i){var r;null==(r=this.featureFlags)||r.updateFlags(e,t,i)}updateEarlyAccessFeatureEnrollment(e,t,i){var r;null==(r=this.featureFlags)||r.updateEarlyAccessFeatureEnrollment(e,t,i)}getEarlyAccessFeatures(e,t,i){var r;return void 0===t&&(t=!1),null==(r=this.featureFlags)?void 0:r.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:Ko}),()=>{})}onSessionId(e){var t,i;return null!==(t=null==(i=this.sessionManager)?void 0:i.onSessionId(e))&&void 0!==t?t:()=>{}}getSurveys(e,t){void 0===t&&(t=!1),this.surveys?this.surveys.getSurveys(e,t):e([],{isLoaded:!1,error:Ko})}getActiveMatchingSurveys(e,t){void 0===t&&(t=!1),this.surveys?this.surveys.getActiveMatchingSurveys(e,t):e([],{isLoaded:!1,error:Ko})}renderSurvey(e,t){var i;null==(i=this.surveys)||i.renderSurvey(e,t)}displaySurvey(e,t){var i;void 0===t&&(t=Bo),null==(i=this.surveys)||i.displaySurvey(e,t)}cancelPendingSurvey(e){var t;null==(t=this.surveys)||t.cancelPendingSurvey(e)}canRenderSurvey(e){var t,i;return null!==(t=null==(i=this.surveys)?void 0:i.canRenderSurvey(e))&&void 0!==t?t:{visible:!1,disabledReason:Ko}}canRenderSurveyAsync(e,t){var i,r;return void 0===t&&(t=!1),null!==(i=null==(r=this.surveys)?void 0:r.canRenderSurveyAsync(e,t))&&void 0!==i?i:Promise.resolve({visible:!1,disabledReason:Ko})}_validateIdentifyId(e){return!e||tt(e)?(gr.critical("Unique user id has not been set in posthog.identify"),!1):e===ee?(gr.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())||(gr.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 gr.uninitializedWarning("posthog.identify");if(st(e)&&(e=e.toString(),gr.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),this._validateIdentifyId(e)&&this._requirePersonProcessing("posthog.identify")){var r=this.get_distinct_id();this.register({$user_id:e}),this.get_property(a)||this.register_once({$had_persisted_distinct_id:!0,$device_id:r},""),e!==r&&e!==this.get_property(l)&&(this.unregister(l),this.register({distinct_id:e}));var s,n=(this.persistence.get_property(V)||ae)===ae;e!==r&&n?(this.persistence.set_property(V,le),this.setPersonPropertiesForFlags({$set:t||{},$set_once:i||{}},!1),this.capture(pe,{distinct_id:e,$anon_distinct_id:r},{$set:t||{},$set_once:i||{}}),this._cachedPersonProperties=Co(e,t,i),null==(s=this.featureFlags)||s.setAnonymousDistinctId(r)):(t||i)&&this.setPersonProperties(t,i),e!==r&&(this.reloadFeatureFlags(),this.unregister(N))}}setPersonProperties(e,t){if((e||t)&&this._requirePersonProcessing("posthog.setPersonProperties")){var i=Co(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):gr.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}unsetPersonProperties(e){var t,i=(Qe(e)?e:[e]).filter((e=>et(e)&&e.length>0));0!==i.length&&this._requirePersonProcessing("posthog.unsetPersonProperties")&&(null==(t=this.featureFlags)||t.unsetPersonPropertiesForFlags(i,!0),this.capture("$set",{$unset:i}),this._cachedPersonProperties=null)}group(e,t,r){if(e&&t){var s=this.getGroups(),n=s[e]!==t;if(n&&this.resetGroupPropertiesForFlags(e),this.register({$groups:i({},s,{[e]:t})}),n||r){var o={$group_type:e,$group_key:t};r&&(o.$group_set=r),this.capture(ge,o)}r&&this.setGroupPropertiesForFlags({[e]:r}),n&&!r&&this.reloadFeatureFlags()}else gr.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,t){var i;void 0===t&&(t=!0),null==(i=this.featureFlags)||i.setPersonPropertiesForFlags(e,t)}resetPersonPropertiesForFlags(e){var t;void 0===e&&(e=!0),null==(t=this.featureFlags)||t.resetPersonPropertiesForFlags(e)}setGroupPropertiesForFlags(e,t){var i;void 0===t&&(t=!0),this._requirePersonProcessing("posthog.setGroupPropertiesForFlags")&&(null==(i=this.featureFlags)||i.setGroupPropertiesForFlags(e,t))}resetGroupPropertiesForFlags(e){var t;null==(t=this.featureFlags)||t.resetGroupPropertiesForFlags(e)}reset(e){var t,i,r,s,n,o,l,u,c;if(gr.info("reset"),!this.__loaded)return gr.uninitializedWarning("posthog.reset");var d,_=this.get_property(a),h=this.get_property(y);if(this.consent.reset(),null==(t=this.persistence)||t.clear(),null==(i=this.sessionPersistence)||i.clear(),Ze(h)||null==(d=this.persistence)||d.register({[y]:h}),null==(r=this.surveys)||r.reset(),null==(s=this._remoteConfigLoader)||s.stop(),null==(n=this.featureFlags)||n.reset(),null==(o=this.conversations)||o.reset(),null==(l=this.logs)||l.reset(),null==(u=this.persistence)||u.set_property(V,ae),null==(c=this.sessionManager)||c.resetSessionId(),this._cachedPersonProperties=null,this.config.cookieless_mode===oe)this.register_once({distinct_id:ee,$device_id:null},"");else{var p=this.config.get_device_id(Mr());this.register_once({distinct_id:p,$device_id:e?p:_},"")}this.register({$last_posthog_reset:(new Date).toISOString()},1),delete this.config.identity_distinct_id,delete this.config.identity_hash,this.reloadFeatureFlags()}setIdentity(e,t){var i;this.config.identity_distinct_id=e,this.config.identity_hash=t,this.alias(e),null==(i=this.conversations)||i._onIdentityChanged()}clearIdentity(){var e;delete this.config.identity_distinct_id,delete this.config.identity_hash,null==(e=this.conversations)||e._onIdentityCleared()}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var e,t;return null!==(e=null==(t=this.sessionManager)?void 0:t.checkAndGetSessionAndWindowId(!0).sessionId)&&void 0!==e?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";var{sessionId:t,sessionStartTimestamp:i}=this.sessionManager.checkAndGetSessionAndWindowId(!0),r=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+t);if(null!=e&&e.withTimestamp&&i){var s,n=null!==(s=e.timestampLookBack)&&void 0!==s?s:10;if(!i)return r;r+="?t="+Math.max(Math.floor(((new Date).getTime()-i)/1e3)-n,0)}return r}alias(e,t){return e===this.get_property(o)?(gr.critical("Attempting to create alias for existing People user - aborting."),-2):this._requirePersonProcessing("posthog.alias")?(Ze(t)&&(t=this.get_distinct_id()),e!==t?(this._register_single(l,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(gr.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var t=i({},this.config);if(Ye(e)){var r,s,o,a,l,u,c,d,_,h,p;yr(this.config,ta(e));var g=this._is_persistence_disabled();null==(r=this.persistence)||r.update_config(this.config,t,g),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new hn(i({},this.config,{persistence:"sessionStorage"}),g,!1);var v=this._checkLocalStorageForDebug(this.config.debug);ot(v)&&(this.config.debug=v),ot(this.config.debug)&&(this.config.debug?(n.DEBUG=!0,Br._is_supported()&&Br._set("ph_debug",!0),gr.info("set_config",{config:e,oldConfig:t,newConfig:i({},this.config)})):(n.DEBUG=!1,Br._is_supported()&&Br._remove("ph_debug"))),null==(s=this.exceptionObserver)||s.onConfigChange(),null==(o=this.exceptions)||o.onConfigChange(),null==(a=this.sessionRecording)||a.startIfEnabledOrStop(),null==(l=this.tracingHeaders)||l.startIfEnabledOrStop(),null==(u=this.autocapture)||u.startIfEnabled(),null==(c=this.heatmaps)||c.startIfEnabled(),null==(d=this.exceptionObserver)||d.startIfEnabledOrStop(),null==(_=this.deadClicksAutocapture)||_.startIfEnabledOrStop(),null==(h=this.surveys)||h.loadIfEnabled(),this._sync_opt_out_with_persistence(),null==(p=this.externalIntegrations)||p.startIfEnabledOrStop()}}_overrideSDKInfo(e,t){n.LIB_NAME=e,n.LIB_VERSION=t}startSessionRecording(e){var t,i,r,s,n,o=!0===e,a={sampling:o||!(null==e||!e.sampling),linked_flag:o||!(null==e||!e.linked_flag),url_trigger:o||!(null==e||!e.url_trigger),event_trigger:o||!(null==e||!e.event_trigger)};Object.values(a).some(Boolean)&&(null==(t=this.sessionManager)||t.checkAndGetSessionAndWindowId(),a.sampling&&(null==(i=this.sessionRecording)||i.overrideSampling()),a.linked_flag&&(null==(r=this.sessionRecording)||r.overrideLinkedFlag()),a.url_trigger&&(null==(s=this.sessionRecording)||s.overrideTrigger("url")),a.event_trigger&&(null==(n=this.sessionRecording)||n.overrideTrigger("event")));this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var e;return!(null==(e=this.sessionRecording)||!e.started)}captureException(e,t){if(this.exceptions){var r=new Error("PostHog syntheticException"),s=this.exceptions.buildProperties(e,{handled:!0,syntheticException:r});return this.exceptions.sendExceptionEvent(i({},s,t))}}addExceptionStep(e,t){var i;null==(i=this.exceptions)||i.addExceptionStep(e,t)}captureLog(e){var t;null==(t=this.logs)||t.captureLog(e)}get logger(){var e,t;return null!==(e=null==(t=this.logs)?void 0:t.logger)&&void 0!==e?e:ra._noopLogger}startExceptionAutocapture(e){this.set_config({capture_exceptions:null==e||e})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(e){var t,i;return null!==(t=null==(i=this.toolbar)?void 0:i.loadToolbar(e))&&void 0!==t&&t}get_property(e){var t;return null==(t=this.persistence)?void 0:t.props[e]}getSessionProperty(e){var t;return null==(t=this.sessionPersistence)?void 0:t.props[e]}toString(){var e,t=null!==(e=this.config.name)&&void 0!==e?e:Yo;return t!==Yo&&(t=Yo+"."+t),t}_isIdentified(){var e,t;return(null==(e=this.persistence)?void 0:e.get_property(V))===le||(null==(t=this.sessionPersistence)?void 0:t.get_property(V))===le}_hasPersonProcessing(){var e,t;return!("never"===this.config.person_profiles||this.config.person_profiles===ue&&!this._isIdentified()&&Xe(this.getGroups())&&(null==(e=this.persistence)||null==(e=e.props)||!e[l])&&(null==(t=this.persistence)||null==(t=t.props)||!t[X]))}_shouldCapturePageleave(){return!0===this.config.capture_pageleave||"if_capture_pageview"===this.config.capture_pageleave&&(!0===this.config.capture_pageview||"history_change"===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?(gr.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this._register_single(X,!0),!0)}_is_persistence_disabled(){if("always"===this.config.cookieless_mode)return!0;var e=this.consent.isOptedOut();return this.config.disable_persistence||e&&!(!this.config.opt_out_persistence_by_default&&this.config.cookieless_mode!==ne)}_sync_opt_out_with_persistence(){var e,t,i,r,s=this._is_persistence_disabled();return(null==(e=this.persistence)?void 0:e._disabled)!==s&&(null==(i=this.persistence)||i.set_disabled(s)),(null==(t=this.sessionPersistence)?void 0:t._disabled)!==s&&(null==(r=this.sessionPersistence)||r.set_disabled(s)),s}opt_in_capturing(e){var t;if(this.config.cookieless_mode!==oe){if(this._inCookielessMode()){var i,r,s,n,o;this.reset(!0),null==(i=this.sessionManager)||i.destroy(),null==(r=this.pageViewManager)||r.destroy(),this.sessionManager=new ko(this),this.pageViewManager=new Bs(this),this.persistence&&(this.sessionPropsManager=new xo(this,this.sessionManager,this.persistence));var a,l=null!==(s=null==(n=this.config.__extensionClasses)?void 0:n.sessionRecording)&&void 0!==s?s:null==(o=ra.__defaultExtensionClasses)?void 0:o.sessionRecording;l&&(this.sessionRecording=this._replaceExtension(this.sessionRecording,new l(this)),this._lastRemoteConfig&&(null==(a=this.sessionRecording)||null==a.onRemoteConfig||a.onRemoteConfig(this._lastRemoteConfig)))}var u,c;this.consent.optInOut(!0),this._sync_opt_out_with_persistence(),this._start_queue_if_opted_in(),null==(t=this.sessionRecording)||t.startIfEnabledOrStop(),this.config.cookieless_mode==ne&&(null==(u=this.surveys)||u.loadIfEnabled()),(Ze(null==e?void 0:e.captureEventName)||null!=e&&e.captureEventName)&&this.capture(null!==(c=null==e?void 0:e.captureEventName)&&void 0!==c?c:"$opt_in",null==e?void 0:e.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this._captureInitialPageview()}else gr.warn(Go)}opt_out_capturing(){var e,t,i;this.config.cookieless_mode!==oe?(this.config.cookieless_mode===ne&&this.consent.isOptedIn()&&this.reset(!0),this.consent.optInOut(!1),this._sync_opt_out_with_persistence(),this.config.cookieless_mode===ne&&(this.register({distinct_id:ee,$device_id:null}),null==(e=this.sessionRecording)||e.stopRecording(),this.sessionRecording=void 0,null==(t=this.sessionManager)||t.destroy(),null==(i=this.pageViewManager)||i.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,this.config.capture_pageview&&this._captureInitialPageview(),this._start_queue_if_opted_in())):gr.warn(Go)}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){var e=this.consent.consent;return 1===e?"granted":0===e?"denied":"pending"}is_capturing(){return this.config.cookieless_mode===oe||(this.config.cookieless_mode===ne?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 me?Po(me,this.config.custom_blocked_useragents):void 0}_captureInitialPageview(){ye&&("visible"===ye.visibilityState?this._initialPageviewCaptured||(this._initialPageviewCaptured=!0,this.capture(_e,{title:ye.title},{send_instantly:!0}),this._visibilityStateListener&&(ye.removeEventListener(ce,this._visibilityStateListener),this._visibilityStateListener=null)):this._visibilityStateListener||(this._visibilityStateListener=this._captureInitialPageview.bind(this),Pr(ye,ce,this._visibilityStateListener)))}debug(e){!1===e?(null==ve||ve.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(null==ve||ve.console.log("You're now in debug mode. All calls to PostHog will be logged in your console.\nYou can disable this with `posthog.debug(false)`."),this.set_config({debug:!0}))}_shouldDisableFlags(){var e,t,i,r,s,n,o=this._originalUserConfig||{};return"advanced_disable_flags"in o?!!o.advanced_disable_flags:!1!==this.config.advanced_disable_flags?!!this.config.advanced_disable_flags:!0===this.config.advanced_disable_decide?(gr.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):(i="advanced_disable_decide",!1,r=gr,s=(t="advanced_disable_flags")in(e=o)&&!rt(e[t]),n=i in e&&!rt(e[i]),s?e[t]:!!n&&(r&&r.warn("Config field '"+i+"' is deprecated. Please use '"+t+"' instead. The old field will be removed in a future major version."),e[i]))}_runBeforeSend(e){var t;if(rt(this.config.before_send))return e;var i=Object.keys(null!==(t=e.properties)&&void 0!==t?t:{}).filter(ut),r=Qe(this.config.before_send)?this.config.before_send:[this.config.before_send],s=e;for(var n of r){if(s=n(s),rt(s)){var o="Event '"+e.event+"' was rejected in beforeSend function";return lt(e.event)?gr.warn(o+". This can cause unexpected behavior."):gr.info(o),null}s.properties&&!Xe(s.properties)||gr.warn("Event '"+e.event+"' has no properties after beforeSend function, this is likely an error.")}for(var a of i)if(s.properties&&rt(s.properties[a]))return gr.warn("Event '"+e.event+"' had its '"+a+"' property removed in a beforeSend function. This property is required for ingestion, so the event will be dropped."),null;return s}getPageViewId(){var e;return null==(e=this.pageViewManager._currentPageview)?void 0:e.pageViewId}captureTraceFeedback(e,t){this.capture("$ai_feedback",{$ai_trace_id:String(e),$ai_feedback_text:t})}captureTraceMetric(e,t,i){this.capture("$ai_metric",{$ai_trace_id:String(e),$ai_metric_name:t,$ai_metric_value:String(i)})}_checkLocalStorageForDebug(e){var t=ot(e)&&!e,i=Br._is_supported()&&"true"===Br._get("ph_debug");return!t&&(!!i||e)}}ra.__defaultExtensionClasses={},ra._noopLogger={trace:jo=()=>{},debug:jo,info:jo,warn:jo,error:jo,fatal:jo},function(e,t){for(var i=0;t.length>i;i++)e.prototype[t[i]]=xr(e.prototype[t[i]])}(ra,["identify"]);class sa{constructor(e){this.disabled=!1===e;var t=Ye(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;var r=this.clicks[this.clicks.length-1];if(r&&Math.abs(e-r.x)+Math.abs(t-r.y)<this.thresholdPx&&this.timeoutMs>i-r.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}}var na="$copy_autocapture",oa=vr("[AutoCapture]");function aa(e,t){return t.length>e?t.slice(0,e)+"...":t}function la(e){if(e.previousElementSibling)return e.previousElementSibling;var t=e;do{t=t.previousSibling}while(t&&!Jr(t));return t}function ua(e,t){var r,s,{e:n,maskAllElementAttributes:o,maskAllText:a,elementAttributeIgnoreList:l,elementsChainAsString:u}=t;if(!Jr(e))return{props:{}};for(var c=[e],d=e;d.parentNode&&!Yr(d,"body");)if(Zr(d.parentNode))c.push(d.parentNode.host),d=d.parentNode.host;else{if(!Jr(d.parentNode))break;c.push(d.parentNode),d=d.parentNode}var _,h,p=[],g={},v=!1,f=!1;if(mr(c,(e=>{var t=ms(e);if(Yr(e,"a")){var i=e.getAttribute("href");v=t&&!!i&&Ps(i)&&i}je(is(e),"ph-no-capture")&&(f=!0),p.push(function(e,t,i,r){var s=e.tagName.toLowerCase(),n={tag_name:s};os.indexOf(s)>-1&&!i&&(n.$el_text="a"===s.toLowerCase()||"button"===s.toLowerCase()?aa(1024,Is(e)):aa(1024,ss(e)));var o=is(e);o.length>0&&(n.classes=o.filter((function(e){return""!==e}))),mr(e.attributes,(function(i){var s;if((!ys(e)||-1!==["name","id","class","aria-label"].indexOf(i.name))&&(null==r||!r.includes(i.name))&&!t&&Ps(i.value)&&(!et(s=i.name)||"_ngcontent"!==s.substring(0,10)&&"_nghost"!==s.substring(0,7))){var o=i.value;"class"===i.name&&(o=es(o).join(" ")),n["attr__"+i.name]=aa(1024,o)}}));for(var a=1,l=1,u=e;u=la(u);)a++,u.tagName===e.tagName&&l++;return n.nth_child=a,n.nth_of_type=l,n}(e,o,a,l));var r=function(e){if(!ms(e))return{};var t={};return mr(e.attributes,(function(e){if(e.name&&0===e.name.indexOf("data-ph-capture-attribute")){var i=e.name.replace("data-ph-capture-attribute-",""),r=e.value;i&&r&&Ps(r)&&(t[i]=r)}})),t}(e);yr(g,r)})),f)return{props:{},explicitNoCapture:f};if(a||(p[0].$el_text=Yr(e,"a")||Yr(e,"button")?Is(e):ss(e)),v){var m,y;p[0].attr__href=v;var b=null==(m=Us(v))?void 0:m.host,w=null==ve||null==(y=ve.location)?void 0:y.host;b&&w&&b!==w&&(_=v)}return{props:yr({$event_type:n.type,$ce_version:1},u?{}:{$elements:p},{$elements_chain:(h=p,function(e){return e.map((e=>{var t,r,s="";if(e.tag_name&&(s+=e.tag_name),e.attr_class)for(var n of(e.attr_class.sort(),e.attr_class))s+="."+n.replace(/"/g,"");var o=i({},e.text?{text:e.text}:{},{"nth-child":null!==(t=e.nth_child)&&void 0!==t?t:0,"nth-of-type":null!==(r=e.nth_of_type)&&void 0!==r?r:0},e.href?{href:e.href}:{},e.attr_id?{attr_id:e.attr_id}:{},e.attributes),a={};return br(o).sort(((e,t)=>{var[i]=e,[r]=t;return i.localeCompare(r)})).forEach((e=>{var[t,i]=e;return a[Fs(t.toString())]=Fs(i.toString())})),(s+=":")+br(a).map((e=>{var[t,i]=e;return t+'="'+i+'"'})).join("")})).join(";")}(function(e){return e.map((e=>{var t,i,r={text:null==(t=e.$el_text)?void 0:t.slice(0,400),tag_name:e.tag_name,href:null==(i=e.attr__href)?void 0:i.slice(0,2048),attr_class:Ts(e),attr_id:e.attr__id,nth_child:e.nth_child,nth_of_type:e.nth_of_type,attributes:{}};return br(e).filter((e=>{var[t]=e;return 0===t.indexOf("attr__")})).forEach((e=>{var[t,i]=e;return r.attributes[t]=i})),r}))}(h)))},null!=(r=p[0])&&r.$el_text?{$el_text:null==(s=p[0])?void 0:s.$el_text}:{},_&&"click"===n.type?{$external_click_url:_}:{},g)}}var ca=vr("[ExceptionAutocapture]"),da=vr("[TracingHeaders]"),_a=vr("[Web Vitals]"),ha=9e5,pa="disabled",ga="lazy_loading",va="awaiting_config",fa="missing_config";vr("[SessionRecording]"),vr("[SessionRecording]");var ma="[SessionRecording]",ya=vr(ma),ba=vr("[Heatmaps]");function wa(e){return Ye(e)&&"clientX"in e&&"clientY"in e&&st(e.clientX)&&st(e.clientY)}var xa=vr("[Product Tours]"),Sa=e=>{var t;return!e.config.disable_product_tours&&!(null==(t=e.persistence)||!t.get_property(f))},Ea=["$set_once","$set"],ka=vr("[SiteApps]"),Pa="Error while initializing PostHog app with config id ";function Ia(e,t,i){if(rt(e))return!1;switch(i){case"exact":return e===t;case"contains":var r=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(r,"i").test(e);case"regex":try{return new RegExp(t).test(e)}catch(e){return!1}default:return!1}}class Ca{constructor(e){this._debugEventEmitter=new So,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||!t.event||(null==e?void 0:e.event)===(null==t?void 0:t.event),this._instance=e,this._actionEvents=new Set,this._actionRegistry=new Set}init(){var e,t;Ze(null==(e=this._instance)?void 0:e._addCaptureHook)||(null==(t=this._instance)||t._addCaptureHook(((e,t)=>{this.on(e,t)})))}register(e){var t,i;if(!Ze(null==(t=this._instance)?void 0:t._addCaptureHook)&&(e.forEach((e=>{var t,i;null==(t=this._actionRegistry)||t.add(e),null==(i=e.steps)||i.forEach((e=>{var t;null==(t=this._actionEvents)||t.add((null==e?void 0:e.event)||"")}))})),null!=(i=this._instance)&&i.autocapture)){var r,s=new Set;e.forEach((e=>{var t;null==(t=e.steps)||t.forEach((e=>{null!=e&&e.selector&&s.add(null==e?void 0:e.selector)}))})),null==(r=this._instance)||r.autocapture.setElementSelectors(s)}}on(e,t){var i;null!=t&&0!=e.length&&(this._actionEvents.has(e)||this._actionEvents.has(null==t?void 0:t.event))&&this._actionRegistry&&(null==(i=this._actionRegistry)?void 0:i.size)>0&&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(var 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&&t.url){var i,r=null==e||null==(i=e.properties)?void 0:i.$current_url;if(!r||"string"!=typeof r)return!1;if(!Ia(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||!t.href)return!0;var r=this._getElementsList(e);if(r.length>0)return r.some((e=>Ia(e.href,t.href,t.href_matching||"exact")));var s,n=(null==e||null==(i=e.properties)?void 0:i.$elements_chain)||"";return!!n&&Ia((s=n.match(/(?::|")href="(.*?)"/))?s[1]:"",t.href,t.href_matching||"exact")}_checkStepText(e,t){var i;if(null==t||!t.text)return!0;var r=this._getElementsList(e);if(r.length>0)return r.some((e=>Ia(e.text,t.text,t.text_matching||"exact")||Ia(e.$el_text,t.text,t.text_matching||"exact")));var s,n,o,a=(null==e||null==(i=e.properties)?void 0:i.$elements_chain)||"";return!!a&&(s=function(e){for(var t,i=[],r=/(?::|")text="(.*?)"/g;!rt(t=r.exec(e));)i.includes(t[1])||i.push(t[1]);return i}(a),n=t.text,o=t.text_matching||"exact",s.some((e=>Ia(e,n,o))))}_checkStepSelector(e,t){var i,r;if(null==t||!t.selector)return!0;var s=null==e||null==(i=e.properties)?void 0:i.$element_selectors;if(null!=s&&s.includes(t.selector))return!0;var n=(null==e||null==(r=e.properties)?void 0:r.$elements_chain)||"";if(t.selector_regex&&n)try{return new RegExp(t.selector_regex).test(n)}catch(e){return!1}return!1}_getElementsList(e){var t;return null==(null==e||null==(t=e.properties)?void 0:t.$elements)?[]:null==e?void 0:e.properties.$elements}_checkStepProperties(e,t){return null==t||!t.properties||0===t.properties.length||Ro(t.properties.reduce(((e,t)=>{var i=Qe(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)}}class Fa{constructor(e){this._pendingActivatedItems=[],this._instance=e,this._eventToItems=new Map,this._cancelEventToItems=new Map,this._actionToItems=new Map}_doesEventMatchFilter(e,t){return!!e&&Ro(e.propertyFilters,null==t?void 0:t.properties)}_buildEventToItemMap(e,t){var i=new Map;return e.forEach((e=>{var r;null==(r=e.conditions)||null==(r=r[t])||null==(r=r.values)||r.forEach((t=>{if(null!=t&&t.name){var r=i.get(t.name)||[];r.push(e.id),i.set(t.name,r)}}))})),i}_getMatchingItems(e,t,i){var r=(i===pn?this._eventToItems:this._cancelEventToItems).get(e),s=[];return this._getItems((e=>{s=e.filter((e=>null==r?void 0:r.includes(e.id)))})),s.filter((r=>{var s,n=null==(s=r.conditions)||null==(s=s[i])||null==(s=s.values)?void 0:s.find((t=>t.name===e));return this._doesEventMatchFilter(n,t)}))}register(e){var t;Ze(null==(t=this._instance)?void 0:t._addCaptureHook)||(this._setupEventBasedItems(e),this._setupActionBasedItems(e))}_setupActionBasedItems(e){var t=e.filter((e=>{var t,i;return(null==(t=e.conditions)?void 0:t.actions)&&(null==(i=e.conditions)||null==(i=i.actions)||null==(i=i.values)?void 0:i.length)>0}));0!==t.length&&(null==this._actionMatcher&&(this._actionMatcher=new Ca(this._instance),this._actionMatcher.init(),this._actionMatcher._addActionHook((e=>{this.onAction(e)}))),t.forEach((e=>{var t,i,r,s,n;e.conditions&&null!=(t=e.conditions)&&t.actions&&null!=(i=e.conditions)&&null!=(i=i.actions)&&i.values&&(null==(r=e.conditions)||null==(r=r.actions)||null==(r=r.values)?void 0:r.length)>0&&(null==(s=this._actionMatcher)||s.register(e.conditions.actions.values),null==(n=e.conditions)||null==(n=n.actions)||null==(n=n.values)||n.forEach((t=>{if(t&&t.name){var i=this._actionToItems.get(t.name);i&&i.push(e.id),this._actionToItems.set(t.name,i||[e.id])}})))})))}_setupEventBasedItems(e){var t,i=e.filter((e=>{var t,i;return(null==(t=e.conditions)?void 0:t.events)&&(null==(i=e.conditions)||null==(i=i.events)||null==(i=i.values)?void 0:i.length)>0})),r=e.filter((e=>{var t,i;return(null==(t=e.conditions)?void 0:t.cancelEvents)&&(null==(i=e.conditions)||null==(i=i.cancelEvents)||null==(i=i.values)?void 0:i.length)>0}));0===i.length&&0===r.length||(null==(t=this._instance)||t._addCaptureHook(((e,t)=>{this.onEvent(e,t)})),this._eventToItems=this._buildEventToItemMap(e,pn),this._cancelEventToItems=this._buildEventToItemMap(e,gn))}onEvent(e,t){var i,r,s=this._getLogger(),n=(null==t||null==(i=t.properties)?void 0:i.$survey_id)||(null==t||null==(r=t.properties)?void 0:r.$product_tour_id);if(n&&this.getActivatedIds().includes(n)){var o=this._activationOutcome(e,n);if("consume"===o)return s.info("event consumed activated item, removing it",{event:e,itemId:n}),void this._deactivateItems([n]);if("persist"===o)return s.info("shown item promoted to persisted activation",{event:e,itemId:n}),void this._persistActivation(n)}if(this._cancelEventToItems.has(e)){var a=this._getMatchingItems(e,t,gn);a.length>0&&(s.info("cancel event matched, cancelling items",{event:e,itemsToCancel:a.map((e=>e.id))}),this._deactivateItems(a.map((e=>e.id))),a.forEach((e=>this._cancelPendingItem(e.id))))}if(this._eventToItems.has(e)){s.info("event name matched",{event:e,eventPayload:t,items:this._eventToItems.get(e)});var l=this._getMatchingItems(e,t,pn);this._activateItems(l.map((e=>e.id)))}}onAction(e){this._actionToItems.has(e)&&this._activateItems(this._actionToItems.get(e)||[])}_activateItems(e){0!==e.length&&(this._pendingActivatedItems=[...new Set([...this._pendingActivatedItems,...e])],this._getLogger().info("updating activated items",{activatedItems:this.getActivatedIds()}))}_persistActivation(e){this._pendingActivatedItems=this._pendingActivatedItems.filter((t=>t!==e));var t=this._getPersistedActivatedIds();t.includes(e)||this._setActivatedItems([...t,e])}_deactivateItems(e){var t=new Set(e);this._pendingActivatedItems=this._pendingActivatedItems.filter((e=>!t.has(e)));var i=this._getPersistedActivatedIds(),r=i.filter((e=>!t.has(e)));r.length!==i.length&&this._setActivatedItems(r)}_getPersistedActivatedIds(){var e,t=this._getActivatedKey();return(null==(e=this._instance)||null==(e=e.persistence)?void 0:e.props[t])||[]}getActivatedIds(){return[...new Set([...this._getPersistedActivatedIds(),...this._pendingActivatedItems])].filter((e=>!this._isItemPermanentlyIneligible(e)))}reset(){this._pendingActivatedItems=[],this._getPersistedActivatedIds().length>0&&this._setActivatedItems([])}getEventToItemsMap(){return this._eventToItems}_getActionMatcher(){return this._actionMatcher}}class Ta extends Fa{constructor(e){super(e)}_getActivatedKey(){return z}_getShownEventName(){return vn}_getItems(e){var t;null==(t=this._instance)||t.getSurveys(e)}_cancelPendingItem(e){var t;null==(t=this._instance)||t.cancelPendingSurvey(e)}_getLogger(){return Oo}_setActivatedItems(e){var t;null==(t=this._instance)||null==(t=t.persistence)||t.register({[z]:e})}_isItemPermanentlyIneligible(){return!1}_activationOutcome(e,t){var i;this._getItems((e=>{i=e.find((e=>e.id===t))}));var r=!i||function(e){var t,i,r,s=(null!==(t=null==(i=e.conditions)||null==(i=i.events)||null==(i=i.values)?void 0:i.length)&&void 0!==t?t:0)>0;return"always"===e.schedule||!(null==(r=e.conditions)||null==(r=r.events)||!r.repeatedActivation||!s)}(i);return r?e===vn?"consume":"ignore":e===vn?"persist":e===fn||e===mn?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}}var Ra="SDK is not enabled or survey functionality is not yet loaded",La="Disabled. Not loading surveys.",Ma=null!=ve&&ve.location?Gs(ve.location.hash,"__posthog")||Gs(location.hash,"state"):null,$a="_postHogToolbarParams",Aa=vr("[Toolbar]"),Oa=vr("[FeatureFlags]"),Da=vr("[FeatureFlags]",{debugEnabled:!0}),qa="\" failed. Feature flags didn't load in time.",Ba=e=>{for(var t={},i=0;e.length>i;i++)t[e[i]]=!0;return t},za=e=>{var t={};for(var[i,r]of br(e||{}))r&&(t[i]=r);return t},Ha=vr("[Error tracking]"),Na="Refusing to render web experiment since the viewer is a likely bot",ja={icontains:(e,t)=>!!ve&&t.href.toLowerCase().indexOf(e.toLowerCase())>-1,not_icontains:(e,t)=>!!ve&&-1===t.href.toLowerCase().indexOf(e.toLowerCase()),regex:(e,t)=>!!ve&&Io(t.href,e),not_regex:(e,t)=>!!ve&&!Io(t.href,e),exact:(e,t)=>t.href===e,is_not:(e,t)=>t.href!==e};class Ua{get _config(){return this._instance.config}constructor(e){var t=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(e){void 0===e&&(e=!1),t.getWebExperiments((e=>{Ua._logInfo("retrieved web experiments from the server"),t._flagToExperiments=new Map,e.forEach((e=>{if(e.feature_flag_key){var i;t._flagToExperiments&&(Ua._logInfo("setting flag key ",e.feature_flag_key," to web experiment ",e),null==(i=t._flagToExperiments)||i.set(e.feature_flag_key,e));var r=t._instance.getFeatureFlag(e.feature_flag_key);et(r)&&e.variants[r]&&t._applyTransforms(e.name,r,e.variants[r].transforms)}else if(e.variants)for(var s in e.variants){var n=e.variants[s];Ua._matchesTestVariant(n)&&t._applyTransforms(e.name,s,n.transforms)}}))}),e)},this._instance=e,this._instance.onFeatureFlags((e=>{this.onFeatureFlags(e)}))}initialize(){}onFeatureFlags(e){if(this._is_bot())Ua._logInfo(Na);else if(!this._config.disable_web_experiments){if(rt(this._flagToExperiments))return this._flagToExperiments=new Map,this.loadIfEnabled(),void this.previewWebExperiment();Ua._logInfo("applying feature flags",e),e.forEach((e=>{var t;if(this._flagToExperiments&&null!=(t=this._flagToExperiments)&&t.has(e)){var i,r=this._instance.getFeatureFlag(e),s=null==(i=this._flagToExperiments)?void 0:i.get(e);r&&null!=s&&s.variants[r]&&this._applyTransforms(s.name,r,s.variants[r].transforms)}}))}}previewWebExperiment(){var e=Ua.getWindowLocation();if(null!=e&&e.search){var t=Ws(null==e?void 0:e.search,"__experiment_id"),i=Ws(null==e?void 0:e.search,"__experiment_variant");t&&i&&(Ua._logInfo("previewing web experiments "+t+" && "+i),this.getWebExperiments((e=>{this._showPreviewWebExperiment(parseInt(t),i,e)}),!1,!0))}}loadIfEnabled(){this._config.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,t,i){if(this._config.disable_web_experiments&&!i)return e([]);var r=this._instance.get_property("$web_experiments");if(r&&!t)return e(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this._config.token),method:"GET",callback:t=>e(200===t.statusCode&&t.json&&t.json.experiments||[])})}_showPreviewWebExperiment(e,t,i){var r=i.filter((t=>t.id===e));r&&r.length>0&&(Ua._logInfo("Previewing web experiment ["+r[0].name+"] with variant ["+t+"]"),this._applyTransforms(r[0].name,t,r[0].variants[t].transforms))}static _matchesTestVariant(e){return!rt(e.conditions)&&Ua._matchUrlConditions(e)&&Ua._matchUTMConditions(e)}static _matchUrlConditions(e){var t;if(rt(e.conditions)||rt(null==(t=e.conditions)?void 0:t.url))return!0;var i,r,s,n=Ua.getWindowLocation();return!!n&&(null==(i=e.conditions)||!i.url||ja[null!==(r=null==(s=e.conditions)?void 0:s.urlMatchType)&&void 0!==r?r:"icontains"](e.conditions.url,n))}static getWindowLocation(){return null==ve?void 0:ve.location}static _matchUTMConditions(e){var t;if(rt(e.conditions)||rt(null==(t=e.conditions)?void 0:t.utm))return!0;var i=Zs();if(i.utm_source){var r,s,n,o,a,l,u,c,d=null==(r=e.conditions)||null==(r=r.utm)||!r.utm_campaign||(null==(s=e.conditions)||null==(s=s.utm)?void 0:s.utm_campaign)==i.utm_campaign,_=null==(n=e.conditions)||null==(n=n.utm)||!n.utm_source||(null==(o=e.conditions)||null==(o=o.utm)?void 0:o.utm_source)==i.utm_source,h=null==(a=e.conditions)||null==(a=a.utm)||!a.utm_medium||(null==(l=e.conditions)||null==(l=l.utm)?void 0:l.utm_medium)==i.utm_medium,p=null==(u=e.conditions)||null==(u=u.utm)||!u.utm_term||(null==(c=e.conditions)||null==(c=c.utm)?void 0:c.utm_term)==i.utm_term;return d&&h&&p&&_}return!1}static _logInfo(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;t>r;r++)i[r-1]=arguments[r];gr.info("[WebExperiments] "+e,i)}_applyTransforms(e,t,i){this._is_bot()?Ua._logInfo(Na):"control"!==t?i.forEach((i=>{if(i.selector){var r;Ua._logInfo("applying transform of variant "+t+" for experiment "+e+" ",i);var s=null==(r=document)?void 0:r.querySelectorAll(i.selector);null==s||s.forEach((e=>{var t=e;i.html&&(t.innerHTML=i.html),i.css&&t.setAttribute("style",i.css)}))}})):Ua._logInfo("Control variants leave the page unmodified.")}_is_bot(){return me&&this._instance?Po(me,this._config.custom_blocked_useragents):void 0}}var Wa=vr("[Conversations]"),Va="Conversations not available yet.",Ga={featureFlags:class{constructor(e){this._override_warning=!1,this._hasLoadedFlags=!1,this._requestInFlight=!1,this._reloadingDisabled=!1,this._additionalReloadRequested=!1,this._flagsLoadedFromRemote=!1,this._hasLoggedDeprecationWarning=!1,this._staleCacheRefreshTriggered=!1,this._instance=e,this.featureFlagEventHandlers=[]}get _config(){return this._instance.config}get _persistence(){return this._instance.persistence}_prop(e){return this._instance.get_property(e)}_isCacheStale(){var e,t;return null!==(e=null==(t=this._persistence)?void 0:t._isFeatureFlagCacheStale(this._config.feature_flag_cache_ttl_ms))&&void 0!==e&&e}_checkAndTriggerStaleRefresh(){return!!this._isCacheStale()&&(this._staleCacheRefreshTriggered||this._requestInFlight||(this._staleCacheRefreshTriggered=!0,Oa.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}_getValidEvaluationEnvironments(){var e,t=null!==(e=this._config.evaluation_contexts)&&void 0!==e?e:this._config.evaluation_environments;return!this._config.evaluation_environments||this._config.evaluation_contexts||this._hasLoggedDeprecationWarning||(Oa.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this._hasLoggedDeprecationWarning=!0),null!=t&&t.length?t.filter((e=>{var t=e&&"string"==typeof e&&e.trim().length>0;return t||Oa.error("Invalid evaluation context found:",e,"Expected non-empty string"),t})):[]}_shouldIncludeEvaluationEnvironments(){return this._getValidEvaluationEnvironments().length>0}_getValidFlagKeys(){var e=this._config.flag_keys;if(!Ze(e)){if(Qe(e))return e.filter((e=>{var t=e&&"string"==typeof e&&e.trim().length>0;return t||Oa.error("Invalid flag key found:",e,"Expected non-empty string"),t}));Oa.error("Invalid flag_keys found:",e,"Expected array of non-empty strings")}}initialize(){var e,t,{config:i}=this._instance,r=null!==(e=null==(t=i.bootstrap)?void 0:t.featureFlags)&&void 0!==e?e:{};if(Object.keys(r).length){var s,n,o=null!==(s=null==(n=i.bootstrap)?void 0:n.featureFlagPayloads)&&void 0!==s?s:{},a=Object.keys(r).filter((e=>!!r[e])).reduce(((e,t)=>(e[t]=r[t]||!1,e)),{}),l=Object.keys(o).filter((e=>a[e])).reduce(((e,t)=>(o[t]&&(e[t]=o[t]),e)),{});this.receivedFeatureFlags({featureFlags:a,featureFlagPayloads:l})}}updateFlags(e,t,r){var s,n,o=null!=r&&r.merge&&null!==(s=this._prop(I))&&void 0!==s?s:{},a=null!=r&&r.merge&&null!==(n=this._prop(R))&&void 0!==n?n:{},l=i({},o,e),u=i({},a,t),c={};for(var[d,_]of Object.entries(l))c[d]={key:d,enabled:Ce(_),variant:Fe(_),reason:void 0,metadata:Ze(null==u?void 0:u[d])?void 0:{id:0,version:void 0,description:void 0,payload:u[d]}};this.receivedFeatureFlags({flags:c})}get hasLoadedFlags(){return this._hasLoadedFlags}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var e=this._prop(T),t=this._prop(M),r=this._prop(A);if(!r&&!t)return e||{};var s=yr({},e||{}),n=[...new Set([...Object.keys(r||{}),...Object.keys(t||{})])];for(var o of n){var a,l,u=s[o],c=null==t?void 0:t[o],d=Ze(c)?null!==(a=null==u?void 0:u.enabled)&&void 0!==a&&a:!!c,_=Ze(c)?u.variant:"string"==typeof c?c:void 0,h=null==r?void 0:r[o],p=i({},u,{enabled:d,variant:d?null!=_?_:null==u?void 0:u.variant:void 0});d!==(null==u?void 0:u.enabled)&&(p.original_enabled=null==u?void 0:u.enabled),_!==(null==u?void 0:u.variant)&&(p.original_variant=null==u?void 0:u.variant),h&&(p.metadata=i({},null==u?void 0:u.metadata,{payload:h,original_payload:null==u||null==(l=u.metadata)?void 0:l.payload})),s[o]=p}return this._override_warning||(Oa.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:r,finalDetails:s}),this._override_warning=!0),s}getFlagVariants(){var e=this._prop(I),t=this._prop(M);if(!t)return e||{};for(var i=yr({},e),r=Object.keys(t),s=0;r.length>s;s++)i[r[s]]=t[r[s]];return this._override_warning||(Oa.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:i}),this._override_warning=!0),i}getFlagPayloads(){var e=this._prop(R),t=this._prop(A);if(!t)return e||{};for(var i=yr({},e||{}),r=Object.keys(t),s=0;r.length>s;s++)i[r[s]]=t[r[s]];return this._override_warning||(Oa.warn(" Overriding feature flag payloads!",{flagPayloads:e,overriddenPayloads:t,finalPayloads:i}),this._override_warning=!0),i}reloadFeatureFlags(){this._reloadingDisabled||this._config.advanced_disable_feature_flags||this._reloadDebouncer||(this._instance._internalEventEmitter.emit("featureFlagsReloading",!0),this._reloadDebouncer=setTimeout((()=>{this._callFlagsEndpoint()}),5))}_clearDebouncer(){clearTimeout(this._reloadDebouncer),this._reloadDebouncer=void 0}ensureFlagsLoaded(){this._hasLoadedFlags||this._requestInFlight||this._reloadDebouncer||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this._reloadingDisabled=e}_callFlagsEndpoint(e){var t;if(this._clearDebouncer(),!this._instance._shouldDisableFlags())if(this._requestInFlight)this._additionalReloadRequested=!0;else{var r=this._config.token,s=this._prop(a),n={token:r,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:i({},(null==(t=this._persistence)?void 0:t.get_initial_props())||{},this._prop(O)||{}),group_properties:this._prop(D),timezone:ln()};it(s)||Ze(s)||(n.$device_id=s),(null!=e&&e.disableFlags||this._config.advanced_disable_feature_flags)&&(n.disable_flags=!0),this._shouldIncludeEvaluationEnvironments()&&(n.evaluation_contexts=this._getValidEvaluationEnvironments());var o=this._getValidFlagKeys();Ze(o)||(n.flag_keys=o);var l=!!this._config.advanced_only_evaluate_survey_feature_flags,u=this._instance.requestRouter.endpointFor("flags","/flags/?v=2"+(this._config.advanced_only_evaluate_survey_feature_flags?"&only_evaluate_survey_feature_flags=true":""));this._requestInFlight=!0,this._instance._send_request({method:"POST",url:u,data:n,compression:this._config.disable_compression?void 0:kn,timeout:this._config.feature_flag_request_timeout_ms,callback:e=>{var t,i,r,s=!0;if(200===e.statusCode&&(this._additionalReloadRequested||(this.$anon_distinct_id=void 0),s=!1),this._requestInFlight=!1,!n.disable_flags||this._additionalReloadRequested){this._flagsLoadedFromRemote=!s;var o=[];e.error?e.error instanceof Error?o.push("AbortError"===e.error.name?"timeout":"connection_error"):o.push("unknown_error"):200!==e.statusCode&&o.push("api_error_"+e.statusCode),null!=(t=e.json)&&t.errorsWhileComputingFlags&&o.push("errors_while_computing_flags");var a,u=!(null==(i=e.json)||null==(i=i.quotaLimited)||!i.includes("feature_flags"));if(u&&o.push("quota_limited"),null==(r=this._persistence)||r.register({[U]:o}),u)Oa.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.");else n.disable_flags||this.receivedFeatureFlags(null!==(a=e.json)&&void 0!==a?a:{},s,{partialResponse:l}),this._additionalReloadRequested&&(this._additionalReloadRequested=!1,this._callFlagsEndpoint())}}})}}getFeatureFlag(e,t){var i;if(void 0===t&&(t={}),!t.fresh||this._flagsLoadedFromRemote)if(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0){if(!this._checkAndTriggerStaleRefresh()){var r=this.getFeatureFlagResult(e,t);return null!==(i=null==r?void 0:r.variant)&&void 0!==i?i:null==r?void 0:r.enabled}}else Oa.warn('getFeatureFlag for key "'+e+qa)}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){var t=this.getFeatureFlagResult(e,{send_event:!1});return null==t?void 0:t.payload}getFeatureFlagResult(e,t){if(void 0===t&&(t={}),!t.fresh||this._flagsLoadedFromRemote)if(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0){if(!this._checkAndTriggerStaleRefresh()){var i=this.getFlagVariants(),r=e in i,s=i[e],n=this.getFlagPayloads()[e],o=String(s),a=this._prop(L)||void 0,l=this._prop(W)||void 0,u=this._prop(N)||{};if(this._config.advanced_feature_flags_dedup_per_session){var c,d=this._instance.get_session_id(),_=this._prop(j);d&&d!==_&&(u={},null==(c=this._persistence)||c.register({[N]:u,[j]:d}))}if((t.send_event||!("send_event"in t))&&(!(e in u)||!u[e].includes(o))){var h,p,g,v,f,m,y,b,w,x;Qe(u[e])?u[e].push(o):u[e]=[o],null==(h=this._persistence)||h.register({[N]:u});var S=this.getFeatureFlagDetails(e),E=[...null!==(p=this._prop(U))&&void 0!==p?p:[]];Ze(s)&&E.push("flag_missing");var k={$feature_flag:e,$feature_flag_response:s,$feature_flag_payload:n||null,$feature_flag_request_id:a,$feature_flag_evaluated_at:l,$feature_flag_bootstrapped_response:(null==(g=this._config.bootstrap)||null==(g=g.featureFlags)?void 0:g[e])||null,$feature_flag_bootstrapped_payload:(null==(v=this._config.bootstrap)||null==(v=v.featureFlagPayloads)?void 0:v[e])||null,$used_bootstrap_value:!this._flagsLoadedFromRemote};Ze(null==S||null==(f=S.metadata)?void 0:f.version)||(k.$feature_flag_version=S.metadata.version);var P,I=null!==(m=null==S||null==(y=S.reason)?void 0:y.description)&&void 0!==m?m:null==S||null==(b=S.reason)?void 0:b.code;I&&(k.$feature_flag_reason=I),null!=S&&null!=(w=S.metadata)&&w.id&&(k.$feature_flag_id=S.metadata.id),Ze(null==S?void 0:S.original_variant)&&Ze(null==S?void 0:S.original_enabled)||(k.$feature_flag_original_response=Ze(S.original_variant)?S.original_enabled:S.original_variant),null!=S&&null!=(x=S.metadata)&&x.original_payload&&(k.$feature_flag_original_payload=null==S||null==(P=S.metadata)?void 0:P.original_payload),E.length&&(k.$feature_flag_error=E.join(",")),this._instance.capture("$feature_flag_called",k)}if(r)return{key:e,enabled:!!s,variant:"string"==typeof s?s:void 0,payload:Ie(n)}}}else Oa.warn('getFeatureFlagResult for key "'+e+qa)}getRemoteConfigPayload(e,t){var i=this._config.token,r={distinct_id:this._instance.get_distinct_id(),token:i};this._shouldIncludeEvaluationEnvironments()&&(r.evaluation_contexts=this._getValidEvaluationEnvironments());var s=this._getValidFlagKeys();Ze(s)||(r.flag_keys=s),this._instance._send_request({method:"POST",url:this._instance.requestRouter.endpointFor("flags","/flags/?v=2"),data:r,compression:this._config.disable_compression?void 0:kn,timeout:this._config.feature_flag_request_timeout_ms,callback(i){var r,s=null==(r=i.json)?void 0:r.featureFlagPayloads;t((null==s?void 0:s[e])||void 0)}})}isFeatureEnabled(e,t){if(void 0===t&&(t={}),!t.fresh||this._flagsLoadedFromRemote){if(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0){var i=this.getFeatureFlag(e,t);return Ze(i)?void 0:!!i}Oa.warn('isFeatureEnabled for key "'+e+qa)}}addFeatureFlagsHandler(e){this.featureFlagEventHandlers.push(e)}removeFeatureFlagsHandler(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((t=>t!==e))}receivedFeatureFlags(e,t,r){if(this._persistence){this._hasLoadedFlags=!0;var s=this.getFlagVariants(),n=this.getFlagPayloads(),o=this.getFlagsWithDetails();!function(e,t,r,s,n,o){void 0===r&&(r={}),void 0===s&&(s={}),void 0===n&&(n={});var a=(e=>{var t=e.flags;return t?(e.featureFlags=Object.fromEntries(Object.keys(t).map((e=>{var i;return[e,null!==(i=t[e].variant)&&void 0!==i?i:t[e].enabled]}))),e.featureFlagPayloads=Object.fromEntries(Object.keys(t).filter((e=>t[e].enabled)).filter((e=>{var i;return null==(i=t[e].metadata)?void 0:i.payload})).map((e=>{var i;return[e,null==(i=t[e].metadata)?void 0:i.payload]})))):Oa.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),e})(e),l=a.flags,u=a.featureFlags,c=a.featureFlagPayloads;if(u){var d=e.requestId,_=e.evaluatedAt;if(Qe(u)){Oa.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var h={};if(u)for(var p=0;u.length>p;p++)h[u[p]]=!0;t&&t.register({[C]:u,[I]:h})}else{var g=u,v=c,f=l;if(null!=o&&o.partialResponse)g=i({},r,g),v=i({},s,v),f=i({},n,f);else if(e.errorsWhileComputingFlags)if(l){var m=new Set(Object.keys(l).filter((e=>{var t;return!(null!=(t=l[e])&&t.failed)})));g=i({},r,Object.fromEntries(Object.entries(g).filter((e=>{var[t]=e;return m.has(t)})))),v=i({},s,Object.fromEntries(Object.entries(v||{}).filter((e=>{var[t]=e;return m.has(t)})))),f=i({},n,Object.fromEntries(Object.entries(f||{}).filter((e=>{var[t]=e;return m.has(t)}))))}else g=i({},r,g),v=i({},s,v),f=i({},n,f);t&&t.register(i({[C]:Object.keys(za(g)),[I]:g||{},[R]:v||{},[T]:f||{}},d?{[L]:d}:{},_?{[W]:_}:{}))}}}(e,this._persistence,s,n,o,r),t||(this._staleCacheRefreshTriggered=!1),this._fireFeatureFlagsCallbacks(t)}}override(e,t){void 0===t&&(t=!1),Oa.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){if(!this._instance.__loaded||!this._persistence)return Oa.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(!1===e)return this._persistence.unregister(M),this._persistence.unregister(A),this._fireFeatureFlagsCallbacks(),Da.info("All overrides cleared");if(Qe(e)){var t=Ba(e);return this._persistence.register({[M]:t}),this._fireFeatureFlagsCallbacks(),Da.info("Flag overrides set",{flags:e})}if(e&&"object"==typeof e&&("flags"in e||"payloads"in e)){var i,r=e;if(this._override_warning=Boolean(null!==(i=r.suppressWarning)&&void 0!==i&&i),"flags"in r)if(!1===r.flags)this._persistence.unregister(M),Da.info("Flag overrides cleared");else if(r.flags){if(Qe(r.flags)){var s=Ba(r.flags);this._persistence.register({[M]:s})}else this._persistence.register({[M]:r.flags});Da.info("Flag overrides set",{flags:r.flags})}return"payloads"in r&&(!1===r.payloads?(this._persistence.unregister(A),Da.info("Payload overrides cleared")):r.payloads&&(this._persistence.register({[A]:r.payloads}),Da.info("Payload overrides set",{payloads:r.payloads}))),void this._fireFeatureFlagsCallbacks()}if(e&&"object"==typeof e)return this._persistence.register({[M]:e}),this._fireFeatureFlagsCallbacks(),Da.info("Flag overrides set",{flags:e});Oa.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:e})}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this._hasLoadedFlags){var{flags:t,flagVariants:i}=this._prepareFeatureFlagsForCallbacks();e(t,i)}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t,r){var s,n=(this._prop(F)||[]).find((t=>t.flagKey===e)),o={["$feature_enrollment/"+e]:t},a={$feature_flag:e,$feature_enrollment:t,$set:o};n&&(a.$early_access_feature_name=n.name),r&&(a.$feature_enrollment_stage=r),this._instance.capture("$feature_enrollment_update",a),this.setPersonPropertiesForFlags(o,!1);var l=i({},this.getFlagVariants(),{[e]:t});null==(s=this._persistence)||s.register({[C]:Object.keys(za(l)),[I]:l}),this._fireFeatureFlagsCallbacks()}getEarlyAccessFeatures(e,t,i){void 0===t&&(t=!1);var r=this._prop(F),s=i?"&"+i.map((e=>"stage="+e)).join("&"):"";if(r&&!t)return e(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/early_access_features/?token="+this._config.token+s),method:"GET",callback:t=>{var i,r;if(t.json){var s=t.json.earlyAccessFeatures;return null==(i=this._persistence)||i.unregister(F),null==(r=this._persistence)||r.register({[F]:s}),e(s)}}})}_prepareFeatureFlagsForCallbacks(){var 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){var{flags:t,flagVariants:i}=this._prepareFeatureFlagsForCallbacks();this.featureFlagEventHandlers.forEach((r=>r(t,i,{errorsLoading:e})))}setPersonPropertiesForFlags(e,t){void 0===t&&(t=!0);var r=this._prop(O)||{},s=(null==e?void 0:e.$set)||(null!=e&&e.$set_once?{}:e),n=null==e?void 0:e.$set_once,o={};if(n)for(var a in n)({}).hasOwnProperty.call(n,a)&&(a in r||(o[a]=n[a]));this._instance.register({[O]:i({},r,o,s)}),t&&this._instance.reloadFeatureFlags()}unsetPersonPropertiesForFlags(e,t){void 0===t&&(t=!0);var r=i({},this._prop(O)||{});e.forEach((e=>{delete r[e]})),this._instance.register({[O]:r}),t&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(e){void 0===e&&(e=!0),this._instance.unregister(O),e&&this._instance.reloadFeatureFlags()}setGroupPropertiesForFlags(e,t){void 0===t&&(t=!0);var r=this._prop(D)||{};0!==Object.keys(r).length&&Object.keys(r).forEach((t=>{r[t]=i({},r[t],e[t]),delete e[t]})),this._instance.register({[D]:i({},r,e)}),t&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var t=this._prop(D)||{};this._instance.register({[D]:i({},t,{[e]:{}})})}else this._instance.unregister(D)}reset(){this._hasLoadedFlags=!1,this._requestInFlight=!1,this._reloadingDisabled=!1,this._additionalReloadRequested=!1,this._flagsLoadedFromRemote=!1,this.$anon_distinct_id=void 0,this._clearDebouncer(),this._override_warning=!1}}},Ka={sessionRecording:class{get _config(){return this._instance.config}get _persistence(){return this._instance.persistence}get started(){var e;return!(null==(e=this._lazyLoadedSessionRecording)||!e.isStarted)}get status(){var e,t;return this._recordingStatus===va||this._recordingStatus===fa?this._recordingStatus:null!==(e=null==(t=this._lazyLoadedSessionRecording)?void 0:t.status)&&void 0!==e?e:this._recordingStatus}constructor(e){if(this._forceAllowLocalhostNetworkCapture=!1,this._recordingStatus=pa,this._persistFlagsOnSessionListener=void 0,this._instance=e,!this._instance.sessionManager)throw ya.error("started without valid sessionManager"),new Error(ma+" started without valid sessionManager. This is a bug.");if(this._config.cookieless_mode===oe)throw new Error(ma+' cannot be used with cookieless_mode="always"')}initialize(){this.startIfEnabledOrStop()}get _isRecordingEnabled(){var e,t=!(null==(e=this._instance.get_property(y))||!e.enabled),i=!this._config.disable_session_recording,r=this._config.disable_session_recording||this._instance.consent.isOptedOut();return ve&&t&&i&&!r}startIfEnabledOrStop(e){var t;if(!this._isRecordingEnabled||null==(t=this._lazyLoadedSessionRecording)||!t.isStarted){var i=!Ze(Object.assign)&&!Ze(Array.from);this._isRecordingEnabled&&i?(this._lazyLoadAndStart(e),ya.info("starting")):(this._recordingStatus=pa,this.stopRecording())}}_lazyLoadAndStart(e){var t,i,r;this._isRecordingEnabled&&(this._recordingStatus!==va&&this._recordingStatus!==fa&&(this._recordingStatus=ga),null!=Pe&&null!=(t=Pe.__PosthogExtensions__)&&null!=(t=t.rrweb)&&t.record&&null!=(i=Pe.__PosthogExtensions__)&&i.initSessionRecording?this._onScriptLoaded(e):null==(r=Pe.__PosthogExtensions__)||null==r.loadExternalDependency||r.loadExternalDependency(this._instance,this._scriptName,(t=>{if(t)return ya.error("could not load recorder",t);this._onScriptLoaded(e)})))}stopRecording(){var e,t;null==(e=this._persistFlagsOnSessionListener)||e.call(this),this._persistFlagsOnSessionListener=void 0,null==(t=this._lazyLoadedSessionRecording)||t.stop()}_discardRecording(){var e,t;null==(e=this._persistFlagsOnSessionListener)||e.call(this),this._persistFlagsOnSessionListener=void 0,null==(t=this._lazyLoadedSessionRecording)||t.discard()}_resetSampling(){var e,t;null==(e=this._persistence)||e.unregister(P),null==(t=this._persistence)||t.unregister(b)}_validateSampleRate(e,t){if(rt(e))return null;var i,r=st(e)?e:parseFloat(e);return"number"!=typeof(i=r)||!Number.isFinite(i)||0>i||i>1?(ya.warn(t+" must be between 0 and 1. Ignoring invalid value:",e),null):r}_persistRemoteConfig(e){if(this._persistence){var t,r,s=this._persistence,n=()=>{var t,r=!1===e.sessionRecording?void 0:e.sessionRecording,n=this._validateSampleRate(null==(t=this._config.session_recording)?void 0:t.sampleRate,"session_recording.sampleRate"),o=this._validateSampleRate(null==r?void 0:r.sampleRate,"remote config sampleRate"),a=null!=n?n:o;rt(a)&&this._resetSampling();var l=null==r?void 0:r.minimumDurationMilliseconds;s.register({[y]:i({cache_timestamp:Date.now(),enabled:!!r},r,{networkPayloadCapture:i({capturePerformance:e.capturePerformance},null==r?void 0:r.networkPayloadCapture),canvasRecording:{enabled:null==r?void 0:r.recordCanvas,fps:null==r?void 0:r.canvasFps,quality:null==r?void 0:r.canvasQuality},sampleRate:a,minimumDurationMilliseconds:Ze(l)?null:l,endpoint:null==r?void 0:r.endpoint,triggerMatchType:null==r?void 0:r.triggerMatchType,masking:null==r?void 0:r.masking,urlTriggers:null==r?void 0:r.urlTriggers,version:null==r?void 0:r.version,triggerGroups:null==r?void 0:r.triggerGroups})})};n(),null==(t=this._persistFlagsOnSessionListener)||t.call(this),this._persistFlagsOnSessionListener=null==(r=this._instance.sessionManager)?void 0:r.onSessionId(n)}}onRemoteConfig(e){return"sessionRecording"in e?!1===e.sessionRecording?(this._persistRemoteConfig(e),void this._discardRecording()):(this._persistRemoteConfig(e),void this.startIfEnabledOrStop()):(this._recordingStatus===va&&(this._recordingStatus=fa,ya.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(e,t){var i;void 0===t&&(t="log"),null!=(i=this._lazyLoadedSessionRecording)&&i.log?this._lazyLoadedSessionRecording.log(e,t):ya.warn("log called before recorder was ready")}get _scriptName(){var e,t,i=null==(e=this._instance)||null==(e=e.persistence)?void 0:e.get_property(y);return(null==i||null==(t=i.scriptConfig)?void 0:t.script)||"lazy-recorder"}_isRemoteConfigFresh(){var e,t,i=this._instance.get_property(y);if(!i)return!1;try{t="object"==typeof i?i:JSON.parse(i)}catch(e){return ya.warn("persisted remote config for session recording is invalid and will be ignored",e),!1}var r=null!==(e=t.cache_timestamp)&&void 0!==e?e:Date.now();return 36e5>=Date.now()-r}_onScriptLoaded(e){var t,i;if(null==(t=Pe.__PosthogExtensions__)||!t.initSessionRecording)return ya.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[re]:!0});if(this._lazyLoadedSessionRecording||(this._lazyLoadedSessionRecording=null==(i=Pe.__PosthogExtensions__)?void 0:i.initSessionRecording(this._instance),this._lazyLoadedSessionRecording._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this._isRemoteConfigFresh()){if(this._recordingStatus===fa||this._recordingStatus===va)return;return this._recordingStatus=va,ya.info("persisted remote config is stale, requesting fresh config before starting"),void new Sn(this._instance).load()}this._recordingStatus=ga,this._lazyLoadedSessionRecording.start(e)}onRRwebEmit(e){var t;null==(t=this._lazyLoadedSessionRecording)||null==t.onRRwebEmit||t.onRRwebEmit(e)}overrideLinkedFlag(){var e,t;this._lazyLoadedSessionRecording||null==(t=this._persistence)||t.register({[x]:!0}),null==(e=this._lazyLoadedSessionRecording)||e.overrideLinkedFlag()}overrideSampling(){var e,t;this._lazyLoadedSessionRecording||null==(t=this._persistence)||t.register({[w]:!0}),null==(e=this._lazyLoadedSessionRecording)||e.overrideSampling()}overrideTrigger(e){var t,i;this._lazyLoadedSessionRecording||null==(i=this._persistence)||i.register({["url"===e?S:E]:!0}),null==(t=this._lazyLoadedSessionRecording)||t.overrideTrigger(e)}get sdkDebugProperties(){var e;return(null==(e=this._lazyLoadedSessionRecording)?void 0:e.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(e,t){var i;return!(null==(i=this._lazyLoadedSessionRecording)||!i.tryAddCustomEvent(e,t))}}},Qa={autocapture:class{constructor(e){this._initialized=!1,this._isDisabledServerSide=null,this._elementsChainAsString=!1,this.instance=e,this.rageclicks=new sa(e.config.rageclick),this._elementSelectors=null}initialize(){this.startIfEnabled()}get _config(){var e,t,i=Ye(this.instance.config.autocapture)?this.instance.config.autocapture:{};return i.url_allowlist=null==(e=i.url_allowlist)?void 0:e.map((e=>new RegExp(e))),i.url_ignorelist=null==(t=i.url_ignorelist)?void 0:t.map((e=>new RegExp(e))),i}_addDomEventHandlers(){if(this.isBrowserSupported()){if(ve&&ye){var e=e=>{e=e||(null==ve?void 0:ve.event);try{this._captureEvent(e)}catch(e){oa.error("Failed to capture event",e)}};if(Pr(ye,"submit",e,{capture:!0}),Pr(ye,"change",e,{capture:!0}),Pr(ye,"click",e,{capture:!0}),this._config.capture_copied_text){var t=e=>{e=e||(null==ve?void 0:ve.event);try{this._captureEvent(e,na)}catch(e){oa.error("Failed to capture copy/cut event",e)}};Pr(ye,"copy",t,{capture:!0}),Pr(ye,"cut",t,{capture:!0})}}}else oa.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this._initialized&&(this._addDomEventHandlers(),this._initialized=!0)}onRemoteConfig(e){e.elementsChainAsString&&(this._elementsChainAsString=e.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[c]:!!e.autocapture_opt_out}),this._isDisabledServerSide=!!e.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(e){this._elementSelectors=e}getElementSelectors(e){var t,i=[];return null==(t=this._elementSelectors)||t.forEach((t=>{var r=null==ye?void 0:ye.querySelectorAll(t);null==r||r.forEach((r=>{e===r&&i.push(t)}))})),i}get isEnabled(){var e,t,i=null==(e=this.instance.persistence)?void 0:e.props[c];if(it(this._isDisabledServerSide)&&!ot(i)&&!this.instance._shouldDisableFlags())return!1;var r=null!==(t=this._isDisabledServerSide)&&void 0!==t?t:!!i;return!!this.instance.config.autocapture&&!r}_captureEvent(e,t){if(void 0===t&&(t="$autocapture"),this.isEnabled){var i,r=ns(e);Xr(r)&&(r=r.parentNode||null),"$autocapture"===t&&"click"===e.type&&e instanceof MouseEvent&&this.instance.config.rageclick&&null!=(i=this.rageclicks)&&i.isRageClick(e.clientX,e.clientY,e.timeStamp||(new Date).getTime())&&gs(r,this.instance.config.rageclick)&&this._captureEvent(e,"$rageclick");var s=t===na;if(r&&function(e,t,i,r,s){var n,o,a,l,u,c;if(void 0===i&&(i=void 0),!ve||vs(e))return!1;if(null!=(n=i)&&n.url_allowlist&&!ts(i.url_allowlist))return!1;if(null!=(o=i)&&o.url_ignorelist&&ts(i.url_ignorelist))return!1;if(null!=(a=i)&&a.dom_event_allowlist){var d=i.dom_event_allowlist;if(d&&!d.some((e=>t.type===e)))return!1}var{parentIsUsefulElement:_,targetElementList:h}=fs(e,r);if(!function(e,t){var i=null==t?void 0:t.element_allowlist;if(Ze(i))return!0;var r,s=function(e){if(i.some((t=>e.tagName.toLowerCase()===t)))return{v:!0}};for(var n of e)if(r=s(n))return r.v;return!1}(h,i))return!1;if(!as(h,null==(l=i)?void 0:l.css_selector_allowlist))return!1;if(as(h,null!==(u=null==(c=i)?void 0:c.css_selector_ignorelist)&&void 0!==u?u:us))return!1;var p=ve.getComputedStyle(e);if(p&&"pointer"===p.getPropertyValue("cursor")&&"click"===t.type)return!0;var g=e.tagName.toLowerCase();switch(g){case"html":return!1;case"form":return(s||["submit"]).indexOf(t.type)>=0;case"input":case"select":case"textarea":return(s||["change","click"]).indexOf(t.type)>=0;default:return _?(s||["click"]).indexOf(t.type)>=0:(s||["click"]).indexOf(t.type)>=0&&(os.indexOf(g)>-1||"true"===e.getAttribute("contenteditable"))}}(r,e,this._config,s,s?["copy","cut"]:void 0)){var{props:n,explicitNoCapture:o}=ua(r,{e:e,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this._config.element_attribute_ignorelist,elementsChainAsString:this._elementsChainAsString});if(o)return!1;var a=this.getElementSelectors(r);if(a&&a.length>0&&(n.$element_selectors=a),t===na){var l,u=rs(null==ve||null==(l=ve.getSelection())?void 0:l.toString()),c=e.type||"clipboard";if(!u)return!1;n.$selected_content=u,n.$copy_type=c}return this.instance.capture(t,n),!0}}}isBrowserSupported(){return Je(null==ye?void 0:ye.querySelectorAll)}},historyAutocapture:class{constructor(e){var t;this._instance=e,this._lastPathname=(null==ve||null==(t=ve.location)?void 0:t.pathname)||""}initialize(){this.startIfEnabled()}get isEnabled(){return"history_change"===this._instance.config.capture_pageview}startIfEnabled(){this.isEnabled&&(gr.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this._popstateListener&&this._popstateListener(),this._popstateListener=void 0,gr.info("History API monitoring stopped")}monitorHistoryChanges(){ve&&ve.history&&(this._patchHistoryMethod("pushState"),this._patchHistoryMethod("replaceState"),this._setupPopstateListener())}_patchHistoryMethod(e){var t;if(ve&&(null==(t=ve.history[e])||!t.__posthog_wrapped__)){var i=this;!function(e,t,i){try{if(!(t in e))return()=>{};var r=e[t],s=i(r);return Je(s)&&(s.prototype=s.prototype||{},Object.defineProperties(s,{__posthog_wrapped__:{enumerable:!1,value:!0}})),e[t]=s,()=>{e[t]===s&&(e[t]=r)}}catch(e){return()=>{}}}(ve.history,e,(t=>function(r,s,n){t.call(this,r,s,n),i._capturePageview(e)}))}}_capturePageview(e){try{var t,i=null==ve||null==(t=ve.location)?void 0:t.pathname;if(!i)return;i!==this._lastPathname&&this.isEnabled&&this._instance.capture(_e,{navigation_type:e}),this._lastPathname=i}catch(t){gr.error("Error capturing "+e+" pageview",t)}}_setupPopstateListener(){if(!this._popstateListener){var e=()=>{this._capturePageview("popstate")};Pr(ve,"popstate",e),this._popstateListener=()=>{ve&&ve.removeEventListener("popstate",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)||!t.props[d]),this.rageclicks=new sa(e.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var e=5e3;return Ye(this._config.capture_heatmaps)&&this._config.capture_heatmaps.flush_interval_milliseconds&&(e=this._config.capture_heatmaps.flush_interval_milliseconds),e}get isEnabled(){return rt(this._config.capture_heatmaps)?rt(this._config.enable_heatmaps)?this._enabledServerSide:this._config.enable_heatmaps:!1!==this._config.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this._initialized)return;ba.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("heatmaps"in e){var t=!!e.heatmaps;this.instance.persistence&&this.instance.persistence.register({[d]:t}),this._enabledServerSide=t,this.startIfEnabled()}}getAndClearBuffer(){var e=this._buffer;return this._buffer=void 0,e}_onDeadClick(e){this._onClick(e.originalEvent,"deadclick")}_onVisibilityChange(){this._flushInterval&&clearInterval(this._flushInterval),this._flushInterval=function(e){return"visible"===(null==e?void 0:e.visibilityState)}(ye)?setInterval(this._flush.bind(this),this.flushIntervalMilliseconds):null}_setupListeners(){ve&&ye&&(this._flushHandler=this._flush.bind(this),Pr(ve,de,this._flushHandler),this._onClickHandler=e=>this._onClick(e||(null==ve?void 0:ve.event)),Pr(ye,"click",this._onClickHandler,{capture:!0}),this._onMouseMoveHandler=e=>this._onMouseMove(e||(null==ve?void 0:ve.event)),Pr(ye,"mousemove",this._onMouseMoveHandler,{capture:!0}),this._deadClicksCapture=new $s(this.instance,Ls,this._onDeadClick.bind(this)),this._deadClicksCapture.startIfEnabledOrStop(),this._onVisibilityChange_handler=this._onVisibilityChange.bind(this),Pr(ye,ce,this._onVisibilityChange_handler),this._initialized=!0)}_removeListeners(){var e;ve&&ye&&(this._flushHandler&&ve.removeEventListener(de,this._flushHandler),this._onClickHandler&&ye.removeEventListener("click",this._onClickHandler,{capture:!0}),this._onMouseMoveHandler&&ye.removeEventListener("mousemove",this._onMouseMoveHandler,{capture:!0}),this._onVisibilityChange_handler&&ye.removeEventListener(ce,this._onVisibilityChange_handler),clearTimeout(this._mouseMoveTimeout),null==(e=this._deadClicksCapture)||e.stop(),this._initialized=!1)}_getProperties(e,t){var i=this.instance.scrollManager.scrollY(),r=this.instance.scrollManager.scrollX(),s=this.instance.scrollManager.scrollElement(),n=function(e,t,i){for(var r=e;r&&Jr(r)&&!Yr(r,"body");){if(r===i)return!1;if(je(t,null==ve?void 0:ve.getComputedStyle(r).position))return!0;r=ls(r)}return!1}(ns(e),["fixed","sticky"],s);return{x:e.clientX+(n?0:r),y:e.clientY+(n?0:i),target_fixed:n,type:t}}_onClick(e,t){var r;if(void 0===t&&(t="click"),!Qr(e.target)&&wa(e)){var s=this._getProperties(e,t);null!=(r=this.rageclicks)&&r.isRageClick(e.clientX,e.clientY,(new Date).getTime())&&gs(ns(e),this.instance.config.rageclick)&&this._capture(i({},s,{type:"rageclick"})),this._capture(s)}}_onMouseMove(e){!Qr(e.target)&&wa(e)&&(clearTimeout(this._mouseMoveTimeout),this._mouseMoveTimeout=setTimeout((()=>{this._capture(this._getProperties(e,"mousemove"))}),500))}_capture(e){if(ve){var t=ve.location.href,i=this._config.custom_personal_data_properties,r=this._config.mask_personal_data_properties?[...Qs,...i||[]]:[],s=Vs(t,r,Ys);this._buffer=this._buffer||{},this._buffer[s]||(this._buffer[s]=[]),this._buffer[s].push(e)}}_flush(){this._buffer&&!Xe(this._buffer)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:$s,webVitalsAutocapture:class{constructor(e){var t;this._enabledServerSide=!1,this._initialized=!1,this._buffer={url:void 0,metrics:[],firstMetricTimestamp:void 0},this._flushToCapture=()=>{clearTimeout(this._delayedFlushTimer),0!==this._buffer.metrics.length&&(this._instance.capture("$web_vitals",this._buffer.metrics.reduce(((e,t)=>i({},e,{["$web_vitals_"+t.name+"_event"]:i({},t),["$web_vitals_"+t.name+"_value"]:t.value})),{})),this._buffer={url:void 0,metrics:[],firstMetricTimestamp:void 0})},this._addToBuffer=e=>{var t;this._buffer=this._buffer||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var r=this._currentURL();if(!Ze(r))if(rt(null==e?void 0:e.name)||rt(null==e?void 0:e.value))_a.error("Invalid metric received",e);else if(!this._maxAllowedValue||this._maxAllowedValue>e.value){this._buffer.url!==r&&(this._flushToCapture(),this._delayedFlushTimer=setTimeout(this._flushToCapture,this.flushToCaptureTimeoutMs)),Ze(this._buffer.url)&&(this._buffer.url=r),this._buffer.firstMetricTimestamp=Ze(this._buffer.firstMetricTimestamp)?Date.now():this._buffer.firstMetricTimestamp,e.attribution&&e.attribution.interactionTargetElement&&(e.attribution.interactionTargetElement=void 0);var s=null==(t=this._instance.sessionManager)?void 0:t.checkAndGetSessionAndWindowId(!0),n=i({},e,{$current_url:r,timestamp:Date.now()});Ze(s)||(n.$session_id=s.sessionId,n.$window_id=s.windowId),this._buffer.metrics.push(n),this._buffer.metrics.length===this.allowedMetrics.length&&this._flushToCapture()}else _a.error("Ignoring metric with value >= "+this._maxAllowedValue,e)},this._startCapturing=()=>{if(!this._initialized){var e,t,i,r,s=Pe.__PosthogExtensions__;Ze(s)||Ze(s.postHogWebVitalsCallbacks)||({onLCP:e,onCLS:t,onFCP:i,onINP:r}=s.postHogWebVitalsCallbacks),e&&t&&i&&r?(this.allowedMetrics.indexOf("LCP")>-1&&e(this._addToBuffer.bind(this)),this.allowedMetrics.indexOf("CLS")>-1&&t(this._addToBuffer.bind(this)),this.allowedMetrics.indexOf("FCP")>-1&&i(this._addToBuffer.bind(this)),this.allowedMetrics.indexOf("INP")>-1&&r(this._addToBuffer.bind(this)),this._initialized=!0):_a.error("web vitals callbacks not loaded - not starting")}},this._instance=e,this._enabledServerSide=!(null==(t=this._instance.persistence)||!t.props[g]),this.startIfEnabled()}get _perfConfig(){return this._instance.config.capture_performance}get allowedMetrics(){var e,t,i=Ye(this._perfConfig)?null==(e=this._perfConfig)?void 0:e.web_vitals_allowed_metrics:void 0;return rt(i)?(null==(t=this._instance.persistence)?void 0:t.props[m])||["CLS","FCP","INP","LCP"]:i}get flushToCaptureTimeoutMs(){return(Ye(this._perfConfig)?this._perfConfig.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var e=Ye(this._perfConfig)?this._perfConfig.web_vitals_attribution:void 0;return null!=e&&e}get _maxAllowedValue(){var e=Ye(this._perfConfig)&&st(this._perfConfig.__web_vitals_max_value)?this._perfConfig.__web_vitals_max_value:ha;return e>0&&6e4>=e?ha:e}get isEnabled(){var e=null==be?void 0:be.protocol;if("http:"!==e&&"https:"!==e)return _a.info("Web Vitals are disabled on non-http/https protocols"),!1;var t=Ye(this._perfConfig)?this._perfConfig.web_vitals:ot(this._perfConfig)?this._perfConfig:void 0;return ot(t)?t:this._enabledServerSide}startIfEnabled(){this.isEnabled&&!this._initialized&&(_a.info("enabled, starting..."),this._loadScript(this._startCapturing))}onRemoteConfig(e){if("capturePerformance"in e){var t=Ye(e.capturePerformance)&&!!e.capturePerformance.web_vitals,i=Ye(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[g]:t}),this._instance.persistence.register({[m]:i})),this._enabledServerSide=t,this.startIfEnabled()}}_loadScript(e){var t,i;null!=(t=Pe.__PosthogExtensions__)&&t.postHogWebVitalsCallbacks?e():null==(i=Pe.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,this.useAttribution?"web-vitals-with-attribution":"web-vitals",(t=>{t?_a.error("failed to load script",t):e()}))}_currentURL(){var e=ve?ve.location.href:void 0;if(e){var t=this._instance.config.custom_personal_data_properties,i=this._instance.config.mask_personal_data_properties?[...Qs,...t||[]]:[];return Vs(e,i,Ys)}_a.error("Could not determine current URL")}}},Ja={exceptionObserver:class{constructor(e){var t,i,r;this._startCapturing=()=>{var e;if(ve&&this.isEnabled&&null!=(e=Pe.__PosthogExtensions__)&&e.errorWrappingFunctions){var t=Pe.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,i=Pe.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,r=Pe.__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=r(this.captureException.bind(this)))}catch(e){ca.error("failed to start",e),this._stopCapturing()}}},this._instance=e,this._remoteEnabled=!(null==(t=this._instance.persistence)||!t.props[_]),this._rateLimiter=new ft({refillRate:null!==(i=this._instance.config.error_tracking.__exceptionRateLimiterRefillRate)&&void 0!==i?i:1,bucketSize:null!==(r=this._instance.config.error_tracking.__exceptionRateLimiterBucketSize)&&void 0!==r?r:10,refillInterval:1e4,_logger:ca}),this._config=this._requiredConfig(),this.startIfEnabledOrStop()}_requiredConfig(){var e=this._instance.config.capture_exceptions,t={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return Ye(e)?t=i({},t,e):(Ze(e)?this._remoteEnabled:e)&&(t=i({},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?(ca.info("enabled"),this._stopCapturing(),this._loadScript(this._startCapturing)):this._stopCapturing()}_loadScript(e){var t,i;null!=(t=Pe.__PosthogExtensions__)&&t.errorWrappingFunctions?e():null==(i=Pe.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"exception-autocapture",(t=>{if(t)return ca.error("failed to load script",t);e()}))}_stopCapturing(){var e,t,i;null==(e=this._unwrapOnError)||e.call(this),this._unwrapOnError=void 0,null==(t=this._unwrapUnhandledRejection)||t.call(this),this._unwrapUnhandledRejection=void 0,null==(i=this._unwrapConsoleError)||i.call(this),this._unwrapConsoleError=void 0}onRemoteConfig(e){"autocaptureExceptions"in e&&(this._remoteEnabled=!!e.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[_]:this._remoteEnabled}),this._config=this._requiredConfig(),this.startIfEnabledOrStop())}onConfigChange(){this._config=this._requiredConfig()}captureException(e){var t,i,r,s=null!==(t=null==e||null==(i=e.$exception_list)||null==(i=i[0])?void 0:i.type)&&void 0!==t?t:"Exception";this._rateLimiter.consumeRateLimit(s)?ca.info("Skipping exception capture because of client rate limiting.",{exception:s}):null==(r=this._instance.exceptions)||r.sendExceptionEvent(e)}},exceptions:class{constructor(e){var t,r;this._suppressionRules=[],this._errorPropertiesBuilder=new qi([new Ji,new or,new Xi,new Yi,new sr,new rr,new er,new nr],function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),s=1;t>s;s++)r[s-1]=arguments[s];return function(t,s){void 0===s&&(s=0);for(var n=[],o=t.split("\n"),a=s;o.length>a;a++){var l=o[a];if(1024>=l.length){var u=Qi.test(l)?l.replace(Qi,"$1"):l;if(!u.match(/\S*Error: /)){for(var c of r){var d=c(u,e);if(d){n.push(d);break}}if(n.length>=50)break}}}return function(e){if(!e.length)return[];var t=Array.from(e);return t.reverse(),t.slice(0,50).map((e=>{return i({},e,{filename:e.filename||(r=t,r[r.length-1]||{}).filename,function:e.function||Bi});var r}))}(n)}}("web:javascript",Wi,Ki)),this._instance=e,this._suppressionRules=null!==(t=null==(r=this._instance.persistence)?void 0:r.get_property(h))&&void 0!==t?t:[],this._exceptionStepsConfig=dr(this._getExceptionStepsConfig()),this._exceptionStepsBuffer=new _r(this._exceptionStepsConfig)}onConfigChange(){this._exceptionStepsConfig=dr(this._getExceptionStepsConfig()),this._exceptionStepsBuffer.setConfig(this._exceptionStepsConfig)}onRemoteConfig(e){var t,i,r;if("errorTracking"in e){var s=null!==(t=null==(i=e.errorTracking)?void 0:i.suppressionRules)&&void 0!==t?t:[],n=null==(r=e.errorTracking)?void 0:r.captureExtensionExceptions;this._suppressionRules=s,this._instance.persistence&&this._instance.persistence.register({[h]:this._suppressionRules,[p]:n})}}get _captureExtensionExceptions(){var e,t=!!this._instance.get_property(p),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(!et(e)||0===e.trim().length)return void Ha.warn("Ignoring exception step because message must be a non-empty string");var r=this._coerceExceptionStepProperties(t),{sanitizedProperties:s,droppedKeys:n}=function(e){if(!e)return{sanitizedProperties:{},droppedKeys:[]};var t=[];return{sanitizedProperties:Object.keys(e).reduce(((i,r)=>ur.has(r)?(t.push(r),i):(i[r]=e[r],i)),{}),droppedKeys:t}}(r);n.length>0&&Ha.warn("Ignoring reserved exception step fields",{droppedKeys:n}),this._exceptionStepsBuffer.add(i({[ar]:e,[lr]:(new Date).toISOString()},s))}catch(e){Ha.error("Failed to add exception step. Ignoring breadcrumb.",e)}}sendExceptionEvent(e){try{var t=e.$exception_list;if(this._isExceptionList(t)){if(this._matchesSuppressionRule(t))return this._addDroppedExceptionStep("Exception dropped: matched a suppression rule"),void Ha.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 Ha.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this._isPostHogException(t))return this._addDroppedExceptionStep("Exception dropped: thrown by the PostHog SDK"),void Ha.info("Skipping exception capture because it was thrown by the PostHog SDK")}var i=this._exceptionStepsConfig.enabled&&rt(e.$exception_steps)?this._addBufferedExceptionSteps(e):e;try{var r=this._instance.capture("$exception",i,{_noTruncate:!0,_batchKey:"exceptionEvent",_originatedFromCaptureException:!0});return r&&this._exceptionStepsBuffer.clear(),r}catch(e){return Ha.error("Failed to capture exception event. Dropping this exception.",e),void this._exceptionStepsBuffer.clear()}}catch(e){return void Ha.error("Failed to process exception event. Ignoring this exception.",e)}}_addBufferedExceptionSteps(e){try{var t=this._exceptionStepsBuffer.getAttachable();return 0===t.length?e:i({},e,{$exception_steps:t})}catch(t){return Ha.error("Failed to read buffered exception steps. Capturing exception without steps.",t),e}}_addDroppedExceptionStep(e){this._exceptionStepsConfig.enabled&&this._exceptionStepsBuffer.add({[ar]:e,[lr]:(new Date).toISOString()})}_coerceExceptionStepProperties(e){return Ye(e)?i({},e):{}}_getExceptionStepsConfig(){var e,t;return null!==(e=null==(t=this._instance.config.error_tracking)?void 0:t.exception_steps)&&void 0!==e?e:{}}_matchesSuppressionRule(e){if(0===e.length)return!1;var t=e.reduce(((e,t)=>{var{type:i,value:r}=t;return et(i)&&i.length>0&&e.$exception_types.push(i),et(r)&&r.length>0&&e.$exception_values.push(r),e}),{$exception_types:[],$exception_values:[]});return this._suppressionRules.some((e=>{var i=e.values.map((e=>{var i,r=Fo[e.operator],s=Qe(e.value)?e.value:[e.value],n=null!==(i=t[e.key])&&void 0!==i?i:[];return s.length>0&&r(s,n)}));return"OR"===e.type?i.some(Boolean):i.every(Boolean)}))}_isExtensionException(e){return e.flatMap((e=>{var t,i;return null!==(t=null==(i=e.stacktrace)?void 0:i.frames)&&void 0!==t?t:[]})).some((e=>e.filename&&e.filename.startsWith("chrome-extension://")))}_isPostHogException(e){if(e.length>0){var t,i,r,s,n=null!==(t=null==(i=e[0].stacktrace)?void 0:i.frames)&&void 0!==t?t:[],o=n[n.length-1];return null!==(r=null==o||null==(s=o.filename)?void 0:s.includes("posthog.com/static"))&&void 0!==r&&r}return!1}_isExceptionList(e){return!rt(e)&&Qe(e)}}},Ya=i({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("productTours"in e){var t,i;if(this._persistence&&this._persistence.register({[f]:!!e.productTours}),!Sa(this._instance))return!this._productTourManager&&rt(null==(t=this._persistence)?void 0:t.props[H])||xa.info("product tours disabled; stopping and clearing cached tours"),null==(i=this._productTourManager)||i.stop(),this._productTourManager=null,void this.clearCache();this.loadIfEnabled()}}loadIfEnabled(){!this._productTourManager&&Sa(this._instance)&&this._loadScript((()=>this._startProductTours()))}_loadScript(e){var t,i;null!=(t=Pe.__PosthogExtensions__)&&t.generateProductTours?e():null==(i=Pe.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"product-tours",(t=>{t?xa.error("Could not load product tours script",t):e()}))}_startProductTours(){var e;!this._productTourManager&&null!=(e=Pe.__PosthogExtensions__)&&e.generateProductTours&&(this._productTourManager=Pe.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,t){if(void 0===t&&(t=!1),!Qe(this._cachedTours)||t){var i=this._persistence;if(i){var r=i.props[H];if(Qe(r)&&!t)return this._cachedTours=r,void e(r,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/product_tours/?token="+this._instance.config.token),method:"GET",callback:t=>{if(Sa(this._instance)){var r=t.statusCode;if(200!==r||!t.json){var s="Product Tours API could not be loaded, status: "+r;return xa.error(s),void e([],{isLoaded:!1,error:s})}var n=Qe(t.json.product_tours)?t.json.product_tours:[];this._cachedTours=n,i&&i.register({[H]:n}),e(n,{isLoaded:!0})}else e([],{isLoaded:!0})}})}else e(this._cachedTours,{isLoaded:!0})}getActiveProductTours(e){rt(this._productTourManager)?e([],{isLoaded:!1,error:"Product tours not loaded"}):this._productTourManager.getActiveProductTours(e)}showProductTour(e){var t;null==(t=this._productTourManager)||t.showTourById(e)}previewTour(e){this._productTourManager?this._productTourManager.previewTour(e):this._loadScript((()=>{var t;this._startProductTours(),null==(t=this._productTourManager)||t.previewTour(e)}))}dismissProductTour(){var e;null==(e=this._productTourManager)||e.dismissTour("user_clicked_skip")}nextStep(){var e;null==(e=this._productTourManager)||e.nextStep()}previousStep(){var e;null==(e=this._productTourManager)||e.previousStep()}clearCache(){var e;this._cachedTours=null,null==(e=this._persistence)||e.unregister(H)}resetTour(e){var t;null==(t=this._productTourManager)||t.resetTour(e)}resetAllTours(){var e;null==(e=this._productTourManager)||e.resetAllTours()}cancelPendingTour(e){var t;null==(t=this._productTourManager)||t.cancelPendingTour(e)}}},Ga),Xa={siteApps:class{constructor(e){this._siteAppElementPatchCount=0,this._instance=e,this._bufferedInvocations=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}_eventCollector(e,t){if(t){var 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=Pe._POSTHOG_REMOTE_CONFIG)||null==(e=e[this._instance.config.token])?void 0:e.siteApps}initialize(){if(this.isEnabled){var e=this._instance._addCaptureHook(this._eventCollector.bind(this));this._stopBuffering=()=>{e(),this._bufferedInvocations=[],this._stopBuffering=void 0}}}globalsForEvent(e){var t,s,n,o,a,l,u;if(!e)throw new Error("Event payload is required");var c={},d=this._instance.get_property("$groups")||[],_=this._instance.get_property("$stored_group_properties")||{};for(var[h,p]of Object.entries(_))c[h]={id:d[h],type:h,properties:p};var{$set_once:g,$set:v}=e;return{event:i({},r(e,Ea),{properties:i({},e.properties,v?{$set:i({},null!==(t=null==(s=e.properties)?void 0:s.$set)&&void 0!==t?t:{},v)}:{},g?{$set_once:i({},null!==(n=null==(o=e.properties)?void 0:o.$set_once)&&void 0!==n?n:{},g)}:{}),elements_chain:null!==(a=null==(l=e.properties)?void 0:l.$elements_chain)&&void 0!==a?a:"",distinct_id:null==(u=e.properties)?void 0:u.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:c}}_prepareElementForSiteApp(e){var t,i=null==(t=e.tagName)?void 0:t.toLowerCase();return"style"===i&&this._instance.config.prepare_external_dependency_stylesheet?this._instance.config.prepare_external_dependency_stylesheet(e)||(ka.error("prepare_external_dependency_stylesheet returned null"),null):"script"===i&&this._instance.config.prepare_external_dependency_script?this._instance.config.prepare_external_dependency_script(e)||(ka.error("prepare_external_dependency_script returned null"),null):e}_patchSiteAppElementInsertionMethods(){var e,t,i,r,s,n,o,a;if(!this._instance.config.prepare_external_dependency_stylesheet&&!this._instance.config.prepare_external_dependency_script)return()=>{};var l=null==ye?void 0:ye.defaultView,u=null==l||null==(e=l.Node)?void 0:e.prototype;if(!l||!u)return()=>{};if(this._siteAppElementPatchCount++,this._restoreSiteAppElementPatches)return this._releaseSiteAppElementPatches();var c=[],d=this,_=new WeakSet,h=(e,t,i)=>{if(null!=e&&e[t]){var r=e[t];e[t]=i(r),c.push((()=>{e[t]=r}))}},p=e=>{if(_.has(e))return e;var t=d._prepareElementForSiteApp(e);return t&&_.add(t),t},g=e=>e.map((e=>"string"==typeof e?e:p(e))).filter((e=>!it(e)));return h(u,"appendChild",(e=>function(t){var i=p(t);return i?e.call(this,i):t})),h(u,"insertBefore",(e=>function(t,i){var r=p(t);return r?e.call(this,r,i):t})),h(u,"replaceChild",(e=>function(t,i){var r=p(t);return r?e.call(this,r,i):i})),[null==(t=l.Element)?void 0:t.prototype,null==(i=l.Document)?void 0:i.prototype,null==(r=l.DocumentFragment)?void 0:r.prototype].forEach((e=>{h(e,"append",(e=>function(){for(var t=arguments.length,i=new Array(t),r=0;t>r;r++)i[r]=arguments[r];return e.apply(this,g(i))})),h(e,"prepend",(e=>function(){for(var t=arguments.length,i=new Array(t),r=0;t>r;r++)i[r]=arguments[r];return e.apply(this,g(i))}))})),[null==(s=l.Element)?void 0:s.prototype,null==(n=l.CharacterData)?void 0:n.prototype,null==(o=l.DocumentType)?void 0:o.prototype].forEach((e=>{h(e,"before",(e=>function(){for(var t=arguments.length,i=new Array(t),r=0;t>r;r++)i[r]=arguments[r];return e.apply(this,g(i))})),h(e,"after",(e=>function(){for(var t=arguments.length,i=new Array(t),r=0;t>r;r++)i[r]=arguments[r];return e.apply(this,g(i))})),h(e,"replaceWith",(e=>function(){for(var t=arguments.length,i=new Array(t),r=0;t>r;r++)i[r]=arguments[r];var s=g(i);return i.length&&!s.length?void 0:e.apply(this,s)}))})),h(null==(a=l.Element)?void 0:a.prototype,"insertAdjacentElement",(e=>function(t,i){var r=p(i);return r?e.call(this,t,r):null})),this._restoreSiteAppElementPatches=()=>{c.forEach((e=>e())),this._restoreSiteAppElementPatches=void 0},this._releaseSiteAppElementPatches()}_releaseSiteAppElementPatches(){var e=!1;return()=>{var t;e||(e=!0,this._siteAppElementPatchCount--,0===this._siteAppElementPatchCount&&(null==(t=this._restoreSiteAppElementPatches)||t.call(this)))}}_runWithPreparedSiteAppElements(e,t){void 0===t&&(t=!0);var i=this._patchSiteAppElementInsertionMethods();try{var r=e(i);return t&&i(),r}catch(e){throw i(),e}}setupSiteApp(e){var t=this.apps[e.id],i=()=>{var i;!t.errored&&this._bufferedInvocations.length&&(ka.info("Processing "+this._bufferedInvocations.length+" events for site app with id "+e.id),this._bufferedInvocations.forEach((e=>this._runWithPreparedSiteAppElements((()=>null==t.processEvent?void 0:t.processEvent(e))))),t.processedBuffer=!0),Object.values(this.apps).every((e=>e.processedBuffer||e.errored))&&(null==(i=this._stopBuffering)||i.call(this))},r=!1,s=s=>{t.errored=!s,t.loaded=!0,ka.info("Site app with id "+e.id+" "+(s?"loaded":"errored")),r&&i()};try{var{processEvent:n}=this._runWithPreparedSiteAppElements((t=>e.init({posthog:this._instance,callback(e){t(),s(e)}})),!1);n&&(t.processEvent=n),r=!0}catch(t){ka.error(Pa+e.id,t),s(!1)}if(r&&t.loaded)try{i()}catch(i){ka.error("Error while processing buffered events PostHog app with config id "+e.id,i),t.errored=!0}}_setupSiteApps(){var e=this.siteAppLoaders||[];for(var t of e)this.apps[t.id]={id:t.id,loaded:!1,errored:!1,processedBuffer:!1};for(var i of e)this.setupSiteApp(i)}_onCapturedEvent(e){var t=this;if(0!==Object.keys(this.apps).length){var i=this.globalsForEvent(e),r=function(r){try{t._runWithPreparedSiteAppElements((()=>null==r.processEvent?void 0:r.processEvent(i)))}catch(t){ka.error("Error while processing event "+e.event+" for site app "+r.id,t)}};for(var s of Object.values(this.apps))r(s)}}onRemoteConfig(e){var t,i,r,s=this;if(null!=(t=this.siteAppLoaders)&&t.length)return this.isEnabled?(this._setupSiteApps(),void this._instance.on("eventCaptured",(e=>this._onCapturedEvent(e)))):void ka.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null==(i=this._stopBuffering)||i.call(this),null!=(r=e.siteApps)&&r.length)if(this.isEnabled){var n=function(e){var t;Pe["__$$ph_site_app_"+e]=s._instance,null==(t=Pe.__PosthogExtensions__)||null==t.loadSiteApp||t.loadSiteApp(s._instance,a,(t=>{if(t)return ka.error(Pa+e,t)}))};for(var{id:o,url:a}of e.siteApps)n(o)}else ka.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}},Za={tracingHeaders:class{constructor(e){this._restoreXHRPatch=void 0,this._restoreFetchPatch=void 0,this._hostnamesForPatch=void 0,this._startCapturing=()=>{var e,t,i=this._syncHostnamesForPatch();i?(Ze(this._restoreXHRPatch)&&(this._restoreXHRPatch=null==(e=Pe.__PosthogExtensions__)||null==(e=e.tracingHeadersPatchFns)?void 0:e._patchXHR(i,(()=>this._instance.get_distinct_id()),this._instance.sessionManager)),Ze(this._restoreFetchPatch)&&(this._restoreFetchPatch=null==(t=Pe.__PosthogExtensions__)||null==(t=t.tracingHeadersPatchFns)?void 0:t._patchFetch(i,(()=>this._instance.get_distinct_id()),this._instance.sessionManager))):this._stopCapturing()},this._instance=e}initialize(){this.startIfEnabledOrStop()}_loadScript(e){var t,i;null!=(t=Pe.__PosthogExtensions__)&&t.tracingHeadersPatchFns?e():null==(i=Pe.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"tracing-headers",(t=>{if(t)return da.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(){var e=this._getConfiguredHostnames();return Qe(e)?(Qe(this._hostnamesForPatch)?this._hostnamesForPatch.splice(0,this._hostnamesForPatch.length,...e):this._hostnamesForPatch=[...e],e.length>0?this._hostnamesForPatch:void 0):(Qe(this._hostnamesForPatch)&&this._hostnamesForPatch.splice(0),this._hostnamesForPatch=e||void 0,this._hostnamesForPatch)}_stopCapturing(){var e,t;null==(e=this._restoreXHRPatch)||e.call(this),null==(t=this._restoreFetchPatch)||t.call(this),this._restoreXHRPatch=void 0,this._restoreFetchPatch=void 0}startIfEnabledOrStop(){this._syncHostnamesForPatch()?this._loadScript(this._startCapturing):this._stopCapturing()}}},el=i({surveys:class{get _config(){return this._instance.config}constructor(e){this._isSurveysEnabled=void 0,this._surveyManager=null,this._isInitializingSurveys=!1,this._surveyCallbacks=[],this._getSurveysInFlightPromise=null,this._instance=e,this._surveyEventReceiver=null}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(!this._config.disable_surveys){var t=e.surveys;if(rt(t))return Oo.warn("Flags not loaded yet. Not loading surveys.");var i=Qe(t);this._isSurveysEnabled=i?t.length>0:t,Oo.info("flags response received, isSurveysEnabled: "+this._isSurveysEnabled),this.loadIfEnabled()}}reset(){try{var e;null==(e=this._surveyEventReceiver)||e.reset(),localStorage.removeItem("lastSeenSurveyDate");for(var t=[],i=0;i<localStorage.length;i++){var r=localStorage.key(i);(null!=r&&r.startsWith(Do)||null!=r&&r.startsWith("inProgressSurvey_"))&&t.push(r)}t.forEach((e=>localStorage.removeItem(e)))}catch(e){}}loadIfEnabled(){if(!this._surveyManager)if(this._isInitializingSurveys)Oo.info("Already initializing surveys, skipping...");else if(this._config.disable_surveys)Oo.info(La);else if(this._config.cookieless_mode&&this._instance.consent.isOptedOut())Oo.info("Not loading surveys in cookieless mode without consent.");else{var e=null==Pe?void 0:Pe.__PosthogExtensions__;if(e){if(!Ze(this._isSurveysEnabled)||this._config.advanced_enable_surveys){var t=this._isSurveysEnabled||this._config.advanced_enable_surveys;this._isInitializingSurveys=!0;try{var i=e.generateSurveys;if(i)return void this._completeSurveyInitialization(i,t);var r=e.loadExternalDependency;if(!r)return void this._handleSurveyLoadError(se);r(this._instance,"surveys",(i=>{i||!e.generateSurveys?this._handleSurveyLoadError("Could not load surveys script",i):this._completeSurveyInitialization(e.generateSurveys,t)}))}catch(e){throw this._handleSurveyLoadError("Error initializing surveys",e),e}finally{this._isInitializingSurveys=!1}}}else Oo.error("PostHog Extensions not found.")}}_completeSurveyInitialization(e,t){this._surveyManager=e(this._instance,t),this._surveyEventReceiver=new Ta(this._instance),Oo.info("Surveys loaded successfully"),this._notifySurveyCallbacks({isLoaded:!0})}_handleSurveyLoadError(e,t){Oo.error(e,t),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){if(void 0===t&&(t=!1),this._config.disable_surveys)return Oo.info(La),e([]);var i,r=this._instance.get_property(q);if(r&&!t)return e(r,{isLoaded:!0});"undefined"!=typeof Promise&&this._getSurveysInFlightPromise?this._getSurveysInFlightPromise.then((t=>{var{surveys:i,context:r}=t;return e(i,r)})):("undefined"!=typeof Promise&&(this._getSurveysInFlightPromise=new Promise((e=>{i=e}))),this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/surveys/?token="+this._config.token),method:"GET",timeout:this._config.surveys_request_timeout_ms,callback:t=>{var r;this._getSurveysInFlightPromise=null;var s=t.statusCode;if(200!==s||!t.json){var n="Surveys API could not be loaded, status: "+s;Oo.error(n);var o={isLoaded:!1,error:n};return e([],o),void(null==i||i({surveys:[],context:o}))}var a,l=t.json.surveys||[],u=l.filter((e=>function(e){return!(!e.start_date||e.end_date)}(e)&&(function(e){var t;return!(null==(t=e.conditions)||null==(t=t.events)||null==(t=t.values)||!t.length)}(e)||function(e){var t;return!(null==(t=e.conditions)||null==(t=t.actions)||null==(t=t.values)||!t.length)}(e))));u.length>0&&(null==(a=this._surveyEventReceiver)||a.register(u)),null==(r=this._instance.persistence)||r.register({[q]:l,[B]:Date.now()});var c={isLoaded:!0};e(l,c),null==i||i({surveys:l,context:c})}}))}_notifySurveyCallbacks(e){for(var t of this._surveyCallbacks)try{if(!e.isLoaded)return t([],e);this.getSurveys(t)}catch(e){Oo.error("Error in survey callback",e)}}getActiveMatchingSurveys(e,t){if(void 0===t&&(t=!1),!rt(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);Oo.warn("init was not called")}_getSurveyById(e){var t=null;return this.getSurveys((i=>{var r;t=null!==(r=i.find((t=>t.id===e)))&&void 0!==r?r:null})),t}_checkSurveyEligibility(e){if(rt(this._surveyManager))return{eligible:!1,reason:Ra};var t="string"==typeof e?this._getSurveyById(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(e){if(rt(this._surveyManager))return Oo.warn("init was not called"),{visible:!1,disabledReason:Ra};var t=this._checkSurveyEligibility(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return rt(this._surveyManager)?(Oo.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:Ra})):new Promise((i=>{this.getSurveys((t=>{var r,s=null!==(r=t.find((t=>t.id===e)))&&void 0!==r?r:null;if(s){var n=this._checkSurveyEligibility(s);i({visible:n.eligible,disabledReason:n.reason})}else i({visible:!1,disabledReason:"Survey not found"})}),t)}))}renderSurvey(e,t,i){var r;if(rt(this._surveyManager))Oo.warn("init was not called");else{var s="string"==typeof e?this._getSurveyById(e):e;if(null!=s&&s.id)if(qo.includes(s.type)){var n=null==ye?void 0:ye.querySelector(t);if(n)return null!=(r=s.appearance)&&r.surveyPopupDelaySeconds?(Oo.info("Rendering survey "+s.id+" with delay of "+s.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var e,t;Oo.info("Rendering survey "+s.id+" with delay of "+(null==(e=s.appearance)?void 0:e.surveyPopupDelaySeconds)+" seconds"),null==(t=this._surveyManager)||t.renderSurvey(s,n,i),Oo.info("Survey "+s.id+" rendered")}),1e3*s.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(s,n,i);Oo.warn("Survey element not found")}else Oo.warn("Surveys of type "+s.type+" cannot be rendered in the app");else Oo.warn("Survey not found")}}displaySurvey(e,t){var r;if(rt(this._surveyManager))Oo.warn("init was not called");else{var s=this._getSurveyById(e);if(s){var n=s;if(null!=(r=s.appearance)&&r.surveyPopupDelaySeconds&&t.ignoreDelay&&(n=i({},s,{appearance:i({},s.appearance,{surveyPopupDelaySeconds:0})})),t.displayType!==yn&&t.initialResponses&&Oo.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),!1===t.ignoreConditions){var o=this.canRenderSurvey(s);if(!o.visible)return void Oo.warn("Survey is not eligible to be displayed: ",o.disabledReason)}"inline"!==t.displayType?this._surveyManager.handlePopoverSurvey(n,t):this.renderSurvey(n,t.selector,t.properties)}else Oo.warn("Survey not found")}}cancelPendingSurvey(e){rt(this._surveyManager)?Oo.warn("init was not called"):this._surveyManager.cancelSurvey(e)}handlePageUnload(){var e;null==(e=this._surveyManager)||e.handlePageUnload()}}},Ga),tl={toolbar:class{constructor(e){this.instance=e}_setToolbarState(e){Pe.ph_toolbar_state=e}_getToolbarState(){var e;return null!==(e=Pe.ph_toolbar_state)&&void 0!==e?e:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(e,t,i){if(void 0===e&&(e=void 0),void 0===t&&(t=void 0),void 0===i&&(i=void 0),Ir(this.instance.config))return!1;if(!ve||!ye)return!1;e=null!=e?e:ve.location,i=null!=i?i:ve.history;try{if(!t){try{ve.localStorage.setItem("test","test"),ve.localStorage.removeItem("test")}catch(e){return!1}t=null==ve?void 0:ve.localStorage}var r,s=Ma||Gs(e.hash,"__posthog")||Gs(e.hash,"state"),n=s?wr((()=>JSON.parse(atob(decodeURIComponent(s)))))||wr((()=>JSON.parse(decodeURIComponent(s)))):null;return n&&"ph_authorize"===n.action?((r=n).source="url",r&&Object.keys(r).length>0&&(n.desiredHash?e.hash=n.desiredHash:i?i.replaceState(i.state,"",e.pathname+e.search):e.hash="")):((r=JSON.parse(t.getItem($a)||"{}")).source="localstorage",delete r.userIntent),!(!r.token||this.instance.config.token!==r.token||(this.loadToolbar(r),0))}catch(e){return!1}}_callLoadToolbar(e){var t=Pe.ph_load_toolbar||Pe.ph_load_editor;!rt(t)&&Je(t)?t(e,this.instance):Aa.warn("No toolbar load function found")}loadToolbar(e){var t=!(null==ye||!ye.getElementById(Z));if(!ve||t)return!1;var r="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,s=i({token:this.instance.config.token},e,{apiURL:this.instance.requestRouter.endpointFor("ui")},r?{instrument:!1}:{});if(ve.localStorage.setItem($a,JSON.stringify(i({},s,{source:void 0}))),2===this._getToolbarState())this._callLoadToolbar(s);else if(0===this._getToolbarState()){var n;this._setToolbarState(1),null==(n=Pe.__PosthogExtensions__)||null==n.loadExternalDependency||n.loadExternalDependency(this.instance,"toolbar",(e=>{if(e)return Aa.error("[Toolbar] Failed to load",e),void this._setToolbarState(0);this._setToolbarState(2),this._callLoadToolbar(s)})),Pr(ve,"turbolinks:load",(()=>{this._setToolbarState(0),this.loadToolbar(s)}))}return!0}_loadEditor(e){return this.loadToolbar(e)}maybeLoadEditor(e,t,i){return void 0===e&&(e=void 0),void 0===t&&(t=void 0),void 0===i&&(i=void 0),this.maybeLoadToolbar(e,t,i)}}},il=i({experiments:Ua},Ga),rl=i({},Ga,Ka,Qa,Ja,Ya,Xa,el,Za,tl,il,{conversations:class{constructor(e){this._isConversationsEnabled=void 0,this._conversationsManager=null,this._isInitializing=!1,this._remoteConfig=null,this._instance=e}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(!this._instance.config.disable_conversations){var t=e.conversations;rt(t)||(ot(t)?this._isConversationsEnabled=t:(this._isConversationsEnabled=t.enabled,this._remoteConfig=t),this.loadIfEnabled())}}reset(){var e;null==(e=this._conversationsManager)||e.reset(),this._conversationsManager=null,this._isConversationsEnabled=void 0,this._remoteConfig=null}loadIfEnabled(){if(!(this._conversationsManager||this._isInitializing||this._instance.config.disable_conversations||Ir(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var e=null==Pe?void 0:Pe.__PosthogExtensions__;if(e&&!Ze(this._isConversationsEnabled)&&this._isConversationsEnabled)if(this._remoteConfig&&this._remoteConfig.token){this._isInitializing=!0;try{var t=e.initConversations;if(t)return this._completeInitialization(t),void(this._isInitializing=!1);var i=e.loadExternalDependency;if(!i)return void this._handleLoadError(se);i(this._instance,"conversations",(t=>{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 Wa.error("Conversations enabled but missing token in remote config.")}}_completeInitialization(e){if(this._remoteConfig)try{this._conversationsManager=e(this._remoteConfig,this._instance),Wa.info("Conversations loaded successfully")}catch(e){this._handleLoadError("Error completing conversations initialization",e)}else Wa.error("Cannot complete initialization: remote config is null")}_handleLoadError(e,t){Wa.error(e,t),this._conversationsManager=null,this._isInitializing=!1}show(){this._conversationsManager?this._conversationsManager.show():Wa.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this._isConversationsEnabled&&!it(this._conversationsManager)}isVisible(){var e,t;return null!==(e=null==(t=this._conversationsManager)?void 0:t.isVisible())&&void 0!==e&&e}sendMessage(e,i,r){var s=this;return t((function*(){return s._conversationsManager?s._conversationsManager.sendMessage(e,i,r):(Wa.warn(Va),null)}))()}getMessages(e,i){var r=this;return t((function*(){return r._conversationsManager?r._conversationsManager.getMessages(e,i):(Wa.warn(Va),null)}))()}markAsRead(e){var i=this;return t((function*(){return i._conversationsManager?i._conversationsManager.markAsRead(e):(Wa.warn(Va),null)}))()}getTickets(e){var i=this;return t((function*(){return i._conversationsManager?i._conversationsManager.getTickets(e):(Wa.warn(Va),null)}))()}requestRestoreLink(e){var i=this;return t((function*(){return i._conversationsManager?i._conversationsManager.requestRestoreLink(e):(Wa.warn(Va),null)}))()}restoreFromToken(e){var i=this;return t((function*(){return i._conversationsManager?i._conversationsManager.restoreFromToken(e):(Wa.warn(Va),null)}))()}restoreFromUrlToken(){var e=this;return t((function*(){return e._conversationsManager?e._conversationsManager.restoreFromUrlToken():(Wa.warn(Va),null)}))()}getCurrentTicketId(){var e,t;return null!==(e=null==(t=this._conversationsManager)?void 0:t.getCurrentTicketId())&&void 0!==e?e:null}getWidgetSessionId(){var e,t;return null!==(e=null==(t=this._conversationsManager)?void 0:t.getWidgetSessionId())&&void 0!==e?e:null}_onIdentityChanged(){var e;null==(e=this._conversationsManager)||e.setIdentity()}_onIdentityCleared(){var e;null==(e=this._conversationsManager)||e.clearIdentity()}}},{logs:class{constructor(e){var t;this._isLogsEnabled=!1,this._isLoaded=!1,this._logger=vr("[logs]"),this._queue=[],this._onReconnect=()=>{var e;null==(e=this._core)||e.onReconnect()},this._instance=e,this._instance&&null!=(t=this._instance.config.logs)&&t.captureConsoleLogs&&(this._isLogsEnabled=!0),ve&&Pr(ve,"online",this._onReconnect)}_getCore(){var e,t,i,r,s,n,o,a,l,u,c,d,_,h,p=null==(e=this._instance)||null==(e=e.config)?void 0:e.logs;return this._core&&this._resolvedFrom===p||(null==(t=this._core)||t.reset(),this._resolvedFrom=p,this._resolvedConfig=(u=null!==(r=null==(i=p)?void 0:i.flushIntervalMs)&&void 0!==r?r:3e3,c=null!==(s=null==i?void 0:i.maxBufferSize)&&void 0!==s?s:100,d=null!==(n=null==i?void 0:i.maxLogsPerInterval)&&void 0!==n?n:1e3,_=Math.max(c,d),{serviceName:null!==(o=null==(h=null==i?void 0:i.resourceAttributes)?void 0:h["service.name"])&&void 0!==o?o:null==i?void 0:i.serviceName,serviceVersion:null!==(a=null==h?void 0:h["service.version"])&&void 0!==a?a:null==i?void 0:i.serviceVersion,environment:null!==(l=null==h?void 0:h["deployment.environment"])&&void 0!==l?l:null==i?void 0:i.environment,resourceAttributes:h,beforeSend:null==i?void 0:i.beforeSend,flushIntervalMs:u,maxBufferSize:c,maxQueueSize:_,maxBatchRecordsPerPost:100,rateCapWindowMs:u,maxLogsPerInterval:d,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}),this._core=new Mi(this._createHost(),this._resolvedConfig,this._logger,(()=>this._getSdkContext()),(e=>e()))),this._core}_getResolvedConfig(){return this._getCore(),this._resolvedConfig}initialize(){this.loadIfEnabled()}onRemoteConfig(e){var t,i=null==(t=e.logs)?void 0:t.captureConsoleLogs;!rt(i)&&i&&(this._isLogsEnabled=!0,this.loadIfEnabled())}reset(){var e;this._queue=[],null==(e=this._core)||e.reset()}captureLog(e){this._getCore().captureLog(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){e?this._flushViaTransport(e):this._getCore().flush().catch((e=>this._logger.error("PostHog logs flush failed:",e)))}loadIfEnabled(){if(this._isLogsEnabled&&!this._isLoaded){var e=null==Pe?void 0:Pe.__PosthogExtensions__;if(e){var t=e.loadExternalDependency;t?t(this._instance,"logs",(t=>{var i;t||null==(i=e.logs)||!i.initializeLogs?this._logger.error("Could not load logs script",t):(e.logs.initializeLogs(this._instance),this._isLoaded=!0)})):this._logger.error(se)}else this._logger.error("PostHog Extensions not found.")}}_createHost(){var e=this._instance;return{get isDisabled(){return!1},get optedOut(){return!e.is_capturing()},getPersistedProperty:e=>e===Re.LogsQueue?this._queue:void 0,setPersistedProperty:(e,t)=>{var i;e===Re.LogsQueue&&(this._queue=null!==(i=t)&&void 0!==i?i:[])},_sendLogsBatch:e=>this._sendLogsBatch(e),getLibraryId:()=>n.LIB_NAME,getLibraryVersion:()=>n.LIB_VERSION}}_sendLogsBatch(e){return new Promise((t=>{var i=!1,r=e=>{i||(i=!0,clearTimeout(s),t(e))},s=setTimeout((()=>r({kind:"retry-later",error:new Error("logs request timed out")})),9e4);this._instance._send_request({method:"POST",url:this._logsUrl(),data:e,compression:"best-available",batchKey:"logs",fireCallbackOnDrop:!0,callback(e){var t=e.statusCode;if(t>=200&&300>t)r({kind:"ok"});else if(413===t)r({kind:"too-large"});else if(0!==t&&429!==t&&500>t)r({kind:"fatal",error:new Error("logs request failed with status "+t)});else{var i;r({kind:"retry-later",error:null!==(i=e.error)&&void 0!==i?i:new Error("logs request failed with status "+t)})}}})}))}_flushViaTransport(e){var t=this._getResolvedConfig();if(0!==this._queue.length){var i=this._queue.map((e=>e.record));this._queue=[];var r=Li(i,Ri(t,n.LIB_NAME,n.LIB_VERSION),n.LIB_NAME,n.LIB_VERSION);this._instance._send_request({method:"POST",url:this._logsUrl(),data:r,compression:"best-available",batchKey:"logs",transport:e})}}_logsUrl(){return this._instance.requestRouter.endpointFor("api","/i/v1/logs")+"?token="+encodeURIComponent(this._instance.config.token)}_getSdkContext(){var e,t={};if(t.distinctId=this._instance.get_distinct_id(),this._instance.sessionManager){var{sessionId:i}=this._instance.sessionManager.checkAndGetSessionAndWindowId(!0);t.sessionId=i}if(null!=Pe&&null!=(e=Pe.location)&&e.href&&(t.currentUrl=Pe.location.href),this._instance.featureFlags){var r=this._instance.featureFlags.getFlags();r&&r.length>0&&(t.activeFeatureFlags=r)}return t}}});ra.__defaultExtensionClasses=i({},rl),function(){n.SDK_DIST_CHANNEL="cdn";var e=Uo[Yo]=new ra,t=Pe.posthog;t&&mr(t._i,(function(i){if(i&&Qe(i)){var r=e.init(i[0],i[1],i[2]),s=t[i[2]]||t;r&&(r._execute_array.call(r.people,s.people),r._execute_array(s))}})),Pe.posthog=e,function(){function e(){e.done||(e.done=!0,Xo=!1,mr(Uo,(function(e){e._dom_loaded()})))}null!=ye&&ye.addEventListener?"complete"===ye.readyState?e():Pr(ye,"DOMContentLoaded",e,{capture:!1}):ve&&gr.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}()}()}();
|
|
2
2
|
//# sourceMappingURL=array.no-external.js.map
|