@incodetech/tri-sdk 0.1.1 → 0.1.2-dev-20260528

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.
Files changed (47) hide show
  1. package/dist/bundle-analysis.html +4950 -0
  2. package/dist/chunks/index-BAwek9Id.cjs +489 -0
  3. package/dist/chunks/index-BAwek9Id.cjs.map +1 -0
  4. package/dist/chunks/index-BBnHO5vA.js +477 -0
  5. package/dist/chunks/index-BBnHO5vA.js.map +1 -0
  6. package/dist/chunks/index-BMVAKptw.cjs +432 -0
  7. package/dist/chunks/index-BMVAKptw.cjs.map +1 -0
  8. package/dist/chunks/index-B_sPgtA6.cjs +489 -0
  9. package/dist/chunks/index-B_sPgtA6.cjs.map +1 -0
  10. package/dist/chunks/index-BlclLEsV.js +420 -0
  11. package/dist/chunks/index-BlclLEsV.js.map +1 -0
  12. package/dist/chunks/index-CECrIW-A.js +420 -0
  13. package/dist/chunks/index-CECrIW-A.js.map +1 -0
  14. package/dist/chunks/index-DUZ-lBzx.js +477 -0
  15. package/dist/chunks/index-DUZ-lBzx.js.map +1 -0
  16. package/dist/chunks/index-SQXEe_Yi.cjs +432 -0
  17. package/dist/chunks/index-SQXEe_Yi.cjs.map +1 -0
  18. package/dist/chunks/index-kx-dpbK_.cjs +432 -0
  19. package/dist/chunks/index-kx-dpbK_.cjs.map +1 -0
  20. package/dist/chunks/index-uSwsY9-F.js +420 -0
  21. package/dist/chunks/index-uSwsY9-F.js.map +1 -0
  22. package/dist/chunks/start-BnvikGDT.cjs +5059 -0
  23. package/dist/chunks/start-BnvikGDT.cjs.map +1 -0
  24. package/dist/chunks/start-CMqC8j2A.cjs +5561 -0
  25. package/dist/chunks/start-CMqC8j2A.cjs.map +1 -0
  26. package/dist/chunks/start-CkLlbFOM.cjs +5554 -0
  27. package/dist/chunks/start-CkLlbFOM.cjs.map +1 -0
  28. package/dist/chunks/start-CwAEBqvW.js +5057 -0
  29. package/dist/chunks/start-CwAEBqvW.js.map +1 -0
  30. package/dist/chunks/start-CymdUpX5.js +5060 -0
  31. package/dist/chunks/start-CymdUpX5.js.map +1 -0
  32. package/dist/chunks/start-DTFRIfeO.js +5552 -0
  33. package/dist/chunks/start-DTFRIfeO.js.map +1 -0
  34. package/dist/chunks/start-Dpgr8IbP.js +5559 -0
  35. package/dist/chunks/start-Dpgr8IbP.js.map +1 -0
  36. package/dist/chunks/start-Dtnxf7k4.cjs +5554 -0
  37. package/dist/chunks/start-Dtnxf7k4.cjs.map +1 -0
  38. package/dist/chunks/start-DwQtOigF.cjs +5062 -0
  39. package/dist/chunks/start-DwQtOigF.cjs.map +1 -0
  40. package/dist/chunks/start-MKWGpbIO.js +5552 -0
  41. package/dist/chunks/start-MKWGpbIO.js.map +1 -0
  42. package/dist/index.d.ts +2 -2
  43. package/dist/tri.cjs.js +1 -1
  44. package/dist/tri.esm.js +1 -1
  45. package/dist/tri.umd.js +156 -591
  46. package/dist/tri.umd.js.map +1 -1
  47. package/package.json +1 -1
@@ -0,0 +1,489 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * @module lib/logger
5
+ *
6
+ * @description
7
+ * Singleton logger for the TRI SDK. This is the **only** sanctioned site for
8
+ * `console.*` calls inside `packages/core`. All other modules must import and
9
+ * use the exported `logger` instance rather than calling `console` directly.
10
+ *
11
+ * ### Debug gating
12
+ * Non-fatal methods (`warn`, `error`, `info`) are no-ops when `DEBUG` is
13
+ * `false`. Set `logger.DEBUG = true` — typically driven by the `debug` field
14
+ * in `TRIConfig` — to activate them. No string concatenation happens in the
15
+ * fast path (early return before any allocation).
16
+ *
17
+ * `fatal` always emits regardless of `DEBUG`; use it only for messages that
18
+ * must surface in production (hard misconfigurations, blocked environments).
19
+ *
20
+ * ### Message format
21
+ * `[prefix] message` — prefix is wrapped in square brackets and prepended to
22
+ * the message with a single space. Extra `args` are forwarded to the underlying
23
+ * `console.*` method unchanged so error objects and context values render with
24
+ * full browser-console expansion.
25
+ */
26
+ const SDK_PREFIX = 'TRI';
27
+ class Logger {
28
+ constructor() {
29
+ this.debugValue = false;
30
+ }
31
+ /** Returns the singleton Logger instance. */
32
+ static get instance() {
33
+ if (!Logger.singleton) {
34
+ Logger.singleton = new Logger();
35
+ }
36
+ return Logger.singleton;
37
+ }
38
+ /** Exposed read-only view of the current debug state. */
39
+ get _DEBUG() {
40
+ return this.debugValue;
41
+ }
42
+ get DEBUG() {
43
+ return this.debugValue;
44
+ }
45
+ set DEBUG(value) {
46
+ this.debugValue = value;
47
+ }
48
+ /** @inheritdoc LoggerInterface.warn */
49
+ warn(prefix, message, ...args) {
50
+ if (!this.debugValue)
51
+ return;
52
+ this._log('warn', prefix, message, ...args);
53
+ }
54
+ /** @inheritdoc LoggerInterface.error */
55
+ error(prefix, message, ...args) {
56
+ if (!this.debugValue)
57
+ return;
58
+ this._log('error', prefix, message, ...args);
59
+ }
60
+ /** @inheritdoc LoggerInterface.info */
61
+ info(prefix, message, ...args) {
62
+ if (!this.debugValue)
63
+ return;
64
+ this._log('info', prefix, message, ...args);
65
+ }
66
+ /** @inheritdoc LoggerInterface.fatal */
67
+ fatal(level, prefix, message, ...args) {
68
+ this._log(level, prefix, message, ...args);
69
+ }
70
+ _log(level, prefix, message, ...args) {
71
+ const modulePrefix = prefix ? `[${prefix}]` : '';
72
+ console[level](`[${SDK_PREFIX}]${modulePrefix} ${message}`, ...args);
73
+ }
74
+ }
75
+ /** Singleton logger instance. Import and use this throughout `packages/core`. */
76
+ const logger = Logger.instance;
77
+
78
+ /**
79
+ * @module sdk/internal/env
80
+ *
81
+ * @description
82
+ * Environment constants and URL resolver for the SDK preflight. This module
83
+ * is part of the **static bundle** — it imports only primitive types and the
84
+ * logger singleton, so it carries no collector-factory cost.
85
+ *
86
+ * Anything that must run before the lazy chunk loads (e.g. `sdk.ts` deciding
87
+ * whether to even fetch the bundle) should import from here rather than from
88
+ * the full `sdk/constants` module.
89
+ *
90
+ * @internal
91
+ */
92
+ /** How long (ms) to wait for a dynamic `import()` before giving up. */
93
+ const DYNAMIC_IMPORT_TIMEOUT_MS = 10000;
94
+ /** Default value for the `debug` flag when the host omits it. */
95
+ const DEFAULT_DEBUG = false;
96
+ /** Default `apiVersion` string when the host omits it. */
97
+ const DEFAULT_API_VERSION = '1.0';
98
+ /**
99
+ * Lookup from a `TriEnv` value to its corresponding base API URL.
100
+ * Entries with an empty string are **not yet provisioned**; hosts attempting
101
+ * to use them will receive a fatal error at SDK start.
102
+ */
103
+ const ENV_TO_BASE_API_URL_LOOKUP = {
104
+ STAGE_K8S: 'https://falcon-ingest-k8s.stage.incodetest.com',
105
+ SAAS: '',
106
+ STAGE: '',
107
+ DEMO: '',
108
+ DEMO_K8S: ''
109
+ };
110
+ /**
111
+ * All known `TriEnv` keys (including those not yet provisioned with a URL).
112
+ * Used to distinguish a typo/unsupported env from a known-but-unprovisioned one.
113
+ */
114
+ const SUPPORTED_ENVS = Object.keys(ENV_TO_BASE_API_URL_LOOKUP);
115
+ /**
116
+ * Base API URLs that are fully provisioned and accepted at SDK start.
117
+ * Derived from `ENV_TO_BASE_API_URL_LOOKUP` by filtering empty strings.
118
+ */
119
+ const SUPPORTED_API_URLS = Object.values(ENV_TO_BASE_API_URL_LOOKUP).filter(Boolean);
120
+ /**
121
+ * Resolves a `TriEnv` value to its base API URL.
122
+ *
123
+ * Returns `undefined` (and logs a fatal) when:
124
+ * - the env is not a known `TriEnv` key, or
125
+ * - the env is known but not yet provisioned (empty URL).
126
+ */
127
+ function resolveBaseApiURLFromEnv(env) {
128
+ if (!SUPPORTED_ENVS.includes(env)) {
129
+ logger.fatal('error', 'SDK', 'Provided environment is not supported:', env, 'Supported environments are:', SUPPORTED_ENVS.join(', '));
130
+ return undefined;
131
+ }
132
+ const url = ENV_TO_BASE_API_URL_LOOKUP[env];
133
+ if (!url) {
134
+ logger.fatal('error', 'SDK', `env "${env}" is not yet provisioned with a base URL.`);
135
+ return undefined;
136
+ }
137
+ return url;
138
+ }
139
+
140
+ /**
141
+ * @module sdk/internal/preflight-config
142
+ *
143
+ * @description
144
+ * Lightweight config validator that runs in the **static bundle** before the
145
+ * lazy chunk is ever fetched. Its only job is to extract the three values
146
+ * needed for the collection-status preflight check (`apiKey`, `baseApiURL`,
147
+ * `debug`) and return them — or log a fatal and return `null` when the host
148
+ * config is unusable.
149
+ *
150
+ * The full `resolveTRIConfig` function (in `sdk/helpers.ts`) performs a
151
+ * superset of this validation and lives in the lazy chunk. This module exists
152
+ * solely to keep the static bundle free of `COLLECTORS_CONFIG` and every
153
+ * transitively-imported collector factory.
154
+ *
155
+ * @internal
156
+ */
157
+ /**
158
+ * Extracts and validates the preflight-critical fields from the host-supplied
159
+ * config. Returns `null` (with a fatal log) when any required field is missing
160
+ * or the resolved URL is not provisioned.
161
+ */
162
+ function resolvePreflightConfig(config) {
163
+ if (!config?.apiKey) {
164
+ logger.fatal('error', 'SDK', 'apiKey is required.');
165
+ return null;
166
+ }
167
+ let baseApiURL;
168
+ if (config.apiURL) {
169
+ if (!SUPPORTED_API_URLS.includes(config.apiURL)) {
170
+ logger.fatal('error', 'SDK', 'Provided apiURL is not supported:', config.apiURL, 'Supported API URLs are:', SUPPORTED_API_URLS.join(', '));
171
+ return null;
172
+ }
173
+ baseApiURL = config.apiURL;
174
+ }
175
+ else if (config.env) {
176
+ baseApiURL = resolveBaseApiURLFromEnv(config.env);
177
+ }
178
+ if (!baseApiURL) {
179
+ logger.fatal('error', 'SDK', "Couldn't initialise SDK — neither apiURL nor env were provided, or the provided value has no provisioned URL.");
180
+ return null;
181
+ }
182
+ return {
183
+ apiKey: config.apiKey,
184
+ baseApiURL,
185
+ debug: config.debug ?? DEFAULT_DEBUG,
186
+ };
187
+ }
188
+
189
+ // Pin timer globals at module evaluation time — same hazard model as `_fetch` in
190
+ // lib/http/http.ts. Host APM SDKs and instrumentation libraries routinely wrap
191
+ // setTimeout; capturing the originals ensures our HTTP timeout and retry timers
192
+ // are immune to those patches.
193
+ const _setTimeout = globalThis.setTimeout.bind(globalThis);
194
+ const _clearTimeout = globalThis.clearTimeout.bind(globalThis);
195
+ function safeSync(fn, finallyFn) {
196
+ try {
197
+ return fn();
198
+ }
199
+ catch (error) {
200
+ logger.warn('utils', 'safeSync swallowed error:', error);
201
+ }
202
+ finally {
203
+ }
204
+ }
205
+ async function safeAsync(fn) {
206
+ try {
207
+ return await fn();
208
+ }
209
+ catch (error) {
210
+ logger.warn('utils', 'safeAsync swallowed error:', error);
211
+ }
212
+ }
213
+ function safeListener(fn) {
214
+ return (event) => safeSync(() => fn(event));
215
+ }
216
+ function safeTimer(fn) {
217
+ return (...args) => {
218
+ try {
219
+ fn(...args);
220
+ }
221
+ catch (error) {
222
+ logger.warn('utils', 'safeTimer swallowed error:', error);
223
+ }
224
+ };
225
+ }
226
+ function safeSetTimeout(fn, delay) {
227
+ return _setTimeout(safeTimer(fn), delay);
228
+ }
229
+ function safeClearTimeout(id) {
230
+ if (id === null)
231
+ return;
232
+ try {
233
+ _clearTimeout(id);
234
+ }
235
+ catch (error) {
236
+ logger.warn('utils', 'safeClearTimeout swallowed error:', error);
237
+ }
238
+ }
239
+
240
+ /**
241
+ * @module sdk/internal/collection-status
242
+ *
243
+ * @description
244
+ * Preflight check — queries the backend to decide whether the SDK should load
245
+ * its full manager bundle for this session.
246
+ *
247
+ * ### Sanctioned `fetch` exception
248
+ * CLAUDE.md prohibits calling `fetch` outside `src/transport/`. This module is
249
+ * the **only** approved exception outside transport, analogous to the History
250
+ * API wrap in the navigation collector. The preflight runs before the transport
251
+ * layer exists (the lazy chunk hasn't loaded yet), so it must call fetch
252
+ * directly. `_fetch` is captured at module-evaluation time to survive host-side
253
+ * patching of `globalThis.fetch` (same hazard model as `lib/http/http.ts`).
254
+ *
255
+ * @internal
256
+ */
257
+ const _fetch = globalThis.fetch.bind(globalThis);
258
+ const TIMEOUT_MS = 10000;
259
+ /**
260
+ * Queries `GET {apiURL}/api/v1/events/collection-status` and returns whether the backend has
261
+ * collection enabled for this API key.
262
+ *
263
+ * Returns `false` on any network error, non-OK response, or timeout so that a
264
+ * hung or unreachable backend silently disables the SDK rather than blocking the
265
+ * host application.
266
+ */
267
+ async function getCollectionStatus(apiURL, apiKey) {
268
+ const controller = new AbortController();
269
+ const timer = setTimeout(() => controller.abort(), TIMEOUT_MS);
270
+ try {
271
+ const base = apiURL.replace(/\/$/, '');
272
+ const response = await _fetch(`${base}/api/v1/events/collection-status`, {
273
+ method: 'GET',
274
+ headers: { 'Content-Type': 'application/json', 'x-api-key': apiKey },
275
+ signal: controller.signal
276
+ });
277
+ if (!response.ok) {
278
+ return false;
279
+ }
280
+ const data = (await response.json());
281
+ return Boolean(data.eventsCollectionEnabled);
282
+ }
283
+ catch (error) {
284
+ logger.warn('CollectionStatus', 'failed to load collection status', error);
285
+ return false;
286
+ }
287
+ finally {
288
+ clearTimeout(timer);
289
+ }
290
+ }
291
+
292
+ /**
293
+ * Singleton entry-point for the TRI SDK.
294
+ *
295
+ * Obtain the instance via `TRI.instance`; the constructor is private.
296
+ *
297
+ * ### Life-cycle states
298
+ * The instance moves through three states:
299
+ * - `'idle'` — not started, or fully stopped.
300
+ * - `'starting'` — `start()` has been called; preflight and lazy bundle load in progress.
301
+ * - `'started'` — all managers are running and `reportEvent()` is active.
302
+ *
303
+ * ### Never throws
304
+ * All public methods are fire-and-forget. Errors are logged via `logger` and
305
+ * swallowed so the host application is never disrupted.
306
+ *
307
+ * ### Bundle split
308
+ * Only the preflight config validator and collection-status check live in the
309
+ * static bundle. The full manager wiring (`internal/start.ts`) is dynamically
310
+ * imported only when the backend confirms collection is enabled, keeping the
311
+ * initial page-load cost minimal.
312
+ */
313
+ let TRI$1 = class TRI {
314
+ constructor() {
315
+ /**
316
+ * Monotonically-increasing counter incremented by every `start()` and
317
+ * `stop()` call. Each in-flight `runStart` captures its own generation value
318
+ * and bails out after every `await` if the counter has moved on, preventing
319
+ * orphaned manager instances from being installed after a concurrent stop.
320
+ */
321
+ this.startGeneration = 0;
322
+ this.startState = 'idle';
323
+ // All manager fields are set after the lazy chunk loads successfully.
324
+ this.falconServiceManager = null;
325
+ this.activityManager = null;
326
+ this.transportManager = null;
327
+ this.tabManager = null;
328
+ this.lifecycleManager = null;
329
+ this.collectorManager = null;
330
+ this.eventReportManager = null;
331
+ }
332
+ static get instance() {
333
+ if (!TRI._instance) {
334
+ TRI._instance = new TRI();
335
+ }
336
+ return TRI._instance;
337
+ }
338
+ /**
339
+ * @description Starts the TRI SDK. Fire-and-forget and idempotent — a second
340
+ * call while the SDK is starting or already started is a no-op. Checks the
341
+ * backend `/collection-status` endpoint and only loads the full manager bundle
342
+ * when collection is enabled. Safe to call in SSR environments; if `document`
343
+ * is unavailable the function logs a fatal and returns without throwing.
344
+ */
345
+ start(config) {
346
+ if (this.startState !== 'idle') {
347
+ logger.warn('Start', 'start() called more than once — ignoring.');
348
+ return;
349
+ }
350
+ this.startState = 'starting';
351
+ const generation = ++this.startGeneration;
352
+ void this._start(config, generation);
353
+ }
354
+ /**
355
+ * @description Stops all collectors, flushes pending events, and tears down
356
+ * every manager. Safe to call more than once. After `stop()`, `start()` may be
357
+ * called again with a fresh config. Any in-flight `start()` is cancelled at
358
+ * the next async checkpoint.
359
+ */
360
+ stop() {
361
+ ++this.startGeneration;
362
+ this.startState = 'idle';
363
+ this.lifecycleManager?.stop();
364
+ this.lifecycleManager = null;
365
+ this.activityManager?.stop();
366
+ this.activityManager = null;
367
+ this.transportManager?.stop();
368
+ this.transportManager = null;
369
+ this.tabManager?.stop();
370
+ this.tabManager = null;
371
+ this.collectorManager?.stop();
372
+ this.collectorManager = null;
373
+ this.eventReportManager?.stop();
374
+ this.eventReportManager = null;
375
+ this.falconServiceManager = null;
376
+ logger.DEBUG = DEFAULT_DEBUG;
377
+ }
378
+ /**
379
+ * @description Reports a host-defined event to the TRI backend. Fire-and-forget —
380
+ * never throws and never returns a promise the host must handle. Drops the
381
+ * event silently (with a dev warning) if called before `start` completes.
382
+ */
383
+ reportEvent(name, metadata) {
384
+ if (this._shouldEarlyEscapeReport()) {
385
+ return;
386
+ }
387
+ void safeAsync(() => this.eventReportManager.report(name, metadata));
388
+ }
389
+ async _start(config, generation) {
390
+ if (typeof document === 'undefined') {
391
+ logger.fatal('error', 'Start', 'start() called in a non-browser environment. The SDK will not start.');
392
+ this.startState = 'idle';
393
+ return;
394
+ }
395
+ // resolvePreflightConfig runs entirely in the static bundle — no collector
396
+ // factories are loaded at this point.
397
+ const preflight = resolvePreflightConfig(config);
398
+ if (!preflight) {
399
+ this.startState = 'idle';
400
+ return;
401
+ }
402
+ const enabled = await getCollectionStatus(preflight.baseApiURL, preflight.apiKey);
403
+ // Bail if stop() or a concurrent start() invalidated this run.
404
+ if (this.startGeneration !== generation) {
405
+ return;
406
+ }
407
+ if (!enabled) {
408
+ this.startState = 'idle';
409
+ return;
410
+ }
411
+ // Flip DEBUG only after the SDK is confirmed to start.
412
+ logger.DEBUG = preflight.debug;
413
+ // Dynamically import the lazy chunk with a hard timeout so a slow/dead
414
+ // CDN does not hang the host application indefinitely.
415
+ let startModule;
416
+ try {
417
+ startModule = await Promise.race([
418
+ Promise.resolve().then(function () { return require('./start-DwQtOigF.cjs'); }),
419
+ new Promise((_, reject) => setTimeout(() => reject(new Error('dynamic import timed out')), DYNAMIC_IMPORT_TIMEOUT_MS))
420
+ ]);
421
+ }
422
+ catch (error) {
423
+ logger.error('Start', 'Failed to load manager bundle:', error);
424
+ if (this.startGeneration === generation) {
425
+ this.startState = 'idle';
426
+ }
427
+ return;
428
+ }
429
+ if (this.startGeneration !== generation) {
430
+ return;
431
+ }
432
+ // The lazy chunk receives the raw config and runs the full resolver internally.
433
+ const managers = await startModule.start(config);
434
+ if (this.startGeneration !== generation) {
435
+ // A concurrent stop() (or new start()) raced us — discard what we built.
436
+ if (managers) {
437
+ managers.lifecycleManager?.stop();
438
+ managers.tabManager?.stop();
439
+ managers.transportManager?.stop();
440
+ void managers.activityManager?.stop();
441
+ }
442
+ return;
443
+ }
444
+ if (!managers) {
445
+ // internal/start.ts already logged the reason.
446
+ this.startState = 'idle';
447
+ return;
448
+ }
449
+ this.falconServiceManager = managers.falconServiceManager;
450
+ this.activityManager = managers.activityManager;
451
+ this.transportManager = managers.transportManager;
452
+ this.tabManager = managers.tabManager;
453
+ this.lifecycleManager = managers.lifecycleManager;
454
+ this.collectorManager = managers.collectorManager;
455
+ this.eventReportManager = managers.eventReportManager;
456
+ this.startState = 'started';
457
+ }
458
+ /**
459
+ * Returns `true` (and logs a dev warning) when `reportEvent()` should be a
460
+ * no-op. Guards against calling before the SDK is fully started, or when
461
+ * the `eventReportManager` is unexpectedly absent.
462
+ */
463
+ _shouldEarlyEscapeReport() {
464
+ if (this.startState !== 'started') {
465
+ logger.warn('ReportEvent', 'reportEvent() called before start() completed.');
466
+ return true;
467
+ }
468
+ if (!this.eventReportManager) {
469
+ logger.warn('ReportEvent', 'eventReportManager not available.');
470
+ return true;
471
+ }
472
+ return false;
473
+ }
474
+ };
475
+
476
+ const TRI = TRI$1.instance;
477
+
478
+ exports.DEFAULT_API_VERSION = DEFAULT_API_VERSION;
479
+ exports.DEFAULT_DEBUG = DEFAULT_DEBUG;
480
+ exports.SUPPORTED_API_URLS = SUPPORTED_API_URLS;
481
+ exports.TRI = TRI;
482
+ exports.logger = logger;
483
+ exports.resolveBaseApiURLFromEnv = resolveBaseApiURLFromEnv;
484
+ exports.safeAsync = safeAsync;
485
+ exports.safeClearTimeout = safeClearTimeout;
486
+ exports.safeListener = safeListener;
487
+ exports.safeSetTimeout = safeSetTimeout;
488
+ exports.safeSync = safeSync;
489
+ //# sourceMappingURL=index-B_sPgtA6.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-B_sPgtA6.cjs","sources":["../../src/lib/logger/logger.ts","../../src/sdk/internal/env.ts","../../src/sdk/internal/preflight-config.ts","../../src/utils/fire-and-forget.ts","../../src/sdk/internal/collection-status.ts","../../src/sdk/sdk.ts","../../src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null],"names":["TRIClass"],"mappings":";;AAA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