posthog-js 1.396.7 → 1.396.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/all-external-dependencies.js +1 -1
- package/dist/all-external-dependencies.js.map +1 -1
- package/dist/array.full.es5.js +1 -1
- package/dist/array.full.js +1 -1
- package/dist/array.full.js.map +1 -1
- package/dist/array.full.no-external.js +1 -1
- package/dist/array.full.no-external.js.map +1 -1
- package/dist/array.js +1 -1
- package/dist/array.no-external.js +1 -1
- package/dist/customizations.full.js +1 -1
- package/dist/default-extensions.js +1 -1
- package/dist/extension-bundles.js +1 -1
- package/dist/lazy-recorder.js +1 -1
- package/dist/logs.js +1 -1
- package/dist/logs.js.map +1 -1
- package/dist/main.js +1 -1
- package/dist/module.full.js +1 -1
- package/dist/module.full.js.map +1 -1
- package/dist/module.full.no-external.js +1 -1
- package/dist/module.full.no-external.js.map +1 -1
- package/dist/module.js +1 -1
- package/dist/module.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/lib/package.json +1 -1
- package/lib/src/entrypoints/logs.js +24 -2
- package/lib/src/entrypoints/logs.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function t(t,e,i,r,s,n,a){try{var o=t[n](a),l=o.value}catch(t){return void i(t)}o.done?e(l):Promise.resolve(l).then(r,s)}function e(e){return function(){var i=this,r=arguments;return new Promise((function(s,n){var a=e.apply(i,r);function o(e){t(a,s,n,o,l,"next",e)}function l(e){t(a,s,n,o,l,"throw",e)}o(void 0)}))}}function i(){return i=Object.assign?Object.assign.bind():function(t){for(var e=1;arguments.length>e;e++){var i=arguments[e];for(var r in i)({}).hasOwnProperty.call(i,r)&&(t[r]=i[r])}return t},i.apply(null,arguments)}var r="1.396.7",s="web",n=t=>{if("string"!=typeof t)return t;try{return JSON.parse(t)}catch(e){return t}};function a(t){return"string"==typeof t||t}function o(t){return"string"==typeof t?t:void 0}var l=function(t){return t.AnonymousId="anonymous_id",t.DistinctId="distinct_id",t.Props="props",t.EnablePersonProcessing="enable_person_processing",t.PersonMode="person_mode",t.FeatureFlagDetails="feature_flag_details",t.FeatureFlags="feature_flags",t.FeatureFlagPayloads="feature_flag_payloads",t.BootstrapFeatureFlagDetails="bootstrap_feature_flag_details",t.BootstrapFeatureFlags="bootstrap_feature_flags",t.BootstrapFeatureFlagPayloads="bootstrap_feature_flag_payloads",t.OverrideFeatureFlags="override_feature_flags",t.Queue="queue",t.LogsQueue="logs_queue",t.OptedOut="opted_out",t.SessionId="session_id",t.SessionStartTimestamp="session_start_timestamp",t.SessionLastTimestamp="session_timestamp",t.PersonProperties="person_properties",t.GroupProperties="group_properties",t.InstalledAppBuild="installed_app_build",t.InstalledAppVersion="installed_app_version",t.SessionReplay="session_replay",t.SessionReplayEventTriggerActivatedSession="session_replay_event_trigger_activated_session",t.SurveyLastSeenDate="survey_last_seen_date",t.SurveysSeen="surveys_seen",t.Surveys="surveys",t.RemoteConfig="remote_config",t.FlagsEndpointWasHit="flags_endpoint_was_hit",t.DeviceId="device_id",t}({}),u=["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"],h=function(t,e){if(void 0===e&&(e=[]),!t)return!1;var i=t.toLowerCase();return u.concat(e).some((t=>{var e=t.toLowerCase();return-1!==i.indexOf(e)}))};function v(t,e){return-1!==t.indexOf(e)}var d=function(t){return t.trim()},c=Object.prototype,f=c.hasOwnProperty,p=c.toString,g=Array.isArray||function(t){return"[object Array]"===p.call(t)},_=t=>"function"==typeof t,b=t=>t===Object(t)&&!g(t),m=t=>void 0===t,y=t=>"[object String]"==p.call(t),w=t=>null===t,x=t=>m(t)||w(t),E=t=>"[object Number]"==p.call(t)&&t==t,k=t=>"[object Boolean]"===p.call(t),S=t=>t instanceof FormData;function C(t){return null===t||"object"!=typeof t}function F(t,e){return{}.toString.call(t)==="[object "+e+"]"}function P(t){return"undefined"!=typeof Event&&function(t,e){try{return t instanceof e}catch(t){return!1}}(t,Event)}function R(t,e,i,r,s){return e>i&&(r.warn("min cannot be greater than max."),e=i),E(t)?t>i?(r.warn(" cannot be greater than max: "+i+". Using max value instead."),i):e>t?(r.warn(" cannot be less than min: "+e+". Using min value instead."),e):t:(r.warn(" must be a number. using max or fallback. max: "+i+", fallback: "+s),R(i,e,i,r))}class T{constructor(t){this.Ee={},this.Pe=t.Pe,this.Fe=R(t.bucketSize,0,100,t.Ae),this.$e=R(t.refillRate,0,this.Fe,t.Ae),this.De=R(t.refillInterval,0,864e5,t.Ae)}Ne(t,e){var i=Math.floor((e-t.lastAccess)/this.De);i>0&&(t.tokens=Math.min(t.tokens+i*this.$e,this.Fe),t.lastAccess=t.lastAccess+i*this.De)}consumeRateLimit(t){var e,i=Date.now(),r=String(t),s=this.Ee[r];return s?this.Ne(s,i):this.Ee[r]=s={tokens:this.Fe,lastAccess:i},0===s.tokens||(s.tokens--,0===s.tokens&&(null==(e=this.Pe)||e.call(this,t)),0===s.tokens)}stop(){this.Ee={}}}function A(t){return t?t.split("#")[0]:t}function I(t,e){var i=setTimeout(t,e);return(null==i?void 0:i.unref)&&(null==i||i.unref()),i}var O={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}},M=O.info;function j(t){if(k(t))return{boolValue:t};if("number"==typeof t)return Number.isFinite(t)?Number.isInteger(t)?{intValue:t}:{doubleValue:t}:{stringValue:String(t)};if("string"==typeof t)return{stringValue:t};if(g(t))return{arrayValue:{values:t.map((t=>j(t)))}};try{return{stringValue:JSON.stringify(t)}}catch(e){return{stringValue:String(t)}}}function L(t){var e=[];for(var i in t){var r=t[i];w(r)||m(r)||e.push({key:i,value:j(r)})}return e}function D(t,e){var r=t.level||"info",{text:s,number:n}=O[r]||M,a=String(Date.now())+"000000",o={};e.distinctId&&(o.posthogDistinctId=e.distinctId),e.sessionId&&(o.sessionId=e.sessionId),e.windowId&&(o["window.id"]=e.windowId),x(e.sessionStartTimestamp)||(o.sessionStartTimestamp=String(e.sessionStartTimestamp)),x(e.lastActivityTimestamp)||(o.lastActivityTimestamp=String(e.lastActivityTimestamp)),e.currentUrl&&(o["url.full"]=e.currentUrl),e.screenName&&(o["screen.name"]=e.screenName),e.appState&&(o["app.state"]=e.appState),e.activeFeatureFlags&&e.activeFeatureFlags.length>0&&(o.feature_flags=e.activeFeatureFlags);var l=i({},o,t.attributes||{}),u={timeUnixNano:a,observedTimeUnixNano:a,severityNumber:n,severityText:s,body:{stringValue:t.body},attributes:L(l)};return t.trace_id&&(u.traceId=t.trace_id),t.span_id&&(u.spanId=t.span_id),m(t.trace_flags)||(u.flags=t.trace_flags),u}function N(t,e,r){return i({},t.resourceAttributes,{"service.name":t.serviceName||"unknown_service"},t.environment&&{"deployment.environment":t.environment},t.serviceVersion&&{"service.version":t.serviceVersion},{"telemetry.sdk.name":e,"telemetry.sdk.version":r})}function z(t,e,i,r){return{resourceLogs:[{resource:{attributes:L(e)},scopeLogs:[{scope:{name:i,version:r},logRecords:t}]}]}}let U=class{constructor(t,e,i,r,s,n,a){var o;void 0===n&&(n=()=>Promise.resolve()),this._instance=t,this.Se=e,this.Ae=i,this.qe=r,this.Be=s,this.je=n,this.He=a,this.Ue=null,this.ze=0,this.Ve=0,this.We=0,this.Ge=0,this.Ze=!1,this.Qe=e.maxBufferSize,this.Je=Math.max(null!==(o=e.maxQueueSize)&&void 0!==o?o:e.maxBufferSize,e.maxBufferSize),this.Ye=e.flushIntervalMs,this.Ke=e.maxBatchRecordsPerPost,this.Xe=e.rateCapWindowMs,this.et=e.maxLogsPerInterval}reset(){this.tt(),this.Ue=null,this.We=0,this.Ge=0,this.Ze=!1,this.ze=0,this.Ve=0,this.Ke=this.Se.maxBatchRecordsPerPost}onReconnect(){this.Ve=0,this.rt()}captureLog(t){if(!this._instance.isDisabled&&!this._instance.optedOut&&null!=t&&t.body){var e=this.it(t);if(null!==e)if(e.body){if(this.nt()){var i={record:D(e,this.qe())};this.Be((()=>this.st(i)))}}else this.Ae.info("Log was rejected in beforeSend function")}}it(t){var e=this.Se.beforeSend;if(!e)return t;var i=g(e)?e:[e],r=t;for(var s of i)try{var n=s(r);if(!n)return this.Ae.info("Log was rejected in beforeSend function"),null;r=n}catch(t){return this.Ae.error("Error in beforeSend function for log:",t),null}return r}nt(){if(void 0===this.et)return!0;var t=Date.now(),e=t-this.We;return this.Xe>e&&e>=0||(this.We=t,this.Ge=0,this.Ze=!1),this.et>this.Ge?(this.Ge++,!0):(this.Ze||(this.Ae.warn("captureLog dropping logs: exceeded "+this.et+" logs per "+this.Xe+"ms"),this.Ze=!0),!1)}flush(){var t=this;return e((function*(){if(!t._instance.isDisabled)return t.Ue||(t.Ue=t.ot().finally((()=>{t.Ue=null}))),t.Ue}))()}ot(){var t=this;return e((function*(){var e;t.tt();var i=null!==(e=t._instance.getPersistedProperty(l.LogsQueue))&&void 0!==e?e:[];if(0!==i.length)for(var r=i.length,s=0;i.length>0&&r>s;){var n,a;t.ze=0;var o=Math.min(i.length,t.Ke),u=i.slice(0,o),h=z(u.map((t=>t.record)),t.ut(),null!==(n=t.He)&&void 0!==n?n:t._instance.getLibraryId(),t._instance.getLibraryVersion()),v=yield t._instance.ht(h);if("too-large"===v.kind&&u.length>1)t.Ke=Math.max(1,Math.floor(u.length/2)),t.Ae.warn("Received 413 when sending logs batch of size "+u.length+", reducing batch size to "+t.Ke);else{if("retry-later"===v.kind)throw v.error;if("too-large"===v.kind?t.Ae.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"===v.kind&&t.Se.maxBatchRecordsPerPost>t.Ke&&(t.Ke=Math.min(t.Se.maxBatchRecordsPerPost,t.Ke+1)),yield t.dt(u.length),i=null!==(a=t._instance.getPersistedProperty(l.LogsQueue))&&void 0!==a?a:[],s+=u.length,"fatal"===v.kind)throw v.error}}}))()}dt(t){var i=this;return e((function*(){var e,r=Math.max(0,t-i.ze),s=null!==(e=i._instance.getPersistedProperty(l.LogsQueue))&&void 0!==e?e:[];i._instance.setPersistedProperty(l.LogsQueue,s.slice(r)),yield i.je()}))()}ut(){return N(this.Se,this._instance.getLibraryId(),this._instance.getLibraryVersion())}st(t){var e;if(!this._instance.optedOut){var i=null!==(e=this._instance.getPersistedProperty(l.LogsQueue))&&void 0!==e?e:[];this.Je>i.length||(i.shift(),this.ze++,this.Ae.info("Logs queue is full, dropping oldest record.")),i.push(t),this._instance.setPersistedProperty(l.LogsQueue,i),this.Qe>i.length?this.ct():this.rt()}}ct(t){void 0===t&&(t=this.Ye),this.vt||(this.vt=I((()=>{this.vt=void 0,this.rt()}),t))}ft(){var t=Math.min(Math.max(0,this.Ve-1),6);return this.Ye*Math.pow(2,t)}yt(){var t=this._instance.getPersistedProperty(l.LogsQueue);return!!t&&t.length>0}shutdown(t){var i=this;return e((function*(){i.tt();var e=i.flush().catch((()=>{}));void 0!==t?yield Promise.race([e,new Promise((e=>I(e,t)))]):yield e}))()}flushWithTimeout(t){var i=this;return e((function*(){var e=!1,r=i.flush(),s=new Promise((i=>I((()=>{e=!0,i()}),t)));try{yield Promise.race([r,s])}finally{e&&r.catch((()=>{}))}}))()}rt(){this.flush().then((()=>{this.Ve=0}),(t=>{this.Ve++,this.Ae.error("PostHog logs flush failed:",t)})).finally((()=>{!this._instance.isDisabled&&this.yt()&&this.ct(this.ft())}))}tt(){this.vt&&(clearTimeout(this.vt),this.vt=void 0)}};var H,V,B;function q(t){var e=globalThis._posthogChunkIds;if(e){var i=Object.keys(e);return B&&i.length===V?B:(V=i.length,B=i.reduce(((i,r)=>{H||(H={});var s=H[r];if(s)i[s[0]]=s[1];else for(var n=t(r),a=n.length-1;a>=0;a--){var o=n[a],l=null==o?void 0:o.filename,u=e[r];if(l&&u){i[l]=u,H[r]=[l,u];break}}return i}),{}))}}class W{constructor(t,e,i){void 0===i&&(i=[]),this.coercers=t,this.stackParser=e,this.modifiers=i}buildFromUnknown(t,e){void 0===e&&(e={});var i=e&&e.mechanism||{handled:!0,type:"generic"},r=this.buildCoercingContext(i,e,0).apply(t),s=this.buildParsingContext(e),n=this.parseStacktrace(r,s);return{$exception_list:this.convertToExceptionList(n,i),$exception_level:"error"}}modifyFrames(t){var i=this;return e((function*(){for(var e of t)e.stacktrace&&e.stacktrace.frames&&g(e.stacktrace.frames)&&(e.stacktrace.frames=yield i.applyModifiers(e.stacktrace.frames));return t}))()}coerceFallback(t){var e;return{type:"Error",value:"Unknown error",stack:null==(e=t.syntheticException)?void 0:e.stack,synthetic:!0}}parseStacktrace(t,e){var r,s;return null!=t.cause&&(r=this.parseStacktrace(t.cause,e)),""!=t.stack&&null!=t.stack&&(s=this.applyChunkIds(this.stackParser(t.stack,t.synthetic?e.skipFirstLines:0),e.chunkIdMap)),i({},t,{cause:r,stack:s})}applyChunkIds(t,e){return t.map((t=>(t.filename&&e&&(t.chunk_id=e[t.filename]),t)))}applyCoercers(t,e){for(var i of this.coercers)if(i.match(t))return i.coerce(t,e);return this.coerceFallback(e)}applyModifiers(t){var i=this;return e((function*(){var e=t;for(var r of i.modifiers)e=yield r(e);return e}))()}convertToExceptionList(t,e){var r,s,n,a={type:t.type,value:t.value,mechanism:{type:null!==(r=e.type)&&void 0!==r?r:"generic",handled:null===(s=e.handled)||void 0===s||s,synthetic:null!==(n=t.synthetic)&&void 0!==n&&n}};t.stack&&(a.stacktrace={type:"raw",frames:t.stack});var o=[a];return null!=t.cause&&o.push(...this.convertToExceptionList(t.cause,i({},e,{handled:!0}))),o}buildParsingContext(t){var e;return{chunkIdMap:q(this.stackParser),skipFirstLines:null!==(e=t.skipFirstLines)&&void 0!==e?e:1}}buildCoercingContext(t,e,r){void 0===r&&(r=0);var s=(i,r)=>{if(4>=r){var s=this.buildCoercingContext(t,e,r);return this.applyCoercers(i,s)}};return i({},e,{syntheticException:0==r?e.syntheticException:void 0,mechanism:t,apply:t=>s(t,r),next:t=>s(t,r+1)})}}var J="?";function K(t,e,i,r,s){var n={platform:t,filename:e,function:"<anonymous>"===i?J:i,in_app:!0};return m(r)||(n.lineno=r),m(s)||(n.colno=s),n}var G=(t,e)=>{var i=-1!==t.indexOf("safari-extension"),r=-1!==t.indexOf("safari-web-extension");return i||r?[-1!==t.indexOf("@")?t.split("@")[0]:J,i?"safari-extension:"+e:"safari-web-extension:"+e]:[t,e]},Y=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,Q=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,Z=/\((\S*)(?::(\d+))(?::(\d+))\)/,X=(t,e)=>{var i=Y.exec(t);if(i){var[,r,s,n]=i;return K(e,r,J,+s,+n)}var a=Q.exec(t);if(a){if(a[2]&&0===a[2].indexOf("eval")){var o=Z.exec(a[2]);o&&(a[2]=o[1],a[3]=o[2],a[4]=o[3])}var[l,u]=G(a[1]||J,a[2]);return K(e,u,l,a[3]?+a[3]:void 0,a[4]?+a[4]:void 0)}},tt=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,et=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,it=(t,e)=>{var i=tt.exec(t);if(i){if(i[3]&&i[3].indexOf(" > eval")>-1){var r=et.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]||J;return[n,s]=G(n,s),K(e,s,n,i[4]?+i[4]:void 0,i[5]?+i[5]:void 0)}},rt=/\(error: (.*)\)/;class st{match(t){return this.isDOMException(t)||this.isDOMError(t)}coerce(t,e){var i=y(t.stack);return{type:this.getType(t),value:this.getValue(t),stack:i?t.stack:void 0,cause:t.cause?e.next(t.cause):void 0,synthetic:!1}}getType(t){return this.isDOMError(t)?"DOMError":"DOMException"}getValue(t){var e=t.name||(this.isDOMError(t)?"DOMError":"DOMException");return t.message?e+": "+t.message:e}isDOMException(t){return F(t,"DOMException")}isDOMError(t){return F(t,"DOMError")}}class nt{match(t){return t instanceof Error}coerce(t,e){return{type:this.getType(t),value:this.getMessage(t,e),stack:this.getStack(t),cause:t.cause?e.next(t.cause):void 0,synthetic:!1}}getType(t){return t.name||t.constructor.name}getMessage(t,e){var i=t.message;return String(i.error&&"string"==typeof i.error.message?i.error.message:i)}getStack(t){return t.stacktrace||t.stack||void 0}}class at{constructor(){}match(t){return F(t,"ErrorEvent")&&null!=t.error}coerce(t,e){var i;return e.apply(t.error)||{type:"ErrorEvent",value:t.message,stack:null==(i=e.syntheticException)?void 0:i.stack,synthetic:!0}}}var ot=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;class lt{match(t){return"string"==typeof t}coerce(t,e){var i,[r,s]=this.getInfos(t);return{type:null!=r?r:"Error",value:null!=s?s:t,stack:null==(i=e.syntheticException)?void 0:i.stack,synthetic:!0}}getInfos(t){var e="Error",i=t,r=t.match(ot);return r&&(e=r[1],i=r[2]),[e,i]}}var ut=["fatal","error","warning","log","info","debug"];function ht(t,e){void 0===e&&(e=40);var i=Object.keys(t);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(e>=s.length)return r===i.length?s:s.length>e?s.slice(0,e)+"...":s}return""}class vt{match(t){return"object"==typeof t&&null!==t}coerce(t,e){var i,r=this.getErrorPropertyFromObject(t);return r?e.apply(r):{type:this.getType(t),value:this.getValue(t),stack:null==(i=e.syntheticException)?void 0:i.stack,level:this.isSeverityLevel(t.level)?t.level:"error",synthetic:!0}}getType(t){return P(t)?t.constructor.name:"Error"}getValue(t){if("name"in t&&"string"==typeof t.name){var e="'"+t.name+"' captured as exception";return"message"in t&&"string"==typeof t.message&&(e+=" with message: '"+t.message+"'"),e}if("message"in t&&"string"==typeof t.message)return t.message;var i=this.getObjectClassName(t);return(i&&"Object"!==i?"'"+i+"'":"Object")+" captured as exception with keys: "+ht(t)}isSeverityLevel(t){return y(t)&&!(t=>y(t)&&0===t.trim().length)(t)&&ut.indexOf(t)>=0}getErrorPropertyFromObject(t){for(var e in t)if({}.hasOwnProperty.call(t,e)){var i=t[e];if(i instanceof Error)return i}}getObjectClassName(t){try{var e=Object.getPrototypeOf(t);return e?e.constructor.name:void 0}catch(t){return}}}class dt{match(t){return P(t)}coerce(t,e){var i,r=t.constructor.name;return{type:r,value:r+" captured as exception with keys: "+ht(t),stack:null==(i=e.syntheticException)?void 0:i.stack,synthetic:!0}}}class ct{match(t){return C(t)}coerce(t,e){var i;return{type:"Error",value:"Primitive value captured as exception: "+String(t),stack:null==(i=e.syntheticException)?void 0:i.stack,synthetic:!0}}}class ft{match(t){return F(t,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(t)}isCustomEventWrappingRejection(t){if(!P(t))return!1;try{var e=t.detail;return null!=e&&"object"==typeof e&&"reason"in e}catch(t){return!1}}coerce(t,e){var i,r=this.getUnhandledRejectionReason(t);return C(r)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(r),stack:null==(i=e.syntheticException)?void 0:i.stack,synthetic:!0}:e.apply(r)}getUnhandledRejectionReason(t){try{if("reason"in t)return t.reason;if("detail"in t&&null!=t.detail&&"object"==typeof t.detail&&"reason"in t.detail)return t.detail.reason}catch(t){}return t}}var pt="$message",gt="$timestamp",_t=new Set([pt,gt]),bt={enabled:!0,max_bytes:32768};function mt(t){var e;return t?{enabled:null!==(e=t.enabled)&&void 0!==e?e:bt.enabled,max_bytes:wt(t.max_bytes,bt.max_bytes)}:i({},bt)}class yt{constructor(t){this.bt=[],this._t=0,this.Se=mt(t)}setConfig(t){this.Se=mt(t),this.wt()}add(t){var e=function(t){var e,i,r;try{r=[],e=null!==(i=JSON.stringify(t,(function(t,e){if("bigint"==typeof e)return e.toString();if("function"!=typeof e&&"symbol"!=typeof e){if(e instanceof Error)return{name:e.name,message:e.message,stack:e.stack};if(e&&"object"==typeof e){for(;r.length>0&&r[r.length-1]!==this;)r.pop();if(r.includes(e))return"[Circular]";r.push(e)}return e}})))&&void 0!==i?i:"null"}catch(t){return}try{var s=JSON.parse(e);if(!b(s))return;var n=s,a=n[pt],o=n[gt];if(!y(a)||0===a.trim().length)return;if(!y(o)&&!E(o))return;return{step:n,json:e}}catch(t){return}}(t);if(e){var i=function(t){if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(t).length;for(var e=encodeURIComponent(t),i=0,r=0;e.length>r;r++)"%"===e[r]?(i+=1,r+=2):i+=1;return i}(e.json);i>this.Se.max_bytes||(this.bt.push({step:e.step,bytes:i}),this._t+=i,this.wt())}}getAttachable(){return this.bt.map((t=>t.step))}clear(){this.bt=[],this._t=0}size(){return this.bt.length}wt(){for(;this._t>this.Se.max_bytes&&this.bt.length>0;){var t=this.bt.shift();t&&(this._t-=t.bytes)}}}function wt(t,e){if(!E(t)||t===1/0||t===-1/0)return e;var i=Math.floor(t);return 0>i?e:i}var xt="undefined"!=typeof window?window:void 0,Et="undefined"!=typeof globalThis?globalThis:xt;"undefined"==typeof self&&(Et.self=Et),"undefined"==typeof File&&(Et.File=function(){});var kt=null==Et?void 0:Et.navigator,St=null==Et?void 0:Et.document,Ct=null==Et?void 0:Et.location;null!=Et&&Et.XMLHttpRequest&&new Et.XMLHttpRequest;var Ft=null!=xt?xt:{};function Pt(){return!(!xt||!1===xt.navigator.onLine)}var Rt=function(t,e){var{debugEnabled:i}=void 0===e?{}:e,r={k(e){if(xt&&(Ft.POSTHOG_DEBUG||i)&&!m(xt.console)&&xt.console){for(var r=("__rrweb_original__"in xt.console[e]?xt.console[e].__rrweb_original__:xt.console[e]),s=arguments.length,n=new Array(s>1?s-1:0),a=1;s>a;a++)n[a-1]=arguments[a];r(t,...n)}},debug(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];r.k("debug",...e)},info(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];r.k("log",...e)},warn(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];r.k("warn",...e)},error(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];r.k("error",...e)},critical(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];console.error(t,...i)},uninitializedWarning(t){r.error("You must initialize PostHog before calling "+t)},createLogger:(e,i)=>Rt(t+" "+e,i)};return r},Tt=Rt("[PostHog.js]"),At=Tt.createLogger;function It(t,e){if(!x(t))if(g(t))t.forEach(e);else if(S(t))t.forEach(((t,i)=>e(t,i)));else for(var i in t)f.call(t,i)&&e(t[i],i)}var $t=function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;e>r;r++)i[r-1]=arguments[r];for(var s of i)for(var n in s)void 0!==s[n]&&(t[n]=s[n]);return t};function Ot(t){for(var e=Object.keys(t),i=e.length,r=new Array(i);i--;)r[i]=[e[i],t[e[i]]];return r}var Mt=function(t){try{return t()}catch(t){return}};function jt(t,e,i,r){var{capture:s=!1,passive:n=!0}=null!=r?r:{};null==t||t.addEventListener(e,i,{capture:s,passive:n})}function Lt(t){return"ph_toolbar_internal"===t.name}function Dt(t,e){var i,r=null==t||null==(i=t.config)?void 0:i.get_current_url;if(!_(r))return e;try{var s=r(e);return y(s)&&s?s:e}catch(t){return Tt.error("Error in get_current_url, falling back to window.location.href",t),e}}var Nt="$autocapture_disabled_server_side",zt="$heatmaps_enabled_server_side",Ut="$exception_capture_enabled_server_side",Ht="$error_tracking_suppression_rules",Vt="$error_tracking_capture_extension_exceptions",Bt="$web_vitals_enabled_server_side",qt="$product_tours_enabled_server_side",Wt="$web_vitals_allowed_metrics",Jt="$session_recording_remote_config",Kt="$enabled_feature_flags",Gt="$active_feature_flags",Yt="$early_access_features",Qt="$feature_flag_details",Zt="$feature_flag_payloads",Xt="$feature_flag_request_id",te="$override_feature_flags",ee="$override_feature_flag_payloads",ie="$stored_person_properties",re="$stored_group_properties",se="$surveys",ne="$surveys_loaded_at",ae="$surveys_activated",oe="ph_product_tours",le="$flag_call_reported",ue="$flag_call_reported_session_id",he="$feature_flag_errors",ve="$feature_flag_evaluated_at",de="__POSTHOG_TOOLBAR__",ce="PostHog loadExternalDependency extension not found.",fe="visibilitychange",pe="beforeunload",ge=1,_e=3,be=11;function me(t){return t instanceof Element&&(t.id===de||!(null==t.closest||!t.closest(".toolbar-global-fade-container")))}function ye(t){return!!t&&t.nodeType===ge}function we(t,e){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===e.toLowerCase()}function xe(t){return!!t&&t.nodeType===_e}function Ee(t){return!!t&&t.nodeType===be&&ye(t.host)}function ke(t){return t?d(t).split(/\s+/):[]}function Se(t,e){var i=function(t){var e,i=null==xt||null==(e=xt.location)?void 0:e.href;return m(i)?void 0:Dt(t,i)}(e);return!!(i&&t&&t.some((t=>i.match(t))))}function Ce(t){var e="";switch(typeof t.className){case"string":e=t.className;break;case"object":e=(t.className&&"baseVal"in t.className?t.className.baseVal:null)||t.getAttribute("class")||"";break;default:e=""}return ke(e)}function Fe(t){return x(t)?null:d(t).split(/(\s+)/).filter((t=>Ge(t))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Pe(t){var e="";return Ue(t)&&!He(t)&&t.childNodes&&t.childNodes.length&&It(t.childNodes,(function(t){var i;xe(t)&&t.textContent&&(e+=null!==(i=Fe(t.textContent))&&void 0!==i?i:"")})),d(e)}function Re(t){return m(t.target)?t.srcElement||null:null!=(e=t.target)&&e.shadowRoot?t.composedPath()[0]||null:t.target||null;var e}var Te=["a","button","form","input","select","textarea","label"];function Ae(t,e){if(m(e))return!0;var i,r=function(t){if(e.some((e=>function(t,e){var i=t.matches||t.matchesSelector||t.msMatchesSelector||t.mozMatchesSelector||t.webkitMatchesSelector||t.oMatchesSelector;try{return!!i&&i.call(t,e)}catch(t){return!1}}(t,e))))return{v:!0}};for(var s of t)if(i=r(s))return i.v;return!1}function Ie(t){var e=t.parentNode;return!(!e||!ye(e))&&e}var $e=[".ph-no-autocapture","[data-ph-no-autocapture]"],Oe=["next","previous","prev",">","<"],Me=(t,e)=>/[a-z0-9]/i.test(e)?t.includes(e):t===e,je=[".ph-no-rageclick",".ph-no-capture"],Le=["","text","search","email","password","url","tel","number"];function De(t,e){if(!xt||Ne(t))return!1;var i,r,s,n,a;if(k(e)?(i=!!e&&je,r=void 0,s=!1):(i=null!==(n=null==e?void 0:e.css_selector_ignorelist)&&void 0!==n?n:je,r=null==e?void 0:e.content_ignorelist,s=null!==(a=null==e?void 0:e.ignore_text_selection)&&void 0!==a&&a),!1===i)return!1;if(s&&function(t){return!(!t||!ye(t))&&(!!we(t,"textarea")||(we(t,"input")?v(Le,(t.getAttribute("type")||"").toLowerCase()):function(t){if(t.isContentEditable)return!0;var e=null==t.getAttribute?void 0:t.getAttribute("contenteditable");return"true"===e||""===e}(t)))}(t))return!1;var{targetElementList:o}=ze(t,!1);return!function(t,e){if(!1===t||m(t))return!1;var i;if(!0===t)i=Oe;else{if(!g(t))return!1;if(t.length>10)return Tt.error("[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching."),!1;i=t.map((t=>t.toLowerCase()))}return e.some((t=>{var{safeText:e,ariaLabel:r}=t;return i.some((t=>Me(e,t)||Me(r,t)))}))}(r,o.map((t=>{var e;return{safeText:Pe(t).toLowerCase(),ariaLabel:(null==(e=t.getAttribute("aria-label"))?void 0:e.toLowerCase().trim())||""}})))&&!Ae(o,i)}var Ne=t=>!t||we(t,"html")||!ye(t),ze=(t,e)=>{if(!xt||Ne(t))return{parentIsUsefulElement:!1,targetElementList:[]};for(var i=!1,r=[t],s=t;s.parentNode&&!we(s,"body");)if(Ee(s.parentNode))r.push(s.parentNode.host),s=s.parentNode.host;else{var n=Ie(s);if(!n)break;if(e||Te.indexOf(n.tagName.toLowerCase())>-1)i=!0;else try{var a=xt.getComputedStyle(n);a&&"pointer"===a.getPropertyValue("cursor")&&(i=!0)}catch(t){}r.push(n),s=n}return{parentIsUsefulElement:i,targetElementList:r}};function Ue(t){for(var e=t;e.parentNode&&!we(e,"body");e=e.parentNode){var i=Ce(e);if(v(i,"ph-sensitive")||v(i,"ph-no-capture"))return!1}if(v(Ce(t),"ph-include"))return!0;var r=t.type||"";if(y(r))switch(r.toLowerCase()){case"hidden":case"password":return!1}var s=t.name||t.id||"";return!y(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 He(t){return!!(we(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||we(t,"select")||we(t,"textarea")||"true"===t.getAttribute("contenteditable"))}var Ve="(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})",Be=new RegExp("^(?:"+Ve+")$"),qe=new RegExp(Ve),We="\\d{3}-?\\d{2}-?\\d{4}",Je=new RegExp("^("+We+")$"),Ke=new RegExp("("+We+")");function Ge(t,e){if(void 0===e&&(e=!0),x(t))return!1;if(y(t)){if(t=d(t),(e?Be:qe).test((t||"").replace(/[- ]/g,"")))return!1;if((e?Je:Ke).test(t))return!1}return!0}function Ye(t){var e=Pe(t);return Ge(e=(e+" "+Qe(t)).trim())?e:""}function Qe(t){var e="";return t&&t.childNodes&&t.childNodes.length&&It(t.childNodes,(function(t){var i;if(t&&"span"===(null==(i=t.tagName)?void 0:i.toLowerCase()))try{var r=Pe(t);e=(e+" "+r).trim(),t.childNodes&&t.childNodes.length&&(e=(e+" "+Qe(t)).trim())}catch(t){Tt.error("[AutoCapture]",t)}})),e}function Ze(t){return t.replace(/"|\\"/g,'\\"')}function Xe(t){var e=t.attr__class;return e?g(e)?e:ke(e):void 0}class ti{constructor(t){this.disabled=!1===t;var e=b(t)?t:{};this.thresholdPx=e.threshold_px||30,this.timeoutMs=e.timeout_ms||1e3,this.clickCount=e.click_count||3,this.clicks=[]}isRageClick(t,e,i){if(this.disabled)return!1;var r=this.clicks[this.clicks.length-1];if(r&&Math.abs(t-r.x)+Math.abs(e-r.y)<this.thresholdPx&&this.timeoutMs>i-r.timestamp){if(this.clicks.push({x:t,y:e,timestamp:i}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:t,y:e,timestamp:i}];return!1}}var ei=function(t,e){for(var i,r=((t.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),s=0;r.length>s;s++){var n=r[s].split("=");if(n[0]===e){i=n;break}}if(!g(i)||2>i.length)return"";var a=i[1];try{a=decodeURIComponent(a)}catch(t){Tt.error("Skipping decoding for malformed query param: "+a)}return a.replace(/\+/g," ")},ii=function(t,e,i){if(!t||!e||!e.length)return t;for(var r=t.split("#"),s=r[1],n=(r[0]||"").split("?"),a=n[1],o=n[0],l=(a||"").split("&"),u=[],h=0;l.length>h;h++){var v=l[h].split("=");g(v)&&(e.includes(v[0])?u.push(v[0]+"="+i):u.push(l[h]))}var d=o;return null!=a&&(d+="?"+u.join("&")),null!=s&&(d+="#"+s),d},ri=function(t,e){var i=t.match(new RegExp(e+"=([^&]*)"));return i?i[1]:null},si="$copy_autocapture",ni=At("[AutoCapture]");function ai(t,e){return e.length>t?e.slice(0,t)+"...":e}function oi(t){if(t.previousElementSibling)return t.previousElementSibling;var e=t;do{e=e.previousSibling}while(e&&!ye(e));return e}function li(t,e){var r,s,{e:n,maskAllElementAttributes:a,maskAllText:o,elementAttributeIgnoreList:l,elementsChainAsString:u,disableCaptureUrlHashes:h}=e;if(!ye(t))return{props:{}};for(var d=[t],c=t;c.parentNode&&!we(c,"body");)if(Ee(c.parentNode))d.push(c.parentNode.host),c=c.parentNode.host;else{if(!ye(c.parentNode))break;d.push(c.parentNode),c=c.parentNode}var f,p,g=[],_={},b=!1,w=!1;if(It(d,(t=>{var e=Ue(t);if(we(t,"a")){var i=t.getAttribute("href");b=!!(e&&i&&Ge(i))&&(h?A(i):i)}v(Ce(t),"ph-no-capture")&&(w=!0),g.push(function(t,e,i,r,s){void 0===s&&(s=!1);var n=t.tagName.toLowerCase(),a={tag_name:n};Te.indexOf(n)>-1&&!i&&(a.$el_text="a"===n.toLowerCase()||"button"===n.toLowerCase()?ai(1024,Ye(t)):ai(1024,Pe(t)));var o=Ce(t);o.length>0&&(a.classes=o.filter((function(t){return""!==t}))),It(t.attributes,(function(i){var n;if((!He(t)||-1!==["name","id","class","aria-label"].indexOf(i.name))&&(null==r||!r.includes(i.name))&&!e&&Ge(i.value)&&(!y(n=i.name)||"_ngcontent"!==n.substring(0,10)&&"_nghost"!==n.substring(0,7))){var o=i.value;"class"===i.name&&(o=ke(o).join(" ")),a["attr__"+i.name]=ai(1024,"href"===i.name&&s?A(o):o)}}));for(var l=1,u=1,h=t;h=oi(h);)l++,h.tagName===t.tagName&&u++;return a.nth_child=l,a.nth_of_type=u,a}(t,a,o,l,h));var r=function(t){if(!Ue(t))return{};var e={};return It(t.attributes,(function(t){if(t.name&&0===t.name.indexOf("data-ph-capture-attribute")){var i=t.name.replace("data-ph-capture-attribute-",""),r=t.value;i&&r&&Ge(r)&&(e[i]=r)}})),e}(t);$t(_,r)})),w)return{props:{},explicitNoCapture:w};if(o||(g[0].$el_text=we(t,"a")||we(t,"button")?Ye(t):Pe(t)),b){var x,E;g[0].attr__href=b;var k=null==(x=(t=>{var e=null==St?void 0:St.createElement("a");return m(e)?null:(e.href=t,e)})(b))?void 0:x.host,S=null==xt||null==(E=xt.location)?void 0:E.host;k&&S&&k!==S&&(f=b)}return{props:$t({$event_type:n.type,$ce_version:1},u?{}:{$elements:g},{$elements_chain:(p=g,function(t){return t.map((t=>{var e,r,s="";if(t.tag_name&&(s+=t.tag_name),t.attr_class)for(var n of(t.attr_class.sort(),t.attr_class))s+="."+n.replace(/"/g,"");var a=i({},t.text?{text:t.text}:{},{"nth-child":null!==(e=t.nth_child)&&void 0!==e?e:0,"nth-of-type":null!==(r=t.nth_of_type)&&void 0!==r?r:0},t.href?{href:t.href}:{},t.attr_id?{attr_id:t.attr_id}:{},t.attributes),o={};return Ot(a).sort(((t,e)=>{var[i]=t,[r]=e;return i.localeCompare(r)})).forEach((t=>{var[e,i]=t;return o[Ze(e.toString())]=Ze(i.toString())})),(s+=":")+Ot(o).map((t=>{var[e,i]=t;return e+'="'+i+'"'})).join("")})).join(";")}(function(t){return t.map((t=>{var e,i,r={text:null==(e=t.$el_text)?void 0:e.slice(0,400),tag_name:t.tag_name,href:null==(i=t.attr__href)?void 0:i.slice(0,2048),attr_class:Xe(t),attr_id:t.attr__id,nth_child:t.nth_child,nth_of_type:t.nth_of_type,attributes:{}};return Ot(t).filter((t=>{var[e]=t;return 0===e.indexOf("attr__")})).forEach((t=>{var[e,i]=t;return r.attributes[e]=i})),r}))}(p)))},null!=(r=g[0])&&r.$el_text?{$el_text:null==(s=g[0])?void 0:s.$el_text}:{},f&&"click"===n.type?{$external_click_url:f}:{},_)}}var ui=At("[Dead Clicks]"),hi=()=>!0;class vi{get lazyLoadedDeadClicksAutocapture(){return this.Et}constructor(t,e,i){this.instance=t,this.isEnabled=e,this.onCapture=i,this.startIfEnabledOrStop()}onRemoteConfig(t){"captureDeadClicks"in t&&(this.instance.persistence&&this.instance.persistence.register({$dead_clicks_enabled_server_side:t.captureDeadClicks}),this.startIfEnabledOrStop())}startIfEnabledOrStop(){this.isEnabled(this)?this.Mt((()=>{this.Pt()})):this.stop()}Mt(t){var e,i;null!=(e=Ft.__PosthogExtensions__)&&e.initDeadClicksAutocapture?t():null==(i=Ft.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this.instance,"dead-clicks-autocapture",(e=>{e?ui.error("failed to load script",e):t()}))}Pt(){var t;if(St){if(!this.Et&&null!=(t=Ft.__PosthogExtensions__)&&t.initDeadClicksAutocapture){var e=b(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};e.__onCapture=this.onCapture,this.Et=Ft.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,e),this.Et.start(St),ui.info("starting...")}}else ui.error("`document` not found. Cannot start.")}stop(){this.Et&&(this.Et.stop(),this.Et=void 0,ui.info("stopping..."))}}var di=At("[ExceptionAutocapture]"),ci=At("[TracingHeaders]");Math.trunc||(Math.trunc=function(t){return 0>t?Math.ceil(t):Math.floor(t)}),Number.isInteger||(Number.isInteger=function(t){return E(t)&&isFinite(t)&&Math.floor(t)===t});class fi{constructor(t){if(this.bytes=t,16!==t.length)throw new TypeError("not 128-bit length")}static fromFieldsV7(t,e,i,r){if(!Number.isInteger(t)||!Number.isInteger(e)||!Number.isInteger(i)||!Number.isInteger(r)||0>t||0>e||0>i||0>r||t>0xffffffffffff||e>4095||i>1073741823||r>4294967295)throw new RangeError("invalid field value");var s=new Uint8Array(16);return s[0]=t/Math.pow(2,40),s[1]=t/Math.pow(2,32),s[2]=t/Math.pow(2,24),s[3]=t/Math.pow(2,16),s[4]=t/Math.pow(2,8),s[5]=t,s[6]=112|e>>>8,s[7]=e,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 fi(s)}toString(){for(var t="",e=0;this.bytes.length>e;e++)t=t+(this.bytes[e]>>>4).toString(16)+(15&this.bytes[e]).toString(16),3!==e&&5!==e&&7!==e&&9!==e||(t+="-");if(36!==t.length)throw new Error("Invalid UUIDv7 was generated");return t}clone(){return new fi(this.bytes.slice(0))}equals(t){return 0===this.compareTo(t)}compareTo(t){for(var e=0;16>e;e++){var i=this.bytes[e]-t.bytes[e];if(0!==i)return Math.sign(i)}return 0}}class pi{constructor(){this.S=0,this.C=0,this.I=new bi}generate(){var t=this.generateOrAbort();if(m(t)){this.S=0;var e=this.generateOrAbort();if(m(e))throw new Error("Could not generate UUID after timestamp reset");return e}return t}generateOrAbort(){var t=Date.now();if(t>this.S)this.S=t,this.M();else{if(this.S>=t+1e4)return;this.C++,this.C>4398046511103&&(this.S++,this.M())}return fi.fromFieldsV7(this.S,Math.trunc(this.C/Math.pow(2,30)),this.C&Math.pow(2,30)-1,this.I.nextUint32())}M(){this.C=1024*this.I.nextUint32()+(1023&this.I.nextUint32())}}var gi,_i=t=>{if("undefined"!=typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var e=0;t.length>e;e++)t[e]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return t};xt&&!m(xt.crypto)&&crypto.getRandomValues&&(_i=t=>crypto.getRandomValues(t));class bi{constructor(){this.R=new Uint32Array(8),this.O=1/0}nextUint32(){return this.R.length>this.O||(_i(this.R),this.O=0),this.R[this.O++]}}var mi=()=>(gi||(gi=new pi)).generate(),yi="",wi=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;function xi(t,e){if(e){var i=function(t,e){if(void 0===e&&(e=St),yi)return yi;if(!e)return"";if(["localhost","127.0.0.1"].includes(t))return"";for(var i=t.split("."),r=Math.min(i.length,8),s="dmn_chk_"+mi().toString();!yi&&r--;){var n=i.slice(r).join("."),a=s+"=1;domain=."+n+";path=/";e.cookie=a+";max-age=3",e.cookie.includes(s)&&(e.cookie=a+";max-age=0",yi=n)}return yi}(t);if(!i){var r=(t=>{var e=t.match(wi);return e?e[0]:""})(t);r!==i&&Tt.info("Warning: cookie subdomain discovery mismatch",r,i),i=r}return i?"; domain=."+i:""}return""}var Ei={N:()=>!!St,D(t){Tt.error("cookieStore error: "+t)},A(t){if(St){try{for(var e=t+"=",i=St.cookie.split(";").filter((t=>t.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(e))return decodeURIComponent(s.substring(e.length,s.length))}}catch(t){}return null}},F(t){var e;try{e=JSON.parse(Ei.A(t))||{}}catch(t){}return e},q(t,e,i,r,s){if(!St)return!1;try{var n="",a="",o=xi(St.location.hostname,r);if(i){var l=new Date;l.setTime(l.getTime()+864e5*i),n="; expires="+l.toUTCString()}s&&(a="; secure");var u=t+"="+encodeURIComponent(JSON.stringify(e))+n+"; SameSite=Lax; path=/"+o+a;return u.length>3686.4&&Tt.warn("cookieStore warning: large cookie, len="+u.length),St.cookie=u,!0}catch(t){return!1}},P(t,e){if(null!=St&&St.cookie)try{Ei.q(t,"",-1,e)}catch(t){return}}},ki=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],Si=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...ki],Ci="<masked>",Fi=["li_fat_id"];function Pi(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(t){return}}var Ri=At("[Web Vitals]"),Ti=9e5,Ai=At("[RemoteConfig]");class Ii{constructor(t){this._instance=t}get remoteConfig(){var t;return null==(t=Ft._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.config}cr(t){var e,i;null!=(e=Ft.__PosthogExtensions__)&&e.loadExternalDependency?null==(i=Ft.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"remote-config",(()=>t(this.remoteConfig))):t()}vr(t){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback(e){t(e.json)}})}load(){try{if(this.remoteConfig)return Ai.info("Using preloaded remote config",this.remoteConfig),this.pr(this.remoteConfig),void this.gr();if(this._instance.mr())return void Ai.warn("Remote config is disabled. Falling back to local config.");this.cr((t=>{if(!t)return Ai.info("No config found after loading remote JS config. Falling back to JSON."),void this.vr((t=>{this.pr(t),this.gr()}));this.pr(t),this.gr()}))}catch(t){Ai.error("Error loading remote config",t)}}stop(){this.yr&&(clearInterval(this.yr),this.yr=void 0)}refresh(){!this._instance.mr()&&St&&"hidden"!==St.visibilityState&&this._instance.reloadFeatureFlags()}gr(){var t;if(!this.yr){var e=null!==(t=this._instance.config.remote_config_refresh_interval_ms)&&void 0!==t?t:3e5;0!==e&&(this.yr=setInterval((()=>{this.refresh()}),e))}}pr(t){var e;t||Ai.error("Failed to fetch remote config from PostHog."),this._instance.pr(null!=t?t:{}),!1!==(null==t?void 0:t.hasFeatureFlags)&&(this._instance.config.advanced_disable_feature_flags_on_first_load||null==(e=this._instance.featureFlags)||e.ensureFlagsLoaded())}}var $i="disabled",Oi="lazy_loading",Mi="awaiting_config",ji="missing_config",Li="base64",Di=function(t,e){if(!function(t){try{new RegExp(t)}catch(t){return!1}return!0}(e))return!1;try{return new RegExp(e).test(t)}catch(t){return!1}},Ni={exact:(t,e)=>e.some((e=>t.some((t=>e===t)))),is_not:(t,e)=>e.every((e=>t.every((t=>e!==t)))),regex:(t,e)=>e.some((e=>t.some((t=>Di(e,t))))),not_regex:(t,e)=>e.every((e=>t.every((t=>!Di(e,t))))),icontains:(t,e)=>e.map(zi).some((e=>t.map(zi).some((t=>e.includes(t))))),not_icontains:(t,e)=>e.map(zi).every((e=>t.map(zi).every((t=>!e.includes(t))))),gt:(t,e)=>e.some((e=>{var i=parseFloat(e);return!isNaN(i)&&t.some((t=>i>parseFloat(t)))})),lt:(t,e)=>e.some((e=>{var i=parseFloat(e);return!isNaN(i)&&t.some((t=>i<parseFloat(t)))}))},zi=t=>t.toLowerCase();function Ui(t,e){return!t||Object.entries(t).every((t=>{var[i,r]=t,s=null==e?void 0:e[i];if(m(s)||w(s))return!1;var n=[String(s)],a=Ni[r.operator];return!!a&&a(r.values,n)}))}At("[SessionRecording]"),At("[SessionRecording]");var Hi="[SessionRecording]",Vi=At(Hi),Bi=At("[Heatmaps]");function qi(t){return b(t)&&"clientX"in t&&"clientY"in t&&E(t.clientX)&&E(t.clientY)}var Wi=At("[Product Tours]"),Ji=t=>{var e;return!t.config.disable_product_tours&&!(null==(e=t.persistence)||!e.get_property(qt))},Ki=["$set_once","$set"],Gi=At("[SiteApps]"),Yi="Error while initializing PostHog app with config id ",Qi="events",Zi="cancelEvents",Xi="survey shown",tr=At("[Surveys]"),er="seenSurvey_",ir=["popover","widget","api"];class rr{constructor(){this.Wr={}}on(t,e){return this.Wr[t]||(this.Wr[t]=[]),this.Wr[t].push(e),()=>{this.Wr[t]=this.Wr[t].filter((t=>t!==e))}}emit(t,e){for(var i of this.Wr[t]||[])i(e);for(var r of this.Wr["*"]||[])r(t,e)}}function sr(t,e,i){if(x(t))return!1;switch(i){case"exact":return t===e;case"contains":var r=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(r,"i").test(t);case"regex":try{return new RegExp(e).test(t)}catch(t){return!1}default:return!1}}class nr{constructor(t){this.sn=new rr,this.an=(t,e)=>this.ln(t,e)&&this.un(t,e)&&this.hn(t,e)&&this.dn(t,e),this.ln=(t,e)=>null==e||!e.event||(null==t?void 0:t.event)===(null==e?void 0:e.event),this._instance=t,this.cn=new Set,this.vn=new Set}init(){var t,e;m(null==(t=this._instance)?void 0:t._addCaptureHook)||(null==(e=this._instance)||e._addCaptureHook(((t,e)=>{this.on(t,e)})))}register(t){var e,i;if(!m(null==(e=this._instance)?void 0:e._addCaptureHook)&&(t.forEach((t=>{var e,i;null==(e=this.vn)||e.add(t),null==(i=t.steps)||i.forEach((t=>{var e;null==(e=this.cn)||e.add((null==t?void 0:t.event)||"")}))})),null!=(i=this._instance)&&i.autocapture)){var r,s=new Set;t.forEach((t=>{var e;null==(e=t.steps)||e.forEach((t=>{null!=t&&t.selector&&s.add(null==t?void 0:t.selector)}))})),null==(r=this._instance)||r.autocapture.setElementSelectors(s)}}on(t,e){var i;null!=e&&0!=t.length&&(this.cn.has(t)||this.cn.has(null==e?void 0:e.event))&&this.vn&&(null==(i=this.vn)?void 0:i.size)>0&&this.vn.forEach((t=>{this.fn(e,t)&&this.sn.emit("actionCaptured",t.name)}))}pn(t){this.onAction("actionCaptured",(e=>t(e)))}fn(t,e){if(null==(null==e?void 0:e.steps))return!1;for(var i of e.steps)if(this.an(t,i))return!0;return!1}onAction(t,e){return this.sn.on(t,e)}un(t,e){if(null!=e&&e.url){var i,r=null==t||null==(i=t.properties)?void 0:i.$current_url;if(!r||"string"!=typeof r)return!1;if(!sr(r,e.url,e.url_matching||"contains"))return!1}return!0}hn(t,e){return!!this.gn(t,e)&&!!this.mn(t,e)&&!!this.yn(t,e)}gn(t,e){var i;if(null==e||!e.href)return!0;var r=this.bn(t);if(r.length>0)return r.some((t=>sr(t.href,e.href,e.href_matching||"exact")));var s,n=(null==t||null==(i=t.properties)?void 0:i.$elements_chain)||"";return!!n&&sr((s=n.match(/(?::|")href="(.*?)"/))?s[1]:"",e.href,e.href_matching||"exact")}mn(t,e){var i;if(null==e||!e.text)return!0;var r=this.bn(t);if(r.length>0)return r.some((t=>sr(t.text,e.text,e.text_matching||"exact")||sr(t.$el_text,e.text,e.text_matching||"exact")));var s,n,a,o=(null==t||null==(i=t.properties)?void 0:i.$elements_chain)||"";return!!o&&(s=function(t){for(var e,i=[],r=/(?::|")text="(.*?)"/g;!x(e=r.exec(t));)i.includes(e[1])||i.push(e[1]);return i}(o),n=e.text,a=e.text_matching||"exact",s.some((t=>sr(t,n,a))))}yn(t,e){var i,r;if(null==e||!e.selector)return!0;var s=null==t||null==(i=t.properties)?void 0:i.$element_selectors;if(null!=s&&s.includes(e.selector))return!0;var n=(null==t||null==(r=t.properties)?void 0:r.$elements_chain)||"";if(e.selector_regex&&n)try{return new RegExp(e.selector_regex).test(n)}catch(t){return!1}return!1}bn(t){var e;return null==(null==t||null==(e=t.properties)?void 0:e.$elements)?[]:null==t?void 0:t.properties.$elements}dn(t,e){return null==e||!e.properties||0===e.properties.length||Ui(e.properties.reduce(((t,e)=>{var i=g(e.value)?e.value.map(String):null!=e.value?[String(e.value)]:[];return t[e.key]={values:i,operator:e.operator||"exact"},t}),{}),null==t?void 0:t.properties)}}class ar{constructor(t){this._n=[],this._instance=t,this.wn=new Map,this.xn=new Map,this.kn=new Map}Sn(t,e){return!!t&&Ui(t.propertyFilters,null==e?void 0:e.properties)}Cn(t,e){var i=new Map;return t.forEach((t=>{var r;null==(r=t.conditions)||null==(r=r[e])||null==(r=r.values)||r.forEach((e=>{if(null!=e&&e.name){var r=i.get(e.name)||[];r.push(t.id),i.set(e.name,r)}}))})),i}In(t,e,i){var r=(i===Qi?this.wn:this.xn).get(t),s=[];return this.Tn((t=>{s=t.filter((t=>null==r?void 0:r.includes(t.id)))})),s.filter((r=>{var s,n=null==(s=r.conditions)||null==(s=s[i])||null==(s=s.values)?void 0:s.find((e=>e.name===t));return this.Sn(n,e)}))}register(t){var e;m(null==(e=this._instance)?void 0:e._addCaptureHook)||(this.En(t),this.Mn(t))}Mn(t){var e=t.filter((t=>{var e,i;return(null==(e=t.conditions)?void 0:e.actions)&&(null==(i=t.conditions)||null==(i=i.actions)||null==(i=i.values)?void 0:i.length)>0}));0!==e.length&&(null==this.Pn&&(this.Pn=new nr(this._instance),this.Pn.init(),this.Pn.pn((t=>{this.onAction(t)}))),e.forEach((t=>{var e,i,r,s,n;t.conditions&&null!=(e=t.conditions)&&e.actions&&null!=(i=t.conditions)&&null!=(i=i.actions)&&i.values&&(null==(r=t.conditions)||null==(r=r.actions)||null==(r=r.values)?void 0:r.length)>0&&(null==(s=this.Pn)||s.register(t.conditions.actions.values),null==(n=t.conditions)||null==(n=n.actions)||null==(n=n.values)||n.forEach((e=>{if(e&&e.name){var i=this.kn.get(e.name);i&&i.push(t.id),this.kn.set(e.name,i||[t.id])}})))})))}En(t){var e,i=t.filter((t=>{var e,i;return(null==(e=t.conditions)?void 0:e.events)&&(null==(i=t.conditions)||null==(i=i.events)||null==(i=i.values)?void 0:i.length)>0})),r=t.filter((t=>{var e,i;return(null==(e=t.conditions)?void 0:e.cancelEvents)&&(null==(i=t.conditions)||null==(i=i.cancelEvents)||null==(i=i.values)?void 0:i.length)>0}));0===i.length&&0===r.length||(null==(e=this._instance)||e._addCaptureHook(((t,e)=>{this.onEvent(t,e)})),this.wn=this.Cn(t,Qi),this.xn=this.Cn(t,Zi))}onEvent(t,e){var i,r,s=this.Rn(),n=(null==e||null==(i=e.properties)?void 0:i.$survey_id)||(null==e||null==(r=e.properties)?void 0:r.$product_tour_id);if(n&&this.getActivatedIds().includes(n)){var a=this.On(t,n);if("consume"===a)return s.info("event consumed activated item, removing it",{event:t,itemId:n}),void this.Ln([n]);if("persist"===a)return s.info("shown item promoted to persisted activation",{event:t,itemId:n}),void this.Fn(n)}if(this.xn.has(t)){var o=this.In(t,e,Zi);o.length>0&&(s.info("cancel event matched, cancelling items",{event:t,itemsToCancel:o.map((t=>t.id))}),this.Ln(o.map((t=>t.id))),o.forEach((t=>this.An(t.id))))}if(this.wn.has(t)){s.info("event name matched",{event:t,eventPayload:e,items:this.wn.get(t)});var l=this.In(t,e,Qi);this.$n(l.map((t=>t.id)))}}onAction(t){this.kn.has(t)&&this.$n(this.kn.get(t)||[])}$n(t){0!==t.length&&(this._n=[...new Set([...this._n,...t])],this.Rn().info("updating activated items",{activatedItems:this.getActivatedIds()}))}Fn(t){this._n=this._n.filter((e=>e!==t));var e=this.Dn();e.includes(t)||this.Nn([...e,t])}Ln(t){var e=new Set(t);this._n=this._n.filter((t=>!e.has(t)));var i=this.Dn(),r=i.filter((t=>!e.has(t)));r.length!==i.length&&this.Nn(r)}Dn(){var t,e=this.qn();return(null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[e])||[]}getActivatedIds(){return[...new Set([...this.Dn(),...this._n])].filter((t=>!this.Bn(t)))}reset(){this._n=[],this.Dn().length>0&&this.Nn([])}getEventToItemsMap(){return this.wn}jn(){return this.Pn}}class or extends ar{constructor(t){super(t)}qn(){return ae}Hn(){return Xi}Tn(t){var e;null==(e=this._instance)||e.getSurveys(t)}An(t){var e;null==(e=this._instance)||e.cancelPendingSurvey(t)}Rn(){return tr}Nn(t){var e;null==(e=this._instance)||null==(e=e.persistence)||e.register({[ae]:t})}Bn(){return!1}On(t,e){var i;this.Tn((t=>{i=t.find((t=>t.id===e))}));var r=!i||function(t){var e,i,r,s=(null!==(e=null==(i=t.conditions)||null==(i=i.events)||null==(i=i.values)?void 0:i.length)&&void 0!==e?e:0)>0;return"always"===t.schedule||!(null==(r=t.conditions)||null==(r=r.events)||!r.repeatedActivation||!s)}(i);return r?t===Xi?"consume":"ignore":t===Xi?"persist":"survey dismissed"===t||"survey sent"===t?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}}var lr="SDK is not enabled or survey functionality is not yet loaded",ur="Disabled. Not loading surveys.",hr=null!=xt&&xt.location?ri(xt.location.hash,"__posthog")||ri(location.hash,"state"):null,vr="_postHogToolbarParams",dr=At("[Toolbar]"),cr=At("[FeatureFlags]"),fr=At("[FeatureFlags]",{debugEnabled:!0}),pr="\" failed. Feature flags didn't load in time.",gr=t=>{for(var e={},i=0;t.length>i;i++)e[t[i]]=!0;return e},_r=t=>{var e={};for(var[i,r]of Ot(t||{}))r&&(e[i]=r);return e},br=At("[Error tracking]"),mr="Refusing to render web experiment since the viewer is a likely bot",yr={icontains:(t,e)=>e.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,e)=>-1===e.toLowerCase().indexOf(t.toLowerCase()),regex:(t,e)=>Di(e,t),not_regex:(t,e)=>!Di(e,t),exact:(t,e)=>e===t,is_not:(t,e)=>e!==t};class wr{get Se(){return this._instance.config}constructor(t){var e=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(t){void 0===t&&(t=!1),e.getWebExperiments((t=>{wr.Un("retrieved web experiments from the server"),e.zn=new Map,t.forEach((t=>{if(t.feature_flag_key){var i;e.zn&&(wr.Un("setting flag key ",t.feature_flag_key," to web experiment ",t),null==(i=e.zn)||i.set(t.feature_flag_key,t));var r=e._instance.getFeatureFlag(t.feature_flag_key);y(r)&&t.variants[r]&&e.Vn(t.name,r,t.variants[r].transforms)}else if(t.variants)for(var s in t.variants){var n=t.variants[s];wr.Wn(n,e._instance)&&e.Vn(t.name,s,n.transforms)}}))}),t)},this._instance=t,this._instance.onFeatureFlags((t=>{this.onFeatureFlags(t)}))}initialize(){}onFeatureFlags(t){if(this._is_bot())wr.Un(mr);else if(!this.Se.disable_web_experiments){if(x(this.zn))return this.zn=new Map,this.loadIfEnabled(),void this.previewWebExperiment();wr.Un("applying feature flags",t),t.forEach((t=>{var e;if(this.zn&&null!=(e=this.zn)&&e.has(t)){var i,r=this._instance.getFeatureFlag(t),s=null==(i=this.zn)?void 0:i.get(t);r&&null!=s&&s.variants[r]&&this.Vn(s.name,r,s.variants[r].transforms)}}))}}previewWebExperiment(){var t=wr.getWindowLocation();if(null!=t&&t.search){var e=ei(null==t?void 0:t.search,"__experiment_id"),i=ei(null==t?void 0:t.search,"__experiment_variant");e&&i&&(wr.Un("previewing web experiments "+e+" && "+i),this.getWebExperiments((t=>{this.Gn(parseInt(e),i,t)}),!1,!0))}}loadIfEnabled(){this.Se.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(t,e,i){if(this.Se.disable_web_experiments&&!i)return t([]);var r=this._instance.get_property("$web_experiments");if(r&&!e)return t(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this.Se.token),method:"GET",callback:e=>t(200===e.statusCode&&e.json&&e.json.experiments||[])})}Gn(t,e,i){var r=i.filter((e=>e.id===t));r&&r.length>0&&(wr.Un("Previewing web experiment ["+r[0].name+"] with variant ["+e+"]"),this.Vn(r[0].name,e,r[0].variants[e].transforms))}static Wn(t,e){return!x(t.conditions)&&wr.Zn(t,e)&&wr.Qn(t)}static Zn(t,e){var i;if(x(t.conditions)||x(null==(i=t.conditions)?void 0:i.url))return!0;var r=wr.getWindowLocation();if(r){var s,n,a,o=Dt(e,r.href);return null==(s=t.conditions)||!s.url||yr[null!==(n=null==(a=t.conditions)?void 0:a.urlMatchType)&&void 0!==n?n:"icontains"](t.conditions.url,o)}return!1}static getWindowLocation(){return null==xt?void 0:xt.location}static Qn(t){var e;if(x(t.conditions)||x(null==(e=t.conditions)?void 0:e.utm))return!0;var i=function(t,e,i){if(!St)return{};var r,s,n,a=(r=ii(St.URL,[],Ci),s=Si.concat([]),n={},It(s,(function(t){var e=ei(r,t);n[t]=e||null})),n),o=function(){var t={};return It(Fi,(function(e){var i=Ei.A(e);t[e]=i||null})),t}();return $t(o,a)}();if(i.utm_source){var r,s,n,a,o,l,u,h,v=null==(r=t.conditions)||null==(r=r.utm)||!r.utm_campaign||(null==(s=t.conditions)||null==(s=s.utm)?void 0:s.utm_campaign)==i.utm_campaign,d=null==(n=t.conditions)||null==(n=n.utm)||!n.utm_source||(null==(a=t.conditions)||null==(a=a.utm)?void 0:a.utm_source)==i.utm_source,c=null==(o=t.conditions)||null==(o=o.utm)||!o.utm_medium||(null==(l=t.conditions)||null==(l=l.utm)?void 0:l.utm_medium)==i.utm_medium,f=null==(u=t.conditions)||null==(u=u.utm)||!u.utm_term||(null==(h=t.conditions)||null==(h=h.utm)?void 0:h.utm_term)==i.utm_term;return v&&c&&f&&d}return!1}static Un(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;e>r;r++)i[r-1]=arguments[r];Tt.info("[WebExperiments] "+t,i)}Vn(t,e,i){this._is_bot()?wr.Un(mr):"control"!==e?i.forEach((i=>{if(i.selector){var r;wr.Un("applying transform of variant "+e+" for experiment "+t+" ",i);var s=null==(r=document)?void 0:r.querySelectorAll(i.selector);null==s||s.forEach((t=>{var e=t;i.html&&(e.innerHTML=i.html),i.css&&e.setAttribute("style",i.css)}))}})):wr.Un("Control variants leave the page unmodified.")}_is_bot(){return kt&&this._instance?function(t,e){if(!t)return!1;var i=t.userAgent;if(i&&h(i,e))return!0;try{var r=null==t?void 0:t.userAgentData;if(null!=r&&r.brands&&r.brands.some((t=>h(null==t?void 0:t.brand,e))))return!0}catch(t){}return!!t.webdriver}(kt,this.Se.custom_blocked_useragents):void 0}}var xr=At("[Conversations]"),Er="Conversations not available yet.",kr="console",Sr={featureFlags:class{constructor(t){this.Jn=!1,this.Yn=!1,this.Kn=!1,this.Xn=!1,this.es=!1,this.ts=!1,this.rs=!1,this.ns=!1,this.ss=0,this.os=()=>{var t=this.ls();this.ss=0,t&&this.reloadFeatureFlags()},this._instance=t,this.featureFlagEventHandlers=[],xt&&jt(xt,"online",this.os)}destroy(){null==xt||xt.removeEventListener("online",this.os)}get Se(){return this._instance.config}get zr(){return this._instance.persistence}us(t){return this._instance.get_property(t)}hs(){var t,e;return null!==(t=null==(e=this.zr)?void 0:e.Gt(this.Se.feature_flag_cache_ttl_ms))&&void 0!==t&&t}ds(){return!!this.hs()&&(this.ns||this.Kn||(this.ns=!0,cr.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}cs(){var t,e=null!==(t=this.Se.evaluation_contexts)&&void 0!==t?t:this.Se.evaluation_environments;return!this.Se.evaluation_environments||this.Se.evaluation_contexts||this.rs||(cr.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.rs=!0),null!=e&&e.length?e.filter((t=>{var e=t&&"string"==typeof t&&t.trim().length>0;return e||cr.error("Invalid evaluation context found:",t,"Expected non-empty string"),e})):[]}vs(){return this.cs().length>0}fs(){var t=this.Se.flag_keys;if(!m(t)){if(g(t))return t.filter((t=>{var e=t&&"string"==typeof t&&t.trim().length>0;return e||cr.error("Invalid flag key found:",t,"Expected non-empty string"),e}));cr.error("Invalid flag_keys found:",t,"Expected array of non-empty strings")}}initialize(){var t,e,{config:i}=this._instance,r=null!==(t=null==(e=i.bootstrap)?void 0:e.featureFlags)&&void 0!==t?t:{};if(Object.keys(r).length){var s,n,a=null!==(s=null==(n=i.bootstrap)?void 0:n.featureFlagPayloads)&&void 0!==s?s:{},o=Object.keys(r).filter((t=>!!r[t])).reduce(((t,e)=>(t[e]=r[e]||!1,t)),{}),l=Object.keys(a).filter((t=>o[t])).reduce(((t,e)=>(a[e]&&(t[e]=a[e]),t)),{});this.receivedFeatureFlags({featureFlags:o,featureFlagPayloads:l})}}updateFlags(t,e,r){var s,n,l=null!=r&&r.merge&&null!==(s=this.us(Kt))&&void 0!==s?s:{},u=null!=r&&r.merge&&null!==(n=this.us(Zt))&&void 0!==n?n:{},h=i({},l,t),v=i({},u,e),d={};for(var[c,f]of Object.entries(h))d[c]={key:c,enabled:a(f),variant:o(f),reason:void 0,metadata:m(null==v?void 0:v[c])?void 0:{id:0,version:void 0,description:void 0,payload:v[c]}};this.receivedFeatureFlags({flags:d})}get hasLoadedFlags(){return this.Yn}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var t=this.us(Qt),e=this.us(te),r=this.us(ee);if(!r&&!e)return t||{};var s=$t({},t||{}),n=[...new Set([...Object.keys(r||{}),...Object.keys(e||{})])];for(var a of n){var o,l,u=s[a],h=null==e?void 0:e[a],v=m(h)?null!==(o=null==u?void 0:u.enabled)&&void 0!==o&&o:!!h,d=m(h)?u.variant:"string"==typeof h?h:void 0,c=null==r?void 0:r[a],f=i({},u,{enabled:v,variant:v?null!=d?d:null==u?void 0:u.variant:void 0});v!==(null==u?void 0:u.enabled)&&(f.original_enabled=null==u?void 0:u.enabled),d!==(null==u?void 0:u.variant)&&(f.original_variant=null==u?void 0:u.variant),c&&(f.metadata=i({},null==u?void 0:u.metadata,{payload:c,original_payload:null==u||null==(l=u.metadata)?void 0:l.payload})),s[a]=f}return this.Jn||(cr.warn(" Overriding feature flag details!",{flagDetails:t,overriddenPayloads:r,finalDetails:s}),this.Jn=!0),s}getAllFeatureFlags(){var t=this.getFlagVariants(),e=this.getFlagPayloads();return Object.keys(t).map((i=>{var r=t[i];return{key:i,enabled:a(r),variant:o(r),payload:n(e[i])}}))}getFlagVariants(){var t=this.us(Kt),e=this.us(te);if(!e)return t||{};for(var i=$t({},t),r=Object.keys(e),s=0;r.length>s;s++)i[r[s]]=e[r[s]];return this.Jn||(cr.warn(" Overriding feature flags!",{enabledFlags:t,overriddenFlags:e,finalFlags:i}),this.Jn=!0),i}getFlagPayloads(){var t=this.us(Zt),e=this.us(ee);if(!e)return t||{};for(var i=$t({},t||{}),r=Object.keys(e),s=0;r.length>s;s++)i[r[s]]=e[r[s]];return this.Jn||(cr.warn(" Overriding feature flag payloads!",{flagPayloads:t,overriddenPayloads:e,finalPayloads:i}),this.Jn=!0),i}reloadFeatureFlags(){this.Xn||this.Se.advanced_disable_feature_flags||this.ls()||this.ps||(this._instance.Ti.emit("featureFlagsReloading",!0),this.ps=setTimeout((()=>{this.gs()}),5))}ys(){clearTimeout(this.ps),this.ps=void 0}ensureFlagsLoaded(){this.Yn||this.Kn||this.ps||this.reloadFeatureFlags()}setAnonymousDistinctId(t){this.$anon_distinct_id=t}setReloadingPaused(t){this.Xn=t}gs(t){var e;if(this.ys(),!this._instance.mr()&&!this.ls())if(this.Kn)this.es=!0;else{var r=this.Se.token,s=this.us("$device_id"),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==(e=this.zr)?void 0:e.get_initial_props())||{},this.us(ie)||{}),group_properties:this.us(re),timezone:Pi()};w(s)||m(s)||(n.$device_id=s),(null!=t&&t.disableFlags||this.Se.advanced_disable_feature_flags)&&(n.disable_flags=!0),this.vs()&&(n.evaluation_contexts=this.cs());var a=this.fs();m(a)||(n.flag_keys=a);var o=!!this.Se.advanced_only_evaluate_survey_feature_flags,l=this._instance.requestRouter.endpointFor("flags","/flags/?v=2"+(this.Se.advanced_only_evaluate_survey_feature_flags?"&only_evaluate_survey_feature_flags=true":""));this.Kn=!0,this._instance._send_request({method:"POST",url:l,data:n,compression:this.Se.disable_compression?void 0:Li,timeout:this.Se.feature_flag_request_timeout_ms,callback:t=>{var e,i,r,s=!0;if(this.bs(t.statusCode),200===t.statusCode&&(this.es||(this.$anon_distinct_id=void 0),s=!1),this.Kn=!1,!n.disable_flags||this.es){this.ts=!s;var a=[];t.error?t.error instanceof Error?a.push("AbortError"===t.error.name?"timeout":"connection_error"):a.push("unknown_error"):200!==t.statusCode&&a.push("api_error_"+t.statusCode),null!=(e=t.json)&&e.errorsWhileComputingFlags&&a.push("errors_while_computing_flags");var l,u=!(null==(i=t.json)||null==(i=i.quotaLimited)||!i.includes("feature_flags"));if(u&&a.push("quota_limited"),null==(r=this.zr)||r.register({[he]:a}),u)cr.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!==(l=t.json)&&void 0!==l?l:{},s,{partialResponse:o}),this.es&&(this.es=!1,this.gs())}}})}}ls(){return this.ss>=3&&Pt()}bs(t){this.ss=((t,e,i,r)=>{if(0===t){if(Pt()){var s=e+1;return 3===s&&cr.warn("Feature flag requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped refreshing feature flags; will try again when connectivity changes."),s}return e}return 0})(t,this.ss)}getFeatureFlag(t,e){var i;if(void 0===e&&(e={}),!e.fresh||this.ts)if(this.Yn||this.getFlags()&&this.getFlags().length>0){if(!this.ds()){var r=this.getFeatureFlagResult(t,e);return null!==(i=null==r?void 0:r.variant)&&void 0!==i?i:null==r?void 0:r.enabled}}else cr.warn('getFeatureFlag for key "'+t+pr)}getFeatureFlagDetails(t){return this.getFlagsWithDetails()[t]}getFeatureFlagPayload(t){var e=this.getFeatureFlagResult(t,{send_event:!1});return null==e?void 0:e.payload}getFeatureFlagResult(t,e){if(void 0===e&&(e={}),!e.fresh||this.ts)if(this.Yn||this.getFlags()&&this.getFlags().length>0){if(!this.ds()){var i=this.getFlagVariants(),r=t in i,s=i[t],a=this.getFlagPayloads()[t],o=String(s),l=this.us(Xt)||void 0,u=this.us(ve)||void 0,h=this.us(le)||{};if(this.Se.advanced_feature_flags_dedup_per_session){var v,d=this._instance.get_session_id(),c=this.us(ue);d&&d!==c&&(h={},null==(v=this.zr)||v.register({[le]:h,[ue]:d}))}if((e.send_event||!("send_event"in e))&&(!(t in h)||!h[t].includes(o))){var f,p,_,b,y,w,x,E,k,S;g(h[t])?h[t].push(o):h[t]=[o],null==(f=this.zr)||f.register({[le]:h});var C=this.getFeatureFlagDetails(t),F=[...null!==(p=this.us(he))&&void 0!==p?p:[]];m(s)&&F.push("flag_missing");var P={$feature_flag:t,$feature_flag_response:s,$feature_flag_payload:a||null,$feature_flag_request_id:l,$feature_flag_evaluated_at:u,$feature_flag_bootstrapped_response:(null==(_=this.Se.bootstrap)||null==(_=_.featureFlags)?void 0:_[t])||null,$feature_flag_bootstrapped_payload:(null==(b=this.Se.bootstrap)||null==(b=b.featureFlagPayloads)?void 0:b[t])||null,$used_bootstrap_value:!this.ts};m(null==C||null==(y=C.metadata)?void 0:y.version)||(P.$feature_flag_version=C.metadata.version);var R,T=null!==(w=null==C||null==(x=C.reason)?void 0:x.description)&&void 0!==w?w:null==C||null==(E=C.reason)?void 0:E.code;T&&(P.$feature_flag_reason=T),null!=C&&null!=(k=C.metadata)&&k.id&&(P.$feature_flag_id=C.metadata.id),m(null==C?void 0:C.original_variant)&&m(null==C?void 0:C.original_enabled)||(P.$feature_flag_original_response=m(C.original_variant)?C.original_enabled:C.original_variant),null!=C&&null!=(S=C.metadata)&&S.original_payload&&(P.$feature_flag_original_payload=null==C||null==(R=C.metadata)?void 0:R.original_payload),F.length&&(P.$feature_flag_error=F.join(",")),this._instance.capture("$feature_flag_called",P)}if(r)return{key:t,enabled:!!s,variant:"string"==typeof s?s:void 0,payload:n(a)}}}else cr.warn('getFeatureFlagResult for key "'+t+pr)}getRemoteConfigPayload(t,e){var i=this.Se.token,r={distinct_id:this._instance.get_distinct_id(),token:i};this.vs()&&(r.evaluation_contexts=this.cs());var s=this.fs();m(s)||(r.flag_keys=s),this._instance._send_request({method:"POST",url:this._instance.requestRouter.endpointFor("flags","/flags/?v=2"),data:r,compression:this.Se.disable_compression?void 0:Li,timeout:this.Se.feature_flag_request_timeout_ms,callback(i){var r,s=null==(r=i.json)?void 0:r.featureFlagPayloads;e((null==s?void 0:s[t])||void 0)}})}isFeatureEnabled(t,e){if(void 0===e&&(e={}),!e.fresh||this.ts){if(this.Yn||this.getFlags()&&this.getFlags().length>0){var i=this.getFeatureFlag(t,e);return m(i)?void 0:!!i}cr.warn('isFeatureEnabled for key "'+t+pr)}}addFeatureFlagsHandler(t){this.featureFlagEventHandlers.push(t)}removeFeatureFlagsHandler(t){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((e=>e!==t))}receivedFeatureFlags(t,e,r){if(this.zr){this.Yn=!0;var s=this.getFlagVariants(),n=this.getFlagPayloads(),a=this.getFlagsWithDetails();!function(t,e,r,s,n,a){void 0===r&&(r={}),void 0===s&&(s={}),void 0===n&&(n={});var o=(t=>{var e=t.flags;return e?(t.featureFlags=Object.fromEntries(Object.keys(e).map((t=>{var i;return[t,null!==(i=e[t].variant)&&void 0!==i?i:e[t].enabled]}))),t.featureFlagPayloads=Object.fromEntries(Object.keys(e).filter((t=>e[t].enabled)).filter((t=>{var i;return null==(i=e[t].metadata)?void 0:i.payload})).map((t=>{var i;return[t,null==(i=e[t].metadata)?void 0:i.payload]})))):t.featureFlags&&cr.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),t})(t),l=o.flags,u=o.featureFlags,h=o.featureFlagPayloads;if(u){var v=t.requestId,d=t.evaluatedAt;if(g(u)){cr.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var c={};if(u)for(var f=0;u.length>f;f++)c[u[f]]=!0;e&&e.register({[Gt]:u,[Kt]:c})}else{var p=u,_=h,b=l;if(null!=a&&a.partialResponse)p=i({},r,p),_=i({},s,_),b=i({},n,b);else if(t.errorsWhileComputingFlags)if(l){var m=new Set(Object.keys(l).filter((t=>{var e;return!(null!=(e=l[t])&&e.failed)})));p=i({},r,Object.fromEntries(Object.entries(p).filter((t=>{var[e]=t;return m.has(e)})))),_=i({},s,Object.fromEntries(Object.entries(_||{}).filter((t=>{var[e]=t;return m.has(e)})))),b=i({},n,Object.fromEntries(Object.entries(b||{}).filter((t=>{var[e]=t;return m.has(e)}))))}else p=i({},r,p),_=i({},s,_),b=i({},n,b);e&&e.register(i({[Gt]:Object.keys(_r(p)),[Kt]:p||{},[Zt]:_||{},[Qt]:b||{}},v?{[Xt]:v}:{},d?{[ve]:d}:{}))}}}(t,this.zr,s,n,a,r),e||(this.ns=!1),this._s(e)}}override(t,e){void 0===e&&(e=!1),cr.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:t,suppressWarning:e})}overrideFeatureFlags(t){if(!this._instance.__loaded||!this.zr)return cr.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(!1===t)return this.zr.unregister(te),this.zr.unregister(ee),this._s(),fr.info("All overrides cleared");if(g(t)){var e=gr(t);return this.zr.register({[te]:e}),this._s(),fr.info("Flag overrides set",{flags:t})}if(t&&"object"==typeof t&&("flags"in t||"payloads"in t)){var i,r=t;if(this.Jn=Boolean(null!==(i=r.suppressWarning)&&void 0!==i&&i),"flags"in r)if(!1===r.flags)this.zr.unregister(te),fr.info("Flag overrides cleared");else if(r.flags){if(g(r.flags)){var s=gr(r.flags);this.zr.register({[te]:s})}else this.zr.register({[te]:r.flags});fr.info("Flag overrides set",{flags:r.flags})}return"payloads"in r&&(!1===r.payloads?(this.zr.unregister(ee),fr.info("Payload overrides cleared")):r.payloads&&(this.zr.register({[ee]:r.payloads}),fr.info("Payload overrides set",{payloads:r.payloads}))),void this._s()}if(t&&"object"==typeof t)return this.zr.register({[te]:t}),this._s(),fr.info("Flag overrides set",{flags:t});cr.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:t})}onFeatureFlags(t){if(this.addFeatureFlagsHandler(t),this.Yn){var{flags:e,flagVariants:i}=this.ws();try{t(e,i)}catch(t){cr.error("Error while running feature flags callback",t)}}return()=>this.removeFeatureFlagsHandler(t)}updateEarlyAccessFeatureEnrollment(t,e,r){var s,n=(this.us(Yt)||[]).find((e=>e.flagKey===t)),a={["$feature_enrollment/"+t]:e},o={$feature_flag:t,$feature_enrollment:e,$set:a};n&&(o.$early_access_feature_name=n.name),r&&(o.$feature_enrollment_stage=r),this._instance.capture("$feature_enrollment_update",o),this.setPersonPropertiesForFlags(a,!1);var l=i({},this.getFlagVariants(),{[t]:e});null==(s=this.zr)||s.register({[Gt]:Object.keys(_r(l)),[Kt]:l}),this._s()}getEarlyAccessFeatures(t,e,i){void 0===e&&(e=!1);var r=this.us(Yt),s=i?"&"+i.map((t=>"stage="+t)).join("&"):"";if(r&&!e)return t(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/early_access_features/?token="+this.Se.token+s),method:"GET",callback:e=>{var i,r;if(e.json){var s=e.json.earlyAccessFeatures;return null==(i=this.zr)||i.unregister(Yt),null==(r=this.zr)||r.register({[Yt]:s}),t(s)}}})}ws(){var t=this.getFlags(),e=this.getFlagVariants();return{flags:t.filter((t=>e[t])),flagVariants:Object.keys(e).filter((t=>e[t])).reduce(((t,i)=>(t[i]=e[i],t)),{})}}_s(t){var{flags:e,flagVariants:i}=this.ws();this.featureFlagEventHandlers.forEach((r=>{try{r(e,i,{errorsLoading:t})}catch(t){cr.error("Error while running feature flags callback",t)}}))}setPersonPropertiesForFlags(t,e){void 0===e&&(e=!0);var r=this.us(ie)||{},s=(null==t?void 0:t.$set)||(null!=t&&t.$set_once?{}:t),n=null==t?void 0:t.$set_once,a={};if(n)for(var o in n)({}).hasOwnProperty.call(n,o)&&(o in r||(a[o]=n[o]));this._instance.register({[ie]:i({},r,a,s)}),e&&this._instance.reloadFeatureFlags()}unsetPersonPropertiesForFlags(t,e){void 0===e&&(e=!0);var r=i({},this.us(ie)||{});t.forEach((t=>{delete r[t]})),this._instance.register({[ie]:r}),e&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(t){void 0===t&&(t=!0),this._instance.unregister(ie),t&&this._instance.reloadFeatureFlags()}setGroupPropertiesForFlags(t,e){void 0===e&&(e=!0);var r=this.us(re)||{};0!==Object.keys(r).length&&Object.keys(r).forEach((e=>{r[e]=i({},r[e],t[e]),delete t[e]})),this._instance.register({[re]:i({},r,t)}),e&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(t){if(t){var e=this.us(re)||{};this._instance.register({[re]:i({},e,{[t]:{}})})}else this._instance.unregister(re)}reset(){this.Yn=!1,this.Kn=!1,this.Xn=!1,this.es=!1,this.ts=!1,this.$anon_distinct_id=void 0,this.ys(),this.Jn=!1,this.ss=0}}},Cr={sessionRecording:class{get Se(){return this._instance.config}get zr(){return this._instance.persistence}get started(){var t;return!(null==(t=this.xs)||!t.isStarted)}get status(){var t,e;return this.ks===Mi||this.ks===ji?this.ks:null!==(t=null==(e=this.xs)?void 0:e.status)&&void 0!==t?t:this.ks}constructor(t){if(this._forceAllowLocalhostNetworkCapture=!1,this.ks=$i,this.Ss=void 0,this._instance=t,!this._instance.sessionManager)throw Vi.error("started without valid sessionManager"),new Error(Hi+" started without valid sessionManager. This is a bug.");if("always"===this.Se.cookieless_mode)throw new Error(Hi+' cannot be used with cookieless_mode="always"')}initialize(){this.startIfEnabledOrStop()}get Cs(){var t,e=!(null==(t=this._instance.get_property(Jt))||!t.enabled),i=!this.Se.disable_session_recording,r=this.Se.disable_session_recording||this._instance.consent.isOptedOut();return xt&&e&&i&&!r}startIfEnabledOrStop(t){var e;if(!this.Cs||null==(e=this.xs)||!e.isStarted){var i=!m(Object.assign)&&!m(Array.from);this.Cs&&i?(this.Is(t),Vi.info("starting")):(this.ks=$i,this.stopRecording())}}Is(t){var e,i,r;this.Cs&&(this.ks!==Mi&&this.ks!==ji&&(this.ks=Oi),null!=Ft&&null!=(e=Ft.__PosthogExtensions__)&&null!=(e=e.rrweb)&&e.record&&null!=(i=Ft.__PosthogExtensions__)&&i.initSessionRecording?this.Ts(t):null==(r=Ft.__PosthogExtensions__)||null==r.loadExternalDependency||r.loadExternalDependency(this._instance,this.Es,(e=>{if(e)return Vi.error("could not load recorder",e);this.Ts(t)})))}stopRecording(){var t,e;null==(t=this.Ss)||t.call(this),this.Ss=void 0,null==(e=this.xs)||e.stop()}Ms(){var t,e;null==(t=this.Ss)||t.call(this),this.Ss=void 0,null==(e=this.xs)||e.discard()}Ps(){var t,e;null==(t=this.zr)||t.unregister("$session_is_sampled"),null==(e=this.zr)||e.unregister("$replay_sample_rate")}Rs(t,e){if(x(t))return null;var i,r=E(t)?t:parseFloat(t);return"number"!=typeof(i=r)||!Number.isFinite(i)||0>i||i>1?(Vi.warn(e+" must be between 0 and 1. Ignoring invalid value:",t),null):r}Os(t){if(this.zr){var e,r,s=this.zr,n=()=>{var e,r=!1===t.sessionRecording?void 0:t.sessionRecording,n=this.Rs(null==(e=this.Se.session_recording)?void 0:e.sampleRate,"session_recording.sampleRate"),a=this.Rs(null==r?void 0:r.sampleRate,"remote config sampleRate"),o=null!=n?n:a;x(o)&&this.Ps();var l=null==r?void 0:r.minimumDurationMilliseconds;s.register({[Jt]:i({cache_timestamp:Date.now(),enabled:!!r},r,{networkPayloadCapture:i({capturePerformance:t.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:o,minimumDurationMilliseconds:m(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==(e=this.Ss)||e.call(this),this.Ss=null==(r=this._instance.sessionManager)?void 0:r.onSessionId(n)}}onRemoteConfig(t){return"sessionRecording"in t?!1===t.sessionRecording?(this.Os(t),void this.Ms()):(this.Os(t),void this.startIfEnabledOrStop()):(this.ks===Mi&&(this.ks=ji,Vi.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(t,e){var i;void 0===e&&(e="log"),null!=(i=this.xs)&&i.log?this.xs.log(t,e):Vi.warn("log called before recorder was ready")}get Es(){var t,e,i=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.get_property(Jt);return(null==i||null==(e=i.scriptConfig)?void 0:e.script)||"lazy-recorder"}Ls(){var t,e,i=this._instance.get_property(Jt);if(!i)return!1;try{e="object"==typeof i?i:JSON.parse(i)}catch(t){return Vi.warn("persisted remote config for session recording is invalid and will be ignored",t),!1}var r=null!==(t=e.cache_timestamp)&&void 0!==t?t:Date.now();return 36e5>=Date.now()-r}Ts(t){var e,i;if(null==(e=Ft.__PosthogExtensions__)||!e.initSessionRecording)return Vi.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({$sdk_debug_recording_script_not_loaded:!0});if(this.xs||(this.xs=null==(i=Ft.__PosthogExtensions__)?void 0:i.initSessionRecording(this._instance),this.xs._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.Ls()){if(this.ks===ji||this.ks===Mi)return;return this.ks=Mi,Vi.info("persisted remote config is stale, requesting fresh config before starting"),void new Ii(this._instance).load()}this.ks=Oi,this.xs.start(t)}onRRwebEmit(t){var e;null==(e=this.xs)||null==e.onRRwebEmit||e.onRRwebEmit(t)}overrideLinkedFlag(){var t,e;this.xs||null==(e=this.zr)||e.register({$replay_override_linked_flag:!0}),null==(t=this.xs)||t.overrideLinkedFlag()}overrideSampling(){var t,e;this.xs||null==(e=this.zr)||e.register({$replay_override_sampling:!0}),null==(t=this.xs)||t.overrideSampling()}overrideTrigger(t){var e,i;this.xs||null==(i=this.zr)||i.register({["url"===t?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),null==(e=this.xs)||e.overrideTrigger(t)}get sdkDebugProperties(){var t;return(null==(t=this.xs)?void 0:t.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(t,e){var i;return!(null==(i=this.xs)||!i.tryAddCustomEvent(t,e))}}},Fr={autocapture:class{constructor(t){this.Fs=!1,this.As=null,this.$s=!1,this.instance=t,this.rageclicks=new ti(t.config.rageclick),this.Ds=null}initialize(){this.startIfEnabled()}get Se(){var t,e,i=b(this.instance.config.autocapture)?this.instance.config.autocapture:{};return i.url_allowlist=null==(t=i.url_allowlist)?void 0:t.map((t=>new RegExp(t))),i.url_ignorelist=null==(e=i.url_ignorelist)?void 0:e.map((t=>new RegExp(t))),i}Ns(){if(this.isBrowserSupported()){if(xt&&St){var t=t=>{t=t||(null==xt?void 0:xt.event);try{this.qs(t)}catch(t){ni.error("Failed to capture event",t)}};if(jt(St,"submit",t,{capture:!0}),jt(St,"change",t,{capture:!0}),jt(St,"click",t,{capture:!0}),this.Se.capture_copied_text){var e=t=>{t=t||(null==xt?void 0:xt.event);try{this.qs(t,si)}catch(t){ni.error("Failed to capture copy/cut event",t)}};jt(St,"copy",e,{capture:!0}),jt(St,"cut",e,{capture:!0})}}}else ni.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this.Fs&&(this.Ns(),this.Fs=!0)}onRemoteConfig(t){t.elementsChainAsString&&(this.$s=t.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[Nt]:!!t.autocapture_opt_out}),this.As=!!t.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(t){this.Ds=t}getElementSelectors(t){var e,i=[];return null==(e=this.Ds)||e.forEach((e=>{var r=null==St?void 0:St.querySelectorAll(e);null==r||r.forEach((r=>{t===r&&i.push(e)}))})),i}get isEnabled(){var t,e,i=null==(t=this.instance.persistence)?void 0:t.props[Nt];if(w(this.As)&&!k(i)&&!this.instance.mr())return!1;var r=null!==(e=this.As)&&void 0!==e?e:!!i;return!!this.instance.config.autocapture&&!r}qs(t,e){if(void 0===e&&(e="$autocapture"),this.isEnabled){var i,r=Re(t);xe(r)&&(r=r.parentNode||null),"$autocapture"===e&&"click"===t.type&&t instanceof MouseEvent&&this.instance.config.rageclick&&null!=(i=this.rageclicks)&&i.isRageClick(t.clientX,t.clientY,t.timeStamp||(new Date).getTime())&&De(r,this.instance.config.rageclick)&&this.qs(t,"$rageclick");var s=e===si;if(r&&function(t,e,i,r,s,n){var a,o,l,u,h,v;if(void 0===i&&(i=void 0),!xt||Ne(t))return!1;if(null!=(a=i)&&a.url_allowlist&&!Se(i.url_allowlist,n))return!1;if(null!=(o=i)&&o.url_ignorelist&&Se(i.url_ignorelist,n))return!1;if(null!=(l=i)&&l.dom_event_allowlist){var d=i.dom_event_allowlist;if(d&&!d.some((t=>e.type===t)))return!1}var{parentIsUsefulElement:c,targetElementList:f}=ze(t,r);if(!function(t,e){var i=null==e?void 0:e.element_allowlist;if(m(i))return!0;var r,s=function(t){if(i.some((e=>t.tagName.toLowerCase()===e)))return{v:!0}};for(var n of t)if(r=s(n))return r.v;return!1}(f,i))return!1;if(!Ae(f,null==(u=i)?void 0:u.css_selector_allowlist))return!1;if(Ae(f,null!==(h=null==(v=i)?void 0:v.css_selector_ignorelist)&&void 0!==h?h:$e))return!1;try{var p=xt.getComputedStyle(t);if(p&&"pointer"===p.getPropertyValue("cursor")&&"click"===e.type)return!0}catch(t){}var g=t.tagName.toLowerCase();switch(g){case"html":return!1;case"form":return(s||["submit"]).indexOf(e.type)>=0;case"input":case"select":case"textarea":return(s||["change","click"]).indexOf(e.type)>=0;default:return c?(s||["click"]).indexOf(e.type)>=0:(s||["click"]).indexOf(e.type)>=0&&(Te.indexOf(g)>-1||"true"===t.getAttribute("contenteditable"))}}(r,t,this.Se,s,s?["copy","cut"]:void 0,this.instance)){var{props:n,explicitNoCapture:a}=li(r,{e:t,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.Se.element_attribute_ignorelist,elementsChainAsString:this.$s,disableCaptureUrlHashes:this.instance.config.disable_capture_url_hashes});if(a)return!1;var o=this.getElementSelectors(r);if(o&&o.length>0&&(n.$element_selectors=o),e===si){var l,u=Fe(null==xt||null==(l=xt.getSelection())?void 0:l.toString()),h=t.type||"clipboard";if(!u)return!1;n.$selected_content=u,n.$copy_type=h}return this.instance.capture(e,n),!0}}}isBrowserSupported(){return _(null==St?void 0:St.querySelectorAll)}},historyAutocapture:class{constructor(t){var e;this._instance=t,this.Bs=(null==xt||null==(e=xt.location)?void 0:e.pathname)||""}initialize(){this.startIfEnabled()}get isEnabled(){return"history_change"===this._instance.config.capture_pageview}startIfEnabled(){this.isEnabled&&(Tt.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this.js&&this.js(),this.js=void 0,Tt.info("History API monitoring stopped")}monitorHistoryChanges(){xt&&xt.history&&(this.Hs("pushState"),this.Hs("replaceState"),this.Us())}Hs(t){var e;if(xt&&(null==(e=xt.history[t])||!e.__posthog_wrapped__)){var i=this;!function(t,e,i){try{if(!(e in t))return()=>{};var r=t[e],s=i(r);return _(s)&&(s.prototype=s.prototype||{},Object.defineProperties(s,{__posthog_wrapped__:{enumerable:!1,value:!0}})),t[e]=s,()=>{t[e]===s&&(t[e]=r)}}catch(t){return()=>{}}}(xt.history,t,(e=>function(r,s,n){e.call(this,r,s,n),i.zs(t)}))}}zs(t){try{var e,i=null==xt||null==(e=xt.location)?void 0:e.pathname;if(!i)return;i!==this.Bs&&this.isEnabled&&this._instance.capture("$pageview",{navigation_type:t}),this.Bs=i}catch(e){Tt.error("Error capturing "+t+" pageview",e)}}Us(){if(!this.js){var t=()=>{this.zs("popstate")};jt(xt,"popstate",t),this.js=()=>{xt&&xt.removeEventListener("popstate",t)}}}},heatmaps:class{get Se(){return this.instance.config}constructor(t){var e;this.Vs=!1,this.Fs=!1,this.Ws=null,this.instance=t,this.Vs=!(null==(e=this.instance.persistence)||!e.props[zt]),this.rageclicks=new ti(t.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var t=5e3;return b(this.Se.capture_heatmaps)&&this.Se.capture_heatmaps.flush_interval_milliseconds&&(t=this.Se.capture_heatmaps.flush_interval_milliseconds),t}get isEnabled(){return x(this.Se.capture_heatmaps)?x(this.Se.enable_heatmaps)?this.Vs:this.Se.enable_heatmaps:!1!==this.Se.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this.Fs)return;Bi.info("starting..."),this.Gs(),this.ke()}else{var t;clearInterval(null!==(t=this.Ws)&&void 0!==t?t:void 0),this.Zs(),this.getAndClearBuffer()}}onRemoteConfig(t){if("heatmaps"in t){var e=!!t.heatmaps;this.instance.persistence&&this.instance.persistence.register({[zt]:e}),this.Vs=e,this.startIfEnabled()}}getAndClearBuffer(){var t=this.R;return this.R=void 0,t}Qs(t){this.fe(t.originalEvent,"deadclick")}ke(){this.Ws&&clearInterval(this.Ws),this.Ws="visible"===(null==St?void 0:St.visibilityState)?setInterval(this.Lr.bind(this),this.flushIntervalMilliseconds):null}Gs(){xt&&St&&(this.Js=this.Lr.bind(this),jt(xt,pe,this.Js),this.Ys=t=>this.fe(t||(null==xt?void 0:xt.event)),jt(St,"click",this.Ys,{capture:!0}),this.Ks=t=>this.Xs(t||(null==xt?void 0:xt.event)),jt(St,"mousemove",this.Ks,{capture:!0}),this.eo=new vi(this.instance,hi,this.Qs.bind(this)),this.eo.startIfEnabledOrStop(),this.ro=this.ke.bind(this),jt(St,fe,this.ro),this.Fs=!0)}Zs(){var t;xt&&St&&(this.Js&&xt.removeEventListener(pe,this.Js),this.Ys&&St.removeEventListener("click",this.Ys,{capture:!0}),this.Ks&&St.removeEventListener("mousemove",this.Ks,{capture:!0}),this.ro&&St.removeEventListener(fe,this.ro),clearTimeout(this.io),null==(t=this.eo)||t.stop(),this.Fs=!1)}no(t,e){var i=this.instance.scrollManager.scrollY(),r=this.instance.scrollManager.scrollX(),s=this.instance.scrollManager.scrollElement(),n=function(t,e,i){for(var r=t;r&&ye(r)&&!we(r,"body");){if(r===i)return!1;var s=void 0;try{var n,a,o;s=null==(n=null!==(a=null==(o=r.ownerDocument)?void 0:o.defaultView)&&void 0!==a?a:xt)?void 0:n.getComputedStyle(r).position}catch(t){return!1}if(v(e,s))return!0;r=Ie(r)}return!1}(Re(t),["fixed","sticky"],s);return{x:t.clientX+(n?0:r),y:t.clientY+(n?0:i),target_fixed:n,type:e}}fe(t,e){var r;if(void 0===e&&(e="click"),!me(t.target)&&qi(t)){var s=this.no(t,e);null!=(r=this.rageclicks)&&r.isRageClick(t.clientX,t.clientY,(new Date).getTime())&&De(Re(t),this.instance.config.rageclick)&&this.so(i({},s,{type:"rageclick"})),this.so(s)}}Xs(t){!me(t.target)&&qi(t)&&(clearTimeout(this.io),this.io=setTimeout((()=>{this.so(this.no(t,"mousemove"))}),500))}so(t){if(xt){var e=this.Se.disable_capture_url_hashes?A(xt.location.href):xt.location.href,i=this.Se.custom_personal_data_properties,r=this.Se.mask_personal_data_properties?[...ki,...i||[]]:[],s=ii(e,r,Ci);this.R=this.R||{},this.R[s]||(this.R[s]=[]),this.R[s].push(t)}}Lr(){this.R&&!(t=>{if(b(t)){for(var e in t)if(f.call(t,e))return!1;return!0}return!1})(this.R)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:vi,webVitalsAutocapture:class{constructor(t){var e;this.Vs=!1,this.Fs=!1,this.R={url:void 0,metrics:[],firstMetricTimestamp:void 0},this.oo=()=>{clearTimeout(this.ao),0!==this.R.metrics.length&&(this._instance.capture("$web_vitals",this.R.metrics.reduce(((t,e)=>i({},t,{["$web_vitals_"+e.name+"_event"]:i({},e),["$web_vitals_"+e.name+"_value"]:e.value})),{})),this.R={url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.lo=t=>{var e;this.R=this.R||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var r=this.uo();if(!m(r))if(x(null==t?void 0:t.name)||x(null==t?void 0:t.value))Ri.error("Invalid metric received",t);else if(!this.ho||this.ho>t.value){this.R.url!==r&&(this.oo(),this.ao=setTimeout(this.oo,this.flushToCaptureTimeoutMs)),m(this.R.url)&&(this.R.url=r),this.R.firstMetricTimestamp=m(this.R.firstMetricTimestamp)?Date.now():this.R.firstMetricTimestamp,t.attribution&&t.attribution.interactionTargetElement&&(t.attribution.interactionTargetElement=void 0);var s=null==(e=this._instance.sessionManager)?void 0:e.checkAndGetSessionAndWindowId(!0),n=i({},t,{$current_url:r,timestamp:Date.now()});m(s)||(n.$session_id=s.sessionId,n.$window_id=s.windowId),this.R.metrics.push(n),this.R.metrics.length===this.allowedMetrics.length&&this.oo()}else Ri.error("Ignoring metric with value >= "+this.ho,t)},this.do=()=>{if(!this.Fs){var t,e,i,r,s=Ft.__PosthogExtensions__;m(s)||m(s.postHogWebVitalsCallbacks)||({onLCP:t,onCLS:e,onFCP:i,onINP:r}=s.postHogWebVitalsCallbacks),t&&e&&i&&r?(this.allowedMetrics.indexOf("LCP")>-1&&t(this.lo.bind(this)),this.allowedMetrics.indexOf("CLS")>-1&&e(this.lo.bind(this)),this.allowedMetrics.indexOf("FCP")>-1&&i(this.lo.bind(this)),this.allowedMetrics.indexOf("INP")>-1&&r(this.lo.bind(this)),this.Fs=!0):Ri.error("web vitals callbacks not loaded - not starting")}},this._instance=t,this.Vs=!(null==(e=this._instance.persistence)||!e.props[Bt]),this.startIfEnabled()}get co(){return this._instance.config.capture_performance}get allowedMetrics(){var t,e,i=b(this.co)?null==(t=this.co)?void 0:t.web_vitals_allowed_metrics:void 0;return x(i)?(null==(e=this._instance.persistence)?void 0:e.props[Wt])||["CLS","FCP","INP","LCP"]:i}get flushToCaptureTimeoutMs(){return(b(this.co)?this.co.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var t=b(this.co)?this.co.web_vitals_attribution:void 0;return null!=t&&t}get ho(){var t=b(this.co)&&E(this.co.__web_vitals_max_value)?this.co.__web_vitals_max_value:Ti;return t>0&&6e4>=t?Ti:t}get isEnabled(){var t=null==Ct?void 0:Ct.protocol;if("http:"!==t&&"https:"!==t)return Ri.info("Web Vitals are disabled on non-http/https protocols"),!1;var e=b(this.co)?this.co.web_vitals:k(this.co)?this.co:void 0;return k(e)?e:this.Vs}startIfEnabled(){this.isEnabled&&!this.Fs&&(Ri.info("enabled, starting..."),this.Mt(this.do))}onRemoteConfig(t){if("capturePerformance"in t){var e=b(t.capturePerformance)&&!!t.capturePerformance.web_vitals,i=b(t.capturePerformance)?t.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[Bt]:e}),this._instance.persistence.register({[Wt]:i})),this.Vs=e,this.startIfEnabled()}}Mt(t){var e,i;null!=(e=Ft.__PosthogExtensions__)&&e.postHogWebVitalsCallbacks?t():null==(i=Ft.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,this.useAttribution?"web-vitals-with-attribution":"web-vitals",(e=>{e?Ri.error("failed to load script",e):t()}))}uo(){var t=xt?this._instance.config.disable_capture_url_hashes?A(xt.location.href):xt.location.href:void 0;if(t){var e=this._instance.config.custom_personal_data_properties,i=this._instance.config.mask_personal_data_properties?[...ki,...e||[]]:[];return ii(t,i,Ci)}Ri.error("Could not determine current URL")}}},Pr={exceptionObserver:class{constructor(t){var e,i,r;this.do=()=>{var t;if(xt&&this.isEnabled&&null!=(t=Ft.__PosthogExtensions__)&&t.errorWrappingFunctions){var e=Ft.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,i=Ft.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,r=Ft.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.vo&&this.Se.capture_unhandled_errors&&(this.vo=e(this.captureException.bind(this))),!this.fo&&this.Se.capture_unhandled_rejections&&(this.fo=i(this.captureException.bind(this))),!this.po&&this.Se.capture_console_errors&&(this.po=r(this.captureException.bind(this)))}catch(t){di.error("failed to start",t),this.mo()}}},this._instance=t,this.yo=!(null==(e=this._instance.persistence)||!e.props[Ut]),this.bo=new T({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,Ae:di}),this.Se=this._o(),this.startIfEnabledOrStop()}_o(){var t=this._instance.config.capture_exceptions,e={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return b(t)?e=i({},e,t):(m(t)?this.yo:t)&&(e=i({},e,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),e}get isEnabled(){return this.Se.capture_console_errors||this.Se.capture_unhandled_errors||this.Se.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(di.info("enabled"),this.mo(),this.Mt(this.do)):this.mo()}Mt(t){var e,i;null!=(e=Ft.__PosthogExtensions__)&&e.errorWrappingFunctions?t():null==(i=Ft.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"exception-autocapture",(e=>{if(e)return di.error("failed to load script",e);t()}))}mo(){var t,e,i;null==(t=this.vo)||t.call(this),this.vo=void 0,null==(e=this.fo)||e.call(this),this.fo=void 0,null==(i=this.po)||i.call(this),this.po=void 0}onRemoteConfig(t){"autocaptureExceptions"in t&&(this.yo=!!t.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[Ut]:this.yo}),this.Se=this._o(),this.startIfEnabledOrStop())}onConfigChange(){this.Se=this._o()}captureException(t){var e,i,r,s=null!==(e=null==t||null==(i=t.$exception_list)||null==(i=i[0])?void 0:i.type)&&void 0!==e?e:"Exception";this.bo.consumeRateLimit(s)?di.info("Skipping exception capture because of client rate limiting.",{exception:s}):null==(r=this._instance.exceptions)||r.sendExceptionEvent(t)}},exceptions:class{constructor(t){var e,r;this.wo=[],this.xo=new W([new st,new ft,new at,new nt,new dt,new vt,new lt,new ct],function(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),s=1;e>s;s++)r[s-1]=arguments[s];return function(e,s){void 0===s&&(s=0);for(var n=[],a=e.split("\n"),o=s;a.length>o;o++){var l=a[o];if(1024>=l.length){var u=rt.test(l)?l.replace(rt,"$1"):l;if(!u.match(/\S*Error: /)){for(var h of r){var v=h(u,t);if(v){n.push(v);break}}if(n.length>=50)break}}}return function(t){if(!t.length)return[];var e=Array.from(t);return e.reverse(),e.slice(0,50).map((t=>{return i({},t,{filename:t.filename||(r=e,r[r.length-1]||{}).filename,function:t.function||J});var r}))}(n)}}("web:javascript",X,it)),this._instance=t,this.wo=null!==(e=null==(r=this._instance.persistence)?void 0:r.get_property(Ht))&&void 0!==e?e:[],this.ko=mt(this.So()),this.Co=new yt(this.ko)}onConfigChange(){this.ko=mt(this.So()),this.Co.setConfig(this.ko)}onRemoteConfig(t){var e,i,r;if("errorTracking"in t){var s=null!==(e=null==(i=t.errorTracking)?void 0:i.suppressionRules)&&void 0!==e?e:[],n=null==(r=t.errorTracking)?void 0:r.captureExtensionExceptions;this.wo=s,this._instance.persistence&&this._instance.persistence.register({[Ht]:this.wo,[Vt]:n})}}get Io(){var t,e=!!this._instance.get_property(Vt),i=this._instance.config.error_tracking.captureExtensionExceptions;return null!==(t=null!=i?i:e)&&void 0!==t&&t}buildProperties(t,e){return this.xo.buildFromUnknown(t,{syntheticException:null==e?void 0:e.syntheticException,mechanism:{handled:null==e?void 0:e.handled}})}addExceptionStep(t,e){if(this.ko.enabled)try{if(!y(t)||0===t.trim().length)return void br.warn("Ignoring exception step because message must be a non-empty string");var r=this.To(e),{sanitizedProperties:s,droppedKeys:n}=function(t){if(!t)return{sanitizedProperties:{},droppedKeys:[]};var e=[];return{sanitizedProperties:Object.keys(t).reduce(((i,r)=>_t.has(r)?(e.push(r),i):(i[r]=t[r],i)),{}),droppedKeys:e}}(r);n.length>0&&br.warn("Ignoring reserved exception step fields",{droppedKeys:n}),this.Co.add(i({[pt]:t,[gt]:(new Date).toISOString()},s))}catch(t){br.error("Failed to add exception step. Ignoring breadcrumb.",t)}}sendExceptionEvent(t){try{var e=t.$exception_list;if(this.Eo(e)){if(this.Mo(e))return this.Po("Exception dropped: matched a suppression rule"),void br.info("Skipping exception capture because a suppression rule matched");if(!this.Io&&this.Ro(e))return this.Po("Exception dropped: thrown by a browser extension"),void br.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.Oo(e))return this.Po("Exception dropped: thrown by the PostHog SDK"),void br.info("Skipping exception capture because it was thrown by the PostHog SDK")}var i=this.ko.enabled&&x(t.$exception_steps)?this.Lo(t):t;try{var r=this._instance.capture("$exception",i,{_noTruncate:!0,_batchKey:"exceptionEvent",Zi:!0});return r&&this.Co.clear(),r}catch(t){return br.error("Failed to capture exception event. Dropping this exception.",t),void this.Co.clear()}}catch(t){return void br.error("Failed to process exception event. Ignoring this exception.",t)}}Lo(t){try{var e=this.Co.getAttachable();return 0===e.length?t:i({},t,{$exception_steps:e})}catch(e){return br.error("Failed to read buffered exception steps. Capturing exception without steps.",e),t}}Po(t){this.ko.enabled&&this.Co.add({[pt]:t,[gt]:(new Date).toISOString()})}To(t){return b(t)?i({},t):{}}So(){var t,e;return null!==(t=null==(e=this._instance.config.error_tracking)?void 0:e.exception_steps)&&void 0!==t?t:{}}Mo(t){if(0===t.length)return!1;var e=t.reduce(((t,e)=>{var{type:i,value:r}=e;return y(i)&&i.length>0&&t.$exception_types.push(i),y(r)&&r.length>0&&t.$exception_values.push(r),t}),{$exception_types:[],$exception_values:[]});return this.wo.some((t=>{var i=t.values.map((t=>{var i,r=Ni[t.operator],s=g(t.value)?t.value:[t.value],n=null!==(i=e[t.key])&&void 0!==i?i:[];return s.length>0&&r(s,n)}));return"OR"===t.type?i.some(Boolean):i.every(Boolean)}))}Ro(t){return t.flatMap((t=>{var e,i;return null!==(e=null==(i=t.stacktrace)?void 0:i.frames)&&void 0!==e?e:[]})).some((t=>t.filename&&t.filename.startsWith("chrome-extension://")))}Oo(t){if(t.length>0){var e,i,r,s,n=null!==(e=null==(i=t[0].stacktrace)?void 0:i.frames)&&void 0!==e?e:[],a=n[n.length-1];return null!==(r=null==a||null==(s=a.filename)?void 0:s.includes("posthog.com/static"))&&void 0!==r&&r}return!1}Eo(t){return!x(t)&&g(t)}}},Rr=i({productTours:class{get zr(){return this._instance.persistence}constructor(t){this.Fo=null,this.Ao=null,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if("productTours"in t){var e,i;if(this.zr&&this.zr.register({[qt]:!!t.productTours}),!Ji(this._instance))return!this.Fo&&x(null==(e=this.zr)?void 0:e.props[oe])||Wi.info("product tours disabled; stopping and clearing cached tours"),null==(i=this.Fo)||i.stop(),this.Fo=null,void this.clearCache();this.loadIfEnabled()}}loadIfEnabled(){!this.Fo&&Ji(this._instance)&&this.Mt((()=>this.$o()))}Mt(t){var e,i;null!=(e=Ft.__PosthogExtensions__)&&e.generateProductTours?t():null==(i=Ft.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"product-tours",(e=>{e?Wi.error("Could not load product tours script",e):t()}))}$o(){var t;!this.Fo&&null!=(t=Ft.__PosthogExtensions__)&&t.generateProductTours&&(this.Fo=Ft.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(t,e){if(void 0===e&&(e=!1),!g(this.Ao)||e){var i=this.zr;if(i){var r=i.props[oe];if(g(r)&&!e)return this.Ao=r,void t(r,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/product_tours/?token="+this._instance.config.token),method:"GET",callback:e=>{if(Ji(this._instance)){var r=e.statusCode;if(200!==r||!e.json){var s="Product Tours API could not be loaded, status: "+r;return Wi.error(s),void t([],{isLoaded:!1,error:s})}var n=g(e.json.product_tours)?e.json.product_tours:[];this.Ao=n,i&&i.register({[oe]:n}),t(n,{isLoaded:!0})}else t([],{isLoaded:!0})}})}else t(this.Ao,{isLoaded:!0})}getActiveProductTours(t){x(this.Fo)?t([],{isLoaded:!1,error:"Product tours not loaded"}):this.Fo.getActiveProductTours(t)}showProductTour(t){var e;null==(e=this.Fo)||e.showTourById(t)}previewTour(t){this.Fo?this.Fo.previewTour(t):this.Mt((()=>{var e;this.$o(),null==(e=this.Fo)||e.previewTour(t)}))}dismissProductTour(){var t;null==(t=this.Fo)||t.dismissTour("user_clicked_skip")}nextStep(){var t;null==(t=this.Fo)||t.nextStep()}previousStep(){var t;null==(t=this.Fo)||t.previousStep()}clearCache(){var t;this.Ao=null,null==(t=this.zr)||t.unregister(oe)}resetTour(t){var e;null==(e=this.Fo)||e.resetTour(t)}resetAllTours(){var t;null==(t=this.Fo)||t.resetAllTours()}cancelPendingTour(t){var e;null==(e=this.Fo)||e.cancelPendingTour(t)}}},Sr),Tr={siteApps:class{constructor(t){this.Do=0,this._instance=t,this.No=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}qo(t,e){if(e){var i=this.globalsForEvent(e);this.No.push(i),this.No.length>1e3&&(this.No=this.No.slice(10))}}get siteAppLoaders(){var t;return null==(t=Ft._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.siteApps}initialize(){if(this.isEnabled){var t=this._instance._addCaptureHook(this.qo.bind(this));this.Bo=()=>{t(),this.No=[],this.Bo=void 0}}}globalsForEvent(t){var e,r,s,n,a,o,l;if(!t)throw new Error("Event payload is required");var u={},h=this._instance.get_property("$groups")||[],v=this._instance.get_property("$stored_group_properties")||{};for(var[d,c]of Object.entries(v))u[d]={id:h[d],type:d,properties:c};var{$set_once:f,$set:p}=t;return{event:i({},function(t,e){if(null==t)return{};var i={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(-1!==e.indexOf(r))continue;i[r]=t[r]}return i}(t,Ki),{properties:i({},t.properties,p?{$set:i({},null!==(e=null==(r=t.properties)?void 0:r.$set)&&void 0!==e?e:{},p)}:{},f?{$set_once:i({},null!==(s=null==(n=t.properties)?void 0:n.$set_once)&&void 0!==s?s:{},f)}:{}),elements_chain:null!==(a=null==(o=t.properties)?void 0:o.$elements_chain)&&void 0!==a?a:"",distinct_id:null==(l=t.properties)?void 0:l.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:u}}jo(t){var e,i=null==(e=t.tagName)?void 0:e.toLowerCase();return"style"===i&&this._instance.config.prepare_external_dependency_stylesheet?this._instance.config.prepare_external_dependency_stylesheet(t)||(Gi.error("prepare_external_dependency_stylesheet returned null"),null):"script"===i&&this._instance.config.prepare_external_dependency_script?this._instance.config.prepare_external_dependency_script(t)||(Gi.error("prepare_external_dependency_script returned null"),null):t}Ho(){var t,e,i,r,s,n,a,o;if(!this._instance.config.prepare_external_dependency_stylesheet&&!this._instance.config.prepare_external_dependency_script)return()=>{};var l=null==St?void 0:St.defaultView,u=null==l||null==(t=l.Node)?void 0:t.prototype;if(!l||!u)return()=>{};if(this.Do++,this.Uo)return this.zo();var h=[],v=this,d=new WeakSet,c=(t,e,i)=>{if(null!=t&&t[e]){var r=t[e];t[e]=i(r),h.push((()=>{t[e]=r}))}},f=t=>{if(d.has(t))return t;var e=v.jo(t);return e&&d.add(e),e},p=t=>t.map((t=>"string"==typeof t?t:f(t))).filter((t=>!w(t)));return c(u,"appendChild",(t=>function(e){var i=f(e);return i?t.call(this,i):e})),c(u,"insertBefore",(t=>function(e,i){var r=f(e);return r?t.call(this,r,i):e})),c(u,"replaceChild",(t=>function(e,i){var r=f(e);return r?t.call(this,r,i):i})),[null==(e=l.Element)?void 0:e.prototype,null==(i=l.Document)?void 0:i.prototype,null==(r=l.DocumentFragment)?void 0:r.prototype].forEach((t=>{c(t,"append",(t=>function(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];return t.apply(this,p(i))})),c(t,"prepend",(t=>function(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];return t.apply(this,p(i))}))})),[null==(s=l.Element)?void 0:s.prototype,null==(n=l.CharacterData)?void 0:n.prototype,null==(a=l.DocumentType)?void 0:a.prototype].forEach((t=>{c(t,"before",(t=>function(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];return t.apply(this,p(i))})),c(t,"after",(t=>function(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];return t.apply(this,p(i))})),c(t,"replaceWith",(t=>function(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];var s=p(i);return i.length&&!s.length?void 0:t.apply(this,s)}))})),c(null==(o=l.Element)?void 0:o.prototype,"insertAdjacentElement",(t=>function(e,i){var r=f(i);return r?t.call(this,e,r):null})),this.Uo=()=>{h.forEach((t=>t())),this.Uo=void 0},this.zo()}zo(){var t=!1;return()=>{var e;t||(t=!0,this.Do--,0===this.Do&&(null==(e=this.Uo)||e.call(this)))}}Vo(t,e){void 0===e&&(e=!0);var i=this.Ho();try{var r=t(i);return e&&i(),r}catch(t){throw i(),t}}setupSiteApp(t){var e=this.apps[t.id],i=()=>{var i;!e.errored&&this.No.length&&(Gi.info("Processing "+this.No.length+" events for site app with id "+t.id),this.No.forEach((t=>this.Vo((()=>null==e.processEvent?void 0:e.processEvent(t))))),e.processedBuffer=!0),Object.values(this.apps).every((t=>t.processedBuffer||t.errored))&&(null==(i=this.Bo)||i.call(this))},r=!1,s=s=>{e.errored=!s,e.loaded=!0,Gi.info("Site app with id "+t.id+" "+(s?"loaded":"errored")),r&&i()};try{var{processEvent:n}=this.Vo((e=>t.init({posthog:this._instance,callback(t){e(),s(t)}})),!1);n&&(e.processEvent=n),r=!0}catch(e){Gi.error(Yi+t.id,e),s(!1)}if(r&&e.loaded)try{i()}catch(i){Gi.error("Error while processing buffered events PostHog app with config id "+t.id,i),e.errored=!0}}Wo(){var t=this.siteAppLoaders||[];for(var e of t)this.apps[e.id]={id:e.id,loaded:!1,errored:!1,processedBuffer:!1};for(var i of t)this.setupSiteApp(i)}Go(t){var e=this;if(0!==Object.keys(this.apps).length){var i=this.globalsForEvent(t),r=function(r){try{e.Vo((()=>null==r.processEvent?void 0:r.processEvent(i)))}catch(e){Gi.error("Error while processing event "+t.event+" for site app "+r.id,e)}};for(var s of Object.values(this.apps))r(s)}}onRemoteConfig(t){var e,i,r,s=this;if(null!=(e=this.siteAppLoaders)&&e.length)return this.isEnabled?(this.Wo(),void this._instance.on("eventCaptured",(t=>this.Go(t)))):void Gi.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null==(i=this.Bo)||i.call(this),null!=(r=t.siteApps)&&r.length)if(this.isEnabled){var n=function(t){var e;Ft["__$$ph_site_app_"+t]=s._instance,null==(e=Ft.__PosthogExtensions__)||null==e.loadSiteApp||e.loadSiteApp(s._instance,o,(e=>{if(e)return Gi.error(Yi+t,e)}))};for(var{id:a,url:o}of t.siteApps)n(a)}else Gi.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}},Ar={tracingHeaders:class{constructor(t){this.Zo=void 0,this.Qo=void 0,this.Jo=void 0,this.do=()=>{var t,e,i=this.Yo();i?(m(this.Zo)&&(this.Zo=null==(t=Ft.__PosthogExtensions__)||null==(t=t.tracingHeadersPatchFns)?void 0:t._patchXHR(i,(()=>this._instance.get_distinct_id()),this._instance.sessionManager)),m(this.Qo)&&(this.Qo=null==(e=Ft.__PosthogExtensions__)||null==(e=e.tracingHeadersPatchFns)?void 0:e._patchFetch(i,(()=>this._instance.get_distinct_id()),this._instance.sessionManager))):this.mo()},this._instance=t}initialize(){this.startIfEnabledOrStop()}Mt(t){var e,i;null!=(e=Ft.__PosthogExtensions__)&&e.tracingHeadersPatchFns?t():null==(i=Ft.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"tracing-headers",(e=>{if(e)return ci.error("failed to load script",e);t()}))}Ko(){var t,e;return null!==(t=null!==(e=this._instance.config.tracing_headers)&&void 0!==e?e:this._instance.config.addTracingHeaders)&&void 0!==t?t:this._instance.config.__add_tracing_headers}Yo(){var t=this.Ko();return g(t)?(g(this.Jo)?this.Jo.splice(0,this.Jo.length,...t):this.Jo=[...t],t.length>0?this.Jo:void 0):(g(this.Jo)&&this.Jo.splice(0),this.Jo=t||void 0,this.Jo)}mo(){var t,e;null==(t=this.Zo)||t.call(this),null==(e=this.Qo)||e.call(this),this.Zo=void 0,this.Qo=void 0}startIfEnabledOrStop(){this.Yo()?this.Mt(this.do):this.mo()}}},Ir=i({surveys:class{get Se(){return this._instance.config}constructor(t){this.Xo=void 0,this._surveyManager=null,this.ea=!1,this.ta=[],this.ra=null,this.ia=null,this._instance=t,this._surveyEventReceiver=null}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!this.Se.disable_surveys){var e=t.surveys;if(x(e))return tr.warn("Flags not loaded yet. Not loading surveys.");var i=g(e);this.Xo=i?e.length>0:e,tr.info("flags response received, isSurveysEnabled: "+this.Xo),this.loadIfEnabled()}}reset(){try{var t;null==(t=this._surveyEventReceiver)||t.reset(),localStorage.removeItem("lastSeenSurveyDate");for(var e=[],i=0;i<localStorage.length;i++){var r=localStorage.key(i);(null!=r&&r.startsWith(er)||null!=r&&r.startsWith("inProgressSurvey_"))&&e.push(r)}e.forEach((t=>localStorage.removeItem(t)))}catch(t){}}loadIfEnabled(){if(!this._surveyManager)if(this.ea)tr.info("Already initializing surveys, skipping...");else if(this.Se.disable_surveys)tr.info(ur);else if(this.Se.cookieless_mode&&this._instance.consent.isOptedOut())tr.info("Not loading surveys in cookieless mode without consent.");else{var t=null==Ft?void 0:Ft.__PosthogExtensions__;if(t){if(!m(this.Xo)||this.Se.advanced_enable_surveys){var e=this.Xo||this.Se.advanced_enable_surveys;this.ea=!0;try{var i=t.generateSurveys;if(i)return void this.na(i,e);var r=t.loadExternalDependency;if(!r)return void this.sa(ce);r(this._instance,"surveys",(i=>{i||!t.generateSurveys?this.sa("Could not load surveys script",i):this.na(t.generateSurveys,e)}))}catch(t){throw this.sa("Error initializing surveys",t),t}finally{this.ea=!1}}}else tr.error("PostHog Extensions not found.")}}na(t,e){this._surveyManager=t(this._instance,e),this._surveyEventReceiver=new or(this._instance),tr.info("Surveys loaded successfully"),this.oa({isLoaded:!0})}sa(t,e){tr.error(t,e),this.oa({isLoaded:!1,error:t})}onSurveysLoaded(t){return this.ta.push(t),this._surveyManager&&this.oa({isLoaded:!0}),()=>{this.ta=this.ta.filter((e=>e!==t))}}getSurveys(t,e){if(void 0===e&&(e=!1),this.Se.disable_surveys)return tr.info(ur),t([]);var i,r=this._instance.get_property(se);if(r&&!e)return t(r,{isLoaded:!0}),void(this.aa()&&this.getSurveys((()=>{}),!0));"undefined"!=typeof Promise&&this.ra?this.ra.then((e=>{var{surveys:i,context:r}=e;return t(i,r)})):("undefined"!=typeof Promise&&(this.ra=new Promise((t=>{i=t}))),this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/surveys/?token="+this.Se.token),method:"GET",timeout:this.Se.surveys_request_timeout_ms,callback:e=>{var r;this.ra=null;var s=e.statusCode;if(200!==s||!e.json){var n="Surveys API could not be loaded, status: "+s;tr.error(n),this.ia=Date.now();var a={isLoaded:!1,error:n};return t([],a),void(null==i||i({surveys:[],context:a}))}this.ia=null;var o,l=e.json.surveys||[],u=l.filter((t=>function(t){return!(!t.start_date||t.end_date)}(t)&&(function(t){var e;return!(null==(e=t.conditions)||null==(e=e.events)||null==(e=e.values)||!e.length)}(t)||function(t){var e;return!(null==(e=t.conditions)||null==(e=e.actions)||null==(e=e.values)||!e.length)}(t))));u.length>0&&(null==(o=this._surveyEventReceiver)||o.register(u)),null==(r=this._instance.persistence)||r.register({[se]:l,[ne]:Date.now()});var h={isLoaded:!0};t(l,h),null==i||i({surveys:l,context:h})}}))}aa(){return this.la()&&!this.ra&&!this.ua()}la(){var t=this._instance.get_property(ne);return E(t)&&Date.now()-t>3e5}ua(){return E(this.ia)&&3e5>Date.now()-this.ia}markSurveyAsSeen(t,e){var i;(t=>{try{var e=(t=>((t,e)=>{var i=""+er+e.id;return e.current_iteration&&e.current_iteration>0&&(i=""+er+e.id+"_"+e.current_iteration),i})(0,t))(t);if(localStorage.getItem(e))return;localStorage.setItem(e,"true")}catch(t){tr.error("Failed to persist survey seen state",t)}})({id:t,current_iteration:null!==(i=null==e?void 0:e.iteration)&&void 0!==i?i:null});try{localStorage.setItem("lastSeenSurveyDate",(new Date).toISOString())}catch(t){}}oa(t){for(var e of this.ta)try{if(!t.isLoaded)return e([],t);this.getSurveys(e)}catch(t){tr.error("Error in survey callback",t)}}getActiveMatchingSurveys(t,e){if(void 0===e&&(e=!1),!x(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(t,e);tr.warn("init was not called")}ha(t){var e=null;return this.getSurveys((i=>{var r;e=null!==(r=i.find((e=>e.id===t)))&&void 0!==r?r:null})),e}da(t){if(x(this._surveyManager))return{eligible:!1,reason:lr};var e="string"==typeof t?this.ha(t):t;return e?this._surveyManager.checkSurveyEligibility(e):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(t){if(x(this._surveyManager))return tr.warn("init was not called"),{visible:!1,disabledReason:lr};var e=this.da(t);return{visible:e.eligible,disabledReason:e.reason}}canRenderSurveyAsync(t,e){return x(this._surveyManager)?(tr.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:lr})):new Promise((i=>{this.getSurveys((e=>{var r,s=null!==(r=e.find((e=>e.id===t)))&&void 0!==r?r:null;if(s){var n=this.da(s);i({visible:n.eligible,disabledReason:n.reason})}else i({visible:!1,disabledReason:"Survey not found"})}),e)}))}renderSurvey(t,e,i){var r;if(x(this._surveyManager))tr.warn("init was not called");else{var s="string"==typeof t?this.ha(t):t;if(null!=s&&s.id)if(ir.includes(s.type)){var n=null==St?void 0:St.querySelector(e);if(n)return null!=(r=s.appearance)&&r.surveyPopupDelaySeconds?(tr.info("Rendering survey "+s.id+" with delay of "+s.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var t,e;tr.info("Rendering survey "+s.id+" with delay of "+(null==(t=s.appearance)?void 0:t.surveyPopupDelaySeconds)+" seconds"),null==(e=this._surveyManager)||e.renderSurvey(s,n,i),tr.info("Survey "+s.id+" rendered")}),1e3*s.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(s,n,i);tr.warn("Survey element not found")}else tr.warn("Surveys of type "+s.type+" cannot be rendered in the app");else tr.warn("Survey not found")}}displaySurvey(t,e){var r;if(x(this._surveyManager))tr.warn("init was not called");else{var s=this.ha(t);if(s){var n=s;if(null!=(r=s.appearance)&&r.surveyPopupDelaySeconds&&e.ignoreDelay&&(n=i({},s,{appearance:i({},s.appearance,{surveyPopupDelaySeconds:0})})),"popover"!==e.displayType&&e.initialResponses&&tr.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),!1===e.ignoreConditions){var a=this.canRenderSurvey(s);if(!a.visible)return void tr.warn("Survey is not eligible to be displayed: ",a.disabledReason)}"inline"!==e.displayType?this._surveyManager.handlePopoverSurvey(n,e):this.renderSurvey(n,e.selector,e.properties)}else tr.warn("Survey not found")}}cancelPendingSurvey(t){x(this._surveyManager)?tr.warn("init was not called"):this._surveyManager.cancelSurvey(t)}handlePageUnload(){var t;null==(t=this._surveyManager)||t.handlePageUnload()}}},Sr),$r={toolbar:class{constructor(t){this.instance=t}ca(t){Ft.ph_toolbar_state=t}va(){var t;return null!==(t=Ft.ph_toolbar_state)&&void 0!==t?t:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(t,e,i){if(void 0===t&&(t=void 0),void 0===e&&(e=void 0),void 0===i&&(i=void 0),Lt(this.instance.config))return!1;if(!xt||!St)return!1;t=null!=t?t:xt.location,i=null!=i?i:xt.history;try{if(!e){try{xt.localStorage.setItem("test","test"),xt.localStorage.removeItem("test")}catch(t){return!1}e=null==xt?void 0:xt.localStorage}var r,s=hr||ri(t.hash,"__posthog")||ri(t.hash,"state"),n=s?Mt((()=>JSON.parse(atob(decodeURIComponent(s)))))||Mt((()=>JSON.parse(decodeURIComponent(s)))):null;return n&&"ph_authorize"===n.action?((r=n).source="url",r&&Object.keys(r).length>0&&(n.desiredHash?t.hash=n.desiredHash:i?i.replaceState(i.state,"",t.pathname+t.search):t.hash="")):((r=JSON.parse(e.getItem(vr)||"{}")).source="localstorage",delete r.userIntent),!(!r.token||this.instance.config.token!==r.token||(this.loadToolbar(r),0))}catch(t){return!1}}fa(t){var e=Ft.ph_load_toolbar||Ft.ph_load_editor;!x(e)&&_(e)?e(t,this.instance):dr.warn("No toolbar load function found")}loadToolbar(t){var e=!(null==St||!St.getElementById(de));if(!xt||e)return!1;var r="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,s=i({token:this.instance.config.token},t,{apiURL:this.instance.requestRouter.endpointFor("ui")},r?{instrument:!1}:{});if(xt.localStorage.setItem(vr,JSON.stringify(i({},s,{source:void 0}))),2===this.va())this.fa(s);else if(0===this.va()){var n;this.ca(1),null==(n=Ft.__PosthogExtensions__)||null==n.loadExternalDependency||n.loadExternalDependency(this.instance,"toolbar",(t=>{if(t)return dr.error("[Toolbar] Failed to load",t),void this.ca(0);this.ca(2),this.fa(s)})),jt(xt,"turbolinks:load",(()=>{this.ca(0),this.loadToolbar(s)}))}return!0}pa(t){return this.loadToolbar(t)}maybeLoadEditor(t,e,i){return void 0===t&&(t=void 0),void 0===e&&(e=void 0),void 0===i&&(i=void 0),this.maybeLoadToolbar(t,e,i)}}},Or=i({experiments:wr},Sr),Mr={conversations:class{constructor(t){this.ga=void 0,this._conversationsManager=null,this.ma=!1,this.ya=null,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!this._instance.config.disable_conversations){var e=t.conversations;x(e)||(k(e)?this.ga=e:(this.ga=e.enabled,this.ya=e),this.loadIfEnabled())}}reset(){var t;null==(t=this._conversationsManager)||t.reset(),this._conversationsManager=null,this.ga=void 0,this.ya=null}loadIfEnabled(){if(!(this._conversationsManager||this.ma||this._instance.config.disable_conversations||Lt(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var t=null==Ft?void 0:Ft.__PosthogExtensions__;if(t&&!m(this.ga)&&this.ga)if(this.ya&&this.ya.token){this.ma=!0;try{var e=t.initConversations;if(e)return this.ba(e),void(this.ma=!1);var i=t.loadExternalDependency;if(!i)return void this._a(ce);i(this._instance,"conversations",(e=>{e||!t.initConversations?this._a("Could not load conversations script",e):this.ba(t.initConversations),this.ma=!1}))}catch(t){this._a("Error initializing conversations",t),this.ma=!1}}else xr.error("Conversations enabled but missing token in remote config.")}}ba(t){if(this.ya)try{this._conversationsManager=t(this.ya,this._instance),xr.info("Conversations loaded successfully")}catch(t){this._a("Error completing conversations initialization",t)}else xr.error("Cannot complete initialization: remote config is null")}_a(t,e){xr.error(t,e),this._conversationsManager=null,this.ma=!1}show(){this._conversationsManager?this._conversationsManager.show():xr.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this.ga&&!w(this._conversationsManager)}isVisible(){var t,e;return null!==(t=null==(e=this._conversationsManager)?void 0:e.isVisible())&&void 0!==t&&t}sendMessage(t,i,r){var s=this;return e((function*(){return s._conversationsManager?s._conversationsManager.sendMessage(t,i,r):(xr.warn(Er),null)}))()}getMessages(t,i){var r=this;return e((function*(){return r._conversationsManager?r._conversationsManager.getMessages(t,i):(xr.warn(Er),null)}))()}markAsRead(t){var i=this;return e((function*(){return i._conversationsManager?i._conversationsManager.markAsRead(t):(xr.warn(Er),null)}))()}getTickets(t){var i=this;return e((function*(){return i._conversationsManager?i._conversationsManager.getTickets(t):(xr.warn(Er),null)}))()}requestRestoreLink(t){var i=this;return e((function*(){return i._conversationsManager?i._conversationsManager.requestRestoreLink(t):(xr.warn(Er),null)}))()}restoreFromToken(t){var i=this;return e((function*(){return i._conversationsManager?i._conversationsManager.restoreFromToken(t):(xr.warn(Er),null)}))()}restoreFromUrlToken(){var t=this;return e((function*(){return t._conversationsManager?t._conversationsManager.restoreFromUrlToken():(xr.warn(Er),null)}))()}getCurrentTicketId(){var t,e;return null!==(t=null==(e=this._conversationsManager)?void 0:e.getCurrentTicketId())&&void 0!==t?t:null}getWidgetSessionId(){var t,e;return null!==(t=null==(e=this._conversationsManager)?void 0:e.getWidgetSessionId())&&void 0!==t?t:null}en(){var t;null==(t=this._conversationsManager)||t.setIdentity()}tn(){var t;null==(t=this._conversationsManager)||t.clearIdentity()}}},jr={logs:class{constructor(t){var e;this.wa=!1,this.xa=!1,this.Ae=At("[logs]"),this._r=[],this.ka=[],this.Sa=()=>{var t,e;null==(t=this.Ca)||t.onReconnect(),null==(e=this.Ia)||e.onReconnect()},this._instance=t,this._instance&&null!=(e=this._instance.config.logs)&&e.captureConsoleLogs&&(this.wa=!0),xt&&jt(xt,"online",this.Sa)}Ta(t,e,i,r){var s,n=function(t,e){var i,r,s,n,a,o,l,u=null!==(i=null==t?void 0:t.flushIntervalMs)&&void 0!==i?i:3e3,h=null!==(r=null==t?void 0:t.maxBufferSize)&&void 0!==r?r:100,v=null!=e&&e.consoleCapture?void 0:null!==(s=null==t?void 0:t.maxLogsPerInterval)&&void 0!==s?s:1e3,d=m(v)?Math.max(h,2048):Math.max(h,v),c=null==t?void 0:t.resourceAttributes;return{serviceName:null!==(n=null!==(a=null==c?void 0:c["service.name"])&&void 0!==a?a:null==t?void 0:t.serviceName)&&void 0!==n?n:null==e?void 0:e.serviceNameDefault,serviceVersion:null!==(o=null==c?void 0:c["service.version"])&&void 0!==o?o:null==t?void 0:t.serviceVersion,environment:null!==(l=null==c?void 0:c["deployment.environment"])&&void 0!==l?l:null==t?void 0:t.environment,resourceAttributes:c,beforeSend:null==t?void 0:t.beforeSend,flushIntervalMs:u,maxBufferSize:h,maxQueueSize:d,maxBatchRecordsPerPost:100,rateCapWindowMs:u,maxLogsPerInterval:v,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}}(null==(s=this._instance)||null==(s=s.config)?void 0:s.logs,i);return[new U(this.Ea(t,e),n,this.Ae,(()=>this.Ma()),(t=>t()),void 0,r),n]}Pa(){var t,e,i=null==(t=this._instance)||null==(t=t.config)?void 0:t.logs;return this.Ca&&this.Ra===i||(null==(e=this.Ca)||e.reset(),this.Ra=i,[this.Ca,this.Oa]=this.Ta((()=>this._r),(t=>{this._r=t}))),this.Ca}La(){var t,e,i=null==(t=this._instance)||null==(t=t.config)?void 0:t.logs;return this.Ia&&this.Fa===i||(null==(e=this.Ia)||e.reset(),this.Fa=i,[this.Ia,this.Aa]=this.Ta((()=>this.ka),(t=>{this.ka=t}),{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},kr)),this.Ia}initialize(){this.loadIfEnabled()}onRemoteConfig(t){var e,i=null==(e=t.logs)?void 0:e.captureConsoleLogs;!x(i)&&i&&(this.wa=!0,this.loadIfEnabled())}reset(){var t,e;this._r=[],null==(t=this.Ca)||t.reset(),this.ka=[],null==(e=this.Ia)||e.reset()}captureLog(t){this.Pa().captureLog(t)}le(t){this.La().captureLog(t)}get logger(){return this.$a||(this.$a={trace:(t,e)=>this.captureLog({body:t,level:"trace",attributes:e}),debug:(t,e)=>this.captureLog({body:t,level:"debug",attributes:e}),info:(t,e)=>this.captureLog({body:t,level:"info",attributes:e}),warn:(t,e)=>this.captureLog({body:t,level:"warn",attributes:e}),error:(t,e)=>this.captureLog({body:t,level:"error",attributes:e}),fatal:(t,e)=>this.captureLog({body:t,level:"fatal",attributes:e})}),this.$a}flushLogs(t){t?this.Da(t):(this.Ca&&this.Ca.flush().catch((t=>this.Ae.error("PostHog logs flush failed:",t))),this.Ia&&this.Ia.flush().catch((t=>this.Ae.error("PostHog logs flush failed:",t))))}loadIfEnabled(){if(this.wa&&!this.xa){var t=null==Ft?void 0:Ft.__PosthogExtensions__;if(t){var e=t.loadExternalDependency;e?e(this._instance,"logs",(e=>{var i;e||null==(i=t.logs)||!i.initializeLogs?this.Ae.error("Could not load logs script",e):(t.logs.initializeLogs(this._instance),this.xa=!0)})):this.Ae.error(ce)}else this.Ae.error("PostHog Extensions not found.")}}Ea(t,e){var i=this._instance;return{get isDisabled(){return!1},get optedOut(){return!i.is_capturing()},getPersistedProperty:e=>e===l.LogsQueue?t():void 0,setPersistedProperty(t,i){var r;t===l.LogsQueue&&e(null!==(r=i)&&void 0!==r?r:[])},ht:t=>this.ht(t),getLibraryId:()=>s,getLibraryVersion:()=>r}}ht(t){return new Promise((e=>{var i=!1,r=t=>{i||(i=!0,clearTimeout(s),e(t))},s=setTimeout((()=>r({kind:"retry-later",error:new Error("logs request timed out")})),9e4);this._instance._send_request({method:"POST",url:this.Na(),data:t,compression:"best-available",batchKey:"logs",fireCallbackOnDrop:!0,callback(t){var e=t.statusCode;if(e>=200&&300>e)r({kind:"ok"});else if(413===e)r({kind:"too-large"});else if(0!==e&&429!==e&&500>e)r({kind:"fatal",error:new Error("logs request failed with status "+e)});else{var i;r({kind:"retry-later",error:null!==(i=t.error)&&void 0!==i?i:new Error("logs request failed with status "+e)})}}})}))}Da(t){this._r.length>0&&this.qa(t,this._r,this.Oa,s,(t=>{this._r=t})),this.ka.length>0&&this.qa(t,this.ka,this.Aa,kr,(t=>{this.ka=t}))}qa(t,e,i,n,a){if(0!==e.length){var o=e.map((t=>t.record));a([]);var l=z(o,N(i,s,r),n,r);this._instance._send_request({method:"POST",url:this.Na(),data:l,compression:"best-available",batchKey:"logs",transport:t})}}Na(){return this._instance.requestRouter.endpointFor("api","/i/v1/logs")+"?token="+encodeURIComponent(this._instance.config.token)}Ma(){var t,e={};if(e.distinctId=this._instance.get_distinct_id(),this._instance.sessionManager){var{sessionId:i,windowId:r,sessionStartTimestamp:s,lastActivityTimestamp:n}=this._instance.sessionManager.checkAndGetSessionAndWindowId(!0);e.sessionId=i,e.windowId=r,x(s)||(e.sessionStartTimestamp=s),x(n)||(e.lastActivityTimestamp=n)}if(null!=Ft&&null!=(t=Ft.location)&&t.href&&(e.currentUrl=this._instance.config.disable_capture_url_hashes?A(Ft.location.href):Ft.location.href),this._instance.featureFlags){var a=this._instance.featureFlags.getFlags();a&&a.length>0&&(e.activeFeatureFlags=a)}return e}}},Lr=i({},Sr,Cr,Fr,Pr,Rr,Tr,Ir,Ar,$r,Or,Mr,jr),Dr=Sr,Nr=Cr,zr=Fr,Ur=Pr,Hr=Rr,Vr=Tr,Br=Ir,qr=Ar,Wr=$r,Jr=Or,Kr=Mr,Gr=jr;export{Lr as AllExtensions,zr as AnalyticsExtensions,Kr as ConversationsExtensions,Ur as ErrorTrackingExtensions,Jr as ExperimentsExtensions,Dr as FeatureFlagsExtensions,Gr as LogsExtensions,Hr as ProductToursExtensions,Nr as SessionReplayExtensions,Vr as SiteAppsExtensions,Br as SurveysExtensions,Wr as ToolbarExtensions,qr as TracingExtensions};
|
|
1
|
+
function t(t,e,i,r,s,n,a){try{var o=t[n](a),l=o.value}catch(t){return void i(t)}o.done?e(l):Promise.resolve(l).then(r,s)}function e(e){return function(){var i=this,r=arguments;return new Promise((function(s,n){var a=e.apply(i,r);function o(e){t(a,s,n,o,l,"next",e)}function l(e){t(a,s,n,o,l,"throw",e)}o(void 0)}))}}function i(){return i=Object.assign?Object.assign.bind():function(t){for(var e=1;arguments.length>e;e++){var i=arguments[e];for(var r in i)({}).hasOwnProperty.call(i,r)&&(t[r]=i[r])}return t},i.apply(null,arguments)}var r="1.396.8",s="web",n=t=>{if("string"!=typeof t)return t;try{return JSON.parse(t)}catch(e){return t}};function a(t){return"string"==typeof t||t}function o(t){return"string"==typeof t?t:void 0}var l=function(t){return t.AnonymousId="anonymous_id",t.DistinctId="distinct_id",t.Props="props",t.EnablePersonProcessing="enable_person_processing",t.PersonMode="person_mode",t.FeatureFlagDetails="feature_flag_details",t.FeatureFlags="feature_flags",t.FeatureFlagPayloads="feature_flag_payloads",t.BootstrapFeatureFlagDetails="bootstrap_feature_flag_details",t.BootstrapFeatureFlags="bootstrap_feature_flags",t.BootstrapFeatureFlagPayloads="bootstrap_feature_flag_payloads",t.OverrideFeatureFlags="override_feature_flags",t.Queue="queue",t.LogsQueue="logs_queue",t.OptedOut="opted_out",t.SessionId="session_id",t.SessionStartTimestamp="session_start_timestamp",t.SessionLastTimestamp="session_timestamp",t.PersonProperties="person_properties",t.GroupProperties="group_properties",t.InstalledAppBuild="installed_app_build",t.InstalledAppVersion="installed_app_version",t.SessionReplay="session_replay",t.SessionReplayEventTriggerActivatedSession="session_replay_event_trigger_activated_session",t.SurveyLastSeenDate="survey_last_seen_date",t.SurveysSeen="surveys_seen",t.Surveys="surveys",t.RemoteConfig="remote_config",t.FlagsEndpointWasHit="flags_endpoint_was_hit",t.DeviceId="device_id",t}({}),u=["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"],h=function(t,e){if(void 0===e&&(e=[]),!t)return!1;var i=t.toLowerCase();return u.concat(e).some((t=>{var e=t.toLowerCase();return-1!==i.indexOf(e)}))};function v(t,e){return-1!==t.indexOf(e)}var d=function(t){return t.trim()},c=Object.prototype,f=c.hasOwnProperty,p=c.toString,g=Array.isArray||function(t){return"[object Array]"===p.call(t)},_=t=>"function"==typeof t,b=t=>t===Object(t)&&!g(t),m=t=>void 0===t,y=t=>"[object String]"==p.call(t),w=t=>null===t,x=t=>m(t)||w(t),E=t=>"[object Number]"==p.call(t)&&t==t,k=t=>"[object Boolean]"===p.call(t),S=t=>t instanceof FormData;function C(t){return null===t||"object"!=typeof t}function F(t,e){return{}.toString.call(t)==="[object "+e+"]"}function P(t){return"undefined"!=typeof Event&&function(t,e){try{return t instanceof e}catch(t){return!1}}(t,Event)}function R(t,e,i,r,s){return e>i&&(r.warn("min cannot be greater than max."),e=i),E(t)?t>i?(r.warn(" cannot be greater than max: "+i+". Using max value instead."),i):e>t?(r.warn(" cannot be less than min: "+e+". Using min value instead."),e):t:(r.warn(" must be a number. using max or fallback. max: "+i+", fallback: "+s),R(i,e,i,r))}class T{constructor(t){this.Ee={},this.Pe=t.Pe,this.Fe=R(t.bucketSize,0,100,t.Ae),this.$e=R(t.refillRate,0,this.Fe,t.Ae),this.De=R(t.refillInterval,0,864e5,t.Ae)}Ne(t,e){var i=Math.floor((e-t.lastAccess)/this.De);i>0&&(t.tokens=Math.min(t.tokens+i*this.$e,this.Fe),t.lastAccess=t.lastAccess+i*this.De)}consumeRateLimit(t){var e,i=Date.now(),r=String(t),s=this.Ee[r];return s?this.Ne(s,i):this.Ee[r]=s={tokens:this.Fe,lastAccess:i},0===s.tokens||(s.tokens--,0===s.tokens&&(null==(e=this.Pe)||e.call(this,t)),0===s.tokens)}stop(){this.Ee={}}}function A(t){return t?t.split("#")[0]:t}function I(t,e){var i=setTimeout(t,e);return(null==i?void 0:i.unref)&&(null==i||i.unref()),i}var O={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}},M=O.info;function j(t){if(k(t))return{boolValue:t};if("number"==typeof t)return Number.isFinite(t)?Number.isInteger(t)?{intValue:t}:{doubleValue:t}:{stringValue:String(t)};if("string"==typeof t)return{stringValue:t};if(g(t))return{arrayValue:{values:t.map((t=>j(t)))}};try{return{stringValue:JSON.stringify(t)}}catch(e){return{stringValue:String(t)}}}function L(t){var e=[];for(var i in t){var r=t[i];w(r)||m(r)||e.push({key:i,value:j(r)})}return e}function D(t,e){var r=t.level||"info",{text:s,number:n}=O[r]||M,a=String(Date.now())+"000000",o={};e.distinctId&&(o.posthogDistinctId=e.distinctId),e.sessionId&&(o.sessionId=e.sessionId),e.windowId&&(o["window.id"]=e.windowId),x(e.sessionStartTimestamp)||(o.sessionStartTimestamp=String(e.sessionStartTimestamp)),x(e.lastActivityTimestamp)||(o.lastActivityTimestamp=String(e.lastActivityTimestamp)),e.currentUrl&&(o["url.full"]=e.currentUrl),e.screenName&&(o["screen.name"]=e.screenName),e.appState&&(o["app.state"]=e.appState),e.activeFeatureFlags&&e.activeFeatureFlags.length>0&&(o.feature_flags=e.activeFeatureFlags);var l=i({},o,t.attributes||{}),u={timeUnixNano:a,observedTimeUnixNano:a,severityNumber:n,severityText:s,body:{stringValue:t.body},attributes:L(l)};return t.trace_id&&(u.traceId=t.trace_id),t.span_id&&(u.spanId=t.span_id),m(t.trace_flags)||(u.flags=t.trace_flags),u}function N(t,e,r){return i({},t.resourceAttributes,{"service.name":t.serviceName||"unknown_service"},t.environment&&{"deployment.environment":t.environment},t.serviceVersion&&{"service.version":t.serviceVersion},{"telemetry.sdk.name":e,"telemetry.sdk.version":r})}function z(t,e,i,r){return{resourceLogs:[{resource:{attributes:L(e)},scopeLogs:[{scope:{name:i,version:r},logRecords:t}]}]}}let U=class{constructor(t,e,i,r,s,n,a){var o;void 0===n&&(n=()=>Promise.resolve()),this._instance=t,this.Se=e,this.Ae=i,this.qe=r,this.Be=s,this.je=n,this.He=a,this.Ue=null,this.ze=0,this.Ve=0,this.We=0,this.Ge=0,this.Ze=!1,this.Qe=e.maxBufferSize,this.Je=Math.max(null!==(o=e.maxQueueSize)&&void 0!==o?o:e.maxBufferSize,e.maxBufferSize),this.Ye=e.flushIntervalMs,this.Ke=e.maxBatchRecordsPerPost,this.Xe=e.rateCapWindowMs,this.et=e.maxLogsPerInterval}reset(){this.tt(),this.Ue=null,this.We=0,this.Ge=0,this.Ze=!1,this.ze=0,this.Ve=0,this.Ke=this.Se.maxBatchRecordsPerPost}onReconnect(){this.Ve=0,this.rt()}captureLog(t){if(!this._instance.isDisabled&&!this._instance.optedOut&&null!=t&&t.body){var e=this.it(t);if(null!==e)if(e.body){if(this.nt()){var i={record:D(e,this.qe())};this.Be((()=>this.st(i)))}}else this.Ae.info("Log was rejected in beforeSend function")}}it(t){var e=this.Se.beforeSend;if(!e)return t;var i=g(e)?e:[e],r=t;for(var s of i)try{var n=s(r);if(!n)return this.Ae.info("Log was rejected in beforeSend function"),null;r=n}catch(t){return this.Ae.error("Error in beforeSend function for log:",t),null}return r}nt(){if(void 0===this.et)return!0;var t=Date.now(),e=t-this.We;return this.Xe>e&&e>=0||(this.We=t,this.Ge=0,this.Ze=!1),this.et>this.Ge?(this.Ge++,!0):(this.Ze||(this.Ae.warn("captureLog dropping logs: exceeded "+this.et+" logs per "+this.Xe+"ms"),this.Ze=!0),!1)}flush(){var t=this;return e((function*(){if(!t._instance.isDisabled)return t.Ue||(t.Ue=t.ot().finally((()=>{t.Ue=null}))),t.Ue}))()}ot(){var t=this;return e((function*(){var e;t.tt();var i=null!==(e=t._instance.getPersistedProperty(l.LogsQueue))&&void 0!==e?e:[];if(0!==i.length)for(var r=i.length,s=0;i.length>0&&r>s;){var n,a;t.ze=0;var o=Math.min(i.length,t.Ke),u=i.slice(0,o),h=z(u.map((t=>t.record)),t.ut(),null!==(n=t.He)&&void 0!==n?n:t._instance.getLibraryId(),t._instance.getLibraryVersion()),v=yield t._instance.ht(h);if("too-large"===v.kind&&u.length>1)t.Ke=Math.max(1,Math.floor(u.length/2)),t.Ae.warn("Received 413 when sending logs batch of size "+u.length+", reducing batch size to "+t.Ke);else{if("retry-later"===v.kind)throw v.error;if("too-large"===v.kind?t.Ae.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"===v.kind&&t.Se.maxBatchRecordsPerPost>t.Ke&&(t.Ke=Math.min(t.Se.maxBatchRecordsPerPost,t.Ke+1)),yield t.dt(u.length),i=null!==(a=t._instance.getPersistedProperty(l.LogsQueue))&&void 0!==a?a:[],s+=u.length,"fatal"===v.kind)throw v.error}}}))()}dt(t){var i=this;return e((function*(){var e,r=Math.max(0,t-i.ze),s=null!==(e=i._instance.getPersistedProperty(l.LogsQueue))&&void 0!==e?e:[];i._instance.setPersistedProperty(l.LogsQueue,s.slice(r)),yield i.je()}))()}ut(){return N(this.Se,this._instance.getLibraryId(),this._instance.getLibraryVersion())}st(t){var e;if(!this._instance.optedOut){var i=null!==(e=this._instance.getPersistedProperty(l.LogsQueue))&&void 0!==e?e:[];this.Je>i.length||(i.shift(),this.ze++,this.Ae.info("Logs queue is full, dropping oldest record.")),i.push(t),this._instance.setPersistedProperty(l.LogsQueue,i),this.Qe>i.length?this.ct():this.rt()}}ct(t){void 0===t&&(t=this.Ye),this.vt||(this.vt=I((()=>{this.vt=void 0,this.rt()}),t))}ft(){var t=Math.min(Math.max(0,this.Ve-1),6);return this.Ye*Math.pow(2,t)}yt(){var t=this._instance.getPersistedProperty(l.LogsQueue);return!!t&&t.length>0}shutdown(t){var i=this;return e((function*(){i.tt();var e=i.flush().catch((()=>{}));void 0!==t?yield Promise.race([e,new Promise((e=>I(e,t)))]):yield e}))()}flushWithTimeout(t){var i=this;return e((function*(){var e=!1,r=i.flush(),s=new Promise((i=>I((()=>{e=!0,i()}),t)));try{yield Promise.race([r,s])}finally{e&&r.catch((()=>{}))}}))()}rt(){this.flush().then((()=>{this.Ve=0}),(t=>{this.Ve++,this.Ae.error("PostHog logs flush failed:",t)})).finally((()=>{!this._instance.isDisabled&&this.yt()&&this.ct(this.ft())}))}tt(){this.vt&&(clearTimeout(this.vt),this.vt=void 0)}};var H,V,B;function q(t){var e=globalThis._posthogChunkIds;if(e){var i=Object.keys(e);return B&&i.length===V?B:(V=i.length,B=i.reduce(((i,r)=>{H||(H={});var s=H[r];if(s)i[s[0]]=s[1];else for(var n=t(r),a=n.length-1;a>=0;a--){var o=n[a],l=null==o?void 0:o.filename,u=e[r];if(l&&u){i[l]=u,H[r]=[l,u];break}}return i}),{}))}}class W{constructor(t,e,i){void 0===i&&(i=[]),this.coercers=t,this.stackParser=e,this.modifiers=i}buildFromUnknown(t,e){void 0===e&&(e={});var i=e&&e.mechanism||{handled:!0,type:"generic"},r=this.buildCoercingContext(i,e,0).apply(t),s=this.buildParsingContext(e),n=this.parseStacktrace(r,s);return{$exception_list:this.convertToExceptionList(n,i),$exception_level:"error"}}modifyFrames(t){var i=this;return e((function*(){for(var e of t)e.stacktrace&&e.stacktrace.frames&&g(e.stacktrace.frames)&&(e.stacktrace.frames=yield i.applyModifiers(e.stacktrace.frames));return t}))()}coerceFallback(t){var e;return{type:"Error",value:"Unknown error",stack:null==(e=t.syntheticException)?void 0:e.stack,synthetic:!0}}parseStacktrace(t,e){var r,s;return null!=t.cause&&(r=this.parseStacktrace(t.cause,e)),""!=t.stack&&null!=t.stack&&(s=this.applyChunkIds(this.stackParser(t.stack,t.synthetic?e.skipFirstLines:0),e.chunkIdMap)),i({},t,{cause:r,stack:s})}applyChunkIds(t,e){return t.map((t=>(t.filename&&e&&(t.chunk_id=e[t.filename]),t)))}applyCoercers(t,e){for(var i of this.coercers)if(i.match(t))return i.coerce(t,e);return this.coerceFallback(e)}applyModifiers(t){var i=this;return e((function*(){var e=t;for(var r of i.modifiers)e=yield r(e);return e}))()}convertToExceptionList(t,e){var r,s,n,a={type:t.type,value:t.value,mechanism:{type:null!==(r=e.type)&&void 0!==r?r:"generic",handled:null===(s=e.handled)||void 0===s||s,synthetic:null!==(n=t.synthetic)&&void 0!==n&&n}};t.stack&&(a.stacktrace={type:"raw",frames:t.stack});var o=[a];return null!=t.cause&&o.push(...this.convertToExceptionList(t.cause,i({},e,{handled:!0}))),o}buildParsingContext(t){var e;return{chunkIdMap:q(this.stackParser),skipFirstLines:null!==(e=t.skipFirstLines)&&void 0!==e?e:1}}buildCoercingContext(t,e,r){void 0===r&&(r=0);var s=(i,r)=>{if(4>=r){var s=this.buildCoercingContext(t,e,r);return this.applyCoercers(i,s)}};return i({},e,{syntheticException:0==r?e.syntheticException:void 0,mechanism:t,apply:t=>s(t,r),next:t=>s(t,r+1)})}}var J="?";function K(t,e,i,r,s){var n={platform:t,filename:e,function:"<anonymous>"===i?J:i,in_app:!0};return m(r)||(n.lineno=r),m(s)||(n.colno=s),n}var G=(t,e)=>{var i=-1!==t.indexOf("safari-extension"),r=-1!==t.indexOf("safari-web-extension");return i||r?[-1!==t.indexOf("@")?t.split("@")[0]:J,i?"safari-extension:"+e:"safari-web-extension:"+e]:[t,e]},Y=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,Q=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,Z=/\((\S*)(?::(\d+))(?::(\d+))\)/,X=(t,e)=>{var i=Y.exec(t);if(i){var[,r,s,n]=i;return K(e,r,J,+s,+n)}var a=Q.exec(t);if(a){if(a[2]&&0===a[2].indexOf("eval")){var o=Z.exec(a[2]);o&&(a[2]=o[1],a[3]=o[2],a[4]=o[3])}var[l,u]=G(a[1]||J,a[2]);return K(e,u,l,a[3]?+a[3]:void 0,a[4]?+a[4]:void 0)}},tt=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,et=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,it=(t,e)=>{var i=tt.exec(t);if(i){if(i[3]&&i[3].indexOf(" > eval")>-1){var r=et.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]||J;return[n,s]=G(n,s),K(e,s,n,i[4]?+i[4]:void 0,i[5]?+i[5]:void 0)}},rt=/\(error: (.*)\)/;class st{match(t){return this.isDOMException(t)||this.isDOMError(t)}coerce(t,e){var i=y(t.stack);return{type:this.getType(t),value:this.getValue(t),stack:i?t.stack:void 0,cause:t.cause?e.next(t.cause):void 0,synthetic:!1}}getType(t){return this.isDOMError(t)?"DOMError":"DOMException"}getValue(t){var e=t.name||(this.isDOMError(t)?"DOMError":"DOMException");return t.message?e+": "+t.message:e}isDOMException(t){return F(t,"DOMException")}isDOMError(t){return F(t,"DOMError")}}class nt{match(t){return t instanceof Error}coerce(t,e){return{type:this.getType(t),value:this.getMessage(t,e),stack:this.getStack(t),cause:t.cause?e.next(t.cause):void 0,synthetic:!1}}getType(t){return t.name||t.constructor.name}getMessage(t,e){var i=t.message;return String(i.error&&"string"==typeof i.error.message?i.error.message:i)}getStack(t){return t.stacktrace||t.stack||void 0}}class at{constructor(){}match(t){return F(t,"ErrorEvent")&&null!=t.error}coerce(t,e){var i;return e.apply(t.error)||{type:"ErrorEvent",value:t.message,stack:null==(i=e.syntheticException)?void 0:i.stack,synthetic:!0}}}var ot=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;class lt{match(t){return"string"==typeof t}coerce(t,e){var i,[r,s]=this.getInfos(t);return{type:null!=r?r:"Error",value:null!=s?s:t,stack:null==(i=e.syntheticException)?void 0:i.stack,synthetic:!0}}getInfos(t){var e="Error",i=t,r=t.match(ot);return r&&(e=r[1],i=r[2]),[e,i]}}var ut=["fatal","error","warning","log","info","debug"];function ht(t,e){void 0===e&&(e=40);var i=Object.keys(t);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(e>=s.length)return r===i.length?s:s.length>e?s.slice(0,e)+"...":s}return""}class vt{match(t){return"object"==typeof t&&null!==t}coerce(t,e){var i,r=this.getErrorPropertyFromObject(t);return r?e.apply(r):{type:this.getType(t),value:this.getValue(t),stack:null==(i=e.syntheticException)?void 0:i.stack,level:this.isSeverityLevel(t.level)?t.level:"error",synthetic:!0}}getType(t){return P(t)?t.constructor.name:"Error"}getValue(t){if("name"in t&&"string"==typeof t.name){var e="'"+t.name+"' captured as exception";return"message"in t&&"string"==typeof t.message&&(e+=" with message: '"+t.message+"'"),e}if("message"in t&&"string"==typeof t.message)return t.message;var i=this.getObjectClassName(t);return(i&&"Object"!==i?"'"+i+"'":"Object")+" captured as exception with keys: "+ht(t)}isSeverityLevel(t){return y(t)&&!(t=>y(t)&&0===t.trim().length)(t)&&ut.indexOf(t)>=0}getErrorPropertyFromObject(t){for(var e in t)if({}.hasOwnProperty.call(t,e)){var i=t[e];if(i instanceof Error)return i}}getObjectClassName(t){try{var e=Object.getPrototypeOf(t);return e?e.constructor.name:void 0}catch(t){return}}}class dt{match(t){return P(t)}coerce(t,e){var i,r=t.constructor.name;return{type:r,value:r+" captured as exception with keys: "+ht(t),stack:null==(i=e.syntheticException)?void 0:i.stack,synthetic:!0}}}class ct{match(t){return C(t)}coerce(t,e){var i;return{type:"Error",value:"Primitive value captured as exception: "+String(t),stack:null==(i=e.syntheticException)?void 0:i.stack,synthetic:!0}}}class ft{match(t){return F(t,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(t)}isCustomEventWrappingRejection(t){if(!P(t))return!1;try{var e=t.detail;return null!=e&&"object"==typeof e&&"reason"in e}catch(t){return!1}}coerce(t,e){var i,r=this.getUnhandledRejectionReason(t);return C(r)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(r),stack:null==(i=e.syntheticException)?void 0:i.stack,synthetic:!0}:e.apply(r)}getUnhandledRejectionReason(t){try{if("reason"in t)return t.reason;if("detail"in t&&null!=t.detail&&"object"==typeof t.detail&&"reason"in t.detail)return t.detail.reason}catch(t){}return t}}var pt="$message",gt="$timestamp",_t=new Set([pt,gt]),bt={enabled:!0,max_bytes:32768};function mt(t){var e;return t?{enabled:null!==(e=t.enabled)&&void 0!==e?e:bt.enabled,max_bytes:wt(t.max_bytes,bt.max_bytes)}:i({},bt)}class yt{constructor(t){this.bt=[],this._t=0,this.Se=mt(t)}setConfig(t){this.Se=mt(t),this.wt()}add(t){var e=function(t){var e,i,r;try{r=[],e=null!==(i=JSON.stringify(t,(function(t,e){if("bigint"==typeof e)return e.toString();if("function"!=typeof e&&"symbol"!=typeof e){if(e instanceof Error)return{name:e.name,message:e.message,stack:e.stack};if(e&&"object"==typeof e){for(;r.length>0&&r[r.length-1]!==this;)r.pop();if(r.includes(e))return"[Circular]";r.push(e)}return e}})))&&void 0!==i?i:"null"}catch(t){return}try{var s=JSON.parse(e);if(!b(s))return;var n=s,a=n[pt],o=n[gt];if(!y(a)||0===a.trim().length)return;if(!y(o)&&!E(o))return;return{step:n,json:e}}catch(t){return}}(t);if(e){var i=function(t){if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(t).length;for(var e=encodeURIComponent(t),i=0,r=0;e.length>r;r++)"%"===e[r]?(i+=1,r+=2):i+=1;return i}(e.json);i>this.Se.max_bytes||(this.bt.push({step:e.step,bytes:i}),this._t+=i,this.wt())}}getAttachable(){return this.bt.map((t=>t.step))}clear(){this.bt=[],this._t=0}size(){return this.bt.length}wt(){for(;this._t>this.Se.max_bytes&&this.bt.length>0;){var t=this.bt.shift();t&&(this._t-=t.bytes)}}}function wt(t,e){if(!E(t)||t===1/0||t===-1/0)return e;var i=Math.floor(t);return 0>i?e:i}var xt="undefined"!=typeof window?window:void 0,Et="undefined"!=typeof globalThis?globalThis:xt;"undefined"==typeof self&&(Et.self=Et),"undefined"==typeof File&&(Et.File=function(){});var kt=null==Et?void 0:Et.navigator,St=null==Et?void 0:Et.document,Ct=null==Et?void 0:Et.location;null!=Et&&Et.XMLHttpRequest&&new Et.XMLHttpRequest;var Ft=null!=xt?xt:{};function Pt(){return!(!xt||!1===xt.navigator.onLine)}var Rt=function(t,e){var{debugEnabled:i}=void 0===e?{}:e,r={k(e){if(xt&&(Ft.POSTHOG_DEBUG||i)&&!m(xt.console)&&xt.console){for(var r=("__rrweb_original__"in xt.console[e]?xt.console[e].__rrweb_original__:xt.console[e]),s=arguments.length,n=new Array(s>1?s-1:0),a=1;s>a;a++)n[a-1]=arguments[a];r(t,...n)}},debug(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];r.k("debug",...e)},info(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];r.k("log",...e)},warn(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];r.k("warn",...e)},error(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];r.k("error",...e)},critical(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];console.error(t,...i)},uninitializedWarning(t){r.error("You must initialize PostHog before calling "+t)},createLogger:(e,i)=>Rt(t+" "+e,i)};return r},Tt=Rt("[PostHog.js]"),At=Tt.createLogger;function It(t,e){if(!x(t))if(g(t))t.forEach(e);else if(S(t))t.forEach(((t,i)=>e(t,i)));else for(var i in t)f.call(t,i)&&e(t[i],i)}var $t=function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;e>r;r++)i[r-1]=arguments[r];for(var s of i)for(var n in s)void 0!==s[n]&&(t[n]=s[n]);return t};function Ot(t){for(var e=Object.keys(t),i=e.length,r=new Array(i);i--;)r[i]=[e[i],t[e[i]]];return r}var Mt=function(t){try{return t()}catch(t){return}};function jt(t,e,i,r){var{capture:s=!1,passive:n=!0}=null!=r?r:{};null==t||t.addEventListener(e,i,{capture:s,passive:n})}function Lt(t){return"ph_toolbar_internal"===t.name}function Dt(t,e){var i,r=null==t||null==(i=t.config)?void 0:i.get_current_url;if(!_(r))return e;try{var s=r(e);return y(s)&&s?s:e}catch(t){return Tt.error("Error in get_current_url, falling back to window.location.href",t),e}}var Nt="$autocapture_disabled_server_side",zt="$heatmaps_enabled_server_side",Ut="$exception_capture_enabled_server_side",Ht="$error_tracking_suppression_rules",Vt="$error_tracking_capture_extension_exceptions",Bt="$web_vitals_enabled_server_side",qt="$product_tours_enabled_server_side",Wt="$web_vitals_allowed_metrics",Jt="$session_recording_remote_config",Kt="$enabled_feature_flags",Gt="$active_feature_flags",Yt="$early_access_features",Qt="$feature_flag_details",Zt="$feature_flag_payloads",Xt="$feature_flag_request_id",te="$override_feature_flags",ee="$override_feature_flag_payloads",ie="$stored_person_properties",re="$stored_group_properties",se="$surveys",ne="$surveys_loaded_at",ae="$surveys_activated",oe="ph_product_tours",le="$flag_call_reported",ue="$flag_call_reported_session_id",he="$feature_flag_errors",ve="$feature_flag_evaluated_at",de="__POSTHOG_TOOLBAR__",ce="PostHog loadExternalDependency extension not found.",fe="visibilitychange",pe="beforeunload",ge=1,_e=3,be=11;function me(t){return t instanceof Element&&(t.id===de||!(null==t.closest||!t.closest(".toolbar-global-fade-container")))}function ye(t){return!!t&&t.nodeType===ge}function we(t,e){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===e.toLowerCase()}function xe(t){return!!t&&t.nodeType===_e}function Ee(t){return!!t&&t.nodeType===be&&ye(t.host)}function ke(t){return t?d(t).split(/\s+/):[]}function Se(t,e){var i=function(t){var e,i=null==xt||null==(e=xt.location)?void 0:e.href;return m(i)?void 0:Dt(t,i)}(e);return!!(i&&t&&t.some((t=>i.match(t))))}function Ce(t){var e="";switch(typeof t.className){case"string":e=t.className;break;case"object":e=(t.className&&"baseVal"in t.className?t.className.baseVal:null)||t.getAttribute("class")||"";break;default:e=""}return ke(e)}function Fe(t){return x(t)?null:d(t).split(/(\s+)/).filter((t=>Ge(t))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Pe(t){var e="";return Ue(t)&&!He(t)&&t.childNodes&&t.childNodes.length&&It(t.childNodes,(function(t){var i;xe(t)&&t.textContent&&(e+=null!==(i=Fe(t.textContent))&&void 0!==i?i:"")})),d(e)}function Re(t){return m(t.target)?t.srcElement||null:null!=(e=t.target)&&e.shadowRoot?t.composedPath()[0]||null:t.target||null;var e}var Te=["a","button","form","input","select","textarea","label"];function Ae(t,e){if(m(e))return!0;var i,r=function(t){if(e.some((e=>function(t,e){var i=t.matches||t.matchesSelector||t.msMatchesSelector||t.mozMatchesSelector||t.webkitMatchesSelector||t.oMatchesSelector;try{return!!i&&i.call(t,e)}catch(t){return!1}}(t,e))))return{v:!0}};for(var s of t)if(i=r(s))return i.v;return!1}function Ie(t){var e=t.parentNode;return!(!e||!ye(e))&&e}var $e=[".ph-no-autocapture","[data-ph-no-autocapture]"],Oe=["next","previous","prev",">","<"],Me=(t,e)=>/[a-z0-9]/i.test(e)?t.includes(e):t===e,je=[".ph-no-rageclick",".ph-no-capture"],Le=["","text","search","email","password","url","tel","number"];function De(t,e){if(!xt||Ne(t))return!1;var i,r,s,n,a;if(k(e)?(i=!!e&&je,r=void 0,s=!1):(i=null!==(n=null==e?void 0:e.css_selector_ignorelist)&&void 0!==n?n:je,r=null==e?void 0:e.content_ignorelist,s=null!==(a=null==e?void 0:e.ignore_text_selection)&&void 0!==a&&a),!1===i)return!1;if(s&&function(t){return!(!t||!ye(t))&&(!!we(t,"textarea")||(we(t,"input")?v(Le,(t.getAttribute("type")||"").toLowerCase()):function(t){if(t.isContentEditable)return!0;var e=null==t.getAttribute?void 0:t.getAttribute("contenteditable");return"true"===e||""===e}(t)))}(t))return!1;var{targetElementList:o}=ze(t,!1);return!function(t,e){if(!1===t||m(t))return!1;var i;if(!0===t)i=Oe;else{if(!g(t))return!1;if(t.length>10)return Tt.error("[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching."),!1;i=t.map((t=>t.toLowerCase()))}return e.some((t=>{var{safeText:e,ariaLabel:r}=t;return i.some((t=>Me(e,t)||Me(r,t)))}))}(r,o.map((t=>{var e;return{safeText:Pe(t).toLowerCase(),ariaLabel:(null==(e=t.getAttribute("aria-label"))?void 0:e.toLowerCase().trim())||""}})))&&!Ae(o,i)}var Ne=t=>!t||we(t,"html")||!ye(t),ze=(t,e)=>{if(!xt||Ne(t))return{parentIsUsefulElement:!1,targetElementList:[]};for(var i=!1,r=[t],s=t;s.parentNode&&!we(s,"body");)if(Ee(s.parentNode))r.push(s.parentNode.host),s=s.parentNode.host;else{var n=Ie(s);if(!n)break;if(e||Te.indexOf(n.tagName.toLowerCase())>-1)i=!0;else try{var a=xt.getComputedStyle(n);a&&"pointer"===a.getPropertyValue("cursor")&&(i=!0)}catch(t){}r.push(n),s=n}return{parentIsUsefulElement:i,targetElementList:r}};function Ue(t){for(var e=t;e.parentNode&&!we(e,"body");e=e.parentNode){var i=Ce(e);if(v(i,"ph-sensitive")||v(i,"ph-no-capture"))return!1}if(v(Ce(t),"ph-include"))return!0;var r=t.type||"";if(y(r))switch(r.toLowerCase()){case"hidden":case"password":return!1}var s=t.name||t.id||"";return!y(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 He(t){return!!(we(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||we(t,"select")||we(t,"textarea")||"true"===t.getAttribute("contenteditable"))}var Ve="(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})",Be=new RegExp("^(?:"+Ve+")$"),qe=new RegExp(Ve),We="\\d{3}-?\\d{2}-?\\d{4}",Je=new RegExp("^("+We+")$"),Ke=new RegExp("("+We+")");function Ge(t,e){if(void 0===e&&(e=!0),x(t))return!1;if(y(t)){if(t=d(t),(e?Be:qe).test((t||"").replace(/[- ]/g,"")))return!1;if((e?Je:Ke).test(t))return!1}return!0}function Ye(t){var e=Pe(t);return Ge(e=(e+" "+Qe(t)).trim())?e:""}function Qe(t){var e="";return t&&t.childNodes&&t.childNodes.length&&It(t.childNodes,(function(t){var i;if(t&&"span"===(null==(i=t.tagName)?void 0:i.toLowerCase()))try{var r=Pe(t);e=(e+" "+r).trim(),t.childNodes&&t.childNodes.length&&(e=(e+" "+Qe(t)).trim())}catch(t){Tt.error("[AutoCapture]",t)}})),e}function Ze(t){return t.replace(/"|\\"/g,'\\"')}function Xe(t){var e=t.attr__class;return e?g(e)?e:ke(e):void 0}class ti{constructor(t){this.disabled=!1===t;var e=b(t)?t:{};this.thresholdPx=e.threshold_px||30,this.timeoutMs=e.timeout_ms||1e3,this.clickCount=e.click_count||3,this.clicks=[]}isRageClick(t,e,i){if(this.disabled)return!1;var r=this.clicks[this.clicks.length-1];if(r&&Math.abs(t-r.x)+Math.abs(e-r.y)<this.thresholdPx&&this.timeoutMs>i-r.timestamp){if(this.clicks.push({x:t,y:e,timestamp:i}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:t,y:e,timestamp:i}];return!1}}var ei=function(t,e){for(var i,r=((t.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),s=0;r.length>s;s++){var n=r[s].split("=");if(n[0]===e){i=n;break}}if(!g(i)||2>i.length)return"";var a=i[1];try{a=decodeURIComponent(a)}catch(t){Tt.error("Skipping decoding for malformed query param: "+a)}return a.replace(/\+/g," ")},ii=function(t,e,i){if(!t||!e||!e.length)return t;for(var r=t.split("#"),s=r[1],n=(r[0]||"").split("?"),a=n[1],o=n[0],l=(a||"").split("&"),u=[],h=0;l.length>h;h++){var v=l[h].split("=");g(v)&&(e.includes(v[0])?u.push(v[0]+"="+i):u.push(l[h]))}var d=o;return null!=a&&(d+="?"+u.join("&")),null!=s&&(d+="#"+s),d},ri=function(t,e){var i=t.match(new RegExp(e+"=([^&]*)"));return i?i[1]:null},si="$copy_autocapture",ni=At("[AutoCapture]");function ai(t,e){return e.length>t?e.slice(0,t)+"...":e}function oi(t){if(t.previousElementSibling)return t.previousElementSibling;var e=t;do{e=e.previousSibling}while(e&&!ye(e));return e}function li(t,e){var r,s,{e:n,maskAllElementAttributes:a,maskAllText:o,elementAttributeIgnoreList:l,elementsChainAsString:u,disableCaptureUrlHashes:h}=e;if(!ye(t))return{props:{}};for(var d=[t],c=t;c.parentNode&&!we(c,"body");)if(Ee(c.parentNode))d.push(c.parentNode.host),c=c.parentNode.host;else{if(!ye(c.parentNode))break;d.push(c.parentNode),c=c.parentNode}var f,p,g=[],_={},b=!1,w=!1;if(It(d,(t=>{var e=Ue(t);if(we(t,"a")){var i=t.getAttribute("href");b=!!(e&&i&&Ge(i))&&(h?A(i):i)}v(Ce(t),"ph-no-capture")&&(w=!0),g.push(function(t,e,i,r,s){void 0===s&&(s=!1);var n=t.tagName.toLowerCase(),a={tag_name:n};Te.indexOf(n)>-1&&!i&&(a.$el_text="a"===n.toLowerCase()||"button"===n.toLowerCase()?ai(1024,Ye(t)):ai(1024,Pe(t)));var o=Ce(t);o.length>0&&(a.classes=o.filter((function(t){return""!==t}))),It(t.attributes,(function(i){var n;if((!He(t)||-1!==["name","id","class","aria-label"].indexOf(i.name))&&(null==r||!r.includes(i.name))&&!e&&Ge(i.value)&&(!y(n=i.name)||"_ngcontent"!==n.substring(0,10)&&"_nghost"!==n.substring(0,7))){var o=i.value;"class"===i.name&&(o=ke(o).join(" ")),a["attr__"+i.name]=ai(1024,"href"===i.name&&s?A(o):o)}}));for(var l=1,u=1,h=t;h=oi(h);)l++,h.tagName===t.tagName&&u++;return a.nth_child=l,a.nth_of_type=u,a}(t,a,o,l,h));var r=function(t){if(!Ue(t))return{};var e={};return It(t.attributes,(function(t){if(t.name&&0===t.name.indexOf("data-ph-capture-attribute")){var i=t.name.replace("data-ph-capture-attribute-",""),r=t.value;i&&r&&Ge(r)&&(e[i]=r)}})),e}(t);$t(_,r)})),w)return{props:{},explicitNoCapture:w};if(o||(g[0].$el_text=we(t,"a")||we(t,"button")?Ye(t):Pe(t)),b){var x,E;g[0].attr__href=b;var k=null==(x=(t=>{var e=null==St?void 0:St.createElement("a");return m(e)?null:(e.href=t,e)})(b))?void 0:x.host,S=null==xt||null==(E=xt.location)?void 0:E.host;k&&S&&k!==S&&(f=b)}return{props:$t({$event_type:n.type,$ce_version:1},u?{}:{$elements:g},{$elements_chain:(p=g,function(t){return t.map((t=>{var e,r,s="";if(t.tag_name&&(s+=t.tag_name),t.attr_class)for(var n of(t.attr_class.sort(),t.attr_class))s+="."+n.replace(/"/g,"");var a=i({},t.text?{text:t.text}:{},{"nth-child":null!==(e=t.nth_child)&&void 0!==e?e:0,"nth-of-type":null!==(r=t.nth_of_type)&&void 0!==r?r:0},t.href?{href:t.href}:{},t.attr_id?{attr_id:t.attr_id}:{},t.attributes),o={};return Ot(a).sort(((t,e)=>{var[i]=t,[r]=e;return i.localeCompare(r)})).forEach((t=>{var[e,i]=t;return o[Ze(e.toString())]=Ze(i.toString())})),(s+=":")+Ot(o).map((t=>{var[e,i]=t;return e+'="'+i+'"'})).join("")})).join(";")}(function(t){return t.map((t=>{var e,i,r={text:null==(e=t.$el_text)?void 0:e.slice(0,400),tag_name:t.tag_name,href:null==(i=t.attr__href)?void 0:i.slice(0,2048),attr_class:Xe(t),attr_id:t.attr__id,nth_child:t.nth_child,nth_of_type:t.nth_of_type,attributes:{}};return Ot(t).filter((t=>{var[e]=t;return 0===e.indexOf("attr__")})).forEach((t=>{var[e,i]=t;return r.attributes[e]=i})),r}))}(p)))},null!=(r=g[0])&&r.$el_text?{$el_text:null==(s=g[0])?void 0:s.$el_text}:{},f&&"click"===n.type?{$external_click_url:f}:{},_)}}var ui=At("[Dead Clicks]"),hi=()=>!0;class vi{get lazyLoadedDeadClicksAutocapture(){return this.Et}constructor(t,e,i){this.instance=t,this.isEnabled=e,this.onCapture=i,this.startIfEnabledOrStop()}onRemoteConfig(t){"captureDeadClicks"in t&&(this.instance.persistence&&this.instance.persistence.register({$dead_clicks_enabled_server_side:t.captureDeadClicks}),this.startIfEnabledOrStop())}startIfEnabledOrStop(){this.isEnabled(this)?this.Mt((()=>{this.Pt()})):this.stop()}Mt(t){var e,i;null!=(e=Ft.__PosthogExtensions__)&&e.initDeadClicksAutocapture?t():null==(i=Ft.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this.instance,"dead-clicks-autocapture",(e=>{e?ui.error("failed to load script",e):t()}))}Pt(){var t;if(St){if(!this.Et&&null!=(t=Ft.__PosthogExtensions__)&&t.initDeadClicksAutocapture){var e=b(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};e.__onCapture=this.onCapture,this.Et=Ft.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,e),this.Et.start(St),ui.info("starting...")}}else ui.error("`document` not found. Cannot start.")}stop(){this.Et&&(this.Et.stop(),this.Et=void 0,ui.info("stopping..."))}}var di=At("[ExceptionAutocapture]"),ci=At("[TracingHeaders]");Math.trunc||(Math.trunc=function(t){return 0>t?Math.ceil(t):Math.floor(t)}),Number.isInteger||(Number.isInteger=function(t){return E(t)&&isFinite(t)&&Math.floor(t)===t});class fi{constructor(t){if(this.bytes=t,16!==t.length)throw new TypeError("not 128-bit length")}static fromFieldsV7(t,e,i,r){if(!Number.isInteger(t)||!Number.isInteger(e)||!Number.isInteger(i)||!Number.isInteger(r)||0>t||0>e||0>i||0>r||t>0xffffffffffff||e>4095||i>1073741823||r>4294967295)throw new RangeError("invalid field value");var s=new Uint8Array(16);return s[0]=t/Math.pow(2,40),s[1]=t/Math.pow(2,32),s[2]=t/Math.pow(2,24),s[3]=t/Math.pow(2,16),s[4]=t/Math.pow(2,8),s[5]=t,s[6]=112|e>>>8,s[7]=e,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 fi(s)}toString(){for(var t="",e=0;this.bytes.length>e;e++)t=t+(this.bytes[e]>>>4).toString(16)+(15&this.bytes[e]).toString(16),3!==e&&5!==e&&7!==e&&9!==e||(t+="-");if(36!==t.length)throw new Error("Invalid UUIDv7 was generated");return t}clone(){return new fi(this.bytes.slice(0))}equals(t){return 0===this.compareTo(t)}compareTo(t){for(var e=0;16>e;e++){var i=this.bytes[e]-t.bytes[e];if(0!==i)return Math.sign(i)}return 0}}class pi{constructor(){this.S=0,this.C=0,this.I=new bi}generate(){var t=this.generateOrAbort();if(m(t)){this.S=0;var e=this.generateOrAbort();if(m(e))throw new Error("Could not generate UUID after timestamp reset");return e}return t}generateOrAbort(){var t=Date.now();if(t>this.S)this.S=t,this.M();else{if(this.S>=t+1e4)return;this.C++,this.C>4398046511103&&(this.S++,this.M())}return fi.fromFieldsV7(this.S,Math.trunc(this.C/Math.pow(2,30)),this.C&Math.pow(2,30)-1,this.I.nextUint32())}M(){this.C=1024*this.I.nextUint32()+(1023&this.I.nextUint32())}}var gi,_i=t=>{if("undefined"!=typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var e=0;t.length>e;e++)t[e]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return t};xt&&!m(xt.crypto)&&crypto.getRandomValues&&(_i=t=>crypto.getRandomValues(t));class bi{constructor(){this.R=new Uint32Array(8),this.O=1/0}nextUint32(){return this.R.length>this.O||(_i(this.R),this.O=0),this.R[this.O++]}}var mi=()=>(gi||(gi=new pi)).generate(),yi="",wi=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;function xi(t,e){if(e){var i=function(t,e){if(void 0===e&&(e=St),yi)return yi;if(!e)return"";if(["localhost","127.0.0.1"].includes(t))return"";for(var i=t.split("."),r=Math.min(i.length,8),s="dmn_chk_"+mi().toString();!yi&&r--;){var n=i.slice(r).join("."),a=s+"=1;domain=."+n+";path=/";e.cookie=a+";max-age=3",e.cookie.includes(s)&&(e.cookie=a+";max-age=0",yi=n)}return yi}(t);if(!i){var r=(t=>{var e=t.match(wi);return e?e[0]:""})(t);r!==i&&Tt.info("Warning: cookie subdomain discovery mismatch",r,i),i=r}return i?"; domain=."+i:""}return""}var Ei={N:()=>!!St,D(t){Tt.error("cookieStore error: "+t)},A(t){if(St){try{for(var e=t+"=",i=St.cookie.split(";").filter((t=>t.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(e))return decodeURIComponent(s.substring(e.length,s.length))}}catch(t){}return null}},F(t){var e;try{e=JSON.parse(Ei.A(t))||{}}catch(t){}return e},q(t,e,i,r,s){if(!St)return!1;try{var n="",a="",o=xi(St.location.hostname,r);if(i){var l=new Date;l.setTime(l.getTime()+864e5*i),n="; expires="+l.toUTCString()}s&&(a="; secure");var u=t+"="+encodeURIComponent(JSON.stringify(e))+n+"; SameSite=Lax; path=/"+o+a;return u.length>3686.4&&Tt.warn("cookieStore warning: large cookie, len="+u.length),St.cookie=u,!0}catch(t){return!1}},P(t,e){if(null!=St&&St.cookie)try{Ei.q(t,"",-1,e)}catch(t){return}}},ki=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],Si=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...ki],Ci="<masked>",Fi=["li_fat_id"];function Pi(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(t){return}}var Ri=At("[Web Vitals]"),Ti=9e5,Ai=At("[RemoteConfig]");class Ii{constructor(t){this._instance=t}get remoteConfig(){var t;return null==(t=Ft._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.config}cr(t){var e,i;null!=(e=Ft.__PosthogExtensions__)&&e.loadExternalDependency?null==(i=Ft.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"remote-config",(()=>t(this.remoteConfig))):t()}vr(t){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback(e){t(e.json)}})}load(){try{if(this.remoteConfig)return Ai.info("Using preloaded remote config",this.remoteConfig),this.pr(this.remoteConfig),void this.gr();if(this._instance.mr())return void Ai.warn("Remote config is disabled. Falling back to local config.");this.cr((t=>{if(!t)return Ai.info("No config found after loading remote JS config. Falling back to JSON."),void this.vr((t=>{this.pr(t),this.gr()}));this.pr(t),this.gr()}))}catch(t){Ai.error("Error loading remote config",t)}}stop(){this.yr&&(clearInterval(this.yr),this.yr=void 0)}refresh(){!this._instance.mr()&&St&&"hidden"!==St.visibilityState&&this._instance.reloadFeatureFlags()}gr(){var t;if(!this.yr){var e=null!==(t=this._instance.config.remote_config_refresh_interval_ms)&&void 0!==t?t:3e5;0!==e&&(this.yr=setInterval((()=>{this.refresh()}),e))}}pr(t){var e;t||Ai.error("Failed to fetch remote config from PostHog."),this._instance.pr(null!=t?t:{}),!1!==(null==t?void 0:t.hasFeatureFlags)&&(this._instance.config.advanced_disable_feature_flags_on_first_load||null==(e=this._instance.featureFlags)||e.ensureFlagsLoaded())}}var $i="disabled",Oi="lazy_loading",Mi="awaiting_config",ji="missing_config",Li="base64",Di=function(t,e){if(!function(t){try{new RegExp(t)}catch(t){return!1}return!0}(e))return!1;try{return new RegExp(e).test(t)}catch(t){return!1}},Ni={exact:(t,e)=>e.some((e=>t.some((t=>e===t)))),is_not:(t,e)=>e.every((e=>t.every((t=>e!==t)))),regex:(t,e)=>e.some((e=>t.some((t=>Di(e,t))))),not_regex:(t,e)=>e.every((e=>t.every((t=>!Di(e,t))))),icontains:(t,e)=>e.map(zi).some((e=>t.map(zi).some((t=>e.includes(t))))),not_icontains:(t,e)=>e.map(zi).every((e=>t.map(zi).every((t=>!e.includes(t))))),gt:(t,e)=>e.some((e=>{var i=parseFloat(e);return!isNaN(i)&&t.some((t=>i>parseFloat(t)))})),lt:(t,e)=>e.some((e=>{var i=parseFloat(e);return!isNaN(i)&&t.some((t=>i<parseFloat(t)))}))},zi=t=>t.toLowerCase();function Ui(t,e){return!t||Object.entries(t).every((t=>{var[i,r]=t,s=null==e?void 0:e[i];if(m(s)||w(s))return!1;var n=[String(s)],a=Ni[r.operator];return!!a&&a(r.values,n)}))}At("[SessionRecording]"),At("[SessionRecording]");var Hi="[SessionRecording]",Vi=At(Hi),Bi=At("[Heatmaps]");function qi(t){return b(t)&&"clientX"in t&&"clientY"in t&&E(t.clientX)&&E(t.clientY)}var Wi=At("[Product Tours]"),Ji=t=>{var e;return!t.config.disable_product_tours&&!(null==(e=t.persistence)||!e.get_property(qt))},Ki=["$set_once","$set"],Gi=At("[SiteApps]"),Yi="Error while initializing PostHog app with config id ",Qi="events",Zi="cancelEvents",Xi="survey shown",tr=At("[Surveys]"),er="seenSurvey_",ir=["popover","widget","api"];class rr{constructor(){this.Wr={}}on(t,e){return this.Wr[t]||(this.Wr[t]=[]),this.Wr[t].push(e),()=>{this.Wr[t]=this.Wr[t].filter((t=>t!==e))}}emit(t,e){for(var i of this.Wr[t]||[])i(e);for(var r of this.Wr["*"]||[])r(t,e)}}function sr(t,e,i){if(x(t))return!1;switch(i){case"exact":return t===e;case"contains":var r=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(r,"i").test(t);case"regex":try{return new RegExp(e).test(t)}catch(t){return!1}default:return!1}}class nr{constructor(t){this.sn=new rr,this.an=(t,e)=>this.ln(t,e)&&this.un(t,e)&&this.hn(t,e)&&this.dn(t,e),this.ln=(t,e)=>null==e||!e.event||(null==t?void 0:t.event)===(null==e?void 0:e.event),this._instance=t,this.cn=new Set,this.vn=new Set}init(){var t,e;m(null==(t=this._instance)?void 0:t._addCaptureHook)||(null==(e=this._instance)||e._addCaptureHook(((t,e)=>{this.on(t,e)})))}register(t){var e,i;if(!m(null==(e=this._instance)?void 0:e._addCaptureHook)&&(t.forEach((t=>{var e,i;null==(e=this.vn)||e.add(t),null==(i=t.steps)||i.forEach((t=>{var e;null==(e=this.cn)||e.add((null==t?void 0:t.event)||"")}))})),null!=(i=this._instance)&&i.autocapture)){var r,s=new Set;t.forEach((t=>{var e;null==(e=t.steps)||e.forEach((t=>{null!=t&&t.selector&&s.add(null==t?void 0:t.selector)}))})),null==(r=this._instance)||r.autocapture.setElementSelectors(s)}}on(t,e){var i;null!=e&&0!=t.length&&(this.cn.has(t)||this.cn.has(null==e?void 0:e.event))&&this.vn&&(null==(i=this.vn)?void 0:i.size)>0&&this.vn.forEach((t=>{this.fn(e,t)&&this.sn.emit("actionCaptured",t.name)}))}pn(t){this.onAction("actionCaptured",(e=>t(e)))}fn(t,e){if(null==(null==e?void 0:e.steps))return!1;for(var i of e.steps)if(this.an(t,i))return!0;return!1}onAction(t,e){return this.sn.on(t,e)}un(t,e){if(null!=e&&e.url){var i,r=null==t||null==(i=t.properties)?void 0:i.$current_url;if(!r||"string"!=typeof r)return!1;if(!sr(r,e.url,e.url_matching||"contains"))return!1}return!0}hn(t,e){return!!this.gn(t,e)&&!!this.mn(t,e)&&!!this.yn(t,e)}gn(t,e){var i;if(null==e||!e.href)return!0;var r=this.bn(t);if(r.length>0)return r.some((t=>sr(t.href,e.href,e.href_matching||"exact")));var s,n=(null==t||null==(i=t.properties)?void 0:i.$elements_chain)||"";return!!n&&sr((s=n.match(/(?::|")href="(.*?)"/))?s[1]:"",e.href,e.href_matching||"exact")}mn(t,e){var i;if(null==e||!e.text)return!0;var r=this.bn(t);if(r.length>0)return r.some((t=>sr(t.text,e.text,e.text_matching||"exact")||sr(t.$el_text,e.text,e.text_matching||"exact")));var s,n,a,o=(null==t||null==(i=t.properties)?void 0:i.$elements_chain)||"";return!!o&&(s=function(t){for(var e,i=[],r=/(?::|")text="(.*?)"/g;!x(e=r.exec(t));)i.includes(e[1])||i.push(e[1]);return i}(o),n=e.text,a=e.text_matching||"exact",s.some((t=>sr(t,n,a))))}yn(t,e){var i,r;if(null==e||!e.selector)return!0;var s=null==t||null==(i=t.properties)?void 0:i.$element_selectors;if(null!=s&&s.includes(e.selector))return!0;var n=(null==t||null==(r=t.properties)?void 0:r.$elements_chain)||"";if(e.selector_regex&&n)try{return new RegExp(e.selector_regex).test(n)}catch(t){return!1}return!1}bn(t){var e;return null==(null==t||null==(e=t.properties)?void 0:e.$elements)?[]:null==t?void 0:t.properties.$elements}dn(t,e){return null==e||!e.properties||0===e.properties.length||Ui(e.properties.reduce(((t,e)=>{var i=g(e.value)?e.value.map(String):null!=e.value?[String(e.value)]:[];return t[e.key]={values:i,operator:e.operator||"exact"},t}),{}),null==t?void 0:t.properties)}}class ar{constructor(t){this._n=[],this._instance=t,this.wn=new Map,this.xn=new Map,this.kn=new Map}Sn(t,e){return!!t&&Ui(t.propertyFilters,null==e?void 0:e.properties)}Cn(t,e){var i=new Map;return t.forEach((t=>{var r;null==(r=t.conditions)||null==(r=r[e])||null==(r=r.values)||r.forEach((e=>{if(null!=e&&e.name){var r=i.get(e.name)||[];r.push(t.id),i.set(e.name,r)}}))})),i}In(t,e,i){var r=(i===Qi?this.wn:this.xn).get(t),s=[];return this.Tn((t=>{s=t.filter((t=>null==r?void 0:r.includes(t.id)))})),s.filter((r=>{var s,n=null==(s=r.conditions)||null==(s=s[i])||null==(s=s.values)?void 0:s.find((e=>e.name===t));return this.Sn(n,e)}))}register(t){var e;m(null==(e=this._instance)?void 0:e._addCaptureHook)||(this.En(t),this.Mn(t))}Mn(t){var e=t.filter((t=>{var e,i;return(null==(e=t.conditions)?void 0:e.actions)&&(null==(i=t.conditions)||null==(i=i.actions)||null==(i=i.values)?void 0:i.length)>0}));0!==e.length&&(null==this.Pn&&(this.Pn=new nr(this._instance),this.Pn.init(),this.Pn.pn((t=>{this.onAction(t)}))),e.forEach((t=>{var e,i,r,s,n;t.conditions&&null!=(e=t.conditions)&&e.actions&&null!=(i=t.conditions)&&null!=(i=i.actions)&&i.values&&(null==(r=t.conditions)||null==(r=r.actions)||null==(r=r.values)?void 0:r.length)>0&&(null==(s=this.Pn)||s.register(t.conditions.actions.values),null==(n=t.conditions)||null==(n=n.actions)||null==(n=n.values)||n.forEach((e=>{if(e&&e.name){var i=this.kn.get(e.name);i&&i.push(t.id),this.kn.set(e.name,i||[t.id])}})))})))}En(t){var e,i=t.filter((t=>{var e,i;return(null==(e=t.conditions)?void 0:e.events)&&(null==(i=t.conditions)||null==(i=i.events)||null==(i=i.values)?void 0:i.length)>0})),r=t.filter((t=>{var e,i;return(null==(e=t.conditions)?void 0:e.cancelEvents)&&(null==(i=t.conditions)||null==(i=i.cancelEvents)||null==(i=i.values)?void 0:i.length)>0}));0===i.length&&0===r.length||(null==(e=this._instance)||e._addCaptureHook(((t,e)=>{this.onEvent(t,e)})),this.wn=this.Cn(t,Qi),this.xn=this.Cn(t,Zi))}onEvent(t,e){var i,r,s=this.Rn(),n=(null==e||null==(i=e.properties)?void 0:i.$survey_id)||(null==e||null==(r=e.properties)?void 0:r.$product_tour_id);if(n&&this.getActivatedIds().includes(n)){var a=this.On(t,n);if("consume"===a)return s.info("event consumed activated item, removing it",{event:t,itemId:n}),void this.Ln([n]);if("persist"===a)return s.info("shown item promoted to persisted activation",{event:t,itemId:n}),void this.Fn(n)}if(this.xn.has(t)){var o=this.In(t,e,Zi);o.length>0&&(s.info("cancel event matched, cancelling items",{event:t,itemsToCancel:o.map((t=>t.id))}),this.Ln(o.map((t=>t.id))),o.forEach((t=>this.An(t.id))))}if(this.wn.has(t)){s.info("event name matched",{event:t,eventPayload:e,items:this.wn.get(t)});var l=this.In(t,e,Qi);this.$n(l.map((t=>t.id)))}}onAction(t){this.kn.has(t)&&this.$n(this.kn.get(t)||[])}$n(t){0!==t.length&&(this._n=[...new Set([...this._n,...t])],this.Rn().info("updating activated items",{activatedItems:this.getActivatedIds()}))}Fn(t){this._n=this._n.filter((e=>e!==t));var e=this.Dn();e.includes(t)||this.Nn([...e,t])}Ln(t){var e=new Set(t);this._n=this._n.filter((t=>!e.has(t)));var i=this.Dn(),r=i.filter((t=>!e.has(t)));r.length!==i.length&&this.Nn(r)}Dn(){var t,e=this.qn();return(null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[e])||[]}getActivatedIds(){return[...new Set([...this.Dn(),...this._n])].filter((t=>!this.Bn(t)))}reset(){this._n=[],this.Dn().length>0&&this.Nn([])}getEventToItemsMap(){return this.wn}jn(){return this.Pn}}class or extends ar{constructor(t){super(t)}qn(){return ae}Hn(){return Xi}Tn(t){var e;null==(e=this._instance)||e.getSurveys(t)}An(t){var e;null==(e=this._instance)||e.cancelPendingSurvey(t)}Rn(){return tr}Nn(t){var e;null==(e=this._instance)||null==(e=e.persistence)||e.register({[ae]:t})}Bn(){return!1}On(t,e){var i;this.Tn((t=>{i=t.find((t=>t.id===e))}));var r=!i||function(t){var e,i,r,s=(null!==(e=null==(i=t.conditions)||null==(i=i.events)||null==(i=i.values)?void 0:i.length)&&void 0!==e?e:0)>0;return"always"===t.schedule||!(null==(r=t.conditions)||null==(r=r.events)||!r.repeatedActivation||!s)}(i);return r?t===Xi?"consume":"ignore":t===Xi?"persist":"survey dismissed"===t||"survey sent"===t?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}}var lr="SDK is not enabled or survey functionality is not yet loaded",ur="Disabled. Not loading surveys.",hr=null!=xt&&xt.location?ri(xt.location.hash,"__posthog")||ri(location.hash,"state"):null,vr="_postHogToolbarParams",dr=At("[Toolbar]"),cr=At("[FeatureFlags]"),fr=At("[FeatureFlags]",{debugEnabled:!0}),pr="\" failed. Feature flags didn't load in time.",gr=t=>{for(var e={},i=0;t.length>i;i++)e[t[i]]=!0;return e},_r=t=>{var e={};for(var[i,r]of Ot(t||{}))r&&(e[i]=r);return e},br=At("[Error tracking]"),mr="Refusing to render web experiment since the viewer is a likely bot",yr={icontains:(t,e)=>e.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,e)=>-1===e.toLowerCase().indexOf(t.toLowerCase()),regex:(t,e)=>Di(e,t),not_regex:(t,e)=>!Di(e,t),exact:(t,e)=>e===t,is_not:(t,e)=>e!==t};class wr{get Se(){return this._instance.config}constructor(t){var e=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(t){void 0===t&&(t=!1),e.getWebExperiments((t=>{wr.Un("retrieved web experiments from the server"),e.zn=new Map,t.forEach((t=>{if(t.feature_flag_key){var i;e.zn&&(wr.Un("setting flag key ",t.feature_flag_key," to web experiment ",t),null==(i=e.zn)||i.set(t.feature_flag_key,t));var r=e._instance.getFeatureFlag(t.feature_flag_key);y(r)&&t.variants[r]&&e.Vn(t.name,r,t.variants[r].transforms)}else if(t.variants)for(var s in t.variants){var n=t.variants[s];wr.Wn(n,e._instance)&&e.Vn(t.name,s,n.transforms)}}))}),t)},this._instance=t,this._instance.onFeatureFlags((t=>{this.onFeatureFlags(t)}))}initialize(){}onFeatureFlags(t){if(this._is_bot())wr.Un(mr);else if(!this.Se.disable_web_experiments){if(x(this.zn))return this.zn=new Map,this.loadIfEnabled(),void this.previewWebExperiment();wr.Un("applying feature flags",t),t.forEach((t=>{var e;if(this.zn&&null!=(e=this.zn)&&e.has(t)){var i,r=this._instance.getFeatureFlag(t),s=null==(i=this.zn)?void 0:i.get(t);r&&null!=s&&s.variants[r]&&this.Vn(s.name,r,s.variants[r].transforms)}}))}}previewWebExperiment(){var t=wr.getWindowLocation();if(null!=t&&t.search){var e=ei(null==t?void 0:t.search,"__experiment_id"),i=ei(null==t?void 0:t.search,"__experiment_variant");e&&i&&(wr.Un("previewing web experiments "+e+" && "+i),this.getWebExperiments((t=>{this.Gn(parseInt(e),i,t)}),!1,!0))}}loadIfEnabled(){this.Se.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(t,e,i){if(this.Se.disable_web_experiments&&!i)return t([]);var r=this._instance.get_property("$web_experiments");if(r&&!e)return t(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this.Se.token),method:"GET",callback:e=>t(200===e.statusCode&&e.json&&e.json.experiments||[])})}Gn(t,e,i){var r=i.filter((e=>e.id===t));r&&r.length>0&&(wr.Un("Previewing web experiment ["+r[0].name+"] with variant ["+e+"]"),this.Vn(r[0].name,e,r[0].variants[e].transforms))}static Wn(t,e){return!x(t.conditions)&&wr.Zn(t,e)&&wr.Qn(t)}static Zn(t,e){var i;if(x(t.conditions)||x(null==(i=t.conditions)?void 0:i.url))return!0;var r=wr.getWindowLocation();if(r){var s,n,a,o=Dt(e,r.href);return null==(s=t.conditions)||!s.url||yr[null!==(n=null==(a=t.conditions)?void 0:a.urlMatchType)&&void 0!==n?n:"icontains"](t.conditions.url,o)}return!1}static getWindowLocation(){return null==xt?void 0:xt.location}static Qn(t){var e;if(x(t.conditions)||x(null==(e=t.conditions)?void 0:e.utm))return!0;var i=function(t,e,i){if(!St)return{};var r,s,n,a=(r=ii(St.URL,[],Ci),s=Si.concat([]),n={},It(s,(function(t){var e=ei(r,t);n[t]=e||null})),n),o=function(){var t={};return It(Fi,(function(e){var i=Ei.A(e);t[e]=i||null})),t}();return $t(o,a)}();if(i.utm_source){var r,s,n,a,o,l,u,h,v=null==(r=t.conditions)||null==(r=r.utm)||!r.utm_campaign||(null==(s=t.conditions)||null==(s=s.utm)?void 0:s.utm_campaign)==i.utm_campaign,d=null==(n=t.conditions)||null==(n=n.utm)||!n.utm_source||(null==(a=t.conditions)||null==(a=a.utm)?void 0:a.utm_source)==i.utm_source,c=null==(o=t.conditions)||null==(o=o.utm)||!o.utm_medium||(null==(l=t.conditions)||null==(l=l.utm)?void 0:l.utm_medium)==i.utm_medium,f=null==(u=t.conditions)||null==(u=u.utm)||!u.utm_term||(null==(h=t.conditions)||null==(h=h.utm)?void 0:h.utm_term)==i.utm_term;return v&&c&&f&&d}return!1}static Un(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;e>r;r++)i[r-1]=arguments[r];Tt.info("[WebExperiments] "+t,i)}Vn(t,e,i){this._is_bot()?wr.Un(mr):"control"!==e?i.forEach((i=>{if(i.selector){var r;wr.Un("applying transform of variant "+e+" for experiment "+t+" ",i);var s=null==(r=document)?void 0:r.querySelectorAll(i.selector);null==s||s.forEach((t=>{var e=t;i.html&&(e.innerHTML=i.html),i.css&&e.setAttribute("style",i.css)}))}})):wr.Un("Control variants leave the page unmodified.")}_is_bot(){return kt&&this._instance?function(t,e){if(!t)return!1;var i=t.userAgent;if(i&&h(i,e))return!0;try{var r=null==t?void 0:t.userAgentData;if(null!=r&&r.brands&&r.brands.some((t=>h(null==t?void 0:t.brand,e))))return!0}catch(t){}return!!t.webdriver}(kt,this.Se.custom_blocked_useragents):void 0}}var xr=At("[Conversations]"),Er="Conversations not available yet.",kr="console",Sr={featureFlags:class{constructor(t){this.Jn=!1,this.Yn=!1,this.Kn=!1,this.Xn=!1,this.es=!1,this.ts=!1,this.rs=!1,this.ns=!1,this.ss=0,this.os=()=>{var t=this.ls();this.ss=0,t&&this.reloadFeatureFlags()},this._instance=t,this.featureFlagEventHandlers=[],xt&&jt(xt,"online",this.os)}destroy(){null==xt||xt.removeEventListener("online",this.os)}get Se(){return this._instance.config}get zr(){return this._instance.persistence}us(t){return this._instance.get_property(t)}hs(){var t,e;return null!==(t=null==(e=this.zr)?void 0:e.Gt(this.Se.feature_flag_cache_ttl_ms))&&void 0!==t&&t}ds(){return!!this.hs()&&(this.ns||this.Kn||(this.ns=!0,cr.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}cs(){var t,e=null!==(t=this.Se.evaluation_contexts)&&void 0!==t?t:this.Se.evaluation_environments;return!this.Se.evaluation_environments||this.Se.evaluation_contexts||this.rs||(cr.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.rs=!0),null!=e&&e.length?e.filter((t=>{var e=t&&"string"==typeof t&&t.trim().length>0;return e||cr.error("Invalid evaluation context found:",t,"Expected non-empty string"),e})):[]}vs(){return this.cs().length>0}fs(){var t=this.Se.flag_keys;if(!m(t)){if(g(t))return t.filter((t=>{var e=t&&"string"==typeof t&&t.trim().length>0;return e||cr.error("Invalid flag key found:",t,"Expected non-empty string"),e}));cr.error("Invalid flag_keys found:",t,"Expected array of non-empty strings")}}initialize(){var t,e,{config:i}=this._instance,r=null!==(t=null==(e=i.bootstrap)?void 0:e.featureFlags)&&void 0!==t?t:{};if(Object.keys(r).length){var s,n,a=null!==(s=null==(n=i.bootstrap)?void 0:n.featureFlagPayloads)&&void 0!==s?s:{},o=Object.keys(r).filter((t=>!!r[t])).reduce(((t,e)=>(t[e]=r[e]||!1,t)),{}),l=Object.keys(a).filter((t=>o[t])).reduce(((t,e)=>(a[e]&&(t[e]=a[e]),t)),{});this.receivedFeatureFlags({featureFlags:o,featureFlagPayloads:l})}}updateFlags(t,e,r){var s,n,l=null!=r&&r.merge&&null!==(s=this.us(Kt))&&void 0!==s?s:{},u=null!=r&&r.merge&&null!==(n=this.us(Zt))&&void 0!==n?n:{},h=i({},l,t),v=i({},u,e),d={};for(var[c,f]of Object.entries(h))d[c]={key:c,enabled:a(f),variant:o(f),reason:void 0,metadata:m(null==v?void 0:v[c])?void 0:{id:0,version:void 0,description:void 0,payload:v[c]}};this.receivedFeatureFlags({flags:d})}get hasLoadedFlags(){return this.Yn}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var t=this.us(Qt),e=this.us(te),r=this.us(ee);if(!r&&!e)return t||{};var s=$t({},t||{}),n=[...new Set([...Object.keys(r||{}),...Object.keys(e||{})])];for(var a of n){var o,l,u=s[a],h=null==e?void 0:e[a],v=m(h)?null!==(o=null==u?void 0:u.enabled)&&void 0!==o&&o:!!h,d=m(h)?u.variant:"string"==typeof h?h:void 0,c=null==r?void 0:r[a],f=i({},u,{enabled:v,variant:v?null!=d?d:null==u?void 0:u.variant:void 0});v!==(null==u?void 0:u.enabled)&&(f.original_enabled=null==u?void 0:u.enabled),d!==(null==u?void 0:u.variant)&&(f.original_variant=null==u?void 0:u.variant),c&&(f.metadata=i({},null==u?void 0:u.metadata,{payload:c,original_payload:null==u||null==(l=u.metadata)?void 0:l.payload})),s[a]=f}return this.Jn||(cr.warn(" Overriding feature flag details!",{flagDetails:t,overriddenPayloads:r,finalDetails:s}),this.Jn=!0),s}getAllFeatureFlags(){var t=this.getFlagVariants(),e=this.getFlagPayloads();return Object.keys(t).map((i=>{var r=t[i];return{key:i,enabled:a(r),variant:o(r),payload:n(e[i])}}))}getFlagVariants(){var t=this.us(Kt),e=this.us(te);if(!e)return t||{};for(var i=$t({},t),r=Object.keys(e),s=0;r.length>s;s++)i[r[s]]=e[r[s]];return this.Jn||(cr.warn(" Overriding feature flags!",{enabledFlags:t,overriddenFlags:e,finalFlags:i}),this.Jn=!0),i}getFlagPayloads(){var t=this.us(Zt),e=this.us(ee);if(!e)return t||{};for(var i=$t({},t||{}),r=Object.keys(e),s=0;r.length>s;s++)i[r[s]]=e[r[s]];return this.Jn||(cr.warn(" Overriding feature flag payloads!",{flagPayloads:t,overriddenPayloads:e,finalPayloads:i}),this.Jn=!0),i}reloadFeatureFlags(){this.Xn||this.Se.advanced_disable_feature_flags||this.ls()||this.ps||(this._instance.Ti.emit("featureFlagsReloading",!0),this.ps=setTimeout((()=>{this.gs()}),5))}ys(){clearTimeout(this.ps),this.ps=void 0}ensureFlagsLoaded(){this.Yn||this.Kn||this.ps||this.reloadFeatureFlags()}setAnonymousDistinctId(t){this.$anon_distinct_id=t}setReloadingPaused(t){this.Xn=t}gs(t){var e;if(this.ys(),!this._instance.mr()&&!this.ls())if(this.Kn)this.es=!0;else{var r=this.Se.token,s=this.us("$device_id"),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==(e=this.zr)?void 0:e.get_initial_props())||{},this.us(ie)||{}),group_properties:this.us(re),timezone:Pi()};w(s)||m(s)||(n.$device_id=s),(null!=t&&t.disableFlags||this.Se.advanced_disable_feature_flags)&&(n.disable_flags=!0),this.vs()&&(n.evaluation_contexts=this.cs());var a=this.fs();m(a)||(n.flag_keys=a);var o=!!this.Se.advanced_only_evaluate_survey_feature_flags,l=this._instance.requestRouter.endpointFor("flags","/flags/?v=2"+(this.Se.advanced_only_evaluate_survey_feature_flags?"&only_evaluate_survey_feature_flags=true":""));this.Kn=!0,this._instance._send_request({method:"POST",url:l,data:n,compression:this.Se.disable_compression?void 0:Li,timeout:this.Se.feature_flag_request_timeout_ms,callback:t=>{var e,i,r,s=!0;if(this.bs(t.statusCode),200===t.statusCode&&(this.es||(this.$anon_distinct_id=void 0),s=!1),this.Kn=!1,!n.disable_flags||this.es){this.ts=!s;var a=[];t.error?t.error instanceof Error?a.push("AbortError"===t.error.name?"timeout":"connection_error"):a.push("unknown_error"):200!==t.statusCode&&a.push("api_error_"+t.statusCode),null!=(e=t.json)&&e.errorsWhileComputingFlags&&a.push("errors_while_computing_flags");var l,u=!(null==(i=t.json)||null==(i=i.quotaLimited)||!i.includes("feature_flags"));if(u&&a.push("quota_limited"),null==(r=this.zr)||r.register({[he]:a}),u)cr.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!==(l=t.json)&&void 0!==l?l:{},s,{partialResponse:o}),this.es&&(this.es=!1,this.gs())}}})}}ls(){return this.ss>=3&&Pt()}bs(t){this.ss=((t,e,i,r)=>{if(0===t){if(Pt()){var s=e+1;return 3===s&&cr.warn("Feature flag requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped refreshing feature flags; will try again when connectivity changes."),s}return e}return 0})(t,this.ss)}getFeatureFlag(t,e){var i;if(void 0===e&&(e={}),!e.fresh||this.ts)if(this.Yn||this.getFlags()&&this.getFlags().length>0){if(!this.ds()){var r=this.getFeatureFlagResult(t,e);return null!==(i=null==r?void 0:r.variant)&&void 0!==i?i:null==r?void 0:r.enabled}}else cr.warn('getFeatureFlag for key "'+t+pr)}getFeatureFlagDetails(t){return this.getFlagsWithDetails()[t]}getFeatureFlagPayload(t){var e=this.getFeatureFlagResult(t,{send_event:!1});return null==e?void 0:e.payload}getFeatureFlagResult(t,e){if(void 0===e&&(e={}),!e.fresh||this.ts)if(this.Yn||this.getFlags()&&this.getFlags().length>0){if(!this.ds()){var i=this.getFlagVariants(),r=t in i,s=i[t],a=this.getFlagPayloads()[t],o=String(s),l=this.us(Xt)||void 0,u=this.us(ve)||void 0,h=this.us(le)||{};if(this.Se.advanced_feature_flags_dedup_per_session){var v,d=this._instance.get_session_id(),c=this.us(ue);d&&d!==c&&(h={},null==(v=this.zr)||v.register({[le]:h,[ue]:d}))}if((e.send_event||!("send_event"in e))&&(!(t in h)||!h[t].includes(o))){var f,p,_,b,y,w,x,E,k,S;g(h[t])?h[t].push(o):h[t]=[o],null==(f=this.zr)||f.register({[le]:h});var C=this.getFeatureFlagDetails(t),F=[...null!==(p=this.us(he))&&void 0!==p?p:[]];m(s)&&F.push("flag_missing");var P={$feature_flag:t,$feature_flag_response:s,$feature_flag_payload:a||null,$feature_flag_request_id:l,$feature_flag_evaluated_at:u,$feature_flag_bootstrapped_response:(null==(_=this.Se.bootstrap)||null==(_=_.featureFlags)?void 0:_[t])||null,$feature_flag_bootstrapped_payload:(null==(b=this.Se.bootstrap)||null==(b=b.featureFlagPayloads)?void 0:b[t])||null,$used_bootstrap_value:!this.ts};m(null==C||null==(y=C.metadata)?void 0:y.version)||(P.$feature_flag_version=C.metadata.version);var R,T=null!==(w=null==C||null==(x=C.reason)?void 0:x.description)&&void 0!==w?w:null==C||null==(E=C.reason)?void 0:E.code;T&&(P.$feature_flag_reason=T),null!=C&&null!=(k=C.metadata)&&k.id&&(P.$feature_flag_id=C.metadata.id),m(null==C?void 0:C.original_variant)&&m(null==C?void 0:C.original_enabled)||(P.$feature_flag_original_response=m(C.original_variant)?C.original_enabled:C.original_variant),null!=C&&null!=(S=C.metadata)&&S.original_payload&&(P.$feature_flag_original_payload=null==C||null==(R=C.metadata)?void 0:R.original_payload),F.length&&(P.$feature_flag_error=F.join(",")),this._instance.capture("$feature_flag_called",P)}if(r)return{key:t,enabled:!!s,variant:"string"==typeof s?s:void 0,payload:n(a)}}}else cr.warn('getFeatureFlagResult for key "'+t+pr)}getRemoteConfigPayload(t,e){var i=this.Se.token,r={distinct_id:this._instance.get_distinct_id(),token:i};this.vs()&&(r.evaluation_contexts=this.cs());var s=this.fs();m(s)||(r.flag_keys=s),this._instance._send_request({method:"POST",url:this._instance.requestRouter.endpointFor("flags","/flags/?v=2"),data:r,compression:this.Se.disable_compression?void 0:Li,timeout:this.Se.feature_flag_request_timeout_ms,callback(i){var r,s=null==(r=i.json)?void 0:r.featureFlagPayloads;e((null==s?void 0:s[t])||void 0)}})}isFeatureEnabled(t,e){if(void 0===e&&(e={}),!e.fresh||this.ts){if(this.Yn||this.getFlags()&&this.getFlags().length>0){var i=this.getFeatureFlag(t,e);return m(i)?void 0:!!i}cr.warn('isFeatureEnabled for key "'+t+pr)}}addFeatureFlagsHandler(t){this.featureFlagEventHandlers.push(t)}removeFeatureFlagsHandler(t){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((e=>e!==t))}receivedFeatureFlags(t,e,r){if(this.zr){this.Yn=!0;var s=this.getFlagVariants(),n=this.getFlagPayloads(),a=this.getFlagsWithDetails();!function(t,e,r,s,n,a){void 0===r&&(r={}),void 0===s&&(s={}),void 0===n&&(n={});var o=(t=>{var e=t.flags;return e?(t.featureFlags=Object.fromEntries(Object.keys(e).map((t=>{var i;return[t,null!==(i=e[t].variant)&&void 0!==i?i:e[t].enabled]}))),t.featureFlagPayloads=Object.fromEntries(Object.keys(e).filter((t=>e[t].enabled)).filter((t=>{var i;return null==(i=e[t].metadata)?void 0:i.payload})).map((t=>{var i;return[t,null==(i=e[t].metadata)?void 0:i.payload]})))):t.featureFlags&&cr.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),t})(t),l=o.flags,u=o.featureFlags,h=o.featureFlagPayloads;if(u){var v=t.requestId,d=t.evaluatedAt;if(g(u)){cr.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var c={};if(u)for(var f=0;u.length>f;f++)c[u[f]]=!0;e&&e.register({[Gt]:u,[Kt]:c})}else{var p=u,_=h,b=l;if(null!=a&&a.partialResponse)p=i({},r,p),_=i({},s,_),b=i({},n,b);else if(t.errorsWhileComputingFlags)if(l){var m=new Set(Object.keys(l).filter((t=>{var e;return!(null!=(e=l[t])&&e.failed)})));p=i({},r,Object.fromEntries(Object.entries(p).filter((t=>{var[e]=t;return m.has(e)})))),_=i({},s,Object.fromEntries(Object.entries(_||{}).filter((t=>{var[e]=t;return m.has(e)})))),b=i({},n,Object.fromEntries(Object.entries(b||{}).filter((t=>{var[e]=t;return m.has(e)}))))}else p=i({},r,p),_=i({},s,_),b=i({},n,b);e&&e.register(i({[Gt]:Object.keys(_r(p)),[Kt]:p||{},[Zt]:_||{},[Qt]:b||{}},v?{[Xt]:v}:{},d?{[ve]:d}:{}))}}}(t,this.zr,s,n,a,r),e||(this.ns=!1),this._s(e)}}override(t,e){void 0===e&&(e=!1),cr.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:t,suppressWarning:e})}overrideFeatureFlags(t){if(!this._instance.__loaded||!this.zr)return cr.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(!1===t)return this.zr.unregister(te),this.zr.unregister(ee),this._s(),fr.info("All overrides cleared");if(g(t)){var e=gr(t);return this.zr.register({[te]:e}),this._s(),fr.info("Flag overrides set",{flags:t})}if(t&&"object"==typeof t&&("flags"in t||"payloads"in t)){var i,r=t;if(this.Jn=Boolean(null!==(i=r.suppressWarning)&&void 0!==i&&i),"flags"in r)if(!1===r.flags)this.zr.unregister(te),fr.info("Flag overrides cleared");else if(r.flags){if(g(r.flags)){var s=gr(r.flags);this.zr.register({[te]:s})}else this.zr.register({[te]:r.flags});fr.info("Flag overrides set",{flags:r.flags})}return"payloads"in r&&(!1===r.payloads?(this.zr.unregister(ee),fr.info("Payload overrides cleared")):r.payloads&&(this.zr.register({[ee]:r.payloads}),fr.info("Payload overrides set",{payloads:r.payloads}))),void this._s()}if(t&&"object"==typeof t)return this.zr.register({[te]:t}),this._s(),fr.info("Flag overrides set",{flags:t});cr.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:t})}onFeatureFlags(t){if(this.addFeatureFlagsHandler(t),this.Yn){var{flags:e,flagVariants:i}=this.ws();try{t(e,i)}catch(t){cr.error("Error while running feature flags callback",t)}}return()=>this.removeFeatureFlagsHandler(t)}updateEarlyAccessFeatureEnrollment(t,e,r){var s,n=(this.us(Yt)||[]).find((e=>e.flagKey===t)),a={["$feature_enrollment/"+t]:e},o={$feature_flag:t,$feature_enrollment:e,$set:a};n&&(o.$early_access_feature_name=n.name),r&&(o.$feature_enrollment_stage=r),this._instance.capture("$feature_enrollment_update",o),this.setPersonPropertiesForFlags(a,!1);var l=i({},this.getFlagVariants(),{[t]:e});null==(s=this.zr)||s.register({[Gt]:Object.keys(_r(l)),[Kt]:l}),this._s()}getEarlyAccessFeatures(t,e,i){void 0===e&&(e=!1);var r=this.us(Yt),s=i?"&"+i.map((t=>"stage="+t)).join("&"):"";if(r&&!e)return t(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/early_access_features/?token="+this.Se.token+s),method:"GET",callback:e=>{var i,r;if(e.json){var s=e.json.earlyAccessFeatures;return null==(i=this.zr)||i.unregister(Yt),null==(r=this.zr)||r.register({[Yt]:s}),t(s)}}})}ws(){var t=this.getFlags(),e=this.getFlagVariants();return{flags:t.filter((t=>e[t])),flagVariants:Object.keys(e).filter((t=>e[t])).reduce(((t,i)=>(t[i]=e[i],t)),{})}}_s(t){var{flags:e,flagVariants:i}=this.ws();this.featureFlagEventHandlers.forEach((r=>{try{r(e,i,{errorsLoading:t})}catch(t){cr.error("Error while running feature flags callback",t)}}))}setPersonPropertiesForFlags(t,e){void 0===e&&(e=!0);var r=this.us(ie)||{},s=(null==t?void 0:t.$set)||(null!=t&&t.$set_once?{}:t),n=null==t?void 0:t.$set_once,a={};if(n)for(var o in n)({}).hasOwnProperty.call(n,o)&&(o in r||(a[o]=n[o]));this._instance.register({[ie]:i({},r,a,s)}),e&&this._instance.reloadFeatureFlags()}unsetPersonPropertiesForFlags(t,e){void 0===e&&(e=!0);var r=i({},this.us(ie)||{});t.forEach((t=>{delete r[t]})),this._instance.register({[ie]:r}),e&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(t){void 0===t&&(t=!0),this._instance.unregister(ie),t&&this._instance.reloadFeatureFlags()}setGroupPropertiesForFlags(t,e){void 0===e&&(e=!0);var r=this.us(re)||{};0!==Object.keys(r).length&&Object.keys(r).forEach((e=>{r[e]=i({},r[e],t[e]),delete t[e]})),this._instance.register({[re]:i({},r,t)}),e&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(t){if(t){var e=this.us(re)||{};this._instance.register({[re]:i({},e,{[t]:{}})})}else this._instance.unregister(re)}reset(){this.Yn=!1,this.Kn=!1,this.Xn=!1,this.es=!1,this.ts=!1,this.$anon_distinct_id=void 0,this.ys(),this.Jn=!1,this.ss=0}}},Cr={sessionRecording:class{get Se(){return this._instance.config}get zr(){return this._instance.persistence}get started(){var t;return!(null==(t=this.xs)||!t.isStarted)}get status(){var t,e;return this.ks===Mi||this.ks===ji?this.ks:null!==(t=null==(e=this.xs)?void 0:e.status)&&void 0!==t?t:this.ks}constructor(t){if(this._forceAllowLocalhostNetworkCapture=!1,this.ks=$i,this.Ss=void 0,this._instance=t,!this._instance.sessionManager)throw Vi.error("started without valid sessionManager"),new Error(Hi+" started without valid sessionManager. This is a bug.");if("always"===this.Se.cookieless_mode)throw new Error(Hi+' cannot be used with cookieless_mode="always"')}initialize(){this.startIfEnabledOrStop()}get Cs(){var t,e=!(null==(t=this._instance.get_property(Jt))||!t.enabled),i=!this.Se.disable_session_recording,r=this.Se.disable_session_recording||this._instance.consent.isOptedOut();return xt&&e&&i&&!r}startIfEnabledOrStop(t){var e;if(!this.Cs||null==(e=this.xs)||!e.isStarted){var i=!m(Object.assign)&&!m(Array.from);this.Cs&&i?(this.Is(t),Vi.info("starting")):(this.ks=$i,this.stopRecording())}}Is(t){var e,i,r;this.Cs&&(this.ks!==Mi&&this.ks!==ji&&(this.ks=Oi),null!=Ft&&null!=(e=Ft.__PosthogExtensions__)&&null!=(e=e.rrweb)&&e.record&&null!=(i=Ft.__PosthogExtensions__)&&i.initSessionRecording?this.Ts(t):null==(r=Ft.__PosthogExtensions__)||null==r.loadExternalDependency||r.loadExternalDependency(this._instance,this.Es,(e=>{if(e)return Vi.error("could not load recorder",e);this.Ts(t)})))}stopRecording(){var t,e;null==(t=this.Ss)||t.call(this),this.Ss=void 0,null==(e=this.xs)||e.stop()}Ms(){var t,e;null==(t=this.Ss)||t.call(this),this.Ss=void 0,null==(e=this.xs)||e.discard()}Ps(){var t,e;null==(t=this.zr)||t.unregister("$session_is_sampled"),null==(e=this.zr)||e.unregister("$replay_sample_rate")}Rs(t,e){if(x(t))return null;var i,r=E(t)?t:parseFloat(t);return"number"!=typeof(i=r)||!Number.isFinite(i)||0>i||i>1?(Vi.warn(e+" must be between 0 and 1. Ignoring invalid value:",t),null):r}Os(t){if(this.zr){var e,r,s=this.zr,n=()=>{var e,r=!1===t.sessionRecording?void 0:t.sessionRecording,n=this.Rs(null==(e=this.Se.session_recording)?void 0:e.sampleRate,"session_recording.sampleRate"),a=this.Rs(null==r?void 0:r.sampleRate,"remote config sampleRate"),o=null!=n?n:a;x(o)&&this.Ps();var l=null==r?void 0:r.minimumDurationMilliseconds;s.register({[Jt]:i({cache_timestamp:Date.now(),enabled:!!r},r,{networkPayloadCapture:i({capturePerformance:t.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:o,minimumDurationMilliseconds:m(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==(e=this.Ss)||e.call(this),this.Ss=null==(r=this._instance.sessionManager)?void 0:r.onSessionId(n)}}onRemoteConfig(t){return"sessionRecording"in t?!1===t.sessionRecording?(this.Os(t),void this.Ms()):(this.Os(t),void this.startIfEnabledOrStop()):(this.ks===Mi&&(this.ks=ji,Vi.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(t,e){var i;void 0===e&&(e="log"),null!=(i=this.xs)&&i.log?this.xs.log(t,e):Vi.warn("log called before recorder was ready")}get Es(){var t,e,i=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.get_property(Jt);return(null==i||null==(e=i.scriptConfig)?void 0:e.script)||"lazy-recorder"}Ls(){var t,e,i=this._instance.get_property(Jt);if(!i)return!1;try{e="object"==typeof i?i:JSON.parse(i)}catch(t){return Vi.warn("persisted remote config for session recording is invalid and will be ignored",t),!1}var r=null!==(t=e.cache_timestamp)&&void 0!==t?t:Date.now();return 36e5>=Date.now()-r}Ts(t){var e,i;if(null==(e=Ft.__PosthogExtensions__)||!e.initSessionRecording)return Vi.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({$sdk_debug_recording_script_not_loaded:!0});if(this.xs||(this.xs=null==(i=Ft.__PosthogExtensions__)?void 0:i.initSessionRecording(this._instance),this.xs._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.Ls()){if(this.ks===ji||this.ks===Mi)return;return this.ks=Mi,Vi.info("persisted remote config is stale, requesting fresh config before starting"),void new Ii(this._instance).load()}this.ks=Oi,this.xs.start(t)}onRRwebEmit(t){var e;null==(e=this.xs)||null==e.onRRwebEmit||e.onRRwebEmit(t)}overrideLinkedFlag(){var t,e;this.xs||null==(e=this.zr)||e.register({$replay_override_linked_flag:!0}),null==(t=this.xs)||t.overrideLinkedFlag()}overrideSampling(){var t,e;this.xs||null==(e=this.zr)||e.register({$replay_override_sampling:!0}),null==(t=this.xs)||t.overrideSampling()}overrideTrigger(t){var e,i;this.xs||null==(i=this.zr)||i.register({["url"===t?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),null==(e=this.xs)||e.overrideTrigger(t)}get sdkDebugProperties(){var t;return(null==(t=this.xs)?void 0:t.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(t,e){var i;return!(null==(i=this.xs)||!i.tryAddCustomEvent(t,e))}}},Fr={autocapture:class{constructor(t){this.Fs=!1,this.As=null,this.$s=!1,this.instance=t,this.rageclicks=new ti(t.config.rageclick),this.Ds=null}initialize(){this.startIfEnabled()}get Se(){var t,e,i=b(this.instance.config.autocapture)?this.instance.config.autocapture:{};return i.url_allowlist=null==(t=i.url_allowlist)?void 0:t.map((t=>new RegExp(t))),i.url_ignorelist=null==(e=i.url_ignorelist)?void 0:e.map((t=>new RegExp(t))),i}Ns(){if(this.isBrowserSupported()){if(xt&&St){var t=t=>{t=t||(null==xt?void 0:xt.event);try{this.qs(t)}catch(t){ni.error("Failed to capture event",t)}};if(jt(St,"submit",t,{capture:!0}),jt(St,"change",t,{capture:!0}),jt(St,"click",t,{capture:!0}),this.Se.capture_copied_text){var e=t=>{t=t||(null==xt?void 0:xt.event);try{this.qs(t,si)}catch(t){ni.error("Failed to capture copy/cut event",t)}};jt(St,"copy",e,{capture:!0}),jt(St,"cut",e,{capture:!0})}}}else ni.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this.Fs&&(this.Ns(),this.Fs=!0)}onRemoteConfig(t){t.elementsChainAsString&&(this.$s=t.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[Nt]:!!t.autocapture_opt_out}),this.As=!!t.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(t){this.Ds=t}getElementSelectors(t){var e,i=[];return null==(e=this.Ds)||e.forEach((e=>{var r=null==St?void 0:St.querySelectorAll(e);null==r||r.forEach((r=>{t===r&&i.push(e)}))})),i}get isEnabled(){var t,e,i=null==(t=this.instance.persistence)?void 0:t.props[Nt];if(w(this.As)&&!k(i)&&!this.instance.mr())return!1;var r=null!==(e=this.As)&&void 0!==e?e:!!i;return!!this.instance.config.autocapture&&!r}qs(t,e){if(void 0===e&&(e="$autocapture"),this.isEnabled){var i,r=Re(t);xe(r)&&(r=r.parentNode||null),"$autocapture"===e&&"click"===t.type&&t instanceof MouseEvent&&this.instance.config.rageclick&&null!=(i=this.rageclicks)&&i.isRageClick(t.clientX,t.clientY,t.timeStamp||(new Date).getTime())&&De(r,this.instance.config.rageclick)&&this.qs(t,"$rageclick");var s=e===si;if(r&&function(t,e,i,r,s,n){var a,o,l,u,h,v;if(void 0===i&&(i=void 0),!xt||Ne(t))return!1;if(null!=(a=i)&&a.url_allowlist&&!Se(i.url_allowlist,n))return!1;if(null!=(o=i)&&o.url_ignorelist&&Se(i.url_ignorelist,n))return!1;if(null!=(l=i)&&l.dom_event_allowlist){var d=i.dom_event_allowlist;if(d&&!d.some((t=>e.type===t)))return!1}var{parentIsUsefulElement:c,targetElementList:f}=ze(t,r);if(!function(t,e){var i=null==e?void 0:e.element_allowlist;if(m(i))return!0;var r,s=function(t){if(i.some((e=>t.tagName.toLowerCase()===e)))return{v:!0}};for(var n of t)if(r=s(n))return r.v;return!1}(f,i))return!1;if(!Ae(f,null==(u=i)?void 0:u.css_selector_allowlist))return!1;if(Ae(f,null!==(h=null==(v=i)?void 0:v.css_selector_ignorelist)&&void 0!==h?h:$e))return!1;try{var p=xt.getComputedStyle(t);if(p&&"pointer"===p.getPropertyValue("cursor")&&"click"===e.type)return!0}catch(t){}var g=t.tagName.toLowerCase();switch(g){case"html":return!1;case"form":return(s||["submit"]).indexOf(e.type)>=0;case"input":case"select":case"textarea":return(s||["change","click"]).indexOf(e.type)>=0;default:return c?(s||["click"]).indexOf(e.type)>=0:(s||["click"]).indexOf(e.type)>=0&&(Te.indexOf(g)>-1||"true"===t.getAttribute("contenteditable"))}}(r,t,this.Se,s,s?["copy","cut"]:void 0,this.instance)){var{props:n,explicitNoCapture:a}=li(r,{e:t,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.Se.element_attribute_ignorelist,elementsChainAsString:this.$s,disableCaptureUrlHashes:this.instance.config.disable_capture_url_hashes});if(a)return!1;var o=this.getElementSelectors(r);if(o&&o.length>0&&(n.$element_selectors=o),e===si){var l,u=Fe(null==xt||null==(l=xt.getSelection())?void 0:l.toString()),h=t.type||"clipboard";if(!u)return!1;n.$selected_content=u,n.$copy_type=h}return this.instance.capture(e,n),!0}}}isBrowserSupported(){return _(null==St?void 0:St.querySelectorAll)}},historyAutocapture:class{constructor(t){var e;this._instance=t,this.Bs=(null==xt||null==(e=xt.location)?void 0:e.pathname)||""}initialize(){this.startIfEnabled()}get isEnabled(){return"history_change"===this._instance.config.capture_pageview}startIfEnabled(){this.isEnabled&&(Tt.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this.js&&this.js(),this.js=void 0,Tt.info("History API monitoring stopped")}monitorHistoryChanges(){xt&&xt.history&&(this.Hs("pushState"),this.Hs("replaceState"),this.Us())}Hs(t){var e;if(xt&&(null==(e=xt.history[t])||!e.__posthog_wrapped__)){var i=this;!function(t,e,i){try{if(!(e in t))return()=>{};var r=t[e],s=i(r);return _(s)&&(s.prototype=s.prototype||{},Object.defineProperties(s,{__posthog_wrapped__:{enumerable:!1,value:!0}})),t[e]=s,()=>{t[e]===s&&(t[e]=r)}}catch(t){return()=>{}}}(xt.history,t,(e=>function(r,s,n){e.call(this,r,s,n),i.zs(t)}))}}zs(t){try{var e,i=null==xt||null==(e=xt.location)?void 0:e.pathname;if(!i)return;i!==this.Bs&&this.isEnabled&&this._instance.capture("$pageview",{navigation_type:t}),this.Bs=i}catch(e){Tt.error("Error capturing "+t+" pageview",e)}}Us(){if(!this.js){var t=()=>{this.zs("popstate")};jt(xt,"popstate",t),this.js=()=>{xt&&xt.removeEventListener("popstate",t)}}}},heatmaps:class{get Se(){return this.instance.config}constructor(t){var e;this.Vs=!1,this.Fs=!1,this.Ws=null,this.instance=t,this.Vs=!(null==(e=this.instance.persistence)||!e.props[zt]),this.rageclicks=new ti(t.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var t=5e3;return b(this.Se.capture_heatmaps)&&this.Se.capture_heatmaps.flush_interval_milliseconds&&(t=this.Se.capture_heatmaps.flush_interval_milliseconds),t}get isEnabled(){return x(this.Se.capture_heatmaps)?x(this.Se.enable_heatmaps)?this.Vs:this.Se.enable_heatmaps:!1!==this.Se.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this.Fs)return;Bi.info("starting..."),this.Gs(),this.ke()}else{var t;clearInterval(null!==(t=this.Ws)&&void 0!==t?t:void 0),this.Zs(),this.getAndClearBuffer()}}onRemoteConfig(t){if("heatmaps"in t){var e=!!t.heatmaps;this.instance.persistence&&this.instance.persistence.register({[zt]:e}),this.Vs=e,this.startIfEnabled()}}getAndClearBuffer(){var t=this.R;return this.R=void 0,t}Qs(t){this.fe(t.originalEvent,"deadclick")}ke(){this.Ws&&clearInterval(this.Ws),this.Ws="visible"===(null==St?void 0:St.visibilityState)?setInterval(this.Lr.bind(this),this.flushIntervalMilliseconds):null}Gs(){xt&&St&&(this.Js=this.Lr.bind(this),jt(xt,pe,this.Js),this.Ys=t=>this.fe(t||(null==xt?void 0:xt.event)),jt(St,"click",this.Ys,{capture:!0}),this.Ks=t=>this.Xs(t||(null==xt?void 0:xt.event)),jt(St,"mousemove",this.Ks,{capture:!0}),this.eo=new vi(this.instance,hi,this.Qs.bind(this)),this.eo.startIfEnabledOrStop(),this.ro=this.ke.bind(this),jt(St,fe,this.ro),this.Fs=!0)}Zs(){var t;xt&&St&&(this.Js&&xt.removeEventListener(pe,this.Js),this.Ys&&St.removeEventListener("click",this.Ys,{capture:!0}),this.Ks&&St.removeEventListener("mousemove",this.Ks,{capture:!0}),this.ro&&St.removeEventListener(fe,this.ro),clearTimeout(this.io),null==(t=this.eo)||t.stop(),this.Fs=!1)}no(t,e){var i=this.instance.scrollManager.scrollY(),r=this.instance.scrollManager.scrollX(),s=this.instance.scrollManager.scrollElement(),n=function(t,e,i){for(var r=t;r&&ye(r)&&!we(r,"body");){if(r===i)return!1;var s=void 0;try{var n,a,o;s=null==(n=null!==(a=null==(o=r.ownerDocument)?void 0:o.defaultView)&&void 0!==a?a:xt)?void 0:n.getComputedStyle(r).position}catch(t){return!1}if(v(e,s))return!0;r=Ie(r)}return!1}(Re(t),["fixed","sticky"],s);return{x:t.clientX+(n?0:r),y:t.clientY+(n?0:i),target_fixed:n,type:e}}fe(t,e){var r;if(void 0===e&&(e="click"),!me(t.target)&&qi(t)){var s=this.no(t,e);null!=(r=this.rageclicks)&&r.isRageClick(t.clientX,t.clientY,(new Date).getTime())&&De(Re(t),this.instance.config.rageclick)&&this.so(i({},s,{type:"rageclick"})),this.so(s)}}Xs(t){!me(t.target)&&qi(t)&&(clearTimeout(this.io),this.io=setTimeout((()=>{this.so(this.no(t,"mousemove"))}),500))}so(t){if(xt){var e=this.Se.disable_capture_url_hashes?A(xt.location.href):xt.location.href,i=this.Se.custom_personal_data_properties,r=this.Se.mask_personal_data_properties?[...ki,...i||[]]:[],s=ii(e,r,Ci);this.R=this.R||{},this.R[s]||(this.R[s]=[]),this.R[s].push(t)}}Lr(){this.R&&!(t=>{if(b(t)){for(var e in t)if(f.call(t,e))return!1;return!0}return!1})(this.R)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:vi,webVitalsAutocapture:class{constructor(t){var e;this.Vs=!1,this.Fs=!1,this.R={url:void 0,metrics:[],firstMetricTimestamp:void 0},this.oo=()=>{clearTimeout(this.ao),0!==this.R.metrics.length&&(this._instance.capture("$web_vitals",this.R.metrics.reduce(((t,e)=>i({},t,{["$web_vitals_"+e.name+"_event"]:i({},e),["$web_vitals_"+e.name+"_value"]:e.value})),{})),this.R={url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.lo=t=>{var e;this.R=this.R||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var r=this.uo();if(!m(r))if(x(null==t?void 0:t.name)||x(null==t?void 0:t.value))Ri.error("Invalid metric received",t);else if(!this.ho||this.ho>t.value){this.R.url!==r&&(this.oo(),this.ao=setTimeout(this.oo,this.flushToCaptureTimeoutMs)),m(this.R.url)&&(this.R.url=r),this.R.firstMetricTimestamp=m(this.R.firstMetricTimestamp)?Date.now():this.R.firstMetricTimestamp,t.attribution&&t.attribution.interactionTargetElement&&(t.attribution.interactionTargetElement=void 0);var s=null==(e=this._instance.sessionManager)?void 0:e.checkAndGetSessionAndWindowId(!0),n=i({},t,{$current_url:r,timestamp:Date.now()});m(s)||(n.$session_id=s.sessionId,n.$window_id=s.windowId),this.R.metrics.push(n),this.R.metrics.length===this.allowedMetrics.length&&this.oo()}else Ri.error("Ignoring metric with value >= "+this.ho,t)},this.do=()=>{if(!this.Fs){var t,e,i,r,s=Ft.__PosthogExtensions__;m(s)||m(s.postHogWebVitalsCallbacks)||({onLCP:t,onCLS:e,onFCP:i,onINP:r}=s.postHogWebVitalsCallbacks),t&&e&&i&&r?(this.allowedMetrics.indexOf("LCP")>-1&&t(this.lo.bind(this)),this.allowedMetrics.indexOf("CLS")>-1&&e(this.lo.bind(this)),this.allowedMetrics.indexOf("FCP")>-1&&i(this.lo.bind(this)),this.allowedMetrics.indexOf("INP")>-1&&r(this.lo.bind(this)),this.Fs=!0):Ri.error("web vitals callbacks not loaded - not starting")}},this._instance=t,this.Vs=!(null==(e=this._instance.persistence)||!e.props[Bt]),this.startIfEnabled()}get co(){return this._instance.config.capture_performance}get allowedMetrics(){var t,e,i=b(this.co)?null==(t=this.co)?void 0:t.web_vitals_allowed_metrics:void 0;return x(i)?(null==(e=this._instance.persistence)?void 0:e.props[Wt])||["CLS","FCP","INP","LCP"]:i}get flushToCaptureTimeoutMs(){return(b(this.co)?this.co.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var t=b(this.co)?this.co.web_vitals_attribution:void 0;return null!=t&&t}get ho(){var t=b(this.co)&&E(this.co.__web_vitals_max_value)?this.co.__web_vitals_max_value:Ti;return t>0&&6e4>=t?Ti:t}get isEnabled(){var t=null==Ct?void 0:Ct.protocol;if("http:"!==t&&"https:"!==t)return Ri.info("Web Vitals are disabled on non-http/https protocols"),!1;var e=b(this.co)?this.co.web_vitals:k(this.co)?this.co:void 0;return k(e)?e:this.Vs}startIfEnabled(){this.isEnabled&&!this.Fs&&(Ri.info("enabled, starting..."),this.Mt(this.do))}onRemoteConfig(t){if("capturePerformance"in t){var e=b(t.capturePerformance)&&!!t.capturePerformance.web_vitals,i=b(t.capturePerformance)?t.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[Bt]:e}),this._instance.persistence.register({[Wt]:i})),this.Vs=e,this.startIfEnabled()}}Mt(t){var e,i;null!=(e=Ft.__PosthogExtensions__)&&e.postHogWebVitalsCallbacks?t():null==(i=Ft.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,this.useAttribution?"web-vitals-with-attribution":"web-vitals",(e=>{e?Ri.error("failed to load script",e):t()}))}uo(){var t=xt?this._instance.config.disable_capture_url_hashes?A(xt.location.href):xt.location.href:void 0;if(t){var e=this._instance.config.custom_personal_data_properties,i=this._instance.config.mask_personal_data_properties?[...ki,...e||[]]:[];return ii(t,i,Ci)}Ri.error("Could not determine current URL")}}},Pr={exceptionObserver:class{constructor(t){var e,i,r;this.do=()=>{var t;if(xt&&this.isEnabled&&null!=(t=Ft.__PosthogExtensions__)&&t.errorWrappingFunctions){var e=Ft.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,i=Ft.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,r=Ft.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.vo&&this.Se.capture_unhandled_errors&&(this.vo=e(this.captureException.bind(this))),!this.fo&&this.Se.capture_unhandled_rejections&&(this.fo=i(this.captureException.bind(this))),!this.po&&this.Se.capture_console_errors&&(this.po=r(this.captureException.bind(this)))}catch(t){di.error("failed to start",t),this.mo()}}},this._instance=t,this.yo=!(null==(e=this._instance.persistence)||!e.props[Ut]),this.bo=new T({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,Ae:di}),this.Se=this._o(),this.startIfEnabledOrStop()}_o(){var t=this._instance.config.capture_exceptions,e={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return b(t)?e=i({},e,t):(m(t)?this.yo:t)&&(e=i({},e,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),e}get isEnabled(){return this.Se.capture_console_errors||this.Se.capture_unhandled_errors||this.Se.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(di.info("enabled"),this.mo(),this.Mt(this.do)):this.mo()}Mt(t){var e,i;null!=(e=Ft.__PosthogExtensions__)&&e.errorWrappingFunctions?t():null==(i=Ft.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"exception-autocapture",(e=>{if(e)return di.error("failed to load script",e);t()}))}mo(){var t,e,i;null==(t=this.vo)||t.call(this),this.vo=void 0,null==(e=this.fo)||e.call(this),this.fo=void 0,null==(i=this.po)||i.call(this),this.po=void 0}onRemoteConfig(t){"autocaptureExceptions"in t&&(this.yo=!!t.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[Ut]:this.yo}),this.Se=this._o(),this.startIfEnabledOrStop())}onConfigChange(){this.Se=this._o()}captureException(t){var e,i,r,s=null!==(e=null==t||null==(i=t.$exception_list)||null==(i=i[0])?void 0:i.type)&&void 0!==e?e:"Exception";this.bo.consumeRateLimit(s)?di.info("Skipping exception capture because of client rate limiting.",{exception:s}):null==(r=this._instance.exceptions)||r.sendExceptionEvent(t)}},exceptions:class{constructor(t){var e,r;this.wo=[],this.xo=new W([new st,new ft,new at,new nt,new dt,new vt,new lt,new ct],function(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),s=1;e>s;s++)r[s-1]=arguments[s];return function(e,s){void 0===s&&(s=0);for(var n=[],a=e.split("\n"),o=s;a.length>o;o++){var l=a[o];if(1024>=l.length){var u=rt.test(l)?l.replace(rt,"$1"):l;if(!u.match(/\S*Error: /)){for(var h of r){var v=h(u,t);if(v){n.push(v);break}}if(n.length>=50)break}}}return function(t){if(!t.length)return[];var e=Array.from(t);return e.reverse(),e.slice(0,50).map((t=>{return i({},t,{filename:t.filename||(r=e,r[r.length-1]||{}).filename,function:t.function||J});var r}))}(n)}}("web:javascript",X,it)),this._instance=t,this.wo=null!==(e=null==(r=this._instance.persistence)?void 0:r.get_property(Ht))&&void 0!==e?e:[],this.ko=mt(this.So()),this.Co=new yt(this.ko)}onConfigChange(){this.ko=mt(this.So()),this.Co.setConfig(this.ko)}onRemoteConfig(t){var e,i,r;if("errorTracking"in t){var s=null!==(e=null==(i=t.errorTracking)?void 0:i.suppressionRules)&&void 0!==e?e:[],n=null==(r=t.errorTracking)?void 0:r.captureExtensionExceptions;this.wo=s,this._instance.persistence&&this._instance.persistence.register({[Ht]:this.wo,[Vt]:n})}}get Io(){var t,e=!!this._instance.get_property(Vt),i=this._instance.config.error_tracking.captureExtensionExceptions;return null!==(t=null!=i?i:e)&&void 0!==t&&t}buildProperties(t,e){return this.xo.buildFromUnknown(t,{syntheticException:null==e?void 0:e.syntheticException,mechanism:{handled:null==e?void 0:e.handled}})}addExceptionStep(t,e){if(this.ko.enabled)try{if(!y(t)||0===t.trim().length)return void br.warn("Ignoring exception step because message must be a non-empty string");var r=this.To(e),{sanitizedProperties:s,droppedKeys:n}=function(t){if(!t)return{sanitizedProperties:{},droppedKeys:[]};var e=[];return{sanitizedProperties:Object.keys(t).reduce(((i,r)=>_t.has(r)?(e.push(r),i):(i[r]=t[r],i)),{}),droppedKeys:e}}(r);n.length>0&&br.warn("Ignoring reserved exception step fields",{droppedKeys:n}),this.Co.add(i({[pt]:t,[gt]:(new Date).toISOString()},s))}catch(t){br.error("Failed to add exception step. Ignoring breadcrumb.",t)}}sendExceptionEvent(t){try{var e=t.$exception_list;if(this.Eo(e)){if(this.Mo(e))return this.Po("Exception dropped: matched a suppression rule"),void br.info("Skipping exception capture because a suppression rule matched");if(!this.Io&&this.Ro(e))return this.Po("Exception dropped: thrown by a browser extension"),void br.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.Oo(e))return this.Po("Exception dropped: thrown by the PostHog SDK"),void br.info("Skipping exception capture because it was thrown by the PostHog SDK")}var i=this.ko.enabled&&x(t.$exception_steps)?this.Lo(t):t;try{var r=this._instance.capture("$exception",i,{_noTruncate:!0,_batchKey:"exceptionEvent",Zi:!0});return r&&this.Co.clear(),r}catch(t){return br.error("Failed to capture exception event. Dropping this exception.",t),void this.Co.clear()}}catch(t){return void br.error("Failed to process exception event. Ignoring this exception.",t)}}Lo(t){try{var e=this.Co.getAttachable();return 0===e.length?t:i({},t,{$exception_steps:e})}catch(e){return br.error("Failed to read buffered exception steps. Capturing exception without steps.",e),t}}Po(t){this.ko.enabled&&this.Co.add({[pt]:t,[gt]:(new Date).toISOString()})}To(t){return b(t)?i({},t):{}}So(){var t,e;return null!==(t=null==(e=this._instance.config.error_tracking)?void 0:e.exception_steps)&&void 0!==t?t:{}}Mo(t){if(0===t.length)return!1;var e=t.reduce(((t,e)=>{var{type:i,value:r}=e;return y(i)&&i.length>0&&t.$exception_types.push(i),y(r)&&r.length>0&&t.$exception_values.push(r),t}),{$exception_types:[],$exception_values:[]});return this.wo.some((t=>{var i=t.values.map((t=>{var i,r=Ni[t.operator],s=g(t.value)?t.value:[t.value],n=null!==(i=e[t.key])&&void 0!==i?i:[];return s.length>0&&r(s,n)}));return"OR"===t.type?i.some(Boolean):i.every(Boolean)}))}Ro(t){return t.flatMap((t=>{var e,i;return null!==(e=null==(i=t.stacktrace)?void 0:i.frames)&&void 0!==e?e:[]})).some((t=>t.filename&&t.filename.startsWith("chrome-extension://")))}Oo(t){if(t.length>0){var e,i,r,s,n=null!==(e=null==(i=t[0].stacktrace)?void 0:i.frames)&&void 0!==e?e:[],a=n[n.length-1];return null!==(r=null==a||null==(s=a.filename)?void 0:s.includes("posthog.com/static"))&&void 0!==r&&r}return!1}Eo(t){return!x(t)&&g(t)}}},Rr=i({productTours:class{get zr(){return this._instance.persistence}constructor(t){this.Fo=null,this.Ao=null,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if("productTours"in t){var e,i;if(this.zr&&this.zr.register({[qt]:!!t.productTours}),!Ji(this._instance))return!this.Fo&&x(null==(e=this.zr)?void 0:e.props[oe])||Wi.info("product tours disabled; stopping and clearing cached tours"),null==(i=this.Fo)||i.stop(),this.Fo=null,void this.clearCache();this.loadIfEnabled()}}loadIfEnabled(){!this.Fo&&Ji(this._instance)&&this.Mt((()=>this.$o()))}Mt(t){var e,i;null!=(e=Ft.__PosthogExtensions__)&&e.generateProductTours?t():null==(i=Ft.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"product-tours",(e=>{e?Wi.error("Could not load product tours script",e):t()}))}$o(){var t;!this.Fo&&null!=(t=Ft.__PosthogExtensions__)&&t.generateProductTours&&(this.Fo=Ft.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(t,e){if(void 0===e&&(e=!1),!g(this.Ao)||e){var i=this.zr;if(i){var r=i.props[oe];if(g(r)&&!e)return this.Ao=r,void t(r,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/product_tours/?token="+this._instance.config.token),method:"GET",callback:e=>{if(Ji(this._instance)){var r=e.statusCode;if(200!==r||!e.json){var s="Product Tours API could not be loaded, status: "+r;return Wi.error(s),void t([],{isLoaded:!1,error:s})}var n=g(e.json.product_tours)?e.json.product_tours:[];this.Ao=n,i&&i.register({[oe]:n}),t(n,{isLoaded:!0})}else t([],{isLoaded:!0})}})}else t(this.Ao,{isLoaded:!0})}getActiveProductTours(t){x(this.Fo)?t([],{isLoaded:!1,error:"Product tours not loaded"}):this.Fo.getActiveProductTours(t)}showProductTour(t){var e;null==(e=this.Fo)||e.showTourById(t)}previewTour(t){this.Fo?this.Fo.previewTour(t):this.Mt((()=>{var e;this.$o(),null==(e=this.Fo)||e.previewTour(t)}))}dismissProductTour(){var t;null==(t=this.Fo)||t.dismissTour("user_clicked_skip")}nextStep(){var t;null==(t=this.Fo)||t.nextStep()}previousStep(){var t;null==(t=this.Fo)||t.previousStep()}clearCache(){var t;this.Ao=null,null==(t=this.zr)||t.unregister(oe)}resetTour(t){var e;null==(e=this.Fo)||e.resetTour(t)}resetAllTours(){var t;null==(t=this.Fo)||t.resetAllTours()}cancelPendingTour(t){var e;null==(e=this.Fo)||e.cancelPendingTour(t)}}},Sr),Tr={siteApps:class{constructor(t){this.Do=0,this._instance=t,this.No=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}qo(t,e){if(e){var i=this.globalsForEvent(e);this.No.push(i),this.No.length>1e3&&(this.No=this.No.slice(10))}}get siteAppLoaders(){var t;return null==(t=Ft._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.siteApps}initialize(){if(this.isEnabled){var t=this._instance._addCaptureHook(this.qo.bind(this));this.Bo=()=>{t(),this.No=[],this.Bo=void 0}}}globalsForEvent(t){var e,r,s,n,a,o,l;if(!t)throw new Error("Event payload is required");var u={},h=this._instance.get_property("$groups")||[],v=this._instance.get_property("$stored_group_properties")||{};for(var[d,c]of Object.entries(v))u[d]={id:h[d],type:d,properties:c};var{$set_once:f,$set:p}=t;return{event:i({},function(t,e){if(null==t)return{};var i={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(-1!==e.indexOf(r))continue;i[r]=t[r]}return i}(t,Ki),{properties:i({},t.properties,p?{$set:i({},null!==(e=null==(r=t.properties)?void 0:r.$set)&&void 0!==e?e:{},p)}:{},f?{$set_once:i({},null!==(s=null==(n=t.properties)?void 0:n.$set_once)&&void 0!==s?s:{},f)}:{}),elements_chain:null!==(a=null==(o=t.properties)?void 0:o.$elements_chain)&&void 0!==a?a:"",distinct_id:null==(l=t.properties)?void 0:l.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:u}}jo(t){var e,i=null==(e=t.tagName)?void 0:e.toLowerCase();return"style"===i&&this._instance.config.prepare_external_dependency_stylesheet?this._instance.config.prepare_external_dependency_stylesheet(t)||(Gi.error("prepare_external_dependency_stylesheet returned null"),null):"script"===i&&this._instance.config.prepare_external_dependency_script?this._instance.config.prepare_external_dependency_script(t)||(Gi.error("prepare_external_dependency_script returned null"),null):t}Ho(){var t,e,i,r,s,n,a,o;if(!this._instance.config.prepare_external_dependency_stylesheet&&!this._instance.config.prepare_external_dependency_script)return()=>{};var l=null==St?void 0:St.defaultView,u=null==l||null==(t=l.Node)?void 0:t.prototype;if(!l||!u)return()=>{};if(this.Do++,this.Uo)return this.zo();var h=[],v=this,d=new WeakSet,c=(t,e,i)=>{if(null!=t&&t[e]){var r=t[e];t[e]=i(r),h.push((()=>{t[e]=r}))}},f=t=>{if(d.has(t))return t;var e=v.jo(t);return e&&d.add(e),e},p=t=>t.map((t=>"string"==typeof t?t:f(t))).filter((t=>!w(t)));return c(u,"appendChild",(t=>function(e){var i=f(e);return i?t.call(this,i):e})),c(u,"insertBefore",(t=>function(e,i){var r=f(e);return r?t.call(this,r,i):e})),c(u,"replaceChild",(t=>function(e,i){var r=f(e);return r?t.call(this,r,i):i})),[null==(e=l.Element)?void 0:e.prototype,null==(i=l.Document)?void 0:i.prototype,null==(r=l.DocumentFragment)?void 0:r.prototype].forEach((t=>{c(t,"append",(t=>function(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];return t.apply(this,p(i))})),c(t,"prepend",(t=>function(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];return t.apply(this,p(i))}))})),[null==(s=l.Element)?void 0:s.prototype,null==(n=l.CharacterData)?void 0:n.prototype,null==(a=l.DocumentType)?void 0:a.prototype].forEach((t=>{c(t,"before",(t=>function(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];return t.apply(this,p(i))})),c(t,"after",(t=>function(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];return t.apply(this,p(i))})),c(t,"replaceWith",(t=>function(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];var s=p(i);return i.length&&!s.length?void 0:t.apply(this,s)}))})),c(null==(o=l.Element)?void 0:o.prototype,"insertAdjacentElement",(t=>function(e,i){var r=f(i);return r?t.call(this,e,r):null})),this.Uo=()=>{h.forEach((t=>t())),this.Uo=void 0},this.zo()}zo(){var t=!1;return()=>{var e;t||(t=!0,this.Do--,0===this.Do&&(null==(e=this.Uo)||e.call(this)))}}Vo(t,e){void 0===e&&(e=!0);var i=this.Ho();try{var r=t(i);return e&&i(),r}catch(t){throw i(),t}}setupSiteApp(t){var e=this.apps[t.id],i=()=>{var i;!e.errored&&this.No.length&&(Gi.info("Processing "+this.No.length+" events for site app with id "+t.id),this.No.forEach((t=>this.Vo((()=>null==e.processEvent?void 0:e.processEvent(t))))),e.processedBuffer=!0),Object.values(this.apps).every((t=>t.processedBuffer||t.errored))&&(null==(i=this.Bo)||i.call(this))},r=!1,s=s=>{e.errored=!s,e.loaded=!0,Gi.info("Site app with id "+t.id+" "+(s?"loaded":"errored")),r&&i()};try{var{processEvent:n}=this.Vo((e=>t.init({posthog:this._instance,callback(t){e(),s(t)}})),!1);n&&(e.processEvent=n),r=!0}catch(e){Gi.error(Yi+t.id,e),s(!1)}if(r&&e.loaded)try{i()}catch(i){Gi.error("Error while processing buffered events PostHog app with config id "+t.id,i),e.errored=!0}}Wo(){var t=this.siteAppLoaders||[];for(var e of t)this.apps[e.id]={id:e.id,loaded:!1,errored:!1,processedBuffer:!1};for(var i of t)this.setupSiteApp(i)}Go(t){var e=this;if(0!==Object.keys(this.apps).length){var i=this.globalsForEvent(t),r=function(r){try{e.Vo((()=>null==r.processEvent?void 0:r.processEvent(i)))}catch(e){Gi.error("Error while processing event "+t.event+" for site app "+r.id,e)}};for(var s of Object.values(this.apps))r(s)}}onRemoteConfig(t){var e,i,r,s=this;if(null!=(e=this.siteAppLoaders)&&e.length)return this.isEnabled?(this.Wo(),void this._instance.on("eventCaptured",(t=>this.Go(t)))):void Gi.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null==(i=this.Bo)||i.call(this),null!=(r=t.siteApps)&&r.length)if(this.isEnabled){var n=function(t){var e;Ft["__$$ph_site_app_"+t]=s._instance,null==(e=Ft.__PosthogExtensions__)||null==e.loadSiteApp||e.loadSiteApp(s._instance,o,(e=>{if(e)return Gi.error(Yi+t,e)}))};for(var{id:a,url:o}of t.siteApps)n(a)}else Gi.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}},Ar={tracingHeaders:class{constructor(t){this.Zo=void 0,this.Qo=void 0,this.Jo=void 0,this.do=()=>{var t,e,i=this.Yo();i?(m(this.Zo)&&(this.Zo=null==(t=Ft.__PosthogExtensions__)||null==(t=t.tracingHeadersPatchFns)?void 0:t._patchXHR(i,(()=>this._instance.get_distinct_id()),this._instance.sessionManager)),m(this.Qo)&&(this.Qo=null==(e=Ft.__PosthogExtensions__)||null==(e=e.tracingHeadersPatchFns)?void 0:e._patchFetch(i,(()=>this._instance.get_distinct_id()),this._instance.sessionManager))):this.mo()},this._instance=t}initialize(){this.startIfEnabledOrStop()}Mt(t){var e,i;null!=(e=Ft.__PosthogExtensions__)&&e.tracingHeadersPatchFns?t():null==(i=Ft.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"tracing-headers",(e=>{if(e)return ci.error("failed to load script",e);t()}))}Ko(){var t,e;return null!==(t=null!==(e=this._instance.config.tracing_headers)&&void 0!==e?e:this._instance.config.addTracingHeaders)&&void 0!==t?t:this._instance.config.__add_tracing_headers}Yo(){var t=this.Ko();return g(t)?(g(this.Jo)?this.Jo.splice(0,this.Jo.length,...t):this.Jo=[...t],t.length>0?this.Jo:void 0):(g(this.Jo)&&this.Jo.splice(0),this.Jo=t||void 0,this.Jo)}mo(){var t,e;null==(t=this.Zo)||t.call(this),null==(e=this.Qo)||e.call(this),this.Zo=void 0,this.Qo=void 0}startIfEnabledOrStop(){this.Yo()?this.Mt(this.do):this.mo()}}},Ir=i({surveys:class{get Se(){return this._instance.config}constructor(t){this.Xo=void 0,this._surveyManager=null,this.ea=!1,this.ta=[],this.ra=null,this.ia=null,this._instance=t,this._surveyEventReceiver=null}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!this.Se.disable_surveys){var e=t.surveys;if(x(e))return tr.warn("Flags not loaded yet. Not loading surveys.");var i=g(e);this.Xo=i?e.length>0:e,tr.info("flags response received, isSurveysEnabled: "+this.Xo),this.loadIfEnabled()}}reset(){try{var t;null==(t=this._surveyEventReceiver)||t.reset(),localStorage.removeItem("lastSeenSurveyDate");for(var e=[],i=0;i<localStorage.length;i++){var r=localStorage.key(i);(null!=r&&r.startsWith(er)||null!=r&&r.startsWith("inProgressSurvey_"))&&e.push(r)}e.forEach((t=>localStorage.removeItem(t)))}catch(t){}}loadIfEnabled(){if(!this._surveyManager)if(this.ea)tr.info("Already initializing surveys, skipping...");else if(this.Se.disable_surveys)tr.info(ur);else if(this.Se.cookieless_mode&&this._instance.consent.isOptedOut())tr.info("Not loading surveys in cookieless mode without consent.");else{var t=null==Ft?void 0:Ft.__PosthogExtensions__;if(t){if(!m(this.Xo)||this.Se.advanced_enable_surveys){var e=this.Xo||this.Se.advanced_enable_surveys;this.ea=!0;try{var i=t.generateSurveys;if(i)return void this.na(i,e);var r=t.loadExternalDependency;if(!r)return void this.sa(ce);r(this._instance,"surveys",(i=>{i||!t.generateSurveys?this.sa("Could not load surveys script",i):this.na(t.generateSurveys,e)}))}catch(t){throw this.sa("Error initializing surveys",t),t}finally{this.ea=!1}}}else tr.error("PostHog Extensions not found.")}}na(t,e){this._surveyManager=t(this._instance,e),this._surveyEventReceiver=new or(this._instance),tr.info("Surveys loaded successfully"),this.oa({isLoaded:!0})}sa(t,e){tr.error(t,e),this.oa({isLoaded:!1,error:t})}onSurveysLoaded(t){return this.ta.push(t),this._surveyManager&&this.oa({isLoaded:!0}),()=>{this.ta=this.ta.filter((e=>e!==t))}}getSurveys(t,e){if(void 0===e&&(e=!1),this.Se.disable_surveys)return tr.info(ur),t([]);var i,r=this._instance.get_property(se);if(r&&!e)return t(r,{isLoaded:!0}),void(this.aa()&&this.getSurveys((()=>{}),!0));"undefined"!=typeof Promise&&this.ra?this.ra.then((e=>{var{surveys:i,context:r}=e;return t(i,r)})):("undefined"!=typeof Promise&&(this.ra=new Promise((t=>{i=t}))),this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/surveys/?token="+this.Se.token),method:"GET",timeout:this.Se.surveys_request_timeout_ms,callback:e=>{var r;this.ra=null;var s=e.statusCode;if(200!==s||!e.json){var n="Surveys API could not be loaded, status: "+s;tr.error(n),this.ia=Date.now();var a={isLoaded:!1,error:n};return t([],a),void(null==i||i({surveys:[],context:a}))}this.ia=null;var o,l=e.json.surveys||[],u=l.filter((t=>function(t){return!(!t.start_date||t.end_date)}(t)&&(function(t){var e;return!(null==(e=t.conditions)||null==(e=e.events)||null==(e=e.values)||!e.length)}(t)||function(t){var e;return!(null==(e=t.conditions)||null==(e=e.actions)||null==(e=e.values)||!e.length)}(t))));u.length>0&&(null==(o=this._surveyEventReceiver)||o.register(u)),null==(r=this._instance.persistence)||r.register({[se]:l,[ne]:Date.now()});var h={isLoaded:!0};t(l,h),null==i||i({surveys:l,context:h})}}))}aa(){return this.la()&&!this.ra&&!this.ua()}la(){var t=this._instance.get_property(ne);return E(t)&&Date.now()-t>3e5}ua(){return E(this.ia)&&3e5>Date.now()-this.ia}markSurveyAsSeen(t,e){var i;(t=>{try{var e=(t=>((t,e)=>{var i=""+er+e.id;return e.current_iteration&&e.current_iteration>0&&(i=""+er+e.id+"_"+e.current_iteration),i})(0,t))(t);if(localStorage.getItem(e))return;localStorage.setItem(e,"true")}catch(t){tr.error("Failed to persist survey seen state",t)}})({id:t,current_iteration:null!==(i=null==e?void 0:e.iteration)&&void 0!==i?i:null});try{localStorage.setItem("lastSeenSurveyDate",(new Date).toISOString())}catch(t){}}oa(t){for(var e of this.ta)try{if(!t.isLoaded)return e([],t);this.getSurveys(e)}catch(t){tr.error("Error in survey callback",t)}}getActiveMatchingSurveys(t,e){if(void 0===e&&(e=!1),!x(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(t,e);tr.warn("init was not called")}ha(t){var e=null;return this.getSurveys((i=>{var r;e=null!==(r=i.find((e=>e.id===t)))&&void 0!==r?r:null})),e}da(t){if(x(this._surveyManager))return{eligible:!1,reason:lr};var e="string"==typeof t?this.ha(t):t;return e?this._surveyManager.checkSurveyEligibility(e):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(t){if(x(this._surveyManager))return tr.warn("init was not called"),{visible:!1,disabledReason:lr};var e=this.da(t);return{visible:e.eligible,disabledReason:e.reason}}canRenderSurveyAsync(t,e){return x(this._surveyManager)?(tr.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:lr})):new Promise((i=>{this.getSurveys((e=>{var r,s=null!==(r=e.find((e=>e.id===t)))&&void 0!==r?r:null;if(s){var n=this.da(s);i({visible:n.eligible,disabledReason:n.reason})}else i({visible:!1,disabledReason:"Survey not found"})}),e)}))}renderSurvey(t,e,i){var r;if(x(this._surveyManager))tr.warn("init was not called");else{var s="string"==typeof t?this.ha(t):t;if(null!=s&&s.id)if(ir.includes(s.type)){var n=null==St?void 0:St.querySelector(e);if(n)return null!=(r=s.appearance)&&r.surveyPopupDelaySeconds?(tr.info("Rendering survey "+s.id+" with delay of "+s.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var t,e;tr.info("Rendering survey "+s.id+" with delay of "+(null==(t=s.appearance)?void 0:t.surveyPopupDelaySeconds)+" seconds"),null==(e=this._surveyManager)||e.renderSurvey(s,n,i),tr.info("Survey "+s.id+" rendered")}),1e3*s.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(s,n,i);tr.warn("Survey element not found")}else tr.warn("Surveys of type "+s.type+" cannot be rendered in the app");else tr.warn("Survey not found")}}displaySurvey(t,e){var r;if(x(this._surveyManager))tr.warn("init was not called");else{var s=this.ha(t);if(s){var n=s;if(null!=(r=s.appearance)&&r.surveyPopupDelaySeconds&&e.ignoreDelay&&(n=i({},s,{appearance:i({},s.appearance,{surveyPopupDelaySeconds:0})})),"popover"!==e.displayType&&e.initialResponses&&tr.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),!1===e.ignoreConditions){var a=this.canRenderSurvey(s);if(!a.visible)return void tr.warn("Survey is not eligible to be displayed: ",a.disabledReason)}"inline"!==e.displayType?this._surveyManager.handlePopoverSurvey(n,e):this.renderSurvey(n,e.selector,e.properties)}else tr.warn("Survey not found")}}cancelPendingSurvey(t){x(this._surveyManager)?tr.warn("init was not called"):this._surveyManager.cancelSurvey(t)}handlePageUnload(){var t;null==(t=this._surveyManager)||t.handlePageUnload()}}},Sr),$r={toolbar:class{constructor(t){this.instance=t}ca(t){Ft.ph_toolbar_state=t}va(){var t;return null!==(t=Ft.ph_toolbar_state)&&void 0!==t?t:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(t,e,i){if(void 0===t&&(t=void 0),void 0===e&&(e=void 0),void 0===i&&(i=void 0),Lt(this.instance.config))return!1;if(!xt||!St)return!1;t=null!=t?t:xt.location,i=null!=i?i:xt.history;try{if(!e){try{xt.localStorage.setItem("test","test"),xt.localStorage.removeItem("test")}catch(t){return!1}e=null==xt?void 0:xt.localStorage}var r,s=hr||ri(t.hash,"__posthog")||ri(t.hash,"state"),n=s?Mt((()=>JSON.parse(atob(decodeURIComponent(s)))))||Mt((()=>JSON.parse(decodeURIComponent(s)))):null;return n&&"ph_authorize"===n.action?((r=n).source="url",r&&Object.keys(r).length>0&&(n.desiredHash?t.hash=n.desiredHash:i?i.replaceState(i.state,"",t.pathname+t.search):t.hash="")):((r=JSON.parse(e.getItem(vr)||"{}")).source="localstorage",delete r.userIntent),!(!r.token||this.instance.config.token!==r.token||(this.loadToolbar(r),0))}catch(t){return!1}}fa(t){var e=Ft.ph_load_toolbar||Ft.ph_load_editor;!x(e)&&_(e)?e(t,this.instance):dr.warn("No toolbar load function found")}loadToolbar(t){var e=!(null==St||!St.getElementById(de));if(!xt||e)return!1;var r="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,s=i({token:this.instance.config.token},t,{apiURL:this.instance.requestRouter.endpointFor("ui")},r?{instrument:!1}:{});if(xt.localStorage.setItem(vr,JSON.stringify(i({},s,{source:void 0}))),2===this.va())this.fa(s);else if(0===this.va()){var n;this.ca(1),null==(n=Ft.__PosthogExtensions__)||null==n.loadExternalDependency||n.loadExternalDependency(this.instance,"toolbar",(t=>{if(t)return dr.error("[Toolbar] Failed to load",t),void this.ca(0);this.ca(2),this.fa(s)})),jt(xt,"turbolinks:load",(()=>{this.ca(0),this.loadToolbar(s)}))}return!0}pa(t){return this.loadToolbar(t)}maybeLoadEditor(t,e,i){return void 0===t&&(t=void 0),void 0===e&&(e=void 0),void 0===i&&(i=void 0),this.maybeLoadToolbar(t,e,i)}}},Or=i({experiments:wr},Sr),Mr={conversations:class{constructor(t){this.ga=void 0,this._conversationsManager=null,this.ma=!1,this.ya=null,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!this._instance.config.disable_conversations){var e=t.conversations;x(e)||(k(e)?this.ga=e:(this.ga=e.enabled,this.ya=e),this.loadIfEnabled())}}reset(){var t;null==(t=this._conversationsManager)||t.reset(),this._conversationsManager=null,this.ga=void 0,this.ya=null}loadIfEnabled(){if(!(this._conversationsManager||this.ma||this._instance.config.disable_conversations||Lt(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var t=null==Ft?void 0:Ft.__PosthogExtensions__;if(t&&!m(this.ga)&&this.ga)if(this.ya&&this.ya.token){this.ma=!0;try{var e=t.initConversations;if(e)return this.ba(e),void(this.ma=!1);var i=t.loadExternalDependency;if(!i)return void this._a(ce);i(this._instance,"conversations",(e=>{e||!t.initConversations?this._a("Could not load conversations script",e):this.ba(t.initConversations),this.ma=!1}))}catch(t){this._a("Error initializing conversations",t),this.ma=!1}}else xr.error("Conversations enabled but missing token in remote config.")}}ba(t){if(this.ya)try{this._conversationsManager=t(this.ya,this._instance),xr.info("Conversations loaded successfully")}catch(t){this._a("Error completing conversations initialization",t)}else xr.error("Cannot complete initialization: remote config is null")}_a(t,e){xr.error(t,e),this._conversationsManager=null,this.ma=!1}show(){this._conversationsManager?this._conversationsManager.show():xr.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this.ga&&!w(this._conversationsManager)}isVisible(){var t,e;return null!==(t=null==(e=this._conversationsManager)?void 0:e.isVisible())&&void 0!==t&&t}sendMessage(t,i,r){var s=this;return e((function*(){return s._conversationsManager?s._conversationsManager.sendMessage(t,i,r):(xr.warn(Er),null)}))()}getMessages(t,i){var r=this;return e((function*(){return r._conversationsManager?r._conversationsManager.getMessages(t,i):(xr.warn(Er),null)}))()}markAsRead(t){var i=this;return e((function*(){return i._conversationsManager?i._conversationsManager.markAsRead(t):(xr.warn(Er),null)}))()}getTickets(t){var i=this;return e((function*(){return i._conversationsManager?i._conversationsManager.getTickets(t):(xr.warn(Er),null)}))()}requestRestoreLink(t){var i=this;return e((function*(){return i._conversationsManager?i._conversationsManager.requestRestoreLink(t):(xr.warn(Er),null)}))()}restoreFromToken(t){var i=this;return e((function*(){return i._conversationsManager?i._conversationsManager.restoreFromToken(t):(xr.warn(Er),null)}))()}restoreFromUrlToken(){var t=this;return e((function*(){return t._conversationsManager?t._conversationsManager.restoreFromUrlToken():(xr.warn(Er),null)}))()}getCurrentTicketId(){var t,e;return null!==(t=null==(e=this._conversationsManager)?void 0:e.getCurrentTicketId())&&void 0!==t?t:null}getWidgetSessionId(){var t,e;return null!==(t=null==(e=this._conversationsManager)?void 0:e.getWidgetSessionId())&&void 0!==t?t:null}en(){var t;null==(t=this._conversationsManager)||t.setIdentity()}tn(){var t;null==(t=this._conversationsManager)||t.clearIdentity()}}},jr={logs:class{constructor(t){var e;this.wa=!1,this.xa=!1,this.Ae=At("[logs]"),this._r=[],this.ka=[],this.Sa=()=>{var t,e;null==(t=this.Ca)||t.onReconnect(),null==(e=this.Ia)||e.onReconnect()},this._instance=t,this._instance&&null!=(e=this._instance.config.logs)&&e.captureConsoleLogs&&(this.wa=!0),xt&&jt(xt,"online",this.Sa)}Ta(t,e,i,r){var s,n=function(t,e){var i,r,s,n,a,o,l,u=null!==(i=null==t?void 0:t.flushIntervalMs)&&void 0!==i?i:3e3,h=null!==(r=null==t?void 0:t.maxBufferSize)&&void 0!==r?r:100,v=null!=e&&e.consoleCapture?void 0:null!==(s=null==t?void 0:t.maxLogsPerInterval)&&void 0!==s?s:1e3,d=m(v)?Math.max(h,2048):Math.max(h,v),c=null==t?void 0:t.resourceAttributes;return{serviceName:null!==(n=null!==(a=null==c?void 0:c["service.name"])&&void 0!==a?a:null==t?void 0:t.serviceName)&&void 0!==n?n:null==e?void 0:e.serviceNameDefault,serviceVersion:null!==(o=null==c?void 0:c["service.version"])&&void 0!==o?o:null==t?void 0:t.serviceVersion,environment:null!==(l=null==c?void 0:c["deployment.environment"])&&void 0!==l?l:null==t?void 0:t.environment,resourceAttributes:c,beforeSend:null==t?void 0:t.beforeSend,flushIntervalMs:u,maxBufferSize:h,maxQueueSize:d,maxBatchRecordsPerPost:100,rateCapWindowMs:u,maxLogsPerInterval:v,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}}(null==(s=this._instance)||null==(s=s.config)?void 0:s.logs,i);return[new U(this.Ea(t,e),n,this.Ae,(()=>this.Ma()),(t=>t()),void 0,r),n]}Pa(){var t,e,i=null==(t=this._instance)||null==(t=t.config)?void 0:t.logs;return this.Ca&&this.Ra===i||(null==(e=this.Ca)||e.reset(),this.Ra=i,[this.Ca,this.Oa]=this.Ta((()=>this._r),(t=>{this._r=t}))),this.Ca}La(){var t,e,i=null==(t=this._instance)||null==(t=t.config)?void 0:t.logs;return this.Ia&&this.Fa===i||(null==(e=this.Ia)||e.reset(),this.Fa=i,[this.Ia,this.Aa]=this.Ta((()=>this.ka),(t=>{this.ka=t}),{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},kr)),this.Ia}initialize(){this.loadIfEnabled()}onRemoteConfig(t){var e,i=null==(e=t.logs)?void 0:e.captureConsoleLogs;!x(i)&&i&&(this.wa=!0,this.loadIfEnabled())}reset(){var t,e;this._r=[],null==(t=this.Ca)||t.reset(),this.ka=[],null==(e=this.Ia)||e.reset()}captureLog(t){this.Pa().captureLog(t)}le(t){this.La().captureLog(t)}get logger(){return this.$a||(this.$a={trace:(t,e)=>this.captureLog({body:t,level:"trace",attributes:e}),debug:(t,e)=>this.captureLog({body:t,level:"debug",attributes:e}),info:(t,e)=>this.captureLog({body:t,level:"info",attributes:e}),warn:(t,e)=>this.captureLog({body:t,level:"warn",attributes:e}),error:(t,e)=>this.captureLog({body:t,level:"error",attributes:e}),fatal:(t,e)=>this.captureLog({body:t,level:"fatal",attributes:e})}),this.$a}flushLogs(t){t?this.Da(t):(this.Ca&&this.Ca.flush().catch((t=>this.Ae.error("PostHog logs flush failed:",t))),this.Ia&&this.Ia.flush().catch((t=>this.Ae.error("PostHog logs flush failed:",t))))}loadIfEnabled(){if(this.wa&&!this.xa){var t=null==Ft?void 0:Ft.__PosthogExtensions__;if(t){var e=t.loadExternalDependency;e?e(this._instance,"logs",(e=>{var i;e||null==(i=t.logs)||!i.initializeLogs?this.Ae.error("Could not load logs script",e):(t.logs.initializeLogs(this._instance),this.xa=!0)})):this.Ae.error(ce)}else this.Ae.error("PostHog Extensions not found.")}}Ea(t,e){var i=this._instance;return{get isDisabled(){return!1},get optedOut(){return!i.is_capturing()},getPersistedProperty:e=>e===l.LogsQueue?t():void 0,setPersistedProperty(t,i){var r;t===l.LogsQueue&&e(null!==(r=i)&&void 0!==r?r:[])},ht:t=>this.ht(t),getLibraryId:()=>s,getLibraryVersion:()=>r}}ht(t){return new Promise((e=>{var i=!1,r=t=>{i||(i=!0,clearTimeout(s),e(t))},s=setTimeout((()=>r({kind:"retry-later",error:new Error("logs request timed out")})),9e4);this._instance._send_request({method:"POST",url:this.Na(),data:t,compression:"best-available",batchKey:"logs",fireCallbackOnDrop:!0,callback(t){var e=t.statusCode;if(e>=200&&300>e)r({kind:"ok"});else if(413===e)r({kind:"too-large"});else if(0!==e&&429!==e&&500>e)r({kind:"fatal",error:new Error("logs request failed with status "+e)});else{var i;r({kind:"retry-later",error:null!==(i=t.error)&&void 0!==i?i:new Error("logs request failed with status "+e)})}}})}))}Da(t){this._r.length>0&&this.qa(t,this._r,this.Oa,s,(t=>{this._r=t})),this.ka.length>0&&this.qa(t,this.ka,this.Aa,kr,(t=>{this.ka=t}))}qa(t,e,i,n,a){if(0!==e.length){var o=e.map((t=>t.record));a([]);var l=z(o,N(i,s,r),n,r);this._instance._send_request({method:"POST",url:this.Na(),data:l,compression:"best-available",batchKey:"logs",transport:t})}}Na(){return this._instance.requestRouter.endpointFor("api","/i/v1/logs")+"?token="+encodeURIComponent(this._instance.config.token)}Ma(){var t,e={};if(e.distinctId=this._instance.get_distinct_id(),this._instance.sessionManager){var{sessionId:i,windowId:r,sessionStartTimestamp:s,lastActivityTimestamp:n}=this._instance.sessionManager.checkAndGetSessionAndWindowId(!0);e.sessionId=i,e.windowId=r,x(s)||(e.sessionStartTimestamp=s),x(n)||(e.lastActivityTimestamp=n)}if(null!=Ft&&null!=(t=Ft.location)&&t.href&&(e.currentUrl=this._instance.config.disable_capture_url_hashes?A(Ft.location.href):Ft.location.href),this._instance.featureFlags){var a=this._instance.featureFlags.getFlags();a&&a.length>0&&(e.activeFeatureFlags=a)}return e}}},Lr=i({},Sr,Cr,Fr,Pr,Rr,Tr,Ir,Ar,$r,Or,Mr,jr),Dr=Sr,Nr=Cr,zr=Fr,Ur=Pr,Hr=Rr,Vr=Tr,Br=Ir,qr=Ar,Wr=$r,Jr=Or,Kr=Mr,Gr=jr;export{Lr as AllExtensions,zr as AnalyticsExtensions,Kr as ConversationsExtensions,Ur as ErrorTrackingExtensions,Jr as ExperimentsExtensions,Dr as FeatureFlagsExtensions,Gr as LogsExtensions,Hr as ProductToursExtensions,Nr as SessionReplayExtensions,Vr as SiteAppsExtensions,Br as SurveysExtensions,Wr as ToolbarExtensions,qr as TracingExtensions};
|
|
2
2
|
//# sourceMappingURL=extension-bundles.js.map
|