{"version":3,"file":"create-legacy-browser-delegate.js","sourceRoot":"","sources":["../../../src/configuration/create-legacy-browser-delegate.ts"],"names":[],"mappings":";;;AAgBA,4FAI8C;AAC9C,+FAAwF;AAIxF;;;;;;GAMG;AACH,SAAgB,qCAAqC,CACnD,MAA8B,EAC9B,UAA2C,EAC3C,kBAA0B,EAC1B,eAAuC;IAEvC,MAAM,wBAAwB,GAAG,wBAAwB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAE1E,MAAM,OAAO,GAAG,IAAA,qEAA+B,EAC7C,MAAM,EACN,kBAAkB,EAClB,eAAe,CAChB,CAAC;IAEF,OAAO,wBAAwB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;AACvD,CAAC;AAfD,sFAeC;AAED,SAAgB,wBAAwB,CACtC,aAAgD;IAEhD,IAAI,CAAC,aAAa,IAAI,OAAO,SAAS,CAAC,UAAU,KAAK,UAAU,EAAE;QAChE,OAAO,sEAAkC,CAAC;KAC3C;SAAM,IAAI,OAAO,UAAU,CAAC,KAAK,KAAK,WAAW,EAAE;QAClD,OAAO,iEAA6B,CAAC;KACtC;SAAM;QACL,OAAO,+DAA2B,CAAC;KACpC;AACH,CAAC;AAVD,4DAUC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { ISerializer } from '@opentelemetry/otlp-transformer';\nimport {\n  createOtlpFetchExportDelegate,\n  createOtlpSendBeaconExportDelegate,\n  createOtlpXhrExportDelegate,\n} from '../otlp-browser-http-export-delegate';\nimport { convertLegacyBrowserHttpOptions } from './convert-legacy-browser-http-options';\nimport { IOtlpExportDelegate } from '../otlp-export-delegate';\nimport { OTLPExporterConfigBase } from './legacy-base-configuration';\n\n/**\n * @deprecated\n * @param config\n * @param serializer\n * @param signalResourcePath\n * @param requiredHeaders\n */\nexport function createLegacyOtlpBrowserExportDelegate<Internal, Response>(\n  config: OTLPExporterConfigBase,\n  serializer: ISerializer<Internal, Response>,\n  signalResourcePath: string,\n  requiredHeaders: Record<string, string>\n): IOtlpExportDelegate<Internal> {\n  const createOtlpExportDelegate = inferExportDelegateToUse(config.headers);\n\n  const options = convertLegacyBrowserHttpOptions(\n    config,\n    signalResourcePath,\n    requiredHeaders\n  );\n\n  return createOtlpExportDelegate(options, serializer);\n}\n\nexport function inferExportDelegateToUse(\n  configHeaders: OTLPExporterConfigBase['headers']\n) {\n  if (!configHeaders && typeof navigator.sendBeacon === 'function') {\n    return createOtlpSendBeaconExportDelegate;\n  } else if (typeof globalThis.fetch !== 'undefined') {\n    return createOtlpFetchExportDelegate;\n  } else {\n    return createOtlpXhrExportDelegate;\n  }\n}\n"]}