posthog-js 1.396.2 → 1.396.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/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/dist/product-tours.js +1 -1
- package/dist/src/entrypoints/web-vitals-with-attribution.d.ts +19 -0
- package/dist/src/entrypoints/web-vitals.d.ts +18 -0
- package/dist/surveys.js +1 -1
- package/dist/web-vitals-with-attribution.js +1 -1
- package/dist/web-vitals-with-attribution.js.map +1 -1
- package/dist/web-vitals.js +1 -1
- package/dist/web-vitals.js.map +1 -1
- package/lib/package.json +1 -1
- package/lib/src/entrypoints/web-vitals-with-attribution.d.ts +19 -0
- package/lib/src/entrypoints/web-vitals-with-attribution.js +3 -0
- package/lib/src/entrypoints/web-vitals-with-attribution.js.map +1 -1
- package/lib/src/entrypoints/web-vitals.d.ts +18 -0
- package/lib/src/entrypoints/web-vitals.js +3 -0
- package/lib/src/entrypoints/web-vitals.js.map +1 -1
- package/lib/src/utils/array-at-polyfill.d.ts +0 -0
- package/lib/src/utils/array-at-polyfill.js +33 -0
- package/lib/src/utils/array-at-polyfill.js.map +1 -0
- package/lib/tsconfig.tsbuildinfo +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.2",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 F(t){return null===t||"object"!=typeof t}function C(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 I{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 T(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.je=s,this.Be=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.je((()=>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.Be()}))()}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=T((()=>{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=>T(e,t)))]):yield e}))()}flushWithTimeout(t){var i=this;return e((function*(){var e=!1,r=i.flush(),s=new Promise((i=>T((()=>{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 W(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 q{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:W(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,X=/\((\S*)(?::(\d+))(?::(\d+))\)/,Z=(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=X.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 C(t,"DOMException")}isDOMError(t){return C(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 C(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 F(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 C(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 F(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=function(t){var e=new WeakSet;try{return JSON.stringify(t,((t,i)=>{if("bigint"==typeof i)return i.toString();if("function"!=typeof i&&"symbol"!=typeof i){if(i instanceof Date)return i.toISOString();if(i instanceof Error)return{name:i.name,message:i.message,stack:i.stack};if(i&&"object"==typeof i){if(e.has(i))return"[Circular]";e.add(i)}return i}}))}catch(t){return}}(t);if(e)try{var i=JSON.parse(e);if(!b(i))return;var r=i,s=r[pt],n=r[gt];if(!y(s)||0===s.trim().length)return;if(!y(n)&&!E(n))return;return{step:r,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,Ft=null==Et?void 0:Et.location;null!=Et&&Et.XMLHttpRequest&&new Et.XMLHttpRequest;var Ct=null!=xt?xt:{},Pt=function(t,e){var{debugEnabled:i}=void 0===e?{}:e,r={k(e){if(xt&&(Ct.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)=>Pt(t+" "+e,i)};return r},Rt=Pt("[PostHog.js]"),It=Rt.createLogger;function $t(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 At=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 Tt(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 Ot=function(t){try{return t()}catch(t){return}};function Mt(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 jt(t){return"ph_toolbar_internal"===t.name}function Lt(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 Rt.error("Error in get_current_url, falling back to window.location.href",t),e}}var Dt="$autocapture_disabled_server_side",Nt="$heatmaps_enabled_server_side",zt="$exception_capture_enabled_server_side",Ut="$error_tracking_suppression_rules",Ht="$error_tracking_capture_extension_exceptions",Vt="$web_vitals_enabled_server_side",Bt="$product_tours_enabled_server_side",Wt="$web_vitals_allowed_metrics",qt="$session_recording_remote_config",Jt="$enabled_feature_flags",Kt="$active_feature_flags",Gt="$early_access_features",Yt="$feature_flag_details",Qt="$feature_flag_payloads",Xt="$feature_flag_request_id",Zt="$override_feature_flags",te="$override_feature_flag_payloads",ee="$stored_person_properties",ie="$stored_group_properties",re="$surveys",se="$surveys_activated",ne="ph_product_tours",ae="$flag_call_reported",oe="$flag_call_reported_session_id",le="$feature_flag_errors",ue="$feature_flag_evaluated_at",he="__POSTHOG_TOOLBAR__",ve="PostHog loadExternalDependency extension not found.",de="visibilitychange",ce="beforeunload",fe=1,pe=3,ge=11;function _e(t){return t instanceof Element&&(t.id===he||!(null==t.closest||!t.closest(".toolbar-global-fade-container")))}function be(t){return!!t&&t.nodeType===fe}function me(t,e){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===e.toLowerCase()}function ye(t){return!!t&&t.nodeType===pe}function we(t){return!!t&&t.nodeType===ge&&be(t.host)}function xe(t){return t?d(t).split(/\s+/):[]}function Ee(t,e){var i=function(t){var e,i=null==xt||null==(e=xt.location)?void 0:e.href;return m(i)?void 0:Lt(t,i)}(e);return!!(i&&t&&t.some((t=>i.match(t))))}function ke(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 xe(e)}function Se(t){return x(t)?null:d(t).split(/(\s+)/).filter((t=>Je(t))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Fe(t){var e="";return Ne(t)&&!ze(t)&&t.childNodes&&t.childNodes.length&&$t(t.childNodes,(function(t){var i;ye(t)&&t.textContent&&(e+=null!==(i=Se(t.textContent))&&void 0!==i?i:"")})),d(e)}function Ce(t){return m(t.target)?t.srcElement||null:null!=(e=t.target)&&e.shadowRoot?t.composedPath()[0]||null:t.target||null;var e}var Pe=["a","button","form","input","select","textarea","label"];function Re(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||!be(e))&&e}var $e=[".ph-no-autocapture","[data-ph-no-autocapture]"],Ae=["next","previous","prev",">","<"],Te=(t,e)=>/[a-z0-9]/i.test(e)?t.includes(e):t===e,Oe=[".ph-no-rageclick",".ph-no-capture"],Me=["","text","search","email","password","url","tel","number"];function je(t,e){if(!xt||Le(t))return!1;var i,r,s,n,a;if(k(e)?(i=!!e&&Oe,r=void 0,s=!1):(i=null!==(n=null==e?void 0:e.css_selector_ignorelist)&&void 0!==n?n:Oe,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||!be(t))&&(!!me(t,"textarea")||(me(t,"input")?v(Me,(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}=De(t,!1);return!function(t,e){if(!1===t||m(t))return!1;var i;if(!0===t)i=Ae;else{if(!g(t))return!1;if(t.length>10)return Rt.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=>Te(e,t)||Te(r,t)))}))}(r,o.map((t=>{var e;return{safeText:Fe(t).toLowerCase(),ariaLabel:(null==(e=t.getAttribute("aria-label"))?void 0:e.toLowerCase().trim())||""}})))&&!Re(o,i)}var Le=t=>!t||me(t,"html")||!be(t),De=(t,e)=>{if(!xt||Le(t))return{parentIsUsefulElement:!1,targetElementList:[]};for(var i=!1,r=[t],s=t;s.parentNode&&!me(s,"body");)if(we(s.parentNode))r.push(s.parentNode.host),s=s.parentNode.host;else{var n=Ie(s);if(!n)break;if(e||Pe.indexOf(n.tagName.toLowerCase())>-1)i=!0;else{var a=xt.getComputedStyle(n);a&&"pointer"===a.getPropertyValue("cursor")&&(i=!0)}r.push(n),s=n}return{parentIsUsefulElement:i,targetElementList:r}};function Ne(t){for(var e=t;e.parentNode&&!me(e,"body");e=e.parentNode){var i=ke(e);if(v(i,"ph-sensitive")||v(i,"ph-no-capture"))return!1}if(v(ke(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 ze(t){return!!(me(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||me(t,"select")||me(t,"textarea")||"true"===t.getAttribute("contenteditable"))}var Ue="(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})",He=new RegExp("^(?:"+Ue+")$"),Ve=new RegExp(Ue),Be="\\d{3}-?\\d{2}-?\\d{4}",We=new RegExp("^("+Be+")$"),qe=new RegExp("("+Be+")");function Je(t,e){if(void 0===e&&(e=!0),x(t))return!1;if(y(t)){if(t=d(t),(e?He:Ve).test((t||"").replace(/[- ]/g,"")))return!1;if((e?We:qe).test(t))return!1}return!0}function Ke(t){var e=Fe(t);return Je(e=(e+" "+Ge(t)).trim())?e:""}function Ge(t){var e="";return t&&t.childNodes&&t.childNodes.length&&$t(t.childNodes,(function(t){var i;if(t&&"span"===(null==(i=t.tagName)?void 0:i.toLowerCase()))try{var r=Fe(t);e=(e+" "+r).trim(),t.childNodes&&t.childNodes.length&&(e=(e+" "+Ge(t)).trim())}catch(t){Rt.error("[AutoCapture]",t)}})),e}function Ye(t){return t.replace(/"|\\"/g,'\\"')}function Qe(t){var e=t.attr__class;return e?g(e)?e:xe(e):void 0}class Xe{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 Ze=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){Rt.error("Skipping decoding for malformed query param: "+a)}return a.replace(/\+/g," ")},ti=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},ei=function(t,e){var i=t.match(new RegExp(e+"=([^&]*)"));return i?i[1]:null},ii="$copy_autocapture",ri=It("[AutoCapture]");function si(t,e){return e.length>t?e.slice(0,t)+"...":e}function ni(t){if(t.previousElementSibling)return t.previousElementSibling;var e=t;do{e=e.previousSibling}while(e&&!be(e));return e}function ai(t,e){var r,s,{e:n,maskAllElementAttributes:a,maskAllText:o,elementAttributeIgnoreList:l,elementsChainAsString:u,disableCaptureUrlHashes:h}=e;if(!be(t))return{props:{}};for(var d=[t],c=t;c.parentNode&&!me(c,"body");)if(we(c.parentNode))d.push(c.parentNode.host),c=c.parentNode.host;else{if(!be(c.parentNode))break;d.push(c.parentNode),c=c.parentNode}var f,p,g=[],_={},b=!1,w=!1;if($t(d,(t=>{var e=Ne(t);if(me(t,"a")){var i=t.getAttribute("href");b=!!(e&&i&&Je(i))&&(h?A(i):i)}v(ke(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};Pe.indexOf(n)>-1&&!i&&(a.$el_text="a"===n.toLowerCase()||"button"===n.toLowerCase()?si(1024,Ke(t)):si(1024,Fe(t)));var o=ke(t);o.length>0&&(a.classes=o.filter((function(t){return""!==t}))),$t(t.attributes,(function(i){var n;if((!ze(t)||-1!==["name","id","class","aria-label"].indexOf(i.name))&&(null==r||!r.includes(i.name))&&!e&&Je(i.value)&&(!y(n=i.name)||"_ngcontent"!==n.substring(0,10)&&"_nghost"!==n.substring(0,7))){var o=i.value;"class"===i.name&&(o=xe(o).join(" ")),a["attr__"+i.name]=si(1024,"href"===i.name&&s?A(o):o)}}));for(var l=1,u=1,h=t;h=ni(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(!Ne(t))return{};var e={};return $t(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&&Je(r)&&(e[i]=r)}})),e}(t);At(_,r)})),w)return{props:{},explicitNoCapture:w};if(o||(g[0].$el_text=me(t,"a")||me(t,"button")?Ke(t):Fe(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:At({$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 Tt(a).sort(((t,e)=>{var[i]=t,[r]=e;return i.localeCompare(r)})).forEach((t=>{var[e,i]=t;return o[Ye(e.toString())]=Ye(i.toString())})),(s+=":")+Tt(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:Qe(t),attr_id:t.attr__id,nth_child:t.nth_child,nth_of_type:t.nth_of_type,attributes:{}};return Tt(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 oi=It("[Dead Clicks]"),li=()=>!0;class ui{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=Ct.__PosthogExtensions__)&&e.initDeadClicksAutocapture?t():null==(i=Ct.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this.instance,"dead-clicks-autocapture",(e=>{e?oi.error("failed to load script",e):t()}))}Pt(){var t;if(St){if(!this.Et&&null!=(t=Ct.__PosthogExtensions__)&&t.initDeadClicksAutocapture){var e=b(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};e.__onCapture=this.onCapture,this.Et=Ct.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,e),this.Et.start(St),oi.info("starting...")}}else oi.error("`document` not found. Cannot start.")}stop(){this.Et&&(this.Et.stop(),this.Et=void 0,oi.info("stopping..."))}}var hi=It("[ExceptionAutocapture]"),vi=It("[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 di{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 di(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 di(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 ci{constructor(){this.S=0,this.C=0,this.I=new gi}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 di.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 fi,pi=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&&(pi=t=>crypto.getRandomValues(t));class gi{constructor(){this.R=new Uint32Array(8),this.O=1/0}nextUint32(){return this.R.length>this.O||(pi(this.R),this.O=0),this.R[this.O++]}}var _i=()=>(fi||(fi=new ci)).generate(),bi="",mi=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;function yi(t,e){if(e){var i=function(t,e){if(void 0===e&&(e=St),bi)return bi;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_"+_i().toString();!bi&&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",bi=n)}return bi}(t);if(!i){var r=(t=>{var e=t.match(mi);return e?e[0]:""})(t);r!==i&&Rt.info("Warning: cookie subdomain discovery mismatch",r,i),i=r}return i?"; domain=."+i:""}return""}var wi={N:()=>!!St,D(t){Rt.error("cookieStore error: "+t)},P(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(wi.P(t))||{}}catch(t){}return e},q(t,e,i,r,s){if(!St)return!1;try{var n="",a="",o=yi(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&&Rt.warn("cookieStore warning: large cookie, len="+u.length),St.cookie=u,!0}catch(t){return!1}},A(t,e){if(null!=St&&St.cookie)try{wi.q(t,"",-1,e)}catch(t){return}}},xi=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],Ei=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...xi],ki="<masked>",Si=["li_fat_id"];function Fi(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(t){return}}var Ci=It("[Web Vitals]"),Pi=9e5,Ri=It("[RemoteConfig]");class Ii{constructor(t){this._instance=t}get remoteConfig(){var t;return null==(t=Ct._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.config}cr(t){var e,i;null!=(e=Ct.__PosthogExtensions__)&&e.loadExternalDependency?null==(i=Ct.__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 Ri.info("Using preloaded remote config",this.remoteConfig),this.pr(this.remoteConfig),void this.gr();if(this._instance.mr())return void Ri.warn("Remote config is disabled. Falling back to local config.");this.cr((t=>{if(!t)return Ri.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){Ri.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||Ri.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",Ai="lazy_loading",Ti="awaiting_config",Oi="missing_config",Mi="base64",ji=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}},Li={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=>ji(e,t))))),not_regex:(t,e)=>e.every((e=>t.every((t=>!ji(e,t))))),icontains:(t,e)=>e.map(Di).some((e=>t.map(Di).some((t=>e.includes(t))))),not_icontains:(t,e)=>e.map(Di).every((e=>t.map(Di).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)))}))},Di=t=>t.toLowerCase();function Ni(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=Li[r.operator];return!!a&&a(r.values,n)}))}It("[SessionRecording]"),It("[SessionRecording]");var zi="[SessionRecording]",Ui=It(zi),Hi=It("[Heatmaps]");function Vi(t){return b(t)&&"clientX"in t&&"clientY"in t&&E(t.clientX)&&E(t.clientY)}var Bi=It("[Product Tours]"),Wi=t=>{var e;return!t.config.disable_product_tours&&!(null==(e=t.persistence)||!e.get_property(Bt))},qi=["$set_once","$set"],Ji=It("[SiteApps]"),Ki="Error while initializing PostHog app with config id ",Gi="events",Yi="cancelEvents",Qi="survey shown",Xi=It("[Surveys]"),Zi=["popover","widget","api"];class tr{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 er(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 ir{constructor(t){this.sn=new tr,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(!er(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=>er(t.href,e.href,e.href_matching||"exact")));var s,n=(null==t||null==(i=t.properties)?void 0:i.$elements_chain)||"";return!!n&&er((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=>er(t.text,e.text,e.text_matching||"exact")||er(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=>er(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||Ni(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 rr{constructor(t){this._n=[],this._instance=t,this.wn=new Map,this.xn=new Map,this.kn=new Map}Sn(t,e){return!!t&&Ni(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===Gi?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 ir(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,Gi),this.xn=this.Cn(t,Yi))}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,Yi);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,Gi);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.jn(t)))}reset(){this._n=[],this.Dn().length>0&&this.Nn([])}getEventToItemsMap(){return this.wn}Bn(){return this.Pn}}class sr extends rr{constructor(t){super(t)}qn(){return se}Hn(){return Qi}Tn(t){var e;null==(e=this._instance)||e.getSurveys(t)}An(t){var e;null==(e=this._instance)||e.cancelPendingSurvey(t)}Rn(){return Xi}Nn(t){var e;null==(e=this._instance)||null==(e=e.persistence)||e.register({[se]:t})}jn(){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===Qi?"consume":"ignore":t===Qi?"persist":"survey dismissed"===t||"survey sent"===t?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}}var nr="SDK is not enabled or survey functionality is not yet loaded",ar="Disabled. Not loading surveys.",or=null!=xt&&xt.location?ei(xt.location.hash,"__posthog")||ei(location.hash,"state"):null,lr="_postHogToolbarParams",ur=It("[Toolbar]"),hr=It("[FeatureFlags]"),vr=It("[FeatureFlags]",{debugEnabled:!0}),dr="\" failed. Feature flags didn't load in time.",cr=t=>{for(var e={},i=0;t.length>i;i++)e[t[i]]=!0;return e},fr=t=>{var e={};for(var[i,r]of Tt(t||{}))r&&(e[i]=r);return e},pr=It("[Error tracking]"),gr="Refusing to render web experiment since the viewer is a likely bot",_r={icontains:(t,e)=>e.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,e)=>-1===e.toLowerCase().indexOf(t.toLowerCase()),regex:(t,e)=>ji(e,t),not_regex:(t,e)=>!ji(e,t),exact:(t,e)=>e===t,is_not:(t,e)=>e!==t};class br{get Se(){return this._instance.config}constructor(t){var e=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(t){void 0===t&&(t=!1),e.getWebExperiments((t=>{br.Un("retrieved web experiments from the server"),e.zn=new Map,t.forEach((t=>{if(t.feature_flag_key){var i;e.zn&&(br.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];br.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())br.Un(gr);else if(!this.Se.disable_web_experiments){if(x(this.zn))return this.zn=new Map,this.loadIfEnabled(),void this.previewWebExperiment();br.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=br.getWindowLocation();if(null!=t&&t.search){var e=Ze(null==t?void 0:t.search,"__experiment_id"),i=Ze(null==t?void 0:t.search,"__experiment_variant");e&&i&&(br.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&&(br.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)&&br.Zn(t,e)&&br.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=br.getWindowLocation();if(r){var s,n,a,o=Lt(e,r.href);return null==(s=t.conditions)||!s.url||_r[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=ti(St.URL,[],ki),s=Ei.concat([]),n={},$t(s,(function(t){var e=Ze(r,t);n[t]=e||null})),n),o=function(){var t={};return $t(Si,(function(e){var i=wi.P(e);t[e]=i||null})),t}();return At(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];Rt.info("[WebExperiments] "+t,i)}Vn(t,e,i){this._is_bot()?br.Un(gr):"control"!==e?i.forEach((i=>{if(i.selector){var r;br.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)}))}})):br.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 mr=It("[Conversations]"),yr="Conversations not available yet.",wr="console",xr={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._instance=t,this.featureFlagEventHandlers=[]}get Se(){return this._instance.config}get zr(){return this._instance.persistence}ss(t){return this._instance.get_property(t)}os(){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}ls(){return!!this.os()&&(this.ns||this.Kn||(this.ns=!0,hr.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}us(){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||(hr.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||hr.error("Invalid evaluation context found:",t,"Expected non-empty string"),e})):[]}hs(){return this.us().length>0}ds(){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||hr.error("Invalid flag key found:",t,"Expected non-empty string"),e}));hr.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.ss(Jt))&&void 0!==s?s:{},u=null!=r&&r.merge&&null!==(n=this.ss(Qt))&&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.ss(Yt),e=this.ss(Zt),r=this.ss(te);if(!r&&!e)return t||{};var s=At({},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||(hr.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.ss(Jt),e=this.ss(Zt);if(!e)return t||{};for(var i=At({},t),r=Object.keys(e),s=0;r.length>s;s++)i[r[s]]=e[r[s]];return this.Jn||(hr.warn(" Overriding feature flags!",{enabledFlags:t,overriddenFlags:e,finalFlags:i}),this.Jn=!0),i}getFlagPayloads(){var t=this.ss(Qt),e=this.ss(te);if(!e)return t||{};for(var i=At({},t||{}),r=Object.keys(e),s=0;r.length>s;s++)i[r[s]]=e[r[s]];return this.Jn||(hr.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.cs||(this._instance.Ti.emit("featureFlagsReloading",!0),this.cs=setTimeout((()=>{this.vs()}),5))}fs(){clearTimeout(this.cs),this.cs=void 0}ensureFlagsLoaded(){this.Yn||this.Kn||this.cs||this.reloadFeatureFlags()}setAnonymousDistinctId(t){this.$anon_distinct_id=t}setReloadingPaused(t){this.Xn=t}vs(t){var e;if(this.fs(),!this._instance.mr())if(this.Kn)this.es=!0;else{var r=this.Se.token,s=this.ss("$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.ss(ee)||{}),group_properties:this.ss(ie),timezone:Fi()};w(s)||m(s)||(n.$device_id=s),(null!=t&&t.disableFlags||this.Se.advanced_disable_feature_flags)&&(n.disable_flags=!0),this.hs()&&(n.evaluation_contexts=this.us());var a=this.ds();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:Mi,timeout:this.Se.feature_flag_request_timeout_ms,callback:t=>{var e,i,r,s=!0;if(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({[le]:a}),u)hr.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.vs())}}})}}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.ls()){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 hr.warn('getFeatureFlag for key "'+t+dr)}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.ls()){var i=this.getFlagVariants(),r=t in i,s=i[t],a=this.getFlagPayloads()[t],o=String(s),l=this.ss(Xt)||void 0,u=this.ss(ue)||void 0,h=this.ss(ae)||{};if(this.Se.advanced_feature_flags_dedup_per_session){var v,d=this._instance.get_session_id(),c=this.ss(oe);d&&d!==c&&(h={},null==(v=this.zr)||v.register({[ae]:h,[oe]: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({[ae]:h});var F=this.getFeatureFlagDetails(t),C=[...null!==(p=this.ss(le))&&void 0!==p?p:[]];m(s)&&C.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==F||null==(y=F.metadata)?void 0:y.version)||(P.$feature_flag_version=F.metadata.version);var R,I=null!==(w=null==F||null==(x=F.reason)?void 0:x.description)&&void 0!==w?w:null==F||null==(E=F.reason)?void 0:E.code;I&&(P.$feature_flag_reason=I),null!=F&&null!=(k=F.metadata)&&k.id&&(P.$feature_flag_id=F.metadata.id),m(null==F?void 0:F.original_variant)&&m(null==F?void 0:F.original_enabled)||(P.$feature_flag_original_response=m(F.original_variant)?F.original_enabled:F.original_variant),null!=F&&null!=(S=F.metadata)&&S.original_payload&&(P.$feature_flag_original_payload=null==F||null==(R=F.metadata)?void 0:R.original_payload),C.length&&(P.$feature_flag_error=C.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 hr.warn('getFeatureFlagResult for key "'+t+dr)}getRemoteConfigPayload(t,e){var i=this.Se.token,r={distinct_id:this._instance.get_distinct_id(),token:i};this.hs()&&(r.evaluation_contexts=this.us());var s=this.ds();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:Mi,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}hr.warn('isFeatureEnabled for key "'+t+dr)}}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&&hr.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)){hr.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({[Kt]:u,[Jt]: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({[Kt]:Object.keys(fr(p)),[Jt]:p||{},[Qt]:_||{},[Yt]:b||{}},v?{[Xt]:v}:{},d?{[ue]:d}:{}))}}}(t,this.zr,s,n,a,r),e||(this.ns=!1),this.ps(e)}}override(t,e){void 0===e&&(e=!1),hr.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:t,suppressWarning:e})}overrideFeatureFlags(t){if(!this._instance.__loaded||!this.zr)return hr.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(!1===t)return this.zr.unregister(Zt),this.zr.unregister(te),this.ps(),vr.info("All overrides cleared");if(g(t)){var e=cr(t);return this.zr.register({[Zt]:e}),this.ps(),vr.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(Zt),vr.info("Flag overrides cleared");else if(r.flags){if(g(r.flags)){var s=cr(r.flags);this.zr.register({[Zt]:s})}else this.zr.register({[Zt]:r.flags});vr.info("Flag overrides set",{flags:r.flags})}return"payloads"in r&&(!1===r.payloads?(this.zr.unregister(te),vr.info("Payload overrides cleared")):r.payloads&&(this.zr.register({[te]:r.payloads}),vr.info("Payload overrides set",{payloads:r.payloads}))),void this.ps()}if(t&&"object"==typeof t)return this.zr.register({[Zt]:t}),this.ps(),vr.info("Flag overrides set",{flags:t});hr.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:t})}onFeatureFlags(t){if(this.addFeatureFlagsHandler(t),this.Yn){var{flags:e,flagVariants:i}=this.gs();t(e,i)}return()=>this.removeFeatureFlagsHandler(t)}updateEarlyAccessFeatureEnrollment(t,e,r){var s,n=(this.ss(Gt)||[]).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({[Kt]:Object.keys(fr(l)),[Jt]:l}),this.ps()}getEarlyAccessFeatures(t,e,i){void 0===e&&(e=!1);var r=this.ss(Gt),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(Gt),null==(r=this.zr)||r.register({[Gt]:s}),t(s)}}})}gs(){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)),{})}}ps(t){var{flags:e,flagVariants:i}=this.gs();this.featureFlagEventHandlers.forEach((r=>r(e,i,{errorsLoading:t})))}setPersonPropertiesForFlags(t,e){void 0===e&&(e=!0);var r=this.ss(ee)||{},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({[ee]:i({},r,a,s)}),e&&this._instance.reloadFeatureFlags()}unsetPersonPropertiesForFlags(t,e){void 0===e&&(e=!0);var r=i({},this.ss(ee)||{});t.forEach((t=>{delete r[t]})),this._instance.register({[ee]:r}),e&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(t){void 0===t&&(t=!0),this._instance.unregister(ee),t&&this._instance.reloadFeatureFlags()}setGroupPropertiesForFlags(t,e){void 0===e&&(e=!0);var r=this.ss(ie)||{};0!==Object.keys(r).length&&Object.keys(r).forEach((e=>{r[e]=i({},r[e],t[e]),delete t[e]})),this._instance.register({[ie]:i({},r,t)}),e&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(t){if(t){var e=this.ss(ie)||{};this._instance.register({[ie]:i({},e,{[t]:{}})})}else this._instance.unregister(ie)}reset(){this.Yn=!1,this.Kn=!1,this.Xn=!1,this.es=!1,this.ts=!1,this.$anon_distinct_id=void 0,this.fs(),this.Jn=!1}}},Er={sessionRecording:class{get Se(){return this._instance.config}get zr(){return this._instance.persistence}get started(){var t;return!(null==(t=this.ys)||!t.isStarted)}get status(){var t,e;return this.bs===Ti||this.bs===Oi?this.bs:null!==(t=null==(e=this.ys)?void 0:e.status)&&void 0!==t?t:this.bs}constructor(t){if(this._forceAllowLocalhostNetworkCapture=!1,this.bs=$i,this._s=void 0,this._instance=t,!this._instance.sessionManager)throw Ui.error("started without valid sessionManager"),new Error(zi+" started without valid sessionManager. This is a bug.");if("always"===this.Se.cookieless_mode)throw new Error(zi+' cannot be used with cookieless_mode="always"')}initialize(){this.startIfEnabledOrStop()}get ws(){var t,e=!(null==(t=this._instance.get_property(qt))||!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.ws||null==(e=this.ys)||!e.isStarted){var i=!m(Object.assign)&&!m(Array.from);this.ws&&i?(this.xs(t),Ui.info("starting")):(this.bs=$i,this.stopRecording())}}xs(t){var e,i,r;this.ws&&(this.bs!==Ti&&this.bs!==Oi&&(this.bs=Ai),null!=Ct&&null!=(e=Ct.__PosthogExtensions__)&&null!=(e=e.rrweb)&&e.record&&null!=(i=Ct.__PosthogExtensions__)&&i.initSessionRecording?this.ks(t):null==(r=Ct.__PosthogExtensions__)||null==r.loadExternalDependency||r.loadExternalDependency(this._instance,this.Ss,(e=>{if(e)return Ui.error("could not load recorder",e);this.ks(t)})))}stopRecording(){var t,e;null==(t=this._s)||t.call(this),this._s=void 0,null==(e=this.ys)||e.stop()}Cs(){var t,e;null==(t=this._s)||t.call(this),this._s=void 0,null==(e=this.ys)||e.discard()}Is(){var t,e;null==(t=this.zr)||t.unregister("$session_is_sampled"),null==(e=this.zr)||e.unregister("$replay_sample_rate")}Ts(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?(Ui.warn(e+" must be between 0 and 1. Ignoring invalid value:",t),null):r}Es(t){if(this.zr){var e,r,s=this.zr,n=()=>{var e,r=!1===t.sessionRecording?void 0:t.sessionRecording,n=this.Ts(null==(e=this.Se.session_recording)?void 0:e.sampleRate,"session_recording.sampleRate"),a=this.Ts(null==r?void 0:r.sampleRate,"remote config sampleRate"),o=null!=n?n:a;x(o)&&this.Is();var l=null==r?void 0:r.minimumDurationMilliseconds;s.register({[qt]: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._s)||e.call(this),this._s=null==(r=this._instance.sessionManager)?void 0:r.onSessionId(n)}}onRemoteConfig(t){return"sessionRecording"in t?!1===t.sessionRecording?(this.Es(t),void this.Cs()):(this.Es(t),void this.startIfEnabledOrStop()):(this.bs===Ti&&(this.bs=Oi,Ui.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.ys)&&i.log?this.ys.log(t,e):Ui.warn("log called before recorder was ready")}get Ss(){var t,e,i=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.get_property(qt);return(null==i||null==(e=i.scriptConfig)?void 0:e.script)||"lazy-recorder"}Ms(){var t,e,i=this._instance.get_property(qt);if(!i)return!1;try{e="object"==typeof i?i:JSON.parse(i)}catch(t){return Ui.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}ks(t){var e,i;if(null==(e=Ct.__PosthogExtensions__)||!e.initSessionRecording)return Ui.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.ys||(this.ys=null==(i=Ct.__PosthogExtensions__)?void 0:i.initSessionRecording(this._instance),this.ys._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.Ms()){if(this.bs===Oi||this.bs===Ti)return;return this.bs=Ti,Ui.info("persisted remote config is stale, requesting fresh config before starting"),void new Ii(this._instance).load()}this.bs=Ai,this.ys.start(t)}onRRwebEmit(t){var e;null==(e=this.ys)||null==e.onRRwebEmit||e.onRRwebEmit(t)}overrideLinkedFlag(){var t,e;this.ys||null==(e=this.zr)||e.register({$replay_override_linked_flag:!0}),null==(t=this.ys)||t.overrideLinkedFlag()}overrideSampling(){var t,e;this.ys||null==(e=this.zr)||e.register({$replay_override_sampling:!0}),null==(t=this.ys)||t.overrideSampling()}overrideTrigger(t){var e,i;this.ys||null==(i=this.zr)||i.register({["url"===t?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),null==(e=this.ys)||e.overrideTrigger(t)}get sdkDebugProperties(){var t;return(null==(t=this.ys)?void 0:t.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(t,e){var i;return!(null==(i=this.ys)||!i.tryAddCustomEvent(t,e))}}},kr={autocapture:class{constructor(t){this.Ps=!1,this.Rs=null,this.Os=!1,this.instance=t,this.rageclicks=new Xe(t.config.rageclick),this.Ls=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}Fs(){if(this.isBrowserSupported()){if(xt&&St){var t=t=>{t=t||(null==xt?void 0:xt.event);try{this.As(t)}catch(t){ri.error("Failed to capture event",t)}};if(Mt(St,"submit",t,{capture:!0}),Mt(St,"change",t,{capture:!0}),Mt(St,"click",t,{capture:!0}),this.Se.capture_copied_text){var e=t=>{t=t||(null==xt?void 0:xt.event);try{this.As(t,ii)}catch(t){ri.error("Failed to capture copy/cut event",t)}};Mt(St,"copy",e,{capture:!0}),Mt(St,"cut",e,{capture:!0})}}}else ri.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this.Ps&&(this.Fs(),this.Ps=!0)}onRemoteConfig(t){t.elementsChainAsString&&(this.Os=t.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[Dt]:!!t.autocapture_opt_out}),this.Rs=!!t.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(t){this.Ls=t}getElementSelectors(t){var e,i=[];return null==(e=this.Ls)||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[Dt];if(w(this.Rs)&&!k(i)&&!this.instance.mr())return!1;var r=null!==(e=this.Rs)&&void 0!==e?e:!!i;return!!this.instance.config.autocapture&&!r}As(t,e){if(void 0===e&&(e="$autocapture"),this.isEnabled){var i,r=Ce(t);ye(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())&&je(r,this.instance.config.rageclick)&&this.As(t,"$rageclick");var s=e===ii;if(r&&function(t,e,i,r,s,n){var a,o,l,u,h,v;if(void 0===i&&(i=void 0),!xt||Le(t))return!1;if(null!=(a=i)&&a.url_allowlist&&!Ee(i.url_allowlist,n))return!1;if(null!=(o=i)&&o.url_ignorelist&&Ee(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}=De(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(!Re(f,null==(u=i)?void 0:u.css_selector_allowlist))return!1;if(Re(f,null!==(h=null==(v=i)?void 0:v.css_selector_ignorelist)&&void 0!==h?h:$e))return!1;var p=xt.getComputedStyle(t);if(p&&"pointer"===p.getPropertyValue("cursor")&&"click"===e.type)return!0;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&&(Pe.indexOf(g)>-1||"true"===t.getAttribute("contenteditable"))}}(r,t,this.Se,s,s?["copy","cut"]:void 0,this.instance)){var{props:n,explicitNoCapture:a}=ai(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.Os,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===ii){var l,u=Se(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.$s=(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&&(Rt.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this.Ds&&this.Ds(),this.Ds=void 0,Rt.info("History API monitoring stopped")}monitorHistoryChanges(){xt&&xt.history&&(this.Ns("pushState"),this.Ns("replaceState"),this.qs())}Ns(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.js(t)}))}}js(t){try{var e,i=null==xt||null==(e=xt.location)?void 0:e.pathname;if(!i)return;i!==this.$s&&this.isEnabled&&this._instance.capture("$pageview",{navigation_type:t}),this.$s=i}catch(e){Rt.error("Error capturing "+t+" pageview",e)}}qs(){if(!this.Ds){var t=()=>{this.js("popstate")};Mt(xt,"popstate",t),this.Ds=()=>{xt&&xt.removeEventListener("popstate",t)}}}},heatmaps:class{get Se(){return this.instance.config}constructor(t){var e;this.Bs=!1,this.Ps=!1,this.Hs=null,this.instance=t,this.Bs=!(null==(e=this.instance.persistence)||!e.props[Nt]),this.rageclicks=new Xe(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.Bs:this.Se.enable_heatmaps:!1!==this.Se.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this.Ps)return;Hi.info("starting..."),this.Us(),this.ke()}else{var t;clearInterval(null!==(t=this.Hs)&&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({[Nt]:e}),this.Bs=e,this.startIfEnabled()}}getAndClearBuffer(){var t=this.R;return this.R=void 0,t}Vs(t){this.fe(t.originalEvent,"deadclick")}ke(){this.Hs&&clearInterval(this.Hs),this.Hs="visible"===(null==St?void 0:St.visibilityState)?setInterval(this.Lr.bind(this),this.flushIntervalMilliseconds):null}Us(){xt&&St&&(this.Ws=this.Lr.bind(this),Mt(xt,ce,this.Ws),this.Gs=t=>this.fe(t||(null==xt?void 0:xt.event)),Mt(St,"click",this.Gs,{capture:!0}),this.Zs=t=>this.Qs(t||(null==xt?void 0:xt.event)),Mt(St,"mousemove",this.Zs,{capture:!0}),this.Js=new ui(this.instance,li,this.Vs.bind(this)),this.Js.startIfEnabledOrStop(),this.Ys=this.ke.bind(this),Mt(St,de,this.Ys),this.Ps=!0)}zs(){var t;xt&&St&&(this.Ws&&xt.removeEventListener(ce,this.Ws),this.Gs&&St.removeEventListener("click",this.Gs,{capture:!0}),this.Zs&&St.removeEventListener("mousemove",this.Zs,{capture:!0}),this.Ys&&St.removeEventListener(de,this.Ys),clearTimeout(this.Ks),null==(t=this.Js)||t.stop(),this.Ps=!1)}Xs(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&&be(r)&&!me(r,"body");){if(r===i)return!1;if(v(e,null==xt?void 0:xt.getComputedStyle(r).position))return!0;r=Ie(r)}return!1}(Ce(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"),!_e(t.target)&&Vi(t)){var s=this.Xs(t,e);null!=(r=this.rageclicks)&&r.isRageClick(t.clientX,t.clientY,(new Date).getTime())&&je(Ce(t),this.instance.config.rageclick)&&this.eo(i({},s,{type:"rageclick"})),this.eo(s)}}Qs(t){!_e(t.target)&&Vi(t)&&(clearTimeout(this.Ks),this.Ks=setTimeout((()=>{this.eo(this.Xs(t,"mousemove"))}),500))}eo(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?[...xi,...i||[]]:[],s=ti(e,r,ki);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:ui,webVitalsAutocapture:class{constructor(t){var e;this.Bs=!1,this.Ps=!1,this.R={url:void 0,metrics:[],firstMetricTimestamp:void 0},this.ro=()=>{clearTimeout(this.io),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.no=t=>{var e;this.R=this.R||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var r=this.so();if(!m(r))if(x(null==t?void 0:t.name)||x(null==t?void 0:t.value))Ci.error("Invalid metric received",t);else if(!this.oo||this.oo>t.value){this.R.url!==r&&(this.ro(),this.io=setTimeout(this.ro,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.ro()}else Ci.error("Ignoring metric with value >= "+this.oo,t)},this.ao=()=>{if(!this.Ps){var t,e,i,r,s=Ct.__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.no.bind(this)),this.allowedMetrics.indexOf("CLS")>-1&&e(this.no.bind(this)),this.allowedMetrics.indexOf("FCP")>-1&&i(this.no.bind(this)),this.allowedMetrics.indexOf("INP")>-1&&r(this.no.bind(this)),this.Ps=!0):Ci.error("web vitals callbacks not loaded - not starting")}},this._instance=t,this.Bs=!(null==(e=this._instance.persistence)||!e.props[Vt]),this.startIfEnabled()}get lo(){return this._instance.config.capture_performance}get allowedMetrics(){var t,e,i=b(this.lo)?null==(t=this.lo)?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.lo)?this.lo.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var t=b(this.lo)?this.lo.web_vitals_attribution:void 0;return null!=t&&t}get oo(){var t=b(this.lo)&&E(this.lo.__web_vitals_max_value)?this.lo.__web_vitals_max_value:Pi;return t>0&&6e4>=t?Pi:t}get isEnabled(){var t=null==Ft?void 0:Ft.protocol;if("http:"!==t&&"https:"!==t)return Ci.info("Web Vitals are disabled on non-http/https protocols"),!1;var e=b(this.lo)?this.lo.web_vitals:k(this.lo)?this.lo:void 0;return k(e)?e:this.Bs}startIfEnabled(){this.isEnabled&&!this.Ps&&(Ci.info("enabled, starting..."),this.Mt(this.ao))}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({[Vt]:e}),this._instance.persistence.register({[Wt]:i})),this.Bs=e,this.startIfEnabled()}}Mt(t){var e,i;null!=(e=Ct.__PosthogExtensions__)&&e.postHogWebVitalsCallbacks?t():null==(i=Ct.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,this.useAttribution?"web-vitals-with-attribution":"web-vitals",(e=>{e?Ci.error("failed to load script",e):t()}))}so(){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?[...xi,...e||[]]:[];return ti(t,i,ki)}Ci.error("Could not determine current URL")}}},Sr={exceptionObserver:class{constructor(t){var e,i,r;this.ao=()=>{var t;if(xt&&this.isEnabled&&null!=(t=Ct.__PosthogExtensions__)&&t.errorWrappingFunctions){var e=Ct.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,i=Ct.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,r=Ct.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.uo&&this.Se.capture_unhandled_errors&&(this.uo=e(this.captureException.bind(this))),!this.ho&&this.Se.capture_unhandled_rejections&&(this.ho=i(this.captureException.bind(this))),!this.do&&this.Se.capture_console_errors&&(this.do=r(this.captureException.bind(this)))}catch(t){hi.error("failed to start",t),this.co()}}},this._instance=t,this.vo=!(null==(e=this._instance.persistence)||!e.props[zt]),this.fo=new I({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:hi}),this.Se=this.po(),this.startIfEnabledOrStop()}po(){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.vo: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?(hi.info("enabled"),this.co(),this.Mt(this.ao)):this.co()}Mt(t){var e,i;null!=(e=Ct.__PosthogExtensions__)&&e.errorWrappingFunctions?t():null==(i=Ct.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"exception-autocapture",(e=>{if(e)return hi.error("failed to load script",e);t()}))}co(){var t,e,i;null==(t=this.uo)||t.call(this),this.uo=void 0,null==(e=this.ho)||e.call(this),this.ho=void 0,null==(i=this.do)||i.call(this),this.do=void 0}onRemoteConfig(t){"autocaptureExceptions"in t&&(this.vo=!!t.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[zt]:this.vo}),this.Se=this.po(),this.startIfEnabledOrStop())}onConfigChange(){this.Se=this.po()}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.fo.consumeRateLimit(s)?hi.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.mo=[],this.yo=new q([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",Z,it)),this._instance=t,this.mo=null!==(e=null==(r=this._instance.persistence)?void 0:r.get_property(Ut))&&void 0!==e?e:[],this.bo=mt(this._o()),this.wo=new yt(this.bo)}onConfigChange(){this.bo=mt(this._o()),this.wo.setConfig(this.bo)}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.mo=s,this._instance.persistence&&this._instance.persistence.register({[Ut]:this.mo,[Ht]:n})}}get xo(){var t,e=!!this._instance.get_property(Ht),i=this._instance.config.error_tracking.captureExtensionExceptions;return null!==(t=null!=i?i:e)&&void 0!==t&&t}buildProperties(t,e){return this.yo.buildFromUnknown(t,{syntheticException:null==e?void 0:e.syntheticException,mechanism:{handled:null==e?void 0:e.handled}})}addExceptionStep(t,e){if(this.bo.enabled)try{if(!y(t)||0===t.trim().length)return void pr.warn("Ignoring exception step because message must be a non-empty string");var r=this.ko(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&&pr.warn("Ignoring reserved exception step fields",{droppedKeys:n}),this.wo.add(i({[pt]:t,[gt]:(new Date).toISOString()},s))}catch(t){pr.error("Failed to add exception step. Ignoring breadcrumb.",t)}}sendExceptionEvent(t){try{var e=t.$exception_list;if(this.So(e)){if(this.Co(e))return this.Io("Exception dropped: matched a suppression rule"),void pr.info("Skipping exception capture because a suppression rule matched");if(!this.xo&&this.To(e))return this.Io("Exception dropped: thrown by a browser extension"),void pr.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.Eo(e))return this.Io("Exception dropped: thrown by the PostHog SDK"),void pr.info("Skipping exception capture because it was thrown by the PostHog SDK")}var i=this.bo.enabled&&x(t.$exception_steps)?this.Mo(t):t;try{var r=this._instance.capture("$exception",i,{_noTruncate:!0,_batchKey:"exceptionEvent",Zi:!0});return r&&this.wo.clear(),r}catch(t){return pr.error("Failed to capture exception event. Dropping this exception.",t),void this.wo.clear()}}catch(t){return void pr.error("Failed to process exception event. Ignoring this exception.",t)}}Mo(t){try{var e=this.wo.getAttachable();return 0===e.length?t:i({},t,{$exception_steps:e})}catch(e){return pr.error("Failed to read buffered exception steps. Capturing exception without steps.",e),t}}Io(t){this.bo.enabled&&this.wo.add({[pt]:t,[gt]:(new Date).toISOString()})}ko(t){return b(t)?i({},t):{}}_o(){var t,e;return null!==(t=null==(e=this._instance.config.error_tracking)?void 0:e.exception_steps)&&void 0!==t?t:{}}Co(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.mo.some((t=>{var i=t.values.map((t=>{var i,r=Li[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)}))}To(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://")))}Eo(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}So(t){return!x(t)&&g(t)}}},Fr=i({productTours:class{get zr(){return this._instance.persistence}constructor(t){this.Po=null,this.Ro=null,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if("productTours"in t){var e,i;if(this.zr&&this.zr.register({[Bt]:!!t.productTours}),!Wi(this._instance))return!this.Po&&x(null==(e=this.zr)?void 0:e.props[ne])||Bi.info("product tours disabled; stopping and clearing cached tours"),null==(i=this.Po)||i.stop(),this.Po=null,void this.clearCache();this.loadIfEnabled()}}loadIfEnabled(){!this.Po&&Wi(this._instance)&&this.Mt((()=>this.Oo()))}Mt(t){var e,i;null!=(e=Ct.__PosthogExtensions__)&&e.generateProductTours?t():null==(i=Ct.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"product-tours",(e=>{e?Bi.error("Could not load product tours script",e):t()}))}Oo(){var t;!this.Po&&null!=(t=Ct.__PosthogExtensions__)&&t.generateProductTours&&(this.Po=Ct.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(t,e){if(void 0===e&&(e=!1),!g(this.Ro)||e){var i=this.zr;if(i){var r=i.props[ne];if(g(r)&&!e)return this.Ro=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(Wi(this._instance)){var r=e.statusCode;if(200!==r||!e.json){var s="Product Tours API could not be loaded, status: "+r;return Bi.error(s),void t([],{isLoaded:!1,error:s})}var n=g(e.json.product_tours)?e.json.product_tours:[];this.Ro=n,i&&i.register({[ne]:n}),t(n,{isLoaded:!0})}else t([],{isLoaded:!0})}})}else t(this.Ro,{isLoaded:!0})}getActiveProductTours(t){x(this.Po)?t([],{isLoaded:!1,error:"Product tours not loaded"}):this.Po.getActiveProductTours(t)}showProductTour(t){var e;null==(e=this.Po)||e.showTourById(t)}previewTour(t){this.Po?this.Po.previewTour(t):this.Mt((()=>{var e;this.Oo(),null==(e=this.Po)||e.previewTour(t)}))}dismissProductTour(){var t;null==(t=this.Po)||t.dismissTour("user_clicked_skip")}nextStep(){var t;null==(t=this.Po)||t.nextStep()}previousStep(){var t;null==(t=this.Po)||t.previousStep()}clearCache(){var t;this.Ro=null,null==(t=this.zr)||t.unregister(ne)}resetTour(t){var e;null==(e=this.Po)||e.resetTour(t)}resetAllTours(){var t;null==(t=this.Po)||t.resetAllTours()}cancelPendingTour(t){var e;null==(e=this.Po)||e.cancelPendingTour(t)}}},xr),Cr={siteApps:class{constructor(t){this.Lo=0,this._instance=t,this.Fo=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}Ao(t,e){if(e){var i=this.globalsForEvent(e);this.Fo.push(i),this.Fo.length>1e3&&(this.Fo=this.Fo.slice(10))}}get siteAppLoaders(){var t;return null==(t=Ct._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.siteApps}initialize(){if(this.isEnabled){var t=this._instance._addCaptureHook(this.Ao.bind(this));this.$o=()=>{t(),this.Fo=[],this.$o=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,qi),{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}}Do(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)||(Ji.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)||(Ji.error("prepare_external_dependency_script returned null"),null):t}No(){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.Lo++,this.qo)return this.jo();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.Do(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.qo=()=>{h.forEach((t=>t())),this.qo=void 0},this.jo()}jo(){var t=!1;return()=>{var e;t||(t=!0,this.Lo--,0===this.Lo&&(null==(e=this.qo)||e.call(this)))}}Bo(t,e){void 0===e&&(e=!0);var i=this.No();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.Fo.length&&(Ji.info("Processing "+this.Fo.length+" events for site app with id "+t.id),this.Fo.forEach((t=>this.Bo((()=>null==e.processEvent?void 0:e.processEvent(t))))),e.processedBuffer=!0),Object.values(this.apps).every((t=>t.processedBuffer||t.errored))&&(null==(i=this.$o)||i.call(this))},r=!1,s=s=>{e.errored=!s,e.loaded=!0,Ji.info("Site app with id "+t.id+" "+(s?"loaded":"errored")),r&&i()};try{var{processEvent:n}=this.Bo((e=>t.init({posthog:this._instance,callback(t){e(),s(t)}})),!1);n&&(e.processEvent=n),r=!0}catch(e){Ji.error(Ki+t.id,e),s(!1)}if(r&&e.loaded)try{i()}catch(i){Ji.error("Error while processing buffered events PostHog app with config id "+t.id,i),e.errored=!0}}Ho(){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)}Uo(t){var e=this;if(0!==Object.keys(this.apps).length){var i=this.globalsForEvent(t),r=function(r){try{e.Bo((()=>null==r.processEvent?void 0:r.processEvent(i)))}catch(e){Ji.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.Ho(),void this._instance.on("eventCaptured",(t=>this.Uo(t)))):void Ji.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null==(i=this.$o)||i.call(this),null!=(r=t.siteApps)&&r.length)if(this.isEnabled){var n=function(t){var e;Ct["__$$ph_site_app_"+t]=s._instance,null==(e=Ct.__PosthogExtensions__)||null==e.loadSiteApp||e.loadSiteApp(s._instance,o,(e=>{if(e)return Ji.error(Ki+t,e)}))};for(var{id:a,url:o}of t.siteApps)n(a)}else Ji.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}},Pr={tracingHeaders:class{constructor(t){this.zo=void 0,this.Vo=void 0,this.Wo=void 0,this.ao=()=>{var t,e,i=this.Go();i?(m(this.zo)&&(this.zo=null==(t=Ct.__PosthogExtensions__)||null==(t=t.tracingHeadersPatchFns)?void 0:t._patchXHR(i,(()=>this._instance.get_distinct_id()),this._instance.sessionManager)),m(this.Vo)&&(this.Vo=null==(e=Ct.__PosthogExtensions__)||null==(e=e.tracingHeadersPatchFns)?void 0:e._patchFetch(i,(()=>this._instance.get_distinct_id()),this._instance.sessionManager))):this.co()},this._instance=t}initialize(){this.startIfEnabledOrStop()}Mt(t){var e,i;null!=(e=Ct.__PosthogExtensions__)&&e.tracingHeadersPatchFns?t():null==(i=Ct.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"tracing-headers",(e=>{if(e)return vi.error("failed to load script",e);t()}))}Zo(){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}Go(){var t=this.Zo();return g(t)?(g(this.Wo)?this.Wo.splice(0,this.Wo.length,...t):this.Wo=[...t],t.length>0?this.Wo:void 0):(g(this.Wo)&&this.Wo.splice(0),this.Wo=t||void 0,this.Wo)}co(){var t,e;null==(t=this.zo)||t.call(this),null==(e=this.Vo)||e.call(this),this.zo=void 0,this.Vo=void 0}startIfEnabledOrStop(){this.Go()?this.Mt(this.ao):this.co()}}},Rr=i({surveys:class{get Se(){return this._instance.config}constructor(t){this.Qo=void 0,this._surveyManager=null,this.Jo=!1,this.Yo=[],this.Ko=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 Xi.warn("Flags not loaded yet. Not loading surveys.");var i=g(e);this.Qo=i?e.length>0:e,Xi.info("flags response received, isSurveysEnabled: "+this.Qo),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("seenSurvey_")||null!=r&&r.startsWith("inProgressSurvey_"))&&e.push(r)}e.forEach((t=>localStorage.removeItem(t)))}catch(t){}}loadIfEnabled(){if(!this._surveyManager)if(this.Jo)Xi.info("Already initializing surveys, skipping...");else if(this.Se.disable_surveys)Xi.info(ar);else if(this.Se.cookieless_mode&&this._instance.consent.isOptedOut())Xi.info("Not loading surveys in cookieless mode without consent.");else{var t=null==Ct?void 0:Ct.__PosthogExtensions__;if(t){if(!m(this.Qo)||this.Se.advanced_enable_surveys){var e=this.Qo||this.Se.advanced_enable_surveys;this.Jo=!0;try{var i=t.generateSurveys;if(i)return void this.Xo(i,e);var r=t.loadExternalDependency;if(!r)return void this.ea(ve);r(this._instance,"surveys",(i=>{i||!t.generateSurveys?this.ea("Could not load surveys script",i):this.Xo(t.generateSurveys,e)}))}catch(t){throw this.ea("Error initializing surveys",t),t}finally{this.Jo=!1}}}else Xi.error("PostHog Extensions not found.")}}Xo(t,e){this._surveyManager=t(this._instance,e),this._surveyEventReceiver=new sr(this._instance),Xi.info("Surveys loaded successfully"),this.ta({isLoaded:!0})}ea(t,e){Xi.error(t,e),this.ta({isLoaded:!1,error:t})}onSurveysLoaded(t){return this.Yo.push(t),this._surveyManager&&this.ta({isLoaded:!0}),()=>{this.Yo=this.Yo.filter((e=>e!==t))}}getSurveys(t,e){if(void 0===e&&(e=!1),this.Se.disable_surveys)return Xi.info(ar),t([]);var i,r=this._instance.get_property(re);if(r&&!e)return t(r,{isLoaded:!0});"undefined"!=typeof Promise&&this.Ko?this.Ko.then((e=>{var{surveys:i,context:r}=e;return t(i,r)})):("undefined"!=typeof Promise&&(this.Ko=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.Ko=null;var s=e.statusCode;if(200!==s||!e.json){var n="Surveys API could not be loaded, status: "+s;Xi.error(n);var a={isLoaded:!1,error:n};return t([],a),void(null==i||i({surveys:[],context:a}))}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({[re]:l,$surveys_loaded_at:Date.now()});var h={isLoaded:!0};t(l,h),null==i||i({surveys:l,context:h})}}))}ta(t){for(var e of this.Yo)try{if(!t.isLoaded)return e([],t);this.getSurveys(e)}catch(t){Xi.error("Error in survey callback",t)}}getActiveMatchingSurveys(t,e){if(void 0===e&&(e=!1),!x(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(t,e);Xi.warn("init was not called")}ra(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}ia(t){if(x(this._surveyManager))return{eligible:!1,reason:nr};var e="string"==typeof t?this.ra(t):t;return e?this._surveyManager.checkSurveyEligibility(e):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(t){if(x(this._surveyManager))return Xi.warn("init was not called"),{visible:!1,disabledReason:nr};var e=this.ia(t);return{visible:e.eligible,disabledReason:e.reason}}canRenderSurveyAsync(t,e){return x(this._surveyManager)?(Xi.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:nr})):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.ia(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))Xi.warn("init was not called");else{var s="string"==typeof t?this.ra(t):t;if(null!=s&&s.id)if(Zi.includes(s.type)){var n=null==St?void 0:St.querySelector(e);if(n)return null!=(r=s.appearance)&&r.surveyPopupDelaySeconds?(Xi.info("Rendering survey "+s.id+" with delay of "+s.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var t,e;Xi.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),Xi.info("Survey "+s.id+" rendered")}),1e3*s.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(s,n,i);Xi.warn("Survey element not found")}else Xi.warn("Surveys of type "+s.type+" cannot be rendered in the app");else Xi.warn("Survey not found")}}displaySurvey(t,e){var r;if(x(this._surveyManager))Xi.warn("init was not called");else{var s=this.ra(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&&Xi.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 Xi.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 Xi.warn("Survey not found")}}cancelPendingSurvey(t){x(this._surveyManager)?Xi.warn("init was not called"):this._surveyManager.cancelSurvey(t)}handlePageUnload(){var t;null==(t=this._surveyManager)||t.handlePageUnload()}}},xr),Ir={toolbar:class{constructor(t){this.instance=t}na(t){Ct.ph_toolbar_state=t}sa(){var t;return null!==(t=Ct.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),jt(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=or||ei(t.hash,"__posthog")||ei(t.hash,"state"),n=s?Ot((()=>JSON.parse(atob(decodeURIComponent(s)))))||Ot((()=>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(lr)||"{}")).source="localstorage",delete r.userIntent),!(!r.token||this.instance.config.token!==r.token||(this.loadToolbar(r),0))}catch(t){return!1}}oa(t){var e=Ct.ph_load_toolbar||Ct.ph_load_editor;!x(e)&&_(e)?e(t,this.instance):ur.warn("No toolbar load function found")}loadToolbar(t){var e=!(null==St||!St.getElementById(he));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(lr,JSON.stringify(i({},s,{source:void 0}))),2===this.sa())this.oa(s);else if(0===this.sa()){var n;this.na(1),null==(n=Ct.__PosthogExtensions__)||null==n.loadExternalDependency||n.loadExternalDependency(this.instance,"toolbar",(t=>{if(t)return ur.error("[Toolbar] Failed to load",t),void this.na(0);this.na(2),this.oa(s)})),Mt(xt,"turbolinks:load",(()=>{this.na(0),this.loadToolbar(s)}))}return!0}aa(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)}}},$r=i({experiments:br},xr),Ar={conversations:class{constructor(t){this.la=void 0,this._conversationsManager=null,this.ua=!1,this.ha=null,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!this._instance.config.disable_conversations){var e=t.conversations;x(e)||(k(e)?this.la=e:(this.la=e.enabled,this.ha=e),this.loadIfEnabled())}}reset(){var t;null==(t=this._conversationsManager)||t.reset(),this._conversationsManager=null,this.la=void 0,this.ha=null}loadIfEnabled(){if(!(this._conversationsManager||this.ua||this._instance.config.disable_conversations||jt(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var t=null==Ct?void 0:Ct.__PosthogExtensions__;if(t&&!m(this.la)&&this.la)if(this.ha&&this.ha.token){this.ua=!0;try{var e=t.initConversations;if(e)return this.da(e),void(this.ua=!1);var i=t.loadExternalDependency;if(!i)return void this.ca(ve);i(this._instance,"conversations",(e=>{e||!t.initConversations?this.ca("Could not load conversations script",e):this.da(t.initConversations),this.ua=!1}))}catch(t){this.ca("Error initializing conversations",t),this.ua=!1}}else mr.error("Conversations enabled but missing token in remote config.")}}da(t){if(this.ha)try{this._conversationsManager=t(this.ha,this._instance),mr.info("Conversations loaded successfully")}catch(t){this.ca("Error completing conversations initialization",t)}else mr.error("Cannot complete initialization: remote config is null")}ca(t,e){mr.error(t,e),this._conversationsManager=null,this.ua=!1}show(){this._conversationsManager?this._conversationsManager.show():mr.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this.la&&!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):(mr.warn(yr),null)}))()}getMessages(t,i){var r=this;return e((function*(){return r._conversationsManager?r._conversationsManager.getMessages(t,i):(mr.warn(yr),null)}))()}markAsRead(t){var i=this;return e((function*(){return i._conversationsManager?i._conversationsManager.markAsRead(t):(mr.warn(yr),null)}))()}getTickets(t){var i=this;return e((function*(){return i._conversationsManager?i._conversationsManager.getTickets(t):(mr.warn(yr),null)}))()}requestRestoreLink(t){var i=this;return e((function*(){return i._conversationsManager?i._conversationsManager.requestRestoreLink(t):(mr.warn(yr),null)}))()}restoreFromToken(t){var i=this;return e((function*(){return i._conversationsManager?i._conversationsManager.restoreFromToken(t):(mr.warn(yr),null)}))()}restoreFromUrlToken(){var t=this;return e((function*(){return t._conversationsManager?t._conversationsManager.restoreFromUrlToken():(mr.warn(yr),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()}}},Tr={logs:class{constructor(t){var e;this.va=!1,this.fa=!1,this.Ae=It("[logs]"),this._r=[],this.pa=[],this.ga=()=>{var t,e;null==(t=this.ma)||t.onReconnect(),null==(e=this.ya)||e.onReconnect()},this._instance=t,this._instance&&null!=(e=this._instance.config.logs)&&e.captureConsoleLogs&&(this.va=!0),xt&&Mt(xt,"online",this.ga)}ba(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._a(t,e),n,this.Ae,(()=>this.wa()),(t=>t()),void 0,r),n]}xa(){var t,e,i=null==(t=this._instance)||null==(t=t.config)?void 0:t.logs;return this.ma&&this.ka===i||(null==(e=this.ma)||e.reset(),this.ka=i,[this.ma,this.Sa]=this.ba((()=>this._r),(t=>{this._r=t}))),this.ma}Ca(){var t,e,i=null==(t=this._instance)||null==(t=t.config)?void 0:t.logs;return this.ya&&this.Ia===i||(null==(e=this.ya)||e.reset(),this.Ia=i,[this.ya,this.Ta]=this.ba((()=>this.pa),(t=>{this.pa=t}),{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},wr)),this.ya}initialize(){this.loadIfEnabled()}onRemoteConfig(t){var e,i=null==(e=t.logs)?void 0:e.captureConsoleLogs;!x(i)&&i&&(this.va=!0,this.loadIfEnabled())}reset(){var t,e;this._r=[],null==(t=this.ma)||t.reset(),this.pa=[],null==(e=this.ya)||e.reset()}captureLog(t){this.xa().captureLog(t)}le(t){this.Ca().captureLog(t)}get logger(){return this.Ea||(this.Ea={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.Ea}flushLogs(t){t?this.Ma(t):(this.ma&&this.ma.flush().catch((t=>this.Ae.error("PostHog logs flush failed:",t))),this.ya&&this.ya.flush().catch((t=>this.Ae.error("PostHog logs flush failed:",t))))}loadIfEnabled(){if(this.va&&!this.fa){var t=null==Ct?void 0:Ct.__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.fa=!0)})):this.Ae.error(ve)}else this.Ae.error("PostHog Extensions not found.")}}_a(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.Pa(),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)})}}})}))}Ma(t){this._r.length>0&&this.Ra(t,this._r,this.Sa,s,(t=>{this._r=t})),this.pa.length>0&&this.Ra(t,this.pa,this.Ta,wr,(t=>{this.pa=t}))}Ra(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.Pa(),data:l,compression:"best-available",batchKey:"logs",transport:t})}}Pa(){return this._instance.requestRouter.endpointFor("api","/i/v1/logs")+"?token="+encodeURIComponent(this._instance.config.token)}wa(){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!=Ct&&null!=(t=Ct.location)&&t.href&&(e.currentUrl=this._instance.config.disable_capture_url_hashes?A(Ct.location.href):Ct.location.href),this._instance.featureFlags){var a=this._instance.featureFlags.getFlags();a&&a.length>0&&(e.activeFeatureFlags=a)}return e}}},Or=i({},xr,Er,kr,Sr,Fr,Cr,Rr,Pr,Ir,$r,Ar,Tr),Mr=xr,jr=Er,Lr=kr,Dr=Sr,Nr=Fr,zr=Cr,Ur=Rr,Hr=Pr,Vr=Ir,Br=$r,Wr=Ar,qr=Tr;export{Or as AllExtensions,Lr as AnalyticsExtensions,Wr as ConversationsExtensions,Dr as ErrorTrackingExtensions,Br as ExperimentsExtensions,Mr as FeatureFlagsExtensions,qr as LogsExtensions,Nr as ProductToursExtensions,jr as SessionReplayExtensions,zr as SiteAppsExtensions,Ur as SurveysExtensions,Vr as ToolbarExtensions,Hr 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.3",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 F(t){return null===t||"object"!=typeof t}function C(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 I{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 T(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.je=s,this.Be=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.je((()=>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.Be()}))()}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=T((()=>{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=>T(e,t)))]):yield e}))()}flushWithTimeout(t){var i=this;return e((function*(){var e=!1,r=i.flush(),s=new Promise((i=>T((()=>{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 W(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 q{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:W(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,X=/\((\S*)(?::(\d+))(?::(\d+))\)/,Z=(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=X.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 C(t,"DOMException")}isDOMError(t){return C(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 C(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 F(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 C(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 F(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=function(t){var e=new WeakSet;try{return JSON.stringify(t,((t,i)=>{if("bigint"==typeof i)return i.toString();if("function"!=typeof i&&"symbol"!=typeof i){if(i instanceof Date)return i.toISOString();if(i instanceof Error)return{name:i.name,message:i.message,stack:i.stack};if(i&&"object"==typeof i){if(e.has(i))return"[Circular]";e.add(i)}return i}}))}catch(t){return}}(t);if(e)try{var i=JSON.parse(e);if(!b(i))return;var r=i,s=r[pt],n=r[gt];if(!y(s)||0===s.trim().length)return;if(!y(n)&&!E(n))return;return{step:r,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,Ft=null==Et?void 0:Et.location;null!=Et&&Et.XMLHttpRequest&&new Et.XMLHttpRequest;var Ct=null!=xt?xt:{},Pt=function(t,e){var{debugEnabled:i}=void 0===e?{}:e,r={k(e){if(xt&&(Ct.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)=>Pt(t+" "+e,i)};return r},Rt=Pt("[PostHog.js]"),It=Rt.createLogger;function $t(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 At=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 Tt(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 Ot=function(t){try{return t()}catch(t){return}};function Mt(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 jt(t){return"ph_toolbar_internal"===t.name}function Lt(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 Rt.error("Error in get_current_url, falling back to window.location.href",t),e}}var Dt="$autocapture_disabled_server_side",Nt="$heatmaps_enabled_server_side",zt="$exception_capture_enabled_server_side",Ut="$error_tracking_suppression_rules",Ht="$error_tracking_capture_extension_exceptions",Vt="$web_vitals_enabled_server_side",Bt="$product_tours_enabled_server_side",Wt="$web_vitals_allowed_metrics",qt="$session_recording_remote_config",Jt="$enabled_feature_flags",Kt="$active_feature_flags",Gt="$early_access_features",Yt="$feature_flag_details",Qt="$feature_flag_payloads",Xt="$feature_flag_request_id",Zt="$override_feature_flags",te="$override_feature_flag_payloads",ee="$stored_person_properties",ie="$stored_group_properties",re="$surveys",se="$surveys_activated",ne="ph_product_tours",ae="$flag_call_reported",oe="$flag_call_reported_session_id",le="$feature_flag_errors",ue="$feature_flag_evaluated_at",he="__POSTHOG_TOOLBAR__",ve="PostHog loadExternalDependency extension not found.",de="visibilitychange",ce="beforeunload",fe=1,pe=3,ge=11;function _e(t){return t instanceof Element&&(t.id===he||!(null==t.closest||!t.closest(".toolbar-global-fade-container")))}function be(t){return!!t&&t.nodeType===fe}function me(t,e){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===e.toLowerCase()}function ye(t){return!!t&&t.nodeType===pe}function we(t){return!!t&&t.nodeType===ge&&be(t.host)}function xe(t){return t?d(t).split(/\s+/):[]}function Ee(t,e){var i=function(t){var e,i=null==xt||null==(e=xt.location)?void 0:e.href;return m(i)?void 0:Lt(t,i)}(e);return!!(i&&t&&t.some((t=>i.match(t))))}function ke(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 xe(e)}function Se(t){return x(t)?null:d(t).split(/(\s+)/).filter((t=>Je(t))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Fe(t){var e="";return Ne(t)&&!ze(t)&&t.childNodes&&t.childNodes.length&&$t(t.childNodes,(function(t){var i;ye(t)&&t.textContent&&(e+=null!==(i=Se(t.textContent))&&void 0!==i?i:"")})),d(e)}function Ce(t){return m(t.target)?t.srcElement||null:null!=(e=t.target)&&e.shadowRoot?t.composedPath()[0]||null:t.target||null;var e}var Pe=["a","button","form","input","select","textarea","label"];function Re(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||!be(e))&&e}var $e=[".ph-no-autocapture","[data-ph-no-autocapture]"],Ae=["next","previous","prev",">","<"],Te=(t,e)=>/[a-z0-9]/i.test(e)?t.includes(e):t===e,Oe=[".ph-no-rageclick",".ph-no-capture"],Me=["","text","search","email","password","url","tel","number"];function je(t,e){if(!xt||Le(t))return!1;var i,r,s,n,a;if(k(e)?(i=!!e&&Oe,r=void 0,s=!1):(i=null!==(n=null==e?void 0:e.css_selector_ignorelist)&&void 0!==n?n:Oe,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||!be(t))&&(!!me(t,"textarea")||(me(t,"input")?v(Me,(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}=De(t,!1);return!function(t,e){if(!1===t||m(t))return!1;var i;if(!0===t)i=Ae;else{if(!g(t))return!1;if(t.length>10)return Rt.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=>Te(e,t)||Te(r,t)))}))}(r,o.map((t=>{var e;return{safeText:Fe(t).toLowerCase(),ariaLabel:(null==(e=t.getAttribute("aria-label"))?void 0:e.toLowerCase().trim())||""}})))&&!Re(o,i)}var Le=t=>!t||me(t,"html")||!be(t),De=(t,e)=>{if(!xt||Le(t))return{parentIsUsefulElement:!1,targetElementList:[]};for(var i=!1,r=[t],s=t;s.parentNode&&!me(s,"body");)if(we(s.parentNode))r.push(s.parentNode.host),s=s.parentNode.host;else{var n=Ie(s);if(!n)break;if(e||Pe.indexOf(n.tagName.toLowerCase())>-1)i=!0;else{var a=xt.getComputedStyle(n);a&&"pointer"===a.getPropertyValue("cursor")&&(i=!0)}r.push(n),s=n}return{parentIsUsefulElement:i,targetElementList:r}};function Ne(t){for(var e=t;e.parentNode&&!me(e,"body");e=e.parentNode){var i=ke(e);if(v(i,"ph-sensitive")||v(i,"ph-no-capture"))return!1}if(v(ke(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 ze(t){return!!(me(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||me(t,"select")||me(t,"textarea")||"true"===t.getAttribute("contenteditable"))}var Ue="(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})",He=new RegExp("^(?:"+Ue+")$"),Ve=new RegExp(Ue),Be="\\d{3}-?\\d{2}-?\\d{4}",We=new RegExp("^("+Be+")$"),qe=new RegExp("("+Be+")");function Je(t,e){if(void 0===e&&(e=!0),x(t))return!1;if(y(t)){if(t=d(t),(e?He:Ve).test((t||"").replace(/[- ]/g,"")))return!1;if((e?We:qe).test(t))return!1}return!0}function Ke(t){var e=Fe(t);return Je(e=(e+" "+Ge(t)).trim())?e:""}function Ge(t){var e="";return t&&t.childNodes&&t.childNodes.length&&$t(t.childNodes,(function(t){var i;if(t&&"span"===(null==(i=t.tagName)?void 0:i.toLowerCase()))try{var r=Fe(t);e=(e+" "+r).trim(),t.childNodes&&t.childNodes.length&&(e=(e+" "+Ge(t)).trim())}catch(t){Rt.error("[AutoCapture]",t)}})),e}function Ye(t){return t.replace(/"|\\"/g,'\\"')}function Qe(t){var e=t.attr__class;return e?g(e)?e:xe(e):void 0}class Xe{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 Ze=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){Rt.error("Skipping decoding for malformed query param: "+a)}return a.replace(/\+/g," ")},ti=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},ei=function(t,e){var i=t.match(new RegExp(e+"=([^&]*)"));return i?i[1]:null},ii="$copy_autocapture",ri=It("[AutoCapture]");function si(t,e){return e.length>t?e.slice(0,t)+"...":e}function ni(t){if(t.previousElementSibling)return t.previousElementSibling;var e=t;do{e=e.previousSibling}while(e&&!be(e));return e}function ai(t,e){var r,s,{e:n,maskAllElementAttributes:a,maskAllText:o,elementAttributeIgnoreList:l,elementsChainAsString:u,disableCaptureUrlHashes:h}=e;if(!be(t))return{props:{}};for(var d=[t],c=t;c.parentNode&&!me(c,"body");)if(we(c.parentNode))d.push(c.parentNode.host),c=c.parentNode.host;else{if(!be(c.parentNode))break;d.push(c.parentNode),c=c.parentNode}var f,p,g=[],_={},b=!1,w=!1;if($t(d,(t=>{var e=Ne(t);if(me(t,"a")){var i=t.getAttribute("href");b=!!(e&&i&&Je(i))&&(h?A(i):i)}v(ke(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};Pe.indexOf(n)>-1&&!i&&(a.$el_text="a"===n.toLowerCase()||"button"===n.toLowerCase()?si(1024,Ke(t)):si(1024,Fe(t)));var o=ke(t);o.length>0&&(a.classes=o.filter((function(t){return""!==t}))),$t(t.attributes,(function(i){var n;if((!ze(t)||-1!==["name","id","class","aria-label"].indexOf(i.name))&&(null==r||!r.includes(i.name))&&!e&&Je(i.value)&&(!y(n=i.name)||"_ngcontent"!==n.substring(0,10)&&"_nghost"!==n.substring(0,7))){var o=i.value;"class"===i.name&&(o=xe(o).join(" ")),a["attr__"+i.name]=si(1024,"href"===i.name&&s?A(o):o)}}));for(var l=1,u=1,h=t;h=ni(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(!Ne(t))return{};var e={};return $t(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&&Je(r)&&(e[i]=r)}})),e}(t);At(_,r)})),w)return{props:{},explicitNoCapture:w};if(o||(g[0].$el_text=me(t,"a")||me(t,"button")?Ke(t):Fe(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:At({$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 Tt(a).sort(((t,e)=>{var[i]=t,[r]=e;return i.localeCompare(r)})).forEach((t=>{var[e,i]=t;return o[Ye(e.toString())]=Ye(i.toString())})),(s+=":")+Tt(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:Qe(t),attr_id:t.attr__id,nth_child:t.nth_child,nth_of_type:t.nth_of_type,attributes:{}};return Tt(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 oi=It("[Dead Clicks]"),li=()=>!0;class ui{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=Ct.__PosthogExtensions__)&&e.initDeadClicksAutocapture?t():null==(i=Ct.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this.instance,"dead-clicks-autocapture",(e=>{e?oi.error("failed to load script",e):t()}))}Pt(){var t;if(St){if(!this.Et&&null!=(t=Ct.__PosthogExtensions__)&&t.initDeadClicksAutocapture){var e=b(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};e.__onCapture=this.onCapture,this.Et=Ct.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,e),this.Et.start(St),oi.info("starting...")}}else oi.error("`document` not found. Cannot start.")}stop(){this.Et&&(this.Et.stop(),this.Et=void 0,oi.info("stopping..."))}}var hi=It("[ExceptionAutocapture]"),vi=It("[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 di{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 di(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 di(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 ci{constructor(){this.S=0,this.C=0,this.I=new gi}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 di.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 fi,pi=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&&(pi=t=>crypto.getRandomValues(t));class gi{constructor(){this.R=new Uint32Array(8),this.O=1/0}nextUint32(){return this.R.length>this.O||(pi(this.R),this.O=0),this.R[this.O++]}}var _i=()=>(fi||(fi=new ci)).generate(),bi="",mi=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;function yi(t,e){if(e){var i=function(t,e){if(void 0===e&&(e=St),bi)return bi;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_"+_i().toString();!bi&&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",bi=n)}return bi}(t);if(!i){var r=(t=>{var e=t.match(mi);return e?e[0]:""})(t);r!==i&&Rt.info("Warning: cookie subdomain discovery mismatch",r,i),i=r}return i?"; domain=."+i:""}return""}var wi={N:()=>!!St,D(t){Rt.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(wi.A(t))||{}}catch(t){}return e},q(t,e,i,r,s){if(!St)return!1;try{var n="",a="",o=yi(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&&Rt.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{wi.q(t,"",-1,e)}catch(t){return}}},xi=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],Ei=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...xi],ki="<masked>",Si=["li_fat_id"];function Fi(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(t){return}}var Ci=It("[Web Vitals]"),Pi=9e5,Ri=It("[RemoteConfig]");class Ii{constructor(t){this._instance=t}get remoteConfig(){var t;return null==(t=Ct._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.config}cr(t){var e,i;null!=(e=Ct.__PosthogExtensions__)&&e.loadExternalDependency?null==(i=Ct.__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 Ri.info("Using preloaded remote config",this.remoteConfig),this.pr(this.remoteConfig),void this.gr();if(this._instance.mr())return void Ri.warn("Remote config is disabled. Falling back to local config.");this.cr((t=>{if(!t)return Ri.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){Ri.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||Ri.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",Ai="lazy_loading",Ti="awaiting_config",Oi="missing_config",Mi="base64",ji=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}},Li={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=>ji(e,t))))),not_regex:(t,e)=>e.every((e=>t.every((t=>!ji(e,t))))),icontains:(t,e)=>e.map(Di).some((e=>t.map(Di).some((t=>e.includes(t))))),not_icontains:(t,e)=>e.map(Di).every((e=>t.map(Di).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)))}))},Di=t=>t.toLowerCase();function Ni(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=Li[r.operator];return!!a&&a(r.values,n)}))}It("[SessionRecording]"),It("[SessionRecording]");var zi="[SessionRecording]",Ui=It(zi),Hi=It("[Heatmaps]");function Vi(t){return b(t)&&"clientX"in t&&"clientY"in t&&E(t.clientX)&&E(t.clientY)}var Bi=It("[Product Tours]"),Wi=t=>{var e;return!t.config.disable_product_tours&&!(null==(e=t.persistence)||!e.get_property(Bt))},qi=["$set_once","$set"],Ji=It("[SiteApps]"),Ki="Error while initializing PostHog app with config id ",Gi="events",Yi="cancelEvents",Qi="survey shown",Xi=It("[Surveys]"),Zi=["popover","widget","api"];class tr{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 er(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 ir{constructor(t){this.sn=new tr,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(!er(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=>er(t.href,e.href,e.href_matching||"exact")));var s,n=(null==t||null==(i=t.properties)?void 0:i.$elements_chain)||"";return!!n&&er((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=>er(t.text,e.text,e.text_matching||"exact")||er(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=>er(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||Ni(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 rr{constructor(t){this._n=[],this._instance=t,this.wn=new Map,this.xn=new Map,this.kn=new Map}Sn(t,e){return!!t&&Ni(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===Gi?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 ir(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,Gi),this.xn=this.Cn(t,Yi))}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,Yi);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,Gi);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.jn(t)))}reset(){this._n=[],this.Dn().length>0&&this.Nn([])}getEventToItemsMap(){return this.wn}Bn(){return this.Pn}}class sr extends rr{constructor(t){super(t)}qn(){return se}Hn(){return Qi}Tn(t){var e;null==(e=this._instance)||e.getSurveys(t)}An(t){var e;null==(e=this._instance)||e.cancelPendingSurvey(t)}Rn(){return Xi}Nn(t){var e;null==(e=this._instance)||null==(e=e.persistence)||e.register({[se]:t})}jn(){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===Qi?"consume":"ignore":t===Qi?"persist":"survey dismissed"===t||"survey sent"===t?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}}var nr="SDK is not enabled or survey functionality is not yet loaded",ar="Disabled. Not loading surveys.",or=null!=xt&&xt.location?ei(xt.location.hash,"__posthog")||ei(location.hash,"state"):null,lr="_postHogToolbarParams",ur=It("[Toolbar]"),hr=It("[FeatureFlags]"),vr=It("[FeatureFlags]",{debugEnabled:!0}),dr="\" failed. Feature flags didn't load in time.",cr=t=>{for(var e={},i=0;t.length>i;i++)e[t[i]]=!0;return e},fr=t=>{var e={};for(var[i,r]of Tt(t||{}))r&&(e[i]=r);return e},pr=It("[Error tracking]"),gr="Refusing to render web experiment since the viewer is a likely bot",_r={icontains:(t,e)=>e.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,e)=>-1===e.toLowerCase().indexOf(t.toLowerCase()),regex:(t,e)=>ji(e,t),not_regex:(t,e)=>!ji(e,t),exact:(t,e)=>e===t,is_not:(t,e)=>e!==t};class br{get Se(){return this._instance.config}constructor(t){var e=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(t){void 0===t&&(t=!1),e.getWebExperiments((t=>{br.Un("retrieved web experiments from the server"),e.zn=new Map,t.forEach((t=>{if(t.feature_flag_key){var i;e.zn&&(br.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];br.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())br.Un(gr);else if(!this.Se.disable_web_experiments){if(x(this.zn))return this.zn=new Map,this.loadIfEnabled(),void this.previewWebExperiment();br.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=br.getWindowLocation();if(null!=t&&t.search){var e=Ze(null==t?void 0:t.search,"__experiment_id"),i=Ze(null==t?void 0:t.search,"__experiment_variant");e&&i&&(br.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&&(br.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)&&br.Zn(t,e)&&br.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=br.getWindowLocation();if(r){var s,n,a,o=Lt(e,r.href);return null==(s=t.conditions)||!s.url||_r[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=ti(St.URL,[],ki),s=Ei.concat([]),n={},$t(s,(function(t){var e=Ze(r,t);n[t]=e||null})),n),o=function(){var t={};return $t(Si,(function(e){var i=wi.A(e);t[e]=i||null})),t}();return At(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];Rt.info("[WebExperiments] "+t,i)}Vn(t,e,i){this._is_bot()?br.Un(gr):"control"!==e?i.forEach((i=>{if(i.selector){var r;br.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)}))}})):br.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 mr=It("[Conversations]"),yr="Conversations not available yet.",wr="console",xr={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._instance=t,this.featureFlagEventHandlers=[]}get Se(){return this._instance.config}get zr(){return this._instance.persistence}ss(t){return this._instance.get_property(t)}os(){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}ls(){return!!this.os()&&(this.ns||this.Kn||(this.ns=!0,hr.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}us(){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||(hr.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||hr.error("Invalid evaluation context found:",t,"Expected non-empty string"),e})):[]}hs(){return this.us().length>0}ds(){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||hr.error("Invalid flag key found:",t,"Expected non-empty string"),e}));hr.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.ss(Jt))&&void 0!==s?s:{},u=null!=r&&r.merge&&null!==(n=this.ss(Qt))&&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.ss(Yt),e=this.ss(Zt),r=this.ss(te);if(!r&&!e)return t||{};var s=At({},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||(hr.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.ss(Jt),e=this.ss(Zt);if(!e)return t||{};for(var i=At({},t),r=Object.keys(e),s=0;r.length>s;s++)i[r[s]]=e[r[s]];return this.Jn||(hr.warn(" Overriding feature flags!",{enabledFlags:t,overriddenFlags:e,finalFlags:i}),this.Jn=!0),i}getFlagPayloads(){var t=this.ss(Qt),e=this.ss(te);if(!e)return t||{};for(var i=At({},t||{}),r=Object.keys(e),s=0;r.length>s;s++)i[r[s]]=e[r[s]];return this.Jn||(hr.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.cs||(this._instance.Ti.emit("featureFlagsReloading",!0),this.cs=setTimeout((()=>{this.vs()}),5))}fs(){clearTimeout(this.cs),this.cs=void 0}ensureFlagsLoaded(){this.Yn||this.Kn||this.cs||this.reloadFeatureFlags()}setAnonymousDistinctId(t){this.$anon_distinct_id=t}setReloadingPaused(t){this.Xn=t}vs(t){var e;if(this.fs(),!this._instance.mr())if(this.Kn)this.es=!0;else{var r=this.Se.token,s=this.ss("$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.ss(ee)||{}),group_properties:this.ss(ie),timezone:Fi()};w(s)||m(s)||(n.$device_id=s),(null!=t&&t.disableFlags||this.Se.advanced_disable_feature_flags)&&(n.disable_flags=!0),this.hs()&&(n.evaluation_contexts=this.us());var a=this.ds();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:Mi,timeout:this.Se.feature_flag_request_timeout_ms,callback:t=>{var e,i,r,s=!0;if(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({[le]:a}),u)hr.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.vs())}}})}}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.ls()){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 hr.warn('getFeatureFlag for key "'+t+dr)}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.ls()){var i=this.getFlagVariants(),r=t in i,s=i[t],a=this.getFlagPayloads()[t],o=String(s),l=this.ss(Xt)||void 0,u=this.ss(ue)||void 0,h=this.ss(ae)||{};if(this.Se.advanced_feature_flags_dedup_per_session){var v,d=this._instance.get_session_id(),c=this.ss(oe);d&&d!==c&&(h={},null==(v=this.zr)||v.register({[ae]:h,[oe]: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({[ae]:h});var F=this.getFeatureFlagDetails(t),C=[...null!==(p=this.ss(le))&&void 0!==p?p:[]];m(s)&&C.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==F||null==(y=F.metadata)?void 0:y.version)||(P.$feature_flag_version=F.metadata.version);var R,I=null!==(w=null==F||null==(x=F.reason)?void 0:x.description)&&void 0!==w?w:null==F||null==(E=F.reason)?void 0:E.code;I&&(P.$feature_flag_reason=I),null!=F&&null!=(k=F.metadata)&&k.id&&(P.$feature_flag_id=F.metadata.id),m(null==F?void 0:F.original_variant)&&m(null==F?void 0:F.original_enabled)||(P.$feature_flag_original_response=m(F.original_variant)?F.original_enabled:F.original_variant),null!=F&&null!=(S=F.metadata)&&S.original_payload&&(P.$feature_flag_original_payload=null==F||null==(R=F.metadata)?void 0:R.original_payload),C.length&&(P.$feature_flag_error=C.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 hr.warn('getFeatureFlagResult for key "'+t+dr)}getRemoteConfigPayload(t,e){var i=this.Se.token,r={distinct_id:this._instance.get_distinct_id(),token:i};this.hs()&&(r.evaluation_contexts=this.us());var s=this.ds();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:Mi,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}hr.warn('isFeatureEnabled for key "'+t+dr)}}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&&hr.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)){hr.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({[Kt]:u,[Jt]: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({[Kt]:Object.keys(fr(p)),[Jt]:p||{},[Qt]:_||{},[Yt]:b||{}},v?{[Xt]:v}:{},d?{[ue]:d}:{}))}}}(t,this.zr,s,n,a,r),e||(this.ns=!1),this.ps(e)}}override(t,e){void 0===e&&(e=!1),hr.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:t,suppressWarning:e})}overrideFeatureFlags(t){if(!this._instance.__loaded||!this.zr)return hr.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(!1===t)return this.zr.unregister(Zt),this.zr.unregister(te),this.ps(),vr.info("All overrides cleared");if(g(t)){var e=cr(t);return this.zr.register({[Zt]:e}),this.ps(),vr.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(Zt),vr.info("Flag overrides cleared");else if(r.flags){if(g(r.flags)){var s=cr(r.flags);this.zr.register({[Zt]:s})}else this.zr.register({[Zt]:r.flags});vr.info("Flag overrides set",{flags:r.flags})}return"payloads"in r&&(!1===r.payloads?(this.zr.unregister(te),vr.info("Payload overrides cleared")):r.payloads&&(this.zr.register({[te]:r.payloads}),vr.info("Payload overrides set",{payloads:r.payloads}))),void this.ps()}if(t&&"object"==typeof t)return this.zr.register({[Zt]:t}),this.ps(),vr.info("Flag overrides set",{flags:t});hr.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:t})}onFeatureFlags(t){if(this.addFeatureFlagsHandler(t),this.Yn){var{flags:e,flagVariants:i}=this.gs();t(e,i)}return()=>this.removeFeatureFlagsHandler(t)}updateEarlyAccessFeatureEnrollment(t,e,r){var s,n=(this.ss(Gt)||[]).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({[Kt]:Object.keys(fr(l)),[Jt]:l}),this.ps()}getEarlyAccessFeatures(t,e,i){void 0===e&&(e=!1);var r=this.ss(Gt),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(Gt),null==(r=this.zr)||r.register({[Gt]:s}),t(s)}}})}gs(){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)),{})}}ps(t){var{flags:e,flagVariants:i}=this.gs();this.featureFlagEventHandlers.forEach((r=>r(e,i,{errorsLoading:t})))}setPersonPropertiesForFlags(t,e){void 0===e&&(e=!0);var r=this.ss(ee)||{},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({[ee]:i({},r,a,s)}),e&&this._instance.reloadFeatureFlags()}unsetPersonPropertiesForFlags(t,e){void 0===e&&(e=!0);var r=i({},this.ss(ee)||{});t.forEach((t=>{delete r[t]})),this._instance.register({[ee]:r}),e&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(t){void 0===t&&(t=!0),this._instance.unregister(ee),t&&this._instance.reloadFeatureFlags()}setGroupPropertiesForFlags(t,e){void 0===e&&(e=!0);var r=this.ss(ie)||{};0!==Object.keys(r).length&&Object.keys(r).forEach((e=>{r[e]=i({},r[e],t[e]),delete t[e]})),this._instance.register({[ie]:i({},r,t)}),e&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(t){if(t){var e=this.ss(ie)||{};this._instance.register({[ie]:i({},e,{[t]:{}})})}else this._instance.unregister(ie)}reset(){this.Yn=!1,this.Kn=!1,this.Xn=!1,this.es=!1,this.ts=!1,this.$anon_distinct_id=void 0,this.fs(),this.Jn=!1}}},Er={sessionRecording:class{get Se(){return this._instance.config}get zr(){return this._instance.persistence}get started(){var t;return!(null==(t=this.ys)||!t.isStarted)}get status(){var t,e;return this.bs===Ti||this.bs===Oi?this.bs:null!==(t=null==(e=this.ys)?void 0:e.status)&&void 0!==t?t:this.bs}constructor(t){if(this._forceAllowLocalhostNetworkCapture=!1,this.bs=$i,this._s=void 0,this._instance=t,!this._instance.sessionManager)throw Ui.error("started without valid sessionManager"),new Error(zi+" started without valid sessionManager. This is a bug.");if("always"===this.Se.cookieless_mode)throw new Error(zi+' cannot be used with cookieless_mode="always"')}initialize(){this.startIfEnabledOrStop()}get ws(){var t,e=!(null==(t=this._instance.get_property(qt))||!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.ws||null==(e=this.ys)||!e.isStarted){var i=!m(Object.assign)&&!m(Array.from);this.ws&&i?(this.xs(t),Ui.info("starting")):(this.bs=$i,this.stopRecording())}}xs(t){var e,i,r;this.ws&&(this.bs!==Ti&&this.bs!==Oi&&(this.bs=Ai),null!=Ct&&null!=(e=Ct.__PosthogExtensions__)&&null!=(e=e.rrweb)&&e.record&&null!=(i=Ct.__PosthogExtensions__)&&i.initSessionRecording?this.ks(t):null==(r=Ct.__PosthogExtensions__)||null==r.loadExternalDependency||r.loadExternalDependency(this._instance,this.Ss,(e=>{if(e)return Ui.error("could not load recorder",e);this.ks(t)})))}stopRecording(){var t,e;null==(t=this._s)||t.call(this),this._s=void 0,null==(e=this.ys)||e.stop()}Cs(){var t,e;null==(t=this._s)||t.call(this),this._s=void 0,null==(e=this.ys)||e.discard()}Is(){var t,e;null==(t=this.zr)||t.unregister("$session_is_sampled"),null==(e=this.zr)||e.unregister("$replay_sample_rate")}Ts(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?(Ui.warn(e+" must be between 0 and 1. Ignoring invalid value:",t),null):r}Es(t){if(this.zr){var e,r,s=this.zr,n=()=>{var e,r=!1===t.sessionRecording?void 0:t.sessionRecording,n=this.Ts(null==(e=this.Se.session_recording)?void 0:e.sampleRate,"session_recording.sampleRate"),a=this.Ts(null==r?void 0:r.sampleRate,"remote config sampleRate"),o=null!=n?n:a;x(o)&&this.Is();var l=null==r?void 0:r.minimumDurationMilliseconds;s.register({[qt]: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._s)||e.call(this),this._s=null==(r=this._instance.sessionManager)?void 0:r.onSessionId(n)}}onRemoteConfig(t){return"sessionRecording"in t?!1===t.sessionRecording?(this.Es(t),void this.Cs()):(this.Es(t),void this.startIfEnabledOrStop()):(this.bs===Ti&&(this.bs=Oi,Ui.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.ys)&&i.log?this.ys.log(t,e):Ui.warn("log called before recorder was ready")}get Ss(){var t,e,i=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.get_property(qt);return(null==i||null==(e=i.scriptConfig)?void 0:e.script)||"lazy-recorder"}Ms(){var t,e,i=this._instance.get_property(qt);if(!i)return!1;try{e="object"==typeof i?i:JSON.parse(i)}catch(t){return Ui.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}ks(t){var e,i;if(null==(e=Ct.__PosthogExtensions__)||!e.initSessionRecording)return Ui.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.ys||(this.ys=null==(i=Ct.__PosthogExtensions__)?void 0:i.initSessionRecording(this._instance),this.ys._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.Ms()){if(this.bs===Oi||this.bs===Ti)return;return this.bs=Ti,Ui.info("persisted remote config is stale, requesting fresh config before starting"),void new Ii(this._instance).load()}this.bs=Ai,this.ys.start(t)}onRRwebEmit(t){var e;null==(e=this.ys)||null==e.onRRwebEmit||e.onRRwebEmit(t)}overrideLinkedFlag(){var t,e;this.ys||null==(e=this.zr)||e.register({$replay_override_linked_flag:!0}),null==(t=this.ys)||t.overrideLinkedFlag()}overrideSampling(){var t,e;this.ys||null==(e=this.zr)||e.register({$replay_override_sampling:!0}),null==(t=this.ys)||t.overrideSampling()}overrideTrigger(t){var e,i;this.ys||null==(i=this.zr)||i.register({["url"===t?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),null==(e=this.ys)||e.overrideTrigger(t)}get sdkDebugProperties(){var t;return(null==(t=this.ys)?void 0:t.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(t,e){var i;return!(null==(i=this.ys)||!i.tryAddCustomEvent(t,e))}}},kr={autocapture:class{constructor(t){this.Ps=!1,this.Rs=null,this.Os=!1,this.instance=t,this.rageclicks=new Xe(t.config.rageclick),this.Ls=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}Fs(){if(this.isBrowserSupported()){if(xt&&St){var t=t=>{t=t||(null==xt?void 0:xt.event);try{this.As(t)}catch(t){ri.error("Failed to capture event",t)}};if(Mt(St,"submit",t,{capture:!0}),Mt(St,"change",t,{capture:!0}),Mt(St,"click",t,{capture:!0}),this.Se.capture_copied_text){var e=t=>{t=t||(null==xt?void 0:xt.event);try{this.As(t,ii)}catch(t){ri.error("Failed to capture copy/cut event",t)}};Mt(St,"copy",e,{capture:!0}),Mt(St,"cut",e,{capture:!0})}}}else ri.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this.Ps&&(this.Fs(),this.Ps=!0)}onRemoteConfig(t){t.elementsChainAsString&&(this.Os=t.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[Dt]:!!t.autocapture_opt_out}),this.Rs=!!t.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(t){this.Ls=t}getElementSelectors(t){var e,i=[];return null==(e=this.Ls)||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[Dt];if(w(this.Rs)&&!k(i)&&!this.instance.mr())return!1;var r=null!==(e=this.Rs)&&void 0!==e?e:!!i;return!!this.instance.config.autocapture&&!r}As(t,e){if(void 0===e&&(e="$autocapture"),this.isEnabled){var i,r=Ce(t);ye(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())&&je(r,this.instance.config.rageclick)&&this.As(t,"$rageclick");var s=e===ii;if(r&&function(t,e,i,r,s,n){var a,o,l,u,h,v;if(void 0===i&&(i=void 0),!xt||Le(t))return!1;if(null!=(a=i)&&a.url_allowlist&&!Ee(i.url_allowlist,n))return!1;if(null!=(o=i)&&o.url_ignorelist&&Ee(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}=De(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(!Re(f,null==(u=i)?void 0:u.css_selector_allowlist))return!1;if(Re(f,null!==(h=null==(v=i)?void 0:v.css_selector_ignorelist)&&void 0!==h?h:$e))return!1;var p=xt.getComputedStyle(t);if(p&&"pointer"===p.getPropertyValue("cursor")&&"click"===e.type)return!0;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&&(Pe.indexOf(g)>-1||"true"===t.getAttribute("contenteditable"))}}(r,t,this.Se,s,s?["copy","cut"]:void 0,this.instance)){var{props:n,explicitNoCapture:a}=ai(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.Os,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===ii){var l,u=Se(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.$s=(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&&(Rt.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this.Ds&&this.Ds(),this.Ds=void 0,Rt.info("History API monitoring stopped")}monitorHistoryChanges(){xt&&xt.history&&(this.Ns("pushState"),this.Ns("replaceState"),this.qs())}Ns(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.js(t)}))}}js(t){try{var e,i=null==xt||null==(e=xt.location)?void 0:e.pathname;if(!i)return;i!==this.$s&&this.isEnabled&&this._instance.capture("$pageview",{navigation_type:t}),this.$s=i}catch(e){Rt.error("Error capturing "+t+" pageview",e)}}qs(){if(!this.Ds){var t=()=>{this.js("popstate")};Mt(xt,"popstate",t),this.Ds=()=>{xt&&xt.removeEventListener("popstate",t)}}}},heatmaps:class{get Se(){return this.instance.config}constructor(t){var e;this.Bs=!1,this.Ps=!1,this.Hs=null,this.instance=t,this.Bs=!(null==(e=this.instance.persistence)||!e.props[Nt]),this.rageclicks=new Xe(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.Bs:this.Se.enable_heatmaps:!1!==this.Se.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this.Ps)return;Hi.info("starting..."),this.Us(),this.ke()}else{var t;clearInterval(null!==(t=this.Hs)&&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({[Nt]:e}),this.Bs=e,this.startIfEnabled()}}getAndClearBuffer(){var t=this.R;return this.R=void 0,t}Vs(t){this.fe(t.originalEvent,"deadclick")}ke(){this.Hs&&clearInterval(this.Hs),this.Hs="visible"===(null==St?void 0:St.visibilityState)?setInterval(this.Lr.bind(this),this.flushIntervalMilliseconds):null}Us(){xt&&St&&(this.Ws=this.Lr.bind(this),Mt(xt,ce,this.Ws),this.Gs=t=>this.fe(t||(null==xt?void 0:xt.event)),Mt(St,"click",this.Gs,{capture:!0}),this.Zs=t=>this.Qs(t||(null==xt?void 0:xt.event)),Mt(St,"mousemove",this.Zs,{capture:!0}),this.Js=new ui(this.instance,li,this.Vs.bind(this)),this.Js.startIfEnabledOrStop(),this.Ys=this.ke.bind(this),Mt(St,de,this.Ys),this.Ps=!0)}zs(){var t;xt&&St&&(this.Ws&&xt.removeEventListener(ce,this.Ws),this.Gs&&St.removeEventListener("click",this.Gs,{capture:!0}),this.Zs&&St.removeEventListener("mousemove",this.Zs,{capture:!0}),this.Ys&&St.removeEventListener(de,this.Ys),clearTimeout(this.Ks),null==(t=this.Js)||t.stop(),this.Ps=!1)}Xs(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&&be(r)&&!me(r,"body");){if(r===i)return!1;if(v(e,null==xt?void 0:xt.getComputedStyle(r).position))return!0;r=Ie(r)}return!1}(Ce(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"),!_e(t.target)&&Vi(t)){var s=this.Xs(t,e);null!=(r=this.rageclicks)&&r.isRageClick(t.clientX,t.clientY,(new Date).getTime())&&je(Ce(t),this.instance.config.rageclick)&&this.eo(i({},s,{type:"rageclick"})),this.eo(s)}}Qs(t){!_e(t.target)&&Vi(t)&&(clearTimeout(this.Ks),this.Ks=setTimeout((()=>{this.eo(this.Xs(t,"mousemove"))}),500))}eo(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?[...xi,...i||[]]:[],s=ti(e,r,ki);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:ui,webVitalsAutocapture:class{constructor(t){var e;this.Bs=!1,this.Ps=!1,this.R={url:void 0,metrics:[],firstMetricTimestamp:void 0},this.ro=()=>{clearTimeout(this.io),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.no=t=>{var e;this.R=this.R||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var r=this.so();if(!m(r))if(x(null==t?void 0:t.name)||x(null==t?void 0:t.value))Ci.error("Invalid metric received",t);else if(!this.oo||this.oo>t.value){this.R.url!==r&&(this.ro(),this.io=setTimeout(this.ro,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.ro()}else Ci.error("Ignoring metric with value >= "+this.oo,t)},this.ao=()=>{if(!this.Ps){var t,e,i,r,s=Ct.__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.no.bind(this)),this.allowedMetrics.indexOf("CLS")>-1&&e(this.no.bind(this)),this.allowedMetrics.indexOf("FCP")>-1&&i(this.no.bind(this)),this.allowedMetrics.indexOf("INP")>-1&&r(this.no.bind(this)),this.Ps=!0):Ci.error("web vitals callbacks not loaded - not starting")}},this._instance=t,this.Bs=!(null==(e=this._instance.persistence)||!e.props[Vt]),this.startIfEnabled()}get lo(){return this._instance.config.capture_performance}get allowedMetrics(){var t,e,i=b(this.lo)?null==(t=this.lo)?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.lo)?this.lo.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var t=b(this.lo)?this.lo.web_vitals_attribution:void 0;return null!=t&&t}get oo(){var t=b(this.lo)&&E(this.lo.__web_vitals_max_value)?this.lo.__web_vitals_max_value:Pi;return t>0&&6e4>=t?Pi:t}get isEnabled(){var t=null==Ft?void 0:Ft.protocol;if("http:"!==t&&"https:"!==t)return Ci.info("Web Vitals are disabled on non-http/https protocols"),!1;var e=b(this.lo)?this.lo.web_vitals:k(this.lo)?this.lo:void 0;return k(e)?e:this.Bs}startIfEnabled(){this.isEnabled&&!this.Ps&&(Ci.info("enabled, starting..."),this.Mt(this.ao))}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({[Vt]:e}),this._instance.persistence.register({[Wt]:i})),this.Bs=e,this.startIfEnabled()}}Mt(t){var e,i;null!=(e=Ct.__PosthogExtensions__)&&e.postHogWebVitalsCallbacks?t():null==(i=Ct.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,this.useAttribution?"web-vitals-with-attribution":"web-vitals",(e=>{e?Ci.error("failed to load script",e):t()}))}so(){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?[...xi,...e||[]]:[];return ti(t,i,ki)}Ci.error("Could not determine current URL")}}},Sr={exceptionObserver:class{constructor(t){var e,i,r;this.ao=()=>{var t;if(xt&&this.isEnabled&&null!=(t=Ct.__PosthogExtensions__)&&t.errorWrappingFunctions){var e=Ct.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,i=Ct.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,r=Ct.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.uo&&this.Se.capture_unhandled_errors&&(this.uo=e(this.captureException.bind(this))),!this.ho&&this.Se.capture_unhandled_rejections&&(this.ho=i(this.captureException.bind(this))),!this.do&&this.Se.capture_console_errors&&(this.do=r(this.captureException.bind(this)))}catch(t){hi.error("failed to start",t),this.co()}}},this._instance=t,this.vo=!(null==(e=this._instance.persistence)||!e.props[zt]),this.fo=new I({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:hi}),this.Se=this.po(),this.startIfEnabledOrStop()}po(){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.vo: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?(hi.info("enabled"),this.co(),this.Mt(this.ao)):this.co()}Mt(t){var e,i;null!=(e=Ct.__PosthogExtensions__)&&e.errorWrappingFunctions?t():null==(i=Ct.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"exception-autocapture",(e=>{if(e)return hi.error("failed to load script",e);t()}))}co(){var t,e,i;null==(t=this.uo)||t.call(this),this.uo=void 0,null==(e=this.ho)||e.call(this),this.ho=void 0,null==(i=this.do)||i.call(this),this.do=void 0}onRemoteConfig(t){"autocaptureExceptions"in t&&(this.vo=!!t.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[zt]:this.vo}),this.Se=this.po(),this.startIfEnabledOrStop())}onConfigChange(){this.Se=this.po()}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.fo.consumeRateLimit(s)?hi.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.mo=[],this.yo=new q([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",Z,it)),this._instance=t,this.mo=null!==(e=null==(r=this._instance.persistence)?void 0:r.get_property(Ut))&&void 0!==e?e:[],this.bo=mt(this._o()),this.wo=new yt(this.bo)}onConfigChange(){this.bo=mt(this._o()),this.wo.setConfig(this.bo)}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.mo=s,this._instance.persistence&&this._instance.persistence.register({[Ut]:this.mo,[Ht]:n})}}get xo(){var t,e=!!this._instance.get_property(Ht),i=this._instance.config.error_tracking.captureExtensionExceptions;return null!==(t=null!=i?i:e)&&void 0!==t&&t}buildProperties(t,e){return this.yo.buildFromUnknown(t,{syntheticException:null==e?void 0:e.syntheticException,mechanism:{handled:null==e?void 0:e.handled}})}addExceptionStep(t,e){if(this.bo.enabled)try{if(!y(t)||0===t.trim().length)return void pr.warn("Ignoring exception step because message must be a non-empty string");var r=this.ko(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&&pr.warn("Ignoring reserved exception step fields",{droppedKeys:n}),this.wo.add(i({[pt]:t,[gt]:(new Date).toISOString()},s))}catch(t){pr.error("Failed to add exception step. Ignoring breadcrumb.",t)}}sendExceptionEvent(t){try{var e=t.$exception_list;if(this.So(e)){if(this.Co(e))return this.Io("Exception dropped: matched a suppression rule"),void pr.info("Skipping exception capture because a suppression rule matched");if(!this.xo&&this.To(e))return this.Io("Exception dropped: thrown by a browser extension"),void pr.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.Eo(e))return this.Io("Exception dropped: thrown by the PostHog SDK"),void pr.info("Skipping exception capture because it was thrown by the PostHog SDK")}var i=this.bo.enabled&&x(t.$exception_steps)?this.Mo(t):t;try{var r=this._instance.capture("$exception",i,{_noTruncate:!0,_batchKey:"exceptionEvent",Zi:!0});return r&&this.wo.clear(),r}catch(t){return pr.error("Failed to capture exception event. Dropping this exception.",t),void this.wo.clear()}}catch(t){return void pr.error("Failed to process exception event. Ignoring this exception.",t)}}Mo(t){try{var e=this.wo.getAttachable();return 0===e.length?t:i({},t,{$exception_steps:e})}catch(e){return pr.error("Failed to read buffered exception steps. Capturing exception without steps.",e),t}}Io(t){this.bo.enabled&&this.wo.add({[pt]:t,[gt]:(new Date).toISOString()})}ko(t){return b(t)?i({},t):{}}_o(){var t,e;return null!==(t=null==(e=this._instance.config.error_tracking)?void 0:e.exception_steps)&&void 0!==t?t:{}}Co(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.mo.some((t=>{var i=t.values.map((t=>{var i,r=Li[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)}))}To(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://")))}Eo(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}So(t){return!x(t)&&g(t)}}},Fr=i({productTours:class{get zr(){return this._instance.persistence}constructor(t){this.Po=null,this.Ro=null,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if("productTours"in t){var e,i;if(this.zr&&this.zr.register({[Bt]:!!t.productTours}),!Wi(this._instance))return!this.Po&&x(null==(e=this.zr)?void 0:e.props[ne])||Bi.info("product tours disabled; stopping and clearing cached tours"),null==(i=this.Po)||i.stop(),this.Po=null,void this.clearCache();this.loadIfEnabled()}}loadIfEnabled(){!this.Po&&Wi(this._instance)&&this.Mt((()=>this.Oo()))}Mt(t){var e,i;null!=(e=Ct.__PosthogExtensions__)&&e.generateProductTours?t():null==(i=Ct.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"product-tours",(e=>{e?Bi.error("Could not load product tours script",e):t()}))}Oo(){var t;!this.Po&&null!=(t=Ct.__PosthogExtensions__)&&t.generateProductTours&&(this.Po=Ct.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(t,e){if(void 0===e&&(e=!1),!g(this.Ro)||e){var i=this.zr;if(i){var r=i.props[ne];if(g(r)&&!e)return this.Ro=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(Wi(this._instance)){var r=e.statusCode;if(200!==r||!e.json){var s="Product Tours API could not be loaded, status: "+r;return Bi.error(s),void t([],{isLoaded:!1,error:s})}var n=g(e.json.product_tours)?e.json.product_tours:[];this.Ro=n,i&&i.register({[ne]:n}),t(n,{isLoaded:!0})}else t([],{isLoaded:!0})}})}else t(this.Ro,{isLoaded:!0})}getActiveProductTours(t){x(this.Po)?t([],{isLoaded:!1,error:"Product tours not loaded"}):this.Po.getActiveProductTours(t)}showProductTour(t){var e;null==(e=this.Po)||e.showTourById(t)}previewTour(t){this.Po?this.Po.previewTour(t):this.Mt((()=>{var e;this.Oo(),null==(e=this.Po)||e.previewTour(t)}))}dismissProductTour(){var t;null==(t=this.Po)||t.dismissTour("user_clicked_skip")}nextStep(){var t;null==(t=this.Po)||t.nextStep()}previousStep(){var t;null==(t=this.Po)||t.previousStep()}clearCache(){var t;this.Ro=null,null==(t=this.zr)||t.unregister(ne)}resetTour(t){var e;null==(e=this.Po)||e.resetTour(t)}resetAllTours(){var t;null==(t=this.Po)||t.resetAllTours()}cancelPendingTour(t){var e;null==(e=this.Po)||e.cancelPendingTour(t)}}},xr),Cr={siteApps:class{constructor(t){this.Lo=0,this._instance=t,this.Fo=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}Ao(t,e){if(e){var i=this.globalsForEvent(e);this.Fo.push(i),this.Fo.length>1e3&&(this.Fo=this.Fo.slice(10))}}get siteAppLoaders(){var t;return null==(t=Ct._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.siteApps}initialize(){if(this.isEnabled){var t=this._instance._addCaptureHook(this.Ao.bind(this));this.$o=()=>{t(),this.Fo=[],this.$o=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,qi),{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}}Do(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)||(Ji.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)||(Ji.error("prepare_external_dependency_script returned null"),null):t}No(){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.Lo++,this.qo)return this.jo();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.Do(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.qo=()=>{h.forEach((t=>t())),this.qo=void 0},this.jo()}jo(){var t=!1;return()=>{var e;t||(t=!0,this.Lo--,0===this.Lo&&(null==(e=this.qo)||e.call(this)))}}Bo(t,e){void 0===e&&(e=!0);var i=this.No();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.Fo.length&&(Ji.info("Processing "+this.Fo.length+" events for site app with id "+t.id),this.Fo.forEach((t=>this.Bo((()=>null==e.processEvent?void 0:e.processEvent(t))))),e.processedBuffer=!0),Object.values(this.apps).every((t=>t.processedBuffer||t.errored))&&(null==(i=this.$o)||i.call(this))},r=!1,s=s=>{e.errored=!s,e.loaded=!0,Ji.info("Site app with id "+t.id+" "+(s?"loaded":"errored")),r&&i()};try{var{processEvent:n}=this.Bo((e=>t.init({posthog:this._instance,callback(t){e(),s(t)}})),!1);n&&(e.processEvent=n),r=!0}catch(e){Ji.error(Ki+t.id,e),s(!1)}if(r&&e.loaded)try{i()}catch(i){Ji.error("Error while processing buffered events PostHog app with config id "+t.id,i),e.errored=!0}}Ho(){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)}Uo(t){var e=this;if(0!==Object.keys(this.apps).length){var i=this.globalsForEvent(t),r=function(r){try{e.Bo((()=>null==r.processEvent?void 0:r.processEvent(i)))}catch(e){Ji.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.Ho(),void this._instance.on("eventCaptured",(t=>this.Uo(t)))):void Ji.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null==(i=this.$o)||i.call(this),null!=(r=t.siteApps)&&r.length)if(this.isEnabled){var n=function(t){var e;Ct["__$$ph_site_app_"+t]=s._instance,null==(e=Ct.__PosthogExtensions__)||null==e.loadSiteApp||e.loadSiteApp(s._instance,o,(e=>{if(e)return Ji.error(Ki+t,e)}))};for(var{id:a,url:o}of t.siteApps)n(a)}else Ji.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}},Pr={tracingHeaders:class{constructor(t){this.zo=void 0,this.Vo=void 0,this.Wo=void 0,this.ao=()=>{var t,e,i=this.Go();i?(m(this.zo)&&(this.zo=null==(t=Ct.__PosthogExtensions__)||null==(t=t.tracingHeadersPatchFns)?void 0:t._patchXHR(i,(()=>this._instance.get_distinct_id()),this._instance.sessionManager)),m(this.Vo)&&(this.Vo=null==(e=Ct.__PosthogExtensions__)||null==(e=e.tracingHeadersPatchFns)?void 0:e._patchFetch(i,(()=>this._instance.get_distinct_id()),this._instance.sessionManager))):this.co()},this._instance=t}initialize(){this.startIfEnabledOrStop()}Mt(t){var e,i;null!=(e=Ct.__PosthogExtensions__)&&e.tracingHeadersPatchFns?t():null==(i=Ct.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"tracing-headers",(e=>{if(e)return vi.error("failed to load script",e);t()}))}Zo(){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}Go(){var t=this.Zo();return g(t)?(g(this.Wo)?this.Wo.splice(0,this.Wo.length,...t):this.Wo=[...t],t.length>0?this.Wo:void 0):(g(this.Wo)&&this.Wo.splice(0),this.Wo=t||void 0,this.Wo)}co(){var t,e;null==(t=this.zo)||t.call(this),null==(e=this.Vo)||e.call(this),this.zo=void 0,this.Vo=void 0}startIfEnabledOrStop(){this.Go()?this.Mt(this.ao):this.co()}}},Rr=i({surveys:class{get Se(){return this._instance.config}constructor(t){this.Qo=void 0,this._surveyManager=null,this.Jo=!1,this.Yo=[],this.Ko=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 Xi.warn("Flags not loaded yet. Not loading surveys.");var i=g(e);this.Qo=i?e.length>0:e,Xi.info("flags response received, isSurveysEnabled: "+this.Qo),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("seenSurvey_")||null!=r&&r.startsWith("inProgressSurvey_"))&&e.push(r)}e.forEach((t=>localStorage.removeItem(t)))}catch(t){}}loadIfEnabled(){if(!this._surveyManager)if(this.Jo)Xi.info("Already initializing surveys, skipping...");else if(this.Se.disable_surveys)Xi.info(ar);else if(this.Se.cookieless_mode&&this._instance.consent.isOptedOut())Xi.info("Not loading surveys in cookieless mode without consent.");else{var t=null==Ct?void 0:Ct.__PosthogExtensions__;if(t){if(!m(this.Qo)||this.Se.advanced_enable_surveys){var e=this.Qo||this.Se.advanced_enable_surveys;this.Jo=!0;try{var i=t.generateSurveys;if(i)return void this.Xo(i,e);var r=t.loadExternalDependency;if(!r)return void this.ea(ve);r(this._instance,"surveys",(i=>{i||!t.generateSurveys?this.ea("Could not load surveys script",i):this.Xo(t.generateSurveys,e)}))}catch(t){throw this.ea("Error initializing surveys",t),t}finally{this.Jo=!1}}}else Xi.error("PostHog Extensions not found.")}}Xo(t,e){this._surveyManager=t(this._instance,e),this._surveyEventReceiver=new sr(this._instance),Xi.info("Surveys loaded successfully"),this.ta({isLoaded:!0})}ea(t,e){Xi.error(t,e),this.ta({isLoaded:!1,error:t})}onSurveysLoaded(t){return this.Yo.push(t),this._surveyManager&&this.ta({isLoaded:!0}),()=>{this.Yo=this.Yo.filter((e=>e!==t))}}getSurveys(t,e){if(void 0===e&&(e=!1),this.Se.disable_surveys)return Xi.info(ar),t([]);var i,r=this._instance.get_property(re);if(r&&!e)return t(r,{isLoaded:!0});"undefined"!=typeof Promise&&this.Ko?this.Ko.then((e=>{var{surveys:i,context:r}=e;return t(i,r)})):("undefined"!=typeof Promise&&(this.Ko=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.Ko=null;var s=e.statusCode;if(200!==s||!e.json){var n="Surveys API could not be loaded, status: "+s;Xi.error(n);var a={isLoaded:!1,error:n};return t([],a),void(null==i||i({surveys:[],context:a}))}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({[re]:l,$surveys_loaded_at:Date.now()});var h={isLoaded:!0};t(l,h),null==i||i({surveys:l,context:h})}}))}ta(t){for(var e of this.Yo)try{if(!t.isLoaded)return e([],t);this.getSurveys(e)}catch(t){Xi.error("Error in survey callback",t)}}getActiveMatchingSurveys(t,e){if(void 0===e&&(e=!1),!x(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(t,e);Xi.warn("init was not called")}ra(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}ia(t){if(x(this._surveyManager))return{eligible:!1,reason:nr};var e="string"==typeof t?this.ra(t):t;return e?this._surveyManager.checkSurveyEligibility(e):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(t){if(x(this._surveyManager))return Xi.warn("init was not called"),{visible:!1,disabledReason:nr};var e=this.ia(t);return{visible:e.eligible,disabledReason:e.reason}}canRenderSurveyAsync(t,e){return x(this._surveyManager)?(Xi.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:nr})):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.ia(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))Xi.warn("init was not called");else{var s="string"==typeof t?this.ra(t):t;if(null!=s&&s.id)if(Zi.includes(s.type)){var n=null==St?void 0:St.querySelector(e);if(n)return null!=(r=s.appearance)&&r.surveyPopupDelaySeconds?(Xi.info("Rendering survey "+s.id+" with delay of "+s.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var t,e;Xi.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),Xi.info("Survey "+s.id+" rendered")}),1e3*s.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(s,n,i);Xi.warn("Survey element not found")}else Xi.warn("Surveys of type "+s.type+" cannot be rendered in the app");else Xi.warn("Survey not found")}}displaySurvey(t,e){var r;if(x(this._surveyManager))Xi.warn("init was not called");else{var s=this.ra(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&&Xi.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 Xi.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 Xi.warn("Survey not found")}}cancelPendingSurvey(t){x(this._surveyManager)?Xi.warn("init was not called"):this._surveyManager.cancelSurvey(t)}handlePageUnload(){var t;null==(t=this._surveyManager)||t.handlePageUnload()}}},xr),Ir={toolbar:class{constructor(t){this.instance=t}na(t){Ct.ph_toolbar_state=t}sa(){var t;return null!==(t=Ct.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),jt(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=or||ei(t.hash,"__posthog")||ei(t.hash,"state"),n=s?Ot((()=>JSON.parse(atob(decodeURIComponent(s)))))||Ot((()=>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(lr)||"{}")).source="localstorage",delete r.userIntent),!(!r.token||this.instance.config.token!==r.token||(this.loadToolbar(r),0))}catch(t){return!1}}oa(t){var e=Ct.ph_load_toolbar||Ct.ph_load_editor;!x(e)&&_(e)?e(t,this.instance):ur.warn("No toolbar load function found")}loadToolbar(t){var e=!(null==St||!St.getElementById(he));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(lr,JSON.stringify(i({},s,{source:void 0}))),2===this.sa())this.oa(s);else if(0===this.sa()){var n;this.na(1),null==(n=Ct.__PosthogExtensions__)||null==n.loadExternalDependency||n.loadExternalDependency(this.instance,"toolbar",(t=>{if(t)return ur.error("[Toolbar] Failed to load",t),void this.na(0);this.na(2),this.oa(s)})),Mt(xt,"turbolinks:load",(()=>{this.na(0),this.loadToolbar(s)}))}return!0}aa(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)}}},$r=i({experiments:br},xr),Ar={conversations:class{constructor(t){this.la=void 0,this._conversationsManager=null,this.ua=!1,this.ha=null,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!this._instance.config.disable_conversations){var e=t.conversations;x(e)||(k(e)?this.la=e:(this.la=e.enabled,this.ha=e),this.loadIfEnabled())}}reset(){var t;null==(t=this._conversationsManager)||t.reset(),this._conversationsManager=null,this.la=void 0,this.ha=null}loadIfEnabled(){if(!(this._conversationsManager||this.ua||this._instance.config.disable_conversations||jt(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var t=null==Ct?void 0:Ct.__PosthogExtensions__;if(t&&!m(this.la)&&this.la)if(this.ha&&this.ha.token){this.ua=!0;try{var e=t.initConversations;if(e)return this.da(e),void(this.ua=!1);var i=t.loadExternalDependency;if(!i)return void this.ca(ve);i(this._instance,"conversations",(e=>{e||!t.initConversations?this.ca("Could not load conversations script",e):this.da(t.initConversations),this.ua=!1}))}catch(t){this.ca("Error initializing conversations",t),this.ua=!1}}else mr.error("Conversations enabled but missing token in remote config.")}}da(t){if(this.ha)try{this._conversationsManager=t(this.ha,this._instance),mr.info("Conversations loaded successfully")}catch(t){this.ca("Error completing conversations initialization",t)}else mr.error("Cannot complete initialization: remote config is null")}ca(t,e){mr.error(t,e),this._conversationsManager=null,this.ua=!1}show(){this._conversationsManager?this._conversationsManager.show():mr.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this.la&&!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):(mr.warn(yr),null)}))()}getMessages(t,i){var r=this;return e((function*(){return r._conversationsManager?r._conversationsManager.getMessages(t,i):(mr.warn(yr),null)}))()}markAsRead(t){var i=this;return e((function*(){return i._conversationsManager?i._conversationsManager.markAsRead(t):(mr.warn(yr),null)}))()}getTickets(t){var i=this;return e((function*(){return i._conversationsManager?i._conversationsManager.getTickets(t):(mr.warn(yr),null)}))()}requestRestoreLink(t){var i=this;return e((function*(){return i._conversationsManager?i._conversationsManager.requestRestoreLink(t):(mr.warn(yr),null)}))()}restoreFromToken(t){var i=this;return e((function*(){return i._conversationsManager?i._conversationsManager.restoreFromToken(t):(mr.warn(yr),null)}))()}restoreFromUrlToken(){var t=this;return e((function*(){return t._conversationsManager?t._conversationsManager.restoreFromUrlToken():(mr.warn(yr),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()}}},Tr={logs:class{constructor(t){var e;this.va=!1,this.fa=!1,this.Ae=It("[logs]"),this._r=[],this.pa=[],this.ga=()=>{var t,e;null==(t=this.ma)||t.onReconnect(),null==(e=this.ya)||e.onReconnect()},this._instance=t,this._instance&&null!=(e=this._instance.config.logs)&&e.captureConsoleLogs&&(this.va=!0),xt&&Mt(xt,"online",this.ga)}ba(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._a(t,e),n,this.Ae,(()=>this.wa()),(t=>t()),void 0,r),n]}xa(){var t,e,i=null==(t=this._instance)||null==(t=t.config)?void 0:t.logs;return this.ma&&this.ka===i||(null==(e=this.ma)||e.reset(),this.ka=i,[this.ma,this.Sa]=this.ba((()=>this._r),(t=>{this._r=t}))),this.ma}Ca(){var t,e,i=null==(t=this._instance)||null==(t=t.config)?void 0:t.logs;return this.ya&&this.Ia===i||(null==(e=this.ya)||e.reset(),this.Ia=i,[this.ya,this.Ta]=this.ba((()=>this.pa),(t=>{this.pa=t}),{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},wr)),this.ya}initialize(){this.loadIfEnabled()}onRemoteConfig(t){var e,i=null==(e=t.logs)?void 0:e.captureConsoleLogs;!x(i)&&i&&(this.va=!0,this.loadIfEnabled())}reset(){var t,e;this._r=[],null==(t=this.ma)||t.reset(),this.pa=[],null==(e=this.ya)||e.reset()}captureLog(t){this.xa().captureLog(t)}le(t){this.Ca().captureLog(t)}get logger(){return this.Ea||(this.Ea={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.Ea}flushLogs(t){t?this.Ma(t):(this.ma&&this.ma.flush().catch((t=>this.Ae.error("PostHog logs flush failed:",t))),this.ya&&this.ya.flush().catch((t=>this.Ae.error("PostHog logs flush failed:",t))))}loadIfEnabled(){if(this.va&&!this.fa){var t=null==Ct?void 0:Ct.__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.fa=!0)})):this.Ae.error(ve)}else this.Ae.error("PostHog Extensions not found.")}}_a(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.Pa(),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)})}}})}))}Ma(t){this._r.length>0&&this.Ra(t,this._r,this.Sa,s,(t=>{this._r=t})),this.pa.length>0&&this.Ra(t,this.pa,this.Ta,wr,(t=>{this.pa=t}))}Ra(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.Pa(),data:l,compression:"best-available",batchKey:"logs",transport:t})}}Pa(){return this._instance.requestRouter.endpointFor("api","/i/v1/logs")+"?token="+encodeURIComponent(this._instance.config.token)}wa(){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!=Ct&&null!=(t=Ct.location)&&t.href&&(e.currentUrl=this._instance.config.disable_capture_url_hashes?A(Ct.location.href):Ct.location.href),this._instance.featureFlags){var a=this._instance.featureFlags.getFlags();a&&a.length>0&&(e.activeFeatureFlags=a)}return e}}},Or=i({},xr,Er,kr,Sr,Fr,Cr,Rr,Pr,Ir,$r,Ar,Tr),Mr=xr,jr=Er,Lr=kr,Dr=Sr,Nr=Fr,zr=Cr,Ur=Rr,Hr=Pr,Vr=Ir,Br=$r,Wr=Ar,qr=Tr;export{Or as AllExtensions,Lr as AnalyticsExtensions,Wr as ConversationsExtensions,Dr as ErrorTrackingExtensions,Br as ExperimentsExtensions,Mr as FeatureFlagsExtensions,qr as LogsExtensions,Nr as ProductToursExtensions,jr as SessionReplayExtensions,zr as SiteAppsExtensions,Ur as SurveysExtensions,Vr as ToolbarExtensions,Hr as TracingExtensions};
|
|
2
2
|
//# sourceMappingURL=extension-bundles.js.map
|