@bluenath/engage 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,1579 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
+ import require$$0, { createContext, useRef, useEffect, useContext } from "react";
5
+ let getRandomValues;
6
+ const rnds8 = new Uint8Array(16);
7
+ function rng() {
8
+ if (!getRandomValues) {
9
+ getRandomValues = typeof crypto !== "undefined" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
10
+ if (!getRandomValues) {
11
+ throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
12
+ }
13
+ }
14
+ return getRandomValues(rnds8);
15
+ }
16
+ const byteToHex = [];
17
+ for (let i = 0; i < 256; ++i) {
18
+ byteToHex.push((i + 256).toString(16).slice(1));
19
+ }
20
+ function unsafeStringify(arr, offset = 0) {
21
+ return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];
22
+ }
23
+ const randomUUID = typeof crypto !== "undefined" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
24
+ const native = {
25
+ randomUUID
26
+ };
27
+ function v4(options, buf, offset) {
28
+ if (native.randomUUID && true && !options) {
29
+ return native.randomUUID();
30
+ }
31
+ options = options || {};
32
+ const rnds = options.random || (options.rng || rng)();
33
+ rnds[6] = rnds[6] & 15 | 64;
34
+ rnds[8] = rnds[8] & 63 | 128;
35
+ return unsafeStringify(rnds);
36
+ }
37
+ const hashFnv32a = (str) => {
38
+ let hval = 2166136261;
39
+ const l = str.length;
40
+ for (let i = 0; i < l; i++) {
41
+ hval ^= str.charCodeAt(i);
42
+ hval += (hval << 1) + (hval << 4) + (hval << 7) + (hval << 8) + (hval << 24);
43
+ }
44
+ return ("0000000" + (hval >>> 0).toString(16)).substr(-8);
45
+ };
46
+ const getDeviceFingerprint = () => {
47
+ if (typeof window === "undefined") return "server-side-id";
48
+ const n = navigator;
49
+ const s = window.screen;
50
+ const signals = {
51
+ userAgent: n.userAgent || "",
52
+ screenRes: `${s.width}x${s.height}`,
53
+ colorDepth: s.colorDepth || 0,
54
+ timezone: (/* @__PURE__ */ new Date()).getTimezoneOffset(),
55
+ language: n.language || "en-US",
56
+ platform: n.platform || "unknown",
57
+ hardwareConcurrency: n.hardwareConcurrency || 1,
58
+ // CPU Cores
59
+ deviceMemory: n.deviceMemory || 0
60
+ // RAM (approx in GB, Chrome only)
61
+ };
62
+ const entropy = [
63
+ signals.platform,
64
+ signals.language,
65
+ signals.screenRes,
66
+ signals.colorDepth,
67
+ signals.timezone,
68
+ signals.hardwareConcurrency,
69
+ signals.deviceMemory
70
+ ].join("|");
71
+ return `${hashFnv32a(entropy)}-${hashFnv32a(signals.userAgent)}`;
72
+ };
73
+ class StorageEngine {
74
+ constructor(type = "local") {
75
+ __publicField(this, "memoryStore", {});
76
+ __publicField(this, "keyPrefix", "engage_");
77
+ __publicField(this, "domain");
78
+ this.type = type;
79
+ this.domain = this.getCookieDomain();
80
+ }
81
+ /**
82
+ * Safe Getter that tries Memory -> Storage Strategy
83
+ */
84
+ getItem(key) {
85
+ const finalKey = this.keyPrefix + key;
86
+ if (this.memoryStore.hasOwnProperty(finalKey)) {
87
+ return this.memoryStore[finalKey];
88
+ }
89
+ try {
90
+ if (this.type === "local" && this.isBrowser()) {
91
+ return window.localStorage.getItem(finalKey);
92
+ }
93
+ if (this.type === "cookie" && this.isBrowser()) {
94
+ return this.getCookie(finalKey);
95
+ }
96
+ } catch (e) {
97
+ return null;
98
+ }
99
+ return null;
100
+ }
101
+ /**
102
+ * Safe Setter with Automatic Fallback
103
+ */
104
+ setItem(key, value) {
105
+ const finalKey = this.keyPrefix + key;
106
+ this.memoryStore[finalKey] = value;
107
+ try {
108
+ if (this.type === "local" && this.isBrowser()) {
109
+ window.localStorage.setItem(finalKey, value);
110
+ } else if (this.type === "cookie" && this.isBrowser()) {
111
+ this.setCookie(finalKey, value, 365);
112
+ }
113
+ } catch (e) {
114
+ if (this.isQuotaError(e)) {
115
+ console.warn(
116
+ "[EngagePro] Storage Quota Exceeded. Falling back to memory."
117
+ );
118
+ this.type = "memory";
119
+ }
120
+ }
121
+ }
122
+ removeItem(key) {
123
+ const finalKey = this.keyPrefix + key;
124
+ delete this.memoryStore[finalKey];
125
+ try {
126
+ if (this.type === "local" && this.isBrowser()) {
127
+ window.localStorage.removeItem(finalKey);
128
+ } else if (this.type === "cookie" && this.isBrowser()) {
129
+ this.setCookie(finalKey, "", -1);
130
+ }
131
+ } catch (e) {
132
+ }
133
+ }
134
+ // --- COOKIE HELPERS ---
135
+ getCookie(name) {
136
+ const nameEQ = name + "=";
137
+ const ca = document.cookie.split(";");
138
+ for (let i = 0; i < ca.length; i++) {
139
+ let c = ca[i];
140
+ while (c.charAt(0) === " ") c = c.substring(1, c.length);
141
+ if (c.indexOf(nameEQ) === 0)
142
+ return decodeURIComponent(c.substring(nameEQ.length, c.length));
143
+ }
144
+ return null;
145
+ }
146
+ setCookie(name, value, days) {
147
+ let expires = "";
148
+ if (days) {
149
+ const date = /* @__PURE__ */ new Date();
150
+ date.setTime(date.getTime() + days * 24 * 60 * 60 * 1e3);
151
+ expires = "; expires=" + date.toUTCString();
152
+ }
153
+ document.cookie = `${name}=${encodeURIComponent(value)}${expires}; path=/; domain=${this.domain}; SameSite=Lax; Secure`;
154
+ }
155
+ // --- UTILITIES ---
156
+ /**
157
+ * Tries to find the highest level domain (e.g. .nike.com) to allow cross-subdomain tracking
158
+ */
159
+ getCookieDomain() {
160
+ if (!this.isBrowser()) return "";
161
+ const host = window.location.hostname;
162
+ const parts = host.split(".");
163
+ if (parts.length === 1 || host === "localhost") return "";
164
+ if (parts.length > 2) {
165
+ return "." + parts.slice(-2).join(".");
166
+ }
167
+ return "." + host;
168
+ }
169
+ isBrowser() {
170
+ try {
171
+ return typeof window !== "undefined" && typeof window.document !== "undefined";
172
+ } catch (e) {
173
+ return false;
174
+ }
175
+ }
176
+ isQuotaError(e) {
177
+ return e instanceof DOMException && // everything except Firefox
178
+ (e.code === 22 || // Firefox
179
+ e.code === 1014 || // test name field too, because code might not be present
180
+ // everything except Firefox
181
+ e.name === "QuotaExceededError" || // Firefox
182
+ e.name === "NS_ERROR_DOM_QUOTA_REACHED");
183
+ }
184
+ }
185
+ class Context {
186
+ constructor(config) {
187
+ __publicField(this, "storage");
188
+ __publicField(this, "SESSION_TIMEOUT", 30 * 60 * 1e3);
189
+ // 30 Minutes
190
+ // State
191
+ __publicField(this, "deviceId");
192
+ __publicField(this, "sessionId");
193
+ __publicField(this, "userId", null);
194
+ // Journey Tracking
195
+ __publicField(this, "currentUrl");
196
+ __publicField(this, "referrer");
197
+ this.storage = new StorageEngine(config.persistence);
198
+ this.deviceId = this.getOrSetDeviceId();
199
+ this.sessionId = "";
200
+ this.manageSession();
201
+ if (typeof window !== "undefined") {
202
+ this.currentUrl = window.location.href;
203
+ this.referrer = document.referrer;
204
+ this.listenToHistory();
205
+ } else {
206
+ this.currentUrl = "";
207
+ this.referrer = "";
208
+ }
209
+ }
210
+ getOrSetDeviceId() {
211
+ const stored = this.storage.getItem("device_id");
212
+ if (stored) return stored;
213
+ const newId = getDeviceFingerprint();
214
+ this.storage.setItem("device_id", newId);
215
+ return newId;
216
+ }
217
+ manageSession() {
218
+ const now = Date.now();
219
+ const storedSession = this.storage.getItem("session_id");
220
+ const lastActivity = parseInt(this.storage.getItem("last_activity") || "0");
221
+ if (!storedSession || now - lastActivity > this.SESSION_TIMEOUT) {
222
+ this.sessionId = `sess_${now}_${Math.random().toString(36).substr(2, 9)}`;
223
+ this.storage.setItem("session_id", this.sessionId);
224
+ } else {
225
+ this.sessionId = storedSession;
226
+ }
227
+ this.storage.setItem("last_activity", now.toString());
228
+ if (typeof window !== "undefined") {
229
+ const update = () => this.storage.setItem("last_activity", Date.now().toString());
230
+ window.addEventListener("click", update);
231
+ window.addEventListener("scroll", update);
232
+ }
233
+ }
234
+ listenToHistory() {
235
+ const originalPush = history.pushState;
236
+ history.pushState = (...args) => {
237
+ originalPush.apply(history, args);
238
+ this.handleUrlChange();
239
+ };
240
+ window.addEventListener("popstate", () => this.handleUrlChange());
241
+ }
242
+ handleUrlChange() {
243
+ const newUrl = window.location.href;
244
+ if (newUrl !== this.currentUrl) {
245
+ this.referrer = this.currentUrl;
246
+ this.currentUrl = newUrl;
247
+ }
248
+ }
249
+ getPayload() {
250
+ var _a;
251
+ return {
252
+ library: { name: "@engagepro/analytics", version: "2.0.0" },
253
+ user: {
254
+ anonymousId: this.deviceId,
255
+ id: this.userId
256
+ },
257
+ session: {
258
+ id: this.sessionId,
259
+ startTime: parseInt(
260
+ this.sessionId.split("_")[1] || Date.now().toString()
261
+ )
262
+ },
263
+ page: {
264
+ path: typeof window !== "undefined" ? window.location.pathname : "",
265
+ referrer: this.referrer,
266
+ title: typeof document !== "undefined" ? document.title : "",
267
+ search: typeof window !== "undefined" ? window.location.search : "",
268
+ url: this.currentUrl
269
+ },
270
+ network: {
271
+ online: typeof navigator !== "undefined" ? navigator.onLine : true,
272
+ downlink: (_a = navigator.connection) == null ? void 0 : _a.downlink
273
+ },
274
+ screen: {
275
+ width: typeof screen !== "undefined" ? screen.width : 0,
276
+ height: typeof screen !== "undefined" ? screen.height : 0,
277
+ density: typeof window !== "undefined" ? window.devicePixelRatio : 1
278
+ },
279
+ device: {
280
+ fingerprint: this.deviceId,
281
+ type: this.getDeviceType(),
282
+ userAgent: typeof navigator !== "undefined" ? navigator.userAgent : "server"
283
+ },
284
+ locale: typeof navigator !== "undefined" ? navigator.language : "en-US",
285
+ timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
286
+ };
287
+ }
288
+ getDeviceType() {
289
+ if (typeof navigator === "undefined") return "desktop";
290
+ const ua = navigator.userAgent;
291
+ if (/(tablet|ipad|playbook|silk)|(android(?!.*mobi))/i.test(ua))
292
+ return "tablet";
293
+ if (/Mobile|Android|iP(hone|od)|IEMobile|BlackBerry|Kindle|Silk-Accelerated/.test(
294
+ ua
295
+ ))
296
+ return "mobile";
297
+ return "desktop";
298
+ }
299
+ }
300
+ class EventQueue {
301
+ constructor(transport) {
302
+ __publicField(this, "queue", []);
303
+ __publicField(this, "storage");
304
+ __publicField(this, "transport");
305
+ __publicField(this, "STORAGE_KEY", "engage_queue_v1");
306
+ __publicField(this, "isFlushing", false);
307
+ this.transport = transport;
308
+ this.storage = new StorageEngine("local");
309
+ this.load();
310
+ if (typeof window !== "undefined") {
311
+ window.addEventListener("online", () => this.flush());
312
+ window.addEventListener("visibilitychange", () => {
313
+ if (document.visibilityState === "hidden") this.flush();
314
+ });
315
+ }
316
+ setInterval(() => this.flush(), 3e3);
317
+ }
318
+ enqueue(event) {
319
+ this.queue.push(event);
320
+ this.save();
321
+ if (this.queue.length >= 10) {
322
+ this.flush();
323
+ }
324
+ }
325
+ save() {
326
+ this.storage.setItem(this.STORAGE_KEY, JSON.stringify(this.queue));
327
+ }
328
+ load() {
329
+ const data = this.storage.getItem(this.STORAGE_KEY);
330
+ if (data) {
331
+ try {
332
+ this.queue = JSON.parse(data);
333
+ } catch (e) {
334
+ this.queue = [];
335
+ }
336
+ }
337
+ }
338
+ async flush() {
339
+ if (this.queue.length === 0 || this.isFlushing) return;
340
+ if (typeof navigator !== "undefined" && !navigator.onLine) return;
341
+ this.isFlushing = true;
342
+ const batch = [...this.queue];
343
+ this.queue = [];
344
+ this.save();
345
+ try {
346
+ const success = await this.transport.send(batch);
347
+ if (!success) {
348
+ this.queue = [...batch, ...this.queue];
349
+ this.save();
350
+ }
351
+ } catch (e) {
352
+ this.queue = [...batch, ...this.queue];
353
+ this.save();
354
+ } finally {
355
+ this.isFlushing = false;
356
+ }
357
+ }
358
+ }
359
+ class Transport {
360
+ constructor(apiEndpoint) {
361
+ this.apiEndpoint = apiEndpoint;
362
+ }
363
+ async send(events) {
364
+ const payload = JSON.stringify({
365
+ batch: events,
366
+ sentAt: (/* @__PURE__ */ new Date()).toISOString()
367
+ });
368
+ if (typeof navigator !== "undefined" && navigator.sendBeacon && payload.length < 6e4) {
369
+ const blob = new Blob([payload], { type: "application/json" });
370
+ const success = navigator.sendBeacon(this.apiEndpoint, blob);
371
+ if (success) return true;
372
+ }
373
+ try {
374
+ const response = await fetch(this.apiEndpoint, {
375
+ method: "POST",
376
+ headers: { "Content-Type": "application/json" },
377
+ body: payload,
378
+ keepalive: true
379
+ // Tries to keep request alive during navigation
380
+ });
381
+ return response.ok;
382
+ } catch (e) {
383
+ console.error("[EngagePro] Transport Failed:", e);
384
+ return false;
385
+ }
386
+ }
387
+ }
388
+ class EngagePro {
389
+ constructor(config) {
390
+ __publicField(this, "config");
391
+ // 🧩 Modules
392
+ __publicField(this, "context");
393
+ __publicField(this, "queue");
394
+ __publicField(this, "transport");
395
+ // ✅ ARROW FUNCTION (Auto-bound 'this')
396
+ __publicField(this, "identify", (userId, traits) => {
397
+ this.context.userId = userId;
398
+ this.processEvent({
399
+ event: "Identify",
400
+ properties: { traits },
401
+ standardEvent: "LOGIN",
402
+ intent: "identity",
403
+ confidence: 1
404
+ });
405
+ });
406
+ // ✅ ARROW FUNCTION
407
+ __publicField(this, "page", (name, properties) => {
408
+ const pageCtx = this.context.getPayload().page;
409
+ this.processEvent({
410
+ event: name || pageCtx.title || "Unknown Page",
411
+ properties: {
412
+ path: pageCtx.path,
413
+ referrer: pageCtx.referrer,
414
+ title: pageCtx.title,
415
+ ...properties
416
+ },
417
+ standardEvent: "PAGE_VIEW",
418
+ intent: "navigation",
419
+ confidence: 1
420
+ });
421
+ });
422
+ // ✅ ARROW FUNCTION
423
+ __publicField(this, "track", (eventName, properties, intelligence) => {
424
+ this.processEvent({
425
+ event: eventName,
426
+ properties: properties || {},
427
+ ...intelligence
428
+ });
429
+ });
430
+ this.config = config;
431
+ this.transport = new Transport(
432
+ config.apiHost || "http://localhost:3000/v1/ingest"
433
+ );
434
+ this.context = new Context({
435
+ persistence: config.tracking.useCookies ? "cookie" : "local"
436
+ });
437
+ this.queue = new EventQueue(this.transport);
438
+ }
439
+ // Internal Helper
440
+ processEvent(data) {
441
+ const baseContext = this.context.getPayload();
442
+ const payload = {
443
+ event: data.event,
444
+ properties: data.properties,
445
+ // Intelligence
446
+ standardEvent: data.standardEvent,
447
+ intent: data.intent,
448
+ confidence: data.confidence,
449
+ rawLabel: data.rawLabel,
450
+ // Metadata
451
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
452
+ messageId: v4(),
453
+ writeKey: this.config.writeKey,
454
+ // Identity
455
+ userId: baseContext.user.id || void 0,
456
+ anonymousId: baseContext.user.anonymousId,
457
+ context: baseContext
458
+ };
459
+ if (this.config.debug) {
460
+ console.log(`[EngagePro] 🧠 ${data.standardEvent || "Event"}:`, payload);
461
+ }
462
+ this.queue.enqueue(payload);
463
+ }
464
+ }
465
+ var jsxRuntime = { exports: {} };
466
+ var reactJsxRuntime_production_min = {};
467
+ /**
468
+ * @license React
469
+ * react-jsx-runtime.production.min.js
470
+ *
471
+ * Copyright (c) Facebook, Inc. and its affiliates.
472
+ *
473
+ * This source code is licensed under the MIT license found in the
474
+ * LICENSE file in the root directory of this source tree.
475
+ */
476
+ var hasRequiredReactJsxRuntime_production_min;
477
+ function requireReactJsxRuntime_production_min() {
478
+ if (hasRequiredReactJsxRuntime_production_min) return reactJsxRuntime_production_min;
479
+ hasRequiredReactJsxRuntime_production_min = 1;
480
+ var f = require$$0, k = Symbol.for("react.element"), l = Symbol.for("react.fragment"), m = Object.prototype.hasOwnProperty, n = f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, p = { key: true, ref: true, __self: true, __source: true };
481
+ function q(c, a, g) {
482
+ var b, d = {}, e = null, h = null;
483
+ void 0 !== g && (e = "" + g);
484
+ void 0 !== a.key && (e = "" + a.key);
485
+ void 0 !== a.ref && (h = a.ref);
486
+ for (b in a) m.call(a, b) && !p.hasOwnProperty(b) && (d[b] = a[b]);
487
+ if (c && c.defaultProps) for (b in a = c.defaultProps, a) void 0 === d[b] && (d[b] = a[b]);
488
+ return { $$typeof: k, type: c, key: e, ref: h, props: d, _owner: n.current };
489
+ }
490
+ reactJsxRuntime_production_min.Fragment = l;
491
+ reactJsxRuntime_production_min.jsx = q;
492
+ reactJsxRuntime_production_min.jsxs = q;
493
+ return reactJsxRuntime_production_min;
494
+ }
495
+ var reactJsxRuntime_development = {};
496
+ /**
497
+ * @license React
498
+ * react-jsx-runtime.development.js
499
+ *
500
+ * Copyright (c) Facebook, Inc. and its affiliates.
501
+ *
502
+ * This source code is licensed under the MIT license found in the
503
+ * LICENSE file in the root directory of this source tree.
504
+ */
505
+ var hasRequiredReactJsxRuntime_development;
506
+ function requireReactJsxRuntime_development() {
507
+ if (hasRequiredReactJsxRuntime_development) return reactJsxRuntime_development;
508
+ hasRequiredReactJsxRuntime_development = 1;
509
+ if (process.env.NODE_ENV !== "production") {
510
+ (function() {
511
+ var React = require$$0;
512
+ var REACT_ELEMENT_TYPE = Symbol.for("react.element");
513
+ var REACT_PORTAL_TYPE = Symbol.for("react.portal");
514
+ var REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
515
+ var REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode");
516
+ var REACT_PROFILER_TYPE = Symbol.for("react.profiler");
517
+ var REACT_PROVIDER_TYPE = Symbol.for("react.provider");
518
+ var REACT_CONTEXT_TYPE = Symbol.for("react.context");
519
+ var REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref");
520
+ var REACT_SUSPENSE_TYPE = Symbol.for("react.suspense");
521
+ var REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list");
522
+ var REACT_MEMO_TYPE = Symbol.for("react.memo");
523
+ var REACT_LAZY_TYPE = Symbol.for("react.lazy");
524
+ var REACT_OFFSCREEN_TYPE = Symbol.for("react.offscreen");
525
+ var MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
526
+ var FAUX_ITERATOR_SYMBOL = "@@iterator";
527
+ function getIteratorFn(maybeIterable) {
528
+ if (maybeIterable === null || typeof maybeIterable !== "object") {
529
+ return null;
530
+ }
531
+ var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
532
+ if (typeof maybeIterator === "function") {
533
+ return maybeIterator;
534
+ }
535
+ return null;
536
+ }
537
+ var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
538
+ function error(format) {
539
+ {
540
+ {
541
+ for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
542
+ args[_key2 - 1] = arguments[_key2];
543
+ }
544
+ printWarning("error", format, args);
545
+ }
546
+ }
547
+ }
548
+ function printWarning(level, format, args) {
549
+ {
550
+ var ReactDebugCurrentFrame2 = ReactSharedInternals.ReactDebugCurrentFrame;
551
+ var stack = ReactDebugCurrentFrame2.getStackAddendum();
552
+ if (stack !== "") {
553
+ format += "%s";
554
+ args = args.concat([stack]);
555
+ }
556
+ var argsWithFormat = args.map(function(item) {
557
+ return String(item);
558
+ });
559
+ argsWithFormat.unshift("Warning: " + format);
560
+ Function.prototype.apply.call(console[level], console, argsWithFormat);
561
+ }
562
+ }
563
+ var enableScopeAPI = false;
564
+ var enableCacheElement = false;
565
+ var enableTransitionTracing = false;
566
+ var enableLegacyHidden = false;
567
+ var enableDebugTracing = false;
568
+ var REACT_MODULE_REFERENCE;
569
+ {
570
+ REACT_MODULE_REFERENCE = Symbol.for("react.module.reference");
571
+ }
572
+ function isValidElementType(type) {
573
+ if (typeof type === "string" || typeof type === "function") {
574
+ return true;
575
+ }
576
+ if (type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || enableDebugTracing || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || enableLegacyHidden || type === REACT_OFFSCREEN_TYPE || enableScopeAPI || enableCacheElement || enableTransitionTracing) {
577
+ return true;
578
+ }
579
+ if (typeof type === "object" && type !== null) {
580
+ if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || // This needs to include all possible module reference object
581
+ // types supported by any Flight configuration anywhere since
582
+ // we don't know which Flight build this will end up being used
583
+ // with.
584
+ type.$$typeof === REACT_MODULE_REFERENCE || type.getModuleId !== void 0) {
585
+ return true;
586
+ }
587
+ }
588
+ return false;
589
+ }
590
+ function getWrappedName(outerType, innerType, wrapperName) {
591
+ var displayName = outerType.displayName;
592
+ if (displayName) {
593
+ return displayName;
594
+ }
595
+ var functionName = innerType.displayName || innerType.name || "";
596
+ return functionName !== "" ? wrapperName + "(" + functionName + ")" : wrapperName;
597
+ }
598
+ function getContextName(type) {
599
+ return type.displayName || "Context";
600
+ }
601
+ function getComponentNameFromType(type) {
602
+ if (type == null) {
603
+ return null;
604
+ }
605
+ {
606
+ if (typeof type.tag === "number") {
607
+ error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue.");
608
+ }
609
+ }
610
+ if (typeof type === "function") {
611
+ return type.displayName || type.name || null;
612
+ }
613
+ if (typeof type === "string") {
614
+ return type;
615
+ }
616
+ switch (type) {
617
+ case REACT_FRAGMENT_TYPE:
618
+ return "Fragment";
619
+ case REACT_PORTAL_TYPE:
620
+ return "Portal";
621
+ case REACT_PROFILER_TYPE:
622
+ return "Profiler";
623
+ case REACT_STRICT_MODE_TYPE:
624
+ return "StrictMode";
625
+ case REACT_SUSPENSE_TYPE:
626
+ return "Suspense";
627
+ case REACT_SUSPENSE_LIST_TYPE:
628
+ return "SuspenseList";
629
+ }
630
+ if (typeof type === "object") {
631
+ switch (type.$$typeof) {
632
+ case REACT_CONTEXT_TYPE:
633
+ var context = type;
634
+ return getContextName(context) + ".Consumer";
635
+ case REACT_PROVIDER_TYPE:
636
+ var provider = type;
637
+ return getContextName(provider._context) + ".Provider";
638
+ case REACT_FORWARD_REF_TYPE:
639
+ return getWrappedName(type, type.render, "ForwardRef");
640
+ case REACT_MEMO_TYPE:
641
+ var outerName = type.displayName || null;
642
+ if (outerName !== null) {
643
+ return outerName;
644
+ }
645
+ return getComponentNameFromType(type.type) || "Memo";
646
+ case REACT_LAZY_TYPE: {
647
+ var lazyComponent = type;
648
+ var payload = lazyComponent._payload;
649
+ var init2 = lazyComponent._init;
650
+ try {
651
+ return getComponentNameFromType(init2(payload));
652
+ } catch (x) {
653
+ return null;
654
+ }
655
+ }
656
+ }
657
+ }
658
+ return null;
659
+ }
660
+ var assign = Object.assign;
661
+ var disabledDepth = 0;
662
+ var prevLog;
663
+ var prevInfo;
664
+ var prevWarn;
665
+ var prevError;
666
+ var prevGroup;
667
+ var prevGroupCollapsed;
668
+ var prevGroupEnd;
669
+ function disabledLog() {
670
+ }
671
+ disabledLog.__reactDisabledLog = true;
672
+ function disableLogs() {
673
+ {
674
+ if (disabledDepth === 0) {
675
+ prevLog = console.log;
676
+ prevInfo = console.info;
677
+ prevWarn = console.warn;
678
+ prevError = console.error;
679
+ prevGroup = console.group;
680
+ prevGroupCollapsed = console.groupCollapsed;
681
+ prevGroupEnd = console.groupEnd;
682
+ var props = {
683
+ configurable: true,
684
+ enumerable: true,
685
+ value: disabledLog,
686
+ writable: true
687
+ };
688
+ Object.defineProperties(console, {
689
+ info: props,
690
+ log: props,
691
+ warn: props,
692
+ error: props,
693
+ group: props,
694
+ groupCollapsed: props,
695
+ groupEnd: props
696
+ });
697
+ }
698
+ disabledDepth++;
699
+ }
700
+ }
701
+ function reenableLogs() {
702
+ {
703
+ disabledDepth--;
704
+ if (disabledDepth === 0) {
705
+ var props = {
706
+ configurable: true,
707
+ enumerable: true,
708
+ writable: true
709
+ };
710
+ Object.defineProperties(console, {
711
+ log: assign({}, props, {
712
+ value: prevLog
713
+ }),
714
+ info: assign({}, props, {
715
+ value: prevInfo
716
+ }),
717
+ warn: assign({}, props, {
718
+ value: prevWarn
719
+ }),
720
+ error: assign({}, props, {
721
+ value: prevError
722
+ }),
723
+ group: assign({}, props, {
724
+ value: prevGroup
725
+ }),
726
+ groupCollapsed: assign({}, props, {
727
+ value: prevGroupCollapsed
728
+ }),
729
+ groupEnd: assign({}, props, {
730
+ value: prevGroupEnd
731
+ })
732
+ });
733
+ }
734
+ if (disabledDepth < 0) {
735
+ error("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
736
+ }
737
+ }
738
+ }
739
+ var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
740
+ var prefix;
741
+ function describeBuiltInComponentFrame(name, source, ownerFn) {
742
+ {
743
+ if (prefix === void 0) {
744
+ try {
745
+ throw Error();
746
+ } catch (x) {
747
+ var match = x.stack.trim().match(/\n( *(at )?)/);
748
+ prefix = match && match[1] || "";
749
+ }
750
+ }
751
+ return "\n" + prefix + name;
752
+ }
753
+ }
754
+ var reentry = false;
755
+ var componentFrameCache;
756
+ {
757
+ var PossiblyWeakMap = typeof WeakMap === "function" ? WeakMap : Map;
758
+ componentFrameCache = new PossiblyWeakMap();
759
+ }
760
+ function describeNativeComponentFrame(fn, construct) {
761
+ if (!fn || reentry) {
762
+ return "";
763
+ }
764
+ {
765
+ var frame = componentFrameCache.get(fn);
766
+ if (frame !== void 0) {
767
+ return frame;
768
+ }
769
+ }
770
+ var control;
771
+ reentry = true;
772
+ var previousPrepareStackTrace = Error.prepareStackTrace;
773
+ Error.prepareStackTrace = void 0;
774
+ var previousDispatcher;
775
+ {
776
+ previousDispatcher = ReactCurrentDispatcher.current;
777
+ ReactCurrentDispatcher.current = null;
778
+ disableLogs();
779
+ }
780
+ try {
781
+ if (construct) {
782
+ var Fake = function() {
783
+ throw Error();
784
+ };
785
+ Object.defineProperty(Fake.prototype, "props", {
786
+ set: function() {
787
+ throw Error();
788
+ }
789
+ });
790
+ if (typeof Reflect === "object" && Reflect.construct) {
791
+ try {
792
+ Reflect.construct(Fake, []);
793
+ } catch (x) {
794
+ control = x;
795
+ }
796
+ Reflect.construct(fn, [], Fake);
797
+ } else {
798
+ try {
799
+ Fake.call();
800
+ } catch (x) {
801
+ control = x;
802
+ }
803
+ fn.call(Fake.prototype);
804
+ }
805
+ } else {
806
+ try {
807
+ throw Error();
808
+ } catch (x) {
809
+ control = x;
810
+ }
811
+ fn();
812
+ }
813
+ } catch (sample) {
814
+ if (sample && control && typeof sample.stack === "string") {
815
+ var sampleLines = sample.stack.split("\n");
816
+ var controlLines = control.stack.split("\n");
817
+ var s = sampleLines.length - 1;
818
+ var c = controlLines.length - 1;
819
+ while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) {
820
+ c--;
821
+ }
822
+ for (; s >= 1 && c >= 0; s--, c--) {
823
+ if (sampleLines[s] !== controlLines[c]) {
824
+ if (s !== 1 || c !== 1) {
825
+ do {
826
+ s--;
827
+ c--;
828
+ if (c < 0 || sampleLines[s] !== controlLines[c]) {
829
+ var _frame = "\n" + sampleLines[s].replace(" at new ", " at ");
830
+ if (fn.displayName && _frame.includes("<anonymous>")) {
831
+ _frame = _frame.replace("<anonymous>", fn.displayName);
832
+ }
833
+ {
834
+ if (typeof fn === "function") {
835
+ componentFrameCache.set(fn, _frame);
836
+ }
837
+ }
838
+ return _frame;
839
+ }
840
+ } while (s >= 1 && c >= 0);
841
+ }
842
+ break;
843
+ }
844
+ }
845
+ }
846
+ } finally {
847
+ reentry = false;
848
+ {
849
+ ReactCurrentDispatcher.current = previousDispatcher;
850
+ reenableLogs();
851
+ }
852
+ Error.prepareStackTrace = previousPrepareStackTrace;
853
+ }
854
+ var name = fn ? fn.displayName || fn.name : "";
855
+ var syntheticFrame = name ? describeBuiltInComponentFrame(name) : "";
856
+ {
857
+ if (typeof fn === "function") {
858
+ componentFrameCache.set(fn, syntheticFrame);
859
+ }
860
+ }
861
+ return syntheticFrame;
862
+ }
863
+ function describeFunctionComponentFrame(fn, source, ownerFn) {
864
+ {
865
+ return describeNativeComponentFrame(fn, false);
866
+ }
867
+ }
868
+ function shouldConstruct(Component) {
869
+ var prototype = Component.prototype;
870
+ return !!(prototype && prototype.isReactComponent);
871
+ }
872
+ function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) {
873
+ if (type == null) {
874
+ return "";
875
+ }
876
+ if (typeof type === "function") {
877
+ {
878
+ return describeNativeComponentFrame(type, shouldConstruct(type));
879
+ }
880
+ }
881
+ if (typeof type === "string") {
882
+ return describeBuiltInComponentFrame(type);
883
+ }
884
+ switch (type) {
885
+ case REACT_SUSPENSE_TYPE:
886
+ return describeBuiltInComponentFrame("Suspense");
887
+ case REACT_SUSPENSE_LIST_TYPE:
888
+ return describeBuiltInComponentFrame("SuspenseList");
889
+ }
890
+ if (typeof type === "object") {
891
+ switch (type.$$typeof) {
892
+ case REACT_FORWARD_REF_TYPE:
893
+ return describeFunctionComponentFrame(type.render);
894
+ case REACT_MEMO_TYPE:
895
+ return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn);
896
+ case REACT_LAZY_TYPE: {
897
+ var lazyComponent = type;
898
+ var payload = lazyComponent._payload;
899
+ var init2 = lazyComponent._init;
900
+ try {
901
+ return describeUnknownElementTypeFrameInDEV(init2(payload), source, ownerFn);
902
+ } catch (x) {
903
+ }
904
+ }
905
+ }
906
+ }
907
+ return "";
908
+ }
909
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
910
+ var loggedTypeFailures = {};
911
+ var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
912
+ function setCurrentlyValidatingElement(element) {
913
+ {
914
+ if (element) {
915
+ var owner = element._owner;
916
+ var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
917
+ ReactDebugCurrentFrame.setExtraStackFrame(stack);
918
+ } else {
919
+ ReactDebugCurrentFrame.setExtraStackFrame(null);
920
+ }
921
+ }
922
+ }
923
+ function checkPropTypes(typeSpecs, values, location, componentName, element) {
924
+ {
925
+ var has = Function.call.bind(hasOwnProperty);
926
+ for (var typeSpecName in typeSpecs) {
927
+ if (has(typeSpecs, typeSpecName)) {
928
+ var error$1 = void 0;
929
+ try {
930
+ if (typeof typeSpecs[typeSpecName] !== "function") {
931
+ var err = Error((componentName || "React class") + ": " + location + " type `" + typeSpecName + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof typeSpecs[typeSpecName] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
932
+ err.name = "Invariant Violation";
933
+ throw err;
934
+ }
935
+ error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
936
+ } catch (ex) {
937
+ error$1 = ex;
938
+ }
939
+ if (error$1 && !(error$1 instanceof Error)) {
940
+ setCurrentlyValidatingElement(element);
941
+ error("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", componentName || "React class", location, typeSpecName, typeof error$1);
942
+ setCurrentlyValidatingElement(null);
943
+ }
944
+ if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {
945
+ loggedTypeFailures[error$1.message] = true;
946
+ setCurrentlyValidatingElement(element);
947
+ error("Failed %s type: %s", location, error$1.message);
948
+ setCurrentlyValidatingElement(null);
949
+ }
950
+ }
951
+ }
952
+ }
953
+ }
954
+ var isArrayImpl = Array.isArray;
955
+ function isArray(a) {
956
+ return isArrayImpl(a);
957
+ }
958
+ function typeName(value) {
959
+ {
960
+ var hasToStringTag = typeof Symbol === "function" && Symbol.toStringTag;
961
+ var type = hasToStringTag && value[Symbol.toStringTag] || value.constructor.name || "Object";
962
+ return type;
963
+ }
964
+ }
965
+ function willCoercionThrow(value) {
966
+ {
967
+ try {
968
+ testStringCoercion(value);
969
+ return false;
970
+ } catch (e) {
971
+ return true;
972
+ }
973
+ }
974
+ }
975
+ function testStringCoercion(value) {
976
+ return "" + value;
977
+ }
978
+ function checkKeyStringCoercion(value) {
979
+ {
980
+ if (willCoercionThrow(value)) {
981
+ error("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", typeName(value));
982
+ return testStringCoercion(value);
983
+ }
984
+ }
985
+ }
986
+ var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
987
+ var RESERVED_PROPS = {
988
+ key: true,
989
+ ref: true,
990
+ __self: true,
991
+ __source: true
992
+ };
993
+ var specialPropKeyWarningShown;
994
+ var specialPropRefWarningShown;
995
+ function hasValidRef(config) {
996
+ {
997
+ if (hasOwnProperty.call(config, "ref")) {
998
+ var getter = Object.getOwnPropertyDescriptor(config, "ref").get;
999
+ if (getter && getter.isReactWarning) {
1000
+ return false;
1001
+ }
1002
+ }
1003
+ }
1004
+ return config.ref !== void 0;
1005
+ }
1006
+ function hasValidKey(config) {
1007
+ {
1008
+ if (hasOwnProperty.call(config, "key")) {
1009
+ var getter = Object.getOwnPropertyDescriptor(config, "key").get;
1010
+ if (getter && getter.isReactWarning) {
1011
+ return false;
1012
+ }
1013
+ }
1014
+ }
1015
+ return config.key !== void 0;
1016
+ }
1017
+ function warnIfStringRefCannotBeAutoConverted(config, self) {
1018
+ {
1019
+ if (typeof config.ref === "string" && ReactCurrentOwner.current && self) ;
1020
+ }
1021
+ }
1022
+ function defineKeyPropWarningGetter(props, displayName) {
1023
+ {
1024
+ var warnAboutAccessingKey = function() {
1025
+ if (!specialPropKeyWarningShown) {
1026
+ specialPropKeyWarningShown = true;
1027
+ error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", displayName);
1028
+ }
1029
+ };
1030
+ warnAboutAccessingKey.isReactWarning = true;
1031
+ Object.defineProperty(props, "key", {
1032
+ get: warnAboutAccessingKey,
1033
+ configurable: true
1034
+ });
1035
+ }
1036
+ }
1037
+ function defineRefPropWarningGetter(props, displayName) {
1038
+ {
1039
+ var warnAboutAccessingRef = function() {
1040
+ if (!specialPropRefWarningShown) {
1041
+ specialPropRefWarningShown = true;
1042
+ error("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", displayName);
1043
+ }
1044
+ };
1045
+ warnAboutAccessingRef.isReactWarning = true;
1046
+ Object.defineProperty(props, "ref", {
1047
+ get: warnAboutAccessingRef,
1048
+ configurable: true
1049
+ });
1050
+ }
1051
+ }
1052
+ var ReactElement = function(type, key, ref, self, source, owner, props) {
1053
+ var element = {
1054
+ // This tag allows us to uniquely identify this as a React Element
1055
+ $$typeof: REACT_ELEMENT_TYPE,
1056
+ // Built-in properties that belong on the element
1057
+ type,
1058
+ key,
1059
+ ref,
1060
+ props,
1061
+ // Record the component responsible for creating this element.
1062
+ _owner: owner
1063
+ };
1064
+ {
1065
+ element._store = {};
1066
+ Object.defineProperty(element._store, "validated", {
1067
+ configurable: false,
1068
+ enumerable: false,
1069
+ writable: true,
1070
+ value: false
1071
+ });
1072
+ Object.defineProperty(element, "_self", {
1073
+ configurable: false,
1074
+ enumerable: false,
1075
+ writable: false,
1076
+ value: self
1077
+ });
1078
+ Object.defineProperty(element, "_source", {
1079
+ configurable: false,
1080
+ enumerable: false,
1081
+ writable: false,
1082
+ value: source
1083
+ });
1084
+ if (Object.freeze) {
1085
+ Object.freeze(element.props);
1086
+ Object.freeze(element);
1087
+ }
1088
+ }
1089
+ return element;
1090
+ };
1091
+ function jsxDEV(type, config, maybeKey, source, self) {
1092
+ {
1093
+ var propName;
1094
+ var props = {};
1095
+ var key = null;
1096
+ var ref = null;
1097
+ if (maybeKey !== void 0) {
1098
+ {
1099
+ checkKeyStringCoercion(maybeKey);
1100
+ }
1101
+ key = "" + maybeKey;
1102
+ }
1103
+ if (hasValidKey(config)) {
1104
+ {
1105
+ checkKeyStringCoercion(config.key);
1106
+ }
1107
+ key = "" + config.key;
1108
+ }
1109
+ if (hasValidRef(config)) {
1110
+ ref = config.ref;
1111
+ warnIfStringRefCannotBeAutoConverted(config, self);
1112
+ }
1113
+ for (propName in config) {
1114
+ if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
1115
+ props[propName] = config[propName];
1116
+ }
1117
+ }
1118
+ if (type && type.defaultProps) {
1119
+ var defaultProps = type.defaultProps;
1120
+ for (propName in defaultProps) {
1121
+ if (props[propName] === void 0) {
1122
+ props[propName] = defaultProps[propName];
1123
+ }
1124
+ }
1125
+ }
1126
+ if (key || ref) {
1127
+ var displayName = typeof type === "function" ? type.displayName || type.name || "Unknown" : type;
1128
+ if (key) {
1129
+ defineKeyPropWarningGetter(props, displayName);
1130
+ }
1131
+ if (ref) {
1132
+ defineRefPropWarningGetter(props, displayName);
1133
+ }
1134
+ }
1135
+ return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
1136
+ }
1137
+ }
1138
+ var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner;
1139
+ var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame;
1140
+ function setCurrentlyValidatingElement$1(element) {
1141
+ {
1142
+ if (element) {
1143
+ var owner = element._owner;
1144
+ var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
1145
+ ReactDebugCurrentFrame$1.setExtraStackFrame(stack);
1146
+ } else {
1147
+ ReactDebugCurrentFrame$1.setExtraStackFrame(null);
1148
+ }
1149
+ }
1150
+ }
1151
+ var propTypesMisspellWarningShown;
1152
+ {
1153
+ propTypesMisspellWarningShown = false;
1154
+ }
1155
+ function isValidElement(object) {
1156
+ {
1157
+ return typeof object === "object" && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
1158
+ }
1159
+ }
1160
+ function getDeclarationErrorAddendum() {
1161
+ {
1162
+ if (ReactCurrentOwner$1.current) {
1163
+ var name = getComponentNameFromType(ReactCurrentOwner$1.current.type);
1164
+ if (name) {
1165
+ return "\n\nCheck the render method of `" + name + "`.";
1166
+ }
1167
+ }
1168
+ return "";
1169
+ }
1170
+ }
1171
+ function getSourceInfoErrorAddendum(source) {
1172
+ {
1173
+ return "";
1174
+ }
1175
+ }
1176
+ var ownerHasKeyUseWarning = {};
1177
+ function getCurrentComponentErrorInfo(parentType) {
1178
+ {
1179
+ var info = getDeclarationErrorAddendum();
1180
+ if (!info) {
1181
+ var parentName = typeof parentType === "string" ? parentType : parentType.displayName || parentType.name;
1182
+ if (parentName) {
1183
+ info = "\n\nCheck the top-level render call using <" + parentName + ">.";
1184
+ }
1185
+ }
1186
+ return info;
1187
+ }
1188
+ }
1189
+ function validateExplicitKey(element, parentType) {
1190
+ {
1191
+ if (!element._store || element._store.validated || element.key != null) {
1192
+ return;
1193
+ }
1194
+ element._store.validated = true;
1195
+ var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
1196
+ if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
1197
+ return;
1198
+ }
1199
+ ownerHasKeyUseWarning[currentComponentErrorInfo] = true;
1200
+ var childOwner = "";
1201
+ if (element && element._owner && element._owner !== ReactCurrentOwner$1.current) {
1202
+ childOwner = " It was passed a child from " + getComponentNameFromType(element._owner.type) + ".";
1203
+ }
1204
+ setCurrentlyValidatingElement$1(element);
1205
+ error('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', currentComponentErrorInfo, childOwner);
1206
+ setCurrentlyValidatingElement$1(null);
1207
+ }
1208
+ }
1209
+ function validateChildKeys(node, parentType) {
1210
+ {
1211
+ if (typeof node !== "object") {
1212
+ return;
1213
+ }
1214
+ if (isArray(node)) {
1215
+ for (var i = 0; i < node.length; i++) {
1216
+ var child = node[i];
1217
+ if (isValidElement(child)) {
1218
+ validateExplicitKey(child, parentType);
1219
+ }
1220
+ }
1221
+ } else if (isValidElement(node)) {
1222
+ if (node._store) {
1223
+ node._store.validated = true;
1224
+ }
1225
+ } else if (node) {
1226
+ var iteratorFn = getIteratorFn(node);
1227
+ if (typeof iteratorFn === "function") {
1228
+ if (iteratorFn !== node.entries) {
1229
+ var iterator = iteratorFn.call(node);
1230
+ var step;
1231
+ while (!(step = iterator.next()).done) {
1232
+ if (isValidElement(step.value)) {
1233
+ validateExplicitKey(step.value, parentType);
1234
+ }
1235
+ }
1236
+ }
1237
+ }
1238
+ }
1239
+ }
1240
+ }
1241
+ function validatePropTypes(element) {
1242
+ {
1243
+ var type = element.type;
1244
+ if (type === null || type === void 0 || typeof type === "string") {
1245
+ return;
1246
+ }
1247
+ var propTypes;
1248
+ if (typeof type === "function") {
1249
+ propTypes = type.propTypes;
1250
+ } else if (typeof type === "object" && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here.
1251
+ // Inner props are checked in the reconciler.
1252
+ type.$$typeof === REACT_MEMO_TYPE)) {
1253
+ propTypes = type.propTypes;
1254
+ } else {
1255
+ return;
1256
+ }
1257
+ if (propTypes) {
1258
+ var name = getComponentNameFromType(type);
1259
+ checkPropTypes(propTypes, element.props, "prop", name, element);
1260
+ } else if (type.PropTypes !== void 0 && !propTypesMisspellWarningShown) {
1261
+ propTypesMisspellWarningShown = true;
1262
+ var _name = getComponentNameFromType(type);
1263
+ error("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", _name || "Unknown");
1264
+ }
1265
+ if (typeof type.getDefaultProps === "function" && !type.getDefaultProps.isReactClassApproved) {
1266
+ error("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
1267
+ }
1268
+ }
1269
+ }
1270
+ function validateFragmentProps(fragment) {
1271
+ {
1272
+ var keys = Object.keys(fragment.props);
1273
+ for (var i = 0; i < keys.length; i++) {
1274
+ var key = keys[i];
1275
+ if (key !== "children" && key !== "key") {
1276
+ setCurrentlyValidatingElement$1(fragment);
1277
+ error("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", key);
1278
+ setCurrentlyValidatingElement$1(null);
1279
+ break;
1280
+ }
1281
+ }
1282
+ if (fragment.ref !== null) {
1283
+ setCurrentlyValidatingElement$1(fragment);
1284
+ error("Invalid attribute `ref` supplied to `React.Fragment`.");
1285
+ setCurrentlyValidatingElement$1(null);
1286
+ }
1287
+ }
1288
+ }
1289
+ var didWarnAboutKeySpread = {};
1290
+ function jsxWithValidation(type, props, key, isStaticChildren, source, self) {
1291
+ {
1292
+ var validType = isValidElementType(type);
1293
+ if (!validType) {
1294
+ var info = "";
1295
+ if (type === void 0 || typeof type === "object" && type !== null && Object.keys(type).length === 0) {
1296
+ info += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.";
1297
+ }
1298
+ var sourceInfo = getSourceInfoErrorAddendum();
1299
+ if (sourceInfo) {
1300
+ info += sourceInfo;
1301
+ } else {
1302
+ info += getDeclarationErrorAddendum();
1303
+ }
1304
+ var typeString;
1305
+ if (type === null) {
1306
+ typeString = "null";
1307
+ } else if (isArray(type)) {
1308
+ typeString = "array";
1309
+ } else if (type !== void 0 && type.$$typeof === REACT_ELEMENT_TYPE) {
1310
+ typeString = "<" + (getComponentNameFromType(type.type) || "Unknown") + " />";
1311
+ info = " Did you accidentally export a JSX literal instead of a component?";
1312
+ } else {
1313
+ typeString = typeof type;
1314
+ }
1315
+ error("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", typeString, info);
1316
+ }
1317
+ var element = jsxDEV(type, props, key, source, self);
1318
+ if (element == null) {
1319
+ return element;
1320
+ }
1321
+ if (validType) {
1322
+ var children = props.children;
1323
+ if (children !== void 0) {
1324
+ if (isStaticChildren) {
1325
+ if (isArray(children)) {
1326
+ for (var i = 0; i < children.length; i++) {
1327
+ validateChildKeys(children[i], type);
1328
+ }
1329
+ if (Object.freeze) {
1330
+ Object.freeze(children);
1331
+ }
1332
+ } else {
1333
+ error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
1334
+ }
1335
+ } else {
1336
+ validateChildKeys(children, type);
1337
+ }
1338
+ }
1339
+ }
1340
+ {
1341
+ if (hasOwnProperty.call(props, "key")) {
1342
+ var componentName = getComponentNameFromType(type);
1343
+ var keys = Object.keys(props).filter(function(k) {
1344
+ return k !== "key";
1345
+ });
1346
+ var beforeExample = keys.length > 0 ? "{key: someKey, " + keys.join(": ..., ") + ": ...}" : "{key: someKey}";
1347
+ if (!didWarnAboutKeySpread[componentName + beforeExample]) {
1348
+ var afterExample = keys.length > 0 ? "{" + keys.join(": ..., ") + ": ...}" : "{}";
1349
+ error('A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />', beforeExample, componentName, afterExample, componentName);
1350
+ didWarnAboutKeySpread[componentName + beforeExample] = true;
1351
+ }
1352
+ }
1353
+ }
1354
+ if (type === REACT_FRAGMENT_TYPE) {
1355
+ validateFragmentProps(element);
1356
+ } else {
1357
+ validatePropTypes(element);
1358
+ }
1359
+ return element;
1360
+ }
1361
+ }
1362
+ function jsxWithValidationStatic(type, props, key) {
1363
+ {
1364
+ return jsxWithValidation(type, props, key, true);
1365
+ }
1366
+ }
1367
+ function jsxWithValidationDynamic(type, props, key) {
1368
+ {
1369
+ return jsxWithValidation(type, props, key, false);
1370
+ }
1371
+ }
1372
+ var jsx = jsxWithValidationDynamic;
1373
+ var jsxs = jsxWithValidationStatic;
1374
+ reactJsxRuntime_development.Fragment = REACT_FRAGMENT_TYPE;
1375
+ reactJsxRuntime_development.jsx = jsx;
1376
+ reactJsxRuntime_development.jsxs = jsxs;
1377
+ })();
1378
+ }
1379
+ return reactJsxRuntime_development;
1380
+ }
1381
+ if (process.env.NODE_ENV === "production") {
1382
+ jsxRuntime.exports = requireReactJsxRuntime_production_min();
1383
+ } else {
1384
+ jsxRuntime.exports = requireReactJsxRuntime_development();
1385
+ }
1386
+ var jsxRuntimeExports = jsxRuntime.exports;
1387
+ const AnalyticsContext = createContext(null);
1388
+ const useAnalytics = () => {
1389
+ const context = useContext(AnalyticsContext);
1390
+ if (!context)
1391
+ throw new Error("useAnalytics must be used within EngageProProvider");
1392
+ return context;
1393
+ };
1394
+ const isSensitive = (el) => {
1395
+ const sensitive = /password|cvc|card|cc-num|ssn|credit|hidden/i;
1396
+ return el.getAttribute("type") === "password" || el.getAttribute("type") === "hidden" || sensitive.test(el.getAttribute("name") || el.id || "");
1397
+ };
1398
+ const analyzeIntent = (el) => {
1399
+ let text = (el.innerText || el.value || el.getAttribute("aria-label") || "").trim();
1400
+ if (!text) {
1401
+ const img = el.querySelector("img");
1402
+ if (img && img.alt) text = img.alt;
1403
+ const svgTitle = el.querySelector("title");
1404
+ if (svgTitle) text = svgTitle.textContent || "";
1405
+ }
1406
+ const label = text.slice(0, 100);
1407
+ const lowerText = label.toLowerCase();
1408
+ const id = (el.id || "").toLowerCase();
1409
+ const href = el.href || "";
1410
+ if (/add to (cart|bag)|buy now/.test(lowerText) || id.includes("add-to-cart")) {
1411
+ return {
1412
+ standard: "ADD_TO_CART",
1413
+ intent: "commerce",
1414
+ label,
1415
+ confidence: 0.9
1416
+ };
1417
+ }
1418
+ if (/checkout|proceed/.test(lowerText) || href.includes("/checkout")) {
1419
+ return {
1420
+ standard: "INITIATE_CHECKOUT",
1421
+ intent: "commerce",
1422
+ label,
1423
+ confidence: 0.9
1424
+ };
1425
+ }
1426
+ if (/place order|pay now/.test(lowerText) || id.includes("place-order")) {
1427
+ return {
1428
+ standard: "PURCHASE",
1429
+ intent: "commerce",
1430
+ label,
1431
+ confidence: 0.95
1432
+ };
1433
+ }
1434
+ if (/cancel order/.test(lowerText) || id.includes("cancel")) {
1435
+ return {
1436
+ standard: "ORDER_CANCEL",
1437
+ intent: "lifecycle",
1438
+ label,
1439
+ confidence: 0.85
1440
+ };
1441
+ }
1442
+ if (/refund|return/.test(lowerText) || id.includes("refund")) {
1443
+ return {
1444
+ standard: "ORDER_REFUND",
1445
+ intent: "lifecycle",
1446
+ label,
1447
+ confidence: 0.85
1448
+ };
1449
+ }
1450
+ if (/track package|shipping/.test(lowerText)) {
1451
+ return {
1452
+ standard: "TRACK_PACKAGE",
1453
+ intent: "lifecycle",
1454
+ label,
1455
+ confidence: 0.8
1456
+ };
1457
+ }
1458
+ if (/write review/.test(lowerText) || lowerText.includes("star") && /^[1-5]/.test(lowerText)) {
1459
+ return {
1460
+ standard: "RATE_PRODUCT",
1461
+ intent: "engagement",
1462
+ label,
1463
+ confidence: 0.8
1464
+ };
1465
+ }
1466
+ if (lowerText.includes("search") || id.includes("search")) {
1467
+ return { standard: "SEARCH", intent: "search", label, confidence: 0.7 };
1468
+ }
1469
+ return { standard: "GENERIC", intent: "interaction", label, confidence: 0.5 };
1470
+ };
1471
+ const EngageProProvider = ({
1472
+ children,
1473
+ ...config
1474
+ }) => {
1475
+ const analyticsRef = useRef(null);
1476
+ const rageClickBuffer = useRef(null);
1477
+ if (!analyticsRef.current) {
1478
+ analyticsRef.current = new EngagePro(config);
1479
+ }
1480
+ const analytics = analyticsRef.current;
1481
+ useEffect(() => {
1482
+ if (!config.tracking.autoTrack) return;
1483
+ const handleInteraction = (e) => {
1484
+ const target = e.target;
1485
+ const el = target.closest(
1486
+ 'button, a, input[type="submit"], [data-track], .clickable'
1487
+ );
1488
+ if (el) {
1489
+ const now = Date.now();
1490
+ const buffer = rageClickBuffer.current;
1491
+ if (buffer && buffer.el === el && now - buffer.ts < 500) {
1492
+ buffer.count++;
1493
+ buffer.ts = now;
1494
+ if (buffer.count === 3) {
1495
+ analytics.track(
1496
+ "Rage Click detected",
1497
+ { element: el.tagName },
1498
+ {
1499
+ standardEvent: "RAGE_CLICK",
1500
+ intent: "frustration",
1501
+ confidence: 1
1502
+ }
1503
+ );
1504
+ rageClickBuffer.current = null;
1505
+ }
1506
+ } else {
1507
+ rageClickBuffer.current = { el, count: 1, ts: now };
1508
+ }
1509
+ const analysis = analyzeIntent(el);
1510
+ const isLink = el.tagName === "A";
1511
+ analytics.track(
1512
+ "Interaction",
1513
+ {
1514
+ element: el.tagName.toLowerCase(),
1515
+ id: el.id,
1516
+ destination: isLink ? el.href : void 0
1517
+ },
1518
+ {
1519
+ standardEvent: analysis.standard,
1520
+ intent: analysis.intent,
1521
+ rawLabel: analysis.label,
1522
+ confidence: analysis.confidence
1523
+ }
1524
+ );
1525
+ }
1526
+ };
1527
+ const handleInput = (e) => {
1528
+ const el = e.target;
1529
+ if (isSensitive(el)) return;
1530
+ if (e.type === "focusin" && !el.dataset.tracked) {
1531
+ el.dataset.tracked = "true";
1532
+ analytics.track(
1533
+ "Form Start",
1534
+ { field: el.name || el.id },
1535
+ { standardEvent: "FORM_START", intent: "identity" }
1536
+ );
1537
+ }
1538
+ };
1539
+ const trackPage = () => {
1540
+ const params = new URLSearchParams(window.location.search);
1541
+ if (params.has("q")) {
1542
+ analytics.track(
1543
+ "Search Query",
1544
+ { query: params.get("q") },
1545
+ { standardEvent: "SEARCH", intent: "search" }
1546
+ );
1547
+ }
1548
+ requestAnimationFrame(() => analytics.page());
1549
+ };
1550
+ const originalPush = history.pushState;
1551
+ history.pushState = (...args) => {
1552
+ originalPush.apply(history, args);
1553
+ trackPage();
1554
+ };
1555
+ window.addEventListener("popstate", trackPage);
1556
+ window.addEventListener("click", handleInteraction, true);
1557
+ window.addEventListener("focusin", handleInput, true);
1558
+ trackPage();
1559
+ return () => {
1560
+ window.removeEventListener("popstate", trackPage);
1561
+ window.removeEventListener("click", handleInteraction, true);
1562
+ window.removeEventListener("focusin", handleInput, true);
1563
+ };
1564
+ }, [config.tracking.autoTrack]);
1565
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(AnalyticsContext.Provider, { value: analytics, children });
1566
+ };
1567
+ let instance = null;
1568
+ const init = (config) => {
1569
+ if (!instance) {
1570
+ instance = new EngagePro(config);
1571
+ }
1572
+ return instance;
1573
+ };
1574
+ export {
1575
+ EngageProProvider,
1576
+ EngagePro as default,
1577
+ init,
1578
+ useAnalytics
1579
+ };