import "@js-temporal/polyfill";
import "urlpattern-polyfill";
globalThis.addEventListener = () => {};
import { BasicTracerProvider, SimpleSpanProcessor } from "@opentelemetry/sdk-trace-base";
import { ExportResultCode } from "@opentelemetry/core";
//#region src/testing/otel.ts
/**
* A test spy for OpenTelemetry spans that captures all spans and events.
*/
var TestSpanExporter = class {
	spans = [];
	export(spans, resultCallback) {
		this.spans.push(...spans);
		resultCallback({ code: ExportResultCode.SUCCESS });
	}
	async forceFlush() {}
	shutdown() {
		this.spans = [];
		return Promise.resolve();
	}
	/**
	* Gets all spans with the given name.
	*/
	getSpans(name) {
		return this.spans.filter((span) => span.name === name);
	}
	/**
	* Gets the first span with the given name.
	*/
	getSpan(name) {
		return this.spans.find((span) => span.name === name);
	}
	/**
	* Gets all events from spans with the given name.
	*/
	getEvents(spanName, eventName) {
		const events = this.getSpans(spanName).flatMap((span) => span.events);
		if (eventName) return events.filter((event) => event.name === eventName);
		return events;
	}
	/**
	* Clears all captured spans.
	*/
	clear() {
		this.spans = [];
	}
};
/**
* Creates a test tracer provider with a test exporter.
* @returns A tuple of [tracerProvider, testExporter]
*/
function createTestTracerProvider() {
	const exporter = new TestSpanExporter();
	const provider = new BasicTracerProvider();
	provider.addSpanProcessor(new SimpleSpanProcessor(exporter));
	return [provider, exporter];
}
//#endregion
export { createTestTracerProvider as t };
