import { LogManager } from "../api-logs/manager/types.js";
import "../api-logs/index.js";
import { PageManager } from "../api-page/manager/types.js";
import "../api-sessions/index.js";
import { TraceManager } from "../api-traces/manager/types.js";
import "../api-traces/index.js";
import { UserManager } from "../api-users/manager/types.js";
import { AttributeScrubber, VisibilityStateDocument } from "../common/types.js";
import { NamespacedStorage } from "../utils/NamespacedStorage/NamespacedStorage.js";
import { PerformanceManager } from "../utils/PerformanceManager/types.js";
import "../utils/index.js";
import { LimitManagerInternal } from "../managers/EmbraceLimitManager/types.js";
import "../managers/index.js";
import { DocumentLoadInstrumentationConfig } from "../instrumentations/document-load/DocumentLoadInstrumentation/types.js";
import { EmptyRootInstrumentationArgs } from "../instrumentations/empty-root/EmptyRootInstrumentation/types.js";
import { ClicksInstrumentationArgs } from "../instrumentations/clicks/ClicksInstrumentation/types.js";
import { ElementTimingInstrumentationArgs } from "../instrumentations/element-timing/ElementTimingInstrumentation/types.js";
import { GlobalExceptionInstrumentationArgs } from "../instrumentations/exceptions/GlobalExceptionInstrumentation/types.js";
import { FirstInteractionInstrumentationArgs } from "../instrumentations/first-interaction/FirstInteractionInstrumentation/types.js";
import { LoafInstrumentationArgs } from "../instrumentations/loaf/LoafInstrumentation/types.js";
import { MaxScrollDepthInstrumentationArgs } from "../instrumentations/max-scroll-depth/MaxScrollDepthInstrumentation/types.js";
import { NavigationInstrumentationArgs } from "../instrumentations/navigation/NavigationInstrumentation/types.js";
import { RageClickInstrumentationArgs } from "../instrumentations/rage-click/RageClickInstrumentation/types.js";
import { ServerTimingInstrumentationArgs } from "../instrumentations/server-timing/ServerTimingInstrumentation/types.js";
import { SignalBuffer } from "../processors/utils/SignalBuffer.js";
import { SoftNavigationPerformanceInstrumentationArgs } from "../instrumentations/soft-navigation-performance/SoftNavigationPerformanceInstrumentation/types.js";
import { UserTimingInstrumentationArgs } from "../instrumentations/user-timing/UserTimingInstrumentation/types.js";
import { WebVitalsInstrumentationConfig } from "../instrumentations/web-vitals/WebVitalsInstrumentation/types.js";
import "../instrumentations/index.js";
import "../processors/index.js";
import { UserSessionManager } from "../api-sessions/manager/types.js";
import { UserSessionManagerInternal } from "../managers/EmbraceUserSessionManager/types.js";
import { ContextManager, DiagLogLevel, DiagLogger, TextMapPropagator } from "@opentelemetry/api";
import { Instrumentation } from "@opentelemetry/instrumentation";
import { Resource } from "@opentelemetry/resources";
import { BatchLogRecordProcessor, LogRecordExporter, LogRecordProcessor } from "@opentelemetry/sdk-logs";
import { SpanExporter, SpanProcessor } from "@opentelemetry/sdk-trace";
import { FetchInstrumentationConfig } from "@opentelemetry/instrumentation-fetch";
import { XMLHttpRequestInstrumentationConfig } from "@opentelemetry/instrumentation-xml-http-request";
//#region src/sdk/types.d.ts
interface DynamicSDKConfig {
  /**
   * Pct of users that are sampled. 100% means all users are sampled.
   *
   * **default**: 100
   */
  samplingPct: number;
  /**
   * Pct of users that should have traceparent headers added to their network spans.
   *
   * **default**: 0
   */
  networkSpansForwardingThreshold?: number;
  /**
   * @deprecated The empty session avoidance feature has been removed. This field is ignored and will be removed in a future major version.
   */
  emptySessionAvoidanceEnabledPct?: number;
  /**
   * Maximum duration of a user session, in seconds. Driven by remote config.
   *
   * **default**: 43200 seconds (12 hours)
   */
  userSessionMaxDurationSeconds?: number;
  /**
   * Inactivity timeout that ends a user session, in seconds. Driven by remote
   * config.
   *
   * **default**: 1800 seconds (30 minutes)
   */
  userSessionInactivityTimeoutSeconds?: number;
  /**
   * Inactivity timeout that ends a session part (and its enclosing user
   * session) while the tab is foregrounded, in seconds. Driven by remote
   * config. Distinct from `userSessionInactivityTimeoutSeconds`, which drives
   * the lazy deadline after a backgrounding.
   *
   * **default**: 1800 seconds (30 minutes)
   */
  userSessionForegroundInactivityTimeoutSeconds?: number;
}
interface DynamicConfigManager {
  refreshRemoteConfig: () => Promise<void>;
  setConfig: (config: Partial<DynamicSDKConfig>) => void;
  getConfig: () => DynamicSDKConfig;
}
type BaseSDKInitConfig = {
  /**
   * appVersion is used to distinguish between different releases of your application. It can be set here if the value
   * is known in code, otherwise our CLI tool can be used to inject the value at build time.
   *
   * **default**: undefined
   */
  appVersion?: string;
  /**
   * defaultInstrumentationConfig can be used pass options to the default instrumentations by Embrace or turn certain
   * ones off entirely. Note that only some default instrumentations support configuration in this manner.
   *
   * **default**: undefined
   */
  defaultInstrumentationConfig?: DefaultInstrumentationConfig;
  /**
   * instrumentations can be set to include instrumentations beyond the default ones provided by Embrace. This does not
   * override Embrace's default instrumentations, to control those set `defaultInstrumentationConfig` instead.
   *
   * **default**: []
   */
  instrumentations?: Instrumentation[];
  /**
   * propagator defines a custom context propagator that will be attached to the TracerProvider setup by the SDK
   *
   * **default**: null
   */
  propagator?: TextMapPropagator | null;
  /**
   * contextManager defines a custom context manager that will be attached to the TracerProvider setup by the SDK
   *
   * **default**: StackContextManager
   */
  contextManager?: ContextManager | null;
  /**
   * resource defines a custom Resource that will be merged with the resource defined in `src/resources/webSdkResource.ts`
   * and included with all produced telemetry
   *
   * **default**: Resource.empty()
   */
  resource?: Resource;
  /**
   * spanProcessors
   * Span processor is an interface which allows hooks for span start and end method invocations.
   * They are invoked in the same order as they were registered.
   * Processors created by the sdk are inserted after processors in this list.
   *
   * **default**: []
   */
  spanProcessors?: SpanProcessor[];
  /**
   * logProcessors
   * LogRecordProcessor is an interface which allows hooks for LogRecord emitting.
   * They are invoked in the same order as they were registered.
   * Processors created by the sdk are inserted after processors in this list.
   *
   * **default**: []
   */
  logProcessors?: LogRecordProcessor[];
  /**
   * logLevel controls the verbosity of the SDK console logging
   *
   * **default**: DiagLogLevel.ERROR
   */
  logLevel?: DiagLogLevel;
  /**
   * AttributeScrubber is an interface that allows scrubbing potentially sensitive data before being emitted by the SDK.
   * Each scrubber specifies an attribute key it is concerned with and a function which is supplied with the string from
   * an AttributeValue whenever that key is encountered on a Log or Span. The string returned by the function is then
   * used in place of the original value
   *
   * **default**: []
   */
  attributeScrubbers?: AttributeScrubber[];
  /**
   * enableDefaultAttributeScrubbing specifies whether the default attribute scrubbers provided the SDK should be used.
   * These default scrubbers redact sensitive information in various url.* attributes following the recommendations
   * from: https://github.com/open-telemetry/semantic-conventions/blob/3b64cb31022feaacb410bfd6e571c1f19b5fbce0/docs/registry/attributes/url.md?plain=1#L33
   *
   * **default**: true
   */
  enableDefaultAttributeScrubbing?: boolean;
  /**
   * additionalQueryParamsToScrub specifies a list of query string parameter keys whose values will be scrubbed by the
   * default attribute scrubber. This list is in addition to the default keys that are checked by the SDK one provided
   * by the SDK, see DEFAULT_SENSITIVE_TOKENS in src/sdk/defaultAttributeScrubbers.ts
   *
   * **default**: []
   */
  additionalQueryParamsToScrub?: string[];
  diagLogger?: DiagLogger;
  /**
   * embraceDataURL is used to specify a custom Embrace data URL. This is only used for testing purposes.
   */
  embraceDataURL?: string;
  /**
   * embraceConfigURL is used to specify a custom Embrace configuration URL. This is only used for testing purposes.
   */
  embraceConfigURL?: string;
  /**
   * dynamicSDKConfigManager is used to manage dynamic SDK configuration. The manager can connect to a
   * remote configuration service to fetch the latest configuration. By default, the SDK will use a config manager that
   * fetches configuration from the Embrace dashboard if an appID is provided.
   *
   * **default**: undefined
   */
  dynamicSDKConfigManager?: DynamicConfigManager;
  /**
   * dynamicSDKConfig is an optional object that can be used to configure the SDK. Everything in this configuration
   * can be set dynamically at any time after the SDK has been initialized.
   * If an Embrace appID is provided, the configuration can be set remotely through the Embrace dashboard.
   *
   * **default**: EmbraceDynamicConfigManager
   */
  dynamicSDKConfig?: Partial<DynamicSDKConfig>;
  /**
   * registerGlobally is used to specify whether the SDK should register itself globally. This is useful when
   * the SDK is used in multiple applications on the same page, and you want to avoid telemetry from one application
   * to interfere with another.
   */
  registerGlobally?: boolean;
  /**
   * Whether the SDK injects a traceparent header on network requests is normally decided through a sample percentage
   * retrieved from remote configuration. When blockNetworkSpanForwarding is true the SDK never injects these headers
   * even if set through remote configuration.
   *
   * **default**: false
   */
  blockNetworkSpanForwarding?: boolean;
  /**
   * restrictedProtocols defines a set of protocols where the SDK should not operate. In `initSDK` if the current
   * `window.location` is on one of these protocols the SDK will stop initialization. Note that when adding protocols
   * the final ":" should be included as per https://developer.mozilla.org/en-US/docs/Web/API/URL/protocol
   *
   * **default**: new Set(['file:'])
   */
  restrictedProtocols?: Set<string>;
  /**
   * useDocumentTitleAsPageLabel enables the fallback to document.title for page label when a custom label is not set.
   *
   * **default**: true
   */
  useDocumentTitleAsPageLabel?: boolean;
};
type EmbraceExportSDKInitConfig = {
  /**
   * appID is a unique identifier for your application. It is used to identify your application in Embrace, and can be
   * found in the Embrace dashboard. This can only be omitted if at least one spanExporter or logExporter is setup to
   * send data to a collector other than Embrace.
   *
   * **default**: undefined
   */
  appID: string;
  spanExporters?: SpanExporter[];
  logExporters?: LogRecordExporter[];
};
type LogExportSDKInitConfig = {
  /**
   * logExporters can be set to export logs to a collector other than Embrace. If `appID` is omitted at lease one
   * exporter needs to be set here, or in `spanExporters`.
   *
   * **default**: []
   */
  logExporters: [LogRecordExporter, ...LogRecordExporter[]];
  appID?: string;
  spanExporters?: SpanExporter[];
};
type SpanExportSDKInitConfig = {
  /**
   * spanExporters can be set to export span to a collector other than Embrace. If `appID` is omitted at lease one
   * exporter needs to be set here, or in `logExporters`.
   *
   * **default**: []
   */
  spanExporters: [SpanExporter, ...SpanExporter[]];
  appID?: string;
  logExporters?: LogRecordExporter[];
};
type SDKInitConfig = BaseSDKInitConfig & (EmbraceExportSDKInitConfig | LogExportSDKInitConfig | SpanExportSDKInitConfig);
interface SDKControl {
  /**
   * @deprecated Will be removed in a future major version. The SDK exports
   * spans when a session part ends, so this method does not flush Embrace's
   * own span buffer. Call `session.endUserSession()` instead to end the
   * active user session and trigger a real export of buffered spans.
   *
   * Currently flushes logs and any user-supplied span exporter, but leaves
   * Embrace's span buffer untouched.
   */
  flush: () => Promise<void>;
  setDynamicConfig: (config: Partial<DynamicSDKConfig>) => void;
  log: LogManager;
  trace: TraceManager;
  session: UserSessionManager;
  user: UserManager;
  page: PageManager;
}
interface SetupUserArgs {
  registerGlobally?: boolean;
  sdkLocalStorage: NamespacedStorage;
}
interface SetupUserSessionArgs {
  limitManager: LimitManagerInternal;
  perf: PerformanceManager;
  registerGlobally?: boolean;
  sdkLocalStorage: NamespacedStorage;
  visibilityDoc: VisibilityStateDocument;
  dynamicConfigManager: DynamicConfigManager;
}
interface SetupTracesArgs {
  resource: Resource;
  userManager: UserManager;
  spanExporters?: SpanExporter[];
  spanProcessors: SpanProcessor[];
  propagator?: TextMapPropagator | null;
  contextManager?: ContextManager | null;
  attributeScrubbers: AttributeScrubber[];
  dynamicSDKConfig?: DynamicSDKConfig;
  registerGlobally?: boolean;
  embraceSpanProcessor?: SpanProcessor;
  pageManager: PageManager;
  signalBuffer?: SignalBuffer;
}
interface SetupLogsArgs {
  resource: Resource;
  userManager: UserManager;
  logExporters?: LogRecordExporter[];
  logProcessors: LogRecordProcessor[];
  userSessionManager: UserSessionManagerInternal;
  limitManager: LimitManagerInternal;
  attributeScrubbers: AttributeScrubber[];
  perf: PerformanceManager;
  registerGlobally?: boolean;
  embraceLogProcessor?: BatchLogRecordProcessor;
  sdkLocalStorage: NamespacedStorage;
  pageManager: PageManager;
  visibilityDoc: VisibilityStateDocument;
  signalBuffer?: SignalBuffer;
}
interface SetupPageArgs {
  useDocumentTitleAsPageLabel?: boolean;
  registerGlobally?: boolean;
  userSessionManager: UserSessionManagerInternal;
  perf: PerformanceManager;
}
type OptionalInstrumentations = 'exception' | 'click' | 'rage-click' | 'max-scroll-depth' | 'first-interaction' | 'web-vital' | 'loaf' | 'user-timing' | 'element-timing' | 'server-timing' | 'soft-navigation-performance' | 'document-load' | '@opentelemetry/instrumentation-fetch' | '@opentelemetry/instrumentation-xml-http-request';
interface NetworkInstrumentationArgs {
  ignoreUrls?: Array<string | RegExp>;
}
interface SetupDefaultInstrumentationsArgs {
  logManager?: LogManager;
  userSessionManager?: UserSessionManagerInternal;
  pageManager?: PageManager;
  limitManager?: LimitManagerInternal;
  signalBuffer?: SignalBuffer;
}
interface DefaultInstrumentationConfig {
  omit?: Set<OptionalInstrumentations>;
  exception?: GlobalExceptionInstrumentationArgs;
  click?: ClicksInstrumentationArgs;
  'rage-click'?: RageClickInstrumentationArgs;
  'max-scroll-depth'?: MaxScrollDepthInstrumentationArgs;
  'first-interaction'?: FirstInteractionInstrumentationArgs;
  'web-vital'?: WebVitalsInstrumentationConfig;
  loaf?: LoafInstrumentationArgs;
  'user-timing'?: UserTimingInstrumentationArgs;
  'element-timing'?: ElementTimingInstrumentationArgs;
  'server-timing'?: ServerTimingInstrumentationArgs;
  'soft-navigation-performance'?: SoftNavigationPerformanceInstrumentationArgs;
  'document-load'?: DocumentLoadInstrumentationConfig;
  navigation?: NavigationInstrumentationArgs;
  network?: NetworkInstrumentationArgs;
  '@opentelemetry/instrumentation-fetch'?: Omit<FetchInstrumentationConfig, 'enabled'>;
  '@opentelemetry/instrumentation-xml-http-request'?: Omit<XMLHttpRequestInstrumentationConfig, 'enabled'>;
  'empty-root'?: EmptyRootInstrumentationArgs;
}
interface SDKRegistryManager {
  register: (sdk: SDKControl) => void;
  clear: () => void;
  registered: () => SDKControl | null;
}
//#endregion
export { DefaultInstrumentationConfig, DynamicConfigManager, DynamicSDKConfig, SDKControl, SDKInitConfig, SDKRegistryManager, SetupDefaultInstrumentationsArgs, SetupLogsArgs, SetupPageArgs, SetupTracesArgs, SetupUserArgs, SetupUserSessionArgs };
//# sourceMappingURL=types.d.ts.map