@utk09/ui-observability 0.1.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.
Files changed (62) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +217 -0
  3. package/dist/bus/bus.d.ts +134 -0
  4. package/dist/bus/links.d.ts +106 -0
  5. package/dist/capture/errors.d.ts +34 -0
  6. package/dist/capture/interactions.d.ts +29 -0
  7. package/dist/capture/network.d.ts +40 -0
  8. package/dist/capture/types.d.ts +78 -0
  9. package/dist/capture/web-vitals.d.ts +21 -0
  10. package/dist/constants-D8-4Ged5.cjs +2 -0
  11. package/dist/constants-D8-4Ged5.cjs.map +1 -0
  12. package/dist/constants-DbvMIryP.js +110 -0
  13. package/dist/constants-DbvMIryP.js.map +1 -0
  14. package/dist/constants.d.ts +339 -0
  15. package/dist/core/breadcrumbs.d.ts +48 -0
  16. package/dist/core/config.d.ts +16 -0
  17. package/dist/core/context.d.ts +35 -0
  18. package/dist/core/diagnostics.d.ts +76 -0
  19. package/dist/core/journey.d.ts +112 -0
  20. package/dist/core/logger.d.ts +117 -0
  21. package/dist/core/pipeline.d.ts +75 -0
  22. package/dist/core/record.d.ts +72 -0
  23. package/dist/core/runtime.d.ts +146 -0
  24. package/dist/core/sampling.d.ts +9 -0
  25. package/dist/index.cjs +4 -0
  26. package/dist/index.cjs.map +1 -0
  27. package/dist/index.d.ts +167 -0
  28. package/dist/index.js +2577 -0
  29. package/dist/index.js.map +1 -0
  30. package/dist/indexeddb-storage-DvsvCUlO.cjs +2 -0
  31. package/dist/indexeddb-storage-DvsvCUlO.cjs.map +1 -0
  32. package/dist/indexeddb-storage-DwpCDRnX.js +88 -0
  33. package/dist/indexeddb-storage-DwpCDRnX.js.map +1 -0
  34. package/dist/models/batch.d.ts +22 -0
  35. package/dist/models/bus.d.ts +97 -0
  36. package/dist/models/config.d.ts +528 -0
  37. package/dist/models/log-record.d.ts +54 -0
  38. package/dist/models/serializer.d.ts +23 -0
  39. package/dist/models/storage.d.ts +62 -0
  40. package/dist/storage/emergency-queue.d.ts +16 -0
  41. package/dist/storage/factory.d.ts +13 -0
  42. package/dist/storage/indexeddb-storage.d.ts +69 -0
  43. package/dist/storage/keys.d.ts +8 -0
  44. package/dist/storage/local-storage.d.ts +80 -0
  45. package/dist/storage/memory-storage.d.ts +52 -0
  46. package/dist/transport/compression.d.ts +7 -0
  47. package/dist/transport/errors.d.ts +29 -0
  48. package/dist/transport/exit-flush.d.ts +63 -0
  49. package/dist/transport/http-transport.d.ts +63 -0
  50. package/dist/transport/retry-engine.d.ts +69 -0
  51. package/dist/transport/serializers/ecs.d.ts +3 -0
  52. package/dist/transport/serializers/otlp.d.ts +3 -0
  53. package/dist/utils/console.d.ts +24 -0
  54. package/dist/utils/identity.d.ts +36 -0
  55. package/dist/utils/lock.d.ts +15 -0
  56. package/dist/utils/platform.d.ts +36 -0
  57. package/dist/utils/sanitize.d.ts +47 -0
  58. package/dist/utils/sequence.d.ts +15 -0
  59. package/dist/utils/timer.d.ts +19 -0
  60. package/dist/utils/tracing.d.ts +55 -0
  61. package/dist/utils/unref.d.ts +9 -0
  62. package/package.json +106 -0
@@ -0,0 +1,117 @@
1
+ import type { MetricType } from "../models/log-record";
2
+ import type { ObservabilityRuntime } from "./runtime";
3
+ /** Configuration options for a scoped OneLogger instance. */
4
+ export interface OneLoggerOptions {
5
+ /** Contextual attributes merged into all records emitted by this logger. */
6
+ scopedContext?: Record<string, unknown>;
7
+ }
8
+ /** Namespaced logger instance for recording structured events, metrics, and errors. */
9
+ export declare class OneLogger {
10
+ private readonly runtime;
11
+ readonly namespace: string;
12
+ private readonly options;
13
+ /**
14
+ * @param runtime Underlying observability runtime instance.
15
+ * @param namespace Application subsystem or module namespace.
16
+ * @param options Scoped context options.
17
+ */
18
+ constructor(runtime: ObservabilityRuntime, namespace: string, options?: OneLoggerOptions);
19
+ /**
20
+ * Creates a child logger with a nested namespace and merged scoped context.
21
+ * @param namespace Sub-namespace appended with dot notation.
22
+ * @param options Additional scoped context attributes.
23
+ * @returns Nested child OneLogger instance.
24
+ */
25
+ child(namespace: string, options?: OneLoggerOptions): OneLogger;
26
+ /**
27
+ * Logs a trace-level debug record.
28
+ * @param message Log message.
29
+ * @param payload Optional contextual attributes.
30
+ */
31
+ trace: (message: string, payload?: Record<string, unknown>) => void;
32
+ /**
33
+ * Logs a debug-level record.
34
+ * @param message Log message.
35
+ * @param payload Optional contextual attributes.
36
+ */
37
+ debug: (message: string, payload?: Record<string, unknown>) => void;
38
+ /**
39
+ * Logs an informational record.
40
+ * @param message Log message.
41
+ * @param payload Optional contextual attributes.
42
+ */
43
+ info: (message: string, payload?: Record<string, unknown>) => void;
44
+ /**
45
+ * Logs a warning record.
46
+ * @param message Log message.
47
+ * @param payload Optional contextual attributes.
48
+ */
49
+ warn: (message: string, payload?: Record<string, unknown>) => void;
50
+ /**
51
+ * Logs an error record with attached breadcrumb history.
52
+ * @param message Error description.
53
+ * @param error Caught error instance or reason.
54
+ * @param payload Optional contextual attributes.
55
+ */
56
+ error: (message: string, error?: unknown, payload?: Record<string, unknown>) => void;
57
+ /**
58
+ * Logs a fatal unrecoverable error record.
59
+ * @param message Error description.
60
+ * @param error Caught error instance or reason.
61
+ * @param payload Optional contextual attributes.
62
+ */
63
+ fatal: (message: string, error?: unknown, payload?: Record<string, unknown>) => void;
64
+ /**
65
+ * Logs a discrete user interaction action.
66
+ * @param name Action identifier.
67
+ * @param payload Optional action attributes.
68
+ */
69
+ logAction: (name: string, payload?: Record<string, unknown>) => void;
70
+ /**
71
+ * Logs an application lifecycle or domain event.
72
+ * @param name Event identifier.
73
+ * @param payload Optional event attributes.
74
+ */
75
+ logEvent: (name: string, payload?: Record<string, unknown>) => void;
76
+ /**
77
+ * Logs a numerical metric measurement.
78
+ * @param name Metric identifier.
79
+ * @param value Numerical measurement.
80
+ * @param unit Unit of measurement.
81
+ * @param type Metric type classification.
82
+ * @param attributes Optional metric attributes.
83
+ */
84
+ logMetric: (name: string, value: number, unit?: string, type?: MetricType, attributes?: Record<string, unknown>) => void;
85
+ /**
86
+ * Times a synchronous function execution and records a duration metric.
87
+ * @param label Metric name prefix.
88
+ * @param fn Synchronous function to time.
89
+ * @param attributes Optional contextual attributes.
90
+ * @returns Result returned by the timed function.
91
+ */
92
+ timeSync: <T>(label: string, fn: () => T, attributes?: Record<string, unknown>) => T;
93
+ /**
94
+ * Times an asynchronous function execution and records a duration metric.
95
+ * @param label Metric name prefix.
96
+ * @param fn Asynchronous function to time.
97
+ * @param attributes Optional contextual attributes.
98
+ * @returns Promise resolving to the result of the timed function.
99
+ */
100
+ timeAsync: <T>(label: string, fn: () => Promise<T>, attributes?: Record<string, unknown>) => Promise<T>;
101
+ /**
102
+ * Builds, logs to console, and emits a standard log record.
103
+ * @param level Severity level.
104
+ * @param type Record classification.
105
+ * @param body Primary message.
106
+ * @param payload Optional contextual attributes.
107
+ */
108
+ private write;
109
+ /**
110
+ * Builds, logs to console, and emits an error record with attached breadcrumbs.
111
+ * @param level Severity level ("ERROR" or "FATAL").
112
+ * @param message Error description.
113
+ * @param error Caught error instance or reason.
114
+ * @param payload Optional contextual attributes.
115
+ */
116
+ private writeError;
117
+ }
@@ -0,0 +1,75 @@
1
+ import { Subject } from "rxjs";
2
+ import type { LogBatch } from "../models/batch";
3
+ import type { ResolvedConfig } from "../models/config";
4
+ import { type LogRecord } from "../models/log-record";
5
+ import type { StorageAdapter } from "../models/storage";
6
+ import type { HttpTransport } from "../transport/http-transport";
7
+ import type { RetryEngine } from "../transport/retry-engine";
8
+ import type { Diagnostics } from "./diagnostics";
9
+ /** Pipeline stream classification for logs versus metrics. */
10
+ export type StreamName = "logs" | "metrics";
11
+ /** Pipeline orchestrating log and metric stream buffering, batch creation, and HTTP dispatch. */
12
+ export declare class LogPipeline {
13
+ private readonly config;
14
+ private readonly transport;
15
+ private readonly storage;
16
+ private readonly retry;
17
+ private readonly diagnostics;
18
+ /** Ingress Subject receiving records pushed into the pipeline. */
19
+ readonly records$: Subject<LogRecord>;
20
+ /** Buffer instances for logs and metrics streams. */
21
+ private readonly streams;
22
+ /** Active RxJS subscription managing the pipeline stream. */
23
+ private subscription;
24
+ /** Unconfirmed in-flight batches tracked for exit flush recovery. */
25
+ private readonly unconfirmed;
26
+ /** Indicates whether the pipeline has been destroyed. */
27
+ private stopped;
28
+ /**
29
+ * @param config Active configuration instance.
30
+ * @param transport HTTP transport for live batch delivery.
31
+ * @param storage Storage adapter for offline batch persistence.
32
+ * @param retry Retry engine for redelivering persisted batches.
33
+ * @param diagnostics Diagnostics reporter.
34
+ */
35
+ constructor(config: ResolvedConfig, transport: HttpTransport, storage: StorageAdapter, retry: RetryEngine, diagnostics: Diagnostics);
36
+ /**
37
+ * Stamps observed timestamp and enqueues a record into the pipeline.
38
+ * @param record Record to push.
39
+ */
40
+ push(record: LogRecord): void;
41
+ /**
42
+ * Atomically drains all buffered and unconfirmed in-flight records into a single exit batch.
43
+ * @returns Combined LogBatch or null if no records are pending.
44
+ */
45
+ drainPending(): LogBatch | null;
46
+ /** Re-subscribes RxJS pipeline stream to apply updated interval and batch size settings. */
47
+ refresh(): void;
48
+ /** Terminates pipeline subscriptions and completes the ingress stream. */
49
+ destroy(): void;
50
+ /** Assembles and subscribes the partitioned RxJS stream pipeline. */
51
+ private subscribe;
52
+ /**
53
+ * Applies sampling, buffers stream records, and triggers timed batch emissions.
54
+ * @param source$ Stream observable emitting records.
55
+ * @param stream Stream buffer managing pending records.
56
+ * @returns Observable emitting closed LogBatch objects.
57
+ */
58
+ private batches;
59
+ /**
60
+ * Drains the stream buffer into a new LogBatch and tracks it in unconfirmed storage.
61
+ * @param stream Stream buffer to drain.
62
+ * @returns Created LogBatch or null if stream was empty.
63
+ */
64
+ private claim;
65
+ /**
66
+ * Sends a batch over HTTP transport or persists it to offline storage if throttled or failed.
67
+ * @param batch Batch to deliver.
68
+ */
69
+ private dispatch;
70
+ /**
71
+ * Persists an undelivered batch to storage and triggers retry engine.
72
+ * @param batch Batch to persist.
73
+ */
74
+ private store;
75
+ }
@@ -0,0 +1,72 @@
1
+ import type { ResolvedConfig } from "../models/config";
2
+ import { type LogLevel, type LogRecord, type LogType } from "../models/log-record";
3
+ import type { Identity } from "../utils/identity";
4
+ import { type PlatformMetadata } from "../utils/platform";
5
+ import type { Sequence } from "../utils/sequence";
6
+ import type { TraceEngine } from "../utils/tracing";
7
+ import type { ContextStore } from "./context";
8
+ import type { Diagnostics } from "./diagnostics";
9
+ import type { JourneyEngine } from "./journey";
10
+ /** Injected dependencies required by RecordBuilder. */
11
+ export interface RecordBuilderDeps {
12
+ /** Active configuration object reference. */
13
+ config: ResolvedConfig;
14
+ /** Diagnostics reporter instance. */
15
+ diagnostics: Diagnostics;
16
+ /** Ambient context store. */
17
+ context: ContextStore;
18
+ /** Active journey engine. */
19
+ journey: JourneyEngine;
20
+ /** Distributed tracing engine. */
21
+ tracing: TraceEngine;
22
+ /** Monotonic sequence counter. */
23
+ sequence: Sequence;
24
+ /** Context, session, and tab identity context. */
25
+ identity: Identity;
26
+ /** Detected host platform metadata. */
27
+ platform: PlatformMetadata;
28
+ }
29
+ /** Input parameters for constructing a single log record. */
30
+ export interface BuildInput {
31
+ /** Severity level of the log entry. */
32
+ level: LogLevel;
33
+ /** Telemetry type classification. */
34
+ type: LogType;
35
+ /** Primary log message body. */
36
+ body: string;
37
+ /** Originating application namespace. */
38
+ namespace: string;
39
+ /** Pre-merged scoped context from logger instance. */
40
+ scoped?: Record<string, unknown>;
41
+ /** Call-site payload attributes. */
42
+ payload?: Record<string, unknown>;
43
+ }
44
+ /** Builds validated and sanitized LogRecord instances from logger inputs. */
45
+ export declare class RecordBuilder {
46
+ private readonly deps;
47
+ /** Cached resource attributes block. */
48
+ private resourceCache;
49
+ /**
50
+ * @param deps Injected builder dependencies.
51
+ */
52
+ constructor(deps: RecordBuilderDeps);
53
+ /** Invalidates cached resource attributes to force recomputation on next build. */
54
+ invalidateResource(): void;
55
+ /**
56
+ * Evaluates whether a log level clears minimum severity thresholds.
57
+ * @param level Target log severity level.
58
+ * @returns True if the level is enabled.
59
+ */
60
+ isEnabled(level: LogLevel): boolean;
61
+ /**
62
+ * Builds a structured LogRecord from input attributes, applying sanitization and size budgeting.
63
+ * @param input Logger call input parameters.
64
+ * @returns Completed LogRecord or null if dropped by severity or redaction.
65
+ */
66
+ build(input: BuildInput): LogRecord | null;
67
+ /**
68
+ * Computes or returns cached resource metadata for this runtime context.
69
+ * @returns Resource attributes record.
70
+ */
71
+ private resource;
72
+ }
@@ -0,0 +1,146 @@
1
+ import { Bus } from "../bus/bus";
2
+ import type { Receive, WorkerLike } from "../bus/links";
3
+ import type { BusMessage } from "../models/bus";
4
+ import type { ObservabilityConfig, ResolvedConfig } from "../models/config";
5
+ import { type LogRecord } from "../models/log-record";
6
+ import { ConsoleSink } from "../utils/console";
7
+ import { type Identity } from "../utils/identity";
8
+ import { type PlatformMetadata } from "../utils/platform";
9
+ import { Sequence } from "../utils/sequence";
10
+ import { TraceEngine } from "../utils/tracing";
11
+ import { BreadcrumbBuffer } from "./breadcrumbs";
12
+ import { ContextStore } from "./context";
13
+ import { Diagnostics } from "./diagnostics";
14
+ import { JourneyEngine } from "./journey";
15
+ import { RecordBuilder } from "./record";
16
+ /** Central runtime managing subsystem lifecycles, bus coordination, and record delivery. */
17
+ export declare class ObservabilityRuntime {
18
+ /** Diagnostics reporter for internal faults. */
19
+ readonly diagnostics: Diagnostics;
20
+ /** Active configuration instance mutated in place during reconfigurations. */
21
+ readonly config: ResolvedConfig;
22
+ /** Detected host platform metadata. */
23
+ readonly platform: PlatformMetadata;
24
+ /** Identity context containing session, tab, and context identifiers. */
25
+ readonly identity: Identity;
26
+ /** Store for ambient application context attributes. */
27
+ readonly context: ContextStore;
28
+ /** Ring buffer holding contextual user breadcrumbs. */
29
+ readonly breadcrumbs: BreadcrumbBuffer;
30
+ /** Distributed tracing context engine. */
31
+ readonly tracing: TraceEngine;
32
+ /** Monotonic sequence counter for records emitted in this context. */
33
+ readonly sequence: Sequence;
34
+ /** Journey tracking engine managing workflow correlation. */
35
+ readonly journey: JourneyEngine;
36
+ /** Record builder assembling structured log records. */
37
+ readonly builder: RecordBuilder;
38
+ /** Console sink for local developer output. */
39
+ readonly console: ConsoleSink;
40
+ /** Cross-realm communication bus. */
41
+ readonly bus: Bus;
42
+ /** Persistent storage adapter for offline batches (sender role only). */
43
+ private storage?;
44
+ /** HTTP transport instance for live log delivery (sender role only). */
45
+ private transport?;
46
+ /** Background retry engine for redelivering failed batches (sender role only). */
47
+ private retry?;
48
+ /** Primary log pipeline managing stream buffering and delivery (sender role only). */
49
+ private pipeline?;
50
+ /** Exit flush handler executing atomic batch delivery on unload (sender role only). */
51
+ private exitFlush?;
52
+ /** Active auto-capture instrumentation modules. */
53
+ private readonly captures;
54
+ /** Queue buffering records created before bus role resolution. */
55
+ private bootBuffer;
56
+ /** Batch buffer staging records for microtask forwarding. */
57
+ private forwardBuffer;
58
+ /** Indicates whether a microtask drain is scheduled for the forward buffer. */
59
+ private forwardScheduled;
60
+ /** Indicates whether asynchronous initialization has completed. */
61
+ private ready;
62
+ /** Indicates whether the runtime has been permanently shut down. */
63
+ private destroyed;
64
+ /** Timestamp of the last reported storage gap warning in epoch milliseconds. */
65
+ private lastGapAt;
66
+ /**
67
+ * @param input Initial consumer configuration options.
68
+ */
69
+ private constructor();
70
+ /**
71
+ * Direct communication receiver invoked by same-origin child frames.
72
+ * @param message Inbound bus message.
73
+ * @param reply Direct response callback.
74
+ */
75
+ readonly busAccept: (message: BusMessage, reply: Receive) => void;
76
+ /**
77
+ * Returns the singleton runtime instance pinned to this realm.
78
+ * @returns Active runtime instance or null.
79
+ */
80
+ static current(): ObservabilityRuntime | null;
81
+ /**
82
+ * Initializes a new runtime instance or updates the existing singleton.
83
+ * @param input Consumer configuration options.
84
+ * @returns Active runtime instance.
85
+ */
86
+ static configure(input: Partial<ObservabilityConfig>): ObservabilityRuntime;
87
+ /**
88
+ * Updates runtime configuration and refreshes affected subsystems.
89
+ * @param input Partial configuration to merge.
90
+ */
91
+ private reconfigure;
92
+ /** Initializes asynchronous subsystems and flushes the boot buffer. */
93
+ private init;
94
+ /** Initializes storage, transport, pipeline, and unload listeners for sender role. */
95
+ private becomeSender;
96
+ /** Instantiates and registers enabled auto-capture modules. */
97
+ private installCaptures;
98
+ /** Uninstalls active capture modules and re-creates them from updated configuration. */
99
+ private reinstallCaptures;
100
+ /**
101
+ * Attaches a Web Worker or MessagePort to the bus for record forwarding.
102
+ * @param worker Target Worker or MessagePort instance.
103
+ */
104
+ registerWorker(worker: WorkerLike): void;
105
+ /** Flushes pending telemetry, unregisters listeners, and unpins the runtime instance. */
106
+ destroy(): Promise<void>;
107
+ /**
108
+ * Routes a completed log record to the pipeline or forward buffer.
109
+ * @param record Log record to emit, or null if dropped during build.
110
+ */
111
+ emit(record: LogRecord | null): void;
112
+ /**
113
+ * Directs a record to the forward buffer or local pipeline based on active bus role.
114
+ * @param record Log record to route.
115
+ */
116
+ private route;
117
+ /**
118
+ * Batches records for asynchronous transmission to the upstream sender.
119
+ * @param record Log record to forward.
120
+ */
121
+ private forward;
122
+ /**
123
+ * Validates and enqueues records received from child frames or workers.
124
+ * @param records Inbound payload from bus.
125
+ */
126
+ private ingestForwarded;
127
+ /** Flushes records buffered during startup and backfills active journey metadata. */
128
+ private releaseBootBuffer;
129
+ /**
130
+ * Emits a warning log record when batches are evicted from persistent storage.
131
+ * @param result Storage prune summary metrics.
132
+ */
133
+ private readonly reportGap;
134
+ /** Generates and persists a replacement tab ID when a collision is detected. */
135
+ private regenerateTabId;
136
+ /**
137
+ * Counts the batches held in storage after a failed or deferred delivery.
138
+ * @returns Promise resolving to the number of stored batches. A forwarder reports 0, because it persists nothing.
139
+ */
140
+ queueDepth(): Promise<number>;
141
+ /**
142
+ * Flushes all pending records in the pipeline or forward buffer.
143
+ * @returns Promise resolving when queued records are transmitted or handed off.
144
+ */
145
+ flush(): Promise<void>;
146
+ }
@@ -0,0 +1,9 @@
1
+ import type { ResolvedConfig } from "../models/config";
2
+ import type { LogRecord } from "../models/log-record";
3
+ /**
4
+ * Evaluates whether a log record should be sampled for retention.
5
+ * @param record Record to evaluate.
6
+ * @param config Active configuration instance.
7
+ * @returns True if the record should be retained and transmitted.
8
+ */
9
+ export declare function shouldSample(record: LogRecord, config: ResolvedConfig): boolean;
package/dist/index.cjs ADDED
@@ -0,0 +1,4 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./constants-D8-4Ged5.cjs");let t=require("@opentelemetry/api"),n=require("rxjs");function r(t){return Math.round((performance.now()-t)*e.j)/e.j}function i(e,t,n,i,a){e.logMetric(`${t}.duration`,r(n),`ms`,`histogram`,{status:i,...a})}function a(e,t,n,i,a){e.error(`${t} failed`,i,{"action.duration_ms":r(n),status:`FAILURE`,...a})}function o(e,t,n,r){let o=performance.now();try{let a=n();return i(e,t,o,`SUCCESS`,r),a}catch(n){throw a(e,t,o,n,r),n}}async function s(e,t,n,r){let o=performance.now();try{let a=await n();return i(e,t,o,`SUCCESS`,r),a}catch(n){throw a(e,t,o,n,r),n}}function c(e){return e instanceof Error?e:Error(String(e))}var l=class t{runtime;namespace;options;constructor(e,t,n={}){this.runtime=e,this.namespace=t,this.options=n}child(e,n={}){return new t(this.runtime,`${this.namespace}.${e}`,{scopedContext:{...this.options.scopedContext,...n.scopedContext}})}trace=(e,t)=>{this.write(`TRACE`,`system`,e,t)};debug=(e,t)=>{this.write(`DEBUG`,`system`,e,t)};info=(e,t)=>{this.write(`INFO`,`system`,e,t)};warn=(e,t)=>{this.write(`WARN`,`system`,e,t)};error=(e,t,n)=>{this.writeError(`ERROR`,e,t,n)};fatal=(e,t,n)=>{this.writeError(`FATAL`,e,t,n)};logAction=(e,t)=>{this.write(`INFO`,`action`,e,t)};logEvent=(e,t)=>{this.write(`INFO`,`event`,e,t)};logMetric=(t,n,r=e.O,i=`gauge`,a)=>{this.write(`INFO`,`metric`,t,{"metric.name":t,"metric.value":n,"metric.unit":r,"metric.type":i,...a})};timeSync=(e,t,n)=>o(this,e,t,n);timeAsync=(e,t,n)=>s(this,e,t,n);write(e,t,n,r){if(!this.runtime.builder.isEnabled(e))return;let i=this.runtime.builder.build({level:e,type:t,body:n,namespace:this.namespace,scoped:this.options.scopedContext,payload:r});i&&t!==`metric`&&this.runtime.breadcrumbs.push({t:Date.now(),category:t===`action`?`action`:t===`event`?`event`:`log`,message:n}),this.runtime.console.write(e,n,i?.attributes),this.runtime.emit(i)}writeError(e,t,n,r){if(!this.runtime.builder.isEnabled(e))return;let i=n===void 0?void 0:c(n),a=this.runtime.builder.build({level:e,type:`system`,body:t,namespace:this.namespace,scoped:this.options.scopedContext,payload:{...r,...i?{"error.type":i.name,"error.message":i.message,"error.stack_trace":i.stack}:{},breadcrumbs:this.runtime.breadcrumbs.snapshot()}});this.runtime.console.write(e,t,i??a?.attributes),this.runtime.emit(a)}};function u(e){typeof e!=`number`&&e.unref?.()}function d(t){return{p:e.b,m:t}}function f(e){if(typeof e!=`object`||!e)return null;let t=e;if(t.p!==`ui-observability/1`||typeof t.m!=`object`||t.m===null)return null;let n=t.m;return typeof n.t==`string`?n:null}var p=Symbol.for(e.yt);function m(e,t){if(typeof window>`u`||window.parent===window)return null;let n;try{n=window.parent[p]}catch{return null}if(typeof n?.busAccept!=`function`)return null;let r=n,i=!0;return{kind:`direct`,post(n){i&&t.guard(`bus.send_failed`,`direct call into the parent runtime`,()=>{r.busAccept(n,e)})},close(){i=!1}}}function h(e,t){if(typeof window>`u`||window.parent===window)return null;let n=t=>{let n=f(t.data);n&&t.source===window.parent&&e(n,{link:`parent`,origin:t.origin})};return addEventListener(`message`,n),{kind:`parent`,post(e){t.guard(`bus.send_failed`,`postMessage to parent`,()=>{window.parent.postMessage(d(e),`*`)})},close(){removeEventListener(`message`,n)}}}function g(e,t,n){if(typeof window>`u`)return null;let r=new Set([window.location.origin,...t]),i=new Set,a=t=>{let a=f(t.data);if(a){if(!r.has(t.origin)){n.report(`bus.untrusted_origin`,`ignored a bus message from ${t.origin}. Add it to bus.trustedOrigins if it is yours.`,{origin:t.origin,type:a.t});return}t.source&&i.add(t.source),e(a,{link:`children`,origin:t.origin})}};return addEventListener(`message`,a),{kind:`children`,post(e){for(let t of i){let r=t;if(r.closed){i.delete(t);continue}n.guard(`bus.send_failed`,`postMessage to child`,()=>{r.postMessage(d(e),`*`)})}},close(){removeEventListener(`message`,a),i.clear()}}}function ee(e,t,n){let r=globalThis.BroadcastChannel;if(r===void 0)return null;let i=n.guard(`bus.send_failed`,`opening BroadcastChannel`,()=>new r(e));return i?(i.onmessage=e=>{let n=f(e.data);n&&t(n,{link:`broadcast`,origin:`same-origin`})},{kind:`broadcast`,post(e){n.guard(`bus.send_failed`,`BroadcastChannel.postMessage`,()=>{i.postMessage(d(e))})},close(){n.guard(`bus.send_failed`,`closing BroadcastChannel`,()=>{i.close()})}}):null}function te(e,t,n){let r=globalThis.fin?.InterApplicationBus;return r?(n.guardAsync(`bus.send_failed`,`InterApplicationBus.subscribe`,()=>r.subscribe({uuid:`*`},e,e=>{let n=f(e);n&&t(n,{link:`openfin`,origin:`openfin`})})),{kind:`openfin`,post(t){n.guardAsync(`bus.send_failed`,`InterApplicationBus.publish`,()=>r.publish(e,d(t)))},close(){}}):null}function ne(e,t){let n=globalThis,r=n.postMessage;return n.WorkerGlobalScope===void 0||!r?null:(n.addEventListener?.(`message`,t=>{let n=f(t.data);n&&e(n,{link:`owner`,origin:`same-origin`})}),{kind:`owner`,post(e){t.guard(`bus.send_failed`,`worker postMessage`,()=>{r(d(e))})},close(){}})}function re(e,t,n){let r=e=>{let n=f(e.data);n&&t(n,{link:`worker`,origin:`same-origin`})};return e.addEventListener(`message`,r),e.start?.(),{kind:`worker`,post(t){n.guard(`bus.send_failed`,`postMessage to a worker`,()=>{e.postMessage(d(t))})},close(){e.removeEventListener(`message`,r)}}}var ie=[`children`,`direct`,`worker`],ae=class{config;diagnostics;platform;contextId;tabId;handlers;role=`sender`;upstream=null;links=[];openFinLink=null;isOpenFinProvider=!1;resolved=!1;awaitingWelcome=null;constructor(e,t,n,r,i,a){this.config=e,this.diagnostics=t,this.platform=n,this.contextId=r,this.tabId=i,this.handlers=a}getRole(){return this.role}isResolved(){return this.resolved}async start(){let{bus:e}=this.config;if(e.mode===`off`)return this.role=`sender`,this.resolved=!0,this.role;if(this.isOpenFinProvider=this.resolveOpenFinProvider(),e.mode===`sender`||e.mode===`forwarder`)return this.role=e.mode,this.openControlLinks(),this.role===`forwarder`&&(this.upstream=this.candidateUpstream(),this.upstream||this.diagnostics.report(`bus.no_owner`,`bus.mode is "forwarder" but there is no owner to forward to. Records will be dropped.`)),this.resolved=!0,this.announce(),this.role;this.openControlLinks();let t=m(this.receive,this.diagnostics);if(t)return this.role=`forwarder`,this.upstream=t,this.resolved=!0,this.diagnostics.report(`bus.role_resolved`,`attached directly to the same-origin parent runtime`,{role:`forwarder`,via:`direct`}),this.announce(),this.role;let n=this.candidateUpstream();if(!n)return this.role=`sender`,this.resolved=!0,this.diagnostics.report(`bus.role_resolved`,`no owner to forward to, sending directly`,{role:`sender`}),this.announce(),this.role;let r=this.orphanPolicy()===`retry`?this.config.bus.maxHandshakeAttempts:1,i=!1;for(let e=0;e<r&&!i;e++)i=await this.handshake(n);return this.role=i?`forwarder`:`sender`,this.upstream=i?n:null,i||(n!==this.openFinLink&&n.close(),this.diagnostics.report(`bus.handshake_timeout`,`no owner answered after ${String(r)} attempt(s) of ${String(this.config.bus.handshakeTimeoutMs)}ms, promoting to sender`,{via:n.kind,crossOrigin:this.isCrossOriginFrame()})),this.diagnostics.report(`bus.role_resolved`,`role is ${this.role}`,{role:this.role,via:i?n.kind:`none`}),this.resolved=!0,this.announce(),this.role}sendRecords(e){this.upstream?.post({t:`records`,from:this.contextId,records:e})}acceptDirect(e,t){if(e.from===this.contextId)return;let n={link:`direct`,origin:`same-origin`};if(e.t===`hello`){this.canOwn(`direct`)&&t({t:`welcome`,from:this.contextId,to:e.from,tabId:this.tabId},n);return}if(e.t===`journey?`){let e=this.handlers.onJourneyRequest();e&&t({t:`journey`,from:this.contextId,journey:e},n);return}this.receive(e,n)}attachWorker(e){this.links.push(re(e,this.receive,this.diagnostics))}broadcastJourney(e){this.post({t:`journey`,from:this.contextId,journey:e})}destroy(){for(let e of this.allLinks())e.close();this.links.length=0,this.upstream=null,this.openFinLink=null}allLinks(){return!this.upstream||this.links.includes(this.upstream)?this.links:[...this.links,this.upstream]}post(e){for(let t of this.allLinks())t.post(e)}postOver(e,t){for(let n of this.allLinks())n.kind===e&&n.post(t)}receive=(e,t)=>{if(e.from!==this.contextId)switch(e.t){case`hello`:this.canOwn(t.link)&&this.postOver(t.link,{t:`welcome`,from:this.contextId,to:e.from,tabId:this.tabId});break;case`welcome`:if(e.to!==this.contextId)break;this.awaitingWelcome?.link===t.link&&this.awaitingWelcome.settle(!0);break;case`records`:this.role===`sender`?this.handlers.onRecords(e.records):this.upstream&&t.link!==this.upstream.kind&&this.upstream.post(e);break;case`journey`:this.handlers.onJourney(e.journey);break;case`journey?`:{let e=this.handlers.onJourneyRequest();e&&this.postOver(t.link,{t:`journey`,from:this.contextId,journey:e});break}case`tab`:t.link===`broadcast`&&e.tabId===this.tabId&&this.contextId>e.from&&this.handlers.onTabConflict()}};canOwn(e){return this.role===`sender`?e===`openfin`?this.isOpenFinProvider:ie.includes(e):!1}resolveOpenFinProvider(){let e=this.config.bus.openFinRole;if(e!==`auto`)return e===`provider`;if(this.platform.platform!==`openfin`&&this.platform.platform!==`openfin_web`)return!1;let t=globalThis.fin?.me;return!t?.identity||t.isView?!1:!!(t.identity.name&&t.identity.name===t.identity.uuid)}orphanPolicy(){let e=this.config.bus.orphanPolicy;return e===`auto`?this.isCrossOriginFrame()?`retry`:`promote`:e}isCrossOriginFrame(){if(typeof window>`u`||window.parent===window)return!1;try{return window.parent.location,!1}catch{return!0}}candidateUpstream(){return this.platform.isWorker?ne(this.receive,this.diagnostics):this.platform.isTopLevelDocument?this.platform.platform===`openfin`&&this.config.bus.openFinHost===`provider`&&!this.isOpenFinProvider?this.ensureOpenFinLink():null:h(this.receive,this.diagnostics)}openControlLinks(){let e=e=>{e&&this.links.push(e)};this.platform.isTopLevelDocument&&(e(g(this.receive,this.config.bus.trustedOrigins,this.diagnostics)),e(ee(this.config.bus.channelName,this.receive,this.diagnostics))),(this.platform.platform===`openfin`||this.platform.platform===`openfin_web`)&&e(this.ensureOpenFinLink())}ensureOpenFinLink(){return this.openFinLink??=te(this.config.bus.channelName,this.receive,this.diagnostics),this.openFinLink}handshake(e){return new Promise(t=>{let n=!1,r=e=>{n||(n=!0,this.awaitingWelcome=null,clearTimeout(i),t(e))};this.awaitingWelcome={link:e.kind,settle:r};let i=setTimeout(()=>{r(!1)},this.config.bus.handshakeTimeoutMs);u(i),e.post({t:`hello`,from:this.contextId,tabId:this.tabId})})}announce(){this.postOver(`broadcast`,{t:`tab`,from:this.contextId,tabId:this.tabId}),this.post({t:`journey?`,from:this.contextId})}},oe=class{ctx;name=`errors`;installed=!1;seen=new Map;windowStart=0;windowCount=0;constructor(e){this.ctx=e}install(){this.installed||typeof addEventListener>`u`||(this.installed=!0,addEventListener(`error`,this.onError,!0),addEventListener(`unhandledrejection`,this.onRejection))}uninstall(){this.installed&&(this.installed=!1,removeEventListener(`error`,this.onError,!0),removeEventListener(`unhandledrejection`,this.onRejection),this.seen.clear())}onError=e=>{let t=e.target,n=t?.src??t?.href??``;if(t!==null&&t!==globalThis&&n!==``){if(!this.ctx.config.capture.resourceErrors)return;this.ctx.breadcrumbs.push({t:Date.now(),category:`http`,message:`resource failed: ${n}`}),this.ctx.logger.warn(`resource failed to load`,{"error.type":`resource`,"resource.url":n,"resource.tag":t.tagName.toLowerCase()});return}if(!this.ctx.config.capture.errors)return;let r=e,i=r.message===``?`unknown error`:r.message,a=r.error??Error(i);this.report(`window.onerror`,a,{"error.source":r.filename,"error.line":r.lineno,"error.column":r.colno})};onRejection=e=>{this.ctx.config.capture.rejections&&this.report(`unhandledrejection`,e.reason,{"error.type":`unhandledrejection`})};report(t,n,r){let i=Date.now();if(i-this.windowStart>1e4&&(this.windowStart=i,this.windowCount=0),this.windowCount++,this.windowCount>20){this.ctx.diagnostics.report(`capture.rate_limited`,`more than 20 errors in ${String(e.F)}ms, suppressing the rest of this window`);return}let a=n instanceof Error?n:Error(String(n)),o=(a.stack??``).split(`
2
+ `)[1]??``,s=`${a.name}|${a.message}|${o}`,c=this.seen.get(s);if(c&&i-c.at<this.ctx.config.capture.errorDedupeMs){c.count++,c.at=i;return}let l=c?c.count-1:0;if(this.seen.delete(s),this.seen.set(s,{at:i,count:1}),this.seen.size>200){let[e]=this.seen.keys();this.seen.delete(e)}this.ctx.logger.error(a.message===``?t:a.message,a,{...r,"error.captured_by":t,"error.suppressed_count":l})}};function se(e){if(e===null)return`unknown`;let t=e.tagName.toLowerCase(),n=e.getAttribute(`data-testid`)??e.getAttribute(`data-test-id`);if(n!==null)return`[data-testid="${n}"]`;if(e.id!==``)return`#${e.id}`;let r=e.getAttribute(`aria-label`);if(r!==null)return`${t}[aria-label="${r.slice(0,40)}"]`;let i=e.getAttribute(`class`)?.trim()??``;return i===``?t:`${t}.${i.split(/\s+/).slice(0,2).join(`.`)}`}function _(){return history}var ce=class{ctx;name=`interactions`;installed=!1;originalPushState=null;originalReplaceState=null;lastUrl=``;constructor(e){this.ctx=e}install(){this.installed||typeof document>`u`||(this.installed=!0,this.lastUrl=location.href,this.ctx.config.capture.interactions&&addEventListener(`click`,this.onClick,!0),this.ctx.config.capture.navigation&&(this.installHistory(),addEventListener(`popstate`,this.onNavigate),addEventListener(`hashchange`,this.onNavigate)))}uninstall(){this.installed&&(this.installed=!1,removeEventListener(`click`,this.onClick,!0),removeEventListener(`popstate`,this.onNavigate),removeEventListener(`hashchange`,this.onNavigate),this.originalPushState&&(_().pushState=this.originalPushState),this.originalReplaceState&&(_().replaceState=this.originalReplaceState),this.originalPushState=null,this.originalReplaceState=null)}onClick=e=>{let t=e.target,n=se(t instanceof Element?t:null),r=t instanceof HTMLElement?t.innerText.trim().slice(0,50):``;this.ctx.tracing.rotate(`interaction`),this.ctx.breadcrumbs.push({t:Date.now(),category:`click`,message:n,data:r===``?void 0:{text:r}})};onNavigate=()=>{let e=this.lastUrl,t=location.href;e!==t&&(this.lastUrl=t,this.ctx.tracing.rotate(`navigation`),this.ctx.breadcrumbs.push({t:Date.now(),category:`navigation`,message:`${e} -> ${t}`}),this.ctx.logger.logEvent(`NAVIGATION`,{"page.url.previous":e}))};installHistory(){if(typeof history>`u`||this.originalPushState)return;let e=_(),t=e.pushState,n=e.replaceState;this.originalPushState=t,this.originalReplaceState=n;let r=this.onNavigate;e.pushState=function(...e){t.apply(this,e),queueMicrotask(r)},e.replaceState=function(...e){n.apply(this,e),queueMicrotask(r)}}};function v(e,t){return t.some(t=>typeof t==`string`?e.includes(t):t.test(e))}function y(){return XMLHttpRequest.prototype}var le=class{ctx;name=`network`;originalFetch=null;originalOpen=null;originalSend=null;constructor(e){this.ctx=e}install(){this.ctx.config.capture.fetch&&this.installFetch(),this.ctx.config.capture.xhr&&this.installXhr()}uninstall(){this.originalFetch&&=(globalThis.fetch=this.originalFetch,null),this.originalOpen&&=(y().open=this.originalOpen,null),this.originalSend&&=(y().send=this.originalSend,null)}ignored(e){return v(e,this.ctx.config.capture.ignoreUrls)}installFetch(){if(typeof globalThis.fetch!=`function`||this.originalFetch)return;let e=globalThis.fetch.bind(globalThis);this.originalFetch=globalThis.fetch;let t=this.ctx,n=e=>this.ignored(e),r=(e,t,n,r,i)=>{this.record(e,t,n,r,i)};globalThis.fetch=async function(i,a){let o=typeof i==`string`?i:i instanceof URL?i.href:i.url,s=(a?.method??(i instanceof Request?i.method:`GET`)).toUpperCase();if(n(o))return e(i,a);let c=i,l=a;if(v(o,t.config.capture.propagateTraceHeaderTo))try{let e=Object.entries(t.tracing.headers());if(i instanceof Request){let t=new Headers(i.headers);for(let[n,r]of e)t.set(n,r);c=new Request(i,{headers:t})}else{let t=new Headers(a?.headers);for(let[n,r]of e)t.set(n,r);l={...a,headers:t}}}catch(e){c=i,l=a,t.diagnostics.report(`capture.header_failed`,`could not attach traceparent, sending the request unchanged`,{url:o},e)}let u=performance.now();try{let t=await e(c,l);return r(s,o,t.status,performance.now()-u,void 0),t}catch(e){throw r(s,o,0,performance.now()-u,e),e}}}installXhr(){if(typeof XMLHttpRequest>`u`||this.originalOpen)return;let e=e=>this.ignored(e),t=(e,t,n,r)=>{this.record(e,t,n,r,void 0)},n=y(),r=n.open,i=n.send;this.originalOpen=r,this.originalSend=i,n.open=function(e,t,...n){this.__uiobs={method:e.toUpperCase(),url:String(t),startedAt:0},r.apply(this,[e,t,...n])},n.send=function(...n){let r=this.__uiobs;r&&!e(r.url)&&(r.startedAt=performance.now(),this.addEventListener(`loadend`,()=>{t(r.method,r.url,this.status,performance.now()-r.startedAt)})),i.apply(this,n)}}record(e,t,n,r,i){this.ctx.diagnostics.guard(`capture.record_failed`,`recording ${e} ${t}`,()=>{let a=Math.round(r);this.ctx.breadcrumbs.push({t:Date.now(),category:`http`,message:`${e} ${t} ${n===0?`failed`:String(n)}`,data:{durationMs:a}});let o={"http.request.method":e,"url.full":t,"http.response.status_code":n,"http.duration_ms":a};if(n===0){this.ctx.logger.error(`${e} ${t} failed`,i,o);return}if(n>=400){this.ctx.logger.warn(`${e} ${t} returned ${String(n)}`,o);return}this.ctx.logger.debug(`${e} ${t}`,o)})}};function ue(){return import(`web-vitals`)}var de=class{ctx;name=`web-vitals`;installed=!1;constructor(e){this.ctx=e}install(){this.installed||(this.installed=!0,this.reportNavigationTiming(),this.loadWebVitals())}uninstall(){this.installed=!1}async loadWebVitals(){let e=this.ctx.config.capture.webVitalsLoader??ue,t=await this.ctx.diagnostics.guardAsync(`capture.install_failed`,`loading web-vitals`,e);if(!t){this.ctx.diagnostics.report(`capture.install_failed`,`web-vitals is not available, so LCP, CLS and INP are unavailable. Navigation timing still works.`);return}let n=(e,t)=>n=>{this.ctx.logger.logMetric(`web_vitals.${e}`,Math.round(n.value*1e3)/1e3,t,`gauge`,{"metric.rating":n.rating,"metric.id":n.id})};t.onLCP(n(`lcp`,`ms`)),t.onCLS(n(`cls`,`1`)),t.onINP(n(`inp`,`ms`)),t.onFCP(n(`fcp`,`ms`)),t.onTTFB(n(`ttfb`,`ms`))}reportNavigationTiming(){this.ctx.diagnostics.guard(`capture.install_failed`,`reading navigation timing`,()=>{let e=performance.getEntriesByType(`navigation`)[0];if(!e)return;let t={"navigation.dns_ms":e.domainLookupEnd-e.domainLookupStart,"navigation.tcp_ms":e.connectEnd-e.connectStart,"navigation.ttfb_ms":e.responseStart-e.requestStart,"navigation.response_ms":e.responseEnd-e.responseStart,"navigation.dom_interactive_ms":e.domInteractive,"navigation.dom_complete_ms":e.domComplete,"navigation.load_ms":e.loadEventEnd};for(let[n,r]of Object.entries(t))Number.isFinite(r)&&r>=0&&this.ctx.logger.logMetric(n,Math.round(r),`ms`,`gauge`,{"navigation.type":e.type})})}};function b(){return`${String(Date.now())}000000`}function x(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.body==`string`&&typeof t.severityText==`string`&&typeof t.timeUnixNano==`string`&&typeof t.attributes==`object`&&t.attributes!==null&&typeof t.resource==`object`&&t.resource!==null}function S(e,t,n,{skipIfBusy:r=!0}={}){let i=globalThis.navigator?.locks;return i?.request?t.guardAsync(`storage.degraded`,`acquiring lock ${e}`,()=>i.request(e,{ifAvailable:r},e=>e?n():Promise.resolve(void 0))):n()}function C(e,t){let n=[];return t.guard(`storage.unavailable`,`enumerating localStorage`,()=>{for(let t=0;t<localStorage.length;t++){let r=String(localStorage.key(t));r.startsWith(e)&&n.push(r)}}),n.sort()}function fe(t){let n=String(t.createdAt).padStart(14,`0`);return`${e.N}${n}.${t.id}`}function pe(e,t){let n=t.guard(`storage.degraded`,`an emergency entry was not JSON and was dropped`,()=>JSON.parse(e));if(typeof n!=`object`||!n)return null;let r=Reflect.get(n,`createdAt`),i=Reflect.get(n,`records`);return typeof r!=`number`||!Array.isArray(i)?(t.report(`storage.degraded`,`an emergency entry was not a batch and was dropped`),null):n}async function me(t,n){let r=0;for(let i of C(e.N,n)){let e=n.guard(`storage.unavailable`,`reading the emergency queue`,()=>{let e=localStorage.getItem(i);return localStorage.removeItem(i),e});if(!e)continue;let a=pe(e,n);if(a!==null)try{await t.save(a),r++}catch(e){n.report(`storage.degraded`,`an emergency batch could not be recovered`,{key:i},e)}}return r}function he(t,n){n.guard(`storage.quota_exceeded`,`writing the emergency queue`,()=>{let r=C(e.N,n);for(let e of r.slice(0,Math.max(0,r.length-20+1)))localStorage.removeItem(e);localStorage.setItem(fe(t),JSON.stringify(t))})}async function ge(e,t){return await S(`ui-observability.emergency`,t,()=>me(e,t),{skipIfBusy:!1})??0}function _e(t){let n=String(t.createdAt).padStart(14,`0`);return`${e.v}${n}.${t.id}`}var ve=class{limits;diagnostics;onGap;name=e.Ot;constructor(e,t,n){this.limits=e,this.diagnostics=t,this.onGap=n}async save(e){if(this.diagnostics.guard(`storage.quota_exceeded`,`localStorage refused a batch, evicting the oldest`,()=>(localStorage.setItem(_e(e),JSON.stringify(e)),!0))!==!0){let e=this.keys();this.evict(e.slice(0,Math.ceil(e.length/4)));return}await this.prune()}take(e){let t=[];for(let n of this.keys().slice(0,e)){let e=this.read(n);if(e===null){this.removeKey(n);continue}t.push(e)}return Promise.resolve(t)}remove(e){let t=this.keyOf(e);return t!==null&&this.removeKey(t),Promise.resolve()}bumpAttempts(e,t){let n=this.keyOf(e);if(n===null)return Promise.resolve();let r=this.read(n);return r===null?Promise.resolve():(r.attempts=t,this.diagnostics.guard(`storage.degraded`,`updating attempts`,()=>{localStorage.setItem(n,JSON.stringify(r))}),Promise.resolve())}prune(){let e=Date.now()-this.limits.maxAgeMs,t={batches:0,records:0,reason:`expired`},n=(e,n)=>{this.removeKey(e),t.batches++,t.records+=n},r=[];for(let t of this.keys()){let i=this.read(t);if(i===null){n(t,0);continue}if(i.createdAt<e){n(t,i.records.length);continue}r.push({key:t,records:i.records.length})}let i=r.length-this.limits.maxBatches;if(i>0){t.reason=`over_capacity`;for(let e of r.slice(0,i))n(e.key,e.records)}return t.batches>0&&(this.diagnostics.report(`storage.evicted`,`dropped ${String(t.batches)} stored batches (${String(t.records)} records)`,{...t}),this.onGap?.(t)),Promise.resolve(t)}count(){return Promise.resolve(this.keys().length)}clear(){return this.evict(this.keys()),Promise.resolve()}close(){return Promise.resolve()}read(e){let t=this.diagnostics.guard(`storage.unavailable`,`reading a stored batch`,()=>localStorage.getItem(e));if(!t)return null;let n=this.diagnostics.guard(`storage.degraded`,`a stored batch was corrupt and was removed`,()=>JSON.parse(t));if(typeof n!=`object`||!n)return null;let r=Reflect.get(n,`createdAt`),i=Reflect.get(n,`records`);return typeof r!=`number`||!Array.isArray(i)?null:n}keyOf(e){return this.keys().find(t=>t.endsWith(`.${e}`))??null}evict(e){for(let t of e)this.removeKey(t)}removeKey(e){this.diagnostics.guard(`storage.degraded`,`removing a stored batch`,()=>{localStorage.removeItem(e)})}keys(){return C(e.v,this.diagnostics)}};function ye(e){return e.reduce((e,t)=>e+t.records.length,0)}var w=class{limits;onGap;name=e.kt;batches=[];constructor(e,t){this.limits=e,this.onGap=t}async save(e){this.batches.push(e),await this.prune()}take(e){return Promise.resolve(this.batches.slice(0,e))}remove(e){return this.batches=this.batches.filter(t=>t.id!==e),Promise.resolve()}bumpAttempts(e,t){let n=this.batches.find(t=>t.id===e);return n&&(n.attempts=t),Promise.resolve()}prune(){let e=Date.now()-this.limits.maxAgeMs,t={batches:0,records:0,reason:`expired`},n=this.batches.filter(t=>t.createdAt<e);this.batches=this.batches.filter(t=>t.createdAt>=e),t.batches+=n.length,t.records+=ye(n);let r=this.batches.length-this.limits.maxBatches;if(r>0){t.reason=`over_capacity`;let e=this.batches.slice(0,r);this.batches=this.batches.slice(r),t.batches+=e.length,t.records+=ye(e)}return t.batches>0&&this.onGap?.(t),Promise.resolve(t)}count(){return Promise.resolve(this.batches.length)}clear(){return this.batches=[],Promise.resolve()}close(){return this.batches=[],Promise.resolve()}},be={name:e.At,save:()=>Promise.resolve(),take:()=>Promise.resolve([]),remove:()=>Promise.resolve(),bumpAttempts:()=>Promise.resolve(),prune:()=>Promise.resolve({batches:0,records:0,reason:`expired`}),count:()=>Promise.resolve(0),clear:()=>Promise.resolve(),close:()=>Promise.resolve()};function xe(e){return e.guard(`storage.unavailable`,`reading indexedDB`,()=>globalThis.indexedDB!=null)===!0}function Se(t){return t.guard(`storage.unavailable`,`probing localStorage`,()=>(localStorage.setItem(e.jt,`1`),localStorage.removeItem(e.jt),!0))===!0}async function Ce(e,t,n,r,i){if(e===`none`)return be;if(e===`memory`)return new w(n,i);if(e===`indexeddb`||e===`auto`){if(xe(r)){let e=await r.guardAsync(`storage.unavailable`,`opening IndexedDB`,async()=>{let{IndexedDbStorage:e}=await Promise.resolve().then(()=>require("./indexeddb-storage-DvsvCUlO.cjs"));return new e(t,n,r,i)});if(e)return e}if(e===`indexeddb`)return r.report(`storage.degraded`,`IndexedDB was asked for by name and is unavailable, using memory`),new w(n,i)}return Se(r)?new ve(n,r,i):(r.report(`storage.degraded`,`no persistent storage available, offline logs are memory only`),new w(n,i))}function T(e,t){if(e.length<=t)return e;let n=we(e.charCodeAt(t-1))?t-1:t;return`${e.slice(0,n)}… [truncated ${String(e.length-n)} chars]`}function we(e){return e>=55296&&e<=56319}function Te(e){return`[Element ${(e.nodeName??`NODE`).toLowerCase()}${e.id?`#${e.id}`:``}${typeof e.className==`string`&&e.className?`.${e.className.trim().split(/\s+/).slice(0,3).join(`.`)}`:``}]`}function E(e,t){let n={bytes:0};return{value:O(e,t,new WeakSet,0,n),bytes:n.bytes}}function D(e,t){return t.bytes+=k(e)+2,e}function O(e,t,n,r,i){if(e==null)return i.bytes+=4,e;if(typeof e==`string`)return D(T(e,t.maxAttributeChars),i);if(typeof e==`number`)return i.bytes+=8,Number.isFinite(e)?e:String(e);if(typeof e==`boolean`)return i.bytes+=5,e;if(typeof e==`bigint`)return D(`${e.toString()}n`,i);if(typeof e==`symbol`)return D(e.toString(),i);if(typeof e==`function`)return D(`[Function ${e.name===``?`anonymous`:e.name}]`,i);if(r>=t.maxDepth)return D(`[MaxDepth]`,i);if(n.has(e))return D(`[Circular]`,i);n.add(e),i.bytes+=2;try{if(e instanceof Error)return{name:D(e.name,i),message:D(T(e.message,t.maxAttributeChars),i),stack:e.stack?D(T(e.stack,t.maxStackChars),i):void 0,cause:e.cause?O(e.cause,t,n,r+1,i):void 0};if(e instanceof Date)return D(e.toISOString(),i);if(e instanceof RegExp)return D(e.toString(),i);if(e instanceof Map){let a=e,o={},s=0;for(let[e,c]of a){if(s>=t.maxArrayLength){o[`…`]=D(`[${String(a.size-t.maxArrayLength)} more entries]`,i);break}s++;let l=String(e);i.bytes+=k(l)+4,o[l]=O(c,t,n,r+1,i)}return o}if(e instanceof Set)return O([...e].slice(0,t.maxArrayLength),t,n,r,i);if(ArrayBuffer.isView(e)){let t=e.length??0;return D(`[${e.constructor.name}(${String(t)})]`,i)}if(e instanceof Promise)return D(`[Promise]`,i);if(typeof Node<`u`&&e instanceof Node)return D(Te(e),i);if(Array.isArray(e)){let a=e,o=a.slice(0,t.maxArrayLength).map(e=>O(e,t,n,r+1,i));return a.length>t.maxArrayLength&&o.push(D(`[${String(a.length-t.maxArrayLength)} more items]`,i)),o}let a=e.toJSON;if(typeof a==`function`)return O(a.call(e),t,n,r+1,i);let o=e,s=Object.keys(o),c={},l=0;for(let e of s){if(l>=t.maxAttributeCount){c[`…`]=D(`[${String(s.length-l)} more keys]`,i);break}l++,i.bytes+=k(e)+4,c[e]=O(o[e],t,n,r+1,i)}return c}catch(e){return D(`[Unserializable: ${e instanceof Error?e.name:`error`}]`,i)}finally{n.delete(e)}}function k(e){let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);r<128?t+=1:r<2048?t+=2:r>=55296&&r<=56319?(t+=4,n++):t+=3}return t}var Ee=class{deps;installed=!1;onVisibility=()=>{document.visibilityState===`hidden`&&this.flush(`hidden`)};onPageHide=()=>{this.flush(`pagehide`)};onFreeze=()=>{this.flush(`freeze`)};onOpenFinClose=()=>{this.flush(`openfin-close`)};constructor(e){this.deps=e}install(){if(this.installed||typeof addEventListener>`u`)return;this.installed=!0,typeof document<`u`&&(document.addEventListener(`visibilitychange`,this.onVisibility),document.addEventListener(`freeze`,this.onFreeze)),addEventListener(`pagehide`,this.onPageHide);let e=globalThis.fin?.me;this.deps.diagnostics.guard(`openfin.unavailable`,`subscribing to close-requested`,()=>{e?.on?.(`close-requested`,this.onOpenFinClose)})}uninstall(){if(!this.installed)return;this.installed=!1,typeof document<`u`&&(document.removeEventListener(`visibilitychange`,this.onVisibility),document.removeEventListener(`freeze`,this.onFreeze)),removeEventListener(`pagehide`,this.onPageHide);let e=globalThis.fin?.me;this.deps.diagnostics.guard(`openfin.unavailable`,`releasing close-requested`,()=>{e?.removeListener?.(`close-requested`,this.onOpenFinClose)})}flush(t){let{diagnostics:n}=this.deps,r=this.endpointUrl();if(r===null)return;let i=this.deps.drainPending();if(!i||i.records.length===0)return;let a=n.guard(`transport.serialize_failed`,`the ${t} exit flush could not serialize its batch`,()=>this.deps.config.serializer.serialize(i.records));if(!a)return;if(k(a.body)>6e4){he(i,n);return}r.searchParams.set(e.rt,i.id),r.searchParams.set(e.it,t);let o=r.toString();this.beacon(o,a.body)||this.keepaliveFetch(o,a.body,t)}endpointUrl(){let{endpoint:e}=this.deps.config;return e?this.deps.diagnostics.guard(`config.invalid`,`the exit flush cannot use endpoint ${e}`,()=>new URL(e))??null:null}beacon(t,n){return this.deps.diagnostics.guard(`transport.http_error`,`sendBeacon`,()=>{let r=globalThis.navigator;return r?.sendBeacon?r.sendBeacon(t,new Blob([n],{type:e.E})):!1})===!0}keepaliveFetch(t,n,r){let{config:i,diagnostics:a}=this.deps;a.guard(`transport.http_error`,`the keepalive fetch fallback`,()=>{fetch(t,{method:`POST`,body:n,headers:{[e.H]:e.E},credentials:i.credentials,keepalive:!0}).catch(e=>{a.report(`transport.http_error`,`the exit flush failed`,{reason:r},e)})})}};async function De(t){let n=globalThis.CompressionStream;if(n===void 0)return null;let r=new Blob([t]).stream().pipeThrough(new n(e.P)),i=await new Response(r).arrayBuffer();return new Uint8Array(i)}var A=class extends Error{kind;status;retryAfterMs;maxBytes;constructor(e,t,n,r,i){super(t),this.kind=e,this.status=n,this.retryAfterMs=r,this.maxBytes=i,this.name=`TransportError`}};function Oe(t){if(!t)return;let n=Number(t);if(Number.isFinite(n))return Math.max(0,n*e.Q);let r=Date.parse(t);return Number.isNaN(r)?void 0:Math.max(0,r-Date.now())}var ke=class{config;diagnostics;throttledUntil=0;constructor(e,t){this.config=e,this.diagnostics=t}async send(e){!this.config.endpoint||e.records.length===0||await this.post(e)}throttledForMs(){return Math.max(0,this.throttledUntil-Date.now())}async post(t){let{config:n}=this,r;try{r=n.serializer.serialize(t.records)}catch(e){this.diagnostics.report(`transport.serialize_failed`,`serializer threw, dropping the batch`,{batchId:t.id},e);return}let i=new Headers(await this.resolveHeaders());i.set(e.H,r.contentType),i.set(e.B,t.id),i.set(e.z,String(t.attempts));let a=await this.encodeBody(r.body);typeof a!=`string`&&i.set(e.V,e.P);let o=await this.dispatch(i,a);if(o.ok){this.throttledUntil=0;return}throw await this.classify(o,t.id)}async encodeBody(e){let{config:t}=this;return t.compression!==`gzip`||k(e)<t.compressionThresholdBytes?e:await this.diagnostics.guardAsync(`transport.http_error`,`gzipping the payload`,()=>De(e))??e}async dispatch(e,t){let{config:n}=this,r=new AbortController,i=setTimeout(()=>{r.abort()},n.requestTimeoutMs);try{return await fetch(n.endpoint,{method:`POST`,headers:e,body:t,credentials:n.credentials,signal:r.signal,cache:`no-store`})}catch{if(r.signal.aborted)throw new A(`timeout`,`request exceeded ${String(n.requestTimeoutMs)}ms`);let e=globalThis.navigator?.onLine;throw new A(e===!1?`offline`:`transient`,`network error`)}finally{clearTimeout(i)}}async classify(t,n){let r=t.status,i=Oe(t.headers.get(e.U));if(r===401||r===403)return this.diagnostics.report(`transport.rejected_credentials`,`server returned ${String(r)}. In a cross-origin iframe the session cookie is a third-party cookie and is very likely blocked. Forward to the platform document instead of promoting to sender, or issue the cookie with the Partitioned attribute.`,{status:r,endpoint:this.config.endpoint}),new A(`permanent`,`rejected with ${String(r)}`,r);if(r===413)return new A(`too_large`,`payload too large`,r,void 0,await this.readMaxBytes(t));if(r===429||r===503){let e=r===429;return this.throttledUntil=Date.now()+(i??this.config.retry.baseDelayMs),e&&this.diagnostics.report(`transport.throttled`,`server throttled us`,{retryAfterMs:i}),new A(`throttled`,e?`throttled`:`service unavailable`,r,i)}return r===408||r>=500?new A(`transient`,`server error ${String(r)}`,r):(this.diagnostics.report(`transport.dropped_permanent`,`server rejected the batch with ${String(r)}, dropping it`,{batchId:n,status:r}),new A(`permanent`,`rejected with ${String(r)}`,r))}async readMaxBytes(e){return this.diagnostics.guardAsync(`transport.http_error`,`reading the 413 body`,async()=>{let t=JSON.parse(await e.text());return typeof t.maxBytes==`number`?t.maxBytes:void 0})}async resolveHeaders(){let{headers:e}=this.config;return e?typeof e==`function`?await this.diagnostics.guardAsync(`transport.http_error`,`headers() threw`,()=>Promise.resolve(e()))??{}:e:{}}};function j(e){let t=new Uint8Array(e);if(typeof crypto<`u`&&typeof crypto.getRandomValues==`function`)crypto.getRandomValues(t);else for(let n=0;n<e;n++)t[n]=Math.floor(Math.random()*256);return Array.from(t,e=>e.toString(16).padStart(2,`0`)).join(``)}function M(){try{if(typeof crypto<`u`&&typeof crypto.randomUUID==`function`)return crypto.randomUUID()}catch{}return j(16)}function N(e,t,n){return n.guard(`storage.unavailable`,`reading ${e}Storage`,()=>(e===`local`?localStorage:sessionStorage).getItem(t))??null}function P(e,t,n,r){r.guard(`storage.unavailable`,`writing ${e}Storage`,()=>{(e===`local`?localStorage:sessionStorage).setItem(t,n)})}function Ae(t){let n=M(),r=Date.now(),i=M(),a=N(`local`,e.Ct,t);if(a)try{let e=JSON.parse(a);e.id&&r-(e.lastSeenAt??0)<18e5&&(i=e.id)}catch{t.report(`storage.degraded`,`session record was not JSON, starting a new session`)}let o=JSON.stringify({id:i,lastSeenAt:r});P(`local`,e.Ct,o,t);let s=N(`session`,`ui-observability.tab`,t)??``;return s||(s=M(),P(`session`,e.Mt,s,t)),{sessionId:i,tabId:s,contextId:n}}var F=0;function je(t,n){let r=Date.now();if(r-F<6e4)return;F=r;let i=JSON.stringify({id:t,lastSeenAt:r});P(`local`,e.Ct,i,n)}function Me(e){if(e.records.length<2)return null;let t=Math.floor(e.records.length/2),n=t=>({id:M(),records:t,createdAt:e.createdAt,attempts:e.attempts});return[n(e.records.slice(0,t)),n(e.records.slice(t))]}var Ne=class{storage;transport;diagnostics;config;batchesPerDrain;timer=null;attempt=0;draining=!1;stopped=!1;onOnline=()=>{this.attempt=0,this.schedule(0)};constructor(e,t,n,r,i=20){this.storage=e,this.transport=t,this.diagnostics=n,this.config=r,this.batchesPerDrain=i}start(){this.stopped=!1,typeof addEventListener<`u`&&addEventListener(`online`,this.onOnline),this.schedule(this.config.retry.idleDelayMs)}nudge(){this.draining||this.schedule(this.config.retry.baseDelayMs)}stop(){this.stopped=!0,typeof removeEventListener<`u`&&removeEventListener(`online`,this.onOnline),this.clearTimer()}schedule(e){if(this.stopped)return;this.clearTimer();let t=setTimeout(()=>{this.drain()},e);this.timer=t,u(t)}clearTimer(){this.timer!==null&&(clearTimeout(this.timer),this.timer=null)}backoffMs(){let e=Math.min(this.config.retry.baseDelayMs*2**this.attempt,this.config.retry.maxDelayMs);return Math.random()*e}async drain(){if(!this.draining){this.draining=!0;try{await S(`ui-observability.drain`,this.diagnostics,()=>this.drainLocked())!==!0&&this.schedule(this.config.retry.idleDelayMs)}finally{this.draining=!1}}}async drainLocked(){try{if(globalThis.navigator?.onLine===!1)return this.schedule(this.config.retry.idleDelayMs),!0;let e=await this.storage.take(this.batchesPerDrain);if(e.length===0)return this.schedule(this.config.retry.idleDelayMs),!0;for(let t of e)if(this.stopped||!await this.deliver(t))return!0;return this.schedule(e.length===this.batchesPerDrain?0:this.config.retry.idleDelayMs),!0}catch(e){return this.diagnostics.report(`storage.degraded`,`the drain loop threw`,void 0,e),this.attempt++,this.schedule(this.backoffMs()),!0}}async deliver(e){if(e.attempts>=this.config.storage.maxAttempts)return this.diagnostics.report(`storage.dead_lettered`,`giving up on a batch after ${e.attempts.toString()} attempts`,{batchId:e.id,records:e.records.length}),await this.storage.remove(e.id),!0;try{return await this.transport.send(e),await this.storage.remove(e.id),this.attempt=0,!0}catch(t){let n=t instanceof A?t:void 0;return n?.kind===`permanent`?(await this.storage.remove(e.id),!0):n?.kind===`too_large`?(await this.splitStored(e,n.maxBytes),!0):n?.kind===`offline`?(this.schedule(this.config.retry.idleDelayMs),!1):(await this.storage.bumpAttempts(e.id,e.attempts+1),this.attempt++,this.schedule(n?.retryAfterMs??this.backoffMs()),!1)}}async splitStored(e,t){let n=Me(e);if(await this.storage.remove(e.id),!n){this.diagnostics.report(`transport.dropped_permanent`,`a single record exceeds the server limit and was dropped`,{batchId:e.id,bodies:e.records.map(e=>e.body)});return}this.diagnostics.report(`transport.batch_split`,`the server refused the batch as too large`,{from:e.records.length,to:n[0].records.length,serverMaxBytes:t});for(let e of n)await this.storage.save(e)}},I={TRACE:`debug`,DEBUG:`debug`,INFO:`info`,WARN:`warn`,ERROR:`error`,FATAL:`error`},Pe=class{enabled;minLevel;constructor(e,t){this.enabled=e,this.minLevel=t}update(e,t){this.enabled=e,this.minLevel=t}write(t,n,r){if(!this.enabled||e.J[t]<e.J[this.minLevel]||typeof console>`u`)return;let i=`%c${e.Y}%c ${t}`;if(r===void 0){console[I[t]](i,e.C,``,n);return}console[I[t]](i,e.C,``,n,r)}},L=null;function R(e,t){let n=e[t];return n!==void 0&&e instanceof n}function Fe(t){if(L)return L;let n=globalThis,r=n.navigator?.userAgent??``,i=`browser`,a,o,s=!1,c=n.fin?.me;return R(n,`ServiceWorkerGlobalScope`)?(i=`service_worker`,s=!0):R(n,`SharedWorkerGlobalScope`)?(i=`shared_worker`,s=!0):R(n,`WorkerGlobalScope`)?(i=`web_worker`,s=!0):c===void 0?n.Capacitor!==void 0||n.Ionic!==void 0?i=`ionic`:n.cordova!==void 0||Ie(r)?i=`mobile_webview`:typeof document>`u`&&typeof process<`u`&&(i=`node`):(i=e.nt.test(r)?`openfin`:`openfin_web`,t.guard(`openfin.unavailable`,`reading fin.me.identity`,()=>{let e=c.identity;a=e?.uuid,o=e?.name})),L={platform:i,openfinUuid:a,openfinName:o,userAgent:r,isWorker:s,isTopLevelDocument:Le()},L}function Ie(t){return e.t.test(t)?!0:(e.K.test(t)||e.Z.test(t)&&e.$.test(t))&&t.includes(`AppleWebKit`)&&!t.includes(`Safari/`)}function Le(){if(typeof window>`u`)return!1;try{return window.self===window.top}catch{return!1}}function Re(){try{return typeof location<`u`?location.href:``}catch{return``}}var ze=class{value=0;next(){return++this.value}reset(){this.value=0}};function Be(){return j(16)}function Ve(){return j(8)}function z(){return{traceId:Be(),spanId:Ve(),traceFlags:1,startedAt:Date.now()}}function B(e){return{traceId:e.traceId,spanId:e.spanId,traceFlags:e.traceFlags}}var He=class{diagnostics;maxAgeMs;ambient=z();constructor(t,n=e.It){this.diagnostics=t,this.maxAgeMs=n}resolve(){let e=this.diagnostics.guard(`trace.otel_failed`,`reading the active OpenTelemetry span`,()=>{let e=t.trace.getActiveSpan();if(e===void 0)return;let n=e.spanContext();if((0,t.isSpanContextValid)(n))return{traceId:n.traceId,spanId:n.spanId,traceFlags:n.traceFlags}});return e===void 0?(Date.now()-this.ambient.startedAt>this.maxAgeMs&&this.rotate(`maxAge`),B(this.ambient)):e}rotate(e){return this.ambient=z(),B(this.ambient)}headers(){let e={};if(this.diagnostics.guard(`trace.otel_failed`,`injecting OpenTelemetry headers`,()=>{t.propagation.inject(t.context.active(),e)}),!e.traceparent){let t=this.resolve(),n=(t.traceFlags&255).toString(16).padStart(2,`0`);e.traceparent=`00-${t.traceId}-${t.spanId}-${n}`}return e}},Ue=class{buffer;pointer=0;filled=!1;capacity;constructor(e){this.capacity=Math.max(e,1),this.buffer=Array(this.capacity)}resize(e){let t=Math.max(e,1);if(t===this.capacity)return;let n=this.snapshot().slice(-t);this.capacity=t,this.clear();for(let e of n)this.push(e)}push(e){this.buffer[this.pointer]=e,this.pointer=(this.pointer+1)%this.capacity,this.pointer===0&&(this.filled=!0)}snapshot(){return(this.filled?[...this.buffer.slice(this.pointer),...this.buffer.slice(0,this.pointer)]:this.buffer.slice(0,this.pointer)).filter(e=>e!==void 0)}clear(){this.buffer=Array(this.capacity),this.pointer=0,this.filled=!1}},We={name:`ecs`,serialize(t){return{body:`${t.map(t=>{let n=Number(BigInt(t.timeUnixNano)/e.et);return JSON.stringify({"@timestamp":new Date(n).toISOString(),message:t.body,log:{level:t.severityText.toLowerCase()},trace:{id:t.traceId},span:{id:t.spanId},service:{name:t.resource[e.ft],version:t.resource[e.pt],environment:t.resource[e.ct]},user_agent:{original:t.resource[e.ot]},url:{full:t.attributes[`url.full`]??t.attributes[`page.url`]},labels:{...t.resource,...t.attributes}})}).join(`
3
+ `)}\n`,contentType:e.T}}};function V(e){return e==null?null:typeof e==`string`?{stringValue:e}:typeof e==`boolean`?{boolValue:e}:typeof e==`number`?Number.isInteger(e)?{intValue:String(e)}:{doubleValue:e}:typeof e==`bigint`?{intValue:e.toString()}:Array.isArray(e)?{arrayValue:{values:e.map(V).filter(e=>e!==null)}}:typeof e==`object`?{kvlistValue:{values:H(e)}}:null}function H(e){let t=[];for(let[n,r]of Object.entries(e)){let e=V(r);e&&t.push({key:n,value:e})}return t}var U=new WeakMap;function Ge(e){let t=U.get(e);if(t!==void 0)return t;let n=JSON.stringify(e);return U.set(e,n),n}var W={name:e.xt,serialize(t){let n=new Map;for(let e of t){let t=Ge(e.resource),r=n.get(t);if(r){r.records.push(e);continue}n.set(t,{resource:e.resource,records:[e]})}let r=[...n.values()].map(t=>({resource:{attributes:H(t.resource)},scopeLogs:[{scope:{name:e.Pt,version:e.Ft},logRecords:t.records.map(e=>({timeUnixNano:e.timeUnixNano,observedTimeUnixNano:e.observedTimeUnixNano??e.timeUnixNano,severityNumber:e.severityNumber,severityText:e.severityText,body:{stringValue:e.body},traceId:e.traceId,spanId:e.spanId,flags:e.traceFlags,attributes:H(e.attributes)}))}]}));return{body:JSON.stringify({resourceLogs:r}),contentType:e.w}}};function Ke(e){return typeof e!=`object`||!e?!1:typeof Reflect.get(e,`serialize`)==`function`}function qe(t,n,r){return t===void 0?n??W:t===`otlp`?W:t===`ecs`?We:Ke(t)?t:(r.report(`config.invalid`,`serializer must be "${e.xt}", "ecs" or an implementation`),W)}function Je(t,n,r){let i=r??e.D,a={...i,...t,serializer:qe(t.serializer,r?.serializer,n),streams:{logs:{...i.streams.logs,...t.streams?.logs},metrics:{...i.streams.metrics,...t.streams?.metrics}},storage:{...i.storage,...t.storage},retry:{...i.retry,...t.retry},sampling:{...i.sampling,...t.sampling,rates:{...i.sampling.rates,...t.sampling?.rates}},journey:{...i.journey,...t.journey},bus:{...i.bus,...t.bus},capture:{...i.capture,...t.capture},limits:{...i.limits,...t.limits},console:{...i.console,...t.console}};if(!a.endpoint)n.report(`config.invalid`,`endpoint is missing. Records will be built and dropped, never sent.`);else try{new URL(a.endpoint)}catch(e){n.report(`config.invalid`,`endpoint is not a valid absolute URL: ${a.endpoint}`,void 0,e)}a.serviceName||=(n.report(`config.invalid`,`serviceName is missing. Every record will report service.name as '${e.zt}'.`),e.zt);let o=a.sampling.defaultRate;(typeof o!=`number`||o<0||o>1)&&(n.report(`config.invalid`,`sampling.defaultRate must be 0..1, got ${String(o)}`),a.sampling.defaultRate=1);let s=Object.entries(a.sampling.rates);for(let[e,t]of s)(typeof t!=`number`||t<0||t>1)&&(n.report(`config.invalid`,`sampling.rates["${e}"] must be 0..1, got ${String(t)}`),a.sampling.rates[e]=1);a.capture.ignoreUrls=a.capture.ignoreUrls.filter(e=>e!==r?.endpoint),a.endpoint&&!a.capture.ignoreUrls.includes(a.endpoint)&&(a.capture.ignoreUrls=[...a.capture.ignoreUrls,a.endpoint]);let c=new Set([...Object.keys(e.D),...e.Rt]);for(let e of Object.keys(t))c.has(e)||n.report(`config.invalid`,`unknown config key "${e}", ignored. Typo?`);return a}function Ye(t,n){for(let r of Object.keys(n))e.S.includes(r)||Object.assign(t,{[r]:n[r]});for(let r of e.S)Object.assign(t[r],n[r])}var Xe=class{map=new Map;set(e,t){this.map.set(e,t)}setMany(e){for(let[t,n]of Object.entries(e))this.map.set(t,n)}get(e){return this.map.get(e)}remove(e){this.map.delete(e)}clear(){this.map.clear()}getAll(){return Object.fromEntries(this.map)}},Ze=class{handler;throttleMs;counters=new Map;lastEmitted=new Map;constructor(t,n=e.k){this.handler=t,this.throttleMs=n}setHandler(e){this.handler=e}count(e,t=1){let n=(this.counters.get(e)??0)+t;return this.counters.set(e,n),n}report(t,n,r,i){let a=this.count(t),o=Date.now();if(o-(this.lastEmitted.get(t)??0)<this.throttleMs)return;this.lastEmitted.set(t,o);let s={code:t,message:n,detail:r,cause:i,at:o,count:a};if(this.handler)try{this.handler(s)}catch(t){this.count(`handler.threw`),typeof console<`u`&&console.warn(`${e.Y} onDiagnostic handler threw`,t)}}guard(e,t,n){try{return n()}catch(n){this.report(e,t,void 0,n);return}}async guardAsync(e,t,n){try{return await n()}catch(n){this.report(e,t,void 0,n);return}}snapshot(){return Object.fromEntries(this.counters)}reset(){this.counters.clear(),this.lastEmitted.clear()}};function G(e,t){let n=Reflect.get(e,t);return typeof n==`string`&&n!==``?n:void 0}function Qe(e,t){let n=Reflect.get(e,t);return typeof n==`number`&&Number.isFinite(n)?n:void 0}function $e(e){if(typeof e!=`object`||!e)return null;let t=G(e,`id`),n=G(e,`name`),r=Qe(e,`startedAt`);return t===void 0||n===void 0||r===void 0?null:{id:t,name:n,startedAt:r,parentId:G(e,`parentId`),ownerContextId:G(e,`ownerContextId`)??``}}function et(e){if(typeof e!=`object`||!e)return null;let t=G(e,`i`),n=G(e,`n`);return t===void 0||n===void 0?null:{id:t,name:n,startedAt:Qe(e,`s`)??Date.now(),parentId:void 0,ownerContextId:``}}function tt(t){let n=JSON.stringify({i:t.id,n:t.name.slice(0,64),s:t.startedAt}),r=new TextEncoder().encode(n),i=``;for(let e of r)i+=String.fromCharCode(e);return btoa(i).replace(e.g,`-`).replace(e._,`_`).replace(e.h,``)}var nt=class{options;diagnostics;contextId;onLocalChange;journey=null;expiryTimer=null;constructor(e,t,n,r){this.options=e,this.diagnostics=t,this.contextId=n,this.onLocalChange=r}current(){return this.journey}async bootstrap(){let t=this.readUrlToken();if(t&&this.adopt(t,`url`))return;let n=this.diagnostics.guard(`storage.unavailable`,`reading the persisted journey`,()=>sessionStorage.getItem(e.q));if(n&&this.restore(n))return;let r=await this.readOpenFinToken();r!==null&&this.adopt(r,`openfin.customData`)}start(e,t={}){let n={id:t.id??M(),name:e,startedAt:Date.now(),parentId:t.parent?this.journey?.id:void 0,ownerContextId:this.contextId};return this.setJourney(n),this.onLocalChange(n),n}end(){this.journey!==null&&(this.setJourney(null),this.onLocalChange(null))}applyRemote(e){let t=this.journey;(e===null||t===null||e.id!==t.id)&&this.setJourney(e)}getToken(){let e=this.journey;if(e===null)return;let t=tt(e);if(t.length>256){this.diagnostics.report(`journey.token_too_large`,`journey token exceeded the size cap and was not issued`,{length:t.length});return}return t}adopt(e,t,n=!1){let r=this.decodeToken(e);return r===null?!1:Date.now()-r.startedAt>this.options.maxAgeMs?(this.diagnostics.report(`journey.expired`,`discarded a seeded journey older than maxAgeMs`,{source:t,name:r.name}),!1):(this.setJourney(r),this.diagnostics.report(`journey.adopted`,`adopted journey "${r.name}"`,{source:t,journeyId:r.id}),n&&this.onLocalChange(r),!0)}ownerClosed(e){this.options.endOnOwnerClose&&this.journey?.ownerContextId===e&&this.end()}destroy(){this.clearTimer()}restore(e){let t=$e(this.diagnostics.guard(`storage.degraded`,`parsing the persisted journey`,()=>JSON.parse(e)));return t===null?!1:Date.now()-t.startedAt>this.options.maxAgeMs?(this.diagnostics.report(`journey.expired`,`discarded a persisted journey older than maxAgeMs`,{name:t.name}),this.clearStored(),!1):(this.setJourney(t),this.diagnostics.report(`journey.adopted`,`resumed journey "${t.name}"`,{source:`sessionStorage`,journeyId:t.id}),!0)}decodeToken(t){return this.diagnostics.guard(`config.invalid`,`decoding a seeded journey token`,()=>{let n=t.replace(e.p,`+`).replace(e.m,`/`),r=(4-n.length%4)%4,i=`=`.repeat(r),a=Uint8Array.from(atob(n+i),e=>e.charCodeAt(0));return et(JSON.parse(new TextDecoder().decode(a)))})??null}setJourney(t){if(this.journey=t,this.clearTimer(),this.diagnostics.guard(`storage.unavailable`,`persisting the journey`,()=>{t===null?sessionStorage.removeItem(e.q):sessionStorage.setItem(e.q,JSON.stringify(t))}),t===null)return;let n=Math.max(this.options.maxAgeMs-(Date.now()-t.startedAt),0),r=setTimeout(()=>{this.diagnostics.report(`journey.expired`,`journey "${t.name}" hit maxAgeMs and was ended automatically`,{journeyId:t.id}),this.journey=null,this.expiryTimer=null,this.clearStored()},n);this.expiryTimer=r,u(r)}clearStored(){this.diagnostics.guard(`storage.unavailable`,`clearing the persisted journey`,()=>{sessionStorage.removeItem(e.q)})}clearTimer(){this.expiryTimer!==null&&(clearTimeout(this.expiryTimer),this.expiryTimer=null)}readUrlToken(){return this.diagnostics.guard(`config.invalid`,`reading the journey token from the URL`,()=>typeof location>`u`?null:new URL(location.href).searchParams.get(this.options.urlParam))??null}async readOpenFinToken(){let t=globalThis.fin?.me,n=t?.getOptions;if(n===void 0)return null;let r=(await this.diagnostics.guardAsync(`openfin.unavailable`,`reading fin.me.getOptions()`,()=>n.call(t)))?.customData?.[e.tt];return typeof r==`string`?r:null}};function rt(t){let n=e.I;for(let r=0;r<t.length;r++)n^=t.charCodeAt(r),n=Math.imul(n,e.L);return n>>>0}function K(e,t){let n=e.attributes[t];return typeof n==`string`?n:``}function it(e,t){let{rates:n,defaultRate:r}=t.sampling,i,a=-1;for(let[t,r]of Object.entries(n))(e===t||e.startsWith(`${t}.`))&&t.length>a&&(i=r,a=t.length);return i??r}function at(t,n){if(t.severityText===`ERROR`||t.severityText===`FATAL`||n.sampling.alwaysSampleTypes.includes(K(t,`log.type`)))return!0;let r=it(K(t,e.n),n);return r>=1?!0:r<=0?!1:rt(K(t,`journey.id`)||t.traceId)/e.Lt<r}function ot(t){return t.attributes[e.l]===e.X}var st=class{config;name;diagnostics;pending=[];constructor(e,t,n){this.config=e,this.name=t,this.diagnostics=n}get options(){return this.config.streams[this.name]}get capacity(){return Math.max(this.options.batchSize,1)*10}add(e){this.pending.length>=this.capacity&&(this.pending.shift(),this.diagnostics.count(`record.dropped_pending_full`)),this.pending.push(e)}take(){let e=this.pending;return this.pending=[],e}},ct=class{config;transport;storage;retry;diagnostics;records$=new n.Subject;streams;subscription=null;unconfirmed=new Map;stopped=!1;constructor(e,t,n,r,i){this.config=e,this.transport=t,this.storage=n,this.retry=r,this.diagnostics=i,this.streams={logs:new st(e,`logs`,i),metrics:new st(e,`metrics`,i)},this.subscribe()}push(e){this.stopped||(e.observedTimeUnixNano=b(),this.records$.next(e))}drainPending(){let e=[...[...this.unconfirmed.values()].flatMap(e=>e.records),...this.streams.metrics.take(),...this.streams.logs.take()];return this.unconfirmed.clear(),e.length===0?null:{id:M(),records:e,createdAt:Date.now(),attempts:0}}refresh(){this.subscription?.unsubscribe(),this.subscribe()}destroy(){this.stopped=!0,this.subscription?.unsubscribe(),this.subscription=null,this.records$.complete()}subscribe(){if(this.stopped)return;let[e,t]=(0,n.partition)(this.records$,ot);this.subscription=(0,n.merge)(this.batches(e,this.streams.metrics),this.batches(t,this.streams.logs)).pipe((0,n.catchError)(e=>(this.diagnostics.report(`pipeline.crashed`,`the pipeline errored and was restarted`,void 0,e),this.subscribe(),n.EMPTY)),(0,n.observeOn)(n.asapScheduler),(0,n.mergeMap)(e=>(0,n.from)(this.dispatch(e)).pipe((0,n.catchError)(t=>(this.diagnostics.report(`pipeline.crashed`,`dispatch rejected, which it is written never to do`,{batchId:e.id},t),n.EMPTY))),this.config.maxConcurrentRequests)).subscribe()}batches(e,t){return e.pipe((0,n.filter)(e=>at(e,this.config)?!0:(this.diagnostics.count(`record.dropped_by_sampling`),!1)),(0,n.tap)(e=>{t.add(e)}),(0,n.bufferTime)(t.options.flushIntervalMs,null,t.options.batchSize),(0,n.map)(()=>this.claim(t)),(0,n.filter)(e=>e!==null))}claim(e){let t=e.take();if(t.length===0)return null;let n={id:M(),records:t,createdAt:Date.now(),attempts:0};return this.unconfirmed.set(n.id,n),n}async dispatch(e){try{let t=this.transport.throttledForMs();if(t>0){await this.store(e),this.diagnostics.report(`transport.throttled`,`stored the batch rather than sending it`,{batchId:e.id,records:e.records.length,throttledMs:t});return}try{await this.transport.send(e)}catch(t){await this.store({...e,attempts:e.attempts+1}),this.diagnostics.report(`transport.http_error`,`batch was stored for retry instead of being delivered`,{batchId:e.id,records:e.records.length},t)}}finally{this.unconfirmed.delete(e.id)}}async store(e){await this.diagnostics.guardAsync(`storage.degraded`,`persisting an undelivered batch`,async()=>{await this.storage.save(e),this.retry.nudge()})}};function q(e){return e}var lt=class{deps;resourceCache=null;constructor(e){this.deps=e}invalidateResource(){this.resourceCache=null}isEnabled(t){let{config:n}=this.deps;return n.enabled?e.J[t]>=e.J[n.minLevel]:!1}build(t){let{config:n,diagnostics:r,tracing:i,journey:a,sequence:o}=this.deps;if(!this.isEnabled(t.level))return r.count(`record.dropped_by_level`),null;let s=n.limits,c=i.resolve(),l=a.current(),u=o.next(),d=Re(),f,p=0;try{let e=E(this.deps.context.getAll(),s),n=E(t.scoped??{},s),r=E(t.payload??{},s);p=e.bytes+n.bytes+r.bytes,f={...q(e.value),...q(n.value),...q(r.value)}}catch(t){r.report(`record.sanitize_failed`,`attributes could not be sanitized`,void 0,t),f={[e.d]:!0}}f[e.l]=t.type,f[e.c]=u,f[e.n]=t.namespace,f[e.u]=d,l&&(f[e.a]=l.id,f[e.o]=l.name,l.parentId!==void 0&&(f[e.s]=l.parentId));let m=T(t.body,s.maxBodyChars);m!==t.body&&r.count(`record.truncated`);let h={timeUnixNano:b(),traceId:c.traceId,spanId:c.spanId,traceFlags:c.traceFlags,severityNumber:e.Tt[t.level],severityText:t.level,body:m,attributes:f,resource:this.resource()},g=n.redact;if(g){let e=r.guard(`record.sanitize_failed`,`redact hook threw`,()=>g(h));if(e===null)return r.count(`record.dropped_by_redact`),null;if(e!==void 0&&e!==h){if(x(e)){let t=E(e.attributes,s);h={...e,attributes:q(t.value)},p=t.bytes}else r.report(`record.sanitize_failed`,`redact hook returned something that is not a record, keeping the original`)}}if(p>s.maxRecordBytes){r.report(`record.truncated`,`attributes exceeded the size budget and were dropped`,{bytes:p,body:h.body});let n={[e.l]:t.type,[e.c]:u,[e.n]:t.namespace,[e.u]:d,[e.i]:!0,[e.r]:p};l&&(n[e.a]=l.id,n[e.o]=l.name),h.attributes=n}return h}resource(){if(this.resourceCache)return this.resourceCache;let{config:t,identity:n,platform:r}=this.deps;return this.resourceCache={[e.ft]:t.serviceName,[e.pt]:t.serviceVersion,[e.ct]:t.environment,[e._t]:e.Pt,[e.vt]:e.Ft,[e.gt]:e.Nt,[e.lt]:r.platform,[e.mt]:n.sessionId,[e.ht]:n.tabId,[e.st]:n.contextId,[e.ot]:r.userAgent,...r.openfinUuid===void 0?{}:{[e.dt]:r.openfinUuid},...r.openfinName===void 0?{}:{[e.ut]:r.openfinName}},this.resourceCache}},J=Symbol.for(e.yt),Y=class t{diagnostics;config;platform;identity;context=new Xe;breadcrumbs;tracing;sequence=new ze;journey;builder;console;bus;storage;transport;retry;pipeline;exitFlush;captures=[];bootBuffer=[];forwardBuffer=[];forwardScheduled=!1;ready=!1;destroyed=!1;lastGapAt=0;constructor(e){this.diagnostics=new Ze(e.onDiagnostic),this.platform=Fe(this.diagnostics),this.config=Je(e,this.diagnostics),this.identity=Ae(this.diagnostics),this.breadcrumbs=new Ue(this.config.capture.maxBreadcrumbs),this.tracing=new He(this.diagnostics),this.console=new Pe(this.config.console.enabled,this.config.console.level),this.journey=new nt(this.config.journey,this.diagnostics,this.identity.contextId,e=>{this.bus.broadcastJourney(e)}),this.builder=new lt({config:this.config,diagnostics:this.diagnostics,context:this.context,journey:this.journey,tracing:this.tracing,sequence:this.sequence,identity:this.identity,platform:this.platform}),this.bus=new ae(this.config,this.diagnostics,this.platform,this.identity.contextId,this.identity.tabId,{onRecords:e=>{this.ingestForwarded(e)},onJourney:e=>{this.journey.applyRemote(e)},onJourneyRequest:()=>this.journey.current(),onTabConflict:()=>{this.regenerateTabId()}})}busAccept=(e,t)=>{this.destroyed||this.diagnostics.guard(`bus.send_failed`,`accepting a direct message from a child`,()=>{this.bus.acceptDirect(e,t)})};static current(){return globalThis[J]??null}static configure(e){let n=t.current();if(n&&!n.destroyed)return n.reconfigure(e),n;let r=new t(e);return globalThis[J]=r,r.init(),r}reconfigure(e){Ye(this.config,Je(e,this.diagnostics,this.config)),this.diagnostics.setHandler(this.config.onDiagnostic),this.builder.invalidateResource(),this.console.update(this.config.console.enabled,this.config.console.level),this.breadcrumbs.resize(this.config.capture.maxBreadcrumbs),this.pipeline?.refresh(),this.ready&&this.reinstallCaptures(),this.diagnostics.report(`config.reconfigured`,`configure() was called again, the existing runtime was updated`)}async init(){try{let e=this.journey.bootstrap();await this.bus.start()===`sender`&&await this.becomeSender(),await e,this.installCaptures()}catch(e){this.diagnostics.report(`pipeline.crashed`,`startup failed, continuing in a degraded state`,void 0,e)}finally{this.ready=!0,this.releaseBootBuffer()}}async becomeSender(){this.storage=await Ce(this.config.storage.strategy,this.config.storage.dbName,this.config.storage,this.diagnostics,this.reportGap),this.transport=new ke(this.config,this.diagnostics),this.retry=new Ne(this.storage,this.transport,this.diagnostics,this.config),this.pipeline=new ct(this.config,this.transport,this.storage,this.retry,this.diagnostics),this.exitFlush=new Ee({config:this.config,diagnostics:this.diagnostics,drainPending:()=>this.pipeline?.drainPending()??null}),await ge(this.storage,this.diagnostics),this.retry.start(),this.exitFlush.install()}installCaptures(){let t={config:this.config,diagnostics:this.diagnostics,breadcrumbs:this.breadcrumbs,tracing:this.tracing,logger:new l(this,e.x)},n=this.config.capture;(n.errors||n.rejections||n.resourceErrors)&&this.captures.push(new oe(t)),(n.fetch||n.xhr)&&this.captures.push(new le(t)),(n.interactions||n.navigation)&&this.captures.push(new ce(t)),n.webVitals&&this.captures.push(new de(t));for(let e of this.captures)this.diagnostics.guard(`capture.install_failed`,`installing ${e.name}`,()=>{e.install()})}reinstallCaptures(){for(let e of this.captures)this.diagnostics.guard(`capture.install_failed`,`uninstalling ${e.name}`,()=>{e.uninstall()});this.captures.length=0,this.installCaptures()}registerWorker(e){this.destroyed||this.diagnostics.guard(`bus.send_failed`,`registering a worker`,()=>{this.bus.attachWorker(e)})}async destroy(){if(!this.destroyed){this.destroyed=!0;for(let e of this.captures)e.uninstall();this.captures.length=0,this.exitFlush?.flush(`shutdown`),this.exitFlush?.uninstall(),this.retry?.stop(),this.pipeline?.destroy(),this.journey.destroy(),this.bus.destroy(),this.forwardBuffer=[],await this.storage?.close(),t.current()===this&&Reflect.deleteProperty(globalThis,J)}}emit(e){if(!(!e||this.destroyed)){if(je(this.identity.sessionId,this.diagnostics),!this.ready){this.bootBuffer.length>=this.config.bus.maxBootBufferRecords&&(this.bootBuffer.shift(),this.diagnostics.count(`record.dropped_boot_buffer_full`)),this.bootBuffer.push(e);return}this.route(e)}}route(e){if(this.bus.getRole()===`forwarder`){this.forward(e);return}this.pipeline?.push(e)}forward(e){this.forwardBuffer.push(e),!this.forwardScheduled&&(this.forwardScheduled=!0,queueMicrotask(()=>{this.forwardScheduled=!1;let e=this.forwardBuffer;this.forwardBuffer=[],e.length>0&&this.bus.sendRecords(e)}))}ingestForwarded(e){if(!Array.isArray(e)){this.diagnostics.count(`record.dropped_malformed`);return}for(let t of e){if(!x(t)){this.diagnostics.count(`record.dropped_malformed`);continue}this.pipeline?.push(t)}}releaseBootBuffer(){let e=this.bootBuffer;this.bootBuffer=[];let t=this.journey.current();for(let n of e)t&&!n.attributes[`journey.id`]&&(n.attributes[`journey.id`]=t.id,n.attributes[`journey.name`]=t.name),this.route(n)}reportGap=t=>{let n=Date.now();n-this.lastGapAt<6e4||(this.lastGapAt=n,new l(this,e.Et).warn(`stored records were dropped before delivery`,{"gap.batches":t.batches,"gap.records":t.records,"gap.reason":t.reason}))};regenerateTabId(){let t=M();this.diagnostics.report(`bus.role_resolved`,`another context claimed this tab id, most likely a duplicated tab. Regenerating.`,{was:this.identity.tabId,now:t}),this.identity.tabId=t,this.diagnostics.guard(`storage.unavailable`,`persisting the new tab id`,()=>{sessionStorage.setItem(e.Mt,t)}),this.builder.invalidateResource()}async queueDepth(){return await this.diagnostics.guardAsync(`storage.degraded`,`counting the batches waiting in storage`,()=>this.storage?.count()??Promise.resolve(0))??0}async flush(){if(this.bus.getRole()===`forwarder`){let e=this.forwardBuffer;this.forwardBuffer=[],e.length>0&&this.bus.sendRecords(e);return}let e=this.pipeline?.drainPending();if(!(!e||!this.transport))try{await this.transport.send(e)}catch(t){await this.diagnostics.guardAsync(`storage.degraded`,`persisting the batch drained by flush()`,async()=>{await this.storage?.save({...e,attempts:1}),this.retry?.nudge()}),this.diagnostics.report(`transport.http_error`,`the batch drained by flush() was stored for retry instead of being delivered`,{batchId:e.id,records:e.records.length},t)}}},X=new Map;function Z(){return Y.current()||Y.configure({})}function ut(e){Y.configure(e),X.clear()}function Q(e,t){let n=t?`${e}::${JSON.stringify(t)}`:e,r=X.get(n);return r||(r=new l(Z(),e,t),X.set(n,r)),r}function $(){return Q(`app`)}function dt(e,t){$().trace(e,t)}function ft(e,t){$().debug(e,t)}function pt(e,t){$().info(e,t)}function mt(e,t){$().warn(e,t)}function ht(e,t,n){$().error(e,t,n)}function gt(e,t){$().logAction(e,t)}function _t(e,t){$().logEvent(e,t)}function vt(e,t,n,r,i){$().logMetric(e,t,n,r,i)}function yt(e,t,n){return $().timeSync(e,t,n)}function bt(e,t,n){return $().timeAsync(e,t,n)}function xt(e,t){Z().context.set(e,t)}function St(e){Z().context.setMany(e)}function Ct(e){Z().context.remove(e)}function wt(e,t){return Z().journey.start(e,t)}function Tt(){Z().journey.end()}function Et(){return Z().journey.current()}function Dt(){return Z().journey.getToken()}function Ot(e){return Z().journey.adopt(e,`manual`,!0)}function kt(e){Z().registerWorker(e)}function At(){Z().tracing.rotate(`explicit`)}function jt(){return Z().tracing.headers()}function Mt(){return Z().flush()}function Nt(){return Z().queueDepth()}function Pt(){return Z().diagnostics.snapshot()}async function Ft(){let e=Y.current();X.clear(),await e?.destroy()}exports.OneLogger=l,exports.adoptJourney=Ot,exports.configure=ut,exports.currentJourney=Et,exports.debug=ft,exports.endJourney=Tt,exports.error=ht,exports.flush=Mt,exports.getDiagnosticCounters=Pt,exports.getJourneyToken=Dt,exports.getLogger=Q,exports.getQueueDepth=Nt,exports.getTraceHeaders=jt,exports.info=pt,exports.logAction=gt,exports.logEvent=_t,exports.logMetric=vt,exports.registerWorker=kt,exports.removeContext=Ct,exports.setContext=xt,exports.setContextMap=St,exports.shutdown=Ft,exports.startJourney=wt,exports.startTrace=At,exports.timeAsync=bt,exports.timeSync=yt,exports.trace=dt,exports.warn=mt;
4
+ //# sourceMappingURL=index.cjs.map