@askdialog/dialog-vue 3.0.0 → 3.0.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.
@@ -1,4215 +1,47 @@
1
- import { defineComponent as Me, createElementBlock as De, openBlock as ie, createElementVNode as H, toDisplayString as Ii, Fragment as fs, renderList as Tn, createVNode as Bt, createBlock as Ht, ref as wt, withDirectives as Fn, withKeys as On, vModelText as Rn, onMounted as An, watch as _s, renderSlot as Dn, computed as hi, withCtx as Mn, createCommentVNode as Ln } from "vue";
2
- var Vt;
3
- (function(r) {
4
- r.OPEN_ASSISTANT = "open_assistant", r.CLOSE_ASSISTANT = "close_assistant", r.SEND_MESSAGE = "PRODUCT_QUESTION", r.SEND_GENERIC_QUESTION = "GENERIC_QUESTION", r.TRACK_ADD_TO_CART = "TRACK_ADD_TO_CART", r.TRACK_SUBMIT_CHECKOUT = "TRACK_SUBMIT_CHECKOUT";
5
- })(Vt || (Vt = {}));
6
- var fr;
7
- (function(r) {
8
- r.USER_OPENED_ASSISTANT = "userOpenedAssistant", r.USER_CLOSED_ASSISTANT = "userClosedAssistant", r.USER_SENT_MESSAGE = "userSentMessage", r.USER_CLICKED_ON_PRODUCT_CARD = "userClickedOnProductCard", r.USER_OPENED_RECOMMENDATION = "userOpenedRecommendation", r.USER_ADDED_TO_CART = "userAddedToCart", r.USER_SEND_POSITIVE_FEEDBACK = "userSendPositiveFeedback", r.USER_SEND_NEGATIVE_FEEDBACK = "userSendNegativeFeedback";
9
- })(fr || (fr = {}));
10
- Vt.TRACK_ADD_TO_CART, Vt.TRACK_SUBMIT_CHECKOUT;
11
- var d = typeof window < "u" ? window : void 0, Y = typeof globalThis < "u" ? globalThis : d, vs = Array.prototype, _r = vs.forEach, vr = vs.indexOf, Q = Y == null ? void 0 : Y.navigator, m = Y == null ? void 0 : Y.document, z = Y == null ? void 0 : Y.location, $i = Y == null ? void 0 : Y.fetch, Ti = Y != null && Y.XMLHttpRequest && "withCredentials" in new Y.XMLHttpRequest() ? Y.XMLHttpRequest : void 0, mr = Y == null ? void 0 : Y.AbortController, W = Q == null ? void 0 : Q.userAgent, k = d ?? {}, me = { DEBUG: !1, LIB_VERSION: "1.293.0" };
12
- function yr(r, e, t, i, s, n, a) {
13
- try {
14
- var o = r[n](a), l = o.value;
15
- } catch (c) {
16
- return void t(c);
17
- }
18
- o.done ? e(l) : Promise.resolve(l).then(i, s);
19
- }
20
- function br(r) {
21
- return function() {
22
- var e = this, t = arguments;
23
- return new Promise((function(i, s) {
24
- var n = r.apply(e, t);
25
- function a(l) {
26
- yr(n, i, s, a, o, "next", l);
27
- }
28
- function o(l) {
29
- yr(n, i, s, a, o, "throw", l);
30
- }
31
- a(void 0);
32
- }));
33
- };
34
- }
35
- function w() {
36
- return w = Object.assign ? Object.assign.bind() : function(r) {
37
- for (var e = 1; e < arguments.length; e++) {
38
- var t = arguments[e];
39
- for (var i in t) ({}).hasOwnProperty.call(t, i) && (r[i] = t[i]);
40
- }
41
- return r;
42
- }, w.apply(null, arguments);
43
- }
44
- function ms(r, e) {
45
- if (r == null) return {};
46
- var t = {};
47
- for (var i in r) if ({}.hasOwnProperty.call(r, i)) {
48
- if (e.indexOf(i) !== -1) continue;
49
- t[i] = r[i];
50
- }
51
- return t;
52
- }
53
- var Nn = ["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"], wr = function(r, e) {
54
- if (e === void 0 && (e = []), !r) return !1;
55
- var t = r.toLowerCase();
56
- return Nn.concat(e).some(((i) => {
57
- var s = i.toLowerCase();
58
- return t.indexOf(s) !== -1;
59
- }));
60
- }, Un = ["$snapshot", "$pageview", "$pageleave", "$set", "survey dismissed", "survey sent", "survey shown", "$identify", "$groupidentify", "$create_alias", "$$client_ingestion_warning", "$web_experiment_applied", "$feature_enrollment_update", "$feature_flag_called"];
61
- function S(r, e) {
62
- return r.indexOf(e) !== -1;
63
- }
64
- var ni = function(r) {
65
- return r.trim();
66
- }, Fi = function(r) {
67
- return r.replace(/^\$/, "");
68
- }, qn = Array.isArray, ys = Object.prototype, bs = ys.hasOwnProperty, ai = ys.toString, F = qn || function(r) {
69
- return ai.call(r) === "[object Array]";
70
- }, Fe = (r) => typeof r == "function", j = (r) => r === Object(r) && !F(r), Xe = (r) => {
71
- if (j(r)) {
72
- for (var e in r) if (bs.call(r, e)) return !1;
73
- return !0;
74
- }
75
- return !1;
76
- }, v = (r) => r === void 0, N = (r) => ai.call(r) == "[object String]", Oi = (r) => N(r) && r.trim().length === 0, Ee = (r) => r === null, O = (r) => v(r) || Ee(r), fe = (r) => ai.call(r) == "[object Number]", Oe = (r) => ai.call(r) === "[object Boolean]", jn = (r) => r instanceof FormData, Bn = (r) => S(Un, r);
77
- function Ri(r) {
78
- return r === null || typeof r != "object";
79
- }
80
- function Gt(r, e) {
81
- return Object.prototype.toString.call(r) === "[object " + e + "]";
82
- }
83
- function ws(r) {
84
- return !v(Event) && (function(e, t) {
85
- try {
86
- return e instanceof t;
87
- } catch {
88
- return !1;
89
- }
90
- })(r, Event);
91
- }
92
- var Hn = [!0, "true", 1, "1", "yes"], di = (r) => S(Hn, r), Vn = [!1, "false", 0, "0", "no"];
93
- function de(r, e, t, i, s) {
94
- return e > t && (i.warn("min cannot be greater than max."), e = t), fe(r) ? r > t ? (i.warn(" cannot be greater than max: " + t + ". Using max value instead."), t) : r < e ? (i.warn(" cannot be less than min: " + e + ". Using min value instead."), e) : r : (i.warn(" must be a number. using max or fallback. max: " + t + ", fallback: " + s), de(s || t, e, t, i));
95
- }
96
- class Gn {
97
- constructor(e) {
98
- this.t = {}, this.i = e.i, this.o = de(e.bucketSize, 0, 100, e.h), this.m = de(e.refillRate, 0, this.o, e.h), this.$ = de(e.refillInterval, 0, 864e5, e.h);
99
- }
100
- S(e, t) {
101
- var i = t - e.lastAccess, s = Math.floor(i / this.$);
102
- if (s > 0) {
103
- var n = s * this.m;
104
- e.tokens = Math.min(e.tokens + n, this.o), e.lastAccess = e.lastAccess + s * this.$;
105
- }
106
- }
107
- consumeRateLimit(e) {
108
- var t, i = Date.now(), s = String(e), n = this.t[s];
109
- return n ? this.S(n, i) : (n = { tokens: this.o, lastAccess: i }, this.t[s] = n), n.tokens === 0 || (n.tokens--, n.tokens === 0 && ((t = this.i) == null || t.call(this, e)), n.tokens === 0);
110
- }
111
- stop() {
112
- this.t = {};
113
- }
114
- }
115
- var Ot, Er, pi, Wn = (r) => r instanceof Error;
116
- function zn(r) {
117
- var e = globalThis._posthogChunkIds;
118
- if (e) {
119
- var t = Object.keys(e);
120
- return pi && t.length === Er || (Er = t.length, pi = t.reduce(((i, s) => {
121
- Ot || (Ot = {});
122
- var n = Ot[s];
123
- if (n) i[n[0]] = n[1];
124
- else for (var a = r(s), o = a.length - 1; o >= 0; o--) {
125
- var l = a[o], c = l == null ? void 0 : l.filename, u = e[s];
126
- if (c && u) {
127
- i[c] = u, Ot[s] = [c, u];
128
- break;
129
- }
130
- }
131
- return i;
132
- }), {})), pi;
133
- }
134
- }
135
- var et = "?";
136
- function Ai(r, e, t, i) {
137
- var s = { platform: "web:javascript", filename: r, function: e === "<anonymous>" ? et : e, in_app: !0 };
138
- return v(t) || (s.lineno = t), v(i) || (s.colno = i), s;
139
- }
140
- var Es = (r, e) => {
141
- var t = r.indexOf("safari-extension") !== -1, i = r.indexOf("safari-web-extension") !== -1;
142
- return t || i ? [r.indexOf("@") !== -1 ? r.split("@")[0] : et, t ? "safari-extension:" + e : "safari-web-extension:" + e] : [r, e];
143
- }, Yn = /^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i, Kn = /^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i, Xn = /\((\S*)(?::(\d+))(?::(\d+))\)/, Jn = (r) => {
144
- var e = Yn.exec(r);
145
- if (e) {
146
- var [, t, i, s] = e;
147
- return Ai(t, et, +i, +s);
148
- }
149
- var n = Kn.exec(r);
150
- if (n) {
151
- if (n[2] && n[2].indexOf("eval") === 0) {
152
- var a = Xn.exec(n[2]);
153
- a && (n[2] = a[1], n[3] = a[2], n[4] = a[3]);
154
- }
155
- var [o, l] = Es(n[1] || et, n[2]);
156
- return Ai(l, o, n[3] ? +n[3] : void 0, n[4] ? +n[4] : void 0);
157
- }
158
- }, Zn = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i, Qn = /(\S+) line (\d+)(?: > eval line \d+)* > eval/i, ea = (r) => {
159
- var e = Zn.exec(r);
160
- if (e) {
161
- if (e[3] && e[3].indexOf(" > eval") > -1) {
162
- var t = Qn.exec(e[3]);
163
- t && (e[1] = e[1] || "eval", e[3] = t[1], e[4] = t[2], e[5] = "");
164
- }
165
- var i = e[3], s = e[1] || et;
166
- return [s, i] = Es(s, i), Ai(i, s, e[4] ? +e[4] : void 0, e[5] ? +e[5] : void 0);
167
- }
168
- }, kr = /\(error: (.*)\)/, xr = 50;
169
- function ta() {
170
- for (var r = arguments.length, e = new Array(r), t = 0; t < r; t++) e[t] = arguments[t];
171
- return function(i, s) {
172
- s === void 0 && (s = 0);
173
- for (var n = [], a = i.split(`
174
- `), o = s; o < a.length; o++) {
175
- var l = a[o];
176
- if (!(l.length > 1024)) {
177
- var c = kr.test(l) ? l.replace(kr, "$1") : l;
178
- if (!c.match(/\S*Error: /)) {
179
- for (var u of e) {
180
- var h = u(c);
181
- if (h) {
182
- n.push(h);
183
- break;
184
- }
185
- }
186
- if (n.length >= xr) break;
187
- }
188
- }
189
- }
190
- return (function(g) {
191
- if (!g.length) return [];
192
- var p = Array.from(g);
193
- return p.reverse(), p.slice(0, xr).map(((f) => {
194
- return w({}, f, { filename: f.filename || (_ = p, _[_.length - 1] || {}).filename, function: f.function || et });
195
- var _;
196
- }));
197
- })(n);
198
- };
199
- }
200
- class ia {
201
- constructor(e, t, i) {
202
- e === void 0 && (e = []), t === void 0 && (t = []), i === void 0 && (i = []), this.coercers = e, this.modifiers = i, this.stackParser = ta(...t);
203
- }
204
- buildFromUnknown(e, t) {
205
- t === void 0 && (t = {});
206
- var i = t && t.mechanism || { handled: !0, type: "generic" }, s = this.buildCoercingContext(i, t, 0).apply(e), n = this.buildParsingContext(), a = this.parseStacktrace(s, n);
207
- return { $exception_list: this.convertToExceptionList(a, i), $exception_level: "error" };
208
- }
209
- modifyFrames(e) {
210
- var t = this;
211
- return br((function* () {
212
- for (var i of e) i.stacktrace && i.stacktrace.frames && F(i.stacktrace.frames) && (i.stacktrace.frames = yield t.applyModifiers(i.stacktrace.frames));
213
- return e;
214
- }))();
215
- }
216
- coerceFallback(e) {
217
- var t;
218
- return { type: "Error", value: "Unknown error", stack: (t = e.syntheticException) == null ? void 0 : t.stack, synthetic: !0 };
219
- }
220
- parseStacktrace(e, t) {
221
- var i, s;
222
- return e.cause != null && (i = this.parseStacktrace(e.cause, t)), e.stack != "" && e.stack != null && (s = this.applyChunkIds(this.stackParser(e.stack, e.synthetic ? 1 : 0), t.chunkIdMap)), w({}, e, { cause: i, stack: s });
223
- }
224
- applyChunkIds(e, t) {
225
- return e.map(((i) => (i.filename && t && (i.chunk_id = t[i.filename]), i)));
226
- }
227
- applyCoercers(e, t) {
228
- for (var i of this.coercers) if (i.match(e)) return i.coerce(e, t);
229
- return this.coerceFallback(t);
230
- }
231
- applyModifiers(e) {
232
- var t = this;
233
- return br((function* () {
234
- var i = e;
235
- for (var s of t.modifiers) i = yield s(i);
236
- return i;
237
- }))();
238
- }
239
- convertToExceptionList(e, t) {
240
- var i, s, n, a = { type: e.type, value: e.value, mechanism: { type: (i = t.type) !== null && i !== void 0 ? i : "generic", handled: (s = t.handled) === null || s === void 0 || s, synthetic: (n = e.synthetic) !== null && n !== void 0 && n } };
241
- e.stack && (a.stacktrace = { type: "raw", frames: e.stack });
242
- var o = [a];
243
- return e.cause != null && o.push(...this.convertToExceptionList(e.cause, w({}, t, { handled: !0 }))), o;
244
- }
245
- buildParsingContext() {
246
- return { chunkIdMap: zn(this.stackParser) };
247
- }
248
- buildCoercingContext(e, t, i) {
249
- i === void 0 && (i = 0);
250
- var s = (n, a) => {
251
- if (a <= 4) {
252
- var o = this.buildCoercingContext(e, t, a);
253
- return this.applyCoercers(n, o);
254
- }
255
- };
256
- return w({}, t, { syntheticException: i == 0 ? t.syntheticException : void 0, mechanism: e, apply: (n) => s(n, i), next: (n) => s(n, i + 1) });
257
- }
258
- }
259
- class ra {
260
- match(e) {
261
- return this.isDOMException(e) || this.isDOMError(e);
262
- }
263
- coerce(e, t) {
264
- var i = N(e.stack);
265
- return { type: this.getType(e), value: this.getValue(e), stack: i ? e.stack : void 0, cause: e.cause ? t.next(e.cause) : void 0, synthetic: !1 };
266
- }
267
- getType(e) {
268
- return this.isDOMError(e) ? "DOMError" : "DOMException";
269
- }
270
- getValue(e) {
271
- var t = e.name || (this.isDOMError(e) ? "DOMError" : "DOMException");
272
- return e.message ? t + ": " + e.message : t;
273
- }
274
- isDOMException(e) {
275
- return Gt(e, "DOMException");
276
- }
277
- isDOMError(e) {
278
- return Gt(e, "DOMError");
279
- }
280
- }
281
- class sa {
282
- match(e) {
283
- return ((t) => t instanceof Error)(e);
284
- }
285
- coerce(e, t) {
286
- return { type: this.getType(e), value: this.getMessage(e, t), stack: this.getStack(e), cause: e.cause ? t.next(e.cause) : void 0, synthetic: !1 };
287
- }
288
- getType(e) {
289
- return e.name || e.constructor.name;
290
- }
291
- getMessage(e, t) {
292
- var i = e.message;
293
- return i.error && typeof i.error.message == "string" ? String(i.error.message) : String(i);
294
- }
295
- getStack(e) {
296
- return e.stacktrace || e.stack || void 0;
297
- }
298
- }
299
- class na {
300
- constructor() {
301
- }
302
- match(e) {
303
- return Gt(e, "ErrorEvent") && e.error != null;
304
- }
305
- coerce(e, t) {
306
- var i, s = t.apply(e.error);
307
- return s || { type: "ErrorEvent", value: e.message, stack: (i = t.syntheticException) == null ? void 0 : i.stack, synthetic: !0 };
308
- }
309
- }
310
- var aa = /^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;
311
- class oa {
312
- match(e) {
313
- return typeof e == "string";
314
- }
315
- coerce(e, t) {
316
- var i, [s, n] = this.getInfos(e);
317
- return { type: s ?? "Error", value: n ?? e, stack: (i = t.syntheticException) == null ? void 0 : i.stack, synthetic: !0 };
318
- }
319
- getInfos(e) {
320
- var t = "Error", i = e, s = e.match(aa);
321
- return s && (t = s[1], i = s[2]), [t, i];
322
- }
323
- }
324
- var la = ["fatal", "error", "warning", "log", "info", "debug"];
325
- function ks(r, e) {
326
- e === void 0 && (e = 40);
327
- var t = Object.keys(r);
328
- if (t.sort(), !t.length) return "[object has no keys]";
329
- for (var i = t.length; i > 0; i--) {
330
- var s = t.slice(0, i).join(", ");
331
- if (!(s.length > e)) return i === t.length || s.length <= e ? s : s.slice(0, e) + "...";
332
- }
333
- return "";
334
- }
335
- class ca {
336
- match(e) {
337
- return typeof e == "object" && e !== null;
338
- }
339
- coerce(e, t) {
340
- var i, s = this.getErrorPropertyFromObject(e);
341
- return s ? t.apply(s) : { type: this.getType(e), value: this.getValue(e), stack: (i = t.syntheticException) == null ? void 0 : i.stack, level: this.isSeverityLevel(e.level) ? e.level : "error", synthetic: !0 };
342
- }
343
- getType(e) {
344
- return ws(e) ? e.constructor.name : "Error";
345
- }
346
- getValue(e) {
347
- if ("name" in e && typeof e.name == "string") {
348
- var t = "'" + e.name + "' captured as exception";
349
- return "message" in e && typeof e.message == "string" && (t += " with message: '" + e.message + "'"), t;
350
- }
351
- if ("message" in e && typeof e.message == "string") return e.message;
352
- var i = this.getObjectClassName(e);
353
- return (i && i !== "Object" ? "'" + i + "'" : "Object") + " captured as exception with keys: " + ks(e);
354
- }
355
- isSeverityLevel(e) {
356
- return N(e) && !Oi(e) && la.indexOf(e) >= 0;
357
- }
358
- getErrorPropertyFromObject(e) {
359
- for (var t in e) if (Object.prototype.hasOwnProperty.call(e, t)) {
360
- var i = e[t];
361
- if (Wn(i)) return i;
362
- }
363
- }
364
- getObjectClassName(e) {
365
- try {
366
- var t = Object.getPrototypeOf(e);
367
- return t ? t.constructor.name : void 0;
368
- } catch {
369
- return;
370
- }
371
- }
372
- }
373
- class ua {
374
- match(e) {
375
- return ws(e);
376
- }
377
- coerce(e, t) {
378
- var i, s = e.constructor.name;
379
- return { type: s, value: s + " captured as exception with keys: " + ks(e), stack: (i = t.syntheticException) == null ? void 0 : i.stack, synthetic: !0 };
380
- }
381
- }
382
- class ha {
383
- match(e) {
384
- return Ri(e);
385
- }
386
- coerce(e, t) {
387
- var i;
388
- return { type: "Error", value: "Primitive value captured as exception: " + String(e), stack: (i = t.syntheticException) == null ? void 0 : i.stack, synthetic: !0 };
389
- }
390
- }
391
- class da {
392
- match(e) {
393
- return Gt(e, "PromiseRejectionEvent");
394
- }
395
- coerce(e, t) {
396
- var i, s = this.getUnhandledRejectionReason(e);
397
- return Ri(s) ? { type: "UnhandledRejection", value: "Non-Error promise rejection captured with value: " + String(s), stack: (i = t.syntheticException) == null ? void 0 : i.stack, synthetic: !0 } : t.apply(s);
398
- }
399
- getUnhandledRejectionReason(e) {
400
- if (Ri(e)) return e;
401
- try {
402
- if ("reason" in e) return e.reason;
403
- if ("detail" in e && "reason" in e.detail) return e.detail.reason;
404
- } catch {
405
- }
406
- return e;
407
- }
408
- }
409
- var xs = (r) => {
410
- var e = { k: function(t) {
411
- if (d && (me.DEBUG || k.POSTHOG_DEBUG) && !v(d.console) && d.console) {
412
- for (var i = ("__rrweb_original__" in d.console[t]) ? d.console[t].__rrweb_original__ : d.console[t], s = arguments.length, n = new Array(s > 1 ? s - 1 : 0), a = 1; a < s; a++) n[a - 1] = arguments[a];
413
- i(r, ...n);
414
- }
415
- }, info: function() {
416
- for (var t = arguments.length, i = new Array(t), s = 0; s < t; s++) i[s] = arguments[s];
417
- e.k("log", ...i);
418
- }, warn: function() {
419
- for (var t = arguments.length, i = new Array(t), s = 0; s < t; s++) i[s] = arguments[s];
420
- e.k("warn", ...i);
421
- }, error: function() {
422
- for (var t = arguments.length, i = new Array(t), s = 0; s < t; s++) i[s] = arguments[s];
423
- e.k("error", ...i);
424
- }, critical: function() {
425
- for (var t = arguments.length, i = new Array(t), s = 0; s < t; s++) i[s] = arguments[s];
426
- console.error(r, ...i);
427
- }, uninitializedWarning: (t) => {
428
- e.error("You must initialize PostHog before calling " + t);
429
- }, createLogger: (t) => xs(r + " " + t) };
430
- return e;
431
- }, y = xs("[PostHog.js]"), U = y.createLogger, pa = U("[ExternalScriptsLoader]"), Sr = (r, e, t) => {
432
- if (r.config.disable_external_dependency_loading) return pa.warn(e + " was requested but loading of external scripts is disabled."), t("Loading of external scripts is disabled");
433
- var i = m == null ? void 0 : m.querySelectorAll("script");
434
- if (i) {
435
- for (var s, n = function() {
436
- if (i[a].src === e) {
437
- var l = i[a];
438
- return l.__posthog_loading_callback_fired ? { v: t() } : (l.addEventListener("load", ((c) => {
439
- l.__posthog_loading_callback_fired = !0, t(void 0, c);
440
- })), l.onerror = (c) => t(c), { v: void 0 });
441
- }
442
- }, a = 0; a < i.length; a++) if (s = n()) return s.v;
443
- }
444
- var o = () => {
445
- if (!m) return t("document not found");
446
- var l = m.createElement("script");
447
- if (l.type = "text/javascript", l.crossOrigin = "anonymous", l.src = e, l.onload = (h) => {
448
- l.__posthog_loading_callback_fired = !0, t(void 0, h);
449
- }, l.onerror = (h) => t(h), r.config.prepare_external_dependency_script && (l = r.config.prepare_external_dependency_script(l)), !l) return t("prepare_external_dependency_script returned null");
450
- var c, u = m.querySelectorAll("body > script");
451
- u.length > 0 ? (c = u[0].parentNode) == null || c.insertBefore(l, u[0]) : m.body.appendChild(l);
452
- };
453
- m != null && m.body ? o() : m == null || m.addEventListener("DOMContentLoaded", o);
454
- };
455
- k.__PosthogExtensions__ = k.__PosthogExtensions__ || {}, k.__PosthogExtensions__.loadExternalDependency = (r, e, t) => {
456
- var i = "/static/" + e + ".js?v=" + r.version;
457
- if (e === "remote-config" && (i = "/array/" + r.config.token + "/config.js"), e === "toolbar") {
458
- var s = 3e5;
459
- i = i + "&t=" + Math.floor(Date.now() / s) * s;
460
- }
461
- var n = r.requestRouter.endpointFor("assets", i);
462
- Sr(r, n, t);
463
- }, k.__PosthogExtensions__.loadSiteApp = (r, e, t) => {
464
- var i = r.requestRouter.endpointFor("api", e);
465
- Sr(r, i, t);
466
- };
467
- var Wt = {};
468
- function Re(r, e, t) {
469
- if (F(r)) {
470
- if (_r && r.forEach === _r) r.forEach(e, t);
471
- else if ("length" in r && r.length === +r.length) {
472
- for (var i = 0, s = r.length; i < s; i++) if (i in r && e.call(t, r[i], i) === Wt) return;
473
- }
474
- }
475
- }
476
- function T(r, e, t) {
477
- if (!O(r)) {
478
- if (F(r)) return Re(r, e, t);
479
- if (jn(r)) {
480
- for (var i of r.entries()) if (e.call(t, i[1], i[0]) === Wt) return;
481
- } else for (var s in r) if (bs.call(r, s) && e.call(t, r[s], s) === Wt) return;
482
- }
483
- }
484
- var M = function(r) {
485
- for (var e = arguments.length, t = new Array(e > 1 ? e - 1 : 0), i = 1; i < e; i++) t[i - 1] = arguments[i];
486
- return Re(t, (function(s) {
487
- for (var n in s) s[n] !== void 0 && (r[n] = s[n]);
488
- })), r;
489
- }, st = function(r) {
490
- for (var e = arguments.length, t = new Array(e > 1 ? e - 1 : 0), i = 1; i < e; i++) t[i - 1] = arguments[i];
491
- return Re(t, (function(s) {
492
- Re(s, (function(n) {
493
- r.push(n);
494
- }));
495
- })), r;
496
- };
497
- function Ut(r) {
498
- for (var e = Object.keys(r), t = e.length, i = new Array(t); t--; ) i[t] = [e[t], r[e[t]]];
499
- return i;
500
- }
501
- var Cr = function(r) {
502
- try {
503
- return r();
504
- } catch {
505
- return;
506
- }
507
- }, ga = function(r) {
508
- return function() {
509
- try {
510
- for (var e = arguments.length, t = new Array(e), i = 0; i < e; i++) t[i] = arguments[i];
511
- return r.apply(this, t);
512
- } catch (s) {
513
- y.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."), y.critical(s);
514
- }
515
- };
516
- }, er = function(r) {
517
- var e = {};
518
- return T(r, (function(t, i) {
519
- (N(t) && t.length > 0 || fe(t)) && (e[i] = t);
520
- })), e;
521
- };
522
- function fa(r, e) {
523
- return t = r, i = (n) => N(n) && !Ee(e) ? n.slice(0, e) : n, s = /* @__PURE__ */ new Set(), (function n(a, o) {
524
- return a !== Object(a) ? i ? i(a, o) : a : s.has(a) ? void 0 : (s.add(a), F(a) ? (l = [], Re(a, ((c) => {
525
- l.push(n(c));
526
- }))) : (l = {}, T(a, ((c, u) => {
527
- s.has(c) || (l[u] = n(c, u));
528
- }))), l);
529
- var l;
530
- })(t);
531
- var t, i, s;
532
- }
533
- var _a = ["herokuapp.com", "vercel.app", "netlify.app"];
534
- function va(r) {
535
- var e = r == null ? void 0 : r.hostname;
536
- if (!N(e)) return !1;
537
- var t = e.split(".").slice(-2).join(".");
538
- for (var i of _a) if (t === i) return !1;
539
- return !0;
540
- }
541
- function Ss(r, e) {
542
- for (var t = 0; t < r.length; t++) if (e(r[t])) return r[t];
543
- }
544
- function L(r, e, t, i) {
545
- var { capture: s = !1, passive: n = !0 } = i ?? {};
546
- r == null || r.addEventListener(e, t, { capture: s, passive: n });
547
- }
548
- var Cs = "$people_distinct_id", gt = "__alias", ft = "__timers", Pr = "$autocapture_disabled_server_side", Di = "$heatmaps_enabled_server_side", Ir = "$exception_capture_enabled_server_side", Mi = "$error_tracking_suppression_rules", $r = "$error_tracking_capture_extension_exceptions", Tr = "$web_vitals_enabled_server_side", Ps = "$dead_clicks_enabled_server_side", Fr = "$web_vitals_allowed_metrics", gi = "$session_recording_remote_config", zt = "$sesid", Is = "$session_is_sampled", Je = "$enabled_feature_flags", _t = "$early_access_features", Li = "$feature_flag_details", vt = "$stored_person_properties", je = "$stored_group_properties", Ni = "$surveys", Rt = "$surveys_activated", Yt = "$flag_call_reported", ye = "$user_state", Ui = "$client_session_props", qi = "$capture_rate_limit", ji = "$initial_campaign_params", Bi = "$initial_referrer_info", Kt = "$initial_person_info", Xt = "$epp", $s = "__POSTHOG_TOOLBAR__", ot = "$posthog_cookieless", ma = [Cs, gt, "__cmpns", ft, "$session_recording_enabled_server_side", Di, zt, Je, Mi, ye, _t, Li, je, vt, Ni, Yt, Ui, qi, ji, Bi, Xt, Kt];
549
- function Or(r) {
550
- return r instanceof Element && (r.id === $s || !(r.closest == null || !r.closest(".toolbar-global-fade-container")));
551
- }
552
- function oi(r) {
553
- return !!r && r.nodeType === 1;
554
- }
555
- function Ae(r, e) {
556
- return !!r && !!r.tagName && r.tagName.toLowerCase() === e.toLowerCase();
557
- }
558
- function Ts(r) {
559
- return !!r && r.nodeType === 3;
560
- }
561
- function Fs(r) {
562
- return !!r && r.nodeType === 11;
563
- }
564
- function tr(r) {
565
- return r ? ni(r).split(/\s+/) : [];
566
- }
567
- function Rr(r) {
568
- var e = d == null ? void 0 : d.location.href;
569
- return !!(e && r && r.some(((t) => e.match(t))));
570
- }
571
- function Jt(r) {
572
- var e = "";
573
- switch (typeof r.className) {
574
- case "string":
575
- e = r.className;
576
- break;
577
- case "object":
578
- e = (r.className && "baseVal" in r.className ? r.className.baseVal : null) || r.getAttribute("class") || "";
579
- break;
580
- default:
581
- e = "";
582
- }
583
- return tr(e);
584
- }
585
- function Os(r) {
586
- return O(r) ? null : ni(r).split(/(\s+)/).filter(((e) => xt(e))).join("").replace(/[\r\n]/g, " ").replace(/[ ]+/g, " ").substring(0, 255);
587
- }
588
- function $t(r) {
589
- var e = "";
590
- return Hi(r) && !Ls(r) && r.childNodes && r.childNodes.length && T(r.childNodes, (function(t) {
591
- var i;
592
- Ts(t) && t.textContent && (e += (i = Os(t.textContent)) !== null && i !== void 0 ? i : "");
593
- })), ni(e);
594
- }
595
- function Rs(r) {
596
- return v(r.target) ? r.srcElement || null : (e = r.target) != null && e.shadowRoot ? r.composedPath()[0] || null : r.target || null;
597
- var e;
598
- }
599
- var ir = ["a", "button", "form", "input", "select", "textarea", "label"];
600
- function As(r, e) {
601
- if (v(e)) return !0;
602
- var t, i = function(n) {
603
- if (e.some(((a) => n.matches(a)))) return { v: !0 };
604
- };
605
- for (var s of r) if (t = i(s)) return t.v;
606
- return !1;
607
- }
608
- function Ds(r) {
609
- var e = r.parentNode;
610
- return !(!e || !oi(e)) && e;
611
- }
612
- var ya = ["next", "previous", "prev", ">", "<"], Ar = 10, Dr = [".ph-no-rageclick", ".ph-no-capture"];
613
- function ba(r, e) {
614
- if (!d || rr(r)) return !1;
615
- var t, i, s;
616
- if (Oe(e) ? (t = !!e && Dr, i = void 0) : (t = (s = e == null ? void 0 : e.css_selector_ignorelist) !== null && s !== void 0 ? s : Dr, i = e == null ? void 0 : e.content_ignorelist), t === !1) return !1;
617
- var { targetElementList: n } = Ms(r, !1);
618
- return !(function(a, o) {
619
- if (a === !1 || v(a)) return !1;
620
- var l;
621
- if (a === !0) l = ya;
622
- else {
623
- if (!F(a)) return !1;
624
- if (a.length > Ar) return y.error("[PostHog] content_ignorelist array cannot exceed " + Ar + " items. Use css_selector_ignorelist for more complex matching."), !1;
625
- l = a.map(((c) => c.toLowerCase()));
626
- }
627
- return o.some(((c) => {
628
- var { safeText: u, ariaLabel: h } = c;
629
- return l.some(((g) => u.includes(g) || h.includes(g)));
630
- }));
631
- })(i, n.map(((a) => {
632
- var o;
633
- return { safeText: $t(a).toLowerCase(), ariaLabel: ((o = a.getAttribute("aria-label")) == null ? void 0 : o.toLowerCase().trim()) || "" };
634
- }))) && !As(n, t);
635
- }
636
- var rr = (r) => !r || Ae(r, "html") || !oi(r), Ms = (r, e) => {
637
- if (!d || rr(r)) return { parentIsUsefulElement: !1, targetElementList: [] };
638
- for (var t = !1, i = [r], s = r; s.parentNode && !Ae(s, "body"); ) if (Fs(s.parentNode)) i.push(s.parentNode.host), s = s.parentNode.host;
639
- else {
640
- var n = Ds(s);
641
- if (!n) break;
642
- if (e || ir.indexOf(n.tagName.toLowerCase()) > -1) t = !0;
643
- else {
644
- var a = d.getComputedStyle(n);
645
- a && a.getPropertyValue("cursor") === "pointer" && (t = !0);
646
- }
647
- i.push(n), s = n;
648
- }
649
- return { parentIsUsefulElement: t, targetElementList: i };
650
- };
651
- function wa(r, e, t, i, s) {
652
- var n, a, o, l;
653
- if (t === void 0 && (t = void 0), !d || rr(r) || (n = t) != null && n.url_allowlist && !Rr(t.url_allowlist) || (a = t) != null && a.url_ignorelist && Rr(t.url_ignorelist)) return !1;
654
- if ((o = t) != null && o.dom_event_allowlist) {
655
- var c = t.dom_event_allowlist;
656
- if (c && !c.some(((f) => e.type === f))) return !1;
657
- }
658
- var { parentIsUsefulElement: u, targetElementList: h } = Ms(r, i);
659
- if (!(function(f, _) {
660
- var b = _ == null ? void 0 : _.element_allowlist;
661
- if (v(b)) return !0;
662
- var E, x = function(C) {
663
- if (b.some(((D) => C.tagName.toLowerCase() === D))) return { v: !0 };
664
- };
665
- for (var I of f) if (E = x(I)) return E.v;
666
- return !1;
667
- })(h, t) || !As(h, (l = t) == null ? void 0 : l.css_selector_allowlist)) return !1;
668
- var g = d.getComputedStyle(r);
669
- if (g && g.getPropertyValue("cursor") === "pointer" && e.type === "click") return !0;
670
- var p = r.tagName.toLowerCase();
671
- switch (p) {
672
- case "html":
673
- return !1;
674
- case "form":
675
- return (s || ["submit"]).indexOf(e.type) >= 0;
676
- case "input":
677
- case "select":
678
- case "textarea":
679
- return (s || ["change", "click"]).indexOf(e.type) >= 0;
680
- default:
681
- return u ? (s || ["click"]).indexOf(e.type) >= 0 : (s || ["click"]).indexOf(e.type) >= 0 && (ir.indexOf(p) > -1 || r.getAttribute("contenteditable") === "true");
682
- }
683
- }
684
- function Hi(r) {
685
- for (var e = r; e.parentNode && !Ae(e, "body"); e = e.parentNode) {
686
- var t = Jt(e);
687
- if (S(t, "ph-sensitive") || S(t, "ph-no-capture")) return !1;
688
- }
689
- if (S(Jt(r), "ph-include")) return !0;
690
- var i = r.type || "";
691
- if (N(i)) switch (i.toLowerCase()) {
692
- case "hidden":
693
- case "password":
694
- return !1;
695
- }
696
- var s = r.name || r.id || "";
697
- return !(N(s) && /^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(s.replace(/[^a-zA-Z0-9]/g, "")));
698
- }
699
- function Ls(r) {
700
- return !!(Ae(r, "input") && !["button", "checkbox", "submit", "reset"].includes(r.type) || Ae(r, "select") || Ae(r, "textarea") || r.getAttribute("contenteditable") === "true");
701
- }
702
- var Ns = "(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})", Ea = new RegExp("^(?:" + Ns + ")$"), ka = new RegExp(Ns), Us = "\\d{3}-?\\d{2}-?\\d{4}", xa = new RegExp("^(" + Us + ")$"), Sa = new RegExp("(" + Us + ")");
703
- function xt(r, e) {
704
- return e === void 0 && (e = !0), !(O(r) || N(r) && (r = ni(r), (e ? Ea : ka).test((r || "").replace(/[- ]/g, "")) || (e ? xa : Sa).test(r)));
705
- }
706
- function qs(r) {
707
- var e = $t(r);
708
- return xt(e = (e + " " + js(r)).trim()) ? e : "";
709
- }
710
- function js(r) {
711
- var e = "";
712
- return r && r.childNodes && r.childNodes.length && T(r.childNodes, (function(t) {
713
- var i;
714
- if (t && ((i = t.tagName) == null ? void 0 : i.toLowerCase()) === "span") try {
715
- var s = $t(t);
716
- e = (e + " " + s).trim(), t.childNodes && t.childNodes.length && (e = (e + " " + js(t)).trim());
717
- } catch (n) {
718
- y.error("[AutoCapture]", n);
719
- }
720
- })), e;
721
- }
722
- function Ca(r) {
723
- return (function(e) {
724
- var t = e.map(((i) => {
725
- var s, n, a = "";
726
- if (i.tag_name && (a += i.tag_name), i.attr_class) for (var o of (i.attr_class.sort(), i.attr_class)) a += "." + o.replace(/"/g, "");
727
- var l = w({}, i.text ? { text: i.text } : {}, { "nth-child": (s = i.nth_child) !== null && s !== void 0 ? s : 0, "nth-of-type": (n = i.nth_of_type) !== null && n !== void 0 ? n : 0 }, i.href ? { href: i.href } : {}, i.attr_id ? { attr_id: i.attr_id } : {}, i.attributes), c = {};
728
- return Ut(l).sort(((u, h) => {
729
- var [g] = u, [p] = h;
730
- return g.localeCompare(p);
731
- })).forEach(((u) => {
732
- var [h, g] = u;
733
- return c[Mr(h.toString())] = Mr(g.toString());
734
- })), a += ":", a += Ut(c).map(((u) => {
735
- var [h, g] = u;
736
- return h + '="' + g + '"';
737
- })).join("");
738
- }));
739
- return t.join(";");
740
- })((function(e) {
741
- return e.map(((t) => {
742
- var i, s, n = { text: (i = t.$el_text) == null ? void 0 : i.slice(0, 400), tag_name: t.tag_name, href: (s = t.attr__href) == null ? void 0 : s.slice(0, 2048), attr_class: Pa(t), attr_id: t.attr__id, nth_child: t.nth_child, nth_of_type: t.nth_of_type, attributes: {} };
743
- return Ut(t).filter(((a) => {
744
- var [o] = a;
745
- return o.indexOf("attr__") === 0;
746
- })).forEach(((a) => {
747
- var [o, l] = a;
748
- return n.attributes[o] = l;
749
- })), n;
750
- }));
751
- })(r));
752
- }
753
- function Mr(r) {
754
- return r.replace(/"|\\"/g, '\\"');
755
- }
756
- function Pa(r) {
757
- var e = r.attr__class;
758
- return e ? F(e) ? e : tr(e) : void 0;
759
- }
760
- class Bs {
761
- constructor(e) {
762
- this.disabled = e === !1;
763
- var t = j(e) ? e : {};
764
- this.thresholdPx = t.threshold_px || 30, this.timeoutMs = t.timeout_ms || 1e3, this.clickCount = t.click_count || 3, this.clicks = [];
765
- }
766
- isRageClick(e, t, i) {
767
- if (this.disabled) return !1;
768
- var s = this.clicks[this.clicks.length - 1];
769
- if (s && Math.abs(e - s.x) + Math.abs(t - s.y) < this.thresholdPx && i - s.timestamp < this.timeoutMs) {
770
- if (this.clicks.push({ x: e, y: t, timestamp: i }), this.clicks.length === this.clickCount) return !0;
771
- } else this.clicks = [{ x: e, y: t, timestamp: i }];
772
- return !1;
773
- }
774
- }
775
- var fi = "$copy_autocapture", we = (function(r) {
776
- return r.GZipJS = "gzip-js", r.Base64 = "base64", r;
777
- })({}), Zt = (r) => {
778
- var e = m == null ? void 0 : m.createElement("a");
779
- return v(e) ? null : (e.href = r, e);
780
- }, Ia = function(r, e) {
781
- var t, i;
782
- e === void 0 && (e = "&");
783
- var s = [];
784
- return T(r, (function(n, a) {
785
- v(n) || v(a) || a === "undefined" || (t = encodeURIComponent(((o) => o instanceof File)(n) ? n.name : n.toString()), i = encodeURIComponent(a), s[s.length] = i + "=" + t);
786
- })), s.join(e);
787
- }, Qt = function(r, e) {
788
- for (var t, i = ((r.split("#")[0] || "").split(/\?(.*)/)[1] || "").replace(/^\?+/g, "").split("&"), s = 0; s < i.length; s++) {
789
- var n = i[s].split("=");
790
- if (n[0] === e) {
791
- t = n;
792
- break;
793
- }
794
- }
795
- if (!F(t) || t.length < 2) return "";
796
- var a = t[1];
797
- try {
798
- a = decodeURIComponent(a);
799
- } catch {
800
- y.error("Skipping decoding for malformed query param: " + a);
801
- }
802
- return a.replace(/\+/g, " ");
803
- }, Tt = function(r, e, t) {
804
- if (!r || !e || !e.length) return r;
805
- for (var i = r.split("#"), s = i[0] || "", n = i[1], a = s.split("?"), o = a[1], l = a[0], c = (o || "").split("&"), u = [], h = 0; h < c.length; h++) {
806
- var g = c[h].split("=");
807
- F(g) && (e.includes(g[0]) ? u.push(g[0] + "=" + t) : u.push(c[h]));
808
- }
809
- var p = l;
810
- return o != null && (p += "?" + u.join("&")), n != null && (p += "#" + n), p;
811
- }, ei = function(r, e) {
812
- var t = r.match(new RegExp(e + "=([^&]*)"));
813
- return t ? t[1] : null;
814
- }, Lr = U("[AutoCapture]");
815
- function _i(r, e) {
816
- return e.length > r ? e.slice(0, r) + "..." : e;
817
- }
818
- function $a(r) {
819
- if (r.previousElementSibling) return r.previousElementSibling;
820
- var e = r;
821
- do
822
- e = e.previousSibling;
823
- while (e && !oi(e));
824
- return e;
825
- }
826
- function Ta(r, e, t, i) {
827
- var s = r.tagName.toLowerCase(), n = { tag_name: s };
828
- ir.indexOf(s) > -1 && !t && (s.toLowerCase() === "a" || s.toLowerCase() === "button" ? n.$el_text = _i(1024, qs(r)) : n.$el_text = _i(1024, $t(r)));
829
- var a = Jt(r);
830
- a.length > 0 && (n.classes = a.filter((function(u) {
831
- return u !== "";
832
- }))), T(r.attributes, (function(u) {
833
- var h;
834
- if ((!Ls(r) || ["name", "id", "class", "aria-label"].indexOf(u.name) !== -1) && (i == null || !i.includes(u.name)) && !e && xt(u.value) && (h = u.name, !N(h) || h.substring(0, 10) !== "_ngcontent" && h.substring(0, 7) !== "_nghost")) {
835
- var g = u.value;
836
- u.name === "class" && (g = tr(g).join(" ")), n["attr__" + u.name] = _i(1024, g);
837
- }
838
- }));
839
- for (var o = 1, l = 1, c = r; c = $a(c); ) o++, c.tagName === r.tagName && l++;
840
- return n.nth_child = o, n.nth_of_type = l, n;
841
- }
842
- function Fa(r, e) {
843
- for (var t, i, { e: s, maskAllElementAttributes: n, maskAllText: a, elementAttributeIgnoreList: o, elementsChainAsString: l } = e, c = [r], u = r; u.parentNode && !Ae(u, "body"); ) Fs(u.parentNode) ? (c.push(u.parentNode.host), u = u.parentNode.host) : (c.push(u.parentNode), u = u.parentNode);
844
- var h, g = [], p = {}, f = !1, _ = !1;
845
- if (T(c, ((C) => {
846
- var D = Hi(C);
847
- C.tagName.toLowerCase() === "a" && (f = C.getAttribute("href"), f = D && f && xt(f) && f), S(Jt(C), "ph-no-capture") && (_ = !0), g.push(Ta(C, n, a, o));
848
- var ne = (function(X) {
849
- if (!Hi(X)) return {};
850
- var P = {};
851
- return T(X.attributes, (function(le) {
852
- if (le.name && le.name.indexOf("data-ph-capture-attribute") === 0) {
853
- var J = le.name.replace("data-ph-capture-attribute-", ""), ae = le.value;
854
- J && ae && xt(ae) && (P[J] = ae);
855
- }
856
- })), P;
857
- })(C);
858
- M(p, ne);
859
- })), _) return { props: {}, explicitNoCapture: _ };
860
- if (a || (r.tagName.toLowerCase() === "a" || r.tagName.toLowerCase() === "button" ? g[0].$el_text = qs(r) : g[0].$el_text = $t(r)), f) {
861
- var b, E;
862
- g[0].attr__href = f;
863
- var x = (b = Zt(f)) == null ? void 0 : b.host, I = d == null || (E = d.location) == null ? void 0 : E.host;
864
- x && I && x !== I && (h = f);
865
- }
866
- return { props: M({ $event_type: s.type, $ce_version: 1 }, l ? {} : { $elements: g }, { $elements_chain: Ca(g) }, (t = g[0]) != null && t.$el_text ? { $el_text: (i = g[0]) == null ? void 0 : i.$el_text } : {}, h && s.type === "click" ? { $external_click_url: h } : {}, p) };
867
- }
868
- class Oa {
869
- constructor(e) {
870
- this.P = !1, this.T = null, this.I = !1, this.instance = e, this.rageclicks = new Bs(e.config.rageclick), this.R = null;
871
- }
872
- get C() {
873
- var e, t, i = j(this.instance.config.autocapture) ? this.instance.config.autocapture : {};
874
- return i.url_allowlist = (e = i.url_allowlist) == null ? void 0 : e.map(((s) => new RegExp(s))), i.url_ignorelist = (t = i.url_ignorelist) == null ? void 0 : t.map(((s) => new RegExp(s))), i;
875
- }
876
- O() {
877
- if (this.isBrowserSupported()) {
878
- if (d && m) {
879
- var e = (i) => {
880
- i = i || (d == null ? void 0 : d.event);
881
- try {
882
- this.F(i);
883
- } catch (s) {
884
- Lr.error("Failed to capture event", s);
885
- }
886
- };
887
- if (L(m, "submit", e, { capture: !0 }), L(m, "change", e, { capture: !0 }), L(m, "click", e, { capture: !0 }), this.C.capture_copied_text) {
888
- var t = (i) => {
889
- i = i || (d == null ? void 0 : d.event), this.F(i, fi);
890
- };
891
- L(m, "copy", t, { capture: !0 }), L(m, "cut", t, { capture: !0 });
892
- }
893
- }
894
- } else Lr.info("Disabling Automatic Event Collection because this browser is not supported");
895
- }
896
- startIfEnabled() {
897
- this.isEnabled && !this.P && (this.O(), this.P = !0);
898
- }
899
- onRemoteConfig(e) {
900
- e.elementsChainAsString && (this.I = e.elementsChainAsString), this.instance.persistence && this.instance.persistence.register({ [Pr]: !!e.autocapture_opt_out }), this.T = !!e.autocapture_opt_out, this.startIfEnabled();
901
- }
902
- setElementSelectors(e) {
903
- this.R = e;
904
- }
905
- getElementSelectors(e) {
906
- var t, i = [];
907
- return (t = this.R) == null || t.forEach(((s) => {
908
- var n = m == null ? void 0 : m.querySelectorAll(s);
909
- n == null || n.forEach(((a) => {
910
- e === a && i.push(s);
911
- }));
912
- })), i;
913
- }
914
- get isEnabled() {
915
- var e, t, i = (e = this.instance.persistence) == null ? void 0 : e.props[Pr], s = this.T;
916
- if (Ee(s) && !Oe(i) && !this.instance.M()) return !1;
917
- var n = (t = this.T) !== null && t !== void 0 ? t : !!i;
918
- return !!this.instance.config.autocapture && !n;
919
- }
920
- F(e, t) {
921
- if (t === void 0 && (t = "$autocapture"), this.isEnabled) {
922
- var i, s = Rs(e);
923
- Ts(s) && (s = s.parentNode || null), t === "$autocapture" && e.type === "click" && e instanceof MouseEvent && this.instance.config.rageclick && (i = this.rageclicks) != null && i.isRageClick(e.clientX, e.clientY, e.timeStamp || (/* @__PURE__ */ new Date()).getTime()) && ba(s, this.instance.config.rageclick) && this.F(e, "$rageclick");
924
- var n = t === fi;
925
- if (s && wa(s, e, this.C, n, n ? ["copy", "cut"] : void 0)) {
926
- var { props: a, explicitNoCapture: o } = Fa(s, { e, maskAllElementAttributes: this.instance.config.mask_all_element_attributes, maskAllText: this.instance.config.mask_all_text, elementAttributeIgnoreList: this.C.element_attribute_ignorelist, elementsChainAsString: this.I });
927
- if (o) return !1;
928
- var l = this.getElementSelectors(s);
929
- if (l && l.length > 0 && (a.$element_selectors = l), t === fi) {
930
- var c, u = Os(d == null || (c = d.getSelection()) == null ? void 0 : c.toString()), h = e.type || "clipboard";
931
- if (!u) return !1;
932
- a.$selected_content = u, a.$copy_type = h;
933
- }
934
- return this.instance.capture(t, a), !0;
935
- }
936
- }
937
- }
938
- isBrowserSupported() {
939
- return Fe(m == null ? void 0 : m.querySelectorAll);
940
- }
941
- }
942
- Math.trunc || (Math.trunc = function(r) {
943
- return r < 0 ? Math.ceil(r) : Math.floor(r);
944
- }), Number.isInteger || (Number.isInteger = function(r) {
945
- return fe(r) && isFinite(r) && Math.floor(r) === r;
946
- });
947
- var Nr = "0123456789abcdef";
948
- class ti {
949
- constructor(e) {
950
- if (this.bytes = e, e.length !== 16) throw new TypeError("not 128-bit length");
951
- }
952
- static fromFieldsV7(e, t, i, s) {
953
- if (!Number.isInteger(e) || !Number.isInteger(t) || !Number.isInteger(i) || !Number.isInteger(s) || e < 0 || t < 0 || i < 0 || s < 0 || e > 281474976710655 || t > 4095 || i > 1073741823 || s > 4294967295) throw new RangeError("invalid field value");
954
- var n = new Uint8Array(16);
955
- return n[0] = e / Math.pow(2, 40), n[1] = e / Math.pow(2, 32), n[2] = e / Math.pow(2, 24), n[3] = e / Math.pow(2, 16), n[4] = e / Math.pow(2, 8), n[5] = e, n[6] = 112 | t >>> 8, n[7] = t, 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 ti(n);
956
- }
957
- toString() {
958
- for (var e = "", t = 0; t < this.bytes.length; t++) e = e + Nr.charAt(this.bytes[t] >>> 4) + Nr.charAt(15 & this.bytes[t]), t !== 3 && t !== 5 && t !== 7 && t !== 9 || (e += "-");
959
- if (e.length !== 36) throw new Error("Invalid UUIDv7 was generated");
960
- return e;
961
- }
962
- clone() {
963
- return new ti(this.bytes.slice(0));
964
- }
965
- equals(e) {
966
- return this.compareTo(e) === 0;
967
- }
968
- compareTo(e) {
969
- for (var t = 0; t < 16; t++) {
970
- var i = this.bytes[t] - e.bytes[t];
971
- if (i !== 0) return Math.sign(i);
972
- }
973
- return 0;
974
- }
975
- }
976
- class Ra {
977
- constructor() {
978
- this.A = 0, this.D = 0, this.j = new Aa();
979
- }
980
- generate() {
981
- var e = this.generateOrAbort();
982
- if (v(e)) {
983
- this.A = 0;
984
- var t = this.generateOrAbort();
985
- if (v(t)) throw new Error("Could not generate UUID after timestamp reset");
986
- return t;
987
- }
988
- return e;
989
- }
990
- generateOrAbort() {
991
- var e = Date.now();
992
- if (e > this.A) this.A = e, this.L();
993
- else {
994
- if (!(e + 1e4 > this.A)) return;
995
- this.D++, this.D > 4398046511103 && (this.A++, this.L());
996
- }
997
- return ti.fromFieldsV7(this.A, Math.trunc(this.D / Math.pow(2, 30)), this.D & Math.pow(2, 30) - 1, this.j.nextUint32());
998
- }
999
- L() {
1000
- this.D = 1024 * this.j.nextUint32() + (1023 & this.j.nextUint32());
1001
- }
1002
- }
1003
- var Ur, Hs = (r) => {
1004
- if (typeof UUIDV7_DENY_WEAK_RNG < "u" && UUIDV7_DENY_WEAK_RNG) throw new Error("no cryptographically strong RNG available");
1005
- for (var e = 0; e < r.length; e++) r[e] = 65536 * Math.trunc(65536 * Math.random()) + Math.trunc(65536 * Math.random());
1006
- return r;
1007
- };
1008
- d && !v(d.crypto) && crypto.getRandomValues && (Hs = (r) => crypto.getRandomValues(r));
1009
- class Aa {
1010
- constructor() {
1011
- this.N = new Uint32Array(8), this.U = 1 / 0;
1012
- }
1013
- nextUint32() {
1014
- return this.U >= this.N.length && (Hs(this.N), this.U = 0), this.N[this.U++];
1015
- }
1016
- }
1017
- var Te = () => Da().toString(), Da = () => (Ur || (Ur = new Ra())).generate(), lt = "", Ma = /[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;
1018
- function La(r, e) {
1019
- if (e) {
1020
- var t = (function(s, n) {
1021
- if (n === void 0 && (n = m), lt) return lt;
1022
- if (!n || ["localhost", "127.0.0.1"].includes(s)) return "";
1023
- for (var a = s.split("."), o = Math.min(a.length, 8), l = "dmn_chk_" + Te(); !lt && o--; ) {
1024
- var c = a.slice(o).join("."), u = l + "=1;domain=." + c + ";path=/";
1025
- n.cookie = u + ";max-age=3", n.cookie.includes(l) && (n.cookie = u + ";max-age=0", lt = c);
1026
- }
1027
- return lt;
1028
- })(r);
1029
- if (!t) {
1030
- var i = ((s) => {
1031
- var n = s.match(Ma);
1032
- return n ? n[0] : "";
1033
- })(r);
1034
- i !== t && y.info("Warning: cookie subdomain discovery mismatch", i, t), t = i;
1035
- }
1036
- return t ? "; domain=." + t : "";
1037
- }
1038
- return "";
1039
- }
1040
- var ge = { H: () => !!m, B: function(r) {
1041
- y.error("cookieStore error: " + r);
1042
- }, q: function(r) {
1043
- if (m) {
1044
- try {
1045
- for (var e = r + "=", t = m.cookie.split(";").filter(((n) => n.length)), i = 0; i < t.length; i++) {
1046
- for (var s = t[i]; s.charAt(0) == " "; ) s = s.substring(1, s.length);
1047
- if (s.indexOf(e) === 0) return decodeURIComponent(s.substring(e.length, s.length));
1048
- }
1049
- } catch {
1050
- }
1051
- return null;
1052
- }
1053
- }, W: function(r) {
1054
- var e;
1055
- try {
1056
- e = JSON.parse(ge.q(r)) || {};
1057
- } catch {
1058
- }
1059
- return e;
1060
- }, G: function(r, e, t, i, s) {
1061
- if (m) try {
1062
- var n = "", a = "", o = La(m.location.hostname, i);
1063
- if (t) {
1064
- var l = /* @__PURE__ */ new Date();
1065
- l.setTime(l.getTime() + 24 * t * 60 * 60 * 1e3), n = "; expires=" + l.toUTCString();
1066
- }
1067
- s && (a = "; secure");
1068
- var c = r + "=" + encodeURIComponent(JSON.stringify(e)) + n + "; SameSite=Lax; path=/" + o + a;
1069
- return c.length > 3686.4 && y.warn("cookieStore warning: large cookie, len=" + c.length), m.cookie = c, c;
1070
- } catch {
1071
- return;
1072
- }
1073
- }, V: function(r, e) {
1074
- if (m != null && m.cookie) try {
1075
- ge.G(r, "", -1, e);
1076
- } catch {
1077
- return;
1078
- }
1079
- } }, vi = null, A = { H: function() {
1080
- if (!Ee(vi)) return vi;
1081
- var r = !0;
1082
- if (v(d)) r = !1;
1083
- else try {
1084
- var e = "__mplssupport__";
1085
- A.G(e, "xyz"), A.q(e) !== '"xyz"' && (r = !1), A.V(e);
1086
- } catch {
1087
- r = !1;
1088
- }
1089
- return r || y.error("localStorage unsupported; falling back to cookie store"), vi = r, r;
1090
- }, B: function(r) {
1091
- y.error("localStorage error: " + r);
1092
- }, q: function(r) {
1093
- try {
1094
- return d == null ? void 0 : d.localStorage.getItem(r);
1095
- } catch (e) {
1096
- A.B(e);
1097
- }
1098
- return null;
1099
- }, W: function(r) {
1100
- try {
1101
- return JSON.parse(A.q(r)) || {};
1102
- } catch {
1103
- }
1104
- return null;
1105
- }, G: function(r, e) {
1106
- try {
1107
- d == null || d.localStorage.setItem(r, JSON.stringify(e));
1108
- } catch (t) {
1109
- A.B(t);
1110
- }
1111
- }, V: function(r) {
1112
- try {
1113
- d == null || d.localStorage.removeItem(r);
1114
- } catch (e) {
1115
- A.B(e);
1116
- }
1117
- } }, Na = ["distinct_id", zt, Is, Xt, Kt], At = w({}, A, { W: function(r) {
1118
- try {
1119
- var e = {};
1120
- try {
1121
- e = ge.W(r) || {};
1122
- } catch {
1123
- }
1124
- var t = M(e, JSON.parse(A.q(r) || "{}"));
1125
- return A.G(r, t), t;
1126
- } catch {
1127
- }
1128
- return null;
1129
- }, G: function(r, e, t, i, s, n) {
1130
- try {
1131
- A.G(r, e, void 0, void 0, n);
1132
- var a = {};
1133
- Na.forEach(((o) => {
1134
- e[o] && (a[o] = e[o]);
1135
- })), Object.keys(a).length && ge.G(r, a, t, i, s, n);
1136
- } catch (o) {
1137
- A.B(o);
1138
- }
1139
- }, V: function(r, e) {
1140
- try {
1141
- d == null || d.localStorage.removeItem(r), ge.V(r, e);
1142
- } catch (t) {
1143
- A.B(t);
1144
- }
1145
- } }), Dt = {}, Ua = { H: function() {
1146
- return !0;
1147
- }, B: function(r) {
1148
- y.error("memoryStorage error: " + r);
1149
- }, q: function(r) {
1150
- return Dt[r] || null;
1151
- }, W: function(r) {
1152
- return Dt[r] || null;
1153
- }, G: function(r, e) {
1154
- Dt[r] = e;
1155
- }, V: function(r) {
1156
- delete Dt[r];
1157
- } }, Ne = null, q = { H: function() {
1158
- if (!Ee(Ne)) return Ne;
1159
- if (Ne = !0, v(d)) Ne = !1;
1160
- else try {
1161
- var r = "__support__";
1162
- q.G(r, "xyz"), q.q(r) !== '"xyz"' && (Ne = !1), q.V(r);
1163
- } catch {
1164
- Ne = !1;
1165
- }
1166
- return Ne;
1167
- }, B: function(r) {
1168
- y.error("sessionStorage error: ", r);
1169
- }, q: function(r) {
1170
- try {
1171
- return d == null ? void 0 : d.sessionStorage.getItem(r);
1172
- } catch (e) {
1173
- q.B(e);
1174
- }
1175
- return null;
1176
- }, W: function(r) {
1177
- try {
1178
- return JSON.parse(q.q(r)) || null;
1179
- } catch {
1180
- }
1181
- return null;
1182
- }, G: function(r, e) {
1183
- try {
1184
- d == null || d.sessionStorage.setItem(r, JSON.stringify(e));
1185
- } catch (t) {
1186
- q.B(t);
1187
- }
1188
- }, V: function(r) {
1189
- try {
1190
- d == null || d.sessionStorage.removeItem(r);
1191
- } catch (e) {
1192
- q.B(e);
1193
- }
1194
- } }, be = (function(r) {
1195
- return r[r.PENDING = -1] = "PENDING", r[r.DENIED = 0] = "DENIED", r[r.GRANTED = 1] = "GRANTED", r;
1196
- })({});
1197
- class qa {
1198
- constructor(e) {
1199
- this._instance = e;
1200
- }
1201
- get C() {
1202
- return this._instance.config;
1203
- }
1204
- get consent() {
1205
- return this.J() ? be.DENIED : this.K;
1206
- }
1207
- isOptedOut() {
1208
- return this.C.cookieless_mode === "always" || this.consent === be.DENIED || this.consent === be.PENDING && (this.C.opt_out_capturing_by_default || this.C.cookieless_mode === "on_reject");
1209
- }
1210
- isOptedIn() {
1211
- return !this.isOptedOut();
1212
- }
1213
- isExplicitlyOptedOut() {
1214
- return this.consent === be.DENIED;
1215
- }
1216
- optInOut(e) {
1217
- this.Y.G(this.X, e ? 1 : 0, this.C.cookie_expiration, this.C.cross_subdomain_cookie, this.C.secure_cookie);
1218
- }
1219
- reset() {
1220
- this.Y.V(this.X, this.C.cross_subdomain_cookie);
1221
- }
1222
- get X() {
1223
- var { token: e, opt_out_capturing_cookie_prefix: t, consent_persistence_name: i } = this._instance.config;
1224
- return i || (t ? t + e : "__ph_opt_in_out_" + e);
1225
- }
1226
- get K() {
1227
- var e = this.Y.q(this.X);
1228
- return di(e) ? be.GRANTED : S(Vn, e) ? be.DENIED : be.PENDING;
1229
- }
1230
- get Y() {
1231
- if (!this.Z) {
1232
- var e = this.C.opt_out_capturing_persistence_type;
1233
- this.Z = e === "localStorage" ? A : ge;
1234
- var t = e === "localStorage" ? ge : A;
1235
- t.q(this.X) && (this.Z.q(this.X) || this.optInOut(di(t.q(this.X))), t.V(this.X, this.C.cross_subdomain_cookie));
1236
- }
1237
- return this.Z;
1238
- }
1239
- J() {
1240
- return !!this.C.respect_dnt && !!Ss([Q == null ? void 0 : Q.doNotTrack, Q == null ? void 0 : Q.msDoNotTrack, k.doNotTrack], ((e) => di(e)));
1241
- }
1242
- }
1243
- var Mt = U("[Dead Clicks]"), ja = () => !0, Ba = (r) => {
1244
- var e, t = !((e = r.instance.persistence) == null || !e.get_property(Ps)), i = r.instance.config.capture_dead_clicks;
1245
- return Oe(i) ? i : t;
1246
- };
1247
- class Vs {
1248
- get lazyLoadedDeadClicksAutocapture() {
1249
- return this.tt;
1250
- }
1251
- constructor(e, t, i) {
1252
- this.instance = e, this.isEnabled = t, this.onCapture = i, this.startIfEnabled();
1253
- }
1254
- onRemoteConfig(e) {
1255
- this.instance.persistence && this.instance.persistence.register({ [Ps]: e == null ? void 0 : e.captureDeadClicks }), this.startIfEnabled();
1256
- }
1257
- startIfEnabled() {
1258
- this.isEnabled(this) && this.it((() => {
1259
- this.et();
1260
- }));
1261
- }
1262
- it(e) {
1263
- var t, i;
1264
- (t = k.__PosthogExtensions__) != null && t.initDeadClicksAutocapture && e(), (i = k.__PosthogExtensions__) == null || i.loadExternalDependency == null || i.loadExternalDependency(this.instance, "dead-clicks-autocapture", ((s) => {
1265
- s ? Mt.error("failed to load script", s) : e();
1266
- }));
1267
- }
1268
- et() {
1269
- var e;
1270
- if (m) {
1271
- if (!this.tt && (e = k.__PosthogExtensions__) != null && e.initDeadClicksAutocapture) {
1272
- var t = j(this.instance.config.capture_dead_clicks) ? this.instance.config.capture_dead_clicks : {};
1273
- t.__onCapture = this.onCapture, this.tt = k.__PosthogExtensions__.initDeadClicksAutocapture(this.instance, t), this.tt.start(m), Mt.info("starting...");
1274
- }
1275
- } else Mt.error("`document` not found. Cannot start.");
1276
- }
1277
- stop() {
1278
- this.tt && (this.tt.stop(), this.tt = void 0, Mt.info("stopping..."));
1279
- }
1280
- }
1281
- var ct = U("[ExceptionAutocapture]");
1282
- class Ha {
1283
- constructor(e) {
1284
- var t, i, s;
1285
- this.rt = () => {
1286
- var n;
1287
- if (d && this.isEnabled && (n = k.__PosthogExtensions__) != null && n.errorWrappingFunctions) {
1288
- var a = k.__PosthogExtensions__.errorWrappingFunctions.wrapOnError, o = k.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection, l = k.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;
1289
- try {
1290
- !this.st && this.C.capture_unhandled_errors && (this.st = a(this.captureException.bind(this))), !this.nt && this.C.capture_unhandled_rejections && (this.nt = o(this.captureException.bind(this))), !this.ot && this.C.capture_console_errors && (this.ot = l(this.captureException.bind(this)));
1291
- } catch (c) {
1292
- ct.error("failed to start", c), this.lt();
1293
- }
1294
- }
1295
- }, this._instance = e, this.ut = !((t = this._instance.persistence) == null || !t.props[Ir]), this.C = this.ht(), this.dt = new Gn({ refillRate: (i = this._instance.config.error_tracking.__exceptionRateLimiterRefillRate) !== null && i !== void 0 ? i : 1, bucketSize: (s = this._instance.config.error_tracking.__exceptionRateLimiterBucketSize) !== null && s !== void 0 ? s : 10, refillInterval: 1e4, h: ct }), this.startIfEnabled();
1296
- }
1297
- ht() {
1298
- var e = this._instance.config.capture_exceptions, t = { capture_unhandled_errors: !1, capture_unhandled_rejections: !1, capture_console_errors: !1 };
1299
- return j(e) ? t = w({}, t, e) : (v(e) ? this.ut : e) && (t = w({}, t, { capture_unhandled_errors: !0, capture_unhandled_rejections: !0 })), t;
1300
- }
1301
- get isEnabled() {
1302
- return this.C.capture_console_errors || this.C.capture_unhandled_errors || this.C.capture_unhandled_rejections;
1303
- }
1304
- startIfEnabled() {
1305
- this.isEnabled && (ct.info("enabled"), this.it(this.rt));
1306
- }
1307
- it(e) {
1308
- var t, i;
1309
- (t = k.__PosthogExtensions__) != null && t.errorWrappingFunctions && e(), (i = k.__PosthogExtensions__) == null || i.loadExternalDependency == null || i.loadExternalDependency(this._instance, "exception-autocapture", ((s) => {
1310
- if (s) return ct.error("failed to load script", s);
1311
- e();
1312
- }));
1313
- }
1314
- lt() {
1315
- var e, t, i;
1316
- (e = this.st) == null || e.call(this), this.st = void 0, (t = this.nt) == null || t.call(this), this.nt = void 0, (i = this.ot) == null || i.call(this), this.ot = void 0;
1317
- }
1318
- onRemoteConfig(e) {
1319
- var t = e.autocaptureExceptions;
1320
- this.ut = !!t || !1, this.C = this.ht(), this._instance.persistence && this._instance.persistence.register({ [Ir]: this.ut }), this.startIfEnabled();
1321
- }
1322
- captureException(e) {
1323
- var t, i, s = (t = e == null || (i = e.$exception_list) == null || (i = i[0]) == null ? void 0 : i.type) !== null && t !== void 0 ? t : "Exception";
1324
- this.dt.consumeRateLimit(s) ? ct.info("Skipping exception capture because of client rate limiting.", { exception: s }) : this._instance.exceptions.sendExceptionEvent(e);
1325
- }
1326
- }
1327
- function qr(r, e, t) {
1328
- try {
1329
- if (!(e in r)) return () => {
1330
- };
1331
- var i = r[e], s = t(i);
1332
- return Fe(s) && (s.prototype = s.prototype || {}, Object.defineProperties(s, { __posthog_wrapped__: { enumerable: !1, value: !0 } })), r[e] = s, () => {
1333
- r[e] = i;
1334
- };
1335
- } catch {
1336
- return () => {
1337
- };
1338
- }
1339
- }
1340
- class Va {
1341
- constructor(e) {
1342
- var t;
1343
- this._instance = e, this.vt = (d == null || (t = d.location) == null ? void 0 : t.pathname) || "";
1344
- }
1345
- get isEnabled() {
1346
- return this._instance.config.capture_pageview === "history_change";
1347
- }
1348
- startIfEnabled() {
1349
- this.isEnabled && (y.info("History API monitoring enabled, starting..."), this.monitorHistoryChanges());
1350
- }
1351
- stop() {
1352
- this.ct && this.ct(), this.ct = void 0, y.info("History API monitoring stopped");
1353
- }
1354
- monitorHistoryChanges() {
1355
- var e, t;
1356
- if (d && d.history) {
1357
- var i = this;
1358
- (e = d.history.pushState) != null && e.__posthog_wrapped__ || qr(d.history, "pushState", ((s) => function(n, a, o) {
1359
- s.call(this, n, a, o), i.ft("pushState");
1360
- })), (t = d.history.replaceState) != null && t.__posthog_wrapped__ || qr(d.history, "replaceState", ((s) => function(n, a, o) {
1361
- s.call(this, n, a, o), i.ft("replaceState");
1362
- })), this.gt();
1363
- }
1364
- }
1365
- ft(e) {
1366
- try {
1367
- var t, i = d == null || (t = d.location) == null ? void 0 : t.pathname;
1368
- if (!i) return;
1369
- i !== this.vt && this.isEnabled && this._instance.capture("$pageview", { navigation_type: e }), this.vt = i;
1370
- } catch (s) {
1371
- y.error("Error capturing " + e + " pageview", s);
1372
- }
1373
- }
1374
- gt() {
1375
- if (!this.ct) {
1376
- var e = () => {
1377
- this.ft("popstate");
1378
- };
1379
- L(d, "popstate", e), this.ct = () => {
1380
- d && d.removeEventListener("popstate", e);
1381
- };
1382
- }
1383
- }
1384
- }
1385
- var mi = U("[SegmentIntegration]");
1386
- function Ga(r, e) {
1387
- var t = r.config.segment;
1388
- if (!t) return e();
1389
- (function(i, s) {
1390
- var n = i.config.segment;
1391
- if (!n) return s();
1392
- var a = (l) => {
1393
- var c = () => l.anonymousId() || Te();
1394
- i.config.get_device_id = c, l.id() && (i.register({ distinct_id: l.id(), $device_id: c() }), i.persistence.set_property(ye, "identified")), s();
1395
- }, o = n.user();
1396
- "then" in o && Fe(o.then) ? o.then(((l) => a(l))) : a(o);
1397
- })(r, (() => {
1398
- t.register(((i) => {
1399
- Promise && Promise.resolve || mi.warn("This browser does not have Promise support, and can not use the segment integration");
1400
- var s = (n, a) => {
1401
- if (!a) return n;
1402
- n.event.userId || n.event.anonymousId === i.get_distinct_id() || (mi.info("No userId set, resetting PostHog"), i.reset()), n.event.userId && n.event.userId !== i.get_distinct_id() && (mi.info("UserId set, identifying with PostHog"), i.identify(n.event.userId));
1403
- var o = i.calculateEventProperties(a, n.event.properties);
1404
- return n.event.properties = Object.assign({}, o, n.event.properties), n;
1405
- };
1406
- return { name: "PostHog JS", type: "enrichment", version: "1.0.0", isLoaded: () => !0, load: () => Promise.resolve(), track: (n) => s(n, n.event.event), page: (n) => s(n, "$pageview"), identify: (n) => s(n, "$identify"), screen: (n) => s(n, "$screen") };
1407
- })(r)).then((() => {
1408
- e();
1409
- }));
1410
- }));
1411
- }
1412
- var Gs = "posthog-js";
1413
- function Ws(r, e) {
1414
- var { organization: t, projectId: i, prefix: s, severityAllowList: n = ["error"], sendExceptionsToPostHog: a = !0 } = e === void 0 ? {} : e;
1415
- return (o) => {
1416
- var l, c, u, h, g;
1417
- if (!(n === "*" || n.includes(o.level)) || !r.__loaded) return o;
1418
- o.tags || (o.tags = {});
1419
- var p = r.requestRouter.endpointFor("ui", "/project/" + r.config.token + "/person/" + r.get_distinct_id());
1420
- o.tags["PostHog Person URL"] = p, r.sessionRecordingStarted() && (o.tags["PostHog Recording URL"] = r.get_session_replay_url({ withTimestamp: !0 }));
1421
- var f = ((l = o.exception) == null ? void 0 : l.values) || [], _ = f.map(((E) => w({}, E, { stacktrace: E.stacktrace ? w({}, E.stacktrace, { type: "raw", frames: (E.stacktrace.frames || []).map(((x) => w({}, x, { platform: "web:javascript" }))) }) : void 0 }))), b = { $exception_message: ((c = f[0]) == null ? void 0 : c.value) || o.message, $exception_type: (u = f[0]) == null ? void 0 : u.type, $exception_level: o.level, $exception_list: _, $sentry_event_id: o.event_id, $sentry_exception: o.exception, $sentry_exception_message: ((h = f[0]) == null ? void 0 : h.value) || o.message, $sentry_exception_type: (g = f[0]) == null ? void 0 : g.type, $sentry_tags: o.tags };
1422
- return t && i && (b.$sentry_url = (s || "https://sentry.io/organizations/") + t + "/issues/?project=" + i + "&query=" + o.event_id), a && r.exceptions.sendExceptionEvent(b), o;
1423
- };
1424
- }
1425
- class Wa {
1426
- constructor(e, t, i, s, n, a) {
1427
- this.name = Gs, this.setupOnce = function(o) {
1428
- o(Ws(e, { organization: t, projectId: i, prefix: s, severityAllowList: n, sendExceptionsToPostHog: a == null || a }));
1429
- };
1430
- }
1431
- }
1432
- var za = d != null && d.location ? ei(d.location.hash, "__posthog") || ei(location.hash, "state") : null, jr = "_postHogToolbarParams", Br = U("[Toolbar]"), $e = (function(r) {
1433
- return r[r.UNINITIALIZED = 0] = "UNINITIALIZED", r[r.LOADING = 1] = "LOADING", r[r.LOADED = 2] = "LOADED", r;
1434
- })($e || {});
1435
- class Ya {
1436
- constructor(e) {
1437
- this.instance = e;
1438
- }
1439
- _t(e) {
1440
- k.ph_toolbar_state = e;
1441
- }
1442
- yt() {
1443
- var e;
1444
- return (e = k.ph_toolbar_state) !== null && e !== void 0 ? e : $e.UNINITIALIZED;
1445
- }
1446
- maybeLoadToolbar(e, t, i) {
1447
- if (e === void 0 && (e = void 0), t === void 0 && (t = void 0), i === void 0 && (i = void 0), !d || !m) return !1;
1448
- e = e ?? d.location, i = i ?? d.history;
1449
- try {
1450
- if (!t) {
1451
- try {
1452
- d.localStorage.setItem("test", "test"), d.localStorage.removeItem("test");
1453
- } catch {
1454
- return !1;
1455
- }
1456
- t = d == null ? void 0 : d.localStorage;
1457
- }
1458
- var s, n = za || ei(e.hash, "__posthog") || ei(e.hash, "state"), a = n ? Cr((() => JSON.parse(atob(decodeURIComponent(n))))) || Cr((() => JSON.parse(decodeURIComponent(n)))) : null;
1459
- return a && a.action === "ph_authorize" ? ((s = a).source = "url", s && Object.keys(s).length > 0 && (a.desiredHash ? e.hash = a.desiredHash : i ? i.replaceState(i.state, "", e.pathname + e.search) : e.hash = "")) : ((s = JSON.parse(t.getItem(jr) || "{}")).source = "localstorage", delete s.userIntent), !(!s.token || this.instance.config.token !== s.token) && (this.loadToolbar(s), !0);
1460
- } catch {
1461
- return !1;
1462
- }
1463
- }
1464
- bt(e) {
1465
- var t = k.ph_load_toolbar || k.ph_load_editor;
1466
- !O(t) && Fe(t) ? t(e, this.instance) : Br.warn("No toolbar load function found");
1467
- }
1468
- loadToolbar(e) {
1469
- var t = !(m == null || !m.getElementById($s));
1470
- if (!d || t) return !1;
1471
- var i = this.instance.requestRouter.region === "custom" && this.instance.config.advanced_disable_toolbar_metrics, s = w({ token: this.instance.config.token }, e, { apiURL: this.instance.requestRouter.endpointFor("ui") }, i ? { instrument: !1 } : {});
1472
- if (d.localStorage.setItem(jr, JSON.stringify(w({}, s, { source: void 0 }))), this.yt() === $e.LOADED) this.bt(s);
1473
- else if (this.yt() === $e.UNINITIALIZED) {
1474
- var n;
1475
- this._t($e.LOADING), (n = k.__PosthogExtensions__) == null || n.loadExternalDependency == null || n.loadExternalDependency(this.instance, "toolbar", ((a) => {
1476
- if (a) return Br.error("[Toolbar] Failed to load", a), void this._t($e.UNINITIALIZED);
1477
- this._t($e.LOADED), this.bt(s);
1478
- })), L(d, "turbolinks:load", (() => {
1479
- this._t($e.UNINITIALIZED), this.loadToolbar(s);
1480
- }));
1481
- }
1482
- return !0;
1483
- }
1484
- wt(e) {
1485
- return this.loadToolbar(e);
1486
- }
1487
- maybeLoadEditor(e, t, i) {
1488
- return e === void 0 && (e = void 0), t === void 0 && (t = void 0), i === void 0 && (i = void 0), this.maybeLoadToolbar(e, t, i);
1489
- }
1490
- }
1491
- var Ka = U("[TracingHeaders]");
1492
- class Xa {
1493
- constructor(e) {
1494
- this.xt = void 0, this.$t = void 0, this.rt = () => {
1495
- var t, i;
1496
- v(this.xt) && ((t = k.__PosthogExtensions__) == null || (t = t.tracingHeadersPatchFns) == null || t._patchXHR(this._instance.config.__add_tracing_headers || [], this._instance.get_distinct_id(), this._instance.sessionManager)), v(this.$t) && ((i = k.__PosthogExtensions__) == null || (i = i.tracingHeadersPatchFns) == null || i._patchFetch(this._instance.config.__add_tracing_headers || [], this._instance.get_distinct_id(), this._instance.sessionManager));
1497
- }, this._instance = e;
1498
- }
1499
- it(e) {
1500
- var t, i;
1501
- (t = k.__PosthogExtensions__) != null && t.tracingHeadersPatchFns && e(), (i = k.__PosthogExtensions__) == null || i.loadExternalDependency == null || i.loadExternalDependency(this._instance, "tracing-headers", ((s) => {
1502
- if (s) return Ka.error("failed to load script", s);
1503
- e();
1504
- }));
1505
- }
1506
- startIfEnabledOrStop() {
1507
- var e, t;
1508
- this._instance.config.__add_tracing_headers ? this.it(this.rt) : ((e = this.xt) == null || e.call(this), (t = this.$t) == null || t.call(this), this.xt = void 0, this.$t = void 0);
1509
- }
1510
- }
1511
- var re = "Mobile", ii = "iOS", pe = "Android", St = "Tablet", zs = pe + " " + St, Ys = "iPad", Ks = "Apple", Xs = Ks + " Watch", Ct = "Safari", tt = "BlackBerry", Js = "Samsung", Zs = Js + "Browser", Qs = Js + " Internet", He = "Chrome", Ja = He + " OS", en = He + " " + ii, sr = "Internet Explorer", tn = sr + " " + re, nr = "Opera", Za = nr + " Mini", ar = "Edge", rn = "Microsoft " + ar, Ze = "Firefox", sn = Ze + " " + ii, Pt = "Nintendo", It = "PlayStation", Qe = "Xbox", nn = pe + " " + re, an = re + " " + Ct, mt = "Windows", Vi = mt + " Phone", Hr = "Nokia", Gi = "Ouya", on = "Generic", Qa = on + " " + re.toLowerCase(), ln = on + " " + St.toLowerCase(), Wi = "Konqueror", G = "(\\d+(\\.\\d+)?)", yi = new RegExp("Version/" + G), eo = new RegExp(Qe, "i"), to = new RegExp(It + " \\w+", "i"), io = new RegExp(Pt + " \\w+", "i"), or = new RegExp(tt + "|PlayBook|BB10", "i"), ro = { "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" }, so = (r, e) => e && S(e, Ks) || (function(t) {
1512
- return S(t, Ct) && !S(t, He) && !S(t, pe);
1513
- })(r), cn = function(r, e) {
1514
- return e = e || "", S(r, " OPR/") && S(r, "Mini") ? Za : S(r, " OPR/") ? nr : or.test(r) ? tt : S(r, "IE" + re) || S(r, "WPDesktop") ? tn : S(r, Zs) ? Qs : S(r, ar) || S(r, "Edg/") ? rn : S(r, "FBIOS") ? "Facebook " + re : S(r, "UCWEB") || S(r, "UCBrowser") ? "UC Browser" : S(r, "CriOS") ? en : S(r, "CrMo") || S(r, He) ? He : S(r, pe) && S(r, Ct) ? nn : S(r, "FxiOS") ? sn : S(r.toLowerCase(), Wi.toLowerCase()) ? Wi : so(r, e) ? S(r, re) ? an : Ct : S(r, Ze) ? Ze : S(r, "MSIE") || S(r, "Trident/") ? sr : S(r, "Gecko") ? Ze : "";
1515
- }, no = { [tn]: [new RegExp("rv:" + G)], [rn]: [new RegExp(ar + "?\\/" + G)], [He]: [new RegExp("(" + He + "|CrMo)\\/" + G)], [en]: [new RegExp("CriOS\\/" + G)], "UC Browser": [new RegExp("(UCBrowser|UCWEB)\\/" + G)], [Ct]: [yi], [an]: [yi], [nr]: [new RegExp("(Opera|OPR)\\/" + G)], [Ze]: [new RegExp(Ze + "\\/" + G)], [sn]: [new RegExp("FxiOS\\/" + G)], [Wi]: [new RegExp("Konqueror[:/]?" + G, "i")], [tt]: [new RegExp(tt + " " + G), yi], [nn]: [new RegExp("android\\s" + G, "i")], [Qs]: [new RegExp(Zs + "\\/" + G)], [sr]: [new RegExp("(rv:|MSIE )" + G)], Mozilla: [new RegExp("rv:" + G)] }, ao = function(r, e) {
1516
- var t = cn(r, e), i = no[t];
1517
- if (v(i)) return null;
1518
- for (var s = 0; s < i.length; s++) {
1519
- var n = i[s], a = r.match(n);
1520
- if (a) return parseFloat(a[a.length - 2]);
1521
- }
1522
- return null;
1523
- }, Vr = [[new RegExp(Qe + "; " + Qe + " (.*?)[);]", "i"), (r) => [Qe, r && r[1] || ""]], [new RegExp(Pt, "i"), [Pt, ""]], [new RegExp(It, "i"), [It, ""]], [or, [tt, ""]], [new RegExp(mt, "i"), (r, e) => {
1524
- if (/Phone/.test(e) || /WPDesktop/.test(e)) return [Vi, ""];
1525
- if (new RegExp(re).test(e) && !/IEMobile\b/.test(e)) return [mt + " " + re, ""];
1526
- var t = /Windows NT ([0-9.]+)/i.exec(e);
1527
- if (t && t[1]) {
1528
- var i = t[1], s = ro[i] || "";
1529
- return /arm/i.test(e) && (s = "RT"), [mt, s];
1530
- }
1531
- return [mt, ""];
1532
- }], [/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/, (r) => {
1533
- if (r && r[3]) {
1534
- var e = [r[3], r[4], r[5] || "0"];
1535
- return [ii, e.join(".")];
1536
- }
1537
- return [ii, ""];
1538
- }], [/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i, (r) => {
1539
- var e = "";
1540
- return r && r.length >= 3 && (e = v(r[2]) ? r[3] : r[2]), ["watchOS", e];
1541
- }], [new RegExp("(" + pe + " (\\d+)\\.(\\d+)\\.?(\\d+)?|" + pe + ")", "i"), (r) => {
1542
- if (r && r[2]) {
1543
- var e = [r[2], r[3], r[4] || "0"];
1544
- return [pe, e.join(".")];
1545
- }
1546
- return [pe, ""];
1547
- }], [/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i, (r) => {
1548
- var e = ["Mac OS X", ""];
1549
- if (r && r[1]) {
1550
- var t = [r[1], r[2], r[3] || "0"];
1551
- e[1] = t.join(".");
1552
- }
1553
- return e;
1554
- }], [/Mac/i, ["Mac OS X", ""]], [/CrOS/, [Ja, ""]], [/Linux|debian/i, ["Linux", ""]]], Gr = function(r) {
1555
- return io.test(r) ? Pt : to.test(r) ? It : eo.test(r) ? Qe : new RegExp(Gi, "i").test(r) ? Gi : new RegExp("(" + Vi + "|WPDesktop)", "i").test(r) ? Vi : /iPad/.test(r) ? Ys : /iPod/.test(r) ? "iPod Touch" : /iPhone/.test(r) ? "iPhone" : /(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(r) ? Xs : or.test(r) ? tt : /(kobo)\s(ereader|touch)/i.test(r) ? "Kobo" : new RegExp(Hr, "i").test(r) ? Hr : /(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(r) || /(kf[a-z]+)( bui|\)).+silk\//i.test(r) ? "Kindle Fire" : /(Android|ZTE)/i.test(r) ? !new RegExp(re).test(r) || /(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(r) ? /pixel[\daxl ]{1,6}/i.test(r) && !/pixel c/i.test(r) || /(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(r) || /lmy47v/i.test(r) && !/QTAQZ3/i.test(r) ? pe : zs : pe : new RegExp("(pda|" + re + ")", "i").test(r) ? Qa : new RegExp(St, "i").test(r) && !new RegExp(St + " pc", "i").test(r) ? ln : "";
1556
- }, Lt = "https?://(.*)", nt = ["gclid", "gclsrc", "dclid", "gbraid", "wbraid", "fbclid", "msclkid", "twclid", "li_fat_id", "igshid", "ttclid", "rdt_cid", "epik", "qclid", "sccid", "irclid", "_kx"], oo = st(["utm_source", "utm_medium", "utm_campaign", "utm_content", "utm_term", "gad_source", "mc_cid"], nt), Ft = "<masked>", lo = ["li_fat_id"];
1557
- function un(r, e, t) {
1558
- if (!m) return {};
1559
- var i, s = e ? st([], nt, t || []) : [], n = hn(Tt(m.URL, s, Ft), r), a = (i = {}, T(lo, (function(o) {
1560
- var l = ge.q(o);
1561
- i[o] = l || null;
1562
- })), i);
1563
- return M(a, n);
1564
- }
1565
- function hn(r, e) {
1566
- var t = oo.concat(e || []), i = {};
1567
- return T(t, (function(s) {
1568
- var n = Qt(r, s);
1569
- i[s] = n || null;
1570
- })), i;
1571
- }
1572
- function dn(r) {
1573
- var e = (function(n) {
1574
- return n ? n.search(Lt + "google.([^/?]*)") === 0 ? "google" : n.search(Lt + "bing.com") === 0 ? "bing" : n.search(Lt + "yahoo.com") === 0 ? "yahoo" : n.search(Lt + "duckduckgo.com") === 0 ? "duckduckgo" : null : null;
1575
- })(r), t = e != "yahoo" ? "q" : "p", i = {};
1576
- if (!Ee(e)) {
1577
- i.$search_engine = e;
1578
- var s = m ? Qt(m.referrer, t) : "";
1579
- s.length && (i.ph_keyword = s);
1580
- }
1581
- return i;
1582
- }
1583
- function Wr() {
1584
- return navigator.language || navigator.userLanguage;
1585
- }
1586
- function pn() {
1587
- return (m == null ? void 0 : m.referrer) || "$direct";
1588
- }
1589
- function gn(r, e) {
1590
- var t = r ? st([], nt, e || []) : [], i = z == null ? void 0 : z.href.substring(0, 1e3);
1591
- return { r: pn().substring(0, 1e3), u: i ? Tt(i, t, Ft) : void 0 };
1592
- }
1593
- function fn(r) {
1594
- var e, { r: t, u: i } = r, s = { $referrer: t, $referring_domain: t == null ? void 0 : t == "$direct" ? "$direct" : (e = Zt(t)) == null ? void 0 : e.host };
1595
- if (i) {
1596
- s.$current_url = i;
1597
- var n = Zt(i);
1598
- s.$host = n == null ? void 0 : n.host, s.$pathname = n == null ? void 0 : n.pathname;
1599
- var a = hn(i);
1600
- M(s, a);
1601
- }
1602
- if (t) {
1603
- var o = dn(t);
1604
- M(s, o);
1605
- }
1606
- return s;
1607
- }
1608
- function _n() {
1609
- try {
1610
- return Intl.DateTimeFormat().resolvedOptions().timeZone;
1611
- } catch {
1612
- return;
1613
- }
1614
- }
1615
- function co() {
1616
- try {
1617
- return (/* @__PURE__ */ new Date()).getTimezoneOffset();
1618
- } catch {
1619
- return;
1620
- }
1621
- }
1622
- function uo(r, e) {
1623
- if (!W) return {};
1624
- var t, i, s, n = r ? st([], nt, e || []) : [], [a, o] = (function(l) {
1625
- for (var c = 0; c < Vr.length; c++) {
1626
- var [u, h] = Vr[c], g = u.exec(l), p = g && (Fe(h) ? h(g, l) : h);
1627
- if (p) return p;
1628
- }
1629
- return ["", ""];
1630
- })(W);
1631
- return M(er({ $os: a, $os_version: o, $browser: cn(W, navigator.vendor), $device: Gr(W), $device_type: (i = W, s = Gr(i), s === Ys || s === zs || s === "Kobo" || s === "Kindle Fire" || s === ln ? St : s === Pt || s === Qe || s === It || s === Gi ? "Console" : s === Xs ? "Wearable" : s ? re : "Desktop"), $timezone: _n(), $timezone_offset: co() }), { $current_url: Tt(z == null ? void 0 : z.href, n, Ft), $host: z == null ? void 0 : z.host, $pathname: z == null ? void 0 : z.pathname, $raw_user_agent: W.length > 1e3 ? W.substring(0, 997) + "..." : W, $browser_version: ao(W, navigator.vendor), $browser_language: Wr(), $browser_language_prefix: (t = Wr(), typeof t == "string" ? t.split("-")[0] : void 0), $screen_height: d == null ? void 0 : d.screen.height, $screen_width: d == null ? void 0 : d.screen.width, $viewport_height: d == null ? void 0 : d.innerHeight, $viewport_width: d == null ? void 0 : d.innerWidth, $lib: "web", $lib_version: me.LIB_VERSION, $insert_id: Math.random().toString(36).substring(2, 10) + Math.random().toString(36).substring(2, 10), $time: Date.now() / 1e3 });
1632
- }
1633
- var Pe = U("[Web Vitals]"), zr = 9e5;
1634
- class ho {
1635
- constructor(e) {
1636
- var t;
1637
- this.St = !1, this.P = !1, this.N = { url: void 0, metrics: [], firstMetricTimestamp: void 0 }, this.Et = () => {
1638
- clearTimeout(this.kt), this.N.metrics.length !== 0 && (this._instance.capture("$web_vitals", this.N.metrics.reduce(((i, s) => w({}, i, { ["$web_vitals_" + s.name + "_event"]: w({}, s), ["$web_vitals_" + s.name + "_value"]: s.value })), {})), this.N = { url: void 0, metrics: [], firstMetricTimestamp: void 0 });
1639
- }, this.Pt = (i) => {
1640
- var s, n = (s = this._instance.sessionManager) == null ? void 0 : s.checkAndGetSessionAndWindowId(!0);
1641
- if (v(n)) Pe.error("Could not read session ID. Dropping metrics!");
1642
- else {
1643
- this.N = this.N || { url: void 0, metrics: [], firstMetricTimestamp: void 0 };
1644
- var a = this.Tt();
1645
- v(a) || (O(i == null ? void 0 : i.name) || O(i == null ? void 0 : i.value) ? Pe.error("Invalid metric received", i) : this.It && i.value >= this.It ? Pe.error("Ignoring metric with value >= " + this.It, i) : (this.N.url !== a && (this.Et(), this.kt = setTimeout(this.Et, this.flushToCaptureTimeoutMs)), v(this.N.url) && (this.N.url = a), this.N.firstMetricTimestamp = v(this.N.firstMetricTimestamp) ? Date.now() : this.N.firstMetricTimestamp, i.attribution && i.attribution.interactionTargetElement && (i.attribution.interactionTargetElement = void 0), this.N.metrics.push(w({}, i, { $current_url: a, $session_id: n.sessionId, $window_id: n.windowId, timestamp: Date.now() })), this.N.metrics.length === this.allowedMetrics.length && this.Et()));
1646
- }
1647
- }, this.rt = () => {
1648
- var i, s, n, a, o = k.__PosthogExtensions__;
1649
- v(o) || v(o.postHogWebVitalsCallbacks) || ({ onLCP: i, onCLS: s, onFCP: n, onINP: a } = o.postHogWebVitalsCallbacks), i && s && n && a ? (this.allowedMetrics.indexOf("LCP") > -1 && i(this.Pt.bind(this)), this.allowedMetrics.indexOf("CLS") > -1 && s(this.Pt.bind(this)), this.allowedMetrics.indexOf("FCP") > -1 && n(this.Pt.bind(this)), this.allowedMetrics.indexOf("INP") > -1 && a(this.Pt.bind(this)), this.P = !0) : Pe.error("web vitals callbacks not loaded - not starting");
1650
- }, this._instance = e, this.St = !((t = this._instance.persistence) == null || !t.props[Tr]), this.startIfEnabled();
1651
- }
1652
- get allowedMetrics() {
1653
- var e, t, i = j(this._instance.config.capture_performance) ? (e = this._instance.config.capture_performance) == null ? void 0 : e.web_vitals_allowed_metrics : void 0;
1654
- return v(i) ? ((t = this._instance.persistence) == null ? void 0 : t.props[Fr]) || ["CLS", "FCP", "INP", "LCP"] : i;
1655
- }
1656
- get flushToCaptureTimeoutMs() {
1657
- return (j(this._instance.config.capture_performance) ? this._instance.config.capture_performance.web_vitals_delayed_flush_ms : void 0) || 5e3;
1658
- }
1659
- get It() {
1660
- var e = j(this._instance.config.capture_performance) && fe(this._instance.config.capture_performance.__web_vitals_max_value) ? this._instance.config.capture_performance.__web_vitals_max_value : zr;
1661
- return 0 < e && e <= 6e4 ? zr : e;
1662
- }
1663
- get isEnabled() {
1664
- var e = z == null ? void 0 : z.protocol;
1665
- if (e !== "http:" && e !== "https:") return Pe.info("Web Vitals are disabled on non-http/https protocols"), !1;
1666
- var t = j(this._instance.config.capture_performance) ? this._instance.config.capture_performance.web_vitals : Oe(this._instance.config.capture_performance) ? this._instance.config.capture_performance : void 0;
1667
- return Oe(t) ? t : this.St;
1668
- }
1669
- startIfEnabled() {
1670
- this.isEnabled && !this.P && (Pe.info("enabled, starting..."), this.it(this.rt));
1671
- }
1672
- onRemoteConfig(e) {
1673
- var t = j(e.capturePerformance) && !!e.capturePerformance.web_vitals, i = j(e.capturePerformance) ? e.capturePerformance.web_vitals_allowed_metrics : void 0;
1674
- this._instance.persistence && (this._instance.persistence.register({ [Tr]: t }), this._instance.persistence.register({ [Fr]: i })), this.St = t, this.startIfEnabled();
1675
- }
1676
- it(e) {
1677
- var t, i;
1678
- (t = k.__PosthogExtensions__) != null && t.postHogWebVitalsCallbacks && e(), (i = k.__PosthogExtensions__) == null || i.loadExternalDependency == null || i.loadExternalDependency(this._instance, "web-vitals", ((s) => {
1679
- s ? Pe.error("failed to load script", s) : e();
1680
- }));
1681
- }
1682
- Tt() {
1683
- var e = d ? d.location.href : void 0;
1684
- if (e) {
1685
- var t = this._instance.config.mask_personal_data_properties, i = this._instance.config.custom_personal_data_properties, s = t ? st([], nt, i || []) : [];
1686
- return Tt(e, s, Ft);
1687
- }
1688
- Pe.error("Could not determine current URL");
1689
- }
1690
- }
1691
- var po = U("[Heatmaps]");
1692
- function Yr(r) {
1693
- return j(r) && "clientX" in r && "clientY" in r && fe(r.clientX) && fe(r.clientY);
1694
- }
1695
- class go {
1696
- constructor(e) {
1697
- var t;
1698
- this.St = !1, this.P = !1, this.Rt = null, this.instance = e, this.St = !((t = this.instance.persistence) == null || !t.props[Di]), this.rageclicks = new Bs(e.config.rageclick);
1699
- }
1700
- get flushIntervalMilliseconds() {
1701
- var e = 5e3;
1702
- return j(this.instance.config.capture_heatmaps) && this.instance.config.capture_heatmaps.flush_interval_milliseconds && (e = this.instance.config.capture_heatmaps.flush_interval_milliseconds), e;
1703
- }
1704
- get isEnabled() {
1705
- return v(this.instance.config.capture_heatmaps) ? v(this.instance.config.enable_heatmaps) ? this.St : this.instance.config.enable_heatmaps : this.instance.config.capture_heatmaps !== !1;
1706
- }
1707
- startIfEnabled() {
1708
- if (this.isEnabled) {
1709
- if (this.P) return;
1710
- po.info("starting..."), this.Ct(), this.Ot();
1711
- } else {
1712
- var e;
1713
- clearInterval((e = this.Rt) !== null && e !== void 0 ? e : void 0), this.Ft(), this.getAndClearBuffer();
1714
- }
1715
- }
1716
- onRemoteConfig(e) {
1717
- var t = !!e.heatmaps;
1718
- this.instance.persistence && this.instance.persistence.register({ [Di]: t }), this.St = t, this.startIfEnabled();
1719
- }
1720
- getAndClearBuffer() {
1721
- var e = this.N;
1722
- return this.N = void 0, e;
1723
- }
1724
- Mt(e) {
1725
- this.At(e.originalEvent, "deadclick");
1726
- }
1727
- Ot() {
1728
- this.Rt && clearInterval(this.Rt), this.Rt = (function(e) {
1729
- return (e == null ? void 0 : e.visibilityState) === "visible";
1730
- })(m) ? setInterval(this.Dt.bind(this), this.flushIntervalMilliseconds) : null;
1731
- }
1732
- Ct() {
1733
- d && m && (this.jt = this.Dt.bind(this), L(d, "beforeunload", this.jt), this.Lt = (e) => this.At(e || (d == null ? void 0 : d.event)), L(m, "click", this.Lt, { capture: !0 }), this.Nt = (e) => this.Ut(e || (d == null ? void 0 : d.event)), L(m, "mousemove", this.Nt, { capture: !0 }), this.zt = new Vs(this.instance, ja, this.Mt.bind(this)), this.zt.startIfEnabled(), this.Ht = this.Ot.bind(this), L(m, "visibilitychange", this.Ht), this.P = !0);
1734
- }
1735
- Ft() {
1736
- var e;
1737
- d && m && (this.jt && d.removeEventListener("beforeunload", this.jt), this.Lt && m.removeEventListener("click", this.Lt, { capture: !0 }), this.Nt && m.removeEventListener("mousemove", this.Nt, { capture: !0 }), this.Ht && m.removeEventListener("visibilitychange", this.Ht), clearTimeout(this.Bt), (e = this.zt) == null || e.stop(), this.P = !1);
1738
- }
1739
- qt(e, t) {
1740
- var i = this.instance.scrollManager.scrollY(), s = this.instance.scrollManager.scrollX(), n = this.instance.scrollManager.scrollElement(), a = (function(o, l, c) {
1741
- for (var u = o; u && oi(u) && !Ae(u, "body"); ) {
1742
- if (u === c) return !1;
1743
- if (S(l, d == null ? void 0 : d.getComputedStyle(u).position)) return !0;
1744
- u = Ds(u);
1745
- }
1746
- return !1;
1747
- })(Rs(e), ["fixed", "sticky"], n);
1748
- return { x: e.clientX + (a ? 0 : s), y: e.clientY + (a ? 0 : i), target_fixed: a, type: t };
1749
- }
1750
- At(e, t) {
1751
- var i;
1752
- if (t === void 0 && (t = "click"), !Or(e.target) && Yr(e)) {
1753
- var s = this.qt(e, t);
1754
- (i = this.rageclicks) != null && i.isRageClick(e.clientX, e.clientY, (/* @__PURE__ */ new Date()).getTime()) && this.Wt(w({}, s, { type: "rageclick" })), this.Wt(s);
1755
- }
1756
- }
1757
- Ut(e) {
1758
- !Or(e.target) && Yr(e) && (clearTimeout(this.Bt), this.Bt = setTimeout((() => {
1759
- this.Wt(this.qt(e, "mousemove"));
1760
- }), 500));
1761
- }
1762
- Wt(e) {
1763
- if (d) {
1764
- var t = d.location.href, i = this.instance.config.mask_personal_data_properties, s = this.instance.config.custom_personal_data_properties, n = i ? st([], nt, s || []) : [], a = Tt(t, n, Ft);
1765
- this.N = this.N || {}, this.N[a] || (this.N[a] = []), this.N[a].push(e);
1766
- }
1767
- }
1768
- Dt() {
1769
- this.N && !Xe(this.N) && this.instance.capture("$$heatmap", { $heatmap_data: this.getAndClearBuffer() });
1770
- }
1771
- }
1772
- class fo {
1773
- constructor(e) {
1774
- this._instance = e;
1775
- }
1776
- doPageView(e, t) {
1777
- var i, s = this.Gt(e, t);
1778
- return this.Vt = { pathname: (i = d == null ? void 0 : d.location.pathname) !== null && i !== void 0 ? i : "", pageViewId: t, timestamp: e }, this._instance.scrollManager.resetContext(), s;
1779
- }
1780
- doPageLeave(e) {
1781
- var t;
1782
- return this.Gt(e, (t = this.Vt) == null ? void 0 : t.pageViewId);
1783
- }
1784
- doEvent() {
1785
- var e;
1786
- return { $pageview_id: (e = this.Vt) == null ? void 0 : e.pageViewId };
1787
- }
1788
- Gt(e, t) {
1789
- var i = this.Vt;
1790
- if (!i) return { $pageview_id: t };
1791
- var s = { $pageview_id: t, $prev_pageview_id: i.pageViewId }, n = this._instance.scrollManager.getContext();
1792
- if (n && !this._instance.config.disable_scroll_properties) {
1793
- var { maxScrollHeight: a, lastScrollY: o, maxScrollY: l, maxContentHeight: c, lastContentY: u, maxContentY: h } = n;
1794
- if (!(v(a) || v(o) || v(l) || v(c) || v(u) || v(h))) {
1795
- a = Math.ceil(a), o = Math.ceil(o), l = Math.ceil(l), c = Math.ceil(c), u = Math.ceil(u), h = Math.ceil(h);
1796
- var g = a <= 1 ? 1 : de(o / a, 0, 1, y), p = a <= 1 ? 1 : de(l / a, 0, 1, y), f = c <= 1 ? 1 : de(u / c, 0, 1, y), _ = c <= 1 ? 1 : de(h / c, 0, 1, y);
1797
- s = M(s, { $prev_pageview_last_scroll: o, $prev_pageview_last_scroll_percentage: g, $prev_pageview_max_scroll: l, $prev_pageview_max_scroll_percentage: p, $prev_pageview_last_content: u, $prev_pageview_last_content_percentage: f, $prev_pageview_max_content: h, $prev_pageview_max_content_percentage: _ });
1798
- }
1799
- }
1800
- return i.pathname && (s.$prev_pageview_pathname = i.pathname), i.timestamp && (s.$prev_pageview_duration = (e.getTime() - i.timestamp.getTime()) / 1e3), s;
1801
- }
1802
- }
1803
- var se = Uint8Array, K = Uint16Array, it = Uint32Array, lr = new se([0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 0, 0, 0]), cr = new se([0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 0, 0]), Kr = new se([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]), vn = function(r, e) {
1804
- for (var t = new K(31), i = 0; i < 31; ++i) t[i] = e += 1 << r[i - 1];
1805
- var s = new it(t[30]);
1806
- for (i = 1; i < 30; ++i) for (var n = t[i]; n < t[i + 1]; ++n) s[n] = n - t[i] << 5 | i;
1807
- return [t, s];
1808
- }, mn = vn(lr, 2), _o = mn[0], zi = mn[1];
1809
- _o[28] = 258, zi[258] = 28;
1810
- for (var Xr = vn(cr, 0)[1], yn = new K(32768), R = 0; R < 32768; ++R) {
1811
- var Ue = (43690 & R) >>> 1 | (21845 & R) << 1;
1812
- Ue = (61680 & (Ue = (52428 & Ue) >>> 2 | (13107 & Ue) << 2)) >>> 4 | (3855 & Ue) << 4, yn[R] = ((65280 & Ue) >>> 8 | (255 & Ue) << 8) >>> 1;
1813
- }
1814
- var Et = function(r, e, t) {
1815
- for (var i = r.length, s = 0, n = new K(e); s < i; ++s) ++n[r[s] - 1];
1816
- var a, o = new K(e);
1817
- for (s = 0; s < e; ++s) o[s] = o[s - 1] + n[s - 1] << 1;
1818
- for (a = new K(i), s = 0; s < i; ++s) a[s] = yn[o[r[s] - 1]++] >>> 15 - r[s];
1819
- return a;
1820
- }, Ve = new se(288);
1821
- for (R = 0; R < 144; ++R) Ve[R] = 8;
1822
- for (R = 144; R < 256; ++R) Ve[R] = 9;
1823
- for (R = 256; R < 280; ++R) Ve[R] = 7;
1824
- for (R = 280; R < 288; ++R) Ve[R] = 8;
1825
- var ri = new se(32);
1826
- for (R = 0; R < 32; ++R) ri[R] = 5;
1827
- var vo = Et(Ve, 9), mo = Et(ri, 5), bn = function(r) {
1828
- return (r / 8 >> 0) + (7 & r && 1);
1829
- }, wn = function(r, e, t) {
1830
- (t == null || t > r.length) && (t = r.length);
1831
- var i = new (r instanceof K ? K : r instanceof it ? it : se)(t - e);
1832
- return i.set(r.subarray(e, t)), i;
1833
- }, ve = function(r, e, t) {
1834
- t <<= 7 & e;
1835
- var i = e / 8 >> 0;
1836
- r[i] |= t, r[i + 1] |= t >>> 8;
1837
- }, ut = function(r, e, t) {
1838
- t <<= 7 & e;
1839
- var i = e / 8 >> 0;
1840
- r[i] |= t, r[i + 1] |= t >>> 8, r[i + 2] |= t >>> 16;
1841
- }, bi = function(r, e) {
1842
- for (var t = [], i = 0; i < r.length; ++i) r[i] && t.push({ s: i, f: r[i] });
1843
- var s = t.length, n = t.slice();
1844
- if (!s) return [new se(0), 0];
1845
- if (s == 1) {
1846
- var a = new se(t[0].s + 1);
1847
- return a[t[0].s] = 1, [a, 1];
1848
- }
1849
- t.sort((function(D, ne) {
1850
- return D.f - ne.f;
1851
- })), t.push({ s: -1, f: 25001 });
1852
- var o = t[0], l = t[1], c = 0, u = 1, h = 2;
1853
- for (t[0] = { s: -1, f: o.f + l.f, l: o, r: l }; u != s - 1; ) o = t[t[c].f < t[h].f ? c++ : h++], l = t[c != u && t[c].f < t[h].f ? c++ : h++], t[u++] = { s: -1, f: o.f + l.f, l: o, r: l };
1854
- var g = n[0].s;
1855
- for (i = 1; i < s; ++i) n[i].s > g && (g = n[i].s);
1856
- var p = new K(g + 1), f = Yi(t[u - 1], p, 0);
1857
- if (f > e) {
1858
- i = 0;
1859
- var _ = 0, b = f - e, E = 1 << b;
1860
- for (n.sort((function(D, ne) {
1861
- return p[ne.s] - p[D.s] || D.f - ne.f;
1862
- })); i < s; ++i) {
1863
- var x = n[i].s;
1864
- if (!(p[x] > e)) break;
1865
- _ += E - (1 << f - p[x]), p[x] = e;
1866
- }
1867
- for (_ >>>= b; _ > 0; ) {
1868
- var I = n[i].s;
1869
- p[I] < e ? _ -= 1 << e - p[I]++ - 1 : ++i;
1870
- }
1871
- for (; i >= 0 && _; --i) {
1872
- var C = n[i].s;
1873
- p[C] == e && (--p[C], ++_);
1874
- }
1875
- f = e;
1876
- }
1877
- return [new se(p), f];
1878
- }, Yi = function(r, e, t) {
1879
- return r.s == -1 ? Math.max(Yi(r.l, e, t + 1), Yi(r.r, e, t + 1)) : e[r.s] = t;
1880
- }, Jr = function(r) {
1881
- for (var e = r.length; e && !r[--e]; ) ;
1882
- for (var t = new K(++e), i = 0, s = r[0], n = 1, a = function(l) {
1883
- t[i++] = l;
1884
- }, o = 1; o <= e; ++o) if (r[o] == s && o != e) ++n;
1885
- else {
1886
- if (!s && n > 2) {
1887
- for (; n > 138; n -= 138) a(32754);
1888
- n > 2 && (a(n > 10 ? n - 11 << 5 | 28690 : n - 3 << 5 | 12305), n = 0);
1889
- } else if (n > 3) {
1890
- for (a(s), --n; n > 6; n -= 6) a(8304);
1891
- n > 2 && (a(n - 3 << 5 | 8208), n = 0);
1892
- }
1893
- for (; n--; ) a(s);
1894
- n = 1, s = r[o];
1895
- }
1896
- return [t.subarray(0, i), e];
1897
- }, ht = function(r, e) {
1898
- for (var t = 0, i = 0; i < e.length; ++i) t += r[i] * e[i];
1899
- return t;
1900
- }, Ki = function(r, e, t) {
1901
- var i = t.length, s = bn(e + 2);
1902
- r[s] = 255 & i, r[s + 1] = i >>> 8, r[s + 2] = 255 ^ r[s], r[s + 3] = 255 ^ r[s + 1];
1903
- for (var n = 0; n < i; ++n) r[s + n + 4] = t[n];
1904
- return 8 * (s + 4 + i);
1905
- }, Zr = function(r, e, t, i, s, n, a, o, l, c, u) {
1906
- ve(e, u++, t), ++s[256];
1907
- for (var h = bi(s, 15), g = h[0], p = h[1], f = bi(n, 15), _ = f[0], b = f[1], E = Jr(g), x = E[0], I = E[1], C = Jr(_), D = C[0], ne = C[1], X = new K(19), P = 0; P < x.length; ++P) X[31 & x[P]]++;
1908
- for (P = 0; P < D.length; ++P) X[31 & D[P]]++;
1909
- for (var le = bi(X, 7), J = le[0], ae = le[1], ee = 19; ee > 4 && !J[Kr[ee - 1]]; --ee) ;
1910
- var _e, ce, ue, Ge, ke = c + 5 << 3, Le = ht(s, Ve) + ht(n, ri) + a, he = ht(s, g) + ht(n, _) + a + 14 + 3 * ee + ht(X, J) + (2 * X[16] + 3 * X[17] + 7 * X[18]);
1911
- if (ke <= Le && ke <= he) return Ki(e, u, r.subarray(l, l + c));
1912
- if (ve(e, u, 1 + (he < Le)), u += 2, he < Le) {
1913
- _e = Et(g, p), ce = g, ue = Et(_, b), Ge = _;
1914
- var xe = Et(J, ae);
1915
- for (ve(e, u, I - 257), ve(e, u + 5, ne - 1), ve(e, u + 10, ee - 4), u += 14, P = 0; P < ee; ++P) ve(e, u + 3 * P, J[Kr[P]]);
1916
- u += 3 * ee;
1917
- for (var We = [x, D], V = 0; V < 2; ++V) {
1918
- var te = We[V];
1919
- for (P = 0; P < te.length; ++P) {
1920
- var Z = 31 & te[P];
1921
- ve(e, u, xe[Z]), u += J[Z], Z > 15 && (ve(e, u, te[P] >>> 5 & 127), u += te[P] >>> 12);
1922
- }
1923
- }
1924
- } else _e = vo, ce = Ve, ue = mo, Ge = ri;
1925
- for (P = 0; P < o; ++P) if (i[P] > 255) {
1926
- Z = i[P] >>> 18 & 31, ut(e, u, _e[Z + 257]), u += ce[Z + 257], Z > 7 && (ve(e, u, i[P] >>> 23 & 31), u += lr[Z]);
1927
- var ze = 31 & i[P];
1928
- ut(e, u, ue[ze]), u += Ge[ze], ze > 3 && (ut(e, u, i[P] >>> 5 & 8191), u += cr[ze]);
1929
- } else ut(e, u, _e[i[P]]), u += ce[i[P]];
1930
- return ut(e, u, _e[256]), u + ce[256];
1931
- }, yo = new it([65540, 131080, 131088, 131104, 262176, 1048704, 1048832, 2114560, 2117632]), bo = (function() {
1932
- for (var r = new it(256), e = 0; e < 256; ++e) {
1933
- for (var t = e, i = 9; --i; ) t = (1 & t && 3988292384) ^ t >>> 1;
1934
- r[e] = t;
1935
- }
1936
- return r;
1937
- })(), wo = function(r, e, t, i, s) {
1938
- return (function(n, a, o, l, c, u) {
1939
- var h = n.length, g = new se(l + h + 5 * (1 + Math.floor(h / 7e3)) + c), p = g.subarray(l, g.length - c), f = 0;
1940
- if (!a || h < 8) for (var _ = 0; _ <= h; _ += 65535) {
1941
- var b = _ + 65535;
1942
- b < h ? f = Ki(p, f, n.subarray(_, b)) : (p[_] = u, f = Ki(p, f, n.subarray(_, h)));
1943
- }
1944
- else {
1945
- for (var E = yo[a - 1], x = E >>> 13, I = 8191 & E, C = (1 << o) - 1, D = new K(32768), ne = new K(C + 1), X = Math.ceil(o / 3), P = 2 * X, le = function(ui) {
1946
- return (n[ui] ^ n[ui + 1] << X ^ n[ui + 2] << P) & C;
1947
- }, J = new it(25e3), ae = new K(288), ee = new K(32), _e = 0, ce = 0, ue = (_ = 0, 0), Ge = 0, ke = 0; _ < h; ++_) {
1948
- var Le = le(_), he = 32767 & _, xe = ne[Le];
1949
- if (D[he] = xe, ne[Le] = he, Ge <= _) {
1950
- var We = h - _;
1951
- if ((_e > 7e3 || ue > 24576) && We > 423) {
1952
- f = Zr(n, p, 0, J, ae, ee, ce, ue, ke, _ - ke, f), ue = _e = ce = 0, ke = _;
1953
- for (var V = 0; V < 286; ++V) ae[V] = 0;
1954
- for (V = 0; V < 30; ++V) ee[V] = 0;
1955
- }
1956
- var te = 2, Z = 0, ze = I, Se = he - xe & 32767;
1957
- if (We > 2 && Le == le(_ - Se)) for (var Cn = Math.min(x, We) - 1, Pn = Math.min(32767, _), In = Math.min(258, We); Se <= Pn && --ze && he != xe; ) {
1958
- if (n[_ + te] == n[_ + te - Se]) {
1959
- for (var Ce = 0; Ce < In && n[_ + Ce] == n[_ + Ce - Se]; ++Ce) ;
1960
- if (Ce > te) {
1961
- if (te = Ce, Z = Se, Ce > Cn) break;
1962
- var $n = Math.min(Se, Ce - 2), hr = 0;
1963
- for (V = 0; V < $n; ++V) {
1964
- var ci = _ - Se + V + 32768 & 32767, dr = ci - D[ci] + 32768 & 32767;
1965
- dr > hr && (hr = dr, xe = ci);
1966
- }
1967
- }
1968
- }
1969
- Se += (he = xe) - (xe = D[he]) + 32768 & 32767;
1970
- }
1971
- if (Z) {
1972
- J[ue++] = 268435456 | zi[te] << 18 | Xr[Z];
1973
- var pr = 31 & zi[te], gr = 31 & Xr[Z];
1974
- ce += lr[pr] + cr[gr], ++ae[257 + pr], ++ee[gr], Ge = _ + te, ++_e;
1975
- } else J[ue++] = n[_], ++ae[n[_]];
1976
- }
1977
- }
1978
- f = Zr(n, p, u, J, ae, ee, ce, ue, ke, _ - ke, f);
1979
- }
1980
- return wn(g, 0, l + bn(f) + c);
1981
- })(r, e.level == null ? 6 : e.level, e.mem == null ? Math.ceil(1.5 * Math.max(8, Math.min(13, Math.log(r.length)))) : 12 + e.mem, t, i, !0);
1982
- }, wi = function(r, e, t) {
1983
- for (; t; ++e) r[e] = t, t >>>= 8;
1984
- };
1985
- function Eo(r, e) {
1986
- e === void 0 && (e = {});
1987
- var t = /* @__PURE__ */ (function() {
1988
- var o = 4294967295;
1989
- return { p: function(l) {
1990
- for (var c = o, u = 0; u < l.length; ++u) c = bo[255 & c ^ l[u]] ^ c >>> 8;
1991
- o = c;
1992
- }, d: function() {
1993
- return 4294967295 ^ o;
1994
- } };
1995
- })(), i = r.length;
1996
- t.p(r);
1997
- var s, n = wo(r, e, 10 + ((s = e).filename && s.filename.length + 1 || 0), 8), a = n.length;
1998
- return (function(o, l) {
1999
- var c = l.filename;
2000
- if (o[0] = 31, o[1] = 139, o[2] = 8, o[8] = l.level < 2 ? 4 : l.level == 9 ? 2 : 0, o[9] = 3, l.mtime != 0 && wi(o, 4, Math.floor(new Date(l.mtime || Date.now()) / 1e3)), c) {
2001
- o[3] = 8;
2002
- for (var u = 0; u <= c.length; ++u) o[u + 10] = c.charCodeAt(u);
2003
- }
2004
- })(n, e), wi(n, a - 8, t.d()), wi(n, a - 4, i), n;
2005
- }
2006
- var ko = function(r) {
2007
- var e, t, i, s, n = "";
2008
- for (e = t = 0, i = (r = (r + "").replace(/\r\n/g, `
2009
- `).replace(/\r/g, `
2010
- `)).length, s = 0; s < i; s++) {
2011
- var a = r.charCodeAt(s), o = null;
2012
- a < 128 ? t++ : o = a > 127 && a < 2048 ? String.fromCharCode(a >> 6 | 192, 63 & a | 128) : String.fromCharCode(a >> 12 | 224, a >> 6 & 63 | 128, 63 & a | 128), Ee(o) || (t > e && (n += r.substring(e, t)), n += o, e = t = s + 1);
2013
- }
2014
- return t > e && (n += r.substring(e, r.length)), n;
2015
- }, xo = !!Ti || !!$i, Qr = "text/plain", si = function(r, e, t) {
2016
- var i;
2017
- t === void 0 && (t = !0);
2018
- var [s, n] = r.split("?"), a = w({}, e), o = (i = n == null ? void 0 : n.split("&").map(((c) => {
2019
- var u, [h, g] = c.split("="), p = t && (u = a[h]) !== null && u !== void 0 ? u : g;
2020
- return delete a[h], h + "=" + p;
2021
- }))) !== null && i !== void 0 ? i : [], l = Ia(a);
2022
- return l && o.push(l), s + "?" + o.join("&");
2023
- }, yt = (r, e) => JSON.stringify(r, ((t, i) => typeof i == "bigint" ? i.toString() : i), e), Ei = (r) => {
2024
- var { data: e, compression: t } = r;
2025
- if (e) {
2026
- if (t === we.GZipJS) {
2027
- var i = Eo((function(l, c) {
2028
- var u = l.length;
2029
- if (typeof TextEncoder < "u") return new TextEncoder().encode(l);
2030
- for (var h = new se(l.length + (l.length >>> 1)), g = 0, p = function(E) {
2031
- h[g++] = E;
2032
- }, f = 0; f < u; ++f) {
2033
- if (g + 5 > h.length) {
2034
- var _ = new se(g + 8 + (u - f << 1));
2035
- _.set(h), h = _;
2036
- }
2037
- var b = l.charCodeAt(f);
2038
- b < 128 || c ? p(b) : b < 2048 ? (p(192 | b >>> 6), p(128 | 63 & b)) : b > 55295 && b < 57344 ? (p(240 | (b = 65536 + (1047552 & b) | 1023 & l.charCodeAt(++f)) >>> 18), p(128 | b >>> 12 & 63), p(128 | b >>> 6 & 63), p(128 | 63 & b)) : (p(224 | b >>> 12), p(128 | b >>> 6 & 63), p(128 | 63 & b));
2039
- }
2040
- return wn(h, 0, g);
2041
- })(yt(e)), { mtime: 0 }), s = new Blob([i], { type: Qr });
2042
- return { contentType: Qr, body: s, estimatedSize: s.size };
2043
- }
2044
- if (t === we.Base64) {
2045
- var n = (function(l) {
2046
- var c, u, h, g, p, f = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", _ = 0, b = 0, E = "", x = [];
2047
- if (!l) return l;
2048
- l = ko(l);
2049
- do
2050
- c = (p = l.charCodeAt(_++) << 16 | l.charCodeAt(_++) << 8 | l.charCodeAt(_++)) >> 18 & 63, u = p >> 12 & 63, h = p >> 6 & 63, g = 63 & p, x[b++] = f.charAt(c) + f.charAt(u) + f.charAt(h) + f.charAt(g);
2051
- while (_ < l.length);
2052
- switch (E = x.join(""), l.length % 3) {
2053
- case 1:
2054
- E = E.slice(0, -2) + "==";
2055
- break;
2056
- case 2:
2057
- E = E.slice(0, -1) + "=";
2058
- }
2059
- return E;
2060
- })(yt(e)), a = ((l) => "data=" + encodeURIComponent(typeof l == "string" ? l : yt(l)))(n);
2061
- return { contentType: "application/x-www-form-urlencoded", body: a, estimatedSize: new Blob([a]).size };
2062
- }
2063
- var o = yt(e);
2064
- return { contentType: "application/json", body: o, estimatedSize: new Blob([o]).size };
2065
- }
2066
- }, qt = [];
2067
- $i && qt.push({ transport: "fetch", method: (r) => {
2068
- var e, t, { contentType: i, body: s, estimatedSize: n } = (e = Ei(r)) !== null && e !== void 0 ? e : {}, a = new Headers();
2069
- T(r.headers, (function(u, h) {
2070
- a.append(h, u);
2071
- })), i && a.append("Content-Type", i);
2072
- var o = r.url, l = null;
2073
- if (mr) {
2074
- var c = new mr();
2075
- l = { signal: c.signal, timeout: setTimeout((() => c.abort()), r.timeout) };
2076
- }
2077
- $i(o, w({ method: (r == null ? void 0 : r.method) || "GET", headers: a, keepalive: r.method === "POST" && (n || 0) < 52428.8, body: s, signal: (t = l) == null ? void 0 : t.signal }, r.fetchOptions)).then(((u) => u.text().then(((h) => {
2078
- var g = { statusCode: u.status, text: h };
2079
- if (u.status === 200) try {
2080
- g.json = JSON.parse(h);
2081
- } catch (p) {
2082
- y.error(p);
2083
- }
2084
- r.callback == null || r.callback(g);
2085
- })))).catch(((u) => {
2086
- y.error(u), r.callback == null || r.callback({ statusCode: 0, text: u });
2087
- })).finally((() => l ? clearTimeout(l.timeout) : null));
2088
- } }), Ti && qt.push({ transport: "XHR", method: (r) => {
2089
- var e, t = new Ti();
2090
- t.open(r.method || "GET", r.url, !0);
2091
- var { contentType: i, body: s } = (e = Ei(r)) !== null && e !== void 0 ? e : {};
2092
- T(r.headers, (function(n, a) {
2093
- t.setRequestHeader(a, n);
2094
- })), i && t.setRequestHeader("Content-Type", i), r.timeout && (t.timeout = r.timeout), r.disableXHRCredentials || (t.withCredentials = !0), t.onreadystatechange = () => {
2095
- if (t.readyState === 4) {
2096
- var n = { statusCode: t.status, text: t.responseText };
2097
- if (t.status === 200) try {
2098
- n.json = JSON.parse(t.responseText);
2099
- } catch {
2100
- }
2101
- r.callback == null || r.callback(n);
2102
- }
2103
- }, t.send(s);
2104
- } }), Q != null && Q.sendBeacon && qt.push({ transport: "sendBeacon", method: (r) => {
2105
- var e = si(r.url, { beacon: "1" });
2106
- try {
2107
- var t, { contentType: i, body: s } = (t = Ei(r)) !== null && t !== void 0 ? t : {}, n = typeof s == "string" ? new Blob([s], { type: i }) : s;
2108
- Q.sendBeacon(e, n);
2109
- } catch {
2110
- }
2111
- } });
2112
- var rt = function(r, e) {
2113
- if (!(function(t) {
2114
- try {
2115
- new RegExp(t);
2116
- } catch {
2117
- return !1;
2118
- }
2119
- return !0;
2120
- })(e)) return !1;
2121
- try {
2122
- return new RegExp(e).test(r);
2123
- } catch {
2124
- return !1;
2125
- }
2126
- };
2127
- function es(r, e, t) {
2128
- return yt({ distinct_id: r, userPropertiesToSet: e, userPropertiesToSetOnce: t });
2129
- }
2130
- var En = { exact: (r, e) => e.some(((t) => r.some(((i) => t === i)))), is_not: (r, e) => e.every(((t) => r.every(((i) => t !== i)))), regex: (r, e) => e.some(((t) => r.some(((i) => rt(t, i))))), not_regex: (r, e) => e.every(((t) => r.every(((i) => !rt(t, i))))), icontains: (r, e) => e.map(Nt).some(((t) => r.map(Nt).some(((i) => t.includes(i))))), not_icontains: (r, e) => e.map(Nt).every(((t) => r.map(Nt).every(((i) => !t.includes(i))))) }, Nt = (r) => r.toLowerCase(), ki = U("[Error tracking]");
2131
- class So {
2132
- constructor(e) {
2133
- var t, i;
2134
- this.Jt = [], this.Kt = new ia([new ra(), new da(), new na(), new sa(), new ua(), new ca(), new oa(), new ha()], [Jn, ea]), this._instance = e, this.Jt = (t = (i = this._instance.persistence) == null ? void 0 : i.get_property(Mi)) !== null && t !== void 0 ? t : [];
2135
- }
2136
- onRemoteConfig(e) {
2137
- var t, i, s, n = (t = (i = e.errorTracking) == null ? void 0 : i.suppressionRules) !== null && t !== void 0 ? t : [], a = (s = e.errorTracking) == null ? void 0 : s.captureExtensionExceptions;
2138
- this.Jt = n, this._instance.persistence && this._instance.persistence.register({ [Mi]: this.Jt, [$r]: a });
2139
- }
2140
- get Yt() {
2141
- var e, t = !!this._instance.get_property($r), i = this._instance.config.error_tracking.captureExtensionExceptions;
2142
- return (e = i ?? t) !== null && e !== void 0 && e;
2143
- }
2144
- buildProperties(e, t) {
2145
- return this.Kt.buildFromUnknown(e, { syntheticException: t == null ? void 0 : t.syntheticException, mechanism: { handled: t == null ? void 0 : t.handled } });
2146
- }
2147
- sendExceptionEvent(e) {
2148
- var t = e.$exception_list;
2149
- if (this.Xt(t)) {
2150
- if (this.Qt(t)) return void ki.info("Skipping exception capture because a suppression rule matched");
2151
- if (!this.Yt && this.Zt(t)) return void ki.info("Skipping exception capture because it was thrown by an extension");
2152
- if (!this._instance.config.error_tracking.__capturePostHogExceptions && this.ti(t)) return void ki.info("Skipping exception capture because it was thrown by the PostHog SDK");
2153
- }
2154
- return this._instance.capture("$exception", e, { _noTruncate: !0, _batchKey: "exceptionEvent" });
2155
- }
2156
- Qt(e) {
2157
- if (e.length === 0) return !1;
2158
- var t = e.reduce(((i, s) => {
2159
- var { type: n, value: a } = s;
2160
- return N(n) && n.length > 0 && i.$exception_types.push(n), N(a) && a.length > 0 && i.$exception_values.push(a), i;
2161
- }), { $exception_types: [], $exception_values: [] });
2162
- return this.Jt.some(((i) => {
2163
- var s = i.values.map(((n) => {
2164
- var a, o = En[n.operator], l = F(n.value) ? n.value : [n.value], c = (a = t[n.key]) !== null && a !== void 0 ? a : [];
2165
- return l.length > 0 && o(l, c);
2166
- }));
2167
- return i.type === "OR" ? s.some(Boolean) : s.every(Boolean);
2168
- }));
2169
- }
2170
- Zt(e) {
2171
- return e.flatMap(((t) => {
2172
- var i, s;
2173
- return (i = (s = t.stacktrace) == null ? void 0 : s.frames) !== null && i !== void 0 ? i : [];
2174
- })).some(((t) => t.filename && t.filename.startsWith("chrome-extension://")));
2175
- }
2176
- ti(e) {
2177
- if (e.length > 0) {
2178
- var t, i, s, n, a = (t = (i = e[0].stacktrace) == null ? void 0 : i.frames) !== null && t !== void 0 ? t : [], o = a[a.length - 1];
2179
- return (s = o == null || (n = o.filename) == null ? void 0 : n.includes("posthog.com/static")) !== null && s !== void 0 && s;
2180
- }
2181
- return !1;
2182
- }
2183
- Xt(e) {
2184
- return !O(e) && F(e);
2185
- }
2186
- }
2187
- var oe = U("[FeatureFlags]"), xi = "$active_feature_flags", Ye = "$override_feature_flags", ts = "$feature_flag_payloads", dt = "$override_feature_flag_payloads", is = "$feature_flag_request_id", rs = (r) => {
2188
- var e = {};
2189
- for (var [t, i] of Ut(r || {})) i && (e[t] = i);
2190
- return e;
2191
- }, Co = (r) => {
2192
- var e = r.flags;
2193
- return e ? (r.featureFlags = Object.fromEntries(Object.keys(e).map(((t) => {
2194
- var i;
2195
- return [t, (i = e[t].variant) !== null && i !== void 0 ? i : e[t].enabled];
2196
- }))), r.featureFlagPayloads = Object.fromEntries(Object.keys(e).filter(((t) => e[t].enabled)).filter(((t) => {
2197
- var i;
2198
- return (i = e[t].metadata) == null ? void 0 : i.payload;
2199
- })).map(((t) => {
2200
- var i;
2201
- return [t, (i = e[t].metadata) == null ? void 0 : i.payload];
2202
- })))) : oe.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"), r;
2203
- }, Po = (function(r) {
2204
- return r.FeatureFlags = "feature_flags", r.Recordings = "recordings", r;
2205
- })({});
2206
- class Io {
2207
- constructor(e) {
2208
- this.ii = !1, this.ei = !1, this.ri = !1, this.si = !1, this.ni = !1, this.oi = !1, this.ai = !1, this._instance = e, this.featureFlagEventHandlers = [];
2209
- }
2210
- li() {
2211
- var e = this._instance.config.evaluation_environments;
2212
- return e != null && e.length ? e.filter(((t) => {
2213
- var i = t && typeof t == "string" && t.trim().length > 0;
2214
- return i || oe.error("Invalid evaluation environment found:", t, "Expected non-empty string"), i;
2215
- })) : [];
2216
- }
2217
- ui() {
2218
- return this.li().length > 0;
2219
- }
2220
- flags() {
2221
- if (this._instance.config.__preview_remote_config) this.oi = !0;
2222
- else {
2223
- var e = !this.hi && (this._instance.config.advanced_disable_feature_flags || this._instance.config.advanced_disable_feature_flags_on_first_load);
2224
- this.di({ disableFlags: e });
2225
- }
2226
- }
2227
- get hasLoadedFlags() {
2228
- return this.ei;
2229
- }
2230
- getFlags() {
2231
- return Object.keys(this.getFlagVariants());
2232
- }
2233
- getFlagsWithDetails() {
2234
- var e = this._instance.get_property(Li), t = this._instance.get_property(Ye), i = this._instance.get_property(dt);
2235
- if (!i && !t) return e || {};
2236
- var s = M({}, e || {}), n = [.../* @__PURE__ */ new Set([...Object.keys(i || {}), ...Object.keys(t || {})])];
2237
- for (var a of n) {
2238
- var o, l, c = s[a], u = t == null ? void 0 : t[a], h = v(u) ? (o = c == null ? void 0 : c.enabled) !== null && o !== void 0 && o : !!u, g = v(u) ? c.variant : typeof u == "string" ? u : void 0, p = i == null ? void 0 : i[a], f = w({}, c, { enabled: h, variant: h ? g ?? (c == null ? void 0 : c.variant) : void 0 });
2239
- h !== (c == null ? void 0 : c.enabled) && (f.original_enabled = c == null ? void 0 : c.enabled), g !== (c == null ? void 0 : c.variant) && (f.original_variant = c == null ? void 0 : c.variant), p && (f.metadata = w({}, c == null ? void 0 : c.metadata, { payload: p, original_payload: c == null || (l = c.metadata) == null ? void 0 : l.payload })), s[a] = f;
2240
- }
2241
- return this.ii || (oe.warn(" Overriding feature flag details!", { flagDetails: e, overriddenPayloads: i, finalDetails: s }), this.ii = !0), s;
2242
- }
2243
- getFlagVariants() {
2244
- var e = this._instance.get_property(Je), t = this._instance.get_property(Ye);
2245
- if (!t) return e || {};
2246
- for (var i = M({}, e), s = Object.keys(t), n = 0; n < s.length; n++) i[s[n]] = t[s[n]];
2247
- return this.ii || (oe.warn(" Overriding feature flags!", { enabledFlags: e, overriddenFlags: t, finalFlags: i }), this.ii = !0), i;
2248
- }
2249
- getFlagPayloads() {
2250
- var e = this._instance.get_property(ts), t = this._instance.get_property(dt);
2251
- if (!t) return e || {};
2252
- for (var i = M({}, e || {}), s = Object.keys(t), n = 0; n < s.length; n++) i[s[n]] = t[s[n]];
2253
- return this.ii || (oe.warn(" Overriding feature flag payloads!", { flagPayloads: e, overriddenPayloads: t, finalPayloads: i }), this.ii = !0), i;
2254
- }
2255
- reloadFeatureFlags() {
2256
- this.si || this._instance.config.advanced_disable_feature_flags || this.hi || (this.hi = setTimeout((() => {
2257
- this.di();
2258
- }), 5));
2259
- }
2260
- vi() {
2261
- clearTimeout(this.hi), this.hi = void 0;
2262
- }
2263
- ensureFlagsLoaded() {
2264
- this.ei || this.ri || this.hi || this.reloadFeatureFlags();
2265
- }
2266
- setAnonymousDistinctId(e) {
2267
- this.$anon_distinct_id = e;
2268
- }
2269
- setReloadingPaused(e) {
2270
- this.si = e;
2271
- }
2272
- di(e) {
2273
- var t;
2274
- if (this.vi(), !this._instance.M()) if (this.ri) this.ni = !0;
2275
- else {
2276
- var i = { token: this._instance.config.token, distinct_id: this._instance.get_distinct_id(), groups: this._instance.getGroups(), $anon_distinct_id: this.$anon_distinct_id, person_properties: w({}, ((t = this._instance.persistence) == null ? void 0 : t.get_initial_props()) || {}, this._instance.get_property(vt) || {}), group_properties: this._instance.get_property(je) };
2277
- (e != null && e.disableFlags || this._instance.config.advanced_disable_feature_flags) && (i.disable_flags = !0), this.ui() && (i.evaluation_environments = this.li());
2278
- var s = this._instance.config.__preview_remote_config, n = s ? "/flags/?v=2" : "/flags/?v=2&config=true", a = this._instance.config.advanced_only_evaluate_survey_feature_flags ? "&only_evaluate_survey_feature_flags=true" : "", o = this._instance.requestRouter.endpointFor("flags", n + a);
2279
- s && (i.timezone = _n()), this.ri = !0, this._instance.ci({ method: "POST", url: o, data: i, compression: this._instance.config.disable_compression ? void 0 : we.Base64, timeout: this._instance.config.feature_flag_request_timeout_ms, callback: (l) => {
2280
- var c, u, h = !0;
2281
- if (l.statusCode === 200 && (this.ni || (this.$anon_distinct_id = void 0), h = !1), this.ri = !1, this.oi || (this.oi = !0, this._instance.fi((u = l.json) !== null && u !== void 0 ? u : {})), !i.disable_flags || this.ni) if (this.ai = !h, l.json && (c = l.json.quotaLimited) != null && c.includes(Po.FeatureFlags)) oe.warn("You have hit your feature flags quota limit, and will not be able to load feature flags until the quota is reset. Please visit https://posthog.com/docs/billing/limits-alerts to learn more.");
2282
- else {
2283
- var g;
2284
- i.disable_flags || this.receivedFeatureFlags((g = l.json) !== null && g !== void 0 ? g : {}, h), this.ni && (this.ni = !1, this.di());
2285
- }
2286
- } });
2287
- }
2288
- }
2289
- getFeatureFlag(e, t) {
2290
- if (t === void 0 && (t = {}), this.ei || this.getFlags() && this.getFlags().length > 0) {
2291
- var i = this.getFlagVariants()[e], s = "" + i, n = this._instance.get_property(is) || void 0, a = this._instance.get_property(Yt) || {};
2292
- if ((t.send_event || !("send_event" in t)) && (!(e in a) || !a[e].includes(s))) {
2293
- var o, l, c, u, h, g, p, f, _;
2294
- F(a[e]) ? a[e].push(s) : a[e] = [s], (o = this._instance.persistence) == null || o.register({ [Yt]: a });
2295
- var b = this.getFeatureFlagDetails(e), E = { $feature_flag: e, $feature_flag_response: i, $feature_flag_payload: this.getFeatureFlagPayload(e) || null, $feature_flag_request_id: n, $feature_flag_bootstrapped_response: ((l = this._instance.config.bootstrap) == null || (l = l.featureFlags) == null ? void 0 : l[e]) || null, $feature_flag_bootstrapped_payload: ((c = this._instance.config.bootstrap) == null || (c = c.featureFlagPayloads) == null ? void 0 : c[e]) || null, $used_bootstrap_value: !this.ai };
2296
- v(b == null || (u = b.metadata) == null ? void 0 : u.version) || (E.$feature_flag_version = b.metadata.version);
2297
- var x, I = (h = b == null || (g = b.reason) == null ? void 0 : g.description) !== null && h !== void 0 ? h : b == null || (p = b.reason) == null ? void 0 : p.code;
2298
- I && (E.$feature_flag_reason = I), b != null && (f = b.metadata) != null && f.id && (E.$feature_flag_id = b.metadata.id), v(b == null ? void 0 : b.original_variant) && v(b == null ? void 0 : b.original_enabled) || (E.$feature_flag_original_response = v(b.original_variant) ? b.original_enabled : b.original_variant), b != null && (_ = b.metadata) != null && _.original_payload && (E.$feature_flag_original_payload = b == null || (x = b.metadata) == null ? void 0 : x.original_payload), this._instance.capture("$feature_flag_called", E);
2299
- }
2300
- return i;
2301
- }
2302
- oe.warn('getFeatureFlag for key "' + e + `" failed. Feature flags didn't load in time.`);
2303
- }
2304
- getFeatureFlagDetails(e) {
2305
- return this.getFlagsWithDetails()[e];
2306
- }
2307
- getFeatureFlagPayload(e) {
2308
- return this.getFlagPayloads()[e];
2309
- }
2310
- getRemoteConfigPayload(e, t) {
2311
- var i = this._instance.config.token, s = { distinct_id: this._instance.get_distinct_id(), token: i };
2312
- this.ui() && (s.evaluation_environments = this.li()), this._instance.ci({ method: "POST", url: this._instance.requestRouter.endpointFor("flags", "/flags/?v=2&config=true"), data: s, compression: this._instance.config.disable_compression ? void 0 : we.Base64, timeout: this._instance.config.feature_flag_request_timeout_ms, callback: (n) => {
2313
- var a, o = (a = n.json) == null ? void 0 : a.featureFlagPayloads;
2314
- t((o == null ? void 0 : o[e]) || void 0);
2315
- } });
2316
- }
2317
- isFeatureEnabled(e, t) {
2318
- if (t === void 0 && (t = {}), this.ei || this.getFlags() && this.getFlags().length > 0) {
2319
- var i = this.getFeatureFlag(e, t);
2320
- return v(i) ? void 0 : !!i;
2321
- }
2322
- oe.warn('isFeatureEnabled for key "' + e + `" failed. Feature flags didn't load in time.`);
2323
- }
2324
- addFeatureFlagsHandler(e) {
2325
- this.featureFlagEventHandlers.push(e);
2326
- }
2327
- removeFeatureFlagsHandler(e) {
2328
- this.featureFlagEventHandlers = this.featureFlagEventHandlers.filter(((t) => t !== e));
2329
- }
2330
- receivedFeatureFlags(e, t) {
2331
- if (this._instance.persistence) {
2332
- this.ei = !0;
2333
- var i = this.getFlagVariants(), s = this.getFlagPayloads(), n = this.getFlagsWithDetails();
2334
- (function(a, o, l, c, u) {
2335
- l === void 0 && (l = {}), c === void 0 && (c = {}), u === void 0 && (u = {});
2336
- var h = Co(a), g = h.flags, p = h.featureFlags, f = h.featureFlagPayloads;
2337
- if (p) {
2338
- var _ = a.requestId;
2339
- if (F(p)) {
2340
- oe.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");
2341
- var b = {};
2342
- if (p) for (var E = 0; E < p.length; E++) b[p[E]] = !0;
2343
- o && o.register({ [xi]: p, [Je]: b });
2344
- } else {
2345
- var x = p, I = f, C = g;
2346
- a.errorsWhileComputingFlags && (x = w({}, l, x), I = w({}, c, I), C = w({}, u, C)), o && o.register(w({ [xi]: Object.keys(rs(x)), [Je]: x || {}, [ts]: I || {}, [Li]: C || {} }, _ ? { [is]: _ } : {}));
2347
- }
2348
- }
2349
- })(e, this._instance.persistence, i, s, n), this.pi(t);
2350
- }
2351
- }
2352
- override(e, t) {
2353
- t === void 0 && (t = !1), oe.warn("override is deprecated. Please use overrideFeatureFlags instead."), this.overrideFeatureFlags({ flags: e, suppressWarning: t });
2354
- }
2355
- overrideFeatureFlags(e) {
2356
- if (!this._instance.__loaded || !this._instance.persistence) return oe.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");
2357
- if (e === !1) return this._instance.persistence.unregister(Ye), this._instance.persistence.unregister(dt), void this.pi();
2358
- if (e && typeof e == "object" && ("flags" in e || "payloads" in e)) {
2359
- var t, i = e;
2360
- if (this.ii = !!((t = i.suppressWarning) !== null && t !== void 0 && t), "flags" in i) {
2361
- if (i.flags === !1) this._instance.persistence.unregister(Ye);
2362
- else if (i.flags) if (F(i.flags)) {
2363
- for (var s = {}, n = 0; n < i.flags.length; n++) s[i.flags[n]] = !0;
2364
- this._instance.persistence.register({ [Ye]: s });
2365
- } else this._instance.persistence.register({ [Ye]: i.flags });
2366
- }
2367
- return "payloads" in i && (i.payloads === !1 ? this._instance.persistence.unregister(dt) : i.payloads && this._instance.persistence.register({ [dt]: i.payloads })), void this.pi();
2368
- }
2369
- this.pi();
2370
- }
2371
- onFeatureFlags(e) {
2372
- if (this.addFeatureFlagsHandler(e), this.ei) {
2373
- var { flags: t, flagVariants: i } = this.gi();
2374
- e(t, i);
2375
- }
2376
- return () => this.removeFeatureFlagsHandler(e);
2377
- }
2378
- updateEarlyAccessFeatureEnrollment(e, t, i) {
2379
- var s, n = (this._instance.get_property(_t) || []).find(((c) => c.flagKey === e)), a = { ["$feature_enrollment/" + e]: t }, o = { $feature_flag: e, $feature_enrollment: t, $set: a };
2380
- n && (o.$early_access_feature_name = n.name), i && (o.$feature_enrollment_stage = i), this._instance.capture("$feature_enrollment_update", o), this.setPersonPropertiesForFlags(a, !1);
2381
- var l = w({}, this.getFlagVariants(), { [e]: t });
2382
- (s = this._instance.persistence) == null || s.register({ [xi]: Object.keys(rs(l)), [Je]: l }), this.pi();
2383
- }
2384
- getEarlyAccessFeatures(e, t, i) {
2385
- t === void 0 && (t = !1);
2386
- var s = this._instance.get_property(_t), n = i ? "&" + i.map(((a) => "stage=" + a)).join("&") : "";
2387
- if (s && !t) return e(s);
2388
- this._instance.ci({ url: this._instance.requestRouter.endpointFor("api", "/api/early_access_features/?token=" + this._instance.config.token + n), method: "GET", callback: (a) => {
2389
- var o, l;
2390
- if (a.json) {
2391
- var c = a.json.earlyAccessFeatures;
2392
- return (o = this._instance.persistence) == null || o.unregister(_t), (l = this._instance.persistence) == null || l.register({ [_t]: c }), e(c);
2393
- }
2394
- } });
2395
- }
2396
- gi() {
2397
- var e = this.getFlags(), t = this.getFlagVariants();
2398
- return { flags: e.filter(((i) => t[i])), flagVariants: Object.keys(t).filter(((i) => t[i])).reduce(((i, s) => (i[s] = t[s], i)), {}) };
2399
- }
2400
- pi(e) {
2401
- var { flags: t, flagVariants: i } = this.gi();
2402
- this.featureFlagEventHandlers.forEach(((s) => s(t, i, { errorsLoading: e })));
2403
- }
2404
- setPersonPropertiesForFlags(e, t) {
2405
- t === void 0 && (t = !0);
2406
- var i = this._instance.get_property(vt) || {};
2407
- this._instance.register({ [vt]: w({}, i, e) }), t && this._instance.reloadFeatureFlags();
2408
- }
2409
- resetPersonPropertiesForFlags() {
2410
- this._instance.unregister(vt);
2411
- }
2412
- setGroupPropertiesForFlags(e, t) {
2413
- t === void 0 && (t = !0);
2414
- var i = this._instance.get_property(je) || {};
2415
- Object.keys(i).length !== 0 && Object.keys(i).forEach(((s) => {
2416
- i[s] = w({}, i[s], e[s]), delete e[s];
2417
- })), this._instance.register({ [je]: w({}, i, e) }), t && this._instance.reloadFeatureFlags();
2418
- }
2419
- resetGroupPropertiesForFlags(e) {
2420
- if (e) {
2421
- var t = this._instance.get_property(je) || {};
2422
- this._instance.register({ [je]: w({}, t, { [e]: {} }) });
2423
- } else this._instance.unregister(je);
2424
- }
2425
- reset() {
2426
- this.ei = !1, this.ri = !1, this.si = !1, this.ni = !1, this.oi = !1, this.ai = !1, this.$anon_distinct_id = void 0, this.vi(), this.ii = !1;
2427
- }
2428
- }
2429
- var $o = ["cookie", "localstorage", "localstorage+cookie", "sessionstorage", "memory"];
2430
- class Si {
2431
- constructor(e, t) {
2432
- this.C = e, this.props = {}, this.mi = !1, this.yi = ((i) => {
2433
- var s = "";
2434
- return i.token && (s = i.token.replace(/\+/g, "PL").replace(/\//g, "SL").replace(/=/g, "EQ")), i.persistence_name ? "ph_" + i.persistence_name : "ph_" + s + "_posthog";
2435
- })(e), this.Y = this.bi(e), this.load(), e.debug && y.info("Persistence loaded", e.persistence, w({}, this.props)), this.update_config(e, e, t), this.save();
2436
- }
2437
- isDisabled() {
2438
- return !!this.wi;
2439
- }
2440
- bi(e) {
2441
- $o.indexOf(e.persistence.toLowerCase()) === -1 && (y.critical("Unknown persistence type " + e.persistence + "; falling back to localStorage+cookie"), e.persistence = "localStorage+cookie");
2442
- var t = e.persistence.toLowerCase();
2443
- return t === "localstorage" && A.H() ? A : t === "localstorage+cookie" && At.H() ? At : t === "sessionstorage" && q.H() ? q : t === "memory" ? Ua : t === "cookie" ? ge : At.H() ? At : ge;
2444
- }
2445
- properties() {
2446
- var e = {};
2447
- return T(this.props, (function(t, i) {
2448
- if (i === Je && j(t)) for (var s = Object.keys(t), n = 0; n < s.length; n++) e["$feature/" + s[n]] = t[s[n]];
2449
- else o = i, l = !1, (Ee(a = ma) ? l : vr && a.indexOf === vr ? a.indexOf(o) != -1 : (T(a, (function(c) {
2450
- if (l || (l = c === o)) return Wt;
2451
- })), l)) || (e[i] = t);
2452
- var a, o, l;
2453
- })), e;
2454
- }
2455
- load() {
2456
- if (!this.wi) {
2457
- var e = this.Y.W(this.yi);
2458
- e && (this.props = M({}, e));
2459
- }
2460
- }
2461
- save() {
2462
- this.wi || this.Y.G(this.yi, this.props, this.xi, this.$i, this.Si, this.C.debug);
2463
- }
2464
- remove() {
2465
- this.Y.V(this.yi, !1), this.Y.V(this.yi, !0);
2466
- }
2467
- clear() {
2468
- this.remove(), this.props = {};
2469
- }
2470
- register_once(e, t, i) {
2471
- if (j(e)) {
2472
- v(t) && (t = "None"), this.xi = v(i) ? this.Ei : i;
2473
- var s = !1;
2474
- if (T(e, ((n, a) => {
2475
- this.props.hasOwnProperty(a) && this.props[a] !== t || (this.props[a] = n, s = !0);
2476
- })), s) return this.save(), !0;
2477
- }
2478
- return !1;
2479
- }
2480
- register(e, t) {
2481
- if (j(e)) {
2482
- this.xi = v(t) ? this.Ei : t;
2483
- var i = !1;
2484
- if (T(e, ((s, n) => {
2485
- e.hasOwnProperty(n) && this.props[n] !== s && (this.props[n] = s, i = !0);
2486
- })), i) return this.save(), !0;
2487
- }
2488
- return !1;
2489
- }
2490
- unregister(e) {
2491
- e in this.props && (delete this.props[e], this.save());
2492
- }
2493
- update_campaign_params() {
2494
- if (!this.mi) {
2495
- var e = un(this.C.custom_campaign_params, this.C.mask_personal_data_properties, this.C.custom_personal_data_properties);
2496
- Xe(er(e)) || this.register(e), this.mi = !0;
2497
- }
2498
- }
2499
- update_search_keyword() {
2500
- var e;
2501
- this.register((e = m == null ? void 0 : m.referrer) ? dn(e) : {});
2502
- }
2503
- update_referrer_info() {
2504
- var e;
2505
- this.register_once({ $referrer: pn(), $referring_domain: m != null && m.referrer && ((e = Zt(m.referrer)) == null ? void 0 : e.host) || "$direct" }, void 0);
2506
- }
2507
- set_initial_person_info() {
2508
- this.props[ji] || this.props[Bi] || this.register_once({ [Kt]: gn(this.C.mask_personal_data_properties, this.C.custom_personal_data_properties) }, void 0);
2509
- }
2510
- get_initial_props() {
2511
- var e = {};
2512
- T([Bi, ji], ((a) => {
2513
- var o = this.props[a];
2514
- o && T(o, (function(l, c) {
2515
- e["$initial_" + Fi(c)] = l;
2516
- }));
2517
- }));
2518
- var t, i, s = this.props[Kt];
2519
- if (s) {
2520
- var n = (t = fn(s), i = {}, T(t, (function(a, o) {
2521
- i["$initial_" + Fi(o)] = a;
2522
- })), i);
2523
- M(e, n);
2524
- }
2525
- return e;
2526
- }
2527
- safe_merge(e) {
2528
- return T(this.props, (function(t, i) {
2529
- i in e || (e[i] = t);
2530
- })), e;
2531
- }
2532
- update_config(e, t, i) {
2533
- if (this.Ei = this.xi = e.cookie_expiration, this.set_disabled(e.disable_persistence || !!i), this.set_cross_subdomain(e.cross_subdomain_cookie), this.set_secure(e.secure_cookie), e.persistence !== t.persistence) {
2534
- var s = this.bi(e), n = this.props;
2535
- this.clear(), this.Y = s, this.props = n, this.save();
2536
- }
2537
- }
2538
- set_disabled(e) {
2539
- this.wi = e, this.wi ? this.remove() : this.save();
2540
- }
2541
- set_cross_subdomain(e) {
2542
- e !== this.$i && (this.$i = e, this.remove(), this.save());
2543
- }
2544
- set_secure(e) {
2545
- e !== this.Si && (this.Si = e, this.remove(), this.save());
2546
- }
2547
- set_event_timer(e, t) {
2548
- var i = this.props[ft] || {};
2549
- i[e] = t, this.props[ft] = i, this.save();
2550
- }
2551
- remove_event_timer(e) {
2552
- var t = (this.props[ft] || {})[e];
2553
- return v(t) || (delete this.props[ft][e], this.save()), t;
2554
- }
2555
- get_property(e) {
2556
- return this.props[e];
2557
- }
2558
- set_property(e, t) {
2559
- this.props[e] = t, this.save();
2560
- }
2561
- }
2562
- (function(r) {
2563
- return r.Button = "button", r.Tab = "tab", r.Selector = "selector", r;
2564
- })({});
2565
- (function(r) {
2566
- return r.TopLeft = "top_left", r.TopRight = "top_right", r.TopCenter = "top_center", r.MiddleLeft = "middle_left", r.MiddleRight = "middle_right", r.MiddleCenter = "middle_center", r.Left = "left", r.Center = "center", r.Right = "right", r.NextToTrigger = "next_to_trigger", r;
2567
- })({});
2568
- var Ci = (function(r) {
2569
- return r.Popover = "popover", r.API = "api", r.Widget = "widget", r.ExternalSurvey = "external_survey", r;
2570
- })({});
2571
- (function(r) {
2572
- return r.Open = "open", r.MultipleChoice = "multiple_choice", r.SingleChoice = "single_choice", r.Rating = "rating", r.Link = "link", r;
2573
- })({});
2574
- (function(r) {
2575
- return r.NextQuestion = "next_question", r.End = "end", r.ResponseBased = "response_based", r.SpecificQuestion = "specific_question", r;
2576
- })({});
2577
- (function(r) {
2578
- return r.Once = "once", r.Recurring = "recurring", r.Always = "always", r;
2579
- })({});
2580
- var jt = (function(r) {
2581
- return r.SHOWN = "survey shown", r.DISMISSED = "survey dismissed", r.SENT = "survey sent", r;
2582
- })({}), ss = (function(r) {
2583
- return r.SURVEY_ID = "$survey_id", r.SURVEY_NAME = "$survey_name", r.SURVEY_RESPONSE = "$survey_response", r.SURVEY_ITERATION = "$survey_iteration", r.SURVEY_ITERATION_START_DATE = "$survey_iteration_start_date", r.SURVEY_PARTIALLY_COMPLETED = "$survey_partially_completed", r.SURVEY_SUBMISSION_ID = "$survey_submission_id", r.SURVEY_QUESTIONS = "$survey_questions", r.SURVEY_COMPLETED = "$survey_completed", r;
2584
- })({}), kn = (function(r) {
2585
- return r.Popover = "popover", r.Inline = "inline", r;
2586
- })({});
2587
- class ur {
2588
- constructor() {
2589
- this.ki = {}, this.ki = {};
2590
- }
2591
- on(e, t) {
2592
- return this.ki[e] || (this.ki[e] = []), this.ki[e].push(t), () => {
2593
- this.ki[e] = this.ki[e].filter(((i) => i !== t));
2594
- };
2595
- }
2596
- emit(e, t) {
2597
- for (var i of this.ki[e] || []) i(t);
2598
- for (var s of this.ki["*"] || []) s(e, t);
2599
- }
2600
- }
2601
- class Be {
2602
- constructor(e) {
2603
- this.Pi = new ur(), this.Ti = (t, i) => this.Ii(t, i) && this.Ri(t, i) && this.Ci(t, i), this.Ii = (t, i) => i == null || !i.event || (t == null ? void 0 : t.event) === (i == null ? void 0 : i.event), this._instance = e, this.Oi = /* @__PURE__ */ new Set(), this.Fi = /* @__PURE__ */ new Set();
2604
- }
2605
- init() {
2606
- var e;
2607
- if (!v((e = this._instance) == null ? void 0 : e.Mi)) {
2608
- var t;
2609
- (t = this._instance) == null || t.Mi(((i, s) => {
2610
- this.on(i, s);
2611
- }));
2612
- }
2613
- }
2614
- register(e) {
2615
- var t, i;
2616
- if (!v((t = this._instance) == null ? void 0 : t.Mi) && (e.forEach(((a) => {
2617
- var o, l;
2618
- (o = this.Fi) == null || o.add(a), (l = a.steps) == null || l.forEach(((c) => {
2619
- var u;
2620
- (u = this.Oi) == null || u.add((c == null ? void 0 : c.event) || "");
2621
- }));
2622
- })), (i = this._instance) != null && i.autocapture)) {
2623
- var s, n = /* @__PURE__ */ new Set();
2624
- e.forEach(((a) => {
2625
- var o;
2626
- (o = a.steps) == null || o.forEach(((l) => {
2627
- l != null && l.selector && n.add(l == null ? void 0 : l.selector);
2628
- }));
2629
- })), (s = this._instance) == null || s.autocapture.setElementSelectors(n);
2630
- }
2631
- }
2632
- on(e, t) {
2633
- var i;
2634
- t != null && e.length != 0 && (this.Oi.has(e) || this.Oi.has(t == null ? void 0 : t.event)) && this.Fi && ((i = this.Fi) == null ? void 0 : i.size) > 0 && this.Fi.forEach(((s) => {
2635
- this.Ai(t, s) && this.Pi.emit("actionCaptured", s.name);
2636
- }));
2637
- }
2638
- Di(e) {
2639
- this.onAction("actionCaptured", ((t) => e(t)));
2640
- }
2641
- Ai(e, t) {
2642
- if ((t == null ? void 0 : t.steps) == null) return !1;
2643
- for (var i of t.steps) if (this.Ti(e, i)) return !0;
2644
- return !1;
2645
- }
2646
- onAction(e, t) {
2647
- return this.Pi.on(e, t);
2648
- }
2649
- Ri(e, t) {
2650
- if (t != null && t.url) {
2651
- var i, s = e == null || (i = e.properties) == null ? void 0 : i.$current_url;
2652
- if (!s || typeof s != "string" || !Be.ji(s, t == null ? void 0 : t.url, (t == null ? void 0 : t.url_matching) || "contains")) return !1;
2653
- }
2654
- return !0;
2655
- }
2656
- static ji(e, t, i) {
2657
- switch (i) {
2658
- case "regex":
2659
- return !!d && rt(e, t);
2660
- case "exact":
2661
- return t === e;
2662
- case "contains":
2663
- var s = Be.Li(t).replace(/_/g, ".").replace(/%/g, ".*");
2664
- return rt(e, s);
2665
- default:
2666
- return !1;
2667
- }
2668
- }
2669
- static Li(e) {
2670
- return e.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&").replace(/-/g, "\\x2d");
2671
- }
2672
- Ci(e, t) {
2673
- if ((t != null && t.href || t != null && t.tag_name || t != null && t.text) && !this.Ni(e).some(((n) => !(t != null && t.href && !Be.ji(n.href || "", t == null ? void 0 : t.href, (t == null ? void 0 : t.href_matching) || "exact")) && (t == null || !t.tag_name || n.tag_name === (t == null ? void 0 : t.tag_name)) && !(t != null && t.text && !Be.ji(n.text || "", t == null ? void 0 : t.text, (t == null ? void 0 : t.text_matching) || "exact") && !Be.ji(n.$el_text || "", t == null ? void 0 : t.text, (t == null ? void 0 : t.text_matching) || "exact"))))) return !1;
2674
- if (t != null && t.selector) {
2675
- var i, s = e == null || (i = e.properties) == null ? void 0 : i.$element_selectors;
2676
- if (!s || !s.includes(t == null ? void 0 : t.selector)) return !1;
2677
- }
2678
- return !0;
2679
- }
2680
- Ni(e) {
2681
- return (e == null ? void 0 : e.properties.$elements) == null ? [] : e == null ? void 0 : e.properties.$elements;
2682
- }
2683
- }
2684
- var $ = U("[Surveys]"), Xi = "seenSurvey_", To = (r, e) => {
2685
- var t = "$survey_" + e + "/" + r.id;
2686
- return r.current_iteration && r.current_iteration > 0 && (t = "$survey_" + e + "/" + r.id + "/" + r.current_iteration), t;
2687
- }, ns = (r) => {
2688
- var e = "" + Xi + r.id;
2689
- return r.current_iteration && r.current_iteration > 0 && (e = "" + Xi + r.id + "_" + r.current_iteration), e;
2690
- }, Fo = [Ci.Popover, Ci.Widget, Ci.API], Oo = { ignoreConditions: !1, ignoreDelay: !1, displayType: kn.Popover };
2691
- class Ro {
2692
- constructor(e) {
2693
- this._instance = e, this.Ui = /* @__PURE__ */ new Map(), this.zi = /* @__PURE__ */ new Map();
2694
- }
2695
- register(e) {
2696
- var t;
2697
- v((t = this._instance) == null ? void 0 : t.Mi) || (this.Hi(e), this.Bi(e));
2698
- }
2699
- Bi(e) {
2700
- var t = e.filter(((i) => {
2701
- var s, n;
2702
- return ((s = i.conditions) == null ? void 0 : s.actions) && ((n = i.conditions) == null || (n = n.actions) == null || (n = n.values) == null ? void 0 : n.length) > 0;
2703
- }));
2704
- t.length !== 0 && (this.qi == null && (this.qi = new Be(this._instance), this.qi.init(), this.qi.Di(((i) => {
2705
- this.onAction(i);
2706
- }))), t.forEach(((i) => {
2707
- var s, n, a, o, l;
2708
- i.conditions && (s = i.conditions) != null && s.actions && (n = i.conditions) != null && (n = n.actions) != null && n.values && ((a = i.conditions) == null || (a = a.actions) == null || (a = a.values) == null ? void 0 : a.length) > 0 && ((o = this.qi) == null || o.register(i.conditions.actions.values), (l = i.conditions) == null || (l = l.actions) == null || (l = l.values) == null || l.forEach(((c) => {
2709
- if (c && c.name) {
2710
- var u = this.zi.get(c.name);
2711
- u && u.push(i.id), this.zi.set(c.name, u || [i.id]);
2712
- }
2713
- })));
2714
- })));
2715
- }
2716
- Hi(e) {
2717
- var t;
2718
- e.filter(((i) => {
2719
- var s, n;
2720
- return ((s = i.conditions) == null ? void 0 : s.events) && ((n = i.conditions) == null || (n = n.events) == null || (n = n.values) == null ? void 0 : n.length) > 0;
2721
- })).length !== 0 && ((t = this._instance) == null || t.Mi(((i, s) => {
2722
- this.onEvent(i, s);
2723
- })), e.forEach(((i) => {
2724
- var s;
2725
- (s = i.conditions) == null || (s = s.events) == null || (s = s.values) == null || s.forEach(((n) => {
2726
- if (n && n.name) {
2727
- var a = this.Ui.get(n.name);
2728
- a && a.push(i.id), this.Ui.set(n.name, a || [i.id]);
2729
- }
2730
- }));
2731
- })));
2732
- }
2733
- onEvent(e, t) {
2734
- var i, s, n = ((i = this._instance) == null || (i = i.persistence) == null ? void 0 : i.props[Rt]) || [];
2735
- if (jt.SHOWN === e && t && n.length > 0) {
2736
- var a;
2737
- $.info("survey event matched, removing survey from activated surveys", { event: e, eventPayload: t, existingActivatedSurveys: n });
2738
- var o = t == null || (a = t.properties) == null ? void 0 : a.$survey_id;
2739
- if (o) {
2740
- var l = n.indexOf(o);
2741
- l >= 0 && (n.splice(l, 1), this.Wi(n));
2742
- }
2743
- } else if (this.Ui.has(e)) {
2744
- $.info("survey event name matched", { event: e, eventPayload: t, surveys: this.Ui.get(e) });
2745
- var c = [];
2746
- (s = this._instance) == null || s.getSurveys(((h) => {
2747
- c = h.filter(((g) => {
2748
- var p;
2749
- return (p = this.Ui.get(e)) == null ? void 0 : p.includes(g.id);
2750
- }));
2751
- }));
2752
- var u = c.filter(((h) => {
2753
- var g, p = (g = h.conditions) == null || (g = g.events) == null || (g = g.values) == null ? void 0 : g.find(((f) => f.name === e));
2754
- return !!p && (!p.propertyFilters || Object.entries(p.propertyFilters).every(((f) => {
2755
- var _, [b, E] = f, x = t == null || (_ = t.properties) == null ? void 0 : _[b];
2756
- if (v(x) || Ee(x)) return !1;
2757
- var I = [String(x)], C = En[E.operator];
2758
- return C ? C(E.values, I) : ($.warn("Unknown property comparison operator: " + E.operator), !1);
2759
- })));
2760
- }));
2761
- this.Wi(n.concat(u.map(((h) => h.id)) || []));
2762
- }
2763
- }
2764
- onAction(e) {
2765
- var t, i = ((t = this._instance) == null || (t = t.persistence) == null ? void 0 : t.props[Rt]) || [];
2766
- this.zi.has(e) && this.Wi(i.concat(this.zi.get(e) || []));
2767
- }
2768
- Wi(e) {
2769
- var t;
2770
- $.info("updating activated surveys", { activatedSurveys: e }), (t = this._instance) == null || (t = t.persistence) == null || t.register({ [Rt]: [...new Set(e)] });
2771
- }
2772
- getSurveys() {
2773
- var e, t = (e = this._instance) == null || (e = e.persistence) == null ? void 0 : e.props[Rt];
2774
- return t || [];
2775
- }
2776
- getEventToSurveys() {
2777
- return this.Ui;
2778
- }
2779
- Gi() {
2780
- return this.qi;
2781
- }
2782
- }
2783
- class Ao {
2784
- constructor(e) {
2785
- this.Vi = void 0, this._surveyManager = null, this.Ji = !1, this.Ki = !1, this.Yi = [], this._instance = e, this._surveyEventReceiver = null;
2786
- }
2787
- onRemoteConfig(e) {
2788
- if (!this._instance.config.disable_surveys) {
2789
- var t = e.surveys;
2790
- if (O(t)) return $.warn("Flags not loaded yet. Not loading surveys.");
2791
- var i = F(t);
2792
- this.Vi = i ? t.length > 0 : t, $.info("flags response received, isSurveysEnabled: " + this.Vi), this.loadIfEnabled();
2793
- }
2794
- }
2795
- reset() {
2796
- localStorage.removeItem("lastSeenSurveyDate");
2797
- for (var e = [], t = 0; t < localStorage.length; t++) {
2798
- var i = localStorage.key(t);
2799
- (i != null && i.startsWith(Xi) || i != null && i.startsWith("inProgressSurvey_")) && e.push(i);
2800
- }
2801
- e.forEach(((s) => localStorage.removeItem(s)));
2802
- }
2803
- loadIfEnabled() {
2804
- if (!this._surveyManager) if (this.Ki) $.info("Already initializing surveys, skipping...");
2805
- else if (this._instance.config.disable_surveys) $.info("Disabled. Not loading surveys.");
2806
- else if (this._instance.config.cookieless_mode && this._instance.consent.isOptedOut()) $.info("Not loading surveys in cookieless mode without consent.");
2807
- else {
2808
- var e = k == null ? void 0 : k.__PosthogExtensions__;
2809
- if (e) {
2810
- if (!v(this.Vi) || this._instance.config.advanced_enable_surveys) {
2811
- var t = this.Vi || this._instance.config.advanced_enable_surveys;
2812
- this.Ki = !0;
2813
- try {
2814
- var i = e.generateSurveys;
2815
- if (i) return void this.Xi(i, t);
2816
- var s = e.loadExternalDependency;
2817
- if (!s) return void this.Qi("PostHog loadExternalDependency extension not found.");
2818
- s(this._instance, "surveys", ((n) => {
2819
- n || !e.generateSurveys ? this.Qi("Could not load surveys script", n) : this.Xi(e.generateSurveys, t);
2820
- }));
2821
- } catch (n) {
2822
- throw this.Qi("Error initializing surveys", n), n;
2823
- } finally {
2824
- this.Ki = !1;
2825
- }
2826
- }
2827
- } else $.error("PostHog Extensions not found.");
2828
- }
2829
- }
2830
- Xi(e, t) {
2831
- this._surveyManager = e(this._instance, t), this._surveyEventReceiver = new Ro(this._instance), $.info("Surveys loaded successfully"), this.Zi({ isLoaded: !0 });
2832
- }
2833
- Qi(e, t) {
2834
- $.error(e, t), this.Zi({ isLoaded: !1, error: e });
2835
- }
2836
- onSurveysLoaded(e) {
2837
- return this.Yi.push(e), this._surveyManager && this.Zi({ isLoaded: !0 }), () => {
2838
- this.Yi = this.Yi.filter(((t) => t !== e));
2839
- };
2840
- }
2841
- getSurveys(e, t) {
2842
- if (t === void 0 && (t = !1), this._instance.config.disable_surveys) return $.info("Disabled. Not loading surveys."), e([]);
2843
- var i = this._instance.get_property(Ni);
2844
- if (i && !t) return e(i, { isLoaded: !0 });
2845
- if (this.Ji) return e([], { isLoaded: !1, error: "Surveys are already being loaded" });
2846
- try {
2847
- this.Ji = !0, this._instance.ci({ url: this._instance.requestRouter.endpointFor("api", "/api/surveys/?token=" + this._instance.config.token), method: "GET", timeout: this._instance.config.surveys_request_timeout_ms, callback: (s) => {
2848
- var n;
2849
- this.Ji = !1;
2850
- var a = s.statusCode;
2851
- if (a !== 200 || !s.json) {
2852
- var o = "Surveys API could not be loaded, status: " + a;
2853
- return $.error(o), e([], { isLoaded: !1, error: o });
2854
- }
2855
- var l, c = s.json.surveys || [], u = c.filter(((h) => (function(g) {
2856
- return !(!g.start_date || g.end_date);
2857
- })(h) && ((function(g) {
2858
- var p;
2859
- return !((p = g.conditions) == null || (p = p.events) == null || (p = p.values) == null || !p.length);
2860
- })(h) || (function(g) {
2861
- var p;
2862
- return !((p = g.conditions) == null || (p = p.actions) == null || (p = p.values) == null || !p.length);
2863
- })(h))));
2864
- return u.length > 0 && ((l = this._surveyEventReceiver) == null || l.register(u)), (n = this._instance.persistence) == null || n.register({ [Ni]: c }), e(c, { isLoaded: !0 });
2865
- } });
2866
- } catch (s) {
2867
- throw this.Ji = !1, s;
2868
- }
2869
- }
2870
- Zi(e) {
2871
- for (var t of this.Yi) try {
2872
- if (!e.isLoaded) return t([], e);
2873
- this.getSurveys(t);
2874
- } catch (i) {
2875
- $.error("Error in survey callback", i);
2876
- }
2877
- }
2878
- getActiveMatchingSurveys(e, t) {
2879
- if (t === void 0 && (t = !1), !O(this._surveyManager)) return this._surveyManager.getActiveMatchingSurveys(e, t);
2880
- $.warn("init was not called");
2881
- }
2882
- te(e) {
2883
- var t = null;
2884
- return this.getSurveys(((i) => {
2885
- var s;
2886
- t = (s = i.find(((n) => n.id === e))) !== null && s !== void 0 ? s : null;
2887
- })), t;
2888
- }
2889
- ie(e) {
2890
- if (O(this._surveyManager)) return { eligible: !1, reason: "SDK is not enabled or survey functionality is not yet loaded" };
2891
- var t = typeof e == "string" ? this.te(e) : e;
2892
- return t ? this._surveyManager.checkSurveyEligibility(t) : { eligible: !1, reason: "Survey not found" };
2893
- }
2894
- canRenderSurvey(e) {
2895
- if (O(this._surveyManager)) return $.warn("init was not called"), { visible: !1, disabledReason: "SDK is not enabled or survey functionality is not yet loaded" };
2896
- var t = this.ie(e);
2897
- return { visible: t.eligible, disabledReason: t.reason };
2898
- }
2899
- canRenderSurveyAsync(e, t) {
2900
- return O(this._surveyManager) ? ($.warn("init was not called"), Promise.resolve({ visible: !1, disabledReason: "SDK is not enabled or survey functionality is not yet loaded" })) : new Promise(((i) => {
2901
- this.getSurveys(((s) => {
2902
- var n, a = (n = s.find(((l) => l.id === e))) !== null && n !== void 0 ? n : null;
2903
- if (a) {
2904
- var o = this.ie(a);
2905
- i({ visible: o.eligible, disabledReason: o.reason });
2906
- } else i({ visible: !1, disabledReason: "Survey not found" });
2907
- }), t);
2908
- }));
2909
- }
2910
- renderSurvey(e, t) {
2911
- var i;
2912
- if (O(this._surveyManager)) $.warn("init was not called");
2913
- else {
2914
- var s = typeof e == "string" ? this.te(e) : e;
2915
- if (s != null && s.id) if (Fo.includes(s.type)) {
2916
- var n = m == null ? void 0 : m.querySelector(t);
2917
- if (n) return (i = s.appearance) != null && i.surveyPopupDelaySeconds ? ($.info("Rendering survey " + s.id + " with delay of " + s.appearance.surveyPopupDelaySeconds + " seconds"), void setTimeout((() => {
2918
- var a, o;
2919
- $.info("Rendering survey " + s.id + " with delay of " + ((a = s.appearance) == null ? void 0 : a.surveyPopupDelaySeconds) + " seconds"), (o = this._surveyManager) == null || o.renderSurvey(s, n), $.info("Survey " + s.id + " rendered");
2920
- }), 1e3 * s.appearance.surveyPopupDelaySeconds)) : void this._surveyManager.renderSurvey(s, n);
2921
- $.warn("Survey element not found");
2922
- } else $.warn("Surveys of type " + s.type + " cannot be rendered in the app");
2923
- else $.warn("Survey not found");
2924
- }
2925
- }
2926
- displaySurvey(e, t) {
2927
- var i;
2928
- if (O(this._surveyManager)) $.warn("init was not called");
2929
- else {
2930
- var s = this.te(e);
2931
- if (s) {
2932
- var n = s;
2933
- if ((i = s.appearance) != null && i.surveyPopupDelaySeconds && t.ignoreDelay && (n = w({}, s, { appearance: w({}, s.appearance, { surveyPopupDelaySeconds: 0 }) })), t.ignoreConditions === !1) {
2934
- var a = this.canRenderSurvey(s);
2935
- if (!a.visible) return void $.warn("Survey is not eligible to be displayed: ", a.disabledReason);
2936
- }
2937
- t.displayType !== kn.Inline ? this._surveyManager.handlePopoverSurvey(n) : this.renderSurvey(n, t.selector);
2938
- } else $.warn("Survey not found");
2939
- }
2940
- }
2941
- }
2942
- var as = U("[RateLimiter]");
2943
- class Do {
2944
- constructor(e) {
2945
- var t, i;
2946
- this.serverLimits = {}, this.lastEventRateLimited = !1, this.checkForLimiting = (s) => {
2947
- var n = s.text;
2948
- if (n && n.length) try {
2949
- (JSON.parse(n).quota_limited || []).forEach(((a) => {
2950
- as.info((a || "events") + " is quota limited."), this.serverLimits[a] = (/* @__PURE__ */ new Date()).getTime() + 6e4;
2951
- }));
2952
- } catch (a) {
2953
- return void as.warn('could not rate limit - continuing. Error: "' + (a == null ? void 0 : a.message) + '"', { text: n });
2954
- }
2955
- }, this.instance = e, this.captureEventsPerSecond = ((t = e.config.rate_limiting) == null ? void 0 : t.events_per_second) || 10, this.captureEventsBurstLimit = Math.max(((i = e.config.rate_limiting) == null ? void 0 : i.events_burst_limit) || 10 * this.captureEventsPerSecond, this.captureEventsPerSecond), this.lastEventRateLimited = this.clientRateLimitContext(!0).isRateLimited;
2956
- }
2957
- clientRateLimitContext(e) {
2958
- var t, i, s;
2959
- e === void 0 && (e = !1);
2960
- var n = (/* @__PURE__ */ new Date()).getTime(), a = (t = (i = this.instance.persistence) == null ? void 0 : i.get_property(qi)) !== null && t !== void 0 ? t : { tokens: this.captureEventsBurstLimit, last: n };
2961
- a.tokens += (n - a.last) / 1e3 * this.captureEventsPerSecond, a.last = n, a.tokens > this.captureEventsBurstLimit && (a.tokens = this.captureEventsBurstLimit);
2962
- var o = a.tokens < 1;
2963
- return o || e || (a.tokens = Math.max(0, a.tokens - 1)), !o || this.lastEventRateLimited || e || this.instance.capture("$$client_ingestion_warning", { $$client_ingestion_warning_message: "posthog-js client rate limited. Config is set to " + this.captureEventsPerSecond + " events per second and " + this.captureEventsBurstLimit + " events burst limit." }, { skip_client_rate_limiting: !0 }), this.lastEventRateLimited = o, (s = this.instance.persistence) == null || s.set_property(qi, a), { isRateLimited: o, remainingTokens: a.tokens };
2964
- }
2965
- isServerRateLimited(e) {
2966
- var t = this.serverLimits[e || "events"] || !1;
2967
- return t !== !1 && (/* @__PURE__ */ new Date()).getTime() < t;
2968
- }
2969
- }
2970
- var qe = U("[RemoteConfig]");
2971
- class Mo {
2972
- constructor(e) {
2973
- this._instance = e;
2974
- }
2975
- get remoteConfig() {
2976
- var e;
2977
- return (e = k._POSTHOG_REMOTE_CONFIG) == null || (e = e[this._instance.config.token]) == null ? void 0 : e.config;
2978
- }
2979
- ee(e) {
2980
- var t, i;
2981
- (t = k.__PosthogExtensions__) != null && t.loadExternalDependency ? (i = k.__PosthogExtensions__) == null || i.loadExternalDependency == null || i.loadExternalDependency(this._instance, "remote-config", (() => e(this.remoteConfig))) : (qe.error("PostHog Extensions not found. Cannot load remote config."), e());
2982
- }
2983
- re(e) {
2984
- this._instance.ci({ method: "GET", url: this._instance.requestRouter.endpointFor("assets", "/array/" + this._instance.config.token + "/config"), callback: (t) => {
2985
- e(t.json);
2986
- } });
2987
- }
2988
- load() {
2989
- try {
2990
- if (this.remoteConfig) return qe.info("Using preloaded remote config", this.remoteConfig), void this.fi(this.remoteConfig);
2991
- if (this._instance.M()) return void qe.warn("Remote config is disabled. Falling back to local config.");
2992
- this.ee(((e) => {
2993
- if (!e) return qe.info("No config found after loading remote JS config. Falling back to JSON."), void this.re(((t) => {
2994
- this.fi(t);
2995
- }));
2996
- this.fi(e);
2997
- }));
2998
- } catch (e) {
2999
- qe.error("Error loading remote config", e);
3000
- }
3001
- }
3002
- fi(e) {
3003
- e ? this._instance.config.__preview_remote_config ? (this._instance.fi(e), e.hasFeatureFlags !== !1 && this._instance.featureFlags.ensureFlagsLoaded()) : qe.info("__preview_remote_config is disabled. Logging config instead", e) : qe.error("Failed to fetch remote config from PostHog.");
3004
- }
3005
- }
3006
- var Ji = 3e3;
3007
- class Lo {
3008
- constructor(e, t) {
3009
- this.se = !0, this.ne = [], this.oe = de((t == null ? void 0 : t.flush_interval_ms) || Ji, 250, 5e3, y.createLogger("flush interval"), Ji), this.ae = e;
3010
- }
3011
- enqueue(e) {
3012
- this.ne.push(e), this.le || this.ue();
3013
- }
3014
- unload() {
3015
- this.he();
3016
- var e = this.ne.length > 0 ? this.de() : {}, t = Object.values(e);
3017
- [...t.filter(((i) => i.url.indexOf("/e") === 0)), ...t.filter(((i) => i.url.indexOf("/e") !== 0))].map(((i) => {
3018
- this.ae(w({}, i, { transport: "sendBeacon" }));
3019
- }));
3020
- }
3021
- enable() {
3022
- this.se = !1, this.ue();
3023
- }
3024
- ue() {
3025
- var e = this;
3026
- this.se || (this.le = setTimeout((() => {
3027
- if (this.he(), this.ne.length > 0) {
3028
- var t = this.de(), i = function() {
3029
- var n = t[s], a = (/* @__PURE__ */ new Date()).getTime();
3030
- n.data && F(n.data) && T(n.data, ((o) => {
3031
- o.offset = Math.abs(o.timestamp - a), delete o.timestamp;
3032
- })), e.ae(n);
3033
- };
3034
- for (var s in t) i();
3035
- }
3036
- }), this.oe));
3037
- }
3038
- he() {
3039
- clearTimeout(this.le), this.le = void 0;
3040
- }
3041
- de() {
3042
- var e = {};
3043
- return T(this.ne, ((t) => {
3044
- var i, s = t, n = (s ? s.batchKey : null) || s.url;
3045
- v(e[n]) && (e[n] = w({}, s, { data: [] })), (i = e[n].data) == null || i.push(s.data);
3046
- })), this.ne = [], e;
3047
- }
3048
- }
3049
- var No = ["retriesPerformedSoFar"];
3050
- class Uo {
3051
- constructor(e) {
3052
- this.ve = !1, this.ce = 3e3, this.ne = [], this._instance = e, this.ne = [], this.fe = !0, !v(d) && "onLine" in d.navigator && (this.fe = d.navigator.onLine, this.pe = () => {
3053
- this.fe = !0, this.Dt();
3054
- }, this.ge = () => {
3055
- this.fe = !1;
3056
- }, L(d, "online", this.pe), L(d, "offline", this.ge));
3057
- }
3058
- get length() {
3059
- return this.ne.length;
3060
- }
3061
- retriableRequest(e) {
3062
- var { retriesPerformedSoFar: t } = e, i = ms(e, No);
3063
- fe(t) && t > 0 && (i.url = si(i.url, { retry_count: t })), this._instance.ci(w({}, i, { callback: (s) => {
3064
- s.statusCode !== 200 && (s.statusCode < 400 || s.statusCode >= 500) && (t ?? 0) < 10 ? this._e(w({ retriesPerformedSoFar: t }, i)) : i.callback == null || i.callback(s);
3065
- } }));
3066
- }
3067
- _e(e) {
3068
- var t = e.retriesPerformedSoFar || 0;
3069
- e.retriesPerformedSoFar = t + 1;
3070
- var i = (function(a) {
3071
- var o = 3e3 * Math.pow(2, a), l = o / 2, c = Math.min(18e5, o), u = (Math.random() - 0.5) * (c - l);
3072
- return Math.ceil(c + u);
3073
- })(t), s = Date.now() + i;
3074
- this.ne.push({ retryAt: s, requestOptions: e });
3075
- var n = "Enqueued failed request for retry in " + i;
3076
- navigator.onLine || (n += " (Browser is offline)"), y.warn(n), this.ve || (this.ve = !0, this.me());
3077
- }
3078
- me() {
3079
- if (this.ye && clearTimeout(this.ye), this.ne.length === 0) return this.ve = !1, void (this.ye = void 0);
3080
- this.ye = setTimeout((() => {
3081
- this.fe && this.ne.length > 0 && this.Dt(), this.me();
3082
- }), this.ce);
3083
- }
3084
- Dt() {
3085
- var e = Date.now(), t = [], i = this.ne.filter(((n) => n.retryAt < e || (t.push(n), !1)));
3086
- if (this.ne = t, i.length > 0) for (var { requestOptions: s } of i) this.retriableRequest(s);
3087
- }
3088
- unload() {
3089
- for (var { requestOptions: e } of (this.ye && (clearTimeout(this.ye), this.ye = void 0), this.ve = !1, v(d) || (this.pe && (d.removeEventListener("online", this.pe), this.pe = void 0), this.ge && (d.removeEventListener("offline", this.ge), this.ge = void 0)), this.ne)) try {
3090
- this._instance.ci(w({}, e, { transport: "sendBeacon" }));
3091
- } catch (t) {
3092
- y.error(t);
3093
- }
3094
- this.ne = [];
3095
- }
3096
- }
3097
- class qo {
3098
- constructor(e) {
3099
- this.be = () => {
3100
- var t, i, s, n;
3101
- this.we || (this.we = {});
3102
- var a = this.scrollElement(), o = this.scrollY(), l = a ? Math.max(0, a.scrollHeight - a.clientHeight) : 0, c = o + ((a == null ? void 0 : a.clientHeight) || 0), u = (a == null ? void 0 : a.scrollHeight) || 0;
3103
- this.we.lastScrollY = Math.ceil(o), this.we.maxScrollY = Math.max(o, (t = this.we.maxScrollY) !== null && t !== void 0 ? t : 0), this.we.maxScrollHeight = Math.max(l, (i = this.we.maxScrollHeight) !== null && i !== void 0 ? i : 0), this.we.lastContentY = c, this.we.maxContentY = Math.max(c, (s = this.we.maxContentY) !== null && s !== void 0 ? s : 0), this.we.maxContentHeight = Math.max(u, (n = this.we.maxContentHeight) !== null && n !== void 0 ? n : 0);
3104
- }, this._instance = e;
3105
- }
3106
- getContext() {
3107
- return this.we;
3108
- }
3109
- resetContext() {
3110
- var e = this.we;
3111
- return setTimeout(this.be, 0), e;
3112
- }
3113
- startMeasuringScrollPosition() {
3114
- L(d, "scroll", this.be, { capture: !0 }), L(d, "scrollend", this.be, { capture: !0 }), L(d, "resize", this.be);
3115
- }
3116
- scrollElement() {
3117
- if (!this._instance.config.scroll_root_selector) return d == null ? void 0 : d.document.documentElement;
3118
- var e = F(this._instance.config.scroll_root_selector) ? this._instance.config.scroll_root_selector : [this._instance.config.scroll_root_selector];
3119
- for (var t of e) {
3120
- var i = d == null ? void 0 : d.document.querySelector(t);
3121
- if (i) return i;
3122
- }
3123
- }
3124
- scrollY() {
3125
- if (this._instance.config.scroll_root_selector) {
3126
- var e = this.scrollElement();
3127
- return e && e.scrollTop || 0;
3128
- }
3129
- return d && (d.scrollY || d.pageYOffset || d.document.documentElement.scrollTop) || 0;
3130
- }
3131
- scrollX() {
3132
- if (this._instance.config.scroll_root_selector) {
3133
- var e = this.scrollElement();
3134
- return e && e.scrollLeft || 0;
3135
- }
3136
- return d && (d.scrollX || d.pageXOffset || d.document.documentElement.scrollLeft) || 0;
3137
- }
3138
- }
3139
- var jo = (r) => gn(r == null ? void 0 : r.config.mask_personal_data_properties, r == null ? void 0 : r.config.custom_personal_data_properties);
3140
- class os {
3141
- constructor(e, t, i, s) {
3142
- this.xe = (n) => {
3143
- var a = this.$e();
3144
- if (!a || a.sessionId !== n) {
3145
- var o = { sessionId: n, props: this.Se(this._instance) };
3146
- this.Ee.register({ [Ui]: o });
3147
- }
3148
- }, this._instance = e, this.ke = t, this.Ee = i, this.Se = s || jo, this.ke.onSessionId(this.xe);
3149
- }
3150
- $e() {
3151
- return this.Ee.props[Ui];
3152
- }
3153
- getSetOnceProps() {
3154
- var e, t = (e = this.$e()) == null ? void 0 : e.props;
3155
- return t ? "r" in t ? fn(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 } : {};
3156
- }
3157
- getSessionProps() {
3158
- var e = {};
3159
- return T(er(this.getSetOnceProps()), ((t, i) => {
3160
- i === "$current_url" && (i = "url"), e["$session_entry_" + Fi(i)] = t;
3161
- })), e;
3162
- }
3163
- }
3164
- var Pi = U("[SessionId]");
3165
- class ls {
3166
- on(e, t) {
3167
- return this.Pe.on(e, t);
3168
- }
3169
- constructor(e, t, i) {
3170
- var s;
3171
- if (this.Te = [], this.Ie = void 0, this.Pe = new ur(), this.Re = (u, h) => Math.abs(u - h) > this.sessionTimeoutMs, !e.persistence) throw new Error("SessionIdManager requires a PostHogPersistence instance");
3172
- if (e.config.cookieless_mode === "always") throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');
3173
- this.C = e.config, this.Ee = e.persistence, this.Ce = void 0, this.Oe = void 0, this._sessionStartTimestamp = null, this._sessionActivityTimestamp = null, this.Fe = t || Te, this.Me = i || Te;
3174
- var n = this.C.persistence_name || this.C.token, a = this.C.session_idle_timeout_seconds || 1800;
3175
- if (this._sessionTimeoutMs = 1e3 * de(a, 60, 36e3, Pi.createLogger("session_idle_timeout_seconds"), 1800), e.register({ $configured_session_timeout_ms: this._sessionTimeoutMs }), this.Ae(), this.De = "ph_" + n + "_window_id", this.je = "ph_" + n + "_primary_window_exists", this.Le()) {
3176
- var o = q.W(this.De), l = q.W(this.je);
3177
- o && !l ? this.Ce = o : q.V(this.De), q.G(this.je, !0);
3178
- }
3179
- if ((s = this.C.bootstrap) != null && s.sessionID) try {
3180
- var c = ((u) => {
3181
- var h = u.replace(/-/g, "");
3182
- if (h.length !== 32) throw new Error("Not a valid UUID");
3183
- if (h[12] !== "7") throw new Error("Not a UUIDv7");
3184
- return parseInt(h.substring(0, 12), 16);
3185
- })(this.C.bootstrap.sessionID);
3186
- this.Ne(this.C.bootstrap.sessionID, (/* @__PURE__ */ new Date()).getTime(), c);
3187
- } catch (u) {
3188
- Pi.error("Invalid sessionID in bootstrap", u);
3189
- }
3190
- this.Ue();
3191
- }
3192
- get sessionTimeoutMs() {
3193
- return this._sessionTimeoutMs;
3194
- }
3195
- onSessionId(e) {
3196
- return v(this.Te) && (this.Te = []), this.Te.push(e), this.Oe && e(this.Oe, this.Ce), () => {
3197
- this.Te = this.Te.filter(((t) => t !== e));
3198
- };
3199
- }
3200
- Le() {
3201
- return this.C.persistence !== "memory" && !this.Ee.wi && q.H();
3202
- }
3203
- ze(e) {
3204
- e !== this.Ce && (this.Ce = e, this.Le() && q.G(this.De, e));
3205
- }
3206
- He() {
3207
- return this.Ce ? this.Ce : this.Le() ? q.W(this.De) : null;
3208
- }
3209
- Ne(e, t, i) {
3210
- e === this.Oe && t === this._sessionActivityTimestamp && i === this._sessionStartTimestamp || (this._sessionStartTimestamp = i, this._sessionActivityTimestamp = t, this.Oe = e, this.Ee.register({ [zt]: [t, e, i] }));
3211
- }
3212
- Be() {
3213
- if (this.Oe && this._sessionActivityTimestamp && this._sessionStartTimestamp) return [this._sessionActivityTimestamp, this.Oe, this._sessionStartTimestamp];
3214
- var e = this.Ee.props[zt];
3215
- return F(e) && e.length === 2 && e.push(e[0]), e || [0, null, 0];
3216
- }
3217
- resetSessionId() {
3218
- this.Ne(null, null, null);
3219
- }
3220
- destroy() {
3221
- clearTimeout(this.qe), this.qe = void 0, this.Ie && d && (d.removeEventListener("beforeunload", this.Ie, { capture: !1 }), this.Ie = void 0), this.Te = [];
3222
- }
3223
- Ue() {
3224
- this.Ie = () => {
3225
- this.Le() && q.V(this.je);
3226
- }, L(d, "beforeunload", this.Ie, { capture: !1 });
3227
- }
3228
- checkAndGetSessionAndWindowId(e, t) {
3229
- if (e === void 0 && (e = !1), t === void 0 && (t = null), this.C.cookieless_mode === "always") throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');
3230
- var i = t || (/* @__PURE__ */ new Date()).getTime(), [s, n, a] = this.Be(), o = this.He(), l = fe(a) && a > 0 && Math.abs(i - a) > 864e5, c = !1, u = !n, h = !u && !e && this.Re(i, s);
3231
- u || h || l ? (n = this.Fe(), o = this.Me(), Pi.info("new session ID generated", { sessionId: n, windowId: o, changeReason: { noSessionId: u, activityTimeout: h, sessionPastMaximumLength: l } }), a = i, c = !0) : o || (o = this.Me(), c = !0);
3232
- var g = s === 0 || !e || l ? i : s, p = a === 0 ? (/* @__PURE__ */ new Date()).getTime() : a;
3233
- return this.ze(o), this.Ne(n, g, p), e || this.Ae(), c && this.Te.forEach(((f) => f(n, o, c ? { noSessionId: u, activityTimeout: h, sessionPastMaximumLength: l } : void 0))), { sessionId: n, windowId: o, sessionStartTimestamp: p, changeReason: c ? { noSessionId: u, activityTimeout: h, sessionPastMaximumLength: l } : void 0, lastActivityTimestamp: s };
3234
- }
3235
- Ae() {
3236
- clearTimeout(this.qe), this.qe = setTimeout((() => {
3237
- var [e] = this.Be();
3238
- if (this.Re((/* @__PURE__ */ new Date()).getTime(), e)) {
3239
- var t = this.Oe;
3240
- this.resetSessionId(), this.Pe.emit("forcedIdleReset", { idleSessionId: t });
3241
- }
3242
- }), 1.1 * this.sessionTimeoutMs);
3243
- }
3244
- }
3245
- var Bo = ["$set_once", "$set"], Ie = U("[SiteApps]");
3246
- class Ho {
3247
- constructor(e) {
3248
- this._instance = e, this.We = [], this.apps = {};
3249
- }
3250
- get isEnabled() {
3251
- return !!this._instance.config.opt_in_site_apps;
3252
- }
3253
- Ge(e, t) {
3254
- if (t) {
3255
- var i = this.globalsForEvent(t);
3256
- this.We.push(i), this.We.length > 1e3 && (this.We = this.We.slice(10));
3257
- }
3258
- }
3259
- get siteAppLoaders() {
3260
- var e;
3261
- return (e = k._POSTHOG_REMOTE_CONFIG) == null || (e = e[this._instance.config.token]) == null ? void 0 : e.siteApps;
3262
- }
3263
- init() {
3264
- if (this.isEnabled) {
3265
- var e = this._instance.Mi(this.Ge.bind(this));
3266
- this.Ve = () => {
3267
- e(), this.We = [], this.Ve = void 0;
3268
- };
3269
- }
3270
- }
3271
- globalsForEvent(e) {
3272
- var t, i, s, n, a, o, l;
3273
- if (!e) throw new Error("Event payload is required");
3274
- var c = {}, u = this._instance.get_property("$groups") || [], h = this._instance.get_property("$stored_group_properties") || {};
3275
- for (var [g, p] of Object.entries(h)) c[g] = { id: u[g], type: g, properties: p };
3276
- var { $set_once: f, $set: _ } = e;
3277
- return { event: w({}, ms(e, Bo), { properties: w({}, e.properties, _ ? { $set: w({}, (t = (i = e.properties) == null ? void 0 : i.$set) !== null && t !== void 0 ? t : {}, _) } : {}, f ? { $set_once: w({}, (s = (n = e.properties) == null ? void 0 : n.$set_once) !== null && s !== void 0 ? s : {}, f) } : {}), elements_chain: (a = (o = e.properties) == null ? void 0 : o.$elements_chain) !== null && a !== void 0 ? a : "", distinct_id: (l = e.properties) == null ? void 0 : l.distinct_id }), person: { properties: this._instance.get_property("$stored_person_properties") }, groups: c };
3278
- }
3279
- setupSiteApp(e) {
3280
- var t = this.apps[e.id], i = () => {
3281
- var o;
3282
- !t.errored && this.We.length && (Ie.info("Processing " + this.We.length + " events for site app with id " + e.id), this.We.forEach(((l) => t.processEvent == null ? void 0 : t.processEvent(l))), t.processedBuffer = !0), Object.values(this.apps).every(((l) => l.processedBuffer || l.errored)) && ((o = this.Ve) == null || o.call(this));
3283
- }, s = !1, n = (o) => {
3284
- t.errored = !o, t.loaded = !0, Ie.info("Site app with id " + e.id + " " + (o ? "loaded" : "errored")), s && i();
3285
- };
3286
- try {
3287
- var { processEvent: a } = e.init({ posthog: this._instance, callback: (o) => {
3288
- n(o);
3289
- } });
3290
- a && (t.processEvent = a), s = !0;
3291
- } catch (o) {
3292
- Ie.error("Error while initializing PostHog app with config id " + e.id, o), n(!1);
3293
- }
3294
- if (s && t.loaded) try {
3295
- i();
3296
- } catch (o) {
3297
- Ie.error("Error while processing buffered events PostHog app with config id " + e.id, o), t.errored = !0;
3298
- }
3299
- }
3300
- Je() {
3301
- var e = this.siteAppLoaders || [];
3302
- for (var t of e) this.apps[t.id] = { id: t.id, loaded: !1, errored: !1, processedBuffer: !1 };
3303
- for (var i of e) this.setupSiteApp(i);
3304
- }
3305
- Ke(e) {
3306
- if (Object.keys(this.apps).length !== 0) {
3307
- var t = this.globalsForEvent(e);
3308
- for (var i of Object.values(this.apps)) try {
3309
- i.processEvent == null || i.processEvent(t);
3310
- } catch (s) {
3311
- Ie.error("Error while processing event " + e.event + " for site app " + i.id, s);
3312
- }
3313
- }
3314
- }
3315
- onRemoteConfig(e) {
3316
- var t, i, s, n = this;
3317
- if ((t = this.siteAppLoaders) != null && t.length) return this.isEnabled ? (this.Je(), void this._instance.on("eventCaptured", ((c) => this.Ke(c)))) : void Ie.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');
3318
- if ((i = this.Ve) == null || i.call(this), (s = e.siteApps) != null && s.length) if (this.isEnabled) {
3319
- var a = function(c) {
3320
- var u;
3321
- k["__$$ph_site_app_" + c] = n._instance, (u = k.__PosthogExtensions__) == null || u.loadSiteApp == null || u.loadSiteApp(n._instance, l, ((h) => {
3322
- if (h) return Ie.error("Error while initializing PostHog app with config id " + c, h);
3323
- }));
3324
- };
3325
- for (var { id: o, url: l } of e.siteApps) a(o);
3326
- } else Ie.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');
3327
- }
3328
- }
3329
- var xn = function(r, e) {
3330
- if (!r) return !1;
3331
- var t = r.userAgent;
3332
- if (t && wr(t, e)) return !0;
3333
- try {
3334
- var i = r == null ? void 0 : r.userAgentData;
3335
- if (i != null && i.brands && i.brands.some(((s) => wr(s == null ? void 0 : s.brand, e)))) return !0;
3336
- } catch {
3337
- }
3338
- return !!r.webdriver;
3339
- }, bt = (function(r) {
3340
- return r.US = "us", r.EU = "eu", r.CUSTOM = "custom", r;
3341
- })({}), cs = "i.posthog.com";
3342
- class Vo {
3343
- constructor(e) {
3344
- this.Ye = {}, this.instance = e;
3345
- }
3346
- get apiHost() {
3347
- var e = this.instance.config.api_host.trim().replace(/\/$/, "");
3348
- return e === "https://app.posthog.com" ? "https://us.i.posthog.com" : e;
3349
- }
3350
- get flagsApiHost() {
3351
- var e = this.instance.config.flags_api_host;
3352
- return e ? e.trim().replace(/\/$/, "") : this.apiHost;
3353
- }
3354
- get uiHost() {
3355
- var e, t = (e = this.instance.config.ui_host) == null ? void 0 : e.replace(/\/$/, "");
3356
- return t || (t = this.apiHost.replace("." + cs, ".posthog.com")), t === "https://app.posthog.com" ? "https://us.posthog.com" : t;
3357
- }
3358
- get region() {
3359
- return this.Ye[this.apiHost] || (/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost) ? this.Ye[this.apiHost] = bt.US : /https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost) ? this.Ye[this.apiHost] = bt.EU : this.Ye[this.apiHost] = bt.CUSTOM), this.Ye[this.apiHost];
3360
- }
3361
- endpointFor(e, t) {
3362
- if (t === void 0 && (t = ""), t && (t = t[0] === "/" ? t : "/" + t), e === "ui") return this.uiHost + t;
3363
- if (e === "flags") return this.flagsApiHost + t;
3364
- if (this.region === bt.CUSTOM) return this.apiHost + t;
3365
- var i = cs + t;
3366
- switch (e) {
3367
- case "assets":
3368
- return "https://" + this.region + "-assets." + i;
3369
- case "api":
3370
- return "https://" + this.region + "." + i;
3371
- }
3372
- }
3373
- }
3374
- var Go = { icontains: (r, e) => !!d && e.href.toLowerCase().indexOf(r.toLowerCase()) > -1, not_icontains: (r, e) => !!d && e.href.toLowerCase().indexOf(r.toLowerCase()) === -1, regex: (r, e) => !!d && rt(e.href, r), not_regex: (r, e) => !!d && !rt(e.href, r), exact: (r, e) => e.href === r, is_not: (r, e) => e.href !== r };
3375
- class B {
3376
- constructor(e) {
3377
- var t = this;
3378
- this.getWebExperimentsAndEvaluateDisplayLogic = function(i) {
3379
- i === void 0 && (i = !1), t.getWebExperiments(((s) => {
3380
- B.Xe("retrieved web experiments from the server"), t.Qe = /* @__PURE__ */ new Map(), s.forEach(((n) => {
3381
- if (n.feature_flag_key) {
3382
- var a;
3383
- t.Qe && (B.Xe("setting flag key ", n.feature_flag_key, " to web experiment ", n), (a = t.Qe) == null || a.set(n.feature_flag_key, n));
3384
- var o = t._instance.getFeatureFlag(n.feature_flag_key);
3385
- N(o) && n.variants[o] && t.Ze(n.name, o, n.variants[o].transforms);
3386
- } else if (n.variants) for (var l in n.variants) {
3387
- var c = n.variants[l];
3388
- B.tr(c) && t.Ze(n.name, l, c.transforms);
3389
- }
3390
- }));
3391
- }), i);
3392
- }, this._instance = e, this._instance.onFeatureFlags(((i) => {
3393
- this.onFeatureFlags(i);
3394
- }));
3395
- }
3396
- onFeatureFlags(e) {
3397
- if (this._is_bot()) B.Xe("Refusing to render web experiment since the viewer is a likely bot");
3398
- else if (!this._instance.config.disable_web_experiments) {
3399
- if (O(this.Qe)) return this.Qe = /* @__PURE__ */ new Map(), this.loadIfEnabled(), void this.previewWebExperiment();
3400
- B.Xe("applying feature flags", e), e.forEach(((t) => {
3401
- var i;
3402
- if (this.Qe && (i = this.Qe) != null && i.has(t)) {
3403
- var s, n = this._instance.getFeatureFlag(t), a = (s = this.Qe) == null ? void 0 : s.get(t);
3404
- n && a != null && a.variants[n] && this.Ze(a.name, n, a.variants[n].transforms);
3405
- }
3406
- }));
3407
- }
3408
- }
3409
- previewWebExperiment() {
3410
- var e = B.getWindowLocation();
3411
- if (e != null && e.search) {
3412
- var t = Qt(e == null ? void 0 : e.search, "__experiment_id"), i = Qt(e == null ? void 0 : e.search, "__experiment_variant");
3413
- t && i && (B.Xe("previewing web experiments " + t + " && " + i), this.getWebExperiments(((s) => {
3414
- this.ir(parseInt(t), i, s);
3415
- }), !1, !0));
3416
- }
3417
- }
3418
- loadIfEnabled() {
3419
- this._instance.config.disable_web_experiments || this.getWebExperimentsAndEvaluateDisplayLogic();
3420
- }
3421
- getWebExperiments(e, t, i) {
3422
- if (this._instance.config.disable_web_experiments && !i) return e([]);
3423
- var s = this._instance.get_property("$web_experiments");
3424
- if (s && !t) return e(s);
3425
- this._instance.ci({ url: this._instance.requestRouter.endpointFor("api", "/api/web_experiments/?token=" + this._instance.config.token), method: "GET", callback: (n) => {
3426
- if (n.statusCode !== 200 || !n.json) return e([]);
3427
- var a = n.json.experiments || [];
3428
- return e(a);
3429
- } });
3430
- }
3431
- ir(e, t, i) {
3432
- var s = i.filter(((n) => n.id === e));
3433
- s && s.length > 0 && (B.Xe("Previewing web experiment [" + s[0].name + "] with variant [" + t + "]"), this.Ze(s[0].name, t, s[0].variants[t].transforms));
3434
- }
3435
- static tr(e) {
3436
- return !O(e.conditions) && B.er(e) && B.rr(e);
3437
- }
3438
- static er(e) {
3439
- var t;
3440
- if (O(e.conditions) || O((t = e.conditions) == null ? void 0 : t.url)) return !0;
3441
- var i, s, n, a = B.getWindowLocation();
3442
- return !!a && ((i = e.conditions) == null || !i.url || Go[(s = (n = e.conditions) == null ? void 0 : n.urlMatchType) !== null && s !== void 0 ? s : "icontains"](e.conditions.url, a));
3443
- }
3444
- static getWindowLocation() {
3445
- return d == null ? void 0 : d.location;
3446
- }
3447
- static rr(e) {
3448
- var t;
3449
- if (O(e.conditions) || O((t = e.conditions) == null ? void 0 : t.utm)) return !0;
3450
- var i = un();
3451
- if (i.utm_source) {
3452
- var s, n, a, o, l, c, u, h, g = (s = e.conditions) == null || (s = s.utm) == null || !s.utm_campaign || ((n = e.conditions) == null || (n = n.utm) == null ? void 0 : n.utm_campaign) == i.utm_campaign, p = (a = e.conditions) == null || (a = a.utm) == null || !a.utm_source || ((o = e.conditions) == null || (o = o.utm) == null ? void 0 : o.utm_source) == i.utm_source, f = (l = e.conditions) == null || (l = l.utm) == null || !l.utm_medium || ((c = e.conditions) == null || (c = c.utm) == null ? void 0 : c.utm_medium) == i.utm_medium, _ = (u = e.conditions) == null || (u = u.utm) == null || !u.utm_term || ((h = e.conditions) == null || (h = h.utm) == null ? void 0 : h.utm_term) == i.utm_term;
3453
- return g && f && _ && p;
3454
- }
3455
- return !1;
3456
- }
3457
- static Xe(e) {
3458
- for (var t = arguments.length, i = new Array(t > 1 ? t - 1 : 0), s = 1; s < t; s++) i[s - 1] = arguments[s];
3459
- y.info("[WebExperiments] " + e, i);
3460
- }
3461
- Ze(e, t, i) {
3462
- this._is_bot() ? B.Xe("Refusing to render web experiment since the viewer is a likely bot") : t !== "control" ? i.forEach(((s) => {
3463
- if (s.selector) {
3464
- var n;
3465
- B.Xe("applying transform of variant " + t + " for experiment " + e + " ", s);
3466
- var a = (n = document) == null ? void 0 : n.querySelectorAll(s.selector);
3467
- a == null || a.forEach(((o) => {
3468
- var l = o;
3469
- s.html && (l.innerHTML = s.html), s.css && l.setAttribute("style", s.css);
3470
- }));
3471
- }
3472
- })) : B.Xe("Control variants leave the page unmodified.");
3473
- }
3474
- _is_bot() {
3475
- return Q && this._instance ? xn(Q, this._instance.config.custom_blocked_useragents) : void 0;
3476
- }
3477
- }
3478
- var Wo = U("[PostHog ExternalIntegrations]"), zo = { intercom: "intercom-integration", crispChat: "crisp-chat-integration" };
3479
- class Yo {
3480
- constructor(e) {
3481
- this._instance = e;
3482
- }
3483
- it(e, t) {
3484
- var i;
3485
- (i = k.__PosthogExtensions__) == null || i.loadExternalDependency == null || i.loadExternalDependency(this._instance, e, ((s) => {
3486
- if (s) return Wo.error("failed to load script", s);
3487
- t();
3488
- }));
3489
- }
3490
- startIfEnabledOrStop() {
3491
- var e = this, t = function(a) {
3492
- var o, l, c;
3493
- !s || (o = k.__PosthogExtensions__) != null && (o = o.integrations) != null && o[a] || e.it(zo[a], (() => {
3494
- var u;
3495
- (u = k.__PosthogExtensions__) == null || (u = u.integrations) == null || (u = u[a]) == null || u.start(e._instance);
3496
- })), !s && (l = k.__PosthogExtensions__) != null && (l = l.integrations) != null && l[a] && ((c = k.__PosthogExtensions__) == null || (c = c.integrations) == null || (c = c[a]) == null || c.stop());
3497
- };
3498
- for (var [i, s] of Object.entries((n = this._instance.config.integrations) !== null && n !== void 0 ? n : {})) {
3499
- var n;
3500
- t(i);
3501
- }
3502
- }
3503
- }
3504
- var Zi = "[SessionRecording]", pt = U(Zi);
3505
- class us {
3506
- get started() {
3507
- var e;
3508
- return !((e = this.sr) == null || !e.isStarted);
3509
- }
3510
- get status() {
3511
- return this.sr ? this.sr.status : this.nr && !this.ar ? "disabled" : "lazy_loading";
3512
- }
3513
- constructor(e) {
3514
- if (this._forceAllowLocalhostNetworkCapture = !1, this.nr = !1, this.lr = void 0, this._instance = e, !this._instance.sessionManager) throw pt.error("started without valid sessionManager"), new Error(Zi + " started without valid sessionManager. This is a bug.");
3515
- if (this._instance.config.cookieless_mode === "always") throw new Error(Zi + ' cannot be used with cookieless_mode="always"');
3516
- }
3517
- get ar() {
3518
- var e, t = !((e = this._instance.get_property(gi)) == null || !e.enabled), i = !this._instance.config.disable_session_recording, s = this._instance.config.disable_session_recording || this._instance.consent.isOptedOut();
3519
- return d && t && i && !s;
3520
- }
3521
- startIfEnabledOrStop(e) {
3522
- var t;
3523
- if (!this.ar || (t = this.sr) == null || !t.isStarted) {
3524
- var i = !v(Object.assign) && !v(Array.from);
3525
- this.ar && i ? (this.ur(e), pt.info("starting")) : this.stopRecording();
3526
- }
3527
- }
3528
- ur(e) {
3529
- var t, i, s;
3530
- this.ar && (k != null && (t = k.__PosthogExtensions__) != null && (t = t.rrweb) != null && t.record && (i = k.__PosthogExtensions__) != null && i.initSessionRecording ? this.hr(e) : (s = k.__PosthogExtensions__) == null || s.loadExternalDependency == null || s.loadExternalDependency(this._instance, this.dr, ((n) => {
3531
- if (n) return pt.error("could not load recorder", n);
3532
- this.hr(e);
3533
- })));
3534
- }
3535
- stopRecording() {
3536
- var e, t;
3537
- (e = this.lr) == null || e.call(this), this.lr = void 0, (t = this.sr) == null || t.stop();
3538
- }
3539
- vr() {
3540
- var e;
3541
- (e = this._instance.persistence) == null || e.unregister(Is);
3542
- }
3543
- cr(e) {
3544
- if (this._instance.persistence) {
3545
- var t, i, s = this._instance.persistence, n = () => {
3546
- var a = e.sessionRecording === !1 ? void 0 : e.sessionRecording, o = a == null ? void 0 : a.sampleRate, l = O(o) ? null : parseFloat(o);
3547
- O(l) && this.vr();
3548
- var c = a == null ? void 0 : a.minimumDurationMilliseconds;
3549
- s.register({ [gi]: w({ enabled: !!a }, a, { networkPayloadCapture: w({ capturePerformance: e.capturePerformance }, a == null ? void 0 : a.networkPayloadCapture), canvasRecording: { enabled: a == null ? void 0 : a.recordCanvas, fps: a == null ? void 0 : a.canvasFps, quality: a == null ? void 0 : a.canvasQuality }, sampleRate: l, minimumDurationMilliseconds: v(c) ? null : c, endpoint: a == null ? void 0 : a.endpoint, triggerMatchType: a == null ? void 0 : a.triggerMatchType, masking: a == null ? void 0 : a.masking, urlTriggers: a == null ? void 0 : a.urlTriggers }) });
3550
- };
3551
- n(), (t = this.lr) == null || t.call(this), this.lr = (i = this._instance.sessionManager) == null ? void 0 : i.onSessionId(n);
3552
- }
3553
- }
3554
- onRemoteConfig(e) {
3555
- "sessionRecording" in e ? e.sessionRecording !== !1 ? (this.cr(e), this.nr = !0, this.startIfEnabledOrStop()) : this.nr = !0 : pt.info("skipping remote config with no sessionRecording", e);
3556
- }
3557
- log(e, t) {
3558
- var i;
3559
- t === void 0 && (t = "log"), (i = this.sr) != null && i.log ? this.sr.log(e, t) : pt.warn("log called before recorder was ready");
3560
- }
3561
- get dr() {
3562
- var e, t, i = (e = this._instance) == null || (e = e.persistence) == null ? void 0 : e.get_property(gi);
3563
- return (i == null || (t = i.scriptConfig) == null ? void 0 : t.script) || "lazy-recorder";
3564
- }
3565
- hr(e) {
3566
- var t, i;
3567
- if ((t = k.__PosthogExtensions__) == null || !t.initSessionRecording) throw Error("Called on script loaded before session recording is available");
3568
- this.sr || (this.sr = (i = k.__PosthogExtensions__) == null ? void 0 : i.initSessionRecording(this._instance), this.sr._forceAllowLocalhostNetworkCapture = this._forceAllowLocalhostNetworkCapture), this.sr.start(e);
3569
- }
3570
- onRRwebEmit(e) {
3571
- var t;
3572
- (t = this.sr) == null || t.onRRwebEmit == null || t.onRRwebEmit(e);
3573
- }
3574
- overrideLinkedFlag() {
3575
- var e, t;
3576
- this.sr || (t = this._instance.persistence) == null || t.register({ $replay_override_linked_flag: !0 }), (e = this.sr) == null || e.overrideLinkedFlag();
3577
- }
3578
- overrideSampling() {
3579
- var e, t;
3580
- this.sr || (t = this._instance.persistence) == null || t.register({ $replay_override_sampling: !0 }), (e = this.sr) == null || e.overrideSampling();
3581
- }
3582
- overrideTrigger(e) {
3583
- var t, i;
3584
- this.sr || (i = this._instance.persistence) == null || i.register({ [e === "url" ? "$replay_override_url_trigger" : "$replay_override_event_trigger"]: !0 }), (t = this.sr) == null || t.overrideTrigger(e);
3585
- }
3586
- get sdkDebugProperties() {
3587
- var e;
3588
- return ((e = this.sr) == null ? void 0 : e.sdkDebugProperties) || { $recording_status: this.status };
3589
- }
3590
- tryAddCustomEvent(e, t) {
3591
- var i;
3592
- return !((i = this.sr) == null || !i.tryAddCustomEvent(e, t));
3593
- }
3594
- }
3595
- var kt = {}, Qi = () => {
3596
- }, Ke = "posthog", Sn = !xo && (W == null ? void 0 : W.indexOf("MSIE")) === -1 && (W == null ? void 0 : W.indexOf("Mozilla")) === -1, hs = (r) => {
3597
- var e;
3598
- return w({ api_host: "https://us.i.posthog.com", flags_api_host: null, ui_host: null, token: "", autocapture: !0, cross_subdomain_cookie: va(m == null ? void 0 : m.location), persistence: "localStorage+cookie", persistence_name: "", loaded: Qi, save_campaign_params: !0, custom_campaign_params: [], custom_blocked_useragents: [], save_referrer: !0, capture_pageleave: "if_capture_pageview", defaults: r ?? "unset", __preview_deferred_init_extensions: !1, debug: z && N(z == null ? void 0 : z.search) && z.search.indexOf("__posthog_debug=true") !== -1 || !1, cookie_expiration: 365, upgrade: !1, disable_session_recording: !1, disable_persistence: !1, disable_web_experiments: !0, disable_surveys: !1, disable_surveys_automatic_display: !1, disable_external_dependency_loading: !1, enable_recording_console_log: void 0, secure_cookie: (d == null || (e = d.location) == null ? void 0 : e.protocol) === "https:", ip: !1, opt_out_capturing_by_default: !1, opt_out_persistence_by_default: !1, opt_out_useragent_filter: !1, opt_out_capturing_persistence_type: "localStorage", consent_persistence_name: null, opt_out_capturing_cookie_prefix: null, opt_in_site_apps: !1, property_denylist: [], respect_dnt: !1, sanitize_properties: null, request_headers: {}, request_batching: !0, properties_string_max_length: 65535, mask_all_element_attributes: !1, mask_all_text: !1, mask_personal_data_properties: !1, custom_personal_data_properties: [], advanced_disable_flags: !1, advanced_disable_decide: !1, advanced_disable_feature_flags: !1, advanced_disable_feature_flags_on_first_load: !1, advanced_only_evaluate_survey_feature_flags: !1, advanced_enable_surveys: !1, advanced_disable_toolbar_metrics: !1, feature_flag_request_timeout_ms: 3e3, surveys_request_timeout_ms: 1e4, on_request_error: (t) => {
3599
- var i = "Bad HTTP status: " + t.statusCode + " " + t.text;
3600
- y.error(i);
3601
- }, get_device_id: (t) => t, capture_performance: void 0, name: "posthog", bootstrap: {}, disable_compression: !1, session_idle_timeout_seconds: 1800, person_profiles: "identified_only", before_send: void 0, request_queue_config: { flush_interval_ms: Ji }, error_tracking: {}, _onCapture: Qi, __preview_eager_load_replay: !1 }, ((t) => ({ rageclick: !(t && t >= "2025-11-30") || { content_ignorelist: !0 }, capture_pageview: !(t && t >= "2025-05-24") || "history_change", session_recording: t && t >= "2025-11-30" ? { strictMinimumDuration: !0 } : {} }))(r));
3602
- }, ds = (r) => {
3603
- var e = {};
3604
- v(r.process_person) || (e.person_profiles = r.process_person), v(r.xhr_headers) || (e.request_headers = r.xhr_headers), v(r.cookie_name) || (e.persistence_name = r.cookie_name), v(r.disable_cookie) || (e.disable_persistence = r.disable_cookie), v(r.store_google) || (e.save_campaign_params = r.store_google), v(r.verbose) || (e.debug = r.verbose);
3605
- var t = M({}, e, r);
3606
- return F(r.property_blacklist) && (v(r.property_denylist) ? t.property_denylist = r.property_blacklist : F(r.property_denylist) ? t.property_denylist = [...r.property_blacklist, ...r.property_denylist] : y.error("Invalid value for property_denylist config: " + r.property_denylist)), t;
3607
- };
3608
- class Ko {
3609
- constructor() {
3610
- this.__forceAllowLocalhost = !1;
3611
- }
3612
- get pr() {
3613
- return this.__forceAllowLocalhost;
3614
- }
3615
- set pr(e) {
3616
- y.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"), this.__forceAllowLocalhost = e;
3617
- }
3618
- }
3619
- class li {
3620
- get decideEndpointWasHit() {
3621
- var e, t;
3622
- return (e = (t = this.featureFlags) == null ? void 0 : t.hasLoadedFlags) !== null && e !== void 0 && e;
3623
- }
3624
- get flagsEndpointWasHit() {
3625
- var e, t;
3626
- return (e = (t = this.featureFlags) == null ? void 0 : t.hasLoadedFlags) !== null && e !== void 0 && e;
3627
- }
3628
- constructor() {
3629
- this.webPerformance = new Ko(), this.gr = !1, this.version = me.LIB_VERSION, this._r = new ur(), this._calculate_event_properties = this.calculateEventProperties.bind(this), this.config = hs(), this.SentryIntegration = Wa, this.sentryIntegration = (e) => (function(t, i) {
3630
- var s = Ws(t, i);
3631
- return { name: Gs, processEvent: (n) => s(n) };
3632
- })(this, e), this.__request_queue = [], this.__loaded = !1, this.analyticsDefaultEndpoint = "/e/", this.mr = !1, this.yr = null, this.br = null, this.wr = null, this.featureFlags = new Io(this), this.toolbar = new Ya(this), this.scrollManager = new qo(this), this.pageViewManager = new fo(this), this.surveys = new Ao(this), this.experiments = new B(this), this.exceptions = new So(this), this.rateLimiter = new Do(this), this.requestRouter = new Vo(this), this.consent = new qa(this), this.externalIntegrations = new Yo(this), this.people = { set: (e, t, i) => {
3633
- var s = N(e) ? { [e]: t } : e;
3634
- this.setPersonProperties(s), i == null || i({});
3635
- }, set_once: (e, t, i) => {
3636
- var s = N(e) ? { [e]: t } : e;
3637
- this.setPersonProperties(void 0, s), i == null || i({});
3638
- } }, this.on("eventCaptured", ((e) => y.info('send "' + (e == null ? void 0 : e.event) + '"', e)));
3639
- }
3640
- init(e, t, i) {
3641
- if (i && i !== Ke) {
3642
- var s, n = (s = kt[i]) !== null && s !== void 0 ? s : new li();
3643
- return n._init(e, t, i), kt[i] = n, kt[Ke][i] = n, n;
3644
- }
3645
- return this._init(e, t, i);
3646
- }
3647
- _init(e, t, i) {
3648
- var s;
3649
- if (t === void 0 && (t = {}), v(e) || Oi(e)) return y.critical("PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()"), this;
3650
- if (this.__loaded) return console.warn("[PostHog.js]", "You have already initialized PostHog! Re-initializing is a no-op"), this;
3651
- this.__loaded = !0, this.config = {}, t.debug = this.$r(t.debug), this.Sr = t, this.Er = [], t.person_profiles && (this.br = t.person_profiles), this.set_config(M({}, hs(t.defaults), ds(t), { name: i, token: e })), this.config.on_xhr_error && y.error("on_xhr_error is deprecated. Use on_request_error instead"), this.compression = t.disable_compression ? void 0 : we.GZipJS;
3652
- var n = this.kr();
3653
- this.persistence = new Si(this.config, n), this.sessionPersistence = this.config.persistence === "sessionStorage" || this.config.persistence === "memory" ? this.persistence : new Si(w({}, this.config, { persistence: "sessionStorage" }), n);
3654
- var a = w({}, this.persistence.props), o = w({}, this.sessionPersistence.props);
3655
- this.register({ $initialization_time: (/* @__PURE__ */ new Date()).toISOString() }), this.Pr = new Lo(((x) => this.Tr(x)), this.config.request_queue_config), this.Ir = new Uo(this), this.__request_queue = [];
3656
- var l = this.config.cookieless_mode === "always" || this.config.cookieless_mode === "on_reject" && this.consent.isExplicitlyOptedOut();
3657
- if (l || (this.sessionManager = new ls(this), this.sessionPropsManager = new os(this, this.sessionManager, this.persistence)), this.config.__preview_deferred_init_extensions ? (y.info("Deferring extension initialization to improve startup performance"), setTimeout((() => {
3658
- this.Rr(l);
3659
- }), 0)) : (y.info("Initializing extensions synchronously"), this.Rr(l)), me.DEBUG = me.DEBUG || this.config.debug, me.DEBUG && y.info("Starting in debug mode", { this: this, config: t, thisC: w({}, this.config), p: a, s: o }), ((s = t.bootstrap) == null ? void 0 : s.distinctID) !== void 0) {
3660
- var c, u, h = this.config.get_device_id(Te()), g = (c = t.bootstrap) != null && c.isIdentifiedID ? h : t.bootstrap.distinctID;
3661
- this.persistence.set_property(ye, (u = t.bootstrap) != null && u.isIdentifiedID ? "identified" : "anonymous"), this.register({ distinct_id: t.bootstrap.distinctID, $device_id: g });
3662
- }
3663
- if (this.Cr()) {
3664
- var p, f, _ = Object.keys(((p = t.bootstrap) == null ? void 0 : p.featureFlags) || {}).filter(((x) => {
3665
- var I;
3666
- return !((I = t.bootstrap) == null || (I = I.featureFlags) == null || !I[x]);
3667
- })).reduce(((x, I) => {
3668
- var C;
3669
- return x[I] = ((C = t.bootstrap) == null || (C = C.featureFlags) == null ? void 0 : C[I]) || !1, x;
3670
- }), {}), b = Object.keys(((f = t.bootstrap) == null ? void 0 : f.featureFlagPayloads) || {}).filter(((x) => _[x])).reduce(((x, I) => {
3671
- var C, D;
3672
- return (C = t.bootstrap) != null && (C = C.featureFlagPayloads) != null && C[I] && (x[I] = (D = t.bootstrap) == null || (D = D.featureFlagPayloads) == null ? void 0 : D[I]), x;
3673
- }), {});
3674
- this.featureFlags.receivedFeatureFlags({ featureFlags: _, featureFlagPayloads: b });
3675
- }
3676
- if (l) this.register_once({ distinct_id: ot, $device_id: null }, "");
3677
- else if (!this.get_distinct_id()) {
3678
- var E = this.config.get_device_id(Te());
3679
- this.register_once({ distinct_id: E, $device_id: E }, ""), this.persistence.set_property(ye, "anonymous");
3680
- }
3681
- return L(d, "onpagehide" in self ? "pagehide" : "unload", this._handle_unload.bind(this), { passive: !1 }), this.toolbar.maybeLoadToolbar(), t.segment ? Ga(this, (() => this.Or())) : this.Or(), Fe(this.config._onCapture) && this.config._onCapture !== Qi && (y.warn("onCapture is deprecated. Please use `before_send` instead"), this.on("eventCaptured", ((x) => this.config._onCapture(x.event, x)))), this.config.ip && y.warn('The `ip` config option has NO EFFECT AT ALL and has been deprecated. Use a custom transformation or "Discard IP data" project setting instead. See https://posthog.com/tutorials/web-redact-properties#hiding-customer-ip-address for more information.'), this;
3682
- }
3683
- Rr(e) {
3684
- var t = performance.now();
3685
- this.historyAutocapture = new Va(this), this.historyAutocapture.startIfEnabled();
3686
- var i = [];
3687
- i.push((() => {
3688
- new Xa(this).startIfEnabledOrStop();
3689
- })), i.push((() => {
3690
- var s;
3691
- this.siteApps = new Ho(this), (s = this.siteApps) == null || s.init();
3692
- })), e || i.push((() => {
3693
- this.sessionRecording = new us(this), this.sessionRecording.startIfEnabledOrStop();
3694
- })), this.config.disable_scroll_properties || i.push((() => {
3695
- this.scrollManager.startMeasuringScrollPosition();
3696
- })), i.push((() => {
3697
- this.autocapture = new Oa(this), this.autocapture.startIfEnabled();
3698
- })), i.push((() => {
3699
- this.surveys.loadIfEnabled();
3700
- })), i.push((() => {
3701
- this.heatmaps = new go(this), this.heatmaps.startIfEnabled();
3702
- })), i.push((() => {
3703
- this.webVitalsAutocapture = new ho(this);
3704
- })), i.push((() => {
3705
- this.exceptionObserver = new Ha(this), this.exceptionObserver.startIfEnabled();
3706
- })), i.push((() => {
3707
- this.deadClicksAutocapture = new Vs(this, Ba), this.deadClicksAutocapture.startIfEnabled();
3708
- })), i.push((() => {
3709
- if (this.Fr) {
3710
- var s = this.Fr;
3711
- this.Fr = void 0, this.fi(s);
3712
- }
3713
- })), this.Mr(i, t);
3714
- }
3715
- Mr(e, t) {
3716
- for (; e.length > 0; ) {
3717
- if (this.config.__preview_deferred_init_extensions && performance.now() - t >= 30 && e.length > 0) return void setTimeout((() => {
3718
- this.Mr(e, t);
3719
- }), 0);
3720
- var i = e.shift();
3721
- if (i) try {
3722
- i();
3723
- } catch (n) {
3724
- y.error("Error initializing extension:", n);
3725
- }
3726
- }
3727
- var s = Math.round(performance.now() - t);
3728
- this.register_for_session({ $sdk_debug_extensions_init_method: this.config.__preview_deferred_init_extensions ? "deferred" : "synchronous", $sdk_debug_extensions_init_time_ms: s }), this.config.__preview_deferred_init_extensions && y.info("PostHog extensions initialized (" + s + "ms)");
3729
- }
3730
- fi(e) {
3731
- var t, i, s, n, a, o, l, c;
3732
- if (!m || !m.body) return y.info("document not ready yet, trying again in 500 milliseconds..."), void setTimeout((() => {
3733
- this.fi(e);
3734
- }), 500);
3735
- this.config.__preview_deferred_init_extensions && (this.Fr = e), this.compression = void 0, e.supportedCompression && !this.config.disable_compression && (this.compression = S(e.supportedCompression, we.GZipJS) ? we.GZipJS : S(e.supportedCompression, we.Base64) ? we.Base64 : void 0), (t = e.analytics) != null && t.endpoint && (this.analyticsDefaultEndpoint = e.analytics.endpoint), this.set_config({ person_profiles: this.br ? this.br : "identified_only" }), (i = this.siteApps) == null || i.onRemoteConfig(e), (s = this.sessionRecording) == null || s.onRemoteConfig(e), (n = this.autocapture) == null || n.onRemoteConfig(e), (a = this.heatmaps) == null || a.onRemoteConfig(e), this.surveys.onRemoteConfig(e), (o = this.webVitalsAutocapture) == null || o.onRemoteConfig(e), (l = this.exceptionObserver) == null || l.onRemoteConfig(e), this.exceptions.onRemoteConfig(e), (c = this.deadClicksAutocapture) == null || c.onRemoteConfig(e);
3736
- }
3737
- Or() {
3738
- try {
3739
- this.config.loaded(this);
3740
- } catch (e) {
3741
- y.critical("`loaded` function failed", e);
3742
- }
3743
- this.Ar(), this.config.capture_pageview && setTimeout((() => {
3744
- (this.consent.isOptedIn() || this.config.cookieless_mode === "always") && this.Dr();
3745
- }), 1), new Mo(this).load(), this.featureFlags.flags();
3746
- }
3747
- Ar() {
3748
- var e;
3749
- this.is_capturing() && this.config.request_batching && ((e = this.Pr) == null || e.enable());
3750
- }
3751
- _dom_loaded() {
3752
- this.is_capturing() && Re(this.__request_queue, ((e) => this.Tr(e))), this.__request_queue = [], this.Ar();
3753
- }
3754
- _handle_unload() {
3755
- var e, t;
3756
- this.config.request_batching ? (this.jr() && this.capture("$pageleave"), (e = this.Pr) == null || e.unload(), (t = this.Ir) == null || t.unload()) : this.jr() && this.capture("$pageleave", null, { transport: "sendBeacon" });
3757
- }
3758
- ci(e) {
3759
- this.__loaded && (Sn ? this.__request_queue.push(e) : this.rateLimiter.isServerRateLimited(e.batchKey) || (e.transport = e.transport || this.config.api_transport, e.url = si(e.url, { ip: this.config.ip ? 1 : 0 }), e.headers = w({}, this.config.request_headers), e.compression = e.compression === "best-available" ? this.compression : e.compression, e.disableXHRCredentials = this.config.__preview_disable_xhr_credentials, this.config.__preview_disable_beacon && (e.disableTransport = ["sendBeacon"]), e.fetchOptions = e.fetchOptions || this.config.fetch_options, ((t) => {
3760
- var i, s, n, a = w({}, t);
3761
- a.timeout = a.timeout || 6e4, a.url = si(a.url, { _: (/* @__PURE__ */ new Date()).getTime().toString(), ver: me.LIB_VERSION, compression: a.compression });
3762
- var o = (i = a.transport) !== null && i !== void 0 ? i : "fetch", l = qt.filter(((u) => !a.disableTransport || !u.transport || !a.disableTransport.includes(u.transport))), c = (s = (n = Ss(l, ((u) => u.transport === o))) == null ? void 0 : n.method) !== null && s !== void 0 ? s : l[0].method;
3763
- if (!c) throw new Error("No available transport method");
3764
- c(a);
3765
- })(w({}, e, { callback: (t) => {
3766
- var i, s;
3767
- this.rateLimiter.checkForLimiting(t), t.statusCode >= 400 && ((i = (s = this.config).on_request_error) == null || i.call(s, t)), e.callback == null || e.callback(t);
3768
- } }))));
3769
- }
3770
- Tr(e) {
3771
- this.Ir ? this.Ir.retriableRequest(e) : this.ci(e);
3772
- }
3773
- _execute_array(e) {
3774
- var t, i = [], s = [], n = [];
3775
- Re(e, ((o) => {
3776
- o && (t = o[0], F(t) ? n.push(o) : Fe(o) ? o.call(this) : F(o) && t === "alias" ? i.push(o) : F(o) && t.indexOf("capture") !== -1 && Fe(this[t]) ? n.push(o) : s.push(o));
3777
- }));
3778
- var a = function(o, l) {
3779
- Re(o, (function(c) {
3780
- if (F(c[0])) {
3781
- var u = l;
3782
- T(c, (function(h) {
3783
- u = u[h[0]].apply(u, h.slice(1));
3784
- }));
3785
- } else this[c[0]].apply(this, c.slice(1));
3786
- }), l);
3787
- };
3788
- a(i, this), a(s, this), a(n, this);
3789
- }
3790
- Cr() {
3791
- var e, t;
3792
- return ((e = this.config.bootstrap) == null ? void 0 : e.featureFlags) && Object.keys((t = this.config.bootstrap) == null ? void 0 : t.featureFlags).length > 0 || !1;
3793
- }
3794
- push(e) {
3795
- this._execute_array([e]);
3796
- }
3797
- capture(e, t, i) {
3798
- var s;
3799
- if (this.__loaded && this.persistence && this.sessionPersistence && this.Pr) {
3800
- if (this.is_capturing()) if (!v(e) && N(e)) {
3801
- var n = !this.config.opt_out_useragent_filter && this._is_bot();
3802
- if (!(n && !this.config.__preview_capture_bot_pageviews)) {
3803
- var a = i != null && i.skip_client_rate_limiting ? void 0 : this.rateLimiter.clientRateLimitContext();
3804
- if (a == null || !a.isRateLimited) {
3805
- t != null && t.$current_url && !N(t == null ? void 0 : t.$current_url) && (y.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."), t == null || 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();
3806
- var o = /* @__PURE__ */ new Date(), l = (i == null ? void 0 : i.timestamp) || o, c = Te(), u = { uuid: c, event: e, properties: this.calculateEventProperties(e, t || {}, l, c) };
3807
- e === "$pageview" && this.config.__preview_capture_bot_pageviews && n && (u.event = "$bot_pageview", u.properties.$browser_type = "bot"), a && (u.properties.$lib_rate_limit_remaining_tokens = a.remainingTokens), i != null && i.$set && (u.$set = i == null ? void 0 : i.$set);
3808
- var h, g = this.Lr(i == null ? void 0 : i.$set_once);
3809
- if (g && (u.$set_once = g), (u = fa(u, i != null && i._noTruncate ? null : this.config.properties_string_max_length)).timestamp = l, v(i == null ? void 0 : i.timestamp) || (u.properties.$event_time_override_provided = !0, u.properties.$event_time_override_system_time = o), e === jt.DISMISSED || e === jt.SENT) {
3810
- var p = t == null ? void 0 : t[ss.SURVEY_ID], f = t == null ? void 0 : t[ss.SURVEY_ITERATION];
3811
- h = { id: p, current_iteration: f }, localStorage.getItem(ns(h)) || localStorage.setItem(ns(h), "true"), u.$set = w({}, u.$set, { [To({ id: p, current_iteration: f }, e === jt.SENT ? "responded" : "dismissed")]: !0 });
3812
- }
3813
- var _ = w({}, u.properties.$set, u.$set);
3814
- if (Xe(_) || this.setPersonPropertiesForFlags(_), !O(this.config.before_send)) {
3815
- var b = this.Nr(u);
3816
- if (!b) return;
3817
- u = b;
3818
- }
3819
- this._r.emit("eventCaptured", u);
3820
- var E = { method: "POST", url: (s = i == null ? void 0 : i._url) !== null && s !== void 0 ? s : this.requestRouter.endpointFor("api", this.analyticsDefaultEndpoint), data: u, compression: "best-available", batchKey: i == null ? void 0 : i._batchKey };
3821
- return !this.config.request_batching || i && (i == null || !i._batchKey) || i != null && i.send_instantly ? this.Tr(E) : this.Pr.enqueue(E), u;
3822
- }
3823
- y.critical("This capture call is ignored due to client rate limiting.");
3824
- }
3825
- } else y.error("No event name provided to posthog.capture");
3826
- } else y.uninitializedWarning("posthog.capture");
3827
- }
3828
- Mi(e) {
3829
- return this.on("eventCaptured", ((t) => e(t.event, t)));
3830
- }
3831
- calculateEventProperties(e, t, i, s, n) {
3832
- if (i = i || /* @__PURE__ */ new Date(), !this.persistence || !this.sessionPersistence) return t;
3833
- var a = n ? void 0 : this.persistence.remove_event_timer(e), o = w({}, t);
3834
- if (o.token = this.config.token, o.$config_defaults = this.config.defaults, (this.config.cookieless_mode == "always" || this.config.cookieless_mode == "on_reject" && this.consent.isExplicitlyOptedOut()) && (o.$cookieless_mode = !0), e === "$snapshot") {
3835
- var l = w({}, this.persistence.properties(), this.sessionPersistence.properties());
3836
- return o.distinct_id = l.distinct_id, (!N(o.distinct_id) && !fe(o.distinct_id) || Oi(o.distinct_id)) && y.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"), o;
3837
- }
3838
- var c, u = uo(this.config.mask_personal_data_properties, this.config.custom_personal_data_properties);
3839
- if (this.sessionManager) {
3840
- var { sessionId: h, windowId: g } = this.sessionManager.checkAndGetSessionAndWindowId(n, i.getTime());
3841
- o.$session_id = h, o.$window_id = g;
3842
- }
3843
- this.sessionPropsManager && M(o, this.sessionPropsManager.getSessionProps());
3844
- try {
3845
- var p;
3846
- this.sessionRecording && M(o, this.sessionRecording.sdkDebugProperties), o.$sdk_debug_retry_queue_size = (p = this.Ir) == null ? void 0 : p.length;
3847
- } catch (E) {
3848
- o.$sdk_debug_error_capturing_properties = String(E);
3849
- }
3850
- if (this.requestRouter.region === bt.CUSTOM && (o.$lib_custom_api_host = this.config.api_host), c = e !== "$pageview" || n ? e !== "$pageleave" || n ? this.pageViewManager.doEvent() : this.pageViewManager.doPageLeave(i) : this.pageViewManager.doPageView(i, s), o = M(o, c), e === "$pageview" && m && (o.title = m.title), !v(a)) {
3851
- var f = i.getTime() - a;
3852
- o.$duration = parseFloat((f / 1e3).toFixed(3));
3853
- }
3854
- W && this.config.opt_out_useragent_filter && (o.$browser_type = this._is_bot() ? "bot" : "browser"), (o = M({}, u, this.persistence.properties(), this.sessionPersistence.properties(), o)).$is_identified = this._isIdentified(), F(this.config.property_denylist) ? T(this.config.property_denylist, (function(E) {
3855
- delete o[E];
3856
- })) : y.error("Invalid value for property_denylist config: " + this.config.property_denylist + " or property_blacklist config: " + this.config.property_blacklist);
3857
- var _ = this.config.sanitize_properties;
3858
- _ && (y.error("sanitize_properties is deprecated. Use before_send instead"), o = _(o, e));
3859
- var b = this.Ur();
3860
- return o.$process_person_profile = b, b && !n && this.zr("_calculate_event_properties"), o;
3861
- }
3862
- Lr(e) {
3863
- var t;
3864
- if (!this.persistence || !this.Ur() || this.gr) return e;
3865
- var i = this.persistence.get_initial_props(), s = (t = this.sessionPropsManager) == null ? void 0 : t.getSetOnceProps(), n = M({}, i, s || {}, e || {}), a = this.config.sanitize_properties;
3866
- return a && (y.error("sanitize_properties is deprecated. Use before_send instead"), n = a(n, "$set_once")), this.gr = !0, Xe(n) ? void 0 : n;
3867
- }
3868
- register(e, t) {
3869
- var i;
3870
- (i = this.persistence) == null || i.register(e, t);
3871
- }
3872
- register_once(e, t, i) {
3873
- var s;
3874
- (s = this.persistence) == null || s.register_once(e, t, i);
3875
- }
3876
- register_for_session(e) {
3877
- var t;
3878
- (t = this.sessionPersistence) == null || t.register(e);
3879
- }
3880
- unregister(e) {
3881
- var t;
3882
- (t = this.persistence) == null || t.unregister(e);
3883
- }
3884
- unregister_for_session(e) {
3885
- var t;
3886
- (t = this.sessionPersistence) == null || t.unregister(e);
3887
- }
3888
- Hr(e, t) {
3889
- this.register({ [e]: t });
3890
- }
3891
- getFeatureFlag(e, t) {
3892
- return this.featureFlags.getFeatureFlag(e, t);
3893
- }
3894
- getFeatureFlagPayload(e) {
3895
- var t = this.featureFlags.getFeatureFlagPayload(e);
3896
- try {
3897
- return JSON.parse(t);
3898
- } catch {
3899
- return t;
3900
- }
3901
- }
3902
- isFeatureEnabled(e, t) {
3903
- return this.featureFlags.isFeatureEnabled(e, t);
3904
- }
3905
- reloadFeatureFlags() {
3906
- this.featureFlags.reloadFeatureFlags();
3907
- }
3908
- updateEarlyAccessFeatureEnrollment(e, t, i) {
3909
- this.featureFlags.updateEarlyAccessFeatureEnrollment(e, t, i);
3910
- }
3911
- getEarlyAccessFeatures(e, t, i) {
3912
- return t === void 0 && (t = !1), this.featureFlags.getEarlyAccessFeatures(e, t, i);
3913
- }
3914
- on(e, t) {
3915
- return this._r.on(e, t);
3916
- }
3917
- onFeatureFlags(e) {
3918
- return this.featureFlags.onFeatureFlags(e);
3919
- }
3920
- onSurveysLoaded(e) {
3921
- return this.surveys.onSurveysLoaded(e);
3922
- }
3923
- onSessionId(e) {
3924
- var t, i;
3925
- return (t = (i = this.sessionManager) == null ? void 0 : i.onSessionId(e)) !== null && t !== void 0 ? t : () => {
3926
- };
3927
- }
3928
- getSurveys(e, t) {
3929
- t === void 0 && (t = !1), this.surveys.getSurveys(e, t);
3930
- }
3931
- getActiveMatchingSurveys(e, t) {
3932
- t === void 0 && (t = !1), this.surveys.getActiveMatchingSurveys(e, t);
3933
- }
3934
- renderSurvey(e, t) {
3935
- this.surveys.renderSurvey(e, t);
3936
- }
3937
- displaySurvey(e, t) {
3938
- t === void 0 && (t = Oo), this.surveys.displaySurvey(e, t);
3939
- }
3940
- canRenderSurvey(e) {
3941
- return this.surveys.canRenderSurvey(e);
3942
- }
3943
- canRenderSurveyAsync(e, t) {
3944
- return t === void 0 && (t = !1), this.surveys.canRenderSurveyAsync(e, t);
3945
- }
3946
- identify(e, t, i) {
3947
- if (!this.__loaded || !this.persistence) return y.uninitializedWarning("posthog.identify");
3948
- if (fe(e) && (e = e.toString(), y.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")), e) if (["distinct_id", "distinctid"].includes(e.toLowerCase())) y.critical('The string "' + e + '" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.');
3949
- else if (e !== ot) {
3950
- if (this.zr("posthog.identify")) {
3951
- var s = this.get_distinct_id();
3952
- if (this.register({ $user_id: e }), !this.get_property("$device_id")) {
3953
- var n = s;
3954
- this.register_once({ $had_persisted_distinct_id: !0, $device_id: n }, "");
3955
- }
3956
- e !== s && e !== this.get_property(gt) && (this.unregister(gt), this.register({ distinct_id: e }));
3957
- var a = (this.persistence.get_property(ye) || "anonymous") === "anonymous";
3958
- e !== s && a ? (this.persistence.set_property(ye, "identified"), this.setPersonPropertiesForFlags(w({}, i || {}, t || {}), !1), this.capture("$identify", { distinct_id: e, $anon_distinct_id: s }, { $set: t || {}, $set_once: i || {} }), this.wr = es(e, t, i), this.featureFlags.setAnonymousDistinctId(s)) : (t || i) && this.setPersonProperties(t, i), e !== s && (this.reloadFeatureFlags(), this.unregister(Yt));
3959
- }
3960
- } else y.critical('The string "' + ot + '" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.');
3961
- else y.error("Unique user id has not been set in posthog.identify");
3962
- }
3963
- setPersonProperties(e, t) {
3964
- if ((e || t) && this.zr("posthog.setPersonProperties")) {
3965
- var i = es(this.get_distinct_id(), e, t);
3966
- this.wr !== i ? (this.setPersonPropertiesForFlags(w({}, t || {}, e || {})), this.capture("$set", { $set: e || {}, $set_once: t || {} }), this.wr = i) : y.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.");
3967
- }
3968
- }
3969
- group(e, t, i) {
3970
- if (e && t) {
3971
- if (this.zr("posthog.group")) {
3972
- var s = this.getGroups();
3973
- s[e] !== t && this.resetGroupPropertiesForFlags(e), this.register({ $groups: w({}, s, { [e]: t }) }), i && (this.capture("$groupidentify", { $group_type: e, $group_key: t, $group_set: i }), this.setGroupPropertiesForFlags({ [e]: i })), s[e] === t || i || this.reloadFeatureFlags();
3974
- }
3975
- } else y.error("posthog.group requires a group type and group key");
3976
- }
3977
- resetGroups() {
3978
- this.register({ $groups: {} }), this.resetGroupPropertiesForFlags(), this.reloadFeatureFlags();
3979
- }
3980
- setPersonPropertiesForFlags(e, t) {
3981
- t === void 0 && (t = !0), this.featureFlags.setPersonPropertiesForFlags(e, t);
3982
- }
3983
- resetPersonPropertiesForFlags() {
3984
- this.featureFlags.resetPersonPropertiesForFlags();
3985
- }
3986
- setGroupPropertiesForFlags(e, t) {
3987
- t === void 0 && (t = !0), this.zr("posthog.setGroupPropertiesForFlags") && this.featureFlags.setGroupPropertiesForFlags(e, t);
3988
- }
3989
- resetGroupPropertiesForFlags(e) {
3990
- this.featureFlags.resetGroupPropertiesForFlags(e);
3991
- }
3992
- reset(e) {
3993
- var t, i, s, n;
3994
- if (y.info("reset"), !this.__loaded) return y.uninitializedWarning("posthog.reset");
3995
- var a = this.get_property("$device_id");
3996
- if (this.consent.reset(), (t = this.persistence) == null || t.clear(), (i = this.sessionPersistence) == null || i.clear(), this.surveys.reset(), this.featureFlags.reset(), (s = this.persistence) == null || s.set_property(ye, "anonymous"), (n = this.sessionManager) == null || n.resetSessionId(), this.wr = null, this.config.cookieless_mode === "always") this.register_once({ distinct_id: ot, $device_id: null }, "");
3997
- else {
3998
- var o = this.config.get_device_id(Te());
3999
- this.register_once({ distinct_id: o, $device_id: e ? o : a }, "");
4000
- }
4001
- this.register({ $last_posthog_reset: (/* @__PURE__ */ new Date()).toISOString() }, 1);
4002
- }
4003
- get_distinct_id() {
4004
- return this.get_property("distinct_id");
4005
- }
4006
- getGroups() {
4007
- return this.get_property("$groups") || {};
4008
- }
4009
- get_session_id() {
4010
- var e, t;
4011
- return (e = (t = this.sessionManager) == null ? void 0 : t.checkAndGetSessionAndWindowId(!0).sessionId) !== null && e !== void 0 ? e : "";
4012
- }
4013
- get_session_replay_url(e) {
4014
- if (!this.sessionManager) return "";
4015
- var { sessionId: t, sessionStartTimestamp: i } = this.sessionManager.checkAndGetSessionAndWindowId(!0), s = this.requestRouter.endpointFor("ui", "/project/" + this.config.token + "/replay/" + t);
4016
- if (e != null && e.withTimestamp && i) {
4017
- var n, a = (n = e.timestampLookBack) !== null && n !== void 0 ? n : 10;
4018
- if (!i) return s;
4019
- s += "?t=" + Math.max(Math.floor(((/* @__PURE__ */ new Date()).getTime() - i) / 1e3) - a, 0);
4020
- }
4021
- return s;
4022
- }
4023
- alias(e, t) {
4024
- return e === this.get_property(Cs) ? (y.critical("Attempting to create alias for existing People user - aborting."), -2) : this.zr("posthog.alias") ? (v(t) && (t = this.get_distinct_id()), e !== t ? (this.Hr(gt, e), this.capture("$create_alias", { alias: e, distinct_id: t })) : (y.warn("alias matches current distinct_id - skipping api call."), this.identify(e), -1)) : void 0;
4025
- }
4026
- set_config(e) {
4027
- var t = w({}, this.config);
4028
- if (j(e)) {
4029
- var i, s, n, a, o;
4030
- M(this.config, ds(e));
4031
- var l = this.kr();
4032
- (i = this.persistence) == null || i.update_config(this.config, t, l), this.sessionPersistence = this.config.persistence === "sessionStorage" || this.config.persistence === "memory" ? this.persistence : new Si(w({}, this.config, { persistence: "sessionStorage" }), l);
4033
- var c = this.$r(this.config.debug);
4034
- Oe(c) && (this.config.debug = c), Oe(this.config.debug) && (this.config.debug ? (me.DEBUG = !0, A.H() && A.G("ph_debug", "true"), y.info("set_config", { config: e, oldConfig: t, newConfig: w({}, this.config) })) : (me.DEBUG = !1, A.H() && A.V("ph_debug"))), (s = this.sessionRecording) == null || s.startIfEnabledOrStop(), (n = this.autocapture) == null || n.startIfEnabled(), (a = this.heatmaps) == null || a.startIfEnabled(), this.surveys.loadIfEnabled(), this.Br(), (o = this.externalIntegrations) == null || o.startIfEnabledOrStop();
4035
- }
4036
- }
4037
- startSessionRecording(e) {
4038
- var t = e === !0, i = { sampling: t || !(e == null || !e.sampling), linked_flag: t || !(e == null || !e.linked_flag), url_trigger: t || !(e == null || !e.url_trigger), event_trigger: t || !(e == null || !e.event_trigger) };
4039
- if (Object.values(i).some(Boolean)) {
4040
- var s, n, a, o, l;
4041
- (s = this.sessionManager) == null || s.checkAndGetSessionAndWindowId(), i.sampling && ((n = this.sessionRecording) == null || n.overrideSampling()), i.linked_flag && ((a = this.sessionRecording) == null || a.overrideLinkedFlag()), i.url_trigger && ((o = this.sessionRecording) == null || o.overrideTrigger("url")), i.event_trigger && ((l = this.sessionRecording) == null || l.overrideTrigger("event"));
4042
- }
4043
- this.set_config({ disable_session_recording: !1 });
4044
- }
4045
- stopSessionRecording() {
4046
- this.set_config({ disable_session_recording: !0 });
4047
- }
4048
- sessionRecordingStarted() {
4049
- var e;
4050
- return !((e = this.sessionRecording) == null || !e.started);
4051
- }
4052
- captureException(e, t) {
4053
- var i = new Error("PostHog syntheticException"), s = this.exceptions.buildProperties(e, { handled: !0, syntheticException: i });
4054
- return this.exceptions.sendExceptionEvent(w({}, s, t));
4055
- }
4056
- loadToolbar(e) {
4057
- return this.toolbar.loadToolbar(e);
4058
- }
4059
- get_property(e) {
4060
- var t;
4061
- return (t = this.persistence) == null ? void 0 : t.props[e];
4062
- }
4063
- getSessionProperty(e) {
4064
- var t;
4065
- return (t = this.sessionPersistence) == null ? void 0 : t.props[e];
4066
- }
4067
- toString() {
4068
- var e, t = (e = this.config.name) !== null && e !== void 0 ? e : Ke;
4069
- return t !== Ke && (t = Ke + "." + t), t;
4070
- }
4071
- _isIdentified() {
4072
- var e, t;
4073
- return ((e = this.persistence) == null ? void 0 : e.get_property(ye)) === "identified" || ((t = this.sessionPersistence) == null ? void 0 : t.get_property(ye)) === "identified";
4074
- }
4075
- Ur() {
4076
- var e, t;
4077
- return !(this.config.person_profiles === "never" || this.config.person_profiles === "identified_only" && !this._isIdentified() && Xe(this.getGroups()) && ((e = this.persistence) == null || (e = e.props) == null || !e[gt]) && ((t = this.persistence) == null || (t = t.props) == null || !t[Xt]));
4078
- }
4079
- jr() {
4080
- return this.config.capture_pageleave === !0 || this.config.capture_pageleave === "if_capture_pageview" && (this.config.capture_pageview === !0 || this.config.capture_pageview === "history_change");
4081
- }
4082
- createPersonProfile() {
4083
- this.Ur() || this.zr("posthog.createPersonProfile") && this.setPersonProperties({}, {});
4084
- }
4085
- zr(e) {
4086
- return this.config.person_profiles === "never" ? (y.error(e + ' was called, but process_person is set to "never". This call will be ignored.'), !1) : (this.Hr(Xt, !0), !0);
4087
- }
4088
- kr() {
4089
- if (this.config.cookieless_mode === "always") return !0;
4090
- var e = this.consent.isOptedOut(), t = this.config.opt_out_persistence_by_default || this.config.cookieless_mode === "on_reject";
4091
- return this.config.disable_persistence || e && !!t;
4092
- }
4093
- Br() {
4094
- var e, t, i, s, n = this.kr();
4095
- return ((e = this.persistence) == null ? void 0 : e.wi) !== n && ((i = this.persistence) == null || i.set_disabled(n)), ((t = this.sessionPersistence) == null ? void 0 : t.wi) !== n && ((s = this.sessionPersistence) == null || s.set_disabled(n)), n;
4096
- }
4097
- opt_in_capturing(e) {
4098
- if (this.config.cookieless_mode !== "always") {
4099
- var t, i;
4100
- this.config.cookieless_mode === "on_reject" && this.consent.isExplicitlyOptedOut() && (this.reset(!0), (t = this.sessionManager) == null || t.destroy(), this.sessionManager = new ls(this), this.persistence && (this.sessionPropsManager = new os(this, this.sessionManager, this.persistence)), this.sessionRecording = new us(this), this.sessionRecording.startIfEnabledOrStop()), this.consent.optInOut(!0), this.Br(), this.Ar(), this.config.cookieless_mode == "on_reject" && this.surveys.loadIfEnabled(), (v(e == null ? void 0 : e.captureEventName) || e != null && e.captureEventName) && this.capture((i = e == null ? void 0 : e.captureEventName) !== null && i !== void 0 ? i : "$opt_in", e == null ? void 0 : e.captureProperties, { send_instantly: !0 }), this.config.capture_pageview && this.Dr();
4101
- } else y.warn('Consent opt in/out is not valid with cookieless_mode="always" and will be ignored');
4102
- }
4103
- opt_out_capturing() {
4104
- var e, t;
4105
- this.config.cookieless_mode !== "always" ? (this.config.cookieless_mode === "on_reject" && this.consent.isOptedIn() && this.reset(!0), this.consent.optInOut(!1), this.Br(), this.config.cookieless_mode === "on_reject" && (this.register({ distinct_id: ot, $device_id: null }), (e = this.sessionManager) == null || e.destroy(), this.sessionManager = void 0, this.sessionPropsManager = void 0, (t = this.sessionRecording) == null || t.stopRecording(), this.sessionRecording = void 0, this.Dr())) : y.warn('Consent opt in/out is not valid with cookieless_mode="always" and will be ignored');
4106
- }
4107
- has_opted_in_capturing() {
4108
- return this.consent.isOptedIn();
4109
- }
4110
- has_opted_out_capturing() {
4111
- return this.consent.isOptedOut();
4112
- }
4113
- get_explicit_consent_status() {
4114
- var e = this.consent.consent;
4115
- return e === be.GRANTED ? "granted" : e === be.DENIED ? "denied" : "pending";
4116
- }
4117
- is_capturing() {
4118
- return this.config.cookieless_mode === "always" || (this.config.cookieless_mode === "on_reject" ? this.consent.isExplicitlyOptedOut() || this.consent.isOptedIn() : !this.has_opted_out_capturing());
4119
- }
4120
- clear_opt_in_out_capturing() {
4121
- this.consent.reset(), this.Br();
4122
- }
4123
- _is_bot() {
4124
- return Q ? xn(Q, this.config.custom_blocked_useragents) : void 0;
4125
- }
4126
- Dr() {
4127
- m && (m.visibilityState === "visible" ? this.mr || (this.mr = !0, this.capture("$pageview", { title: m.title }, { send_instantly: !0 }), this.yr && (m.removeEventListener("visibilitychange", this.yr), this.yr = null)) : this.yr || (this.yr = this.Dr.bind(this), L(m, "visibilitychange", this.yr)));
4128
- }
4129
- debug(e) {
4130
- e === !1 ? (d == null || d.console.log("You've disabled debug mode."), this.set_config({ debug: !1 })) : (d == null || d.console.log("You're now in debug mode. All calls to PostHog will be logged in your console.\nYou can disable this with `posthog.debug(false)`."), this.set_config({ debug: !0 }));
4131
- }
4132
- M() {
4133
- var e, t, i, s, n, a, o, l = this.Sr || {};
4134
- return "advanced_disable_flags" in l ? !!l.advanced_disable_flags : this.config.advanced_disable_flags !== !1 ? !!this.config.advanced_disable_flags : this.config.advanced_disable_decide === !0 ? (y.warn("Config field 'advanced_disable_decide' is deprecated. Please use 'advanced_disable_flags' instead. The old field will be removed in a future major version."), !0) : (i = "advanced_disable_decide", s = !1, n = y, a = (t = "advanced_disable_flags") in (e = l) && !v(e[t]), o = i in e && !v(e[i]), a ? e[t] : o ? (n && n.warn("Config field '" + i + "' is deprecated. Please use '" + t + "' instead. The old field will be removed in a future major version."), e[i]) : s);
4135
- }
4136
- Nr(e) {
4137
- if (O(this.config.before_send)) return e;
4138
- var t = F(this.config.before_send) ? this.config.before_send : [this.config.before_send], i = e;
4139
- for (var s of t) {
4140
- if (i = s(i), O(i)) {
4141
- var n = "Event '" + e.event + "' was rejected in beforeSend function";
4142
- return Bn(e.event) ? y.warn(n + ". This can cause unexpected behavior.") : y.info(n), null;
4143
- }
4144
- i.properties && !Xe(i.properties) || y.warn("Event '" + e.event + "' has no properties after beforeSend function, this is likely an error.");
4145
- }
4146
- return i;
4147
- }
4148
- getPageViewId() {
4149
- var e;
4150
- return (e = this.pageViewManager.Vt) == null ? void 0 : e.pageViewId;
4151
- }
4152
- captureTraceFeedback(e, t) {
4153
- this.capture("$ai_feedback", { $ai_trace_id: String(e), $ai_feedback_text: t });
4154
- }
4155
- captureTraceMetric(e, t, i) {
4156
- this.capture("$ai_metric", { $ai_trace_id: String(e), $ai_metric_name: t, $ai_metric_value: String(i) });
4157
- }
4158
- $r(e) {
4159
- var t = Oe(e) && !e, i = A.H() && A.q("ph_debug") === "true";
4160
- return !t && (!!i || e);
4161
- }
4162
- }
4163
- (function(r, e) {
4164
- for (var t = 0; t < e.length; t++) r.prototype[e[t]] = ga(r.prototype[e[t]]);
4165
- })(li, ["identify"]);
4166
- var ps;
4167
- ps = kt[Ke] = new li(), (function() {
4168
- function r() {
4169
- r.done || (r.done = !0, Sn = !1, T(kt, (function(e) {
4170
- e._dom_loaded();
4171
- })));
4172
- }
4173
- m != null && m.addEventListener ? m.readyState === "complete" ? r() : L(m, "DOMContentLoaded", r, { capture: !1 }) : d && y.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized");
4174
- })();
4175
- var gs;
4176
- (function(r) {
4177
- r.USER_ADDED_TO_CART = "user_added_to_cart", r.USER_SUBMITTED_CHECKOUT = "user_submitted_checkout";
4178
- })(gs || (gs = {}));
4179
- const Xo = { class: "dialog-block-header-container" }, Jo = { class: "dialog-block-title" }, Zo = { class: "dialog-block-description" }, Qo = /* @__PURE__ */ Me({
1
+ import { defineComponent as p, createElementBlock as u, openBlock as d, createElementVNode as c, toDisplayString as I, Fragment as b, renderList as A, createVNode as m, createBlock as S, ref as k, withDirectives as R, withKeys as N, vModelText as O, onMounted as w, watch as E, renderSlot as $, computed as v, withCtx as L, createCommentVNode as B } from "vue";
2
+ var f;
3
+ (function(t) {
4
+ t.OPEN_ASSISTANT = "open_assistant", t.CLOSE_ASSISTANT = "close_assistant", t.SEND_MESSAGE = "PRODUCT_QUESTION", t.SEND_GENERIC_QUESTION = "GENERIC_QUESTION", t.TRACK_ADD_TO_CART = "TRACK_ADD_TO_CART", t.TRACK_SUBMIT_CHECKOUT = "TRACK_SUBMIT_CHECKOUT";
5
+ })(f || (f = {}));
6
+ var T;
7
+ (function(t) {
8
+ t.USER_OPENED_ASSISTANT = "userOpenedAssistant", t.USER_CLOSED_ASSISTANT = "userClosedAssistant", t.USER_SENT_MESSAGE = "userSentMessage", t.USER_CLICKED_ON_PRODUCT_CARD = "userClickedOnProductCard", t.USER_OPENED_RECOMMENDATION = "userOpenedRecommendation", t.USER_ADDED_TO_CART = "userAddedToCart", t.USER_SEND_POSITIVE_FEEDBACK = "userSendPositiveFeedback", t.USER_SEND_NEGATIVE_FEEDBACK = "userSendNegativeFeedback";
9
+ })(T || (T = {}));
10
+ f.TRACK_ADD_TO_CART, f.TRACK_SUBMIT_CHECKOUT;
11
+ const U = { class: "dialog-block-header-container" }, V = { class: "dialog-block-title" }, x = { class: "dialog-block-description" }, P = /* @__PURE__ */ p({
4180
12
  __name: "DialogBlockHeader",
4181
13
  props: {
4182
14
  title: {},
4183
15
  description: {}
4184
16
  },
4185
- setup(r) {
4186
- const e = r;
4187
- return (t, i) => (ie(), De("div", Xo, [
4188
- H("div", Jo, Ii(e.title ?? "Your expert"), 1),
4189
- H("div", Zo, Ii(e.description ?? "A question about this product?"), 1)
17
+ setup(t) {
18
+ const e = t;
19
+ return (s, o) => (d(), u("div", U, [
20
+ c("div", V, I(e.title ?? "Your expert"), 1),
21
+ c("div", x, I(e.description ?? "A question about this product?"), 1)
4190
22
  ]));
4191
23
  }
4192
- }), at = (r, e) => {
4193
- const t = r.__vccOpts || r;
4194
- for (const [i, s] of e)
4195
- t[i] = s;
4196
- return t;
4197
- }, el = /* @__PURE__ */ at(Qo, [["__scopeId", "data-v-28e6dda7"]]), tl = {
24
+ }), C = (t, e) => {
25
+ const s = t.__vccOpts || t;
26
+ for (const [o, a] of e)
27
+ s[o] = a;
28
+ return s;
29
+ }, K = /* @__PURE__ */ C(P, [["__scopeId", "data-v-28e6dda7"]]), M = {
4198
30
  width: "20",
4199
31
  height: "20",
4200
32
  viewBox: "0 0 20 20",
4201
33
  fill: "none",
4202
34
  xmlns: "http://www.w3.org/2000/svg"
4203
- }, il = { "clip-path": "url(#clip0_466_934)" }, rl = ["stroke"], sl = ["stroke"], nl = /* @__PURE__ */ Me({
35
+ }, q = { "clip-path": "url(#clip0_466_934)" }, F = ["stroke"], j = ["stroke"], Q = /* @__PURE__ */ p({
4204
36
  __name: "AiStarsIcon",
4205
37
  props: {
4206
38
  color: {}
4207
39
  },
4208
- setup(r) {
4209
- const e = r;
4210
- return (t, i) => (ie(), De("svg", tl, [
4211
- H("g", il, [
4212
- H("path", {
40
+ setup(t) {
41
+ const e = t;
42
+ return (s, o) => (d(), u("svg", M, [
43
+ c("g", q, [
44
+ c("path", {
4213
45
  d: `M5.41675 10.8333L6.07046 12.1408C6.2917 12.5832 6.40232 12.8045 6.55011
4214
46
  12.9962C6.68124 13.1663 6.83375 13.3188 7.00388 13.45C7.19559 13.5977 7.41684
4215
47
  13.7084 7.85932 13.9296L9.16675 14.5833L7.85932 15.237C7.41684 15.4583 7.19559
@@ -4224,8 +56,8 @@ const Xo = { class: "dialog-block-header-container" }, Jo = { class: "dialog-blo
4224
56
  "stroke-width": "1.5",
4225
57
  "stroke-linecap": "round",
4226
58
  "stroke-linejoin": "round"
4227
- }, null, 8, rl),
4228
- H("path", {
59
+ }, null, 8, F),
60
+ c("path", {
4229
61
  d: `M12.5001 1.66666L13.4823 4.22034C13.7173 4.83136 13.8348 5.13688 14.0175
4230
62
  5.39386C14.1795 5.62162 14.3785 5.82061 14.6062 5.98256C14.8632 6.16529 15.1687
4231
63
  6.2828 15.7797 6.5178L18.3334 7.49999L15.7797 8.48217C15.1687 8.71718 14.8632
@@ -4240,11 +72,11 @@ const Xo = { class: "dialog-block-header-container" }, Jo = { class: "dialog-blo
4240
72
  "stroke-width": "1.5",
4241
73
  "stroke-linecap": "round",
4242
74
  "stroke-linejoin": "round"
4243
- }, null, 8, sl)
75
+ }, null, 8, j)
4244
76
  ]),
4245
- i[0] || (i[0] = H("defs", null, [
4246
- H("clipPath", { id: "clip0_466_934" }, [
4247
- H("rect", {
77
+ o[0] || (o[0] = c("defs", null, [
78
+ c("clipPath", { id: "clip0_466_934" }, [
79
+ c("rect", {
4248
80
  width: "20",
4249
81
  height: "20",
4250
82
  fill: "white"
@@ -4253,7 +85,7 @@ const Xo = { class: "dialog-block-header-container" }, Jo = { class: "dialog-blo
4253
85
  ], -1))
4254
86
  ]));
4255
87
  }
4256
- }), al = ["onClick"], ol = { class: "dialog-block-suggestions-item-label" }, ll = /* @__PURE__ */ Me({
88
+ }), G = ["onClick"], H = { class: "dialog-block-suggestions-item-label" }, Z = /* @__PURE__ */ p({
4257
89
  __name: "DialogBlockSuggestions",
4258
90
  props: {
4259
91
  client: {},
@@ -4262,37 +94,37 @@ const Xo = { class: "dialog-block-header-container" }, Jo = { class: "dialog-blo
4262
94
  productTitle: {},
4263
95
  selectedVariantId: {}
4264
96
  },
4265
- setup(r) {
4266
- const e = r, t = (i) => {
97
+ setup(t) {
98
+ const e = t, s = (o) => {
4267
99
  e.client.sendProductMessage({
4268
100
  productId: e.productId,
4269
101
  productTitle: e.productTitle,
4270
102
  selectedVariantId: e.selectedVariantId,
4271
- question: i,
103
+ question: o,
4272
104
  fromQuestionSuggestion: !0
4273
105
  });
4274
106
  };
4275
- return (i, s) => (ie(!0), De(fs, null, Tn(e.questions, (n) => (ie(), De("button", {
107
+ return (o, a) => (d(!0), u(b, null, A(e.questions, (n) => (d(), u("button", {
4276
108
  key: n.question,
4277
109
  class: "dialog-block-suggestions-item",
4278
- onClick: (a) => t(n.question)
110
+ onClick: (l) => s(n.question)
4279
111
  }, [
4280
- Bt(nl, {
112
+ m(Q, {
4281
113
  class: "dialog-block-suggestions-item-icon",
4282
114
  color: e.client.theme.primaryColor
4283
115
  }, null, 8, ["color"]),
4284
- H("span", ol, Ii(n.question), 1)
4285
- ], 8, al))), 128));
4286
- }
4287
- }), cl = /* @__PURE__ */ at(ll, [["__scopeId", "data-v-fb1910ce"]]), ul = {};
4288
- function hl(r, e) {
4289
- return ie(), De(fs, null, [
4290
- e[0] || (e[0] = H("div", { class: "dialog-block-suggestions-skeleton-item" }, null, -1)),
4291
- e[1] || (e[1] = H("div", { class: "dialog-block-suggestions-skeleton-item" }, null, -1)),
4292
- e[2] || (e[2] = H("div", { class: "dialog-block-suggestions-skeleton-item" }, null, -1))
116
+ c("span", H, I(n.question), 1)
117
+ ], 8, G))), 128));
118
+ }
119
+ }), Y = /* @__PURE__ */ C(Z, [["__scopeId", "data-v-fb1910ce"]]), z = {};
120
+ function J(t, e) {
121
+ return d(), u(b, null, [
122
+ e[0] || (e[0] = c("div", { class: "dialog-block-suggestions-skeleton-item" }, null, -1)),
123
+ e[1] || (e[1] = c("div", { class: "dialog-block-suggestions-skeleton-item" }, null, -1)),
124
+ e[2] || (e[2] = c("div", { class: "dialog-block-suggestions-skeleton-item" }, null, -1))
4293
125
  ], 64);
4294
126
  }
4295
- const dl = /* @__PURE__ */ at(ul, [["render", hl], ["__scopeId", "data-v-26a64b58"]]), pl = { class: "dialog-block-suggestions-container" }, gl = /* @__PURE__ */ Me({
127
+ const W = /* @__PURE__ */ C(z, [["render", J], ["__scopeId", "data-v-26a64b58"]]), X = { class: "dialog-block-suggestions-container" }, ee = /* @__PURE__ */ p({
4296
128
  __name: "DialogBlockSuggestionsContainer",
4297
129
  props: {
4298
130
  client: {},
@@ -4302,10 +134,10 @@ const dl = /* @__PURE__ */ at(ul, [["render", hl], ["__scopeId", "data-v-26a64b5
4302
134
  productTitle: {},
4303
135
  selectedVariantId: {}
4304
136
  },
4305
- setup(r) {
4306
- const e = r;
4307
- return (t, i) => (ie(), De("div", pl, [
4308
- e.isLoading || !e.questions ? (ie(), Ht(dl, { key: 0 })) : (ie(), Ht(cl, {
137
+ setup(t) {
138
+ const e = t;
139
+ return (s, o) => (d(), u("div", X, [
140
+ e.isLoading || !e.questions ? (d(), S(W, { key: 0 })) : (d(), S(Y, {
4309
141
  key: 1,
4310
142
  client: e.client,
4311
143
  questions: e.questions,
@@ -4315,30 +147,30 @@ const dl = /* @__PURE__ */ at(ul, [["render", hl], ["__scopeId", "data-v-26a64b5
4315
147
  }, null, 8, ["client", "questions", "product-id", "product-title", "selected-variant-id"]))
4316
148
  ]));
4317
149
  }
4318
- }), fl = /* @__PURE__ */ at(gl, [["__scopeId", "data-v-18c9e78b"]]), _l = {
150
+ }), te = /* @__PURE__ */ C(ee, [["__scopeId", "data-v-18c9e78b"]]), oe = {
4319
151
  width: "20",
4320
152
  height: "20",
4321
153
  viewBox: "0 0 20 20",
4322
154
  fill: "none",
4323
155
  xmlns: "http://www.w3.org/2000/svg"
4324
- }, vl = ["stroke"], ml = /* @__PURE__ */ Me({
156
+ }, ne = ["stroke"], se = /* @__PURE__ */ p({
4325
157
  __name: "ArrowIcon",
4326
158
  props: {
4327
159
  color: {}
4328
160
  },
4329
- setup(r) {
4330
- const e = r;
4331
- return (t, i) => (ie(), De("svg", _l, [
4332
- H("path", {
161
+ setup(t) {
162
+ const e = t;
163
+ return (s, o) => (d(), u("svg", oe, [
164
+ c("path", {
4333
165
  d: "M10 16.6667V3.33334M10 3.33334L5 8.33334M10 3.33334L15 8.33334",
4334
166
  stroke: e.color || "#ffffff",
4335
167
  "stroke-width": "1.5",
4336
168
  "stroke-linecap": "round",
4337
169
  "stroke-linejoin": "round"
4338
- }, null, 8, vl)
170
+ }, null, 8, ne)
4339
171
  ]));
4340
172
  }
4341
- }), yl = ["placeholder"], bl = ["disabled"], wl = /* @__PURE__ */ Me({
173
+ }), ie = ["placeholder"], ce = ["disabled"], le = /* @__PURE__ */ p({
4342
174
  __name: "DialogInput",
4343
175
  props: {
4344
176
  client: {},
@@ -4347,97 +179,97 @@ const dl = /* @__PURE__ */ at(ul, [["render", hl], ["__scopeId", "data-v-26a64b5
4347
179
  productTitle: {},
4348
180
  selectedVariantId: {}
4349
181
  },
4350
- setup(r) {
4351
- const e = r, t = wt(), i = wt(""), s = () => {
4352
- var a;
4353
- (a = t.value) == null || a.focus();
182
+ setup(t) {
183
+ const e = t, s = k(), o = k(""), a = () => {
184
+ var l;
185
+ (l = s.value) == null || l.focus();
4354
186
  }, n = () => {
4355
- const a = i.value;
4356
- a.trim() && (e.client.sendProductMessage({
187
+ const l = o.value;
188
+ l.trim() && (e.client.sendProductMessage({
4357
189
  productId: e.productId,
4358
190
  productTitle: e.productTitle,
4359
191
  selectedVariantId: e.selectedVariantId,
4360
- question: a,
192
+ question: l,
4361
193
  fromQuestionSuggestion: !0
4362
- }), i.value = "");
194
+ }), o.value = "");
4363
195
  };
4364
- return (a, o) => (ie(), De("div", {
196
+ return (l, r) => (d(), u("div", {
4365
197
  class: "dialog-input-wrapper",
4366
- onClick: s
198
+ onClick: a
4367
199
  }, [
4368
- Fn(H("input", {
200
+ R(c("input", {
4369
201
  id: "dialog-ask-anything-input-ai-input",
4370
202
  ref_key: "inputRef",
4371
- ref: t,
4372
- "onUpdate:modelValue": o[0] || (o[0] = (l) => i.value = l),
203
+ ref: s,
204
+ "onUpdate:modelValue": r[0] || (r[0] = (_) => o.value = _),
4373
205
  class: "dialog-ask-anything-input-ai-input",
4374
206
  placeholder: e.placeholder ?? "Ask anything...",
4375
- onKeydown: On(n, ["enter"])
4376
- }, null, 40, yl), [
4377
- [Rn, i.value]
207
+ onKeydown: N(n, ["enter"])
208
+ }, null, 40, ie), [
209
+ [O, o.value]
4378
210
  ]),
4379
- H("button", {
211
+ c("button", {
4380
212
  id: "send-message-button-ai-input",
4381
213
  class: "dialog-input-submit",
4382
- disabled: !i.value.trim(),
214
+ disabled: !o.value.trim(),
4383
215
  onClick: n
4384
216
  }, [
4385
- Bt(ml, {
217
+ m(se, {
4386
218
  color: e.client.theme.ctaTextColor
4387
219
  }, null, 8, ["color"])
4388
- ], 8, bl)
220
+ ], 8, ce)
4389
221
  ]));
4390
222
  }
4391
- }), El = /* @__PURE__ */ at(wl, [["__scopeId", "data-v-7649af7c"]]), kl = /* @__PURE__ */ Me({
223
+ }), re = /* @__PURE__ */ C(le, [["__scopeId", "data-v-7649af7c"]]), de = /* @__PURE__ */ p({
4392
224
  __name: "ThemeProvider",
4393
225
  props: {
4394
226
  theme: {}
4395
227
  },
4396
- setup(r) {
4397
- const e = r, t = document.body, i = (n) => n.replace(/([A-Z])/g, "-$1").toLowerCase(), s = (n) => {
4398
- n && Object.keys(n).forEach((a) => {
4399
- const o = a, l = i(a);
4400
- if (n[o] !== void 0) {
4401
- if (typeof n[o] == "object") {
4402
- Object.keys(n[o]).forEach((c) => {
228
+ setup(t) {
229
+ const e = t, s = document.body, o = (n) => n.replace(/([A-Z])/g, "-$1").toLowerCase(), a = (n) => {
230
+ n && Object.keys(n).forEach((l) => {
231
+ const r = l, _ = o(l);
232
+ if (n[r] !== void 0) {
233
+ if (typeof n[r] == "object") {
234
+ Object.keys(n[r]).forEach((i) => {
4403
235
  var h;
4404
- const u = c;
4405
- if (u !== void 0) {
4406
- const g = i(c), p = n[o];
4407
- t.style.setProperty(
4408
- `--dialog-theme-${l}-${g}`,
4409
- (h = p[u]) == null ? void 0 : h.toString()
236
+ const g = i;
237
+ if (g !== void 0) {
238
+ const y = o(i), D = n[r];
239
+ s.style.setProperty(
240
+ `--dialog-theme-${_}-${y}`,
241
+ (h = D[g]) == null ? void 0 : h.toString()
4410
242
  );
4411
243
  }
4412
244
  });
4413
245
  return;
4414
246
  }
4415
- if (o === "ctaBorderType") {
4416
- const c = n[o] === "rounded" ? "24px" : "0";
4417
- t.style.setProperty(`--dialog-theme-${l}`, c);
247
+ if (r === "ctaBorderType") {
248
+ const i = n[r] === "rounded" ? "24px" : "0";
249
+ s.style.setProperty(`--dialog-theme-${_}`, i);
4418
250
  return;
4419
251
  }
4420
- t.style.setProperty(
4421
- `--dialog-theme-${l}`,
4422
- n[o].toString()
252
+ s.style.setProperty(
253
+ `--dialog-theme-${_}`,
254
+ n[r].toString()
4423
255
  );
4424
256
  }
4425
257
  });
4426
258
  };
4427
- return An(() => {
4428
- e.theme && s(e.theme);
4429
- }), _s(
259
+ return w(() => {
260
+ e.theme && a(e.theme);
261
+ }), E(
4430
262
  () => e.theme,
4431
263
  (n) => {
4432
- n && s(n);
264
+ n && a(n);
4433
265
  },
4434
266
  { deep: !0 }
4435
- ), (n, a) => Dn(n.$slots, "default");
267
+ ), (n, l) => $(n.$slots, "default");
4436
268
  }
4437
- }), xl = {
269
+ }), ae = {
4438
270
  id: "dialog-instant",
4439
271
  class: "dialog-block-container"
4440
- }, Sl = /* @__PURE__ */ Me({
272
+ }, ue = /* @__PURE__ */ p({
4441
273
  __name: "DialogProductBlock",
4442
274
  props: {
4443
275
  client: {},
@@ -4446,69 +278,69 @@ const dl = /* @__PURE__ */ at(ul, [["render", hl], ["__scopeId", "data-v-26a64b5
4446
278
  selectedVariantId: { default: void 0 },
4447
279
  enableInput: { type: Boolean, default: !0 }
4448
280
  },
4449
- setup(r) {
4450
- const e = r, t = wt(!0), i = wt(void 0), s = wt(0), n = hi(() => {
4451
- var c;
4452
- return t.value ? "" : (c = i.value) == null ? void 0 : c.assistantName;
4453
- }), a = hi(() => {
4454
- var c;
4455
- return t.value ? "" : (c = i.value) == null ? void 0 : c.description;
4456
- }), o = hi(() => {
4457
- var c;
4458
- return t.value ? "" : (c = i.value) == null ? void 0 : c.inputPlaceholder;
4459
- }), l = async () => {
4460
- const c = ++s.value;
4461
- t.value = !0, i.value = void 0;
281
+ setup(t) {
282
+ const e = t, s = k(!0), o = k(void 0), a = k(0), n = v(() => {
283
+ var i;
284
+ return s.value ? "" : (i = o.value) == null ? void 0 : i.assistantName;
285
+ }), l = v(() => {
286
+ var i;
287
+ return s.value ? "" : (i = o.value) == null ? void 0 : i.description;
288
+ }), r = v(() => {
289
+ var i;
290
+ return s.value ? "" : (i = o.value) == null ? void 0 : i.inputPlaceholder;
291
+ }), _ = async () => {
292
+ const i = ++a.value;
293
+ s.value = !0, o.value = void 0;
4462
294
  try {
4463
- const u = await e.client.getSuggestions(e.productId);
4464
- c === s.value && (i.value = u);
4465
- } catch (u) {
4466
- console.error("error", u);
295
+ const g = await e.client.getSuggestions(e.productId);
296
+ i === a.value && (o.value = g);
297
+ } catch (g) {
298
+ console.error("error", g);
4467
299
  } finally {
4468
- c === s.value && (t.value = !1);
300
+ i === a.value && (s.value = !1);
4469
301
  }
4470
302
  };
4471
- return _s(
303
+ return E(
4472
304
  () => [e.client, e.productId],
4473
305
  () => {
4474
- l();
306
+ _();
4475
307
  },
4476
308
  { immediate: !0 }
4477
- ), (c, u) => (ie(), Ht(kl, {
309
+ ), (i, g) => (d(), S(de, {
4478
310
  theme: e.client.theme
4479
311
  }, {
4480
- default: Mn(() => {
312
+ default: L(() => {
4481
313
  var h;
4482
314
  return [
4483
- H("div", xl, [
4484
- Bt(el, {
315
+ c("div", ae, [
316
+ m(K, {
4485
317
  title: n.value,
4486
- description: a.value
318
+ description: l.value
4487
319
  }, null, 8, ["title", "description"]),
4488
- Bt(fl, {
320
+ m(te, {
4489
321
  client: e.client,
4490
- questions: (h = i.value) == null ? void 0 : h.questions,
4491
- "is-loading": t.value,
322
+ questions: (h = o.value) == null ? void 0 : h.questions,
323
+ "is-loading": s.value,
4492
324
  "product-id": e.productId,
4493
325
  "product-title": e.productTitle,
4494
326
  "selected-variant-id": e == null ? void 0 : e.selectedVariantId
4495
327
  }, null, 8, ["client", "questions", "is-loading", "product-id", "product-title", "selected-variant-id"]),
4496
- e.enableInput ? (ie(), Ht(El, {
328
+ e.enableInput ? (d(), S(re, {
4497
329
  key: 0,
4498
330
  client: e.client,
4499
- placeholder: o.value,
331
+ placeholder: r.value,
4500
332
  "product-id": e.productId,
4501
333
  "product-title": e.productTitle,
4502
334
  "selected-variant-id": e == null ? void 0 : e.selectedVariantId
4503
- }, null, 8, ["client", "placeholder", "product-id", "product-title", "selected-variant-id"])) : Ln("", !0)
335
+ }, null, 8, ["client", "placeholder", "product-id", "product-title", "selected-variant-id"])) : B("", !0)
4504
336
  ])
4505
337
  ];
4506
338
  }),
4507
339
  _: 1
4508
340
  }, 8, ["theme"]));
4509
341
  }
4510
- }), Pl = /* @__PURE__ */ at(Sl, [["__scopeId", "data-v-651875ac"]]);
342
+ }), _e = /* @__PURE__ */ C(ue, [["__scopeId", "data-v-651875ac"]]);
4511
343
  export {
4512
- El as DialogInput,
4513
- Pl as DialogProductBlock
344
+ re as DialogInput,
345
+ _e as DialogProductBlock
4514
346
  };