@leanbase.com/js 0.2.0-alpha.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/consent.d.ts +25 -0
- package/dist/leanbase.d.ts +5 -1
- package/dist/leanbase.iife.js +1 -1
- package/dist/leanbase.iife.js.map +1 -1
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/module.d.ts +84 -8
- package/dist/module.js +1 -1
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +55 -7
- package/dist/utils/index.d.ts +2 -0
- package/dist/version.d.ts +1 -1
- package/lib/consent.d.ts +25 -0
- package/lib/consent.js +101 -0
- package/lib/consent.js.map +1 -0
- package/lib/leanbase.d.ts +5 -1
- package/lib/leanbase.js +68 -3
- package/lib/leanbase.js.map +1 -1
- package/lib/types.d.ts +55 -7
- package/lib/types.js.map +1 -1
- package/lib/utils/index.d.ts +2 -0
- package/lib/utils/index.js +9 -0
- package/lib/utils/index.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/lib/version.js.map +1 -1
- package/package.json +4 -6
package/dist/module.d.ts
CHANGED
|
@@ -123,15 +123,15 @@ interface LeanbaseConfig extends Partial<PostHogCoreOptions> {
|
|
|
123
123
|
* An object containing the `distinctID`, `isIdentifiedID`, and `featureFlags` keys,
|
|
124
124
|
* where `distinctID` is a string, and `featureFlags` is an object of key-value pairs.
|
|
125
125
|
*
|
|
126
|
-
* Since there is a delay between initializing
|
|
126
|
+
* Since there is a delay between initializing Leanbase and fetching feature flags,
|
|
127
127
|
* feature flags are not always available immediately.
|
|
128
128
|
* This makes them unusable if you want to do something like redirecting a user
|
|
129
129
|
* to a different page based on a feature flag.
|
|
130
130
|
*
|
|
131
131
|
* You can, therefore, fetch the feature flags in your server and pre-fill them here,
|
|
132
|
-
* allowing
|
|
132
|
+
* allowing Leanbase to know the feature flag values immediately.
|
|
133
133
|
*
|
|
134
|
-
* After the SDK fetches feature flags from
|
|
134
|
+
* After the SDK fetches feature flags from Leanbase, it will use those flag values instead of bootstrapped ones.
|
|
135
135
|
*
|
|
136
136
|
* @default {}
|
|
137
137
|
*/
|
|
@@ -236,19 +236,19 @@ interface LeanbaseConfig extends Partial<PostHogCoreOptions> {
|
|
|
236
236
|
* Enables cookieless mode. In this mode, Leanbase will not set any cookies, or use session or local storage. User
|
|
237
237
|
* identity is handled by generating a privacy-preserving hash on Leanbase's servers.
|
|
238
238
|
* - 'always' - enable cookieless mode immediately on startup, use this if you do not intend to show a cookie banner
|
|
239
|
-
* - 'on_reject' - enable cookieless mode only if the user rejects cookies, use this if you want to show a cookie banner. If the user accepts cookies, cookieless mode will not be used, and
|
|
239
|
+
* - 'on_reject' - enable cookieless mode only if the user rejects cookies, use this if you want to show a cookie banner. If the user accepts cookies, cookieless mode will not be used, and Leanbase will use cookies and local storage as usual.
|
|
240
240
|
*
|
|
241
241
|
* Note that you MUST enable cookieless mode in your Leanbase project's settings, otherwise all your cookieless events will be ignored. We plan to remove this requirement in the future.
|
|
242
242
|
* */
|
|
243
243
|
cookieless_mode?: 'always' | 'on_reject';
|
|
244
244
|
/**
|
|
245
|
-
* Determines whether
|
|
245
|
+
* Determines whether Leanbase should save referrer information.
|
|
246
246
|
*
|
|
247
247
|
* @default true
|
|
248
248
|
*/
|
|
249
249
|
save_referrer: boolean;
|
|
250
250
|
/**
|
|
251
|
-
* Determines whether
|
|
251
|
+
* Determines whether Leanbase should save marketing parameters.
|
|
252
252
|
* These are `utm_*` paramaters and friends.
|
|
253
253
|
*
|
|
254
254
|
* @see {CAMPAIGN_PARAMS} from './utils/event-utils' - Default campaign parameters like utm_source, utm_medium, etc.
|
|
@@ -269,7 +269,7 @@ interface LeanbaseConfig extends Partial<PostHogCoreOptions> {
|
|
|
269
269
|
scroll_root_selector?: string | string[];
|
|
270
270
|
/**
|
|
271
271
|
* Determines if users should be opted out of user agent filtering such as googlebot or other bots.
|
|
272
|
-
* If this is set to `true`,
|
|
272
|
+
* If this is set to `true`, Leanbase will set `$browser_type` to either `bot` or `browser` for all events,
|
|
273
273
|
* but will process all events as if they were from a browser.
|
|
274
274
|
*
|
|
275
275
|
* @default false
|
|
@@ -281,6 +281,54 @@ interface LeanbaseConfig extends Partial<PostHogCoreOptions> {
|
|
|
281
281
|
* @default 65535
|
|
282
282
|
*/
|
|
283
283
|
properties_string_max_length: number;
|
|
284
|
+
/**
|
|
285
|
+
* Determines whether Leanbase should respect the Do Not Track header when computing
|
|
286
|
+
* consent in `ConsentManager`.
|
|
287
|
+
*
|
|
288
|
+
* @see `ConsentManager`
|
|
289
|
+
* @default false
|
|
290
|
+
*/
|
|
291
|
+
respect_dnt: boolean;
|
|
292
|
+
/**
|
|
293
|
+
* Determines if users should be opted out of Leanbase tracking by default,
|
|
294
|
+
* requiring additional logic to opt them into capturing by calling `leanbase.opt_in_capturing()`.
|
|
295
|
+
*
|
|
296
|
+
* @default false
|
|
297
|
+
*/
|
|
298
|
+
opt_out_capturing_by_default: boolean;
|
|
299
|
+
/**
|
|
300
|
+
* Determines where we'll save the information about whether users are opted out of capturing.
|
|
301
|
+
*
|
|
302
|
+
* @default 'localStorage'
|
|
303
|
+
*/
|
|
304
|
+
opt_out_capturing_persistence_type: 'localStorage' | 'cookie';
|
|
305
|
+
/**
|
|
306
|
+
* Determines if users should be opted out of Leanbase data storage by this Leanbase instance by default,
|
|
307
|
+
* requiring additional logic to opt them into capturing by calling `leanbase.opt_in_capturing()`.
|
|
308
|
+
*
|
|
309
|
+
* @default false
|
|
310
|
+
*/
|
|
311
|
+
opt_out_persistence_by_default?: boolean;
|
|
312
|
+
/** @deprecated Use `consent_persistence_name` instead. This will be removed in a future major version. **/
|
|
313
|
+
opt_out_capturing_cookie_prefix: string | null;
|
|
314
|
+
/**
|
|
315
|
+
* Determines the key for the cookie / local storage used to store the information about whether users are opted in/out of capturing.
|
|
316
|
+
* When `null`, we used a key based on your token.
|
|
317
|
+
*
|
|
318
|
+
* @default null
|
|
319
|
+
* @see `ConsentManager._storageKey`
|
|
320
|
+
*/
|
|
321
|
+
consent_persistence_name: string | null;
|
|
322
|
+
/**
|
|
323
|
+
* Function to get the device ID.
|
|
324
|
+
* This doesn't usually need to be set, but can be useful if you want to use a custom device ID.
|
|
325
|
+
*
|
|
326
|
+
* @param uuid - The UUID we would use for the device ID.
|
|
327
|
+
* @returns The device ID.
|
|
328
|
+
*
|
|
329
|
+
* @default (uuid) => uuid
|
|
330
|
+
*/
|
|
331
|
+
getDeviceId: (uuid: string) => string;
|
|
284
332
|
/**
|
|
285
333
|
* A function to be called once the Leanbase scripts have loaded successfully.
|
|
286
334
|
*
|
|
@@ -735,10 +783,36 @@ declare class ScrollManager {
|
|
|
735
783
|
scrollX(): number;
|
|
736
784
|
}
|
|
737
785
|
|
|
786
|
+
declare enum ConsentStatus {
|
|
787
|
+
PENDING = -1,
|
|
788
|
+
DENIED = 0,
|
|
789
|
+
GRANTED = 1
|
|
790
|
+
}
|
|
791
|
+
/**
|
|
792
|
+
* ConsentManager provides tools for managing user consent as configured by the application.
|
|
793
|
+
*/
|
|
794
|
+
declare class ConsentManager {
|
|
795
|
+
private _instance;
|
|
796
|
+
private _persistentStore?;
|
|
797
|
+
constructor(_instance: Leanbase);
|
|
798
|
+
private get _config();
|
|
799
|
+
get consent(): ConsentStatus;
|
|
800
|
+
isOptedOut(): boolean;
|
|
801
|
+
isOptedIn(): boolean;
|
|
802
|
+
isExplicitlyOptedOut(): boolean;
|
|
803
|
+
optInOut(isOptedIn: boolean): void;
|
|
804
|
+
reset(): void;
|
|
805
|
+
private get _storageKey();
|
|
806
|
+
private get _storedConsent();
|
|
807
|
+
private get _storage();
|
|
808
|
+
private _getDnt;
|
|
809
|
+
}
|
|
810
|
+
|
|
738
811
|
declare class Leanbase extends PostHogCore {
|
|
739
812
|
config: LeanbaseConfig;
|
|
740
813
|
scrollManager: ScrollManager;
|
|
741
814
|
pageViewManager: PageViewManager;
|
|
815
|
+
consent: ConsentManager;
|
|
742
816
|
replayAutocapture?: Autocapture;
|
|
743
817
|
persistence?: LeanbasePersistence;
|
|
744
818
|
sessionPersistence?: LeanbasePersistence;
|
|
@@ -750,7 +824,7 @@ declare class Leanbase extends PostHogCore {
|
|
|
750
824
|
initialPageviewCaptured: boolean;
|
|
751
825
|
visibilityStateListener: (() => void) | null;
|
|
752
826
|
constructor(token: string, config?: Partial<LeanbaseConfig>);
|
|
753
|
-
init(token: string, config: Partial<LeanbaseConfig>):
|
|
827
|
+
init(token: string, config: Partial<LeanbaseConfig>): this;
|
|
754
828
|
captureInitialPageview(): void;
|
|
755
829
|
capturePageLeave(): void;
|
|
756
830
|
loadRemoteConfig(): Promise<void>;
|
|
@@ -764,6 +838,7 @@ declare class Leanbase extends PostHogCore {
|
|
|
764
838
|
setPersistedProperty<T>(key: PostHogPersistedProperty, value: T | null): void;
|
|
765
839
|
calculateEventProperties(eventName: string, eventProperties: PostHogEventProperties, timestamp: Date, uuid: string, readOnly?: boolean): Properties;
|
|
766
840
|
isIdentified(): boolean;
|
|
841
|
+
isCapturing(): boolean;
|
|
767
842
|
/**
|
|
768
843
|
* Add additional set_once properties to the event when creating a person profile. This allows us to create the
|
|
769
844
|
* profile with mostly-accurate properties, despite earlier events not setting them. We do this by storing them in
|
|
@@ -774,6 +849,7 @@ declare class Leanbase extends PostHogCore {
|
|
|
774
849
|
capture(event: string, properties?: PostHogEventProperties, options?: LeanbasegCaptureOptions): void;
|
|
775
850
|
identify(distinctId?: string, properties?: PostHogEventProperties, options?: LeanbasegCaptureOptions): void;
|
|
776
851
|
destroy(): void;
|
|
852
|
+
private _isPersistenceDisabled;
|
|
777
853
|
}
|
|
778
854
|
|
|
779
855
|
export { Leanbase };
|
package/dist/module.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function e(e,t,r,i,s,n,o){try{var a=e[n](o),l=a.value}catch(e){return void r(e)}a.done?t(l):Promise.resolve(l).then(i,s)}function t(t){return function(){var r=this,i=arguments;return new Promise((function(s,n){var o=t.apply(r,i);function a(t){e(o,s,n,a,l,"next",t)}function l(t){e(o,s,n,a,l,"throw",t)}a(void 0)}))}}function r(){return r=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)({}).hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},r.apply(null,arguments)}var i=e=>{if("flags"in e)return r({},e,{featureFlags:n(e.flags),featureFlagPayloads:o(e.flags)});var t,i=null!==(t=e.featureFlags)&&void 0!==t?t:{},a=Object.fromEntries(Object.entries(e.featureFlagPayloads||{}).map((e=>{var[t,r]=e;return[t,l(r)]}))),u=Object.fromEntries(Object.entries(i).map((e=>{var[t,r]=e;return[t,s(t,r,a[t])]})));return r({},e,{featureFlags:i,featureFlagPayloads:a,flags:u})};function s(e,t,r){return{key:e,enabled:"string"==typeof t||t,variant:"string"==typeof t?t:void 0,reason:void 0,metadata:{id:void 0,version:void 0,payload:r?JSON.stringify(r):void 0,description:void 0}}}var n=e=>Object.fromEntries(Object.entries(null!=e?e:{}).map((e=>{var[t,r]=e;return[t,a(r)]})).filter((e=>{var[,t]=e;return void 0!==t}))),o=e=>{var t=null!=e?e:{};return Object.fromEntries(Object.keys(t).filter((e=>{var r=t[e];return r.enabled&&r.metadata&&void 0!==r.metadata.payload})).map((e=>{var r,i=null==(r=t[e].metadata)?void 0:r.payload;return[e,i?l(i):void 0]})))},a=e=>{var t;return void 0===e?void 0:null!==(t=e.variant)&&void 0!==t?t:e.enabled},l=e=>{if("string"!=typeof e)return e;try{return JSON.parse(e)}catch(t){return e}},u=(e,t)=>{var r=[...new Set([...Object.keys(null!=e?e:{}),...Object.keys(null!=t?t:{})])].filter((r=>!!e[r]||!!t[r])).reduce(((t,r)=>{var i;return t[r]=null===(i=e[r])||void 0===i||i,t}),{});return i({featureFlags:r,featureFlagPayloads:null!=t?t:{}})};function c(e){return"string"==typeof e||e}function d(e){return"string"==typeof e?e:void 0}var p="0123456789abcdef";let h=class e{constructor(e){this.bytes=e}static ofInner(t){if(16===t.length)return new e(t);throw new TypeError("not 128-bit length")}static fromFieldsV7(t,r,i,s){if(!Number.isInteger(t)||!Number.isInteger(r)||!Number.isInteger(i)||!Number.isInteger(s)||t<0||r<0||i<0||s<0||t>0xffffffffffff||r>4095||i>1073741823||s>4294967295)throw new RangeError("invalid field value");var n=new Uint8Array(16);return n[0]=t/Math.pow(2,40),n[1]=t/Math.pow(2,32),n[2]=t/Math.pow(2,24),n[3]=t/Math.pow(2,16),n[4]=t/256,n[5]=t,n[6]=112|r>>>8,n[7]=r,n[8]=128|i>>>24,n[9]=i>>>16,n[10]=i>>>8,n[11]=i,n[12]=s>>>24,n[13]=s>>>16,n[14]=s>>>8,n[15]=s,new e(n)}static parse(t){var r,i,s,n,o;switch(t.length){case 32:o=null==(r=/^[0-9a-f]{32}$/i.exec(t))?void 0:r[0];break;case 36:o=null==(i=/^([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(t))?void 0:i.slice(1,6).join("");break;case 38:o=null==(s=/^\{([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})\}$/i.exec(t))?void 0:s.slice(1,6).join("");break;case 45:o=null==(n=/^urn:uuid:([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(t))?void 0:n.slice(1,6).join("")}if(o){for(var a=new Uint8Array(16),l=0;l<16;l+=4){var u=parseInt(o.substring(2*l,2*l+8),16);a[l+0]=u>>>24,a[l+1]=u>>>16,a[l+2]=u>>>8,a[l+3]=u}return new e(a)}throw new SyntaxError("could not parse UUID string")}toString(){for(var e="",t=0;t<this.bytes.length;t++)e+=p.charAt(this.bytes[t]>>>4),e+=p.charAt(15&this.bytes[t]),3!==t&&5!==t&&7!==t&&9!==t||(e+="-");return e}toHex(){for(var e="",t=0;t<this.bytes.length;t++)e+=p.charAt(this.bytes[t]>>>4),e+=p.charAt(15&this.bytes[t]);return e}toJSON(){return this.toString()}getVariant(){var e=this.bytes[8]>>>4;if(e<0)throw new Error("unreachable");if(e<=7)return this.bytes.every((e=>0===e))?"NIL":"VAR_0";if(e<=11)return"VAR_10";if(e<=13)return"VAR_110";if(e<=15)return this.bytes.every((e=>255===e))?"MAX":"VAR_RESERVED";throw new Error("unreachable")}getVersion(){return"VAR_10"===this.getVariant()?this.bytes[6]>>>4:void 0}clone(){return new e(this.bytes.slice(0))}equals(e){return 0===this.compareTo(e)}compareTo(e){for(var t=0;t<16;t++){var r=this.bytes[t]-e.bytes[t];if(0!==r)return Math.sign(r)}return 0}},g=class{constructor(e){this.timestamp=0,this.counter=0,this.random=null!=e?e:v()}generate(){return this.generateOrResetCore(Date.now(),1e4)}generateOrAbort(){return this.generateOrAbortCore(Date.now(),1e4)}generateOrResetCore(e,t){var r=this.generateOrAbortCore(e,t);return void 0===r&&(this.timestamp=0,r=this.generateOrAbortCore(e,t)),r}generateOrAbortCore(e,t){if(!Number.isInteger(e)||e<1||e>0xffffffffffff)throw new RangeError("`unixTsMs` must be a 48-bit positive integer");if(t<0||t>0xffffffffffff)throw new RangeError("`rollbackAllowance` out of reasonable range");if(e>this.timestamp)this.timestamp=e,this.resetCounter();else{if(!(e+t>=this.timestamp))return;this.counter++,this.counter>4398046511103&&(this.timestamp++,this.resetCounter())}return h.fromFieldsV7(this.timestamp,Math.trunc(this.counter/Math.pow(2,30)),this.counter&Math.pow(2,30)-1,this.random.nextUint32())}resetCounter(){this.counter=1024*this.random.nextUint32()+(1023&this.random.nextUint32())}generateV4(){var e=new Uint8Array(Uint32Array.of(this.random.nextUint32(),this.random.nextUint32(),this.random.nextUint32(),this.random.nextUint32()).buffer);return e[6]=64|e[6]>>>4,e[8]=128|e[8]>>>2,h.ofInner(e)}};var f,v=()=>({nextUint32:()=>65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random())}),_=()=>m().toString(),m=()=>(f||(f=new g)).generate(),y=function(e){return e.AnonymousId="anonymous_id",e.DistinctId="distinct_id",e.Props="props",e.FeatureFlagDetails="feature_flag_details",e.FeatureFlags="feature_flags",e.FeatureFlagPayloads="feature_flag_payloads",e.BootstrapFeatureFlagDetails="bootstrap_feature_flag_details",e.BootstrapFeatureFlags="bootstrap_feature_flags",e.BootstrapFeatureFlagPayloads="bootstrap_feature_flag_payloads",e.OverrideFeatureFlags="override_feature_flags",e.Queue="queue",e.OptedOut="opted_out",e.SessionId="session_id",e.SessionStartTimestamp="session_start_timestamp",e.SessionLastTimestamp="session_timestamp",e.PersonProperties="person_properties",e.GroupProperties="group_properties",e.InstalledAppBuild="installed_app_build",e.InstalledAppVersion="installed_app_version",e.SessionReplay="session_replay",e.SurveyLastSeenDate="survey_last_seen_date",e.SurveysSeen="surveys_seen",e.Surveys="surveys",e.RemoteConfig="remote_config",e.FlagsEndpointWasHit="flags_endpoint_was_hit",e}({}),b=function(e){return e.GZipJS="gzip-js",e.Base64="base64",e}({});function w(e,t){return-1!==e.indexOf(t)}var P=function(e){return e.trim()},F=function(e){return e.replace(/^\$/,"")},S=Array.isArray,x=Object.prototype,E=x.hasOwnProperty,I=x.toString,C=S||function(e){return"[object Array]"===I.call(e)},k=e=>"function"==typeof e,A=e=>e===Object(e)&&!C(e),R=e=>{if(A(e)){for(var t in e)if(E.call(e,t))return!1;return!0}return!1},O=e=>void 0===e,T=e=>"[object String]"==I.call(e),M=e=>null===e,D=e=>O(e)||M(e),N=e=>"[object Number]"==I.call(e),L=e=>"[object Boolean]"===I.call(e),j=e=>e instanceof FormData,B=e=>e instanceof Error;function U(e,t,r,i,s){return N(e)?e>r?(i.warn(" cannot be greater than max: "+r+". Using max value instead."),r):e<t?(i.warn(" cannot be less than min: "+t+". Using min value instead."),t):e:(i.warn(" must be a number. using max or fallback. max: "+r+", fallback: "+s),U(r,t,r,i))}class q{add(e){var t=_();return this.promiseByIds[t]=e,e.catch((()=>{})).finally((()=>{delete this.promiseByIds[t]})),e}join(){var e=this;return t((function*(){for(var t=Object.values(e.promiseByIds),r=t.length;r>0;)yield Promise.all(t),r=(t=Object.values(e.promiseByIds)).length}))()}get length(){return Object.keys(this.promiseByIds).length}constructor(){this.promiseByIds={}}}function z(){return(z=t((function*(e,t){for(var r=null,i=0;i<t.retryCount+1;i++){i>0&&(yield new Promise((e=>setTimeout(e,t.retryDelay))));try{return yield e()}catch(e){if(r=e,!t.retryCheck(e))throw e}}throw r}))).apply(this,arguments)}function V(){return(new Date).toISOString()}function H(e,t){var r=setTimeout(e,t);return(null==r?void 0:r.unref)&&(null==r||r.unref()),r}function G(e){return Promise.all(e.map((e=>(null!=e?e:Promise.resolve()).then((e=>({status:"fulfilled",value:e})),(e=>({status:"rejected",reason:e}))))))}class K{constructor(){this.events={},this.events={}}on(e,t){return this.events[e]||(this.events[e]=[]),this.events[e].push(t),()=>{this.events[e]=this.events[e].filter((e=>e!==t))}}emit(e,t){for(var r of this.events[e]||[])r(t);for(var i of this.events["*"]||[])i(e,t)}}function W(e,t){return J.apply(this,arguments)}function J(){return(J=t((function*(e,t){void 0===t&&(t=!0);try{var r=new Blob([e],{type:"text/plain"}).stream().pipeThrough(new CompressionStream("gzip"));return yield new Response(r).blob()}catch(e){return t&&console.error("Failed to gzip compress data",e),null}}))).apply(this,arguments)}var Q=(e,t,r)=>{function i(i){for(var s=arguments.length,n=new Array(s>1?s-1:0),o=1;o<s;o++)n[o-1]=arguments[o];t((()=>{(0,r[i])(e,...n)}))}return{info:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];i("log",...t)},warn:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];i("warn",...t)},error:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];i("error",...t)},critical:function(){for(var t=arguments.length,i=new Array(t),s=0;s<t;s++)i[s]=arguments[s];r.error(e,...i)},createLogger:i=>Q(e+" "+i,t,r)}};function Y(e,t){return Q(e,t,(void 0===r&&(r=console),{log:r.log.bind(r),warn:r.warn.bind(r),error:r.error.bind(r),debug:r.debug.bind(r)}));var r}class X extends Error{constructor(e,t){super("HTTP error while fetching PostHog: status="+e.status+", reqByteLength="+t),this.response=e,this.reqByteLength=t,this.name="PostHogFetchHttpError"}get status(){return this.response.status}get text(){return this.response.text()}get json(){return this.response.json()}}class Z extends Error{constructor(e){super("Network error while fetching PostHog",e instanceof Error?{cause:e}:{}),this.error=e,this.name="PostHogFetchNetworkError"}}var ee=(e,t)=>void 0!==t?{[e]:t}:{};function te(e){return re.apply(this,arguments)}function re(){return(re=t((function*(e){if(e instanceof X){var t="";try{t=yield e.text}catch(e){}console.error("Error while flushing PostHog: message="+e.message+", response body="+t,e)}else console.error("Error while flushing PostHog",e);return Promise.resolve()}))).apply(this,arguments)}function ie(e){return"object"==typeof e&&(e instanceof X||e instanceof Z)}function se(e){return"object"==typeof e&&e instanceof X&&413===e.status}var ne=function(e){return e.FeatureFlags="feature_flags",e.Recordings="recordings",e}({});class oe{constructor(e,t){var r,i,s,n,o,a,l,u,c,d,p,h,g,f,v,_,m,y,b;void 0===t&&(t={}),this.flushPromise=null,this.shutdownPromise=null,this.promiseQueue=new q,this._events=new K,this._isInitialized=!1,function(e,t){if(!e||"string"!=typeof e||function(e){return 0===e.trim().length}(e))throw new Error(t)}(e,"You must pass your PostHog project's api key."),this.apiKey=e,this.host=null==(b=t.host||"https://us.i.posthog.com")?void 0:b.replace(/\/+$/,""),this.flushAt=t.flushAt?Math.max(t.flushAt,1):20,this.maxBatchSize=Math.max(this.flushAt,null!==(r=t.maxBatchSize)&&void 0!==r?r:100),this.maxQueueSize=Math.max(this.flushAt,null!==(i=t.maxQueueSize)&&void 0!==i?i:1e3),this.flushInterval=null!==(s=t.flushInterval)&&void 0!==s?s:1e4,this.preloadFeatureFlags=null===(n=t.preloadFeatureFlags)||void 0===n||n,this.defaultOptIn=null===(o=t.defaultOptIn)||void 0===o||o,this.disableSurveys=null!==(a=t.disableSurveys)&&void 0!==a&&a,this._retryOptions={retryCount:null!==(l=t.fetchRetryCount)&&void 0!==l?l:3,retryDelay:null!==(u=t.fetchRetryDelay)&&void 0!==u?u:3e3,retryCheck:ie},this.requestTimeout=null!==(c=t.requestTimeout)&&void 0!==c?c:1e4,this.featureFlagsRequestTimeoutMs=null!==(d=t.featureFlagsRequestTimeoutMs)&&void 0!==d?d:3e3,this.remoteConfigRequestTimeoutMs=null!==(p=t.remoteConfigRequestTimeoutMs)&&void 0!==p?p:3e3,this.disableGeoip=null===(h=t.disableGeoip)||void 0===h||h,this.disabled=null!==(g=t.disabled)&&void 0!==g&&g,this.historicalMigration=null!==(f=null==(v=t)?void 0:v.historicalMigration)&&void 0!==f&&f,this.evaluationEnvironments=null==(_=t)?void 0:_.evaluationEnvironments,this._initPromise=Promise.resolve(),this._isInitialized=!0,this._logger=Y("[PostHog]",this.logMsgIfDebug.bind(this)),this.disableCompression=!("CompressionStream"in globalThis)||null!==(m=null==(y=t)?void 0:y.disableCompression)&&void 0!==m&&m}logMsgIfDebug(e){this.isDebug&&e()}wrap(e){if(!this.disabled)return this._isInitialized?e():void this._initPromise.then((()=>e()));this._logger.warn("The client is disabled")}getCommonEventProperties(){return{$lib:this.getLibraryId(),$lib_version:this.getLibraryVersion()}}get optedOut(){var e;return null!==(e=this.getPersistedProperty(y.OptedOut))&&void 0!==e?e:!this.defaultOptIn}optIn(){var e=this;return t((function*(){e.wrap((()=>{e.setPersistedProperty(y.OptedOut,!1)}))}))()}optOut(){var e=this;return t((function*(){e.wrap((()=>{e.setPersistedProperty(y.OptedOut,!0)}))}))()}on(e,t){return this._events.on(e,t)}debug(e){var t;if(void 0===e&&(e=!0),null==(t=this.removeDebugCallback)||t.call(this),e){var r=this.on("*",((e,t)=>this._logger.info(e,t)));this.removeDebugCallback=()=>{r(),this.removeDebugCallback=void 0}}}get isDebug(){return!!this.removeDebugCallback}get isDisabled(){return this.disabled}buildPayload(e){return{distinct_id:e.distinct_id,event:e.event,properties:r({},e.properties||{},this.getCommonEventProperties())}}addPendingPromise(e){return this.promiseQueue.add(e)}identifyStateless(e,t,i){this.wrap((()=>{var s=r({},this.buildPayload({distinct_id:e,event:"$identify",properties:t}));this.enqueue("identify",s,i)}))}identifyStatelessImmediate(e,i,s){var n=this;return t((function*(){var t=r({},n.buildPayload({distinct_id:e,event:"$identify",properties:i}));yield n.sendImmediate("identify",t,s)}))()}captureStateless(e,t,r,i){this.wrap((()=>{var s=this.buildPayload({distinct_id:e,event:t,properties:r});this.enqueue("capture",s,i)}))}captureStatelessImmediate(e,r,i,s){var n=this;return t((function*(){var t=n.buildPayload({distinct_id:e,event:r,properties:i});yield n.sendImmediate("capture",t,s)}))()}aliasStateless(e,t,i,s){this.wrap((()=>{var n=this.buildPayload({event:"$create_alias",distinct_id:t,properties:r({},i||{},{distinct_id:t,alias:e})});this.enqueue("alias",n,s)}))}aliasStatelessImmediate(e,i,s,n){var o=this;return t((function*(){var t=o.buildPayload({event:"$create_alias",distinct_id:i,properties:r({},s||{},{distinct_id:i,alias:e})});yield o.sendImmediate("alias",t,n)}))()}groupIdentifyStateless(e,t,i,s,n,o){this.wrap((()=>{var a=this.buildPayload({distinct_id:n||"$"+e+"_"+t,event:"$groupidentify",properties:r({$group_type:e,$group_key:t,$group_set:i||{}},o||{})});this.enqueue("capture",a,s)}))}getRemoteConfig(){var e=this;return t((function*(){yield e._initPromise;var t=e.host;"https://us.i.posthog.com"===t?t="https://us-assets.i.posthog.com":"https://eu.i.posthog.com"===t&&(t="https://eu-assets.i.posthog.com");var i=t+"/array/"+e.apiKey+"/config",s={method:"GET",headers:r({},e.getCustomHeaders(),{"Content-Type":"application/json"})};return e.fetchWithRetry(i,s,{retryCount:0},e.remoteConfigRequestTimeoutMs).then((e=>e.json())).catch((t=>{e._logger.error("Remote config could not be loaded",t),e._events.emit("error",t)}))}))()}getFlags(e,s,n,o,a,l){var u=this;return t((function*(){void 0===s&&(s={}),void 0===n&&(n={}),void 0===o&&(o={}),void 0===a&&(a={}),void 0===l&&(l=!0),yield u._initPromise;var t=l?"&config=true":"",c=u.host+"/flags/?v=2"+t,d=r({token:u.apiKey,distinct_id:e,groups:s,person_properties:n,group_properties:o},a);u.evaluationEnvironments&&u.evaluationEnvironments.length>0&&(d.evaluation_environments=u.evaluationEnvironments);var p={method:"POST",headers:r({},u.getCustomHeaders(),{"Content-Type":"application/json"}),body:JSON.stringify(d)};return u._logger.info("Flags URL",c),u.fetchWithRetry(c,p,{retryCount:0},u.featureFlagsRequestTimeoutMs).then((e=>e.json())).then((e=>i(e))).catch((e=>{u._events.emit("error",e)}))}))()}getFeatureFlagStateless(e,r,i,s,n,o){var l=this;return t((function*(){void 0===i&&(i={}),void 0===s&&(s={}),void 0===n&&(n={}),yield l._initPromise;var t=yield l.getFeatureFlagDetailStateless(e,r,i,s,n,o);if(void 0===t)return{response:void 0,requestId:void 0};var u=a(t.response);return void 0===u&&(u=!1),{response:u,requestId:t.requestId}}))()}getFeatureFlagDetailStateless(e,r,i,s,n,o){var a=this;return t((function*(){void 0===i&&(i={}),void 0===s&&(s={}),void 0===n&&(n={}),yield a._initPromise;var t=yield a.getFeatureFlagDetailsStateless(r,i,s,n,o,[e]);if(void 0!==t)return{response:t.flags[e],requestId:t.requestId}}))()}getFeatureFlagPayloadStateless(e,r,i,s,n,o){var a=this;return t((function*(){void 0===i&&(i={}),void 0===s&&(s={}),void 0===n&&(n={}),yield a._initPromise;var t=yield a.getFeatureFlagPayloadsStateless(r,i,s,n,o,[e]);if(t){var l=t[e];return void 0===l?null:l}}))()}getFeatureFlagPayloadsStateless(e,r,i,s,n,o){var a=this;return t((function*(){return void 0===r&&(r={}),void 0===i&&(i={}),void 0===s&&(s={}),yield a._initPromise,(yield a.getFeatureFlagsAndPayloadsStateless(e,r,i,s,n,o)).payloads}))()}getFeatureFlagsStateless(e,r,i,s,n,o){var a=this;return t((function*(){return void 0===r&&(r={}),void 0===i&&(i={}),void 0===s&&(s={}),yield a._initPromise,yield a.getFeatureFlagsAndPayloadsStateless(e,r,i,s,n,o)}))()}getFeatureFlagsAndPayloadsStateless(e,r,i,s,n,o){var a=this;return t((function*(){void 0===r&&(r={}),void 0===i&&(i={}),void 0===s&&(s={}),yield a._initPromise;var t=yield a.getFeatureFlagDetailsStateless(e,r,i,s,n,o);return t?{flags:t.featureFlags,payloads:t.featureFlagPayloads,requestId:t.requestId}:{flags:void 0,payloads:void 0,requestId:void 0}}))()}getFeatureFlagDetailsStateless(e,r,i,s,n,o){var a=this;return t((function*(){var t;void 0===r&&(r={}),void 0===i&&(i={}),void 0===s&&(s={}),yield a._initPromise;var l={};(null!=n?n:a.disableGeoip)&&(l.geoip_disable=!0),o&&(l.flag_keys_to_evaluate=o);var u=yield a.getFlags(e,r,i,s,l);if(void 0!==u)return u.errorsWhileComputingFlags&&console.error("[FEATURE FLAGS] Error while computing feature flags, some flags may be missing or incorrect. Learn more at https://posthog.com/docs/feature-flags/best-practices"),null!=(t=u.quotaLimited)&&t.includes("feature_flags")?(console.warn("[FEATURE FLAGS] Feature flags quota limit exceeded - feature flags unavailable. Learn more about billing limits at https://posthog.com/docs/billing/limits-alerts"),{flags:{},featureFlags:{},featureFlagPayloads:{},requestId:null==u?void 0:u.requestId}):u}))()}getSurveysStateless(){var e=this;return t((function*(){if(yield e._initPromise,!0===e.disableSurveys)return e._logger.info("Loading surveys is disabled."),[];var t=e.host+"/api/surveys/?token="+e.apiKey,i={method:"GET",headers:r({},e.getCustomHeaders(),{"Content-Type":"application/json"})},s=yield e.fetchWithRetry(t,i).then((t=>{if(200!==t.status||!t.json){var r="Surveys API could not be loaded: "+t.status,i=new Error(r);return e._logger.error(i),void e._events.emit("error",new Error(r))}return t.json()})).catch((t=>{e._logger.error("Surveys API could not be loaded",t),e._events.emit("error",t)})),n=null==s?void 0:s.surveys;return n&&e._logger.info("Surveys fetched from API: ",JSON.stringify(n)),null!=n?n:[]}))()}get props(){return this._props||(this._props=this.getPersistedProperty(y.Props)),this._props||{}}set props(e){this._props=e}register(e){var i=this;return t((function*(){i.wrap((()=>{i.props=r({},i.props,e),i.setPersistedProperty(y.Props,i.props)}))}))()}unregister(e){var r=this;return t((function*(){r.wrap((()=>{delete r.props[e],r.setPersistedProperty(y.Props,r.props)}))}))()}enqueue(e,t,r){this.wrap((()=>{if(this.optedOut)this._events.emit(e,"Library is disabled. Not sending event. To re-enable, call posthog.optIn()");else{var i=this.prepareMessage(e,t,r),s=this.getPersistedProperty(y.Queue)||[];s.length>=this.maxQueueSize&&(s.shift(),this._logger.info("Queue is full, the oldest event is dropped.")),s.push({message:i}),this.setPersistedProperty(y.Queue,s),this._events.emit(e,i),s.length>=this.flushAt&&this.flushBackground(),this.flushInterval&&!this._flushTimer&&(this._flushTimer=H((()=>this.flushBackground()),this.flushInterval))}}))}sendImmediate(e,i,s){var n=this;return t((function*(){if(n.disabled)n._logger.warn("The client is disabled");else if(n._isInitialized||(yield n._initPromise),n.optedOut)n._events.emit(e,"Library is disabled. Not sending event. To re-enable, call posthog.optIn()");else{var t={api_key:n.apiKey,batch:[n.prepareMessage(e,i,s)],sent_at:V()};n.historicalMigration&&(t.historical_migration=!0);var o=JSON.stringify(t),a=n.host+"/batch/",l=n.disableCompression?null:yield W(o,n.isDebug),u={method:"POST",headers:r({},n.getCustomHeaders(),{"Content-Type":"application/json"},null!==l&&{"Content-Encoding":"gzip"}),body:l||o};try{yield n.fetchWithRetry(a,u)}catch(e){n._events.emit("error",e)}}}))()}prepareMessage(e,t,i){var s,n=r({},t,{type:e,library:this.getLibraryId(),library_version:this.getLibraryVersion(),timestamp:null!=i&&i.timestamp?null==i?void 0:i.timestamp:V(),uuid:null!=i&&i.uuid?i.uuid:_()});return(null!==(s=null==i?void 0:i.disableGeoip)&&void 0!==s?s:this.disableGeoip)&&(n.properties||(n.properties={}),n.properties.$geoip_disable=!0),n.distinctId&&(n.distinct_id=n.distinctId,delete n.distinctId),n}clearFlushTimer(){this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=void 0)}flushBackground(){this.flush().catch(function(){var e=t((function*(e){yield te(e)}));return function(t){return e.apply(this,arguments)}}())}flush(){var e=this;return t((function*(){var t=G([e.flushPromise]).then((()=>e._flush()));return e.flushPromise=t,e.addPendingPromise(t),G([t]).then((()=>{e.flushPromise===t&&(e.flushPromise=null)})),t}))()}getCustomHeaders(){var e=this.getCustomUserAgent(),t={};return e&&""!==e&&(t["User-Agent"]=e),t}_flush(){var e=this;return t((function*(){e.clearFlushTimer(),yield e._initPromise;var t=e.getPersistedProperty(y.Queue)||[];if(t.length){for(var i=[],s=t.length,n=function*(){var s=t.slice(0,e.maxBatchSize),n=s.map((e=>e.message)),o=()=>{var r=(e.getPersistedProperty(y.Queue)||[]).slice(s.length);e.setPersistedProperty(y.Queue,r),t=r},a={api_key:e.apiKey,batch:n,sent_at:V()};e.historicalMigration&&(a.historical_migration=!0);var l=JSON.stringify(a),u=e.host+"/batch/",c=e.disableCompression?null:yield W(l,e.isDebug),d={method:"POST",headers:r({},e.getCustomHeaders(),{"Content-Type":"application/json"},null!==c&&{"Content-Encoding":"gzip"}),body:c||l},p={retryCheck:e=>!se(e)&&ie(e)};try{yield e.fetchWithRetry(u,d,p)}catch(t){if(se(t)&&n.length>1)return e.maxBatchSize=Math.max(1,Math.floor(n.length/2)),e._logger.warn("Received 413 when sending batch of size "+n.length+", reducing batch size to "+e.maxBatchSize),1;throw t instanceof Z||o(),e._events.emit("error",t),t}o(),i.push(...n)};t.length>0&&i.length<s;)yield*n();e._events.emit("flush",i)}}))()}fetchWithRetry(e,i,s,n){var o=this;return t((function*(){var a,l;null!==(l=(a=AbortSignal).timeout)&&void 0!==l||(a.timeout=function(e){var t=new AbortController;return setTimeout((()=>t.abort()),e),t.signal});var u=i.body?i.body:"",c=-1;try{c=u instanceof Blob?u.size:Buffer.byteLength(u,"utf8")}catch(e){if(u instanceof Blob)c=u.size;else{var d=(new TextEncoder).encode(u);c=d.length}}return yield function(e,t){return z.apply(this,arguments)}(t((function*(){var t=null;try{t=yield o.fetch(e,r({signal:AbortSignal.timeout(null!=n?n:o.requestTimeout)},i))}catch(e){throw new Z(e)}if(!("no-cors"===i.mode)&&(t.status<200||t.status>=400))throw new X(t,c);return t})),r({},o._retryOptions,s))}))()}_shutdown(e){var r=this;return t((function*(){void 0===e&&(e=3e4),yield r._initPromise;var i=!1;r.clearFlushTimer();var s=function(){var e=t((function*(){try{for(yield r.promiseQueue.join();;){if(0===(r.getPersistedProperty(y.Queue)||[]).length)break;if(yield r.flush(),i)break}}catch(e){if(!ie(e))throw e;yield te(e)}}));return function(){return e.apply(this,arguments)}}();return Promise.race([new Promise(((t,s)=>{H((()=>{r._logger.error("Timed out while shutting down PostHog"),i=!0,s("Timeout while shutting down PostHog. Some events may not have been sent.")}),e)})),s()])}))()}shutdown(e){var r=this;return t((function*(){return void 0===e&&(e=3e4),r.shutdownPromise?r._logger.warn("shutdown() called while already shutting down. shutdown() is meant to be called once before process exit - use flush() for per-request cleanup"):r.shutdownPromise=r._shutdown(e).finally((()=>{r.shutdownPromise=null})),r.shutdownPromise}))()}}class ae extends oe{constructor(e,t){var i,s,n,o;super(e,r({},t,{disableGeoip:null!==(i=null==t?void 0:t.disableGeoip)&&void 0!==i&&i,featureFlagsRequestTimeoutMs:null!==(s=null==t?void 0:t.featureFlagsRequestTimeoutMs)&&void 0!==s?s:1e4})),this.flagCallReported={},this._sessionMaxLengthSeconds=86400,this.sessionProps={},this.sendFeatureFlagEvent=null===(n=null==t?void 0:t.sendFeatureFlagEvent)||void 0===n||n,this._sessionExpirationTimeSeconds=null!==(o=null==t?void 0:t.sessionExpirationTimeSeconds)&&void 0!==o?o:1800}setupBootstrap(e){var t,i=null==e?void 0:e.bootstrap;if(i){if(i.distinctId)if(i.isIdentifiedId){this.getPersistedProperty(y.DistinctId)||this.setPersistedProperty(y.DistinctId,i.distinctId)}else{this.getPersistedProperty(y.AnonymousId)||this.setPersistedProperty(y.AnonymousId,i.distinctId)}var s=i.featureFlags,n=null!==(t=i.featureFlagPayloads)&&void 0!==t?t:{};if(s&&Object.keys(s).length){var o=u(s,n);if(Object.keys(o.flags).length>0){this.setBootstrappedFeatureFlagDetails(o);var a=this.getKnownFeatureFlagDetails()||{flags:{},requestId:void 0},l={flags:r({},o.flags,a.flags),requestId:o.requestId};this.setKnownFeatureFlagDetails(l)}}}}clearProps(){this.props=void 0,this.sessionProps={},this.flagCallReported={}}on(e,t){return this._events.on(e,t)}reset(e){this.wrap((()=>{var t=[y.Queue,...e||[]];for(var r of(this.clearProps(),Object.keys(y)))t.includes(y[r])||this.setPersistedProperty(y[r],null);this.reloadFeatureFlags()}))}getCommonEventProperties(){var e=this.getFeatureFlags(),t={};if(e)for(var[i,s]of Object.entries(e))t["$feature/"+i]=s;return r({},ee("$active_feature_flags",e?Object.keys(e):void 0),t,super.getCommonEventProperties())}enrichProperties(e){return r({},this.props,this.sessionProps,e||{},this.getCommonEventProperties(),{$session_id:this.getSessionId()})}getSessionId(){if(!this._isInitialized)return"";var e=this.getPersistedProperty(y.SessionId),t=this.getPersistedProperty(y.SessionLastTimestamp)||0,r=this.getPersistedProperty(y.SessionStartTimestamp)||0,i=Date.now(),s=i-r;return(!e||i-t>1e3*this._sessionExpirationTimeSeconds||s>1e3*this._sessionMaxLengthSeconds)&&(e=_(),this.setPersistedProperty(y.SessionId,e),this.setPersistedProperty(y.SessionStartTimestamp,i)),this.setPersistedProperty(y.SessionLastTimestamp,i),e}resetSessionId(){this.wrap((()=>{this.setPersistedProperty(y.SessionId,null),this.setPersistedProperty(y.SessionLastTimestamp,null),this.setPersistedProperty(y.SessionStartTimestamp,null)}))}getAnonymousId(){if(!this._isInitialized)return"";var e=this.getPersistedProperty(y.AnonymousId);return e||(e=_(),this.setPersistedProperty(y.AnonymousId,e)),e}getDistinctId(){return this._isInitialized?this.getPersistedProperty(y.DistinctId)||this.getAnonymousId():""}registerForSession(e){this.sessionProps=r({},this.sessionProps,e)}unregisterForSession(e){delete this.sessionProps[e]}identify(e,t,i){this.wrap((()=>{var s=this.getDistinctId();e=e||s,null!=t&&t.$groups&&this.groups(t.$groups);var n=null==t?void 0:t.$set_once;null==t||delete t.$set_once;var o=(null==t?void 0:t.$set)||t,a=this.enrichProperties(r({$anon_distinct_id:this.getAnonymousId()},ee("$set",o),ee("$set_once",n)));e!==s&&(this.setPersistedProperty(y.AnonymousId,s),this.setPersistedProperty(y.DistinctId,e),this.reloadFeatureFlags()),super.identifyStateless(e,a,i)}))}capture(e,t,r){this.wrap((()=>{var i=this.getDistinctId();null!=t&&t.$groups&&this.groups(t.$groups);var s=this.enrichProperties(t);super.captureStateless(i,e,s,r)}))}alias(e){this.wrap((()=>{var t=this.getDistinctId(),r=this.enrichProperties({});super.aliasStateless(e,t,r)}))}autocapture(e,t,i,s){void 0===i&&(i={}),this.wrap((()=>{var n={distinct_id:this.getDistinctId(),event:"$autocapture",properties:r({},this.enrichProperties(i),{$event_type:e,$elements:t})};this.enqueue("autocapture",n,s)}))}groups(e){this.wrap((()=>{var t=this.props.$groups||{};this.register({$groups:r({},t,e)}),Object.keys(e).find((r=>t[r]!==e[r]))&&this.reloadFeatureFlags()}))}group(e,t,r,i){this.wrap((()=>{this.groups({[e]:t}),r&&this.groupIdentify(e,t,r,i)}))}groupIdentify(e,t,r,i){this.wrap((()=>{var s=this.getDistinctId(),n=this.enrichProperties({});super.groupIdentifyStateless(e,t,r,i,s,n)}))}setPersonPropertiesForFlags(e){this.wrap((()=>{var t=this.getPersistedProperty(y.PersonProperties)||{};this.setPersistedProperty(y.PersonProperties,r({},t,e))}))}resetPersonPropertiesForFlags(){this.wrap((()=>{this.setPersistedProperty(y.PersonProperties,null)}))}setGroupPropertiesForFlags(e){this.wrap((()=>{var t=this.getPersistedProperty(y.GroupProperties)||{};0!==Object.keys(t).length&&Object.keys(t).forEach((i=>{t[i]=r({},t[i],e[i]),delete e[i]})),this.setPersistedProperty(y.GroupProperties,r({},t,e))}))}resetGroupPropertiesForFlags(){this.wrap((()=>{this.setPersistedProperty(y.GroupProperties,null)}))}remoteConfigAsync(){var e=this;return t((function*(){return yield e._initPromise,e._remoteConfigResponsePromise?e._remoteConfigResponsePromise:e._remoteConfigAsync()}))()}flagsAsync(e,r){var i=this;return t((function*(){return void 0===e&&(e=!0),void 0===r&&(r=!0),yield i._initPromise,i._flagsResponsePromise?i._flagsResponsePromise:i._flagsAsync(e,r)}))()}cacheSessionReplay(e,t){var r=null==t?void 0:t.sessionRecording;r?(this.setPersistedProperty(y.SessionReplay,r),this._logger.info("Session replay config from "+e+": ",JSON.stringify(r))):"boolean"==typeof r&&!1===r&&(this._logger.info("Session replay config from "+e+" disabled."),this.setPersistedProperty(y.SessionReplay,null))}_remoteConfigAsync(){var e=()=>super.getRemoteConfig,i=this;return t((function*(){return i._remoteConfigResponsePromise=i._initPromise.then((()=>{var t=i.getPersistedProperty(y.RemoteConfig);return i._logger.info("Cached remote config: ",JSON.stringify(t)),e().call(i).then((e=>{if(e){var s,n=r({},e);if(delete n.surveys,i._logger.info("Fetched remote config: ",JSON.stringify(n)),!1===i.disableSurveys){var o=e.surveys,a=!0;Array.isArray(o)?i._logger.info("Surveys fetched from remote config: ",JSON.stringify(o)):(i._logger.info("There are no surveys."),a=!1),a?i.setPersistedProperty(y.Surveys,o):i.setPersistedProperty(y.Surveys,null)}else i.setPersistedProperty(y.Surveys,null);i.setPersistedProperty(y.RemoteConfig,n),i.cacheSessionReplay("remote config",e),!1===e.hasFeatureFlags?(i.setKnownFeatureFlagDetails({flags:{}}),i._logger.warn("Remote config has no feature flags, will not load feature flags.")):!1!==i.preloadFeatureFlags&&i.reloadFeatureFlags(),null!=(s=e.supportedCompression)&&s.includes(b.GZipJS)||(i.disableCompression=!0),t=e}return t}))})).finally((()=>{i._remoteConfigResponsePromise=void 0})),i._remoteConfigResponsePromise}))()}_flagsAsync(e,i){var s=()=>super.getFlags,n=this;return t((function*(){return void 0===e&&(e=!0),void 0===i&&(i=!0),n._flagsResponsePromise=n._initPromise.then(t((function*(){var t,o=n.getDistinctId(),a=n.props.$groups||{},l=n.getPersistedProperty(y.PersonProperties)||{},u=n.getPersistedProperty(y.GroupProperties)||{},c={$anon_distinct_id:e?n.getAnonymousId():void 0},d=yield s().call(n,o,a,l,u,c,i);if(null!=d&&null!=(t=d.quotaLimited)&&t.includes(ne.FeatureFlags))return n.setKnownFeatureFlagDetails(null),console.warn("[FEATURE FLAGS] Feature flags quota limit exceeded - unsetting all flags. Learn more about billing limits at https://posthog.com/docs/billing/limits-alerts"),d;if(null!=d&&d.featureFlags){n.sendFeatureFlagEvent&&(n.flagCallReported={});var p=d;if(d.errorsWhileComputingFlags){var h=n.getKnownFeatureFlagDetails();n._logger.info("Cached feature flags: ",JSON.stringify(h)),p=r({},d,{flags:r({},null==h?void 0:h.flags,d.flags)})}n.setKnownFeatureFlagDetails(p),n.setPersistedProperty(y.FlagsEndpointWasHit,!0),n.cacheSessionReplay("flags",d)}return d}))).finally((()=>{n._flagsResponsePromise=void 0})),n._flagsResponsePromise}))()}setKnownFeatureFlagDetails(e){this.wrap((()=>{var t;this.setPersistedProperty(y.FeatureFlagDetails,e),this._events.emit("featureflags",n(null!==(t=null==e?void 0:e.flags)&&void 0!==t?t:{}))}))}getKnownFeatureFlagDetails(){var e=this.getPersistedProperty(y.FeatureFlagDetails);if(!e){var t=this.getPersistedProperty(y.FeatureFlags),r=this.getPersistedProperty(y.FeatureFlagPayloads);if(void 0===t&&void 0===r)return;return u(null!=t?t:{},null!=r?r:{})}return i(e)}getKnownFeatureFlags(){var e=this.getKnownFeatureFlagDetails();if(e)return n(e.flags)}getKnownFeatureFlagPayloads(){var e=this.getKnownFeatureFlagDetails();if(e)return o(e.flags)}getBootstrappedFeatureFlagDetails(){var e=this.getPersistedProperty(y.BootstrapFeatureFlagDetails);if(e)return e}setBootstrappedFeatureFlagDetails(e){this.setPersistedProperty(y.BootstrapFeatureFlagDetails,e)}getBootstrappedFeatureFlags(){var e=this.getBootstrappedFeatureFlagDetails();if(e)return n(e.flags)}getBootstrappedFeatureFlagPayloads(){var e=this.getBootstrappedFeatureFlagDetails();if(e)return o(e.flags)}getFeatureFlag(e){var t=this.getFeatureFlagDetails();if(t){var i=t.flags[e],s=a(i);if(void 0===s&&(s=!1),this.sendFeatureFlagEvent&&!this.flagCallReported[e]){var n,o,l,u,c,d,p,h=null==(n=this.getBootstrappedFeatureFlags())?void 0:n[e],g=null==(o=this.getBootstrappedFeatureFlagPayloads())?void 0:o[e];this.flagCallReported[e]=!0,this.capture("$feature_flag_called",r({$feature_flag:e,$feature_flag_response:s},ee("$feature_flag_id",null==i||null==(l=i.metadata)?void 0:l.id),ee("$feature_flag_version",null==i||null==(u=i.metadata)?void 0:u.version),ee("$feature_flag_reason",null!==(c=null==i||null==(d=i.reason)?void 0:d.description)&&void 0!==c?c:null==i||null==(p=i.reason)?void 0:p.code),ee("$feature_flag_bootstrapped_response",h),ee("$feature_flag_bootstrapped_payload",g),{$used_bootstrap_value:!this.getPersistedProperty(y.FlagsEndpointWasHit)},ee("$feature_flag_request_id",t.requestId)))}return s}}getFeatureFlagPayload(e){var t=this.getFeatureFlagPayloads();if(t){var r=t[e];return void 0===r?null:r}}getFeatureFlagPayloads(){var e;return null==(e=this.getFeatureFlagDetails())?void 0:e.featureFlagPayloads}getFeatureFlags(){var e;return null==(e=this.getFeatureFlagDetails())?void 0:e.featureFlags}getFeatureFlagDetails(){var e,t=this.getKnownFeatureFlagDetails(),s=this.getPersistedProperty(y.OverrideFeatureFlags);if(!s)return t;var n,o,a=null!==(e=(t=null!=t?t:{featureFlags:{},featureFlagPayloads:{},flags:{}}).flags)&&void 0!==e?e:{};for(var l in s)s[l]?a[l]=(n=a[l],o=s[l],r({},n,{enabled:c(o),variant:d(o)})):delete a[l];var u=r({},t,{flags:a});return i(u)}getFeatureFlagsAndPayloads(){return{flags:this.getFeatureFlags(),payloads:this.getFeatureFlagPayloads()}}isFeatureEnabled(e){var t=this.getFeatureFlag(e);if(void 0!==t)return!!t}reloadFeatureFlags(e){this.flagsAsync(!0).then((t=>{null==e||null==e.cb||e.cb(void 0,null==t?void 0:t.featureFlags)})).catch((t=>{null==e||null==e.cb||e.cb(t,void 0),null!=e&&e.cb||this._logger.info("Error reloading feature flags",t)}))}reloadRemoteConfigAsync(){var e=this;return t((function*(){return yield e.remoteConfigAsync()}))()}reloadFeatureFlagsAsync(e){var r=this;return t((function*(){var t;return null==(t=yield r.flagsAsync(null==e||e))?void 0:t.featureFlags}))()}onFeatureFlags(e){var r=this;return this.on("featureflags",t((function*(){var t=r.getFeatureFlags();t&&e(t)})))}onFeatureFlag(e,r){var i=this;return this.on("featureflags",t((function*(){var t=i.getFeatureFlag(e);void 0!==t&&r(t)})))}overrideFeatureFlag(e){var r=this;return t((function*(){r.wrap((()=>null===e?r.setPersistedProperty(y.OverrideFeatureFlags,null):r.setPersistedProperty(y.OverrideFeatureFlags,e)))}))()}captureException(e,t){var i=r({$exception_level:"error",$exception_list:[{type:B(e)?e.name:"Error",value:B(e)?e.message:e,mechanism:{handled:!0,synthetic:!1}}]},t);this.capture("$exception",i)}captureTraceFeedback(e,t){this.capture("$ai_feedback",{$ai_feedback_text:t,$ai_trace_id:String(e)})}captureTraceMetric(e,t,r){this.capture("$ai_metric",{$ai_metric_name:t,$ai_metric_value:String(r),$ai_trace_id:String(e)})}}var le={},ue=Array.prototype,ce=ue.forEach,de=ue.indexOf,pe="undefined"!=typeof window?window:void 0,he="undefined"!=typeof globalThis?globalThis:pe,ge=null==he?void 0:he.navigator,fe=null==he?void 0:he.document,ve=null==he?void 0:he.location;null==he||he.fetch,null!=he&&he.XMLHttpRequest&&"withCredentials"in new he.XMLHttpRequest&&he.XMLHttpRequest,null==he||he.AbortController;var _e=null==ge?void 0:ge.userAgent;function me(e,t,r){if(C(e))if(ce&&e.forEach===ce)e.forEach(t,r);else if("length"in e&&e.length===+e.length)for(var i=0,s=e.length;i<s;i++)if(i in e&&t.call(r,e[i],i)===le)return}function ye(e,t,r){if(!D(e)){if(C(e))return me(e,t,r);if(j(e)){for(var i of e.entries())if(t.call(r,i[1],i[0])===le)return}else for(var s in e)if(E.call(e,s)&&t.call(r,e[s],s)===le)return}}var be=function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];return me(r,(function(t){for(var r in t)void 0!==t[r]&&(e[r]=t[r])})),e},we=function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];return me(r,(function(t){me(t,(function(t){e.push(t)}))})),e};function Pe(e){for(var t=Object.keys(e),r=t.length,i=new Array(r);r--;)i[r]=[t[r],e[t[r]]];return i}function Fe(e,t,r,i){var{capture:s=!1,passive:n=!0}=null!=i?i:{};null==e||e.addEventListener(t,r,{capture:s,passive:n})}var Se=function(e){var t={};return ye(e,(function(e,r){(T(e)&&e.length>0||N(e))&&(t[r]=e)})),t},xe=["herokuapp.com","vercel.app","netlify.app"];function Ee(e){var t=null==e?void 0:e.hostname;if(!T(t))return!1;var r=t.split(".").slice(-2).join(".");for(var i of xe)if(r===i)return!1;return!0}function $e(e,t){return r=e,i=e=>T(e)&&!M(t)?e.slice(0,t):e,s=new Set,function e(t,r){return t!==Object(t)?i?i(t,r):t:s.has(t)?void 0:(s.add(t),C(t)?(n=[],me(t,(t=>{n.push(e(t))}))):(n={},ye(t,((t,r)=>{s.has(t)||(n[r]=e(t,r))}))),n);var n}(r);var r,i,s}var Ie="__timers",Ce="$autocapture_disabled_server_side",ke="$sesid",Ae="$enabled_feature_flags",Re="$user_state",Oe="$initial_campaign_params",Te="$initial_referrer_info",Me="$initial_person_info",De="$epp",Ne=["$people_distinct_id","__alias","__cmpns",Ie,"$session_recording_enabled_server_side","$heatmaps_enabled_server_side",ke,Ae,"$error_tracking_suppression_rules",Re,"$early_access_features","$feature_flag_details","$stored_group_properties","$stored_person_properties","$surveys","$flag_call_reported","$client_session_props","$capture_rate_limit",Oe,Te,De,Me,y.Queue,y.FeatureFlagDetails,y.FlagsEndpointWasHit,y.AnonymousId,y.RemoteConfig,y.Surveys,y.FeatureFlags],Le="[Leanbase]",je={info:function(){if("undefined"!=typeof console){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];console.log(Le,...t)}},warn:function(){if("undefined"!=typeof console){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];console.warn(Le,...t)}},error:function(){if("undefined"!=typeof console){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];console.error(Le,...t)}},critical:function(){if("undefined"!=typeof console){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];console.error(Le,"CRITICAL:",...t)}}};Math.trunc||(Math.trunc=function(e){return e<0?Math.ceil(e):Math.floor(e)}),Number.isInteger||(Number.isInteger=function(e){return N(e)&&isFinite(e)&&Math.floor(e)===e});var Be="0123456789abcdef";class Ue{constructor(e){if(this.bytes=e,16!==e.length)throw new TypeError("not 128-bit length")}static fromFieldsV7(e,t,r,i){if(!Number.isInteger(e)||!Number.isInteger(t)||!Number.isInteger(r)||!Number.isInteger(i)||e<0||t<0||r<0||i<0||e>0xffffffffffff||t>4095||r>1073741823||i>4294967295)throw new RangeError("invalid field value");var s=new Uint8Array(16);return s[0]=e/Math.pow(2,40),s[1]=e/Math.pow(2,32),s[2]=e/Math.pow(2,24),s[3]=e/Math.pow(2,16),s[4]=e/Math.pow(2,8),s[5]=e,s[6]=112|t>>>8,s[7]=t,s[8]=128|r>>>24,s[9]=r>>>16,s[10]=r>>>8,s[11]=r,s[12]=i>>>24,s[13]=i>>>16,s[14]=i>>>8,s[15]=i,new Ue(s)}toString(){for(var e="",t=0;t<this.bytes.length;t++)e=e+Be.charAt(this.bytes[t]>>>4)+Be.charAt(15&this.bytes[t]),3!==t&&5!==t&&7!==t&&9!==t||(e+="-");if(36!==e.length)throw new Error("Invalid UUIDv7 was generated");return e}clone(){return new Ue(this.bytes.slice(0))}equals(e){return 0===this.compareTo(e)}compareTo(e){for(var t=0;t<16;t++){var r=this.bytes[t]-e.bytes[t];if(0!==r)return Math.sign(r)}return 0}}class qe{constructor(){this._timestamp=0,this._counter=0,this._random=new He}generate(){var e=this.generateOrAbort();if(O(e)){this._timestamp=0;var t=this.generateOrAbort();if(O(t))throw new Error("Could not generate UUID after timestamp reset");return t}return e}generateOrAbort(){var e=Date.now();if(e>this._timestamp)this._timestamp=e,this._resetCounter();else{if(!(e+1e4>this._timestamp))return;this._counter++,this._counter>4398046511103&&(this._timestamp++,this._resetCounter())}return Ue.fromFieldsV7(this._timestamp,Math.trunc(this._counter/Math.pow(2,30)),this._counter&Math.pow(2,30)-1,this._random.nextUint32())}_resetCounter(){this._counter=1024*this._random.nextUint32()+(1023&this._random.nextUint32())}}var ze,Ve=e=>{if("undefined"!=typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var t=0;t<e.length;t++)e[t]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return e};pe&&!O(pe.crypto)&&crypto.getRandomValues&&(Ve=e=>crypto.getRandomValues(e));class He{constructor(){this._buffer=new Uint32Array(8),this._cursor=1/0}nextUint32(){return this._cursor>=this._buffer.length&&(Ve(this._buffer),this._cursor=0),this._buffer[this._cursor++]}}var Ge=()=>Ke().toString(),Ke=()=>(ze||(ze=new qe)).generate(),We="";var Je=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;function Qe(e,t){if(t){var r=function(e,t){if(void 0===t&&(t=fe),We)return We;if(!t)return"";if(["localhost","127.0.0.1"].includes(e))return"";for(var r=e.split("."),i=Math.min(r.length,8),s="dmn_chk_"+Ge();!We&&i--;){var n=r.slice(i).join("."),o=s+"=1;domain=."+n+";path=/";t.cookie=o+";max-age=3",t.cookie.includes(s)&&(t.cookie=o+";max-age=0",We=n)}return We}(e);if(!r){var i=(e=>{var t=e.match(Je);return t?t[0]:""})(e);i!==r&&je.info("Warning: cookie subdomain discovery mismatch",i,r),r=i}return r?"; domain=."+r:""}return""}var Ye={_is_supported:()=>!!fe,_error:function(e){je.error("cookieStore error: "+e)},_get:function(e){if(fe){try{for(var t=e+"=",r=fe.cookie.split(";").filter((e=>e.length)),i=0;i<r.length;i++){for(var s=r[i];" "==s.charAt(0);)s=s.substring(1,s.length);if(0===s.indexOf(t))return decodeURIComponent(s.substring(t.length,s.length))}}catch(e){}return null}},_parse:function(e){var t;try{t=JSON.parse(Ye._get(e))||{}}catch(e){}return t},_set:function(e,t,r,i,s){if(fe)try{var n="",o="",a=Qe(fe.location.hostname,i);if(r){var l=new Date;l.setTime(l.getTime()+24*r*60*60*1e3),n="; expires="+l.toUTCString()}s&&(o="; secure");var u=e+"="+encodeURIComponent(JSON.stringify(t))+n+"; SameSite=Lax; path=/"+a+o;return u.length>3686.4&&je.warn("cookieStore warning: large cookie, len="+u.length),fe.cookie=u,u}catch(e){return}},_remove:function(e,t){if(null!=fe&&fe.cookie)try{Ye._set(e,"",-1,t)}catch(e){return}}},Xe=null,Ze={_is_supported:function(){if(!M(Xe))return Xe;var e=!0;if(O(pe))e=!1;else try{var t="__mplssupport__";Ze._set(t,"xyz"),'"xyz"'!==Ze._get(t)&&(e=!1),Ze._remove(t)}catch(t){e=!1}return e||je.error("localStorage unsupported; falling back to cookie store"),Xe=e,e},_error:function(e){je.error("localStorage error: "+e)},_get:function(e){try{return null==pe?void 0:pe.localStorage.getItem(e)}catch(e){Ze._error(e)}return null},_parse:function(e){try{return JSON.parse(Ze._get(e))||{}}catch(e){}return null},_set:function(e,t){try{null==pe||pe.localStorage.setItem(e,JSON.stringify(t))}catch(e){Ze._error(e)}},_remove:function(e){try{null==pe||pe.localStorage.removeItem(e)}catch(e){Ze._error(e)}}},et=["distinct_id",ke,"$session_is_sampled",De,Me],tt=r({},Ze,{_parse:function(e){try{var t={};try{t=Ye._parse(e)||{}}catch(e){}var r=be(t,JSON.parse(Ze._get(e)||"{}"));return Ze._set(e,r),r}catch(e){}return null},_set:function(e,t,r,i,s,n){try{Ze._set(e,t,void 0,void 0,n);var o={};et.forEach((e=>{t[e]&&(o[e]=t[e])})),Object.keys(o).length&&Ye._set(e,o,r,i,s,n)}catch(e){Ze._error(e)}},_remove:function(e,t){try{null==pe||pe.localStorage.removeItem(e),Ye._remove(e,t)}catch(e){Ze._error(e)}}}),rt={},it={_is_supported:function(){return!0},_error:function(e){je.error("memoryStorage error: "+e)},_get:function(e){return rt[e]||null},_parse:function(e){return rt[e]||null},_set:function(e,t){rt[e]=t},_remove:function(e){delete rt[e]}},st=null,nt={_is_supported:function(){if(!M(st))return st;if(st=!0,O(pe))st=!1;else try{var e="__support__";nt._set(e,"xyz"),'"xyz"'!==nt._get(e)&&(st=!1),nt._remove(e)}catch(e){st=!1}return st},_error:function(e){je.error("sessionStorage error: ",e)},_get:function(e){try{return null==pe?void 0:pe.sessionStorage.getItem(e)}catch(e){nt._error(e)}return null},_parse:function(e){try{return JSON.parse(nt._get(e))||null}catch(e){}return null},_set:function(e,t){try{null==pe||pe.sessionStorage.setItem(e,JSON.stringify(t))}catch(e){nt._error(e)}},_remove:function(e){try{null==pe||pe.sessionStorage.removeItem(e)}catch(e){nt._error(e)}}},ot=e=>{var t=null==fe?void 0:fe.createElement("a");return O(t)?null:(t.href=e,t)},at=function(e,t){for(var r,i=((e.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),s=0;s<i.length;s++){var n=i[s].split("=");if(n[0]===t){r=n;break}}if(!C(r)||r.length<2)return"";var o=r[1];try{o=decodeURIComponent(o)}catch(e){je.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},lt=function(e,t,r){if(!e||!t||!t.length)return e;for(var i=e.split("#"),s=i[0]||"",n=i[1],o=s.split("?"),a=o[1],l=o[0],u=(a||"").split("&"),c=[],d=0;d<u.length;d++){var p=u[d].split("=");C(p)&&(t.includes(p[0])?c.push(p[0]+"="+r):c.push(u[d]))}var h=l;return null!=a&&(h+="?"+c.join("&")),null!=n&&(h+="#"+n),h},ut="Mobile",ct="iOS",dt="Android",pt="Tablet",ht=dt+" "+pt,gt="iPad",ft="Apple",vt=ft+" Watch",_t="Safari",mt="BlackBerry",yt="Samsung",bt=yt+"Browser",wt=yt+" Internet",Pt="Chrome",Ft=Pt+" OS",St=Pt+" "+ct,xt="Internet Explorer",Et=xt+" "+ut,$t="Opera",It=$t+" Mini",Ct="Edge",kt="Microsoft "+Ct,At="Firefox",Rt=At+" "+ct,Ot="Nintendo",Tt="PlayStation",Mt="Xbox",Dt=dt+" "+ut,Nt=ut+" "+_t,Lt="Windows",jt=Lt+" Phone",Bt="Nokia",Ut="Ouya",qt="Generic",zt=qt+" "+ut.toLowerCase(),Vt=qt+" "+pt.toLowerCase(),Ht="Konqueror",Gt="(\\d+(\\.\\d+)?)",Kt=new RegExp("Version/"+Gt),Wt=new RegExp(Mt,"i"),Jt=new RegExp(Tt+" \\w+","i"),Qt=new RegExp(Ot+" \\w+","i"),Yt=new RegExp(mt+"|PlayBook|BB10","i"),Xt={"NT3.51":"NT 3.11","NT4.0":"NT 4.0","5.0":"2000",5.1:"XP",5.2:"XP","6.0":"Vista",6.1:"7",6.2:"8",6.3:"8.1",6.4:"10","10.0":"10"};var Zt=(e,t)=>t&&w(t,ft)||function(e){return w(e,_t)&&!w(e,Pt)&&!w(e,dt)}(e),er=function(e,t){return t=t||"",w(e," OPR/")&&w(e,"Mini")?It:w(e," OPR/")?$t:Yt.test(e)?mt:w(e,"IE"+ut)||w(e,"WPDesktop")?Et:w(e,bt)?wt:w(e,Ct)||w(e,"Edg/")?kt:w(e,"FBIOS")?"Facebook "+ut:w(e,"UCWEB")||w(e,"UCBrowser")?"UC Browser":w(e,"CriOS")?St:w(e,"CrMo")||w(e,Pt)?Pt:w(e,dt)&&w(e,_t)?Dt:w(e,"FxiOS")?Rt:w(e.toLowerCase(),Ht.toLowerCase())?Ht:Zt(e,t)?w(e,ut)?Nt:_t:w(e,At)?At:w(e,"MSIE")||w(e,"Trident/")?xt:w(e,"Gecko")?At:""},tr={[Et]:[new RegExp("rv:"+Gt)],[kt]:[new RegExp(Ct+"?\\/"+Gt)],[Pt]:[new RegExp("("+Pt+"|CrMo)\\/"+Gt)],[St]:[new RegExp("CriOS\\/"+Gt)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+Gt)],[_t]:[Kt],[Nt]:[Kt],[$t]:[new RegExp("(Opera|OPR)\\/"+Gt)],[At]:[new RegExp(At+"\\/"+Gt)],[Rt]:[new RegExp("FxiOS\\/"+Gt)],[Ht]:[new RegExp("Konqueror[:/]?"+Gt,"i")],[mt]:[new RegExp(mt+" "+Gt),Kt],[Dt]:[new RegExp("android\\s"+Gt,"i")],[wt]:[new RegExp(bt+"\\/"+Gt)],[xt]:[new RegExp("(rv:|MSIE )"+Gt)],Mozilla:[new RegExp("rv:"+Gt)]},rr=function(e,t){var r=er(e,t),i=tr[r];if(O(i))return null;for(var s=0;s<i.length;s++){var n=i[s],o=e.match(n);if(o)return parseFloat(o[o.length-2])}return null},ir=[[new RegExp(Mt+"; "+Mt+" (.*?)[);]","i"),e=>[Mt,e&&e[1]||""]],[new RegExp(Ot,"i"),[Ot,""]],[new RegExp(Tt,"i"),[Tt,""]],[Yt,[mt,""]],[new RegExp(Lt,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[jt,""];if(new RegExp(ut).test(t)&&!/IEMobile\b/.test(t))return[Lt+" "+ut,""];var r=/Windows NT ([0-9.]+)/i.exec(t);if(r&&r[1]){var i=r[1],s=Xt[i]||"";return/arm/i.test(t)&&(s="RT"),[Lt,s]}return[Lt,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>{if(e&&e[3]){var t=[e[3],e[4],e[5]||"0"];return[ct,t.join(".")]}return[ct,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var t="";return e&&e.length>=3&&(t=O(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("("+dt+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+dt+")","i"),e=>{if(e&&e[2]){var t=[e[2],e[3],e[4]||"0"];return[dt,t.join(".")]}return[dt,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{var t=["Mac OS X",""];if(e&&e[1]){var r=[e[1],e[2],e[3]||"0"];t[1]=r.join(".")}return t}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[Ft,""]],[/Linux|debian/i,["Linux",""]]],sr=function(e){return Qt.test(e)?Ot:Jt.test(e)?Tt:Wt.test(e)?Mt:new RegExp(Ut,"i").test(e)?Ut:new RegExp("("+jt+"|WPDesktop)","i").test(e)?jt:/iPad/.test(e)?gt:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?vt:Yt.test(e)?mt:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(Bt,"i").test(e)?Bt:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(e)||/(kf[a-z]+)( bui|\)).+silk\//i.test(e)?"Kindle Fire":/(Android|ZTE)/i.test(e)?!new RegExp(ut).test(e)||/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(e)?/pixel[\daxl ]{1,6}/i.test(e)&&!/pixel c/i.test(e)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(e)||/lmy47v/i.test(e)&&!/QTAQZ3/i.test(e)?dt:ht:dt:new RegExp("(pda|"+ut+")","i").test(e)?zt:new RegExp(pt,"i").test(e)&&!new RegExp(pt+" pc","i").test(e)?Vt:""},nr={LIB_VERSION:"0.2.0-alpha.0"},or="https?://(.*)",ar=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],lr=we(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],ar),ur="<masked>",cr=["li_fat_id"];function dr(e,t,r){if(!fe)return{};var i,s=t?we([],ar,r||[]):[],n=pr(lt(fe.URL,s,ur),e),o=(i={},ye(cr,(function(e){var t=Ye._get(e);i[e]=t||null})),i);return be(o,n)}function pr(e,t){var r=lr.concat(t||[]),i={};return ye(r,(function(t){var r=at(e,t);i[t]=r||null})),i}function hr(e){var t=function(e){return e?0===e.search(or+"google.([^/?]*)")?"google":0===e.search(or+"bing.com")?"bing":0===e.search(or+"yahoo.com")?"yahoo":0===e.search(or+"duckduckgo.com")?"duckduckgo":null:null}(e),r="yahoo"!=t?"q":"p",i={};if(!M(t)){i.$search_engine=t;var s=fe?at(fe.referrer,r):"";s.length&&(i.ph_keyword=s)}return i}function gr(){return navigator.language||navigator.userLanguage}function fr(){return(null==fe?void 0:fe.referrer)||"$direct"}function vr(e){var t=function(e){var t,{r:r,u:i}=e,s={$referrer:r,$referring_domain:null==r?void 0:"$direct"==r?"$direct":null==(t=ot(r))?void 0:t.host};if(i){s.$current_url=i;var n=ot(i);s.$host=null==n?void 0:n.host,s.$pathname=null==n?void 0:n.pathname;var o=pr(i);be(s,o)}if(r){var a=hr(r);be(s,a)}return s}(e),r={};return ye(t,(function(e,t){r["$initial_"+F(t)]=e})),r}function _r(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(e){return}}function mr(){try{return(new Date).getTimezoneOffset()}catch(e){return}}function yr(e,t){if(!_e)return{};var r,i,s,n=e?we([],ar,t||[]):[],[o,a]=function(e){for(var t=0;t<ir.length;t++){var[r,i]=ir[t],s=r.exec(e),n=s&&(k(i)?i(s,e):i);if(n)return n}return["",""]}(_e);return be(Se({$os:o,$os_version:a,$browser:er(_e,navigator.vendor),$device:sr(_e),$device_type:(i=_e,s=sr(i),s===gt||s===ht||"Kobo"===s||"Kindle Fire"===s||s===Vt?pt:s===Ot||s===Mt||s===Tt||s===Ut?"Console":s===vt?"Wearable":s?ut:"Desktop"),$timezone:_r(),$timezone_offset:mr()}),{$current_url:lt(null==ve?void 0:ve.href,n,ur),$host:null==ve?void 0:ve.host,$pathname:null==ve?void 0:ve.pathname,$raw_user_agent:_e.length>1e3?_e.substring(0,997)+"...":_e,$browser_version:rr(_e,navigator.vendor),$browser_language:gr(),$browser_language_prefix:(r=gr(),"string"==typeof r?r.split("-")[0]:void 0),$screen_height:null==pe?void 0:pe.screen.height,$screen_width:null==pe?void 0:pe.screen.width,$viewport_height:null==pe?void 0:pe.innerHeight,$viewport_width:null==pe?void 0:pe.innerWidth,$lib:"web",$lib_version:nr.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})}var br=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"];class wr{constructor(e,t){this._config=e,this.props={},this._campaign_params_saved=!1,this._name=(e=>{var t="";return e.token&&(t=e.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),e.persistence_name?e.persistence_name:"leanbase_"+t})(e),this._storage=this._buildStorage(e),this.load(),e.debug&&je.info("Persistence loaded",e.persistence,r({},this.props)),this.update_config(e,e,t),this.save()}isDisabled(){return!!this._disabled}_buildStorage(e){-1===br.indexOf(e.persistence.toLowerCase())&&(je.info("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var t=e.persistence.toLowerCase();return"localstorage"===t&&Ze._is_supported()?Ze:"localstorage+cookie"===t&&tt._is_supported()?tt:"sessionstorage"===t&&nt._is_supported()?nt:"memory"===t?it:"cookie"===t?Ye:tt._is_supported()?tt:Ye}properties(){var e={};return ye(this.props,(function(t,r){if(r===Ae&&A(t))for(var i=Object.keys(t),s=0;s<i.length;s++)e["$feature/"+i[s]]=t[i[s]];else o=r,a=!1,(M(n=Ne)?a:de&&n.indexOf===de?-1!=n.indexOf(o):(ye(n,(function(e){if(a||(a=e===o))return le})),a))||(e[r]=t);var n,o,a})),e}load(){if(!this._disabled){var e=this._storage._parse(this._name);e&&(this.props=be({},e))}}save(){this._disabled||this._storage._set(this._name,this.props,this._expire_days,this._cross_subdomain,this._secure,this._config.debug)}remove(){this._storage._remove(this._name,!1),this._storage._remove(this._name,!0)}clear(){this.remove(),this.props={}}register_once(e,t,r){if(A(e)){O(t)&&(t="None"),this._expire_days=O(r)?this._default_expiry:r;var i=!1;if(ye(e,((e,r)=>{this.props.hasOwnProperty(r)&&this.props[r]!==t||(this.props[r]=e,i=!0)})),i)return this.save(),!0}return!1}register(e,t){if(A(e)){this._expire_days=O(t)?this._default_expiry:t;var r=!1;if(ye(e,((t,i)=>{e.hasOwnProperty(i)&&this.props[i]!==t&&(this.props[i]=t,r=!0)})),r)return this.save(),!0}return!1}unregister(e){e in this.props&&(delete this.props[e],this.save())}update_campaign_params(){if(!this._campaign_params_saved){var e=dr(this._config.custom_campaign_params,this._config.mask_personal_data_properties,this._config.custom_personal_data_properties);R(Se(e))||this.register(e),this._campaign_params_saved=!0}}update_search_keyword(){var e;this.register((e=null==fe?void 0:fe.referrer)?hr(e):{})}update_referrer_info(){var e;this.register_once({$referrer:fr(),$referring_domain:null!=fe&&fe.referrer&&(null==(e=ot(fe.referrer))?void 0:e.host)||"$direct"},void 0)}set_initial_person_info(){var e,t,r,i;this.props[Oe]||this.props[Te]||this.register_once({[Me]:(e=this._config.mask_personal_data_properties,t=this._config.custom_personal_data_properties,r=e?we([],ar,t||[]):[],i=null==ve?void 0:ve.href.substring(0,1e3),{r:fr().substring(0,1e3),u:i?lt(i,r,ur):void 0})},void 0)}get_initial_props(){var e={};ye([Te,Oe],(t=>{var r=this.props[t];r&&ye(r,(function(t,r){e["$initial_"+F(r)]=t}))}));var t=this.props[Me];if(t){var r=vr(t);be(e,r)}return e}safe_merge(e){return ye(this.props,(function(t,r){r in e||(e[r]=t)})),e}update_config(e,t,r){if(this._default_expiry=this._expire_days=e.cookie_expiration,this.set_disabled(e.disable_persistence||!!r),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),e.persistence!==t.persistence){var i=this._buildStorage(e),s=this.props;this.clear(),this._storage=i,this.props=s,this.save()}}set_disabled(e){if(this._disabled=e,this._disabled)return this.remove();this.save()}set_cross_subdomain(e){e!==this._cross_subdomain&&(this._cross_subdomain=e,this.remove(),this.save())}set_secure(e){e!==this._secure&&(this._secure=e,this.remove(),this.save())}set_event_timer(e,t){var r=this.props[Ie]||{};r[e]=t,this.props[Ie]=r,this.save()}remove_event_timer(e){var t=(this.props[Ie]||{})[e];return O(t)||(delete this.props[Ie][e],this.save()),t}get_property(e){return this.props[e]}set_property(e,t){this.props[e]=t,this.save()}}function Pr(e){return!!e&&1===e.nodeType}function Fr(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function Sr(e){return!!e&&3===e.nodeType}function xr(e){return!!e&&11===e.nodeType}function Er(e){return e?P(e).split(/\s+/):[]}function $r(e){var t,r=null==(t=window)?void 0:t.location.href;return!!(r&&e&&e.some((e=>r.match(e))))}function Ir(e){var t="";switch(typeof e.className){case"string":t=e.className;break;case"object":t=(e.className&&"baseVal"in e.className?e.className.baseVal:null)||e.getAttribute("class")||"";break;default:t=""}return Er(t)}function Cr(e){return D(e)?null:P(e).split(/(\s+)/).filter((e=>Gr(e))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function kr(e){var t="";return Lr(e)&&!jr(e)&&e.childNodes&&e.childNodes.length&&ye(e.childNodes,(function(e){var r;Sr(e)&&e.textContent&&(t+=null!==(r=Cr(e.textContent))&&void 0!==r?r:"")})),P(t)}var Ar=["a","button","form","input","select","textarea","label"];function Rr(e,t){if(O(t))return!0;var r,i=function(e){if(t.some((t=>e.matches(t))))return{v:!0}};for(var s of e)if(r=i(s))return r.v;return!1}function Or(e){var t=e.parentNode;return!(!t||!Pr(t))&&t}var Tr=[".ph-no-rageclick",".ph-no-capture"];var Mr=e=>!e||Fr(e,"html")||!Pr(e),Dr=(e,t)=>{if(!window||Mr(e))return{parentIsUsefulElement:!1,targetElementList:[]};for(var r=!1,i=[e],s=e;s.parentNode&&!Fr(s,"body");)if(xr(s.parentNode))i.push(s.parentNode.host),s=s.parentNode.host;else{var n=Or(s);if(!n)break;if(t||Ar.indexOf(n.tagName.toLowerCase())>-1)r=!0;else{var o=window.getComputedStyle(n);o&&"pointer"===o.getPropertyValue("cursor")&&(r=!0)}i.push(n),s=n}return{parentIsUsefulElement:r,targetElementList:i}};function Nr(e,t,r,i,s){var n,o,a,l;if(void 0===r&&(r=void 0),!window||Mr(e))return!1;if(null!=(n=r)&&n.url_allowlist&&!$r(r.url_allowlist))return!1;if(null!=(o=r)&&o.url_ignorelist&&$r(r.url_ignorelist))return!1;if(null!=(a=r)&&a.dom_event_allowlist){var u=r.dom_event_allowlist;if(u&&!u.some((e=>t.type===e)))return!1}var{parentIsUsefulElement:c,targetElementList:d}=Dr(e,i);if(!function(e,t){var r=null==t?void 0:t.element_allowlist;if(O(r))return!0;var i,s=function(e){if(r.some((t=>e.tagName.toLowerCase()===t)))return{v:!0}};for(var n of e)if(i=s(n))return i.v;return!1}(d,r))return!1;if(!Rr(d,null==(l=r)?void 0:l.css_selector_allowlist))return!1;var p=window.getComputedStyle(e);if(p&&"pointer"===p.getPropertyValue("cursor")&&"click"===t.type)return!0;var h=e.tagName.toLowerCase();switch(h){case"html":return!1;case"form":return(s||["submit"]).indexOf(t.type)>=0;case"input":case"select":case"textarea":return(s||["change","click"]).indexOf(t.type)>=0;default:return c?(s||["click"]).indexOf(t.type)>=0:(s||["click"]).indexOf(t.type)>=0&&(Ar.indexOf(h)>-1||"true"===e.getAttribute("contenteditable"))}}function Lr(e){for(var t=e;t.parentNode&&!Fr(t,"body");t=t.parentNode){var r=Ir(t);if(w(r,"ph-sensitive")||w(r,"ph-no-capture"))return!1}if(w(Ir(e),"ph-include"))return!0;var i=e.type||"";if(T(i))switch(i.toLowerCase()){case"hidden":case"password":return!1}var s=e.name||e.id||"";if(T(s)){if(/^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,"")))return!1}return!0}function jr(e){return!!(Fr(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||Fr(e,"select")||Fr(e,"textarea")||"true"===e.getAttribute("contenteditable"))}var Br="(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})",Ur=new RegExp("^(?:"+Br+")$"),qr=new RegExp(Br),zr="\\d{3}-?\\d{2}-?\\d{4}",Vr=new RegExp("^("+zr+")$"),Hr=new RegExp("("+zr+")");function Gr(e,t){if(void 0===t&&(t=!0),D(e))return!1;if(T(e)){if(e=P(e),(t?Ur:qr).test((e||"").replace(/[- ]/g,"")))return!1;if((t?Vr:Hr).test(e))return!1}return!0}function Kr(e){var t=kr(e);return Gr(t=(t+" "+Wr(e)).trim())?t:""}function Wr(e){var t="";return e&&e.childNodes&&e.childNodes.length&&ye(e.childNodes,(function(e){var r;if(e&&"span"===(null==(r=e.tagName)?void 0:r.toLowerCase()))try{var i=kr(e);t=(t+" "+i).trim(),e.childNodes&&e.childNodes.length&&(t=(t+" "+Wr(e)).trim())}catch(e){je.error("[AutoCapture]",e)}})),t}function Jr(e){return function(e){var t=e.map((e=>{var t,i,s="";if(e.tag_name&&(s+=e.tag_name),e.attr_class)for(var n of(e.attr_class.sort(),e.attr_class))s+="."+n.replace(/"/g,"");var o=r({},e.text?{text:e.text}:{},{"nth-child":null!==(t=e.nth_child)&&void 0!==t?t:0,"nth-of-type":null!==(i=e.nth_of_type)&&void 0!==i?i:0},e.href?{href:e.href}:{},e.attr_id?{attr_id:e.attr_id}:{},e.attributes),a={};return Pe(o).sort(((e,t)=>{var[r]=e,[i]=t;return r.localeCompare(i)})).forEach((e=>{var[t,r]=e;return a[Qr(t.toString())]=Qr(r.toString())})),s+=":",s+=Pe(a).map((e=>{var[t,r]=e;return t+'="'+r+'"'})).join("")}));return t.join(";")}(function(e){return e.map((e=>{var t,r,i={text:null==(t=e.$el_text)?void 0:t.slice(0,400),tag_name:e.tag_name,href:null==(r=e.attr__href)?void 0:r.slice(0,2048),attr_class:Yr(e),attr_id:e.attr__id,nth_child:e.nth_child,nth_of_type:e.nth_of_type,attributes:{}};return Pe(e).filter((e=>{var[t]=e;return 0===t.indexOf("attr__")})).forEach((e=>{var[t,r]=e;return i.attributes[t]=r})),i}))}(e))}function Qr(e){return e.replace(/"|\\"/g,'\\"')}function Yr(e){var t=e.attr__class;return t?C(t)?t:Er(t):void 0}class Xr{constructor(){this.clicks=[]}isRageClick(e,t,r){var i=this.clicks[this.clicks.length-1];if(i&&Math.abs(e-i.x)+Math.abs(t-i.y)<30&&r-i.timestamp<1e3){if(this.clicks.push({x:e,y:t,timestamp:r}),3===this.clicks.length)return!0}else this.clicks=[{x:e,y:t,timestamp:r}];return!1}}var Zr,ei="$copy_autocapture";function ti(e,t){return t.length>e?t.slice(0,e)+"...":t}function ri(e){if(e.previousElementSibling)return e.previousElementSibling;var t=e;do{t=t.previousSibling}while(t&&!Pr(t));return t}function ii(e,t,r,i){var s=e.tagName.toLowerCase(),n={tag_name:s};Ar.indexOf(s)>-1&&!r&&("a"===s.toLowerCase()||"button"===s.toLowerCase()?n.$el_text=ti(1024,Kr(e)):n.$el_text=ti(1024,kr(e)));var o=Ir(e);o.length>0&&(n.classes=o.filter((function(e){return""!==e}))),ye(e.attributes,(function(r){var s;if((!jr(e)||-1!==["name","id","class","aria-label"].indexOf(r.name))&&((null==i||!i.includes(r.name))&&!t&&Gr(r.value)&&(s=r.name,!T(s)||"_ngcontent"!==s.substring(0,10)&&"_nghost"!==s.substring(0,7)))){var o=r.value;"class"===r.name&&(o=Er(o).join(" ")),n["attr__"+r.name]=ti(1024,o)}}));for(var a=1,l=1,u=e;u=ri(u);)a++,u.tagName===e.tagName&&l++;return n.nth_child=a,n.nth_of_type=l,n}function si(e,t){for(var r,i,{e:s,maskAllElementAttributes:n,maskAllText:o,elementAttributeIgnoreList:a,elementsChainAsString:l}=t,u=[e],c=e;c.parentNode&&!Fr(c,"body");)xr(c.parentNode)?(u.push(c.parentNode.host),c=c.parentNode.host):(u.push(c.parentNode),c=c.parentNode);var d,p=[],h={},g=!1,f=!1;if(ye(u,(e=>{var t=Lr(e);"a"===e.tagName.toLowerCase()&&(g=e.getAttribute("href"),g=t&&g&&Gr(g)&&g),w(Ir(e),"ph-no-capture")&&(f=!0),p.push(ii(e,n,o,a));var r=function(e){if(!Lr(e))return{};var t={};return ye(e.attributes,(function(e){if(e.name&&0===e.name.indexOf("data-ph-capture-attribute")){var r=e.name.replace("data-ph-capture-attribute-",""),i=e.value;r&&i&&Gr(i)&&(t[r]=i)}})),t}(e);be(h,r)})),f)return{props:{},explicitNoCapture:f};if(o||("a"===e.tagName.toLowerCase()||"button"===e.tagName.toLowerCase()?p[0].$el_text=Kr(e):p[0].$el_text=kr(e)),g){var v,_;p[0].attr__href=g;var m=null==(v=ot(g))?void 0:v.host,y=null==pe||null==(_=pe.location)?void 0:_.host;m&&y&&m!==y&&(d=g)}return{props:be({$event_type:s.type,$ce_version:1},l?{}:{$elements:p},{$elements_chain:Jr(p)},null!=(r=p[0])&&r.$el_text?{$el_text:null==(i=p[0])?void 0:i.$el_text}:{},d&&"click"===s.type?{$external_click_url:d}:{},h)}}!function(e){e.GZipJS="gzip-js",e.Base64="base64"}(Zr||(Zr={}));class ni{constructor(e){this._initialized=!1,this._isDisabledServerSide=null,this.rageclicks=new Xr,this._elementsChainAsString=!1,this.instance=e,this._elementSelectors=null}get _config(){var e,t,r=A(this.instance.config.autocapture)?this.instance.config.autocapture:{};return r.url_allowlist=null==(e=r.url_allowlist)?void 0:e.map((e=>new RegExp(e))),r.url_ignorelist=null==(t=r.url_ignorelist)?void 0:t.map((e=>new RegExp(e))),r}_addDomEventHandlers(){if(this.isBrowserSupported()){if(pe&&fe){var e=e=>{e=e||(null==pe?void 0:pe.event);try{this._captureEvent(e)}catch(e){je.error("Failed to capture event",e)}};if(Fe(fe,"submit",e,{capture:!0}),Fe(fe,"change",e,{capture:!0}),Fe(fe,"click",e,{capture:!0}),this._config.capture_copied_text){var t=e=>{e=e||(null==pe?void 0:pe.event),this._captureEvent(e,ei)};Fe(fe,"copy",t,{capture:!0}),Fe(fe,"cut",t,{capture:!0})}}}else je.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this._initialized&&(this._addDomEventHandlers(),this._initialized=!0)}onRemoteConfig(e){e.elementsChainAsString&&(this._elementsChainAsString=e.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[Ce]:!!e.autocapture_opt_out}),this._isDisabledServerSide=!!e.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(e){this._elementSelectors=e}getElementSelectors(e){var t,r=[];return null==(t=this._elementSelectors)||t.forEach((t=>{var i=null==fe?void 0:fe.querySelectorAll(t);null==i||i.forEach((i=>{e===i&&r.push(t)}))})),r}get isEnabled(){var e,t,r=null==(e=this.instance.persistence)?void 0:e.props[Ce],i=this._isDisabledServerSide;if(M(i)&&!L(r))return!1;var s=null!==(t=this._isDisabledServerSide)&&void 0!==t?t:!!r;return!!this.instance.config.autocapture&&!s}_captureEvent(e,t){if(void 0===t&&(t="$autocapture"),this.isEnabled){var r,i=function(e){return O(e.target)?e.srcElement||null:null!=(t=e.target)&&t.shadowRoot?e.composedPath()[0]||null:e.target||null;var t}(e);if(Sr(i)&&(i=i.parentNode||null),"$autocapture"===t&&"click"===e.type&&e instanceof MouseEvent)this.instance.config.rageclick&&null!=(r=this.rageclicks)&&r.isRageClick(e.clientX,e.clientY,(new Date).getTime())&&function(e,t){if(!window||Mr(e))return!1;var r,i;if(!1===(r=L(t)?!!t&&Tr:null!==(i=null==t?void 0:t.css_selector_ignorelist)&&void 0!==i?i:Tr))return!1;var{targetElementList:s}=Dr(e,!1);return!Rr(s,r)}(i,this.instance.config.rageclick)&&this._captureEvent(e,"$rageclick");var s=t===ei;if(i&&Nr(i,e,this._config,s,s?["copy","cut"]:void 0)){var{props:n,explicitNoCapture:o}=si(i,{e:e,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this._config.element_attribute_ignorelist,elementsChainAsString:this._elementsChainAsString});if(o)return!1;var a=this.getElementSelectors(i);if(a&&a.length>0&&(n.$element_selectors=a),t===ei){var l,u=Cr(null==pe||null==(l=pe.getSelection())?void 0:l.toString()),c=e.type||"clipboard";if(!u)return!1;n.$selected_content=u,n.$copy_type=c}return this.instance.capture(t,n),!0}}}isBrowserSupported(){return k(null==fe?void 0:fe.querySelectorAll)}}class oi{constructor(e){this._instance=e}doPageView(e,t){var r,i=this._previousPageViewProperties(e,t);return this._currentPageview={pathname:null!==(r=null==pe?void 0:pe.location.pathname)&&void 0!==r?r:"",pageViewId:t,timestamp:e},this._instance.scrollManager.resetContext(),i}doPageLeave(e){var t;return this._previousPageViewProperties(e,null==(t=this._currentPageview)?void 0:t.pageViewId)}doEvent(){var e;return{$pageview_id:null==(e=this._currentPageview)?void 0:e.pageViewId}}_previousPageViewProperties(e,t){var r=this._currentPageview;if(!r)return{$pageview_id:t};var i={$pageview_id:t,$prev_pageview_id:r.pageViewId},s=this._instance.scrollManager.getContext();if(s&&!this._instance.config.disable_scroll_properties){var{maxScrollHeight:n,lastScrollY:o,maxScrollY:a,maxContentHeight:l,lastContentY:u,maxContentY:c}=s;if(!(O(n)||O(o)||O(a)||O(l)||O(u)||O(c))){n=Math.ceil(n),o=Math.ceil(o),a=Math.ceil(a),l=Math.ceil(l),u=Math.ceil(u),c=Math.ceil(c);var d=n<=1?1:U(o/n,0,1,je),p=n<=1?1:U(a/n,0,1,je),h=l<=1?1:U(u/l,0,1,je),g=l<=1?1:U(c/l,0,1,je);i=be(i,{$prev_pageview_last_scroll:o,$prev_pageview_last_scroll_percentage:d,$prev_pageview_max_scroll:a,$prev_pageview_max_scroll_percentage:p,$prev_pageview_last_content:u,$prev_pageview_last_content_percentage:h,$prev_pageview_max_content:c,$prev_pageview_max_content_percentage:g})}}return r.pathname&&(i.$prev_pageview_pathname=r.pathname),r.timestamp&&(i.$prev_pageview_duration=(e.getTime()-r.timestamp.getTime())/1e3),i}}class ai{constructor(e){this._instance=e,this._updateScrollData=()=>{var e,t,r,i;this._context||(this._context={});var s=this.scrollElement(),n=this.scrollY(),o=s?Math.max(0,s.scrollHeight-s.clientHeight):0,a=n+((null==s?void 0:s.clientHeight)||0),l=(null==s?void 0:s.scrollHeight)||0;this._context.lastScrollY=Math.ceil(n),this._context.maxScrollY=Math.max(n,null!==(e=this._context.maxScrollY)&&void 0!==e?e:0),this._context.maxScrollHeight=Math.max(o,null!==(t=this._context.maxScrollHeight)&&void 0!==t?t:0),this._context.lastContentY=a,this._context.maxContentY=Math.max(a,null!==(r=this._context.maxContentY)&&void 0!==r?r:0),this._context.maxContentHeight=Math.max(l,null!==(i=this._context.maxContentHeight)&&void 0!==i?i:0)}}getContext(){return this._context}resetContext(){var e=this._context;return setTimeout(this._updateScrollData,0),e}startMeasuringScrollPosition(){Fe(pe,"scroll",this._updateScrollData,{capture:!0}),Fe(pe,"scrollend",this._updateScrollData,{capture:!0}),Fe(pe,"resize",this._updateScrollData)}scrollElement(){if(!this._instance.config.scroll_root_selector)return null==pe?void 0:pe.document.documentElement;var e=C(this._instance.config.scroll_root_selector)?this._instance.config.scroll_root_selector:[this._instance.config.scroll_root_selector];for(var t of e){var r=null==pe?void 0:pe.document.querySelector(t);if(r)return r}}scrollY(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollTop||0}return pe&&(pe.scrollY||pe.pageYOffset||pe.document.documentElement.scrollTop)||0}scrollX(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollLeft||0}return pe&&(pe.scrollX||pe.pageXOffset||pe.document.documentElement.scrollLeft)||0}}var li=["amazonbot","amazonproductbot","app.hypefactors.com","applebot","archive.org_bot","awariobot","backlinksextendedbot","baiduspider","bingbot","bingpreview","chrome-lighthouse","dataforseobot","deepscan","duckduckbot","facebookexternal","facebookcatalog","http://yandex.com/bots","hubspot","ia_archiver","leikibot","linkedinbot","meta-externalagent","mj12bot","msnbot","nessus","petalbot","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"],ui=function(e,t){if(!e)return!1;var r=e.toLowerCase();return li.concat(t||[]).some((e=>{var t=e.toLowerCase();return-1!==r.indexOf(t)}))},ci=()=>{var e;return{host:"https://i.leanbase.co",token:"",autocapture:!0,rageclick:!0,persistence:"localStorage+cookie",capture_pageview:!0,capture_pageleave:"if_capture_pageview",persistence_name:"",mask_all_element_attributes:!1,cookie_expiration:365,cross_subdomain_cookie:Ee(null==fe?void 0:fe.location),custom_campaign_params:[],custom_personal_data_properties:[],disable_persistence:!1,mask_personal_data_properties:!1,secure_cookie:"https:"===(null==(e=window)||null==(e=e.location)?void 0:e.protocol),mask_all_text:!1,bootstrap:{},session_idle_timeout_seconds:1800,save_campaign_params:!0,save_referrer:!0,opt_out_useragent_filter:!1,properties_string_max_length:65535,loaded:()=>{}}};class di extends ae{constructor(e,t){var r=be(ci(),t||{},{token:e});super(e,r),this.personProcessingSetOncePropertiesSent=!1,this.isLoaded=!1,this.config=r,this.visibilityStateListener=null,this.initialPageviewCaptured=!1,this.scrollManager=new ai(this),this.pageViewManager=new oi(this),this.init(e,r)}init(e,t){var r,i;this.setConfig(be(ci(),t,{token:e})),this.isLoaded=!0,this.persistence=new wr(this.config),this.replayAutocapture=new ni(this),this.replayAutocapture.startIfEnabled(),!1!==this.config.preloadFeatureFlags&&this.reloadFeatureFlags(),null==(r=(i=this.config).loaded)||r.call(i,this),this.config.capture_pageview&&setTimeout((()=>{"always"===this.config.cookieless_mode&&this.captureInitialPageview()}),1),Fe(fe,"DOMContentLoaded",(()=>{this.loadRemoteConfig()})),Fe(window,"onpagehide"in self?"pagehide":"unload",this.capturePageLeave.bind(this),{passive:!1})}captureInitialPageview(){fe&&("visible"===fe.visibilityState?this.initialPageviewCaptured||(this.initialPageviewCaptured=!0,this.capture("$pageview",{title:fe.title}),this.visibilityStateListener&&(fe.removeEventListener("visibilitychange",this.visibilityStateListener),this.visibilityStateListener=null)):this.visibilityStateListener||(this.visibilityStateListener=this.captureInitialPageview.bind(this),Fe(fe,"visibilitychange",this.visibilityStateListener)))}capturePageLeave(){var{capture_pageleave:e,capture_pageview:t}=this.config;!0!==e&&("if_capture_pageview"!==e||!0!==t&&"history_change"!==t)||this.capture("$pageleave")}loadRemoteConfig(){var e=this;return t((function*(){if(!e.isRemoteConfigLoaded){var t=yield e.reloadRemoteConfigAsync();t&&e.onRemoteConfig(t)}}))()}onRemoteConfig(e){var t;fe&&fe.body?(this.isRemoteConfigLoaded=!0,null==(t=this.replayAutocapture)||t.onRemoteConfig(e)):setTimeout((()=>{this.onRemoteConfig(e)}),500)}fetch(e,t){var r="undefined"!=typeof fetch?fetch:void 0!==globalThis.fetch?globalThis.fetch:void 0;return r?r(e,t):Promise.reject(new Error("Fetch API is not available in this environment."))}setConfig(e){var t,i,s=r({},this.config);A(e)&&(be(this.config,e),null==(t=this.persistence)||t.update_config(this.config,s),null==(i=this.replayAutocapture)||i.startIfEnabled());var n="sessionStorage"===this.config.persistence||"memory"===this.config.persistence;this.sessionPersistence=n?this.persistence:new wr(r({},this.config,{persistence:"sessionStorage"}))}getLibraryId(){return"leanbase"}getLibraryVersion(){return nr.LIB_VERSION}getCustomUserAgent(){}getPersistedProperty(e){var t;return null==(t=this.persistence)?void 0:t.get_property(e)}setPersistedProperty(e,t){var r;null==(r=this.persistence)||r.set_property(e,t)}calculateEventProperties(e,t,i,s,n){var o;if(!this.persistence||!this.sessionPersistence)return t;i=i||new Date;var a,l=n||null==(o=this.persistence)?void 0:o.remove_event_timer(e),u=r({},t);if(u.token=this.config.token,"always"!=this.config.cookieless_mode&&"on_reject"!=this.config.cookieless_mode||(u.$cookieless_mode=!0),"$snapshot"===e){var c=r({},this.persistence.properties());return u.distinct_id=c.distinct_id,(!T(u.distinct_id)&&!N(u.distinct_id)||(a=u.distinct_id,T(a)&&0===a.trim().length))&&je.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),u}var d=yr(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties);if(this.sessionManager){var{sessionId:p,windowId:h}=this.sessionManager.checkAndGetSessionAndWindowId(n,i.getTime());u.$session_id=p,u.$window_id=h}this.sessionPropsManager&&be(u,this.sessionPropsManager.getSessionProps());var g=this.pageViewManager.doEvent();if("$pageview"!==e||n||(g=this.pageViewManager.doPageView(i,s)),"$pageleave"!==e||n||(g=this.pageViewManager.doPageLeave(i)),u=be(u,g),"$pageview"===e&&fe&&(u.title=fe.title),!O(l)){var f=i.getTime()-l;u.$duration=parseFloat((f/1e3).toFixed(3))}return _e&&this.config.opt_out_useragent_filter&&(u.$browser_type=function(e,t){if(!e)return!1;var r=e.userAgent;if(r&&ui(r,t))return!0;try{var i=null==e?void 0:e.userAgentData;if(null!=i&&i.brands&&i.brands.some((e=>ui(null==e?void 0:e.brand,t))))return!0}catch(e){}return!!e.webdriver}(ge,[])?"bot":"browser"),(u=be({},d,this.persistence.properties(),this.sessionPersistence.properties(),u)).$is_identified=this.isIdentified(),u}isIdentified(){var e,t;return"identified"===(null==(e=this.persistence)?void 0:e.get_property(Re))||"identified"===(null==(t=this.sessionPersistence)?void 0:t.get_property(Re))}calculateSetOnceProperties(e){var t;if(!this.persistence)return e;if(this.personProcessingSetOncePropertiesSent)return e;var r=this.persistence.get_initial_props(),i=null==(t=this.sessionPropsManager)?void 0:t.getSetOnceProps(),s=be({},r,i||{},e||{});return this.personProcessingSetOncePropertiesSent=!0,R(s)?void 0:s}capture(e,t,i){if(this.isLoaded&&this.sessionPersistence&&this.persistence)if(!O(e)&&T(e)){null!=t&&t.$current_url&&!T(null==t?void 0:t.$current_url)&&(je.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),null==t||delete t.$current_url),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&this.sessionPersistence.update_campaign_params(),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();var s=new Date,n=(null==i?void 0:i.timestamp)||s,o=Ge(),a={uuid:o,event:e,properties:this.calculateEventProperties(e,t||{},n,o)};(null==i?void 0:i.$set)&&(a.$set=null==i?void 0:i.$set);var l=this.calculateSetOnceProperties(null==i?void 0:i.$set_once);l&&(a.$set_once=l),(a=$e(a,null!=i&&i._noTruncate?null:this.config.properties_string_max_length)).timestamp=n,O(null==i?void 0:i.timestamp)||(a.properties.$event_time_override_provided=!0,a.properties.$event_time_override_system_time=s);var u=r({},a.properties.$set,a.$set);R(u)||this.setPersonPropertiesForFlags(u),super.capture(a.event,a.properties,i)}else je.error("No event name provided to posthog.capture")}identify(e,t,r){super.identify(e,t,r)}destroy(){var e;null==(e=this.persistence)||e.clear()}}export{di as Leanbase};
|
|
1
|
+
function e(e,t,r,i,s,n,o){try{var a=e[n](o),l=a.value}catch(e){return void r(e)}a.done?t(l):Promise.resolve(l).then(i,s)}function t(t){return function(){var r=this,i=arguments;return new Promise((function(s,n){var o=t.apply(r,i);function a(t){e(o,s,n,a,l,"next",t)}function l(t){e(o,s,n,a,l,"throw",t)}a(void 0)}))}}function r(){return r=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)({}).hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},r.apply(null,arguments)}var i=e=>{if("flags"in e)return r({},e,{featureFlags:n(e.flags),featureFlagPayloads:o(e.flags)});var t,i=null!==(t=e.featureFlags)&&void 0!==t?t:{},a=Object.fromEntries(Object.entries(e.featureFlagPayloads||{}).map((e=>{var[t,r]=e;return[t,l(r)]}))),u=Object.fromEntries(Object.entries(i).map((e=>{var[t,r]=e;return[t,s(t,r,a[t])]})));return r({},e,{featureFlags:i,featureFlagPayloads:a,flags:u})};function s(e,t,r){return{key:e,enabled:"string"==typeof t||t,variant:"string"==typeof t?t:void 0,reason:void 0,metadata:{id:void 0,version:void 0,payload:r?JSON.stringify(r):void 0,description:void 0}}}var n=e=>Object.fromEntries(Object.entries(null!=e?e:{}).map((e=>{var[t,r]=e;return[t,a(r)]})).filter((e=>{var[,t]=e;return void 0!==t}))),o=e=>{var t=null!=e?e:{};return Object.fromEntries(Object.keys(t).filter((e=>{var r=t[e];return r.enabled&&r.metadata&&void 0!==r.metadata.payload})).map((e=>{var r,i=null==(r=t[e].metadata)?void 0:r.payload;return[e,i?l(i):void 0]})))},a=e=>{var t;return void 0===e?void 0:null!==(t=e.variant)&&void 0!==t?t:e.enabled},l=e=>{if("string"!=typeof e)return e;try{return JSON.parse(e)}catch(t){return e}},u=(e,t)=>{var r=[...new Set([...Object.keys(null!=e?e:{}),...Object.keys(null!=t?t:{})])].filter((r=>!!e[r]||!!t[r])).reduce(((t,r)=>{var i;return t[r]=null===(i=e[r])||void 0===i||i,t}),{});return i({featureFlags:r,featureFlagPayloads:null!=t?t:{}})};function c(e){return"string"==typeof e||e}function d(e){return"string"==typeof e?e:void 0}var h="0123456789abcdef";let p=class e{constructor(e){this.bytes=e}static ofInner(t){if(16===t.length)return new e(t);throw new TypeError("not 128-bit length")}static fromFieldsV7(t,r,i,s){if(!Number.isInteger(t)||!Number.isInteger(r)||!Number.isInteger(i)||!Number.isInteger(s)||t<0||r<0||i<0||s<0||t>0xffffffffffff||r>4095||i>1073741823||s>4294967295)throw new RangeError("invalid field value");var n=new Uint8Array(16);return n[0]=t/Math.pow(2,40),n[1]=t/Math.pow(2,32),n[2]=t/Math.pow(2,24),n[3]=t/Math.pow(2,16),n[4]=t/256,n[5]=t,n[6]=112|r>>>8,n[7]=r,n[8]=128|i>>>24,n[9]=i>>>16,n[10]=i>>>8,n[11]=i,n[12]=s>>>24,n[13]=s>>>16,n[14]=s>>>8,n[15]=s,new e(n)}static parse(t){var r,i,s,n,o;switch(t.length){case 32:o=null==(r=/^[0-9a-f]{32}$/i.exec(t))?void 0:r[0];break;case 36:o=null==(i=/^([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(t))?void 0:i.slice(1,6).join("");break;case 38:o=null==(s=/^\{([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})\}$/i.exec(t))?void 0:s.slice(1,6).join("");break;case 45:o=null==(n=/^urn:uuid:([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(t))?void 0:n.slice(1,6).join("")}if(o){for(var a=new Uint8Array(16),l=0;l<16;l+=4){var u=parseInt(o.substring(2*l,2*l+8),16);a[l+0]=u>>>24,a[l+1]=u>>>16,a[l+2]=u>>>8,a[l+3]=u}return new e(a)}throw new SyntaxError("could not parse UUID string")}toString(){for(var e="",t=0;t<this.bytes.length;t++)e+=h.charAt(this.bytes[t]>>>4),e+=h.charAt(15&this.bytes[t]),3!==t&&5!==t&&7!==t&&9!==t||(e+="-");return e}toHex(){for(var e="",t=0;t<this.bytes.length;t++)e+=h.charAt(this.bytes[t]>>>4),e+=h.charAt(15&this.bytes[t]);return e}toJSON(){return this.toString()}getVariant(){var e=this.bytes[8]>>>4;if(e<0)throw new Error("unreachable");if(e<=7)return this.bytes.every((e=>0===e))?"NIL":"VAR_0";if(e<=11)return"VAR_10";if(e<=13)return"VAR_110";if(e<=15)return this.bytes.every((e=>255===e))?"MAX":"VAR_RESERVED";throw new Error("unreachable")}getVersion(){return"VAR_10"===this.getVariant()?this.bytes[6]>>>4:void 0}clone(){return new e(this.bytes.slice(0))}equals(e){return 0===this.compareTo(e)}compareTo(e){for(var t=0;t<16;t++){var r=this.bytes[t]-e.bytes[t];if(0!==r)return Math.sign(r)}return 0}},g=class{constructor(e){this.timestamp=0,this.counter=0,this.random=null!=e?e:_()}generate(){return this.generateOrResetCore(Date.now(),1e4)}generateOrAbort(){return this.generateOrAbortCore(Date.now(),1e4)}generateOrResetCore(e,t){var r=this.generateOrAbortCore(e,t);return void 0===r&&(this.timestamp=0,r=this.generateOrAbortCore(e,t)),r}generateOrAbortCore(e,t){if(!Number.isInteger(e)||e<1||e>0xffffffffffff)throw new RangeError("`unixTsMs` must be a 48-bit positive integer");if(t<0||t>0xffffffffffff)throw new RangeError("`rollbackAllowance` out of reasonable range");if(e>this.timestamp)this.timestamp=e,this.resetCounter();else{if(!(e+t>=this.timestamp))return;this.counter++,this.counter>4398046511103&&(this.timestamp++,this.resetCounter())}return p.fromFieldsV7(this.timestamp,Math.trunc(this.counter/Math.pow(2,30)),this.counter&Math.pow(2,30)-1,this.random.nextUint32())}resetCounter(){this.counter=1024*this.random.nextUint32()+(1023&this.random.nextUint32())}generateV4(){var e=new Uint8Array(Uint32Array.of(this.random.nextUint32(),this.random.nextUint32(),this.random.nextUint32(),this.random.nextUint32()).buffer);return e[6]=64|e[6]>>>4,e[8]=128|e[8]>>>2,p.ofInner(e)}};var f,_=()=>({nextUint32:()=>65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random())}),v=()=>m().toString(),m=()=>(f||(f=new g)).generate(),y=function(e){return e.AnonymousId="anonymous_id",e.DistinctId="distinct_id",e.Props="props",e.FeatureFlagDetails="feature_flag_details",e.FeatureFlags="feature_flags",e.FeatureFlagPayloads="feature_flag_payloads",e.BootstrapFeatureFlagDetails="bootstrap_feature_flag_details",e.BootstrapFeatureFlags="bootstrap_feature_flags",e.BootstrapFeatureFlagPayloads="bootstrap_feature_flag_payloads",e.OverrideFeatureFlags="override_feature_flags",e.Queue="queue",e.OptedOut="opted_out",e.SessionId="session_id",e.SessionStartTimestamp="session_start_timestamp",e.SessionLastTimestamp="session_timestamp",e.PersonProperties="person_properties",e.GroupProperties="group_properties",e.InstalledAppBuild="installed_app_build",e.InstalledAppVersion="installed_app_version",e.SessionReplay="session_replay",e.SurveyLastSeenDate="survey_last_seen_date",e.SurveysSeen="surveys_seen",e.Surveys="surveys",e.RemoteConfig="remote_config",e.FlagsEndpointWasHit="flags_endpoint_was_hit",e}({}),b=function(e){return e.GZipJS="gzip-js",e.Base64="base64",e}({});function w(e,t){return-1!==e.indexOf(t)}var P=function(e){return e.trim()},S=function(e){return e.replace(/^\$/,"")},I=Array.isArray,F=Object.prototype,x=F.hasOwnProperty,E=F.toString,k=I||function(e){return"[object Array]"===E.call(e)},C=e=>"function"==typeof e,A=e=>e===Object(e)&&!k(e),O=e=>{if(A(e)){for(var t in e)if(x.call(e,t))return!1;return!0}return!1},T=e=>void 0===e,R=e=>"[object String]"==E.call(e),D=e=>null===e,M=e=>T(e)||D(e),N=e=>"[object Number]"==E.call(e),L=e=>"[object Boolean]"===E.call(e),j=e=>e instanceof FormData,U=e=>e instanceof Error,B=[!0,"true",1,"1","yes"],q=e=>w(B,e),H=[!1,"false",0,"0","no"];function z(e,t,r,i,s){return t>r&&(i.warn("min cannot be greater than max."),t=r),N(e)?e>r?(i.warn(" cannot be greater than max: "+r+". Using max value instead."),r):e<t?(i.warn(" cannot be less than min: "+t+". Using min value instead."),t):e:(i.warn(" must be a number. using max or fallback. max: "+r+", fallback: "+s),z(s||r,t,r,i))}class G{add(e){var t=v();return this.promiseByIds[t]=e,e.catch((()=>{})).finally((()=>{delete this.promiseByIds[t]})),e}join(){var e=this;return t((function*(){for(var t=Object.values(e.promiseByIds),r=t.length;r>0;)yield Promise.all(t),r=(t=Object.values(e.promiseByIds)).length}))()}get length(){return Object.keys(this.promiseByIds).length}constructor(){this.promiseByIds={}}}function V(){return(V=t((function*(e,t){for(var r=null,i=0;i<t.retryCount+1;i++){i>0&&(yield new Promise((e=>setTimeout(e,t.retryDelay))));try{return yield e()}catch(e){if(r=e,!t.retryCheck(e))throw e}}throw r}))).apply(this,arguments)}function K(){return(new Date).toISOString()}function W(e,t){var r=setTimeout(e,t);return(null==r?void 0:r.unref)&&(null==r||r.unref()),r}function J(e){return Promise.all(e.map((e=>(null!=e?e:Promise.resolve()).then((e=>({status:"fulfilled",value:e})),(e=>({status:"rejected",reason:e}))))))}let Q=class{constructor(){this.events={},this.events={}}on(e,t){return this.events[e]||(this.events[e]=[]),this.events[e].push(t),()=>{this.events[e]=this.events[e].filter((e=>e!==t))}}emit(e,t){for(var r of this.events[e]||[])r(t);for(var i of this.events["*"]||[])i(e,t)}};function Y(e,t){return X.apply(this,arguments)}function X(){return(X=t((function*(e,t){void 0===t&&(t=!0);try{var r=new Blob([e],{type:"text/plain"}).stream().pipeThrough(new CompressionStream("gzip"));return yield new Response(r).blob()}catch(e){return t&&console.error("Failed to gzip compress data",e),null}}))).apply(this,arguments)}var Z=(e,t,r)=>{function i(i){for(var s=arguments.length,n=new Array(s>1?s-1:0),o=1;o<s;o++)n[o-1]=arguments[o];t((()=>{(0,r[i])(e,...n)}))}return{info:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];i("log",...t)},warn:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];i("warn",...t)},error:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];i("error",...t)},critical:function(){for(var t=arguments.length,i=new Array(t),s=0;s<t;s++)i[s]=arguments[s];r.error(e,...i)},createLogger:i=>Z(e+" "+i,t,r)}};function ee(e,t){return Z(e,t,(void 0===r&&(r=console),{log:r.log.bind(r),warn:r.warn.bind(r),error:r.error.bind(r),debug:r.debug.bind(r)}));var r}class te extends Error{constructor(e,t){super("HTTP error while fetching PostHog: status="+e.status+", reqByteLength="+t),this.response=e,this.reqByteLength=t,this.name="PostHogFetchHttpError"}get status(){return this.response.status}get text(){return this.response.text()}get json(){return this.response.json()}}class re extends Error{constructor(e){super("Network error while fetching PostHog",e instanceof Error?{cause:e}:{}),this.error=e,this.name="PostHogFetchNetworkError"}}var ie=(e,t)=>void 0!==t?{[e]:t}:{};function se(e){return ne.apply(this,arguments)}function ne(){return(ne=t((function*(e){if(e instanceof te){var t="";try{t=yield e.text}catch(e){}console.error("Error while flushing PostHog: message="+e.message+", response body="+t,e)}else console.error("Error while flushing PostHog",e);return Promise.resolve()}))).apply(this,arguments)}function oe(e){return"object"==typeof e&&(e instanceof te||e instanceof re)}function ae(e){return"object"==typeof e&&e instanceof te&&413===e.status}var le=function(e){return e.FeatureFlags="feature_flags",e.Recordings="recordings",e}({});class ue{constructor(e,t){var r,i,s,n,o,a,l,u,c,d,h,p,g,f,_,v,m,y,b;void 0===t&&(t={}),this.flushPromise=null,this.shutdownPromise=null,this.promiseQueue=new G,this._events=new Q,this._isInitialized=!1,function(e,t){if(!e||"string"!=typeof e||function(e){return 0===e.trim().length}(e))throw new Error(t)}(e,"You must pass your PostHog project's api key."),this.apiKey=e,this.host=null==(b=t.host||"https://us.i.posthog.com")?void 0:b.replace(/\/+$/,""),this.flushAt=t.flushAt?Math.max(t.flushAt,1):20,this.maxBatchSize=Math.max(this.flushAt,null!==(r=t.maxBatchSize)&&void 0!==r?r:100),this.maxQueueSize=Math.max(this.flushAt,null!==(i=t.maxQueueSize)&&void 0!==i?i:1e3),this.flushInterval=null!==(s=t.flushInterval)&&void 0!==s?s:1e4,this.preloadFeatureFlags=null===(n=t.preloadFeatureFlags)||void 0===n||n,this.defaultOptIn=null===(o=t.defaultOptIn)||void 0===o||o,this.disableSurveys=null!==(a=t.disableSurveys)&&void 0!==a&&a,this._retryOptions={retryCount:null!==(l=t.fetchRetryCount)&&void 0!==l?l:3,retryDelay:null!==(u=t.fetchRetryDelay)&&void 0!==u?u:3e3,retryCheck:oe},this.requestTimeout=null!==(c=t.requestTimeout)&&void 0!==c?c:1e4,this.featureFlagsRequestTimeoutMs=null!==(d=t.featureFlagsRequestTimeoutMs)&&void 0!==d?d:3e3,this.remoteConfigRequestTimeoutMs=null!==(h=t.remoteConfigRequestTimeoutMs)&&void 0!==h?h:3e3,this.disableGeoip=null===(p=t.disableGeoip)||void 0===p||p,this.disabled=null!==(g=t.disabled)&&void 0!==g&&g,this.historicalMigration=null!==(f=null==(_=t)?void 0:_.historicalMigration)&&void 0!==f&&f,this.evaluationEnvironments=null==(v=t)?void 0:v.evaluationEnvironments,this._initPromise=Promise.resolve(),this._isInitialized=!0,this._logger=ee("[PostHog]",this.logMsgIfDebug.bind(this)),this.disableCompression=!("CompressionStream"in globalThis)||null!==(m=null==(y=t)?void 0:y.disableCompression)&&void 0!==m&&m}logMsgIfDebug(e){this.isDebug&&e()}wrap(e){if(!this.disabled)return this._isInitialized?e():void this._initPromise.then((()=>e()));this._logger.warn("The client is disabled")}getCommonEventProperties(){return{$lib:this.getLibraryId(),$lib_version:this.getLibraryVersion()}}get optedOut(){var e;return null!==(e=this.getPersistedProperty(y.OptedOut))&&void 0!==e?e:!this.defaultOptIn}optIn(){var e=this;return t((function*(){e.wrap((()=>{e.setPersistedProperty(y.OptedOut,!1)}))}))()}optOut(){var e=this;return t((function*(){e.wrap((()=>{e.setPersistedProperty(y.OptedOut,!0)}))}))()}on(e,t){return this._events.on(e,t)}debug(e){var t;if(void 0===e&&(e=!0),null==(t=this.removeDebugCallback)||t.call(this),e){var r=this.on("*",((e,t)=>this._logger.info(e,t)));this.removeDebugCallback=()=>{r(),this.removeDebugCallback=void 0}}}get isDebug(){return!!this.removeDebugCallback}get isDisabled(){return this.disabled}buildPayload(e){return{distinct_id:e.distinct_id,event:e.event,properties:r({},e.properties||{},this.getCommonEventProperties())}}addPendingPromise(e){return this.promiseQueue.add(e)}identifyStateless(e,t,i){this.wrap((()=>{var s=r({},this.buildPayload({distinct_id:e,event:"$identify",properties:t}));this.enqueue("identify",s,i)}))}identifyStatelessImmediate(e,i,s){var n=this;return t((function*(){var t=r({},n.buildPayload({distinct_id:e,event:"$identify",properties:i}));yield n.sendImmediate("identify",t,s)}))()}captureStateless(e,t,r,i){this.wrap((()=>{var s=this.buildPayload({distinct_id:e,event:t,properties:r});this.enqueue("capture",s,i)}))}captureStatelessImmediate(e,r,i,s){var n=this;return t((function*(){var t=n.buildPayload({distinct_id:e,event:r,properties:i});yield n.sendImmediate("capture",t,s)}))()}aliasStateless(e,t,i,s){this.wrap((()=>{var n=this.buildPayload({event:"$create_alias",distinct_id:t,properties:r({},i||{},{distinct_id:t,alias:e})});this.enqueue("alias",n,s)}))}aliasStatelessImmediate(e,i,s,n){var o=this;return t((function*(){var t=o.buildPayload({event:"$create_alias",distinct_id:i,properties:r({},s||{},{distinct_id:i,alias:e})});yield o.sendImmediate("alias",t,n)}))()}groupIdentifyStateless(e,t,i,s,n,o){this.wrap((()=>{var a=this.buildPayload({distinct_id:n||"$"+e+"_"+t,event:"$groupidentify",properties:r({$group_type:e,$group_key:t,$group_set:i||{}},o||{})});this.enqueue("capture",a,s)}))}getRemoteConfig(){var e=this;return t((function*(){yield e._initPromise;var t=e.host;"https://us.i.posthog.com"===t?t="https://us-assets.i.posthog.com":"https://eu.i.posthog.com"===t&&(t="https://eu-assets.i.posthog.com");var i=t+"/array/"+e.apiKey+"/config",s={method:"GET",headers:r({},e.getCustomHeaders(),{"Content-Type":"application/json"})};return e.fetchWithRetry(i,s,{retryCount:0},e.remoteConfigRequestTimeoutMs).then((e=>e.json())).catch((t=>{e._logger.error("Remote config could not be loaded",t),e._events.emit("error",t)}))}))()}getFlags(e,s,n,o,a,l){var u=this;return t((function*(){void 0===s&&(s={}),void 0===n&&(n={}),void 0===o&&(o={}),void 0===a&&(a={}),void 0===l&&(l=!0),yield u._initPromise;var t=l?"&config=true":"",c=u.host+"/flags/?v=2"+t,d=r({token:u.apiKey,distinct_id:e,groups:s,person_properties:n,group_properties:o},a);u.evaluationEnvironments&&u.evaluationEnvironments.length>0&&(d.evaluation_environments=u.evaluationEnvironments);var h={method:"POST",headers:r({},u.getCustomHeaders(),{"Content-Type":"application/json"}),body:JSON.stringify(d)};return u._logger.info("Flags URL",c),u.fetchWithRetry(c,h,{retryCount:0},u.featureFlagsRequestTimeoutMs).then((e=>e.json())).then((e=>i(e))).catch((e=>{u._events.emit("error",e)}))}))()}getFeatureFlagStateless(e,r,i,s,n,o){var l=this;return t((function*(){void 0===i&&(i={}),void 0===s&&(s={}),void 0===n&&(n={}),yield l._initPromise;var t=yield l.getFeatureFlagDetailStateless(e,r,i,s,n,o);if(void 0===t)return{response:void 0,requestId:void 0};var u=a(t.response);return void 0===u&&(u=!1),{response:u,requestId:t.requestId}}))()}getFeatureFlagDetailStateless(e,r,i,s,n,o){var a=this;return t((function*(){void 0===i&&(i={}),void 0===s&&(s={}),void 0===n&&(n={}),yield a._initPromise;var t=yield a.getFeatureFlagDetailsStateless(r,i,s,n,o,[e]);if(void 0!==t)return{response:t.flags[e],requestId:t.requestId}}))()}getFeatureFlagPayloadStateless(e,r,i,s,n,o){var a=this;return t((function*(){void 0===i&&(i={}),void 0===s&&(s={}),void 0===n&&(n={}),yield a._initPromise;var t=yield a.getFeatureFlagPayloadsStateless(r,i,s,n,o,[e]);if(t){var l=t[e];return void 0===l?null:l}}))()}getFeatureFlagPayloadsStateless(e,r,i,s,n,o){var a=this;return t((function*(){return void 0===r&&(r={}),void 0===i&&(i={}),void 0===s&&(s={}),yield a._initPromise,(yield a.getFeatureFlagsAndPayloadsStateless(e,r,i,s,n,o)).payloads}))()}getFeatureFlagsStateless(e,r,i,s,n,o){var a=this;return t((function*(){return void 0===r&&(r={}),void 0===i&&(i={}),void 0===s&&(s={}),yield a._initPromise,yield a.getFeatureFlagsAndPayloadsStateless(e,r,i,s,n,o)}))()}getFeatureFlagsAndPayloadsStateless(e,r,i,s,n,o){var a=this;return t((function*(){void 0===r&&(r={}),void 0===i&&(i={}),void 0===s&&(s={}),yield a._initPromise;var t=yield a.getFeatureFlagDetailsStateless(e,r,i,s,n,o);return t?{flags:t.featureFlags,payloads:t.featureFlagPayloads,requestId:t.requestId}:{flags:void 0,payloads:void 0,requestId:void 0}}))()}getFeatureFlagDetailsStateless(e,r,i,s,n,o){var a=this;return t((function*(){var t;void 0===r&&(r={}),void 0===i&&(i={}),void 0===s&&(s={}),yield a._initPromise;var l={};(null!=n?n:a.disableGeoip)&&(l.geoip_disable=!0),o&&(l.flag_keys_to_evaluate=o);var u=yield a.getFlags(e,r,i,s,l);if(void 0!==u)return u.errorsWhileComputingFlags&&console.error("[FEATURE FLAGS] Error while computing feature flags, some flags may be missing or incorrect. Learn more at https://posthog.com/docs/feature-flags/best-practices"),null!=(t=u.quotaLimited)&&t.includes("feature_flags")?(console.warn("[FEATURE FLAGS] Feature flags quota limit exceeded - feature flags unavailable. Learn more about billing limits at https://posthog.com/docs/billing/limits-alerts"),{flags:{},featureFlags:{},featureFlagPayloads:{},requestId:null==u?void 0:u.requestId}):u}))()}getSurveysStateless(){var e=this;return t((function*(){if(yield e._initPromise,!0===e.disableSurveys)return e._logger.info("Loading surveys is disabled."),[];var t=e.host+"/api/surveys/?token="+e.apiKey,i={method:"GET",headers:r({},e.getCustomHeaders(),{"Content-Type":"application/json"})},s=yield e.fetchWithRetry(t,i).then((t=>{if(200!==t.status||!t.json){var r="Surveys API could not be loaded: "+t.status,i=new Error(r);return e._logger.error(i),void e._events.emit("error",new Error(r))}return t.json()})).catch((t=>{e._logger.error("Surveys API could not be loaded",t),e._events.emit("error",t)})),n=null==s?void 0:s.surveys;return n&&e._logger.info("Surveys fetched from API: ",JSON.stringify(n)),null!=n?n:[]}))()}get props(){return this._props||(this._props=this.getPersistedProperty(y.Props)),this._props||{}}set props(e){this._props=e}register(e){var i=this;return t((function*(){i.wrap((()=>{i.props=r({},i.props,e),i.setPersistedProperty(y.Props,i.props)}))}))()}unregister(e){var r=this;return t((function*(){r.wrap((()=>{delete r.props[e],r.setPersistedProperty(y.Props,r.props)}))}))()}enqueue(e,t,r){this.wrap((()=>{if(this.optedOut)this._events.emit(e,"Library is disabled. Not sending event. To re-enable, call posthog.optIn()");else{var i=this.prepareMessage(e,t,r),s=this.getPersistedProperty(y.Queue)||[];s.length>=this.maxQueueSize&&(s.shift(),this._logger.info("Queue is full, the oldest event is dropped.")),s.push({message:i}),this.setPersistedProperty(y.Queue,s),this._events.emit(e,i),s.length>=this.flushAt&&this.flushBackground(),this.flushInterval&&!this._flushTimer&&(this._flushTimer=W((()=>this.flushBackground()),this.flushInterval))}}))}sendImmediate(e,i,s){var n=this;return t((function*(){if(n.disabled)n._logger.warn("The client is disabled");else if(n._isInitialized||(yield n._initPromise),n.optedOut)n._events.emit(e,"Library is disabled. Not sending event. To re-enable, call posthog.optIn()");else{var t={api_key:n.apiKey,batch:[n.prepareMessage(e,i,s)],sent_at:K()};n.historicalMigration&&(t.historical_migration=!0);var o=JSON.stringify(t),a=n.host+"/batch/",l=n.disableCompression?null:yield Y(o,n.isDebug),u={method:"POST",headers:r({},n.getCustomHeaders(),{"Content-Type":"application/json"},null!==l&&{"Content-Encoding":"gzip"}),body:l||o};try{yield n.fetchWithRetry(a,u)}catch(e){n._events.emit("error",e)}}}))()}prepareMessage(e,t,i){var s,n=r({},t,{type:e,library:this.getLibraryId(),library_version:this.getLibraryVersion(),timestamp:null!=i&&i.timestamp?null==i?void 0:i.timestamp:K(),uuid:null!=i&&i.uuid?i.uuid:v()});return(null!==(s=null==i?void 0:i.disableGeoip)&&void 0!==s?s:this.disableGeoip)&&(n.properties||(n.properties={}),n.properties.$geoip_disable=!0),n.distinctId&&(n.distinct_id=n.distinctId,delete n.distinctId),n}clearFlushTimer(){this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=void 0)}flushBackground(){this.flush().catch(function(){var e=t((function*(e){yield se(e)}));return function(t){return e.apply(this,arguments)}}())}flush(){var e=this;return t((function*(){var t=J([e.flushPromise]).then((()=>e._flush()));return e.flushPromise=t,e.addPendingPromise(t),J([t]).then((()=>{e.flushPromise===t&&(e.flushPromise=null)})),t}))()}getCustomHeaders(){var e=this.getCustomUserAgent(),t={};return e&&""!==e&&(t["User-Agent"]=e),t}_flush(){var e=this;return t((function*(){e.clearFlushTimer(),yield e._initPromise;var t=e.getPersistedProperty(y.Queue)||[];if(t.length){for(var i=[],s=t.length,n=function*(){var s=t.slice(0,e.maxBatchSize),n=s.map((e=>e.message)),o=()=>{var r=(e.getPersistedProperty(y.Queue)||[]).slice(s.length);e.setPersistedProperty(y.Queue,r),t=r},a={api_key:e.apiKey,batch:n,sent_at:K()};e.historicalMigration&&(a.historical_migration=!0);var l=JSON.stringify(a),u=e.host+"/batch/",c=e.disableCompression?null:yield Y(l,e.isDebug),d={method:"POST",headers:r({},e.getCustomHeaders(),{"Content-Type":"application/json"},null!==c&&{"Content-Encoding":"gzip"}),body:c||l},h={retryCheck:e=>!ae(e)&&oe(e)};try{yield e.fetchWithRetry(u,d,h)}catch(t){if(ae(t)&&n.length>1)return e.maxBatchSize=Math.max(1,Math.floor(n.length/2)),e._logger.warn("Received 413 when sending batch of size "+n.length+", reducing batch size to "+e.maxBatchSize),1;throw t instanceof re||o(),e._events.emit("error",t),t}o(),i.push(...n)};t.length>0&&i.length<s;)yield*n();e._events.emit("flush",i)}}))()}fetchWithRetry(e,i,s,n){var o=this;return t((function*(){var a,l;null!==(l=(a=AbortSignal).timeout)&&void 0!==l||(a.timeout=function(e){var t=new AbortController;return setTimeout((()=>t.abort()),e),t.signal});var u=i.body?i.body:"",c=-1;try{c=u instanceof Blob?u.size:Buffer.byteLength(u,"utf8")}catch(e){if(u instanceof Blob)c=u.size;else{var d=(new TextEncoder).encode(u);c=d.length}}return yield function(e,t){return V.apply(this,arguments)}(t((function*(){var t=null;try{t=yield o.fetch(e,r({signal:AbortSignal.timeout(null!=n?n:o.requestTimeout)},i))}catch(e){throw new re(e)}if(!("no-cors"===i.mode)&&(t.status<200||t.status>=400))throw new te(t,c);return t})),r({},o._retryOptions,s))}))()}_shutdown(e){var r=this;return t((function*(){void 0===e&&(e=3e4),yield r._initPromise;var i=!1;r.clearFlushTimer();var s=function(){var e=t((function*(){try{for(yield r.promiseQueue.join();;){if(0===(r.getPersistedProperty(y.Queue)||[]).length)break;if(yield r.flush(),i)break}}catch(e){if(!oe(e))throw e;yield se(e)}}));return function(){return e.apply(this,arguments)}}();return Promise.race([new Promise(((t,s)=>{W((()=>{r._logger.error("Timed out while shutting down PostHog"),i=!0,s("Timeout while shutting down PostHog. Some events may not have been sent.")}),e)})),s()])}))()}shutdown(e){var r=this;return t((function*(){return void 0===e&&(e=3e4),r.shutdownPromise?r._logger.warn("shutdown() called while already shutting down. shutdown() is meant to be called once before process exit - use flush() for per-request cleanup"):r.shutdownPromise=r._shutdown(e).finally((()=>{r.shutdownPromise=null})),r.shutdownPromise}))()}}class ce extends ue{constructor(e,t){var i,s,n,o;super(e,r({},t,{disableGeoip:null!==(i=null==t?void 0:t.disableGeoip)&&void 0!==i&&i,featureFlagsRequestTimeoutMs:null!==(s=null==t?void 0:t.featureFlagsRequestTimeoutMs)&&void 0!==s?s:1e4})),this.flagCallReported={},this._sessionMaxLengthSeconds=86400,this.sessionProps={},this.sendFeatureFlagEvent=null===(n=null==t?void 0:t.sendFeatureFlagEvent)||void 0===n||n,this._sessionExpirationTimeSeconds=null!==(o=null==t?void 0:t.sessionExpirationTimeSeconds)&&void 0!==o?o:1800}setupBootstrap(e){var t,i=null==e?void 0:e.bootstrap;if(i){if(i.distinctId)if(i.isIdentifiedId){this.getPersistedProperty(y.DistinctId)||this.setPersistedProperty(y.DistinctId,i.distinctId)}else{this.getPersistedProperty(y.AnonymousId)||this.setPersistedProperty(y.AnonymousId,i.distinctId)}var s=i.featureFlags,n=null!==(t=i.featureFlagPayloads)&&void 0!==t?t:{};if(s&&Object.keys(s).length){var o=u(s,n);if(Object.keys(o.flags).length>0){this.setBootstrappedFeatureFlagDetails(o);var a=this.getKnownFeatureFlagDetails()||{flags:{},requestId:void 0},l={flags:r({},o.flags,a.flags),requestId:o.requestId};this.setKnownFeatureFlagDetails(l)}}}}clearProps(){this.props=void 0,this.sessionProps={},this.flagCallReported={}}on(e,t){return this._events.on(e,t)}reset(e){this.wrap((()=>{var t=[y.Queue,...e||[]];for(var r of(this.clearProps(),Object.keys(y)))t.includes(y[r])||this.setPersistedProperty(y[r],null);this.reloadFeatureFlags()}))}getCommonEventProperties(){var e=this.getFeatureFlags(),t={};if(e)for(var[i,s]of Object.entries(e))t["$feature/"+i]=s;return r({},ie("$active_feature_flags",e?Object.keys(e):void 0),t,super.getCommonEventProperties())}enrichProperties(e){return r({},this.props,this.sessionProps,e||{},this.getCommonEventProperties(),{$session_id:this.getSessionId()})}getSessionId(){if(!this._isInitialized)return"";var e=this.getPersistedProperty(y.SessionId),t=this.getPersistedProperty(y.SessionLastTimestamp)||0,r=this.getPersistedProperty(y.SessionStartTimestamp)||0,i=Date.now(),s=i-r;return(!e||i-t>1e3*this._sessionExpirationTimeSeconds||s>1e3*this._sessionMaxLengthSeconds)&&(e=v(),this.setPersistedProperty(y.SessionId,e),this.setPersistedProperty(y.SessionStartTimestamp,i)),this.setPersistedProperty(y.SessionLastTimestamp,i),e}resetSessionId(){this.wrap((()=>{this.setPersistedProperty(y.SessionId,null),this.setPersistedProperty(y.SessionLastTimestamp,null),this.setPersistedProperty(y.SessionStartTimestamp,null)}))}getAnonymousId(){if(!this._isInitialized)return"";var e=this.getPersistedProperty(y.AnonymousId);return e||(e=v(),this.setPersistedProperty(y.AnonymousId,e)),e}getDistinctId(){return this._isInitialized?this.getPersistedProperty(y.DistinctId)||this.getAnonymousId():""}registerForSession(e){this.sessionProps=r({},this.sessionProps,e)}unregisterForSession(e){delete this.sessionProps[e]}identify(e,t,i){this.wrap((()=>{var s=this.getDistinctId();e=e||s,null!=t&&t.$groups&&this.groups(t.$groups);var n=null==t?void 0:t.$set_once;null==t||delete t.$set_once;var o=(null==t?void 0:t.$set)||t,a=this.enrichProperties(r({$anon_distinct_id:this.getAnonymousId()},ie("$set",o),ie("$set_once",n)));e!==s&&(this.setPersistedProperty(y.AnonymousId,s),this.setPersistedProperty(y.DistinctId,e),this.reloadFeatureFlags()),super.identifyStateless(e,a,i)}))}capture(e,t,r){this.wrap((()=>{var i=this.getDistinctId();null!=t&&t.$groups&&this.groups(t.$groups);var s=this.enrichProperties(t);super.captureStateless(i,e,s,r)}))}alias(e){this.wrap((()=>{var t=this.getDistinctId(),r=this.enrichProperties({});super.aliasStateless(e,t,r)}))}autocapture(e,t,i,s){void 0===i&&(i={}),this.wrap((()=>{var n={distinct_id:this.getDistinctId(),event:"$autocapture",properties:r({},this.enrichProperties(i),{$event_type:e,$elements:t})};this.enqueue("autocapture",n,s)}))}groups(e){this.wrap((()=>{var t=this.props.$groups||{};this.register({$groups:r({},t,e)}),Object.keys(e).find((r=>t[r]!==e[r]))&&this.reloadFeatureFlags()}))}group(e,t,r,i){this.wrap((()=>{this.groups({[e]:t}),r&&this.groupIdentify(e,t,r,i)}))}groupIdentify(e,t,r,i){this.wrap((()=>{var s=this.getDistinctId(),n=this.enrichProperties({});super.groupIdentifyStateless(e,t,r,i,s,n)}))}setPersonPropertiesForFlags(e){this.wrap((()=>{var t=this.getPersistedProperty(y.PersonProperties)||{};this.setPersistedProperty(y.PersonProperties,r({},t,e))}))}resetPersonPropertiesForFlags(){this.wrap((()=>{this.setPersistedProperty(y.PersonProperties,null)}))}setGroupPropertiesForFlags(e){this.wrap((()=>{var t=this.getPersistedProperty(y.GroupProperties)||{};0!==Object.keys(t).length&&Object.keys(t).forEach((i=>{t[i]=r({},t[i],e[i]),delete e[i]})),this.setPersistedProperty(y.GroupProperties,r({},t,e))}))}resetGroupPropertiesForFlags(){this.wrap((()=>{this.setPersistedProperty(y.GroupProperties,null)}))}remoteConfigAsync(){var e=this;return t((function*(){return yield e._initPromise,e._remoteConfigResponsePromise?e._remoteConfigResponsePromise:e._remoteConfigAsync()}))()}flagsAsync(e,r){var i=this;return t((function*(){return void 0===e&&(e=!0),void 0===r&&(r=!0),yield i._initPromise,i._flagsResponsePromise?i._flagsResponsePromise:i._flagsAsync(e,r)}))()}cacheSessionReplay(e,t){var r=null==t?void 0:t.sessionRecording;r?(this.setPersistedProperty(y.SessionReplay,r),this._logger.info("Session replay config from "+e+": ",JSON.stringify(r))):"boolean"==typeof r&&!1===r&&(this._logger.info("Session replay config from "+e+" disabled."),this.setPersistedProperty(y.SessionReplay,null))}_remoteConfigAsync(){var e=()=>super.getRemoteConfig,i=this;return t((function*(){return i._remoteConfigResponsePromise=i._initPromise.then((()=>{var t=i.getPersistedProperty(y.RemoteConfig);return i._logger.info("Cached remote config: ",JSON.stringify(t)),e().call(i).then((e=>{if(e){var s,n=r({},e);if(delete n.surveys,i._logger.info("Fetched remote config: ",JSON.stringify(n)),!1===i.disableSurveys){var o=e.surveys,a=!0;Array.isArray(o)?i._logger.info("Surveys fetched from remote config: ",JSON.stringify(o)):(i._logger.info("There are no surveys."),a=!1),a?i.setPersistedProperty(y.Surveys,o):i.setPersistedProperty(y.Surveys,null)}else i.setPersistedProperty(y.Surveys,null);i.setPersistedProperty(y.RemoteConfig,n),i.cacheSessionReplay("remote config",e),!1===e.hasFeatureFlags?(i.setKnownFeatureFlagDetails({flags:{}}),i._logger.warn("Remote config has no feature flags, will not load feature flags.")):!1!==i.preloadFeatureFlags&&i.reloadFeatureFlags(),null!=(s=e.supportedCompression)&&s.includes(b.GZipJS)||(i.disableCompression=!0),t=e}return t}))})).finally((()=>{i._remoteConfigResponsePromise=void 0})),i._remoteConfigResponsePromise}))()}_flagsAsync(e,i){var s=()=>super.getFlags,n=this;return t((function*(){return void 0===e&&(e=!0),void 0===i&&(i=!0),n._flagsResponsePromise=n._initPromise.then(t((function*(){var t,o=n.getDistinctId(),a=n.props.$groups||{},l=n.getPersistedProperty(y.PersonProperties)||{},u=n.getPersistedProperty(y.GroupProperties)||{},c={$anon_distinct_id:e?n.getAnonymousId():void 0},d=yield s().call(n,o,a,l,u,c,i);if(null!=d&&null!=(t=d.quotaLimited)&&t.includes(le.FeatureFlags))return n.setKnownFeatureFlagDetails(null),console.warn("[FEATURE FLAGS] Feature flags quota limit exceeded - unsetting all flags. Learn more about billing limits at https://posthog.com/docs/billing/limits-alerts"),d;if(null!=d&&d.featureFlags){n.sendFeatureFlagEvent&&(n.flagCallReported={});var h=d;if(d.errorsWhileComputingFlags){var p=n.getKnownFeatureFlagDetails();n._logger.info("Cached feature flags: ",JSON.stringify(p)),h=r({},d,{flags:r({},null==p?void 0:p.flags,d.flags)})}n.setKnownFeatureFlagDetails(h),n.setPersistedProperty(y.FlagsEndpointWasHit,!0),n.cacheSessionReplay("flags",d)}return d}))).finally((()=>{n._flagsResponsePromise=void 0})),n._flagsResponsePromise}))()}setKnownFeatureFlagDetails(e){this.wrap((()=>{var t;this.setPersistedProperty(y.FeatureFlagDetails,e),this._events.emit("featureflags",n(null!==(t=null==e?void 0:e.flags)&&void 0!==t?t:{}))}))}getKnownFeatureFlagDetails(){var e=this.getPersistedProperty(y.FeatureFlagDetails);if(!e){var t=this.getPersistedProperty(y.FeatureFlags),r=this.getPersistedProperty(y.FeatureFlagPayloads);if(void 0===t&&void 0===r)return;return u(null!=t?t:{},null!=r?r:{})}return i(e)}getKnownFeatureFlags(){var e=this.getKnownFeatureFlagDetails();if(e)return n(e.flags)}getKnownFeatureFlagPayloads(){var e=this.getKnownFeatureFlagDetails();if(e)return o(e.flags)}getBootstrappedFeatureFlagDetails(){var e=this.getPersistedProperty(y.BootstrapFeatureFlagDetails);if(e)return e}setBootstrappedFeatureFlagDetails(e){this.setPersistedProperty(y.BootstrapFeatureFlagDetails,e)}getBootstrappedFeatureFlags(){var e=this.getBootstrappedFeatureFlagDetails();if(e)return n(e.flags)}getBootstrappedFeatureFlagPayloads(){var e=this.getBootstrappedFeatureFlagDetails();if(e)return o(e.flags)}getFeatureFlag(e){var t=this.getFeatureFlagDetails();if(t){var i=t.flags[e],s=a(i);if(void 0===s&&(s=!1),this.sendFeatureFlagEvent&&!this.flagCallReported[e]){var n,o,l,u,c,d,h,p=null==(n=this.getBootstrappedFeatureFlags())?void 0:n[e],g=null==(o=this.getBootstrappedFeatureFlagPayloads())?void 0:o[e];this.flagCallReported[e]=!0,this.capture("$feature_flag_called",r({$feature_flag:e,$feature_flag_response:s},ie("$feature_flag_id",null==i||null==(l=i.metadata)?void 0:l.id),ie("$feature_flag_version",null==i||null==(u=i.metadata)?void 0:u.version),ie("$feature_flag_reason",null!==(c=null==i||null==(d=i.reason)?void 0:d.description)&&void 0!==c?c:null==i||null==(h=i.reason)?void 0:h.code),ie("$feature_flag_bootstrapped_response",p),ie("$feature_flag_bootstrapped_payload",g),{$used_bootstrap_value:!this.getPersistedProperty(y.FlagsEndpointWasHit)},ie("$feature_flag_request_id",t.requestId)))}return s}}getFeatureFlagPayload(e){var t=this.getFeatureFlagPayloads();if(t){var r=t[e];return void 0===r?null:r}}getFeatureFlagPayloads(){var e;return null==(e=this.getFeatureFlagDetails())?void 0:e.featureFlagPayloads}getFeatureFlags(){var e;return null==(e=this.getFeatureFlagDetails())?void 0:e.featureFlags}getFeatureFlagDetails(){var e,t=this.getKnownFeatureFlagDetails(),s=this.getPersistedProperty(y.OverrideFeatureFlags);if(!s)return t;var n,o,a=null!==(e=(t=null!=t?t:{featureFlags:{},featureFlagPayloads:{},flags:{}}).flags)&&void 0!==e?e:{};for(var l in s)s[l]?a[l]=(n=a[l],o=s[l],r({},n,{enabled:c(o),variant:d(o)})):delete a[l];var u=r({},t,{flags:a});return i(u)}getFeatureFlagsAndPayloads(){return{flags:this.getFeatureFlags(),payloads:this.getFeatureFlagPayloads()}}isFeatureEnabled(e){var t=this.getFeatureFlag(e);if(void 0!==t)return!!t}reloadFeatureFlags(e){this.flagsAsync(!0).then((t=>{null==e||null==e.cb||e.cb(void 0,null==t?void 0:t.featureFlags)})).catch((t=>{null==e||null==e.cb||e.cb(t,void 0),null!=e&&e.cb||this._logger.info("Error reloading feature flags",t)}))}reloadRemoteConfigAsync(){var e=this;return t((function*(){return yield e.remoteConfigAsync()}))()}reloadFeatureFlagsAsync(e){var r=this;return t((function*(){var t;return null==(t=yield r.flagsAsync(null==e||e))?void 0:t.featureFlags}))()}onFeatureFlags(e){var r=this;return this.on("featureflags",t((function*(){var t=r.getFeatureFlags();t&&e(t)})))}onFeatureFlag(e,r){var i=this;return this.on("featureflags",t((function*(){var t=i.getFeatureFlag(e);void 0!==t&&r(t)})))}overrideFeatureFlag(e){var r=this;return t((function*(){r.wrap((()=>null===e?r.setPersistedProperty(y.OverrideFeatureFlags,null):r.setPersistedProperty(y.OverrideFeatureFlags,e)))}))()}captureException(e,t){var i=r({$exception_level:"error",$exception_list:[{type:U(e)?e.name:"Error",value:U(e)?e.message:e,mechanism:{handled:!0,synthetic:!1}}]},t);this.capture("$exception",i)}captureTraceFeedback(e,t){this.capture("$ai_feedback",{$ai_feedback_text:t,$ai_trace_id:String(e)})}captureTraceMetric(e,t,r){this.capture("$ai_metric",{$ai_metric_name:t,$ai_metric_value:String(r),$ai_trace_id:String(e)})}}var de={},he=Array.prototype,pe=he.forEach,ge=he.indexOf,fe="undefined"!=typeof window?window:void 0,_e="undefined"!=typeof globalThis?globalThis:fe,ve=null==_e?void 0:_e.navigator,me=null==_e?void 0:_e.document,ye=null==_e?void 0:_e.location;null==_e||_e.fetch,null!=_e&&_e.XMLHttpRequest&&"withCredentials"in new _e.XMLHttpRequest&&_e.XMLHttpRequest,null==_e||_e.AbortController;var be=null==ve?void 0:ve.userAgent,we=null!=fe?fe:{};function Pe(e,t,r){if(k(e))if(pe&&e.forEach===pe)e.forEach(t,r);else if("length"in e&&e.length===+e.length)for(var i=0,s=e.length;i<s;i++)if(i in e&&t.call(r,e[i],i)===de)return}function Se(e,t,r){if(!M(e)){if(k(e))return Pe(e,t,r);if(j(e)){for(var i of e.entries())if(t.call(r,i[1],i[0])===de)return}else for(var s in e)if(x.call(e,s)&&t.call(r,e[s],s)===de)return}}var Ie=function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];return Pe(r,(function(t){for(var r in t)void 0!==t[r]&&(e[r]=t[r])})),e},Fe=function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];return Pe(r,(function(t){Pe(t,(function(t){e.push(t)}))})),e};function xe(e){for(var t=Object.keys(e),r=t.length,i=new Array(r);r--;)i[r]=[t[r],e[t[r]]];return i}function Ee(e,t,r,i){var{capture:s=!1,passive:n=!0}=null!=i?i:{};null==e||e.addEventListener(t,r,{capture:s,passive:n})}var ke=function(e){var t={};return Se(e,(function(e,r){(R(e)&&e.length>0||N(e))&&(t[r]=e)})),t},$e=["herokuapp.com","vercel.app","netlify.app"];function Ce(e){var t=null==e?void 0:e.hostname;if(!R(t))return!1;var r=t.split(".").slice(-2).join(".");for(var i of $e)if(r===i)return!1;return!0}function Ae(e,t){return r=e,i=e=>R(e)&&!D(t)?e.slice(0,t):e,s=new Set,function e(t,r){return t!==Object(t)?i?i(t,r):t:s.has(t)?void 0:(s.add(t),k(t)?(n=[],Pe(t,(t=>{n.push(e(t))}))):(n={},Se(t,((t,r)=>{s.has(t)||(n[r]=e(t,r))}))),n);var n}(r);var r,i,s}var Oe="__timers",Te="$autocapture_disabled_server_side",Re="$sesid",De="$enabled_feature_flags",Me="$user_state",Ne="$client_session_props",Le="$initial_campaign_params",je="$initial_referrer_info",Ue="$initial_person_info",Be="$epp",qe=["$people_distinct_id","__alias","__cmpns",Oe,"$session_recording_enabled_server_side","$heatmaps_enabled_server_side",Re,De,"$error_tracking_suppression_rules",Me,"$early_access_features","$feature_flag_details","$stored_group_properties","$stored_person_properties","$surveys","$flag_call_reported",Ne,"$capture_rate_limit",Le,je,Be,Ue,y.Queue,y.FeatureFlagDetails,y.FlagsEndpointWasHit,y.AnonymousId,y.RemoteConfig,y.Surveys,y.FeatureFlags],He="[Leanbase]",ze={info:function(){if("undefined"!=typeof console){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];console.log(He,...t)}},warn:function(){if("undefined"!=typeof console){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];console.warn(He,...t)}},error:function(){if("undefined"!=typeof console){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];console.error(He,...t)}},critical:function(){if("undefined"!=typeof console){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];console.error(He,"CRITICAL:",...t)}}};Math.trunc||(Math.trunc=function(e){return e<0?Math.ceil(e):Math.floor(e)}),Number.isInteger||(Number.isInteger=function(e){return N(e)&&isFinite(e)&&Math.floor(e)===e});var Ge="0123456789abcdef";class Ve{constructor(e){if(this.bytes=e,16!==e.length)throw new TypeError("not 128-bit length")}static fromFieldsV7(e,t,r,i){if(!Number.isInteger(e)||!Number.isInteger(t)||!Number.isInteger(r)||!Number.isInteger(i)||e<0||t<0||r<0||i<0||e>0xffffffffffff||t>4095||r>1073741823||i>4294967295)throw new RangeError("invalid field value");var s=new Uint8Array(16);return s[0]=e/Math.pow(2,40),s[1]=e/Math.pow(2,32),s[2]=e/Math.pow(2,24),s[3]=e/Math.pow(2,16),s[4]=e/Math.pow(2,8),s[5]=e,s[6]=112|t>>>8,s[7]=t,s[8]=128|r>>>24,s[9]=r>>>16,s[10]=r>>>8,s[11]=r,s[12]=i>>>24,s[13]=i>>>16,s[14]=i>>>8,s[15]=i,new Ve(s)}toString(){for(var e="",t=0;t<this.bytes.length;t++)e=e+Ge.charAt(this.bytes[t]>>>4)+Ge.charAt(15&this.bytes[t]),3!==t&&5!==t&&7!==t&&9!==t||(e+="-");if(36!==e.length)throw new Error("Invalid UUIDv7 was generated");return e}clone(){return new Ve(this.bytes.slice(0))}equals(e){return 0===this.compareTo(e)}compareTo(e){for(var t=0;t<16;t++){var r=this.bytes[t]-e.bytes[t];if(0!==r)return Math.sign(r)}return 0}}class Ke{constructor(){this._timestamp=0,this._counter=0,this._random=new Qe}generate(){var e=this.generateOrAbort();if(T(e)){this._timestamp=0;var t=this.generateOrAbort();if(T(t))throw new Error("Could not generate UUID after timestamp reset");return t}return e}generateOrAbort(){var e=Date.now();if(e>this._timestamp)this._timestamp=e,this._resetCounter();else{if(!(e+1e4>this._timestamp))return;this._counter++,this._counter>4398046511103&&(this._timestamp++,this._resetCounter())}return Ve.fromFieldsV7(this._timestamp,Math.trunc(this._counter/Math.pow(2,30)),this._counter&Math.pow(2,30)-1,this._random.nextUint32())}_resetCounter(){this._counter=1024*this._random.nextUint32()+(1023&this._random.nextUint32())}}var We,Je=e=>{if("undefined"!=typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var t=0;t<e.length;t++)e[t]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return e};fe&&!T(fe.crypto)&&crypto.getRandomValues&&(Je=e=>crypto.getRandomValues(e));class Qe{constructor(){this._buffer=new Uint32Array(8),this._cursor=1/0}nextUint32(){return this._cursor>=this._buffer.length&&(Je(this._buffer),this._cursor=0),this._buffer[this._cursor++]}}var Ye=()=>Xe().toString(),Xe=()=>(We||(We=new Ke)).generate(),Ze="";var et=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;function tt(e,t){if(t){var r=function(e,t){if(void 0===t&&(t=me),Ze)return Ze;if(!t)return"";if(["localhost","127.0.0.1"].includes(e))return"";for(var r=e.split("."),i=Math.min(r.length,8),s="dmn_chk_"+Ye();!Ze&&i--;){var n=r.slice(i).join("."),o=s+"=1;domain=."+n+";path=/";t.cookie=o+";max-age=3",t.cookie.includes(s)&&(t.cookie=o+";max-age=0",Ze=n)}return Ze}(e);if(!r){var i=(e=>{var t=e.match(et);return t?t[0]:""})(e);i!==r&&ze.info("Warning: cookie subdomain discovery mismatch",i,r),r=i}return r?"; domain=."+r:""}return""}var rt={_is_supported:()=>!!me,_error:function(e){ze.error("cookieStore error: "+e)},_get:function(e){if(me){try{for(var t=e+"=",r=me.cookie.split(";").filter((e=>e.length)),i=0;i<r.length;i++){for(var s=r[i];" "==s.charAt(0);)s=s.substring(1,s.length);if(0===s.indexOf(t))return decodeURIComponent(s.substring(t.length,s.length))}}catch(e){}return null}},_parse:function(e){var t;try{t=JSON.parse(rt._get(e))||{}}catch(e){}return t},_set:function(e,t,r,i,s){if(me)try{var n="",o="",a=tt(me.location.hostname,i);if(r){var l=new Date;l.setTime(l.getTime()+24*r*60*60*1e3),n="; expires="+l.toUTCString()}s&&(o="; secure");var u=e+"="+encodeURIComponent(JSON.stringify(t))+n+"; SameSite=Lax; path=/"+a+o;return u.length>3686.4&&ze.warn("cookieStore warning: large cookie, len="+u.length),me.cookie=u,u}catch(e){return}},_remove:function(e,t){if(null!=me&&me.cookie)try{rt._set(e,"",-1,t)}catch(e){return}}},it=null,st={_is_supported:function(){if(!D(it))return it;var e=!0;if(T(fe))e=!1;else try{var t="__mplssupport__";st._set(t,"xyz"),'"xyz"'!==st._get(t)&&(e=!1),st._remove(t)}catch(t){e=!1}return e||ze.error("localStorage unsupported; falling back to cookie store"),it=e,e},_error:function(e){ze.error("localStorage error: "+e)},_get:function(e){try{return null==fe?void 0:fe.localStorage.getItem(e)}catch(e){st._error(e)}return null},_parse:function(e){try{return JSON.parse(st._get(e))||{}}catch(e){}return null},_set:function(e,t){try{null==fe||fe.localStorage.setItem(e,JSON.stringify(t))}catch(e){st._error(e)}},_remove:function(e){try{null==fe||fe.localStorage.removeItem(e)}catch(e){st._error(e)}}},nt=["distinct_id",Re,"$session_is_sampled",Be,Ue],ot=r({},st,{_parse:function(e){try{var t={};try{t=rt._parse(e)||{}}catch(e){}var r=Ie(t,JSON.parse(st._get(e)||"{}"));return st._set(e,r),r}catch(e){}return null},_set:function(e,t,r,i,s,n){try{st._set(e,t,void 0,void 0,n);var o={};nt.forEach((e=>{t[e]&&(o[e]=t[e])})),Object.keys(o).length&&rt._set(e,o,r,i,s,n)}catch(e){st._error(e)}},_remove:function(e,t){try{null==fe||fe.localStorage.removeItem(e),rt._remove(e,t)}catch(e){st._error(e)}}}),at={},lt={_is_supported:function(){return!0},_error:function(e){ze.error("memoryStorage error: "+e)},_get:function(e){return at[e]||null},_parse:function(e){return at[e]||null},_set:function(e,t){at[e]=t},_remove:function(e){delete at[e]}},ut=null,ct={_is_supported:function(){if(!D(ut))return ut;if(ut=!0,T(fe))ut=!1;else try{var e="__support__";ct._set(e,"xyz"),'"xyz"'!==ct._get(e)&&(ut=!1),ct._remove(e)}catch(e){ut=!1}return ut},_error:function(e){ze.error("sessionStorage error: ",e)},_get:function(e){try{return null==fe?void 0:fe.sessionStorage.getItem(e)}catch(e){ct._error(e)}return null},_parse:function(e){try{return JSON.parse(ct._get(e))||null}catch(e){}return null},_set:function(e,t){try{null==fe||fe.sessionStorage.setItem(e,JSON.stringify(t))}catch(e){ct._error(e)}},_remove:function(e){try{null==fe||fe.sessionStorage.removeItem(e)}catch(e){ct._error(e)}}},dt=e=>{var t=null==me?void 0:me.createElement("a");return T(t)?null:(t.href=e,t)},ht=function(e,t){for(var r,i=((e.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),s=0;s<i.length;s++){var n=i[s].split("=");if(n[0]===t){r=n;break}}if(!k(r)||r.length<2)return"";var o=r[1];try{o=decodeURIComponent(o)}catch(e){ze.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},pt=function(e,t,r){if(!e||!t||!t.length)return e;for(var i=e.split("#"),s=i[0]||"",n=i[1],o=s.split("?"),a=o[1],l=o[0],u=(a||"").split("&"),c=[],d=0;d<u.length;d++){var h=u[d].split("=");k(h)&&(t.includes(h[0])?c.push(h[0]+"="+r):c.push(u[d]))}var p=l;return null!=a&&(p+="?"+c.join("&")),null!=n&&(p+="#"+n),p},gt="Mobile",ft="iOS",_t="Android",vt="Tablet",mt=_t+" "+vt,yt="iPad",bt="Apple",wt=bt+" Watch",Pt="Safari",St="BlackBerry",It="Samsung",Ft=It+"Browser",xt=It+" Internet",Et="Chrome",kt=Et+" OS",$t=Et+" "+ft,Ct="Internet Explorer",At=Ct+" "+gt,Ot="Opera",Tt=Ot+" Mini",Rt="Edge",Dt="Microsoft "+Rt,Mt="Firefox",Nt=Mt+" "+ft,Lt="Nintendo",jt="PlayStation",Ut="Xbox",Bt=_t+" "+gt,qt=gt+" "+Pt,Ht="Windows",zt=Ht+" Phone",Gt="Nokia",Vt="Ouya",Kt="Generic",Wt=Kt+" "+gt.toLowerCase(),Jt=Kt+" "+vt.toLowerCase(),Qt="Konqueror",Yt="(\\d+(\\.\\d+)?)",Xt=new RegExp("Version/"+Yt),Zt=new RegExp(Ut,"i"),er=new RegExp(jt+" \\w+","i"),tr=new RegExp(Lt+" \\w+","i"),rr=new RegExp(St+"|PlayBook|BB10","i"),ir={"NT3.51":"NT 3.11","NT4.0":"NT 4.0","5.0":"2000",5.1:"XP",5.2:"XP","6.0":"Vista",6.1:"7",6.2:"8",6.3:"8.1",6.4:"10","10.0":"10"};var sr=(e,t)=>t&&w(t,bt)||function(e){return w(e,Pt)&&!w(e,Et)&&!w(e,_t)}(e),nr=function(e,t){return t=t||"",w(e," OPR/")&&w(e,"Mini")?Tt:w(e," OPR/")?Ot:rr.test(e)?St:w(e,"IE"+gt)||w(e,"WPDesktop")?At:w(e,Ft)?xt:w(e,Rt)||w(e,"Edg/")?Dt:w(e,"FBIOS")?"Facebook "+gt:w(e,"UCWEB")||w(e,"UCBrowser")?"UC Browser":w(e,"CriOS")?$t:w(e,"CrMo")||w(e,Et)?Et:w(e,_t)&&w(e,Pt)?Bt:w(e,"FxiOS")?Nt:w(e.toLowerCase(),Qt.toLowerCase())?Qt:sr(e,t)?w(e,gt)?qt:Pt:w(e,Mt)?Mt:w(e,"MSIE")||w(e,"Trident/")?Ct:w(e,"Gecko")?Mt:""},or={[At]:[new RegExp("rv:"+Yt)],[Dt]:[new RegExp(Rt+"?\\/"+Yt)],[Et]:[new RegExp("("+Et+"|CrMo)\\/"+Yt)],[$t]:[new RegExp("CriOS\\/"+Yt)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+Yt)],[Pt]:[Xt],[qt]:[Xt],[Ot]:[new RegExp("(Opera|OPR)\\/"+Yt)],[Mt]:[new RegExp(Mt+"\\/"+Yt)],[Nt]:[new RegExp("FxiOS\\/"+Yt)],[Qt]:[new RegExp("Konqueror[:/]?"+Yt,"i")],[St]:[new RegExp(St+" "+Yt),Xt],[Bt]:[new RegExp("android\\s"+Yt,"i")],[xt]:[new RegExp(Ft+"\\/"+Yt)],[Ct]:[new RegExp("(rv:|MSIE )"+Yt)],Mozilla:[new RegExp("rv:"+Yt)]},ar=function(e,t){var r=nr(e,t),i=or[r];if(T(i))return null;for(var s=0;s<i.length;s++){var n=i[s],o=e.match(n);if(o)return parseFloat(o[o.length-2])}return null},lr=[[new RegExp(Ut+"; "+Ut+" (.*?)[);]","i"),e=>[Ut,e&&e[1]||""]],[new RegExp(Lt,"i"),[Lt,""]],[new RegExp(jt,"i"),[jt,""]],[rr,[St,""]],[new RegExp(Ht,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[zt,""];if(new RegExp(gt).test(t)&&!/IEMobile\b/.test(t))return[Ht+" "+gt,""];var r=/Windows NT ([0-9.]+)/i.exec(t);if(r&&r[1]){var i=r[1],s=ir[i]||"";return/arm/i.test(t)&&(s="RT"),[Ht,s]}return[Ht,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>{if(e&&e[3]){var t=[e[3],e[4],e[5]||"0"];return[ft,t.join(".")]}return[ft,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var t="";return e&&e.length>=3&&(t=T(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("("+_t+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+_t+")","i"),e=>{if(e&&e[2]){var t=[e[2],e[3],e[4]||"0"];return[_t,t.join(".")]}return[_t,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{var t=["Mac OS X",""];if(e&&e[1]){var r=[e[1],e[2],e[3]||"0"];t[1]=r.join(".")}return t}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[kt,""]],[/Linux|debian/i,["Linux",""]]],ur=function(e){return tr.test(e)?Lt:er.test(e)?jt:Zt.test(e)?Ut:new RegExp(Vt,"i").test(e)?Vt:new RegExp("("+zt+"|WPDesktop)","i").test(e)?zt:/iPad/.test(e)?yt:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?wt:rr.test(e)?St:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(Gt,"i").test(e)?Gt:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(e)||/(kf[a-z]+)( bui|\)).+silk\//i.test(e)?"Kindle Fire":/(Android|ZTE)/i.test(e)?!new RegExp(gt).test(e)||/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(e)?/pixel[\daxl ]{1,6}/i.test(e)&&!/pixel c/i.test(e)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(e)||/lmy47v/i.test(e)&&!/QTAQZ3/i.test(e)?_t:mt:_t:new RegExp("(pda|"+gt+")","i").test(e)?Wt:new RegExp(vt,"i").test(e)&&!new RegExp(vt+" pc","i").test(e)?Jt:""},cr={LIB_VERSION:"0.2.1"},dr="https?://(.*)",hr=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],pr=Fe(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],hr),gr="<masked>",fr=["li_fat_id"];function _r(e,t,r){if(!me)return{};var i,s=t?Fe([],hr,r||[]):[],n=vr(pt(me.URL,s,gr),e),o=(i={},Se(fr,(function(e){var t=rt._get(e);i[e]=t||null})),i);return Ie(o,n)}function vr(e,t){var r=pr.concat(t||[]),i={};return Se(r,(function(t){var r=ht(e,t);i[t]=r||null})),i}function mr(e){var t=function(e){return e?0===e.search(dr+"google.([^/?]*)")?"google":0===e.search(dr+"bing.com")?"bing":0===e.search(dr+"yahoo.com")?"yahoo":0===e.search(dr+"duckduckgo.com")?"duckduckgo":null:null}(e),r="yahoo"!=t?"q":"p",i={};if(!D(t)){i.$search_engine=t;var s=me?ht(me.referrer,r):"";s.length&&(i.ph_keyword=s)}return i}function yr(){return navigator.language||navigator.userLanguage}function br(){return(null==me?void 0:me.referrer)||"$direct"}function wr(e,t){var r=e?Fe([],hr,t||[]):[],i=null==ye?void 0:ye.href.substring(0,1e3);return{r:br().substring(0,1e3),u:i?pt(i,r,gr):void 0}}function Pr(e){var t,{r:r,u:i}=e,s={$referrer:r,$referring_domain:null==r?void 0:"$direct"==r?"$direct":null==(t=dt(r))?void 0:t.host};if(i){s.$current_url=i;var n=dt(i);s.$host=null==n?void 0:n.host,s.$pathname=null==n?void 0:n.pathname;var o=vr(i);Ie(s,o)}if(r){var a=mr(r);Ie(s,a)}return s}function Sr(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(e){return}}function Ir(){try{return(new Date).getTimezoneOffset()}catch(e){return}}function Fr(e,t){if(!be)return{};var r,i,s,n=e?Fe([],hr,t||[]):[],[o,a]=function(e){for(var t=0;t<lr.length;t++){var[r,i]=lr[t],s=r.exec(e),n=s&&(C(i)?i(s,e):i);if(n)return n}return["",""]}(be);return Ie(ke({$os:o,$os_version:a,$browser:nr(be,navigator.vendor),$device:ur(be),$device_type:(i=be,s=ur(i),s===yt||s===mt||"Kobo"===s||"Kindle Fire"===s||s===Jt?vt:s===Lt||s===Ut||s===jt||s===Vt?"Console":s===wt?"Wearable":s?gt:"Desktop"),$timezone:Sr(),$timezone_offset:Ir()}),{$current_url:pt(null==ye?void 0:ye.href,n,gr),$host:null==ye?void 0:ye.host,$pathname:null==ye?void 0:ye.pathname,$raw_user_agent:be.length>1e3?be.substring(0,997)+"...":be,$browser_version:ar(be,navigator.vendor),$browser_language:yr(),$browser_language_prefix:(r=yr(),"string"==typeof r?r.split("-")[0]:void 0),$screen_height:null==fe?void 0:fe.screen.height,$screen_width:null==fe?void 0:fe.screen.width,$viewport_height:null==fe?void 0:fe.innerHeight,$viewport_width:null==fe?void 0:fe.innerWidth,$lib:"web",$lib_version:cr.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})}var xr=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"];class Er{constructor(e,t){this._config=e,this.props={},this._campaign_params_saved=!1,this._name=(e=>{var t="";return e.token&&(t=e.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),e.persistence_name?e.persistence_name:"leanbase_"+t})(e),this._storage=this._buildStorage(e),this.load(),e.debug&&ze.info("Persistence loaded",e.persistence,r({},this.props)),this.update_config(e,e,t),this.save()}isDisabled(){return!!this._disabled}_buildStorage(e){-1===xr.indexOf(e.persistence.toLowerCase())&&(ze.info("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var t=e.persistence.toLowerCase();return"localstorage"===t&&st._is_supported()?st:"localstorage+cookie"===t&&ot._is_supported()?ot:"sessionstorage"===t&&ct._is_supported()?ct:"memory"===t?lt:"cookie"===t?rt:ot._is_supported()?ot:rt}properties(){var e={};return Se(this.props,(function(t,r){if(r===De&&A(t))for(var i=Object.keys(t),s=0;s<i.length;s++)e["$feature/"+i[s]]=t[i[s]];else o=r,a=!1,(D(n=qe)?a:ge&&n.indexOf===ge?-1!=n.indexOf(o):(Se(n,(function(e){if(a||(a=e===o))return de})),a))||(e[r]=t);var n,o,a})),e}load(){if(!this._disabled){var e=this._storage._parse(this._name);e&&(this.props=Ie({},e))}}save(){this._disabled||this._storage._set(this._name,this.props,this._expire_days,this._cross_subdomain,this._secure,this._config.debug)}remove(){this._storage._remove(this._name,!1),this._storage._remove(this._name,!0)}clear(){this.remove(),this.props={}}register_once(e,t,r){if(A(e)){T(t)&&(t="None"),this._expire_days=T(r)?this._default_expiry:r;var i=!1;if(Se(e,((e,r)=>{this.props.hasOwnProperty(r)&&this.props[r]!==t||(this.props[r]=e,i=!0)})),i)return this.save(),!0}return!1}register(e,t){if(A(e)){this._expire_days=T(t)?this._default_expiry:t;var r=!1;if(Se(e,((t,i)=>{e.hasOwnProperty(i)&&this.props[i]!==t&&(this.props[i]=t,r=!0)})),r)return this.save(),!0}return!1}unregister(e){e in this.props&&(delete this.props[e],this.save())}update_campaign_params(){if(!this._campaign_params_saved){var e=_r(this._config.custom_campaign_params,this._config.mask_personal_data_properties,this._config.custom_personal_data_properties);O(ke(e))||this.register(e),this._campaign_params_saved=!0}}update_search_keyword(){var e;this.register((e=null==me?void 0:me.referrer)?mr(e):{})}update_referrer_info(){var e;this.register_once({$referrer:br(),$referring_domain:null!=me&&me.referrer&&(null==(e=dt(me.referrer))?void 0:e.host)||"$direct"},void 0)}set_initial_person_info(){this.props[Le]||this.props[je]||this.register_once({[Ue]:wr(this._config.mask_personal_data_properties,this._config.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};Se([je,Le],(t=>{var r=this.props[t];r&&Se(r,(function(t,r){e["$initial_"+S(r)]=t}))}));var t,r,i=this.props[Ue];if(i){var s=(t=Pr(i),r={},Se(t,(function(e,t){r["$initial_"+S(t)]=e})),r);Ie(e,s)}return e}safe_merge(e){return Se(this.props,(function(t,r){r in e||(e[r]=t)})),e}update_config(e,t,r){if(this._default_expiry=this._expire_days=e.cookie_expiration,this.set_disabled(e.disable_persistence||!!r),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),e.persistence!==t.persistence){var i=this._buildStorage(e),s=this.props;this.clear(),this._storage=i,this.props=s,this.save()}}set_disabled(e){if(this._disabled=e,this._disabled)return this.remove();this.save()}set_cross_subdomain(e){e!==this._cross_subdomain&&(this._cross_subdomain=e,this.remove(),this.save())}set_secure(e){e!==this._secure&&(this._secure=e,this.remove(),this.save())}set_event_timer(e,t){var r=this.props[Oe]||{};r[e]=t,this.props[Oe]=r,this.save()}remove_event_timer(e){var t=(this.props[Oe]||{})[e];return T(t)||(delete this.props[Oe][e],this.save()),t}get_property(e){return this.props[e]}set_property(e,t){this.props[e]=t,this.save()}}function kr(e){return!!e&&1===e.nodeType}function $r(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function Cr(e){return!!e&&3===e.nodeType}function Ar(e){return!!e&&11===e.nodeType}function Or(e){return e?P(e).split(/\s+/):[]}function Tr(e){var t,r=null==(t=window)?void 0:t.location.href;return!!(r&&e&&e.some((e=>r.match(e))))}function Rr(e){var t="";switch(typeof e.className){case"string":t=e.className;break;case"object":t=(e.className&&"baseVal"in e.className?e.className.baseVal:null)||e.getAttribute("class")||"";break;default:t=""}return Or(t)}function Dr(e){return M(e)?null:P(e).split(/(\s+)/).filter((e=>Xr(e))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Mr(e){var t="";return zr(e)&&!Gr(e)&&e.childNodes&&e.childNodes.length&&Se(e.childNodes,(function(e){var r;Cr(e)&&e.textContent&&(t+=null!==(r=Dr(e.textContent))&&void 0!==r?r:"")})),P(t)}var Nr=["a","button","form","input","select","textarea","label"];function Lr(e,t){if(T(t))return!0;var r,i=function(e){if(t.some((t=>e.matches(t))))return{v:!0}};for(var s of e)if(r=i(s))return r.v;return!1}function jr(e){var t=e.parentNode;return!(!t||!kr(t))&&t}var Ur=[".ph-no-rageclick",".ph-no-capture"];var Br=e=>!e||$r(e,"html")||!kr(e),qr=(e,t)=>{if(!window||Br(e))return{parentIsUsefulElement:!1,targetElementList:[]};for(var r=!1,i=[e],s=e;s.parentNode&&!$r(s,"body");)if(Ar(s.parentNode))i.push(s.parentNode.host),s=s.parentNode.host;else{var n=jr(s);if(!n)break;if(t||Nr.indexOf(n.tagName.toLowerCase())>-1)r=!0;else{var o=window.getComputedStyle(n);o&&"pointer"===o.getPropertyValue("cursor")&&(r=!0)}i.push(n),s=n}return{parentIsUsefulElement:r,targetElementList:i}};function Hr(e,t,r,i,s){var n,o,a,l;if(void 0===r&&(r=void 0),!window||Br(e))return!1;if(null!=(n=r)&&n.url_allowlist&&!Tr(r.url_allowlist))return!1;if(null!=(o=r)&&o.url_ignorelist&&Tr(r.url_ignorelist))return!1;if(null!=(a=r)&&a.dom_event_allowlist){var u=r.dom_event_allowlist;if(u&&!u.some((e=>t.type===e)))return!1}var{parentIsUsefulElement:c,targetElementList:d}=qr(e,i);if(!function(e,t){var r=null==t?void 0:t.element_allowlist;if(T(r))return!0;var i,s=function(e){if(r.some((t=>e.tagName.toLowerCase()===t)))return{v:!0}};for(var n of e)if(i=s(n))return i.v;return!1}(d,r))return!1;if(!Lr(d,null==(l=r)?void 0:l.css_selector_allowlist))return!1;var h=window.getComputedStyle(e);if(h&&"pointer"===h.getPropertyValue("cursor")&&"click"===t.type)return!0;var p=e.tagName.toLowerCase();switch(p){case"html":return!1;case"form":return(s||["submit"]).indexOf(t.type)>=0;case"input":case"select":case"textarea":return(s||["change","click"]).indexOf(t.type)>=0;default:return c?(s||["click"]).indexOf(t.type)>=0:(s||["click"]).indexOf(t.type)>=0&&(Nr.indexOf(p)>-1||"true"===e.getAttribute("contenteditable"))}}function zr(e){for(var t=e;t.parentNode&&!$r(t,"body");t=t.parentNode){var r=Rr(t);if(w(r,"ph-sensitive")||w(r,"ph-no-capture"))return!1}if(w(Rr(e),"ph-include"))return!0;var i=e.type||"";if(R(i))switch(i.toLowerCase()){case"hidden":case"password":return!1}var s=e.name||e.id||"";if(R(s)){if(/^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,"")))return!1}return!0}function Gr(e){return!!($r(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||$r(e,"select")||$r(e,"textarea")||"true"===e.getAttribute("contenteditable"))}var Vr="(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})",Kr=new RegExp("^(?:"+Vr+")$"),Wr=new RegExp(Vr),Jr="\\d{3}-?\\d{2}-?\\d{4}",Qr=new RegExp("^("+Jr+")$"),Yr=new RegExp("("+Jr+")");function Xr(e,t){if(void 0===t&&(t=!0),M(e))return!1;if(R(e)){if(e=P(e),(t?Kr:Wr).test((e||"").replace(/[- ]/g,"")))return!1;if((t?Qr:Yr).test(e))return!1}return!0}function Zr(e){var t=Mr(e);return Xr(t=(t+" "+ei(e)).trim())?t:""}function ei(e){var t="";return e&&e.childNodes&&e.childNodes.length&&Se(e.childNodes,(function(e){var r;if(e&&"span"===(null==(r=e.tagName)?void 0:r.toLowerCase()))try{var i=Mr(e);t=(t+" "+i).trim(),e.childNodes&&e.childNodes.length&&(t=(t+" "+ei(e)).trim())}catch(e){ze.error("[AutoCapture]",e)}})),t}function ti(e){return function(e){var t=e.map((e=>{var t,i,s="";if(e.tag_name&&(s+=e.tag_name),e.attr_class)for(var n of(e.attr_class.sort(),e.attr_class))s+="."+n.replace(/"/g,"");var o=r({},e.text?{text:e.text}:{},{"nth-child":null!==(t=e.nth_child)&&void 0!==t?t:0,"nth-of-type":null!==(i=e.nth_of_type)&&void 0!==i?i:0},e.href?{href:e.href}:{},e.attr_id?{attr_id:e.attr_id}:{},e.attributes),a={};return xe(o).sort(((e,t)=>{var[r]=e,[i]=t;return r.localeCompare(i)})).forEach((e=>{var[t,r]=e;return a[ri(t.toString())]=ri(r.toString())})),s+=":",s+=xe(a).map((e=>{var[t,r]=e;return t+'="'+r+'"'})).join("")}));return t.join(";")}(function(e){return e.map((e=>{var t,r,i={text:null==(t=e.$el_text)?void 0:t.slice(0,400),tag_name:e.tag_name,href:null==(r=e.attr__href)?void 0:r.slice(0,2048),attr_class:ii(e),attr_id:e.attr__id,nth_child:e.nth_child,nth_of_type:e.nth_of_type,attributes:{}};return xe(e).filter((e=>{var[t]=e;return 0===t.indexOf("attr__")})).forEach((e=>{var[t,r]=e;return i.attributes[t]=r})),i}))}(e))}function ri(e){return e.replace(/"|\\"/g,'\\"')}function ii(e){var t=e.attr__class;return t?k(t)?t:Or(t):void 0}class si{constructor(){this.clicks=[]}isRageClick(e,t,r){var i=this.clicks[this.clicks.length-1];if(i&&Math.abs(e-i.x)+Math.abs(t-i.y)<30&&r-i.timestamp<1e3){if(this.clicks.push({x:e,y:t,timestamp:r}),3===this.clicks.length)return!0}else this.clicks=[{x:e,y:t,timestamp:r}];return!1}}var ni,oi="$copy_autocapture";function ai(e,t){return t.length>e?t.slice(0,e)+"...":t}function li(e){if(e.previousElementSibling)return e.previousElementSibling;var t=e;do{t=t.previousSibling}while(t&&!kr(t));return t}function ui(e,t,r,i){var s=e.tagName.toLowerCase(),n={tag_name:s};Nr.indexOf(s)>-1&&!r&&("a"===s.toLowerCase()||"button"===s.toLowerCase()?n.$el_text=ai(1024,Zr(e)):n.$el_text=ai(1024,Mr(e)));var o=Rr(e);o.length>0&&(n.classes=o.filter((function(e){return""!==e}))),Se(e.attributes,(function(r){var s;if((!Gr(e)||-1!==["name","id","class","aria-label"].indexOf(r.name))&&((null==i||!i.includes(r.name))&&!t&&Xr(r.value)&&(s=r.name,!R(s)||"_ngcontent"!==s.substring(0,10)&&"_nghost"!==s.substring(0,7)))){var o=r.value;"class"===r.name&&(o=Or(o).join(" ")),n["attr__"+r.name]=ai(1024,o)}}));for(var a=1,l=1,u=e;u=li(u);)a++,u.tagName===e.tagName&&l++;return n.nth_child=a,n.nth_of_type=l,n}function ci(e,t){for(var r,i,{e:s,maskAllElementAttributes:n,maskAllText:o,elementAttributeIgnoreList:a,elementsChainAsString:l}=t,u=[e],c=e;c.parentNode&&!$r(c,"body");)Ar(c.parentNode)?(u.push(c.parentNode.host),c=c.parentNode.host):(u.push(c.parentNode),c=c.parentNode);var d,h=[],p={},g=!1,f=!1;if(Se(u,(e=>{var t=zr(e);"a"===e.tagName.toLowerCase()&&(g=e.getAttribute("href"),g=t&&g&&Xr(g)&&g),w(Rr(e),"ph-no-capture")&&(f=!0),h.push(ui(e,n,o,a));var r=function(e){if(!zr(e))return{};var t={};return Se(e.attributes,(function(e){if(e.name&&0===e.name.indexOf("data-ph-capture-attribute")){var r=e.name.replace("data-ph-capture-attribute-",""),i=e.value;r&&i&&Xr(i)&&(t[r]=i)}})),t}(e);Ie(p,r)})),f)return{props:{},explicitNoCapture:f};if(o||("a"===e.tagName.toLowerCase()||"button"===e.tagName.toLowerCase()?h[0].$el_text=Zr(e):h[0].$el_text=Mr(e)),g){var _,v;h[0].attr__href=g;var m=null==(_=dt(g))?void 0:_.host,y=null==fe||null==(v=fe.location)?void 0:v.host;m&&y&&m!==y&&(d=g)}return{props:Ie({$event_type:s.type,$ce_version:1},l?{}:{$elements:h},{$elements_chain:ti(h)},null!=(r=h[0])&&r.$el_text?{$el_text:null==(i=h[0])?void 0:i.$el_text}:{},d&&"click"===s.type?{$external_click_url:d}:{},p)}}!function(e){e.GZipJS="gzip-js",e.Base64="base64"}(ni||(ni={}));class di{constructor(e){this._initialized=!1,this._isDisabledServerSide=null,this.rageclicks=new si,this._elementsChainAsString=!1,this.instance=e,this._elementSelectors=null}get _config(){var e,t,r=A(this.instance.config.autocapture)?this.instance.config.autocapture:{};return r.url_allowlist=null==(e=r.url_allowlist)?void 0:e.map((e=>new RegExp(e))),r.url_ignorelist=null==(t=r.url_ignorelist)?void 0:t.map((e=>new RegExp(e))),r}_addDomEventHandlers(){if(this.isBrowserSupported()){if(fe&&me){var e=e=>{e=e||(null==fe?void 0:fe.event);try{this._captureEvent(e)}catch(e){ze.error("Failed to capture event",e)}};if(Ee(me,"submit",e,{capture:!0}),Ee(me,"change",e,{capture:!0}),Ee(me,"click",e,{capture:!0}),this._config.capture_copied_text){var t=e=>{e=e||(null==fe?void 0:fe.event),this._captureEvent(e,oi)};Ee(me,"copy",t,{capture:!0}),Ee(me,"cut",t,{capture:!0})}}}else ze.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this._initialized&&(this._addDomEventHandlers(),this._initialized=!0)}onRemoteConfig(e){e.elementsChainAsString&&(this._elementsChainAsString=e.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[Te]:!!e.autocapture_opt_out}),this._isDisabledServerSide=!!e.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(e){this._elementSelectors=e}getElementSelectors(e){var t,r=[];return null==(t=this._elementSelectors)||t.forEach((t=>{var i=null==me?void 0:me.querySelectorAll(t);null==i||i.forEach((i=>{e===i&&r.push(t)}))})),r}get isEnabled(){var e,t,r=null==(e=this.instance.persistence)?void 0:e.props[Te],i=this._isDisabledServerSide;if(D(i)&&!L(r))return!1;var s=null!==(t=this._isDisabledServerSide)&&void 0!==t?t:!!r;return!!this.instance.config.autocapture&&!s}_captureEvent(e,t){if(void 0===t&&(t="$autocapture"),this.isEnabled){var r,i=function(e){return T(e.target)?e.srcElement||null:null!=(t=e.target)&&t.shadowRoot?e.composedPath()[0]||null:e.target||null;var t}(e);if(Cr(i)&&(i=i.parentNode||null),"$autocapture"===t&&"click"===e.type&&e instanceof MouseEvent)this.instance.config.rageclick&&null!=(r=this.rageclicks)&&r.isRageClick(e.clientX,e.clientY,(new Date).getTime())&&function(e,t){if(!window||Br(e))return!1;var r,i;if(!1===(r=L(t)?!!t&&Ur:null!==(i=null==t?void 0:t.css_selector_ignorelist)&&void 0!==i?i:Ur))return!1;var{targetElementList:s}=qr(e,!1);return!Lr(s,r)}(i,this.instance.config.rageclick)&&this._captureEvent(e,"$rageclick");var s=t===oi;if(i&&Hr(i,e,this._config,s,s?["copy","cut"]:void 0)){var{props:n,explicitNoCapture:o}=ci(i,{e:e,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this._config.element_attribute_ignorelist,elementsChainAsString:this._elementsChainAsString});if(o)return!1;var a=this.getElementSelectors(i);if(a&&a.length>0&&(n.$element_selectors=a),t===oi){var l,u=Dr(null==fe||null==(l=fe.getSelection())?void 0:l.toString()),c=e.type||"clipboard";if(!u)return!1;n.$selected_content=u,n.$copy_type=c}return this.instance.capture(t,n),!0}}}isBrowserSupported(){return C(null==me?void 0:me.querySelectorAll)}}class hi{constructor(){this._events={},this._events={}}on(e,t){return this._events[e]||(this._events[e]=[]),this._events[e].push(t),()=>{this._events[e]=this._events[e].filter((e=>e!==t))}}emit(e,t){for(var r of this._events[e]||[])r(t);for(var i of this._events["*"]||[])i(e,t)}}class pi{on(e,t){return this._eventEmitter.on(e,t)}constructor(e,t,r){var i;if(this._sessionIdChangedHandlers=[],this._beforeUnloadListener=void 0,this._eventEmitter=new hi,this._sessionHasBeenIdleTooLong=(e,t)=>Math.abs(e-t)>this.sessionTimeoutMs,!e.persistence)throw new Error("SessionIdManager requires a LeanbasePersistence instance");if("always"===e.config.cookieless_mode)throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this._config=e.config,this._persistence=e.persistence,this._windowId=void 0,this._sessionId=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this._sessionIdGenerator=t||Ye,this._windowIdGenerator=r||Ye;var s=this._config.persistence_name||this._config.token,n=this._config.session_idle_timeout_seconds||1800;if(this._sessionTimeoutMs=1e3*z(n,60,36e3,ze,1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this._resetIdleTimer(),this._window_id_storage_key="ph_"+s+"_window_id",this._primary_window_exists_storage_key="ph_"+s+"_primary_window_exists",this._canUseSessionStorage()){var o=ct._parse(this._window_id_storage_key),a=ct._parse(this._primary_window_exists_storage_key);o&&!a?this._windowId=o:ct._remove(this._window_id_storage_key),ct._set(this._primary_window_exists_storage_key,!0)}if(null!=(i=this._config.bootstrap)&&i.sessionID)try{var l=(e=>{var t=e.replace(/-/g,"");if(32!==t.length)throw new Error("Not a valid UUID");if("7"!==t[12])throw new Error("Not a UUIDv7");return parseInt(t.substring(0,12),16)})(this._config.bootstrap.sessionID);this._setSessionId(this._config.bootstrap.sessionID,(new Date).getTime(),l)}catch(e){ze.error("Invalid sessionID in bootstrap",e)}this._listenToReloadWindow()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return T(this._sessionIdChangedHandlers)&&(this._sessionIdChangedHandlers=[]),this._sessionIdChangedHandlers.push(e),this._sessionId&&e(this._sessionId,this._windowId),()=>{this._sessionIdChangedHandlers=this._sessionIdChangedHandlers.filter((t=>t!==e))}}_canUseSessionStorage(){return"memory"!==this._config.persistence&&!this._persistence._disabled&&ct._is_supported()}_setWindowId(e){e!==this._windowId&&(this._windowId=e,this._canUseSessionStorage()&&ct._set(this._window_id_storage_key,e))}_getWindowId(){return this._windowId?this._windowId:this._canUseSessionStorage()?ct._parse(this._window_id_storage_key):null}_setSessionId(e,t,r){e===this._sessionId&&t===this._sessionActivityTimestamp&&r===this._sessionStartTimestamp||(this._sessionStartTimestamp=r,this._sessionActivityTimestamp=t,this._sessionId=e,this._persistence.register({[Re]:[t,e,r]}))}_getSessionId(){if(this._sessionId&&this._sessionActivityTimestamp&&this._sessionStartTimestamp)return[this._sessionActivityTimestamp,this._sessionId,this._sessionStartTimestamp];var e=this._persistence.props[Re];return k(e)&&2===e.length&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this._setSessionId(null,null,null)}destroy(){clearTimeout(this._enforceIdleTimeout),this._enforceIdleTimeout=void 0,this._beforeUnloadListener&&fe&&(fe.removeEventListener("beforeunload",this._beforeUnloadListener,{capture:!1}),this._beforeUnloadListener=void 0),this._sessionIdChangedHandlers=[]}_listenToReloadWindow(){this._beforeUnloadListener=()=>{this._canUseSessionStorage()&&ct._remove(this._primary_window_exists_storage_key)},Ee(fe,"beforeunload",this._beforeUnloadListener,{capture:!1})}checkAndGetSessionAndWindowId(e,t){if(void 0===e&&(e=!1),void 0===t&&(t=null),"always"===this._config.cookieless_mode)throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var r=t||(new Date).getTime(),[i,s,n]=this._getSessionId(),o=this._getWindowId(),a=N(n)&&n>0&&Math.abs(r-n)>864e5,l=!1,u=!s,c=!e&&this._sessionHasBeenIdleTooLong(r,i);u||c||a?(s=this._sessionIdGenerator(),o=this._windowIdGenerator(),ze.info("new session ID generated",{sessionId:s,windowId:o,changeReason:{noSessionId:u,activityTimeout:c,sessionPastMaximumLength:a}}),n=r,l=!0):o||(o=this._windowIdGenerator(),l=!0);var d=0===i||!e||a?r:i,h=0===n?(new Date).getTime():n;return this._setWindowId(o),this._setSessionId(s,d,h),e||this._resetIdleTimer(),l&&this._sessionIdChangedHandlers.forEach((e=>e(s,o,l?{noSessionId:u,activityTimeout:c,sessionPastMaximumLength:a}:void 0))),{sessionId:s,windowId:o,sessionStartTimestamp:h,changeReason:l?{noSessionId:u,activityTimeout:c,sessionPastMaximumLength:a}:void 0,lastActivityTimestamp:i}}_resetIdleTimer(){clearTimeout(this._enforceIdleTimeout),this._enforceIdleTimeout=setTimeout((()=>{var[e]=this._getSessionId();if(this._sessionHasBeenIdleTooLong((new Date).getTime(),e)){var t=this._sessionId;this.resetSessionId(),this._eventEmitter.emit("forcedIdleReset",{idleSessionId:t})}}),1.1*this.sessionTimeoutMs)}}var gi=e=>wr(null==e?void 0:e.config.mask_personal_data_properties,null==e?void 0:e.config.custom_personal_data_properties);class fi{constructor(e,t,r,i){this._onSessionIdCallback=e=>{var t=this._getStored();if(!t||t.sessionId!==e){var r={sessionId:e,props:this._sessionSourceParamGenerator(this._instance)};this._persistence.register({[Ne]:r})}},this._instance=e,this._sessionIdManager=t,this._persistence=r,this._sessionSourceParamGenerator=i||gi,this._sessionIdManager.onSessionId(this._onSessionIdCallback)}_getStored(){return this._persistence.props[Ne]}getSetOnceProps(){var e,t=null==(e=this._getStored())?void 0:e.props;return t?"r"in t?Pr(t):{$referring_domain:t.referringDomain,$pathname:t.initialPathName,utm_source:t.utm_source,utm_campaign:t.utm_campaign,utm_medium:t.utm_medium,utm_content:t.utm_content,utm_term:t.utm_term}:{}}getSessionProps(){var e={};return Se(ke(this.getSetOnceProps()),((t,r)=>{"$current_url"===r&&(r="url"),e["$session_entry_"+S(r)]=t})),e}}class _i{constructor(e){this._instance=e}doPageView(e,t){var r,i=this._previousPageViewProperties(e,t);return this._currentPageview={pathname:null!==(r=null==fe?void 0:fe.location.pathname)&&void 0!==r?r:"",pageViewId:t,timestamp:e},this._instance.scrollManager.resetContext(),i}doPageLeave(e){var t;return this._previousPageViewProperties(e,null==(t=this._currentPageview)?void 0:t.pageViewId)}doEvent(){var e;return{$pageview_id:null==(e=this._currentPageview)?void 0:e.pageViewId}}_previousPageViewProperties(e,t){var r=this._currentPageview;if(!r)return{$pageview_id:t};var i={$pageview_id:t,$prev_pageview_id:r.pageViewId},s=this._instance.scrollManager.getContext();if(s&&!this._instance.config.disable_scroll_properties){var{maxScrollHeight:n,lastScrollY:o,maxScrollY:a,maxContentHeight:l,lastContentY:u,maxContentY:c}=s;if(!(T(n)||T(o)||T(a)||T(l)||T(u)||T(c))){n=Math.ceil(n),o=Math.ceil(o),a=Math.ceil(a),l=Math.ceil(l),u=Math.ceil(u),c=Math.ceil(c);var d=n<=1?1:z(o/n,0,1,ze),h=n<=1?1:z(a/n,0,1,ze),p=l<=1?1:z(u/l,0,1,ze),g=l<=1?1:z(c/l,0,1,ze);i=Ie(i,{$prev_pageview_last_scroll:o,$prev_pageview_last_scroll_percentage:d,$prev_pageview_max_scroll:a,$prev_pageview_max_scroll_percentage:h,$prev_pageview_last_content:u,$prev_pageview_last_content_percentage:p,$prev_pageview_max_content:c,$prev_pageview_max_content_percentage:g})}}return r.pathname&&(i.$prev_pageview_pathname=r.pathname),r.timestamp&&(i.$prev_pageview_duration=(e.getTime()-r.timestamp.getTime())/1e3),i}}class vi{constructor(e){this._instance=e,this._updateScrollData=()=>{var e,t,r,i;this._context||(this._context={});var s=this.scrollElement(),n=this.scrollY(),o=s?Math.max(0,s.scrollHeight-s.clientHeight):0,a=n+((null==s?void 0:s.clientHeight)||0),l=(null==s?void 0:s.scrollHeight)||0;this._context.lastScrollY=Math.ceil(n),this._context.maxScrollY=Math.max(n,null!==(e=this._context.maxScrollY)&&void 0!==e?e:0),this._context.maxScrollHeight=Math.max(o,null!==(t=this._context.maxScrollHeight)&&void 0!==t?t:0),this._context.lastContentY=a,this._context.maxContentY=Math.max(a,null!==(r=this._context.maxContentY)&&void 0!==r?r:0),this._context.maxContentHeight=Math.max(l,null!==(i=this._context.maxContentHeight)&&void 0!==i?i:0)}}getContext(){return this._context}resetContext(){var e=this._context;return setTimeout(this._updateScrollData,0),e}startMeasuringScrollPosition(){Ee(fe,"scroll",this._updateScrollData,{capture:!0}),Ee(fe,"scrollend",this._updateScrollData,{capture:!0}),Ee(fe,"resize",this._updateScrollData)}scrollElement(){if(!this._instance.config.scroll_root_selector)return null==fe?void 0:fe.document.documentElement;var e=k(this._instance.config.scroll_root_selector)?this._instance.config.scroll_root_selector:[this._instance.config.scroll_root_selector];for(var t of e){var r=null==fe?void 0:fe.document.querySelector(t);if(r)return r}}scrollY(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollTop||0}return fe&&(fe.scrollY||fe.pageYOffset||fe.document.documentElement.scrollTop)||0}scrollX(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollLeft||0}return fe&&(fe.scrollX||fe.pageXOffset||fe.document.documentElement.scrollLeft)||0}}var mi,yi=["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"],bi=function(e,t){if(!e)return!1;var r=e.toLowerCase();return yi.concat(t||[]).some((e=>{var t=e.toLowerCase();return-1!==r.indexOf(t)}))};!function(e){e[e.PENDING=-1]="PENDING",e[e.DENIED=0]="DENIED",e[e.GRANTED=1]="GRANTED"}(mi||(mi={}));class wi{constructor(e){this._instance=e}get _config(){return this._instance.config}get consent(){return this._getDnt()?mi.DENIED:this._storedConsent}isOptedOut(){return"always"===this._config.cookieless_mode||(this.consent===mi.DENIED||this.consent===mi.PENDING&&(this._config.opt_out_capturing_by_default||"on_reject"===this._config.cookieless_mode))}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===mi.DENIED}optInOut(e){this._storage._set(this._storageKey,e?1:0,this._config.cookie_expiration,this._config.cross_subdomain_cookie,this._config.secure_cookie)}reset(){this._storage._remove(this._storageKey,this._config.cross_subdomain_cookie)}get _storageKey(){var{token:e,opt_out_capturing_cookie_prefix:t,consent_persistence_name:r}=this._instance.config;return r||(t?t+e:"__lb_opt_in_out_"+e)}get _storedConsent(){var e=this._storage._get(this._storageKey);return q(e)?mi.GRANTED:w(H,e)?mi.DENIED:mi.PENDING}get _storage(){if(!this._persistentStore){var e=this._config.opt_out_capturing_persistence_type;this._persistentStore="localStorage"===e?st:rt;var t="localStorage"===e?rt:st;t._get(this._storageKey)&&(this._persistentStore._get(this._storageKey)||this.optInOut(q(t._get(this._storageKey))),t._remove(this._storageKey,this._config.cross_subdomain_cookie))}return this._persistentStore}_getDnt(){return!!this._config.respect_dnt&&!!function(e,t){for(var r=0;r<e.length;r++)if(t(e[r]))return e[r]}([null==ve?void 0:ve.doNotTrack,null==ve?void 0:ve.msDoNotTrack,we.doNotTrack],(e=>q(e)))}}var Pi=()=>{var e;return{host:"https://i.leanbase.co",token:"",autocapture:!0,rageclick:!0,persistence:"localStorage+cookie",capture_pageview:!0,capture_pageleave:"if_capture_pageview",persistence_name:"",mask_all_element_attributes:!1,cookie_expiration:365,cross_subdomain_cookie:Ce(null==me?void 0:me.location),custom_campaign_params:[],custom_personal_data_properties:[],disable_persistence:!1,mask_personal_data_properties:!1,secure_cookie:"https:"===(null==(e=window)||null==(e=e.location)?void 0:e.protocol),mask_all_text:!1,bootstrap:{},session_idle_timeout_seconds:1800,save_campaign_params:!0,save_referrer:!0,opt_out_useragent_filter:!1,properties_string_max_length:65535,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_capturing_persistence_type:"localStorage",consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,respect_dnt:!1,getDeviceId:e=>e,loaded:()=>{}}};class Si extends ce{constructor(e,t){var r=Ie(Pi(),t||{},{token:e});super(e,r),this.personProcessingSetOncePropertiesSent=!1,this.isLoaded=!1,this.config=r,this.visibilityStateListener=null,this.initialPageviewCaptured=!1,this.scrollManager=new vi(this),this.pageViewManager=new _i(this),this.consent=new wi(this),this.init(e,r)}init(e,t){var i,s,n;this.setConfig(Ie(Pi(),t,{token:e})),this.isLoaded=!0;var o=this._isPersistenceDisabled();this.persistence=new Er(this.config),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new Er(r({},this.config,{persistence:"sessionStorage"}),o);var a="always"===this.config.cookieless_mode||"on_reject"===this.config.cookieless_mode&&this.consent.isExplicitlyOptedOut();if(a||(this.sessionManager=new pi(this),this.sessionPropsManager=new fi(this,this.sessionManager,this.persistence)),this.replayAutocapture=new di(this),this.replayAutocapture.startIfEnabled(),!1!==this.config.preloadFeatureFlags&&this.reloadFeatureFlags(),null==(i=(s=this.config).loaded)||i.call(s,this),this.config.capture_pageview&&setTimeout((()=>{(this.consent.isOptedIn()||"always"===this.config.cookieless_mode)&&this.captureInitialPageview()}),1),this.config.disable_scroll_properties||this.scrollManager.startMeasuringScrollPosition(),void 0!==(null==(n=this.config.bootstrap)?void 0:n.distinctId)){var l,u,c=this.config.getDeviceId(Ye()),d=null!=(l=this.config.bootstrap)&&l.isIdentifiedId?c:this.config.bootstrap.distinctId;this.persistence.set_property(Me,null!=(u=this.config.bootstrap)&&u.isIdentifiedId?"identified":"anonymous"),this.register({distinct_id:this.config.bootstrap.distinctId,$device_id:d})}if(a&&this.persistence.register_once({distinct_id:"$posthog_cookieless",$device_id:null},""),!a&&!this.getDistinctId()){var h=Ye();this.persistence.register_once({distinct_id:h,$device_id:h},""),this.persistence.set_property(Me,"anonymous")}return Ee(me,"DOMContentLoaded",(()=>{this.loadRemoteConfig()})),Ee(window,"onpagehide"in self?"pagehide":"unload",this.capturePageLeave.bind(this),{passive:!1}),this}captureInitialPageview(){me&&("visible"===me.visibilityState?this.initialPageviewCaptured||(this.initialPageviewCaptured=!0,this.capture("$pageview",{title:me.title}),this.visibilityStateListener&&(me.removeEventListener("visibilitychange",this.visibilityStateListener),this.visibilityStateListener=null)):this.visibilityStateListener||(this.visibilityStateListener=this.captureInitialPageview.bind(this),Ee(me,"visibilitychange",this.visibilityStateListener)))}capturePageLeave(){var{capture_pageleave:e,capture_pageview:t}=this.config;!0!==e&&("if_capture_pageview"!==e||!0!==t&&"history_change"!==t)||this.capture("$pageleave")}loadRemoteConfig(){var e=this;return t((function*(){if(!e.isRemoteConfigLoaded){var t=yield e.reloadRemoteConfigAsync();t&&e.onRemoteConfig(t)}}))()}onRemoteConfig(e){var t;me&&me.body?(this.isRemoteConfigLoaded=!0,null==(t=this.replayAutocapture)||t.onRemoteConfig(e)):setTimeout((()=>{this.onRemoteConfig(e)}),500)}fetch(e,t){var r="undefined"!=typeof fetch?fetch:void 0!==globalThis.fetch?globalThis.fetch:void 0;return r?r(e,t):Promise.reject(new Error("Fetch API is not available in this environment."))}setConfig(e){var t,i,s=r({},this.config);A(e)&&(Ie(this.config,e),null==(t=this.persistence)||t.update_config(this.config,s),null==(i=this.replayAutocapture)||i.startIfEnabled());var n="sessionStorage"===this.config.persistence||"memory"===this.config.persistence;this.sessionPersistence=n?this.persistence:new Er(r({},this.config,{persistence:"sessionStorage"}))}getLibraryId(){return"leanbase"}getLibraryVersion(){return cr.LIB_VERSION}getCustomUserAgent(){}getPersistedProperty(e){var t;return null==(t=this.persistence)?void 0:t.get_property(e)}setPersistedProperty(e,t){var r;null==(r=this.persistence)||r.set_property(e,t)}calculateEventProperties(e,t,i,s,n){var o;if(!this.persistence||!this.sessionPersistence)return t;i=i||new Date;var a,l=n||null==(o=this.persistence)?void 0:o.remove_event_timer(e),u=r({},t);if(u.token=this.config.token,("always"==this.config.cookieless_mode||"on_reject"==this.config.cookieless_mode&&this.consent.isExplicitlyOptedOut())&&(u.$cookieless_mode=!0),"$snapshot"===e){var c=r({},this.persistence.properties());return u.distinct_id=c.distinct_id,(!R(u.distinct_id)&&!N(u.distinct_id)||(a=u.distinct_id,R(a)&&0===a.trim().length))&&ze.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),u}var d=Fr(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties);if(this.sessionManager){var{sessionId:h,windowId:p}=this.sessionManager.checkAndGetSessionAndWindowId(n,i.getTime());u.$session_id=h,u.$window_id=p}this.sessionPropsManager&&Ie(u,this.sessionPropsManager.getSessionProps());var g=this.pageViewManager.doEvent();if("$pageview"!==e||n||(g=this.pageViewManager.doPageView(i,s)),"$pageleave"!==e||n||(g=this.pageViewManager.doPageLeave(i)),u=Ie(u,g),"$pageview"===e&&me&&(u.title=me.title),!T(l)){var f=i.getTime()-l;u.$duration=parseFloat((f/1e3).toFixed(3))}return be&&this.config.opt_out_useragent_filter&&(u.$browser_type=function(e,t){if(!e)return!1;var r=e.userAgent;if(r&&bi(r,t))return!0;try{var i=null==e?void 0:e.userAgentData;if(null!=i&&i.brands&&i.brands.some((e=>bi(null==e?void 0:e.brand,t))))return!0}catch(e){}return!!e.webdriver}(ve,[])?"bot":"browser"),(u=Ie({},d,this.persistence.properties(),this.sessionPersistence.properties(),u)).$is_identified=this.isIdentified(),u}isIdentified(){var e,t;return"identified"===(null==(e=this.persistence)?void 0:e.get_property(Me))||"identified"===(null==(t=this.sessionPersistence)?void 0:t.get_property(Me))}isCapturing(){return this.consent.isOptedIn()}calculateSetOnceProperties(e){var t;if(!this.persistence)return e;if(this.personProcessingSetOncePropertiesSent)return e;var r=this.persistence.get_initial_props(),i=null==(t=this.sessionPropsManager)?void 0:t.getSetOnceProps(),s=Ie({},r,i||{},e||{});return this.personProcessingSetOncePropertiesSent=!0,O(s)?void 0:s}capture(e,t,i){if(this.isLoaded&&this.sessionPersistence&&this.persistence&&this.isCapturing())if(!T(e)&&R(e)){null!=t&&t.$current_url&&!R(null==t?void 0:t.$current_url)&&(ze.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),null==t||delete t.$current_url),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&this.sessionPersistence.update_campaign_params(),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();var s=new Date,n=(null==i?void 0:i.timestamp)||s,o=Ye(),a={uuid:o,event:e,properties:this.calculateEventProperties(e,t||{},n,o)};(null==i?void 0:i.$set)&&(a.$set=null==i?void 0:i.$set);var l=this.calculateSetOnceProperties(null==i?void 0:i.$set_once);l&&(a.$set_once=l),(a=Ae(a,null!=i&&i._noTruncate?null:this.config.properties_string_max_length)).timestamp=n,T(null==i?void 0:i.timestamp)||(a.properties.$event_time_override_provided=!0,a.properties.$event_time_override_system_time=s);var u=r({},a.properties.$set,a.$set);O(u)||this.setPersonPropertiesForFlags(u),super.capture(a.event,a.properties,i)}else ze.error("No event name provided to posthog.capture")}identify(e,t,r){super.identify(e,t,r)}destroy(){var e;null==(e=this.persistence)||e.clear()}_isPersistenceDisabled(){if("always"===this.config.cookieless_mode)return!0;var e=this.consent.isOptedOut(),t=this.config.opt_out_persistence_by_default||"on_reject"===this.config.cookieless_mode;return this.config.disable_persistence||e&&!!t}}export{Si as Leanbase};
|
|
2
2
|
//# sourceMappingURL=module.js.map
|