browser-devtools-mcp 0.1.7 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +93 -21
- package/README.md +82 -16
- package/SECURITY.md +9 -0
- package/dist/cli.js +53 -1721
- package/dist/core.js +764 -0
- package/dist/daemon-server.js +1 -338
- package/dist/index.d.ts +2 -0
- package/dist/index.js +210 -80
- package/dist/otel/otel-initializer.bundle.js +0 -1
- package/dist/tools/a11y/index.d.ts +2 -0
- package/dist/tools/content/index.d.ts +2 -0
- package/dist/tools/debug/index.d.ts +2 -0
- package/dist/tools/figma/compare/index.d.ts +56 -0
- package/dist/tools/figma/compare/types.d.ts +15 -0
- package/dist/tools/figma/index.d.ts +2 -0
- package/dist/tools/index.d.ts +4 -0
- package/dist/tools/interaction/index.d.ts +2 -0
- package/dist/tools/navigation/index.d.ts +2 -0
- package/dist/tools/o11y/index.d.ts +2 -0
- package/dist/tools/react/index.d.ts +2 -0
- package/dist/tools/run/index.d.ts +2 -0
- package/dist/tools/stub/index.d.ts +2 -0
- package/dist/tools/sync/index.d.ts +2 -0
- package/dist/tools/types.d.ts +21 -0
- package/dist/types.d.ts +78 -0
- package/package.json +11 -11
- package/dist/browser.js +0 -213
- package/dist/browser.js.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/config.js +0 -96
- package/dist/config.js.map +0 -1
- package/dist/context.js +0 -298
- package/dist/context.js.map +0 -1
- package/dist/daemon-server.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/logger.js +0 -97
- package/dist/logger.js.map +0 -1
- package/dist/mcp-server.js +0 -401
- package/dist/mcp-server.js.map +0 -1
- package/dist/otel/otel-controller.js +0 -323
- package/dist/otel/otel-controller.js.map +0 -1
- package/dist/otel/otel-initializer.bundle.js.map +0 -7
- package/dist/otel/otel-proxy.js +0 -407
- package/dist/otel/otel-proxy.js.map +0 -1
- package/dist/server-info.js +0 -186
- package/dist/server-info.js.map +0 -1
- package/dist/tools/a11y/index.js +0 -7
- package/dist/tools/a11y/index.js.map +0 -1
- package/dist/tools/a11y/take-aria-snapshot.js +0 -54
- package/dist/tools/a11y/take-aria-snapshot.js.map +0 -1
- package/dist/tools/a11y/take-ax-tree-snapshot.js +0 -850
- package/dist/tools/a11y/take-ax-tree-snapshot.js.map +0 -1
- package/dist/tools/content/get-as-html.js +0 -164
- package/dist/tools/content/get-as-html.js.map +0 -1
- package/dist/tools/content/get-as-text.js +0 -76
- package/dist/tools/content/get-as-text.js.map +0 -1
- package/dist/tools/content/index.js +0 -14
- package/dist/tools/content/index.js.map +0 -1
- package/dist/tools/content/save-as-pdf.js +0 -119
- package/dist/tools/content/save-as-pdf.js.map +0 -1
- package/dist/tools/content/take-screenshot.js +0 -297
- package/dist/tools/content/take-screenshot.js.map +0 -1
- package/dist/tools/figma/compare/compare-image-embedding.js +0 -159
- package/dist/tools/figma/compare/compare-image-embedding.js.map +0 -1
- package/dist/tools/figma/compare/compare-mssim.js +0 -98
- package/dist/tools/figma/compare/compare-mssim.js.map +0 -1
- package/dist/tools/figma/compare/compare-text-embedding.js +0 -291
- package/dist/tools/figma/compare/compare-text-embedding.js.map +0 -1
- package/dist/tools/figma/compare/index.js +0 -139
- package/dist/tools/figma/compare/index.js.map +0 -1
- package/dist/tools/figma/compare/types.js +0 -3
- package/dist/tools/figma/compare/types.js.map +0 -1
- package/dist/tools/figma/compare/vector.js +0 -46
- package/dist/tools/figma/compare/vector.js.map +0 -1
- package/dist/tools/figma/compare-page-with-design.js +0 -240
- package/dist/tools/figma/compare-page-with-design.js.map +0 -1
- package/dist/tools/figma/figma-service.js +0 -134
- package/dist/tools/figma/figma-service.js.map +0 -1
- package/dist/tools/figma/index.js +0 -6
- package/dist/tools/figma/index.js.map +0 -1
- package/dist/tools/index.js +0 -41
- package/dist/tools/index.js.map +0 -1
- package/dist/tools/interaction/click.js +0 -29
- package/dist/tools/interaction/click.js.map +0 -1
- package/dist/tools/interaction/drag.js +0 -41
- package/dist/tools/interaction/drag.js.map +0 -1
- package/dist/tools/interaction/fill.js +0 -28
- package/dist/tools/interaction/fill.js.map +0 -1
- package/dist/tools/interaction/hover.js +0 -29
- package/dist/tools/interaction/hover.js.map +0 -1
- package/dist/tools/interaction/index.js +0 -24
- package/dist/tools/interaction/index.js.map +0 -1
- package/dist/tools/interaction/press-key.js +0 -99
- package/dist/tools/interaction/press-key.js.map +0 -1
- package/dist/tools/interaction/resize-viewport.js +0 -110
- package/dist/tools/interaction/resize-viewport.js.map +0 -1
- package/dist/tools/interaction/resize-window.js +0 -261
- package/dist/tools/interaction/resize-window.js.map +0 -1
- package/dist/tools/interaction/scroll.js +0 -304
- package/dist/tools/interaction/scroll.js.map +0 -1
- package/dist/tools/interaction/select.js +0 -30
- package/dist/tools/interaction/select.js.map +0 -1
- package/dist/tools/navigation/go-back.js +0 -76
- package/dist/tools/navigation/go-back.js.map +0 -1
- package/dist/tools/navigation/go-forward.js +0 -76
- package/dist/tools/navigation/go-forward.js.map +0 -1
- package/dist/tools/navigation/go-to.js +0 -80
- package/dist/tools/navigation/go-to.js.map +0 -1
- package/dist/tools/navigation/index.js +0 -14
- package/dist/tools/navigation/index.js.map +0 -1
- package/dist/tools/navigation/reload.js +0 -76
- package/dist/tools/navigation/reload.js.map +0 -1
- package/dist/tools/o11y/get-console-messages.js +0 -151
- package/dist/tools/o11y/get-console-messages.js.map +0 -1
- package/dist/tools/o11y/get-http-requests.js +0 -216
- package/dist/tools/o11y/get-http-requests.js.map +0 -1
- package/dist/tools/o11y/get-trace-id.js +0 -30
- package/dist/tools/o11y/get-trace-id.js.map +0 -1
- package/dist/tools/o11y/get-web-vitals.js +0 -595
- package/dist/tools/o11y/get-web-vitals.js.map +0 -1
- package/dist/tools/o11y/index.js +0 -18
- package/dist/tools/o11y/index.js.map +0 -1
- package/dist/tools/o11y/new-trace-id.js +0 -32
- package/dist/tools/o11y/new-trace-id.js.map +0 -1
- package/dist/tools/o11y/set-trace-id.js +0 -28
- package/dist/tools/o11y/set-trace-id.js.map +0 -1
- package/dist/tools/react/get-component-for-element.js +0 -941
- package/dist/tools/react/get-component-for-element.js.map +0 -1
- package/dist/tools/react/get-element-for-component.js +0 -1190
- package/dist/tools/react/get-element-for-component.js.map +0 -1
- package/dist/tools/react/index.js +0 -10
- package/dist/tools/react/index.js.map +0 -1
- package/dist/tools/run/index.js +0 -7
- package/dist/tools/run/index.js.map +0 -1
- package/dist/tools/run/js-in-browser.js +0 -51
- package/dist/tools/run/js-in-browser.js.map +0 -1
- package/dist/tools/run/js-in-sandbox.js +0 -175
- package/dist/tools/run/js-in-sandbox.js.map +0 -1
- package/dist/tools/stub/clear.js +0 -41
- package/dist/tools/stub/clear.js.map +0 -1
- package/dist/tools/stub/index.js +0 -14
- package/dist/tools/stub/index.js.map +0 -1
- package/dist/tools/stub/intercept-http-request.js +0 -112
- package/dist/tools/stub/intercept-http-request.js.map +0 -1
- package/dist/tools/stub/list.js +0 -75
- package/dist/tools/stub/list.js.map +0 -1
- package/dist/tools/stub/mock-http-response.js +0 -152
- package/dist/tools/stub/mock-http-response.js.map +0 -1
- package/dist/tools/stub/stub-controller.js +0 -284
- package/dist/tools/stub/stub-controller.js.map +0 -1
- package/dist/tools/sync/index.js +0 -6
- package/dist/tools/sync/index.js.map +0 -1
- package/dist/tools/sync/wait-for-network-idle.js +0 -152
- package/dist/tools/sync/wait-for-network-idle.js.map +0 -1
- package/dist/tools/tool-executor.js +0 -79
- package/dist/tools/tool-executor.js.map +0 -1
- package/dist/tools/types.js +0 -3
- package/dist/tools/types.js.map +0 -1
- package/dist/types.js +0 -55
- package/dist/types.js.map +0 -1
- package/dist/utils/cli-utils.js +0 -253
- package/dist/utils/cli-utils.js.map +0 -1
- package/dist/utils.js +0 -85
- package/dist/utils.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,81 +1,211 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
2
|
+
import{A as w,B as y,C as S,D as r,E as u,F as c,G as T,H as C,a as s,b as f,c as h,d as b,e as v}from"./core.js";import H from"crypto";import{createRequire as A}from"module";var N=A(import.meta.url),P="browser-devtools-mcp",I=N("../package.json").version,D=`
|
|
3
|
+
This MCP server exposes a Playwright-powered browser runtime to AI agents,
|
|
4
|
+
enabling deep, bidirectional debugging and interaction with live web pages.
|
|
5
|
+
|
|
6
|
+
It supports both visual understanding and code-level inspection of browser state,
|
|
7
|
+
similar to existing Playwright and Chrome DevTools\u2013based MCP servers, with a focus on AI-driven exploration, diagnosis, and action.
|
|
8
|
+
|
|
9
|
+
Core capabilities include:
|
|
10
|
+
|
|
11
|
+
**Content & Visual Inspection:**
|
|
12
|
+
- Screenshots (full page or specific elements)
|
|
13
|
+
- HTML and text content extraction with filtering options
|
|
14
|
+
- PDF generation with customizable formats
|
|
15
|
+
- Design comparison: Compare live page UI against Figma designs with similarity scoring
|
|
16
|
+
- Accessibility snapshots (ARIA and AX tree) with visual diagnostics
|
|
17
|
+
- Viewport and window resizing for responsive testing
|
|
18
|
+
|
|
19
|
+
**Browser Control & Interaction:**
|
|
20
|
+
- Navigation (go to URL, back, forward)
|
|
21
|
+
- Element interaction (click, fill, hover, select, drag)
|
|
22
|
+
- Keyboard simulation (press-key)
|
|
23
|
+
- Scrolling (viewport or container-based with multiple modes)
|
|
24
|
+
- Viewport emulation and real window resizing
|
|
25
|
+
|
|
26
|
+
**JavaScript Execution:**
|
|
27
|
+
- Run JavaScript in browser page context (access to window, document, DOM, Web APIs)
|
|
28
|
+
- Run JavaScript in Node.js VM sandbox on the server (with Playwright Page access and safe built-ins)
|
|
29
|
+
|
|
30
|
+
**Observability & Monitoring:**
|
|
31
|
+
- Console message capture with filtering
|
|
32
|
+
- HTTP request/response monitoring with detailed filtering
|
|
33
|
+
- Web Vitals performance metrics (LCP, INP, CLS, TTFB, FCP) with recommendations
|
|
34
|
+
- OpenTelemetry trace ID management for distributed tracing correlation
|
|
35
|
+
|
|
36
|
+
**Network Stubbing & Mocking:**
|
|
37
|
+
- HTTP request interception and modification (headers, body, method) using glob patterns
|
|
38
|
+
- HTTP response mocking (fulfill with custom status/headers/body or abort) with configurable delay, times limit, and probability
|
|
39
|
+
- Stub management (list all installed stubs, clear specific or all stubs)
|
|
40
|
+
- Supports A/B testing, security testing, offline testing, error scenarios, and flaky API testing
|
|
41
|
+
|
|
42
|
+
**Synchronization:**
|
|
43
|
+
- Network idle waiting for async operations
|
|
44
|
+
- Configurable timeouts and polling intervals
|
|
45
|
+
|
|
46
|
+
**Design Comparison:**
|
|
47
|
+
- Figma design comparison: Compare live page UI against Figma design snapshots
|
|
48
|
+
- Multi-signal similarity scoring (MSSIM, image embedding, text embedding)
|
|
49
|
+
- Configurable weights and comparison modes (raw vs semantic)
|
|
50
|
+
|
|
51
|
+
**React Component Inspection:**
|
|
52
|
+
- Get component for element: Find React component(s) associated with a DOM element using React Fiber
|
|
53
|
+
- Get element for component: Map a React component instance to the DOM elements it renders
|
|
54
|
+
- Requires persistent browser context (BROWSER_PERSISTENT_ENABLE=true) for optimal operation
|
|
55
|
+
- React DevTools extension must be manually installed in the browser profile (MCP server does NOT auto-install)
|
|
56
|
+
- Without extension, tools fall back to best-effort DOM scanning for __reactFiber$ pointers (less reliable)
|
|
57
|
+
|
|
58
|
+
**Non-Blocking Debugging:**
|
|
59
|
+
- Tracepoints: Capture call stack, local variables, and watch expressions at specific code locations without pausing execution
|
|
60
|
+
- Logpoints: Evaluate and log expressions at code locations (lightweight alternative to tracepoints)
|
|
61
|
+
- Exceptionpoints: Automatically capture snapshots when uncaught or all exceptions occur
|
|
62
|
+
- Netpoints: Monitor specific network requests/responses matching URL patterns
|
|
63
|
+
- Dompoints: Monitor DOM mutations (attribute changes, subtree modifications, node removal) on specific elements
|
|
64
|
+
- Watch expressions: Evaluate custom expressions at every tracepoint hit
|
|
65
|
+
- Source map support: Automatically resolves bundled code locations to original source files
|
|
66
|
+
- Snapshot retrieval: Query captured snapshots by probe ID or sequence number for incremental polling
|
|
67
|
+
|
|
68
|
+
**Advanced Features:**
|
|
69
|
+
- OpenTelemetry integration: Automatic UI trace collection and backend trace correlation
|
|
70
|
+
- Session-based architecture with long-lived browser contexts
|
|
71
|
+
- Persistent browser contexts for stateful sessions (required for React tools)
|
|
72
|
+
- Headless and headful mode support
|
|
73
|
+
- System-installed browser usage option
|
|
74
|
+
- Streamable responses and server-initiated notifications
|
|
75
|
+
- Clean lifecycle management and teardown
|
|
76
|
+
|
|
77
|
+
UI debugging guidance for AI agents:
|
|
78
|
+
- Prefer Accessibility (AX) and ARIA snapshots over raw DOM dumps when diagnosing UI problems.
|
|
79
|
+
These snapshots provide higher-signal, semantically meaningful anchors (roles, names, states) that
|
|
80
|
+
map more reliably to what users perceive and what assistive tech can interact with.
|
|
81
|
+
- Use the AX Tree Snapshot tool to correlate interactive semantics with runtime visual truth:
|
|
82
|
+
bounding boxes, visibility, viewport intersection, and (optionally) computed styles.
|
|
83
|
+
- If a UI control appears present but interactions fail (e.g., clicks do nothing), suspect overlap/occlusion.
|
|
84
|
+
In such cases, enable occlusion checking ("elementFromPoint") to identify which element is actually on top.
|
|
85
|
+
- Use ARIA snapshots to reason about accessibility roles/states and to validate that the intended
|
|
86
|
+
semantics (labels, roles, disabled state, focusability) match the visible UI.
|
|
87
|
+
- Before taking screenshots or snapshots, wait for network idle to ensure page stability.
|
|
88
|
+
- Use Web Vitals tool to assess performance and identify optimization opportunities.
|
|
89
|
+
- For design validation, use "figma_compare-page-with-design" to compare live page UI against Figma designs:
|
|
90
|
+
- Use "semantic" MSSIM mode for comparing real data vs design data (less sensitive to text/value differences)
|
|
91
|
+
- Use "raw" MSSIM mode only when expecting near pixel-identical output
|
|
92
|
+
- If layout mismatch is suspected, run with fullPage=true first, then retry with a selector for the problematic region
|
|
93
|
+
- Notes explain which signals were used or skipped; skipped signals usually mean missing cloud configuration
|
|
94
|
+
- For React component inspection, use "react_get-component-for-element" and "react_get-element-for-component":
|
|
95
|
+
- These tools work best with persistent browser context enabled (BROWSER_PERSISTENT_ENABLE=true)
|
|
96
|
+
- React DevTools extension must be manually installed in the browser profile (MCP server does NOT auto-install)
|
|
97
|
+
- Chrome Web Store: https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi
|
|
98
|
+
- Without extension, tools use best-effort DOM scanning (less reliable than using DevTools hook)
|
|
99
|
+
- Component names and debug source info are best-effort and may vary by build (dev/prod)
|
|
100
|
+
- For distributed tracing, set trace IDs before navigation to correlate frontend and backend traces.
|
|
101
|
+
- For testing and debugging scenarios, use stub tools to intercept/modify requests or mock responses:
|
|
102
|
+
- Use "stub_intercept-http-request" to modify outgoing requests (inject headers, change body/method)
|
|
103
|
+
- Use "stub_mock-http-response" to mock responses for offline testing, error scenarios, or flaky API simulation
|
|
104
|
+
- Use "stub_list" to check what stubs are active and "stub_clear" to remove them when done
|
|
105
|
+
- For non-blocking JavaScript debugging:
|
|
106
|
+
- Use "debug_put-tracepoint" to capture call stack, local variables, and watch expressions at specific code locations
|
|
107
|
+
- Use "debug_put-logpoint" for lightweight logging at code locations (no call stack capture)
|
|
108
|
+
- Use "debug_put-exceptionpoint" to capture snapshots when exceptions occur (state: "uncaught" or "all")
|
|
109
|
+
- Use "debug_put-netpoint" to monitor specific network requests/responses by URL pattern
|
|
110
|
+
- Use "debug_put-dompoint" to monitor DOM mutations on specific elements
|
|
111
|
+
- Use "debug_add-watch" to add watch expressions evaluated at every tracepoint hit
|
|
112
|
+
- Use "debug_get-tracepoint-snapshots", "debug_get-logpoint-snapshots", etc. to retrieve captured data
|
|
113
|
+
- Use "fromSequence" parameter for incremental polling of new snapshots
|
|
114
|
+
- Tracepoints/logpoints support source maps: set probes on original source file locations
|
|
115
|
+
|
|
116
|
+
This server is designed for AI coding assistants, visual debugging agents, and automated analysis tools
|
|
117
|
+
that need to reason about what a page looks like, how it is structured, and how it behaves \u2014 all through a single MCP interface.
|
|
118
|
+
|
|
119
|
+
It treats the browser as a queryable, inspectable, and controllable execution environment rather than a static screenshot source.
|
|
120
|
+
`,M=`
|
|
121
|
+
<ui_debugging_policy>
|
|
122
|
+
When asked to check for UI problems, layout issues, or visual bugs, ALWAYS follow this policy:
|
|
123
|
+
|
|
124
|
+
1. **Synchronization**: If the page loads content asynchronously, call "sync_wait-for-network-idle" first
|
|
125
|
+
to ensure the page is stable before inspection.
|
|
126
|
+
|
|
127
|
+
2. **Visual Inspection**: Call "content_take-screenshot" for general aesthetics and layout overview.
|
|
128
|
+
|
|
129
|
+
3. **Accessibility Tree Analysis**: Call "a11y_take-ax-tree-snapshot" tool with "checkOcclusion:true"
|
|
130
|
+
- Provides precise bounding boxes, runtime visual data, and occlusion detection
|
|
131
|
+
- Best for detecting overlaps and measuring exact positions
|
|
132
|
+
- Use "onlyVisible:true" or "onlyInViewport:true" to filter results
|
|
133
|
+
- Set "includeStyles:true" to analyze computed CSS properties
|
|
134
|
+
|
|
135
|
+
4. **ARIA Snapshot**: Call "a11y_take-aria-snapshot" tool (full page or specific selector)
|
|
136
|
+
- Provides semantic structure and accessibility roles
|
|
137
|
+
- Best for understanding page hierarchy and accessibility issues
|
|
138
|
+
- Use in combination with AX tree snapshot for comprehensive analysis
|
|
139
|
+
|
|
140
|
+
5. **Design Comparison** (if Figma design is available): Call "figma_compare-page-with-design" tool
|
|
141
|
+
- Compares live page UI against Figma design snapshot
|
|
142
|
+
- Returns combined similarity score using multiple signals (MSSIM, image embedding, text embedding)
|
|
143
|
+
- Use "semantic" mode for real data vs design data comparisons
|
|
144
|
+
- Use "raw" mode only when expecting pixel-identical output
|
|
145
|
+
- Notes explain which signals were used or skipped
|
|
146
|
+
|
|
147
|
+
6. **React Component Inspection** (if page uses React): Use React tools to understand component structure
|
|
148
|
+
- Call "react_get-component-for-element" with selector or (x,y) to find React component for a DOM element
|
|
149
|
+
- Call "react_get-element-for-component" to find DOM elements rendered by a React component
|
|
150
|
+
- **Important:** These tools require persistent browser context (BROWSER_PERSISTENT_ENABLE=true)
|
|
151
|
+
- React DevTools extension must be manually installed in the browser profile for optimal reliability
|
|
152
|
+
- Without extension, tools use best-effort DOM scanning (less reliable)
|
|
153
|
+
- Component names and debug source info are best-effort and may vary by build (dev/prod)
|
|
154
|
+
|
|
155
|
+
7. **Performance Check** (optional but recommended): Call "o11y_get-web-vitals" to assess page performance
|
|
156
|
+
- Identifies performance issues that may affect user experience
|
|
157
|
+
- Provides actionable recommendations based on Google's thresholds
|
|
158
|
+
|
|
159
|
+
8. **Console & Network Inspection**: Check for errors and failed requests
|
|
160
|
+
- Call "o11y_get-console-messages" with "type:ERROR" to find JavaScript errors
|
|
161
|
+
- Call "o11y_get-http-requests" with "ok:false" to find failed network requests
|
|
162
|
+
- If network issues are suspected or testing error scenarios, use stub tools:
|
|
163
|
+
- Use "stub_mock-http-response" to simulate error responses (e.g., 500, 404, timeout) to test UI error handling
|
|
164
|
+
- Use "stub_intercept-http-request" to modify requests (e.g., inject headers) to test different scenarios
|
|
165
|
+
- Use "stub_list" to verify active stubs and "stub_clear" to remove them after testing
|
|
166
|
+
|
|
167
|
+
9. **Manual Verification**: Calculate bounding box overlaps:
|
|
168
|
+
- Horizontal: (element1.x + element1.width) \u2264 element2.x
|
|
169
|
+
- Vertical: (element1.y + element1.height) \u2264 element2.y
|
|
170
|
+
|
|
171
|
+
10. **Report ALL findings**: aesthetic issues, overlaps, spacing problems, alignment issues,
|
|
172
|
+
accessibility problems, semantic structure issues, design parity issues (if compared with Figma),
|
|
173
|
+
React component structure issues (if inspected), performance problems, console errors, failed requests
|
|
174
|
+
|
|
175
|
+
11. **JavaScript Execution** (when needed for advanced debugging):
|
|
176
|
+
- Use "run_js-in-browser" to inspect or mutate DOM state, read client-side variables, or extract computed values directly from the page
|
|
177
|
+
- Use "run_js-in-sandbox" for server-side automation logic that needs access to Playwright Page object or safe built-ins
|
|
178
|
+
|
|
179
|
+
12. **Non-Blocking JavaScript Debugging** (for deep code investigation):
|
|
180
|
+
- Use "debug_put-tracepoint" to set breakpoints that capture call stack and local variables without pausing
|
|
181
|
+
- Use "debug_put-logpoint" for lightweight logging at specific code locations
|
|
182
|
+
- Use "debug_put-exceptionpoint" with state "uncaught" or "all" to capture exception snapshots
|
|
183
|
+
- Use "debug_put-netpoint" to monitor specific network requests by URL pattern
|
|
184
|
+
- Use "debug_put-dompoint" to monitor DOM mutations (attributes, subtree, removal) on elements
|
|
185
|
+
- Use "debug_add-watch" to add expressions evaluated at every tracepoint hit
|
|
186
|
+
- Retrieve snapshots with "debug_get-tracepoint-snapshots", "debug_get-logpoint-snapshots", etc.
|
|
187
|
+
- Use "fromSequence" parameter to poll only new snapshots since last retrieval
|
|
188
|
+
- Probes support source maps: specify original source file paths for bundled applications
|
|
189
|
+
- Use "debug_status" to check current debugging state and probe counts
|
|
190
|
+
|
|
191
|
+
**Tool Usage Notes:**
|
|
192
|
+
- AX tree: Technical measurements, occlusion, precise positioning, visual diagnostics
|
|
193
|
+
- ARIA snapshot: Semantic understanding, accessibility structure, role hierarchy
|
|
194
|
+
- Screenshot: Quick visual reference, but not sufficient alone
|
|
195
|
+
- Network idle: Essential for SPAs and async content
|
|
196
|
+
- Web Vitals: Performance context for UI issues
|
|
197
|
+
- Tracepoints: Deep code investigation with call stack and variables (non-blocking)
|
|
198
|
+
- Logpoints: Lightweight logging at specific code locations
|
|
199
|
+
- Exceptionpoints: Automatic exception capture without manual breakpoints
|
|
200
|
+
- Netpoints/Dompoints: Monitor network and DOM changes without code modification
|
|
201
|
+
|
|
202
|
+
**Important:**
|
|
203
|
+
- Never assume "looks good visually" = "no problems". Overlaps and accessibility issues
|
|
204
|
+
can be functionally broken while appearing visually correct.
|
|
205
|
+
- Always check occlusion when interactions fail or elements appear misaligned.
|
|
206
|
+
- Use scroll tool if elements are below the fold before inspection.
|
|
207
|
+
- For responsive issues, use resize-viewport or resize-window tools to test different sizes.
|
|
208
|
+
</ui_debugging_policy>
|
|
209
|
+
`;function x(){let t=[];return t.push(D),t.join(`
|
|
210
|
+
|
|
211
|
+
`).trim()}s(x,"getServerInstructions");import{StreamableHTTPTransport as L}from"@hono/mcp";import{serve as j}from"@hono/node-server";import{McpServer as $}from"@modelcontextprotocol/sdk/server/mcp.js";import{StdioServerTransport as V}from"@modelcontextprotocol/sdk/server/stdio.js";import{Hono as B}from"hono";import{cors as W}from"hono/cors";var z={jsonrpc:"2.0",error:{code:0,message:"N/A"},id:null},d={get sessionNotFound(){return m(-32001,"Session Not Found")},get unauthorized(){return m(-32001,"Unauthorized")},get internalServerError(){return m(-32603,"Internal Server Error")}},p=new Map;function m(t,e){let o={...z};return o.error.code=t,o.error.message=e,o}s(m,"_buildMCPErrorResponse");function G(t){if("image"in t&&t.image!==null&&typeof t.image=="object"&&"data"in t.image&&"mimeType"in t.image&&Buffer.isBuffer(t.image.data)&&typeof t.image.mimeType=="string"){let e=t.image;return delete t.image,e}}s(G,"_getImage");function J(t){let e=G(t),o=[];return o.push({type:"text",text:JSON.stringify(t,null,2)}),e&&(e.mimeType==="image/svg+xml"?o.push({type:"text",text:e.data.toString(),mimeType:e.mimeType}):o.push({type:"image",data:e.data.toString("base64"),mimeType:e.mimeType})),{content:o,structuredContent:t,isError:!1}}s(J,"_toResponse");function X(t){let e=new $({name:P,version:I},{capabilities:{resources:{},tools:{}},instructions:x()}),o=[];o.push({role:"user",content:{type:"text",text:M}}),e.registerPrompt("default_system",{title:"Default System Prompt",description:"General behavior for the AI assistant"},async()=>({description:"Defines the assistant's general reasoning and tool usage rules.",messages:o}));let n=new T(()=>t.sessionIdProvider?t.sessionIdProvider():""),i=s(a=>async U=>{try{let g=await n.executeTool(a,U);return J(g)}catch(g){return{content:[{type:"text",text:`Error: ${g.message}`}],isError:!0}}},"createToolCallback");return C.forEach(a=>{r(`Registering tool ${a.name()} ...`),e.registerTool(a.name(),{description:a.description(),inputSchema:a.inputSchema(),outputSchema:a.outputSchema()},i(a))}),e}s(X,"_createServer");async function _(t,e){let o=X({config:e.config,sessionIdProvider:s(()=>t.sessionId,"sessionIdProvider")});return await o.connect(t),o}s(_,"_createAndConnectServer");function k(){return{}}s(k,"_getConfig");function Y(t,e,o){let n={transport:e,server:o,closed:!1,lastActiveAt:Date.now()},i=t.env.incoming.socket;return i._mcpRegistered||(i._mcpRegistered=!0,i.on("close",async()=>{r(`Socket, which is for MCP session with id ${e.sessionId}, has been closed`),v&&await e.close()})),ee(e,n.server),r(`Created MCP server session with id ${e.sessionId}`),n}s(Y,"_createSession");async function K(t){let e=k(),o={},n=new L({enableJsonResponse:!0,sessionIdGenerator:s(()=>H.randomUUID(),"sessionIdGenerator"),onsessioninitialized:s(async i=>{let a=Y(t,n,o.server);p.set(i,a),r(`MCP session initialized with id ${i}`)},"onsessioninitialized"),onsessionclosed:s(async i=>{r(`Closing MCP session closed with id ${i} ...`),await n.close(),r(`MCP session closed with id ${i}`)},"onsessionclosed")});return o.server=await _(n,{config:e}),n}s(K,"_createTransport");async function Q(t){let e=t.req.header("mcp-session-id");if(e){let o=p.get(e);if(o)return r(`Reusing MCP session with id ${e}`),o.transport}}s(Q,"_getTransport");async function Z(t){let e=t.req.header("mcp-session-id");if(e){let o=p.get(e);if(o)return r(`Reusing MCP session with id ${e}`),o.transport;r(`No MCP session could be found with id ${e}`);return}return await K(t)}s(Z,"_getOrCreateTransport");function ee(t,e){let o=!1;t.onclose=async()=>{if(r(`Closing MCP session with id ${t.sessionId} ...`),o){r(`MCP session with id ${t.sessionId} has already been closed`);return}o=!0;try{await e.close(),r("Closed MCP server")}catch(n){c("Error occurred while closing MCP server",n)}if(t.sessionId){let n=p.get(t.sessionId);if(n&&(n.closed=!0,n.context))try{await n.context.close(),r("Closed MCP session context")}catch(i){c("Error occurred while closing MCP session context",i)}p.delete(t.sessionId)}r(`Closing MCP session with id ${t.sessionId} ...`)}}s(ee,"_registerMCPSessionClose");function te(){setInterval(s(()=>{let e=Date.now();for(let[o,n]of p)r(`Checking whether session with id ${o} is idle or not ...`),e-n.lastActiveAt>h*1e3&&(r(`Session with id ${o} is idle, so it will be closing ...`),n.transport.close().then(()=>{r(`Session with id ${o} was idle, so it has been closed`)}).catch(i=>{c(`Unable to delete idle session with id ${o}`,i)}))},"sessionCheck"),b*1e3)}s(te,"_scheduleIdleSessionCheck");async function oe(t){let e=t.req.raw.clone();r(`Got request: ${await e.json()}`)}s(oe,"_logRequest");function se(t){let e=t.req.header("mcp-session-id");if(e){let o=p.get(e);o&&(o.lastActiveAt=Date.now())}}s(se,"_markSessionAsActive");async function E(){let t=new V;await _(t,{config:k()})}s(E,"startStdioServer");var l=new B;async function R(t){l.use("*",W({origin:"*",allowMethods:["GET","POST","OPTIONS"],allowHeaders:["Content-Type","Authorization","MCP-Protocol-Version"]})),l.get("/health",e=>e.json({status:"ok"})),l.get("/ping",e=>e.json({status:"ok",message:"pong"})),l.get("/mcp",e=>e.json({status:"ok",protocol:"model-context-protocol",version:"1.0"})),l.post("/mcp",async e=>{try{S()&&await oe(e);let o=await Z(e);return o?(se(e),await o.handleRequest(e)):e.json(d.sessionNotFound,400)}catch(o){return c("Error occurred while handling MCP request",o),e.json(d.internalServerError,500)}}),l.delete("/mcp",async e=>{try{let o=await Q(e);return o?(await o.close(),e.json({ok:!0},200)):e.json(d.sessionNotFound,400)}catch(o){return c("Error occurred while deleting MCP session",o),e.json(d.internalServerError,500)}}),l.notFound(e=>e.json({error:"Not Found",status:404},404)),j({fetch:l.fetch,port:t},()=>u(`Listening on port ${t}`)),te()}s(R,"startStreamableHTTPServer");import{Command as ne,Option as O,InvalidOptionArgumentError as re}from"commander";function ie(t){let e=Number(t);if(!Number.isInteger(e)||e<1||e>65535)throw new re("port must be an integer between 1 and 65535");return e}s(ie,"_parsePort");function ae(){return new ne().addOption(new O("--transport <type>","transport type").choices(["stdio","streamable-http"]).default("stdio")).addOption(new O("--port <number>","port for Streamable HTTP transport").argParser(ie).default(f)).allowUnknownOption().parse(process.argv).opts()}s(ae,"_getOptions");async function ce(){let t=ae();t.transport==="stdio"?(y(),await E()):t.transport==="streamable-http"?(u("Starting MCP server..."),await R(t.port),u("Started MCP Server")):(c(`Invalid transport: ${t.transport}`),process.exit(1))}s(ce,"main");ce().catch(t=>{w(),c("MCP server error",t),process.exit(1)});
|
|
@@ -1,2 +1 @@
|
|
|
1
1
|
"use strict";var __mcpOtelBundle=(()=>{var hr=Object.defineProperty;var Vs=Object.getOwnPropertyDescriptor;var Gs=Object.getOwnPropertyNames;var Hs=Object.prototype.hasOwnProperty;var Bs=(t,e,r)=>e in t?hr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var Fs=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Gs(e))!Hs.call(t,o)&&o!==r&&hr(t,o,{get:()=>e[o],enumerable:!(n=Vs(e,o))||n.enumerable});return t};var ks=t=>Fs(hr({},"__esModule",{value:!0}),t);var c=(t,e,r)=>Bs(t,typeof e!="symbol"?e+"":e,r);var pc={};var _n=typeof globalThis=="object"?globalThis:typeof self=="object"?self:typeof window=="object"?window:typeof global=="object"?global:{};var Q="1.9.0";var En=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function Ks(t){var e=new Set([t]),r=new Set,n=t.match(En);if(!n)return function(){return!1};var o={major:+n[1],minor:+n[2],patch:+n[3],prerelease:n[4]};if(o.prerelease!=null)return function(p){return p===t};function s(a){return r.add(a),!1}function i(a){return e.add(a),!0}return function(p){if(e.has(p))return!0;if(r.has(p))return!1;var u=p.match(En);if(!u)return s(p);var _={major:+u[1],minor:+u[2],patch:+u[3],prerelease:u[4]};return _.prerelease!=null||o.major!==_.major?s(p):o.major===0?o.minor===_.minor&&o.patch<=_.patch?i(p):s(p):o.minor<=_.minor?i(p):s(p)}}var Tn=Ks(Q);var Ys=Q.split(".")[0],bt=Symbol.for("opentelemetry.js.api."+Ys),vt=_n;function Y(t,e,r,n){var o;n===void 0&&(n=!1);var s=vt[bt]=(o=vt[bt])!==null&&o!==void 0?o:{version:Q};if(!n&&s[t]){var i=new Error("@opentelemetry/api: Attempted duplicate registration of API: "+t);return r.error(i.stack||i.message),!1}if(s.version!==Q){var i=new Error("@opentelemetry/api: Registration of version v"+s.version+" for "+t+" does not match previously registered API v"+Q);return r.error(i.stack||i.message),!1}return s[t]=e,r.debug("@opentelemetry/api: Registered a global for "+t+" v"+Q+"."),!0}function w(t){var e,r,n=(e=vt[bt])===null||e===void 0?void 0:e.version;if(!(!n||!Tn(n)))return(r=vt[bt])===null||r===void 0?void 0:r[t]}function j(t,e){e.debug("@opentelemetry/api: Unregistering a global for "+t+" v"+Q+".");var r=vt[bt];r&&delete r[t]}var js=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),o,s=[],i;try{for(;(e===void 0||e-- >0)&&!(o=n.next()).done;)s.push(o.value)}catch(a){i={error:a}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(i)throw i.error}}return s},Ws=function(t,e,r){if(r||arguments.length===2)for(var n=0,o=e.length,s;n<o;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return t.concat(s||Array.prototype.slice.call(e))},ln=(function(){function t(e){this._namespace=e.namespace||"DiagComponentLogger"}return t.prototype.debug=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Dt("debug",this._namespace,e)},t.prototype.error=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Dt("error",this._namespace,e)},t.prototype.info=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Dt("info",this._namespace,e)},t.prototype.warn=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Dt("warn",this._namespace,e)},t.prototype.verbose=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Dt("verbose",this._namespace,e)},t})();function Dt(t,e,r){var n=w("diag");if(n)return r.unshift(e),n[t].apply(n,Ws([],js(r),!1))}var y;(function(t){t[t.NONE=0]="NONE",t[t.ERROR=30]="ERROR",t[t.WARN=50]="WARN",t[t.INFO=60]="INFO",t[t.DEBUG=70]="DEBUG",t[t.VERBOSE=80]="VERBOSE",t[t.ALL=9999]="ALL"})(y||(y={}));function fn(t,e){t<y.NONE?t=y.NONE:t>y.ALL&&(t=y.ALL),e=e||{};function r(n,o){var s=e[n];return typeof s=="function"&&t>=o?s.bind(e):function(){}}return{error:r("error",y.ERROR),warn:r("warn",y.WARN),info:r("info",y.INFO),debug:r("debug",y.DEBUG),verbose:r("verbose",y.VERBOSE)}}var zs=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),o,s=[],i;try{for(;(e===void 0||e-- >0)&&!(o=n.next()).done;)s.push(o.value)}catch(a){i={error:a}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(i)throw i.error}}return s},Xs=function(t,e,r){if(r||arguments.length===2)for(var n=0,o=e.length,s;n<o;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return t.concat(s||Array.prototype.slice.call(e))},$s="diag",v=(function(){function t(){function e(o){return function(){for(var s=[],i=0;i<arguments.length;i++)s[i]=arguments[i];var a=w("diag");if(a)return a[o].apply(a,Xs([],zs(s),!1))}}var r=this,n=function(o,s){var i,a,p;if(s===void 0&&(s={logLevel:y.INFO}),o===r){var u=new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");return r.error((i=u.stack)!==null&&i!==void 0?i:u.message),!1}typeof s=="number"&&(s={logLevel:s});var _=w("diag"),f=fn((a=s.logLevel)!==null&&a!==void 0?a:y.INFO,o);if(_&&!s.suppressOverrideMessage){var h=(p=new Error().stack)!==null&&p!==void 0?p:"<failed to generate stacktrace>";_.warn("Current logger will be overwritten from "+h),f.warn("Current logger will overwrite one already registered from "+h)}return Y("diag",f,r,!0)};r.setLogger=n,r.disable=function(){j($s,r)},r.createComponentLogger=function(o){return new ln(o)},r.verbose=e("verbose"),r.debug=e("debug"),r.info=e("info"),r.warn=e("warn"),r.error=e("error")}return t.instance=function(){return this._instance||(this._instance=new t),this._instance},t})();var qs=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),o,s=[],i;try{for(;(e===void 0||e-- >0)&&!(o=n.next()).done;)s.push(o.value)}catch(a){i={error:a}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(i)throw i.error}}return s},Qs=function(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},dn=(function(){function t(e){this._entries=e?new Map(e):new Map}return t.prototype.getEntry=function(e){var r=this._entries.get(e);if(r)return Object.assign({},r)},t.prototype.getAllEntries=function(){return Array.from(this._entries.entries()).map(function(e){var r=qs(e,2),n=r[0],o=r[1];return[n,o]})},t.prototype.setEntry=function(e,r){var n=new t(this._entries);return n._entries.set(e,r),n},t.prototype.removeEntry=function(e){var r=new t(this._entries);return r._entries.delete(e),r},t.prototype.removeEntries=function(){for(var e,r,n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];var s=new t(this._entries);try{for(var i=Qs(n),a=i.next();!a.done;a=i.next()){var p=a.value;s._entries.delete(p)}}catch(u){e={error:u}}finally{try{a&&!a.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}return s},t.prototype.clear=function(){return new t},t})();var Sn=Symbol("BaggageEntryMetadata");var Js=v.instance();function mn(t){return t===void 0&&(t={}),new dn(new Map(Object.entries(t)))}function Ar(t){return typeof t!="string"&&(Js.error("Cannot create baggage metadata from unknown type: "+typeof t),t=""),{__TYPE__:Sn,toString:function(){return t}}}function ct(t){return Symbol.for(t)}var Zs=(function(){function t(e){var r=this;r._currentContext=e?new Map(e):new Map,r.getValue=function(n){return r._currentContext.get(n)},r.setValue=function(n,o){var s=new t(r._currentContext);return s._currentContext.set(n,o),s},r.deleteValue=function(n){var o=new t(r._currentContext);return o._currentContext.delete(n),o}}return t})(),K=new Zs;var gr=[{n:"error",c:"error"},{n:"warn",c:"warn"},{n:"info",c:"info"},{n:"debug",c:"debug"},{n:"verbose",c:"trace"}],Rr=(function(){function t(){function e(n){return function(){for(var o=[],s=0;s<arguments.length;s++)o[s]=arguments[s];if(console){var i=console[n];if(typeof i!="function"&&(i=console.log),typeof i=="function")return i.apply(console,o)}}}for(var r=0;r<gr.length;r++)this[gr[r].n]=e(gr[r].c)}return t})();var pt=(function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,o){n.__proto__=o}||function(n,o){for(var s in o)Object.prototype.hasOwnProperty.call(o,s)&&(n[s]=o[s])},t(e,r)};return function(e,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");t(e,r);function n(){this.constructor=e}e.prototype=r===null?Object.create(r):(n.prototype=r.prototype,new n)}})(),ti=(function(){function t(){}return t.prototype.createGauge=function(e,r){return pi},t.prototype.createHistogram=function(e,r){return ui},t.prototype.createCounter=function(e,r){return ci},t.prototype.createUpDownCounter=function(e,r){return _i},t.prototype.createObservableGauge=function(e,r){return Ti},t.prototype.createObservableCounter=function(e,r){return Ei},t.prototype.createObservableUpDownCounter=function(e,r){return li},t.prototype.addBatchObservableCallback=function(e,r){},t.prototype.removeBatchObservableCallback=function(e){},t})();var Ae=(function(){function t(){}return t})();var ei=(function(t){pt(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.prototype.add=function(r,n){},e})(Ae);var ri=(function(t){pt(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.prototype.add=function(r,n){},e})(Ae);var ni=(function(t){pt(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.prototype.record=function(r,n){},e})(Ae);var oi=(function(t){pt(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.prototype.record=function(r,n){},e})(Ae);var Or=(function(){function t(){}return t.prototype.addCallback=function(e){},t.prototype.removeCallback=function(e){},t})();var si=(function(t){pt(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e})(Or);var ii=(function(t){pt(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e})(Or);var ai=(function(t){pt(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e})(Or);var hn=new ti,ci=new ei,pi=new ni,ui=new oi,_i=new ri,Ei=new si,Ti=new ii,li=new ai;var An={get:function(t,e){if(t!=null)return t[e]},keys:function(t){return t==null?[]:Object.keys(t)}},gn={set:function(t,e,r){t!=null&&(t[e]=r)}};var fi=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),o,s=[],i;try{for(;(e===void 0||e-- >0)&&!(o=n.next()).done;)s.push(o.value)}catch(a){i={error:a}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(i)throw i.error}}return s},di=function(t,e,r){if(r||arguments.length===2)for(var n=0,o=e.length,s;n<o;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return t.concat(s||Array.prototype.slice.call(e))},Rn=(function(){function t(){}return t.prototype.active=function(){return K},t.prototype.with=function(e,r,n){for(var o=[],s=3;s<arguments.length;s++)o[s-3]=arguments[s];return r.call.apply(r,di([n],fi(o),!1))},t.prototype.bind=function(e,r){return r},t.prototype.enable=function(){return this},t.prototype.disable=function(){return this},t})();var Si=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),o,s=[],i;try{for(;(e===void 0||e-- >0)&&!(o=n.next()).done;)s.push(o.value)}catch(a){i={error:a}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(i)throw i.error}}return s},mi=function(t,e,r){if(r||arguments.length===2)for(var n=0,o=e.length,s;n<o;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return t.concat(s||Array.prototype.slice.call(e))},Lr="context",hi=new Rn,ot=(function(){function t(){}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalContextManager=function(e){return Y(Lr,e,v.instance())},t.prototype.active=function(){return this._getContextManager().active()},t.prototype.with=function(e,r,n){for(var o,s=[],i=3;i<arguments.length;i++)s[i-3]=arguments[i];return(o=this._getContextManager()).with.apply(o,mi([e,r,n],Si(s),!1))},t.prototype.bind=function(e,r){return this._getContextManager().bind(e,r)},t.prototype._getContextManager=function(){return w(Lr)||hi},t.prototype.disable=function(){this._getContextManager().disable(),j(Lr,v.instance())},t})();var I;(function(t){t[t.NONE=0]="NONE",t[t.SAMPLED=1]="SAMPLED"})(I||(I={}));var ge="0000000000000000",Re="00000000000000000000000000000000",Ut={traceId:Re,spanId:ge,traceFlags:I.NONE};var st=(function(){function t(e){e===void 0&&(e=Ut),this._spanContext=e}return t.prototype.spanContext=function(){return this._spanContext},t.prototype.setAttribute=function(e,r){return this},t.prototype.setAttributes=function(e){return this},t.prototype.addEvent=function(e,r){return this},t.prototype.addLink=function(e){return this},t.prototype.addLinks=function(e){return this},t.prototype.setStatus=function(e){return this},t.prototype.updateName=function(e){return this},t.prototype.end=function(e){},t.prototype.isRecording=function(){return!1},t.prototype.recordException=function(e,r){},t})();var xr=ct("OpenTelemetry Context Key SPAN");function Oe(t){return t.getValue(xr)||void 0}function On(){return Oe(ot.getInstance().active())}function wt(t,e){return t.setValue(xr,e)}function Ln(t){return t.deleteValue(xr)}function xn(t,e){return wt(t,new st(e))}function Le(t){var e;return(e=Oe(t))===null||e===void 0?void 0:e.spanContext()}var Ai=/^([0-9a-f]{32})$/i,gi=/^[0-9a-f]{16}$/i;function xe(t){return Ai.test(t)&&t!==Re}function Nn(t){return gi.test(t)&&t!==ge}function J(t){return xe(t.traceId)&&Nn(t.spanId)}function Pn(t){return new st(t)}var Nr=ot.getInstance(),Ne=(function(){function t(){}return t.prototype.startSpan=function(e,r,n){n===void 0&&(n=Nr.active());var o=!!r?.root;if(o)return new st;var s=n&&Le(n);return Ri(s)&&J(s)?new st(s):new st},t.prototype.startActiveSpan=function(e,r,n,o){var s,i,a;if(!(arguments.length<2)){arguments.length===2?a=r:arguments.length===3?(s=r,a=n):(s=r,i=n,a=o);var p=i??Nr.active(),u=this.startSpan(e,s,p),_=wt(p,u);return Nr.with(_,a,void 0,u)}},t})();function Ri(t){return typeof t=="object"&&typeof t.spanId=="string"&&typeof t.traceId=="string"&&typeof t.traceFlags=="number"}var Oi=new Ne,Cn=(function(){function t(e,r,n,o){this._provider=e,this.name=r,this.version=n,this.options=o}return t.prototype.startSpan=function(e,r,n){return this._getTracer().startSpan(e,r,n)},t.prototype.startActiveSpan=function(e,r,n,o){var s=this._getTracer();return Reflect.apply(s.startActiveSpan,s,arguments)},t.prototype._getTracer=function(){if(this._delegate)return this._delegate;var e=this._provider.getDelegateTracer(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):Oi},t})();var Mn=(function(){function t(){}return t.prototype.getTracer=function(e,r,n){return new Ne},t})();var Li=new Mn,Pr=(function(){function t(){}return t.prototype.getTracer=function(e,r,n){var o;return(o=this.getDelegateTracer(e,r,n))!==null&&o!==void 0?o:new Cn(this,e,r,n)},t.prototype.getDelegate=function(){var e;return(e=this._delegate)!==null&&e!==void 0?e:Li},t.prototype.setDelegate=function(e){this._delegate=e},t.prototype.getDelegateTracer=function(e,r,n){var o;return(o=this._delegate)===null||o===void 0?void 0:o.getTracer(e,r,n)},t})();var At;(function(t){t[t.NOT_RECORD=0]="NOT_RECORD",t[t.RECORD=1]="RECORD",t[t.RECORD_AND_SAMPLED=2]="RECORD_AND_SAMPLED"})(At||(At={}));var Z;(function(t){t[t.INTERNAL=0]="INTERNAL",t[t.SERVER=1]="SERVER",t[t.CLIENT=2]="CLIENT",t[t.PRODUCER=3]="PRODUCER",t[t.CONSUMER=4]="CONSUMER"})(Z||(Z={}));var W;(function(t){t[t.UNSET=0]="UNSET",t[t.OK=1]="OK",t[t.ERROR=2]="ERROR"})(W||(W={}));var S=ot.getInstance();var T=v.instance();var xi=(function(){function t(){}return t.prototype.getMeter=function(e,r,n){return hn},t})();var yn=new xi;var Cr="metrics",In=(function(){function t(){}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalMeterProvider=function(e){return Y(Cr,e,v.instance())},t.prototype.getMeterProvider=function(){return w(Cr)||yn},t.prototype.getMeter=function(e,r,n){return this.getMeterProvider().getMeter(e,r,n)},t.prototype.disable=function(){j(Cr,v.instance())},t})();var Vt=In.getInstance();var bn=(function(){function t(){}return t.prototype.inject=function(e,r){},t.prototype.extract=function(e,r){return e},t.prototype.fields=function(){return[]},t})();var Mr=ct("OpenTelemetry Baggage Key");function yr(t){return t.getValue(Mr)||void 0}function vn(){return yr(ot.getInstance().active())}function Dn(t,e){return t.setValue(Mr,e)}function Un(t){return t.deleteValue(Mr)}var Ir="propagation",Ni=new bn,wn=(function(){function t(){this.createBaggage=mn,this.getBaggage=yr,this.getActiveBaggage=vn,this.setBaggage=Dn,this.deleteBaggage=Un}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalPropagator=function(e){return Y(Ir,e,v.instance())},t.prototype.inject=function(e,r,n){return n===void 0&&(n=gn),this._getGlobalPropagator().inject(e,r,n)},t.prototype.extract=function(e,r,n){return n===void 0&&(n=An),this._getGlobalPropagator().extract(e,r,n)},t.prototype.fields=function(){return this._getGlobalPropagator().fields()},t.prototype.disable=function(){j(Ir,v.instance())},t.prototype._getGlobalPropagator=function(){return w(Ir)||Ni},t})();var C=wn.getInstance();var br="trace",Vn=(function(){function t(){this._proxyTracerProvider=new Pr,this.wrapSpanContext=Pn,this.isSpanContextValid=J,this.deleteSpan=Ln,this.getSpan=Oe,this.getActiveSpan=On,this.getSpanContext=Le,this.setSpan=wt,this.setSpanContext=xn}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalTracerProvider=function(e){var r=Y(br,this._proxyTracerProvider,v.instance());return r&&this._proxyTracerProvider.setDelegate(e),r},t.prototype.getTracerProvider=function(){return w(br)||this._proxyTracerProvider},t.prototype.getTracer=function(e,r){return this.getTracerProvider().getTracer(e,r)},t.prototype.disable=function(){j(br,v.instance()),this._proxyTracerProvider=new Pr},t})();var A=Vn.getInstance();var Gn=ct("OpenTelemetry SDK Context Key SUPPRESS_TRACING");function Gt(t){return t.setValue(Gn,!0)}function ut(t){return t.getValue(Gn)===!0}var Pe="baggage";function Bn(t){return t.reduce((e,r)=>{let n=`${e}${e!==""?",":""}${r}`;return n.length>8192?e:n},"")}function Fn(t){return t.getAllEntries().map(([e,r])=>{let n=`${encodeURIComponent(e)}=${encodeURIComponent(r.value)}`;return r.metadata!==void 0&&(n+=";"+r.metadata.toString()),n})}function kn(t){let e=t.split(";");if(e.length<=0)return;let r=e.shift();if(!r)return;let n=r.indexOf("=");if(n<=0)return;let o=decodeURIComponent(r.substring(0,n).trim()),s=decodeURIComponent(r.substring(n+1).trim()),i;return e.length>0&&(i=Ar(e.join(";"))),{key:o,value:s,metadata:i}}var Ht=class{inject(e,r,n){let o=C.getBaggage(e);if(!o||ut(e))return;let s=Fn(o).filter(a=>a.length<=4096).slice(0,180),i=Bn(s);i.length>0&&n.set(r,Pe,i)}extract(e,r,n){let o=n.get(r,Pe),s=Array.isArray(o)?o.join(","):o;if(!s)return e;let i={};return s.length===0||(s.split(",").forEach(p=>{let u=kn(p);if(u){let _={value:u.value};u.metadata&&(_.metadata=u.metadata),i[u.key]=_}}),Object.entries(i).length===0)?e:C.setBaggage(e,C.createBaggage(i))}fields(){return[Pe]}};function _t(t){let e={};if(typeof t!="object"||t==null)return e;for(let r in t){if(!Object.prototype.hasOwnProperty.call(t,r))continue;if(!Mi(r)){T.warn(`Invalid attribute key: ${r}`);continue}let n=t[r];if(!Ce(n)){T.warn(`Invalid attribute value set for key: ${r}`);continue}Array.isArray(n)?e[r]=n.slice():e[r]=n}return e}function Mi(t){return typeof t=="string"&&t!==""}function Ce(t){return t==null?!0:Array.isArray(t)?yi(t):Kn(typeof t)}function yi(t){let e;for(let r of t){if(r==null)continue;let n=typeof r;if(n!==e){if(!e){if(Kn(n)){e=n;continue}return!1}return!1}}return!0}function Kn(t){switch(t){case"number":case"boolean":case"string":return!0}return!1}function Yn(){return t=>{T.error(Ii(t))}}function Ii(t){return typeof t=="string"?t:JSON.stringify(bi(t))}function bi(t){let e={},r=t;for(;r!==null;)Object.getOwnPropertyNames(r).forEach(n=>{if(e[n])return;let o=r[n];o&&(e[n]=String(o))}),r=Object.getPrototypeOf(r);return e}var vi=Yn();function V(t){try{vi(t)}catch{}}var Rt=typeof globalThis=="object"?globalThis:typeof self=="object"?self:typeof window=="object"?window:typeof global=="object"?global:{};var M=performance;var jn="2.2.0";var Di="service.name";var Ui="service.version";var Wn=Di;var zn=Ui;var Bt="error.type";var Me="exception.message",Xn="exception.stacktrace",ye="exception.type";var Ie="http.request.method";var be="http.request.method_original";var ve="http.response.status_code";var De="server.address",Ue="server.port",$n="service.name";var Ft="telemetry.sdk.language";var qn="webjs",kt="telemetry.sdk.name",Kt="telemetry.sdk.version";var it="url.full";var Qn="user_agent.original";var Jn="process.runtime.name";var Ot={[kt]:"opentelemetry",[Jn]:"browser",[Ft]:qn,[Kt]:jn};var wi=9,Vi=6,Gi=Math.pow(10,Vi),we=Math.pow(10,wi);function G(t){let e=t/1e3,r=Math.trunc(e),n=Math.round(t%1e3*Gi);return[r,n]}function Yt(){let t=M.timeOrigin;if(typeof t!="number"){let e=M;t=e.timing&&e.timing.fetchStart}return t}function H(t){let e=G(Yt()),r=G(typeof t=="number"?t:M.now());return He(e,r)}function Et(t){if(jt(t))return t;if(typeof t=="number")return t<Yt()?H(t):G(t);if(t instanceof Date)return G(t.getTime());throw TypeError("Invalid input type")}function Dr(t,e){let r=e[0]-t[0],n=e[1]-t[1];return n<0&&(r-=1,n+=we),[r,n]}function B(t){return t[0]*we+t[1]}function Ve(t){return t[0]*1e6+t[1]/1e3}function jt(t){return Array.isArray(t)&&t.length===2&&typeof t[0]=="number"&&typeof t[1]=="number"}function Ge(t){return jt(t)||typeof t=="number"||t instanceof Date}function He(t,e){let r=[t[0]+e[0],t[1]+e[1]];return r[1]>=we&&(r[1]-=we,r[0]+=1),r}var b;(function(t){t[t.SUCCESS=0]="SUCCESS",t[t.FAILED=1]="FAILED"})(b||(b={}));var Wt=class{constructor(e={}){c(this,"_propagators");c(this,"_fields");this._propagators=e.propagators??[],this._fields=Array.from(new Set(this._propagators.map(r=>typeof r.fields=="function"?r.fields():[]).reduce((r,n)=>r.concat(n),[])))}inject(e,r,n){for(let o of this._propagators)try{o.inject(e,r,n)}catch(s){T.warn(`Failed to inject with ${o.constructor.name}. Err: ${s.message}`)}}extract(e,r,n){return this._propagators.reduce((o,s)=>{try{return s.extract(o,r,n)}catch(i){T.warn(`Failed to extract with ${s.constructor.name}. Err: ${i.message}`)}return o},e)}fields(){return this._fields.slice()}};var Ur="[_0-9a-z-*/]",Hi=`[a-z]${Ur}{0,255}`,Bi=`[a-z0-9]${Ur}{0,240}@[a-z]${Ur}{0,13}`,Fi=new RegExp(`^(?:${Hi}|${Bi})$`),ki=/^[ -~]{0,255}[!-~]$/,Ki=/,|=/;function Zn(t){return Fi.test(t)}function to(t){return ki.test(t)&&!Ki.test(t)}var eo=32,Yi=512,ro=",",no="=",Be=class t{constructor(e){c(this,"_internalState",new Map);e&&this._parse(e)}set(e,r){let n=this._clone();return n._internalState.has(e)&&n._internalState.delete(e),n._internalState.set(e,r),n}unset(e){let r=this._clone();return r._internalState.delete(e),r}get(e){return this._internalState.get(e)}serialize(){return this._keys().reduce((e,r)=>(e.push(r+no+this.get(r)),e),[]).join(ro)}_parse(e){e.length>Yi||(this._internalState=e.split(ro).reverse().reduce((r,n)=>{let o=n.trim(),s=o.indexOf(no);if(s!==-1){let i=o.slice(0,s),a=o.slice(s+1,n.length);Zn(i)&&to(a)&&r.set(i,a)}return r},new Map),this._internalState.size>eo&&(this._internalState=new Map(Array.from(this._internalState.entries()).reverse().slice(0,eo))))}_keys(){return Array.from(this._internalState.keys()).reverse()}_clone(){let e=new t;return e._internalState=new Map(this._internalState),e}};var Lt="traceparent",Fe="tracestate",ji="00",Wi="(?!ff)[\\da-f]{2}",zi="(?![0]{32})[\\da-f]{32}",Xi="(?![0]{16})[\\da-f]{16}",$i="[\\da-f]{2}",qi=new RegExp(`^\\s?(${Wi})-(${zi})-(${Xi})-(${$i})(-.*)?\\s?$`);function oo(t){let e=qi.exec(t);return!e||e[1]==="00"&&e[5]?null:{traceId:e[2],spanId:e[3],traceFlags:parseInt(e[4],16)}}var zt=class{inject(e,r,n){let o=A.getSpanContext(e);if(!o||ut(e)||!J(o))return;let s=`${ji}-${o.traceId}-${o.spanId}-0${Number(o.traceFlags||I.NONE).toString(16)}`;n.set(r,Lt,s),o.traceState&&n.set(r,Fe,o.traceState.serialize())}extract(e,r,n){let o=n.get(r,Lt);if(!o)return e;let s=Array.isArray(o)?o[0]:o;if(typeof s!="string")return e;let i=oo(s);if(!i)return e;i.isRemote=!0;let a=n.get(r,Fe);if(a){let p=Array.isArray(a)?a.join(","):a;i.traceState=new Be(typeof p=="string"?p:void 0)}return A.setSpanContext(e,i)}fields(){return[Lt,Fe]}};var Qi="[object Object]",Ji="[object Null]",Zi="[object Undefined]",ta=Function.prototype,so=ta.toString,ea=so.call(Object),ra=Object.getPrototypeOf,io=Object.prototype,ao=io.hasOwnProperty,Tt=Symbol?Symbol.toStringTag:void 0,co=io.toString;function wr(t){if(!na(t)||oa(t)!==Qi)return!1;let e=ra(t);if(e===null)return!0;let r=ao.call(e,"constructor")&&e.constructor;return typeof r=="function"&&r instanceof r&&so.call(r)===ea}function na(t){return t!=null&&typeof t=="object"}function oa(t){return t==null?t===void 0?Zi:Ji:Tt&&Tt in Object(t)?sa(t):ia(t)}function sa(t){let e=ao.call(t,Tt),r=t[Tt],n=!1;try{t[Tt]=void 0,n=!0}catch{}let o=co.call(t);return n&&(e?t[Tt]=r:delete t[Tt]),o}function ia(t){return co.call(t)}var aa=20;function Gr(...t){let e=t.shift(),r=new WeakMap;for(;t.length>0;)e=uo(e,t.shift(),0,r);return e}function Vr(t){return Ke(t)?t.slice():t}function uo(t,e,r=0,n){let o;if(!(r>aa)){if(r++,ke(t)||ke(e)||_o(e))o=Vr(e);else if(Ke(t)){if(o=t.slice(),Ke(e))for(let s=0,i=e.length;s<i;s++)o.push(Vr(e[s]));else if(Xt(e)){let s=Object.keys(e);for(let i=0,a=s.length;i<a;i++){let p=s[i];o[p]=Vr(e[p])}}}else if(Xt(t))if(Xt(e)){if(!ca(t,e))return e;o=Object.assign({},t);let s=Object.keys(e);for(let i=0,a=s.length;i<a;i++){let p=s[i],u=e[p];if(ke(u))typeof u>"u"?delete o[p]:o[p]=u;else{let _=o[p],f=u;if(po(t,p,n)||po(e,p,n))delete o[p];else{if(Xt(_)&&Xt(f)){let h=n.get(_)||[],R=n.get(f)||[];h.push({obj:t,key:p}),R.push({obj:e,key:p}),n.set(_,h),n.set(f,R)}o[p]=uo(o[p],u,r,n)}}}}else o=e;return o}}function po(t,e,r){let n=r.get(t[e])||[];for(let o=0,s=n.length;o<s;o++){let i=n[o];if(i.key===e&&i.obj===t)return!0}return!1}function Ke(t){return Array.isArray(t)}function _o(t){return typeof t=="function"}function Xt(t){return!ke(t)&&!Ke(t)&&!_o(t)&&typeof t=="object"}function ke(t){return typeof t=="string"||typeof t=="number"||typeof t=="boolean"||typeof t>"u"||t instanceof Date||t instanceof RegExp||t===null}function ca(t,e){return!(!wr(t)||!wr(e))}function Ye(t,e){return typeof e=="string"?t===e:!!t.match(e)}function $t(t,e){if(!e)return!1;for(let r of e)if(Ye(t,r))return!0;return!1}var je=class{constructor(){c(this,"_promise");c(this,"_resolve");c(this,"_reject");this._promise=new Promise((e,r)=>{this._resolve=e,this._reject=r})}get promise(){return this._promise}resolve(e){this._resolve(e)}reject(e){this._reject(e)}};var lt=class{constructor(e,r){c(this,"_callback");c(this,"_that");c(this,"_isCalled",!1);c(this,"_deferred",new je);this._callback=e,this._that=r}get isCalled(){return this._isCalled}get promise(){return this._deferred.promise}call(...e){if(!this._isCalled){this._isCalled=!0;try{Promise.resolve(this._callback.call(this._that,...e)).then(r=>this._deferred.resolve(r),r=>this._deferred.reject(r))}catch(r){this._deferred.reject(r)}}return this._deferred.promise}};function Eo(t,e){return new Promise(r=>{S.with(Gt(S.active()),()=>{t.export(e,n=>{r(n)})})})}var To={_export:Eo};function Hr(){return"unknown_service"}var xt=t=>t!==null&&typeof t=="object"&&typeof t.then=="function";var Br=class t{constructor(e,r){c(this,"_rawAttributes");c(this,"_asyncAttributesPending",!1);c(this,"_schemaUrl");c(this,"_memoizedAttributes");let n=e.attributes??{};this._rawAttributes=Object.entries(n).map(([o,s])=>(xt(s)&&(this._asyncAttributesPending=!0),[o,s])),this._rawAttributes=lo(this._rawAttributes),this._schemaUrl=_a(r?.schemaUrl)}static FromAttributeList(e,r){let n=new t({},r);return n._rawAttributes=lo(e),n._asyncAttributesPending=e.filter(([o,s])=>xt(s)).length>0,n}get asyncAttributesPending(){return this._asyncAttributesPending}async waitForAsyncAttributes(){if(this.asyncAttributesPending){for(let e=0;e<this._rawAttributes.length;e++){let[r,n]=this._rawAttributes[e];this._rawAttributes[e]=[r,xt(n)?await n:n]}this._asyncAttributesPending=!1}}get attributes(){if(this.asyncAttributesPending&&T.error("Accessing resource attributes before async attributes settled"),this._memoizedAttributes)return this._memoizedAttributes;let e={};for(let[r,n]of this._rawAttributes){if(xt(n)){T.debug(`Unsettled resource attribute ${r} skipped`);continue}n!=null&&(e[r]??(e[r]=n))}return this._asyncAttributesPending||(this._memoizedAttributes=e),e}getRawAttributes(){return this._rawAttributes}get schemaUrl(){return this._schemaUrl}merge(e){if(e==null)return this;let r=Ea(this,e),n=r?{schemaUrl:r}:void 0;return t.FromAttributeList([...e.getRawAttributes(),...this.getRawAttributes()],n)}};function We(t,e){return Br.FromAttributeList(Object.entries(t),e)}function Fr(){return We({[$n]:Hr(),[Ft]:Ot[Ft],[kt]:Ot[kt],[Kt]:Ot[Kt]})}function lo(t){return t.map(([e,r])=>xt(r)?[e,r.catch(n=>{T.debug("promise rejection for resource attribute: %s - %s",e,n)})]:[e,r])}function _a(t){if(typeof t=="string"||t===void 0)return t;T.warn("Schema URL must be string or undefined, got %s. Schema URL will be ignored.",t)}function Ea(t,e){let r=t?.schemaUrl,n=e?.schemaUrl,o=r===void 0||r==="",s=n===void 0||n==="";if(o)return n;if(s||r===n)return r;T.warn('Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.',r,n)}var fo="exception";var ze=class{constructor(e){c(this,"_spanContext");c(this,"kind");c(this,"parentSpanContext");c(this,"attributes",{});c(this,"links",[]);c(this,"events",[]);c(this,"startTime");c(this,"resource");c(this,"instrumentationScope");c(this,"_droppedAttributesCount",0);c(this,"_droppedEventsCount",0);c(this,"_droppedLinksCount",0);c(this,"name");c(this,"status",{code:W.UNSET});c(this,"endTime",[0,0]);c(this,"_ended",!1);c(this,"_duration",[-1,-1]);c(this,"_spanProcessor");c(this,"_spanLimits");c(this,"_attributeValueLengthLimit");c(this,"_performanceStartTime");c(this,"_performanceOffset");c(this,"_startTimeProvided");let r=Date.now();this._spanContext=e.spanContext,this._performanceStartTime=M.now(),this._performanceOffset=r-(this._performanceStartTime+Yt()),this._startTimeProvided=e.startTime!=null,this._spanLimits=e.spanLimits,this._attributeValueLengthLimit=this._spanLimits.attributeValueLengthLimit||0,this._spanProcessor=e.spanProcessor,this.name=e.name,this.parentSpanContext=e.parentSpanContext,this.kind=e.kind,this.links=e.links||[],this.startTime=this._getTime(e.startTime??r),this.resource=e.resource,this.instrumentationScope=e.scope,e.attributes!=null&&this.setAttributes(e.attributes),this._spanProcessor.onStart(this,e.context)}spanContext(){return this._spanContext}setAttribute(e,r){if(r==null||this._isSpanEnded())return this;if(e.length===0)return T.warn(`Invalid attribute key: ${e}`),this;if(!Ce(r))return T.warn(`Invalid attribute value set for key: ${e}`),this;let{attributeCountLimit:n}=this._spanLimits;return n!==void 0&&Object.keys(this.attributes).length>=n&&!Object.prototype.hasOwnProperty.call(this.attributes,e)?(this._droppedAttributesCount++,this):(this.attributes[e]=this._truncateToSize(r),this)}setAttributes(e){for(let[r,n]of Object.entries(e))this.setAttribute(r,n);return this}addEvent(e,r,n){if(this._isSpanEnded())return this;let{eventCountLimit:o}=this._spanLimits;if(o===0)return T.warn("No events allowed."),this._droppedEventsCount++,this;o!==void 0&&this.events.length>=o&&(this._droppedEventsCount===0&&T.debug("Dropping extra events."),this.events.shift(),this._droppedEventsCount++),Ge(r)&&(Ge(n)||(n=r),r=void 0);let s=_t(r);return this.events.push({name:e,attributes:s,time:this._getTime(n),droppedAttributesCount:0}),this}addLink(e){return this.links.push(e),this}addLinks(e){return this.links.push(...e),this}setStatus(e){return this._isSpanEnded()?this:(this.status={...e},this.status.message!=null&&typeof e.message!="string"&&(T.warn(`Dropping invalid status.message of type '${typeof e.message}', expected 'string'`),delete this.status.message),this)}updateName(e){return this._isSpanEnded()?this:(this.name=e,this)}end(e){if(this._isSpanEnded()){T.error(`${this.name} ${this._spanContext.traceId}-${this._spanContext.spanId} - You can only call end() on a span once.`);return}this._ended=!0,this.endTime=this._getTime(e),this._duration=Dr(this.startTime,this.endTime),this._duration[0]<0&&(T.warn("Inconsistent start and end time, startTime > endTime. Setting span duration to 0ms.",this.startTime,this.endTime),this.endTime=this.startTime.slice(),this._duration=[0,0]),this._droppedEventsCount>0&&T.warn(`Dropped ${this._droppedEventsCount} events because eventCountLimit reached`),this._spanProcessor.onEnd(this)}_getTime(e){if(typeof e=="number"&&e<=M.now())return H(e+this._performanceOffset);if(typeof e=="number")return G(e);if(e instanceof Date)return G(e.getTime());if(jt(e))return e;if(this._startTimeProvided)return G(Date.now());let r=M.now()-this._performanceStartTime;return He(this.startTime,G(r))}isRecording(){return this._ended===!1}recordException(e,r){let n={};typeof e=="string"?n[Me]=e:e&&(e.code?n[ye]=e.code.toString():e.name&&(n[ye]=e.name),e.message&&(n[Me]=e.message),e.stack&&(n[Xn]=e.stack)),n[ye]||n[Me]?this.addEvent(fo,n,r):T.warn(`Failed to record an exception ${e}`)}get duration(){return this._duration}get ended(){return this._ended}get droppedAttributesCount(){return this._droppedAttributesCount}get droppedEventsCount(){return this._droppedEventsCount}get droppedLinksCount(){return this._droppedLinksCount}_isSpanEnded(){if(this._ended){let e=new Error(`Operation attempted on ended Span {traceId: ${this._spanContext.traceId}, spanId: ${this._spanContext.spanId}}`);T.warn(`Cannot execute the operation on ended Span {traceId: ${this._spanContext.traceId}, spanId: ${this._spanContext.spanId}}`,e)}return this._ended}_truncateToLimitUtil(e,r){return e.length<=r?e:e.substring(0,r)}_truncateToSize(e){let r=this._attributeValueLengthLimit;return r<=0?(T.warn(`Attribute value limit must be positive, got ${r}`),e):typeof e=="string"?this._truncateToLimitUtil(e,r):Array.isArray(e)?e.map(n=>typeof n=="string"?this._truncateToLimitUtil(n,r):n):e}};var tt;(function(t){t[t.NOT_RECORD=0]="NOT_RECORD",t[t.RECORD=1]="RECORD",t[t.RECORD_AND_SAMPLED=2]="RECORD_AND_SAMPLED"})(tt||(tt={}));var at=class{shouldSample(){return{decision:tt.NOT_RECORD}}toString(){return"AlwaysOffSampler"}};var z=class{shouldSample(){return{decision:tt.RECORD_AND_SAMPLED}}toString(){return"AlwaysOnSampler"}};var ft=class{constructor(e){c(this,"_root");c(this,"_remoteParentSampled");c(this,"_remoteParentNotSampled");c(this,"_localParentSampled");c(this,"_localParentNotSampled");this._root=e.root,this._root||(V(new Error("ParentBasedSampler must have a root sampler configured")),this._root=new z),this._remoteParentSampled=e.remoteParentSampled??new z,this._remoteParentNotSampled=e.remoteParentNotSampled??new at,this._localParentSampled=e.localParentSampled??new z,this._localParentNotSampled=e.localParentNotSampled??new at}shouldSample(e,r,n,o,s,i){let a=A.getSpanContext(e);return!a||!J(a)?this._root.shouldSample(e,r,n,o,s,i):a.isRemote?a.traceFlags&I.SAMPLED?this._remoteParentSampled.shouldSample(e,r,n,o,s,i):this._remoteParentNotSampled.shouldSample(e,r,n,o,s,i):a.traceFlags&I.SAMPLED?this._localParentSampled.shouldSample(e,r,n,o,s,i):this._localParentNotSampled.shouldSample(e,r,n,o,s,i)}toString(){return`ParentBased{root=${this._root.toString()}, remoteParentSampled=${this._remoteParentSampled.toString()}, remoteParentNotSampled=${this._remoteParentNotSampled.toString()}, localParentSampled=${this._localParentSampled.toString()}, localParentNotSampled=${this._localParentNotSampled.toString()}}`}};var qt=class{constructor(e=0){c(this,"_ratio");c(this,"_upperBound");this._ratio=e,this._ratio=this._normalize(e),this._upperBound=Math.floor(this._ratio*4294967295)}shouldSample(e,r){return{decision:xe(r)&&this._accumulate(r)<this._upperBound?tt.RECORD_AND_SAMPLED:tt.NOT_RECORD}}toString(){return`TraceIdRatioBased{${this._ratio}}`}_normalize(e){return typeof e!="number"||isNaN(e)?0:e>=1?1:e<=0?0:e}_accumulate(e){let r=0;for(let n=0;n<e.length/8;n++){let o=n*8,s=parseInt(e.slice(o,o+8),16);r=(r^s)>>>0}return r}};var X;(function(t){t.AlwaysOff="always_off",t.AlwaysOn="always_on",t.ParentBasedAlwaysOff="parentbased_always_off",t.ParentBasedAlwaysOn="parentbased_always_on",t.ParentBasedTraceIdRatio="parentbased_traceidratio",t.TraceIdRatio="traceidratio"})(X||(X={}));var Xe=1;function $e(){return{sampler:kr(),forceFlushTimeoutMillis:3e4,generalLimits:{attributeValueLengthLimit:void 0??1/0,attributeCountLimit:void 0??128},spanLimits:{attributeValueLengthLimit:void 0??1/0,attributeCountLimit:void 0??128,linkCountLimit:void 0??128,eventCountLimit:void 0??128,attributePerEventCountLimit:void 0??128,attributePerLinkCountLimit:void 0??128}}}function kr(){let t=void 0??X.ParentBasedAlwaysOn;switch(t){case X.AlwaysOn:return new z;case X.AlwaysOff:return new at;case X.ParentBasedAlwaysOn:return new ft({root:new z});case X.ParentBasedAlwaysOff:return new ft({root:new at});case X.TraceIdRatio:return new qt(So());case X.ParentBasedTraceIdRatio:return new ft({root:new qt(So())});default:return T.error(`OTEL_TRACES_SAMPLER value "${t}" invalid, defaulting to "${X.ParentBasedAlwaysOn}".`),new ft({root:new z})}}function So(){let t=void 0;return t==null?(T.error(`OTEL_TRACES_SAMPLER_ARG is blank, defaulting to ${Xe}.`),Xe):t<0||t>1?(T.error(`OTEL_TRACES_SAMPLER_ARG=${t} was given, but it is out of range ([0..1]), defaulting to ${Xe}.`),Xe):t}var Ta=128,la=1/0;function mo(t){let e={sampler:kr()},r=$e(),n=Object.assign({},r,e,t);return n.generalLimits=Object.assign({},r.generalLimits,t.generalLimits||{}),n.spanLimits=Object.assign({},r.spanLimits,t.spanLimits||{}),n}function ho(t){let e=Object.assign({},t.spanLimits);return e.attributeCountLimit=t.spanLimits?.attributeCountLimit??t.generalLimits?.attributeCountLimit??void 0??void 0??Ta,e.attributeValueLengthLimit=t.spanLimits?.attributeValueLengthLimit??t.generalLimits?.attributeValueLengthLimit??void 0??void 0??la,Object.assign({},t,{spanLimits:e})}var qe=class{constructor(e,r){c(this,"_exporter");c(this,"_maxExportBatchSize");c(this,"_maxQueueSize");c(this,"_scheduledDelayMillis");c(this,"_exportTimeoutMillis");c(this,"_isExporting",!1);c(this,"_finishedSpans",[]);c(this,"_timer");c(this,"_shutdownOnce");c(this,"_droppedSpansCount",0);this._exporter=e,this._maxExportBatchSize=typeof r?.maxExportBatchSize=="number"?r.maxExportBatchSize:void 0??512,this._maxQueueSize=typeof r?.maxQueueSize=="number"?r.maxQueueSize:void 0??2048,this._scheduledDelayMillis=typeof r?.scheduledDelayMillis=="number"?r.scheduledDelayMillis:void 0??5e3,this._exportTimeoutMillis=typeof r?.exportTimeoutMillis=="number"?r.exportTimeoutMillis:void 0??3e4,this._shutdownOnce=new lt(this._shutdown,this),this._maxExportBatchSize>this._maxQueueSize&&(T.warn("BatchSpanProcessor: maxExportBatchSize must be smaller or equal to maxQueueSize, setting maxExportBatchSize to match maxQueueSize"),this._maxExportBatchSize=this._maxQueueSize)}forceFlush(){return this._shutdownOnce.isCalled?this._shutdownOnce.promise:this._flushAll()}onStart(e,r){}onEnd(e){this._shutdownOnce.isCalled||(e.spanContext().traceFlags&I.SAMPLED)!==0&&this._addToBuffer(e)}shutdown(){return this._shutdownOnce.call()}_shutdown(){return Promise.resolve().then(()=>this.onShutdown()).then(()=>this._flushAll()).then(()=>this._exporter.shutdown())}_addToBuffer(e){if(this._finishedSpans.length>=this._maxQueueSize){this._droppedSpansCount===0&&T.debug("maxQueueSize reached, dropping spans"),this._droppedSpansCount++;return}this._droppedSpansCount>0&&(T.warn(`Dropped ${this._droppedSpansCount} spans because maxQueueSize reached`),this._droppedSpansCount=0),this._finishedSpans.push(e),this._maybeStartTimer()}_flushAll(){return new Promise((e,r)=>{let n=[],o=Math.ceil(this._finishedSpans.length/this._maxExportBatchSize);for(let s=0,i=o;s<i;s++)n.push(this._flushOneBatch());Promise.all(n).then(()=>{e()}).catch(r)})}_flushOneBatch(){return this._clearTimer(),this._finishedSpans.length===0?Promise.resolve():new Promise((e,r)=>{let n=setTimeout(()=>{r(new Error("Timeout"))},this._exportTimeoutMillis);S.with(Gt(S.active()),()=>{let o;this._finishedSpans.length<=this._maxExportBatchSize?(o=this._finishedSpans,this._finishedSpans=[]):o=this._finishedSpans.splice(0,this._maxExportBatchSize);let s=()=>this._exporter.export(o,a=>{clearTimeout(n),a.code===b.SUCCESS?e():r(a.error??new Error("BatchSpanProcessor: span export failed"))}),i=null;for(let a=0,p=o.length;a<p;a++){let u=o[a];u.resource.asyncAttributesPending&&u.resource.waitForAsyncAttributes&&(i??(i=[]),i.push(u.resource.waitForAsyncAttributes()))}i===null?s():Promise.all(i).then(s,a=>{V(a),r(a)})})})}_maybeStartTimer(){if(this._isExporting)return;let e=()=>{this._isExporting=!0,this._flushOneBatch().finally(()=>{this._isExporting=!1,this._finishedSpans.length>0&&(this._clearTimer(),this._maybeStartTimer())}).catch(r=>{this._isExporting=!1,V(r)})};if(this._finishedSpans.length>=this._maxExportBatchSize)return e();this._timer===void 0&&(this._timer=setTimeout(()=>e(),this._scheduledDelayMillis),typeof this._timer!="number"&&this._timer.unref())}_clearTimer(){this._timer!==void 0&&(clearTimeout(this._timer),this._timer=void 0)}};var Nt=class extends qe{constructor(r,n){super(r,n);c(this,"_visibilityChangeListener");c(this,"_pageHideListener");this.onInit(n)}onInit(r){r?.disableAutoFlushOnDocumentHide!==!0&&typeof document<"u"&&(this._visibilityChangeListener=()=>{document.visibilityState==="hidden"&&this.forceFlush().catch(n=>{V(n)})},this._pageHideListener=()=>{this.forceFlush().catch(n=>{V(n)})},document.addEventListener("visibilitychange",this._visibilityChangeListener),document.addEventListener("pagehide",this._pageHideListener))}onShutdown(){typeof document<"u"&&(this._visibilityChangeListener&&document.removeEventListener("visibilitychange",this._visibilityChangeListener),this._pageHideListener&&document.removeEventListener("pagehide",this._pageHideListener))}};var Pt=class{constructor(){c(this,"generateTraceId",Ao(16));c(this,"generateSpanId",Ao(8))}},Qe=Array(32);function Ao(t){return function(){for(let r=0;r<t*2;r++)Qe[r]=Math.floor(Math.random()*16)+48,Qe[r]>=58&&(Qe[r]+=39);return String.fromCharCode.apply(null,Qe.slice(0,t*2))}}var Je=class{constructor(e,r,n,o){c(this,"_sampler");c(this,"_generalLimits");c(this,"_spanLimits");c(this,"_idGenerator");c(this,"instrumentationScope");c(this,"_resource");c(this,"_spanProcessor");let s=mo(r);this._sampler=s.sampler,this._generalLimits=s.generalLimits,this._spanLimits=s.spanLimits,this._idGenerator=r.idGenerator||new Pt,this._resource=n,this._spanProcessor=o,this.instrumentationScope=e}startSpan(e,r={},n=S.active()){r.root&&(n=A.deleteSpan(n));let o=A.getSpan(n);if(ut(n))return T.debug("Instrumentation suppressed, returning Noop Span"),A.wrapSpanContext(Ut);let s=o?.spanContext(),i=this._idGenerator.generateSpanId(),a,p,u;!s||!A.isSpanContextValid(s)?p=this._idGenerator.generateTraceId():(p=s.traceId,u=s.traceState,a=s);let _=r.kind??Z.INTERNAL,f=(r.links??[]).map(m=>({context:m.context,attributes:_t(m.attributes)})),h=_t(r.attributes),R=this._sampler.shouldSample(n,p,e,_,h,f);u=R.traceState??u;let O=R.decision===At.RECORD_AND_SAMPLED?I.SAMPLED:I.NONE,L={traceId:p,spanId:i,traceFlags:O,traceState:u};if(R.decision===At.NOT_RECORD)return T.debug("Recording is off, propagating context in a non-recording span"),A.wrapSpanContext(L);let E=_t(Object.assign(h,R.attributes));return new ze({resource:this._resource,scope:this.instrumentationScope,context:n,spanContext:L,name:e,kind:_,links:f,parentSpanContext:a,attributes:E,startTime:r.startTime,spanProcessor:this._spanProcessor,spanLimits:this._spanLimits})}startActiveSpan(e,r,n,o){let s,i,a;if(arguments.length<2)return;arguments.length===2?a=r:arguments.length===3?(s=r,a=n):(s=r,i=n,a=o);let p=i??S.active(),u=this.startSpan(e,s,p),_=A.setSpan(p,u);return S.with(_,a,void 0,u)}getGeneralLimits(){return this._generalLimits}getSpanLimits(){return this._spanLimits}};var Ze=class{constructor(e){c(this,"_spanProcessors");this._spanProcessors=e}forceFlush(){let e=[];for(let r of this._spanProcessors)e.push(r.forceFlush());return new Promise(r=>{Promise.all(e).then(()=>{r()}).catch(n=>{V(n||new Error("MultiSpanProcessor: forceFlush failed")),r()})})}onStart(e,r){for(let n of this._spanProcessors)n.onStart(e,r)}onEnd(e){for(let r of this._spanProcessors)r.onEnd(e)}shutdown(){let e=[];for(let r of this._spanProcessors)e.push(r.shutdown());return new Promise((r,n)=>{Promise.all(e).then(()=>{r()},n)})}};var dt;(function(t){t[t.resolved=0]="resolved",t[t.timeout=1]="timeout",t[t.error=2]="error",t[t.unresolved=3]="unresolved"})(dt||(dt={}));var Qt=class{constructor(e={}){c(this,"_config");c(this,"_tracers",new Map);c(this,"_resource");c(this,"_activeSpanProcessor");let r=Gr({},$e(),ho(e));this._resource=r.resource??Fr(),this._config=Object.assign({},r,{resource:this._resource});let n=[];e.spanProcessors?.length&&n.push(...e.spanProcessors),this._activeSpanProcessor=new Ze(n)}getTracer(e,r,n){let o=`${e}@${r||""}:${n?.schemaUrl||""}`;return this._tracers.has(o)||this._tracers.set(o,new Je({name:e,version:r,schemaUrl:n?.schemaUrl},this._config,this._resource,this._activeSpanProcessor)),this._tracers.get(o)}forceFlush(){let e=this._config.forceFlushTimeoutMillis,r=this._activeSpanProcessor._spanProcessors.map(n=>new Promise(o=>{let s,i=setTimeout(()=>{o(new Error(`Span processor did not completed within timeout period of ${e} ms`)),s=dt.timeout},e);n.forceFlush().then(()=>{clearTimeout(i),s!==dt.timeout&&(s=dt.resolved,o(s))}).catch(a=>{clearTimeout(i),s=dt.error,o(a)})}));return new Promise((n,o)=>{Promise.all(r).then(s=>{let i=s.filter(a=>a!==dt.resolved);i.length>0?o(i):n()}).catch(s=>o([s]))})}shutdown(){return this._activeSpanProcessor.shutdown()}};var Jt=class{export(e,r){return this._sendSpans(e,r)}shutdown(){return this._sendSpans([]),this.forceFlush()}forceFlush(){return Promise.resolve()}_exportInfo(e){return{resource:{attributes:e.resource.attributes},instrumentationScope:e.instrumentationScope,traceId:e.spanContext().traceId,parentSpanContext:e.parentSpanContext,traceState:e.spanContext().traceState?.serialize(),name:e.name,id:e.spanContext().spanId,kind:e.kind,timestamp:Ve(e.startTime),duration:Ve(e.duration),attributes:e.attributes,status:e.status,events:e.events,links:e.links}}_sendSpans(e,r){for(let n of e)console.dir(this._exportInfo(n),{depth:3});if(r)return r({code:b.SUCCESS})}};var Zt=class{constructor(e){c(this,"_exporter");c(this,"_shutdownOnce");c(this,"_pendingExports");this._exporter=e,this._shutdownOnce=new lt(this._shutdown,this),this._pendingExports=new Set}async forceFlush(){await Promise.all(Array.from(this._pendingExports)),this._exporter.forceFlush&&await this._exporter.forceFlush()}onStart(e,r){}onEnd(e){if(this._shutdownOnce.isCalled||(e.spanContext().traceFlags&I.SAMPLED)===0)return;let r=this._doExport(e).catch(n=>V(n));this._pendingExports.add(r),r.finally(()=>this._pendingExports.delete(r))}async _doExport(e){e.resource.asyncAttributesPending&&await e.resource.waitForAsyncAttributes?.();let r=await To._export(this._exporter,[e]);if(r.code!==b.SUCCESS)throw r.error??new Error(`SimpleSpanProcessor: span export failed (status ${r})`)}shutdown(){return this._shutdownOnce.call()}_shutdown(){return this._exporter.shutdown()}};var tr=class{constructor(){c(this,"_enabled",!1);c(this,"_currentContext",K)}_bindFunction(e=K,r){let n=this,o=function(...s){return n.with(e,()=>r.apply(this,s))};return Object.defineProperty(o,"length",{enumerable:!1,configurable:!0,writable:!1,value:r.length}),o}active(){return this._currentContext}bind(e,r){return e===void 0&&(e=this.active()),typeof r=="function"?this._bindFunction(e,r):r}disable(){return this._currentContext=K,this._enabled=!1,this}enable(){return this._enabled?this:(this._enabled=!0,this._currentContext=K,this)}with(e,r,n,...o){let s=this._currentContext;this._currentContext=e||K;try{return r.call(n,...o)}finally{this._currentContext=s}}};function fa(t){if(t!==null){if(t===void 0){let e=new tr;e.enable(),S.setGlobalContextManager(e);return}t.enable(),S.setGlobalContextManager(t)}}function da(t){if(t!==null){if(t===void 0){C.setGlobalPropagator(new Wt({propagators:[new zt,new Ht]}));return}C.setGlobalPropagator(t)}}var te=class extends Qt{constructor(e={}){super(e)}register(e={}){A.setGlobalTracerProvider(this),da(e.propagator),fa(e.contextManager)}};var d;(function(t){t.CONNECT_END="connectEnd",t.CONNECT_START="connectStart",t.DECODED_BODY_SIZE="decodedBodySize",t.DOM_COMPLETE="domComplete",t.DOM_CONTENT_LOADED_EVENT_END="domContentLoadedEventEnd",t.DOM_CONTENT_LOADED_EVENT_START="domContentLoadedEventStart",t.DOM_INTERACTIVE="domInteractive",t.DOMAIN_LOOKUP_END="domainLookupEnd",t.DOMAIN_LOOKUP_START="domainLookupStart",t.ENCODED_BODY_SIZE="encodedBodySize",t.FETCH_START="fetchStart",t.LOAD_EVENT_END="loadEventEnd",t.LOAD_EVENT_START="loadEventStart",t.NAVIGATION_START="navigationStart",t.REDIRECT_END="redirectEnd",t.REDIRECT_START="redirectStart",t.REQUEST_START="requestStart",t.RESPONSE_END="responseEnd",t.RESPONSE_START="responseStart",t.SECURE_CONNECTION_START="secureConnectionStart",t.START_TIME="startTime",t.UNLOAD_EVENT_END="unloadEventEnd",t.UNLOAD_EVENT_START="unloadEventStart"})(d||(d={}));var go="http.response_content_length",Ro="http.response_content_length_uncompressed";var Kr;function Sa(){return Kr||(Kr=document.createElement("a")),Kr}function et(t,e){return e in t}function P(t,e,r,n=!0){if(et(r,e)&&typeof r[e]=="number"&&!(n&&r[e]===0))return t.addEvent(e,r[e])}function $(t,e,r=!1,n,o){if(n===void 0&&(n=e[d.START_TIME]!==0),r||(P(t,d.FETCH_START,e,n),P(t,d.DOMAIN_LOOKUP_START,e,n),P(t,d.DOMAIN_LOOKUP_END,e,n),P(t,d.CONNECT_START,e,n),P(t,d.SECURE_CONNECTION_START,e,n),P(t,d.CONNECT_END,e,n),P(t,d.REQUEST_START,e,n),P(t,d.RESPONSE_START,e,n),P(t,d.RESPONSE_END,e,n)),!o){let s=e[d.ENCODED_BODY_SIZE];s!==void 0&&t.setAttribute(go,s);let i=e[d.DECODED_BODY_SIZE];i!==void 0&&s!==i&&t.setAttribute(Ro,i)}}function Oo(t){return t.slice().sort((e,r)=>{let n=e[d.FETCH_START],o=r[d.FETCH_START];return n>o?1:n<o?-1:0})}function Lo(){return typeof location<"u"?location.origin:void 0}function ee(t,e,r,n,o=new WeakSet,s){let i=F(t);t=i.toString();let a=ha(t,e,r,n,o,s);if(a.length===0)return{mainRequest:void 0};if(a.length===1)return{mainRequest:a[0]};let p=Oo(a);if(i.origin!==Lo()&&p.length>1){let u=p[0],_=ma(p,u[d.RESPONSE_END],r),f=u[d.RESPONSE_END];return _[d.FETCH_START]<f&&(_=u,u=void 0),{corsPreFlightRequest:u,mainRequest:_}}else return{mainRequest:a[0]}}function ma(t,e,r){let n=B(r),o=B(Et(e)),s=t[1],i,a=t.length;for(let p=1;p<a;p++){let u=t[p],_=B(Et(u[d.FETCH_START])),f=B(Et(u[d.RESPONSE_END])),h=n-f;_>=o&&(!i||h<i)&&(i=h,s=u)}return s}function ha(t,e,r,n,o,s){let i=B(e),a=B(r),p=n.filter(u=>{let _=B(Et(u[d.FETCH_START])),f=B(Et(u[d.RESPONSE_END]));return u.initiatorType.toLowerCase()===(s||"xmlhttprequest")&&u.name===t&&_>=i&&f<=a});return p.length>0&&(p=p.filter(u=>!o.has(u))),p}function F(t){if(typeof URL=="function")return new URL(t,typeof document<"u"?document.baseURI:typeof location<"u"?location.href:void 0);let e=Sa();return e.href=t,e}function er(t,e){if(t.nodeType===Node.DOCUMENT_NODE)return"/";let r=ga(t,e);if(e&&r.indexOf("@id")>0)return r;let n="";return t.parentNode&&(n+=er(t.parentNode,!1)),n+=r,n}function Aa(t){if(!t.parentNode)return 0;let e=[t.nodeType];t.nodeType===Node.CDATA_SECTION_NODE&&e.push(Node.TEXT_NODE);let r=Array.from(t.parentNode.childNodes);return r=r.filter(n=>{let o=n.localName;return e.indexOf(n.nodeType)>=0&&o===t.localName}),r.length>=1?r.indexOf(t)+1:0}function ga(t,e){let r=t.nodeType,n=Aa(t),o="";if(r===Node.ELEMENT_NODE){let s=t.getAttribute("id");if(e&&s)return`//*[@id="${s}"]`;o=t.localName}else if(r===Node.TEXT_NODE||r===Node.CDATA_SECTION_NODE)o="text()";else if(r===Node.COMMENT_NODE)o="comment()";else return"";return o&&n>1?`/${o}[${n}]`:`/${o}`}function re(t,e){let r=e||[];return(typeof r=="string"||r instanceof RegExp)&&(r=[r]),F(t).origin===Lo()?!0:r.some(o=>Ye(t,o))}var ne=class{constructor(e){c(this,"_delegate");this._delegate=e}export(e,r){this._delegate.export(e,r)}forceFlush(){return this._delegate.forceFlush()}shutdown(){return this._delegate.shutdown()}};var oe=class extends Error{constructor(r,n,o){super(r);c(this,"code");c(this,"name","OTLPExporterError");c(this,"data");this.data=o,this.code=n}};function Oa(t){if(Number.isFinite(t)&&t>0)return t;throw new Error(`Configuration: timeoutMillis is invalid, expected number greater than 0 (actual: '${t}')`)}function xo(t){if(t!=null)return async()=>t}function No(t,e,r){return{timeoutMillis:Oa(t.timeoutMillis??e.timeoutMillis??r.timeoutMillis),concurrencyLimit:t.concurrencyLimit??e.concurrencyLimit??r.concurrencyLimit,compression:t.compression??e.compression??r.compression}}function Po(){return{timeoutMillis:1e4,concurrencyLimit:30,compression:"none"}}var Yr=class{constructor(e){c(this,"_concurrencyLimit");c(this,"_sendingPromises",[]);this._concurrencyLimit=e}pushPromise(e){if(this.hasReachedLimit())throw new Error("Concurrency Limit reached");this._sendingPromises.push(e);let r=()=>{let n=this._sendingPromises.indexOf(e);this._sendingPromises.splice(n,1)};e.then(r,r)}hasReachedLimit(){return this._sendingPromises.length>=this._concurrencyLimit}async awaitAll(){await Promise.all(this._sendingPromises)}};function Co(t){return new Yr(t.concurrencyLimit)}function La(t){return Object.prototype.hasOwnProperty.call(t,"partialSuccess")}function Mo(){return{handleResponse(t){t==null||!La(t)||t.partialSuccess==null||Object.keys(t.partialSuccess).length===0||T.warn("Received Partial Success response:",JSON.stringify(t.partialSuccess))}}}var jr=class{constructor(e,r,n,o,s){c(this,"_transport");c(this,"_serializer");c(this,"_responseHandler");c(this,"_promiseQueue");c(this,"_timeout");c(this,"_diagLogger");this._transport=e,this._serializer=r,this._responseHandler=n,this._promiseQueue=o,this._timeout=s,this._diagLogger=T.createComponentLogger({namespace:"OTLPExportDelegate"})}export(e,r){if(this._diagLogger.debug("items to be sent",e),this._promiseQueue.hasReachedLimit()){r({code:b.FAILED,error:new Error("Concurrent export limit reached")});return}let n=this._serializer.serializeRequest(e);if(n==null){r({code:b.FAILED,error:new Error("Nothing to send")});return}this._promiseQueue.pushPromise(this._transport.send(n,this._timeout).then(o=>{if(o.status==="success"){if(o.data!=null)try{this._responseHandler.handleResponse(this._serializer.deserializeResponse(o.data))}catch(s){this._diagLogger.warn("Export succeeded but could not deserialize response - is the response specification compliant?",s,o.data)}r({code:b.SUCCESS});return}else if(o.status==="failure"&&o.error){r({code:b.FAILED,error:o.error});return}else o.status==="retryable"?r({code:b.FAILED,error:new oe("Export failed with retryable status")}):r({code:b.FAILED,error:new oe("Export failed with unknown error")})},o=>r({code:b.FAILED,error:o})))}forceFlush(){return this._promiseQueue.awaitAll()}async shutdown(){this._diagLogger.debug("shutdown started"),await this.forceFlush(),this._transport.shutdown()}};function yo(t,e){return new jr(t.transport,t.serializer,Mo(),t.promiseHandler,e.timeout)}function rr(t,e,r){return yo({transport:r,serializer:e,promiseHandler:Co(t)},{timeout:t.timeoutMillis})}function Io(t){return t>=48&&t<=57?t-48:t>=97&&t<=102?t-87:t-55}function nr(t){let e=new Uint8Array(t.length/2),r=0;for(let n=0;n<t.length;n+=2){let o=Io(t.charCodeAt(n)),s=Io(t.charCodeAt(n+1));e[r++]=o<<4|s}return e}function vo(t){let e=BigInt(1e9);return BigInt(Math.trunc(t[0]))*e+BigInt(Math.trunc(t[1]))}function xa(t){let e=Number(BigInt.asUintN(32,t)),r=Number(BigInt.asUintN(32,t>>BigInt(32)));return{low:e,high:r}}function Do(t){let e=vo(t);return xa(e)}function Na(t){return vo(t).toString()}var Pa=typeof BigInt<"u"?Na:B;function bo(t){return t}function Uo(t){if(t!==void 0)return nr(t)}var Ca={encodeHrTime:Do,encodeSpanContext:nr,encodeOptionalSpanContext:Uo};function wo(t){if(t===void 0)return Ca;let e=t.useLongBits??!0,r=t.useHex??!1;return{encodeHrTime:e?Do:Pa,encodeSpanContext:r?bo:nr,encodeOptionalSpanContext:r?bo:Uo}}function Vo(t){let e={attributes:se(t.attributes),droppedAttributesCount:0},r=t.schemaUrl;return r&&r!==""&&(e.schemaUrl=r),e}function Go(t){return{name:t.name,version:t.version}}function se(t){return Object.keys(t).map(e=>Ho(e,t[e]))}function Ho(t,e){return{key:t,value:Bo(e)}}function Bo(t){let e=typeof t;return e==="string"?{stringValue:t}:e==="number"?Number.isInteger(t)?{intValue:t}:{doubleValue:t}:e==="boolean"?{boolValue:t}:t instanceof Uint8Array?{bytesValue:t}:Array.isArray(t)?{arrayValue:{values:t.map(Bo)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(([r,n])=>Ho(r,n))}}:{}}var Ma=256,ya=512;function Fo(t,e){let r=t&255|Ma;return e&&(r|=ya),r}function Ia(t,e){let r=t.spanContext(),n=t.status,o=t.parentSpanContext?.spanId?e.encodeSpanContext(t.parentSpanContext?.spanId):void 0;return{traceId:e.encodeSpanContext(r.traceId),spanId:e.encodeSpanContext(r.spanId),parentSpanId:o,traceState:r.traceState?.serialize(),name:t.name,kind:t.kind==null?0:t.kind+1,startTimeUnixNano:e.encodeHrTime(t.startTime),endTimeUnixNano:e.encodeHrTime(t.endTime),attributes:se(t.attributes),droppedAttributesCount:t.droppedAttributesCount,events:t.events.map(s=>va(s,e)),droppedEventsCount:t.droppedEventsCount,status:{code:n.code,message:n.message},links:t.links.map(s=>ba(s,e)),droppedLinksCount:t.droppedLinksCount,flags:Fo(r.traceFlags,t.parentSpanContext?.isRemote)}}function ba(t,e){return{attributes:t.attributes?se(t.attributes):[],spanId:e.encodeSpanContext(t.context.spanId),traceId:e.encodeSpanContext(t.context.traceId),traceState:t.context.traceState?.serialize(),droppedAttributesCount:t.droppedAttributesCount||0,flags:Fo(t.context.traceFlags,t.context.isRemote)}}function va(t,e){return{attributes:t.attributes?se(t.attributes):[],name:t.name,timeUnixNano:e.encodeHrTime(t.time),droppedAttributesCount:t.droppedAttributesCount||0}}function ko(t,e){let r=wo(e);return{resourceSpans:Ua(t,r)}}function Da(t){let e=new Map;for(let r of t){let n=e.get(r.resource);n||(n=new Map,e.set(r.resource,n));let o=`${r.instrumentationScope.name}@${r.instrumentationScope.version||""}:${r.instrumentationScope.schemaUrl||""}`,s=n.get(o);s||(s=[],n.set(o,s)),s.push(r)}return e}function Ua(t,e){let r=Da(t),n=[],o=r.entries(),s=o.next();for(;!s.done;){let[i,a]=s.value,p=[],u=a.values(),_=u.next();for(;!_.done;){let R=_.value;if(R.length>0){let O=R.map(L=>Ia(L,e));p.push({scope:Go(R[0].instrumentationScope),spans:O,schemaUrl:R[0].instrumentationScope.schemaUrl})}_=u.next()}let f=Vo(i),h={resource:f,scopeSpans:p,schemaUrl:f.schemaUrl};n.push(h),s=o.next()}return n}var or={serializeRequest:t=>{let e=ko(t,{useHex:!0,useLongBits:!1});return new TextEncoder().encode(JSON.stringify(e))},deserializeResponse:t=>{if(t.length===0)return{};let e=new TextDecoder;return JSON.parse(e.decode(t))}};function wa(){return Math.random()*(2*.2)-.2}var Wr=class{constructor(e){c(this,"_transport");this._transport=e}retry(e,r,n){return new Promise((o,s)=>{setTimeout(()=>{this._transport.send(e,r).then(o,s)},n)})}async send(e,r){let n=Date.now()+r,o=await this._transport.send(e,r),s=5,i=1e3;for(;o.status==="retryable"&&s>0;){s--;let a=Math.max(Math.min(i,5e3)+wa(),0);i=i*1.5;let p=o.retryInMillis??a,u=n-Date.now();if(p>u)return o;o=await this.retry(e,u,p)}return o}shutdown(){return this._transport.shutdown()}};function sr(t){return new Wr(t.transport)}function ir(t){return[429,502,503,504].includes(t)}function ar(t){if(t==null)return;let e=Number.parseInt(t,10);if(Number.isInteger(e))return e>0?e*1e3:-1;let r=new Date(t).getTime()-Date.now();return r>=0?r:0}var zr=class{constructor(e){c(this,"_parameters");this._parameters=e}async send(e,r){let n=await this._parameters.headers();return await new Promise(s=>{let i=new XMLHttpRequest;i.timeout=r,i.open("POST",this._parameters.url),Object.entries(n).forEach(([a,p])=>{i.setRequestHeader(a,p)}),i.ontimeout=a=>{s({status:"failure",error:new Error("XHR request timed out")})},i.onreadystatechange=()=>{i.status>=200&&i.status<=299?(T.debug("XHR success"),s({status:"success"})):i.status&&ir(i.status)?s({status:"retryable",retryInMillis:ar(i.getResponseHeader("Retry-After"))}):i.status!==0&&s({status:"failure",error:new Error("XHR request failed with non-retryable status")})},i.onabort=()=>{s({status:"failure",error:new Error("XHR request aborted")})},i.onerror=()=>{s({status:"failure",error:new Error("XHR request errored")})},i.send(e)})}shutdown(){}};function Ko(t){return new zr(t)}var Xr=class{constructor(e){c(this,"_params");this._params=e}async send(e){let r=(await this._params.headers())["Content-Type"];return new Promise(n=>{navigator.sendBeacon(this._params.url,new Blob([e],{type:r}))?(T.debug("SendBeacon success"),n({status:"success"})):n({status:"failure",error:new Error("SendBeacon failed")})})}shutdown(){}};function Yo(t){return new Xr(t)}var $r=class{constructor(e){c(this,"_parameters");this._parameters=e}async send(e,r){let n=new AbortController,o=setTimeout(()=>n.abort(),r);try{let s=!!globalThis.location,i=new URL(this._parameters.url),a=await fetch(i.href,{method:"POST",headers:await this._parameters.headers(),body:e,signal:n.signal,keepalive:s,mode:s?globalThis.location?.origin===i.origin?"same-origin":"cors":"no-cors"});if(a.status>=200&&a.status<=299)return T.debug("response success"),{status:"success"};if(ir(a.status)){let p=a.headers.get("Retry-After");return{status:"retryable",retryInMillis:ar(p)}}return{status:"failure",error:new Error("Fetch request failed with non-retryable status")}}catch(s){return s?.name==="AbortError"?{status:"failure",error:new Error("Fetch request timed out",{cause:s})}:{status:"failure",error:new Error("Fetch request errored",{cause:s})}}finally{clearTimeout(o)}}shutdown(){}};function jo(t){return new $r(t)}function Wo(t,e){return rr(t,e,sr({transport:Ko(t)}))}function zo(t,e){return rr(t,e,sr({transport:jo(t)}))}function Xo(t,e){return rr(t,e,sr({transport:Yo({url:t.url,headers:t.headers})}))}function $o(t){let e={};return Object.entries(t??{}).forEach(([r,n])=>{typeof n<"u"?e[r]=String(n):T.warn(`Header "${r}" has invalid value (${n}) and will be ignored`)}),e}function Va(t,e,r){return async()=>{let n={...await r()},o={};return e!=null&&Object.assign(o,await e()),t!=null&&Object.assign(o,$o(await t())),Object.assign(o,n)}}function Ga(t){if(t!=null)try{let e=globalThis.location?.href;return new URL(t,e).href}catch{throw new Error(`Configuration: Could not parse user-provided export URL: '${t}'`)}}function qo(t,e,r){return{...No(t,e,r),headers:Va(t.headers,e.headers,r.headers),url:Ga(t.url)??e.url??r.url}}function Qo(t,e){return{...Po(),headers:async()=>t,url:"http://localhost:4318/"+e}}function Jo(t){return typeof t.headers=="function"?t.headers:xo(t.headers)}function Zo(t,e,r){return qo({url:t.url,timeoutMillis:t.timeoutMillis,headers:Jo(t),concurrencyLimit:t.concurrencyLimit},{},Qo(r,e))}function qr(t,e,r,n){let o=Ha(t.headers),s=Zo(t,r,n);return o(s,e)}function Ha(t){return!t&&typeof navigator.sendBeacon=="function"?Xo:typeof globalThis.fetch<"u"?zo:Wo}var Ct=class extends ne{constructor(e={}){super(qr(e,or,"v1/traces",{"Content-Type":"application/json"}))}};var ie=class{emit(e){}},ts=new ie;var Qr=class{getLogger(e,r,n){return new ie}},cr=new Qr;var pr=class{constructor(e,r,n,o){this._provider=e,this.name=r,this.version=n,this.options=o}emit(e){this._getLogger().emit(e)}_getLogger(){if(this._delegate)return this._delegate;let e=this._provider._getDelegateLogger(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):ts}};var ae=class{getLogger(e,r,n){var o;return(o=this._getDelegateLogger(e,r,n))!==null&&o!==void 0?o:new pr(this,e,r,n)}_getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:cr}_setDelegate(e){this._delegate=e}_getDelegateLogger(e,r,n){var o;return(o=this._delegate)===null||o===void 0?void 0:o.getLogger(e,r,n)}};var Jr=typeof globalThis=="object"?globalThis:typeof self=="object"?self:typeof window=="object"?window:typeof global=="object"?global:{};var ce=Symbol.for("io.opentelemetry.js.api.logs"),Mt=Jr;function es(t,e,r){return n=>n===t?e:r}var Zr=1;var ur=class t{constructor(){this._proxyLoggerProvider=new ae}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalLoggerProvider(e){return Mt[ce]?this.getLoggerProvider():(Mt[ce]=es(Zr,e,cr),this._proxyLoggerProvider._setDelegate(e),e)}getLoggerProvider(){var e,r;return(r=(e=Mt[ce])===null||e===void 0?void 0:e.call(Mt,Zr))!==null&&r!==void 0?r:this._proxyLoggerProvider}getLogger(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)}disable(){delete Mt[ce],this._proxyLoggerProvider=new ae}};var _r=ur.getInstance();function rs(t,e,r,n){for(let o=0,s=t.length;o<s;o++){let i=t[o];e&&i.setTracerProvider(e),r&&i.setMeterProvider(r),n&&i.setLoggerProvider&&i.setLoggerProvider(n),i.getConfig().enabled||i.enable()}}function ns(t){t.forEach(e=>e.disable())}function tn(t){let e=t.tracerProvider||A.getTracerProvider(),r=t.meterProvider||Vt.getMeterProvider(),n=t.loggerProvider||_r.getLoggerProvider(),o=t.instrumentations?.flat()??[];return rs(o,e,r,n),()=>{ns(o)}}var D=console.error.bind(console);function pe(t,e,r){let n=!!t[e]&&Object.prototype.propertyIsEnumerable.call(t,e);Object.defineProperty(t,e,{configurable:!0,enumerable:n,writable:!0,value:r})}var Er=(t,e,r)=>{if(!t||!t[e]){D("no original function "+String(e)+" to wrap");return}if(!r){D("no wrapper function"),D(new Error().stack);return}let n=t[e];if(typeof n!="function"||typeof r!="function"){D("original object and wrapper must be functions");return}let o=r(n,e);return pe(o,"__original",n),pe(o,"__unwrap",()=>{t[e]===o&&pe(t,e,n)}),pe(o,"__wrapped",!0),pe(t,e,o),o},en=(t,e,r)=>{if(t)Array.isArray(t)||(t=[t]);else{D("must provide one or more modules to patch"),D(new Error().stack);return}if(!(e&&Array.isArray(e))){D("must provide one or more functions to wrap on modules");return}t.forEach(n=>{e.forEach(o=>{Er(n,o,r)})})},Tr=(t,e)=>{if(!t||!t[e]){D("no function to unwrap."),D(new Error().stack);return}let r=t[e];if(!r.__unwrap)D("no original to unwrap to -- has "+String(e)+" already been unwrapped?");else{r.__unwrap();return}},rn=(t,e)=>{if(t)Array.isArray(t)||(t=[t]);else{D("must provide one or more modules to patch"),D(new Error().stack);return}if(!(e&&Array.isArray(e))){D("must provide one or more functions to unwrap on modules");return}t.forEach(r=>{e.forEach(n=>{Tr(r,n)})})};function ue(t){t&&t.logger&&(typeof t.logger!="function"?D("new logger isn't a function, not replacing"):D=t.logger)}ue.wrap=Er;ue.massWrap=en;ue.unwrap=Tr;ue.massUnwrap=rn;var lr=class{constructor(e,r,n){c(this,"instrumentationName");c(this,"instrumentationVersion");c(this,"_config",{});c(this,"_tracer");c(this,"_meter");c(this,"_logger");c(this,"_diag");c(this,"_wrap",Er);c(this,"_unwrap",Tr);c(this,"_massWrap",en);c(this,"_massUnwrap",rn);this.instrumentationName=e,this.instrumentationVersion=r,this.setConfig(n),this._diag=T.createComponentLogger({namespace:e}),this._tracer=A.getTracer(e,r),this._meter=Vt.getMeter(e,r),this._logger=_r.getLogger(e,r),this._updateMetricInstruments()}get meter(){return this._meter}setMeterProvider(e){this._meter=e.getMeter(this.instrumentationName,this.instrumentationVersion),this._updateMetricInstruments()}get logger(){return this._logger}setLoggerProvider(e){this._logger=e.getLogger(this.instrumentationName,this.instrumentationVersion)}getModuleDefinitions(){let e=this.init()??[];return Array.isArray(e)?e:[e]}_updateMetricInstruments(){}getConfig(){return this._config}setConfig(e){this._config={enabled:!0,...e}}setTracerProvider(e){this._tracer=e.getTracer(this.instrumentationName,this.instrumentationVersion)}get tracer(){return this._tracer}_runSpanCustomizationHook(e,r,n,o){if(e)try{e(n,o)}catch(s){this._diag.error("Error running span customization hook due to exception in handler",{triggerName:r},s)}}};var k=class extends lr{constructor(e,r,n){super(e,r,n),this._config.enabled&&this.enable()}};function rt(t,e,r){let n,o;try{o=t()}catch(s){n=s}finally{if(e(n,o),n&&!r)throw n;return o}}function x(t){return typeof t=="function"&&typeof t.__original=="function"&&typeof t.__unwrap=="function"&&t.__wrapped===!0}var g;(function(t){t[t.STABLE=1]="STABLE",t[t.OLD=2]="OLD",t[t.DUPLICATE=3]="DUPLICATE"})(g||(g={}));function St(t,e){let r=g.OLD,n=e?.split(",").map(o=>o.trim()).filter(o=>o!=="");for(let o of n??[])if(o.toLowerCase()===t+"/dup"){r=g.DUPLICATE;break}else o.toLowerCase()===t&&(r=g.STABLE);return r}var mt;(function(t){t.DOCUMENT_LOAD="documentLoad",t.DOCUMENT_FETCH="documentFetch",t.RESOURCE_FETCH="resourceFetch"})(mt||(mt={}));var os="0.54.0",ss="@opentelemetry/instrumentation-document-load";var fr="http.url",is="http.user_agent";var _e;(function(t){t.FIRST_PAINT="firstPaint",t.FIRST_CONTENTFUL_PAINT="firstContentfulPaint"})(_e||(_e={}));var cs=()=>{let t={},e=M.getEntriesByType?.("navigation")[0];if(e)Object.values(d).forEach(n=>{if(et(e,n)){let o=e[n];typeof o=="number"&&(t[n]=o)}});else{let n=M.timing;n&&Object.values(d).forEach(s=>{if(et(n,s)){let i=n[s];typeof i=="number"&&(t[s]=i)}})}return t},as={"first-paint":_e.FIRST_PAINT,"first-contentful-paint":_e.FIRST_CONTENTFUL_PAINT},ps=t=>{let e=M.getEntriesByType?.("paint");e&&e.forEach(({name:r,startTime:n})=>{et(as,r)&&t.addEvent(as[r],n)})};var Ee=class extends k{constructor(r={}){super(ss,os,r);c(this,"component","document-load");c(this,"version","1");c(this,"moduleName",this.component);c(this,"_semconvStability");this._semconvStability=St("http",r?.semconvStabilityOptIn)}init(){}_onDocumentLoaded(){window.setTimeout(()=>{this._collectPerformance()})}_addResourcesSpans(r){let n=M.getEntriesByType?.("resource");n&&n.forEach(o=>{this._initResourceSpan(o,r)})}_collectPerformance(){let r=Array.from(document.getElementsByTagName("meta")).find(s=>s.getAttribute("name")===Lt),n=cs(),o=r&&r.content||"";S.with(C.extract(K,{traceparent:o}),()=>{let s=this._startSpan(mt.DOCUMENT_LOAD,d.FETCH_START,n);s&&(S.with(A.setSpan(S.active(),s),()=>{let i=this._startSpan(mt.DOCUMENT_FETCH,d.FETCH_START,n);i&&(this._semconvStability&g.OLD&&i.setAttribute(fr,location.href),this._semconvStability&g.STABLE&&i.setAttribute(it,location.href),S.with(A.setSpan(S.active(),i),()=>{let a=!(this._semconvStability&g.OLD);$(i,n,this.getConfig().ignoreNetworkEvents,void 0,a),this._addCustomAttributesOnSpan(i,this.getConfig().applyCustomAttributesOnSpan?.documentFetch),this._endSpan(i,d.RESPONSE_END,n)}))}),this._semconvStability&g.OLD&&(s.setAttribute(fr,location.href),s.setAttribute(is,navigator.userAgent)),this._semconvStability&g.STABLE&&(s.setAttribute(it,location.href),s.setAttribute(Qn,navigator.userAgent)),this._addResourcesSpans(s),this.getConfig().ignoreNetworkEvents||(P(s,d.FETCH_START,n),P(s,d.UNLOAD_EVENT_START,n),P(s,d.UNLOAD_EVENT_END,n),P(s,d.DOM_INTERACTIVE,n),P(s,d.DOM_CONTENT_LOADED_EVENT_START,n),P(s,d.DOM_CONTENT_LOADED_EVENT_END,n),P(s,d.DOM_COMPLETE,n),P(s,d.LOAD_EVENT_START,n),P(s,d.LOAD_EVENT_END,n)),this.getConfig().ignorePerformancePaintEvents||ps(s),this._addCustomAttributesOnSpan(s,this.getConfig().applyCustomAttributesOnSpan?.documentLoad),this._endSpan(s,d.LOAD_EVENT_END,n))})}_endSpan(r,n,o){r&&(et(o,n)?r.end(o[n]):r.end())}_initResourceSpan(r,n){let o=this._startSpan(mt.RESOURCE_FETCH,d.FETCH_START,r,n);if(o){this._semconvStability&g.OLD&&o.setAttribute(fr,r.name),this._semconvStability&g.STABLE&&o.setAttribute(it,r.name);let s=!(this._semconvStability&g.OLD);$(o,r,this.getConfig().ignoreNetworkEvents,void 0,s),this._addCustomAttributesOnResourceSpan(o,r,this.getConfig().applyCustomAttributesOnSpan?.resourceFetch),this._endSpan(o,d.RESPONSE_END,r)}}_startSpan(r,n,o,s){if(et(o,n)&&typeof o[n]=="number")return this.tracer.startSpan(r,{startTime:o[n]},s?A.setSpan(S.active(),s):void 0)}_waitForPageLoad(){window.document.readyState==="complete"?this._onDocumentLoaded():(this._onDocumentLoaded=this._onDocumentLoaded.bind(this),window.addEventListener("load",this._onDocumentLoaded))}_addCustomAttributesOnSpan(r,n){n&&rt(()=>n(r),o=>{o&&this._diag.error("addCustomAttributesOnSpan",o)},!0)}_addCustomAttributesOnResourceSpan(r,n,o){o&&rt(()=>o(r,n),s=>{s&&this._diag.error("addCustomAttributesOnResourceSpan",s)},!0)}enable(){window.removeEventListener("load",this._onDocumentLoaded),this._waitForPageLoad()}disable(){window.removeEventListener("load",this._onDocumentLoaded)}};var Te;(function(t){t.COMPONENT="component",t.HTTP_STATUS_TEXT="http.status_text"})(Te||(Te={}));var us="http.host",_s="http.method",Es="http.request.body.size",Ts="http.request_content_length_uncompressed";var ls="http.scheme",fs="http.status_code",ds="http.url",Ss="http.user_agent";var ms=T.createComponentLogger({namespace:"@opentelemetry/opentelemetry-instrumentation-fetch/utils"});function hs(...t){if(t[0]instanceof URL||typeof t[0]=="string"){let e=t[1];if(!e?.body)return Promise.resolve();if(e.body instanceof ReadableStream){let{body:r,length:n}=Fa(e.body);return e.body=r,n}else return Promise.resolve(Ka(e.body))}else{let e=t[0];return e?.body?e.clone().text().then(r=>nn(r)):Promise.resolve()}}function Fa(t){if(!t.pipeThrough)return ms.warn("Platform has ReadableStream but not pipeThrough!"),{body:t,length:Promise.resolve(void 0)};let e=0,r,n=new Promise(s=>{r=s}),o=new TransformStream({start(){},async transform(s,i){let a=await s;e+=a.byteLength,i.enqueue(s)},flush(){r(e)}});return{body:t.pipeThrough(o),length:n}}function ka(t){return typeof Document<"u"&&t instanceof Document}function Ka(t){if(ka(t))return new XMLSerializer().serializeToString(document).length;if(typeof t=="string")return nn(t);if(t instanceof Blob)return t.size;if(t instanceof FormData)return ja(t);if(t instanceof URLSearchParams)return nn(t.toString());if(t.byteLength!==void 0)return t.byteLength;ms.warn("unknown body type")}var Ya=new TextEncoder;function nn(t){return Ya.encode(t).byteLength}function ja(t){let e=0;for(let[r,n]of t.entries())e+=r.length,n instanceof Blob?e+=n.size:e+=n.length;return e}function As(t){let e=za(),r=t.toUpperCase();return r in e?r:"_OTHER"}var Wa={CONNECT:!0,DELETE:!0,GET:!0,HEAD:!0,OPTIONS:!0,PATCH:!0,POST:!0,PUT:!0,TRACE:!0},le;function za(){if(le===void 0){let t=void 0;t&&t.length>0?(le={},t.forEach(e=>{le[e]=!0})):le=Wa}return le}var Xa={"https:":"443","http:":"80"};function gs(t){let e=Number(t.port||Xa[t.protocol]);if(e&&!isNaN(e))return e}var on="0.208.0";var $a=300,Rs=typeof process=="object"&&process.release?.name==="node",fe=class extends k{constructor(r={}){super("@opentelemetry/instrumentation-fetch",on,r);c(this,"component","fetch");c(this,"version",on);c(this,"moduleName",this.component);c(this,"_usedResources",new WeakSet);c(this,"_tasksCount",0);c(this,"_semconvStability");this._semconvStability=St("http",r?.semconvStabilityOptIn)}init(){}_addChildSpan(r,n){let o=this.tracer.startSpan("CORS Preflight",{startTime:n[d.FETCH_START]},A.setSpan(S.active(),r)),s=!(this._semconvStability&g.OLD);$(o,n,this.getConfig().ignoreNetworkEvents,void 0,s),o.end(n[d.RESPONSE_END])}_addFinalSpanAttributes(r,n){let o=F(n.url);if(this._semconvStability&g.OLD&&(r.setAttribute(fs,n.status),n.statusText!=null&&r.setAttribute(Te.HTTP_STATUS_TEXT,n.statusText),r.setAttribute(us,o.host),r.setAttribute(ls,o.protocol.replace(":","")),typeof navigator<"u"&&r.setAttribute(Ss,navigator.userAgent)),this._semconvStability&g.STABLE){r.setAttribute(ve,n.status),r.setAttribute(De,o.hostname);let s=gs(o);s&&r.setAttribute(Ue,s)}}_addHeaders(r,n){if(!re(n,this.getConfig().propagateTraceHeaderCorsUrls)){let o={};C.inject(S.active(),o),Object.keys(o).length>0&&this._diag.debug("headers inject skipped due to CORS policy");return}if(r instanceof Request)C.inject(S.active(),r.headers,{set:(o,s,i)=>o.set(s,typeof i=="string"?i:String(i))});else if(r.headers instanceof Headers)C.inject(S.active(),r.headers,{set:(o,s,i)=>o.set(s,typeof i=="string"?i:String(i))});else if(r.headers instanceof Map)C.inject(S.active(),r.headers,{set:(o,s,i)=>o.set(s,typeof i=="string"?i:String(i))});else{let o={};C.inject(S.active(),o),r.headers=Object.assign({},o,r.headers||{})}}_clearResources(){this._tasksCount===0&&this.getConfig().clearTimingResources&&(performance.clearResourceTimings(),this._usedResources=new WeakSet)}_createSpan(r,n={}){if($t(r,this.getConfig().ignoreUrls)){this._diag.debug("ignoring span as url matches ignored url");return}let o="",s={};if(this._semconvStability&g.OLD){let i=(n.method||"GET").toUpperCase();o=`HTTP ${i}`,s[Te.COMPONENT]=this.moduleName,s[_s]=i,s[ds]=r}if(this._semconvStability&g.STABLE){let i=n.method,a=As(n.method||"GET");o||(o=a),s[Ie]=a,a!==i&&(s[be]=i),s[it]=r}return this.tracer.startSpan(o,{kind:Z.CLIENT,attributes:s})}_findResourceAndAddNetworkEvents(r,n,o){let s=n.entries;if(!s.length){if(!performance.getEntriesByType)return;s=performance.getEntriesByType("resource")}let i=ee(n.spanUrl,n.startTime,o,s,this._usedResources,"fetch");if(i.mainRequest){let a=i.mainRequest;this._markResourceAsUsed(a);let p=i.corsPreFlightRequest;p&&(this._addChildSpan(r,p),this._markResourceAsUsed(p));let u=!(this._semconvStability&g.OLD);$(r,a,this.getConfig().ignoreNetworkEvents,void 0,u)}}_markResourceAsUsed(r){this._usedResources.add(r)}_endSpan(r,n,o){let s=G(Date.now()),i=H();this._addFinalSpanAttributes(r,o),this._semconvStability&g.STABLE&&o.status>=400&&(r.setStatus({code:W.ERROR}),r.setAttribute(Bt,String(o.status))),setTimeout(()=>{n.observer?.disconnect(),this._findResourceAndAddNetworkEvents(r,n,i),this._tasksCount--,this._clearResources(),r.end(s)},$a)}_patchConstructor(){return r=>{let n=this;return function(...s){let i=this,a=F(s[0]instanceof Request?s[0].url:String(s[0])).href,p=s[0]instanceof Request?s[0]:s[1]||{},u=n._createSpan(a,p);if(!u)return r.apply(this,s);let _=n._prepareSpanData(a);n.getConfig().measureRequestSize&&hs(...s).then(E=>{E&&(n._semconvStability&g.OLD&&u.setAttribute(Ts,E),n._semconvStability&g.STABLE&&u.setAttribute(Es,E))}).catch(E=>{n._diag.warn("getFetchBodyLength",E)});function f(E,l){n._applyAttributesAfterFetch(E,p,l),n._endSpan(E,_,{status:l.status||0,statusText:l.message,url:a})}function h(E,l){n._applyAttributesAfterFetch(E,p,l),l.status>=200&&l.status<400?n._endSpan(E,_,l):n._endSpan(E,_,{status:l.status,statusText:l.statusText,url:a})}function R(E,l){if(!E)return null;let m=E.getReader();return new ReadableStream({async pull(N){try{let{value:U,done:nt}=await m.read();nt?(m.releaseLock(),N.close()):N.enqueue(U)}catch(U){N.error(U),m.cancel(U).catch(nt=>{});try{m.releaseLock()}catch{}}},cancel(N){return l.cancel(N).catch(U=>{}),m.cancel(N)}})}function O(E,l,m){let N=null;try{let nt=m.clone().body;if(nt){let It=nt.getReader(),he=m.status===204||m.status===205||m.status===304?null:R(m.body,It);N=new Response(he,{status:m.status,statusText:m.statusText,headers:m.headers});let un=()=>{It.read().then(({done:mr})=>{mr?h(E,m):un()},mr=>{f(E,mr)})};un()}else h(E,m)}finally{l(N??m)}}function L(E,l,m){try{f(E,m)}finally{l(m)}}return new Promise((E,l)=>S.with(A.setSpan(S.active(),u),()=>(n._addHeaders(p,a),n._callRequestHook(u,p),n._tasksCount++,r.apply(i,p instanceof Request?[p]:[a,p]).then(O.bind(i,u,E),L.bind(i,u,l)))))}}}_applyAttributesAfterFetch(r,n,o){let s=this.getConfig().applyCustomAttributesOnSpan;s&&rt(()=>s(r,n,o),i=>{i&&this._diag.error("applyCustomAttributesOnSpan",i)},!0)}_callRequestHook(r,n){let o=this.getConfig().requestHook;o&&rt(()=>o(r,n),s=>{s&&this._diag.error("requestHook",s)},!0)}_prepareSpanData(r){let n=H(),o=[];if(typeof PerformanceObserver!="function")return{entries:o,startTime:n,spanUrl:r};let s=new PerformanceObserver(i=>{i.getEntries().forEach(p=>{p.initiatorType==="fetch"&&p.name===r&&o.push(p)})});return s.observe({entryTypes:["resource"]}),{entries:o,observer:s,startTime:n,spanUrl:r}}enable(){if(Rs){this._diag.warn("this instrumentation is intended for web usage only, it does not instrument Node.js's fetch()");return}x(fetch)&&(this._unwrap(Rt,"fetch"),this._diag.debug("removing previous patch for constructor")),this._wrap(Rt,"fetch",this._patchConstructor())}disable(){Rs||(this._unwrap(Rt,"fetch"),this._usedResources=new WeakSet)}};var ht;(function(t){t.EVENT_TYPE="event_type",t.TARGET_ELEMENT="target_element",t.TARGET_XPATH="target_xpath",t.HTTP_URL="http.url"})(ht||(ht={}));var sn="0.53.0",Os="@opentelemetry/instrumentation-user-interaction";var qa="OT_ZONE_CONTEXT",Qa="Navigation:",Ja=["click"];function Za(){return!1}var de=class extends k{constructor(r={}){super(Os,sn,r);c(this,"version",sn);c(this,"moduleName","user-interaction");c(this,"_spansData",new WeakMap);c(this,"_wrappedListeners",new WeakMap);c(this,"_eventsSpanMap",new WeakMap);c(this,"_eventNames");c(this,"_shouldPreventSpanCreation");this._eventNames=new Set(r?.eventNames??Ja),this._shouldPreventSpanCreation=typeof r?.shouldPreventSpanCreation=="function"?r.shouldPreventSpanCreation:Za}init(){}_checkForTimeout(r,n){let o=this._spansData.get(n);o&&(r.source==="setTimeout"?o.hrTimeLastTimeout=H():r.source!=="Promise.then"&&r.source!=="setTimeout"&&(o.hrTimeLastTimeout=void 0))}_allowEventName(r){return this._eventNames.has(r)}_createSpan(r,n,o){if(!(r instanceof HTMLElement)||!r.getAttribute||r.hasAttribute("disabled")||!this._allowEventName(n))return;let s=er(r,!0);try{let i=this.tracer.startSpan(n,{attributes:{[ht.EVENT_TYPE]:n,[ht.TARGET_ELEMENT]:r.tagName,[ht.TARGET_XPATH]:s,[ht.HTTP_URL]:window.location.href}},o?A.setSpan(S.active(),o):void 0);return this._shouldPreventSpanCreation(n,r,i)===!0?void 0:(this._spansData.set(i,{taskCount:0}),i)}catch(i){this._diag.error("failed to start create new user interaction span",i)}}_decrementTask(r){let n=this._spansData.get(r);n&&(n.taskCount--,n.taskCount===0&&this._tryToEndSpan(r,n.hrTimeLastTimeout))}_getCurrentSpan(r){let n=r.get(qa);return n&&A.getSpan(n)}_incrementTask(r){let n=this._spansData.get(r);n&&n.taskCount++}addPatchedListener(r,n,o,s){let i=this._wrappedListeners.get(o);i||(i=new Map,this._wrappedListeners.set(o,i));let a=i.get(n);return a||(a=new Map,i.set(n,a)),a.has(r)?!1:(a.set(r,s),!0)}removePatchedListener(r,n,o){let s=this._wrappedListeners.get(o);if(!s)return;let i=s.get(n);if(!i)return;let a=i.get(r);return a&&(i.delete(r),i.size===0&&(s.delete(n),s.size===0&&this._wrappedListeners.delete(o))),a}_invokeListener(r,n,o){return typeof r=="function"?r.apply(n,o):r.handleEvent(o[0])}_patchAddEventListener(){let r=this;return n=>function(s,i,a){if(!i)return n.call(this,s,i,a);let p=a&&typeof a=="object"&&a.once,u=function(..._){let f,h=_[0],R=h?.target;h&&(f=r._eventsSpanMap.get(h)),p&&r.removePatchedListener(this,s,i);let O=r._createSpan(R,s,f);return O?(h&&r._eventsSpanMap.set(h,O),S.with(A.setSpan(S.active(),O),()=>{let L=r._invokeListener(i,this,_);return O.end(),L})):r._invokeListener(i,this,_)};if(r.addPatchedListener(this,s,i,u))return n.call(this,s,u,a)}}_patchRemoveEventListener(){let r=this;return n=>function(s,i,a){let p=r.removePatchedListener(this,s,i);return p?n.call(this,s,p,a):n.call(this,s,i,a)}}_getPatchableEventTargets(){return window.EventTarget?[EventTarget.prototype]:[Node.prototype,Window.prototype]}_patchHistoryApi(){this._unpatchHistoryApi(),this._wrap(history,"replaceState",this._patchHistoryMethod()),this._wrap(history,"pushState",this._patchHistoryMethod()),this._wrap(history,"back",this._patchHistoryMethod()),this._wrap(history,"forward",this._patchHistoryMethod()),this._wrap(history,"go",this._patchHistoryMethod())}_patchHistoryMethod(){let r=this;return n=>function(...s){let i=`${location.pathname}${location.hash}${location.search}`,a=n.apply(this,s),p=`${location.pathname}${location.hash}${location.search}`;return i!==p&&r._updateInteractionName(p),a}}_unpatchHistoryApi(){x(history.replaceState)&&this._unwrap(history,"replaceState"),x(history.pushState)&&this._unwrap(history,"pushState"),x(history.back)&&this._unwrap(history,"back"),x(history.forward)&&this._unwrap(history,"forward"),x(history.go)&&this._unwrap(history,"go")}_updateInteractionName(r){let n=A.getSpan(S.active());n&&typeof n.updateName=="function"&&n.updateName(`${Qa} ${r}`)}_patchZoneCancelTask(){let r=this;return n=>function(s){let i=Zone.current,a=r._getCurrentSpan(i);return a&&r._shouldCountTask(s,i)&&r._decrementTask(a),n.call(this,s)}}_patchZoneScheduleTask(){let r=this;return n=>function(s){let i=Zone.current,a=r._getCurrentSpan(i);return a&&r._shouldCountTask(s,i)&&(r._incrementTask(a),r._checkForTimeout(s,a)),n.call(this,s)}}_patchZoneRunTask(){let r=this;return n=>function(s,i,a){let u=(Array.isArray(a)&&a[0]instanceof Event?a[0]:void 0)?.target,_,f=this;if(u){if(_=r._createSpan(u,s.eventName),_)return r._incrementTask(_),f.run(()=>{try{return S.with(A.setSpan(S.active(),_),()=>{let h=Zone.current;return s._zone=h,n.call(h,s,i,a)})}finally{r._decrementTask(_)}})}else _=r._getCurrentSpan(f);try{return n.call(f,s,i,a)}finally{_&&r._shouldCountTask(s,f)&&r._decrementTask(_)}}}_shouldCountTask(r,n){if(r._zone&&(n=r._zone),!n||!r.data||r.data.isPeriodic)return!1;let o=this._getCurrentSpan(n);return!o||!this._spansData.get(o)?!1:r.type==="macroTask"||r.type==="microTask"}_tryToEndSpan(r,n){r&&this._spansData.get(r)&&(r.end(n),this._spansData.delete(r))}enable(){let r=this._getZoneWithPrototype();this._diag.debug("applying patch to",this.moduleName,this.version,"zone:",!!r),r?(x(r.prototype.runTask)&&(this._unwrap(r.prototype,"runTask"),this._diag.debug("removing previous patch from method runTask")),x(r.prototype.scheduleTask)&&(this._unwrap(r.prototype,"scheduleTask"),this._diag.debug("removing previous patch from method scheduleTask")),x(r.prototype.cancelTask)&&(this._unwrap(r.prototype,"cancelTask"),this._diag.debug("removing previous patch from method cancelTask")),this._zonePatched=!0,this._wrap(r.prototype,"runTask",this._patchZoneRunTask()),this._wrap(r.prototype,"scheduleTask",this._patchZoneScheduleTask()),this._wrap(r.prototype,"cancelTask",this._patchZoneCancelTask())):(this._zonePatched=!1,this._getPatchableEventTargets().forEach(o=>{x(o.addEventListener)&&(this._unwrap(o,"addEventListener"),this._diag.debug("removing previous patch from method addEventListener")),x(o.removeEventListener)&&(this._unwrap(o,"removeEventListener"),this._diag.debug("removing previous patch from method removeEventListener")),this._wrap(o,"addEventListener",this._patchAddEventListener()),this._wrap(o,"removeEventListener",this._patchRemoveEventListener())})),this._patchHistoryApi()}disable(){let r=this._getZoneWithPrototype();this._diag.debug("removing patch from",this.moduleName,this.version,"zone:",!!r),r&&this._zonePatched?(x(r.prototype.runTask)&&this._unwrap(r.prototype,"runTask"),x(r.prototype.scheduleTask)&&this._unwrap(r.prototype,"scheduleTask"),x(r.prototype.cancelTask)&&this._unwrap(r.prototype,"cancelTask")):this._getPatchableEventTargets().forEach(o=>{x(o.addEventListener)&&this._unwrap(o,"addEventListener"),x(o.removeEventListener)&&this._unwrap(o,"removeEventListener")}),this._unpatchHistoryApi()}_getZoneWithPrototype(){return window.Zone}};var Ls="http.host",xs="http.method",Ns="http.request.body.size",Ps="http.request_content_length_uncompressed";var Cs="http.scheme",Ms="http.status_code",ys="http.url",Is="http.user_agent";var q;(function(t){t.METHOD_OPEN="open",t.METHOD_SEND="send",t.EVENT_ABORT="abort",t.EVENT_ERROR="error",t.EVENT_LOAD="loaded",t.EVENT_TIMEOUT="timeout"})(q||(q={}));var tc=T.createComponentLogger({namespace:"@opentelemetry/opentelemetry-instrumentation-xml-http-request/utils"});function ec(t){return typeof Document<"u"&&t instanceof Document}function vs(t){if(ec(t))return new XMLSerializer().serializeToString(document).length;if(typeof t=="string")return bs(t);if(t instanceof Blob)return t.size;if(t instanceof FormData)return nc(t);if(t instanceof URLSearchParams)return bs(t.toString());if(t.byteLength!==void 0)return t.byteLength;tc.warn("unknown body type")}var rc=new TextEncoder;function bs(t){return rc.encode(t).byteLength}function nc(t){let e=0;for(let[r,n]of t.entries())e+=r.length,n instanceof Blob?e+=n.size:e+=n.length;return e}function Ds(t){let e=sc(),r=t.toUpperCase();return r in e?r:"_OTHER"}var oc={CONNECT:!0,DELETE:!0,GET:!0,HEAD:!0,OPTIONS:!0,PATCH:!0,POST:!0,PUT:!0,TRACE:!0},Se;function sc(){if(Se===void 0){let t=void 0;t&&t.length>0?(Se={},t.forEach(e=>{Se[e]=!0})):Se=oc}return Se}var ic={"https:":"443","http:":"80"};function Us(t){let e=Number(t.port||ic[t.protocol]);if(e&&!isNaN(e))return e}var an="0.208.0";var dr;(function(t){t.HTTP_STATUS_TEXT="http.status_text"})(dr||(dr={}));var ac=300,me=class extends k{constructor(r={}){super("@opentelemetry/instrumentation-xml-http-request",an,r);c(this,"component","xml-http-request");c(this,"version",an);c(this,"moduleName",this.component);c(this,"_tasksCount",0);c(this,"_xhrMem",new WeakMap);c(this,"_usedResources",new WeakSet);c(this,"_semconvStability");this._semconvStability=St("http",r?.semconvStabilityOptIn)}init(){}_addHeaders(r,n){let o=F(n).href;if(!re(o,this.getConfig().propagateTraceHeaderCorsUrls)){let i={};C.inject(S.active(),i),Object.keys(i).length>0&&this._diag.debug("headers inject skipped due to CORS policy");return}let s={};C.inject(S.active(),s),Object.keys(s).forEach(i=>{r.setRequestHeader(i,String(s[i]))})}_addChildSpan(r,n){S.with(A.setSpan(S.active(),r),()=>{let o=this.tracer.startSpan("CORS Preflight",{startTime:n[d.FETCH_START]}),s=!(this._semconvStability&g.OLD);$(o,n,this.getConfig().ignoreNetworkEvents,void 0,s),o.end(n[d.RESPONSE_END])})}_addFinalSpanAttributes(r,n,o){if(this._semconvStability&g.OLD){if(n.status!==void 0&&r.setAttribute(Ms,n.status),n.statusText!==void 0&&r.setAttribute(dr.HTTP_STATUS_TEXT,n.statusText),typeof o=="string"){let s=F(o);r.setAttribute(Ls,s.host),r.setAttribute(Cs,s.protocol.replace(":",""))}r.setAttribute(Is,navigator.userAgent)}this._semconvStability&g.STABLE&&n.status&&r.setAttribute(ve,n.status)}_applyAttributesAfterXHR(r,n){let o=this.getConfig().applyCustomAttributesOnSpan;typeof o=="function"&&rt(()=>o(r,n),s=>{s&&this._diag.error("applyCustomAttributesOnSpan",s)},!0)}_addResourceObserver(r,n){let o=this._xhrMem.get(r);!o||typeof PerformanceObserver!="function"||typeof PerformanceResourceTiming!="function"||(o.createdResources={observer:new PerformanceObserver(s=>{let i=s.getEntries(),a=F(n);i.forEach(p=>{p.initiatorType==="xmlhttprequest"&&p.name===a.href&&o.createdResources&&o.createdResources.entries.push(p)})}),entries:[]},o.createdResources.observer.observe({entryTypes:["resource"]}))}_clearResources(){this._tasksCount===0&&this.getConfig().clearTimingResources&&(M.clearResourceTimings(),this._xhrMem=new WeakMap,this._usedResources=new WeakSet)}_findResourceAndAddNetworkEvents(r,n,o,s,i){if(!o||!s||!i||!r.createdResources)return;let a=r.createdResources.entries;(!a||!a.length)&&(a=M.getEntriesByType("resource"));let p=ee(F(o).href,s,i,a,this._usedResources);if(p.mainRequest){let u=p.mainRequest;this._markResourceAsUsed(u);let _=p.corsPreFlightRequest;_&&(this._addChildSpan(n,_),this._markResourceAsUsed(_));let f=!(this._semconvStability&g.OLD);$(n,u,this.getConfig().ignoreNetworkEvents,void 0,f)}}_cleanPreviousSpanInformation(r){let n=this._xhrMem.get(r);if(n){let o=n.callbackToRemoveEvents;o&&o(),this._xhrMem.delete(r)}}_createSpan(r,n,o){if($t(n,this.getConfig().ignoreUrls)){this._diag.debug("ignoring span as url matches ignored url");return}let s="",i=F(n),a={};if(this._semconvStability&g.OLD&&(s=o.toUpperCase(),a[xs]=o,a[ys]=i.toString()),this._semconvStability&g.STABLE){let u=o,_=Ds(o);s||(s=_),a[Ie]=_,_!==u&&(a[be]=u),a[it]=i.toString(),a[De]=i.hostname;let f=Us(i);f&&(a[Ue]=f)}let p=this.tracer.startSpan(s,{kind:Z.CLIENT,attributes:a});return p.addEvent(q.METHOD_OPEN),this._cleanPreviousSpanInformation(r),this._xhrMem.set(r,{span:p,spanUrl:n}),p}_markResourceAsUsed(r){this._usedResources.add(r)}_patchOpen(){return r=>{let n=this;return function(...s){let i=s[0],a=s[1];return n._createSpan(this,a,i),r.apply(this,s)}}}_patchSend(){let r=this;function n(_,f,h,R){let O=f.callbackToRemoveEvents;typeof O=="function"&&O();let{span:L,spanUrl:E,sendStartTime:l}=f;L&&(r._findResourceAndAddNetworkEvents(f,L,E,l,h),L.addEvent(_,R),r._addFinalSpanAttributes(L,f,E),L.end(R),r._tasksCount--),r._clearResources()}function o(_,f,h,R){let O=r._xhrMem.get(f);if(!O)return;if(O.status=f.status,O.statusText=f.statusText,r._xhrMem.delete(f),O.span){let l=O.span;r._applyAttributesAfterXHR(l,f),r._semconvStability&g.STABLE&&(h?R&&(l.setStatus({code:W.ERROR,message:R}),l.setAttribute(Bt,R)):O.status&&O.status>=400&&(l.setStatus({code:W.ERROR}),l.setAttribute(Bt,String(O.status))))}let L=H(),E=Date.now();setTimeout(()=>{n(_,O,L,E)},ac)}function s(){o(q.EVENT_ERROR,this,!0,"error")}function i(){o(q.EVENT_ABORT,this,!1)}function a(){o(q.EVENT_TIMEOUT,this,!0,"timeout")}function p(){this.status<299?o(q.EVENT_LOAD,this,!1):o(q.EVENT_ERROR,this,!1)}function u(_){_.removeEventListener("abort",i),_.removeEventListener("error",s),_.removeEventListener("load",p),_.removeEventListener("timeout",a);let f=r._xhrMem.get(_);f&&(f.callbackToRemoveEvents=void 0)}return _=>function(...h){let R=r._xhrMem.get(this);if(!R)return _.apply(this,h);let O=R.span,L=R.spanUrl;if(O&&L){if(r.getConfig().measureRequestSize&&h?.[0]){let E=h[0],l=vs(E);l!==void 0&&(r._semconvStability&g.OLD&&O.setAttribute(Ps,l),r._semconvStability&g.STABLE&&O.setAttribute(Ns,l))}S.with(A.setSpan(S.active(),O),()=>{r._tasksCount++,R.sendStartTime=H(),O.addEvent(q.METHOD_SEND),this.addEventListener("abort",i),this.addEventListener("error",s),this.addEventListener("load",p),this.addEventListener("timeout",a),R.callbackToRemoveEvents=()=>{u(this),R.createdResources&&R.createdResources.observer.disconnect()},r._addHeaders(this,L),r._addResourceObserver(this,L)})}return _.apply(this,h)}}enable(){this._diag.debug("applying patch to",this.moduleName,this.version),x(XMLHttpRequest.prototype.open)&&(this._unwrap(XMLHttpRequest.prototype,"open"),this._diag.debug("removing previous patch from method open")),x(XMLHttpRequest.prototype.send)&&(this._unwrap(XMLHttpRequest.prototype,"send"),this._diag.debug("removing previous patch from method send")),this._wrap(XMLHttpRequest.prototype,"open",this._patchOpen()),this._wrap(XMLHttpRequest.prototype,"send",this._patchSend())}disable(){this._diag.debug("removing patch from",this.moduleName,this.version),this._unwrap(XMLHttpRequest.prototype,"open"),this._unwrap(XMLHttpRequest.prototype,"send"),this._tasksCount=0,this._xhrMem=new WeakMap,this._usedResources=new WeakSet}};var ws="v1/traces";function cc(t){let e=t.trim().toLowerCase();return/^[0-9a-f]{32}$/.test(e)&&e!=="00000000000000000000000000000000"}function pn(t){let e=new Uint8Array(t);crypto.getRandomValues(e);let r="";for(let n=0;n<e.length;n++){let o=e[n];r+=o.toString(16).padStart(2,"0")}return r}function yt(t){let e=t.trim().toLowerCase();return cc(e)?e:pn(16)}var cn=class{constructor(e){c(this,"traceId");this.traceId=yt(e)}setTraceId(e){this.traceId=yt(e)}getTraceId(){return this.traceId}generateTraceId(){return this.traceId}generateSpanId(){return pn(8)}};(function(){let e=globalThis;e.__MCP_DEVTOOLS__||(e.__MCP_DEVTOOLS__={});let r=e.__MCP_DEVTOOLS__;if(e.__mcpOtel)return;let n=null,o=!1,s;function i(E){E===!0&&T.setLogger(new Rr,y.DEBUG)}function a(E){let l=[];if(E.exporter.type==="none")return l;if(E.exporter.type==="console"){let m=new Jt,N=new Zt(m);return l.push(N),l}else if(E.exporter.type==="otlp/http"){let m=E.exporter.url.endsWith("/")?`${E.exporter.url}${ws}`:`${E.exporter.url}/${ws}`,N=new Ct({url:m,headers:E.exporter.headers}),U=new Nt(N);return l.push(U),l}throw new Error(`Not supported exporter type: ${E.exporter.type}`)}function p(E){let l=E.trim();if(!l)return[];let m=l.startsWith("/")?l:"/"+l,N=m.endsWith("/")?m:m+"/";return[new RegExp(`^${N.replace(/\//g,"\\/")}`),new RegExp(`${N.replace(/\//g,"\\/")}`)]}function u(E,l,m){let N=m?p(m):[],U=l??{},nt=new fe({ignoreUrls:N}),It=new me({ignoreUrls:N}),Sr=new Ee,he=new de({eventNames:U.userInteractionEvents||["click"]});tn({tracerProvider:E,instrumentations:[nt,It,Sr,he]});try{nt.enable?.()}catch{}try{It.enable?.()}catch{}try{Sr.enable?.()}catch{}try{he.enable?.()}catch{}}function _(E){try{if(e.__MCP_DEVTOOLS__||(e.__MCP_DEVTOOLS__={}),r.otelInitialized===!0){n&&n.setTraceId(E.traceId),e.__MCP_TRACE_ID__=yt(E.traceId),o=!0,s=void 0;return}i(E.debug);let l=yt(E.traceId);n=new cn(l);let m=We({[Wn]:E.serviceName,...E.serviceVersion?{[zn]:E.serviceVersion}:{}}),N=a(E),U=new te({resource:m,idGenerator:n,spanProcessors:N});U.register(),u(U,E.instrumentation??{},E.exporter.url),A.getTracer(E.serviceName),r.otelInitialized=!0,r.otelInitError=void 0,e.__MCP_TRACE_ID__=l,o=!0,s=void 0}catch(l){let m=String(l?.message??l);r.otelInitialized=!1,r.otelInitError=m,o=!1,s=m}}function f(E){let l=yt(E);n&&n.setTraceId(l),e.__MCP_TRACE_ID__=l}function h(){return n?n.getTraceId():typeof e.__MCP_TRACE_ID__=="string"&&e.__MCP_TRACE_ID__?String(e.__MCP_TRACE_ID__).toLowerCase():yt(pn(16))}function R(){return r.otelInitialized===!0&&o===!0}function O(){let E=r.otelInitError??s;if(typeof E=="string"&&E.trim())return E}let L={init:E=>{_(E)},setTraceId:E=>{f(E)},getTraceId:()=>h(),isInitialized:()=>R(),getInitError:()=>O()};e.__mcpOtel=L})();return ks(pc);})();
|
|
2
|
-
//# sourceMappingURL=otel-initializer.bundle.js.map
|