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AE,YAAY,CAAC,EAAE,CAAC;AAC1D,CAAC;AAnBD,sCAmBC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { Attributes, AttributeValue } from '@opentelemetry/api';\nimport type { Resource } from '@opentelemetry/resources';\n\n/**\n * Well-known symbol used by Node.js `util.inspect` (and `console.*`) to\n * render an object via a custom representation. Defined as a global Symbol\n * so it works without importing from `node:util`, keeping this module safe\n * for browser builds (where the symbol is simply never looked up).\n */\nexport const inspectCustom = Symbol.for('nodejs.util.inspect.custom');\n\n/**\n * Collect a Resource's settled attributes without touching the\n * `attributes` getter, which emits diag.error/debug entries when async\n * attribute detectors are still pending. Promise-like (unsettled)\n * entries are silently skipped so logging a Span/Tracer/Provider during\n * startup doesn't recurse through the diag pipeline.\n */\nexport function settledResourceAttributes(resource: Resource): Attributes {\n const attrs: Attributes = {};\n for (const [k, v] of resource.getRawAttributes()) {\n if (typeof (v as Partial>)?.then === 'function') {\n continue;\n }\n if (v != null) {\n attrs[k] ??= v as AttributeValue;\n }\n }\n return attrs;\n}\n\nexport type InspectFn = (value: unknown, options: unknown) => string;\n\nexport interface InspectStylizeOptions {\n depth?: number | null;\n stylize?: (text: string, styleType: string) => string;\n}\n\n/**\n * Build a class-tagged inspect representation. Returns a stub like\n * `[ClassName]` once the recursion budget is exhausted, otherwise returns\n * `ClassName ` so nested fields keep proper coloring,\n * indentation, and depth handling. In environments that don't supply an\n * `inspect` callback (e.g. browsers), falls back to returning the raw\n * payload object.\n */\nexport function formatInspect(\n className: string,\n payload: object,\n depth: number,\n options: InspectStylizeOptions | undefined,\n inspect: InspectFn | undefined\n): unknown {\n if (typeof depth === 'number' && depth < 0) {\n const tag = `[${className}]`;\n return options?.stylize ? options.stylize(tag, 'special') : tag;\n }\n if (typeof inspect !== 'function' || !options) {\n return payload;\n }\n const childOptions = {\n ...options,\n depth: options.depth == null ? options.depth : options.depth - 1,\n };\n return `${className} ${inspect(payload, childOptions)}`;\n}\n"]}