firebase
Version:
Firebase JavaScript library for web and Node.js
4 lines • 183 kB
JavaScript
import{registerVersion as _,_registerComponent as E,_getProvider,getApp as w}from"https://www.gstatic.com/firebasejs/13.3.0/firebase-app.js";class FirebaseError extends Error{constructor(_,E,w){super(E),this.code=_,this.customData=w,this.name="FirebaseError",Object.setPrototypeOf(this,FirebaseError.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,ErrorFactory.prototype.create)}}class ErrorFactory{constructor(_,E,w){this.service=_,this.serviceName=E,this.errors=w}create(_,...E){const w=E[0]||{},C=`${this.service}/${_}`,L=this.errors[_],R=L?function replaceTemplate(_,E){try{let w=0,C="";for(;w<_.length;){const L=_.indexOf("{$",w);if(-1===L){C+=_.substring(w);break}const R=_.indexOf("}",L+2);if(-1===R){C+=_.substring(w);break}const P=_.substring(L+2,R),I=E[P];C+=_.substring(w,L)+(null!=I?String(I):`<${P}?>`),w=R+1}return C}catch(E){return _}}(L,w):"Error",P=`${this.serviceName}: ${R} (${C}).`;return new FirebaseError(C,P,w)}}function deepEqual(_,E){if(_===E)return!0;const w=Object.keys(_),C=Object.keys(E);for(const L of w){if(!C.includes(L))return!1;const w=_[L],R=E[L];if(isObject$1(w)&&isObject$1(R)){if(!deepEqual(w,R))return!1}else if(w!==R)return!1}for(const _ of C)if(!w.includes(_))return!1;return!0}function isObject$1(_){return null!==_&&"object"==typeof _}class Component{constructor(_,E,w){this.name=_,this.instanceFactory=E,this.type=w,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}setInstantiationMode(_){return this.instantiationMode=_,this}setMultipleInstances(_){return this.multipleInstances=_,this}setServiceProps(_){return this.serviceProps=_,this}setInstanceCreatedCallback(_){return this.onInstanceCreated=_,this}}var C,L,R;!function(_){_.LAZY="LAZY",_.EAGER="EAGER",_.EXPLICIT="EXPLICIT"}(C||(C={})),function(_){_.PUBLIC="PUBLIC",_.PRIVATE="PRIVATE",_.VERSION="VERSION"}(L||(L={})),function(_){_[_.UNSPECIFIED=0]="UNSPECIFIED",_[_.TRACE=1]="TRACE",_[_.TRACE2=2]="TRACE2",_[_.TRACE3=3]="TRACE3",_[_.TRACE4=4]="TRACE4",_[_.DEBUG=5]="DEBUG",_[_.DEBUG2=6]="DEBUG2",_[_.DEBUG3=7]="DEBUG3",_[_.DEBUG4=8]="DEBUG4",_[_.INFO=9]="INFO",_[_.INFO2=10]="INFO2",_[_.INFO3=11]="INFO3",_[_.INFO4=12]="INFO4",_[_.WARN=13]="WARN",_[_.WARN2=14]="WARN2",_[_.WARN3=15]="WARN3",_[_.WARN4=16]="WARN4",_[_.ERROR=17]="ERROR",_[_.ERROR2=18]="ERROR2",_[_.ERROR3=19]="ERROR3",_[_.ERROR4=20]="ERROR4",_[_.FATAL=21]="FATAL",_[_.FATAL2=22]="FATAL2",_[_.FATAL3=23]="FATAL3",_[_.FATAL4=24]="FATAL4"}(R||(R={}));class NoopLogger{emit(_){}enabled(){return!1}}const P=new NoopLogger;const I=Symbol.for("io.opentelemetry.js.api.logs"),k=globalThis;const F=new class NoopLoggerProvider{getLogger(_,E,w){return new NoopLogger}};class ProxyLogger{constructor(_,E,w,C){this._provider=_,this.name=E,this.version=w,this.options=C}emit(_){this._getLogger().emit(_)}enabled(_){return this._getLogger().enabled(_)}_getLogger(){if(this._delegate)return this._delegate;const _=this._provider._getDelegateLogger(this.name,this.version,this.options);return _?(this._delegate=_,this._delegate):P}}class ProxyLoggerProvider{getLogger(_,E,w){var C;return null!==(C=this._getDelegateLogger(_,E,w))&&void 0!==C?C:new ProxyLogger(this,_,E,w)}_getDelegate(){var _;return null!==(_=this._delegate)&&void 0!==_?_:F}_setDelegate(_){this._delegate=_}_getDelegateLogger(_,E,w){var C;return null===(C=this._delegate)||void 0===C?void 0:C.getLogger(_,E,w)}}class LogsAPI{constructor(){this._proxyLoggerProvider=new ProxyLoggerProvider}static getInstance(){return this._instance||(this._instance=new LogsAPI),this._instance}setGlobalLoggerProvider(_){return k[I]?this.getLoggerProvider():(k[I]=function makeGetter(_,E,w){return C=>C===_?E:w}(1,_,F),this._proxyLoggerProvider._setDelegate(_),_)}getLoggerProvider(){var _,E;return null!==(E=null===(_=k[I])||void 0===_?void 0:_.call(k,1))&&void 0!==E?E:this._proxyLoggerProvider}getLogger(_,E,w){return this.getLoggerProvider().getLogger(_,E,w)}disable(){delete k[I],this._proxyLoggerProvider=new ProxyLoggerProvider}}const $=LogsAPI.getInstance(),V="1.9.1",H=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;const j=function _makeCompatibilityCheck(_){const E=new Set([_]),w=new Set,C=_.match(H);if(!C)return()=>!1;const L=+C[1],R=+C[2],P=+C[3];if(null!=C[4])return function isExactmatch(E){return E===_};function _reject(_){return w.add(_),!1}function _accept(_){return E.add(_),!0}return function isCompatible(_){if(E.has(_))return!0;if(w.has(_))return!1;const C=_.match(H);if(!C)return _reject(_);const I=+C[1],k=+C[2],F=+C[3];return null!=C[4]||L!==I?_reject(_):0===L?R===k&&P<=F?_accept(_):_reject(_):R<=k?_accept(_):_reject(_)}}(V),z=V.split(".")[0],q=Symbol.for(`opentelemetry.js.api.${z}`),G="object"==typeof globalThis?globalThis:"object"==typeof self?self:"object"==typeof window?window:"object"==typeof global?global:{};function registerGlobal(_,E,w,C=!1){var L;const R=G[q]=null!==(L=G[q])&&void 0!==L?L:{version:V};if(!C&&R[_]){const E=new Error(`@opentelemetry/api: Attempted duplicate registration of API: ${_}`);return w.error(E.stack||E.message),!1}if(R.version!==V){const E=new Error(`@opentelemetry/api: Registration of version v${R.version} for ${_} does not match previously registered API v${V}`);return w.error(E.stack||E.message),!1}return R[_]=E,w.debug(`@opentelemetry/api: Registered a global for ${_} v${V}.`),!0}function getGlobal(_){var E,w;const C=null===(E=G[q])||void 0===E?void 0:E.version;if(C&&j(C))return null===(w=G[q])||void 0===w?void 0:w[_]}function unregisterGlobal(_,E){E.debug(`@opentelemetry/api: Unregistering a global for ${_} v${V}.`);const w=G[q];w&&delete w[_]}class DiagComponentLogger{constructor(_){this._namespace=_.namespace||"DiagComponentLogger"}debug(..._){return logProxy("debug",this._namespace,_)}error(..._){return logProxy("error",this._namespace,_)}info(..._){return logProxy("info",this._namespace,_)}warn(..._){return logProxy("warn",this._namespace,_)}verbose(..._){return logProxy("verbose",this._namespace,_)}}function logProxy(_,E,w){const C=getGlobal("diag");if(C)return C[_](E,...w)}var K;!function(_){_[_.NONE=0]="NONE",_[_.ERROR=30]="ERROR",_[_.WARN=50]="WARN",_[_.INFO=60]="INFO",_[_.DEBUG=70]="DEBUG",_[_.VERBOSE=80]="VERBOSE",_[_.ALL=9999]="ALL"}(K||(K={}));class DiagAPI{static instance(){return this._instance||(this._instance=new DiagAPI),this._instance}constructor(){function _logProxy(_){return function(...E){const w=getGlobal("diag");if(w)return w[_](...E)}}const _=this;_.setLogger=(E,w={logLevel:K.INFO})=>{var C,L,R;if(E===_){const E=new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");return _.error(null!==(C=E.stack)&&void 0!==C?C:E.message),!1}"number"==typeof w&&(w={logLevel:w});const P=getGlobal("diag"),I=function createLogLevelDiagLogger(_,E){function _filterFunc(w,C){const L=E[w];return"function"==typeof L&&_>=C?L.bind(E):function(){}}return _<K.NONE?_=K.NONE:_>K.ALL&&(_=K.ALL),E=E||{},{error:_filterFunc("error",K.ERROR),warn:_filterFunc("warn",K.WARN),info:_filterFunc("info",K.INFO),debug:_filterFunc("debug",K.DEBUG),verbose:_filterFunc("verbose",K.VERBOSE)}}(null!==(L=w.logLevel)&&void 0!==L?L:K.INFO,E);if(P&&!w.suppressOverrideMessage){const _=null!==(R=(new Error).stack)&&void 0!==R?R:"<failed to generate stacktrace>";P.warn(`Current logger will be overwritten from ${_}`),I.warn(`Current logger will overwrite one already registered from ${_}`)}return registerGlobal("diag",I,_,!0)},_.disable=()=>{unregisterGlobal("diag",_)},_.createComponentLogger=_=>new DiagComponentLogger(_),_.verbose=_logProxy("verbose"),_.debug=_logProxy("debug"),_.info=_logProxy("info"),_.warn=_logProxy("warn"),_.error=_logProxy("error")}}class BaggageImpl{constructor(_){this._entries=_?new Map(_):new Map}getEntry(_){const E=this._entries.get(_);if(E)return Object.assign({},E)}getAllEntries(){return Array.from(this._entries.entries())}setEntry(_,E){const w=new BaggageImpl(this._entries);return w._entries.set(_,E),w}removeEntry(_){const E=new BaggageImpl(this._entries);return E._entries.delete(_),E}removeEntries(..._){const E=new BaggageImpl(this._entries);for(const w of _)E._entries.delete(w);return E}clear(){return new BaggageImpl}}const Q=Symbol("BaggageEntryMetadata"),X=DiagAPI.instance();function createBaggage(_={}){return new BaggageImpl(new Map(Object.entries(_)))}function createContextKey(_){return Symbol.for(_)}class BaseContext{constructor(_){const E=this;E._currentContext=_?new Map(_):new Map,E.getValue=_=>E._currentContext.get(_),E.setValue=(_,w)=>{const C=new BaseContext(E._currentContext);return C._currentContext.set(_,w),C},E.deleteValue=_=>{const w=new BaseContext(E._currentContext);return w._currentContext.delete(_),w}}}const Y=new BaseContext;class NoopMetric{}class NoopObservableMetric{addCallback(_){}removeCallback(_){}}const Z=new class NoopMeter{constructor(){}createGauge(_,E){return tt}createHistogram(_,E){return et}createCounter(_,E){return J}createUpDownCounter(_,E){return rt}createObservableGauge(_,E){return st}createObservableCounter(_,E){return nt}createObservableUpDownCounter(_,E){return it}addBatchObservableCallback(_,E){}removeBatchObservableCallback(_){}},J=new class NoopCounterMetric extends NoopMetric{add(_,E){}},tt=new class NoopGaugeMetric extends NoopMetric{record(_,E){}},et=new class NoopHistogramMetric extends NoopMetric{record(_,E){}},rt=new class NoopUpDownCounterMetric extends NoopMetric{add(_,E){}},nt=new class NoopObservableCounterMetric extends NoopObservableMetric{},st=new class NoopObservableGaugeMetric extends NoopObservableMetric{},it=new class NoopObservableUpDownCounterMetric extends NoopObservableMetric{};function createNoopMeter(){return Z}const ot={get(_,E){if(null!=_)return _[E]},keys:_=>null==_?[]:Object.keys(_)},at={set(_,E,w){null!=_&&(_[E]=w)}};const ct="context",ut=new class NoopContextManager{active(){return Y}with(_,E,w,...C){return E.call(w,...C)}bind(_,E){return E}enable(){return this}disable(){return this}};class ContextAPI{constructor(){}static getInstance(){return this._instance||(this._instance=new ContextAPI),this._instance}setGlobalContextManager(_){return registerGlobal(ct,_,DiagAPI.instance())}active(){return this._getContextManager().active()}with(_,E,w,...C){return this._getContextManager().with(_,E,w,...C)}bind(_,E){return this._getContextManager().bind(_,E)}_getContextManager(){return getGlobal(ct)||ut}disable(){this._getContextManager().disable(),unregisterGlobal(ct,DiagAPI.instance())}}var lt;!function(_){_[_.NONE=0]="NONE",_[_.SAMPLED=1]="SAMPLED"}(lt||(lt={}));const dt="0000000000000000",ht="00000000000000000000000000000000",pt={traceId:ht,spanId:dt,traceFlags:lt.NONE};class NonRecordingSpan{constructor(_=pt){this._spanContext=_}spanContext(){return this._spanContext}setAttribute(_,E){return this}setAttributes(_){return this}addEvent(_,E){return this}addLink(_){return this}addLinks(_){return this}setStatus(_){return this}updateName(_){return this}end(_){}isRecording(){return!1}recordException(_,E){}}const gt=createContextKey("OpenTelemetry Context Key SPAN");function getSpan(_){return _.getValue(gt)||void 0}function getActiveSpan(){return getSpan(ContextAPI.getInstance().active())}function setSpan(_,E){return _.setValue(gt,E)}function deleteSpan(_){return _.deleteValue(gt)}function setSpanContext(_,E){return setSpan(_,new NonRecordingSpan(E))}function getSpanContext(_){var E;return null===(E=getSpan(_))||void 0===E?void 0:E.spanContext()}const mt=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1]);function isValidHex(_,E){if("string"!=typeof _||_.length!==E)return!1;let w=0;for(let E=0;E<_.length;E+=4)w+=(0|mt[_.charCodeAt(E)])+(0|mt[_.charCodeAt(E+1)])+(0|mt[_.charCodeAt(E+2)])+(0|mt[_.charCodeAt(E+3)]);return w===E}function isValidTraceId(_){return isValidHex(_,32)&&_!==ht}function isSpanContextValid(_){return isValidTraceId(_.traceId)&&function isValidSpanId(_){return isValidHex(_,16)&&_!==dt}(_.spanId)}function wrapSpanContext(_){return new NonRecordingSpan(_)}const ft=ContextAPI.getInstance();class NoopTracer{startSpan(_,E,w=ft.active()){if(Boolean(null==E?void 0:E.root))return new NonRecordingSpan;const C=w&&getSpanContext(w);return function isSpanContext(_){return null!==_&&"object"==typeof _&&"spanId"in _&&"string"==typeof _.spanId&&"traceId"in _&&"string"==typeof _.traceId&&"traceFlags"in _&&"number"==typeof _.traceFlags}(C)&&isSpanContextValid(C)?new NonRecordingSpan(C):new NonRecordingSpan}startActiveSpan(_,E,w,C){let L,R,P;if(arguments.length<2)return;2===arguments.length?P=E:3===arguments.length?(L=E,P=w):(L=E,R=w,P=C);const I=null!=R?R:ft.active(),k=this.startSpan(_,L,I),F=setSpan(I,k);return ft.with(F,P,void 0,k)}}const _t=new NoopTracer;class ProxyTracer{constructor(_,E,w,C){this._provider=_,this.name=E,this.version=w,this.options=C}startSpan(_,E,w){return this._getTracer().startSpan(_,E,w)}startActiveSpan(_,E,w,C){const L=this._getTracer();return Reflect.apply(L.startActiveSpan,L,arguments)}_getTracer(){if(this._delegate)return this._delegate;const _=this._provider.getDelegateTracer(this.name,this.version,this.options);return _?(this._delegate=_,this._delegate):_t}}const bt=new class NoopTracerProvider{getTracer(_,E,w){return new NoopTracer}};class ProxyTracerProvider{getTracer(_,E,w){var C;return null!==(C=this.getDelegateTracer(_,E,w))&&void 0!==C?C:new ProxyTracer(this,_,E,w)}getDelegate(){var _;return null!==(_=this._delegate)&&void 0!==_?_:bt}setDelegate(_){this._delegate=_}getDelegateTracer(_,E,w){var C;return null===(C=this._delegate)||void 0===C?void 0:C.getTracer(_,E,w)}}var yt,St,Et;!function(_){_[_.NOT_RECORD=0]="NOT_RECORD",_[_.RECORD=1]="RECORD",_[_.RECORD_AND_SAMPLED=2]="RECORD_AND_SAMPLED"}(yt||(yt={})),function(_){_[_.INTERNAL=0]="INTERNAL",_[_.SERVER=1]="SERVER",_[_.CLIENT=2]="CLIENT",_[_.PRODUCER=3]="PRODUCER",_[_.CONSUMER=4]="CONSUMER"}(St||(St={})),function(_){_[_.UNSET=0]="UNSET",_[_.OK=1]="OK",_[_.ERROR=2]="ERROR"}(Et||(Et={}));const Tt=ContextAPI.getInstance(),vt=DiagAPI.instance();const wt=new class NoopMeterProvider{getMeter(_,E,w){return Z}},At="metrics";class MetricsAPI{constructor(){}static getInstance(){return this._instance||(this._instance=new MetricsAPI),this._instance}setGlobalMeterProvider(_){return registerGlobal(At,_,DiagAPI.instance())}getMeterProvider(){return getGlobal(At)||wt}getMeter(_,E,w){return this.getMeterProvider().getMeter(_,E,w)}disable(){unregisterGlobal(At,DiagAPI.instance())}}const Ct=MetricsAPI.getInstance();const Lt=createContextKey("OpenTelemetry Baggage Key");function getBaggage(_){return _.getValue(Lt)||void 0}function getActiveBaggage(){return getBaggage(ContextAPI.getInstance().active())}function setBaggage(_,E){return _.setValue(Lt,E)}function deleteBaggage(_){return _.deleteValue(Lt)}const Rt="propagation",Pt=new class NoopTextMapPropagator{inject(_,E){}extract(_,E){return _}fields(){return[]}};class PropagationAPI{constructor(){this.createBaggage=createBaggage,this.getBaggage=getBaggage,this.getActiveBaggage=getActiveBaggage,this.setBaggage=setBaggage,this.deleteBaggage=deleteBaggage}static getInstance(){return this._instance||(this._instance=new PropagationAPI),this._instance}setGlobalPropagator(_){return registerGlobal(Rt,_,DiagAPI.instance())}inject(_,E,w=at){return this._getGlobalPropagator().inject(_,E,w)}extract(_,E,w=ot){return this._getGlobalPropagator().extract(_,E,w)}fields(){return this._getGlobalPropagator().fields()}disable(){unregisterGlobal(Rt,DiagAPI.instance())}_getGlobalPropagator(){return getGlobal(Rt)||Pt}}const Ot=PropagationAPI.getInstance(),xt="trace";class TraceAPI{constructor(){this._proxyTracerProvider=new ProxyTracerProvider,this.wrapSpanContext=wrapSpanContext,this.isSpanContextValid=isSpanContextValid,this.deleteSpan=deleteSpan,this.getSpan=getSpan,this.getActiveSpan=getActiveSpan,this.getSpanContext=getSpanContext,this.setSpan=setSpan,this.setSpanContext=setSpanContext}static getInstance(){return this._instance||(this._instance=new TraceAPI),this._instance}setGlobalTracerProvider(_){const E=registerGlobal(xt,this._proxyTracerProvider,DiagAPI.instance());return E&&this._proxyTracerProvider.setDelegate(_),E}getTracerProvider(){return getGlobal(xt)||this._proxyTracerProvider}getTracer(_,E){return this.getTracerProvider().getTracer(_,E)}disable(){unregisterGlobal(xt,DiagAPI.instance()),this._proxyTracerProvider=new ProxyTracerProvider}}const It=TraceAPI.getInstance(),Nt=createContextKey("OpenTelemetry SDK Context Key SUPPRESS_TRACING");function suppressTracing$2(_){return _.setValue(Nt,!0)}function isTracingSuppressed$1(_){return!0===_.getValue(Nt)}const Dt="baggage";function parsePairKeyValue(_){if(!_)return;const E=_.indexOf(";"),w=-1===E?_:_.substring(0,E),C=w.indexOf("=");if(C<=0)return;const L=w.substring(0,C).trim(),R=w.substring(C+1).trim();if(!L||!R)return;let P,I,k;try{P=decodeURIComponent(L),I=decodeURIComponent(R)}catch{return}if(-1!==E&&E<_.length-1){k=function baggageEntryMetadataFromString(_){return"string"!=typeof _&&(X.error("Cannot create baggage metadata from unknown type: "+typeof _),_=""),{__TYPE__:Q,toString:()=>_}}(_.substring(E+1))}return{key:P,value:I,metadata:k}}function parseBaggageHeaderString(_,E,w,C){let L=0;for(;L<_.length&&w<180;){const R=_.indexOf(",",L),P=-1===R?_.length:R,I=P-L;if(I<=4096){const R=parsePairKeyValue(_.substring(L,P));if(R){const _=(0===w?0:1)+I;if(C+_>8192)break;E[R.key]=R.metadata?{value:R.value,metadata:R.metadata}:{value:R.value},w++,C+=_}}if(-1===R)break;L=R+1}return[w,C]}class W3CBaggagePropagator{inject(_,E,w){const C=Ot.getBaggage(_);if(!C||isTracingSuppressed$1(_))return;const L=function getKeyPairs(_){return _.getAllEntries().map((([_,E])=>{let w=`${encodeURIComponent(_)}=${encodeURIComponent(E.value)}`;return void 0!==E.metadata&&(w+=";"+E.metadata.toString()),w}))}(C).filter((_=>_.length<=4096)).slice(0,180),R=function serializeKeyPairs(_){return _.reduce(((_,E)=>{const w=`${_}${""!==_?",":""}${E}`;return w.length>8192?_:w}),"")}(L);R.length>0&&w.set(E,Dt,R)}extract(_,E,w){const C=w.get(E,Dt);if(!C)return _;const L={};let R=0,P=0;if(Array.isArray(C))for(let _=0;_<C.length;_++)[R,P]=parseBaggageHeaderString(C[_],L,R,P);else[R]=parseBaggageHeaderString(C,L,R,P);return 0===R?_:Ot.setBaggage(_,Ot.createBaggage(L))}fields(){return[Dt]}}var kt;!function(_){_[_.SUCCESS=0]="SUCCESS",_[_.FAILED=1]="FAILED"}(kt||(kt={}));class CompositePropagator{constructor(_={}){this._propagators=_.propagators??[];const E=new Set;for(const _ of this._propagators){const w="function"==typeof _.fields?_.fields():[];for(const _ of w)E.add(_)}this._fields=Array.from(E)}inject(_,E,w){for(const C of this._propagators)try{C.inject(_,E,w)}catch(_){vt.warn(`Failed to inject with ${C.constructor.name}. Err: ${_.message}`)}}extract(_,E,w){return this._propagators.reduce(((_,C)=>{try{return C.extract(_,E,w)}catch(_){vt.warn(`Failed to extract with ${C.constructor.name}. Err: ${_.message}`)}return _}),_)}fields(){return this._fields.slice()}}const Mt="[_0-9a-z-*/]",Ft=new RegExp(`^(?:${`[a-z]${Mt}{0,255}`}|${`[a-z0-9]${Mt}{0,240}@[a-z]${Mt}{0,13}`})$`),Bt=/^[ -~]{0,255}[!-~]$/,Ut=/,|=/;function validateKey(_){return Ft.test(_)}function validateValue(_){return Bt.test(_)&&!Ut.test(_)}class TraceState{constructor(_){this._rawTraceState="string"==typeof _?_:"",this._length=this._rawTraceState.length}set(_,E){if(!validateKey(_)||!validateValue(E))return this;const w=this._getState(),C=w.get(_);let L=this._length;if(L+="string"==typeof C?E.length-C.length:_.length+E.length+(w.size>0?2:1),L>512)return this;const R=new Map(w);return R.delete(_),R.set(_,E),this._fromState(R,L)}unset(_){const E=this._getState(),w=E.get(_);if("string"!=typeof w)return this;let C=this._length-(_.length+w.length+1);E.size>1&&(C-=1);const L=new Map(E);return L.delete(_),this._fromState(L,C)}get(_){return this._getState().get(_)}serialize(){let _="",E=0;for(const w of this._getState())E>0&&(_=","+_),_=`${w[0]}=${w[1]}`+_,E++;return _}_getState(){if(this._internalState)return this._internalState;const _=this._rawTraceState.split(","),E=new Map;let w=0;for(const C of _){const _=C.trim(),L=_.indexOf("=");if(-1===L)continue;const R=_.slice(0,L),P=_.slice(L+1);if(!validateKey(R)||!validateValue(P))continue;const I=w+_.length+(E.size>0?1:0);if(!(I>512)&&(E.set(R,P),w=I,E.size>=32))break}return this._length=w,this._internalState=new Map(Array.from(E.entries()).reverse()),this._internalState}_fromState(_,E){const w=Object.create(TraceState.prototype);return w._internalState=_,w._length=E,w}}const $t="traceparent",Vt="tracestate",Ht=new RegExp("^\\s?((?!ff)[\\da-f]{2})-((?![0]{32})[\\da-f]{32})-((?![0]{16})[\\da-f]{16})-([\\da-f]{2})(-.*)?\\s?$");class W3CTraceContextPropagator{inject(_,E,w){const C=It.getSpanContext(_);if(!C||isTracingSuppressed$1(_)||!isSpanContextValid(C))return;const L=`00-${C.traceId}-${C.spanId}-0${Number(C.traceFlags||lt.NONE).toString(16)}`;w.set(E,$t,L),C.traceState&&w.set(E,Vt,C.traceState.serialize())}extract(_,E,w){const C=w.get(E,$t);if(!C)return _;const L=Array.isArray(C)?C[0]:C;if("string"!=typeof L)return _;const R=function parseTraceParent(_){const E=Ht.exec(_);return E?"00"===E[1]&&E[5]?null:{traceId:E[2],spanId:E[3],traceFlags:parseInt(E[4],16)}:null}(L);if(!R)return _;R.isRemote=!0;const P=w.get(E,Vt);if(P){const _=Array.isArray(P)?P.join(","):P;R.traceState=new TraceState("string"==typeof _?_:void 0)}return It.setSpanContext(_,R)}fields(){return[$t,Vt]}}const jt={},zt=createContextKey("OpenTelemetry SDK Context Key SUPPRESS_TRACING");let qt=function loggingErrorHandler$1(){return _=>{vt.error(function stringifyException$1(_){return"string"==typeof _?_:JSON.stringify(function flattenException$1(_){const E={};let w=_;for(;null!==w;)Object.getOwnPropertyNames(w).forEach((_=>{if(E[_])return;const C=w[_];C&&(E[_]=String(C))})),w=Object.getPrototypeOf(w);return E}(_))}(_))}}();function globalErrorHandler$1(_){try{qt(_)}catch{}}const Gt="error.type",Wt="exception.message",Kt="exception.stacktrace",Qt="exception.type",Xt="http.request.method",Yt="http.request.method_original",Zt="http.response.status_code",Jt="server.address",te="server.port",ee="service.name",re="telemetry.sdk.language",ne="webjs",se="telemetry.sdk.name",ie="telemetry.sdk.version",oe="url.full",ae="process.runtime.name",ce={[se]:"opentelemetry",[ae]:"browser",[re]:ne,[ie]:"2.9.0"},ue=performance,le=Math.pow(10,6),de=Math.pow(10,9);function millisToHrTime$1(_){const E=_/1e3;return[Math.trunc(E),Math.round(_%1e3*le)]}function hrTime$1(_){return function addHrTimes$1(_,E){const w=[_[0]+E[0],_[1]+E[1]];w[1]>=de&&(w[1]-=de,w[0]+=1);return w}(millisToHrTime$1(ue.timeOrigin),millisToHrTime$1("number"==typeof _?_:ue.now()))}function timeInputToHrTime(_){if(function isTimeInputHrTime$1(_){return Array.isArray(_)&&2===_.length&&"number"==typeof _[0]&&"number"==typeof _[1]}(_))return _;if("number"==typeof _)return _<ue.timeOrigin/2?hrTime$1(_):millisToHrTime$1(_);if(_ instanceof Date)return millisToHrTime$1(_.getTime());throw TypeError("Invalid input type")}function hrTimeToNanoseconds(_){return _[0]*de+_[1]}var he;!function(_){_[_.SUCCESS=0]="SUCCESS",_[_.FAILED=1]="FAILED"}(he||(he={}));class TimeoutError extends Error{constructor(_){super(_),Object.setPrototypeOf(this,TimeoutError.prototype)}}function urlMatches(_,E){return"string"==typeof E?_===E:!!_.match(E)}function isUrlIgnored(_,E){if(!E)return!1;for(const w of E)if(urlMatches(_,w))return!0;return!1}let pe,ge=class Deferred{constructor(){this._promise=new Promise(((_,E)=>{this._resolve=_,this._reject=E}))}get promise(){return this._promise}resolve(_){this._resolve(_)}reject(_){this._reject(_)}},me=class BindOnceFuture{constructor(_,E){this._isCalled=!1,this._deferred=new ge,this._callback=_,this._that=E}get isCalled(){return this._isCalled}get promise(){return this._deferred.promise}call(..._){if(!this._isCalled){this._isCalled=!0;try{Promise.resolve(this._callback.call(this._that,..._)).then((_=>this._deferred.resolve(_)),(_=>this._deferred.reject(_)))}catch(_){this._deferred.reject(_)}}return this._deferred.promise}};function defaultServiceName$1(){if(void 0===pe)try{const _=globalThis.process.argv0;pe=_?`unknown_service:${_}`:"unknown_service"}catch{pe="unknown_service"}return pe}const isPromiseLike$2=_=>null!==_&&"object"==typeof _&&"function"==typeof _.then;let fe=class ResourceImpl{static FromAttributeList(_,E){const w=new ResourceImpl({},E);return w._rawAttributes=guardedRawAttributes$2(_),w._asyncAttributesPending=_.filter((([_,E])=>isPromiseLike$2(E))).length>0,w}constructor(_,E){this._asyncAttributesPending=!1;const w=_.attributes??{};this._rawAttributes=Object.entries(w).map((([_,E])=>(isPromiseLike$2(E)&&(this._asyncAttributesPending=!0),[_,E]))),this._rawAttributes=guardedRawAttributes$2(this._rawAttributes),this._schemaUrl=function validateSchemaUrl$2(_){if("string"==typeof _||void 0===_)return _;return void vt.warn("Schema URL must be string or undefined, got %s. Schema URL will be ignored.",_)}(E?.schemaUrl)}get asyncAttributesPending(){return this._asyncAttributesPending}async waitForAsyncAttributes(){if(this.asyncAttributesPending){for(let _=0;_<this._rawAttributes.length;_++){const[E,w]=this._rawAttributes[_];this._rawAttributes[_]=[E,isPromiseLike$2(w)?await w:w]}this._asyncAttributesPending=!1}}get attributes(){if(this.asyncAttributesPending&&vt.error("Accessing resource attributes before async attributes settled"),this._memoizedAttributes)return this._memoizedAttributes;const _={};for(const[E,w]of this._rawAttributes)isPromiseLike$2(w)?vt.debug(`Unsettled resource attribute ${E} skipped`):null!=w&&(_[E]??(_[E]=w));return this._asyncAttributesPending||(this._memoizedAttributes=_),_}getRawAttributes(){return this._rawAttributes}get schemaUrl(){return this._schemaUrl}merge(_){if(null==_)return this;const E=function mergeSchemaUrl$2(_,E){const w=_?.schemaUrl,C=E?.schemaUrl,L=void 0===w||""===w,R=void 0===C||""===C;if(L)return C;if(R)return w;if(w===C)return w;return void vt.warn('Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.',w,C)}(this,_),w=E?{schemaUrl:E}:void 0;return ResourceImpl.FromAttributeList([..._.getRawAttributes(),...this.getRawAttributes()],w)}};function defaultResource$1(){return function resourceFromAttributes$2(_,E){return fe.FromAttributeList(Object.entries(_),E)}({[ee]:defaultServiceName$1(),[re]:ce[re],[se]:ce[se],[ie]:ce[ie]})}function guardedRawAttributes$2(_){return _.map((([_,E])=>isPromiseLike$2(E)?[_,E.catch((E=>{vt.debug("promise rejection for resource attribute: %s - %s",_,E)}))]:[_,E]))}function isLogAttributeValue(_){return isLogAttributeValueInternal(_,new WeakSet)}function isLogAttributeValueInternal(_,E){if(null==_)return!0;if("string"==typeof _||"number"==typeof _||"boolean"==typeof _)return!0;if(_ instanceof Uint8Array)return!0;if("object"==typeof _){if(E.has(_))return!1;if(E.add(_),Array.isArray(_)){for(const w of _)if(!isLogAttributeValueInternal(w,E))return!1;return!0}const w=_;if(w.constructor!==Object&&void 0!==w.constructor)return!1;for(const _ in w)if(Object.prototype.hasOwnProperty.call(w,_)&&!isLogAttributeValueInternal(w[_],E))return!1;return!0}return!1}var _e;function addAttribute(_,E,w,C,L){if(0===C.length)return vt.warn(`Invalid attribute key: ${C}`),_e.DROP_INVALID;if(!isLogAttributeValue(L))return vt.warn(`Invalid attribute value set for key: ${C}`),_e.DROP_INVALID;const R=!Object.prototype.hasOwnProperty.call(_,C);return R&&w>=E.attributeCountLimit?_e.DROP_LIMIT_REACHED:(_[C]=truncateToSize(L,E.attributeValueLengthLimit),R?_e.ADD_NEW:_e.ADD_OVERWRITE_EXISTING)}function truncateToSize(_,E){if(E<=0)return vt.warn(`Attribute value limit must be positive, got ${E}`),_;if(null==_)return _;if("string"==typeof _)return _.length<=E?_:_.substring(0,E);if(_ instanceof Uint8Array)return _;if(Array.isArray(_))return _.map((_=>truncateToSize(_,E)));if("object"==typeof _){const w={};for(const[C,L]of Object.entries(_))w[C]=truncateToSize(L,E);return w}return _}function normalizeScopeAttributes(_,E){if(null==E)return{};const w={};let C=0,L=0;for(const[R,P]of Object.entries(E)){const E=addAttribute(w,_,C,R,P);E===_e.ADD_NEW?C+=1:(E===_e.DROP_INVALID||E===_e.DROP_LIMIT_REACHED)&&(L+=1)}return{attributes:C>0?w:void 0,droppedAttributesCount:L}}!function(_){_[_.DROP_INVALID=0]="DROP_INVALID",_[_.DROP_LIMIT_REACHED=1]="DROP_LIMIT_REACHED",_[_.ADD_NEW=2]="ADD_NEW",_[_.ADD_OVERWRITE_EXISTING=3]="ADD_OVERWRITE_EXISTING"}(_e||(_e={}));class LogRecordImpl{set severityText(_){this._isLogRecordReadonly()||(this._severityText=_)}get severityText(){return this._severityText}set severityNumber(_){this._isLogRecordReadonly()||(this._severityNumber=_)}get severityNumber(){return this._severityNumber}set body(_){this._isLogRecordReadonly()||(this._body=_)}get body(){return this._body}get eventName(){return this._eventName}set eventName(_){this._isLogRecordReadonly()||(this._eventName=_)}get droppedAttributesCount(){return this._droppedAttributesCount}constructor(_,E,w){this.attributes={},this._attributesCount=0,this._droppedAttributesCount=0,this._isReadonly=!1;const{timestamp:C,observedTimestamp:L,eventName:R,severityNumber:P,severityText:I,body:k,attributes:F={},exception:$,context:V}=w,H=Date.now();if(this.hrTime=timeInputToHrTime(C??H),this.hrTimeObserved=timeInputToHrTime(L??H),V){const _=It.getSpanContext(V);_&&isSpanContextValid(_)&&(this.spanContext=_)}this.severityNumber=P,this.severityText=I,this.body=k,this.resource=_.resource,this.instrumentationScope=E,this._logRecordLimits=_.logRecordLimits,this._eventName=R,this.setAttributes(F),null!=$&&this._setException($)}setAttribute(_,E){if(this._isLogRecordReadonly())return this;const w=addAttribute(this.attributes,this._logRecordLimits,this._attributesCount,_,E);return w===_e.DROP_LIMIT_REACHED?(this._droppedAttributesCount++,1===this._droppedAttributesCount&&vt.warn("Dropping extra attributes.")):w===_e.ADD_NEW&&this._attributesCount++,this}setAttributes(_){for(const[E,w]of Object.entries(_))this.setAttribute(E,w);return this}setBody(_){return this.body=_,this}setEventName(_){return this.eventName=_,this}setSeverityNumber(_){return this.severityNumber=_,this}setSeverityText(_){return this.severityText=_,this}_makeReadonly(){this._isReadonly=!0}_setException(_){let E=!1;if("string"==typeof _||"number"==typeof _)Object.hasOwn(this.attributes,Wt)||this.setAttribute(Wt,String(_)),E=!0;else if(_&&"object"==typeof _){const w=_;w.code?(Object.hasOwn(this.attributes,Qt)||this.setAttribute(Qt,w.code.toString()),E=!0):w.name&&(Object.hasOwn(this.attributes,Qt)||this.setAttribute(Qt,w.name),E=!0),w.message&&(Object.hasOwn(this.attributes,Wt)||this.setAttribute(Wt,w.message),E=!0),w.stack&&(Object.hasOwn(this.attributes,Kt)||this.setAttribute(Kt,w.stack),E=!0)}E||vt.warn(`Failed to record an exception ${_}`)}_isLogRecordReadonly(){return this._isReadonly&&vt.warn("Can not execute the operation on emitted log record"),this._isReadonly}}class Logger{constructor(_,E){this._instrumentationScope=_,this._sharedState=E,this._loggerConfig=this._sharedState.getLoggerConfig(this._instrumentationScope)}emit(_){const E=_.context||Tt.active();if(!this.enabled(_))return;const w=new LogRecordImpl(this._sharedState,this._instrumentationScope,{context:E,..._});this._sharedState.loggerMetrics.emitLog(),this._sharedState.activeProcessor.onEmit(w,E),w._makeReadonly()}enabled(_){if(this._sharedState.hasShutdown)return!1;const E=this._loggerConfig;if(E.disabled)return!1;const w=_?.severityNumber;if("number"==typeof w&&w!==R.UNSPECIFIED&&w<E.minimumSeverity)return!1;const C=_?.context||Tt.active();if(E.traceBased){const _=It.getSpanContext(C);if(_&&isSpanContextValid(_)){if(!((_.traceFlags<.SAMPLED)===lt.SAMPLED))return!1}}const L={context:C,instrumentationScope:this._instrumentationScope,severityNumber:_?.severityNumber,eventName:_?.eventName};for(const _ of this._sharedState.processors)if(!_.enabled||_.enabled(L))return!0;return!1}}class NoopLogRecordProcessor{forceFlush(){return Promise.resolve()}onEmit(_,E){}shutdown(){return Promise.resolve()}enabled(_){return!1}}class MultiLogRecordProcessor{constructor(_,E){this.processors=_,this.forceFlushTimeoutMillis=E}async forceFlush(){const _=this.forceFlushTimeoutMillis;await Promise.all(this.processors.map((E=>function callWithTimeout(_,E){let w;const C=new Promise((function timeoutFunction(_,C){w=setTimeout((function timeoutHandler(){C(new TimeoutError("Operation timed out."))}),E)}));return Promise.race([_,C]).then((_=>(clearTimeout(w),_)),(_=>{throw clearTimeout(w),_}))}(E.forceFlush(),_))))}onEmit(_,E){this.processors.forEach((w=>w.onEmit(_,E)))}async shutdown(){await Promise.all(this.processors.map((_=>_.shutdown())))}enabled(_){for(const E of this.processors)if(!E.enabled||E.enabled(_))return!0;return!1}}function normalizeAnyValue(_){if(void 0===_)return["u",null];if(null===_)return["n",null];const E=typeof _;return"string"===E?["s",_]:"boolean"===E?["b",_]:"number"===E?Number.isNaN(_)?["nan",null]:_===1/0?["inf",null]:_===-1/0?["-inf",null]:Object.is(_,-0)?["n0",null]:["d",_]:_ instanceof Uint8Array?["bytes",Array.from(_)]:Array.isArray(_)?["arr",_.map(normalizeAnyValue)]:["map",Object.entries(_).sort((([_],[E])=>_.localeCompare(E))).map((([_,E])=>[_,normalizeAnyValue(E)]))]}function getInstrumentationScopeKey(_){return JSON.stringify([_.name,_.version||"",_.schemaUrl||"",normalizeAnyValue(_.attributes),_.droppedAttributesCount??0])}class LoggerMetrics{constructor(_){this.createdLogs=_.createCounter("otel.sdk.log.created",{unit:"{log_record}",description:"The number of logs submitted to enabled SDK Loggers."})}emitLog(){this.createdLogs.add(1)}}const be={disabled:!1,minimumSeverity:R.UNSPECIFIED,traceBased:!1},DEFAULT_LOGGER_CONFIGURATOR=()=>({...be});class LoggerProviderSharedState{constructor(_,E,w,C,L,R){this.loggers=new Map,this.registeredLogRecordProcessors=[],this.hasShutdown=!1,this._loggerConfigs=new Map,this.resource=_,this.forceFlushTimeoutMillis=E,this.logRecordLimits=w,this.processors=C,C.length>0?(this.registeredLogRecordProcessors=C,this.activeProcessor=new MultiLogRecordProcessor(this.registeredLogRecordProcessors,this.forceFlushTimeoutMillis)):this.activeProcessor=new NoopLogRecordProcessor,this._loggerConfigurator=L??DEFAULT_LOGGER_CONFIGURATOR;const P=R?R.getMeter("@opentelemetry/sdk-logs","0.220.0"):createNoopMeter();this.loggerMetrics=new LoggerMetrics(P)}getLoggerConfig(_){const E=getInstrumentationScopeKey(_);let w=this._loggerConfigs.get(E);return w||(w=this._loggerConfigurator(_),this._loggerConfigs.set(E,w),w)}}class LoggerProvider{constructor(_={}){const E={resource:_.resource??defaultResource$1(),forceFlushTimeoutMillis:_.forceFlushTimeoutMillis??3e4,logRecordLimits:{attributeCountLimit:_.logRecordLimits?.attributeCountLimit??128,attributeValueLengthLimit:_.logRecordLimits?.attributeValueLengthLimit??1/0},loggerConfigurator:_.loggerConfigurator??DEFAULT_LOGGER_CONFIGURATOR,processors:_.processors??[],meterProvider:_.meterProvider};this._sharedState=new LoggerProviderSharedState(E.resource,E.forceFlushTimeoutMillis,E.logRecordLimits,E.processors,E.loggerConfigurator,E.meterProvider),this._shutdownOnce=new me(this._shutdown,this)}getLogger(_,E,w){if(this._shutdownOnce.isCalled)return vt.warn("A shutdown LoggerProvider cannot provide a Logger"),function createNoopLogger(){return P}();_||vt.warn("Logger requested without instrumentation scope name.");const C={name:_||"unknown",version:E,schemaUrl:w?.schemaUrl,...normalizeScopeAttributes(this._sharedState.logRecordLimits,w?.attributes)},L=getInstrumentationScopeKey(C);return this._sharedState.loggers.has(L)||this._sharedState.loggers.set(L,new Logger(C,this._sharedState)),this._sharedState.loggers.get(L)}forceFlush(){return this._shutdownOnce.isCalled?(vt.warn("invalid attempt to force flush after LoggerProvider shutdown"),this._shutdownOnce.promise):this._sharedState.activeProcessor.forceFlush()}shutdown(){return this._shutdownOnce.isCalled?(vt.warn("shutdown may only be called once per LoggerProvider"),this._shutdownOnce.promise):this._shutdownOnce.call()}_shutdown(){return this._sharedState.hasShutdown=!0,this._sharedState.activeProcessor.shutdown()}}class ExportOperation{constructor(_,E,w){this._exportScheduledPromise=new Promise((_=>{this._exportScheduledResolve=_})),this._exportCompleted=this._executeExport(_,E,w)}get exportCompleted(){return this._exportCompleted}get exportScheduled(){return this._exportScheduledPromise}async _executeExport(_,E,w){try{await async function waitForResources(_){const E=[];for(let w=0,C=_.length;w<C;w++){const C=_[w];C.resource.asyncAttributesPending&&C.resource.waitForAsyncAttributes&&E.push(C.resource.waitForAsyncAttributes())}null!=E&&E.length>0&&await Promise.all(E)}(E),await Tt.with(function suppressTracing$1(_){return _.setValue(zt,!0)}(Tt.active()),(async()=>this._exportWithTimeout(_,E,w)))}catch(_){globalErrorHandler$1(_),this._exportScheduledResolve()}}async _exportWithTimeout(_,E,w){return new Promise(((C,L)=>{const R=setTimeout((()=>{L(new Error("Timeout"))}),w);_.export(E,(_=>{clearTimeout(R),_.code===he.SUCCESS?C():L(_.error??new Error("BatchLogRecordProcessor: log record export failed"))})),this._exportScheduledResolve()}))}}class BatchLogRecordProcessorBase{constructor(_){this._currentExport=null,this._finishedLogRecords=[],this._flushing=!1,this._exporter=_.exporter,this._maxExportBatchSize=_.maxExportBatchSize??512,this._maxQueueSize=_.maxQueueSize??2048,this._scheduledDelayMillis=_.scheduledDelayMillis??1e3,this._exportTimeoutMillis=_.exportTimeoutMillis??3e4,this._shutdownOnce=new me(this._shutdown,this),this._maxExportBatchSize>this._maxQueueSize&&(vt.warn("BatchLogRecordProcessor: maxExportBatchSize must be smaller or equal to maxQueueSize, setting maxExportBatchSize to match maxQueueSize"),this._maxExportBatchSize=this._maxQueueSize)}onEmit(_){this._shutdownOnce.isCalled||this._addToBuffer(_)}forceFlush(){return this._shutdownOnce.isCalled?this._shutdownOnce.promise:this._flushAll()}_addToBuffer(_){this._finishedLogRecords.length>=this._maxQueueSize||(this._finishedLogRecords.push(_),this._maybeStartTimer())}shutdown(){return this._shutdownOnce.call()}async _shutdown(){this.onShutdown(),await this._flushAll(),await this._exporter.shutdown()}async _flushAll(){if(this._flushing)return;this._flushing=!0;let _=this._finishedLogRecords;this._finishedLogRecords=[],this._clearTimer();const E=this._currentExport;for(null!==E&&(await this._exporter.forceFlush(),await E.exportCompleted,this._currentExport=null);_.length>0;){let E;_.length<=this._maxExportBatchSize?(E=_,_=[]):E=_.splice(0,this._maxExportBatchSize);const w=new ExportOperation(this._exporter,E,this._exportTimeoutMillis);this._currentExport=w;try{await w.exportScheduled,await this._exporter.forceFlush(),await w.exportCompleted}catch(_){globalErrorHandler$1(_)}finally{this._currentExport=null}}this._flushing=!1,this._maybeStartTimer()}_extractBatch(){if(0===this._finishedLogRecords.length)return null;if(this._finishedLogRecords.length<=this._maxExportBatchSize){const _=this._finishedLogRecords;return this._finishedLogRecords=[],_}return this._finishedLogRecords.splice(0,this._maxExportBatchSize)}_exportOneBatch(){this._clearTimer();const _=this._extractBatch();if(null===_)return;const E=new ExportOperation(this._exporter,_,this._exportTimeoutMillis);this._currentExport=E,E.exportCompleted.then((()=>{this._currentExport=null,this._maybeStartTimer()})).catch((_=>{this._currentExport=null,globalErrorHandler$1(_),this._maybeStartTimer()}))}_maybeStartTimer(){this._shutdownOnce.isCalled||this._flushing||0!==this._finishedLogRecords.length&&null===this._currentExport&&(this._finishedLogRecords.length>=this._maxExportBatchSize?this._exportOneBatch():void 0===this._timer&&(this._timer=setTimeout((()=>{this._timer=void 0,this._exportOneBatch()}),this._scheduledDelayMillis),"number"!=typeof this._timer&&this._timer.unref()))}_clearTimer(){void 0!==this._timer&&(clearTimeout(this._timer),this._timer=void 0)}}class BatchLogRecordProcessor extends BatchLogRecordProcessorBase{constructor(_){super(_),this._onInit(_)}onShutdown(){"undefined"!=typeof document&&(this._visibilityChangeListener&&document.removeEventListener("visibilitychange",this._visibilityChangeListener),this._pageHideListener&&document.removeEventListener("pagehide",this._pageHideListener))}_onInit(_){!0!==_.disableAutoFlushOnDocumentHide&&"undefined"!=typeof document&&(this._visibilityChangeListener=()=>{"hidden"===document.visibilityState&&this.forceFlush()},this._pageHideListener=()=>{this.forceFlush()},document.addEventListener("visibilitychange",this._visibilityChangeListener),document.addEventListener("pagehide",this._pageHideListener))}}const ye="service.name",isPromiseLike$1=_=>null!==_&&"object"==typeof _&&"function"==typeof _.then;let Se=class ResourceImpl{static FromAttributeList(_,E){const w=new ResourceImpl({},E);return w._rawAttributes=guardedRawAttributes$1(_),w._asyncAttributesPending=_.filter((([_,E])=>isPromiseLike$1(E))).length>0,w}constructor(_,E){this._asyncAttributesPending=!1;const w=_.attributes??{};this._rawAttributes=Object.entries(w).map((([_,E])=>(isPromiseLike$1(E)&&(this._asyncAttributesPending=!0),[_,E]))),this._rawAttributes=guardedRawAttributes$1(this._rawAttributes),this._schemaUrl=function validateSchemaUrl$1(_){if("string"==typeof _||void 0===_)return _;return void vt.warn("Schema URL must be string or undefined, got %s. Schema URL will be ignored.",_)}(E?.schemaUrl)}get asyncAttributesPending(){return this._asyncAttributesPending}async waitForAsyncAttributes(){if(this.asyncAttributesPending){for(let _=0;_<this._rawAttributes.length;_++){const[E,w]=this._rawAttributes[_];this._rawAttributes[_]=[E,isPromiseLike$1(w)?await w:w]}this._asyncAttributesPending=!1}}get attributes(){if(this.asyncAttributesPending&&vt.error("Accessing resource attributes before async attributes settled"),this._memoizedAttributes)return this._memoizedAttributes;const _={};for(const[E,w]of this._rawAttributes)isPromiseLike$1(w)?vt.debug(`Unsettled resource attribute ${E} skipped`):null!=w&&(_[E]??(_[E]=w));return this._asyncAttributesPending||(this._memoizedAttributes=_),_}getRawAttributes(){return this._rawAttributes}get schemaUrl(){return this._schemaUrl}merge(_){if(null==_)return this;const E=function mergeSchemaUrl$1(_,E){const w=_?.schemaUrl,C=E?.schemaUrl,L=void 0===w||""===w,R=void 0===C||""===C;if(L)return C;if(R)return w;if(w===C)return w;return void vt.warn('Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.',w,C)}(this,_),w=E?{schemaUrl:E}:void 0;return ResourceImpl.FromAttributeList([..._.getRawAttributes(),...this.getRawAttributes()],w)}};function resourceFromAttributes$1(_,E){return Se.FromAttributeList(Object.entries(_),E)}function guardedRawAttributes$1(_){return _.map((([_,E])=>isPromiseLike$1(E)?[_,E.catch((E=>{vt.debug("promise rejection for resource attribute: %s - %s",_,E)}))]:[_,E]))}function estimateVarintSize(_){return _<0?10:_<128?1:_<16384?2:_<2097152?3:_<268435456?4:_<34359738368?5:_<4398046511104?6:_<562949953421312?7:_<72057594037927940?8:9}class ProtobufWriter{constructor(_=65536){this.pos=0,this._buffer=new Uint8Array(_),this._textEncoder=new TextEncoder,this._dataView=new DataView(this._buffer.buffer,this._buffer.byteOffset)}_ensureCapacity(_){const E=this.pos+_;if(E<=this._buffer.length)return;vt.debug("ProtobufWriter: estimated size was too small, growing buffer.");let w=2*this._buffer.length;for(;w<E;)w*=2;const C=new Uint8Array(w);C.set(this._buffer),this._buffer=C,this._dataView=new DataView(this._buffer.buffer,this._buffer.byteOffset)}finish(){return this._buffer.subarray(0,this.pos)}startLengthDelimited(){const _=this.pos;return this._ensureCapacity(1),this.pos+=1,_}finishLengthDelimited(_,E){const w=E>>>0,C=estimateVarintSize(w);if(C>1){const E=C-1;this._ensureCapacity(E),this._buffer.copyWithin(_+C,_+1,this.pos),this.pos+=E}let L=_;w<128?this._buffer[L]=w:w<16384?(this._buffer[L++]=127&w|128,this._buffer[L]=w>>>7):w<2097152?(this._buffer[L++]=127&w|128,this._buffer[L++]=w>>>7&127|128,this._buffer[L]=w>>>14):w<268435456?(this._buffer[L++]=127&w|128,this._buffer[L++]=w>>>7&127|128,this._buffer[L++]=w>>>14&127|128,this._buffer[L]=w>>>21):(this._buffer[L++]=127&w|128,this._buffer[L++]=w>>>7&127|128,this._buffer[L++]=w>>>14&127|128,this._buffer[L++]=w>>>21&127|128,this._buffer[L]=w>>>28)}writeSint32(_){this.writeVarint((_<<1^_>>31)>>>0)}writeSfixed64(_){let E,w;if(_>=0)E=_>>>0,w=_/4294967296>>>0;else{const C=Math.abs(_);E=C>>>0,w=C/4294967296>>>0,E=~E>>>0,w=~w>>>0,E=E+1>>>0,0===E&&(w=w+1>>>0)}this.writeFixed64(E,w)}writeVarint(_){if(this._ensureCapacity(estimateVarintSize(_)),_>=0&&_<=4294967295){let E=_>>>0;for(;E>127;)this._buffer[this.pos++]=127&E|128,E>>>=7;this._buffer[this.pos++]=E}else{let E,w;if(_>=0)E=_>>>0,w=_/4294967296>>>0;else{const C=Math.abs(_);E=C>>>0,w=C/4294967296>>>0,E=~E>>>0,w=~w>>>0,E=E+1>>>0,0===E&&(w=w+1>>>0)}for(;w>0||E>127;)this._buffer[this.pos++]=127&E|128,E=(E>>>7|w<<25)>>>0,w>>>=7;this._buffer[this.pos++]=127&E}}writeFixed32(_){this._ensureCapacity(4);const E=_>>>0;this._buffer[this.pos++]=255&E,this._buffer[this.pos++]=E>>>8&255,this._buffer[this.pos++]=E>>>16&255,this._buffer[this.pos++]=E>>>24&255}writeFixed64(_,E){this._ensureCapacity(8);const w=_>>>0,C=E>>>0;this._buffer[this.pos++]=255&w,this._buffer[this.pos++]=w>>>8&255,this._buffer[this.pos++]=w>>>16&255,this._buffer[this.pos++]=w>>>24&255,this._buffer[this.pos++]=255&C,this._buffer[this.pos++]=C>>>8&255,this._buffer[this.pos++]=C>>>16&255,this._buffer[this.pos++]=C>>>24&255}writeBytes(_){this.writeVarint(_.length),this._ensureCapacity(_.length),this._buffer.set(_,this.pos),this.pos+=_.length}writeTag(_,E){this.writeVarint(_<<3|E)}writeDouble(_){this._ensureCapacity(8),this._dataView.setFloat64(this.pos,_,!0),this.pos+=8}writeString(_){let E=!0;const w=_.length;for(let C=0;C<w;C++)if(_.charCodeAt(C)>127){E=!1;break}if(E){this.writeVarint(w),this._ensureCapacity(w);for(let E=0;E<w;E++)this._buffer[this.pos++]=_.charCodeAt(E)}else{const E=this._textEncoder.encode(_);this.writeBytes(E)}}}function intValue(_){return _>=48&&_<=57?_-48:_>=97&&_<=102?_-87:_-55}function hexToBinary(_){const E=new Uint8Array(_.length/2);let w=0;for(let C=0;C<_.length;C+=2){const L=intValue(_.charCodeAt(C)),R=intValue(_.charCodeAt(C+1));E[w++]=L<<4|R}return E}function writeHrTimeAsFixed64(_,E){const w=E[0],C=1e9,L=(65535&w)*C,R=(w/65536>>>0)*C,P=(L>>>0)+(65536*(65535&R)>>>0)+E[1],I=P>>>0,k=Math.floor(L/4294967296)+(R/65536>>>0)+Math.floor(P/4294967296)>>>0;_.writeFixed64(I,k)}function writeAttributes(_,E,w){for(const C in E){if(!Object.prototype.hasOwnProperty.call(E,C))continue;const L=E[C];_.writeTag(w,2);const R=_.startLengthDelimited(),P=_.pos;writeKeyValue(_,C,L),_.finishLengthDelimited(R,_.pos-P)}}function writeKeyValue(_,E,w){_.writeTag(1,2),_.writeString(E),_.writeTag(2,2);const C=_.startLengthDelimited(),L=_.pos;writeAnyValue(_,w),_.finishLengthDelimited(C,_.pos-L)}const Ee=-0x8000000000000000,Te=2**63;function writeAnyValue(_,E){const w=typeof E;if("string"===w)_.writeTag(1,2),_.writeString(E);else if("boolean"===w)_.writeTag(2,0),_.writeVarint(E?1:0);else if("number"===w){const w=E;Number.isInteger(w)&&w>=Ee&&w<Te?(_.writeTag(3,0),_.writeVarint(w)):(_.writeTag(4,1),_.writeDouble(w))}else if(E instanceof Uint8Array)_.writeTag(7,2),_.writeBytes(E);else if(Array.isArray(E)){_.writeTag(5,2);const w=_.startLengthDelimited(),C=_.pos;for(const w of E){_.writeTag(1,2);const E=_.startLengthDelimited(),C=_.pos;writeAnyValue(_,w),_.finishLengthDelimited(E,_.pos-C)}_.finishLengthDelimited(w,_.pos-C)}else if("object"===w&&null!=E){_.writeTag(6,2);const w=_.startLengthDelimited(),C=_.pos,L=E;for(const E in L){if(!Object.prototype.hasOwnProperty.call(L,E))continue;const w=L[E];_.writeTag(1,2);const C=_.startLengthDelimited(),R=_.pos;_.writeTag(1,2),_.writeString(E),_.writeTag(2,2);const P=_.startLengthDelimited(),I=_.pos;writeAnyValue(_,w),_.finishLengthDelimited(P,_.pos-I),_.finishLengthDelimited(C,_.pos-R)}_.finishLengthDelimited(w,_.pos-C)}}class ProtobufSizeEstimator{constructor(){this.pos=0}startLengthDelimited(){return this.pos}finishLengthDelimited(_,E){this.pos+=estimateVarintSize(E)}writeVarint(_){this.pos+=estimateVarintSize(_)}writeSint32(_){this.pos+=estimateVarintSize((_<<1^_>>31)>>>0)}writeSfixed64(_){this.pos+=8}writeFixed32(_){this.pos+=4}writeFixed64(_,E){this.pos+=8}writeBytes(_){this.pos+=estimateVarintSize(_.length),this.pos+=_.length}writeTag(_,E){this.writeVarint(_<<3|E)}writeDouble(_){this.pos+=8}writeString(_){const E=function utf8ByteLength(_){const E=_.length;let w=0;for(let C=0;C<E;C++){const E=_.charCodeAt(C);E<128?w+=1:E<2048?w+=2:E<55296||E>=57344?w+=3:(C++,w+=4)}return w}(_);this.pos+=estimateVarintSize(E),this.pos+=E}}class ProtobufReader{constructor(_){this.pos=0,this._buf=_,this._textDecoder=new TextDecoder}isAtEnd(){return this.pos>=this._buf.length}readTag(){const _=this.readVarint();return{fieldNumber:_>>>3,wireType:7&_}}readVarint(){let _=0,E=0,w=!1;for(;this.pos<this._buf.length;){const C=this._buf[this.pos++];if(_+=(127&C)*Math.pow(2,E),E+=7,!(128&C)){w=!0;break}}if(!w)throw new Error("Truncated buffer: unexpected end of data while reading varint");return _}readBytes(){const _=this.readVarint();if(this.pos+_>this._buf.length)throw new Error(`Truncated buffer: expected ${_} bytes at position ${this.pos}, but only ${this._buf.length-this.pos} available`);const E=this._buf.subarray(this.pos,this.pos+_);return this.pos+=_,E}readString(){return this._textDecoder.decode(this.readBytes())}skip(_){switch(_){case 0:this.readVarint();break;case 1:this.pos+=8;break;case 2:this.readBytes();break;case 5:this.pos+=4;break;default:throw new Error(`Unknown wire type ${_}, cannot safely skip`)}}}function buildSpanFlags(_,E){let w=255&_|256;return E&&(w|=512),w}function serializeEvent(_,E){const w=_.startLengthDelimited(),C=_.pos;_.writeTag(1,1),writeHrTimeAsFixed64(_,E.time),_.writeTag(2,2),_.writeString(E.name),E.attributes&&writeAttributes(_,E.attributes,3),_.writeTag(4,0),_.writeVarint(E.droppedAttributesCount||0),_.finishLengthDelimited(w,_.pos-C)}function serializeLink(_,E){const w=_.startLengthDelimited(),C=_.pos,L=E.context;_.writeTag(1,2),_.writeBytes(hexToBinary(L.traceId)),_.writeTag(2,2),_.writeBytes(hexToBinary(L.spanId));const R=L.traceState?.serialize();R&&(_.writeTag(3,2),_.writeString(R)),E.attributes&&writeAttributes(_,E.attributes,4),_.writeTag(5,0),_.writeVarint(E.droppedAttributesCount||0);const P=buildSpanFlags(L.traceFlags,L.isRemote);P&&(_.writeTag(6,5),_.writeFixed32(P)),_.finishLengthDelimited(w,_.pos-C)}function serializeSpan(_,E){const w=_.startLengthDelimited(),C=_.pos,L=E.spanContext();_.writeTag(1,2),_.writeBytes(hexToBinary(L.traceId)),_.writeTag(2,2),_.writeBytes(hexToBinary(L.spanId));const R=L.traceState?.serialize();R&&(_.writeTag(3,2),_.writeString(R)),E.parentSpanContext?.spanId&&(_.writeTag(4,2),_.writeBytes(hexToBinary(E.parentSpanContext.spanId))),_.writeTag(5,2),_.writeString(E.name);const P=null==E.kind?0:E.kind+1;0!==P&&(_.writeTag(6,0),_.writeVarint(P)),_.writeTag(7,1),writeHrTimeAsFixed64(_,E.startTime),_.writeTag(8,1),writeHrTimeAsFixed64(_,E.endTime),E.attributes&&writeAttributes(_,E.attributes,9),_.writeTag(10,0),_.writeVarint(E.droppedAttributesCount);for(const w of E.events)_.writeTag(11,2),serializeEvent(_,w);_.writeTag(12,0),_.writeVarint(E.droppedEventsCount);for(const w of E.links)_.writeTag(13,2),serializeLink(_,w);_.writeTag(14,0),_.writeVarint(E.droppedLinksCount),_.writeTag(15,2),function serializeStatus(_,E){const w=_.startLengthDelimited(),C=_.pos;E.message&&(_.writeTag(2,2),_.writeString(E.message)),_.writeTag(3,0),_.writeVarint(E.code),_.finishLengthDelimited(w,_.pos-C)}(_,E.status);const I=buildSpanFlags(L.traceFlags,E.parentSpanContext?.isRemote);I&&(_.writeTag(16,5),_.writeFixed32(I)),_.finishLengthDelimited(w,_.pos-C)}function serializeScopeSpans(_,E,w){const C=_.startLengthDelimited(),L=_.pos;!function writeInstrumentationScope(_,E,w){_.writeTag(w,2);const C=_.startLengthDelimited(),L=_.pos;_.writeTag(1,2),_.writeString(E.name),E.version&&(_.writeTag(2,2),_.writeString(E.version)),E.attributes&&writeAttributes(_,E.attributes,3),E.droppedAttributesCount&&(_.writeTag(4,0),_.writeVarint(E.droppedAttributesCount)),_.finishLengthDelimited(C,_.pos-L)}(_,E,1);for(const E of w)_.writeTag(2,2),serializeSpan(_,E);E.schemaUrl&&(_.writeTag(3,2),_.writeString(E.schemaUrl)),_.finishLengthDelimited(C,_.pos-L)}function serializeResourceSpans(_,E,w){const C=_.startLengthDelimited(),L=_.pos;!function writeResource(_,E,w){_.writeTag(w,2);const C=_.startLengthDelimited(),L=_.pos;E.attributes&&writeAttributes(_,E.attributes,1),_.writeTag(2,0),_.writeVarint(0),_.finishLengthDelimited(C,_.pos-L)}(_,E,1);for(const E of w.values()){_.writeTag(2,2);serializeScopeSpans(_,E[0].instrumentationScope,E)}E.schemaUrl&&(_.writeTag(3,2),_.writeString(E.schemaUrl)),_.finishLengthDelimited(C,_.pos-L)}function serializeTraceExportRequest(_){const E=function createResourceMap$2(_){const E=new Map;for(const w of _){const _=w.resource,C=w.instrumentationScope;let L=E.get(_);L||(L=new Map,E.set(_,L));let R=L.get(C);R||(R=[],L.set(C,R)),R.push(w)}return E}(_),w=new ProtobufSizeEstimator;for(const[_,C]of E)w.writeTag(1,2),serializeResourceSpans(w,_,C);const C=new ProtobufWriter(w.pos);for(const[_,w]of E)C.writeTag(1,2),serializeResourceSpans(C,_,w);return C.finish()}function deserializePartialSuccess(_){const E=new ProtobufReader(_),w={};for(;!E.isAtEnd();){const{fieldNumber:_,wireType:C}=E.readTag();switch(_){case 1:0===C?w.rejectedSpans=E.readVarint():E.skip(C);break;case 2:2===C?w.errorMessage=E.readString():E.skip(C);break;default:E.skip(C)}}return w}const ve={serializeRequest:_=>serializeTraceExportRequest(_),deserializeResponse:_=>function deserializeExportTraceServiceResponse(_){const E=new ProtobufReader(_),w={};for(;!E.isAtEnd();){const{fieldNumber:_,wireType:C}=E.readTag();1===_&&2===C?w.partialSuccess=deserializePartialSuccess(E.readBytes()):E.skip(C)}return w}(_)};function createResource(_,E){const w={attributes:toAttributes(_.attributes,E),droppedAttributesCount:0},C=_.schemaUrl;return C&&""!==C&&(w.schemaUrl=C),w}function createInstrumentationScope(_,E){const w={name:_.name,version:_.version};return _.attributes&&Object.keys(_.attributes).length>0&&(w.attributes=toAttributes(_.attributes,E),w.droppedAttributesCount=_.droppedAttributesCount??0),w}function toAttributes(_,E){return Object.keys(_).map((w=>function toKeyValue(_,E,w){return{key:_,value:toAnyValue(E,w)}}(w,_[w],E)))}function toAnyValue(_,E){const w=typeof _;if("string"===w)return{stringValue:_};if("number"===w)return Number.isInteger(_)?{intValue:_}:{doubleValue:_};if("boolean"===w)return{boolValue:_};if(_ instanceof Uint8Array)return{bytesValue:E.encodeUint8Array(_)};if(Array.isArray(_)){const w=new Array(_.length);for(let C=0;C<_.length;C++)w[C]=toAnyValue(_[C],E);return{arrayValue:{values:w}}}if("object"===w&&null!=_){const w=Object.keys(_),C=new Array(w.length);for(let L=0;L<w.length;L++)C[L]={key:w[L],value:toAnyValue(_[w[L]],E)};return{kvlistValue:{values:C}}}return{}}function logRecordsToResourceLogs(_,E){const w=function createResourceMap$1(_){const E=new Map;for(const w of _){const{resource:_,instrumentationScope:C}=w;let L=E.get(_);L||(L=new Map,E.set(_,L));let R=L.get(C);R||(R=[],L.set(C,R)),R.push(w)}return E}(_);return Array.from(w,(([_,w])=>{const C=createResource(_,E);return{resource:C,scopeLogs:Array.from(w,(([,_])=>({scope:createInstrumentationScope(_[0].instrumentationScope,E),logRecords:_.map((_=>function toLogRecord(_,E){return{timeUnixNano:E.encodeHrTime(_.hrTime),observedTimeUnixNano:E.encodeHrTime(_.hrTimeObserved),severityNumber:_.severityNumber,severityText:_.severityText,body:toAnyValue(_.body,E),eventName:_.eventName,attributes:toAttributes(_.attributes,E),droppedAttributesCount:_.droppedAttributesCount,flags:_.spanContext?.traceFlags,traceId:E.encodeOptionalSpanContext(_.spanContext?.traceId),spanId:E.encodeOptionalSpanContext(_.spanContext?.spanId)}}(_,E))),schemaUrl:_[0].instrumentationScope.schemaUrl}))),schemaUrl:C.schemaUrl}}))}const we="undefined"!=typeof BigInt?function encodeAsString(_){const E=function hrTimeToNanos(_){const E=BigInt(1e9);return BigInt(Math.trunc(_[0]))*E+BigInt(Math.trunc(_[1]))}(_);return E.toString()}:hrTimeToNanoseconds;function identity(_){return _}const Ae={encodeHrTime:we,encodeSpanContext:identity,encodeOptionalSpanContext:identity,encodeUint8Array:_=>{if("undefined"!=typeof Buffer)return Buffer.from(_).toString("base64");const E=new Array(_.length);for(let w=0;w<_.length;w++)E[w]=String.fromCharCode(_[w]);return btoa(E.join(""))}},Ce={serializeRequest:_=>{const E=function createExportLogsServiceRequest(_,E){return{resourceLogs:logRecordsToResourceLogs(_,E)}}(_,Ae);return(new TextEncoder).encode(JSON.stringify(E))},deserializeResponse:_=>{if(0===_.length)return{};const E=new TextDecoder;try{return JSON.parse(E.decode(_))}catch(_){return vt.warn(`Failed to parse logs export response: ${_.message}. Returning empty response`),{}}}};function buildSpanFlagsFrom(_,E){let w=255&_|256;return E&&(w|=512),w}function sdkSpanToOtlpSpan(_,E){const w=_.spanContext(),C=_.status,L=_.parentSpanContext?.spanId?E.encodeSpanContext(_.parentSpanContext?.spanId):void 0;return{traceId:E.encodeSpanContext(w.traceId),spanId:E.encodeSpanContext(w.spanId),parentSpanId:L,traceState:w.traceState?.serialize(),name:_.name,kind:null==_.kind?0:_.kind+1,startTimeUnixNano:E.encodeHrTime(_.startTime),endTimeUnixNano:E.encodeHrTime(_.endTime),attributes:toAttributes(_.attributes,E),droppedAttributesCount:_.droppedAttributesCount,events:_.events.map((_=>function toOtlpSpanEvent(_,E){return{attributes:_.attributes?toAttributes(_.attributes,E):[],name:_.name,timeUnixNano:E.encodeHrTime(_.time),droppedAttributesCount:_.droppedAttributesCount||0}}(_,E))),droppedEventsCount:_.droppedEventsCount,status:{code:C.code,message:C.message},links:_.links.map((_=>function toOtlpLink(_,E){return{attributes:_.attributes?toAttributes(_.attributes,E):[],spanId:E.encodeSpanContext(_.context.spanId),traceId:E.encodeSpanContext(_.context.traceId),traceState:_.context.traceState?.serialize(),droppedAttributesCount:_.droppedAttributesCount||0,flags:buildSpanFlagsFrom(_.context.traceFlags,_.context.isRemote)}}(_,E))),droppedLinksCount:_.droppedLinksCount,flags:buildSpanFlagsFrom(w.traceFlags,_.parentSpanContext?.isRemote)}}function spanRecordsToResourceSpans(_,E){const w=function createResourceMap(_){const E=new Map;for(const w of _){let _=E.get(w.resource);_||(_=new Map,E.set(w.resource,_));const C=`${w.instrumentationScope.name}@${w.instrumentationScope.version||""}:${w.instrumentationScope.schemaUrl||""}`;let L=_.get(C);L||(L=[],_.set(C,L)),L.push(w)}return E}(_),C=[],L=w.entries();let R=L.next();for(;!R.done;){const[_,w]=R.value,P=[],I=w.values();let k=I.next();for(;!k.done;){const _=k.value;if(_.length>0){const w=_.map((_=>sdkSpanToOtlpSpan(_,E)));P.push({scope:createInstrumentationScope(_[0].instrumentationScope,E),spans:w,schemaUrl:_[0].instrumentationScope.schemaUrl})}k=I.next()}const F=createResource(_,E),$={resource:F,scopeSpans:P,schemaUrl:F.schemaUrl};C.push($),R=L.next()}return C}const Le={serializeRequest:_=>{const E=function createExportTraceServiceRequest(_,E){return{resourceSpans:spanRecordsToResourceSpans(_,E)}}(_,Ae);return(new TextEncoder).encode(JSON.stringify(E))},deserializeResponse:_=>{if(0===_.length)return{};const E=new TextDecoder;try{return JSON.parse(E.decode(_))}catch(_){return vt.warn(`Failed to parse trace export response: ${_.message}. Returning empty response`),{}}}};class OTLPExporterBase{constructor(_){this._delegate=_}export(_,E){this._delegate.export(_,E)}forceFlush(){return this._delegate.forceFlush()}shutdown(){return this._delegate.shutdown()}}class OTLPExporterError extends Error{constructor(_,E,w){super(_),this.name="OTLPExporterError",this.data=w,this.code=E}}function validateTimeoutMillis(_){if(Number.isFinite(_)&&_>0)return _;throw new Error(`Configuration: timeoutMillis is invalid, expected number greater than 0 (actual: '${_}')`)}function mergeOtlpSharedConfigurationWithDefaults(_,E,w){return{timeoutMillis:validateTimeoutMillis(_.timeoutMillis??E.timeoutMillis??w.timeoutMillis),concurrencyLimit:_.concurrencyLimit??E.concurrencyLimit??w.concurrencyLimit,compression:_.compression??E.compression??w.compression}}class BoundedQueueExportPromiseHandler{constructor(_){this._sendingPromises=[],this._concurrencyLimit=_}pushPromise(_){if(this.hasReachedLimit())throw new Error("Concurrency Limit reached");this._sendingPromises.push(_);const popPromise=()=>{const E=this._sendingPromises.indexOf(_);this._sendingPromises.splice(E,1)};_.then(popPromise,popPromise)}hasReachedLimit(){return this._sendingPromises.length>=this._concurrencyLimit}async awaitAll(){await Promise.all(this._sendingPromises)}}function createBoundedQueueExportPromiseHandler(_){return new BoundedQueueExportPromiseHandler(_.concurrencyLimit)}function createLoggingPartialSuccessResponseHandler(){return{handleResponse(_){null!=_&&function isPartialSuccessResponse(_){return Object.prototype.hasOwnProperty.call(_,"partialSuccess")}(_)&&null!=_.partialSuccess&&0!==Object.keys(_.partialSuccess).length&&vt.warn("Received Partial Success response:",JSON.stringify(_.partialSuccess))}}}class OTLPExportDelegate{constructor(_,E,w,C,L){this._transport=_,this._serializer=E,this._responseHandler=w,this._promiseQueue=C,this._timeout=L,this._diagLogger=vt.createComponentLogger({namespace:"OTLPExportDelegate"})}export(_,E){if(this._diagLogger.debug("items to be sent",_),this._promiseQueue.hasReachedLimit())return void E({code:he.FAILED,error:new Error("Concurrent export limit reached")});const w=this._serializer.serializeRequest(_);null!=w?this._promiseQueue.pushPromise(this._transport.send(w,this._timeout).then((_=>{if("success"!==_.status)"failure"===_.status&&_.error?E({code:he.FAILED,error:_.error}):"retryable"===_.status?E({code:he.FAILED,error:_.error??new OTLPExporterError("Export failed with retryable status")}):E({code:he.FAILED,error:new OTLPExporterError("Export failed with unknown error")});else{if(null!=_.data)try{this._responseHandler.handleResponse(this._serializer.deserializeResponse(_.data))}catch(E){this._diagLogger.warn("Export succeeded but could not deserialize response - is the response specification compliant?",E,_.data)}E({code:he.SUCCESS})}}),(_=>E({code:he.FAILED,error:_})))):E({code:he.FAILED,error:new Error("Nothing to send")})}forceFlush(){return this._promiseQueue.awaitAll()}async shutdown(){this._diagLogger.debug("shutdown started"),await this.forceFlush(),this._transport.shutdown()}}function createOtlpNetworkExportDelegate(_,E,w){return function createOtlpExportDelegate(_,E){return new OTLPExportDelegate(_.transport,_.serializer,createLoggingPartialSuccessResponseHandler(),_.promiseHandler,E.timeout)}({transport:w,serializer:E,promiseHandler:createBoundedQueueExportPromiseHandler(_)},{timeout:_.timeoutMillis})}let Re,Pe;const Oe=new WeakMap,xe=new WeakMap,Ie=new WeakMap,Ne=new WeakMap,De=new WeakMap;let ke={get(_,E,w){if(_ instanceof IDBTransaction){if("done"===E)return xe.get(_);if("objectStoreNames"===E)return _.objectStoreNames||Ie.get(_);if("store"===E)return w.objectStoreNames[1]?void 0:w.objectStore(w.objectStoreNames[0])}return wrap$1(_[E])},set:(_,E,w)=>(_[E]=w,!0),has:(_,E)=>_ instanceof IDBTransaction&&("done"===E||"store"===E)||E in _};function wrapFunction(_){return _!==IDBDatabase.prototype.transaction||"objectStoreNames"in IDBTransaction.prototype?function getCursorAdvanceMethods(){return Pe||(Pe=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}().includes(_)?function(...E){return _.apply(unwrap$1(this),E),wrap$1(Oe.get(this))}:function(...E){return wrap$1(_.apply(unwrap$1(this),E))}:function(E,...w){const C=_.call(unwrap$1(this),E,...w);return Ie.set(C,E.sort?E.sort():[E]),wrap$1(C)}}function transformCachableValue(_){return"function"==typeof _?wrapFunction(_):(_ instanceof IDBTransaction&&function cacheDonePromiseForTransaction(_){if(xe.has(_))return;const E=new Promise(((E,w)=>{const unlisten=()=>{_.removeEventListener("complete",complete),_.removeEventListener("error",error),_.removeEventListener("abort",error)},complete=()=>{E(),unlisten()},error=()=>{w(_.error||new DOMException("AbortError","AbortError")),unlisten()};_.addEventListener("complete",complete),_.addEventListener("error",error),_.addEventListener("abort",error)}));xe.set(_,E)}(_),E=_,function getIdbProxyableTypes(){return Re||(Re=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}().some((_=>E instanceof _))?new Proxy(_,ke):_);var E}function wrap$1(_){if(_ instanceof IDBRequest)return function promisifyRequest(_){const E=new Promise(((E,w)=>{const unlisten=()=>{_.removeEventListener("success",success),_.removeEventListener("error",error)},success=()=>{E(wrap$1(_.result)),unlisten()},error=()=>{w(_.error),unlisten()};_.addEventListener("success",success),_.addEventListener("error",error)}));return E.then((E=>{E instanceof IDBCursor&&Oe.set(E,_)})).catch((()=>{})),De.set(E,_),E}(_);if(Ne.has(_))return Ne.get(_);const E=transformCachableValue(_);return E!==_&&(Ne.set(_,E),De.set(E,_)),E}const unwrap$1=_=>De.get(_);const Me=["get","getKey","getAll","getAllKeys","count"],Fe=["put","add","delete","clear"],Be=new Map;function getMethod(_,E){if(!(_ instanceof IDBDatabase)||E in _||"string"!=typeof E)return;if(Be.get(E))return Be.get(E);const w=E.replace(/FromIndex$/,""),C=E!==w,L=Fe.includes(w);if(!(w in(C?IDBIndex:IDBObjectStore).prototype)||!L&&!Me.includes(w))return;const method=async function(_,...E){const R=this.transaction(_,L?"readwrite":"readonly");let P=R.store;return C&&(P=P.index(E.shift())),(await Promise.all([P[w](...E),L&&R.done]))[0]};return Be.set(E,method),method}!function replaceTraps(_){ke=_(ke)}((_=>({..._,get:(E,w,C)=>getMethod(E,w)||_.get(E,w,C),has:(E,w)=>!!getMethod(E,w)||_.has(E,w)})));const Ue="@firebase/installations",$e="0.6.24",Ve=1e4,He=`w:${$e}`,je="FIS_v2",ze=36e5,qe=new ErrorFactory("installations","Installations",{"missing-app-config-values":'Missing App configuration value: "{$valueName}"',"not-registered":"Firebase Installation is not registered.","installation-not-found":"Firebase Installation not found.","request-failed":'{$requestName} request failed with error "{$serverCode} {$serverStatus}: {$serverMessage}"',"app-offline":"Could not process request. Application offline.","delete-pending-registration":"Can't delete installation while there is a pending registration request."});function isServerError(_){return _ instanceof FirebaseError&&_.code.includes("request-failed")}function getInstallationsEndpoint({projectId:_}){return`https://firebaseinstallations.googleapis.com/v1/projects/${_}/installations`}function extractAuthTokenInfoFromResponse(_){return{token:_.token,requestStatus:2,expiresIn:(E=_.expiresIn,Number(E.replace("s","000"))),creationTime:Date.now()};var E}async function getErrorFromResponse(_,E){const w=(await E.json()).error;return qe.create("request-failed",{requestName:_,serverCode:w.code,serverMessage:w.message,serverStatus:w.status})}function getHeaders({apiKey:_}){return new Headers({"Content-Type":"application/json",Accept:"application/json","x-goog-api-key":_})}function getHeadersWithAuth(_,{refreshToken:E}){const w=getHeaders(_);return w.append("Authorization",function getAuthorizationHeader(_){return`${je} ${_}`}(E)),w}async function retryIfServerError(_){const E=await _();return E.status>=500&&E.status<600?_():E}function sleep(_){return new Promise((E=>{setTimeout(E,_)}))}const Ge=/^[cdef][\w-]{21}$/;function generateFid(){try{const _=new Uint8Array(17);(self.crypto||self.msCrypto).getRandomValues(_),_[0]=112+_[0]%16;const E=function encode(_){const E=function bufferToBase64UrlSafe(_){return btoa(String.fromCharCode(..._)).replace(/\+/g,"-").replace(/\//g,"_")}(_);return E.substr(0,22)}(_);return Ge.test(E)?E:""}catch{return""}}function getKey(_){return`${_.appName}!${_.appId}`}const We=new Map;function fidChanged(_,E){const w=getKey(_);callFidChangeCallbacks(w,E),function broadcastFidChange(_,E){const w=function getBroadcastChannel(){!Ke&&"BroadcastChannel"in self&&(Ke=new BroadcastChannel("[Firebase] FID Change"),Ke.onmessage=_=>{callFidChangeCallbacks(_.data.key,_.data.fid)});return Ke}();w&&w.postMessage({key:_,fid:E});!function closeBroadcastChannel(){0===We.size&&Ke&&(Ke.close(),Ke=null)}()}(w,E)}function callFidChangeCallbacks(_,E){const w=We.get(_);if(w)for(const _ of w)_(E)}let Ke=null;const Qe="firebase-installations-store";let Xe=null;function getDbPromise(){return Xe||(Xe=function openDB(_,E,{blocked:w,upgrade:C,blocking:L,terminated:R}={}){const P=indexedDB.open(_,E),I=wrap$1(P);return C&&P.addEventListener("upgradeneeded",(_=>{C(wrap$1(P.result),_.oldVersion,_.newVersion,wrap$1(P.transaction),_)})),w&&P.addEventListener("blocked",(_=>w(_.oldVersion,_.newVersion,_))),I.then((_=>{R&&_.addEventListener("close",(()=>R())),L&&_.addEventListener("versionchange",(_=>L(_.oldVersion,_.newVersion,_)))})).catch((()=>{})),I}("firebase-installations-database",1,{upgrade:(_,E)=>{if(0===E)_.createObjectStore(Qe)}})),Xe}async function set(_,E){const w=getKey(_),C=(await getDbPromise()).transaction(Qe,"readwrite"),L=C.objectStore(Qe),R=await L.get(w);return await L.put(E,w),await C.done,R&&R.fid===E.fid||fidChanged(_,E.fid),E}async function remove(_){const E=getKey(_),w=(await getDbPromise()).transaction(Qe,"readwrite");await w.objectStore(Qe).delete(E),await w.done}async function update(_,E){const w=getKey(_),C=(await getDbPromise()).transaction(Qe,"readwrite"),L=C.objectStore(Qe),R=await L.get(w),P=E(R);return void 0===P?await L.delete(w):await L.put(P,w),await C.done,!P||R&&R.fid===P.fid||fidChanged(_,P.fid),P}async function getInstallationEntry(_){let E;const w=await update(_.appConfig,(w=>{const C=function updateOrCreateInstallationEntry(_){const E=_||{fid:generateFid(),registrationStatus:0};return clearTimedOutRequest(E)}(w),L=function triggerRegistrationIfNecessary(_,E){if(0===E.registrationStatus){if(!navigator.onLine){return{installationEntry:E,registrationPromise:Promise.reject(qe.create("app-offline"))}}const w={fid:E.fid,registrationStatus:1,registrationTime:Date.now()},C=async function registerInstallation(_,E){try{const w=await async function createInstallationRequest({appConfig:_,heartbeatServiceProvider:E},{fid:w}){const C=getInstallationsEndpoint(_),L=getHeaders(_),R=E.getImmediate({optional:!0});if(R){const _=await R.getHeartbeatsHeader();_&&L.append("x-firebase-client",_)}const P={fid:w,authVersion:je,appId:_.appId,sdkVersion:He},I={method:"POST",headers:L,body:JSON.stringify(P)},k=await retryIfServerError((()=>fetch(C,I)));if(k.ok){const _=await k.json();return{fid:_.fid||w,registrationStatus:2,refreshToken:_.refreshToken,authToken:extractAuthTokenInfoFromResponse(_.authToken)}}throw await getErrorFromResponse("Create Installation",k)}(_,E);return set(_.appConfig,w)}catch(w){throw isServerError(w)&&409===w.customData.serverCode?await remove(_.appConfig):await set(_.appConfig,{fid:E.fid,registrationStatus:0}),w}}(_,w);return{installationEntry:w,registrationPromise:C}}return 1===E.registrationStatus?{installationEntry:E,registrationPromise:waitUntilFidRegistration(_)}:{installationEntry:E}}(_,C);return E=L.registrationPromise,L.installationEntry}));return""===w.fid?{installationEntry:await E}:{installationEntry:w,registrationPromise:E}}async function waitUntilFidRegistration(_){let E=await updateInstallationRequest(_.appConfig);for(;1===E.registrationStatus;)await sleep(100),E=await updateInstallationRequest(_.appConfig);if(0===E.registrationStatus){const{installationEntry:E,registrationPromise:w}=await getInstallationEntry(_);return w||E}return E}function updateInstallationRequest(_){return update(_,(_=>{if(!_)throw qe.create("installation-not-found");return clearTimedOutRequest(_)}))}function clearTimedOutRequest(_){return function hasInstallationRequestTimedOut(_){return 1===_.registrationStatus&&_.registrationTime+Ve<Date.now()}(_)?{fid:_.fid,registrationStatus:0}:_}async function generateAuthTokenRequest({appConfig:_,heartbeatServiceProvider:E},w){const C=function getGenerateAuthTokenEndpoint(_,{fid:E}){return`${getInstallationsEndpoint(_)}/${E}/authTokens:generate`}(_,w),L=getHeadersWithAuth(_,w),R=E.getImmediate({optional:!0});if(R){const _=await R.getHeartbeatsHeader();_&&L.append("x-firebase-client",_)}const P={installation:{sdkVersion:He,appId:_.appId}},I={method:"POST",headers:L,body:JSON.stringify(P)},k=await retryIfServerError((()=>fetch(C,I)));if(k.ok){return extractAuthTokenInfoFromResponse(await k.json())}throw await getErrorFromResponse("Generate Auth Token",k)}async function refreshAuthToken(_,E=!1){let w;const C=await update(_.appConfig,(C=>{if(!isEntryRegistered(C))throw qe.create("not-registered");const L=C.authToken;if(!E&&function isAuthTokenValid(_){return 2===_.requestStatus&&!function isAuthTokenExpired(_){const E=Date.now();return E<_.creationTime||_.creationTime+_.expiresIn<E+ze}(_)}(L))return C;if(1===L.requestStatus)return w=async function waitUntilAuthTokenRequest(_,E){let w=await updateAuthTokenRequest(_.appConfig);for(;1===w.authToken.requestStatus;)await sleep(100),w=await updateAuthTokenRequest(_.appConfig);const C=w.authToken;return 0===C.requestStatus?refreshAuthToken(_,E):C}(_,E),C;{if(!navigator.onLine)throw qe.create("app-offline");const E=function makeAuthTokenRequestInProgressEntry(_){const E={requestStatus:1,requestTime:Date.now()};return{..._,authToken:E}}(C);return w=async function fetchAuthTokenFromServer(_,E){try{const w=await generateAuthTokenRequest(_,E),C={...E,authToken:w};return await set(_.appConfig,C),w}catch(w){if(!isServerError(w)||401!==w.customData.serverCode&&404!==w.customData.serverCode){const w={...E,authToken:{requestStatus:0}};await set(_.appConfig,w)}else await remove(_.appConfig);throw w}}(_,E),E}}));return w?await w:C.authToken}function updateAuthTokenRequest(_){return update(_,(_=>{if(!isEntryRegistered(_))throw qe.create("not-registered");return function hasAuthTokenRequestTimedOut(_){return 1===_.requestStatus&&_.requestTime+Ve<Date.now()}(_.authToken)?{..._,authToken:{requestStatus:0}}:_}))}function isEntryRegistered(_){return void 0!==_&&2===_.registrationStatus}async function getToken(_,E=!1){const w=_;await async function completeInstallationRegistration(_){const{registrationPromise:E}=await getInstallationEntry(_);E&&await E}(w);return(await refreshAuthToken(w,E)).token}function getMissingValueError(_){return qe.create("missing-app-config-values",{valueName:_})}const Ye="installations",publicFactory=_=>{const E=_.getProvider("app").getImmediate(),w=function extractAppConfig(_){if(!_||!_.options)throw getMissingValueError("App Configuration");if(!_.name)throw getMissingValueError("App Name");const E=["projectId","apiKey","appId"];for(const w of E)if(!_.options[w])throw getMissingValueError(w);return{appName:_.name,projectId:_.options.projectId,apiKey:_.options.apiKey,appId:_.options.appId}}(E);return{app:E,appConfig:w,heartbeatServiceProvider:_getProvider(E,"heartbeat"),_delete:()=>Promise.resolve()}},internalFactory=_=>{const E=_.getProvider("app").getImmediate(),w=_getProvider(E,Ye).getImmediate();return{getId:()=>async function getId(_){const E=_,{installationEntry:w,registrationPromise:C}=await getInstallationEntry(E);return C?C.catch(console.error):refreshAuthToken(E).catch(console.error),w.fid}(w),getToken:_=>getToken(w,_)}};function registerInstrumentations(_){const E=_.tracerProvider||It.getTracerProvider(),w=_.meterProvider||Ct.getMeterProvider(),C=_.loggerProvider||$.getLoggerProvider(),L=_.instrumentations?.flat()??[];return function enableInstrumentations(_,E,w,C){for(let L=0,R=_.length;L<R;L++){const R=_[L];E&&R.setTracerProvider(E),w&&R.setMeterProvider(w),C&&R.setLoggerProvider&&R.setLoggerProvider(C),R.getConfig().enabled||R.enable()}}(L,E,w,C),()=>{!function disableInstrumentations(_){_.forEach((_=>_.disable()))}(L)}}!function registerInstallations(){E(new Component(Ye,publicFactory,"PUBLIC")),E(new Component("installations-internal",internalFactory,"PRIVATE"))}(),_(Ue,$e),_(Ue,$e,"esm2020");let Ze=console.error.bind(console);function defineProperty(_,E,w){const C=!!_[E]&&Object.prototype.propertyIsEnumerable.call(_,E);Object.defineProperty(_,E,{configurable:!0,enumerable:C,writable:!0,value:w})}const wrap=(_,E,w)=>{if(!_||!_[E])return void Ze("no original function "+String(E)+" to wrap");if(!w)return Ze("no wrapper function"),void Ze((new Error).stack);const C=_[E];if("function"!=typeof C||"function"!=typeof w)return void Ze("original object and wrapper must be functions");const L=w(C,E);return defineProperty(L,"__original",C),defineProperty(L,"__unwrap",(()=>{_[E]===L&&defineProperty(_,E,C)})),defineProperty(L,"__wrapped",!0),defineProperty(_,E,L),L},massWrap=(_,E,w)=>{if(!_)return Ze("must provide one or more modules to patch"),void Ze((new Error).stack);Array.isArray(_)||(_=[_]),E&&Array.isArray(E)?_.forEach((_=>{E.forEach((E=>{wrap(_,E,w)}))})):Ze("must provide one or more functions to wrap on modules")},unwrap=(_,E)=>{if(!_||!_[E])return Ze("no function to unwrap."),void Ze((new Error).stack);const w=_[E];w.__unwrap?w.__unwrap():Ze("no original to unwrap to -- has "+String(E)+" already been unwrapped?")},massUnwrap=(_,E)=>{if(!_)return Ze("must provide one or more modules to patch"),void Ze((new Error).stack);Array.isArray(_)||(_=[_]),E&&Array.isArray(E)?_.forEach((_=>{E.forEach((E=>{unwrap(_,E)}))})):Ze("must provide one or more functions to unwrap on modules")};class InstrumentationAbstract{constructor(_,E,w){this._config={},this._wrap=wrap,this._unwrap=unwrap,this._massWrap=massWrap,this._massUnwrap=massUnwrap,this.instrumentationName=_,this.instrumentationVersion=E,this.setConfig(w),this._diag=vt.createComponentLogger({namespace:_}),this._tracer=It.getTracer(_,E),this._meter=Ct.getMeter(_,E),this._logger=$.getLogger(_,E),this._updateMetricInstruments()}get meter(){return this._meter}setMeterProvider(_){this._meter=_.getMeter(this.instrumentationName,this.instrumentationVersion),this._updateMetricInstruments()}get logger(){return this._logger}setLoggerProvider(_){this._logger=_.getLogger(this.instrumentationName,this.instrumentationVersion)}getModuleDefinitions(){const _=this.init()??[];return Array.isArray(_)?_:[_]}_updateMetricInstruments(){}getConfig(){return this._config}setConfig(_){this._config={enabled:!0,..._}}setTracerProvider(_){this._tracer=_.getTracer(this.instrumentationName,this.instrumentationVersion)}get tracer(){return this._tracer}_runSpanCustomizationHook(_,E,w,C){if(_)try{_(w,C)}catch(_){this._diag.error("Error running span customization hook due to exception in handler",{triggerName:E},_)}}}class InstrumentationBase extends InstrumentationAbstract{constructor(_,E,w){super(_,E,w),this._config.enabled&&this.enable()}}function safeExecuteInTheMiddle(_,E,w){let C,L;try{L=_()}catch(_){C=_}finally{return E(C,L),L}}var Je;function semconvStabilityFromStr(_,E){let w=Je.OLD;const C=E?.split(",").map((_=>_.trim())).filter((_=>""!==_));for(const E of C??[]){if(E.toLowerCase()===_+"/dup"){w=Je.DUPLICATE;break}E.toLowerCase()===_&&(w=Je.STABLE)}return w}!function(_){_[_.STABLE=1]="STABLE",_[_.OLD=2]="OLD",_[_.DUPLICATE=3]="DUPLICATE"}(Je||(Je={}));var tr="0.6.0";const er="browser.navigation_timing.type",rr="url.full",nr="browser.navigation_timing.dom_complete",sr="browser.navigation_timing.dom_content_loaded_event_end",ir="browser.navigation_timing.dom_content_loaded_event_start",or="browser.navigation_timing.dom_interactive",ar="browser.navigation_timing.load_event_end",cr="browser.navigation_timing.load_event_start",ur="browser.navigation_timing.redirect_count",lr="browser.navigation_timing.unload_event_end",dr="browser.navigation_timing.unload_event_start",hr="browser.resource_timing.duration",pr="browser.resource_timing.fetch_start",gr="browser.resource_timing.domain_lookup_start",mr="browser.resource_timing.domain_lookup_end",fr="browser.resource_timing.connect_start",_r="browser.resource_timing.connect_end",br="browser.resource_timing.secure_connection_start",yr="browser.resource_timing.request_start",Sr="browser.resource_timing.response_start",Er="browser.resource_timing.response_end",Tr="browser.resource_timing.transfer_size",vr="browser.resource_timing.encoded_body_size",wr="browser.resource_timing.decoded_body_size";var Ar=class extends InstrumentationBase{constructor(_={}){super("@opentelemetry/browser-instrumentation/navigation-timing",tr,_),this._retryCount=0,this._didEmit=!1}init(){return[]}enable(){this._isEnabled||(this._isEnabled=!0,this._onLoad=()=>this._tryEmitOrSchedule(),this._onPageHide=()=>this._handleUnload(),this._tryEmitOrSchedule(),this._didEmit||window.addEventListener("pagehide",this._onPageHide))}disable(){this._isEnabled=!1,this._unsubscribeAll(),this._lastEntry=void 0,this._didEmit=!1,this._retryCount=0}_getLatestNavigationEntry(){const _=performance?.getEntriesByType?.("navigation");if(_&&0!==_.length)return _[_.length-1]}_calculateBackoffDelay(){return 50*this._retryCount}_tryEmitOrSchedule(){if(this._didEmit)return;const _=this._getLatestNavigationEntry();if(_&&(this._lastEntry=_),_&&_.loadEventEnd>0)return void this._emitAndCleanup(_);if("complete"!==document.readyState)return void window.addEventListener("load",this._onLoad,{once:!0});if(void 0!==this._completeDelayTimeoutId)return;if(this._retryCount>5)return void(this._lastEntry?(this._diag.warn("Navigation timing: retries exhausted, emitting incomplete entry"),this._emitAndCleanup(this._lastEntry)):(this._diag.warn("Navigation timing: retries exhausted with no entry available"),this._unsubscribeAll()));const E=this._calculateBackoffDelay();this._retryCount++,this._completeDelayTimeoutId=window.setTimeout((()=>{this._completeDelayTimeoutId=void 0,this._tryEmitOrSchedule()}),E)}_handleUnload(){if(this._didEmit)return;const _=this._getLatestNavigationEntry()??this._lastEntry;_?this._emitAndCleanup(_):(this._diag.warn("Navigation timing: no entry available at unload"),this._unsubscribeAll())}_emitAndCleanup(_){this._didEmit||(this._didEmit=!0,this._emitNavigationTiming(_),this._lastEntry=void 0,this._unsubscribeAll())}_emitNavigationTiming(_){_&&this.logger.emit({eventName:"browser.navigation_timing",severityNumber:R.INFO,attributes:{[er]:_.type,[rr]:_.name,[hr]:_.duration,[nr]:_.domComplete,[sr]:_.domContentLoadedEventEnd,[ir]:_.domContentLoadedEventStart,[or]:_.domInteractive,[ar]:_.loadEventEnd,[cr]:_.loadEventStart,[ur]:_.redirectCount,[lr]:_.unloadEventEnd,[dr]:_.unloadEventStart,[pr]:_.fetchStart,[gr]:_.domainLookupStart,[mr]:_.domainLookupEnd,[fr]:_.connectStart,[_r]:_.connectEnd,[br]:_.secureConnectionStart,[yr]:_.requestStart,[Sr]:_.responseStart,[Er]:_.responseEnd,[Tr]:_.transferSize,[vr]:_.encodedBodySize,[wr]:_.decodedBodySize}})}_unsubscribeAll(){this._completeDelayTimeoutId&&(clearTimeout(this._completeDelayTimeoutId),this._completeDelayTimeoutId=void 0),this._onLoad&&window.removeEventListener("load",this._onLoad),this._onPageHide&&window.removeEventListener("pagehide",this._onPageHide)}};const getElementCSSSelector=(_,{useIdForTargetElement:E=!1,useIdForAncestors:w=!1}={})=>{if(_.nodeType===Node.DOCUMENT_NODE)return"";const C=_,L=getNodeSelector(C,E||w);if(L.startsWith("#"))return L;const R=C.parentElement,P=R?getElementCSSSelector(R,{useIdForAncestors:w,useIdForTargetElement:!1}):"";return P?`${P} > ${L}`:L},getNodeSelector=(_,E=!1)=>{if(_.nodeType!==Node.ELEMENT_NODE)return"";const w=_,C=w.getAttribute("id");if(E&&C&&1===w.ownerDocument.querySelectorAll(`#${CSS.escape(C)}`).length)return`#${CSS.escape(C)}`;let L=getFullClassSelector(w);const R=getNthChild(w);return R>0&&(L+=`:nth-child(${R})`),L},getNthChild=_=>{if(!_.parentElement)return 0;const E=getFullClassSelector(_),w=Array.from(_.parentElement.children).filter((_=>getFullClassSelector(_)===E));return w.length>1?w.indexOf(_)+1:0},getFullClassSelector=_=>_.localName+(_.classList.length>0?Array.from(_.classList).map((_=>`.${CSS.escape(_)}`)).join(""):""),Cr="browser.mouse_event.button",Lr="browser.page.x",Rr="browser.page.y",Pr="browser.tag_name",Or="browser.element.attributes",xr="browser.css_selector",Ir=["click"];var Nr=class extends InstrumentationBase{constructor(_={}){super("@opentelemetry/browser-instrumentation/user-action",tr,_)}init(){return[]}_getMouseButtonFromMouseEvent(_){switch(_.button){case 0:default:return"left";case 1:return"middle";case 2:return"right"}}onClick(_){const E=_.target;if(!(E instanceof HTMLElement))return;if(E.hasAttribute("disabled"))return;const w=getElementCSSSelector(E,{useIdForTargetElement:!0,useIdForAncestors:!0}),C={};for(const _ of E.attributes)_.name.startsWith("data-otel-")&&(C[_.name.slice(10)]=_.value);this.logger.emit({severityNumber:R.INFO,eventName:"browser.user_action.click",attributes:{[Lr]:_.pageX,[Rr]:_.pageY,[Pr]:E.tagName,[Or]:C,[Cr]:this._getMouseButtonFromMouseEvent(_),[xr]:w}})}enable(){const _=this._config.autoCapturedActions??Ir;this._onClickHandler||(this._onClickHandler=this.onClick.bind(this)),_.includes("click")&&document.addEventListener("click",this._onClickHandler,!0)}disable(){this._onClickHandler&&document.removeEventListener("click",this._onClickHandler,!0)}};const Dr="browser.web_vital.name",kr="browser.web_vital.value",Mr="browser.web_vital.rating",Fr="browser.web_vital.delta",Br="browser.web_vital.id",Ur="browser.web_vital.navigation_type";class t{constructor(){this.o=0,this.i=[]}u(_){if(_.hadRecentInput)return;const E=this.i[0],w=this.i.at(-1);this.o&&E&&w&&_.startTime-w.startTime<1e3&&_.startTime-E.startTime<5e3?(this.o+=_.value,this.i.push(_)):(this.o=_.value,this.i=[_]),this.t?.(_)}}const e=()=>{const _=performance.getEntriesByType("navigation")[0];if(_&&_.responseStart>0&&_.responseStart<performance.now())return _},n=_=>{if("loading"===document.readyState)return"loading";const E=e();if(E){if(_<E.domInteractive)return"loading";if(0===E.domContentLoadedEventStart||_<E.domContentLoadedEventStart)return"dom-interactive";if(0===E.domComplete||_<E.domComplete)return"dom-content-loaded"}return"complete"},o=_=>{const E=_.nodeName;return 1===_.nodeType?E.toLowerCase():E.toUpperCase().replace(/^#/,"")},i=_=>{let E="";try{for(;9!==_?.nodeType;){const w=_,C=w.id?"#"+w.id:[o(w),...Array.from(w.classList).sort()].join(".");if(E.length+C.length>99)return E||C;if(E=E?C+">"+E:C,w.id)break;_=w.parentNode}}catch{}return E},$r=new WeakMap;function s(_,E){let w=$r.get(E);return w||(w=new WeakMap,$r.set(E,w)),w.get(_)||w.set(_,new E),w.get(_)}let Vr=-1;const c=()=>Vr,u=_=>{addEventListener("pageshow",(E=>{E.persisted&&(Vr=E.timeStamp,_(E))}),!0)},f=(_,E,w,C)=>{let L,R;return P=>{E.value>=0&&(P||C)&&(R=E.value-(L??0),(R||void 0===L)&&(L=E.value,E.delta=R,E.rating=((_,E)=>_>E[1]?"poor":_>E[0]?"needs-improvement":"good")(E.value,w),_(E)))}},l=_=>{requestAnimationFrame((()=>requestAnimationFrame(_)))},d=()=>e()?.activationStart??0,h=(_,E=-1)=>{const w=e();let C="navigate";return c()>=0?C="back-forward-cache":w&&(document.prerendering||d()>0?C="prerender":document.wasDiscarded?C="restore":w.type&&(C=w.type.replace(/_/g,"-"))),{name:_,value:E,rating:"good",delta:0,entries:[],id:`v5-${Date.now()}-${Math.floor(8999999999999*Math.random())+1e12}`,navigationType:C}},m=(_,E,w={})=>{try{if(PerformanceObserver.supportedEntryTypes.includes(_)){const C=new PerformanceObserver((_=>{queueMicrotask((()=>{E(_.getEntries())}))}));return C.observe({type:_,buffered:!0,...w}),C}}catch{}},g=_=>{let E=!1;return()=>{E||(_(),E=!0)}};let Hr=-1;const jr=new Set,v=()=>"hidden"!==document.visibilityState||document.prerendering?1/0:0,b=_=>{if("hidden"===document.visibilityState){if("visibilitychange"===_.type)for(const _ of jr)_();isFinite(Hr)||(Hr="visibilitychange"===_.type?_.timeStamp:0,removeEventListener("prerenderingchange",b,!0))}},M=()=>{if(Hr<0){const _=d(),E=document.prerendering?void 0:globalThis.performance.getEntriesByType("visibility-state").find((E=>"hidden"===E.name&&E.startTime>=_))?.startTime;Hr=E??v(),addEventListener("visibilitychange",b,!0),addEventListener("prerenderingchange",b,!0),u((()=>{setTimeout((()=>{Hr=v()}))}))}return{get firstHiddenTime(){return Hr},onHidden(_){jr.add(_)}}},T=_=>{document.prerendering?addEventListener("prerenderingchange",_,!0):_()},zr=[1800,3e3],D=(_,E={})=>{T((()=>{const w=M();let C,L=h("FCP");const R=m("paint",(_=>{for(const E of _)"first-contentful-paint"===E.name&&(R.disconnect(),E.startTime<w.firstHiddenTime&&(L.value=Math.max(E.startTime-d(),0),L.entries.push(E),C(!0)))}));R&&(C=f(_,L,zr,E.reportAllChanges),u((w=>{L=h("FCP"),C=f(_,L,zr,E.reportAllChanges),l((()=>{L.value=performance.now()-w.timeStamp,C(!0)}))})))}))},qr=[.1,.25],S=_=>_.find((_=>1===_.node?.nodeType))||_[0];let Gr=0,Wr=1/0,Kr=0;const B=_=>{for(const E of _)E.interactionId&&(Wr=Math.min(Wr,E.interactionId),Kr=Math.max(Kr,E.interactionId),Gr=Kr?(Kr-Wr)/7+1:0)};let Qr;const O=()=>Qr?Gr:performance.interactionCount??0;let Xr=0;class A{constructor(){this.l=[],this.h=new Map}v(){Xr=O(),this.l.length=0,this.h.clear()}M(){const _=Math.min(this.l.length-1,Math.floor((O()-Xr)/50));return this.l[_]}u(_){if(this.m?.(_),!_.interactionId&&"first-input"!==_.entryType)return;const E=this.l.at(-1);let w=this.h.get(_.interactionId);if(w||this.l.length<10||_.duration>E.T){if(w?_.duration>w.T?(w.entries=[_],w.T=_.duration):_.duration===w.T&&_.startTime===w.entries[0].startTime&&w.entries.push(_):(w={id:_.interactionId,entries:[_],T:_.duration},this.h.set(w.id,w),this.l.push(w)),this.l.sort(((_,E)=>E.T-_.T)),this.l.length>10){const _=this.l.splice(10);for(const E of _)this.h.delete(E.id)}this.p?.(w)}}}const W=_=>{const E=globalThis.requestIdleCallback||setTimeout,w=globalThis.cancelIdleCallback||clearTimeout;if("hidden"===document.visibilityState)_();else{const C=g(_);let L=-1;const r=()=>{w(L),C()};addEventListener("visibilitychange",r,{once:!0,capture:!0}),L=E((()=>{removeEventListener("visibilitychange",r,{capture:!0}),C()}))}},Yr=[200,500],x=(_,E={})=>{const w=s(E=Object.assign({},E),A);let C=[],L=[],R=0;const P=new WeakMap,I=new WeakMap;let k=!1;const p=()=>{k||(W(y),k=!0)},y=()=>{const _=new Set(w.l.map((_=>P.get(_.entries[0])))),E=L.length-10;L=L.filter(((w,C)=>C>=E||_.has(w)));const I=new Set;for(const _ of L){const E=v(_.startTime,_.processingEnd);for(const _ of E)I.add(_)}C=C.filter((_=>_.startTime>R||I.has(_))),k=!1};w.m=_=>{const w=_.startTime+_.duration;let C;R=Math.max(R,_.processingEnd);for(let R=L.length-1;R>=0;R--){const P=L[R];if(Math.abs(w-P.renderTime)<=8){C=P,C.startTime=Math.min(_.startTime,C.startTime),C.processingStart=Math.min(_.processingStart,C.processingStart),C.processingEnd=Math.max(_.processingEnd,C.processingEnd),!1!==E.includeProcessedEventEntries&&C.entries.push(_);break}}C||(C={startTime:_.startTime,processingStart:_.processingStart,processingEnd:_.processingEnd,renderTime:w,entries:!1!==E.includeProcessedEventEntries?[_]:[]},L.push(C)),(_.interactionId||"first-input"===_.entryType)&&P.set(_,C),p()},w.p=_=>{if(!I.get(_)){const w=_.entries.find((_=>_.target))?.target;if(w){const C=E.generateTarget?.(w)??i(w);I.set(_,C)}else{const E=_.entries.find((_=>_.targetSelector))?.targetSelector;E&&I.set(_,E)}}};const v=(_,E)=>{const w=[];for(const L of C)if(!(L.startTime+L.duration<_)){if(L.startTime>E)break;w.push(L)}return w};m("long-animation-frame",(_=>{C=C.concat(_),p()})),((_,E={})=>{if(!globalThis.PerformanceEventTiming||!("interactionId"in PerformanceEventTiming.prototype))return;const w=M();T((()=>{"interactionCount"in performance||Qr||(Qr=m("event",B,{durationThreshold:0}));let C,L=h("INP");const R=s(E,A),a=_=>{W((()=>{for(const E of _)R.u(E);const E=R.M();E&&E.T!==L.value&&(L.value=E.T,L.entries=E.entries,C())}))},P=m("event",a,{durationThreshold:E.durationThreshold??40});C=f(_,L,Yr,E.reportAllChanges),P&&(P.observe({type:"first-input",buffered:!0}),w.onHidden((()=>{a(P.takeRecords()),C(!0)})),u((()=>{R.v(),L=h("INP"),C=f(_,L,Yr,E.reportAllChanges)})))}))})((E=>{_((_=>{const E=_.entries[0],C=P.get(E),L=E.processingStart,R=Math.max(E.startTime+E.duration,L),k=Math.min(C.processingEnd,R),F=C.entries.sort(((_,E)=>_.processingStart-E.processingStart)),$=v(E.startTime,k),V=w.h.get(E.interactionId),H={interactionTarget:I.get(V),interactionType:E.name.startsWith("key")?"keyboard":"pointer",interactionTime:E.startTime,nextPaintTime:R,processedEventEntries:F,longAnimationFrameEntries:$,inputDelay:L-E.startTime,processingDuration:k-L,presentationDelay:R-k,loadState:n(E.startTime),longestScript:void 0,totalScriptDuration:void 0,totalStyleAndLayoutDuration:void 0,totalPaintDuration:void 0,totalUnattributedDuration:void 0};return(_=>{if(!_.longAnimationFrameEntries?.length)return;const E=_.interactionTime,w=_.inputDelay,C=_.processingDuration;let L,R,P=0,I=0,k=0,F=0;for(const k of _.longAnimationFrameEntries){I=I+k.startTime+k.duration-k.styleAndLayoutStart;for(const _ of k.scripts){const k=_.startTime+_.duration;if(k<E)continue;const $=k-Math.max(E,_.startTime),V=_.duration?$/_.duration*_.forcedStyleAndLayoutDuration:0;P+=$-V,I+=V,$>F&&(R=_.startTime<E+w?"input-delay":_.startTime>=E+w+C?"presentation-delay":"processing-duration",L=_,F=$)}}const $=_.longAnimationFrameEntries.at(-1),V=$?$.startTime+$.duration:0;V>=E+w+C&&(k=_.nextPaintTime-V),L&&R&&(_.longestScript={entry:L,subpart:R,intersectingDuration:F}),_.totalScriptDuration=P,_.totalStyleAndLayoutDuration=I,_.totalPaintDuration=k,_.totalUnattributedDuration=_.nextPaintTime-E-P-I-k})(H),Object.assign(_,{attribution:H})})(E))}),E)};class N{u(_){this.m?.(_)}}const Zr=[2500,4e3],Jr=[800,1800],U=_=>{document.prerendering?T((()=>U(_))):"complete"!==document.readyState?addEventListener("load",(()=>U(_)),!0):setTimeout(_)};var tn=class extends InstrumentationBase{constructor(_={}){super("@opentelemetry/browser-instrumentation/web-vitals",tr,_),this._applyCustomLogRecordData=_.applyCustomLogRecordData,this._includeRawAttribution=_.includeRawAttribution??!1}init(){return[]}enable(){"undefined"!=typeof PerformanceObserver?(this._isEnabled=!0,this._listenersRegistered?this._diag.debug("Listeners already registered, resuming emission"):(this._listenersRegistered=!0,this._diag.debug("Registering listeners"),((_,E={})=>{const w=s(E=Object.assign({},E),t),C=new WeakMap;w.t=_=>{if(_?.sources?.length){const w=S(_.sources),L=w?.node;if(L){const _=E.generateTarget?.(L)??i(L);C.set(w,_)}}},((_,E={})=>{const w=M();D(g((()=>{let C,L=h("CLS",0);const R=s(E,t),c=_=>{for(const E of _)R.u(E);R.o>L.value&&(L.value=R.o,L.entries=R.i,C())},P=m("layout-shift",c);P&&(C=f(_,L,qr,E.reportAllChanges),w.onHidden((()=>{c(P.takeRecords()),C(!0)})),u((()=>{R.o=0,L=h("CLS",0),C=f(_,L,qr,E.reportAllChanges),l(C)})),setTimeout(C))})))})((E=>{_((_=>{let E={};if(_.entries.length){const w=_.entries.reduce(((_,E)=>_.value>E.value?_:E));if(w?.sources?.length){const _=S(w.sources);_&&(E={largestShiftTarget:C.get(_),largestShiftTime:w.startTime,largestShiftValue:w.value,largestShiftSource:_,largestShiftEntry:w,loadState:n(w.startTime)})}}return Object.assign(_,{attribution:E})})(E))}),E)})((_=>this._emitWebVital(_))),x((_=>this._emitWebVital(_))),((_,E={})=>{const w=s(E=Object.assign({},E),N),C=new WeakMap;w.m=_=>{const w=_.element;if(w){const L=E.generateTarget?.(w)??i(w);C.set(_,L)}else _.id&&C.set(_,`#${_.id}`)},((_,E={})=>{T((()=>{const w=M();let C,L=h("LCP");const R=s(E,N),a=_=>{E.reportAllChanges||(_=_.slice(-1));for(const E of _)R.u(E),E.startTime<w.firstHiddenTime&&(L.value=Math.max(E.startTime-d(),0),L.entries=[E],C())},P=m("largest-contentful-paint",a);if(P){C=f(_,L,Zr,E.reportAllChanges);const w=g((()=>{a(P.takeRecords()),P.disconnect(),C(!0)})),r=_=>{_.isTrusted&&(W(w),removeEventListener(_.type,r,{capture:!0}))};for(const _ of["keydown","click","visibilitychange"])addEventListener(_,r,{capture:!0});u((w=>{L=h("LCP"),C=f(_,L,Zr,E.reportAllChanges),l((()=>{L.value=performance.now()-w.timeStamp,C(!0)}))}))}}))})((E=>{_((_=>{let E={timeToFirstByte:0,resourceLoadDelay:0,resourceLoadDuration:0,elementRenderDelay:_.value};if(_.entries.length){const w=_.entries.at(-1),L=w.url&&performance.getEntriesByType("resource").find((_=>_.name===w.url));E.target=C.get(w),E.lcpEntry=w,w.url&&(E.url=w.url),L&&(E.lcpResourceEntry=L);const R=e();if(R){const w=R.activationStart||0,C=Math.max(0,R.responseStart-w),P=Math.max(C,L?(L.requestStart||L.startTime)-w:0),I=Math.min(_.value,Math.max(P,L?L.responseEnd-w:0));E={...E,timeToFirstByte:C,resourceLoadDelay:P-C,resourceLoadDuration:I-P,elementRenderDelay:_.value-I,navigationEntry:R}}}return Object.assign(_,{attribution:E})})(E))}),E)})((_=>this._emitWebVital(_))),((_,E={})=>{D((E=>{_((_=>{let E={timeToFirstByte:0,firstByteToFCP:_.value,loadState:n(c())};if(_.entries.length){const w=e(),C=_.entries.at(-1);if(w){const L=w.activationStart||0,R=Math.max(0,w.responseStart-L);E={timeToFirstByte:R,firstByteToFCP:_.value-R,loadState:n(_.entries[0].startTime),navigationEntry:w,fcpEntry:C}}}return Object.assign(_,{attribution:E})})(E))}),E)})((_=>this._emitWebVital(_))),((_,E={})=>{((_,E={})=>{let w=h("TTFB"),C=f(_,w,Jr,E.reportAllChanges);U((()=>{const L=e();L&&(w.value=Math.max(L.responseStart-d(),0),w.entries=[L],C(!0),u((()=>{w=h("TTFB",0),C=f(_,w,Jr,E.reportAllChanges),C(!0)})))}))})((E=>{_((_=>{let E={waitingDuration:0,cacheDuration:0,dnsDuration:0,connectionDuration:0,requestDuration:0};if(_.entries.length){const w=_.entries[0],C=w.activationStart||0,L=Math.max((w.workerStart||w.fetchStart)-C,0),R=Math.max(w.domainLookupStart-C,0),P=Math.max(w.connectStart-C,0),I=Math.max(w.connectEnd-C,0);E={waitingDuration:L,cacheDuration:R-L,dnsDuration:P-R,connectionDuration:I-P,requestDuration:_.value-I,navigationEntry:w}}return Object.assign(_,{attribution:E})})(E))}),E)})((_=>this._emitWebVital(_))))):this._diag.debug("PerformanceObserver not supported, web vitals will not be collected")}disable(){this._isEnabled=!1,this._diag.debug("Instrumentation disabled, pausing emission")}_getTimestampForMetric(_){if("CLS"===_.name){const{attribution:E}=_;return void 0!==E.largestShiftTime?E.largestShiftTime:void 0}if("INP"===_.name){const{attribution:E}=_;return E.interactionTime}return _.value}_emitWebVital(_){if(!this._isEnabled)return;const E={[Dr]:_.name.toLowerCase(),[kr]:_.value,[Fr]:_.delta,[Mr]:_.rating,[Br]:_.id,[Ur]:_.navigationType},w=this._getTimestampForMetric(_),C={eventName:"browser.web_vital",severityNumber:R.INFO,attributes:E,...this._includeRawAttribution?{body:JSON.stringify(_.attribution)}:{},...void 0!==w?{timestamp:w}:{}};this._applyCustomLogRecordData&&safeExecuteInTheMiddle((()=>this._applyCustomLogRecordData?.(C)),(_=>{_&&this._diag.error("applyCustomLogRecordData hook failed",_)})),this.logger.emit(C)}};const en=createContextKey("OpenTelemetry SDK Context Key SUPPRESS_TRACING");function sanitizeAttributes(_){const E={};if("object"!=typeof _||null==_)return E;for(const w in _){if(!Object.prototype.hasOwnProperty.call(_,w))continue;if(!isAttributeKey(w)){vt.warn(`Invalid attribute key: ${w}`);continue}const C=_[w];isAttributeValue(C)?Array.isArray(C)?E[w]=C.slice():E[w]=C:vt.warn(`Invalid attribute value set for key: ${w}`)}return E}function isAttributeKey(_){return"string"==typeof _&&""!==_}function isAttributeValue(_){return null==_||(Array.isArray(_)?function isHomogeneousAttributeValueArray(_){let E;for(const w of _){if(null==w)continue;const _=typeof w;if(_!==E){if(!E){if(isValidPrimitiveAttributeValueType(_)){E=_;continue}return!1}return!1}}return!0}(_):isValidPrimitiveAttributeValueType(typeof _))}function isValidPrimitiveAttributeValueType(_){switch(_){case"number":case"boolean":case"string":return!0}return!1}let rn=function loggingErrorHandler(){return _=>{vt.error(function stringifyException(_){return"string"==typeof _?_:JSON.stringify(function flattenException(_){const E={};let w=_;for(;null!==w;)Object.getOwnPropertyNames(w).forEach((_=>{if(E[_])return;const C=w[_];C&&(E[_]=String(C))})),w=Object.getPrototypeOf(w);return E}(_))}(_))}}();function globalErrorHandler(_){try{rn(_)}catch{}}const nn="process.runtime.name",sn={[se]:"opentelemetry",[nn]:"browser",[re]:ne,[ie]:"2.10.0"},on=performance,an=Math.pow(10,6),cn=Math.pow(10,9);function millisToHrTime(_){const E=_/1e3;return[Math.trunc(E),Math.round(_%1e3*an)]}function isTimeInputHrTime(_){return Array.isArray(_)&&2===_.length&&"number"==typeof _[0]&&"number"==typeof _[1]}function isTimeInput(_){return isTimeInputHrTime(_)||"number"==typeof _||_ instanceof Date}function addHrTimes(_,E){const w=[_[0]+E[0],_[1]+E[1]];return w[1]>=cn&&(w[1]-=cn,w[0]+=1),w}var un;!function(_){_[_.SUCCESS=0]="SUCCESS",_[_.FAILED=1]="FAILED"}(un||(un={}));const ln="[object Null]",dn="[object Undefined]",hn=Function.prototype.toString,pn=hn.call(Object),gn=Object.getPrototypeOf,mn=Object.prototype,fn=mn.hasOwnProperty,_n=Symbol?Symbol.toStringTag:void 0,bn=mn.toString;function isPlainObject(_){if(!function isObjectLike(_){return null!=_&&"object"==typeof _}(_)||"[object Object]"!==function baseGetTag(_){if(null==_)return void 0===_?dn:ln;return _n&&_n in Object(_)?function getRawTag(_){const E=fn.call(_,_n),w=_[_n];let C=!1;try{_[_n]=void 0,C=!0}catch{}const L=bn.call(_);C&&(E?_[_n]=w:delete _[_n]);return L}(_):function objectToString(_){return bn.call(_)}(_)}(_))return!1;const E=gn(_);if(null===E)return!0;const w=fn.call(E,"constructor")&&E.constructor;return"function"==typeof w&&w instanceof w&&hn.call(w)===pn}function takeValue(_){return isArray(_)?_.slice():_}function mergeTwoObjects(_,E,w=0,C){let L;if(!(w>20)){if(w++,isPrimitive(_)||isPrimitive(E)||isFunction(E))L=takeValue(E);else if(isArray(_)){if(L=_.slice(),isArray(E))for(let _=0,w=E.length;_<w;_++)L.push(takeValue(E[_]));else if(isObject(E)){const _=Object.keys(E);for(let w=0,C=_.length;w<C;w++){const C=_[w];"__proto__"!==C&&"constructor"!==C&&"prototype"!==C&&(L[C]=takeValue(E[C]))}}}else if(isObject(_))if(isObject(E)){if(!function shouldMerge(_,E){if(!isPlainObject(_)||!isPlainObject(E))return!1;return!0}(_,E))return E;L=Object.assign({},_);const R=Object.keys(E);for(let P=0,I=R.length;P<I;P++){const I=R[P];if("__proto__"===I||"constructor"===I||"prototype"===I)continue;const k=E[I];if(isPrimitive(k))void 0===k?delete L[I]:L[I]=k;else{const R=L[I],P=k;if(wasObjectReferenced(_,I,C)||wasObjectReferenced(E,I,C))delete L[I];else{if(isObject(R)&&isObject(P)){const w=C.get(R)||[],L=C.get(P)||[];w.push({obj:_,key:I}),L.push({obj:E,key:I}),C.set(R,w),C.set(P,L)}L[I]=mergeTwoObjects(L[I],k,w,C)}}}}else L=E;return L}}function wasObjectReferenced(_,E,w){const C=w.get(_[E])||[];for(let w=0,L=C.length;w<L;w++){const L=C[w];if(L.key===E&&L.obj===_)return!0}return!1}function isArray(_){return Array.isArray(_)}function isFunction(_){return"function"==typeof _}function isObject(_){return!isPrimitive(_)&&!isArray(_)&&!isFunction(_)&&"object"==typeof _}function isPrimitive(_){return"string"==typeof _||"number"==typeof _||"boolean"==typeof _||void 0===_||_ instanceof Date||_ instanceof RegExp||null===_}class Deferred{constructor(){this._promise=new Promise(((_,E)=>{this._resolve=_,this._reject=E}))}get promise(){return this._promise}resolve(_){this._resolve(_)}reject(_){this._reject(_)}}class BindOnceFuture{constructor(_,E){this._isCalled=!1,this._deferred=new Deferred,this._callback=_,this._that=E}get isCalled(){return this._isCalled}get promise(){return this._deferred.promise}call(..._){if(!this._isCalled){this._isCalled=!0;try{Promise.resolve(this._callback.call(this._that,..._)).then((_=>this._deferred.resolve(_)),(_=>this._deferred.reject(_)))}catch(_){this._deferred.reject(_)}}return this._deferred.promise}}let yn;function defaultServiceName(){if(void 0===yn)try{const _=globalThis.process.argv0;yn=_?`unknown_service:${_}`:"unknown_service"}catch{yn="unknown_service"}return yn}const isPromiseLike=_=>null!==_&&"object"==typeof _&&"function"==typeof _.then;class ResourceImpl{static FromAttributeList(_,E){const w=new ResourceImpl({},E);return w._rawAttributes=guardedRawAttributes(_),w._asyncAttributesPending=_.filter((([_,E])=>isPromiseLike(E))).length>0,w}constructor(_,E){this._asyncAttributesPending=!1;const w=_.attributes??{};this._rawAttributes=Object.entries(w).map((([_,E])=>(isPromiseLike(E)&&(this._asyncAttributesPending=!0),[_,E]))),this._rawAttributes=guardedRawAttributes(this._rawAttributes),this._schemaUrl=function validateSchemaUrl(_){if("string"==typeof _||void 0===_)return _;return void vt.warn("Schema URL must be string or undefined, got %s. Schema URL will be ignored.",_)}(E?.schemaUrl)}get asyncAttributesPending(){return this._asyncAttributesPending}async waitForAsyncAttributes(){if(this.asyncAttributesPending){for(let _=0;_<this._rawAttributes.length;_++){const[E,w]=this._rawAttributes[_];this._rawAttributes[_]=[E,isPromiseLike(w)?await w:w]}this._asyncAttributesPending=!1}}get attributes(){if(this.asyncAttributesPending&&vt.error("Accessing resource attributes before async attributes settled"),this._memoizedAttributes)return this._memoizedAttributes;const _={};for(const[E,w]of this._rawAttributes)isPromiseLike(w)?vt.debug(`Unsettled resource attribute ${E} skipped`):null!=w&&(_[E]??(_[E]=w));return this._asyncAttributesPending||(this._memoizedAttributes=_),_}getRawAttributes(){return this._rawAttributes}get schemaUrl(){return this._schemaUrl}merge(_){if(null==_)return this;const E=function mergeSchemaUrl(_,E){const w=_?.schemaUrl,C=E?.schemaUrl,L=void 0===w||""===w,R=void 0===C||""===C;if(L)return C;if(R)return w;if(w===C)return w;return void vt.warn('Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.',w,C)}(this,_),w=E?{schemaUrl:E}:void 0;return ResourceImpl.FromAttributeList([..._.getRawAttributes(),...this.getRawAttributes()],w)}}function defaultResource(){return function resourceFromAttributes(_,E){return ResourceImpl.FromAttributeList(Object.entries(_),E)}({[ee]:defaultServiceName(),[re]:sn[re],[se]:sn[se],[ie]:sn[ie]})}function guardedRawAttributes(_){return _.map((([_,E])=>isPromiseLike(E)?[_,E.catch((E=>{vt.debug("promise rejection for resource attribute: %s - %s",_,E)}))]:[_,E]))}const Sn=Symbol.for("nodejs.util.inspect.custom");function settledResourceAttributes(_){const E={};for(const[w,C]of _.getRawAttributes())"function"!=typeof C?.then&&null!=C&&(E[w]??(E[w]=C));return E}function formatInspect(_,E,w,C,L){if("number"==typeof w&&w<0){const E=`[${_}]`;return C?.stylize?C.stylize(E,"special"):E}if("function"!=typeof L||!C)return E;return`${_} ${L(E,{...C,depth:null==C.depth?C.depth:C.depth-1})}`}class SpanImpl{constructor(_){this.attributes={},this.links=[],this.events=[],this._droppedAttributesCount=0,this._droppedEventsCount=0,this._droppedLinksCount=0,this._attributesCount=0,this.status={code:Et.UNSET},this.endTime=[0,0],this._ended=!1,this._duration=[-1,-1];const E=Date.now();if(this._spanContext=_.spanContext,this._performanceStartTime=on.now(),this._performanceOffset=E-(this._performanceStartTime+on.timeOrigin),this._startTimeProvided=null!=_.startTime,this._spanLimits=_.spanLimits,this._attributeValueLengthLimit=this._spanLimits.attributeValueLengthLimit??0,this._spanProcessor=_.spanProcessor,this.name=_.name,this.parentSpanContext=_.parentSpanContext,this.kind=_.kind,_.links)for(const E of _.links)this.addLink(E);this.startTime=this._getTime(_.startTime??E),this.resource=_.resource,this.instrumentationScope=_.scope,this._recordEndMetrics=_.recordEndMetrics,null!=_.attributes&&this.setAttributes(_.attributes),this._spanProcessor.onStart(this,_.context)}spanContext(){return this._spanContext}setAttribute(_,E){if(null==E||this._isSpanEnded())return this;if(0===_.length)return vt.warn(`Invalid attribute key: ${_}`),this;if(!isAttributeValue(E))return vt.warn(`Invalid attribute value set for key: ${_}`),this;const{attributeCountLimit:w}=this._spanLimits,C=!Object.prototype.hasOwnProperty.call(this.attributes,_);return void 0!==w&&this._attributesCount>=w&&C?(this._droppedAttributesCount++,this):(this.attributes[_]=this._truncateToSize(E),C&&this._attributesCount++,this)}setAttributes(_){for(const E in _)Object.prototype.hasOwnProperty.call(_,E)&&this.setAttribute(E,_[E]);return this}addEvent(_,E,w){if(this._isSpanEnded())return this;const{eventCountLimit:C}=this._spanLimits;if(0===C)return vt.warn("No events allowed."),this._droppedEventsCount++,this;void 0!==C&&this.events.length>=C&&(0===this._droppedEventsCount&&vt.debug("Dropping extra events."),this.events.shift(),this._droppedEventsCount++),isTimeInput(E)&&(isTimeInput(w)||(w=E),E=void 0);const L=sanitizeAttributes(E),{attributePerEventCountLimit:R}=this._spanLimits,P={};let I=0,k=0;for(const _ in L){if(!Object.prototype.hasOwnProperty.call(L,_))continue;const E=L[_];void 0!==R&&k>=R?I++:(P[_]=this._truncateToSize(E),k++)}return this.events.push({name:_,attributes:P,time:this._getTime(w),droppedAttributesCount:I}),this}addLink(_){if(this._isSpanEnded())return this;const{linkCountLimit:E}=this._spanLimits;if(0===E)return this._droppedLinksCount++,this;void 0!==E&&this.links.length>=E&&(0===this._droppedLinksCount&&vt.debug("Dropping extra links."),this.links.shift(),this._droppedLinksCount++);const{attributePerLinkCountLimit:w}=this._spanLimits,C=sanitizeAttributes(_.attributes),L={};let R=0,P=0;for(const _ in C){if(!Object.prototype.hasOwnProperty.call(C,_))continue;const E=C[_];void 0!==w&&P>=w?R++:(L[_]=this._truncateToSize(E),P++)}const I={context:_.context};return P>0&&(I.attributes=L),R>0&&(I.droppedAttributesCount=R),this.links.push(I),this}addLinks(_){for(const E of _)this.addLink(E);return this}setStatus(_){if(this._isSpanEnded())return this;if(_.code===Et.UNSET)return this;if(this.status.code===Et.OK)return this;const E={code:_.code};return _.code===Et.ERROR&&("string"==typeof _.message?E.message=_.message:null!=_.message&&vt.warn(`Dropping invalid status.message of type '${typeof _.message}', expected 'string'`)),this.status=E,this}updateName(_){return this._isSpanEnded()||(this.name=_),this}end(_){this._isSpanEnded()?vt.error(`${this.name} ${this._spanContext.traceId}-${this._spanContext.spanId} - You can only call end() on a span once.`):(this.endTime=this._getTime(_),this._duration=function hrTimeDuration(_,E){let w=E[0]-_[0],C=E[1]-_[1];return C<0&&(w-=1,C+=cn),[w,C]}(this.startTime,this.endTime),this._duration[0]<0&&(vt.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&&vt.warn(`Dropped ${this._droppedEventsCount} events because eventCountLimit reached`),this._droppedLinksCount>0&&vt.warn(`Dropped ${this._droppedLinksCount} links because linkCountLimit reached`),this._spanProcessor.onEnding&&this._spanProcessor.onEnding(this),this._recordEndMetrics?.(),this._ended=!0,this._spanProcessor.onEnd(this))}_getTime(_){if("number"==typeof _&&_<=on.now())return function hrTime(_){return addHrTimes(millisToHrTime(on.timeOrigin),millisToHrTime("number"==typeof _?_:on.now()))}(_+this._performanceOffset);if("number"==typeof _)return millisToHrTime(_);if(_ instanceof Date)return millisToHrTime(_.getTime());if(isTimeInputHrTime(_))return _;if(this._startTimeProvided)return millisToHrTime(Date.now());const E=on.now()-this._performanceStartTime;return addHrTimes(this.startTime,millisToHrTime(E))}isRecording(){return!1===this._ended}recordException(_,E){const w={};"string"==typeof _?w[Wt]=_:_&&(_.code?w[Qt]=_.code.toString():_.name&&(w[Qt]=_.name),_.message&&(w[Wt]=_.message),_.stack&&(w[Kt]=_.stack)),w[Qt]||w[Wt]?this.addEvent("exception",w,E):vt.warn(`Failed to record an exception ${_}`)}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){const _=new Error(`Operation attempted on ended Span {traceId: ${this._spanContext.traceId}, spanId: ${this._spanContext.spanId}}`);vt.warn(`Cannot execute the operation on ended Span {traceId: ${this._spanContext.traceId}, spanId: ${this._spanContext.spanId}}`,_)}return this._ended}_truncateToLimitUtil(_,E){return _.length<=E?_:_.substring(0,E)}_truncateToSize(_){const E=this._attributeValueLengthLimit;return E<=0?(vt.warn(`Attribute value limit must be positive, got ${E}`),_):"string"==typeof _?this._truncateToLimitUtil(_,E):Array.isArray(_)?_.map((_=>"string"==typeof _?this._truncateToLimitUtil(_,E):_)):_}[Sn](_,E,w){return formatInspect("SpanImpl",{name:this.name,kind:this.kind,spanContext:this._spanContext,parentSpanContext:this.parentSpanContext,status:this.status,startTime:this.startTime,endTime:this.endTime,duration:this._duration,ended:this._ended,attributes:this.attributes,events:this.events,links:this.links,droppedAttributesCount:this._droppedAttributesCount,droppedEventsCount:this._droppedEventsCount,droppedLinksCount:this._droppedLinksCount,instrumentationScope:this.instrumentationScope,resource:{attributes:settledResourceAttributes(this.resource)}},_,E,w)}}var En;!function(_){_[_.NOT_RECORD=0]="NOT_RECORD",_[_.RECORD=1]="RECORD",_[_.RECORD_AND_SAMPLED=2]="RECORD_AND_SAMPLED"}(En||(En={}));const Tn="otel.component.name",vn="otel.component.type",wn="otel.span.parent.origin",An="otel.span.sampling_result";class TracerMetrics{constructor(_){this.startedSpans=_.createCounter("otel.sdk.span.started",{unit:"{span}",description:"The number of created spans."}),this.liveSpans=_.createUpDownCounter("otel.sdk.span.live",{unit:"{span}",description:"The number of currently live spans."})}startSpan(_,E){const w=function samplingDecisionToString(_){switch(_){case En.RECORD_AND_SAMPLED:return"RECORD_AND_SAMPLE";case En.RECORD:return"RECORD_ONLY";case En.NOT_RECORD:return"DROP"}}(E);if(this.startedSpans.add(1,{[wn]:parentOrigin(_),[An]:w}),E===En.NOT_RECORD)return()=>{};const C={[An]:w};return this.liveSpans.add(1,C),()=>{this.liveSpans.add(-1,C)}}}function parentOrigin(_){return _?_.isRemote?"remote":"local":"none"}class Tracer{constructor(_,E){this.instrumentationScope=_,this._sampler=E.sampler,this._spanLimits=E.spanLimits,this._resource=E.resource,this._idGenerator=E.idGenerator,this._spanProcessor=E.spanProcessor;const w=E.meterProvider.getMeter("@opentelemetry/sdk-trace","2.10.0");this._tracerMetrics=new TracerMetrics(w)}startSpan(_,E={},w=Tt.active()){E.root&&(w=It.deleteSpan(w));const C=It.getSpan(w);if(function isTracingSuppressed(_){return!0===_.getValue(en)}(w)){vt.debug("Instrumentation suppressed, returning Noop Span");return It.wrapSpanContext(pt)}const L=C?.spanContext(),R=this._idGenerator.generateSpanId();let P,I,k;L&&It.isSpanContextValid(L)?(I=L.traceId,k=L.traceState,P=L):I=this._idGenerator.generateTraceId();const F=E.kind??St.INTERNAL,$=(E.links??[]).map((_=>({context:_.context,attributes:sanitizeAttributes(_.attributes)}))),V=sanitizeAttributes(E.attributes),H=this._sampler.shouldSample(w,I,_,F,V,$),j=this._tracerMetrics.startSpan(L,H.decision);k=H.traceState??k;const z={traceId:I,spanId:R,traceFlags:H.decision===yt.RECORD_AND_SAMPLED?lt.SAMPLED:lt.NONE,traceState:k};if(H.decision===yt.NOT_RECORD){vt.debug("Recording is off, propagating context in a non-recording span");return It.wrapSpanContext(z)}const q=sanitizeAttributes(Object.assign(V,H.attributes));return new SpanImpl({resource:this._resource,scope:this.instrumentationScope,context:w,spanContext:z,name:_,kind:F,links:$,parentSpanContext:P,attributes:q,startTime:E.startTime,spanProcessor:this._spanProcessor,spanLimits:this._spanLimits,recordEndMetrics:j})}startActiveSpan(_,E,w,C){let L,R,P;if(arguments.length<2)return;2===arguments.length?P=E:3===arguments.length?(L=E,P=w):(L=E,R=w,P=C);const I=R??Tt.active(),k=this.startSpan(_,L,I),F=It.setSpan(I,k);return Tt.with(F,P,void 0,k)}[Sn](_,E,w){return formatInspect("Tracer",{instrumentationScope:this.instrumentationScope,resource:{attributes:settledResourceAttributes(this._resource)},spanLimits:this._spanLimits},_,E,w)}}class MultiSpanProcessor{constructor(_){this._spanProcessors=_}forceFlush(){const _=[];for(const E of this._spanProcessors)_.push(E.forceFlush());return new Promise((E=>{Promise.all(_).then((()=>{E()})).catch((_=>{globalErrorHandler(_||new Error("MultiSpanProcessor: forceFlush failed")),E()}))}))}onStart(_,E){for(const w of this._spanProcessors)w.onStart(_,E)}onEnding(_){for(const E of this._spanProcessors)E.onEnding&&E.onEnding(_)}onEnd(_){for(const E of this._spanProcessors)E.onEnd(_)}shutdown(){const _=[];for(const E of this._spanProcessors)_.push(E.shutdown());return new Promise(((E,w)=>{Promise.all(_).then((()=>{E()}),w)}))}}class AlwaysOffSampler{shouldSample(){return{decision:En.NOT_RECORD}}toString(){return"AlwaysOffSampler"}}class AlwaysOnSampler{shouldSample(){return{decision:En.RECORD_AND_SAMPLED}}toString(){return"AlwaysOnSampler"}}class ParentBasedSampler{constructor(_){this._root=_.root,this._root||(globalErrorHandler(new Error("ParentBasedSampler must have a root sampler configured")),this._root=new AlwaysOnSampler),this._remoteParentSampled=_.remoteParentSampled??new AlwaysOnSampler,this._remoteParentNotSampled=_.remoteParentNotSampled??new AlwaysOffSampler,this._localParentSampled=_.localParentSampled??new AlwaysOnSampler,this._localParentNotSampled=_.localParentNotSampled??new AlwaysOffSampler}shouldSample(_,E,w,C,L,R){const P=It.getSpanContext(_);return P&&isSpanContextValid(P)?P.isRemote?P.traceFlags<.SAMPLED?this._remoteParentSampled.shouldSample(_,E,w,C,L,R):this._remoteParentNotSampled.shouldSample(_,E,w,C,L,R):P.traceFlags<.SAMPLED?this._localParentSampled.shouldSample(_,E,w,C,L,R):this._localParentNotSampled.shouldSample(_,E,w,C,L,R):this._root.shouldSample(_,E,w,C,L,R)}toString(){return`ParentBased{root=${this._root.toString()}, remoteParentSampled=${this._remoteParentSampled.toString()}, remoteParentNotSampled=${this._remoteParentNotSampled.toString()}, localParentSampled=${this._localParentSampled.toString()}, localParentNotSampled=${this._localParentNotSampled.toString()}}`}}const Cn=new Map;class SpanProcessorMetrics{constructor(_,E,w){const C=Cn.get(_)??0;if(Cn.set(_,C+1),this.standardAttrs={[vn]:_,[Tn]:`${_}/${C}`},this.droppedAttrs={...this.standardAttrs,[Gt]:"queue_full"},this.processedSpans=E.createCounter("otel.sdk.processor.span.processed",{unit:"{span}",description:"The number of spans for which the processing has finished, either successful or failed."}),w){const{capacity:_,getQueueSize:C}=w;E.createUpDownCounter("otel.sdk.processor.span.queue.capacity",{unit:"{span}",description:"The maximum number of spans the queue of a given instance of an SDK span processor can hold."}).add(_,this.standardAttrs),this.queueSize=E.createObservableUpDownCounter("otel.sdk.processor.span.queue.size",{unit:"{span}",description:"The number of spans in the queue of a given instance of an SDK span processor."}),this.queueSizeCallback=_=>_.observe(C(),this.standardAttrs),this.queueSize.addCallback(this.queueSizeCallback)}}dropSpans(_){this.processedSpans.add(_,this.droppedAttrs)}finishSpans(_,E){if(!E)return void this.processedSpans.add(_,this.standardAttrs);const w={...this.standardAttrs,[Gt]:E.name};this.processedSpans.add(_,w)}shutdown(){this.queueSize&&this.queueSizeCallback&&this.queueSize.removeCallback(this.queueSizeCallback)}}class BatchSpanProcessorBase{constructor(_){this._isExporting=!1,this._finishedSpans=[],this._droppedSpansCount=0,this._exporter=_.exporter,this._maxExportBatchSize=_.maxExportBatchSize??512,this._maxQueueSize=_.maxQueueSize??2048,this._scheduledDelayMillis=_.scheduledDelayMillis??5e3,this._exportTimeoutMillis=_.exportTimeoutMillis??3e4,this._shutdownOnce=new BindOnceFuture(this._shutdown,this),this._maxExportBatchSize>this._maxQueueSize&&(vt.warn("BatchSpanProcessor: maxExportBatchSize must be smaller or equal to maxQueueSize, setting maxExportBatchSize to match maxQueueSize"),this._maxExportBatchSize=this._maxQueueSize);const E=_.selfObsMeterProvider?_.selfObsMeterProvider.getMeter("@opentelemetry/sdk-trace"):createNoopMeter();this._metrics=new SpanProcessorMetrics("batching_span_processor",E,{capacity:this._maxQueueSize,getQueueSize:()=>this._finishedSpans.length})}forceFlush(){return this._shutdownOnce.isCalled?this._shutdownOnce.promise:this._flushAll()}onStart(_,E){}onEnd(_){this._shutdownOnce.isCalled||_.spanContext().traceFlags<.SAMPLED&&this._addToBuffer(_)}shutdown(){return this._shutdownOnce.call()}_shutdown(){return Promise.resolve().then((()=>this.onShutdown())).then((()=>this._flushAll())).then((()=>(this._metrics.shutdown(),this._exporter.shutdown())))}_addToBuffer(_){if(this._finishedSpans.length>=this._maxQueueSize)return 0===this._droppedSpansCount&&vt.debug("maxQueueSize reached, dropping spans"),this._droppedSpansCount++,void this._metrics.dropSpans(1);this._droppedSpansCount>0&&(vt.warn(`Dropped ${this._droppedSpansCount} spans because maxQueueSize reached`),this._droppedSpansCount=0),this._finishedSpans.push(_),this._maybeStartTimer()}_flushAll(){return new Promise(((_,E)=>{const w=[];for(let _=0,E=Math.ceil(this._finishedSpans.length/this._maxExportBatchSize);_<E;_++)w.push(this._flushOneBatch());Promise.all(w).then((()=>{_()})).catch(E)}))}_flushOneBatch(){return this._clearTimer(),0===this._finishedSpans.length?Promise.resolve():new Promise(((_,E)=>{const w=setTimeout((()=>{E(new Error("Timeout"))}),this._exportTimeoutMillis);Tt.with(function suppressTracing(_){return _.setValue(en,!0)}(Tt.active()),(()=>{let C;this._finishedSpans.length<=this._maxExportBatchSize?(C=this._finishedSpans,this._finishedSpans=[]):C=this._finishedSpans.splice(0,this._maxExportBatchSize);const doExport=()=>this._exporter.export(C,(L=>{clearTimeout(w),this._metrics.finishSpans(C.length,L.error),L.code===un.SUCCESS?_():E(L.error??new Error("BatchSpanProcessor: span export failed"))}));let L=null;for(let _=0,E=C.length;_<E;_++){const E=C[_];E.resource.asyncAttributesPending&&E.resource.waitForAsyncAttributes&&(L??(L=[]),L.push(E.resource.waitForAsyncAttributes()))}null===L?doExport():Promise.all(L).then(doExport,(_=>{globalErrorHandler(_),E(_)}))}))}))}_maybeStartTimer(){if(this._isExporting)return;const flush=()=>{this._isExporting=!0,this._flushOneBatch().finally((()=>{this._isExporting=!1,this._finishedSpans.length>0&&(this._clearTimer(),this._maybeStartTimer())})).catch((_=>{this._isExporting=!1,globalErrorHandler(_)}))};if(this._finishedSpans.length>=this._maxExportBatchSize)return flush();void 0===this._timer&&(this._timer=setTimeout((()=>flush()),this._scheduledDelayMillis),"number"!=typeof this._timer&&this._timer.unref())}_clearTimer(){void 0!==this._timer&&(clearTimeout(this._timer),this._timer=void 0)}}let Ln=class BatchSpanProcessor extends BatchSpanProcessorBase{constructor(_){super(_),this.onInit(_)}onInit(_){!0!==_.disableAutoFlushOnDocumentHide&&"undefined"!=typeof document&&(this._visibilityChangeListener=()=>{"hidden"===document.visibilityState&&this.forceFlush().catch((_=>{globalErrorHandler(_)}))},this._pageHideListener=()=>{this.forceFlush().catch((_=>{globalErrorHandler(_)}))},document.addEventListener("visibilitychange",this._visibilityChangeListener),document.addEventListener("pagehide",this._pageHideListener))}onShutdown(){"undefined"!=typeof document&&(this._visibilityChangeListener&&document.removeEventListener("visibilitychange",this._visibilityChangeListener),this._pageHideListener&&document.removeEventListener("pagehide",this._pageHideListener))}};const Rn=new Uint8Array(16),Pn=new Uint8Array(8),On=Array.from({length:256},((_,E)=>E.toString(16).padStart(2,"0")));function randomFill(_){for(let E=0;E<_.length;E++)_[E]=256*Math.random()>>>0;for(let E=0;E<_.length;E++)if(_[E]>0)return;_[_.length-1]=1}function toHex(_){let E="";for(let w=0;w<_.length;w++)E+=On[_[w]];return E}class RandomIdGenerator{generateTraceId(){return randomFill(Rn),toHex(Rn)}generateSpanId(){return randomFill(Pn),toHex(Pn)}}var xn,In;!function(_){_[_.resolved=0]="resolved",_[_.timeout=1]="timeout",_[_.error=2]="error",_[_.unresolved=3]="unresolved"}(xn||(xn={}));class TracerProvider{constructor(_={}){this._tracers=new Map,this._forceFlushTimeoutMillis=_.forceFlushTimeoutMillis??3e4,this._resource=_.resource??defaultResource();const E=_.spanProcessors??[];this._activeSpanProcessor=new MultiSpanProcessor(E),this._tracerOptions={resource:this._resource,sampler:_.sampler??new ParentBasedSampler({root:new AlwaysOnSampler}),spanLimits:{attributeCountLimit:_.spanLimits?.attributeCountLimit??128,attributeValueLengthLimit:_.spanLimits?.attributeValueLengthLimit??1/0,eventCountLimit:_.spanLimits?.eventCountLimit??128,linkCountLimit:_.spanLimits?.linkCountLimit??128,attributePerEventCountLimit:_.spanLimits?.attributePerEventCountLimit??128,attributePerLinkCountLimit:_.spanLimits?.attributePerLinkCountLimit??128},idGenerator:_.idGenerator||new RandomIdGenerator,spanProcessor:this._activeSpanProcessor,meterProvider:_.meterProvider??{getMeter:()=>createNoopMeter()}}}getTracer(_,E,w){const C=`${_}@${E||""}:${w?.schemaUrl||""}`;return this._tracers.has(C)||this._tracers.set(C,new Tracer({name:_,version:E,schemaUrl:w?.schemaUrl},this._tracerOptions)),this._tracers.get(C)}forceFlush(){const _=this._forceFlushTimeoutMillis,E=this._activeSpanProcessor._spanProcessors.map((E=>new Promise((w=>{let C;const L=setTimeout((()=>{w(new Error(`Span processor did not completed within timeout period of ${_} ms`)),C=xn.timeout}),_);E.forceFlush().then((()=>{clearTimeout(L),C!==xn.timeout&&(C=xn.resolved,w(C))})).catch((_=>{clearTimeout(L),C=xn.error,w(_)}))}))));return new Promise(((_,w)=>{Promise.all(E).then((E=>{const C=E.filter((_=>_!==xn.resolved));C.length>0?w(C):_()})).catch((_=>w([_])))}))}shutdown(){return this._activeSpanProcessor.shutdown()}[Sn](_,E,w){const C=this._activeSpanProcessor._spanProcessors,L={resource:{attributes:settledResourceAttributes(this._resource)},tracers:Array.from(this._tracers.keys()),spanProcessors:C.map((_=>_.constructor?.name??"SpanProcessor"))};return formatInspect("TracerProvider",L,_,E,w)}}class TraceIdRatioBasedSampler{constructor(_=0){this._ratio=this._normalize(_),this._upperBound=1===this._ratio?4294967296:Math.floor(4294967295*this._ratio)}shouldSample(_,E){return{decision:isValidTraceId(E)&&this._accumulate(E)<this._upperBound?En.RECORD_AND_SAMPLED:En.NOT_RECORD}}toString(){return`TraceIdRatioBased{${this._ratio}}`}_normalize(_){return"number"!=typeof _||isNaN(_)?0:_>=1?1:_<=0?0:_}_accumulate(_){let E=0;for(let w=0;w<32;w+=8){let C=0;for(let E=0;E<8;E++){const L=_.charCodeAt(w+E);C=C<<4|(L<58?L-48:L<71?L-55:L-87)}E=(E^C)>>>0}return E}}!function(_){_.AlwaysOff="always_off",_.AlwaysOn="always_on",_.ParentBasedAlwaysOff="parentbased_always_off",_.ParentBasedAlwaysOn="parentbased_always_on",_.ParentBasedTraceIdRatio="parentbased_traceidratio",_.TraceIdRatio="traceidratio"}(In||(In={}));function buildSamplerFromEnv(){const _=In.ParentBasedAlwaysOn;switch(_){case In.AlwaysOn:return new AlwaysOnSampler;case In.AlwaysOff:return new AlwaysOffSampler;case In.ParentBasedAlwaysOn:return new ParentBasedSampler({root:new AlwaysOnSampler});case In.ParentBasedAlwaysOff:return new ParentBasedSampler({root:new AlwaysOffSampler});case In.TraceIdRatio:return new TraceIdRatioBasedSampler(getSamplerProbabilityFromEnv());case In.ParentBasedTraceIdRatio:return new ParentBasedSampler({root:new TraceIdRatioBasedSampler(getSamplerProbabilityFromEnv())});default:return vt.error(`OTEL_TRACES_SAMPLER value "${_}" invalid, defaulting to "${In.ParentBasedAlwaysOn}".`),new ParentBasedSampler({root:new AlwaysOnSampler})}}function getSamplerProbabilityFromEnv(){return vt.error("OTEL_TRACES_SAMPLER_ARG is blank, defaulting to 1."),1}const Nn=1/0;class BasicTracerProvider extends TracerProvider{constructor(_={}){const E=function merge(..._){let E=_.shift();const w=new WeakMap;for(;_.length>0;)E=mergeTwoObjects(E,_.shift(),0,w);return E}({},function loadDefaultConfig(){return{sampler:buildSamplerFromEnv(),forceFlushTimeoutMillis:3e4,generalLimits:{attributeValueLengthLimit:1/0,attributeCountLimit:128},spanLimits:{attributeValueLengthLimit:1/0,attributeCountLimit:128,linkCountLimit:128,eventCountLimit:128,attributePerEventCountLimit:128,attributePerLinkCountLimit:128}}}(),function reconfigureLimits(_){const E=Object.assign({},_.spanLimits);return E.attributeCountLimit=_.spanLimits?.attributeCountLimit??_.generalLimits?.attributeCountLimit??void 0??void 0??128,E.attributeValueLengthLimit=_.spanLimits?.attributeValueLengthLimit??_.generalLimits?.attributeValueLengthLimit??void 0??void 0??Nn,Object.assign({},_,{spanLimits:E})}(_));delete E.generalLimits,super(E)}}class BatchSpanProcessor extends Ln{constructor(_,E){E||(E={});const w=[["maxExportBatchSize","OTEL_BSP_MAX_EXPORT_BATCH_SIZE"],["maxQueueSize","OTEL_BSP_MAX_QUEUE_SIZE"],["scheduledDelayMillis","OTEL_BSP_SCHEDULE_DELAY"],["exportTimeoutMillis","OTEL_BSP_EXPORT_TIMEOUT"]];for(const[_,C]of w)E[_];super({exporter:_,...E})}}class StackContextManager{constructor(){this._enabled=!1,this._currentContext=Y}_bindFunction(_=Y,E){const w=this,contextWrapper=function(...C){return w.with(_,(()=>E.apply(this,C)))};return Object.defineProperty(contextWrapper,"length",{enumerable:!1,configurable:!0,writable:!1,value:E.length}),contextWrapper}active(){return this._currentContext}bind(_,E){return void 0===_&&(_=this.active()),"function"==typeof E?this._bindFunction(_,E):E}disable(){return this._currentContext=Y,this._enabled=!1,this}enable(){return this._enabled||(this._enabled=!0,this._currentContext=Y),this}with(_,E,w,...C){const L=this._currentContext;this._currentContext=_||Y;try{return E.call(w,...C)}finally{this._currentContext=L}}}class WebTracerProvider extends BasicTracerProvider{constructor(_={}){super(_)}register(_={}){It.setGlobalTracerProvider(this),function setupPropagator(_){null!==_&&(void 0!==_?Ot.setGlobalPropagator(_):Ot.setGlobalPropagator(new CompositePropagator({propagators:[new W3CTraceContextPropagator,new W3CBaggagePropagator]})))}(_.propagator),function setupContextManager(_){if(null!==_){if(void 0===_){const _=new StackContextManager;return _.enable(),void Tt.setGlobalContextManager(_)}_.enable(),Tt.setGlobalContextManager(_)}}(_.contextManager)}}var Dn;!function(_){_.CONNECT_END="connectEnd",_.CONNECT_START="connectStart",_.DECODED_BODY_SIZE="decodedBodySize",_.DOM_COMPLETE="domComplete",_.DOM_CONTENT_LOADED_EVENT_END="domContentLoadedEventEnd",_.DOM_CONTENT_LOADED_EVENT_START="domContentLoadedEventStart",_.DOM_INTERACTIVE="domInteractive",_.DOMAIN_LOOKUP_END="domainLookupEnd",_.DOMAIN_LOOKUP_START="domainLookupStart",_.ENCODED_BODY_SIZE="encodedBodySize",_.FETCH_START="fetchStart",_.LOAD_EVENT_END="loadEventEnd",_.LOAD_EVENT_START="loadEventStart",_.NAVIGATION_START="navigationStart",_.REDIRECT_END="redirectEnd",_.REDIRECT_START="redirectStart",_.REQUEST_START="requestStart",_.RESPONSE_END="responseEnd",_.RESPONSE_START="responseStart",_.SECURE_CONNECTION_START="secureConnectionStart",_.START_TIME="startTime",_.UNLOAD_EVENT_END="unloadEventEnd",_.UNLOAD_EVENT_START="unloadEventStart"}(Dn||(Dn={}));let kn;function addSpanNetworkEvent$1(_,E,w,C=!0){if(function hasKey$1(_,E){return E in _}(w,E)&&"number"==typeof w[E]&&(!C||0!==w[E]))return _.addEvent(E,w[E])}function addSpanNetworkEvents$1(_,E,w=!1,C,L){if(void 0===C&&(C=0!==E[Dn.START_TIME]),w||(addSpanNetworkEvent$1(_,Dn.FETCH_START,E,C),addSpanNetworkEvent$1(_,Dn.DOMAIN_LOOKUP_START,E,C),addSpanNetworkEvent$1(_,Dn.DOMAIN_LOOKUP_END,E,C),addSpanNetworkEvent$1(_,Dn.CONNECT_START,E,C),addSpanNetworkEvent$1(_,Dn.SECURE_CONNECTION_START,E,C),addSpanNetworkEvent$1(_,Dn.CONNECT_END,E,C),addSpanNetworkEvent$1(_,Dn.REQUEST_START,E,C),addSpanNetworkEvent$1(_,Dn.RESPONSE_START,E,C),addSpanNetworkEvent$1(_,Dn.RESPONSE_END,E,C)),!L){const w=E[Dn.ENCODED_BODY_SIZE];void 0!==w&&_.setAttribute("http.response_content_length",w);const C=E[Dn.DECODED_BODY_SIZE];void 0!==C&&w!==C&&_.setAttribute("http.response_content_length_uncompressed",C)}}function getOrigin(){return"undefined"!=typeof location?location.origin:void 0}function getResource(_,E,w,C,L=new WeakSet,R){const P=parseUrl(_),I=function filterResourcesForSpan(_,E,w,C,L,R){const P=hrTimeToNanoseconds(E),I=hrTimeToNanoseconds(w);let k=C.filter((E=>{const w=hrTimeToNanoseconds(timeInputToHrTime(E[Dn.FETCH_START])),C=hrTimeToNanoseconds(timeInputToHrTime(E[Dn.RESPONSE_END]));return E.initiatorType.toLowerCase()===(R||"xmlhttprequest")&&E.name===_&&w>=P&&C<=I}));k.length>0&&(k=k.filter((_=>!L.has(_))));return k}(_=P.toString(),E,w,C,L,R);if(0===I.length)return{mainRequest:void 0};if(1===I.length)return{mainRequest:I[0]};const k=function sortResources(_){return _.slice().sort(((_,E)=>{const w=_[Dn.FETCH_START],C=E[Dn.FETCH_START];return w>C?1:w<C?-1:0}))}(I);if(P.origin!==getOrigin()&&k.length>1){let _=k[0],E=function findMainRequest(_,E,w){const C=hrTimeToNanoseconds(w),L=hrTimeToNanoseconds(timeInputToHrTime(E));let R,P=_[1];const I=_.length;for(let E=1;E<I;E++){const w=_[E],I=hrTimeToNanoseconds(timeInputToHrTime(w[Dn.FETCH_START])),k=C-hrTimeToNanoseconds(timeInputToHrTime(w[Dn.RESPONSE_END]));I>=L&&(!R||k<R)&&(R=k,P=w)}return P}(k,_[Dn.RESPONSE_END],w);const C=_[Dn.RESPONSE_END];return E[Dn.FETCH_START]<C&&(E=_,_=void 0),{corsPreFlightRequest:_,mainRequest:E}}return{mainRequest:I[0]}}function parseUrl(_){if("function"==typeof URL)return new URL(_,"undefined"!=typeof document?document.baseURI:"undefined"!=typeof location?location.href:void 0);const E=function getUrlNormalizingAnchor(){return kn||(kn=document.createElement("a")),kn}();return E.href=_,E}function shouldPropagateTraceHeaders(_,E){let w=E||[];("string"==typeof w||w instanceof RegExp)&&(w=[w]);return parseUrl(_).origin===getOrigin()||w.some((E=>urlMatches(_,E)))}var Mn;!function(_){_.METHOD_OPEN="open",_.METHOD_SEND="send",_.EVENT_ABORT="abort",_.EVENT_ERROR="error",_.EVENT_LOAD="loaded",_.EVENT_TIMEOUT="timeout"}(Mn||(Mn={}));const Fn=vt.createComponentLogger({namespace:"@opentelemetry/opentelemetry-instrumentation-xml-http-request/utils"});function getXHRBodyLength$1(_){return function isDocument$1(_){return"undefined"!=typeof Document&&_ instanceof Document}(_)?(new XMLSerializer).serializeToString(document).length:"string"==typeof _?getByteLength$1(_):_ instanceof Blob?_.size:_ instanceof FormData?function getFormDataSize$1(_){let E=0;for(const[w,C]of _.entries())E+=w.length,C instanceof Blob?E+=C.size:E+=C.length;return E}(_):_ instanceof URLSearchParams?getByteLength$1(_.toString()):void 0!==_.byteLength?_.byteLength:void Fn.warn("unknown body type")}const Bn=new TextEncoder;function getByteLength$1(_){return Bn.encode(_).byteLength}function normalizeHttpRequestMethod$1(_){const E=function getKnownMethods$1(){void 0===$n&&($n=Un);return $n}(),w=_.toUpperCase();return w in E?w:"_OTHER"}const Un={CONNECT:!0,DELETE:!0,GET:!0,HEAD:!0,OPTIONS:!0,PATCH:!0,POST:!0,PUT:!0,TRACE:!0,QUERY:!0};let $n;const Vn={"https:":"443","http:":"80"};const Hn="0.220.0";var jn;(jn||(jn={})).HTTP_STATUS_TEXT="http.status_text";class XMLHttpRequestInstrumentation extends InstrumentationBase{constructor(_={}){super("@opentelemetry/instrumentation-xml-http-request",Hn,_),this.component="xml-http-request",this.version=Hn,this.moduleName=this.component,this._tasksCount=0,this._xhrMem=new WeakMap,this._usedResources=new WeakSet,this._semconvStability=semconvStabilityFromStr("http",_?.semconvStabilityOptIn)}init(){}_addHeaders(_,E){if(!shouldPropagateTraceHeaders(parseUrl(E).href,this.getConfig().propagateTraceHeaderCorsUrls)){const _={};return Ot.inject(Tt.active(),_),void(Object.keys(_).length>0&&this._diag.debug("headers inject skipped due to CORS policy"))}const w={};Ot.inject(Tt.active(),w),Object.keys(w).forEach((E=>{_.setRequestHeader(E,String(w[E]))}))}_addChildSpan(_,E){Tt.with(It.setSpan(Tt.active(),_),(()=>{const _=this.tracer.startSpan("CORS Preflight",{startTime:E[Dn.FETCH_START]}),w=!(this._semconvStability&Je.OLD);addSpanNetworkEvents$1(_,E,this.getConfig().ignoreNetworkEvents,void 0,w),_.end(E[Dn.RESPONSE_END])}))}_addFinalSpanAttributes(_,E,w){if(this._semconvStability&Je.OLD){if(void 0!==E.status&&_.setAttribute("http.status_code",E.status),void 0!==E.statusText&&_.setAttribute(jn.HTTP_STATUS_TEXT,E.statusText),"string"==typeof w){const E=parseUrl(w);_.setAttribute("http.host",E.host),_.setAttribute("http.scheme",E.protocol.replace(":",""))}_.setAttribute("http.user_agent",navigator.userAgent)}this._semconvStability&Je.STABLE&&E.status&&_.setAttribute(Zt,E.status)}_applyAttributesAfterXHR(_,E){const w=this.getConfig().applyCustomAttributesOnSpan;"function"==typeof w&&safeExecuteInTheMiddle((()=>w(_,E)),(_=>{_&&this._diag.error("applyCustomAttributesOnSpan",_)}))}_addResourceObserver(_,E){const w=this._xhrMem.get(_);w&&"function"==typeof PerformanceObserver&&"function"==typeof PerformanceResourceTiming&&(w.createdResources={observer:new PerformanceObserver((_=>{const C=_.getEntries(),L=parseUrl(E);C.forEach((_=>{"xmlhttprequest"===_.initiatorType&&_.name===L.href&&w.createdResources&&w.createdResources.entries.push(_)}))})),entries:[]},w.createdResources.observer.observe({entryTypes:["resource"]}))}_clearResources(){0===this._tasksCount&&this.getConfig().clearTimingResources&&(ue.clearResourceTimings(),this._xhrMem=new WeakMap,this._usedResources=new WeakSet)}_findResourceAndAddNetworkEvents(_,E,w,C,L){if(!(w&&C&&L&&_.createdResources))return;let R=_.createdResources.entries;R&&R.length||(R=ue.getEntriesByType("resource"));const P=getResource(parseUrl(w).href,C,L,R,this._usedResources);if(P.mainRequest){const _=P.mainRequest;this._markResourceAsUsed(_);const w=P.corsPreFlightRequest;w&&(this._addChildSpan(E,w),this._markResourceAsUsed(w));const C=!(this._semconvStability&Je.OLD);addSpanNetworkEvents$1(E,_,this.getConfig().ignoreNetworkEvents,void 0,C)}}_cleanPreviousSpanInformation(_){const E=this._xhrMem.get(_);if(E){const w=E.callbackToRemoveEvents;w&&w(),this._xhrMem.delete(_)}}_createSpan(_,E,w){const C=parseUrl(E);if(isUrlIgnored(C.href,this.getConfig().ignoreUrls))return void this._diag.debug("ignoring span as url matches ignored url");let L="";const R={};if(this._semconvStability&Je.OLD&&(L=w.toUpperCase(),R["http.method"]=w,R["http.url"]=C.toString()),this._semconvStability&Je.STABLE){const _=w,E=normalizeHttpRequestMethod$1(w);L||(L=E),R[Xt]=E,E!==_&&(R[Yt]=_),R[oe]=C.toString(),R[Jt]=C.hostname;const P=function serverPortFromUrl$1(_){const E=Number(_.port||Vn[_.protocol]);return E&&!isNaN(E)?E:void 0}(C);P&&(R[te]=P)}const P=this.tracer.startSpan(L,{kind:St.CLIENT,attributes:R});return P.addEvent(Mn.METHOD_OPEN),this._cleanPreviousSpanInformation(_),this._xhrMem.set(_,{span:P,spanUrl:E}),P}_markResourceAsUsed(_){this._usedResources.add(_)}_patchOpen(){return _=>{const E=this;return function patchOpen(...w){if(!E._isEnabled)return _.apply(this,w);const C=w[0],L=w[1];return E._createSpan(this,L,C),_.apply(this,w)}}}_patchSend(){const _=this;function endSpan(E,w,C,L){const R=_._xhrMem.get(w);if(!R)return;if(R.status=w.status,R.statusText=w.statusText,_._xhrMem.delete(w),R.span){const E=R.span;_._applyAttributesAfterXHR(E,w),_._semconvStability&Je.STABLE&&(C?L&&(E.setStatus({code:Et.ERROR,message:L}),E.setAttribute(Gt,L)):R.status&&R.status>=400&&(E.setStatus({code:Et.ERROR}),E.setAttribute(Gt,String(R.status))))}const P=hrTime$1(),I=Date.now();setTimeout((()=>{!function endSpanTimeout(E,w,C,L){const R=w.callbackToRemoveEvents;"function"==typeof R&&R();const{span:P,spanUrl:I,sendStartTime:k}=w;P&&(_._findResourceAndAddNetworkEvents(w,P,I,k,C),P.addEvent(E,L),_._addFinalSpanAttributes(P,w,I),P.end(L),_._tasksCount--),_._clearResources()}(E,R,P,I)}),300)}function onError(){endSpan(Mn.EVENT_ERROR,this,!0,"error")}function onAbort(){endSpan(Mn.EVENT_ABORT,this,!1)}function onTimeout(){endSpan(Mn.EVENT_TIMEOUT,this,!0,"timeout")}function onLoad(){this.status<299?endSpan(Mn.EVENT_LOAD,this,!1):endSpan(Mn.EVENT_ERROR,this,!1)}return E=>function patchSend(...w){if(!_._isEnabled)return E.apply(this,w);const C=_._xhrMem.get(this);if(!C)return E.apply(this,w);const L=C.span,R=C.spanUrl;if(L&&R){if(_.getConfig().measureRequestSize&&w?.[0]){const E=getXHRBodyLength$1(w[0]);void 0!==E&&(_._semconvStability&Je.OLD&&L.setAttribute("http.request_content_length_uncompressed",E),_._semconvStability&Je.STABLE&&L.setAttribute("http.request.body.size",E))}Tt.with(It.setSpan(Tt.active(),L),(()=>{_._tasksCount++,C.sendStartTime=hrTime$1(),L.addEvent(Mn.METHOD_SEND),this.addEventListener("abort",onAbort),this.addEventListener("error",onError),this.addEventListener("load",onLoad),this.addEventListener("timeout",onTimeout),C.callbackToRemoveEvents=()=>{!function unregister(E){E.removeEventListener("abort",onAbort),E.removeEventListener("error",onError),E.removeEventListener("load",onLoad),E.removeEventListener("timeout",onTimeout);const w=_._xhrMem.get(E);w&&(w.callbackToRemoveEvents=void 0)}(this),C.createdResources&&C.createdResources.observer.disconnect()},_._addHeaders(this,R),_._addResourceObserver(this,R)}))}return E.apply(this,w)}}enable(){if(!this._isEnabled){if(this._isXhrPatched)return this._diag.debug("reactivating existing patch on",this.moduleName,this.version),void(this._isEnabled=!0);try{this._diag.debug("applying patch to",this.moduleName,this.version),this._wrap(XMLHttpRequest.prototype,"open",this._patchOpen()),this._wrap(XMLHttpRequest.prototype,"send",this._patchSend()),this._isXhrPatched=!0,this._isEnabled=!0}catch(_){this._unwrap(XMLHttpRequest.prototype,"open"),this._unwrap(XMLHttpRequest.prototype,"send"),this._diag.warn("Failed to patch globalThis.XMLHttpRequest; instrumentation will not be enabled. Another script may have locked globalThis.XMLHttpRequest via Object.defineProperty.",_)}}}disable(){this._isEnabled&&(this._isEnabled=!1,this._tasksCount=0,this._xhrMem=new WeakMap,this._usedResources=new WeakSet)}}var zn;!function(_){_.COMPONENT="component",_.HTTP_STATUS_TEXT="http.status_text"}(zn||(zn={}));const qn=vt.createComponentLogger({namespace:"@opentelemetry/opentelemetry-instrumentation-fetch/utils"});function getFetchBodyLength(..._){if(_[0]instanceof URL||"string"==typeof _[0]){const E=_[1];if(!E?.body)return Promise.resolve();if(E.body instanceof ReadableStream){const{body:_,length:w}=function _getBodyNonDestructively(_){if(!_.pipeThrough)return qn.warn("Platform has ReadableStream but not pipeThrough!"),{body:_,length:Promise.resolve(void 0)};let E,w=0;const C=new Promise((_=>{E=_})),L=new TransformStream({start(){},async transform(_,E){const C=await _;w+=C.byteLength,E.enqueue(_)},flush(){E(w)}});return{body:_.pipeThrough(L),length:C}}(E.body);return E.body=_,w}return Promise.resolve(function getXHRBodyLength(_){if(function isDocument(_){return"undefined"!=typeof Document&&_ instanceof Document}(_))return(new XMLSerializer).serializeToString(document).length;if("string"==typeof _)return getByteLength(_);if(_ instanceof Blob)return _.size;if(_ instanceof FormData)return function getFormDataSize(_){let E=0;for(const[w,C]of _.entries())E+=w.length,C instanceof Blob?E+=C.size:E+=C.length;return E}(_);if(_ instanceof URLSearchParams)return getByteLength(_.toString());if(void 0!==_.byteLength)return _.byteLength;return void qn.warn("unknown body type")}(E.body))}{const E=_[0];return E?.body?E.clone().text().then((_=>getByteLength(_))):Promise.resolve()}}const Gn=new TextEncoder;function getByteLength(_){return Gn.encode(_).byteLength}const Wn={CONNECT:!0,DELETE:!0,GET:!0,HEAD:!0,OPTIONS:!0,PATCH:!0,POST:!0,PUT:!0,TRACE:!0,QUERY:!0};let Kn;function getKnownMethods(){return void 0===Kn&&(Kn=Wn),Kn}const Qn={"https:":"443","http:":"80"};const Xn="0.220.0",Yn="undefined"!=typeof PerformanceObserver;class FetchInstrumentation extends InstrumentationBase{constructor(_={}){super("@opentelemetry/instrumentation-fetch",Xn,_),this.component="fetch",this.version=Xn,this.moduleName=this.component,this._usedResources=new WeakSet,this._tasksCount=0,this._semconvStability=semconvStabilityFromStr("http",_?.semconvStabilityOptIn)}init(){}_addChildSpan(_,E){const w=this.tracer.startSpan("CORS Preflight",{startTime:E[Dn.FETCH_START]},It.setSpan(Tt.active(),_)),C=!(this._semconvStability&Je.OLD);addSpanNetworkEvents$1(w,E,this.getConfig().ignoreNetworkEvents,void 0,C),w.end(E[Dn.RESPONSE_END])}_addFinalSpanAttributes(_,E){const w=parseUrl(E.url);if(this._semconvStability&Je.OLD&&(_.setAttribute("http.status_code",E.status),null!=E.statusText&&_.setAttribute(zn.HTTP_STATUS_TEXT,E.statusText),_.setAttribute("http.host",w.host),_.setAttribute("http.scheme",w.protocol.replace(":","")),"undefined"!=typeof navigator&&_.setAttribute("http.user_agent",navigator.userAgent)),this._semconvStability&Je.STABLE){_.setAttribute(Zt,E.status),_.setAttribute(Jt,w.hostname);const C=function serverPortFromUrl(_){const E=Number(_.port||Qn[_.protocol]);return E&&!isNaN(E)?E:void 0}(w);C&&_.setAttribute(te,C)}}_addHeaders(_,E){if(!shouldPropagateTraceHeaders(E,this.getConfig().propagateTraceHeaderCorsUrls)){const _={};return Ot.inject(Tt.active(),_),void(Object.keys(_).length>0&&this._diag.debug("headers inject skipped due to CORS policy"))}if(_ instanceof Request)Ot.inject(Tt.active(),_.headers,{set:(_,E,w)=>_.set(E,"string"==typeof w?w:String(w))});else{const E=new Headers(_.headers);Ot.inject(Tt.active(),E,{set:(_,E,w)=>_.set(E,"string"==typeof w?w:String(w))}),_.headers=E}}_clearResources(){0===this._tasksCount&&this.getConfig().clearTimingResources&&(performance.clearResourceTimings(),this._usedResources=new WeakSet)}_createSpan(_,E={}){if(isUrlIgnored(_,this.getConfig().ignoreUrls))return void this._diag.debug("ignoring span as url matches ignored url");let w="";const C={};if(this._semconvStability&Je.OLD){const L=(E.method||"GET").toUpperCase();w=`HTTP ${L}`,C[zn.COMPONENT]=this.moduleName,C["http.method"]=L,C["http.url"]=_}if(this._semconvStability&Je.STABLE){const L=E.method,R=function normalizeHttpRequestMethod(_){const E=getKnownMethods(),w=_.toUpperCase();return w in E?w:"_OTHER"}(E.method||"GET");w||(w=R),C[Xt]=R,R!==L&&(C[Yt]=L),C[oe]=_}return this.tracer.startSpan(w,{kind:St.CLIENT,attributes:C})}_findResourceAndAddNetworkEvents(_,E,w){let C=E.entries;if(!C.length){if(!performance.getEntriesByType)return;C=performance.getEntriesByType("resource")}const L=getResource(E.spanUrl,E.startTime,w,C,this._usedResources,"fetch");if(L.mainRequest){const E=L.mainRequest;this._markResourceAsUsed(E);const w=L.corsPreFlightRequest;w&&(this._addChildSpan(_,w),this._markResourceAsUsed(w));const C=!(this._semconvStability&Je.OLD);addSpanNetworkEvents$1(_,E,this.getConfig().ignoreNetworkEvents,void 0,C)}}_markResourceAsUsed(_){this._usedResources.add(_)}_endSpan(_,E,w){const C=millisToHrTime$1(Date.now()),L=hrTime$1();this._addFinalSpanAttributes(_,w),this._semconvStability&Je.STABLE&&w.status>=400&&(_.setStatus({code:Et.ERROR}),_.setAttribute(Gt,String(w.status))),setTimeout((()=>{E.observer?.disconnect(),this._findResourceAndAddNetworkEvents(_,E,L),this._tasksCount--,this._clearResources(),_.end(C)}),300)}_patchConstructor(){return _=>{const E=this;return function patchConstructor(...w){if(!E._isEnabled)return _.apply(this,w);const C=this,L=parseUrl(w[0]instanceof Request?w[0].url:String(w[0])).href;let R;R=w[0]instanceof Request?null!=w[1]?new Request(w[0],w[1]):w[0]:w[1]||{};const P=E._createSpan(L,R);if(!P)return _.apply(this,w);const I=E._prepareSpanData(L);function endSpanOnError(_,w){E._applyAttributesAfterFetch(_,R,w),E._endSpan(_,I,{status:w.status||0,statusText:w.message,url:L})}function endSpanOnSuccess(_,w){E._applyAttributesAfterFetch(_,R,w),w.status>=200&&w.status<400?E._endSpan(_,I,w):E._endSpan(_,I,{status:w.status,statusText:w.statusText,url:L})}function onSuccess(_,w){try{const E=w.clone().body;if(E){const C=E.getReader(),read=()=>{C.read().then((({done:E})=>{E?endSpanOnSuccess(_,w):read()}),(E=>{endSpanOnError(_,E)}))};read()}else endSpanOnSuccess(_,w)}catch(w){E._diag.error("Failed to read fetch response body",w),E._endSpan(_,I,{status:0,url:L})}return w}function onError(_,w){try{endSpanOnError(_,w)}catch(C){E._diag.error("Failed to end span on fetch error",C),E._endSpan(_,I,{status:w.status||0,url:L})}throw w}return E.getConfig().measureRequestSize&&getFetchBodyLength(...w).then((_=>{_&&(E._semconvStability&Je.OLD&&P.setAttribute("http.request_content_length_uncompressed",_),E._semconvStability&Je.STABLE&&P.setAttribute("http.request.body.size",_))})).catch((_=>{E._diag.warn("getFetchBodyLength",_)})),Tt.with(It.setSpan(Tt.active(),P),(()=>(E._callRequestHook(P,R),E._addHeaders(R,L),E._tasksCount++,_.apply(C,R instanceof Request?[R]:[L,R]).then(onSuccess.bind(C,P),onError.bind(C,P)))))}}}_applyAttributesAfterFetch(_,E,w){const C=this.getConfig().applyCustomAttributesOnSpan;C&&safeExecuteInTheMiddle((()=>C(_,E,w)),(_=>{_&&this._diag.error("applyCustomAttributesOnSpan",_)}))}_callRequestHook(_,E){const w=this.getConfig().requestHook;w&&safeExecuteInTheMiddle((()=>w(_,E)),(_=>{_&&this._diag.error("requestHook",_)}))}_prepareSpanData(_){const E=hrTime$1(),w=[];if("function"!=typeof PerformanceObserver)return{entries:w,startTime:E,spanUrl:_};const C=new PerformanceObserver((E=>{E.getEntries().forEach((E=>{"fetch"===E.initiatorType&&E.name===_&&w.push(E)}))}));return C.observe({entryTypes:["resource"]}),{entries:w,observer:C,startTime:E,spanUrl:_}}enable(){if(Yn){if(!this._isEnabled){if(this._isFetchPatched)return this._diag.debug("fetch constructor already patched"),void(this._isEnabled=!0);try{this._wrap(globalThis,"fetch",this._patchConstructor()),this._isFetchPatched=!0,this._isEnabled=!0}catch(_){this._diag.warn("Failed to patch globalThis.fetch; instrumentation will not be enabled. Another script may have locked globalThis.fetch via Object.defineProperty.",_)}}}else this._diag.warn("this instrumentation is intended for web usage only, it does not instrument server-side fetch()")}disable(){Yn&&this._isEnabled&&(this._isEnabled=!1,this._usedResources=new WeakSet)}}const Zn=performance;var Jn;!function(_){_.CONNECT_END="connectEnd",_.CONNECT_START="connectStart",_.DECODED_BODY_SIZE="decodedBodySize",_.DOM_COMPLETE="domComplete",_.DOM_CONTENT_LOADED_EVENT_END="domContentLoadedEventEnd",_.DOM_CONTENT_LOADED_EVENT_START="domContentLoadedEventStart",_.DOM_INTERACTIVE="domInteractive",_.DOMAIN_LOOKUP_END="domainLookupEnd",_.DOMAIN_LOOKUP_START="domainLookupStart",_.ENCODED_BODY_SIZE="encodedBodySize",_.FETCH_START="fetchStart",_.LOAD_EVENT_END="loadEventEnd",_.LOAD_EVENT_START="loadEventStart",_.NAVIGATION_START="navigationStart",_.REDIRECT_END="redirectEnd",_.REDIRECT_START="redirectStart",_.REQUEST_START="requestStart",_.RESPONSE_END="responseEnd",_.RESPONSE_START="responseStart",_.SECURE_CONNECTION_START="secureConnectionStart",_.START_TIME="startTime",_.UNLOAD_EVENT_END="unloadEventEnd",_.UNLOAD_EVENT_START="unloadEventStart"}(Jn||(Jn={}));function hasKey(_,E){return E in _}function addSpanNetworkEvent(_,E,w,C=!0){if(hasKey(w,E)&&"number"==typeof w[E]&&(!C||0!==w[E]))return _.addEvent(E,w[E])}function addSpanNetworkEvents(_,E,w=!1,C,L){if(void 0===C&&(C=0!==E[Jn.START_TIME]),w||(addSpanNetworkEvent(_,Jn.FETCH_START,E,C),addSpanNetworkEvent(_,Jn.DOMAIN_LOOKUP_START,E,C),addSpanNetworkEvent(_,Jn.DOMAIN_LOOKUP_END,E,C),addSpanNetworkEvent(_,Jn.CONNECT_START,E,C),addSpanNetworkEvent(_,Jn.SECURE_CONNECTION_START,E,C),addSpanNetworkEvent(_,Jn.CONNECT_END,E,C),addSpanNetworkEvent(_,Jn.REQUEST_START,E,C),addSpanNetworkEvent(_,Jn.RESPONSE_START,E,C),addSpanNetworkEvent(_,Jn.RESPONSE_END,E,C)),!L){const w=E[Jn.ENCODED_BODY_SIZE];void 0!==w&&_.setAttribute("http.response_content_length",w);const C=E[Jn.DECODED_BODY_SIZE];void 0!==C&&w!==C&&_.setAttribute("http.response_content_length_uncompressed",C)}}var ts;!function(_){_.DOCUMENT_LOAD="documentLoad",_.DOCUMENT_FETCH="documentFetch",_.RESOURCE_FETCH="resourceFetch"}(ts||(ts={}));const es="http.url";var rs;!function(_){_.FIRST_PAINT="firstPaint",_.FIRST_CONTENTFUL_PAINT="firstContentfulPaint"}(rs||(rs={}));const ns={"first-paint":rs.FIRST_PAINT,"first-contentful-paint":rs.FIRST_CONTENTFUL_PAINT};class DocumentLoadInstrumentation extends InstrumentationBase{constructor(_={}){super("@opentelemetry/instrumentation-document-load","0.65.0",_),this.component="document-load",this.version="1",this.moduleName=this.component,this._semconvStability=semconvStabilityFromStr("http",_?.semconvStabilityOptIn)}init(){}_onDocumentLoaded(){window.setTimeout((()=>{this._collectPerformance()}))}_addResourcesSpans(_){const E=Zn.getEntriesByType?.("resource");E&&E.forEach((E=>{this._initResourceSpan(E,_)}))}_collectPerformance(){const _=Array.from(document.getElementsByTagName("meta")).find((_=>"traceparent"===_.getAttribute("name"))),E=(()=>{const _={},E=Zn.getEntriesByType?.("navigation")[0];if(E)Object.values(Jn).forEach((w=>{if(hasKey(E,w)){const C=E[w];"number"==typeof C&&(_[w]=C)}}));else{const E=Zn.timing;E&&Object.values(Jn).forEach((w=>{if(hasKey(E,w)){const C=E[w];"number"==typeof C&&(_[w]=C)}}))}return _})(),w=_&&_.content||"";Tt.with(Ot.extract(Y,{traceparent:w}),(()=>{const _=this._startSpan(ts.DOCUMENT_LOAD,Jn.FETCH_START,E);_&&(Tt.with(It.setSpan(Tt.active(),_),(()=>{const _=this._startSpan(ts.DOCUMENT_FETCH,Jn.FETCH_START,E);_&&(this._semconvStability&Je.OLD&&_.setAttribute(es,location.href),this._semconvStability&Je.STABLE&&_.setAttribute(oe,location.href),Tt.with(It.setSpan(Tt.active(),_),(()=>{const w=!(this._semconvStability&Je.OLD);addSpanNetworkEvents(_,E,this.getConfig().ignoreNetworkEvents,void 0,w),this._addCustomAttributesOnSpan(_,this.getConfig().applyCustomAttributesOnSpan?.documentFetch),this._endSpan(_,Jn.RESPONSE_END,E)})))})),this._semconvStability&Je.OLD&&(_.setAttribute(es,location.href),_.setAttribute("http.user_agent",navigator.userAgent)),this._semconvStability&Je.STABLE&&(_.setAttribute(oe,location.href),_.setAttribute("user_agent.original",navigator.userAgent)),this._addResourcesSpans(_),this.getConfig().ignoreNetworkEvents||(addSpanNetworkEvent(_,Jn.FETCH_START,E),addSpanNetworkEvent(_,Jn.UNLOAD_EVENT_START,E),addSpanNetworkEvent(_,Jn.UNLOAD_EVENT_END,E),addSpanNetworkEvent(_,Jn.DOM_INTERACTIVE,E),addSpanNetworkEvent(_,Jn.DOM_CONTENT_LOADED_EVENT_START,E),addSpanNetworkEvent(_,Jn.DOM_CONTENT_LOADED_EVENT_END,E),addSpanNetworkEvent(_,Jn.DOM_COMPLETE,E),addSpanNetworkEvent(_,Jn.LOAD_EVENT_START,E),addSpanNetworkEvent(_,Jn.LOAD_EVENT_END,E)),this.getConfig().ignorePerformancePaintEvents||(_=>{const E=Zn.getEntriesByType?.("paint");E&&E.forEach((({name:E,startTime:w})=>{hasKey(ns,E)&&_.addEvent(ns[E],w)}))})(_),this._addCustomAttributesOnSpan(_,this.getConfig().applyCustomAttributesOnSpan?.documentLoad),this._endSpan(_,Jn.LOAD_EVENT_END,E))}))}_endSpan(_,E,w){_&&(hasKey(w,E)?_.end(w[E]):_.end())}_initResourceSpan(_,E){const w=this._startSpan(ts.RESOURCE_FETCH,Jn.FETCH_START,_,E);if(w){this._semconvStability&Je.OLD&&w.setAttribute(es,_.name),this._semconvStability&Je.STABLE&&w.setAttribute(oe,_.name);const E=!(this._semconvStability&Je.OLD);addSpanNetworkEvents(w,_,this.getConfig().ignoreNetworkEvents,void 0,E),this._addCustomAttributesOnResourceSpan(w,_,this.getConfig().applyCustomAttributesOnSpan?.resourceFetch),this._endSpan(w,Jn.RESPONSE_END,_)}}_startSpan(_,E,w,C){if(hasKey(w,E)&&"number"==typeof w[E]){return this.tracer.startSpan(_,{startTime:w[E]},C?It.setSpan(Tt.active(),C):void 0)}}_waitForPageLoad(){"complete"===window.document.readyState?this._onDocumentLoaded():(this._onDocumentLoaded=this._onDocumentLoaded.bind(this),window.addEventListener("load",this._onDocumentLoaded))}_addCustomAttributesOnSpan(_,E){E&&safeExecuteInTheMiddle((()=>E(_)),(_=>{_&&this._diag.error("addCustomAttributesOnSpan",_)}))}_addCustomAttributesOnResourceSpan(_,E,w){w&&safeExecuteInTheMiddle((()=>w(_,E)),(_=>{_&&this._diag.error("addCustomAttributesOnResourceSpan",_)}))}enable(){window.removeEventListener("load",this._onDocumentLoaded),this._waitForPageLoad()}disable(){window.removeEventListener("load",this._onDocumentLoaded)}}class RetryingTransport{constructor(_){this._transport=_}retry(_,E,w){return new Promise(((C,L)=>{setTimeout((()=>{this._transport.send(_,E).then(C,L)}),w)}))}async send(_,E){let w=5,C=1e3;const L=Date.now()+E;let R=await this._transport.send(_,E);for(;"retryable"===R.status&&w>0;){w--;const E=Math.max(Math.min(C*(.4*Math.random()-.2+1),5e3),0);C*=1.5;const P=R.retryInMillis??E,I=L-Date.now();if(P>I)return vt.info(`Export retry time ${Math.round(P)}ms exceeds remaining timeout ${Math.round(I)}ms, not retrying further.`),R;vt.verbose(`Scheduling export retry in ${Math.round(P)}ms`),R=await this.retry(_,I,P)}return"success"===R.status?vt.verbose(`Export succeeded after ${5-w} retry attempts.`):"retryable"===R.status?vt.info("Export failed after maximum retry attempts (5)."):vt.info(`Export failed with non-retryable error: ${R.error}`),R}shutdown(){return this._transport.shutdown()}}let ss=0,is=0,os=class FetchTransport{constructor(_){this._parameters=_}async send(_,E){const w=new AbortController,C=setTimeout((()=>w.abort()),E);let L=globalThis.fetch;"function"==typeof L.__original&&(L=L.__original);const R=_.byteLength,P=ss+R>61440,I=!P&&!(is>=9);if(I)ss+=R,is++;else{const _=P?"size limit":"count limit";vt.debug(`keepalive disabled: ${(R/1024).toFixed(1)}KB payload, ${is} pending (${_})`)}try{const E=new URL(this._parameters.url),C=await L(E.href,{method:"POST",headers:await this._parameters.headers(),body:_,signal:w.signal,keepalive:I,mode:globalThis.location?globalThis.location.origin===E.origin?"same-origin":"cors":"no-cors"});if(C.status>=200&&C.status<=299)return vt.debug(`export response success (status: ${C.status})`),{status:"success"};if(function isExportHTTPErrorRetryable(_){return 429===_||502===_||503===_||504===_}(C.status)){vt.warn(`export response retryable (status: ${C.status})`);const _=function parseRetryAfterToMills$2(_){if(null==_)return;const E=Number.parseInt(_,10);if(Number.isInteger(E))return E>0?1e3*E:-1;const w=new Date(_).getTime()-Date.now();return w>=0?w:0}(C.headers.get("Retry-After"));return{status:"retryable",retryInMillis:_}}return vt.error(`export response failure (status: ${C.status})`),{status:"failure",error:new Error(`Fetch request failed with non-retryable status ${C.status}`)}}catch(_){return function isFetchNetworkErrorRetryable(_){return _ instanceof TypeError&&!_.cause}(_)?(vt.warn(`export request retryable (network error: ${_})`),{status:"retryable",error:new Error("Fetch request encountered a network error",{cause:_})}):(vt.error(`export request failure (error: ${_})`),{status:"failure",error:new Error("Fetch request errored",{cause:_})})}finally{clearTimeout(C),I&&(ss-=R,is--)}}shutdown(){}};function createOtlpFetchExportDelegate(_,E){return createOtlpNetworkExportDelegate(_,E,function createRetryingTransport(_){return new RetryingTransport(_.transport)}({transport:(w=_,new os(w))}));var w}function mergeHeaders(_,E,w){return async()=>{const C={...await w()},L={};return null!=E&&Object.assign(L,await E()),null!=_&&Object.assign(L,function validateAndNormalizeHeaders(_){const E={};return Object.entries(_??{}).forEach((([_,w])=>{void 0!==w?E[_]=String(w):vt.warn(`Header "${_}" has invalid value (${w}) and will be ignored`)})),E}(await _())),Object.assign(L,C)}}function validateUserProvidedUrl(_){if(null!=_)try{const E=globalThis.location?.href;return new URL(_,E).href}catch{throw new Error(`Configuration: Could not parse user-provided export URL: '${_}'`)}}function convertLegacyHeaders(_){return"function"==typeof _.headers?_.headers:function wrapStaticHeadersInFunction(_){if(null!=_)return async()=>_}(_.headers)}function convertLegacyBrowserHttpOptions(_,E,w){return function mergeOtlpHttpConfigurationWithDefaults(_,E,w){return{...mergeOtlpSharedConfigurationWithDefaults(_,E,w),headers:mergeHeaders(_.headers,E.headers,w.headers),url:validateUserProvidedUrl(_.url)??E.url??w.url}}({url:_.url,timeoutMillis:_.timeoutMillis,headers:convertLegacyHeaders(_),concurrencyLimit:_.concurrencyLimit},{},function getHttpConfigurationDefaults(_,E){return{timeoutMillis:1e4,concurrencyLimit:30,compression:"none",headers:async()=>_,url:"http://localhost:4318/"+E}}(w,E))}let as=class OTLPTraceExporter extends OTLPExporterBase{constructor(_={}){super(function createLegacyOtlpBrowserExportDelegate(_,E,w,C){return createOtlpFetchExportDelegate(convertLegacyBrowserHttpOptions(_,w,C),E)}(_,ve,"v1/traces",{"Content-Type":"application/x-protobuf"}))}};const cs="global",us="gcp.project_id",ls="gcp.firebase.app_id",ds="cloud.region",hs="gcp.firebase.domain";var ps;function isSpan(_){return"function"==typeof _.spanContext}function getSpanId(_){return _.spanContext().spanId}function isRootEvent(_){return isSpan(_)?void 0===_.parentSpanContext:void 0===_.spanContext?.traceId}!function(_){_[_.RootSpan=0]="RootSpan",_[_.RootLog=1]="RootLog",_[_.ChildSpan=2]="ChildSpan",_[_.ChildLog=3]="ChildLog"}(ps||(ps={}));class TraceEvents{constructor(){this.logs=new Set,this.spans=new Map,this.isTraceQueuedForExport=!1}add(_){isSpan(_)?this.spans.set(getSpanId(_),_):this.logs.add(_)}has(_){return isSpan(_)?this.spans.has(getSpanId(_)):this.logs.has(_)}}class TelemetryStore{constructor(_=TelemetryStore.DEFAULT_BUFFER_LIMIT,E){this._telemetryBufferMap=new Map,this._totalTelemetryCount=0,this._shouldAddLimitLog=!1,this._bufferLimit=_,this._rootTelemetryQueue=new RootTelemetryQueue(E)}get totalTelemetryCount(){return this._totalTelemetryCount}add(_){const E=this._getEventId(_);if(isRootEvent(_)&&this._telemetryBufferMap.has(E))return;if(!isRootEvent(_)&&!this._telemetryBufferMap.has(E))return;if(!this._bufferHasCapacity()){if(this._isQueueEmpty())return void(this._shouldAddLimitLog=!0);this._evictOldest()}const w=function getEventType(_){return isSpan(_)?isRootEvent(_)?ps.RootSpan:ps.ChildSpan:isRootEvent(_)?ps.RootLog:ps.ChildLog}(_);switch(w){case ps.RootSpan:{const w=new TraceEvents;return w.add(_),this._telemetryBufferMap.set(E,w),void this._totalTelemetryCount++}case ps.RootLog:return this._telemetryBufferMap.set(E,_),this._rootTelemetryQueue.isFull()&&this._evictOldest(),this._rootTelemetryQueue.enqueue(E),void this._totalTelemetryCount++;case ps.ChildSpan:case ps.ChildLog:{const w=this._telemetryBufferMap.get(E);return void(w&&w instanceof TraceEvents&&!w.has(_)&&(w.add(_),this._totalTelemetryCount++))}}}update(_){if(!isRootEvent(_))return;const E=this._getEventId(_),w=this._telemetryBufferMap.get(E);if(w&&w instanceof TraceEvents){if(w.isTraceQueuedForExport)return;this._rootTelemetryQueue.isFull()&&this._evictOldest(),this._rootTelemetryQueue.enqueue(E),w.isTraceQueuedForExport=!0}}getSpansToExport(){const _=[];for(const E of this._rootTelemetryQueue.getValues()){const w=this._telemetryBufferMap.get(E);w instanceof TraceEvents&&_.push(...w.spans.values())}return _}getLogsToExport(){const _=[];if(this._shouldAddLimitLog){const E={severityNumber:R.INFO,body:"Telemetry buffer limit reached. Some telemetry events were dropped."};_.push(E)}for(const E of this._rootTelemetryQueue.getValues()){const w=this._telemetryBufferMap.get(E);w instanceof TraceEvents?_.push(...w.logs):w&&_.push(w)}return _}clear(){this._rootTelemetryQueue.clear(),this._telemetryBufferMap.clear(),this._totalTelemetryCount=0,this._shouldAddLimitLog=!1}_getEventId(_){return isSpan(_)?_.spanContext().traceId:_.spanContext?.traceId??function generateUuid$1(){if("undefined"!=typeof crypto&&"function"==typeof crypto.randomUUID)return crypto.randomUUID();if("undefined"!=typeof crypto&&"function"==typeof crypto.getRandomValues){const _=new Uint8Array(16);crypto.getRandomValues(_),_[6]=15&_[6]|64,_[8]=63&_[8]|128;const E=Array.from(_,(_=>_.toString(16).padStart(2,"0"))).join("");return`${E.slice(0,8)}-${E.slice(8,12)}-${E.slice(12,16)}-${E.slice(16,20)}-${E.slice(20,32)}`}throw new Error("Web Crypto API is not available to generate a UUID.")}()}_bufferHasCapacity(){return this._totalTelemetryCount<this._bufferLimit}_isQueueEmpty(){return 0===this._rootTelemetryQueue.size}_evictOldest(){const _=this._rootTelemetryQueue.dequeue();_&&this._maybeEvictIdFromBuffer(_)}_maybeEvictIdFromBuffer(_){const E=this._telemetryBufferMap.get(_);E&&(this._totalTelemetryCount-=E instanceof TraceEvents?E.spans.size+E.logs.size:1,this._telemetryBufferMap.delete(_))}}TelemetryStore.DEFAULT_BUFFER_LIMIT=1e3;class RootTelemetryQueue{constructor(_=RootTelemetryQueue.DEFAULT_LIMIT){if(this._limit=_,this._head=0,this._tail=0,this._size=0,_<=0)throw new Error("Limit must be a positive integer greater than 0");this._items=new Array(this._limit).fill(void 0)}get size(){return this._size}isFull(){return this._size===this._limit}enqueue(_){this._size!==this._limit&&(this._items[this._tail]=_,this._tail=(this._tail+1)%this._limit,this._size++)}dequeue(){if(0===this._size)return;const _=this._items[this._head];return this._items[this._head]=void 0,this._head=(this._head+1)%this._limit,this._size--,_}peek(){if(0!==this._size)return this._items[this._head]}getValues(){const _=[];for(let E=0;E<this._size;E++){const w=(this._head+E)%this._items.length;this._items[w]&&_.push(this._items[w])}return _}clear(){this._items.fill(void 0),this._head=0,this._tail=0,this._size=0}}RootTelemetryQueue.DEFAULT_LIMIT=100;class OnErrorLogRecordProcessor extends BatchLogRecordProcessor{constructor(_,E){super({exporter:_,disableAutoFlushOnDocumentHide:!0}),this._store=E}onEmit(_){"good"!==_.attributes?.["browser.web_vital.rating"]&&this._store.add(_)}shutdown(){return this._store.clear(),super.shutdown()}onErrorOccurred(){const _=this._store.getLogsToExport();for(const E of _)super.onEmit(E)}}class OnErrorSpanProcessor extends BatchSpanProcessor{constructor(_,E){super(_),this._store=E}onStart(_,E){this._store.add(_)}onEnd(_){this._store.update(_)}shutdown(){return this._store.clear(),super.shutdown()}onErrorOccurred(){const _=this._store.getSpansToExport();for(const E of _)super.onEnd(E)}}class FirebaseAttributesSpanProcessor{constructor(_){this.attributesStore=_}onStart(_,E){const w=this.attributesStore.getSpanAttributes();for(const[E,C]of Object.entries(w))void 0!==C&&void 0===_.attributes?.[E]&&_.setAttribute(E,C)}onEnd(_){_.attributes&&delete _.attributes["user_agent.original"]}async forceFlush(){}async shutdown(){}}let gs,ms=class FetchTransport{constructor(_){this.parameters=_}async send(_,E){const w=new AbortController,C=setTimeout((()=>w.abort()),E);try{const E=new Headers(this.parameters.headers);if(this.parameters.dynamicHeaderProviders&&this.parameters.dynamicHeaderProviders.length>0){const _=this.parameters.dynamicHeaderProviders.map((async _=>{try{return await _.getHeader()}catch(_){return vt.debug(`Failed to retrieve dynamic header: ${_}`),null}})),w=await Promise.all(_);for(const _ of w)_&&E.append(..._)}const C=_.byteLength<6e4,L={method:"POST",headers:E,signal:w.signal,keepalive:C,mode:"cors",body:_},R=await Tt.with(suppressTracing$2(Tt.active()),(()=>fetch(this.parameters.url,L)));if(R.status>=200&&R.status<=299)return vt.debug("response success"),{status:"success"};if(function isExportRetryable$1(_){return[429,502,503,504].includes(_)}(R.status)){const _=function parseRetryAfterToMills$1(_){if(null==_)return;const E=Number.parseInt(_,10);if(Number.isInteger(E))return E>0?1e3*E:-1;const w=new Date(_).getTime()-Date.now();return w>=0?w:0}(R.headers.get("Retry-After"));return{status:"retryable",retryInMillis:_}}return{status:"failure",error:new Error("Fetch request failed with non-retryable status")}}catch(_){return _ instanceof Error?{status:"failure",error:_}:{status:"failure",error:new Error(`Fetch request errored: ${_}`)}}finally{clearTimeout(C)}}shutdown(){}};function createTracingProvider(_,E,w,C,L=[]){if("undefined"==typeof window)return{tracingProvider:It.getTracerProvider()};const R=function getTelemetryEndpointUrl$1(_={}){const E=_||{};if(E.endpointUrl){let _=E.endpointUrl.length;for(;_>0&&"/"===E.endpointUrl[_-1];)_--;return E.endpointUrl.slice(0,_)}const w=E.region||cs;return w!==cs?`https://clienttelemetry.${w}.rep.googleapis.com`:"https://clienttelemetry.googleapis.com"}(E),{projectId:P,appId:I,apiKey:k}=_.options,F=E.region||cs,$={[hs]:window.location.hostname};P&&($[us]=P),I&&($[ls]=I),F!==cs&&($[ds]=F);const V=resourceFromAttributes$1($),H=`${R}/v1/traces`;let j;j="http://localhost:4318"===R?new as({url:H,headers:{"X-Goog-User-Project":P||"",...k?{"X-Goog-Api-Key":k}:{}}}):new OTLPTraceExporter({url:H,headers:{"Content-Type":"application/json",...k?{"X-Goog-Api-Key":k}:{}}},L,w);const z=new OnErrorSpanProcessor(j,C),q=new WebTracerProvider({resource:V,spanProcessors:[new FirebaseAttributesSpanProcessor(w),z]});q.register({propagator:new CompositePropagator({propagators:[new W3CTraceContextPropagator]})});const G=`^${R.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}`,K={ignoreUrls:[new RegExp(G)],semconvStabilityOptIn:"http"};return gs&&gs(),gs=registerInstrumentations({instrumentations:[new FetchInstrumentation(K),new XMLHttpRequestInstrumentation(K),new DocumentLoadInstrumentation({semconvStabilityOptIn:"http"})]}),{tracingProvider:q,onErrorSpanProcessor:z}}class OTLPTraceExporter extends OTLPExporterBase{constructor(_={},E=[],w){super(createOtlpNetworkExportDelegate({timeoutMillis:1e4,concurrencyLimit:5},Le,new ms({url:_.url,headers:new Headers("object"==typeof _.headers?_.headers:{}),dynamicHeaderProviders:E}))),this.attributesStore=w}async export(_,E){const w=await(this.attributesStore?.getInstallationIdAttribute());w&&_.forEach((_=>{Object.assign(_.attributes,w)})),super.export(_,E)}}const fs=new Set;function unregisterLoggerInstrumentations(){for(const _ of fs)_();fs.clear()}class BreadcrumbsFeatureImpl{constructor(){this.name="breadcrumbs"}createTelemetryStore(){return new TelemetryStore}createLogRecordProcessor(_,E){return new OnErrorLogRecordProcessor(_,E)}initializeLoggerInstrumentations(_){if("undefined"==typeof window)return;const E=new Ar({enabled:!1}),w=new tn({enabled:!1,includeRawAttribution:!0});this._unregisterLoggerInstrumentationsFn&&(this._unregisterLoggerInstrumentationsFn(),fs.delete(this._unregisterLoggerInstrumentationsFn));const C=registerInstrumentations({loggerProvider:_,instrumentations:[E,w,new Nr({autoCapturedActions:["click"]})]});Object.defineProperty(this,"_unregisterLoggerInstrumentationsFn",{value:C,writable:!0,configurable:!0,enumerable:!1}),fs.add(C)}createTracingProvider(_,E,w,C,L=[]){return createTracingProvider(_,E,w,C,L)}unregisterInstrumentations(){this._unregisterLoggerInstrumentationsFn&&(this._unregisterLoggerInstrumentationsFn(),fs.delete(this._unregisterLoggerInstrumentationsFn),this._unregisterLoggerInstrumentationsFn=void 0),function unregisterTracingInstrumentations(){gs&&(gs(),gs=void 0)}()}}function breadcrumbs(){return new BreadcrumbsFeatureImpl}var _s="@firebase/crashlytics",bs="0.1.1";const ys="crashlytics",Ss="global",Es="gcp.project_id",Ts="gcp.firebase.app_id",vs="cloud.region",ws=Symbol("firebase_crashlytics_logged"),As="app.installation.id",Cs="firebasecrashlytics.sessionid",Ls="app.build_id",Rs="session.id",Ps="app.screen.id",Os="logging.googleapis.com/trace",xs="logging.googleapis.com/spanId",Is="gcp.resource.name",Ns="session.id",Ds="service.version",ks="app.screen.id";class AttributesStore{constructor(_,E,w){this._projectId=_.projectId,this._region=E?.region||Ss,this.updateOptions(E);const C=this.getSessionIdFromStorage();C&&(this._sessionId=C),this._installations=w?.getImmediate({optional:!0})??null,this._installations||w?.get().then((_=>this._installations=_)).catch((()=>{}))}updateOptions(_){const E=_?.appVersion?_.appVersion:jt?.appVersion?jt.appVersion:"unset";this._appVersion=E,this._customAttributes=_?.customAttributes?{..._.customAttributes}:void 0}get sessionId(){return this._sessionId}setSessionId(_){if(this._sessionId=_,"undefined"!=typeof sessionStorage)try{sessionStorage.setItem(Cs,_)}catch(_){}}setRoutePathProvider(_){this._routePathProvider=_}getLogAttributes(_){const E={};this._customAttributes&&Object.assign(E,this._customAttributes),this._appVersion&&(E[Ls]=this._appVersion),this._sessionId&&(E[Rs]=this._sessionId);const w=this._routePathProvider?.();return w&&(E[Ps]=w),_?{...E,..._}:E}getSpanAttributes(){const _={};this._projectId&&(_[Is]=`//clienttelemetry.googleapis.com/projects/${this._projectId}/locations/${this._region}/`),this._appVersion&&(_[Ds]=this._appVersion),this._sessionId&&(_[Ns]=this._sessionId);const E=this._routePathProvider?.();return E&&(_[ks]=E),_}async getInstallationIdAttribute(){if(!this._installations)return null;if(this._iid)return{[As]:this._iid};const _=await this._installations.getId();return _?(this._iid=_,{[As]:_}):null}getSessionIdFromStorage(){if("undefined"!=typeof sessionStorage)try{return sessionStorage.getItem(Cs)||void 0}catch(_){}}}function getCrashlytics(_=w(),E){const C=_getProvider(_,ys);if(C.isInitialized()){const _=C.getImmediate();if(deepEqual(E||{},C.getOptions()))return _;throw new Error("getCrashlytics() cannot be called with different options")}const L=C.initialize({options:E});return E&&(L.options=E),L}function recordError(_,E,w){if(!_)return;if(E&&"object"==typeof E)try{E[ws]=!0}catch(_){}const{loggerProvider:C,telemetryStore:L,onErrorSpanProcessor:P,onErrorLogRecordProcessor:I}=_,k=C.getLogger("error-logger"),F=w?{...w}:{};E instanceof Error?k.emit({severityNumber:R.ERROR,body:E.message,attributes:{"exception.type":E.name||"Error","exception.stacktrace":E.stack||"No stack trace available","exception.message":E.message,...F}}):"string"==typeof E?k.emit({severityNumber:R.ERROR,body:E,attributes:F}):k.emit({severityNumber:R.ERROR,body:"Unknown error type: "+typeof E,attributes:F}),P&&P.onErrorOccurred(),I&&I.onErrorOccurred(),L&&L.clear()}function log(_,E,w){if(!_)return;const{loggerProvider:C}=_,L=C.getLogger("custom-logger"),P=w?{...w}:{};L.emit({severityNumber:R.INFO,body:E,attributes:P})}function logViewBoundary(_,E,w){const{loggerProvider:C,attributesStore:L,options:P}=_;if(!getBreadcrumbsFeature(P))return;const I=C.getLogger("view-boundary-logger"),k=L.getLogAttributes({[Ps]:E,...w});I.emit({severityNumber:R.INFO,body:"Navigation event",attributes:k})}function getBreadcrumbsFeature(_){return _?.features?.find((_=>Boolean(_&&"breadcrumbs"===_.name)))}function startNewSession(_){const{loggerProvider:E,attributesStore:w}=_;if("undefined"!=typeof sessionStorage)try{const _=function generateUuid(){if("undefined"!=typeof crypto&&"function"==typeof crypto.randomUUID)return crypto.randomUUID();if("undefined"!=typeof crypto&&"function"==typeof crypto.getRandomValues){const _=new Uint8Array(16);crypto.getRandomValues(_),_[6]=15&_[6]|64,_[8]=63&_[8]|128;const E=Array.from(_,(_=>_.toString(16).padStart(2,"0"))).join("");return`${E.slice(0,8)}-${E.slice(8,12)}-${E.slice(12,16)}-${E.slice(16,20)}-${E.slice(20,32)}`}throw new Error("Web Crypto API is not available to generate a UUID.")}();w.setSessionId(_);const C=w.getLogAttributes();E.getLogger("session-logger").emit({severityNumber:R.DEBUG,body:"Session created",attributes:C})}catch(_){}}function registerListeners(_){if("undefined"!=typeof window&&"undefined"!=typeof document){const onVisibilityChange=async()=>{!getBreadcrumbsFeature(_.options)||"visible"!==document.visibilityState&&"hidden"!==document.visibilityState||function logVisibilityEvent(_,E){const{loggerProvider:w,attributesStore:C}=_,L=w.getLogger("visibility-logger"),P=C.getLogAttributes(),I="hidden"===E?"Background lifecycle event":"Foreground lifecycle event";L.emit({severityNumber:R.INFO,body:I,attributes:P})}(_,document.visibilityState),"hidden"===document.visibilityState&&await flush(_)},onPageHide=async()=>{await flush(_)};return window.addEventListener("visibilitychange",onVisibilityChange),window.addEventListener("pagehide",onPageHide),()=>{window.removeEventListener("visibilitychange",onVisibilityChange),window.removeEventListener("pagehide",onPageHide)}}return()=>{}}let Ms=null;function flush(_){return _.loggerProvider.forceFlush().catch((_=>{console.error("Error flushing logs from Firebase Crashlytics:",_)}))}class CrashlyticsService{constructor(_,E,w,C,L,R,P){this.app=_,this.loggerProvider=E,this.tracingProvider=w,this.attributesStore=C,this.telemetryStore=L,this.onErrorLogRecordProcessor=R,this.onErrorSpanProcessor=P}unsubscribeListeners(_){this._unsubscribeListeners=_}async _delete(){this._unsubscribeListeners&&this._unsubscribeListeners(),getBreadcrumbsFeature(this._options)?.unregisterInstrumentations();const _=[];if(this.loggerProvider&&"function"==typeof this.loggerProvider.shutdown&&_.push(this.loggerProvider.shutdown().catch((_=>{console.warn("Error shutting down logger provider:",_)}))),this.tracingProvider){const E=this.tracingProvider;"function"==typeof E.shutdown&&_.push(E.shutdown().catch((_=>{console.warn("Error shutting down tracing provider:",_)})))}await Promise.all(_)}set options(_){this._options=_,this.attributesStore.updateOptions(_)}get options(){return this._options}}class FetchTransport{constructor(_){this.parameters=_}async send(_,E){const w=new AbortController,C=setTimeout((()=>w.abort()),E);try{const E=new Headers(this.parameters.headers);if(this.parameters.dynamicHeaderProviders&&this.parameters.dynamicHeaderProviders.length>0){const _=this.parameters.dynamicHeaderProviders.map((async _=>{try{return await _.getHeader()}catch(_){return vt.debug(`Failed to retrieve dynamic header: ${_}`),null}})),w=await Promise.all(_);for(const _ of w)_&&E.append(..._)}const C=_.byteLength<6e4,L={method:"POST",headers:E,signal:w.signal,keepalive:C,mode:"cors",body:_},R=await Tt.with(suppressTracing$2(Tt.active()),(()=>fetch(this.parameters.url,L)));if(R.status>=200&&R.status<=299)return vt.debug("response success"),{status:"success"};if(function isExportRetryable(_){return[429,502,503,504].includes(_)}(R.status)){const _=function parseRetryAfterToMills(_){if(null==_)return;const E=Number.parseInt(_,10);if(Number.isInteger(E))return E>0?1e3*E:-1;const w=new Date(_).getTime()-Date.now();return w>=0?w:0}(R.headers.get("Retry-After"));return{status:"retryable",retryInMillis:_}}return{status:"failure",error:new Error("Fetch request failed with non-retryable status")}}catch(_){return _ instanceof Error?{status:"failure",error:_}:{status:"failure",error:new Error(`Fetch request errored: ${_}`)}}finally{clearTimeout(C)}}shutdown(){}}class FirebaseAttributesLogProcessor{constructor(_,E){this.attributesStore=_,this.projectId=E}onEmit(_,E){var w,C,L,R,P;_.attributes||(_.attributes={});const I=this.attributesStore.getLogAttributes();for(const[E,C]of Object.entries(I))void 0!==C&&((w=_.attributes)[E]??(w[E]=C));const k=_.spanContext??(E?It.getSpanContext(E):void 0)??It.getActiveSpan()?.spanContext();k?.traceId&&k?.spanId&&this.projectId&&((C=_.attributes)[L=Os]??(C[L]=`projects/${this.projectId}/traces/${k.traceId}`),(R=_.attributes)[P=xs]??(R[P]=k.spanId))}async forceFlush(){}async shutdown(){}}function createLoggerProvider(_,E={},w,C,L=[]){const R=function getTelemetryEndpointUrl(_={}){const E=_||{};if(E.endpointUrl){let _=E.endpointUrl.length;for(;_>0&&"/"===E.endpointUrl[_-1];)_--;return E.endpointUrl.slice(0,_)}const w=E.region||Ss;return w!==Ss?`https://clienttelemetry.${w}.rep.googleapis.com`:"https://clienttelemetry.googleapis.com"}(E),{projectId:P,appId:I,apiKey:k}=_.options,F=E.region||Ss,V=`${R}/v1/logs`,H={[ye]:"firebase_telemetry_service"};P&&(H[Es]=P),I&&(H[Ts]=I),F!==Ss&&(H[vs]=F);const j=resourceFromAttributes$1(H),z=new OTLPLogExporter({url:V,headers:{"Content-Type":"application/json",...k?{"X-Goog-Api-Key":k}:{}}},L,w);let q;const G=[new FirebaseAttributesLogProcessor(w,P)],K=getBreadcrumbsFeature(E);K?(q=K.createLogRecordProcessor(z,C??K.createTelemetryStore()),G.push(q)):G.push(new BatchLogRecordProcessor({exporter:z,disableAutoFlushOnDocumentHide:!0}));const Q=new LoggerProvider({resource:j,processors:G,logRecordLimits:{}});return E.registerGlobalLoggerProvider&&$.setGlobalLoggerProvider(Q),K&&"undefined"!=typeof window&&K.initializeLoggerInstrumentations(Q),{loggerProvider:Q,onErrorLogRecordProcessor:q}}class OTLPLogExporter extends OTLPExporterBase{constructor(_={},E=[],w){super(createOtlpNetworkExportDelegate({timeoutMillis:1e4,concurrencyLimit:5},Ce,new FetchTransport({url:_.url,headers:new Headers("object"==typeof _.headers?_.headers:{}),dynamicHeaderProviders:E}))),this.attributesStore=w,this.endpointUrl=_.url}async export(_,E){const w=_.filter((_=>!function isTelemetryUrl(_,E){return!!("string"==typeof _&&_&&(/^https?:\/\/clienttelemetry\.(googleapis\.com|[a-z0-9-]+\.rep\.googleapis\.com)(\/|$)/.test(_)||E&&_.startsWith(E)))}(_.attributes?.["url.full"]||_.attributes?.["http.url"]||_.attributes?.["resource.url"],this.endpointUrl)));if(0===w.length)return void E({code:kt.SUCCESS});const C=await this.attributesStore.getInstallationIdAttribute();C&&w.forEach((_=>{Object.assign(_.attributes,C)})),super.export(w,E)}}class AppCheckProvider{constructor(_){this.appCheck=_?.getImmediate({optional:!0}),this.appCheck||_?.get().then((_=>this.appCheck=_)).catch()}async getHeader(){if(!this.appCheck)return null;const _=await this.appCheck.getToken();return!_||_.error?null:["X-Firebase-AppCheck",_.token]}}!function registerCrashlytics(){E(new Component(ys,((_,{options:E})=>{const w=E||{},C=_.getProvider("app").getImmediate(),L=_.getProvider("app-check-internal"),R=_.getProvider("installations-internal"),P=new AttributesStore(C.options,w,R),I=getBreadcrumbsFeature(w),k=I?.createTelemetryStore(),F=[new AppCheckProvider(L)],{loggerProvider:$,onErrorLogRecordProcessor:V}=createLoggerProvider(C,w,P,k,F),{tracingProvider:H,onErrorSpanProcessor:j}=I&&k?I.createTracingProvider(C,w,P,k,F):{tracingProvider:null,onErrorSpanProcessor:void 0},z=new CrashlyticsService(C,$,H,P,k,V,j);E&&(z.options=w),P.sessionId||startNewSession(z);const q=registerListeners(z),G=!1!==w.captureUnhandledErrors?function registerGlobalErrorListeners(_){if("undefined"==typeof window||!1===_.options?.captureUnhandledErrors)return()=>{};if(Ms){if(Ms.crashlytics===_)return()=>{};Ms.unsubscribe()}const errorListener=E=>{E.error&&E.error[ws]||recordError(_,E.error)},unhandledRejectionListener=E=>{E.reason&&E.reason[ws]||recordError(_,E.reason)};try{window.addEventListener("error",errorListener),window.addEventListener("unhandledrejection",unhandledRejectionListener)}catch(_){return console.warn("Firebase Crashlytics was not initialized:\n",_),()=>{}}let E=!1;const unsubscribe=()=>{E||(E=!0,Ms?.unsubscribe===unsubscribe&&(Ms=null),window.removeEventListener("error",errorListener),window.removeEventListener("unhandledrejection",unhandledRejectionListener))};return Ms={crashlytics:_,unsubscribe:unsubscribe},unsubscribe}(z):()=>{};return z.unsubscribeListeners((()=>{q(),G()})),z}),"PUBLIC").setMultipleInstances(!0)),_(_s,bs),_(_s,bs,"esm2020")}();export{breadcrumbs,flush,getCrashlytics,log,logViewBoundary,recordError,unregisterLoggerInstrumentations};
//# sourceMappingURL=firebase-crashlytics.js.map